Ejemplo n.º 1
0
    $result = $db->sql_query("SELECT * FROM " . ATTACHMENTS_DESC_TABLE . " ORDER BY attach_id");
    while ($attachrow = $db->sql_fetchrow($result)) {
        if (isset($attachments['_' . $attachrow['attach_id']])) {
            if ($attachrow['comment'] != $attachments['_' . $attachrow['attach_id']]['comment'] || intval($attachrow['download_count']) != intval($attachments['_' . $attachrow['attach_id']]['download_count'])) {
                $sql = "UPDATE " . ATTACHMENTS_DESC_TABLE . " \n\t\t\t\tSET comment = '" . $attachments['_' . $attachrow['attach_id']]['comment'] . "', download_count = " . intval($attachments['_' . $attachrow['attach_id']]['download_count']) . "\n\t\t\t\tWHERE attach_id = " . $attachrow['attach_id'];
                if (!$db->sql_query($sql)) {
                    message_die(GENERAL_ERROR, 'Couldn\'t update Attachments Informations', '', __LINE__, __FILE__, $sql);
                }
            }
        }
    }
} else {
    if ($view == 'stats') {
        $template->set_filenames(array('body' => 'forums/admin/attach_cp_body.html'));
        $upload_dir_size = get_formatted_dirsize();
        $attachment_quota = filesize_to_human(intval($attach_config['attachment_quota']));
        $result = $db->sql_query("SELECT count(*) AS total FROM " . ATTACHMENTS_DESC_TABLE);
        $total = $db->sql_fetchrow($result);
        $number_of_attachments = $total['total'];
        $result = $db->sql_query("SELECT post_id FROM " . ATTACHMENTS_TABLE . " WHERE post_id <> 0 GROUP BY post_id");
        $number_of_posts = $db->sql_numrows($result);
        $result = $db->sql_query("SELECT privmsgs_id FROM " . ATTACHMENTS_TABLE . " WHERE privmsgs_id <> 0 GROUP BY privmsgs_id");
        $number_of_pms = $db->sql_numrows($result);
        $result = $db->sql_query("SELECT p.topic_id FROM " . ATTACHMENTS_TABLE . " a, " . POSTS_TABLE . " p WHERE a.post_id = p.post_id GROUP BY p.topic_id");
        $number_of_topics = $db->sql_numrows($result);
        $result = $db->sql_query("SELECT user_id_1 FROM " . ATTACHMENTS_TABLE . " WHERE (post_id <> 0) GROUP BY user_id_1");
        $number_of_users = $db->sql_numrows($result);
        $template->assign_vars(array('L_STATISTIC' => $lang['Statistic'], 'L_VALUE' => $lang['Value'], 'L_NUMBER_OF_ATTACHMENTS' => $lang['Number_of_attachments'], 'L_TOTAL_FILESIZE' => $lang['Total_filesize'], 'L_ATTACH_QUOTA' => $lang['Attach_quota'], 'L_NUMBER_OF_POSTS' => $lang['Number_posts_attach'], 'L_NUMBER_OF_PMS' => $lang['Number_pms_attach'], 'L_NUMBER_OF_TOPICS' => $lang['Number_topics_attach'], 'L_NUMBER_OF_USERS' => $lang['Number_users_attach'], 'TOTAL_FILESIZE' => $upload_dir_size, 'ATTACH_QUOTA' => $attachment_quota, 'NUMBER_OF_ATTACHMENTS' => $number_of_attachments, 'NUMBER_OF_POSTS' => $number_of_posts, 'NUMBER_OF_PMS' => $number_of_pms, 'NUMBER_OF_TOPICS' => $number_of_topics, 'NUMBER_OF_USERS' => $number_of_users));
    } else {
        if ($view == 'search') {
            //
Ejemplo n.º 2
0
function get_formatted_dirsize()
{
    global $attach_config, $upload_dir, $lang;
    $upload_dir_size = 0;
    if (!intval($attach_config['allow_ftp_upload'])) {
        if ($dirname = opendir($upload_dir)) {
            while ($file = readdir($dirname)) {
                if ($file != 'index.php' && $file != '.htaccess' && !is_dir($upload_dir . '/' . $file) && !is_link($upload_dir . '/' . $file)) {
                    $upload_dir_size += filesize($upload_dir . '/' . $file);
                }
            }
            closedir($dirname);
        } else {
            $upload_dir_size = $lang['Not_available'];
            return $upload_dir_size;
        }
    } else {
        include_once 'includes/classes/cpg_ftp.php';
        $ftp = new cpg_ftp($attach_config['ftp_server'], $attach_config['ftp_user'], $attach_config['ftp_pass'], $attach_config['ftp_path'], $attach_config['ftp_pasv_mode']);
        $file_listing = $ftp->dirlist();
        $ftp->close();
        if (!$file_listing) {
            return $lang['Not_available'];
        }
        for ($i = 0; $i < count($file_listing); $i++) {
            if (!$file_listing[1] && $file_listing[4] != 'index.php' && $file_listing[4] != '.htaccess') {
                $upload_dir_size += $file_listing[1];
            }
        }
    }
    return filesize_to_human($upload_dir_size);
}
Ejemplo n.º 3
0
 /**
  * Get the human readable file size.
  *
  * @return string
  */
 public function getSizeAttribute()
 {
     return filesize_to_human($this->attributes['size']);
 }
Ejemplo n.º 4
0
 $result = $db->sql_query($sql . ' sid DESC LIMIT ' . $storynum . ' OFFSET ' . $offset);
 //	$sql .= ($catid > 0) ?  "s.catid='$catid' $querylang ORDER BY sid DESC" : "$qdb $querylang ORDER BY display_order DESC, time DESC";
 //	$result = $db->sql_query($sql.' LIMIT '.$storynum.' OFFSET 0');
 require_once 'includes/nbbcode.php';
 while ($row = $db->sql_fetchrow($result, SQL_ASSOC)) {
     $title = $row['title'];
     $row['hometext'] = decode_bb_all($row['hometext'], 1, true);
     $morecount = strlen($row['bodytext']);
     $comments = $row['comments'];
     $datetime = formatDateTime($row['time'], _DATESTRING);
     $story_link = '<a href="' . URL::index('News&amp;file=article&amp;sid=' . $row['sid']) . '">';
     $morelink = $commentlink = $catlink = '';
     if ($morecount > 0 || $comments > 0) {
         $morelink .= $story_link . '<b>' . _READMORE . '</b></a>';
         if ($morecount > 0) {
             $morelink .= ' (' . filesize_to_human($morecount) . ') | ';
         } else {
             $morelink .= ' | ';
         }
     }
     if ($row['acomm']) {
         if ($comments == 0) {
             $commentlink = $story_link . _COMMENTSQ . '</a> | ';
         } elseif ($comments == 1) {
             $commentlink = $story_link . $comments . ' ' . _COMMENT . '</a> | ';
         } elseif ($comments > 1) {
             $commentlink = $story_link . $comments . ' ' . _COMMENTS . '</a> | ';
         }
     }
     $printlink = '<a href="' . URL::index('News&amp;file=print&amp;sid=' . $row['sid']) . '"><img src="images/news/print.gif" alt="' . _PRINTER . '" title="' . _PRINTER . '" /></a>';
     if ($row['catid'] != 0) {
Ejemplo n.º 5
0
 private function upload_attachment()
 {
     global $db, $error, $error_msg, $lang, $attach_config, $userdata, $upload_dir, $forum_id;
     $this->post_attach = false;
     if (!is_uploaded_file($_FILES['fileupload']['tmp_name']) || $_FILES['fileupload']['name'] == 'none' || $_FILES['fileupload']['name'] == '') {
         $error = true;
         if (!empty($error_msg)) {
             $error_msg .= '<br />';
         }
         switch ($_FILES['fileupload']['error']) {
             case 1:
                 //uploaded file exceeds the upload_max_filesize directive in php.ini
                 if (!empty($error_msg)) {
                     $error_msg .= '<br />';
                 }
                 $max_size = ini_get('upload_max_filesize');
                 $error_msg .= $max_size == '' ? $lang['Attachment_php_size_na'] : sprintf($lang['Attachment_php_size_overrun'], $max_size);
                 break;
             case 2:
                 //uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the html form
                 $error_msg .= $lang['Attachment_php_size_na'];
                 break;
             case 3:
                 //uploaded file was only partially uploaded
                 $error_msg .= 'The file you are trying upload was only partially uploaded.';
                 break;
         }
         return false;
     }
     $r_file = trim(basename($this->filename));
     $this->filesize = intval($_FILES['fileupload']['size']);
     $this->type = $_FILES['fileupload']['type'];
     // Opera add the name to the mime type
     $this->type = strstr($this->type, '; name') ? str_replace(strstr($this->type, '; name'), '', $this->type) : $this->type;
     $this->extension = get_extension($this->filename);
     $sql = "SELECT g.allow_group, g.max_filesize, g.cat_id, g.forum_permissions\n\t\tFROM " . EXTENSION_GROUPS_TABLE . " g, " . EXTENSIONS_TABLE . " e\n\t\tWHERE (g.group_id = e.group_id) AND (e.extension = '" . $this->extension . "')\n\t\tLIMIT 1";
     $result = $db->sql_query($sql);
     $row = $db->sql_fetchrow($result);
     $allowed_filesize = intval($row['max_filesize']) != 0 ? intval($row['max_filesize']) : intval($attach_config['max_filesize']);
     $cat_id = intval($row['cat_id']);
     $auth_cache = trim($row['forum_permissions']);
     //
     // check Filename
     //
     if (preg_match("/[\\/:*?\"<>|]/i", $this->filename)) {
         $error = TRUE;
         if (!empty($error_msg)) {
             $error_msg .= '<br />';
         }
         $error_msg .= sprintf($lang['Invalid_filename'], $this->filename);
     }
     //
     // Check Extension
     //
     if (!$error && intval($row['allow_group']) == 0) {
         $error = TRUE;
         if (!empty($error_msg)) {
             $error_msg .= '<br />';
         }
         $error_msg .= sprintf($lang['Disallowed_extension'], $this->extension);
     }
     //
     // Check Forum Permissions
     //
     if (!$error && $userdata['user_level'] != ADMIN && !is_forum_authed($auth_cache, $forum_id) && trim($auth_cache) != '') {
         $error = TRUE;
         if (!empty($error_msg)) {
             $error_msg .= '<br />';
         }
         $error_msg .= sprintf($lang['Disallowed_extension_within_forum'], $this->extension);
     }
     //
     // Check Image Size, if it's an image
     //
     $this->thumbnail = intval($cat_id == IMAGE_CAT && intval($attach_config['img_create_thumbnail']));
     if (!$error && $userdata['user_level'] != ADMIN && $cat_id == IMAGE_CAT) {
         list($width, $height) = image_getdimension($_FILES['fileupload']['tmp_name']);
         $attach_config['img_max_width'] = intval($attach_config['img_max_width']);
         $attach_config['img_max_height'] = intval($attach_config['img_max_height']);
         if ($width > 0 && $height > 0 && $attach_config['img_max_width'] > 0 && $attach_config['img_max_height'] > 0 && ($width > $attach_config['img_max_width'] || $height > $attach_config['img_max_height'])) {
             $error = TRUE;
             if (!empty($error_msg)) {
                 $error_msg .= '<br />';
             }
             $error_msg .= sprintf($lang['Error_imagesize'], $attach_config['img_max_width'], $attach_config['img_max_height']);
         }
     }
     //
     // check Filesize
     //
     if (!$error && $allowed_filesize != 0 && $this->filesize > $allowed_filesize && $userdata['user_level'] != ADMIN) {
         $error = TRUE;
         if (!empty($error_msg)) {
             $error_msg .= '<br />';
         }
         $error_msg .= sprintf($lang['Attachment_too_big'], filesize_to_human($allowed_filesize), '');
     }
     //
     // Check our complete quota
     //
     if (intval($attach_config['attachment_quota']) != 0) {
         list($total_filesize) = $db->sql_ufetchrow('SELECT sum(filesize) FROM ' . ATTACHMENTS_DESC_TABLE, SQL_NUM);
         if ($total_filesize + $this->filesize > intval($attach_config['attachment_quota'])) {
             $error = TRUE;
             if (!empty($error_msg)) {
                 $error_msg .= '<br />';
             }
             $error_msg .= $lang['Attach_quota_reached'];
         }
     }
     $this->get_quota_limits($userdata);
     //
     // Check our user quota
     //
     if (intval($attach_config['upload_filesize_limit']) != 0) {
         $sql = "SELECT attach_id FROM " . ATTACHMENTS_TABLE . "\n\t\t\tWHERE (user_id_1 = " . $userdata['user_id'] . ") AND (privmsgs_id = 0)\n\t\t\tGROUP BY attach_id";
         $result = $db->sql_uquery($sql);
         $attach_id = array();
         while ($row = $db->sql_fetchrow($result, SQL_NUM)) {
             $attach_id[] = intval($row[0]);
         }
         if (count($attach_id) > 0) {
             // Now get the total filesize
             list($total_filesize) = $db->sql_ufetchrow("SELECT sum(filesize) FROM " . ATTACHMENTS_DESC_TABLE . " WHERE attach_id IN (" . implode(', ', $attach_id) . ")", SQL_NUM);
         } else {
             $total_filesize = 0;
         }
         if ($total_filesize + $this->filesize > intval($attach_config['upload_filesize_limit'])) {
             $upload_filesize_limit = intval($attach_config['upload_filesize_limit']);
             $error = TRUE;
             if (!empty($error_msg)) {
                 $error_msg .= '<br />';
             }
             $error_msg .= sprintf($lang['User_upload_quota_reached'], filesize_to_human($upload_filesize_limit), '');
         }
     }
     //
     // Prepare Values
     //
     if (!$error) {
         $this->filetime = time();
         $this->filename = $r_file;
         $this->attach_filename = $this->filename;
         // To re-add cryptic filenames, change this variable to true
         $cryptic = false;
         if (!$cryptic) {
             $this->attach_filename = str_replace(' ', '_', $this->attach_filename);
             $this->attach_filename = rawurlencode($this->attach_filename);
             $this->attach_filename = preg_replace("/%(\\w{2})/", "_", $this->attach_filename);
             if ($this->attach_filename != '' && $db->sql_count(ATTACHMENTS_DESC_TABLE, "physical_filename='" . $this->attach_filename . "'") > 0) {
                 $this->attach_filename = substr($this->attach_filename, 0, strrpos($this->attach_filename, '.'));
                 $this->attach_filename = $this->attach_filename . '_' . substr(rand(), 0, 3) . '.' . $this->extension;
             }
         } else {
             $u_id = intval($userdata['user_id']) == ANONYMOUS ? 0 : intval($userdata['user_id']);
             $this->attach_filename = $u_id . '_' . $this->filetime . '.' . $this->extension;
         }
         $this->filename = str_replace("'", "\\'", $this->filename);
     }
     //
     // Upload Attachment
     //
     if (!$error) {
         $this->move_uploaded_attachment($_FILES['fileupload'], $_FILES['fileupload']['tmp_name']);
     }
     $this->post_attach = !$error;
 }
Ejemplo n.º 6
0
function display_attachments($post_id)
{
    global $template, $upload_dir, $userdata, $allowed_extensions, $display_categories, $download_modes, $db, $lang, $attachments, $upload_icons, $attach_config, $module_name;
    if (empty($attachments) || !isset($attachments['_' . $post_id])) {
        //		  trigger_error('There are no attachments for '.$post_id, E_USER_NOTICE);
        return;
    }
    $num_attachments = count($attachments['_' . $post_id]);
    $blockvar = 'postrow.attachment';
    //
    // Some basic Template Vars
    //
    $template->assign_vars(array('L_DESCRIPTION' => $lang['Description'], 'L_DOWNLOAD' => $lang['Download'], 'L_FILENAME' => $lang['File_name'], 'L_FILESIZE' => $lang['Filesize']));
    for ($i = 0; $i < $num_attachments; $i++) {
        //
        // Some basic things...
        //
        $attachments['_' . $post_id][$i]['extension'] = strtolower(trim($attachments['_' . $post_id][$i]['extension']));
        //
        // Admin is allowed to view forbidden Attachments, but the error-message is displayed too to inform the Admin
        //
        $denied = !in_array($attachments['_' . $post_id][$i]['extension'], $allowed_extensions);
        if (!$denied || is_admin()) {
            $filename = $upload_dir . '/' . $attachments['_' . $post_id][$i]['physical_filename'];
            $upload_image = '';
            if ($attach_config['upload_img'] != '' && trim($upload_icons[$attachments['_' . $post_id][$i]['extension']]) == '') {
                $upload_image = '<img src="' . $attach_config['upload_img'] . '" alt="" />';
            } else {
                if (trim($upload_icons[$attachments['_' . $post_id][$i]['extension']]) != '') {
                    $upload_image = '<img src="' . $upload_icons[$attachments['_' . $post_id][$i]['extension']] . '" alt="" />';
                }
            }
            //
            // define category
            //
            $display = 'DEF_CAT';
            if (intval($display_categories[$attachments['_' . $post_id][$i]['extension']]) == STREAM_CAT) {
                $display = 'STREAM_CAT';
            } else {
                if (intval($display_categories[$attachments['_' . $post_id][$i]['extension']]) == SWF_CAT) {
                    $display = 'SWF_CAT';
                } else {
                    if (intval($display_categories[$attachments['_' . $post_id][$i]['extension']]) == IMAGE_CAT && $attachments['_' . $post_id][$i]['thumbnail'] == 1) {
                        $display = 'THUMB_CAT';
                    } else {
                        if (intval($display_categories[$attachments['_' . $post_id][$i]['extension']]) == IMAGE_CAT && intval($attach_config['img_display_inlined'])) {
                            if (intval($attach_config['img_link_width']) != 0 || intval($attach_config['img_link_height']) != 0) {
                                list($width, $height) = image_getdimension($filename);
                                if ($width == 0 && $height == 0) {
                                    $display = 'IMAGE_CAT';
                                } else {
                                    if ($width <= intval($attach_config['img_link_width']) && $height <= intval($attach_config['img_link_height'])) {
                                        $display = 'IMAGE_CAT';
                                    }
                                }
                            } else {
                                $display = 'IMAGE_CAT';
                            }
                        }
                    }
                }
            }
            $thumb_source = '';
            $width = $height = 0;
            $blockname = $blockvar;
            $module = $module_name == 'Private_Messages' ? 'Forums' : $module_name;
            switch ($display) {
                // Images
                case 'IMAGE_CAT':
                    // NOTE: If you want to use the download.php everytime an image is displayed inlined, replace the
                    // Section between BEGIN and END with (Without the // of course):
                    //	  $img_source = URL::index($module.'&amp;file=download&amp;id=' . $attachments['_' . $post_id][$i]['attach_id']);
                    //	  $download_link = TRUE;
                    //
                    if (intval($attach_config['allow_ftp_upload']) && trim($attach_config['download_path']) == '') {
                        $filename = URL::index($module . '&amp;file=download&amp;id=' . $attachments['_' . $post_id][$i]['attach_id']);
                        $download_link = TRUE;
                    } else {
                        $download_link = FALSE;
                    }
                    //
                    // Directly Viewed Image ... update the download count
                    //
                    if (!$download_link) {
                        $db->sql_query('UPDATE ' . ATTACHMENTS_DESC_TABLE . '
						SET download_count = download_count + 1
						WHERE attach_id = ' . $attachments['_' . $post_id][$i]['attach_id']);
                    }
                    break;
                    // Images, but display Thumbnail
                // Images, but display Thumbnail
                case 'THUMB_CAT':
                    // NOTE: If you want to use the download.php everytime an thumnmail is displayed inlined, replace the
                    // Section between BEGIN and END with (Without the // of course):
                    //	  $thumb_source = URL::index($module.'&amp;file=download&amp;id=' . $attachments['_' . $post_id][$i]['attach_id'] . '&thumb=1');
                    //
                    if (intval($attach_config['allow_ftp_upload']) && trim($attach_config['download_path']) == '') {
                        $thumb_source = URL::index($module . '&amp;file=download&amp;id=' . $attachments['_' . $post_id][$i]['attach_id'] . '&thumb=1');
                    } else {
                        $thumb_source = $upload_dir . '/' . THUMB_DIR . '/t_' . $attachments['_' . $post_id][$i]['physical_filename'];
                    }
                    $filename = URL::index($module . '&amp;file=download&amp;id=' . $attachments['_' . $post_id][$i]['attach_id']);
                    break;
                    // Streams
                // Streams
                case 'STREAM_CAT':
                    //
                    // Viewed/Heared File ... update the download count (download.php is not called here)
                    //
                    $db->sql_query('UPDATE ' . ATTACHMENTS_DESC_TABLE . '
					SET download_count = download_count + 1
					WHERE attach_id = ' . $attachments['_' . $post_id][$i]['attach_id']);
                    break;
                    // Macromedia Flash Files
                // Macromedia Flash Files
                case 'SWF_CAT':
                    list($width, $height) = swf_getdimension($filename);
                    //
                    // Viewed/Heared File ... update the download count (download.php is not called here)
                    //
                    $db->sql_query('UPDATE ' . ATTACHMENTS_DESC_TABLE . '
					SET download_count = download_count + 1
					WHERE attach_id = ' . $attachments['_' . $post_id][$i]['attach_id']);
                    break;
                    // display attachment
                // display attachment
                default:
                    $filename = URL::index($module . '&amp;file=download&amp;id=' . $attachments['_' . $post_id][$i]['attach_id']);
                    break;
            }
            $template->assign_block_vars($blockname, array('L_ALLOWED' => !$denied || is_admin(), 'L_DENIED' => $denied ? sprintf($lang['Extension_disabled_after_posting'], $attachments['_' . $post_id][$i]['extension']) : false, 'S_DEF_CAT' => false, 'S_IMAGE_CAT' => false, 'S_THUMB_CAT' => false, 'S_STREAM_CAT' => false, 'S_SWF_CAT' => false, 'S_' . $display => true, 'DOWNLOAD_NAME' => $attachments['_' . $post_id][$i]['real_filename'], 'S_UPLOAD_IMAGE' => $upload_image, 'FILESIZE' => filesize_to_human($attachments['_' . $post_id][$i]['filesize']), 'COMMENT' => htmlprepare($attachments['_' . $post_id][$i]['comment'], true), 'L_DOWNLOADED_VIEWED' => $display == 'DEF_CAT' ? $lang['Downloaded'] : $lang['Viewed'], 'L_DOWNLOAD_COUNT' => sprintf($lang['Download_number'], $attachments['_' . $post_id][$i]['download_count']), 'IMG_SRC' => $filename, 'IMG_THUMB_SRC' => $thumb_source, 'U_DOWNLOAD_LINK' => $filename, 'WIDTH' => $width, 'HEIGHT' => $height, 'TARGET_BLANK' => intval($display_categories[$attachments['_' . $post_id][$i]['extension']]) == IMAGE_CAT || $display == 'DEF_CAT' ? 'target="_blank"' : ''));
        }
    }
}
Ejemplo n.º 7
0
$rows = $db->sql_fetchrowset($result);
$num_rows = $db->sql_numrows($result);
// Ok, only process those Groups allowed within this forum
$nothing = TRUE;
for ($i = 0; $i < $num_rows; $i++) {
    $auth_cache = trim($rows[$i]['forum_permissions']);
    if ($privmsg) {
        $permit = TRUE;
    } else {
        $permit = is_forum_authed($auth_cache, $forum_id) || trim($rows[$i]['forum_permissions']) == '';
    }
    if ($permit) {
        $nothing = FALSE;
        $group_name = $rows[$i]['group_name'];
        $det_filesize = intval(trim($rows[$i]['max_filesize']));
        $max_filesize = $det_filesize == 0 ? $lang['Unlimited'] : filesize_to_human($det_filesize);
        $template->assign_block_vars('group_row', array('GROUP_RULE_HEADER' => sprintf($lang['Group_rule_header'], $group_name, $max_filesize)));
        $sql = "SELECT extension FROM " . EXTENSIONS_TABLE . "\n\t\tWHERE group_id = " . $rows[$i]['group_id'] . "\n\t\tORDER BY extension ASC";
        $result = $db->sql_query($sql, false, __FILE, __LINE__);
        $e_rows = $db->sql_fetchrowset($result);
        $e_num_rows = $db->sql_numrows($result);
        for ($j = 0; $j < $e_num_rows; $j++) {
            $template->assign_block_vars('group_row.extension_row', array('EXTENSION' => $e_rows[$j]['extension']));
        }
    }
}
$gen_simple_header = TRUE;
$page_title = $lang['Attach_rules_title'];
require_once 'includes/phpBB/page_header.php';
$template->assign_vars(array('L_RULES_TITLE' => $lang['Attach_rules_title'], 'L_CLOSE_WINDOW' => $lang['Close_window'], 'L_EMPTY_GROUP_PERMS' => $lang['Note_user_empty_group_permissions']));
if ($nothing) {
Ejemplo n.º 8
0
        if (intval($attach_config['upload_filesize_limit']) == 0) {
            $upload_filesize_limit = intval($attach_config['attachment_quota']);
        } else {
            $upload_filesize_limit = intval($attach_config['upload_filesize_limit']);
        }
        $user_quota = $upload_filesize_limit == 0 ? $lang['Unlimited'] : filesize_to_human($upload_filesize_limit);
        //
        // Get all attach_id's the specific user posted, but only uploads to the board and not Private Messages
        //
        $sql = "SELECT attach_id FROM " . ATTACHMENTS_TABLE . "\n\t\tWHERE (user_id_1 = " . $user_id . ") AND (privmsgs_id = 0)\n\t\tGROUP BY attach_id";
        $result = $db->sql_query($sql);
        $attach_ids = $db->sql_fetchrowset($result);
        $num_attach_ids = $db->sql_numrows($result);
        $attach_id = array();
        for ($j = 0; $j < $num_attach_ids; $j++) {
            $attach_id[] = intval($attach_ids[$j]['attach_id']);
        }
        $upload_filesize = count($attach_id) > 0 ? get_total_attach_filesize(implode(',', $attach_id)) : 0;
        $user_uploaded = filesize_to_human($upload_filesize);
        $upload_limit_pct = $upload_filesize_limit > 0 ? round($upload_filesize / $upload_filesize_limit * 100) : 0;
        $upload_limit_img_length = $upload_filesize_limit > 0 ? round($upload_filesize / $upload_filesize_limit * $board_config['privmsg_graphic_length']) : 0;
        if ($upload_limit_pct > 100) {
            $upload_limit_img_length = $board_config['privmsg_graphic_length'];
        }
        $upload_limit_remain = $upload_filesize_limit > 0 ? $upload_filesize_limit - $upload_filesize : 100;
        $l_box_size_status = sprintf($lang['Upload_percent_profile'], $upload_limit_pct);
        $cpgtpl->assign_vars(array('S_UPLOAD_QUOTA' => $lang['Upload_quota'], 'BGCOLOR4' => $bgcolor4, 'UPLOAD_LIMIT_WIDTH' => $upload_limit_img_length, 'UPLOAD_LIMIT_PERCENT' => $upload_limit_pct, 'S_UPLOADED' => sprintf($lang['User_uploaded_profile'], $user_uploaded), 'S_QUOTA' => sprintf($lang['User_quota_profile'], $user_quota), 'S_TOTAL' => $l_box_size_status, 'ATTACHMENT_CP_URL' => URL::index('Forums&amp;file=uacp&amp;u=' . $user_id), 'S_ATTACHMENT_CP' => $lang['UACP']));
        $cpgtpl->set_handle('ya_block', 'your_account/blocks/forumsattach.html');
        $cpgtpl->display('ya_block');
    }
}
Ejemplo n.º 9
0
                    if ($version != $editmodule->version) {
                        $version .= ' <a href="' . URL::admin('&amp;upgrade=' . $mid) . '">' . sprintf(_UPGRADE, $editmodule->version) . '</a>';
                    }
                    $dbsize = 0;
                    $backup = '';
                    if (isset($editmodule->dbtables) && !empty($editmodule->dbtables)) {
                        if (0 === strpos(SQL_LAYER, 'mysql')) {
                            if ($result = $db->sql_query("SHOW TABLE STATUS FROM {$dbname}", true)) {
                                while ($table = $db->sql_fetchrow($result)) {
                                    if (in_array(substr($table['Name'], strlen($prefix) + 1), $editmodule->dbtables) && (isset($table['Type']) && $table['Type'] != 'MRG_MyISAM' || isset($table['Engine']) && $table['Engine'] != "MRG_MyISAM")) {
                                        $dbsize += $table['Data_length'] + $table['Index_length'];
                                    }
                                }
                            }
                        }
                        $backup = '<label class="ulog">' . _DBSIZE . '</label>' . filesize_to_human($dbsize) . ', <a href="' . URL::admin('&amp;backup=' . $title) . '">' . _SAVEDATABASE . '</a><br />';
                    }
                    if (strlen($editmodule->website) > 3) {
                        $author = '<a href="http://' . $editmodule->website . '" target="_blank">' . $editmodule->author . '</a>';
                    } else {
                        $author = $editmodule->author;
                    }
                    echo '<fieldset><legend><b>' . _TB_INFO . '</b></legend>
	<label class="ulog">' . _CREDITS_AUTHORS . '</label>' . $author . '<br />
	<label class="ulog">' . _CREDITS_DESC . '</label>' . $editmodule->description . '<br />
	<label class="ulog">' . _VERSION . '</label>' . $version . '<br />
	' . $backup . '
	</fieldset>';
                }
                //	if (is_dir('modules/'.$title.'/CVS')) {
                if (is_dir('modules/' . $title . '/CVS') && is_writeable('modules/' . $title)) {