Esempio n. 1
0
 public function command()
 {
     // Por si entra sin permiso
     if (!hasRank('Moderador', $this->registry->userdata[User::RANK])) {
         echo 'No tienes permiso para hacer eso, listillo ¬_¬';
         return;
     }
     $ws = new Websend('127.0.0.1');
     if ($ws->connect()) {
         $command = isset($_POST['command']) ? $_POST['command'] : '';
         $ws->doCommandAsConsole($command);
         echo 0;
     }
     $ws->disconnect();
 }
Esempio n. 2
0
/**
 * Executes a command without the initiation of Websend
 * always does this as the console since no user initiating it.
 *.
 * @param type $cmd
 * @param type $how (asConsole (default), asPlayer, toConsole, toPlayer, broadcast, doScript
 * @param type $player
 */
function umc_exec_command($cmd, $how = 'asConsole', $player = false)
{
    global $UMC_PATH_MC;
    XMPP_ERROR_trace(__FUNCTION__, func_get_args());
    umc_log('websend', 'outgoing', "{$cmd} {$how} to {$player}");
    require_once "{$UMC_PATH_MC}/server/bin/includes/websend_class.php";
    $ws = new Websend("74.208.45.80");
    //, 4445
    $ws->password = "******";
    if (!$ws->connect()) {
        // try again
        $ws = new Websend("74.208.45.80");
        //, 4445
        $ws->password = "******";
        if (!$ws->connect()) {
            // fail agin? bail.
            XMPP_ERROR_trigger("Could not connect to websend server (umc_exec_command / {$cmd} / {$how} / {$player})");
        }
    }
    // $ws->writeOutputToConsole("starting ws communication;");
    // $ws->writeOutputToConsole("Executing Command '$cmd' Method '$how' Player '$player';");
    switch ($how) {
        case 'asConsole':
            $check = $ws->doCommandAsConsole($cmd);
            break;
        case 'asPlayer':
            $check = $ws->doCommandAsPlayer($cmd, $player);
            break;
        case 'toConsole':
            $check = $ws->writeOutputToConsole($cmd);
            break;
        case 'toPlayer':
            $check = $ws->writeOutputToPlayer($cmd, $player);
            break;
        case 'broadcast':
            $check = $ws->broadcast($cmd);
            break;
        case 'doScript':
            $check = $ws->doScript($cmd);
            break;
    }
    if (!$check) {
        XMPP_ERROR_trigger("Could not verify correct connection to websend (umc_exec_command / {$cmd} / {$how} / {$player})");
    } else {
        //echo "nah.";
        //$check = $ws->writeOutputToConsole("error");
    }
    $ws->disconnect();
}
function umc_ws_connect()
{
    XMPP_ERROR_trace(__FUNCTION__, func_get_args());
    global $UMC_PATH_MC;
    require_once "{$UMC_PATH_MC}/server/bin/includes/websend_class.php";
    $ws = new Websend("74.208.45.80");
    //, 4445
    $password = file_get_contents("/home/includes/certificates/websend_code.txt");
    $ws->password = $password;
    if (!$ws->connect()) {
        // try again
        XMPP_ERROR_trace("websend Auth failed (attempt 1, trying again)", "none");
        $ws = new Websend("74.208.45.80");
        //, 4445
        $ws->password = $password;
        if (!$ws->connect()) {
            // fail agin? bail.
            XMPP_ERROR_trigger("Could not connect to websend server (umc_exec_command)");
            return false;
        }
    }
    return $ws;
}
Esempio n. 4
0
<?php

require_once 'Websend.php';
$ws = new Websend("123.456.789.123");
$ws->password = "******";
if ($ws->connect()) {
    $ws->doCommandAsConsole("time set 6000");
    echo "Time set.";
} else {
    echo "Failed to connect.";
}
$ws->disconnect();