1) { array_pop($_SESSION["path"]); } } function endFTP() { ftp_close($GLOBALS["conn_id"]); } function getFileTable($directory) { ob_clean(); echo "Current Path: " . ftp_pwd($GLOBALS["conn_id"]) . " "; $contents = ftp_nlist($GLOBALS["conn_id"], $directory); //table header echo ""; echo ""; //upload file / go up row echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; foreach ($contents as $file) { //file/folder row echo ""; echo ""; echo ""; echo ""; echo ""; } echo "
NameAction
"; echo ""; echo ""; echo ""; echo "
"; echo ""; echo ""; echo "
$file"; echo "
"; echo ""; echo ""; echo ""; echo "
"; echo "
"; echo "
"; echo ""; echo ""; echo ""; echo "
"; echo "
"; } function downloadFile($file) { if (ftp_get($GLOBALS["conn_id"], basename($file), basename($file), FTP_BINARY)) { if (basename($file)) { header('Content-Description: File Transfer'); header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename="' . basename(substr(basename($file), 1)) . '"'); header('Expires: 0'); header('Cache-Control: must-revalidate'); header('Pragma: public'); header('Content-Length: ' . filesize(substr(basename($file), 1))); readfile(substr(basename($file), 1)); unlink(basename($file)); } } else { echo "There was a problem\n"; } } function uploadFile($temp_name, $target_file) { if (startFTP()) { if (move_uploaded_file($temp_name, $target_file)) { if (ftp_put($GLOBALS["conn_id"], $target_file, $target_file, FTP_BINARY)) { unlink(basename($target_file)); getFileTable($_SESSION["path"][count($_SESSION["path"]) - 1]); } else { echo "There was a problem while uploading $target_file\n"; } } endFTP(); } else { echo "Sorry, there was an error uploading your file."; } } function deleteFile($file) { if (ftp_delete($GLOBALS["conn_id"], $file)) { return true; } echo "File not deleted!"; } function getLoginForm() { echo "
"; echo "Host: "; echo "

"; echo "Name: "; echo "

"; echo "Password: "; echo "

"; echo ""; echo "
"; }