演示:http://www.xiaobenxiong.net
修改文件为:
source\do_register.php
找到[//默认好友],修改为
//默认好友
$flog = $inserts = $fuids = $pokes = array();
if(!empty($_SCONFIG['defaultfusername'])) {
$query = $_SGLOBAL['db']->query("SELECT uid,username FROM ".tname('space')." WHERE username IN (".simplode(explode(',', $_SCONFIG['defaultfusername'])).")");
}
else {
$query = $_SGLOBAL['db']->query("SELECT uid,username FROM ".tname('space')." ORDER BY RAND() LIMIT 9");
}
while ($value = $_SGLOBAL['db']->fetch_array($query)) {
$value = saddslashes($value);
$fuids[] = $value['uid'];
$inserts[] = "('$newuid','$value[uid]','$value[username]','1','$_SGLOBAL[timestamp]')";
$inserts[] = "('$value[uid]','$newuid','$username','1','$_SGLOBAL[timestamp]')";
$pokes[] = "('$newuid','$value[uid]','$value[username]','".addslashes($_SCONFIG['defaultpoke'])."','$_SGLOBAL[timestamp]')";
//添加好友变更记录
$flog[] = "('$value[uid]','$newuid','add','$_SGLOBAL[timestamp]')";
}
if($inserts) {
$_SGLOBAL['db']->query("REPLACE INTO ".tname('friend')." (uid,fuid,fusername,status,dateline) VALUES ".implode(',', $inserts));
$_SGLOBAL['db']->query("REPLACE INTO ".tname('poke')." (uid,fromuid,fromusername,note,dateline) VALUES ".implode(',', $pokes));
$_SGLOBAL['db']->query("REPLACE INTO ".tname('friendlog')." (uid,fuid,action,dateline) VALUES ".implode(',', $flog));
//添加到附加表
$friendstr = empty($fuids)?'':implode(',', $fuids);
updatetable('space', array('friendnum'=>count($fuids), 'pokenum'=>count($pokes)), array('uid'=>$newuid));
updatetable('spacefield', array('friend'=>$friendstr, 'feedfriend'=>$friendstr), array('uid'=>$newuid));
//更新默认用户好友缓存
include_once(S_ROOT.'./source/function_cp.php');
foreach ($fuids as $fuid) {
friend_cache($fuid);
}
} |