Ejemplo n.º 1
0
$file_size = null;
$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);
Ejemplo n.º 2
0
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"));
}