本帖最后由 fbean 于 2009-10-30 23:31 编辑
由于PHP环境版本差异,导致转义读写出现异常,已经修改,本地测试正常,欢迎反馈问题,鉴于大家版本不一,就不放出统一的覆盖文件,以免出现异常,修改之后记得清空数据库的log字段之前的记录数据
出售日志修改部分为第f步骤
日志不会即时显示,需要刷新一下
附之前提供的功能修复帖子列表:
1、《【开心农场】安装后页面白屏解决方案(添加空方法无效者可看)》
2、《【开心农场】牧场 留言功能修复》
3、《【开心农场】牧场日志和留言清空功能修复》
本补丁作用:恢复农场日志功能,对于狗咬部分的日志我没有写,因为关于狗的部分,有些朋友是固定金额、有的朋友是改成了随机金额,不知道大家怎么补的,所以不好统一,该部分的日志修改就不放了,免得出乱子
附说明:脑子有点乱……有问题欢迎提醒,
修改步骤:
1、数据库修改放弃,采用自带log字段存储,代码已经全部修改为log
2、修改newfarm/newfarmjson.php
a、查找- if ( $_REQUEST['mod'] == "user" && $_REQUEST['act'] == "getLog" )
- {
复制代码 将以下代码删除- echo "[{"time":".$_SGLOBAL['supe_uid'].","msg":"<a href=\\"event:222769470\\"><font color=\\"#009900\\"><b>\\u7CFB\\u7EDF<\\/b><\\/font><\\/a> \\u6B64\\u529F\\u80FD\\u6682\\u65F6\\u672A\\u5F00\\u653E\\uFF01\\uFF01"}]";
复制代码 并替换为以下代码- if ( empty( $space[name] ) )
- {
- $space[name] = $space[username];
- }
- $space[name] = unicode_encodegb( $space[name] );
- $tempecho="";
- $log = $_SGLOBAL['db']->result( $_SGLOBAL['db']->query( "SELECT log FROM ".tname( "plug_newfarm" )." where uid=".intval( $_SGLOBAL['supe_uid']) ), 0 );
- $log = json_decode( $log );
- $tempLog=$log->l;
- foreach($tempLog as $val){
- $tempecho=json_encode($val).",".$tempecho;
- }
- $tempecho=substr($tempecho,0,-1);
- echo "[".$tempecho."]";
复制代码 b、查找:- if ( $_REQUEST['mod'] == "farmlandstatus" && $_REQUEST['act'] == "clearWeed" )
复制代码 从这句代码往下找,找到第2句- include_once( S_ROOT."./source/function_cp.php" );
复制代码 在这句代码上面加入- $farm_log = $_SGLOBAL['db']->result( $_SGLOBAL['db']->query( "SELECT log FROM ".tname( "plug_newfarm" )." where uid=".intval( $_REQUEST['ownerId'] ) ), 0 );
- $farm_log = json_decode( $farm_log );
- $log_msg="";
- if ( empty( $space[name] ) )
- {
- $space[name] = $space[username];
- }
- $space[name] = unicode_encodegb( $space[name] );
-
- $log_msg="<b>".$space[name]."<\/b>\\u6765\\u519C\\u573A\\u5E2E\\u5FD9\\u9664\\u8349\\u3002";
-
- $farm_log->l[] = "{"time":".$_SGLOBAL['timestamp'].","msg":"".$log_msg.""}";
- $farm_log = json_encode( $farm_log );
- $farm_log = str_replace( ""{", "{", $farm_log );
- $farm_log = str_replace( "}"", "}", $farm_log );
- $farm_log = str_replace( "\\u", "\\\\u", $farm_log );
- $_SGLOBAL['db']->query( "UPDATE ".tname( "plug_newfarm" )." set log='".$farm_log."' where uid=".intval( $_REQUEST['ownerId'] ) );
复制代码 c、查找:- if ( $_REQUEST['mod'] == "farmlandstatus" && $_REQUEST['act'] == "spraying" )
复制代码 同前面操作一样,往下找到第2句- include_once( S_ROOT."./source/function_cp.php" );
复制代码 在这句上面插入如下代码- $farm_log = $_SGLOBAL['db']->result( $_SGLOBAL['db']->query( "SELECT log FROM ".tname( "plug_newfarm" )." where uid=".intval( $_REQUEST['ownerId'] ) ), 0 );
- $farm_log = json_decode( $farm_log );
- $log_msg="";
- if ( empty( $space[name] ) )
- {
- $space[name] = $space[username];
- }
- $space[name] = unicode_encodegb( $space[name] );
-
- $log_msg="<b>".$space[name]."<\/b>\\u6765\\u519C\\u573A\\u5E2E\\u5FD9\\u6740\\u866B\\u3002";
-
- $farm_log->l[] = "{"time":".$_SGLOBAL['timestamp'].","msg":"".$log_msg.""}";
- $farm_log = json_encode( $farm_log );
- $farm_log = str_replace( ""{", "{", $farm_log );
- $farm_log = str_replace( "}"", "}", $farm_log );
- $farm_log = str_replace( "\\u", "\\\\u", $farm_log );
- $_SGLOBAL['db']->query( "UPDATE ".tname( "plug_newfarm" )." set log='".$farm_log."' where uid=".intval( $_REQUEST['ownerId'] ) );
复制代码 d、查找:- if ( $_REQUEST['mod'] == "farmlandstatus" && $_REQUEST['act'] == "water" )
复制代码 如前面操作,找到那个第2句之后,在那句前面插入代码- $farm_log = $_SGLOBAL['db']->result( $_SGLOBAL['db']->query( "SELECT log FROM ".tname( "plug_newfarm" )." where uid=".intval( $_REQUEST['ownerId'] ) ), 0 );
- $farm_log = json_decode( $farm_log );
- $log_msg="";
- if ( empty( $space[name] ) )
- {
- $space[name] = $space[username];
- }
- $space[name] = unicode_encodegb( $space[name] );
-
- $log_msg="<b>".$space[name]."<\/b>\\u6765\\u519C\\u573A\\u5E2E\\u5FD9\\u6D47\\u6C34\\u3002";
-
- $farm_log->l[] = "{"time":".$_SGLOBAL['timestamp'].","msg":"".$log_msg.""}";
- $farm_log = json_encode( $farm_log );
- $farm_log = str_replace( ""{", "{", $farm_log );
- $farm_log = str_replace( "}"", "}", $farm_log );
- $farm_log = str_replace( "\\u", "\\\\u", $farm_log );
- $_SGLOBAL['db']->query( "UPDATE ".tname( "plug_newfarm" )." set log='".$farm_log."' where uid=".intval( $_REQUEST['ownerId'] ) );
复制代码 e步骤是对偷菜日志的修复,这里的修复没有涉及到狗狗咬人的日志,包括狗狗咬人的日志请到https://discuz.dismall.com/viewthread.php?tid=1465822&page=1&extra=#pid12299551进行参照修补
e【修改方法1,代码中默认好像每个菜是固定偷取一个的,这里不改变它】、查找:- if ( $_REQUEST['mod'] == "farmlandstatus" && $_REQUEST['act'] == "scrounge" )
- {
复制代码 往下两句有句代码- $fruit = $_SGLOBAL['db']->result( $_SGLOBAL['db']->query( "SELECT fruit FROM ".tname( "plug_newfarm" )." where uid=".$_SGLOBAL['supe_uid'] ), 0 );
复制代码 在下面插入- $farm_log = $_SGLOBAL['db']->result( $_SGLOBAL['db']->query( "SELECT log FROM ".tname( "plug_newfarm" )." where uid=".intval( $_REQUEST['ownerId'] ) ), 0 );
- $farm_log = json_decode( $farm_log );
- $log_msg="";
复制代码 往下找到(在代码if ( $_REQUEST['mod'] == "repertory" && $_REQUEST['act'] == "sale" )之前的那句哦)- include_once( S_ROOT."./source/function_cp.php" )
复制代码 在上面插入代码e【修改方法2,改变了偷窃数量为1-5个随机产生,数量是可以偷到,不过Flash显示数字始终是+1,有待改进】
将代码- if ( $_REQUEST['mod'] == "farmlandstatus" && $_REQUEST['act'] == "scrounge" )
- {
复制代码 和代码- }
- if ( $_REQUEST['mod'] == "repertory" && $_REQUEST['act'] == "sale" )
复制代码 之间的所有代码替换为如下:- $farm = $_SGLOBAL['db']->result( $_SGLOBAL['db']->query( "SELECT farmlandstatus FROM ".tname( "plug_newfarm" )." where uid=".intval( $_REQUEST['ownerId'] ) ), 0 );
- $fruit = $_SGLOBAL['db']->result( $_SGLOBAL['db']->query( "SELECT fruit FROM ".tname( "plug_newfarm" )." where uid=".$_SGLOBAL['supe_uid'] ), 0 );
-
-
- $farm_log = $_SGLOBAL['db']->result( $_SGLOBAL['db']->query( "SELECT log FROM ".tname( "plug_newfarm" )." where uid=".intval( $_REQUEST['ownerId'] ) ), 0 );
-
- $farmarr = json_decode( $farm );
- $fruitarr = json_decode( $fruit );
-
- $farm_log = json_decode( $farm_log );
- $log_msg="";
- $get_num=rand(1, 5);
-
-
- if ( stristr( $farmarr->farmlandstatus[$_REQUEST['place']]->n, ",".$_SGLOBAL['supe_uid']."," ) )
- {
- exit( );
- }
- $cid = $farmarr->farmlandstatus[$_REQUEST['place']]->a;
- $fruitarr->$cid = $fruitarr->$cid + $get_num;
- $farmarr->farmlandstatus[$_REQUEST['place']]->m = $farmarr->farmlandstatus[$_REQUEST['place']]->m - $get_num;
- if ( $farmarr->farmlandstatus[$_REQUEST['place']]->m < $farmarr->farmlandstatus[$_REQUEST['place']]->l )
- {
- exit( );
- }
- $farmarr->farmlandstatus[$_REQUEST['place']]->n = $farmarr->farmlandstatus[$_REQUEST['place']]->n.",".$_SGLOBAL['supe_uid'].",";
- $farmarr_str = json_encode( $farmarr );
- $fruitarr = json_encode( $fruitarr );
- $_SGLOBAL['db']->query( "UPDATE ".tname( "plug_newfarm" )." set farmlandstatus='".$farmarr_str."' where uid=".intval( $_REQUEST['ownerId'] ) );
- $_SGLOBAL['db']->query( "UPDATE ".tname( "plug_newfarm" )." set fruit='".$fruitarr."' where uid=".$_SGLOBAL['supe_uid'] );
- echo "{"farmlandIndex":".$_REQUEST['place'].","code":1,"poptype":4,"direction":"","harvest":1,"status":{"cId":".$farmarr->farmlandstatus[$_REQUEST['place']]->a.","cropStatus":".$farmarr->farmlandstatus[$_REQUEST['place']]->b.","weed":".$farmarr->farmlandstatus[$_REQUEST['place']]->f.","pest":".$farmarr->farmlandstatus[$_REQUEST['place']]->g.","humidity":".$farmarr->farmlandstatus[$_REQUEST['place']]->h.","killer":".json_encode( $farmarr->farmlandstatus[$_REQUEST['place']]->i ).","harvestTimes":".$farmarr->farmlandstatus[$_REQUEST['place']]->j.","output":".$farmarr->farmlandstatus[$_REQUEST['place']]->k.","min":".$farmarr->farmlandstatus[$_REQUEST['place']]->l.","leavings":".$farmarr->farmlandstatus[$_REQUEST['place']]->m.","thief":1,"fertilize":".$farmarr->farmlandstatus[$_REQUEST['place']]->o.","action":".json_encode( $farmarr->farmlandstatus[$_REQUEST['place']]->p ).","plantTime":".$farmarr->farmlandstatus[$_REQUEST['place']]->q.","updateTime":".$farmarr->farmlandstatus[$_REQUEST['place']]->r.","pId":".$farmarr->farmlandstatus[$_REQUEST['place']]->s.","nph":".$farmarr->farmlandstatus[$_REQUEST['place']]->t.","mph":".$farmarr->farmlandstatus[$_REQUEST['place']]->u."}}";
-
-
-
- if ( empty( $space[name] ) )
- {
- $space[name] = $space[username];
- }
- $space[name] = unicode_encodegb( $space[name] );
-
- $log_msg="<b>".$space[name]."<\/b>\\u6765\\u519C\\u573A\\u6458\\u53D6\\uFF0C\\u6458\\u8D70".$get_num."\\u4E2A";
-
- switch ($cid) {
- case 1:
- $log_msg=$log_msg."\\u8349\\u8393";
- break;
- case 2:
- $log_msg=$log_msg."\\u767D\\u841D\\u535C";
- break;
- case 3:
- $log_msg=$log_msg."\\u80E1\\u841D\\u535C";
- break;
- case 4:
- $log_msg=$log_msg."\\u7389\\u7C73";
- break;
- case 5:
- $log_msg=$log_msg."\\u571F\\u8C46";
- break;
- case 6:
- $log_msg=$log_msg."\\u8304\\u5B50";
- break;
- case 7:
- $log_msg=$log_msg."\\u756A\\u8304";
- break;
- case 8:
- $log_msg=$log_msg."\\u8C4C\\u8C46";
- break;
- case 9:
- $log_msg=$log_msg."\\u8FA3\\u6912";
- break;
- case 10:
- $log_msg=$log_msg."\\u5357\\u74DC";
- break;
- case 11:
- $log_msg=$log_msg."\\u82F9\\u679C";
- break;
- case 12:
- $log_msg=$log_msg."\\u54C8\\u5BC6\\u74DC";
- break;
- case 13:
- $log_msg=$log_msg."\\u8461\\u8404";
- break;
- case 14:
- $log_msg=$log_msg."\\u897F\\u74DC";
- break;
- case 15:
- $log_msg=$log_msg."\\u9999\\u8549";
- break;
- case 16:
- $log_msg=$log_msg."\\u67E0\\u6AAC";
- break;
- case 17:
- $log_msg=$log_msg."\\u6787\\u6777";
- break;
- case 18:
- $log_msg=$log_msg."\\u6843\\u5B50";
- break;
- case 19:
- $log_msg=$log_msg."\\u6A59\\u5B50";
- break;
- case 20:
- $log_msg=$log_msg."\\u7518\\u8517";
- break;
- case 21:
- $log_msg=$log_msg."\\u8611\\u83C7";
- break;
- case 22:
- $log_msg=$log_msg."\\u6768\\u6885";
- break;
- case 23:
- $log_msg=$log_msg."\\u77F3\\u69B4";
- break;
- case 26:
- $log_msg=$log_msg."\\u91C9\\u5B50";
- break;
- case 27:
- $log_msg=$log_msg."\\u83E0\\u841D";
- break;
- case 29:
- $log_msg=$log_msg."\\u6930\\u5B50";
- break;
- case 31:
- $log_msg=$log_msg."\\u846B\\u82A6";
- break;
- case 33:
- $log_msg=$log_msg."\\u706B\\u9F99\\u679C";
- break;
- case 34:
- $log_msg=$log_msg."\\u6A31\\u6843";
- break;
- case 35:
- $log_msg=$log_msg."\\u8354\\u679D";
- break;
- case 36:
- $log_msg=$log_msg."\\u5947\\u5F02\\u679C";
- break;
- case 40:
- $log_msg=$log_msg."\\u7267\\u8349";
- break;
- case 101:
- $log_msg=$log_msg."\\u73AB\\u7470\\uFF08\\u7EA2\\u8272\\uFF09";
- break;
- case 102:
- $log_msg=$log_msg."\\u73AB\\u7470\\uFF08\\u7C89\\u8272\\uFF09";
- break;
- case 103:
- $log_msg=$log_msg."\\u73AB\\u7470\\uFF08\\u767D\\u8272\\uFF09";
- break;
- case 104:
- $log_msg=$log_msg."\\u73AB\\u7470\\uFF08\\u9EC4\\u8272\\uFF09";
- break;
- case 105:
- $log_msg=$log_msg."\\u592A\\u9633\\u82B1\\uFF08\\u91D1\\u8272\\uFF09";
- break;
- case 106:
- $log_msg=$log_msg."\\u592A\\u9633\\u82B1\\uFF08\\u7C89\\u8272\\uFF09";
- break;
- case 107:
- $log_msg=$log_msg."\\u592A\\u9633\\u82B1\\uFF08\\u767D\\u8272\\uFF09";
- break;
- case 108:
- $log_msg=$log_msg."\\u592A\\u9633\\u82B1\\uFF08\\u7C73\\u8272\\uFF09";
- break;
- case 109:
- $log_msg=$log_msg."\\u5EB7\\u4E43\\u99A8\\uFF08\\u767D\\u8272\\uFF09";
- break;
- case 110:
- $log_msg=$log_msg."\\u5EB7\\u4E43\\u99A8\\uFF08\\u7C89\\u8272\\uFF09";
- break;
- case 111:
- $log_msg=$log_msg."\\u5EB7\\u4E43\\u99A8\\uFF08\\u9EC4\\u8272\\uFF09";
- break;
- case 112:
- $log_msg=$log_msg."\\u5EB7\\u4E43\\u99A8\\uFF08\\u7D2B\\u8272\\uFF09";
- break;
- case 113:
- $log_msg=$log_msg."\\u90C1\\u91D1\\u9999\\uFF08\\u7D2B\\u8272\\uFF09";
- break;
- case 114:
- $log_msg=$log_msg."\\u90C1\\u91D1\\u9999\\uFF08\\u7EA2\\u8272\\uFF09";
- break;
- case 115:
- $log_msg=$log_msg."\\u90C1\\u91D1\\u9999\\uFF08\\u7C89\\u8272\\uFF09";
- break;
- case 116:
- $log_msg=$log_msg."\\u90C1\\u91D1\\u9999\\uFF08\\u767E\\u8272\\uFF09";
- break;
- case 117:
- $log_msg=$log_msg."\\u6C34\\u4ED9\\uFF08\\u767D\\u8272\\uFF09";
- break;
- case 118:
- $log_msg=$log_msg."\\u6C34\\u4ED9\\uFF08\\u9EC4\\u8272\\uFF09";
- break;
- case 119:
- $log_msg=$log_msg."\\u6C34\\u4ED9\\uFF08\\u7C89\\u8272\\uFF09";
- break;
- case 120:
- $log_msg=$log_msg."\\u6C34\\u4ED9\\uFF08\\u7D2B\\u8272\\uFF09";
- break;
- case 121:
- $log_msg=$log_msg."\\u98CE\\u4FE1\\u5B50\\uFF08\\u767D\\u8272\\uFF09";
- break;
- case 122:
- $log_msg=$log_msg."\\u98CE\\u4FE1\\u5B50\\uFF08\\u7D2B\\u8272\\uFF09";
- break;
- case 123:
- $log_msg=$log_msg."\\u98CE\\u4FE1\\u5B50\\uFF08\\u7EA2\\u8272\\uFF09";
- break;
- case 124:
- $log_msg=$log_msg."\\u98CE\\u4FE1\\u5B50\\uFF08\\u9EC4\\u8272\\uFF09";
- break;
- }
- $farm_log->l[] = "{"time":".$_SGLOBAL['timestamp'].","msg":"".$log_msg.""}";
- $farm_log = json_encode( $farm_log );
- $farm_log = str_replace( ""{", "{", $farm_log );
- $farm_log = str_replace( "}"", "}", $farm_log );
- $farm_log = str_replace( "\\u", "\\\\u", $farm_log );
- $_SGLOBAL['db']->query( "UPDATE ".tname( "plug_newfarm" )." set log='".$farm_log."' where uid=".intval( $_REQUEST['ownerId'] ) );
-
- include_once( S_ROOT."./source/function_cp.php" );
- $icon = "farm";
- $title_template = "{actor}去{touser}的 <a href="newfarm.php">农场</a> 好好洗劫了一番,收获不小!";
- $touserspace = getspace( intval( $_REQUEST['ownerId'] ) );
-
- if ( empty( $touserspace[name] ) )
- {
- $touserspace[name] = $touserspace[username];
- }
- $title_data = array(
- "touser" => "<a href="space.php?uid=".intval( $_REQUEST['ownerId'] )."">".$touserspace[name]."</a>"
- );
- $body_general = "我们是害虫,我们是害虫,正义的敌人、正义的敌人!";
- feed_add( $icon, $title_template, $title_data, NULL, NULL, NULL );
- exit( );
复制代码 f 、出售日志部分
查找- if ( $_REQUEST['mod'] == "repertory" && $_REQUEST['act'] == "sale" )
复制代码 这句往下第一句include_once( S_ROOT."./source/function_cp.php" );的上面加入代码
各位有钱的捧个钱场,没钱的捧个人场~~ |