Esempio n. 1
0
         // and as we do the client is still untrusted, this will probably never happen.
         // Could be used to increase trustlevel from level 1 to level 2
         //
         $log->lwrite("main:: login request: " . $data['login'] . ", password" . $data['password'], 1);
         break;
         // Client can send a number of supported "console" messages. Console messages are recognized
         // and return values sent back to the calling GUI client.
         // Supported messages are for logfile inspection, listing connected clients, reset saemon etc etc
     // Client can send a number of supported "console" messages. Console messages are recognized
     // and return values sent back to the calling GUI client.
     // Supported messages are for logfile inspection, listing connected clients, reset saemon etc etc
     case "console":
         // Handling of LamPI operation. Fields:
         // action=="console", request=="clients","logs",
         $log->lwrite("main:: Received console message: " . $data['action'] . ", request: " . $data['request'], 2);
         $list = console_message($data['request']);
         $response = array('tcnt' => $tcnt . "", 'type' => 'raw', 'action' => 'console', 'request' => $data['request'], 'response' => $list);
         if (false === ($message = json_encode($response))) {
             $log->lwrite("ERROR main:: json_encode failed: <" . $response['tcnt'] . ", " . $response['action'] . ">", 0);
         }
         $log->lwrite("Json encoded console: " . $response['response'], 2);
         if ($sock->s_send($message) == -1) {
             $log->lwrite("ERROR main:: failed writing login message on socket", 1);
             continue;
         }
         $log->lwrite("main:: writing console message on socket OK", 2);
         break;
     default:
         $log->lwrite("ERROR main:: json data action: " . $data['action'] . ", type: <" . $data['type'] . "> not found using raw message", 0);
         $cmd = $data['message'];
 }
/**
 * Sends request to the host
 *
 * @param string $host
 * @return string bool if host is available, otherwise false
 */
function host_test($host)
{
    print console_message("Sending request to the host \"{$host}\".", CONSOLE_MESSAGE_INFO);
    $success = file_get_contents($host) !== false;
    if ($success) {
        print console_message("Hostname \"{$host}\" is available.", CONSOLE_MESSAGE_SUCCESS);
    } else {
        print console_message("Can't get access to the \"{$host}\".", CONSOLE_MESSAGE_ERROR);
    }
    return $success;
}