⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 webftp.php

📁 ftpupdateapp是使用glib开发的在linux环境下运行的ftp客户端程序。
💻 PHP
📖 第 1 页 / 共 2 页
字号:
<?php/* ============================================================= *//* This script is a heavily modified version of inebria's PHPFTP *//* read licenses below for more details./* ============================================================= *//* Both WebFTP and PHPFTP licenses are BSD-style *//*	WebFTP License					*//* webftp.php *//* v0.1 2006/01/26 Author: Leandro Martinez <delphinen@gmail.com> *//* This software came from http://webphpftp.sourceforge.net/ *//* Copyright (c) 2006      Leandro Martinez.  All rights reserved.Redistribution and use in source and binary forms, with or withoutmodification, are permitted provided that the following conditionsare met:1. Redistributions of source code must retain the above copyright    notice, this list of conditions and the following disclaimer.2. Redistributions in binary form must reproduce the above copyright    notice, this list of conditions and the following disclaimer in the    documentation and/or other materials provided with the distribution.3. The name of the author may not be used to endorse or promote    products derived from this software without specific prior    written permission.THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESSOR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIEDWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSEARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANYDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIALDAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTEGOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESSINTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCEOR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *//*	PHPFTP License					*//* $Id: ftp.php,v 2.2 2002/03/12 23:21:28 pauls Exp $ *//* This software came from http://inebria.com/ *//* Copyright (c) 2000      Paul Southworth.  All rights reserved.Redistribution and use in source and binary forms, with or withoutmodification, are permitted provided that the following conditionsare met:1. Redistributions of source code must retain the above copyright    notice, this list of conditions and the following disclaimer.2. Redistributions in binary form must reproduce the above copyright    notice, this list of conditions and the following disclaimer in the    documentation and/or other materials provided with the distribution.3. The name of the author may not be used to endorse or promote    products derived from this software without specific prior    written permission.THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESSOR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIEDWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSEARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANYDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIALDAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTEGOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESSINTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCEOR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *//* ============================================================= *//* End license stuff											 *//* ============================================================= */$phpftp_version = "0.1";$show_version_footer = 1;/*Human-readable bytes size function*/function size_readable($size, $unit = null, $retstring = null){    // Units    $sizes = array('B', 'KB', 'MB', 'GB', 'TB');    $ii = count($sizes) - 1;     // Max unit    $unit = array_search((string) $unit, $sizes);    if ($unit === null || $unit === false) {        $unit = $ii;    }     // Return string    if ($retstring === null) {        $retstring = '%01.2f %s';    }     // Loop    $i = 0;    while ($unit != $i && $size >= 1024 && $i < $ii) {        $size /= 1024;        $i++;    }     return sprintf($retstring, $size, $sizes[$i]);}/*Header*/function phpftp_top() {	global $phpftp_version;?><html><head><script src="multifile.js"></script><script language="JavaScript"><!--function confirm_entry(){input_box=confirm("Delete the specified file?");if (input_box==true){ return true;}else{return false;}}function confirm_entry_b(){input_box=confirm("Save changes?");if (input_box==true){ return true;}else{return false;}}--></script><title>Web FTP</title><style type="text/css">	TD{	font-family: Verdana, Arial, Helvetica, sans-serif;	font-size: 12px;	color: #000000;	}		.texto1 { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; color: #FFFFFF; background-position: center}	.texto2 { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; color: #000066}	.texto3 { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; color: #330099}	body { 	font-family: Verdana, Arial, Helvetica, sans-serif;	font-size: 12px;	color: #EAEAEA;	}</style><body topmargin="1"><p align="center">&nbsp;</p><?php}/*Bottom*/function phpftp_bottom() {	global $phpftp_version;	global $show_version_footer;if (isset($show_version_footer)) {?><p align="center" class="texto3">This is <a href="http://webftpphp.sourceforge.net">WebFTP</a> version <?php echo $phpftp_version;?> based on <a href="http://inebria.com/phpftp/">PHP FTP</a> of inebria software.</font></p><?php}?></body></html><?php}/*Login function*/function phpftp_login() {	phpftp_top();?><tbody><tr valign="bottom">          <td><div align="right">&nbsp;</div></td>        </tr>        <tr>          <td nowrap>            <table style="margin-bottom: 5px;" align="center" bgcolor="#c3d9ff" cellpadding="0" cellspacing="0" width="400">              <tbody><tr>                <td class="bubble tl" align="left" valign="top"><img src="corner_tl.gif" class="c" alt=""></td>                <td class="bubble" rowspan="2" style="padding: 3px 0pt; font-family: arial; text-align: left; font-weight: bold;"><p align="center">                  <form action="webftp.php" method=post>                    <p align="center">                    <table bgcolor="#c3d9ff" border=0 align="center" width="300">                      <tr>                        <td align="center" colspan="2"><img src="webftp.gif"></td>                      </tr>                      <tr>                        <td bgcolor="#E8EEFA" colspan="2" align="center">.: <b>Welcome to Web FTP. Please login</b> :.</td>                      </tr>                      <tr>                        <td align="right" width="64"><strong>Hostname:</strong> </td>                        <td width="330"><input name="phpftp_host" type="text" style="width:200px;"></td>                      </tr>                      <tr>                        <td align="right" width="64"><strong>Username:</strong> </td>                        <td width="330"><input name="phpftp_user" type="text" style="width:200px;"></td>                      </tr>                      <tr>                        <td align="right" width="64"><strong >Password:</strong> </td>                        <td width="330"><input name="phpftp_passwd" type="password"  style="width:200px;" ></td>                      </tr>                      <tr>                        <td colspan="2"><div align="center">                            <input type="submit" value="Connect" name="submit">                        </div></td>                      </tr>                      <input type="hidden" name="phpftp_dir" value="/">					  <input type="hidden" name="function" value="dir">                    </table>                </form></td>                <td class="bubble tr" align="right" valign="top"><img src="corner_tr.gif" class="c" alt=""></td>              </tr>              <tr>                <td class="bubble bl" align="left" valign="bottom"><img src="corner_bl.gif" class="c" alt=""></td>                <td class="bubble br" align="right" valign="bottom"><img src="corner_br.gif" class="c" alt=""></td>              </tr>            </tbody></table>          </td>        </tr>      </tbody><?php	phpftp_bottom();}/*FTP connection function*/function phpftp_connect($phpftp_user,$phpftp_passwd,$phpftp_host) {/* This function does not return TRUE/FALSE - it returns the value of$ftp, the current FTP stream. */	$ftp = ftp_connect($phpftp_host);	if ($ftp) {		if (ftp_login($ftp,$phpftp_user,urldecode($phpftp_passwd))) {			if(!ftp_pasv($ftp, true))			{				echo "Could not initialize passive mode.";			}			return $ftp;		}	}}/*Filelist function.*/function phpftp_list($phpftp_user,$phpftp_passwd,$phpftp_dir,$phpftp_host) {	phpftp_top();?><?php	$ftp = @phpftp_connect($phpftp_user,$phpftp_passwd,$phpftp_host);	if (!$ftp) {?><strong>Could not establish FTP connection.</strong><a href="webftp.php" <font color=#666666>Re-login?</font></a><?php		phpftp_bottom();	} else {		if (!$phpftp_dir) {			$phpftp_dir=ftp_pwd($ftp);		}		if (!@ftp_chdir($ftp,$phpftp_dir)) {?><font color="#ff0000"><strong>Could not access directory.</strong></font><p><p><?php			$phpftp_dir=ftp_pwd($ftp);		}						?>		<table width="507" align="center">		<tr>		<td bgcolor="#CCCCFF" colspan="2" align="center"><strong><?echo "Server:".$phpftp_host;?></strong>		</td>		</tr>		<tr>		<td bgcolor="#CCCCFF" colspan="2" align="center"><strong><?echo "Directory:".$phpftp_dir;?></strong>		</td>		</tr>		</table><?		echo "<p align=\"center\">";		if ($phpftp_dir == "/") {			$phpftp_dir="";		}		if ($contents = ftp_rawlist($ftp,$phpftp_dir)) {			$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 style="margin-bottom: 5px;" align="center" bgcolor="#c3d9ff" cellpadding="0" cellspacing="0" width="700">              <tbody><tr>                <td class="bubble tl" align="left" valign="top"><img src="corner_tl.gif" class="c" alt=""></td>                <td class="bubble" rowspan="2" style="padding: 3px 0pt; font-family: arial; text-align: left; font-weight: bold;"><p align="center">                <table bgcolor="#c3d9ff" border=0><tr><td><table border=0 bgcolor="#c3d9ff" cellspacing=20><?php			if (count($nlist_dirs)>0) {?><tr>      <td align=left valign=top> <strong><img src="folder_red.gif">Directories</strong><br><form action="webftp.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; ?>"><input type="hidden" name="phpftp_host" value="<?php echo $phpftp_host; ?>"><select name="select_directory" size="18" width="100" style="width:250px;background-color: #E8E8FF;" class="texto2"><?php				for ($i=0; $i < count($nlist_dirs); $i++) {					echo "<option value=\"" . $nlist_dirs[$i] . "\">" . $nlist_dirs[$i] . "</option>\n";				}?></select><br><?php		$cdup=dirname($phpftp_dir);		if ($cdup == "") {			$cdup="/";		}?><input type="hidden" name="Dphpftp_dir" value="<?php echo $cdup; ?>"><input type="submit" name="sbutton" value="Go in" class="texto2"><input type="submit" name="sbutton" value="Go up" class="texto2"><input type="submit" name="sbutton" value="Remove directory" class="texto2"></form></td><?php			}else			{	?><tr>      <td align=left valign=top> <strong><img src="folder_red.gif">Directories</strong><br><form action="webftp.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; ?>"><input type="hidden" name="phpftp_host" value="<?php echo $phpftp_host; ?>"><select name="select_directory" size="18" width="100" style="width:250px;background-color: #E8E8FF;" class="texto2"><?php				for ($i=0; $i < count($nlist_dirs); $i++) {					echo "<option value=\"" . $nlist_dirs[$i] . "\">" . $nlist_dirs[$i] . "</option>\n";				}?></select><br><?php		$cdup=dirname($phpftp_dir);		if ($cdup == "") {			$cdup="/";		}?><input type="hidden" name="Dphpftp_dir" value="<?php echo $cdup; ?>"><input type="submit" name="sbutton" value="Go in" class="texto2"><input type="submit" name="sbutton" value="Go up" class="texto2"></form></td><?php }				if (count($nlist_files)>0) {?>      <td align=left valign=top> <strong><img src="folder_red_open.gif">Files</strong><br><form name="formfiles" action="webftp.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; ?>"><input type="hidden" name="phpftp_host" value="<?php echo $phpftp_host; ?>"><select name="select_file" size="18" width="100" style="width:300px;background-color: #E8E8FF;" class="texto2"><?php				for ($i=0; $i < count($nlist_files); $i++) {					echo "<option value=\"" . $nlist_files[$i] . "\">" . $nlist_files[$i] . " ($nlist_filesize[$i] bytes)". "</option>\n";					$nlist_total += $nlist_filesize[$i];				}?></select><br><input type="submit" value="Download file" name='button' class="texto2"><input type="submit" value="Edit file" name='button' class="texto2"><input type="submit" onClick="return confirm_entry()" value="Remove file" name='button' class="texto2"></form>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -