function attachments_form($uid, $hash_array) { if (!is_numeric($uid)) { return ''; } if (!is_array($hash_array)) { $hash_array = array(); } $selected_total_size = attachments_get_post_used_space($uid, $hash_array); $attachment_free_post_space = attachments_get_free_post_space($uid, $hash_array); $attachment_free_user_space = attachments_get_free_user_space($uid); $attachments_array = attachments_get($uid, $hash_array); return sprintf('<ul>%s</ul> <div class="buttons"></div> <div class="summary"> <div> <span>%s:</span> <span class="used_post_space">%s</span> </div> <div> <span>%s:</span> <span class="free_post_space">%s</span> </div> <div> <span>%s:</span> <span class="free_upload_space">%s</span> </div> </div> <div class="clearer"></div>', attachments_form_list($attachments_array, $hash_array), gettext("Total Size"), format_file_size($selected_total_size), gettext("Free Post Space"), $attachment_free_post_space >= 0 ? format_file_size($attachment_free_post_space) : gettext("Unlimited"), gettext("Free Upload Space"), $attachment_free_user_space >= 0 ? format_file_size($attachment_free_user_space) : gettext("Unlimited")); }
$file_name = null; $content_type = 'text/html; charset=UTF-8'; $file_hash = md5(uniqid(mt_rand())); $max_user_attachment_space = forum_get_setting('attachments_max_user_space', 'is_numeric', 1048576); $free_upload_space = attachments_get_free_user_space($_SESSION['UID']); $attachment_mime_types = attachments_get_mime_types(); $total_attachment_size = 0; $attachment_dir = rtrim($attachment_dir, '/'); if (isset($_POST['summary'])) { if (isset($_POST['hashes']) && is_array($_POST['hashes'])) { $hash_array = array_filter($_POST['hashes'], 'is_md5'); } else { $hash_array = array(); } $used_post_space = format_file_size(attachments_get_post_used_space($_SESSION['UID'], $hash_array)); $free_post_space = attachments_get_free_post_space($_SESSION['UID'], $hash_array); $content_type = 'application/json; charset=UTF-8'; $content = json_encode(array('used_post_space' => $used_post_space, 'free_post_space' => $free_post_space > -1 ? format_file_size($free_post_space) : gettext("Unlimited"), 'free_upload_space' => $free_upload_space > -1 ? format_file_size($free_upload_space) : gettext("Unlimited"))); } else { if (isset($_POST['delete'])) { $valid = true; if (isset($_POST['hashes']) && is_array($_POST['hashes'])) { foreach ($_POST['hashes'] as $hash) { if (!attachments_delete($hash)) { $valid = false; } } } $content_type = 'application/json; charset=UTF-8'; $content = json_encode($valid); } else {
} else { $aid = false; $t_fid = 0; } } // Check that the UID we have belongs to the current user // or that it is an admin if we're viewing another user's // attachments. if ($uid != session::get_value('UID') && !session::check_perm(USER_PERM_FOLDER_MODERATE, $t_fid)) { html_draw_error(gettext("You do not have permission to use this section.")); } // Total attachment space used $total_attachment_size = 0; // Free space if (is_md5($aid)) { $users_free_space = attachments_get_free_post_space($aid); } else { $users_free_space = attachments_get_free_user_space($uid); } // Check for attachment deletion. if (isset($_POST['delete_confirm'])) { $valid = true; if (isset($_POST['attachments_delete_confirm']) && is_array($_POST['attachments_delete_confirm'])) { foreach ($_POST['attachments_delete_confirm'] as $hash => $del_attachment) { if ($del_attachment == "Y" && attachments_get_by_hash($hash)) { if (!attachments_delete($hash)) { $valid = false; $error_msg_array[] = gettext("Failed to delete all of the selected attachments"); } } }