function channelGetStatus($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 = channelGetLog($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"; $color = "green"; //scan lines for interesting things foreach ($lines as $line) { //check if we disconnected from battle.net if (strpos($line, 'disconnected from battle.net') !== false) { $posBegin = strpos($line, 'BNET: '); if ($posBegin !== false) { $realmBegin = $posBegin + 6; $posEnd = strpos($line, ']', $posBegin); if ($posEnd !== false) { $realm = substr($line, $realmBegin, $posEnd - $realmBegin); $error = "Disconnected from bnet/{$realm}"; //need to ensure this error wasn't added // because this could occur multiple times if (!in_array($error, $errors)) { $errors[] = $error; } } } } # cd keys in use? if (strpos($line, 'CD key in use') !== false) { $posBegin = strpos($line, 'BNET: '); if ($posBegin !== false) { $realmBegin = $posBegin + 6; $posEnd = strpos($line, ']', $posBegin); if ($posEnd !== false) { $realm = substr($line, $realmBegin, $posEnd - $realmBegin); $error = "CD keys in use on bnet/{$realm}"; //need to ensure this error wasn't added // because this could occur multiple times if (!in_array($error, $errors)) { $errors[] = $error; } } } } } # 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); if (time() - $time > 2400) { $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/channel.php"; if (isset($_SESSION['account_id']) && isset($_REQUEST['id']) && is_numeric($_REQUEST['id']) && isset($_SESSION['is_' . $_REQUEST['id'] . '_channel'])) { $log = channelGetLog($_REQUEST['id']); get_page("log", "channel", array('service_id' => $_REQUEST['id'], 'log' => $log)); } else { header("Location: ../panel/"); }