本帖最后由 fbean 于 2009-10-31 20:22 编辑
之前那个附件有点点问题,请大家重新更新一下,再说一下:已经统一使用log字段保存,请大家删除之前的farm_log字段,log字段之前有记录的,请先清空记录,否则会出现问题
先上图
测试环境:
位置:本地
系统:windows7+IIS7+IE7
PHP:PHP 5.2.11
MYSQL:MYSQL 5.0.19
测试插件源版本:https://discuz.dismall.com/thread-1442984-1-1.html
已经修补补丁:
补丁1:修复了乱码BUG(by yoyo)地址:https://discuz.dismall.com/thread-1453790-1-3.html
补丁2:修复了商品全部卖出BUG(by yoyo)地址:https://discuz.dismall.com/thread-1454295-1-2.html
补丁3:修复了无法装饰或者装饰后不保存并且刷新进入初始化失败BUG、化肥10XN数量只能使用一次刷新消失BUG、农场默认包裹很多过期装饰BUG(by yoyo) 地址:https://discuz.dismall.com/thread-1455241-1-1.html
补丁4:牧场反复偷取的问题(by 残月)地址:https://discuz.dismall.com/thread-1461663-1-1.html
补丁5:狗不咬人的问题(by 残月 ,修改为随机金额,最低30金币损失)地址:https://discuz.dismall.com/thread-1462082-1-1.html
补丁6:买狗时赠送的狗粮与说明不符(by 1youcheng)地址:https://discuz.dismall.com/thread-1462978-1-1.html
补丁7:牧场留言功能修复(by me)地址:https://discuz.dismall.com/thread-1463182-1-2.html
补丁8:牧场日志和留言清空功能(by me)地址:https://discuz.dismall.com/thread-1463644-1-1.html
补丁9:农场系统日志功能修复【偷、浇水、除草、杀虫、狗咬、出售】(by me) 地址:https://discuz.dismall.com/thread-1464009-1-1.html
以后我对农场做修补就在此基础上修正,虽然该版本没有新版本那么华丽,不过比较稳定,合用。请各位对号入座,避免造成不必要的错误,为了避免数据冗余,我放弃了之前的farm_log字段,采用自带的log字段修复,之前的修改文档我也会对应修改!请大家注意
下面来对农场日志进行最后修补(newfarm/newfarmjson.php):
首先请参照补丁9,这里提供最后的关于狗咬日志的添加
查找:- if ( $_REQUEST['mod'] == "farmlandstatus" && $_REQUEST['act'] == "scrounge" )
复制代码 包括这句,一直到- if ( $_REQUEST['mod'] == "repertory" && $_REQUEST['act'] == "sale" )
复制代码 之前的代码,全部替换为以下代码即可(怕出错的可以看后面的具体修改步骤,稍微麻烦一点):- if ( $_REQUEST['mod'] == "farmlandstatus" && $_REQUEST['act'] == "scrounge" )
- {
- $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 );
- $farm_log = json_decode( $farm_log );
- $log_msg="";
- $farmarr = json_decode( $farm );
- $fruitarr = json_decode( $fruit );
- if ( stristr( $farmarr->farmlandstatus[$_REQUEST['place']]->n, ",".$_SGLOBAL['supe_uid']."," ) )
- {
- exit( );
- }
- $cid = $farmarr->farmlandstatus[$_REQUEST['place']]->a;
- $query = $_SGLOBAL['db']->query( "SELECT dog FROM ".tname( "plug_newfarm" )." where uid=".intval( $_REQUEST['ownerId'] ) );
- while ( $value = $_SGLOBAL['db']->fetch_array( $query ) )
- {
- $list[] = $value;
- }
-
- $dog = json_decode( $list[0][dog] );
- $dogstr = "";
- $dog_poptype=4;
- $dog_harvest=1;
- $dog_money=0;
- $dog_thief=1;
- $dog_ok=0;
-
- foreach ( $dog as $key => $value )
- {
- if ( $value->status == 1 && $_SGLOBAL['timestamp'] < $value->dogFeedTime )
- {
- $suiji=rand(1,10);
- if($suiji>6){
- $dog_ok=1;
- $dog_poptype=3;
- $dog_harvest=0;
- $dog_thief=0;
-
- $suiji2=rand(1,10);
- if($suiji2>8){
- $dog_money=round(20*rand(1,30)/5)*rand(1,2);
- }else{
- $dog_money=round(10*rand(1,20)/5);
- }
- $dogstr ="\\u4F60\\u5728\\u5077\\u7A83\\u8FC7\\u7A0B\\u4E2D\\u88ABTA\\u7684\\u72D7\\u72D7\\u53D1\\u73B0\\uFF0C\\u5728\\u9003\\u8DD1\\u8FC7\\u7A0B\\u4E2D\\u4E22\\u5931".$dog_money."\\u91D1\\u5E01\\u3002";
- }
-
- }
- }
- if ( empty( $space[name] ) )
- {
- $space[name] = $space[username];
- }
- $space[name] = unicode_encodegb( $space[name] );
- if($dog_ok==0){
- $fruitarr->$cid = $fruitarr->$cid + 1;
- $farmarr->farmlandstatus[$_REQUEST['place']]->m = $farmarr->farmlandstatus[$_REQUEST['place']]->m - 1;
- 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'] );
-
-
-
- $log_msg="<b>".$space[name]."<\/b>\\u6765\\u519C\\u573A\\u6458\\u53D6\\uFF0C\\u6458\\u8D701\\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'] ) );
-
- }else{
- $fruitarr->$cid = $fruitarr->$cid;
- $farmarr->farmlandstatus[$_REQUEST['place']]->m = $farmarr->farmlandstatus[$_REQUEST['place']]->m;
- 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."',money=money+'".$dog_money."' where uid=".intval( $_REQUEST['ownerId'] ) );
- $_SGLOBAL['db']->query( "UPDATE ".tname( "plug_newfarm" )." set money=money-'".$dog_money."' where uid=".$_SGLOBAL['supe_uid'] );
- $dog_log=""; $dog_log="<b>".$space[name]."<\/b>\\u6765\\u519C\\u573A\\u6458\\u53D6\\u88AB\\u72D7\\u72D7\\u53D1\\u73B0\\u4E86\\uFF0C\\u5B83\\u4E3A\\u4E3B\\u4EBA\\u6293\\u83B7".$dog_money."\\u4E2A\\u91D1\\u5E01\\u3002";
- $farm_log->l[] = "{"time":".$_SGLOBAL['timestamp'].","msg":"".$dog_log.""}";
- $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'] ) );
- }
-
- echo "{"farmlandIndex":".$_REQUEST['place'].","code":1,"poptype":".$dog_poptype.","direction":"".$dogstr."","harvest":".$dog_harvest.","money":-".$dog_money.","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":".$dog_thief.","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."}}";
- 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( );
- }
复制代码 以下为具体修改步骤(按照上面修改了的就可以略了):
查找:- 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 ( empty( $space[name] ) )
- {
- $space[name] = $space[username];
- }
- $space[name] = unicode_encodegb( $space[name] );
复制代码 从开始往下大概第11行处,就是如下代码的位置- $_SGLOBAL['db']->query( "UPDATE ".tname( "plug_newfarm" )." set fruit='".$fruitarr."' where uid=".$_SGLOBAL['supe_uid'] );
复制代码 在这句下面加入代码继续往下一句应该是句}else{,从这句往下大概11句处,应该为如下代码- $_SGLOBAL['db']->query( "UPDATE ".tname( "plug_newfarm" )." set money=money-'".$dog_money."' where uid=".$_SGLOBAL['supe_uid'] );
复制代码 在这句下面加入代码- $dog_log=""; $dog_log="<b>".$space[name]."<\/b>\\u6765\\u519C\\u573A\\u6458\\u53D6\\u88AB\\u72D7\\u72D7\\u53D1\\u73B0\\u4E86\\uFF0C\\u5B83\\u4E3A\\u4E3B\\u4EBA\\u6293\\u83B7".$dog_money."\\u4E2A\\u91D1\\u5E01\\u3002";
- $farm_log->l[] = "{"time":".$_SGLOBAL['timestamp'].","msg":"".$dog_log.""}";
- $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'] ) );
复制代码 修改完毕,代码比较多,可能会出现一些失误,欢迎大家反馈!
还是老规矩,有钱的捧个钱场,没钱的捧个人场!
还是放出一个成品文件吧,不过不建议直接替换,因为可能补丁打得不同 |