var $use_usleep=0; // change to 1 for faster execution // don't change to 1 on Windows servers unless you have PHP 5 " /> 青青成人福利国产在线视频,在线免费观看视频黄,成人3p视频免费

一区二区久久-一区二区三区www-一区二区三区久久-一区二区三区久久精品-麻豆国产一区二区在线观看-麻豆国产视频

php實現(xiàn)telnet功能示例

復制代碼 代碼如下:
<?php
class phpTelNET {
    var $show_connect_error=1;

    var $use_usleep=0;  // change to 1 for faster execution
        // don't change to 1 on Windows servers unless you have php 5
    var $sleeptime=125000;
    var $loginsleeptime=1000000;

    var $fp=NULL;
    var $loginprompt;

    var $conn1;
    var $conn2;

    /*
    0 = success
    1 = couldn't open NETwork connection
    2 = unknown host
    3 = login failed
    4 = php version too low
    */
    function Connect($server,$user,$pass) {
        $rv=0;
        $vers=explode('.',php_VERSION);
        $needvers=array(4,3,0);
        $j=count($vers);
        $k=count($needvers);
        if ($k<$j) $j=$k;
        for ($i=0;$i<$j;$i++) {
            if (($vers[$i]+0)>$needvers[$i]) break;
            if (($vers[$i]+0)<$needvers[$i]) {
                $this->ConnectError(4);
                return 4;
            }
        }

        $this->Disconnect();

        if (strlen($server)) {
            if (preg_match('/[^0-9.]/',$server)) {
                $ip=gethostbyname($server);
                if ($ip==$server) {
                    $ip='';
                    $rv=2;
                }
            } else $ip=$server;
        } else $ip='127.0.0.1';

        if (strlen($ip)) {
            if ($this->fp=fsockopen($ip,23)) {
                fputs($this->fp,$this->conn1);
                $this->Sleep();

                fputs($this->fp,$this->conn2);
                $this->Sleep();
                $this->GetResponse($r);
                $r=explode("/n",$r);
                $this->loginprompt=$r[count($r)-1];

                fputs($this->fp,"$user/n");
                $this->Sleep();

                fputs($this->fp,"$pass/n");
                if ($this->use_usleep) usleep($this->loginsleeptime);
                else sleep(1);
                $this->GetResponse($r);
                $r=explode("/n",$r);
                if (($r[count($r)-1]=='')||($this->loginprompt==$r[count($r)-1])) {
                    $rv=3;
                    $this->Disconnect();
                }
            } else $rv=1;
        }

        if ($rv) $this->ConnectError($rv);
        return $rv;
    }

    function Disconnect($exit=1) {
        if ($this->fp) {
            if ($exit) $this->DoCommand('exit',$junk);
            fclose($this->fp);
            $this->fp=NULL;
        }
    }

    function DoCommand($c,&$r) {
        if ($this->fp) {
            fputs($this->fp,"$c/n");
            $this->Sleep();
            $this->GetResponse($r);
            $r=preg_replace("/^.*?/n(.*)/n[^/n]*$/","$1",$r);
        }
        return $this->fp?1:0;
    }

    function GetResponse(&$r) {
        $r='';
        do {
            $r.=fread($this->fp, 1024);
            $s=socket_get_status($this->fp);
        } while ($s['unread_bytes']);
    }

    function Sleep() {
        if ($this->use_usleep) usleep($this->sleeptime);
        else sleep(1);
    }

    function phpTelNET() {
        $this->conn1=chr(0xFF).chr(0xFB).chr(0x1F).chr(0xFF).chr(0xFB).
            chr(0x20).chr(0xFF).chr(0xFB).chr(0x18).chr(0xFF).chr(0xFB).
            chr(0x27).chr(0xFF).chr(0xFD).chr(0x01).chr(0xFF).chr(0xFB).
            chr(0x03).chr(0xFF).chr(0xFD).chr(0x03).chr(0xFF).chr(0xFC).
            chr(0x23).chr(0xFF).chr(0xFC).chr(0x24).chr(0xFF).chr(0xFA).
            chr(0x1F).chr(0x00).chr(0x50).chr(0x00).chr(0x18).chr(0xFF).
            chr(0xF0).chr(0xFF).chr(0xFA).chr(0x20).chr(0x00).chr(0x33).
            chr(0x38).chr(0x34).chr(0x30).chr(0x30).chr(0x2C).chr(0x33).
            chr(0x38).chr(0x34).chr(0x30).chr(0x30).chr(0xFF).chr(0xF0).
            chr(0xFF).chr(0xFA).chr(0x27).chr(0x00).chr(0xFF).chr(0xF0).
            chr(0xFF).chr(0xFA).chr(0x18).chr(0x00).chr(0x58).chr(0x54).
            chr(0x45).chr(0x52).chr(0x4D).chr(0xFF).chr(0xF0);
        $this->conn2=chr(0xFF).chr(0xFC).chr(0x01).chr(0xFF).chr(0xFC).
            chr(0x22).chr(0xFF).chr(0xFE).chr(0x05).chr(0xFF).chr(0xFC).chr(0x21);
    }

    function ConnectError($num) {
        if ($this->show_connect_error) switch ($num) {
        case 1: echo '<br />[php TelNET] <a href="http://www.jb51.NET/php-telNET/errors/fsockopen.php">Connect failed: Unable to open NETwork connection</a><br />'; break;
        case 2: echo '<br />[php TelNET] <a href="http://www.jb51.NET/php-telNET/errors/unknown-host.php">Connect failed: Unknown host</a><br />'; break;
        case 3: echo '<br />[php TelNET] <a href="http://www.jb51.NET/php-telNET/errors/login.php">Connect failed: Login failed</a><br />'; break;
        case 4: echo '<br />[php TelNET] <a href="http://www.jb51.NET/php-telNET/errors/php-version.php">Connect failed: Your server/'s php version is too low for php TelNET</a><br />'; break;
        }
    }
}

?>

php技術php實現(xiàn)telnet功能示例,轉(zhuǎn)載需保留來源!

鄭重聲明:本文版權歸原作者所有,轉(zhuǎn)載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯(lián)系我們修改或刪除,多謝。

主站蜘蛛池模板: 在线不卡亚洲 | 91久久青青草原线免费 | 色婷婷香蕉| 狠狠色噜噜狠狠狠米奇9999 | 欧美在线色| 黄色大片网站在线观看 | 国产精品欧美在线不卡 | 久久精品国产线看观看亚洲 | 久久婷婷影院 | 国产男人女人做性全过程视频 | 亚洲妇人成熟性成熟网站 | 久久麻豆亚洲精品 | 91精品国产麻豆国产自产在线 | 欧美a级片免费看 | 欧美激情中文字幕一区二区 | 久久精品国产99精品最新 | 国产福利精品一区二区 | 久久福利青草狠狠午夜 | 91大神精品长腿在线观看网站 | 五月六月婷婷 | 337p欧洲大胆扒开图片 | 日韩中文字幕免费版 | 99久久精品国语对白 | 手机偷拍视频 | 亚洲一区不卡视频 | 中文字幕亚洲国产 | 免费国产午夜高清在线视频 | 欧美一区二区精品 | 欧美精品v日韩精品v国产精品 | 999精品视频| 亚洲视频黄色 | 日韩精品一区二区三区国语自制 | 欧美激情成人网 | 色偷偷91久久综合噜噜噜 | 色播视频在线播放 | 国内精品美女久久久久 | 手机在线日韩高清理论片 | 免费小视频在线观看 | 久久98精品久久久久久婷婷 | 国产精品久久久久久久牛牛 | 亚洲五月花丁香花社区 |