if(empty($error_msg)){ // read in the file $fp=fopen($_FILES["newfile"]["tmp_name"], "r"); $buffer=base64_encode(fread($fp, $_FILES["newfile"]["size"])); fclose($fp); $file_id=phorum_db_file_save($PHORUM["user"]["user_id"], $_FILES["newfile"]["name"], $_FILES["newfile"]["size"], $buffer); } } elseif(!empty($_POST["delete"])) { foreach($_POST["delete"] as $file_id){ phorum_db_file_delete($file_id); } } $files = phorum_db_get_user_file_list($PHORUM["user"]["user_id"]); $total_size=0; foreach($files as $key => $file) { $files[$key]["filesize"] = phorum_filesize($file["filesize"]); $files[$key]["dateadded"]=phorum_date($PHORUM["short_date"], $file["add_datetime"]); $files[$key]["url"]=phorum_get_url(PHORUM_FILE_URL, "file=$key");
//////////////////////////////////////////////////////////////////////////////// if(!defined("PHORUM")) return; if ($do_detach) { // Find the message to detach. foreach ($message["attachments"] as $id => $info) { if ($info["file_id"] == $do_detach && $info["keep"]) { // Attachments which are not yet linked to a message // can be deleted immediately. Linked attachments should // be kept in the db, in case the users clicks "Cancel". if (! $info["linked"]) { phorum_db_file_delete($info["file_id"]); unset($message["attachments"][$id]); } else { $message["attachments"][$id]["keep"] = false; } // Run the after_detach hook. list($message,$info) = phorum_hook("after_detach", array($message,$info)); $attach_count--; break; } } }
/** * Delete a Phorum file. * * @example file_delete.php Delete a file. * * @param mixed $file * This is either an array containing at least the field "file_id" * or a numerical file_id value. */ function phorum_api_file_delete($file) { $PHORUM = $GLOBALS["PHORUM"]; // Find the file_id parameter to use. if (is_array($file)) { if (!isset($file["file_id"])) { trigger_error("phorum_api_file_delete(): \$file parameter needs a " . "\"file_id\" field.", E_USER_ERROR); } $file_id = (int) $file["file_id"]; } else { $file_id = (int) $file; } // Allow storage modules to handle the file data removal. // Modules should be aware of the fact that files don't have to // exist. The Phorum core does not throw errors when deleting a // non existent file. Therefore modules should accept that case // as well, without throwing errors. if (isset($PHORUM["hooks"]["file_delete"])) { phorum_hook("file_delete", $file_id); } // Delete the file from the Phorum database. phorum_db_file_delete($file_id); }