《php和mysql web development開發(fā)第20章源代碼》由會員分享,可在線閱讀,更多相關(guān)《php和mysql web development開發(fā)第20章源代碼(4頁珍藏版)》請在裝配圖網(wǎng)上搜索。
1、Lockup.php代碼如下:?php $symbol=AMZN; /提取信息的關(guān)鍵詞 echo stock quote for : . .$symbol.; /原始信息的地址,下載后用EXCEL打開就明白 了$url= if(!($contents=file_get_contents($url) die(failure to open.$url); list($symbol,$quote,$date,$time)=explode(,$contents); echo $symbol.:.$quote.; echo $date.; echo $url.; echo .$url.;?directo
2、ry_submit.html代碼如下:無標(biāo)題文檔Submit your siteSubmit siteURL:Email contact:directory_submit.php代碼如下:?php $url=$_REQUESTurl; $email=$_REQUESTemail;/parse_url($url)得到URL不同部分的相關(guān)數(shù)據(jù)$url=parse_url($url);/測試主機是否存在,返回IP$hostname=$urlhost;if(!($ip=gethostbyname($hostname)echo host for url dose not have valid ip;ex
3、it;echo Host is at IP $ip;/做簡單的EMAIL測試$email=explode(,$email);$emailhost=$email1;/在windows下沒有dns_get_xm()函數(shù),故下面在windows下須注釋掉/* if(!dns_get_mx($emailhost,$mxhostsarr)echo Email address is not at valid host;exit; */echo Email address is delivered via : ;echo .$email0.$email1.;echo all submitted detail
4、s are ok.;?ftp_mirror.php代碼如下:?php $host=192.168.0.2;$user=second;$password=1;$remotefile=ftp/http.rar;$localfile=F:ftpfilehttp.rar;$conn=ftp_connect($host);if(!$conn) echo Error:could not connect to ftp server;exit; echo Connected to $host.; $result=ftp_login($conn,$user,$password);if(!$result)echo
5、 Error:could not log on as $user;exit;echo logged in as $user ;if(file_exists($localfile)$localtime=filemtime($localfile);echo local file last updated : ;echo date(G:i j-M-Y,$localtime);echo ;else$localtime=0;if(file_exists($remotefile) echo the remotefile is exists!.;else echo the remotefile isnt e
6、xists.;$remotetime=ftp_mdtm($conn,$remotefile);echo $remotetime.; if(!($remotetime=0)echo cant access remote file time.;$remotetime=$localtime+1;elseecho remote file last updated : ;echo date(G:i j-M-Y,$remotetime);echo ;if(!($remotetime$localtime) echo Local copy is up to date.; exit;echo Getting file from server.;$fp=fopen($localfile,w);if(!$success=ftp_fget($conn,$fp,$remotefile,FTP_BINARY)echo Error:Could not download file;ftp_quit($conn);exit;fclose($fp);echo File downloaded successfully;ftp_close($conn);?