diff --git a/webapp/controller/TempToolsController.class.php b/webapp/controller/TempToolsController.class.php new file mode 100644 index 00000000..832acbf0 --- /dev/null +++ b/webapp/controller/TempToolsController.class.php @@ -0,0 +1,176 @@ +_getMysql($targetId); + $data = array(); + $survivalTime = 0; + $sameTimes = 0; + $sessionChgTimes = 0; + { + $rows = SqlHelper::ormSelect( + $conn, + 't_battle_record', + array( + 'account_id' => $targetId + ) + ); + foreach ($rows as $row) { + $reqObj = json_decode($row['request'], true); + $reqObj['start_time'] = $reqObj['game_time'] - + $reqObj['alive_time']/1000; + $survivalTime += $reqObj['alive_time']/1000; + array_push($data, $reqObj); + } + } + usort($data, function ($a, $b) { + return $a['start_time'] < $b['start_time'] ? -1 : 1; + }); + $lastSessionId = ''; + { + for ($i = 0; $i < count($data); ++$i){ + if ($i + 1 >= count($data)) { + break; + } + if ($data[$i]['start_time'] + $time > $data[$i + 1]['start_time']) { + ++$i; + ++$sameTimes; + } + if ($lastSessionId) { + if ($lastSessionId != $data[$i]['session_id']) { + ++$sessionChgTimes; + $lastSessionId = $data[$i]['session_id']; + } + } else { + $lastSessionId = $data[$i]['session_id']; + } + } + } + myself()->_rspData(array( + 'battle_times' => count($data), + 'same_times' => $sameTimes, + 'session_chg_times' => $sessionChgTimes, + 'survival_time' => $survivalTime, + 'data' => $data + )); + } + + public function exportRankActivity() + { + $type = getReqVal('type', ''); + $count = getReqVal('count', ''); + $accounts = array(); + $conn = myself()->_getMysql(''); + { + $count = 1000; + $rows = $conn->execQuery( + 'SELECT * FROM t_rank_activity ' . + 'WHERE type=:type AND channel=:channel AND value>=:value ' . + 'ORDER BY value DESC, modifytime ASC ' . + "LIMIT ${count}", + array( + ':type' => $type, + ':channel' => 6516, + ':value' => 600 + ) + ); + $ranked = 1; + foreach ($rows as $row) { + array_push($accounts, array( + 'account_id' => $row['account_id'], + 'name' => '', + 'ranked' => $ranked + )); + ++$ranked; + } + } + { + foreach ($accounts as &$account) { + $row = SqlHelper::ormSelectone( + $conn, + 't_user', + array( + 'account_id' => $account['account_id'] + ) + ); + $account['name'] = $row['name']; + } + } + echo 'account_id,name,rank' . "\n"; + foreach ($accounts as $account) { + echo $account['account_id'] . ',' . $account['name'] . ',' . $account['ranked'] . "\n"; + } + } + + public function getRiskAccounts() + { + $accounts = array(); + $conn = myself()->_getMysql(''); + { + $count = 1000; + $rows = $conn->execQuery( + 'SELECT * FROM t_rank_activity ' . + 'WHERE type=:type AND channel=:channel AND value>=:value ' . + 'ORDER BY value DESC, modifytime ASC ' . + "LIMIT ${count}", + array( + ':type' => 1, + ':channel' => 6516, + ':value' => 600 + ) + ); + $ranked = 1; + foreach ($rows as $row) { + array_push($accounts, array( + 'account_id' => $row['account_id'], + 'ranked' => $ranked + )); + ++$ranked; + } + } + $riskAccountHash = array(); + foreach ($accounts as $account) { + $rows = SqlHelper::ormSelect( + $conn, + 't_battle_record', + array( + 'account_id' => $account['account_id'] + ) + ); + $sessionChgTimes = 0; + $lastSessionId = ''; + foreach ($rows as $row) { + $reqObj = json_decode($row['request'], true); + if ($lastSessionId) { + if ($lastSessionId != $reqObj['session_id']) { + ++$sessionChgTimes; + $lastSessionId = $reqObj['session_id']; + } + } else { + $lastSessionId = $reqObj['session_id']; + } + } + $account['session_changed_times'] = $sessionChgTimes; + array_push($riskAccountHash, $account); + } + usort($riskAccountHash, function ($a, $b) { + return $a['session_changed_times'] > $b['session_changed_times'] ? -1 : 1; + }); + echo 'account_id,rank,session_changed_times' . "\n"; + foreach ($riskAccountHash as $account) { + echo $account['account_id'] . ',' . $account['ranked'] . ',' . $account['session_changed_times'] . "\n"; + } + } + +}