Beispiel #1
0
/**
 */
function getServerStatus()
{
    $cfg = EasySCP_Registry::get('Config');
    $tpl = EasySCP_TemplateEngine::getInstance();
    $easyscp_status = new status();
    $sql_query = "\n\t    SELECT\n\t\t\t*\n\t\tFROM\n\t\t\tconfig\n\t\tWHERE\n\t\t\tname LIKE 'PORT_%'\n\t\tORDER BY\n\t\t\tname ASC\n\t";
    // Dynamic added Ports
    foreach (DB::query($sql_query) as $row) {
        $value = count(explode(";", $row['value'])) < 6 ? $row['value'] . ';' : $row['value'];
        list($port, $protocol, $name, $status, , $ip) = explode(";", $value);
        if ($status) {
            $easyscp_status->addService($ip == '127.0.0.1' ? 'localhost' : (empty($ip) ? $cfg->BASE_SERVER_IP : $ip), (int) $port, $name, $protocol);
        }
    }
    $easyscp_status->checkStatus(5);
    $data = $easyscp_status->getStatus();
    $up = tr('UP');
    $down = tr('DOWN');
    // $easyscp_status->addService('localhost', 9875, 'EasySCP Controller', 'tcp');
    if (file_exists(EasyConfig::$cfg->SOCK_EASYSCPC)) {
        $img = $up;
        $class = "content up";
    } else {
        $img = $down;
        $class = "content down";
    }
    $tpl->append(array('HOST' => 'localhost', 'PORT' => '0', 'SERVICE' => 'EasySCP Controller', 'STATUS' => $img, 'CLASS' => $class));
    // $easyscp_status->addService('localhost', 9876, 'EasySCP Daemon', 'tcp');
    if (file_exists(EasyConfig::$cfg->SOCK_EASYSCPD)) {
        $img = $up;
        $class = "content up";
    } else {
        $img = $down;
        $class = "content down";
    }
    $tpl->append(array('HOST' => 'localhost', 'PORT' => '0', 'SERVICE' => 'EasySCP Daemon', 'STATUS' => $img, 'CLASS' => $class));
    for ($i = 0, $cnt_data = count($data); $i < $cnt_data; $i++) {
        if ($data[$i]['status']) {
            $img = $up;
            $class = "content up";
        } else {
            $img = $down;
            $class = "content down";
        }
        if ($data[$i]['port'] == 23) {
            // 23 = telnet
            if ($data[$i]['status']) {
                $class = 'content2 down';
                $img = $up;
            } else {
                $class = 'content2 up';
                $img = $down;
            }
        }
        $tpl->append(array('HOST' => $data[$i]['ip'], 'PORT' => $data[$i]['port'], 'SERVICE' => tohtml($data[$i]['service']), 'STATUS' => $img, 'CLASS' => $class));
    }
}