示例#1
0
文件: ami-fns.php 项目: rkania/GS3
 public function ami_login($username, $password, $host, $port)
 {
     $this->_socket = fSockOpen($host, $port, $err, $errmsg, 2);
     if (!$this->_check_socket()) {
         gs_log(GS_LOG_WARNING, 'Connection to AMI on ' . $host . ' failed');
         return false;
     }
     # check: is AMI?
     $tStart = time();
     $data = '';
     while (!fEof($this->_socket) && time() < $tStart + 3) {
         $data .= @fRead($this->_socket, 8192);
         if (@preg_match('/[\\r\\n]/', $data)) {
             break;
         }
         usleep(1000);
         # sleep 0.001 secs
     }
     if (!preg_match('/^Asterisk [^\\/]+\\/(\\d(?:\\.\\d)?)/mis', $data, $m)) {
         gs_log(GS_LOG_WARNING, 'Incompatible Asterisk Manager Interface on ' . $host);
         $m = array(1 => '0.0');
     } else {
         if ($m[1] > '1.1') {
             # Asterisk 1.4: manager 1.0
             # Asterisk 1.6: manager 1.1
             gs_log(GS_LOG_WARNING, 'Asterisk manager interface on ' . $host . ' speaks a new protocol version (' . $m[1] . ')');
             # let's try anyway and hope to understand it
         }
         $req = 'Action: Login' . "\r\n" . 'Username: '******'Secret: ' . $password . "\r\n" . 'Events: off' . "\r\n" . "\r\n";
         $data = $this->ami_send_command($req);
         if (strToLower($data['Message']) !== 'authentication accepted') {
             gs_log(GS_LOG_WARNING, 'Authentication to AMI on ' . $host . ' failed');
             return false;
         }
     }
     return true;
 }
示例#2
0
 function getSize($lpszFileName, &$width, &$height)
 {
     if (!($fh = @fOpen($lpszFileName, "rb"))) {
         return false;
     }
     $data = @fRead($fh, @fileSize($lpszFileName));
     @fClose($fh);
     $gfh = new CGIFFILEHEADER();
     if (!$gfh->load($data, $len = 0)) {
         return false;
     }
     $width = $gfh->m_nWidth;
     $height = $gfh->m_nHeight;
     return true;
 }
示例#3
0
文件: proxy.php 项目: rkania/GS3
}
@stream_set_blocking($sock, false);
$tStart = time();
$cnt_no_data = 0;
$buf = '';
echo $html_start;
echo $msg_open;
echo 'e("");', "\n";
# everything is fine
echo $msie_pad;
echo $msg_close;
@ob_flush();
@flush();
//$db = gs_db_slave_connect();
while (!@fEof($sock) && time() < $tStart + $maxtime) {
    $data = @fRead($sock, 8190);
    if (strLen($data) > 0) {
        $cnt_no_data = 0;
        $buf .= $data;
    } else {
        if (++$cnt_no_data > 250) {
            # we sleep 0.02 secs so this is 5 secs
            echo $html_end;
            @ob_flush();
            @flush();
            exit(0);
        }
    }
    while (preg_match('/=====/S', $buf, $m, PREG_OFFSET_CAPTURE)) {
        $pos = (int) @$m[0][1];
        $msg = subStr($buf, 0, $pos);
示例#4
0
function _sock_read($sock, $timeout, $stop_regex)
{
    if (!is_resource($sock)) {
        return false;
    }
    @stream_set_blocking($sock, false);
    //stream_set_timeout( $sock, 5 );  // not really used here
    $tStart = time();
    $data = '';
    while (!@fEof($sock) && time() < $tStart + $timeout) {
        $data .= @fRead($sock, 8192);
        if (@preg_match($stop_regex, $data)) {
            break;
        }
        uSleep(1000);
        # sleep 0.001 secs
    }
    if ($data === '') {
        # assume timeout
        return false;
    }
    return $data;
}
示例#5
0
function readDataFile($data_file)
{
    global $node;
    $datafilep = @fOpen($data_file, 'rb');
    if (!$datafilep) {
        write_log("Cannot open {$data_file} for reading! Using cluster data from configuration. This will reset *all* states!");
        return 1;
    }
    $datafilesize = fileSize($data_file);
    $save_struct = @fRead($datafilep, $datafilesize);
    $node = unSerialize($save_struct);
    fClose($datafilep);
}
 private function streamRead($length)
 {
     $result = fRead($this->fp, $length);
     if ($result === false) {
         throw new TSimpleHttpClientException('streamread_failed', $this->getHost(), $this->getPort(), $this->getPath());
     }
     return $result;
 }
示例#7
0
//toilet -f mono12  Linux
$boxes = '|boxes -d santa';
//boxes -d <boxid>
$cusfuncshell = 'echo "Your Message here"|boxes';
//justom function what you want. JUST TERMINAL CODES like echo "some think" or "cd /somedir" etc.
###############################################################
$cusfunc = "  " . $cusfuncshell;
###############################################################
//PocketControl
$control1 = shell_exec("dpkg -s figlet");
if (strstr($control1, "install ok installed")) {
    $control2 = shell_exec("dpkg -s boxes");
    if (strstr($control2, "install ok installed")) {
        //Bashrc Control
        $dosya_ici = fOpen("/root/.bashrc", "r");
        $dosya_oku = fRead($dosya_ici, fileSize("/root/.bashrc"));
        fClose($dosya_ici);
        //somecommands
        $whoami = shell_exec("whoami");
        $say = count($_SERVER['argv']);
        $argum = $_SERVER['argv'];
        if (strstr($dosya_oku, "php CusTerm.php", true)) {
            ###############################################################
            if (@$argum[1] == "--help") {
                echo "yardım mı lazımdır?";
                exit;
            }
            if ($ne == "standard") {
                $nick = exec("whoami");
                echo $figlet = shell_exec($figlet . " " . $nick . $boxes);
                echo $customch = shell_exec($cusfunc);
示例#8
0
文件: tivoli.php 项目: rkania/GS3
function tivoli_http_request()
{
    global $scheme, $host, $port, $timeout, $sessionName;
    /*
    echo "<pre>";
    print_r($_SERVER);
    print_r($_FILES);
    echo "</pre>";
    */
    if (is_array($_FILES) && count($_FILES) > 0) {
        $errout = 'File uploads cannot be handled by the WebSeal simulation script.';
    } else {
        $errout = '';
    }
    $postVals = array();
    if ($_SERVER['REQUEST_METHOD'] == 'POST') {
        foreach ($_POST as $k => $v) {
            if (subStr($k, 0, 10) != '_x_tivoli_') {
                $postVals[] = urlEncode($k) . '=' . urlEncode($v);
            }
        }
    }
    $postData = implode('&', $postVals);
    $headers = array();
    foreach ($_SERVER as $k => $v) {
        if (subStr($k, 0, 5) == 'HTTP_') {
            $k = strToLower(str_replace('_', '-', subStr($k, 5)));
            $headers[$k] = $v;
        }
    }
    $headers['accept-encoding'] = 'identity';
    $headers['connection'] = 'close';
    $headers['host'] = $host . ':' . $port;
    unset($headers['keep-alive']);
    $headers['iv-user'] = $_SESSION['user'];
    if ($_SERVER['REQUEST_METHOD'] == 'POST') {
        $headers['content-type'] = 'application/x-www-form-urlencoded';
        $headers['content-length'] = strLen($postData);
    }
    if (isset($headers['cookie'])) {
        $headers['cookie'] = preg_replace('/' . $sessionName . '=[^\\s]*/', '', $headers['cookie']);
    }
    if (isset($headers['referer'])) {
        $headers['referer'] = str_replace('http://' . $_SERVER['HTTP_HOST'] . '/', 'http://' . $host . ':' . $port . '/', $headers['referer']);
        if ($port == 80) {
            $headers['referer'] = str_replace(':80', '', $headers['referer']);
        }
    }
    $req = $_SERVER['REQUEST_METHOD'] . ' ' . $_SERVER['REQUEST_URI'] . ' HTTP/1.0' . "\r\n";
    foreach ($headers as $k => $v) {
        $req .= ucWords($k) . ': ' . $v . "\r\n";
    }
    $req .= "\r\n";
    if ($_SERVER['REQUEST_METHOD'] == 'POST') {
        $req .= $postData;
    }
    unset($headers);
    $sock = @fSockOpen('tcp://' . $host, $port, $err, $errMsg, $timeout);
    if (!$sock) {
        echo "Could not connect to host {$host}, port {$port}\n";
        return false;
    }
    fWrite($sock, $req, strLen($req));
    unset($req);
    $response = '';
    while (!fEof($sock)) {
        $response .= fRead($sock, 10000);
    }
    my_http_handle_response($response, $errout);
}
示例#9
0
文件: gif.php 项目: hugcoday/wiki
 function getSize($lpszFileName, &$width, &$height)
 {
     if (!($fh = @fOpen($lpszFileName, "rb"))) {
         return false;
     }
     $data = @fRead($fh, @fileSize($lpszFileName));
     @fClose($fh);
 }
 function getLastClassUpdateDate()
 {
     $line = "";
     if (file_exists(dirname(__FILE__) . "/config/lastclassupdate.tmp")) {
         $lcuFile = fOpen(dirname(__FILE__) . "/config/lastclassupdate.tmp", "r+");
         $line = fRead($lcuFile, 8);
     }
     return $line;
 }