本帖最后由 wxiong1984 于 2009-11-6 12:16 编辑
考虑许多人不能看到我们论坛的帖子,现在再次把帖子在这里发布一次
在数据库建立两个新的字段
wenzi TEXT
bad INT
修改newfarm/newmc.php
如想知道BUG修复的原理和整个过程,可一边参考我昨天发的:
【开心农场】牧场放蚊子BUG修复分析帖--BY-残月 https://discuz.dismall.com/thread-1464123-1-1.html
我实在纳闷,为何这么久都没有人去写代码,都想坐享其成,呵呵。
待续。。。。
找到代码:- if ( $_REQUEST['mod'] == "cgi_enter" || $_REQUEST['mod'] == "cgi_enter?" )
- {
复制代码 把上面整个过程代码替换为:- if ( $_REQUEST['mod'] == "cgi_enter" || $_REQUEST['mod'] == "cgi_enter?" )
- {
- if ( 0 < intval( $_REQUEST['uId'] ) )
- {
- $touarr = array( "1001" => 0, "1002" => 0, "1003" => 0, "1004" => 0, "1005" => 0, "1006" => 0, "1501" => 0, "1502" => 0, "1503" => 0, "1504" => 0 );
- $query = $_SGLOBAL['db']->query( "SELECT money,animal,mc_exp,wenzi FROM ".tname( "plug_newfarm" )." where uid=".intval( $_REQUEST['uId'] ) );
- while ( $value = $_SGLOBAL['db']->fetch_array( $query ) )
- {
- $list[] = $value;
- }
- $animal = ( array )json_decode( $list[0][animal] );
- //wenzi
- $wenzi_num=0;
- $wenzi_mynum=0;
- if ($list[0][wenzi]!=""){
- $wenzi = explode(",",$list[0][wenzi]);
- $wenzi_num = count($wenzi);
-
- for ($i=0;$i<$wenzi_num-1;$i++){
-
- if ($wenzi[$i]==$_SGLOBAL['supe_uid']){
- $wenzi_mynum=$wenzi_mynum+1;
- }
- }
-
- if($wenzi_mynum>0) {
- $wenzi_mynum=8;
- }
-
-
-
- }
- //wenzi
- $needfood = 0;
- foreach ( $animal[animal] as $key => $value )
- {
- if ( 0 < $value->cId )
- {
- if ( $touarr[$value->cId] = 3 )
- {
- $touarr[$value->cId] = 3;
- if ( stristr( $value->tou, ",".$_SGLOBAL['supe_uid']."," ) )
- {
- $touarr[$value->cId] = 2;
- }
- if ( $value->totalCome <= $shop[$value->cId][output] / 2 )
- {
- $touarr[$value->cId] = 1;
- }
- }
- $needfood += $shop[$value->cId][consum];
- if ( $value->postTime == 0 )
- {
- $time = $_SGLOBAL['timestamp'] - $value->buyTime;
- if ( $animaltime[$value->cId][0] + $animaltime[$value->cId][1] <= $time )
- {
- $status = 3;
- $growTimeNext = 12993;
- $statusNext = 6;
- }
- if ( $animaltime[$value->cId][0] <= $time && $time < $animaltime[$value->cId][0] + $animaltime[$value->cId][1] )
- {
- $status = 2;
- $growTimeNext = $animaltime[$value->cId][0] + $animaltime[$value->cId][1] - $time;
- $statusNext = 3;
- }
- if ( $time < $animaltime[$value->cId][0] )
- {
- $status = 1;
- $growTimeNext = $animaltime[$value->cId][0] - $time;
- $statusNext = 2;
- }
- if ( $animaltime[$value->cId][5] < $time )
- {
- $status = 6;
- $growTimeNext = 0;
- $statusNext = 6;
- }
- $newanimal[] = "{"buyTime":".$value->buyTime.","cId":".$value->cId.","growTime":".$time.","growTimeNext":".$growTimeNext.","hungry":0,"serial":".$key.","status":".$status.","statusNext":".$statusNext.","totalCome":".$value->totalCome."}";
- }
- else
- {
- $totalCome = $value->totalCome;
- $time = $_SGLOBAL['timestamp'] - $value->buyTime;
- if ( $animaltime[$value->cId][5] < $time )
- {
- $status = 6;
- $statusNext = 6;
- $growTimeNext = 0;
- }
- if ( $animaltime[$value->cId][4] < $_SGLOBAL['timestamp'] - $value->postTime )
- {
- $status = 3;
- $statusNext = 6;
- $growTimeNext = 12993;
- }
- if ( $_SGLOBAL['timestamp'] - $value->postTime <= $animaltime[$value->cId][4] )
- {
- $status = 5;
- $statusNext = 3;
- $growTimeNext = $animaltime[$value->cId][4] - ( $_SGLOBAL['timestamp'] - $value->postTime );
- }
- if ( $_SGLOBAL['timestamp'] - $value->postTime <= $animaltime[$value->cId][3] )
- {
- $status = 4;
- $statusNext = 5;
- $growTimeNext = $animaltime[$value->cId][3] - ( $_SGLOBAL['timestamp'] - $value->postTime );
- $totalCome -= $shop[$value->cId][output];
- }
- if ( $value->buyTime + $animaltime[$value->cId][5] - $animaltime[$value->cId][3] - $animaltime[$value->cId][4] < $_SGLOBAL['timestamp'] )
- {
- $status = 5;
- $statusNext = 6;
- $growTimeNext = $animaltime[$value->cId][5] - $time;
- }
- $newanimal[] = "{"buyTime":".$value->buyTime.","cId":".$value->cId.","growTime":".$time.","growTimeNext":".$growTimeNext.","hungry":0,"serial":".$key.","status":".$status.","statusNext":".$statusNext.","totalCome":".$totalCome."}";
- }
- }
- }
- $newanimal = json_encode( $newanimal );
- $newanimal = str_replace( ""{", "{", $newanimal );
- $newanimal = str_replace( "}"", "}", $newanimal );
- $newanimal = str_replace( "null", "[]", $newanimal );
- $animal[animalfood] = $animal[animalfood] - ( $_SGLOBAL['timestamp'] - $animal[animalfeedtime] ) / 3600 * $needfood / 4;
- if ( $animal[animalfood] < 0 )
- {
- $animal[animalfood] = 0;
- }
- if ( $animal[animalfood] == 0 )
- {
- $newanimal = str_replace( "\\"hungry\\":0", "\\"hungry\\":1", $newanimal );
- }
- $animal[animalfeedtime] = $_SGLOBAL['timestamp'];
- $stranimal = json_encode( $animal );
- $animal[animalfood] = floor( $animal[animalfood] );
- $touyes = ">";
- foreach ( $touarr as $key => $value )
- {
- if ( 0 < $value )
- {
- $touyes = $touyes.","".$key."":".$value."";
- }
- }
- $touyes = str_replace( ">,", "", $touyes );
- $touyes = str_replace( ">", "", $touyes );
- $_SGLOBAL['db']->query( "UPDATE ".tname( "plug_newfarm" )." set animal='".$stranimal."' where uid=".intval( $_REQUEST['uId'] ) );
- if ( $animal[item2] == 10220 )
- {
- $animal[item2] = "";
- }
- else
- {
- $animal[item2] = ""2":{"itemId":".$animal[item2]."},";
- }
- if ( $animal[item3] == 10330 )
- {
- $animal[item3] = "";
- }
- else
- {
- $animal[item3] = ""3":{"itemId":".$animal[item3]."},";
- }
- echo stripslashes( "{"animal":".$newanimal.","animalFood":".$animal[animalfood].","badinfo":[{"mynum":".$wenzi_mynum.","num":".$wenzi_num.","type":1}],"items":{"1":{"itemId":".$animal[item1]."},".$animal[item2].$animal[item3].""4":{"itemId":".$animal[item4]."}},"notice":"","serverTime":{"time":".$_SGLOBAL['timestamp']."},"stealflag":{".$touyes."},"task":{"taskFlag":1,"taskId":8},"user":{"exp":".$list[0][mc_exp].","headPic":"".avatar( $_SGLOBAL[supe_uid], "small", TRUE )."","money":".$list[0][money].","uId":".$_SGLOBAL['supe_uid'].","userName":"".$space[name]."","yellowlevel":7,"yellowstatus":0},"weather":{"weatherDesc":"晴天","weatherId":1}}" );
- exit( );
- }
- $query = $_SGLOBAL['db']->query( "SELECT money,animal,mc_exp,mc_taskid,wenzi FROM ".tname( "plug_newfarm" )." where uid=".$_SGLOBAL['supe_uid'] );
- while ( $value = $_SGLOBAL['db']->fetch_array( $query ) )
- {
- $list[] = $value;
- }
- $animal = ( array )json_decode( $list[0][animal] );
-
- //wenzi
- $wenzi_num=0;
- $wenzi_mynum=0;
- if ($list[0][wenzi]!=""){
- $wenzi = explode(",",$list[0][wenzi]);
- $wenzi_num = count($wenzi);
-
-
- }
-
-
- //wenzi
-
-
- $needfood = 0;
- foreach ( $animal[animal] as $key => $value )
- {
- if ( 0 < $value->cId )
- {
- $needfood += $shop[$value->cId][consum];
- if ( $value->postTime == 0 )
- {
- $time = $_SGLOBAL['timestamp'] - $value->buyTime;
- if ( $animaltime[$value->cId][0] + $animaltime[$value->cId][1] <= $time )
- {
- $status = 3;
- $growTimeNext = 12993;
- $statusNext = 6;
- }
- if ( $animaltime[$value->cId][0] <= $time && $time < $animaltime[$value->cId][0] + $animaltime[$value->cId][1] )
- {
- $status = 2;
- $growTimeNext = $animaltime[$value->cId][0] + $animaltime[$value->cId][1] - $time;
- $statusNext = 3;
- }
- if ( $time < $animaltime[$value->cId][0] )
- {
- $status = 1;
- $growTimeNext = $animaltime[$value->cId][0] - $time;
- $statusNext = 2;
- }
- if ( $animaltime[$value->cId][5] < $time )
- {
- $status = 6;
- $growTimeNext = 0;
- $statusNext = 6;
- }
- $newanimal[] = "{"buyTime":".$value->buyTime.","cId":".$value->cId.","growTime":".$time.","growTimeNext":".$growTimeNext.","hungry":0,"serial":".$key.","status":".$status.","statusNext":".$statusNext.","totalCome":".$value->totalCome."}";
- }
- else
- {
- $time = $_SGLOBAL['timestamp'] - $value->buyTime;
- $totalCome = $value->totalCome;
- if ( $animaltime[$value->cId][5] < $time )
- {
- $status = 6;
- $statusNext = 6;
- $growTimeNext = 0;
- }
- if ( $animaltime[$value->cId][4] < $_SGLOBAL['timestamp'] - $value->postTime )
- {
- $status = 3;
- $statusNext = 6;
- $growTimeNext = 12993;
- }
- if ( $_SGLOBAL['timestamp'] - $value->postTime <= $animaltime[$value->cId][4] )
- {
- $status = 5;
- $statusNext = 3;
- $growTimeNext = $animaltime[$value->cId][4] - ( $_SGLOBAL['timestamp'] - $value->postTime );
- }
- if ( $_SGLOBAL['timestamp'] - $value->postTime <= $animaltime[$value->cId][3] )
- {
- $status = 4;
- $statusNext = 5;
- $growTimeNext = $animaltime[$value->cId][3] - ( $_SGLOBAL['timestamp'] - $value->postTime );
- $totalCome -= $shop[$value->cId][output];
- }
- if ( $value->buyTime + $animaltime[$value->cId][5] - $animaltime[$value->cId][3] - $animaltime[$value->cId][4] < $_SGLOBAL['timestamp'] )
- {
- $status = 5;
- $statusNext = 6;
- $growTimeNext = $animaltime[$value->cId][5] - $time;
- }
- $newanimal[] = "{"buyTime":".$value->buyTime.","cId":".$value->cId.","growTime":".$time.","growTimeNext":".$growTimeNext.","hungry":0,"serial":".$key.","status":".$status.","statusNext":".$statusNext.","totalCome":".$totalCome."}";
- }
- }
- }
- $newanimal = json_encode( $newanimal );
- $newanimal = str_replace( ""{", "{", $newanimal );
- $newanimal = str_replace( "}"", "}", $newanimal );
- $newanimal = str_replace( "null", "[]", $newanimal );
- $animal[animalfood] = $animal[animalfood] - ( $_SGLOBAL['timestamp'] - $animal[animalfeedtime] ) / 3600 * $needfood / 4;
- if ( $animal[animalfood] < 0 )
- {
- $animal[animalfood] = 0;
- }
- if ( $animal[animalfood] == 0 )
- {
- $newanimal = str_replace( "\\"hungry\\":0", "\\"hungry\\":1", $newanimal );
- }
- $animal[animalfeedtime] = $_SGLOBAL['timestamp'];
- $stranimal = json_encode( $animal );
- $animal[animalfood] = floor( $animal[animalfood] );
- $_SGLOBAL['db']->query( "UPDATE ".tname( "plug_newfarm" )." set animal='".$stranimal."' where uid=".$_SGLOBAL['supe_uid'] );
- if ( $animal[item2] == 10220 )
- {
- $animal[item2] = "";
- }
- else
- {
- $animal[item2] = ""2":{"itemId":".$animal[item2]."},";
- }
- if ( $animal[item3] == 10330 )
- {
- $animal[item3] = "";
- }
- else
- {
- $animal[item3] = ""3":{"itemId":".$animal[item3]."},";
- }
- $taskFlag = 1;
- if ( $list[0][mc_taskid] == 10 )
- {
- $taskFlag = 0;
- }
- if ( $space['name'] == "" )
- {
- $space['name'] = $space['username'];
- }
- echo stripslashes( "{"animal":".$newanimal.","animalFood":".$animal[animalfood].","badinfo":[{"mynum":".$wenzi_mynum.","num":".$wenzi_num.","type":1}],"items":{"1":{"itemId":".$animal[item1]."},".$animal[item2].$animal[item3].""4":{"itemId":".$animal[item4]."}},"notice":"","serverTime":{"time":".$_SGLOBAL['timestamp']."},"stealflag":{},"task":{"taskFlag":".$taskFlag.","taskId":".$list[0][mc_taskid]."},"user":{"exp":".$list[0][mc_exp].","headPic":"".avatar( $_SGLOBAL[supe_uid], "small", TRUE )."","money":".$list[0][money].","uId":".$_SGLOBAL['supe_uid'].","userName":"".str_replace( "\\u", "\\\\u", unicode_encodegb( $space['name'] ) )."","yellowlevel":7,"yellowstatus":0},"weather":{"weatherDesc":"晴天","weatherId":1}}" );
- exit( );
- }
复制代码 在newmc.php 最下面加上两个过程:- if ( $_REQUEST['mod'] == "cgi_demolish_pasture" )
- {
- //这里主要是写接受数据并处理数据
- $query = $_SGLOBAL['db']->query( "SELECT money,mc_exp,bad FROM ".tname( "plug_newfarm" )." where uid=".$_SGLOBAL['supe_uid'] );
- while ( $value_me = $_SGLOBAL['db']->fetch_array( $query ) )
- {
- $list_me[] = $value_me;
- }
-
- if ($list_me[0][bad]>24){
- //此处输出使坏次数已满提示
- exit;
- }
- $query = $_SGLOBAL['db']->query( "SELECT money,mc_exp,wenzi FROM ".tname( "plug_newfarm" )." where uid=".intval( $_REQUEST['uId'] ) );
- while ( $value= $_SGLOBAL['db']->fetch_array( $query ) )
- {
- $list[] = $value;
- }
-
- $wenzi_num=0;
- $wenzi_mynum=0;
- $num=0;
- $wenzi_all=$list[0][wenzi];
- if ($wenzi_all!=""){
- $wenzi = explode(",",$list[0][wenzi]);
- $wenzi_num = count($wenzi);
- }
-
-
- if ((intval( $_REQUEST['num'] )+$wenzi_num)<9)
- {
- $num=intval( $_REQUEST['num']);
- }else{
- $num=8-$wenzi_num;
- }
-
- for ($i=0;$i<$num;$i++){
-
- if($wenzi_all=="")
- {
- $wenzi_all=$_SGLOBAL['supe_uid'];
- }else
- {
- $wenzi_all=$wenzi_all.",".$_SGLOBAL['supe_uid'];
- }
-
- }
-
-
-
- $_SGLOBAL['db']->query( "UPDATE ".tname( "plug_newfarm" )." set wenzi='".$wenzi_all."' where uid=".intval( $_REQUEST['uId'] ) );
-
- $_SGLOBAL['db']->query( "UPDATE ".tname( "plug_newfarm" )." set bad=bad+'".$num."' where uid=".$_SGLOBAL['supe_uid'] );
-
- echo "{"cId":1,"leftnum":11,"num":".$num.","total":".($wenzi_num+$num)."}" ;
-
- }
- //拍蚊子
- if ( $_REQUEST['mod'] == "cgi_help_pasture" )
- {
- //这里主要是写接受数据并处理数据
- $query = $_SGLOBAL['db']->query( "SELECT money,mc_exp,wenzi FROM ".tname( "plug_newfarm" )." where uid=".intval( $_REQUEST['uId'] ) );
- while ( $value = $_SGLOBAL['db']->fetch_array( $query ) )
- {
- $list[] = $value;
- }
- //wenzi
- $wenzi_num=0;
- $wenzi_mynum=0;
- if ($list[0][wenzi]!=""){
- $wenzi = explode(",",$list[0][wenzi],2);
- $wenzi_all =$wenzi[1];
- }
-
-
-
-
- $_SGLOBAL['db']->query( "UPDATE ".tname( "plug_newfarm" )." set wenzi='".$wenzi_all."' where uid=".intval( $_REQUEST['uId'] ) );
-
- $_SGLOBAL['db']->query( "UPDATE ".tname( "plug_newfarm" )." set mc_exp=mc_exp+4 where uid=".$_SGLOBAL['supe_uid'] );
- echo "{"addExp":4,"cId":1,"num":1,"pos":".$_REQUEST['pos']."}";
- }
复制代码 建立一个UCHOME任务,24小时清理一下所有用户的bad=0:- $_SGLOBAL['db']->query("UPDATE ".tname('plug_newfarm')." set bad=0 ");
复制代码 ------BY 残月
测试地址:http://www.80li.cn/home/
修改方法:http://www.80li.cn/bbs/
更新一下头像就可以获得10000积分,就可以换F币
相关工具和代码下载可加入以下群
QQ群号:30042275
------BY 残月
本人其他帖子:
【开心农场】牧场放蚊子BUG已完成--BY-残月 https://discuz.dismall.com/viewth ... p;extra=&page=1
【开心农场】牧场放蚊子BUG修复分析帖--BY-残月 https://discuz.dismall.com/thread-1464123-1-1.html
【本地农场】==【昼夜奋战解决了狗不咬人的问题】== https://discuz.dismall.com/thread-1462082-1-2.html
【本地农场】【unescape码加密与解密】https://discuz.dismall.com/thread-1460043-1-1.html
【开心农场】修复交流贴=【已修复牧场反复偷取的问题-】https://discuz.dismall.com/thread-1461663-1-1.html
【开心农场】牧场放蚊子BUG修复分析帖https://discuz.dismall.com/thread-1464123-1-1.html
【httpwatch6.0破解版下载】https://discuz.dismall.com/thread-1464257-1-1.html
实现附带版权的【站内日志转载】功能【增加了图片转载】https://discuz.dismall.com/thread-1451760-1-1.html |