function garenaGetStatus($service_id) { global $config; //get the identifier $id = stripAlphaNumeric(getServiceParam($service_id, "id")); if ($id === false) { return array('status' => "ERROR: failed to find bot identifier", 'err' => array(), 'color' => 'red'); } //read last lines of the log file and scan for interesting things $lines = garenaGetLog($service_id, 1000); if (empty($lines)) { return array('status' => "Failed to read log file", 'err' => array(), 'color' => 'red'); } $lastline = $lines[count($lines) - 1]; $errors = array(); $status = "Up, no activity"; $color = "orange"; //scan lines for interesting things foreach ($lines as $line) { # check if user has joined game recently if (strpos($line, 'Starting TCP') !== false) { $status = "Good"; $color = "green"; } } # check last line to see if the bot is still running $posBegin = strpos($lastline, '['); if ($posBegin !== false) { $posEnd = strpos($lastline, ']', $posBegin); if ($posEnd !== false) { $strTime = substr($lastline, $posBegin + 1, $posEnd - $posBegin - 1); $time = strtotime($strTime); $time2 = strtotime($strTime . " UTC"); //sometimes gcb output might not be system timezone if (abs(time() - $time) > 1200 && abs(time() - $time2) > 1200) { $status = "Down"; $errors[] = "Does not appear to be running!"; $color = "red"; } } } return array('status' => $status, 'err' => $errors, 'color' => $color); }
<?php include "../include/common.php"; include "../config.php"; include "../include/session.php"; include "../include/dbconnect.php"; include "../include/account.php"; include "../include/garena.php"; if (isset($_SESSION['account_id']) && isset($_REQUEST['id']) && is_numeric($_REQUEST['id']) && isset($_SESSION['is_' . $_REQUEST['id'] . '_garena'])) { $log = garenaGetLog($_REQUEST['id']); get_page("log", "garena", array('service_id' => $_REQUEST['id'], 'log' => $log)); } else { header("Location: ../panel/"); }