PHP Implementation Telnet feature example _php instance
Source: Internet
Author: User
Copy CodeThe code is as follows:
Class Phptelnet {
var $show _connect_error=1;
var $use _usleep=0; Change to 1 for faster execution
Don ' t change the 1 on the Windows servers unless you have PHP 5
var $sleeptime = 125000;
var $loginsleeptime = 1000000;
var $fp =null;
var $loginprompt;
var $conn 1;
var $conn 2;
/*
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;
}
}
function Connecterror ($num) {
if ($this->show_connect_error) switch ($num) {
Case 1:echo '
[PHP Telnet] Connect failed:unable to open network connection
'; Break
Case 2:echo '
[PHP Telnet] Connect Failed:unknown Host
'; Break
Case 3:echo '
[PHP Telnet] Connect Failed:login failed
'; Break
Case 4:echo '
[PHP Telnet] Connect failed:your server\ ' s PHP version is too low for PHP Telnet
'; Break
}
}
}
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service