phpftp 汉化改良版 www.cayoo.com 片段function phpftp_list( $phpftp_user, $phpftp_passwd, $phpftp_dir ) {
phpftp_top();
echo "<!-- function phpftp_list -->\n";
$ftp = phpftp_connect( $phpftp_user, $phpftp_passwd );
if ( ! $ftp ) {
echo "<strong>FTP 登陆失败!</strong>\n";
echo "<a href=\"ftp.php\">点击这里重新联结!</a>\n";
phpftp_bottom();
} else {
if ( ! $phpftp_dir ) {
$phpftp_dir=ftp_pwd( $ftp );
}
if ( ! @ftp_chdir( $ftp, $phpftp_dir ) ) {
echo "<font color=\"#ff0000\"><strong>失败,不能打开这个目录!</strong></font><p><p>\n";
$phpftp_dir=ftp_pwd( $ftp );
}
echo "<strong>当前路径:</strong> " . $phpftp_dir . "<br>\n";
if ( $phpftp_dir == "/" ) {
$phpftp_dir="";
}
echo "<table border=0 cellspacing=20>\n";
if ( $contents = ftp_nlist( $ftp, "." ) ) {
$d_i=0;
$f_i=0;
sort($contents);
for ( $i=0; $i < count( $contents ); $i++ ) {
$file_size = ftp_size( $ftp, $contents[$i] );
if ( $file_size == -1 ) {
$nlist_dirs[$d_i]=$contents[$i];
$d_i++;
} else {
$nlist_files[$f_i]=$contents[$i];
$nlist_filesize[$f_i]=$file_size;
$f_i++;
}
}
echo "<tr><td>\n";
echo "<font face=\"courier\"><strong>目录</strong></font><br>\n";
echo "<form action=\"ftp.php\" method=post>\n";
echo "<input type=\"hidden\" name=\"function\" value=\"cd\">\n";
echo "<input type=\"hidden\" name=\"phpftp_user\" value=\"" . $phpftp_user . "\">\n";
echo "<input type=\"hidden\" name=\"phpftp_passwd\" value=\"" . $phpftp_passwd . "\">\n"; 
echo "<input type=\"hidden\" name=\"phpftp_dir\" value=\"" . $phpftp_dir . "\">\n";
echo "<select name=\"select_directory\" size=\"10\" width=\"100\">\n";
for ( $i=0; $i < count( $nlist_dirs ); $i++ ) {
echo "<option value=\"" . $nlist_dirs[$i] . "\">" . $nlist_dirs[$i] . "</option>\n";
}
echo "</select><br>\n";
echo "<input type=\"submit\" value=\"进入所选目录\">\n";
echo "</form>\n";
echo "</td><td>\n\n";
echo "<font face=\"courier\"><strong>文件</strong></font><br>\n";
echo "<form action=\"ftp.php\" method=post>\n";
echo "<input type=\"hidden\" name=\"function\" value=\"get\">\n";
echo "<input type=\"hidden\" name=\"phpftp_user\" value=\"" . $phpftp_user . "\">\n";
echo "<input type=\"hidden\" name=\"phpftp_passwd\" value=\"" . $phpftp_passwd . "\">\n";
echo "<input type=\"hidden\" name=\"phpftp_dir\" value=\"" . $phpftp_dir . "\">\n";
echo "<select name=\"select_file\" size=\"10\">\n";
for ( $i=0; $i < count( $nlist_files ); $i++ ) {
echo "<option value=\"" . $nlist_files[$i] . "\">" . $nlist_files[$i] ." ($nlist_filesize[$i] bytes)". "</option>\n";
}
echo "</select><br>\n";
echo "<input type=\"submit\" value=\"下载文件\">\n";
echo "</form>\n";
echo "</td></tr>\n\n";
} else {
echo "<p><font color=\"#ff0000\"><strong>此目录为空或不可读取!</strong></font><p>\n";
}
echo "</table>\n\n";
echo "<p>\n";
echo "<form action=\"ftp.php\" method=post>\n";
$cdup=dirname( $phpftp_dir );
if ( $cdup == "" ) {
$cdup="/";
}
echo "<input type=\"hidden\" name=\"function\" value=\"dir\">\n";
echo "<input type=\"hidden\" name=\"phpftp_user\" value=\"" . $phpftp_user . "\">\n";
echo "<input type=\"hidden\" name=\"phpftp_passwd\" value=\"" . $phpftp_passwd . "\">\n";
echo "<input type=\"hidden\" name=\"phpftp_dir\" value=\"" . $cdup . "\">\n";
echo "<input type=\"submit\" value=\"返回上一级目录\">\n";
echo "</form>\n";
echo "<p>\n";
echo "<form enctype=\"multipart/form-data\" action=\"ftp.php\" method=post>\n";
echo "<input type=\"hidden\" name=\"max_file_size\" value=\"1000000\">\n";
echo "<input type=\"hidden\" name=\"phpftp_user\" value=\"" . $phpftp_user . "\">\n";
echo "<input type=\"hidden\" name=\"phpftp_passwd\" value=\"" . $phpftp_passwd . "\">\n";
echo "<input type=\"hidden\" name=\"phpftp_dir\" value=\"" . $phpftp_dir . "\">\n";
echo "<input type=\"hidden\" name=\"function\" value=\"put\">\n";
echo "<input type=\"submit\" value=\"上传这个文件:\">\n";
echo "<input name=\"userfile\" type=\"file\">\n";
echo "</form>\n";
echo "<p>\n\n";
echo "<form action=\"ftp.php\" method=post>\n";
echo "<input type=\"hidden\" name=\"function\" value=\"mkdir\">\n";
echo "<input type=\"hidden\" name=\"phpftp_user\" value=\"" . $phpftp_user . "\">\n";
echo "<input type=\"hidden\" name=\"phpftp_passwd\" value=\"" . $phpftp_passwd . "\">\n";
echo "<input type=\"hidden\" name=\"phpftp_dir\" value=\"" . $phpftp_dir . "\">\n"; 
echo "<input type=\"submit\" value=\"新建目录:\">\n";
echo "<input name=\"new_dir\" type=\"text\">\n";
ftp_quit( $ftp );
phpftp_bottom();
}
}