ZooStudy 板


LINE

<?php $phpftp_host="localhost"; /* Comment this out if you don't want the version footer */ $show_version_footer=1; /* How large a file will you accept? You may also need to edit your php.ini file and change upload_max_filesize appropriately */ $max_file_size="1000000"; /* The temporary directory $phpftp_tmpdir must exist and be writable by your web server. Hint: mkdir /var/tmp/xfers && chmod 1777 /var/tmp/xfers */ $phpftp_tmpdir="/var/tmp/xfers"; /* $use_mime_lookup Turning this on creates a dependency upon the http://www.inebria.com/mime_lookup/ MIME type lookup library. Setting this variable to "1" enables it. "0" disables. If you turn it on, put the mime_lookup.php file in the same directory as ftp.php and uncomment the 'include("mime_lookup.php");' statement. */ $use_mime_lookup="0"; /* include("mime_lookup.php"); */ /* We enclose the top and bottom in functions because sometimes we might not send them (ie, in a file-download situation) */ function phpftp_top() { global $phpftp_version; ?> <!-- function phpftp_top --> <html> <head> <title>PHP FTP Client <?php echo $phpftp_version; ?></title> </head> <body bgcolor="#ffffff"> <?php } function phpftp_bottom() { global $phpftp_version; global $show_version_footer; ?> <!-- function phpftp_bottom --> <?php if (isset($show_version_footer)) { ?> <?php } ?> </body> </html> <?php } /* This is the form used for initially collecting username/passwd */ function phpftp_login() { phpftp_top(); ?> <!-- function phpftp_login --> <p> <form action="ftp.php" method=post> <p><table border=0> <tr><td> Login: </td><td> <input name="phpftp_user" type="text"> </td></tr> <tr><td> Password: </td><td> <input name="phpftp_passwd" type="password"> </td></tr> <tr><td> Directory: </td><td> <input name="phpftp_dir" type="text"> </td></tr> </table> </p><p> <input type="hidden" name="function" value="dir"> <input type="submit" value="connect"> </p> </form> <p> <?php phpftp_bottom(); } /* This function does not return TRUE/FALSE - it returns the value of $ftp, the current FTP stream. */ function phpftp_connect($phpftp_user,$phpftp_passwd) { global $phpftp_host; $ftp = ftp_connect($phpftp_host); if ($ftp) { if (ftp_login($ftp,$phpftp_user,urldecode($phpftp_passwd))) { return $ftp; } } } function phpftp_list($phpftp_user,$phpftp_passwd,$phpftp_dir) { global $phpftp_host; phpftp_top(); ?> <!-- function phpftp_list --> <?php $ftp = @phpftp_connect($phpftp_user,$phpftp_passwd); if (!$ftp) { ?> <strong>FTP login failed!</strong> <a href="ftp.php">Start over?</a> <?php phpftp_bottom(); } else { if (!$phpftp_dir) { $phpftp_dir=ftp_pwd($ftp); } if (!@ftp_chdir($ftp,$phpftp_dir)) { ?> <font color="#ff0000"><strong>Can't enter that directory!</strong></font><p><p> <?php $phpftp_dir=ftp_pwd($ftp); } echo "<strong>Current host:</strong> " . $phpftp_host . "<br>\n"; echo "<strong>Current directory:</strong> " . $phpftp_dir . "<br>\n"; if ($phpftp_dir == "/") { $phpftp_dir=""; } if ($contents = ftp_rawlist($ftp,"")) { $d_i=0; $f_i=0; $l_i=0; $i=0; while ($contents[$i]) { $item[] = split("[ ]+",$contents[$i],9); $item_type=substr($item[$i][0],0,1); if ($item_type == "d") { /* it's a directory */ $nlist_dirs[$d_i]=$item[$i][8]; $d_i++; } elseif ($item_type == "l") { /* it's a symlink */ $nlist_links[$l_i]=$item[$i][8]; $l_i++; } elseif ($item_type == "-") { /* it's a file */ $nlist_files[$f_i]=$item[$i][8]; $nlist_filesize[$f_i]=$item[$i][4]; $f_i++; } elseif ($item_type == "+") { /* it's something on an anonftp server */ $eplf=split(",",implode(" ",$item[$i]),5); if ($eplf[2] == "r") { /* it's a file */ $nlist_files[$f_i]=trim($eplf[4]); $nlist_filesize[$f_i]=substr($eplf[3],1); $f_i++; } elseif ($eplf[2] == "/") { /* it's a directory */ $nlist_dirs[$d_i]=trim($eplf[3]); $d_i++; } } /* ignore all others */ $i++; } ?> <table border=0 cellspacing=20> <?php if (count($nlist_dirs)>0) { ?> <tr><td align=left valign=top> <strong>Directories</strong><br> <form action="ftp.php" method=post> <input type="hidden" name="function" value="cd"> <input type="hidden" name="phpftp_user" value="<?php echo $phpftp_user; ?>"> <input type="hidden" name="phpftp_passwd" value="<?php echo $phpftp_passwd; ?>"> <input type="hidden" name="phpftp_dir" value="<?php echo $phpftp_dir; ?>"> <select name="select_directory" size="10" width="100"> <?php for ($i=0; $i < count($nlist_dirs); $i++) { echo "<option value=\"" . $nlist_dirs[$i] . "\">" . $nlist_dirs[$i] . "</option>\n"; } ?> </select><br> <input type="submit" value="Enter Directory"> </form> </td> <?php } if (count($nlist_files)>0) { ?> <td align=left valign=top> <strong>Files</strong><br> <form action="ftp.php" method=post> <input type="hidden" name="function" value="get"> <input type="hidden" name="phpftp_user" value="<?php echo $phpftp_user; ?>"> <input type="hidden" name="phpftp_passwd" value="<?php echo $phpftp_passwd; ?>"> <input type="hidden" name="phpftp_dir" value="<?php echo $phpftp_dir; ?>"> <select name="select_file" size="10"> <?php for ($i=0; $i < count($nlist_files); $i++) { echo "<option value=\"" . $nlist_files[$i] . "\">" . $nlist_files[$i] ." ($nlist_filesize[$i] bytes)". "</option>\n"; } ?> </select><br> <input type="submit" value="Download File"> </form> </td></tr> <?php } } else { ?> <p><font color="#ff0000"><strong>Directory empty or not readable</strong></font><p> <?php } ?> </table> <p> <form action="ftp.php" method=post> <?php $cdup=dirname($phpftp_dir); if ($cdup == "") { $cdup="/"; } ?> <input type="hidden" name="function" value="dir"> <input type="hidden" name="phpftp_user" value="<?php echo $phpftp_user; ?>"> <input type="hidden" name="phpftp_passwd" value="<?php echo $phpftp_passwd; ?>"> <input type="hidden" name="phpftp_dir" value="<?php echo $cdup; ?>"> <input type="submit" value="Go up one directory"> </form> <p> <form enctype="multipart/form-data" action="ftp.php" method=post> <input type="hidden" name="max_file_size" value="<?php echo $max_file_size ?>"> <input type="hidden" name="phpftp_user" value="<?php echo $phpftp_user; ?>"> <input type="hidden" name="phpftp_passwd" value="<?php echo $phpftp_passwd; ?>"> <input type="hidden" name="phpftp_dir" value="<?php echo $phpftp_dir; ?>"> <input type="hidden" name="function" value="put"> <input type="submit" value="Upload this:"> <input name="userfile" type="file"> </form> <p> <form action="ftp.php" method=post> <input type="hidden" name="function" value="mkdir"> <input type="hidden" name="phpftp_user" value="<?php echo $phpftp_user; ?>"> <input type="hidden" name="phpftp_passwd" value="<?php echo $phpftp_passwd; ?>"> <input type="hidden" name="phpftp_dir" value="<?php echo $phpftp_dir; ?>"> <input type="submit" value="Make subdirectory:"> <input name="new_dir" type="text"> <?php ftp_quit($ftp); phpftp_bottom(); } } function phpftp_cd($phpftp_user,$phpftp_passwd,$phpftp_dir,$select_directory) { ?> <!-- function phpftp_cd --> <?php $new_directory=$phpftp_dir . "/" . $select_directory; phpftp_list($phpftp_user,$phpftp_passwd,$new_directory); } function phpftp_mkdir($phpftp_user,$phpftp_passwd,$phpftp_dir,$new_dir) { ?> <!-- function phpftp_mkdir --> <?php $ftp = @phpftp_connect($phpftp_user,$phpftp_passwd); if ($phpftp_dir == "") { $phpftp_dir="/"; } if (!$ftp) { @ftp_quit($ftp); phpftp_top(); ?> <font color="#ff0000"><strong>FTP login failed!</strong></font><p><p> <a href="ftp.php">Start over?</a> <?php phpftp_bottom(); } else { $dir_path = $phpftp_dir . "/" . $new_dir; @ftp_mkdir($ftp,$dir_path); @ftp_quit($ftp); phpftp_list($phpftp_user,$phpftp_passwd,$phpftp_dir); } }; function phpftp_get($phpftp_user,$phpftp_passwd,$phpftp_dir,$select_file) { $ftp = @phpftp_connect($phpftp_user,$phpftp_passwd); if ($phpftp_dir == "") { $phpftp_dir="/"; } if ((!$ftp) || (!@ftp_chdir($ftp,$phpftp_dir))) { @ftp_quit($ftp); phpftp_top(); ?> <font color="#ff0000"><strong>FTP login failed!</strong></font><p><p> <a href="ftp.php">Start over?</a> <?php phpftp_bottom(); } else { srand((double)microtime()*1000000); $randval = rand(); $tmpfile=$phpftp_tmpdir . "/" . $select_file . "." . $randval; if (!ftp_get($ftp,$tmpfile,$select_file,FTP_BINARY)) { ftp_quit($ftp); phpftp_top(); ?> <font color="#ff0000"><strong>FTP get failed!</strong></font><p><p> <a href="ftp.php">Start over?</a> <?php phpftp_bottom(); } else { ftp_quit($ftp); global $use_mime_lookup; if ($use_mime_lookup == "1") { $file_mime_type=mime_lookup(substr(strrchr($select_file,"."),1)); } if (!$file_mime_type) { $file_mime_type="application/octet-stream"; } header("Content-Type: " . $file_mime_type); header("Content-Disposition: attachment; filename=" . $select_file); readfile($tmpfile); } @unlink($tmpfile); } } function phpftp_put($phpftp_user,$phpftp_passwd,$phpftp_dir,$userfile,$userfile_name) { srand((double)microtime()*1000000); $randval = rand(); $tmpfile=$phpftp_tmpdir . "/" . $userfile_name . "." . $randval; if (!@move_uploaded_file($userfile,$tmpfile)) { phpftp_top(); ?> <font color="#ff0000"><strong>Upload failed! Can't create temp file?</strong></font> <p><p> <a href="ftp.php">Start over?</a> <?php phpftp_bottom(); } else { if (!$ftp = @phpftp_connect($phpftp_user,$phpftp_passwd)) { unlink($tmpfile); phpftp_top(); ?> <font color="#ff0000"><strong>FTP login failed!</strong></font><p><p> <a href="ftp.php">Start over?</a> <?php phpftp_bottom(); } else { ftp_chdir($ftp,$phpftp_dir); ftp_put($ftp,$userfile_name,$tmpfile,FTP_BINARY); ftp_quit($ftp); unlink($tmpfile); phpftp_list($phpftp_user,$phpftp_passwd,$phpftp_dir); } } } switch($function) { case "dir"; phpftp_list($phpftp_user,$phpftp_passwd,$phpftp_dir); break; case "cd"; phpftp_cd($phpftp_user,$phpftp_passwd,$phpftp_dir,$select_directory); break; case "get"; phpftp_get($phpftp_user,$phpftp_passwd,$phpftp_dir,$select_file); break; case "put"; phpftp_put($phpftp_user,$phpftp_passwd,$phpftp_dir,$userfile,$userfile_name); break; case "mkdir"; phpftp_mkdir($phpftp_user,$phpftp_passwd,$phpftp_dir,$new_dir); break; case ""; phpftp_login(); break; } ?> --



※ 發信站: 批踢踢實業坊(ptt.csie.ntu.edu.tw)
◆ From: 140.112.7.59 ※ 編輯: magicfx 來自: 140.112.7.59 (04/22 15:49)







like.gif 您可能會有興趣的文章
icon.png[問題/行為] 貓晚上進房間會不會有憋尿問題
icon.pngRe: [閒聊] 選了錯誤的女孩成為魔法少女 XDDDDDDDDDD
icon.png[正妹] 瑞典 一張
icon.png[心得] EMS高領長版毛衣.墨小樓MC1002
icon.png[分享] 丹龍隔熱紙GE55+33+22
icon.png[問題] 清洗洗衣機
icon.png[尋物] 窗台下的空間
icon.png[閒聊] 双極の女神1 木魔爵
icon.png[售車] 新竹 1997 march 1297cc 白色 四門
icon.png[討論] 能從照片感受到攝影者心情嗎
icon.png[狂賀] 賀賀賀賀 賀!島村卯月!總選舉NO.1
icon.png[難過] 羨慕白皮膚的女生
icon.png閱讀文章
icon.png[黑特]
icon.png[問題] SBK S1安裝於安全帽位置
icon.png[分享] 舊woo100絕版開箱!!
icon.pngRe: [無言] 關於小包衛生紙
icon.png[開箱] E5-2683V3 RX480Strix 快睿C1 簡單測試
icon.png[心得] 蒼の海賊龍 地獄 執行者16PT
icon.png[售車] 1999年Virage iO 1.8EXi
icon.png[心得] 挑戰33 LV10 獅子座pt solo
icon.png[閒聊] 手把手教你不被桶之新手主購教學
icon.png[分享] Civic Type R 量產版官方照無預警流出
icon.png[售車] Golf 4 2.0 銀色 自排
icon.png[出售] Graco提籃汽座(有底座)2000元誠可議
icon.png[問題] 請問補牙材質掉了還能再補嗎?(台中半年內
icon.png[問題] 44th 單曲 生寫竟然都給重複的啊啊!
icon.png[心得] 華南紅卡/icash 核卡
icon.png[問題] 拔牙矯正這樣正常嗎
icon.png[贈送] 老莫高業 初業 102年版
icon.png[情報] 三大行動支付 本季掀戰火
icon.png[寶寶] 博客來Amos水蠟筆5/1特價五折
icon.pngRe: [心得] 新鮮人一些面試分享
icon.png[心得] 蒼の海賊龍 地獄 麒麟25PT
icon.pngRe: [閒聊] (君の名は。雷慎入) 君名二創漫畫翻譯
icon.pngRe: [閒聊] OGN中場影片:失蹤人口局 (英文字幕)
icon.png[問題] 台灣大哥大4G訊號差
icon.png[出售] [全國]全新千尋侘草LED燈, 水草

請輸入看板名稱,例如:WOW站內搜尋

TOP