日韩天天综合网_野战两个奶头被亲到高潮_亚洲日韩欧美精品综合_av女人天堂污污污_视频一区**字幕无弹窗_国产亚洲欧美小视频_国内性爱精品在线免费视频_国产一级电影在线播放_日韩欧美内地福利_亚洲一二三不卡片区

解析用SSH與PHP相連接 確保數(shù)據(jù)傳輸?shù)陌踩?2)_PHP教程

編輯Tag賺U幣
教程Tag:暫無Tag,歡迎添加,賺取U幣!

推薦:解析Windows XP系統(tǒng)下安裝apache+php+mysql
Apache和mysql的安裝較簡單,主要是安裝前請保證80端口未被占用 比如 iis 以前安裝過的apache mysql 先停止運行phpmyadmin,主要是配置文件的問題,把phpMyAdmin安裝目錄下Libraries目錄下面的Config.default.php復(fù)制到PHPmyAdmin根目錄下,改 名為Config.in

 

下面我們分別詳述之:

第一種方法:執(zhí)行

你最好為下面的代碼創(chuàng)建函數(shù)或者是一個類,不過本文僅僅起到一個為您提供基本觀念的作用,所以說你可以如此開始:

if (!function_exists(“ssh2_connect”)) die(“function ssh2_connect doesn‘t exist”)

// log in at server1.example.com on port 22

if(�。�$con = ssh2_connect(“server1.example.com”, 22))){

echo “fail: unable to establish connection\n”;

}

else {

// try to authenticate with username root, password secretpassword

if(!ssh2_auth_password($con, “root”, “secretpassword”)) {

echo “fail: unable to authenticate\n”;

}

else {

// allright, we’re in!

echo “okay: logged in.。.\n”;

// execute a command

if(�。�$stream = ssh2_exec($con, “ls -al” )) ){

echo “fail: unable to execute command\n”;

}

else{

// collect returning data from command

stream_set_blocking( $stream, true );

$data = “”;

while( $buf = fread($stream,4096) ){$data 。= $buf;

}

fclose($stream);

}

}

第二種方法:外殼

同樣道理,你也可以為如下的代碼編寫函數(shù)或者一個類。不過,本文僅僅提供基本觀念:

if (!function_exists(“ssh2_connect”)) die(“function ssh2_connect doesn‘t exist”)

// log in at server1.example.com on port 22

if(�。�$con = ssh2_connect(“server1.example.com”, 22))){

echo “fail: unable to establish connection\n”;

}

else {

// try to authenticate with username root, password secretpassword

if(!ssh2_auth_password($con, “root”, “secretpassword”)) {

echo “fail: unable to authenticate\n”;

}

else {

// allright, we’re in!echo “okay: logged in.。.\n”;

// create a shell

if(!($shell = ssh2_shell($con, ‘vt102’, null, 80, 40, SSH2_TERM_UNIT_CHARS))){

echo “fail: unable to establish shell\n”;

}

else{

stream_set_blocking( $shell, true );

// send a commandfwrite($shell,“ls -al\n”);

sleep(1);

// & collect returning data$data = “”;

while( $buf = fread($shell,,4096) ){

$data 。= $buf;

}

fclose($shell);

}

}

}

 

 

分享:重力推薦--正則表達式在線檢測工具
正則表達式(Regular Expression)在web開發(fā)中的應(yīng)用非常廣泛,很多時候使用它會給開發(fā)帶來極大的便利。 但是,正則表達式的編寫和使用是個比較復(fù)雜的過程。很多時候,即使將表達式寫出來了,也不能保證正確。 那么,有沒有便捷的檢測方法呢?有。本站推薦給

來源:模板無憂//所屬分類:PHP教程/更新時間:2009-10-03
相關(guān)PHP教程