"; if ($lista = @ftp_nlist($connection, "$file")){ for ($x=0;$x"; if (!@ftp_delete($connection, "$lista[$x]")) del_recursive($currentDir,$connection,$lista[$x]); } @ftp_rmdir($connection, "$file"); } } include("parser.inc.php"); session_start(); $HPV = $HTTP_POST_VARS; // Get the POST, GET and SESSION variables (if register_globals=off (PHP4.2.1+)) // It's a bit of a dirty hack but variables are sometimes GET and sometimes POST variables $mode=(isset($HPV['mode']))?$HPV['mode']:$HTTP_GET_VARS['mode']; $action=(isset($HPV['action']))?$HPV['action']:$HTTP_GET_VARS['action']; $currentDir=(isset($HPV['currentDir']))?$HPV['currentDir']:$HTTP_GET_VARS['currentDir']; $file=(isset($HPV['file']))?$HPV['file']:$HTTP_GET_VARS['file']; $file2=(isset($HPV['file2']))?$HPV['file2']:$HTTP_GET_VARS['file2']; $permissions=(isset($HPV['permissions']))?$HPV['permissions']:$HTTP_GET_VARS['permissions']; $directory=(isset($HPV['directory']))?$HPV['directory']:$HTTP_GET_VARS['directory']; $MAX_FILE_SIZE=(isset($HPV['MAX_FILE_SIZE']))?$HPV['MAX_FILE_SIZE']:$HTTP_GET_VARS['MAX_FILE_SIZE']; $logoff=(isset($HPV['logoff']))?$HPV['logoff']:$HTTP_GET_VARS['logoff']; if(isset($HTTP_SESSION_VARS['server'])) { $server=$HTTP_SESSION_VARS['server']; $user=$HTTP_SESSION_VARS['user']; $password=$HTTP_SESSION_VARS['password']; $port=$HTTP_SESSION_VARS['port']; } else { $server=$HTTP_POST_VARS['server']; $user=$HTTP_POST_VARS['user']; $password=$HTTP_POST_VARS['password']; $port=$HTTP_POST_VARS['port']; } if (isset($logoff)) { session_unregister('server'); session_unregister('user'); session_unregister('password'); session_unregister('port'); unset($server); unset($user); unset($password); unset($port); session_destroy(); } if (isset($server)) { session_register('server', $server); session_register('user', $user); session_register('password', $password); session_register('port', $port); // $connection = @ftp_connect($server); $connection = @ftp_connect($server, $port); $loggedOn = @ftp_login($connection, $user, $password); $systype = @ftp_systype($connection); if(!isset($mode)) { $mode=1; //(FTP_ASCII = 0; FTP_BINARY=1) } if ($loggedOn) { if (isset($currentDir)) { ftp_chdir($connection, $currentDir); } $currentDir = ftp_pwd($connection); $msg = "Current directory = $currentDir"; // what to do now ??? if(isset($action)) { switch ($action) { case "chmod": // Change permissions if(@ftp_site($connection, "chmod $permissions $file")) { $msg= "File permission changed."; } else { $msg= "Could not change permissions for " . $file; } break; case "cd": // Change directory //First try : normal directory if(@ftp_chdir($connection, $currentDir . "/" . $file)) { $currentDir = @ftp_pwd($connection); $msg = "Current directory = " . $currentDir; } elseif(@ftp_chdir($connection, $file)) // Symbolic link directory { $currentDir = @ftp_pwd($connection); $msg = "Current directory = " . $currentDir; } else // link to a file so let's retrieve this... { header("Content-disposition: attachment; filename=\"$file\""); header("Content-type: application/octetstream"); header("Pragma: "); header("Cache-Control: cache"); header("Expires: 0"); //Determine original filename $filearray = explode("/",$file); $file = $filearray[sizeof($filearray)-1]; $msg = $file; $fp = fopen($downloadDir . $file, "w"); if(!@ftp_fget($connection,$fp,"$file",$mode)) { fclose($fp); exit; } fclose($fp); $data = readfile($downloadDir . $file); $i=0; while ($data[$i] != "") { echo $data[$i]; $i++; } unlink($downloadDir . $file); exit; } break; case "get": // Download file header("Content-disposition: attachment; filename=\"$file\""); header("Content-type: application/octetstream"); header("Pragma: "); header("Cache-Control: cache"); header("Expires: 0"); $fp = fopen($downloadDir . $file, "w"); ftp_fget($connection,$fp,"$file",$mode) OR DIE("Error downloading file"); fclose($fp); $data = readfile($downloadDir . $file); $i=0; while ($data[$i] != "") { echo $data[$i]; $i++; } unlink($downloadDir . $file); exit; break; case "put": // Upload file if($file_size > $MAX_FILE_SIZE) { $msg = " (max. " . $MAX_FILE_SIZE . "bytes)

"; } else { if(file_exists($HTTP_POST_FILES['file']['tmp_name'])) { if ($mode==1) { ftp_put($connection, $currentDir . "/" . $HTTP_POST_FILES['file']['name'], $HTTP_POST_FILES['file']['tmp_name'], 1); } else { ftp_put($connection, $currentDir . "/" . $HTTP_POST_FILES['file']['name'], $HTTP_POST_FILES['file']['tmp_name'], 0); } unlink($HTTP_POST_FILES['file']['tmp_name']); } else { $msg = "File could not be uploaded."; } } break; case "deldir"; // Delete directory if(@ftp_rmdir($connection, "$file")) { $msg = "$file deleted"; } else { //Verify if has files inside and if so, call recursive del if ($lista = @ftp_nlist($connection, "$currentDir/$file")){ del_recursive($currentDir,$connection,$file); $msg = "Directory $currentDir/$file deleted"; } else $msg = "Could not delete $file"; } break; case "delfile"; // Delete file if(@ftp_delete($connection, "$file")) { $msg = "$file deleted"; } else { $msg = "Could not delete $file"; } break; case "rename"; // Rename file if(@ftp_rename($connection, "$file", "$file2")) { $msg = "$file renamed to $file2"; } else { $msg = "Could not rename $file to $file2"; } break; case "createdir": // Create a new directory if(@ftp_mkdir($connection, "$file")) { $msg = "$file created"; } else { $msg = "Could not create $file"; } break; case "unzipfile"; $filens = str_replace(" ","\\ ",$file); if (exec("$unzipCommand $currentDir/$filens -d $currentDir/")) { $msg = "$file unziped"; } else { $msg = "Could not unzip the file"; } break; } } ?>



\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; } } // Links foreach($list as $myDir) { if ($myDir["is_link"]==1) { $fileAction = "cd"; $fileName = $myDir["target"]; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; } } // Files foreach($list as $myDir) { if ($myDir["is_link"]!=1 && $myDir["is_dir"]!=1) { $fileAction = "get"; $fileName = $myDir["name"]; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; if (strtolower($myDir["extension"]) == "zip") { print "\n"; } else { echo ""; } print "\n"; } } } print "
..
". $myDir["name"] . "". $myDir["size"] . "". $myDir["date"] . "". $myDir["perms"] . "". $myDir["user"] . "". $myDir["group"] . "\"Delete\"\"Rename\""; print "Change permissions"; print "
". $myDir["name"] . "". $myDir["size"] . "". $myDir["date"] . "". $myDir["perms"] . "". $myDir["user"] . "". $myDir["group"] . "\"Delete\"\"Rename\""; print "Symbolic link to ". $myDir["target"]; print "
". $myDir["name"] . "". $myDir["size"] . "". $myDir["date"] . "" . $myDir["perms"] . "". $myDir["user"] . "". $myDir["group"] . "\"Delete\"\"Rename\""; print "Change permissions"; print "\"Unzip\" 
"; } else { if(!isset($msg)) { $msg = "Could not connect to server $server:$port with user $user

Try again..."; } ?>

Server  Port :
User : Anonymous access
Password

Notice

WebFTP comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to redistribute it under certain conditions. Read the full GPL license here

WebFTP version 1.4 © 2002, Edwin van Wijk, www.v-wijk.net