我只说修改过程,喜欢折腾修改的朋友自己可改改!!
使用 plug_newfarm_logs 日志表的朋友,增加一字段:counts 类型:text varchar(512)
在 代码中,寻找
if ( $_REQUEST['mod'] == "farmlandstatus" && $_REQUEST['act'] == "scrounge" )
将插入和更新日志的地方修改为:
$sql1 = "SELECT `id`, `uid`, `cropid`, `fromid`, `count`,`counts`,`time`, `type` FROM ".tname( "plug_newfarm_logs" )." WHERE fromid = ".$_SGLOBAL['supe_uid']." and type=1 and uid = ".$_REQUEST['ownerId']." and time > ".($_SGLOBAL['timestamp']-3600);
$query_r = $_SGLOBAL['db']->query($sql1);
$value_r = $_SGLOBAL['db']->fetch_array($query_r);
if ($value_r != null){
//while ( $value_r = $_SGLOBAL['db']->fetch_array($query_r) ){
$result[] = $value_r;
//}
if(strpos($result[0][counts],':') !== false){
$counts_ = explode(';',$result[0][counts]);
$counts_chk = true;
foreach ( $counts_ as $key => $value_ ){
$counts_t = explode(':',$value_);
if($counts_t[0] == $cid){
$counts_t[1]++;
$counts_chk = false;
$counts_[$key] = join(':',$counts_t);
break;
}
}
if($counts_chk){
$counts_all = $result[0][counts] . ";{$cid}:1";
}else{
$counts_all = join(';',$counts_);
}
}else{
$counts_all = "{$cid}:1";
}
$sql = "UPDATE ".tname( "plug_newfarm_logs" )." set count = count+1,counts='{$counts_all}',time = ".$_SGLOBAL['timestamp']." where id = ".$result[0][id];
}else{
$sql = "INSERT INTO ".tname( "plug_newfarm_logs" )." (`uid`, `type`, `count`,`counts`, `fromid`, `time`, `cropid`, `isread` ) VALUES (".$_REQUEST['ownerId'].", 1, 1,'{$cid}:1', ".$_SGLOBAL['supe_uid'].", ".$_SGLOBAL['timestamp'].", ".$cid.", 0);";
}
$_SGLOBAL['db']->query( $sql );
不要嫌代码长,仔细研究就知道了!!
除草、捉虫、浇水的更新添加日志的三个地方地方,更改为:
$sql1 = "SELECT `id`, `uid`, `cropid`, `fromid`, `count`,`counts`,`time`, `type` FROM ".tname( "plug_newfarm_logs" )." WHERE fromid = ".$_SGLOBAL['supe_uid']." and type=2 and uid = ".$_REQUEST['ownerId']." and time > ".($_SGLOBAL['timestamp']-3600);
$query_r = $_SGLOBAL['db']->query($sql1);
$value_r = $_SGLOBAL['db']->fetch_array($query_r);
if ($value_r != null){
//while ( $value_r = $_SGLOBAL['db']->fetch_array($query_r) ){
$result[] = $value_r;
//}
if(strpos($result[0][counts],':') !== false){
$counts_ = explode(':',$result[0][counts]);
$counts_[0]++;
$counts_all = join(':',$counts_);
}else{
$counts_all = "1:0:0";
}
$sql = "UPDATE ".tname( "plug_newfarm_logs" )." set count = count+1,counts='{$counts_all}',time = ".$_SGLOBAL['timestamp']." where id = ".$result[0][id];
}else {
$sql = "INSERT INTO ".tname( "plug_newfarm_logs" )." (`uid`, `type`, `count`,`counts`, `fromid`, `time`, `cropid`, `isread` ) VALUES (".$_REQUEST['ownerId'].", 2, 1,'1:0:0', ".$_SGLOBAL['supe_uid'].", ".$_SGLOBAL['timestamp'].", 0, 0);";
}
$_SGLOBAL['db']->query( $sql );
注意一点:1:0:0 和 $counts_[0]++; 是增加除草,
捉虫的地方修改:0:1:0 和 $counts_[1]++;
浇水的地方为:0:0:1 和 $counts_[2]++;
然后显示日志的地方:
type=1
type=2
两个地方修改如下:
if ($value[type]==1){
$query1 = $_SGLOBAL['db']->query( "SELECT uid,username,name FROM ".tname( "space" )." WHERE uid = ".$value[fromid]."");
$value1 = $_SGLOBAL['db']->fetch_array( $query1 );
$counts_ = explode(';',$value[counts]);
$counts_all="";
foreach ( $counts_ as $value_ ){
$counts_t = explode(':',$value_);
$counts_all .= $counts_t[1]."\\u4e2a".$crops[$counts_t[0]][cName]."\\u3001";
}
if($counts_all!=""){$counts_all =substr($counts_all,0,-6);}
$msg = "\"<a href=\\\"event:".$value[fromid]."\\\"><font color=\\\"#009900\\\"><b>".unicode_encodegb( $value1['username'])."<\\/b><\\/font><\/a> \\u6765\\u519c\\u573a\\u5077\\u7a83\\uff0c\\u5077\\u8d70{$counts_all}\\u3002\"";
$str .= "{\"time\":".$value['time'].",\"msg\":".$msg."},";
}elseif ($value[type]==2){
$query1 = $_SGLOBAL['db']->query( "SELECT uid,username,name FROM ".tname( "space" )." WHERE uid = ".$value[fromid]."");
$value1 = $_SGLOBAL['db']->fetch_array( $query1 );
$counts_all = "";
$counts_ = explode(':',$value[counts]);
if($counts_[0]>0){$counts_all .= "\\u9664\\u8349".$counts_[0]."\\u6B21\\u3001";}
if($counts_[1]>0){$counts_all .= "\\u6740\\u866B".$counts_[1]."\\u6B21\\u3001";}
if($counts_[2]>0){$counts_all .= "\\u6D47\\u6C34".$counts_[2]."\\u6B21\\u3001";}
if($counts_all!=""){$counts_all = substr($counts_all,0,-6);}
//$counts_all =str_replace(array('a1','a2','a3'),$counts_,"\\u9664\\u8349a1\\u6B21\\u3001\\u6740\\u866Ba2\\u6B21\\u3001\\u6D47\\u6C34a3\\u6B21");
$msg = "\"<a href=\\\"event:".$value[fromid]."\\\"><font color=\\\"#009900\\\"><b>".unicode_encodegb( $value1['username'])."<\\/b><\\/font><\/a> \\u6765\\u519c\\u573a\\u5e2e\\u5fd9{$counts_all}\\uff01\"";
$str .= "{\"time\":".$value['time'].",\"msg\":".$msg."},";
想法原理:
为了节省日志空间,1个小时之内的相同操作是累加的,超过一个小时自动增加新日志,在一个小时内操作,只是更新操作次数!!看看图就明白了!!
本人不提供修改文件,因为农场各种各样,我也不知道我是什么版,还经过谁修改过,懂的人喜欢自己改吧!!! |