PHPÄ£ÄâµÇ½µÄʵÏÖ
֮ǰ²Î¼ÓѧУµÄÌôÕ½±£¬×öÁËÒ»¸öСµÄÊÖ»úÍøÕ¾ÏîÄ¿£¬ÆäÖÐҪʵÏֵǽѧУУÄÚÓÊÏ䣬¿¼Âǵ½ÊÖ»úÓû§¶ËûÓа취ֱ½Ó·ÃÎÊѧУÍøÒ³¡£ÓÚÊÇÏëµ½ÁËʹÓÃphpʵÏÖÄ£ÄâµÇ½£¬ÓÐЩÐíµÄÐĵá£Ë³±ã¼Ç¼һÏ¡£
ÔÚÎÒÃÇѧУµÄÓÊÏäµÇ½ҳÃæµÄµÇ½±íµ¥µÄÄÚÈÝÓÐÓû§ÃûºÍÃÜÂ룬ûÓÐÑéÖ¤Âë»úÖÆ£¬ÕâÑù±È½ÏºÃ°ì¡£´ÓÔ´ÎļþÀï¼ÇÏÂ±íµ¥ÀïÓÐusernameºÍpasswordÏî¡£ÄÇôÎÒÃÇ¿ÉÒÔÏò´¦ÀíµÄÒ³ÃæÌá½»ÕâЩÊý¾Ý£¬½ÓÏÂÀ´Òª¹¹ÔìhttpÍ·£¬²ÅÄÜÄ£Äâä¯ÀÀÆ÷·¢³öµÄhttpÇëÇó¡£ÎÒÓÃhttpWatchProÀ´×¥°ü£¬ÖªµÀÁËѧУÓʼþ·þÎñÆ÷·µ»ØµÄcookie¸ñʽ¡£½ÓÏÂÀ´¹Ø¼üµÄÒ»²½¾ÍÊÇÒª¼Ç¼Ï·µ»ØµÄcookieÖµ£¬ÕâÑù²ÅÄܱ£³ÖµÇ¼״̬¡£ÏÂÃæÊǹ¹ÔìhttpÍ·µÄ·½·¨ºÍ¸ñʽ¡£
$flag = 0;
$argv = arra('username'=>$UseID, 'password'=>$Password);
//$UseIDºÍ$Password·Ö±ð±£´æÁËÓû§µÄÕ˺ÅÃûºÍÃÜÂë
foreach ($argv as $key=>$value)
{
if ($flag!=0)
{
$params .= "&";
$flag = 1;
}
$params.= $key."=";
$params.= urlencode($value);
$flag = 1;
}
$length = strlen($params);//»ñÈ¡¸ñʽºÃºóµÇ½ÐÅÏ¢³¤¶È
$header .= "POST /xxx.jsp HTTP/1.1\r\n";//xxx.jspλ´¦ÀíÒ³Ãæ
$header .= "Accept: */*\r\n";
$header .= "Host: www.XXXX.edu.cn\r\n";
$header .= "Referer: http://www.XXXX.edu.cn/index.jsp\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Content-Length: ".$length."\r\n";
$header .= "Connection: Keep-Alive\r\n\r\n";
//��ï¿絧ost���ַ�
$header .= $params."\r\n";
ÔÚ¹¹ÔìºÃhttpÍ·ºó¾Í¿ÉÒÔʹÓÃsocket·½Ê½½øÐÐÁ¬½Ó¡£
//´ò¿ªsocket½øÐÐÁ¬½Ó£¬www.XXXX.edu.cnΪÐèÒªµÇ½µÄÖ÷»úµØÖ·
$fp = fsockopen("www.XXXX.edu.cn",80,$errno,$errstr,10) or exit($errstr."--->".$errno);
fputs($fp,$header);
for($i=0;$i<=22;$i++){
$line .= fgets($fp,1024);
}
fclose($fp);
//·µ»ØµÄÊý¾Ý±£´æÔÚ$line±äÁ¿µ±ÖÐ
ͨ¹ý·ÖÎö·µ»ØµÄÊý¾Ý£¬ÎÒÃǾͿÉÒÔ»ñµÃcookieµÄÖµ¡£ÔÚÖ®ºóµÄÇëÇóÖÐÖ»ÒªÔÚhttpÇëÇóµ±ÖмÓÈëcookieµÄÖµ£¬¾ÍÄܹ»ÊµÏÖÄ£ÄâµÇ½µÄ¹¦ÄÜ£¬Ê£ÏÂÀ´¾ÍÊÇ·ÖÎö¹ýÂË·µ»ØµÄÒ³Ã湤×÷£¬¿ÉÒÔʹÓÃÕýÔò±í´ïʽ¡£ÎªÁ˼ò»¯²Ù×÷£¬ÎÒÔÚºóÃæµÄ²Ù×÷ÖÐʹÓÃÁËÒ»¸ö½ÐSnoopyµÄÀàÎļþ£¬Õâ¸öÀÏÍâдµÄÀàÀïÃæ·â×°Á˺öàÏà¹ØµÄ¹¦ÄÜ¡£ºóÀ´Ô
Ïà¹ØÎĵµ£º
<?php
/**
* ¸Ä±äͼƬµÄ¿í¸ß
*
* @author flynetcn (2009-12-16)
*
* @param string $img_src ÔͼƬµÄ´æ·ÅµØÖ·»òurl
* @param string $new_img_path ÐÂͼƬµÄ´æ·ÅµØÖ·
* @param int $new_width ÐÂͼƬµÄ¿í¶È
* @param int $new_height ÐÂͼƬµÄ¸ß¶È
* @return bool ³É¹¦true, ʧ°Üfalse
* ......
<?php
//н¨Ä¿Â¼
mkdir("/path/to/my/dir", 0700); //0700±íʾȨÏÞ×î´ó
//ɾ³ýĿ¼
rmdir("/path/to/my/dir");
//±éÀúĿ¼
$p =dir(/etc/php5);
echo "handler:".$p->handler;
while(false!=$entry=$p->read()){
echo $entry."\n" ;
}
$p->close();
//Êä³öÎļþÄÚÈÝ
$handle=@ ......
tidy ÊÇÒ»¸ö·Ç³£°ïæµÄÍøÒ³´úÂë·ÖÎöºÍ¾À´íµÄ¹¤¾ß£¬Äܹ»Ö§³Ö¶àÖÖÒ³Ãæ±àÂ룬²¢ÇÒÖ§³ÖxhtmlÊä³ö¡£Èç¹ûÎÒÃÇ͵ÀÁ£¬ÉõÖÁ¿ÉÒÔ½«Õû¸öÒ³Ã滺´æ£¬×îºó²ÉÓÃtidy´¦Àí£¬×îºóÊä³öÍêÃÀµÄxhtml´úÂë¡£
linuxÏ°²×°¹ý³ÌÈçÏ£º
Ê×ÏÈ°²×°tidy £¬ÏÂÔØtidyÔ´´úÂ룺
cvs -d:pserver: anonymous@tidy.cvs.sourceforge.net Ϊ·À±¸µç×ÓÓʼþµØÖ·ÊÕ¼¯ ......
PHPСʵÀý-ÖÆ×÷ÁôÑÔ±¾
µÚÒ»²½£ºÔÚmysqlÖÐн¨Êý¾Ý¿âbbs È»ºóÖ´ÐÐsql´úÂë
CREATE TABLE `message` (
`id` tinyint(1) NOT NULL auto_increment,
`user` varchar(25) NOT NULL,
`title` varchar(50) NOT NULL,
`content` tinytext NOT NULL,
`lastdate` date NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT ......
»ù±¾¸ÅÄî
Ò»¸öÕýÔò±í´ïʽͨ³£±»³ÆΪһ¸öģʽ (pattern)£¬ÎªÓÃÀ´ÃèÊö»òÕßÆ¥ÅäһϵÁзûºÏij¸ö¾ä·¨¹æÔòµÄ×Ö·û´®¡£ÀýÈ磺Handel¡¢Händel ºÍ Haendel ÕâÈý¸ö×Ö·û´®£¬¶¼¿ÉÒÔÓÉ“H(a|ä|ae)ndel”Õâ¸öģʽÀ´ÃèÊö¡£´ó²¿·ÖÕýÔò±í´ïʽµÄÐÎʽ¶¼ÓÐÈçϵĽṹ£º
Ñ¡Ôñ| ÊúÖ±·Ö¸ô·û´ú±íÑ¡Ôñ¡£ÀýÈç“gray|grey&rd ......