本帖最后由 liuzhly 于 2009-12-16 22:29 编辑
在表中: plug_newfarm 增加字段---username,varchar(20)
建立UID索引 ,顺便建立日志表的time索引~~~ 这句话不懂的人可以忽略
newfarmjson.php
找到:
if ( $_REQUEST['mod'] == "friend" )
{
if ( $_REQUEST['false'] == "refresh" )
{
echo "{\"code\":0}";
exit( );
}
if ( !empty( $space[friend] ) )
{
$space[friend] = $space[friend].",";
}
$query = $_SGLOBAL['db']->query( "SELECT uid,exp,money,charm FROM ".tname( "plug_newfarm" )." WHERE uid IN (".$space[friend].$_SGLOBAL['supe_uid'].")" );
while ( $value = $_SGLOBAL['db']->fetch_array( $query ) )
{
$list[$value['uid']] = $value;
}
$friendid = ""; //下面代码就是为了个用户名重新查询数据库,浪费资源,真是不值得
foreach ( $list as $value )
{
$friendid = $friendid.$value[uid];
$friendid = $friendid.",";
}
$friendid = substr( $friendid, 0, 0 - 1 );
$query = $_SGLOBAL['db']->query( "SELECT uid,username,name FROM ".tname( "space" )." WHERE uid IN (".$friendid.")" );
while ( $value = $_SGLOBAL['db']->fetch_array( $query ) )
{
$list[$value['uid']] = array_merge( $list[$value['uid']], $value );
}
$jishu = 0;
foreach ( $list as $key => $value )
{
$jishu++;
if ( 300 < $jishu )
{
break;
}
if ( empty( $value[name] ) )
{
$value[name] = $value[username];
}
include_once( '../source/function_cp.php' ); //这里竟然在循环里?搞不明白,看下面修改的,去掉就OK
$friendavatarimage = ckavatar($value[uid])?avatarfarm($value[uid], 'small', true):UC_API.'/images/noavatar_small.gif'; //无用的一些判断,修改如下面代码就OK了
$friend_str[] = "{\"userId\":".$value[uid].",\"userName\":\"".unicode_encodegb( $value[name] )."\",\"headPic\":\"".$friendavatarimage."\",\"exp\":".$value[exp].",\"money\":".$value[money].",\"charm\":".$value[charm]."}";
}
$friend_str = json_encode( $friend_str );
$friend_str = str_replace( "\"{", "{", $friend_str );
$friend_str = str_replace( "}\"", "}", $friend_str );
$friend_str = str_replace( "\\/", "\\\\/", $friend_str );
$friend_str = str_replace( ",null,", ",", $friend_str );
echo stripslashes( $friend_str );
exit( );
}
修改为:
if ( $_REQUEST['mod'] == "friend" ){ //[=4=]
if ( $_REQUEST['false'] == "refresh" ){
echo "{\"code\":0}";
exit( );
}
if ( !empty( $space[friend] ) ){
$space[friend] = $space[friend].",";
}
$query = $_SGLOBAL['db']->query( "SELECT uid,username,exp,money,charm FROM ".tname( "plug_newfarm" )." WHERE uid IN (".$space[friend].$_SGLOBAL['supe_uid'].")" );
while ( $value = $_SGLOBAL['db']->fetch_array( $query ) ){
$list[] = $value;
}
$jishu = 0;
$maxfriendnum = intval(checkperm('maxfriendnum'));
if($maxfriendnum > 0){
$maxfriendnum += $space['addfriend'];
}//用于判断用户最大好友数量,用于显示
foreach ( $list as $value ){
$jishu++;
if ($maxfriendnum > 0 && $jishu > $maxfriendnum){
break;
}
//include_once( '../source/function_cp.php' );
//$friendavatarimage = ckavatar($value[uid])?avatarfarm($value[uid], 'small', true):UC_API.'/images/noavatar_small.gif';
$friendavatarimage = avatarfarm($value[uid], 'small', true);
$friend_str[] = "{\"userId\":".$value[uid].",\"userName\":\"".unicode_encodegb( $value[username] )."\",\"headPic\":\"".$friendavatarimage."\",\"exp\":".$value[exp].",\"money\":".$value[money].",\"charm\":".$value[charm]."}";
}
$friend_str = json_encode( $friend_str );
$friend_str = str_replace( "\"{", "{", $friend_str );
$friend_str = str_replace( "}\"", "}", $friend_str );
$friend_str = str_replace( "\\/", "\\\\/", $friend_str );
$friend_str = str_replace( ",null,", ",", $friend_str );
echo stripslashes( $friend_str );
exit( );
} //[=4=] 显示好友列表
然后打开 cp_profile.php
找到 updatetable('space', $setarr, array('uid'=>$_SGLOBAL['supe_uid']));
在其下行增加
updatetable('friend', array('fusername'=>$setarr['name']), array('fuid'=>$_SGLOBAL['supe_uid']));以同步更新好友姓名!!
if($setarr['namestatus'] == 1){updatetable('plug_newfarm', array('username'=>$setarr['name']), array('uid'=>$_SGLOBAL['supe_uid']));} //如果实名验证,更新农场实名
打开根下的 newfarm.php ,修改新用户插入信息(红色为增加的):
如果开头没有 $space=getspace($_SGLOBAL['supe_uid']); 这句,请自行加上~~
$usernames = $space[name];
if ( empty( $usernames ) || $space[namestatus] ==0 ){
$usernames = $space[username];
}
$_SGLOBAL['db']->query( "INSERT INTO ".tname( "plug_newfarm" )." (uid,username,farmlandstatus,package,fertilizer,decorative,fruit,dog,nosegay,message,animal,mc_package,mc_log) VALUES(".$_SGLOBAL['supe_uid'].",'".$usernames."','".$farmlandstatus."','".$package."','".$fertilizer."','".$decorative."','".$package."','".$dog."','".$nosegay."','".$message."','".$animal."','".$mc_package."','".$mc_log."')" );
然后将下面代码另存为 a.php 放UCHOME根目录下,运行一下更新所有人用户名:
<?php
include_once( "./common.php" );
$query = $_SGLOBAL['db']->query( "SELECT uid,username FROM ".tname( "space" )." order by uid asc" );
while ( $value = $_SGLOBAL['db']->fetch_array( $query ) ){
$list[] = $value;
}
foreach ( $list as $value ){
$_SGLOBAL['db']->query( "UPDATE ".tname( "plug_newfarm" )." set username='".$value[username]."' where uid=".$value[uid] );
echo "UPDATE ".tname( "plug_newfarm" )." set username='".$value[username]."' where uid=".$value[uid]."<BR>";
}
?>
然后再试试吧???是不是速度快很多???
操作有风险,请注意备份数据和程序~~~ |