FTP module of PHP is not installed.

The administrator of this website should install this FTP module. Installation instructions are given on php.net
"); setErrorVars(false, $errormessage, debug_backtrace(), __FILE__, __LINE__); return false; } // Decrypt password if (isset($_SESSION["net2ftp_password_encrypted_" . $net2ftp_globals["ftpserver"] . $net2ftp_globals["username"]]) == true) { $net2ftp_password = decryptPassword($_SESSION["net2ftp_password_encrypted_" . $net2ftp_globals["ftpserver"] . $net2ftp_globals["username"]]); } else { $net2ftp_password = decryptPassword($net2ftp_globals["password_encrypted"]); } // Check if port nr is filled in if ($net2ftp_globals["ftpserverport"] < 1 || $net2ftp_globals["ftpserverport"] > 65535 || $net2ftp_globals["ftpserverport"] == "") { $net2ftp_globals["ftpserverport"] = 21; } // Set up basic connection $ftp_connect = "ftp_connect"; if ($net2ftp_globals["sslconnect"] == "yes" && function_exists("ftp_ssl_connect")) { $ftp_connect = "ftp_ssl_connect"; } $conn_id = $ftp_connect($net2ftp_globals["ftpserver"], $net2ftp_globals["ftpserverport"]); if ($conn_id == false) { $errormessage = __("Unable to connect to FTP server %1\$s on port %2\$s.

Are you sure this is the address of the FTP server? This is often different from that of the HTTP (web) server. Please contact your ISP helpdesk or system administrator for help.
", $net2ftp_globals["ftpserver"], $net2ftp_globals["ftpserverport"]); setErrorVars(false, $errormessage, debug_backtrace(), __FILE__, __LINE__); return false; } // Login with username and password $login_result = ftp_login($conn_id, $net2ftp_globals["username"], $net2ftp_password); if ($login_result == false) { $errormessage = __("Unable to login to FTP server %1\$s with username %2\$s.

Are you sure your username and password are correct? Please contact your ISP helpdesk or system administrator for help.
", $net2ftp_globals["ftpserver"], $net2ftp_globals["username"]); setErrorVars(false, $errormessage, debug_backtrace(), __FILE__, __LINE__); return false; } // Set passive mode if ($net2ftp_globals["passivemode"] == "yes") { $success = ftp_pasv($conn_id, TRUE); if ($success == false) { $errormessage = __("Unable to switch to the passive mode on FTP server %1\$s.", $net2ftp_globals["ftpserver"]); setErrorVars(false, $errormessage, debug_backtrace(), __FILE__, __LINE__); return false; } } // Get the system type // $net2ftp_globals["systype"] = ftp_systype($conn_id); // Return the connection ID return $conn_id; } // End function ftp_openconnection // ** ** // ** ** // ************************************************************************************** // ************************************************************************************** // ************************************************************************************** // ************************************************************************************** // ** ** // ** ** function ftp_openconnection2() { // -------------- // This function opens an ftp connection to the secondary FTP server, to which // files can be copied or moved. // -------------- // Global variables global $net2ftp_globals; // Check if the FTP module of PHP is installed if (function_exists("ftp_connect") == false) { $errormessage = __("The FTP module of PHP is not installed.

The administrator of this website should install this FTP module. Installation instructions are given on php.net
"); setErrorVars(false, $errormessage, debug_backtrace(), __FILE__, __LINE__); return false; } // Check if port nr is correct if ($net2ftp_globals["ftpserverport2"] < 1 || $net2ftp_globals["ftpserverport2"] > 65535 || $net2ftp_globals["ftpserverport2"] == "") { $net2ftp_globals["ftpserverport2"] = 21; } // Set up basic connection $conn_id = ftp_connect($net2ftp_globals["ftpserver2"], $net2ftp_globals["ftpserverport2"]); if ($conn_id == false) { $errormessage = __("Unable to connect to the second (target) FTP server %1\$s on port %2\$s.

Are you sure this is the address of the second (target) FTP server? This is often different from that of the HTTP (web) server. Please contact your ISP helpdesk or system administrator for help.
", $net2ftp_globals["ftpserver2"], $net2ftp_globals["ftpserverport2"]); setErrorVars(false, $errormessage, debug_backtrace(), __FILE__, __LINE__); return false; } // Login with username and password $login_result = ftp_login($conn_id, $net2ftp_globals["username2"], $net2ftp_globals["password2"]); if ($login_result == false) { $errormessage = __("Unable to login to the second (target) FTP server %1\$s with username %2\$s.

Are you sure your username and password are correct? Please contact your ISP helpdesk or system administrator for help.
", $net2ftp_globals["ftpserver2"], $net2ftp_globals["username2"]); setErrorVars(false, $errormessage, debug_backtrace(), __FILE__, __LINE__); return false; } // Set passive mode if ($net2ftp_globals["passivemode"] == "yes") { $success = ftp_pasv($conn_id, TRUE); if ($success == false) { $errormessage = __("Unable to switch to the passive mode on the second (target) FTP server %1\$s.", $net2ftp_globals["ftpserver2"]); setErrorVars(false, $errormessage, debug_backtrace(), __FILE__, __LINE__); return false; } } // Get the system type // $net2ftp_globals["systype2"] = ftp_systype($conn_id); // Return the connection ID return $conn_id; } // End function ftp_openconnection2 // ** ** // ** ** // ************************************************************************************** // ************************************************************************************** // ************************************************************************************** // ************************************************************************************** // ** ** // ** ** function ftp_closeconnection($conn_id) { // -------------- // This function closes an ftp connection // -------------- ftp_quit($conn_id); } // End function ftp_closeconnection // ** ** // ** ** // ************************************************************************************** // ************************************************************************************** // ************************************************************************************** // ************************************************************************************** // ** ** // ** ** function ftp_rename2($conn_id, $directory, $entry, $newName) { // -------------- // This function renames a directory // -------------- $old = glueDirectories($directory, $entry); $new = glueDirectories($directory, $newName); $ftp_rename_result = ftp_rename($conn_id, $old, $new); if ($ftp_rename_result == false) { $errormessage = __("Unable to rename directory or file %1\$s into %2\$s", $old, $new); setErrorVars(false, $errormessage, debug_backtrace(), __FILE__, __LINE__); return false; } } // End function ftp_rename2 // ** ** // ** ** // ************************************************************************************** // ************************************************************************************** // ************************************************************************************** // ************************************************************************************** // ** ** // ** ** function ftp_rename3($conn_id, $old, $new) { // -------------- // This function renames a directory or file // -------------- $ftp_rename_result = ftp_rename($conn_id, $old, $new); if ($ftp_rename_result == false) { $errormessage = __("Unable to rename directory or file %1\$s into %2\$s", $old, $new); setErrorVars(false, $errormessage, debug_backtrace(), __FILE__, __LINE__); return false; } } // End function ftp_rename3 // ** ** // ** ** // ************************************************************************************** // ************************************************************************************** // ************************************************************************************** // ************************************************************************************** // ** ** // ** ** function ftp_chmod2($conn_id, $directory, $list, $divelevel) { // -------------- // This function chmods a directory or file // // $list[$i]["dirorfile"] contains d or - which indicates if the entry is a directory or a file // $list[$i]["dirfilename"] contains the name of the entry // $list[$i]["chmodoctal"] contains the 3-digit nr // // If the entry is a directory, $list[$i]["chmod_subdirectories"] and $list[$i]["chmod_subfiles"] are "yes" if // the subdirectories and files within the chmodded directory should also be chmodded // -------------- // ------------------------------------------------------------------------- // Global variables // ------------------------------------------------------------------------- global $net2ftp_globals, $net2ftp_result, $net2ftp_output; // ------------------------------------------------------------------------- // Initialization // ------------------------------------------------------------------------- if ($divelevel == 0) { $net2ftp_output["ftp_chmod2"][] = ""; return false; } } // ------------------------------ // For copy (to the same or another FTP server), move (to another FTP server) or delete // ------------------------------ if ($copymovedelete == "copy" || ($copymovedelete == "move" && $conn_id_source != $conn_id_target) || $copymovedelete == "delete") { // Create the targetdirectory if ($copymovedelete == "copy" || $copymovedelete == "move") { $success1 = ftp_mkdir($conn_id_target, $target); if ($success1 == false) { $net2ftp_output["ftp_copymovedelete"][] = __("Unable to create the subdirectory %1\$s. It may already exist. Continuing the copy/move process...", $target); } else { $net2ftp_output["ftp_copymovedelete"][] = __("Created target subdirectory %1\$s", $target); } } // Get a new list $newlist = ftp_getlist($conn_id_source, $source); if ($net2ftp_result["success"] == false) { $net2ftp_output["ftp_copymovedelete"][] = __("The directory %1\$s could not be selected, so this directory will be skipped", $source); $net2ftp_output["ftp_copymovedelete"][] = ""; setErrorVars(true, "", "", "", ""); continue; } // Add information to the list for ($j=1; $j<=$newlist["stats"]["directories"]["total_number"]; $j++) { $newlist["directories"][$j]["sourcedirectory"] = $source; $newlist["directories"][$j]["targetdirectory"] = $target; } for ($j=1; $j<=$newlist["stats"]["files"]["total_number"]; $j++) { $newlist["files"][$j]["sourcedirectory"] = $source; $newlist["files"][$j]["targetdirectory"] = $target; } // Call the function recursively $newdivelevel = $divelevel + 1; $ftp_copymovedelete_result = ftp_copymovedelete($conn_id_source, $conn_id_target, $newlist, $copymovedelete, $newdivelevel); // Delete the source directory // (Only if there were no problems in the recursive call to ftp_copymovedelete() above) if ($ftp_copymovedelete_result == true && ($copymovedelete == "move" || $copymovedelete == "delete")) { ftp_rmdir2($conn_id_source, $source); if ($net2ftp_result["success"] == false) { setErrorVars(true, "", "", "", ""); $net2ftp_output["ftp_copymovedelete"][] = __("Unable to delete the subdirectory %1\$s - it may not be empty", $source); } else { $net2ftp_output["ftp_copymovedelete"][] = __("Deleted subdirectory %1\$s", $source); } } } // end if copy, move to another FTP server, delete // ------------------------------ // For move (to the same FTP server) // ------------------------------ if ($copymovedelete == "move" && $conn_id_source == $conn_id_target) { ftp_rename3($conn_id_source, $source, $target); if ($net2ftp_result["success"] == false) { setErrorVars(true, "", "", "", ""); $net2ftp_output["ftp_copymovedelete"][] = __("Unable to move the directory %1\$s", $source); $net2ftp_output["ftp_copymovedelete"][] = ""; continue; } else { $net2ftp_output["ftp_copymovedelete"][] = __("Moved directory %1\$s", $source); } } // end if move to the same FTP server // ------------------------------ // Print ending message // ------------------------------ $net2ftp_output["ftp_copymovedelete"][] = __("Processing of directory %1\$s completed", $source); $net2ftp_output["ftp_copymovedelete"][] = ""; } // end for list_directories // ------------------------------------------------------------------------- // Process the files // ------------------------------------------------------------------------- for ($i=1; $i<=$list["stats"]["files"]["total_number"]; $i=$i+1) { // ------------------------------ // Set the status // ------------------------------ $j = $list["stats"]["directories"]["total_number"] + $i; $message = __("Processing entry %1\$s", javascriptEncode2($list["files"][$i]["dirfilename"])) . " ($j/$total_dirs_files)"; setStatus($j, $total_dirs_files, $message); // ------------------------------ // Source and target // ------------------------------ $source = glueDirectories($list["files"][$i]["sourcedirectory"], $list["files"][$i]["dirfilename"]); if ($copymovedelete == "copy" || $copymovedelete == "move") { if (isset($list["files"][$i]["newname"])) { $target = glueDirectories($list["files"][$i]["targetdirectory"], $list["files"][$i]["newname"]); } else { $target = glueDirectories($list["files"][$i]["targetdirectory"], $list["files"][$i]["dirfilename"]); } } else { $target = ""; } // ------------------------------ // Check that the target is not the same as the source file // ------------------------------ if (($conn_id_source == $conn_id_target) && ($target == $source)) { $net2ftp_output["ftp_copymovedelete"][] = __("The target for file %1\$s is the same as the source, so this file will be skipped", $source); continue; } // ------------------------------ // Check if the file contains a banned keyword, and if it is not bigger than the limit // ------------------------------ // If banned keyword or too big - copy: continue with the other files // If banned keyword or too big - move: abort if ($list["files"][$i]["selectable"] == "banned_keyword") { if ($copymovedelete == "copy") { $net2ftp_output["ftp_copymovedelete"][] = __("The file %1\$s contains a banned keyword, so this file will be skipped", $source); continue; } elseif ($copymovedelete == "move") { $net2ftp_output["ftp_copymovedelete"][] = __("The file %1\$s contains a banned keyword, aborting the move", $source); return false; } } elseif ($list["files"][$i]["selectable"] == "too_big") { if ($copymovedelete == "copy") { $net2ftp_output["ftp_copymovedelete"][] = __("The file %1\$s is too big to be copied, so this file will be skipped", $source); continue; } elseif ($copymovedelete == "move") { $net2ftp_output["ftp_copymovedelete"][] = __("The file %1\$s is too big to be moved, aborting the move", $source); return false; } } // ------------------------------------ // For copy (to the same or another FTP server) or move (to another FTP server) // ------------------------------------ if ($copymovedelete == "copy" || ($copymovedelete == "move" && $conn_id_source != $conn_id_target)) { // Get file from remote sourcedirectory to local temp directory // Don't delete the source file yet $localtargetdir = $net2ftp_globals["application_tempdir"]; $localtargetfile = $list["files"][$i]["dirfilename"] . ".txt"; $remotesourcedir = $list["files"][$i]["sourcedirectory"]; $remotesourcefile = $list["files"][$i]["dirfilename"]; $ftpmode = ftpAsciiBinary($list["files"][$i]["dirfilename"]); $copymove = "copy"; ftp_getfile($conn_id_source, $localtargetdir, $localtargetfile, $remotesourcedir, $remotesourcefile, $ftpmode, $copymove); if ($net2ftp_result["success"] == false) { setErrorVars(true, "", "", "", ""); if ($copymovedelete == "copy") { $net2ftp_output["ftp_copymovedelete"][] = __("Unable to copy the file %1\$s", $list["files"][$i]["dirfilename"]); continue; } elseif ($copymovedelete == "move") { $net2ftp_output["ftp_copymovedelete"][] = __("Unable to move the file %1\$s, aborting the move", $list["files"][$i]["dirfilename"]); return false; } } // Put file from local temp directory to remote targetdirectory // Delete the temporary file $localsourcedir = $net2ftp_globals["application_tempdir"]; $localsourcefile = $list["files"][$i]["dirfilename"] . ".txt"; $remotetargetdir = $list["files"][$i]["targetdirectory"]; if (isset($list["files"][$i]["newname"])) { $remotetargetfile = $list["files"][$i]["newname"]; } else { $remotetargetfile = $list["files"][$i]["dirfilename"]; } $copymove = "move"; ftp_putfile($conn_id_target, $localsourcedir, $localsourcefile, $remotetargetdir, $remotetargetfile, $ftpmode, $copymove); if ($net2ftp_result["success"] == false) { setErrorVars(true, "", "", "", ""); if ($copymovedelete == "copy") { $net2ftp_output["ftp_copymovedelete"][] = __("Unable to copy the file %1\$s", $list["files"][$i]["dirfilename"]); continue; } elseif ($copymovedelete == "move") { $net2ftp_output["ftp_copymovedelete"][] = __("Unable to move the file %1\$s, aborting the move", $list["files"][$i]["dirfilename"]); return false; } } // Copy: if the operation is successful, print a message elseif ($net2ftp_result["success"] == true && $copymovedelete == "copy") { $net2ftp_output["ftp_copymovedelete"][] = __("Copied file %1\$s", $list["files"][$i]["dirfilename"]); } // Move: only if the operation is successful, delete the source file elseif ($copymovedelete == "move") { $remotesource = glueDirectories($list["files"][$i]["sourcedirectory"], $list["files"][$i]["dirfilename"]); ftp_delete2($conn_id_source, $remotesource); if ($net2ftp_result["success"] == false) { setErrorVars(true, "", "", "", ""); $net2ftp_output["ftp_copymovedelete"][] = __("Unable to move the file %1\$s", $list["files"][$i]["dirfilename"]); } else { $net2ftp_output["ftp_copymovedelete"][] = __("Moved file %1\$s", $list["files"][$i]["dirfilename"]); } } } // end if copy, move to another FTP server, delete // ------------------------------ // For move (to the same FTP server) // ------------------------------ elseif ($copymovedelete == "move" && $conn_id_source == $conn_id_target) { ftp_rename3($conn_id_source, $source, $target); if ($net2ftp_result["success"] == false) { setErrorVars(true, "", "", "", ""); $net2ftp_output["ftp_copymovedelete"][] = __("Unable to move the file %1\$s", $source); } else { $net2ftp_output["ftp_copymovedelete"][] = __("Moved file %1\$s", $source); } } // end if move to the same FTP server // ------------------------------------ // For delete // ------------------------------------ elseif ($copymovedelete == "delete") { $remotesource = glueDirectories($list["files"][$i]["sourcedirectory"], $list["files"][$i]["dirfilename"]); ftp_delete2($conn_id_source, $remotesource); if ($net2ftp_result["success"] == false) { setErrorVars(true, "", "", "", ""); $net2ftp_output["ftp_copymovedelete"][] = __("Unable to delete the file %1\$s", $list["files"][$i]["dirfilename"]); continue; } else { $net2ftp_output["ftp_copymovedelete"][] = __("Deleted file %1\$s", $list["files"][$i]["dirfilename"]); } } // end delete } // end for list_files if ($divelevel == 0) { $net2ftp_output["ftp_copymovedelete"][] = ""; } // Print message if ($divelevel == 0) { $net2ftp_output["ftp_copymovedelete"][] = __("All the selected directories and files have been processed."); } return true; } // End function ftp_copymovedelete // ** ** // ** ** // ************************************************************************************** // ************************************************************************************** // ************************************************************************************** // ************************************************************************************** // ** ** // ** ** function ftp_processfiles($dowhat, $conn_id, $directory, $list, $options, $result, $divelevel) { // -------------- // This function does something with files (get size, find string, ...) // The $list contains both directories and files. The files are simply processed; the // directories are parsed recursively. // // $list[$i]["dirorfile"] contains d or - which indicates if the entry is a directory or a file // $list[$i]["dirfilename"] contains the name of the entry // $list[$i]["size"] contains the size of the entry // // OPTIONS: // if ($dowhat == "calculatesize") then // $options = array() doesn't contain anything // if ($dowhat == "findstring") then // $options["string"] a string // $options["case_sensitive"] blank or yes // $options["filename"] a filename with possible wildcard character * (it should match this preg_match regular expression: "/^[a-zA-Z0-9_ *-]*$/") // $options["size_from"], $options["size_to"] a number (in Bytes) // $options["modified_from"], $options["modified_to"] unix timestamps of the modification dates // // RESULT: // if ($dowhat == "calculatesize") then // $result["size"] // $result["skipped"] // if ($dowhat == "findstring") then // $result[$k]["directory"] contains the directory // $result[$k]["dirfilename"] contains the filename // $result[$k]["line"] contains the line nr // // -------------- // ------------------------------------------------------------------------- // Global variables // ------------------------------------------------------------------------- global $net2ftp_globals, $net2ftp_result; // ------------------------------------------------------------------------- // Initialization // ------------------------------------------------------------------------- if ($divelevel == 0) { } // ------------------------------------------------------------------------- // For all directories // ------------------------------------------------------------------------- for ($i=1; $i<=$list["stats"]["directories"]["total_number"]; $i=$i+1) { $currentdirectory = glueDirectories($directory, $list["directories"][$i]["dirfilename"]); // Check if the directory contains a banned keyword if ($list["directories"][$i]["selectable"] != "ok") { continue; } // Get a new list $newlist = ftp_getlist($conn_id, $currentdirectory); if ($net2ftp_result["success"] == false) { return false; } // Call the function recursively $newdivelevel = $divelevel + 1; $result = ftp_processfiles($dowhat, $conn_id, $currentdirectory, $newlist, $options, $result, $newdivelevel); if ($net2ftp_result["success"] == false) { return false; } } // end for list_directories // ------------------------------------------------------------------------- // Process the files // ------------------------------------------------------------------------- for ($i=1; $i<=$list["stats"]["files"]["total_number"]; $i=$i+1) { // ------------------------------- // Calculate size // ------------------------------- if ($dowhat == "calculatesize") { // Check if the size information is entered // Check also if the size is numeric if (isset($list["files"][$i]["size"]) && is_numeric($list["files"][$i]["size"])) { $result["size"] = $result["size"] + $list["files"][$i]["size"]; } else { $result["skipped"] = $result["skipped"] + 1; } } // end if calculatesize // ------------------------------- // Find string // ------------------------------- elseif ($dowhat == "findstring") { // Check that the file is smaller than the maximum file size that can be processed with net2ftp if ($list["files"][$i]["selectable"] != "ok") { continue; } // Check that the file is within the limits indicated on the selection screen if ($list["files"][$i]["size"] < $options["size_from"] || $list["files"][$i]["size"] > $options["size_to"]) { // echo "File $i skipped"; continue; } // Check modification date (if that data is returned by the FTP server in the correct format) $mtime_file = strtotime($list["files"][$i]["mtime"]); // If strtotime cannot interprete the data returned by the FTP server it returns -1 if (($mtime_file != -1) && (($mtime_file < $options["modified_from"]) || ($mtime_file > $options["modified_to"]))) { continue; } // Check the filename $pattern = "/^" . $options["filename"] . "$/i"; // i at the end is for a case-insensitive match if (preg_match($pattern, $list["files"][$i]["dirfilename"]) == 0) { continue; } // Read the file $text = ftp_readfile("", $directory, $list["files"][$i]["dirfilename"]); // If the file could not be read correctly, continue to the next one if ($net2ftp_result["success"] == false) { setErrorVars(true, "", "", "", ""); continue; } elseif ($text == "") { continue; } // Split the file in an array, each element of the array containing one line of the file $text_lines = explode_lines($text); // For each line, check if the string occurs for ($line=0; $line $net2ftp_settings["max_filesize"]) { // $errormessage = __("The file is too big to be transferred"); // setErrorVars(false, $errormessage, debug_backtrace(), __FILE__, __LINE__); // return false; // } // Check the consumption if(checkConsumption() == false) { $errormessage = __("Daily limit reached: the file %1\$s will not be transferred", $remotesource); setErrorVars(false, $errormessage, debug_backtrace(), __FILE__, __LINE__); return false; } // Get file $success1 = ftp_get($conn_id, $localtarget, $remotesource, $ftpmode); if ($success1 == false) { $errormessage = __("Unable to copy the remote file %1\$s to the local file using FTP mode %2\$s", $remotesource, $printftpmode); setErrorVars(false, $errormessage, debug_backtrace(), __FILE__, __LINE__); return false; } else { registerTempfile("register", $localtarget); } // Add the filesize to the global consumption variables addConsumption(filesize($localtarget), 0); // Copy ==> do nothing // Move ==> delete remote source file if ($copymove != "copy") { $success2 = ftp_delete2($conn_id, $remotesource); if ($success2 == false) { $errormessage = __("Unable to delete file %1\$s", $remotesource); setErrorVars(false, $errormessage, debug_backtrace(), __FILE__, __LINE__); return false; } } } // End function ftp_getfile // ** ** // ** ** // ************************************************************************************** // ************************************************************************************** // ************************************************************************************** // ************************************************************************************** // ** ** // ** ** function ftp_putfile($conn_id, $localsourcedir, $localsourcefile, $remotetargetdir, $remotetargetfile, $ftpmode, $copymove) { // -------------- // This function copies or moves a local file to a remote file // $ftpmode is used to specify whether the file is to be transferred in ASCII or BINARY mode // $copymove is used to specify whether to delete (move) or not (copy) the local source // // The opposite function is ftp_getfile // -------------- // Global variables global $net2ftp_settings; // Source and target $localsource = glueDirectories($localsourcedir, $localsourcefile); $remotetarget = glueDirectories($remotetargetdir, $remotetargetfile); // In the function ftp_put, use FTP_BINARY without the double quotes, otherwhise ftp_put assumes FTP_ASCII // DO NOT REMOVE THIS OR THE BINARY FILES WILL BE CORRUPTED (when copying, moving, uploading,...) if ($ftpmode == "FTP_BINARY") { $ftpmode = FTP_BINARY; } if ($ftpmode == FTP_ASCII) { $printftpmode = "FTP_ASCII"; } elseif ($ftpmode == FTP_BINARY) { $printftpmode = "FTP_BINARY"; } // Check if the filesize is smaller than the allowed filesize if (filesize($localsource) > $net2ftp_settings["max_filesize"]) { $errormessage = __("The file is too big to be transferred"); setErrorVars(false, $errormessage, debug_backtrace(), __FILE__, __LINE__); return false; } // Add the filesize to the global consumption variables addConsumption(filesize($localsource), 0); // Check the consumption if(checkConsumption() == false) { addConsumption((-1)*filesize($localsource), 0); $errormessage = __("Daily limit reached: the file %1\$s will not be transferred", $remotetarget); setErrorVars(false, $errormessage, debug_backtrace(), __FILE__, __LINE__); return false; } // Put local file to remote file // int ftp_put (int ftp_stream, string remote_file, string local_file, int mode) $success1 = ftp_put($conn_id, $remotetarget, $localsource, $ftpmode); if ($success1 == false) { $errormessage = __("Unable to copy the local file to the remote file %1\$s using FTP mode %2\$s", $remotetarget, $printftpmode); setErrorVars(false, $errormessage, debug_backtrace(), __FILE__, __LINE__); return false; } // If ftp_put fails, this function returns an error message and does not delete the temporary file. // In case the file was copied, a copy exists in the source directory. // In case the file was moved, the only copy is in the temporary directory, and so this has to be moved back to the source directory. // Copy ==> do nothing // Move ==> delete local source file if ($copymove != "copy") { $success2 = unlink($localsource); if ($success2 == false) { $errormessage = __("Unable to delete the local file"); setErrorVars(false, $errormessage, debug_backtrace(), __FILE__, __LINE__); return false; } else { registerTempfile("unregister", $localsource); } } } // End function ftp_putfile // ** ** // ** ** // ************************************************************************************** // ************************************************************************************** // ************************************************************************************** // ************************************************************************************** // ** ** // ** ** function getContentType($entry) { // -------------------- // Content-type, for a complete list, see http://www.isi.edu/in-notes/iana/assignments/media-types/media-types // Content-disposition: attachment. See http://www.w3.org/Protocols/HTTP/Issues/content-disposition.txt // -------------------- $filename_extension = get_filename_extension($entry); if ($filename_extension == "ai") { $content_type = "application/postscript"; } elseif ($filename_extension == "aif") { $content_type = "audio/x-aiff"; } elseif ($filename_extension == "aifc") { $content_type = "audio/x-aiff"; } elseif ($filename_extension == "aiff") { $content_type = "audio/x-aiff"; } elseif ($filename_extension == "asc") { $content_type = "text/plain"; } elseif ($filename_extension == "atom") { $content_type = "application/atom+xml"; } elseif ($filename_extension == "au") { $content_type = "audio/basic"; } elseif ($filename_extension == "avi") { $content_type = "video/x-msvideo"; } elseif ($filename_extension == "bcpio") { $content_type = "application/x-bcpio"; } elseif ($filename_extension == "bin") { $content_type = "application/octet-stream"; } elseif ($filename_extension == "bmp") { $content_type = "image/bmp"; } elseif ($filename_extension == "cdf") { $content_type = "application/x-netcdf"; } elseif ($filename_extension == "cgm") { $content_type = "image/cgm"; } elseif ($filename_extension == "class") { $content_type = "application/octet-stream"; } elseif ($filename_extension == "cpio") { $content_type = "application/x-cpio"; } elseif ($filename_extension == "cpt") { $content_type = "application/mac-compactpro"; } elseif ($filename_extension == "csh") { $content_type = "application/x-csh"; } elseif ($filename_extension == "css") { $content_type = "text/css"; } elseif ($filename_extension == "dcr") { $content_type = "application/x-director"; } elseif ($filename_extension == "dif") { $content_type = "video/x-dv"; } elseif ($filename_extension == "dir") { $content_type = "application/x-director"; } elseif ($filename_extension == "djv") { $content_type = "image/vnd.djvu"; } elseif ($filename_extension == "djvu") { $content_type = "image/vnd.djvu"; } elseif ($filename_extension == "dll") { $content_type = "application/octet-stream"; } elseif ($filename_extension == "dmg") { $content_type = "application/octet-stream"; } elseif ($filename_extension == "dms") { $content_type = "application/octet-stream"; } elseif ($filename_extension == "doc") { $content_type = "application/msword"; } elseif ($filename_extension == "dtd") { $content_type = "application/xml-dtd"; } elseif ($filename_extension == "dv") { $content_type = "video/x-dv"; } elseif ($filename_extension == "dvi") { $content_type = "application/x-dvi"; } elseif ($filename_extension == "dxr") { $content_type = "application/x-director"; } elseif ($filename_extension == "eps") { $content_type = "application/postscript"; } elseif ($filename_extension == "etx") { $content_type = "text/x-setext"; } elseif ($filename_extension == "exe") { $content_type = "application/octet-stream"; } elseif ($filename_extension == "ez") { $content_type = "application/andrew-inset"; } elseif ($filename_extension == "gif") { $content_type = "image/gif"; } elseif ($filename_extension == "gram") { $content_type = "application/srgs"; } elseif ($filename_extension == "grxml") { $content_type = "application/srgs+xml"; } elseif ($filename_extension == "gtar") { $content_type = "application/x-gtar"; } elseif ($filename_extension == "hdf") { $content_type = "application/x-hdf"; } elseif ($filename_extension == "hqx") { $content_type = "application/mac-binhex40"; } elseif ($filename_extension == "htm") { $content_type = "text/html"; } elseif ($filename_extension == "html") { $content_type = "text/html"; } elseif ($filename_extension == "ice") { $content_type = "x-conference/x-cooltalk"; } elseif ($filename_extension == "ico") { $content_type = "image/x-icon"; } elseif ($filename_extension == "ics") { $content_type = "text/calendar"; } elseif ($filename_extension == "ief") { $content_type = "image/ief"; } elseif ($filename_extension == "ifb") { $content_type = "text/calendar"; } elseif ($filename_extension == "iges") { $content_type = "model/iges"; } elseif ($filename_extension == "igs") { $content_type = "model/iges"; } elseif ($filename_extension == "jnlp") { $content_type = "application/x-java-jnlp-file"; } elseif ($filename_extension == "jp2") { $content_type = "image/jp2"; } elseif ($filename_extension == "jpe") { $content_type = "image/jpeg"; } elseif ($filename_extension == "jpeg") { $content_type = "image/jpeg"; } elseif ($filename_extension == "jpg") { $content_type = "image/jpeg"; } elseif ($filename_extension == "js") { $content_type = "application/x-javascript"; } elseif ($filename_extension == "kar") { $content_type = "audio/midi"; } elseif ($filename_extension == "latex") { $content_type = "application/x-latex"; } elseif ($filename_extension == "lha") { $content_type = "application/octet-stream"; } elseif ($filename_extension == "lzh") { $content_type = "application/octet-stream"; } elseif ($filename_extension == "m3u") { $content_type = "audio/x-mpegurl"; } elseif ($filename_extension == "m4a") { $content_type = "audio/mp4a-latm"; } elseif ($filename_extension == "m4b") { $content_type = "audio/mp4a-latm"; } elseif ($filename_extension == "m4p") { $content_type = "audio/mp4a-latm"; } elseif ($filename_extension == "m4u") { $content_type = "video/vnd.mpegurl"; } elseif ($filename_extension == "m4v") { $content_type = "video/x-m4v"; } elseif ($filename_extension == "mac") { $content_type = "image/x-macpaint"; } elseif ($filename_extension == "man") { $content_type = "application/x-troff-man"; } elseif ($filename_extension == "mathml") { $content_type = "application/mathml+xml"; } elseif ($filename_extension == "me") { $content_type = "application/x-troff-me"; } elseif ($filename_extension == "mesh") { $content_type = "model/mesh"; } elseif ($filename_extension == "mid") { $content_type = "audio/midi"; } elseif ($filename_extension == "midi") { $content_type = "audio/midi"; } elseif ($filename_extension == "mif") { $content_type = "application/vnd.mif"; } elseif ($filename_extension == "mov") { $content_type = "video/quicktime"; } elseif ($filename_extension == "movie") { $content_type = "video/x-sgi-movie"; } elseif ($filename_extension == "mp2") { $content_type = "audio/mpeg"; } elseif ($filename_extension == "mp3") { $content_type = "audio/mpeg"; } elseif ($filename_extension == "mp4") { $content_type = "video/mp4"; } elseif ($filename_extension == "mpe") { $content_type = "video/mpeg"; } elseif ($filename_extension == "mpeg") { $content_type = "video/mpeg"; } elseif ($filename_extension == "mpg") { $content_type = "video/mpeg"; } elseif ($filename_extension == "mpga") { $content_type = "audio/mpeg"; } elseif ($filename_extension == "ms") { $content_type = "application/x-troff-ms"; } elseif ($filename_extension == "msh") { $content_type = "model/mesh"; } elseif ($filename_extension == "mxu") { $content_type = "video/vnd.mpegurl"; } elseif ($filename_extension == "nc") { $content_type = "application/x-netcdf"; } elseif ($filename_extension == "oda") { $content_type = "application/oda"; } elseif ($filename_extension == "ogg") { $content_type = "application/ogg"; } elseif ($filename_extension == "pbm") { $content_type = "image/x-portable-bitmap"; } elseif ($filename_extension == "pct") { $content_type = "image/pict"; } elseif ($filename_extension == "pdb") { $content_type = "chemical/x-pdb"; } elseif ($filename_extension == "pdf") { $content_type = "application/pdf"; } elseif ($filename_extension == "pgm") { $content_type = "image/x-portable-graymap"; } elseif ($filename_extension == "pgn") { $content_type = "application/x-chess-pgn"; } elseif ($filename_extension == "pic") { $content_type = "image/pict"; } elseif ($filename_extension == "pict") { $content_type = "image/pict"; } elseif ($filename_extension == "png") { $content_type = "image/png"; } elseif ($filename_extension == "pnm") { $content_type = "image/x-portable-anymap"; } elseif ($filename_extension == "pnt") { $content_type = "image/x-macpaint"; } elseif ($filename_extension == "pntg") { $content_type = "image/x-macpaint"; } elseif ($filename_extension == "ppm") { $content_type = "image/x-portable-pixmap"; } elseif ($filename_extension == "ppt") { $content_type = "application/vnd.ms-powerpoint"; } elseif ($filename_extension == "ps") { $content_type = "application/postscript"; } elseif ($filename_extension == "qt") { $content_type = "video/quicktime"; } elseif ($filename_extension == "qti") { $content_type = "image/x-quicktime"; } elseif ($filename_extension == "qtif") { $content_type = "image/x-quicktime"; } elseif ($filename_extension == "ra") { $content_type = "audio/x-pn-realaudio"; } elseif ($filename_extension == "ram") { $content_type = "audio/x-pn-realaudio"; } elseif ($filename_extension == "ras") { $content_type = "image/x-cmu-raster"; } elseif ($filename_extension == "rdf") { $content_type = "application/rdf+xml"; } elseif ($filename_extension == "rgb") { $content_type = "image/x-rgb"; } elseif ($filename_extension == "rm") { $content_type = "application/vnd.rn-realmedia"; } elseif ($filename_extension == "roff") { $content_type = "application/x-troff"; } elseif ($filename_extension == "rtf") { $content_type = "text/rtf"; } elseif ($filename_extension == "rtx") { $content_type = "text/richtext"; } elseif ($filename_extension == "sgm") { $content_type = "text/sgml"; } elseif ($filename_extension == "sgml") { $content_type = "text/sgml"; } elseif ($filename_extension == "sh") { $content_type = "application/x-sh"; } elseif ($filename_extension == "shar") { $content_type = "application/x-shar"; } elseif ($filename_extension == "silo") { $content_type = "model/mesh"; } elseif ($filename_extension == "sit") { $content_type = "application/x-stuffit"; } elseif ($filename_extension == "skd") { $content_type = "application/x-koan"; } elseif ($filename_extension == "skm") { $content_type = "application/x-koan"; } elseif ($filename_extension == "skp") { $content_type = "application/x-koan"; } elseif ($filename_extension == "skt") { $content_type = "application/x-koan"; } elseif ($filename_extension == "smi") { $content_type = "application/smil"; } elseif ($filename_extension == "smil") { $content_type = "application/smil"; } elseif ($filename_extension == "snd") { $content_type = "audio/basic"; } elseif ($filename_extension == "so") { $content_type = "application/octet-stream"; } elseif ($filename_extension == "spl") { $content_type = "application/x-futuresplash"; } elseif ($filename_extension == "src") { $content_type = "application/x-wais-source"; } elseif ($filename_extension == "sv4cpio") { $content_type = "application/x-sv4cpio"; } elseif ($filename_extension == "sv4crc") { $content_type = "application/x-sv4crc"; } elseif ($filename_extension == "svg") { $content_type = "image/svg+xml"; } elseif ($filename_extension == "swf") { $content_type = "application/x-shockwave-flash"; } elseif ($filename_extension == "t") { $content_type = "application/x-troff"; } elseif ($filename_extension == "tar") { $content_type = "application/x-tar"; } elseif ($filename_extension == "tcl") { $content_type = "application/x-tcl"; } elseif ($filename_extension == "tex") { $content_type = "application/x-tex"; } elseif ($filename_extension == "texi") { $content_type = "application/x-texinfo"; } elseif ($filename_extension == "texinfo") { $content_type = "application/x-texinfo"; } elseif ($filename_extension == "tif") { $content_type = "image/tiff"; } elseif ($filename_extension == "tiff") { $content_type = "image/tiff"; } elseif ($filename_extension == "tr") { $content_type = "application/x-troff"; } elseif ($filename_extension == "tsv") { $content_type = "text/tab-separated-values"; } elseif ($filename_extension == "txt") { $content_type = "text/plain"; } elseif ($filename_extension == "ustar") { $content_type = "application/x-ustar"; } elseif ($filename_extension == "vcd") { $content_type = "application/x-cdlink"; } elseif ($filename_extension == "vrml") { $content_type = "model/vrml"; } elseif ($filename_extension == "vxml") { $content_type = "application/voicexml+xml"; } elseif ($filename_extension == "wav") { $content_type = "audio/x-wav"; } elseif ($filename_extension == "wbmp") { $content_type = "image/vnd.wap.wbmp"; } elseif ($filename_extension == "wbmxl") { $content_type = "application/vnd.wap.wbxml"; } elseif ($filename_extension == "wml") { $content_type = "text/vnd.wap.wml"; } elseif ($filename_extension == "wmlc") { $content_type = "application/vnd.wap.wmlc"; } elseif ($filename_extension == "wmls") { $content_type = "text/vnd.wap.wmlscript"; } elseif ($filename_extension == "wmlsc") { $content_type = "application/vnd.wap.wmlscriptc"; } elseif ($filename_extension == "wrl") { $content_type = "model/vrml"; } elseif ($filename_extension == "xbm") { $content_type = "image/x-xbitmap"; } elseif ($filename_extension == "xht") { $content_type = "application/xhtml+xml"; } elseif ($filename_extension == "xhtml") { $content_type = "application/xhtml+xml"; } elseif ($filename_extension == "xls") { $content_type = "application/vnd.ms-excel"; } elseif ($filename_extension == "xml") { $content_type = "application/xml"; } elseif ($filename_extension == "xpm") { $content_type = "image/x-xpixmap"; } elseif ($filename_extension == "xsl") { $content_type = "application/xml"; } elseif ($filename_extension == "xslt") { $content_type = "application/xslt+xml"; } elseif ($filename_extension == "xul") { $content_type = "application/vnd.mozilla.xul+xml"; } elseif ($filename_extension == "xwd") { $content_type = "image/x-xwindowdump"; } elseif ($filename_extension == "xyz") { $content_type = "chemical/x-xyz"; } elseif ($filename_extension == "zip") { $content_type = "application/zip"; } else { $content_type = "application/octet-stream"; } return $content_type; } // ** ** // ** ** // ************************************************************************************** // ************************************************************************************** // ************************************************************************************** // ************************************************************************************** // ** ** // ** ** function ftp_downloadfile($directory, $entry) { // ------------------------------------------------------------------------- // Global variables // ------------------------------------------------------------------------- global $net2ftp_globals, $net2ftp_result, $net2ftp_settings; // ------------------------------------------------------------------------- // Get the file from the FTP server to the web server // ------------------------------------------------------------------------- // Open connection $conn_id = ftp_openconnection(); if ($net2ftp_result["success"] == false) { return false; } // Check if the filesize is smaller than the allowed filesize // $ftp_size_result = ftp_size($conn_id, "$directory/$entry"); // if ($ftp_size_result > $net2ftp_settings["max_filesize"]) { // $errormessage = __("The file is too big to be transferred"); // setErrorVars(false, $errormessage, debug_backtrace(), __FILE__, __LINE__); // return false; // } // FTP mode $ftpmode = ftpAsciiBinary($entry); // Temporary filename $tempfilename = tempnam($net2ftp_globals["application_tempdir"], "downl__"); if ($tempfilename == false) { @unlink($tempfilename); $errormessage = __("Unable to create the temporary file. Check the permissions of the %1\$s directory.", $net2ftp_globals["application_tempdir"]); setErrorVars(false, $errormessage, debug_backtrace(), __FILE__, __LINE__); return false; } registerTempfile("register", $tempfilename); // Get the file // ftp_getfile($conn_id, $localtargetdir, $localtargetfile, $remotesourcedir, $remotesourcefile, $ftpmode, $copymove) ftp_getfile($conn_id, "", $tempfilename, $directory, $entry, $ftpmode, "copy"); if ($net2ftp_result["success"] == false) { @unlink($tempfilename); $errormessage = __("Unable to get the file %1\$s from the FTP server and to save it as temporary file %2\$s.
Check the permissions of the %3\$s directory.
", $entry, $tempfilename, $net2ftp_globals["application_tempdir"]); setErrorVars(false, $errormessage, debug_backtrace(), __FILE__, __LINE__); return false; } // Close connection ftp_closeconnection($conn_id); // ------------------------------------------------------------------------- // Transfer temp file to browser // ------------------------------------------------------------------------- // Send the download headers - this function is in httpheaders.inc.php sendDownloadHeaders($entry, filesize($tempfilename)); // -------------------- // Open file // -------------------- // From the PHP manual: // Note: The mode may contain the letter 'b'. // This is useful only on systems which differentiate between binary and text // files (i.e. Windows. It's useless on Unix). If not needed, this will be // ignored. You are encouraged to include the 'b' flag in order to make your scripts // more portable. // Thanks to Malte for bringing this to my attention ! registerTempfile("register", $tempfilename); $handle = fopen($tempfilename , "rb"); if ($handle == false) { @unlink($tempfilename); $errormessage = __("Unable to open the temporary file. Check the permissions of the %1\$s directory.", $net2ftp_globals["application_tempdir"]); setErrorVars(false, $errormessage, debug_backtrace(), __FILE__, __LINE__); return false; } // -------------------- // Send file to browser // -------------------- // Old method: fpassthru. Avoid using fpassthru, as it reads the entire file into memory! // $success1 = fpassthru($handle); // if ($success1 == false) { // @fclose($handle); // @unlink($tempfilename); // $errormessage = __("Unable to send the file to the browser"); // setErrorVars(false, $errormessage, debug_backtrace(), __FILE__, __LINE__); // return false; // } // New method: read the file piece by piece and send it to the browser. while(!feof($handle)) { $buffer = fread($handle, 2048); echo $buffer; } // -------------------- // Close file // -------------------- $success2 = @fclose($handle); // -------------------- // Delete the temporary file // -------------------- $success3 = @unlink($tempfilename); if ($success3 == false) { $errormessage = __("Unable to delete the temporary file"); setErrorVars(false, $errormessage, debug_backtrace(), __FILE__, __LINE__); return false; } registerTempfile("unregister", $tempfilename); } // End function ftp_downloadfile // ** ** // ** ** // ************************************************************************************** // ************************************************************************************** // ************************************************************************************** // ************************************************************************************** // ** ** // ** ** function ftp_zip($conn_id, $directory, $list, $zipactions, $zipdir, $divelevel) { // -------------- // This function allows to download/save/email a zipfile which contains the selected directories and files // -------------- // ------------------------------------------------------------------------- // Global variables // ------------------------------------------------------------------------- global $net2ftp_globals, $net2ftp_settings, $net2ftp_result, $net2ftp_output; // ------------------------------------------------------------------------- // Initialization // ------------------------------------------------------------------------- if ($divelevel == 0) { // Create the zipfile $net2ftp_globals["zipfile"] = new zipfile(); $timenow = time(); $zipdir = ""; // Open the connection $conn_id = ftp_openconnection(); if ($net2ftp_result["success"] == false) { return false; } } // ------------------------------------------------------------------------- // For all directories... // ------------------------------------------------------------------------- for ($i=1; $i<=$list["stats"]["directories"]["total_number"]; $i=$i+1) { $newdir = glueDirectories($directory, $list["directories"][$i]["dirfilename"]); $newzipdir = glueDirectories($zipdir, $list["directories"][$i]["dirfilename"]); $newdivelevel = $divelevel + 1; // Check if the directory contains a banned keyword if ($list["directories"][$i]["selectable"] == "banned_keyword") { continue; } // Get a new list $newlist = ftp_getlist($conn_id, $newdir); if ($net2ftp_result["success"] == false) { return false; } ftp_zip($conn_id, $newdir, $newlist, $zipactions, $newzipdir, $newdivelevel); if ($net2ftp_result["success"] == false) { setErrorVars(true, "", "", "", ""); continue; } if ($divelevel == 0 && ($zipactions["save"] == "yes" || $zipactions["email"] == "yes")) { $total = $list["stats"]["directories"]["total_number"] + $list["stats"]["files"]["total_number"]; setStatus($i, $total, __("Processing the entries")); } } // end for directories // ------------------------------------------------------------------------- // For all files... // ------------------------------------------------------------------------- for ($i=1; $i<=$list["stats"]["files"]["total_number"]; $i=$i+1) { if ($list["files"][$i]["selectable"] != "ok") { continue; } $text = ftp_readfile($conn_id, $directory, $list["files"][$i]["dirfilename"]); if ($net2ftp_result["success"] == false) { setErrorVars(true, "", "", "", ""); continue; } $filename = stripDirectory(glueDirectories($zipdir, $list["files"][$i]["dirfilename"])); $net2ftp_globals["zipfile"]->addFile($text, $filename); if ($divelevel == 0 && ($zipactions["save"] == "yes" || $zipactions["email"] == "yes")) { $total = $list["stats"]["directories"]["total_number"] + $list["stats"]["files"]["total_number"]; setStatus($list["stats"]["directories"]["total_number"] + $i - 1, $total, __("Processing the entries")); } } // end for files // ------------------------------------------------------------------------- // End // ------------------------------------------------------------------------- if ($divelevel == 0) { // ------------------------ // Send the zipfile to the browser // ------------------------ if ($zipactions["download"] == "yes") { $timenow = time(); $filenameToSend = "net2ftp-" . $timenow . ".zip"; $filesizeToSend = strlen($net2ftp_globals["zipfile"]->file()); sendDownloadHeaders($filenameToSend, $filesizeToSend); echo $net2ftp_globals["zipfile"]->file(); flush(); } // ------------------------ // Save the zipfile string to a file // ------------------------ if ($zipactions["save"] == "yes" || $zipactions["email"] == "yes") { $string = $net2ftp_globals["zipfile"]->file(); $tempfilename = tempnam($net2ftp_globals["application_tempdir"], "zip__"); if ($tempfilename == false) { @unlink($tempfilename); $errormessage = __("Unable to create the temporary file. Check the permissions of the %1\$s directory.", $net2ftp_globals["application_tempdir"]); setErrorVars(false, $errormessage, debug_backtrace(), __FILE__, __LINE__); return false; } registerTempfile("register", $tempfilename); local_writefile($tempfilename, $string); if ($net2ftp_result["success"] == false) { return false; } } // ------------------------ // Save the zip file to the FTP server // ------------------------ if ($zipactions["save"] == "yes") { ftp_putfile($conn_id, "", $tempfilename, $directory, $zipactions["save_filename"], FTP_BINARY, "copy"); if ($net2ftp_result["success"] == false) { @unlink($tempfilename); // $errormessage = __("Unable to put the file %1\$s on the FTP server.
You may not have write permissions on the directory.", $zipactions["save_filename"]); // setErrorVars(false, $errormessage, debug_backtrace(), __FILE__, __LINE__); return false; } else { $net2ftp_output["ftp_zip"][] = __("The zip file has been saved on the FTP server as %1\$s", $zipactions["save_filename"]) . "

\n"; } } // ------------------------ // Close the connection // ------------------------ ftp_closeconnection($conn_id); // ------------------------ // Email // ------------------------ if ($zipactions["email"] == "yes") { $FromName = "net2ftp"; $From = $net2ftp_settings["email_feedback"]; $ToName = ""; $To = $zipactions["email_to"]; $Subject = __("Requested files"); // Email message $Text = __("Dear,") . "\n\n"; $Text .= __("Someone has requested the files in attachment to be sent to this email account (%1\$s).", $To) . "\n"; $Text .= __("If you know nothing about this or if you don't trust that person, please delete this email without opening the Zip file in attachment.") . "\n"; $Text .= __("Note that if you don't open the Zip file, the files inside cannot harm your computer.") . "\n"; $Text .= "\n\n---------------------------------------\n"; $Text .= __("Information about the sender: ") . "\n"; $Text .= __("IP address: ") . $REMOTE_ADDR . "\n"; $Text .= __("Time of sending: ") . mytime() . "\n"; $Text .= __("Sent via the net2ftp application installed on this website: ") . $HTTP_REFERER . "\n"; $Text .= __("Webmaster's email: ") . $From . "\n"; $Text .= "\n\n---------------------------------------\n"; $Text .= __("Message of the sender: ") . "\n"; $Text .= $zipactions["message"] . "\n"; $Text .= "\n\n---------------------------------------\n"; $Text .= __("net2ftp is free software, released under the GNU/GPL license. For more information, go to http://www.net2ftp.com.") . "\n\n\n"; $AttmFiles = array($tempfilename); SendMail($From, $FromName, $To, $ToName, $Subject, $Text, $Html, $AttmFiles); if ($net2ftp_result["success"] == false) { @unlink($tempfilename); return false; } $net2ftp_output["ftp_zip"][] = __("The zip file has been sent to %1\$s.", $To) . "

"; } // ------------------------ // Delete the temporary zipfile // ------------------------ if ($zipactions["save"] == "yes" || $zipactions["email"] == "yes") { $success4 = @unlink($tempfilename); if ($success4 == false) { $errormessage = __("Unable to delete the temporary file"); setErrorVars(false, $errormessage, debug_backtrace(), __FILE__, __LINE__); return false; } registerTempfile("unregister", $tempfilename); } // Set the variable to NULL to save memory $net2ftp_globals["zipfile"] = NULL; } // end if $divelevel == 0 } // End function ftp_zip // ** ** // ** ** // ************************************************************************************** // ************************************************************************************** // ************************************************************************************** // ************************************************************************************** // ** ** // ** ** function acceptFiles($uploadedFilesArray) { // -------------- // This PHP function takes files that were just uploaded with HTTP POST, // verifies if the size is smaller than a certain value, and moves them // using move_uploaded_file() from the server's temporary directory to // net2ftp's temporary directory // // $uploadedFilesArray[number]["name"] and $acceptedFilesArray[number]["name"] contain the real name of the file // $uploadedFilesArray[number]["tmp_name"] contains the temporary name of the file in the *webserver's* temporary directory (eg C:\temp) // $acceptedFilesArray[number]["tmp_name"] contains the temporary name of the file in *net2ftp's* temporary directory (eg C:\web\net2ftp\temp) // // Note 1 - $acceptedFilesArray[number]["tmp_name"] may not be the same as $uploadedFilesArray[number]["tmp_name"] because // $acceptedFilesArray[number]["tmp_name"] should be unique at the moment the file is transferred to the new directory. // Note 2 - $acceptedFilesArray[number]["tmp_name"] // - starts with upload (or upl on Windows, because on that platform only the first 3 letters are kept) // - has the same filename extension as the real filename // - ends with .txt // The filename extension is needed by the PCL TAR library, which needs to determine if the archive is tar, tgz or gz. // The additional .txt is to ensure that no temporary file would be executed on the web server, which could compromise it. // // For example: script.php is uploaded to the web server's temporary directory C:\temp\f9skpqri // Then it is moved to net2ftp's temporary directory C:\web\net2ftp\temp\upload9oeic.php.txt // And finally it is transferred to the FTP server as script.php in functions ftp_transferfiles() and ftp_unziptransferfiles() -- see below // -------------- // ------------------------------------------------------------------------- // Global variables // ------------------------------------------------------------------------- global $net2ftp_globals, $net2ftp_settings, $net2ftp_output; $max_filesize = $net2ftp_settings["max_filesize"]; $skipped = 0; // Index of the files which are too big / contain a banned keyword $moved_ok = 0; // Index of the files that have been treated successfully $moved_notok = 0; // Index of the files that have been treated unsuccessfully for ($i=1; $i<=sizeof($uploadedFilesArray); $i++) { // ------------------------------------------------------------------------- // 1 -- Get the data from the filesArray (for each file, its location, name, size, ftpmode // ------------------------------------------------------------------------- $file_name = $uploadedFilesArray["$i"]["name"]; $file_tmp_name = $uploadedFilesArray["$i"]["tmp_name"]; $file_size = $uploadedFilesArray["$i"]["size"]; if (($file_name != "" && $file_tmp_name == "") || $file_size > $max_filesize) { // The case ($file_name != "" && $file_tmp_name == "") occurs when the file is bigger than the directives set in php.ini // In that case, only $uploadedFilesArray["$i"]["name"] is filled in. $net2ftp_output["acceptFiles"][] = __("File %1\$s is too big. This file will not be uploaded.", $file_name); $skipped = $skipped + 1; @unlink($file_tmp_name); continue; } elseif (checkAuthorizedName($file_name) == false) { $net2ftp_output["acceptFiles"][] = __("File %1\$s is contains a banned keyword. This file will not be uploaded.", $file_name); $skipped = $skipped + 1; @unlink($file_tmp_name); continue; } // ------------------------------------------------------------------------- // 3 -- upload and copy the file; if a file with the same name already exists, it is overwritten with the new file // ------------------------------------------------------------------------- $extension = get_filename_extension($file_name); if (substr($file_name, -6) == "tar.gz") { $extension = "tar.gz"; } $tempfilename = tempnam2($net2ftp_globals["application_tempdir"], "upload__", "." . $extension . ".txt"); if ($tempfilename == false) { @unlink($tempfilename); $errormessage = __("Could not generate a temporary file."); setErrorVars(false, $errormessage, debug_backtrace(), __FILE__, __LINE__); return false; } $success2 = move_uploaded_file($file_tmp_name, $tempfilename); if ($success2 == false) { $net2ftp_output["acceptFiles"][] = __("File %1\$s could not be moved", $file_name); @unlink($file_tmp_name); @unlink($tempfilename); $moved_notok = $moved_notok + 1; continue; } // ------------------------------------------------------------------------- // 4 -- if everything went fine, put file in acceptedFilesArray // ------------------------------------------------------------------------- else { // When uploading files, print some output // When updating files, do not print anything registerTempfile("register", $tempfilename); if ($net2ftp_globals["state"] == "upload") { $net2ftp_output["acceptFiles"][] = __("File %1\$s is OK", $file_name); } $moved_ok = $moved_ok + 1; $acceptedFilesArray[$moved_ok]["name"] = $file_name; $acceptedFilesArray[$moved_ok]["tmp_name"] = $tempfilename; } } // End for if ($moved_notok > 0) { $errormessage = __("Unable to move the uploaded file to the temp directory.

The administrator of this website has to chmod 777 the /temp directory of net2ftp."); setErrorVars(false, $errormessage, debug_backtrace(), __FILE__, __LINE__); return false; } elseif ($moved_ok == 0 && $skipped == 0) { $errormessage = __("You did not provide any file to upload."); setErrorVars(false, $errormessage, debug_backtrace(), __FILE__, __LINE__); return false; } elseif ($moved_ok == 0 && $skipped > 0) { return "all_uploaded_files_are_too_big"; } else { return $acceptedFilesArray; } } // End function acceptFiles // ** ** // ** ** // ************************************************************************************** // ************************************************************************************** // ************************************************************************************** // ************************************************************************************** // ** ** // ** ** function ftp_transferfiles($filesArray, $targetDir) { // -------------- // This PHP function takes a file that was uploaded from a client computer via a browser to the web server, // and puts it on another FTP server // -------------- // ------------------------------------------------------------------------- // Global variables // ------------------------------------------------------------------------- global $net2ftp_globals, $net2ftp_result, $net2ftp_output; // ------------------------------ // Open connection // ------------------------------ $conn_id = ftp_openconnection(); if ($net2ftp_result["success"] == false) { for ($i=1; $i<=sizeof($filesArray); $i++) { @unlink($filesArray[$i]["tmp_name"]); } return false; } // ------------------------------ // For loop // ------------------------------ for ($i=1; $i<=sizeof($filesArray); $i++) { // Set status setStatus($i, sizeof($filesArray), __("Transferring files to the FTP server")); // Determine which FTP mode should be used $ftpmode = ftpAsciiBinary($filesArray[$i]["name"]); if ($ftpmode == FTP_ASCII) { $printftpmode = "FTP_ASCII"; } elseif ($ftpmode == FTP_BINARY) { $printftpmode = "FTP_BINARY"; } // Put files ftp_putfile($conn_id, "", $filesArray[$i]["tmp_name"], $targetDir, $filesArray[$i]["name"], $ftpmode, "move"); if ($net2ftp_result["success"] == false) { setErrorVars(true, "", "", "", ""); @unlink($filesArray[$i]["tmp_name"]); $net2ftp_output["ftp_transferfiles"][] = __("File %1\$s could not be transferred to the FTP server", $filesArray[$i]["name"]); continue; } $net2ftp_output["ftp_transferfiles"][] = __("File %1\$s has been transferred to the FTP server using FTP mode %2\$s", $filesArray[$i]["name"], $printftpmode); } // End for // ------------------------------ // Close connection // ------------------------------ ftp_closeconnection($conn_id); } // End function ftp_transferfiles // ** ** // ** ** // ************************************************************************************** // ************************************************************************************** // ************************************************************************************** // ************************************************************************************** // ** ** // ** ** function ftp_unziptransferfiles($archivesArray) { // -------------- // Extract the directories and files from the archive to a temporary directory on the web server, and // then create the directories and put the files on the FTP server // -------------- // ------------------------------------------------------------------------- // Global variables // ------------------------------------------------------------------------- global $net2ftp_globals, $net2ftp_result, $net2ftp_output; // ------------------------------------------------------------------------- // Open connection // ------------------------------------------------------------------------- $conn_id = ftp_openconnection(); if ($net2ftp_result["success"] == false) { for ($archive_nr=1; $archive_nr<=sizeof($archivesArray); $archive_nr++) { @unlink($archivesArray[$archive_nr]["tmp_name"]); } return false; } // ------------------------------------------------------------------------- // For each archive... // ------------------------------------------------------------------------- for ($archive_nr=1; $archive_nr<=sizeof($archivesArray); $archive_nr++) { // Set status setStatus($archive_nr, sizeof($archivesArray), __("Decompressing archives and transferring files")); // ------------------------------------------------------------------------- // Determine the type of archive depending on the filename extension // ------------------------------------------------------------------------- $archive_name = $archivesArray[$archive_nr]["name"]; $archive_file = $archivesArray[$archive_nr]["tmp_name"]; $archivename_without_dottext = substr($archivesArray[$archive_nr]["tmp_name"], 0, strlen($archive)-4); $archive_type = get_filename_extension($archivename_without_dottext); $net2ftp_output["ftp_unziptransferfiles"][] = __("Processing archive nr %1\$s: %2\$s", $archive_nr, $archive_name); $net2ftp_output["ftp_unziptransferfiles"][] = "