Пример #1
0
function attachments_get_free_user_space($uid)
{
    $max_user_attachment_space = forum_get_setting('attachments_max_user_space', null, 1048576);
    $user_attachment_space = attachments_get_user_used_space($uid);
    if ($max_user_attachment_space > 0) {
        return $max_user_attachment_space - $user_attachment_space < 0 ? 0 : $max_user_attachment_space - $user_attachment_space;
    }
    return -1;
}
Пример #2
0
// End Required includes
// Check we're logged in correctly
if (!session::logged_in()) {
    html_guest_error();
}
// Array to hold error messages
$error_msg_array = array();
// Arrays to hold our attachments
$attachments_array = array();
$image_attachments_array = array();
// If attachments are disabled then no need to go any further.
if (!($attachment_dir = attachments_check_dir())) {
    html_draw_error(gettext("Attachments have been disabled by the forum owner."));
}
// Total attachment space used
$total_attachment_size = attachments_get_user_used_space($_SESSION['UID']);
// Free space
$attachment_free_user_space = attachments_get_free_user_space($_SESSION['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");
                }
            }
        }
        if ($valid) {