} if (!file_exists($filepath)) { trigger_error("Error the temporary upload file ({$file}) was not found at: {$filepath}", E_USER_WARNING); } // Check file size $filesize = filesize($filepath); if ($filesize > $CONFIG['upload_max_filesize']) { trigger_error("User Error: Attachment too large or file ('.{$file}.') upload error - size: " . filesize($filepath), E_USER_WARNING); // throwing an error isn't the nicest thing to do for the user but there seems to be no way of // checking file sizes at the client end before the attachment is uploaded. - INL } if ($filesize == FALSE) { trigger_error("Error handling uploaded file: {$file}", E_USER_WARNING); } // set up basic connection $conn_id = create_ftp_connection(); $destination_filepath = $CONFIG['ftp_path'] . $file_name; // check the source file exists if (!file_exists($filepath)) { trigger_error("Source file cannot be found: {$filepath}", E_USER_WARNING); } // set passive mode if required if (!ftp_pasv($conn_id, $CONFIG['ftp_pasv'])) { trigger_error("Problem setting passive ftp mode", E_USER_WARNING); } // upload the file $upload = ftp_put($conn_id, "{$destination_filepath}", "{$filepath}", FTP_BINARY); // close the FTP stream ftp_close($conn_id); // check upload status if (!$upload) {
/** * Checks for expired FTP files (where expired is before now) and removes them * @author Paul Heaney */ function saction_PurgeExpiredFTPItems() { global $dbFiles, $now; $success = TRUE; // Retreieve names first so we can delete them from FTP site $sql = "SELECT * FROM `{$dbFiles}` WHERE expiry <= '{$now}' AND expiry != 0"; $result = mysql_query($sql); if (mysql_error()) { trigger_error("MySQL Query Error" . mysql_error(), E_USER_WARNING); $success = FALSE; } if (mysql_numrows($result) > 0) { $connection = create_ftp_connection(); while ($obj = mysql_fetch_object($result)) { $success &= ftp_delete($connection, $obj->path . "/" . $obj->filename); $sqlDel = "DELETE FROM `{$dbFiles}` WHERE id = {$obj->id}"; $resultdel = mysql_query($sqlDel); if (mysql_error()) { trigger_error("MySQL Query Error" . mysql_error(), E_USER_WARNING); $success = FALSE; } } ftp_close($connection); } return $success; }