/** * This function deletes the files uploaded to the files sharing section * and its data in tattachment older than X days */ function delete_old_fs_files_data() { global $config; if (!isset($config["max_days_fs_files"])) { $config["max_days_fs_files"] = 7; } // 7 is the default value $DELETE_DAYS = (int) $config["max_days_fs_files"]; if ($DELETE_DAYS > 0) { require_once $config["homedir"] . '/operation/file_sharing/FileSharingPackage.class.php'; $limit = time() - $DELETE_DAYS * 86400; $sql = sprintf("SELECT id_attachment\n\t\t\t\t\t\tFROM tattachment\n\t\t\t\t\t\tWHERE file_sharing = 1\n\t\t\t\t\t\t\tAND timestamp < '%s'", date("Y-m-d", $limit)); $old_files = get_db_all_rows_sql($sql); if (!empty($old_files)) { foreach ($old_files as $file) { $package = new FileSharingPackage($file['id_attachment']); $package->delete(); } } } }
return; } else { exit; } } require_once $config['homedir'] . "/operation/file_sharing/FileSharingFile.class.php"; require_once $config['homedir'] . "/operation/file_sharing/FileSharingPackage.class.php"; if (defined('AJAX')) { ob_clean(); $delete_package = (bool) get_parameter("deletePackage"); if ($delete_package) { $result = array("status" => false, "message" => ''); $id = (int) get_parameter("id"); if (!empty($id)) { $user_is_admin = (bool) dame_admin($config['id_user']); $package = new FileSharingPackage($id); if ($package->getUploader() == $config['id_user'] || $user_is_admin) { $result['status'] = $package->delete(); if (!$result['status']) { $result['message'] = __("An error occurred while deleting the file"); } } else { audit_db($config["id_user"], $config["REMOTE_ADDR"], "ACL Violation", "Trying to delete a Shared File without permission"); $result['message'] = __("You don't have permisison to delete this file"); } } else { $result['message'] = __("Empty ID"); } echo json_encode($result); return; }
$id_user = get_parameter('id_user', $config['id_user']); // If the user doesn't exist get the current user $user_data = get_user($id_user); if (empty($user_data)) { $id_user = $config['id_user']; } $user_is_admin = (bool) dame_admin($config['id_user']); $sql = "SELECT id_attachment FROM tattachment\n\t\tWHERE id_usuario = '{$id_user}'\n\t\t\tAND file_sharing = 1\n\t\tORDER BY timestamp DESC, id_attachment DESC"; $files_aux = get_db_all_rows_sql($sql); if (empty($files_aux) || empty($files_aux[0])) { $files_aux = array(); } $files = array(); foreach ($files_aux as $file_aux) { $id = $file_aux['id_attachment']; $file = new FileSharingPackage($id); $file->loadTrackingDownload(); // Load the downloads tracking info $files[] = $file->toArray(); } ?> <div id="user_files" class="table user_files_table"></div> <script src="<?php echo $config['base_url']; ?> /operation/file_sharing/FileSharingAdapters.js"></script> <script src="<?php echo $config['base_url']; ?>
require $general_error; exit; } break; default: } //Compound file path if ($type == "release" || $type == "external_release") { $fileLocation = $config["homedir"] . "/" . $data["location"]; $short_name = preg_split("/\\//", $data["location"]); $last_name = $short_name[sizeof($short_name) - 1]; } else { if ($type == "file_sharing") { if (!empty($id_attachment)) { require_once $config['homedir'] . "/operation/file_sharing/FileSharingPackage.class.php"; $file = new FileSharingPackage($id_attachment); $fileLocation = $file->getFullpath(); $last_name = $file->getName(); $file->trackingDownload(); $data = $id_attachment; } } else { $fileLocation = $config["homedir"] . "/attachment/" . $data["id_attachment"] . "_" . $data["filename"]; $last_name = $data["filename"]; } } //General check to avoid hacking using wrong id of files if (!$data) { audit_db($config["id_user"], $config["REMOTE_ADDR"], "ACL Violation", "Trying to access Downloads browser"); require $general_error; exit;