{ global $tbl_serv_db, $tbl_game_server, $tbl_gm_db; $dbinfo = $tbl_serv_db[$serv_id]; $Conn = mysql_connect($dbinfo[2], $dbinfo[0], $dbinfo[1]); mysql_select_db($dbinfo[3], $Conn); $qs = "select sum(cm_uMoney) s1, sum(cm.cm_uBindingMoney) s2, count(*) c from tbl_char_onlinetime co, tbl_char_money cm where co.cs_uId = cm.cs_uId and co.co_dtLastLoginTime > addDate(now(), interval -3 day) having (s1/c) > {$money_max} or (s2/c) > {$binding_max}"; $result = mysql_query($qs); if (!$result) { echo mysql_error() . "\n"; } $dbinfo = $tbl_gm_db[0]; $Conn = mysql_connect($dbinfo[2], $dbinfo[0], $dbinfo[1]); mysql_select_db($dbinfo[3], $Conn); while ($row = mysql_fetch_row($result)) { mysql_query("insert into tbl_server_money_warning values('" . date("Y-m-d h:i:s") . "','{$serv_id}','{$row['2']}','{$row['0']}','{$row['1']}')"); echo date("Y-m-d h:i:s") . "\t" . $tbl_game_server[$serv_id][2] . "\t" . $row[2] . "\t" . $row[0] . "\t" . $row[0] / $row[2] . "\t" . $row[1] . "\t" . $row[1] / $row[2] . "\n"; } mysql_close($Conn); } if (count($argv) == 3) { global $tbl_serv_db; foreach ($tbl_serv_db as $serv => $dbinfo) { MainFun($serv, $argv[1], $argv[2]); } } else { if (count($argv) == 4) { MainFun($argv[1], $argv[2], $argv[3]); } else { echo "Argv error"; } }
$qs = "select le_dtDateTime from tbl_log_event where le_uId = {$max_le} and le_uServerId = {$server_id}"; $result = mysql_query($qs); if (!$result) { echo mysql_error() . "\n"; } if ($row = mysql_fetch_row($result)) { $max_dt = $row[0]; } else { return false; } $qs = "select lm.lcs_uId, sum(lm.lm_uMoney) s, count(*) c from tbl_log_money lm, tbl_log_event le, tbl_log_event_type let where lm.le_uId = le.le_uId and lm.le_uServerId = le.le_uServerId and let.le_uId = le.le_uId and let.le_uServerId = le.le_uServerId and lm.lm_uMoney > 0 and let.let_uEventType in (2,78,42,84,159,126) and le.le_uServerId = {$server_id} and le.le_dtDateTime > DATE_SUB('{$max_dt}', INTERVAL {$time_step} MINUTE) group by lm.lcs_uId having s > {$max_money} and c > {$max_times}"; $result = mysql_query($qs); if (!$result) { echo mysql_error() . "\n"; } $dbinfo = $tbl_gm_db[0]; $Conn = mysql_connect($dbinfo[2], $dbinfo[0], $dbinfo[1]); mysql_select_db($dbinfo[3], $Conn); while ($row = mysql_fetch_row($result)) { $ret = mysql_query("insert into tbl_output_money_warning values('{$max_dt}','{$server_id}','{$row['0']}',null,'{$row['1']}','{$row['2']}')"); if (!$ret) { echo mysql_error(); } printf("报警时间:%s\t角色ID:%s\t产出金额:%d\t产出次数:%d\n", $max_dt, $row[0], $row[1], $row[2]); } mysql_close($Conn); return true; } if (!MainFun($argv[1], $argv[2], $argv[3], $argv[4])) { echo "ERROR"; }
echo mysql_error(); } $where = array(); echo "This will remove all logs created before follow lines each servers.\n"; while ($row = mysql_fetch_row($rs)) { echo "Server ID: " . $row[0] . "\tDate: " . $row[2] . "\n"; array_push($where, "(le_userverId = " . $row[0] . " and le_uId < " . $row[1] . ")"); } echo "\n"; if (count($where) == 0) { return; } $where = implode(" or ", $where); $file = fopen("CleanLog.txt", "r"); while (!feof($file)) { $table = fgets($file); if ($table == "") { continue; } $qs = "delete from {$table} where {$where}"; $rs = mysql_query($qs); if (!$rs) { echo "Faile! Table '{$table}'"; echo "==>" . mysql_error() . "\n"; } else { printf("Success! Remove %d rows\t from table %s", mysql_affected_rows(), $table); } } } MainFun($argv[1]);