PHPÖ®Socket±à³Ì
±¾ÆªÎÄÕÂÀ´Ô´ÓÚ ºÚ¿Í»ùµØ-È«Çò×î´óµÄÖÐÎĺڿÍÕ¾ ÔÎÄÁ´½Ó£ºhttp://hackbase.com/tech/2009-08-04/54550_1.html
2007Äê11ÔÂ01ÈÕ ÐÇÆÚËÄ ÏÂÎç 03:48ÈÃÎÒÃÇÒÔÒ»¸ö¼òµ¥µÄÀý×Ó¿ªÊ¼---Ò»¸ö½ÓÊÕÊäÈë×Ö·û´®,´¦Àí²¢·µ»ØÕâ¸ö×Ö·û´®µ½¿Í»§¶ËµÄTCP·þÎñ.ÏÂÃæÊÇÏàÓ¦µÄ´úÂë:PHP ´úÂë: ------------------------------------------------- ...
2007Äê11ÔÂ01ÈÕ ÐÇÆÚËÄ ÏÂÎç 03:48ÈÃÎÒÃÇÒÔÒ»¸ö¼òµ¥µÄÀý×Ó¿ªÊ¼---Ò»¸ö½ÓÊÕÊäÈë×Ö·û´®,´¦Àí²¢·µ»ØÕâ¸ö×Ö·û´®µ½¿Í»§¶ËµÄTCP·þÎñ.ÏÂÃæÊÇÏàÓ¦µÄ´úÂë:
PHP ´úÂë:
--------------------------------------------------------------------------------
<?
// ÉèÖÃһЩ»ù±¾µÄ±äÁ¿
$host = "192.168.1.99";
$port = 1234;
// ÉèÖó¬Ê±Ê±¼ä
set_time_limit(0);
// ´´½¨Ò»¸öSocket
$socket = socket_create(AF_INET, SOCK_STREAM, 0) or die("Could not create
socket\n");
//°ó¶¨Socketµ½¶Ë¿Ú
$result = socket_bind($socket, $host, $port) or die("Could not bind to
socket\n");
// ¿ªÊ¼¼àÌýÁ´½Ó
$result = socket_listen($socket, 3) or die("Could not set up socket
listener\n");
// accept incoming connections
// ÁíÒ»¸öSocketÀ´´¦ÀíͨÐÅ
$spawn = socket_accept($socket) or die("Could not accept incoming
connection\n");
// »ñµÃ¿Í»§¶ËµÄÊäÈë
$input = socket_read($spawn, 1024) or die("Could not read input\n");
// Çå¿ÕÊäÈë×Ö·û´®
$input = trim($input);//½«ÊäÈë½á¹ûдÈëok.php£¬Õâ¾äÊÇÎÒ¼ÓµÄ
fputs(fopen('ok.php','a+'),"$input");
//´¦Àí¿Í»§¶ËÊäÈë²¢·µ»Ø½á¹û
$output = strrev($input) . "\n";
socket_write($spawn, $output, strlen ($output)) or die("Could not write
output\n");
// ¹Ø±Õsockets
socket_close($spawn);
socket_close($socket);
?>
--------------------------------------------------------------------------------
ÏÂÃæÊÇÆäÿһ²½ÖèµÄÏêϸ˵Ã÷:
1.µÚÒ»²½Êǽ¨Á¢Á½¸ö±äÁ¿À´±£´æSocketÔËÐеķþÎñÆ÷µÄIPµØÖ·ºÍ¶Ë¿Ú.Äã¿ÉÒÔÉèÖÃΪÄã×Ô¼ºµÄ·þÎñÆ÷ºÍ¶Ë¿Ú(Õâ¸ö¶Ë¿Ú¿ÉÒÔÊÇ1µ½65535Ö®¼äµÄÊý×Ö),ǰÌáÊÇÕâ¸ö¶Ë¿Úδ±»Ê¹ÓÃ.
PHP ´úÂë:
--------------------------------------------------------------------------------
<?
// ÉèÖÃÁ½¸ö±äÁ¿
$host = "192.168.1.99";
$port = 1234;
?>
-----------
Ïà¹ØÎĵµ£º
<?
//ÐÂÎÅÀà±ð
$query_cat="select * from $dbtable1";
$result_cat=mysql_query($query_cat) or die("<mce:script type="text/javascript"><!--
alert('Ìáʾ£º²éѰÐÂÎÅÀà±ðʧ°Ü£¬Çë¸ú¹ÜÀíÔ±ÁªÏµ')
// --></mce:script>");
if(!$resul ......
<?php
/*
*PHP¹ÜÀíMYSQLµÄÊý¾Ý¿âÀà
ʹÓ÷½·¨£º$dbConn = new DbConn([$Êý¾Ý¿âÃû(¿ÉÑ¡)]);
ÔÊÐí·µ»ØµÄ·½·¨£º
Execute($sql) //Ö´ÐÐSQLÓï¾ä£¬Ã»Óзµ»ØÖµ;
getRs($sql) //·µ»Ø²éѯÓï¾äµÄ¼Ç¼£¬Ò»Ìõ;
getRsArray($sql) //·µ» ......
<?php
$host="192.168.1.214";
$post=21;
$username="zwc3g";
$password="zwc3ggg";
$ftp=ftp_connect($host,$post);
ftp_login($ftp,$username,$password);
displayTheFolder($ftp,"/zhulu2");
//´òÓ¡FTPÉϵĸÃĿ¼ÏµÄËùÓÐÎļþ¡£
fu ......
¼Æ»®ÈÎÎñ£¨Schedule Task£©ÊÇwindowsƽ̨ÉϺÍcronÀàËÆµÄÒ»¸ö³ÌÐò£¬µ±È»¹¦ÄÜÉϲîÁ˺ܶàÁË¡£
ÒòΪÐèҪÿ¸öСʱÔËÐÐÒ»¸öPHP³ÌÐò£¬ÊÖ¶¯²Ù×÷²»ÏÖʵÁË¡£
Ê×ÏÈÔÚcmdϲâÊÔ£¬ÀýÈ磺 c:\appserv\php5\php.exe "C:\AppServ\www\temp2.php"
ÓÐÒ»µãҪעÒâ¾ÍÊÇÈç¹ûÄǸöPHPÒýÓÃÁËÆäËûÒ³Ãæ£¬ÐèÒªÌṩ¾ø¶Ô·¾¶ÁË£¬ÖÁÉÙÎҵIJâÊÔ ......
1.ðÅÝÅÅÐò
function m_sort($arr)
{
$l = count($arr);
if($l==0) return false;
for($i=0;$i<$l-1;$i++)
{
for($j=$i+1;$j<$l-1;$j++)
......