当前位置: 首页>>代码示例>>PHP>>正文


PHP get_formatted_filesize函数代码示例

本文整理汇总了PHP中get_formatted_filesize函数的典型用法代码示例。如果您正苦于以下问题:PHP get_formatted_filesize函数的具体用法?PHP get_formatted_filesize怎么用?PHP get_formatted_filesize使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了get_formatted_filesize函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: end_output

/**
* Main file
*
* @package mpv_server
* @version $Id$
* @copyright (c) 2010 phpBB Group
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
*
*/
function end_output()
{
    global $starttime, $lang;
    // Some debug stuff.
    $mtime = explode(' ', microtime());
    $totaltime = $mtime[0] + $mtime[1] - $starttime;
    if (is_array($lang)) {
        $debug_output = "\n" . sprintf($lang['TOTAL_TIME'], $totaltime);
    } else {
        $debug_output = "\n" . sprintf('Time : %.3fs', $totaltime);
    }
    if (function_exists('memory_get_usage') && is_array($lang)) {
        if ($memory_usage = memory_get_usage()) {
            global $base_memory_usage;
            $memory_usage -= $base_memory_usage;
            $memory_usage = get_formatted_filesize($memory_usage);
            $debug_output .= ' | ' . $lang['MEM_USE'] . ' ' . $memory_usage;
        }
    }
    print $debug_output . "\n" . (HTML_HEADERS ? "</body></html>" : "");
}
开发者ID:phpbb,项目名称:mpv,代码行数:30,代码来源:functions_mpv.php

示例2: max_filesize

 /**
  * Adjust all three max_filesize config vars for display
  */
 function max_filesize($value, $key = '')
 {
     // Determine size var and adjust the value accordingly
     $filesize = get_formatted_filesize($value, false, array('mb', 'kb', 'b'));
     $size_var = $filesize['si_identifier'];
     $value = $filesize['value'];
     // size and maxlength must not be specified for input of type number
     return '<input type="number" id="' . $key . '" min="0" max="999999999999999" step="any" name="config[' . $key . ']" value="' . $value . '" /> <select name="' . $key . '">' . size_select_options($size_var) . '</select>';
 }
开发者ID:bantu,项目名称:phpbb,代码行数:12,代码来源:acp_attachments.php

示例3: rawurlencode

 $size = $item instanceof steam_document ? $data_result[$data_tnr[$item->get_id()]["contentsize"]] : 0;
 if ($item instanceof steam_container || $item instanceof steam_room) {
     $content->setVariable("LINK_ITEM", $base_url . $item->get_id());
     $edit_link = $base_url . $item->get_id() . "/" . "edit";
     $delete_link = $base_url . $item->get_id() . "/" . "delete";
 } else {
     if ($item instanceof steam_docextern) {
         $content->setVariable("LINK_ITEM", $attributes[DOC_EXTERN_URL]);
         $edit_link = PATH_URL . "doc/" . $item->get_id() . "/" . "edit";
         $delete_link = PATH_URL . "doc/" . $item->get_id() . "/" . "delete";
     } else {
         // Document
         //      $content->setVariable( "LINK_ITEM", PATH_URL . "get_document.php?id=" . $item->get_id() );
         $content->setVariable("LINK_ITEM", PATH_URL . "download/" . $item->get_id() . "/" . rawurlencode($attributes[OBJ_NAME]));
         //$content->setVariable( "LINK_ITEM", PATH_URL . "doc/" . $item->get_id() . "/");
         $content->setVariable("SIZE_ITEM", get_formatted_filesize($size));
         $last_modified = $attributes[DOC_LAST_MODIFIED];
         $edit_link = PATH_URL . "doc/" . $item->get_id() . "/edit";
         $delete_link = PATH_URL . "doc/" . $item->get_id() . "/delete";
     }
 }
 if (!isset($last_modified) || $last_modified == 0) {
     $last_modified = $attributes[OBJ_CREATION_TIME];
 }
 if ($last_modified != 0) {
     $authorname = $author_result[$author_tnr[$item->get_id()]["authorname"]];
     $authorstring = "<a href=\"" . PATH_URL . "user/" . $authorname . "/\">" . $authorname . "</a>";
     $modifiedstring = $authorstring . "<br />" . "<small>" . strftime("%x", $last_modified) . strftime(", %R", $last_modified) . "</small>";
     $content->setVariable("MODIFIED_ITEM", $modifiedstring);
 }
 $content->setVariable("VALUE_COMMENTS", str_replace("%NO_COMMENTS", count($data_result[$data_tnr[$item->get_id()]["annotations"]]), gettext("%NO_COMMENTS comments")));
开发者ID:rolwi,项目名称:koala,代码行数:31,代码来源:container_inventory.php

示例4: main


//.........这里部分代码省略.........
                $s_sort_key = '';
                foreach ($sk_text as $key => $value) {
                    $selected = $sort_key == $key ? ' selected="selected"' : '';
                    $s_sort_key .= '<option value="' . $key . '"' . $selected . '>' . $value . '</option>';
                }
                $s_sort_dir = '';
                foreach ($sd_text as $key => $value) {
                    $selected = $sort_dir == $key ? ' selected="selected"' : '';
                    $s_sort_dir .= '<option value="' . $key . '"' . $selected . '>' . $value . '</option>';
                }
                if (!isset($sk_sql[$sort_key])) {
                    $sort_key = 'a';
                }
                $order_by = $sk_sql[$sort_key] . ' ' . ($sort_dir == 'a' ? 'ASC' : 'DESC');
                $sql = 'SELECT COUNT(attach_id) as num_attachments
					FROM ' . ATTACHMENTS_TABLE . "\n\t\t\t\t\tWHERE poster_id = {$user_id}\n\t\t\t\t\t\tAND is_orphan = 0";
                $result = $db->sql_query_limit($sql, 1);
                $num_attachments = (int) $db->sql_fetchfield('num_attachments');
                $db->sql_freeresult($result);
                $sql = 'SELECT a.*, t.topic_title, p.message_subject as message_title
					FROM ' . ATTACHMENTS_TABLE . ' a
						LEFT JOIN ' . TOPICS_TABLE . ' t ON (a.topic_id = t.topic_id
							AND a.in_message = 0)
						LEFT JOIN ' . PRIVMSGS_TABLE . ' p ON (a.post_msg_id = p.msg_id
							AND a.in_message = 1)
					WHERE a.poster_id = ' . $user_id . "\n\t\t\t\t\t\tAND a.is_orphan = 0\n\t\t\t\t\tORDER BY {$order_by}";
                $result = $db->sql_query_limit($sql, $config['topics_per_page'], $start);
                while ($row = $db->sql_fetchrow($result)) {
                    if ($row['in_message']) {
                        $view_topic = append_sid("{$phpbb_root_path}ucp.{$phpEx}", "i=pm&amp;p={$row['post_msg_id']}");
                    } else {
                        $view_topic = append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", "t={$row['topic_id']}&amp;p={$row['post_msg_id']}") . '#p' . $row['post_msg_id'];
                    }
                    $template->assign_block_vars('attach', array('REAL_FILENAME' => $row['real_filename'], 'COMMENT' => nl2br($row['attach_comment']), 'EXTENSION' => $row['extension'], 'SIZE' => get_formatted_filesize($row['filesize']), 'DOWNLOAD_COUNT' => $row['download_count'], 'POST_TIME' => $user->format_date($row['filetime']), 'TOPIC_TITLE' => $row['in_message'] ? $row['message_title'] : $row['topic_title'], 'ATTACH_ID' => $row['attach_id'], 'POST_ID' => $row['post_msg_id'], 'TOPIC_ID' => $row['topic_id'], 'S_IN_MESSAGE' => $row['in_message'], 'U_DOWNLOAD' => append_sid("{$phpbb_root_path}download/file.{$phpEx}", 'mode=view&amp;id=' . $row['attach_id']), 'U_VIEW_TOPIC' => $view_topic));
                }
                $db->sql_freeresult($result);
                $base_url = $this->u_action . "&amp;u={$user_id}&amp;sk={$sort_key}&amp;sd={$sort_dir}";
                $pagination->generate_template_pagination($base_url, 'pagination', 'start', $num_attachments, $config['topics_per_page'], $start);
                $template->assign_vars(array('S_ATTACHMENTS' => true, 'S_SORT_KEY' => $s_sort_key, 'S_SORT_DIR' => $s_sort_dir));
                break;
            case 'groups':
                if (!function_exists('group_user_attributes')) {
                    include $phpbb_root_path . 'includes/functions_user.' . $phpEx;
                }
                $user->add_lang(array('groups', 'acp/groups'));
                $group_id = $request->variable('g', 0);
                if ($group_id) {
                    // Check the founder only entry for this group to make sure everything is well
                    $sql = 'SELECT group_founder_manage
						FROM ' . GROUPS_TABLE . '
						WHERE group_id = ' . $group_id;
                    $result = $db->sql_query($sql);
                    $founder_manage = (int) $db->sql_fetchfield('group_founder_manage');
                    $db->sql_freeresult($result);
                    if ($user->data['user_type'] != USER_FOUNDER && $founder_manage) {
                        trigger_error($user->lang['NOT_ALLOWED_MANAGE_GROUP'] . adm_back_link($this->u_action . '&amp;u=' . $user_id), E_USER_WARNING);
                    }
                }
                switch ($action) {
                    case 'demote':
                    case 'promote':
                    case 'default':
                        if (!$group_id) {
                            trigger_error($user->lang['NO_GROUP'] . adm_back_link($this->u_action . '&amp;u=' . $user_id), E_USER_WARNING);
                        }
                        group_user_attributes($action, $group_id, $user_id);
开发者ID:bantu,项目名称:phpbb,代码行数:67,代码来源:acp_users.php

示例5: posting_gen_attachment_entry

/**
* Generate inline attachment entry
*/
function posting_gen_attachment_entry($attachment_data, &$filename_data, $show_attach_box = true)
{
    global $template, $config, $phpbb_root_path, $phpEx, $user;
    // Some default template variables
    $template->assign_vars(array('S_SHOW_ATTACH_BOX' => $show_attach_box, 'S_HAS_ATTACHMENTS' => sizeof($attachment_data), 'FILESIZE' => $config['max_filesize'], 'FILE_COMMENT' => isset($filename_data['filecomment']) ? $filename_data['filecomment'] : ''));
    if (sizeof($attachment_data)) {
        // We display the posted attachments within the desired order.
        $config['display_order'] ? krsort($attachment_data) : ksort($attachment_data);
        foreach ($attachment_data as $count => $attach_row) {
            $hidden = '';
            $attach_row['real_filename'] = utf8_basename($attach_row['real_filename']);
            foreach ($attach_row as $key => $value) {
                $hidden .= '<input type="hidden" name="attachment_data[' . $count . '][' . $key . ']" value="' . $value . '" />';
            }
            $download_link = append_sid("{$phpbb_root_path}download/file.{$phpEx}", 'mode=view&amp;id=' . (int) $attach_row['attach_id'], true, $attach_row['is_orphan'] ? $user->session_id : false);
            $template->assign_block_vars('attach_row', array('FILENAME' => utf8_basename($attach_row['real_filename']), 'A_FILENAME' => addslashes(utf8_basename($attach_row['real_filename'])), 'FILE_COMMENT' => $attach_row['attach_comment'], 'ATTACH_ID' => $attach_row['attach_id'], 'S_IS_ORPHAN' => $attach_row['is_orphan'], 'ASSOC_INDEX' => $count, 'FILESIZE' => get_formatted_filesize($attach_row['filesize']), 'U_VIEW_ATTACHMENT' => $download_link, 'S_HIDDEN' => $hidden));
        }
    }
    return sizeof($attachment_data);
}
开发者ID:prototech,项目名称:phpbb,代码行数:23,代码来源:functions_posting.php

示例6: main

    function main($id, $mode)
    {
        global $template, $user, $db, $config, $phpEx, $phpbb_root_path, $phpbb_container, $request;
        $start = $request->variable('start', 0);
        $sort_key = $request->variable('sk', 'a');
        $sort_dir = $request->variable('sd', 'a');
        $delete = isset($_POST['delete']) ? true : false;
        $delete_ids = array_keys($request->variable('attachment', array(0)));
        if ($delete && sizeof($delete_ids)) {
            // Validate $delete_ids...
            $sql = 'SELECT attach_id
				FROM ' . ATTACHMENTS_TABLE . '
				WHERE poster_id = ' . $user->data['user_id'] . '
					AND is_orphan = 0
					AND ' . $db->sql_in_set('attach_id', $delete_ids);
            $result = $db->sql_query($sql);
            $delete_ids = array();
            while ($row = $db->sql_fetchrow($result)) {
                $delete_ids[] = $row['attach_id'];
            }
            $db->sql_freeresult($result);
        }
        if ($delete && sizeof($delete_ids)) {
            $s_hidden_fields = array('delete' => 1);
            foreach ($delete_ids as $attachment_id) {
                $s_hidden_fields['attachment'][$attachment_id] = 1;
            }
            if (confirm_box(true)) {
                /** @var \phpbb\attachment\manager $attachment_manager */
                $attachment_manager = $phpbb_container->get('attachment.manager');
                $attachment_manager->delete('attach', $delete_ids);
                unset($attachment_manager);
                meta_refresh(3, $this->u_action);
                $message = (sizeof($delete_ids) == 1 ? $user->lang['ATTACHMENT_DELETED'] : $user->lang['ATTACHMENTS_DELETED']) . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], '<a href="' . $this->u_action . '">', '</a>');
                trigger_error($message);
            } else {
                confirm_box(false, sizeof($delete_ids) == 1 ? 'DELETE_ATTACHMENT' : 'DELETE_ATTACHMENTS', build_hidden_fields($s_hidden_fields));
            }
        }
        // Select box eventually
        $sort_key_text = array('a' => $user->lang['SORT_FILENAME'], 'b' => $user->lang['SORT_COMMENT'], 'c' => $user->lang['SORT_EXTENSION'], 'd' => $user->lang['SORT_SIZE'], 'e' => $user->lang['SORT_DOWNLOADS'], 'f' => $user->lang['SORT_POST_TIME'], 'g' => $user->lang['SORT_TOPIC_TITLE']);
        $sort_key_sql = array('a' => 'a.real_filename', 'b' => 'a.attach_comment', 'c' => 'a.extension', 'd' => 'a.filesize', 'e' => 'a.download_count', 'f' => 'a.filetime', 'g' => 't.topic_title');
        $sort_dir_text = array('a' => $user->lang['ASCENDING'], 'd' => $user->lang['DESCENDING']);
        $s_sort_key = '';
        foreach ($sort_key_text as $key => $value) {
            $selected = $sort_key == $key ? ' selected="selected"' : '';
            $s_sort_key .= '<option value="' . $key . '"' . $selected . '>' . $value . '</option>';
        }
        $s_sort_dir = '';
        foreach ($sort_dir_text as $key => $value) {
            $selected = $sort_dir == $key ? ' selected="selected"' : '';
            $s_sort_dir .= '<option value="' . $key . '"' . $selected . '>' . $value . '</option>';
        }
        if (!isset($sort_key_sql[$sort_key])) {
            $sort_key = 'a';
        }
        $order_by = $sort_key_sql[$sort_key] . ' ' . ($sort_dir == 'a' ? 'ASC' : 'DESC');
        $sql = 'SELECT COUNT(attach_id) as num_attachments
			FROM ' . ATTACHMENTS_TABLE . '
			WHERE poster_id = ' . $user->data['user_id'] . '
				AND is_orphan = 0';
        $result = $db->sql_query($sql);
        $num_attachments = $db->sql_fetchfield('num_attachments');
        $db->sql_freeresult($result);
        // Ensure start is a valid value
        /* @var $pagination \phpbb\pagination */
        $pagination = $phpbb_container->get('pagination');
        $start = $pagination->validate_start($start, $config['topics_per_page'], $num_attachments);
        $sql = 'SELECT a.*, t.topic_title, p.message_subject as message_title
			FROM ' . ATTACHMENTS_TABLE . ' a
				LEFT JOIN ' . TOPICS_TABLE . ' t ON (a.topic_id = t.topic_id AND a.in_message = 0)
				LEFT JOIN ' . PRIVMSGS_TABLE . ' p ON (a.post_msg_id = p.msg_id AND a.in_message = 1)
			WHERE a.poster_id = ' . $user->data['user_id'] . "\n\t\t\t\tAND a.is_orphan = 0\n\t\t\tORDER BY {$order_by}";
        $result = $db->sql_query_limit($sql, $config['topics_per_page'], $start);
        $row_count = 0;
        if ($row = $db->sql_fetchrow($result)) {
            $template->assign_var('S_ATTACHMENT_ROWS', true);
            do {
                if ($row['in_message']) {
                    $view_topic = append_sid("{$phpbb_root_path}ucp.{$phpEx}", "i=pm&amp;p={$row['post_msg_id']}");
                } else {
                    $view_topic = append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", "t={$row['topic_id']}&amp;p={$row['post_msg_id']}") . "#p{$row['post_msg_id']}";
                }
                $template->assign_block_vars('attachrow', array('ROW_NUMBER' => $row_count + ($start + 1), 'FILENAME' => $row['real_filename'], 'COMMENT' => bbcode_nl2br($row['attach_comment']), 'EXTENSION' => $row['extension'], 'SIZE' => get_formatted_filesize($row['filesize']), 'DOWNLOAD_COUNT' => $row['download_count'], 'POST_TIME' => $user->format_date($row['filetime']), 'TOPIC_TITLE' => $row['in_message'] ? $row['message_title'] : $row['topic_title'], 'ATTACH_ID' => $row['attach_id'], 'POST_ID' => $row['post_msg_id'], 'TOPIC_ID' => $row['topic_id'], 'S_IN_MESSAGE' => $row['in_message'], 'U_VIEW_ATTACHMENT' => append_sid("{$phpbb_root_path}download/file.{$phpEx}", 'id=' . $row['attach_id']), 'U_VIEW_TOPIC' => $view_topic));
                $row_count++;
            } while ($row = $db->sql_fetchrow($result));
        }
        $db->sql_freeresult($result);
        $base_url = $this->u_action . "&amp;sk={$sort_key}&amp;sd={$sort_dir}";
        $pagination->generate_template_pagination($base_url, 'pagination', 'start', $num_attachments, $config['topics_per_page'], $start);
        $template->assign_vars(array('TOTAL_ATTACHMENTS' => $num_attachments, 'NUM_ATTACHMENTS' => $user->lang('NUM_ATTACHMENTS', $num_attachments), 'L_TITLE' => $user->lang['UCP_ATTACHMENTS'], 'U_SORT_FILENAME' => $this->u_action . "&amp;sk=a&amp;sd=" . ($sort_key == 'a' && $sort_dir == 'a' ? 'd' : 'a'), 'U_SORT_FILE_COMMENT' => $this->u_action . "&amp;sk=b&amp;sd=" . ($sort_key == 'b' && $sort_dir == 'a' ? 'd' : 'a'), 'U_SORT_EXTENSION' => $this->u_action . "&amp;sk=c&amp;sd=" . ($sort_key == 'c' && $sort_dir == 'a' ? 'd' : 'a'), 'U_SORT_FILESIZE' => $this->u_action . "&amp;sk=d&amp;sd=" . ($sort_key == 'd' && $sort_dir == 'a' ? 'd' : 'a'), 'U_SORT_DOWNLOADS' => $this->u_action . "&amp;sk=e&amp;sd=" . ($sort_key == 'e' && $sort_dir == 'a' ? 'd' : 'a'), 'U_SORT_POST_TIME' => $this->u_action . "&amp;sk=f&amp;sd=" . ($sort_key == 'f' && $sort_dir == 'a' ? 'd' : 'a'), 'U_SORT_TOPIC_TITLE' => $this->u_action . "&amp;sk=g&amp;sd=" . ($sort_key == 'g' && $sort_dir == 'a' ? 'd' : 'a'), 'S_DISPLAY_MARK_ALL' => $num_attachments ? true : false, 'S_DISPLAY_PAGINATION' => $num_attachments ? true : false, 'S_UCP_ACTION' => $this->u_action, 'S_SORT_OPTIONS' => $s_sort_key, 'S_ORDER_SELECT' => $s_sort_dir));
        $this->tpl_name = 'ucp_attachments';
        $this->page_title = 'UCP_ATTACHMENTS';
    }
开发者ID:bruninoit,项目名称:phpbb,代码行数:94,代码来源:ucp_attachments.php

示例7: main


//.........这里部分代码省略.........
                            }
                            unset($posted);
                            if (sizeof($sql_ary)) {
                                $db->sql_multi_insert(TOPICS_POSTED_TABLE, $sql_ary);
                            }
                        }
                        add_log('admin', 'LOG_RESYNC_POST_MARKING');
                        break;
                    case 'purge_cache':
                        if ((int) $user->data['user_type'] !== USER_FOUNDER) {
                            trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action), E_USER_WARNING);
                        }
                        global $cache;
                        $cache->purge();
                        // Clear permissions
                        $auth->acl_clear_prefetch();
                        cache_moderators();
                        add_log('admin', 'LOG_PURGE_CACHE');
                        break;
                }
            }
        }
        // Get forum statistics
        $total_posts = $config['num_posts'];
        $total_topics = $config['num_topics'];
        $total_users = $config['num_users'];
        $total_files = $config['num_files'];
        $start_date = $user->format_date($config['board_startdate']);
        $boarddays = (time() - $config['board_startdate']) / 86400;
        $posts_per_day = sprintf('%.2f', $total_posts / $boarddays);
        $topics_per_day = sprintf('%.2f', $total_topics / $boarddays);
        $users_per_day = sprintf('%.2f', $total_users / $boarddays);
        $files_per_day = sprintf('%.2f', $total_files / $boarddays);
        $upload_dir_size = get_formatted_filesize($config['upload_dir_size']);
        $avatar_dir_size = 0;
        if ($avatar_dir = @opendir($phpbb_root_path . $config['avatar_path'])) {
            while (($file = readdir($avatar_dir)) !== false) {
                if ($file[0] != '.' && $file != 'CVS' && strpos($file, 'index.') === false) {
                    $avatar_dir_size += filesize($phpbb_root_path . $config['avatar_path'] . '/' . $file);
                }
            }
            closedir($avatar_dir);
            $avatar_dir_size = get_formatted_filesize($avatar_dir_size);
        } else {
            // Couldn't open Avatar dir.
            $avatar_dir_size = $user->lang['NOT_AVAILABLE'];
        }
        if ($posts_per_day > $total_posts) {
            $posts_per_day = $total_posts;
        }
        if ($topics_per_day > $total_topics) {
            $topics_per_day = $total_topics;
        }
        if ($users_per_day > $total_users) {
            $users_per_day = $total_users;
        }
        if ($files_per_day > $total_files) {
            $files_per_day = $total_files;
        }
        if ($config['allow_attachments'] || $config['allow_pm_attach']) {
            $sql = 'SELECT COUNT(attach_id) AS total_orphan
				FROM ' . ATTACHMENTS_TABLE . '
				WHERE is_orphan = 1
					AND filetime < ' . (time() - 3 * 60 * 60);
            $result = $db->sql_query($sql);
            $total_orphan = (int) $db->sql_fetchfield('total_orphan');
开发者ID:BackupTheBerlios,项目名称:phpbb-hu-svn,代码行数:67,代码来源:acp_main.php

示例8: template_cache


//.........这里部分代码省略.........
        $file_ary = array_diff(request_var('delete', array('')), array(''));
        $submit = isset($_POST['submit']) ? true : false;
        $sql = 'SELECT *
			FROM ' . STYLES_TEMPLATE_TABLE . "\n\t\t\tWHERE template_id = {$template_id}";
        $result = $db->sql_query($sql);
        $template_row = $db->sql_fetchrow($result);
        $db->sql_freeresult($result);
        if (!$template_row) {
            trigger_error($user->lang['NO_TEMPLATE'] . adm_back_link($this->u_action), E_USER_WARNING);
        }
        // User wants to delete one or more files ...
        if ($submit && $file_ary) {
            $this->clear_template_cache($template_row, $file_ary);
            trigger_error($user->lang['TEMPLATE_CACHE_CLEARED'] . adm_back_link($this->u_action . "&amp;action=cache&amp;id={$template_id}"));
        }
        $cache_prefix = 'tpl_' . str_replace('_', '-', $template_row['template_path']);
        // Someone wants to see the cached source ... so we'll highlight it,
        // add line numbers and indent it appropriately. This could be nasty
        // on larger source files ...
        if ($source && file_exists("{$phpbb_root_path}cache/{$cache_prefix}_{$source}.html.{$phpEx}")) {
            adm_page_header($user->lang['TEMPLATE_CACHE']);
            $template->set_filenames(array('body' => 'viewsource.html'));
            $template->assign_vars(array('FILENAME' => str_replace('.', '/', $source) . '.html'));
            $code = str_replace(array("\r\n", "\r"), array("\n", "\n"), file_get_contents("{$phpbb_root_path}cache/{$cache_prefix}_{$source}.html.{$phpEx}"));
            $conf = array('highlight.bg', 'highlight.comment', 'highlight.default', 'highlight.html', 'highlight.keyword', 'highlight.string');
            foreach ($conf as $ini_var) {
                @ini_set($ini_var, str_replace('highlight.', 'syntax', $ini_var));
            }
            $marker = 'MARKER' . time();
            $code = highlight_string(str_replace("\n", $marker, $code), true);
            $code = str_replace($marker, "\n", $code);
            $str_from = array('<span style="color: ', '<font color="syntax', '</font>', '<code>', '</code>', '[', ']', '.', ':');
            $str_to = array('<span class="', '<span class="syntax', '</span>', '', '', '&#91;', '&#93;', '&#46;', '&#58;');
            $code = str_replace($str_from, $str_to, $code);
            $code = preg_replace('#^(<span class="[a-z_]+">)\\n?(.*?)\\n?(</span>)$#ism', '$1$2$3', $code);
            $code = substr($code, strlen('<span class="syntaxhtml">'));
            $code = substr($code, 0, -1 * strlen('</ span>'));
            $code = explode("\n", $code);
            foreach ($code as $key => $line) {
                $template->assign_block_vars('source', array('LINENUM' => $key + 1, 'LINE' => preg_replace('#([^ ;])&nbsp;([^ &])#', '$1 $2', $line)));
                unset($code[$key]);
            }
            adm_page_footer();
        }
        $filemtime = array();
        if ($template_row['template_storedb']) {
            $ids = array();
            if (isset($template_row['template_inherits_id']) && $template_row['template_inherits_id']) {
                $ids[] = $template_row['template_inherits_id'];
            }
            $ids[] = $template_row['template_id'];
            $filemtime = array();
            $file_template_db = array();
            foreach ($ids as $id) {
                $sql = 'SELECT template_filename, template_mtime
					FROM ' . STYLES_TEMPLATE_DATA_TABLE . "\n\t\t\t\t\tWHERE template_id = {$id}";
                $result = $db->sql_query($sql);
                while ($row = $db->sql_fetchrow($result)) {
                    $filemtime[$row['template_filename']] = $row['template_mtime'];
                    $file_template_db[$row['template_filename']] = $id;
                }
                $db->sql_freeresult($result);
            }
        }
        // Get a list of cached template files and then retrieve additional information about them
        $file_ary = $this->template_cache_filelist($template_row['template_path']);
        foreach ($file_ary as $file) {
            $file = str_replace('/', '.', $file);
            // perform some dirty guessing to get the path right.
            // We assume that three dots in a row were '../'
            $tpl_file = str_replace('.', '/', $file);
            $tpl_file = str_replace('///', '../', $tpl_file);
            $filename = "{$cache_prefix}_{$file}.html.{$phpEx}";
            if (!file_exists("{$phpbb_root_path}cache/{$filename}")) {
                continue;
            }
            $file_tpl = "{$phpbb_root_path}styles/{$template_row['template_path']}/template/{$tpl_file}.html";
            $inherited = false;
            if (isset($template_row['template_inherits_id']) && $template_row['template_inherits_id']) {
                if (!$template_row['template_storedb']) {
                    if (!file_exists($file_tpl)) {
                        $file_tpl = "{$phpbb_root_path}styles/{$template_row['template_inherit_path']}/template/{$tpl_file}.html";
                        $inherited = true;
                    }
                } else {
                    if ($file_template_db[$file . '.html'] == $template_row['template_inherits_id']) {
                        $file_tpl = "{$phpbb_root_path}styles/{$template_row['template_inherit_path']}/template/{$tpl_file}.html";
                        $inherited = true;
                    }
                }
            }
            // Correct the filename if it is stored in database and the file is in a subfolder.
            if ($template_row['template_storedb']) {
                $file = str_replace('.', '/', $file);
            }
            $template->assign_block_vars('file', array('U_VIEWSOURCE' => $this->u_action . "&amp;action=cache&amp;id={$template_id}&amp;source={$file}", 'CACHED' => $user->format_date(filemtime("{$phpbb_root_path}cache/{$filename}")), 'FILENAME' => $file, 'FILENAME_PATH' => $file_tpl, 'FILESIZE' => get_formatted_filesize(filesize("{$phpbb_root_path}cache/{$filename}")), 'MODIFIED' => $user->format_date(!$template_row['template_storedb'] ? filemtime($file_tpl) : $filemtime[$file . '.html'])));
        }
        unset($filemtime);
        $template->assign_vars(array('S_CACHE' => true, 'S_TEMPLATE' => true, 'U_ACTION' => $this->u_action . "&amp;action=cache&amp;id={$template_id}", 'U_BACK' => $this->u_action));
    }
开发者ID:jverkoey,项目名称:Three20-Scope,代码行数:101,代码来源:acp_styles.php

示例9: max_filesize

 /**
  * Adjust all three max_filesize config vars for display
  */
 function max_filesize($value, $key = '')
 {
     // Determine size var and adjust the value accordingly
     $filesize = get_formatted_filesize($value, false, array('mb', 'kb', 'b'));
     $size_var = $filesize['si_identifier'];
     $value = $filesize['value'];
     return '<input type="text" id="' . $key . '" size="8" maxlength="15" name="config[' . $key . ']" value="' . $value . '" /> <select name="' . $key . '">' . size_select_options($size_var) . '</select>';
 }
开发者ID:ubick,项目名称:lorekeepers.org,代码行数:11,代码来源:acp_attachments.php

示例10: main


//.........这里部分代码省略.........
                    for ($file_count = 0; $file_count < $upload_files_limit; $file_count++) {
                        /**
                         * Upload an image from the FILES-array,
                         * call some functions (rotate, resize, ...)
                         * and store the image to the database
                         */
                        $file = $this->request->file('image_file_' . $file_count, '');
                        if (isset($file['size'])) {
                            if ($file['size'] > 0) {
                                $process->upload_file($file_count);
                            }
                        }
                    }
                }
                if (!$process->uploaded_files) {
                    $process->new_error($this->user->lang['UPLOAD_NO_FILE']);
                } else {
                    $mode = 'upload_edit';
                    // Remove submit, so we get the first screen of step 2.
                    $submit = false;
                }
                $error = implode('<br />', $process->errors);
                /*if (phpbb_gallery_misc::display_captcha('upload'))
                		{
                			$captcha->reset();
                		}*/
            }
            if (!$submit || isset($process) && !$process->uploaded_files) {
                for ($i = 0; $i < $upload_files_limit; $i++) {
                    $this->template->assign_block_vars('upload_image', array());
                }
            }
            if ($mode == 'upload') {
                $this->template->assign_vars(array('ERROR' => $error, 'S_MAX_FILESIZE' => get_formatted_filesize($this->gallery_config->get('max_filesize')), 'S_MAX_WIDTH' => $this->gallery_config->get('max_width'), 'S_MAX_HEIGHT' => $this->gallery_config->get('max_height'), 'S_ALLOWED_FILETYPES' => implode(', ', $process->get_allowed_types(true)), 'S_ALBUM_ACTION' => $this->helper->route('phpbbgallery_album_upload', array('album_id' => $album_id)), 'S_UPLOAD' => true, 'S_ALLOW_ROTATE' => $this->gallery_config->get('allow_rotate') && function_exists('imagerotate'), 'S_UPLOAD_LIMIT' => $upload_files_limit, 'S_COMMENTS_ENABLED' => $this->gallery_config->get('allow_comments') && $this->gallery_config->get('comment_user_control'), 'S_ALLOW_COMMENTS' => true, 'L_ALLOW_COMMENTS' => $this->user->lang('ALLOW_COMMENTS_ARY', $upload_files_limit)));
                /*if (phpbb_gallery_misc::display_captcha('upload'))
                		{
                			if (!$submit || !$captcha->is_solved())
                			{
                				$template->assign_vars(array(
                					'S_CONFIRM_CODE'			=> true,
                					'CAPTCHA_TEMPLATE'			=> $captcha->get_template(),
                				));
                			}
                			$template->assign_vars(array(
                				'S_CAPTCHA_HIDDEN_FIELDS'	=> $s_captcha_hidden_fields,
                			));
                		}*/
            }
        }
        if ($mode == 'upload_edit') {
            if ($submit) {
                // Upload Quota Check
                // 1. Check album-configuration Quota
                if ($this->gallery_config->get('album_images') >= 0 && $album_data['album_images'] >= $this->gallery_config->get('album_images')) {
                    //@todo: Add return link
                    trigger_error('ALBUM_REACHED_QUOTA');
                }
                // 2. Check user-limit, if he is not allowed to go unlimited
                if (!$this->auth->acl_check('i_unlimited', $album_id, $album_data['album_user_id'])) {
                    $sql = 'SELECT COUNT(image_id) count
						FROM ' . $this->images_table . '
						WHERE image_user_id = ' . $this->user->data['user_id'] . '
							AND image_status <> ' . $this->image->get_status_orphan() . '
							AND image_album_id = ' . $album_id;
                    $result = $this->db->sql_query($sql);
                    $own_images = (int) $this->db->sql_fetchfield('count');
开发者ID:vodis,项目名称:phpbbgallery,代码行数:67,代码来源:upload.php

示例11: display_stats

    /**
     * Display phpBB Directory statistics
     *
     * @return null
     */
    public function display_stats()
    {
        // Count number of categories
        $sql = 'SELECT COUNT(cat_id) AS nb_cats
			FROM ' . DIR_CAT_TABLE;
        $result = $this->db->sql_query($sql);
        $total_cats = (int) $this->db->sql_fetchfield('nb_cats');
        $this->db->sql_freeresult($result);
        // Cont number of links
        $sql = 'SELECT link_id, link_active
			FROM ' . DIR_LINK_TABLE;
        $result = $this->db->sql_query($sql);
        $total_links = $waiting_links = 0;
        while ($row = $this->db->sql_fetchrow($result)) {
            $total_links++;
            if (!$row['link_active']) {
                $waiting_links++;
            }
        }
        $this->db->sql_freeresult($result);
        // Comments number calculating
        $sql = 'SELECT COUNT(comment_id) AS nb_comments
			FROM ' . DIR_COMMENT_TABLE;
        $result = $this->db->sql_query($sql);
        $total_comments = (int) $this->db->sql_fetchfield('nb_comments');
        $this->db->sql_freeresult($result);
        // Votes number calculating
        $sql = 'SELECT COUNT(vote_id) AS nb_votes
			FROM ' . DIR_VOTE_TABLE;
        $result = $this->db->sql_query($sql);
        $total_votes = (int) $this->db->sql_fetchfield('nb_votes');
        $this->db->sql_freeresult($result);
        // Click number calculating
        $sql = 'SELECT SUM(link_view) AS nb_clicks
			FROM ' . DIR_LINK_TABLE;
        $result = $this->db->sql_query($sql);
        $total_clicks = (int) $this->db->sql_fetchfield('nb_clicks');
        $this->db->sql_freeresult($result);
        $banners_dir_size = 0;
        $banners_path = $this->dir_helper->get_banner_path();
        if ($banners_dir = @opendir($banners_path)) {
            while (($file = readdir($banners_dir)) !== false) {
                if ($file[0] != '.' && $file[0] != '..' && strpos($file, 'index.') === false && strpos($file, '.db') === false) {
                    $banners_dir_size += filesize($banners_path . $file);
                }
            }
            closedir($banners_dir);
            $banners_dir_size = get_formatted_filesize($banners_dir_size);
        } else {
            // Couldn't open banners dir.
            $banners_dir_size = $this->user->lang['NOT_AVAILABLE'];
        }
        $total_orphan = $this->_orphan_files();
        $this->template->assign_vars(array('U_ACTION' => $this->u_action, 'TOTAL_CATS' => $total_cats, 'TOTAL_LINKS' => $total_links - $waiting_links, 'WAITING_LINKS' => $waiting_links, 'TOTAL_COMMENTS' => $total_comments, 'TOTAL_VOTES' => $total_votes, 'TOTAL_CLICKS' => $total_clicks, 'TOTAL_ORPHANS' => $total_orphan, 'BANNERS_DIR_SIZE' => $banners_dir_size));
    }
开发者ID:rmcgirr83,项目名称:ext-phpbb-directory,代码行数:60,代码来源:main.php

示例12: while

            $rows = $db->sql_fetchrowset($result);
            $rows[] = false;
            // indicate end of array for while loop below
            $db->sql_freeresult($result);
        }
        $i = 0;
        while ($row = $buffer ? $rows[$i++] : $db->sql_fetchrow($result)) {
            // Indexing enabled for this forum or global announcement?
            // Global announcements get indexed by default.
            if (!$row['forum_id'] || !empty($forums[$row['forum_id']])) {
                ++$row_count;
                $search->index('post', $row['post_id'], $row['post_text'], $row['post_subject'], $row['poster_id'], $row['forum_id']);
                if ($row_count % 10 == 0) {
                    echo '.';
                }
            }
        }
        $delta = time() - $time;
        $delta = $delta <= 0 ? 1 : $delta;
        printf(" %d posts/sec\n", $row_count / $delta);
        if (!$buffer) {
            $db->sql_freeresult($result);
        }
        $post_counter += $batch_size;
    }
}
$search->tidy();
add_log('admin', 'LOG_SEARCH_INDEX_CREATED', $search_name);
echo $user->lang['SEARCH_INDEX_CREATED'] . "\n";
echo 'Peak Memory Usage: ' . get_formatted_filesize(memory_get_peak_usage()) . "\n";
exit(0);
开发者ID:Voxel37,项目名称:phpbb,代码行数:31,代码来源:create_search_index.php

示例13: ImgObj

 // --------------------------------
 // Cache is empty. Try to re-generate!
 // --------------------------------
 if ($pic_width > $pic_height) {
     $thumbnail_width = $config['thumbnail_size'];
     $thumbnail_height = $config['thumbnail_size'] * ($pic_height / $pic_width);
 } else {
     $thumbnail_height = $config['thumbnail_size'];
     $thumbnail_width = $config['thumbnail_size'] * ($pic_width / $pic_height);
 }
 $Image = new ImgObj();
 $Image->JPGQuality = $config['thumbnail_quality'];
 $Image->ReadSourceFile($pic_fullpath);
 $Image->Resize($thumbnail_width, $thumbnail_height);
 if ($config['show_pic_size_on_thumb'] == 1) {
     $image_filesize = get_formatted_filesize(filesize($pic_fullpath));
     $image_dimension = intval($pic_width) . "x" . intval($pic_height);
     $image_text_output = $image_dimension . ($thumbnail_width >= 360 ? ' - ' . $image_filesize : '');
     if ($thumbnail_width >= 260) {
         $image_exif_data = $Image->ExifData;
         if (!empty($image_exif_data)) {
             $image_exif_data_short = $Image->exif_get_data_short($image_exif_data);
             $exif_data_key_array = array('MODEL', 'FOCAL_LENGTH', 'EXPOSURE', 'APERTURE', 'ISO');
             $exif_data_array = array();
             foreach ($exif_data_key_array as $exif_key) {
                 if ($image_exif_data_short[$exif_key] != 'EXIF_UNKNOWN') {
                     $process_tag = true;
                     if ($exif_key == 'ISO') {
                         $image_exif_data_short[$exif_key] = 'ISO ' . $image_exif_data_short[$exif_key];
                     } elseif ($exif_key == 'MODEL') {
                         if ($thumbnail_width >= 320) {
开发者ID:GabrielAnca,项目名称:icy_phoenix,代码行数:31,代码来源:image_thumbnail.php

示例14: view

    private function view($cat_id, $topic_id = 0)
    {
        $start = $this->request->variable('start', 0);
        $sort_key = $this->request->variable('sk', 'a');
        $sort_dir = $this->request->variable('sd', 'a');
        // Select box eventually
        $sort_key_text = array('a' => $this->user->lang['SORT_FILENAME'], 'b' => $this->user->lang['SORT_COMMENT'], 'c' => $this->user->lang['SORT_EXTENSION'], 'd' => $this->user->lang['SORT_SIZE'], 'e' => $this->user->lang['SORT_DOWNLOADS'], 'f' => $this->user->lang['SORT_POST_TIME'], 'g' => $this->user->lang['SORT_TOPIC_TITLE']);
        $sort_key_sql = array('a' => 'a.real_filename', 'b' => 'a.attach_comment', 'c' => 'a.extension', 'd' => 'a.filesize', 'e' => 'a.download_count', 'f' => 'a.filetime', 'g' => 't.topic_title');
        $sort_dir_text = array('a' => $this->user->lang['ASCENDING'], 'd' => $this->user->lang['DESCENDING']);
        $s_sort_key = '';
        foreach ($sort_key_text as $key => $value) {
            $selected = $sort_key == $key ? ' selected="selected"' : '';
            $s_sort_key .= '<option value="' . $key . '"' . $selected . '>' . $value . '</option>';
        }
        $s_sort_dir = '';
        foreach ($sort_dir_text as $key => $value) {
            $selected = $sort_dir == $key ? ' selected="selected"' : '';
            $s_sort_dir .= '<option value="' . $key . '"' . $selected . '>' . $value . '</option>';
        }
        if (!isset($sort_key_sql[$sort_key])) {
            $sort_key = 'a';
        }
        $order_by = $sort_key_sql[$sort_key] . ' ' . ($sort_dir == 'a' ? 'ASC' : 'DESC');
        if ($cat_id) {
            $sql_topic = $topic_id ? " AND a.topic_id = " . (int) $topic_id : '';
            $sql = "SELECT e.extension, COUNT(a.attach_id) AS num_attachments\n\t\t\t\tFROM " . EXTENSIONS_TABLE . " e, " . ATTACHMENTS_TABLE . " a\n\t\t\t\tWHERE e.group_id = " . (int) $cat_id . "\n\t\t\t\t\t{$sql_topic}\n\t\t\t\t\tAND a.extension = e.extension\n\t\t\t\t\tAND a.is_orphan = 0\n\t\t\t\t\tAND a.in_message = 0\n\t\t\t\tGROUP BY a.extension";
            $result = $this->db->sql_query($sql);
            $extension = array();
            while ($row = $this->db->sql_fetchrow($result)) {
                $extension[] = $row['extension'];
                $num_attachments = isset($num_attachments) ? $num_attachments + $row['num_attachments'] : $row['num_attachments'];
            }
            $this->db->sql_freeresult($result);
            if (!sizeof($extension)) {
                return;
            }
            $sql_where = 'WHERE ' . $this->db->sql_in_set('a.extension', $extension);
            $sql_where .= $sql_topic . ' AND a.in_message = 0';
        } else {
            $sql_where = $topic_id ? "WHERE a.topic_id = " . (int) $topic_id . " AND " : "WHERE ";
            $sql_where = "{$sql_where} a.in_message = 0";
            $sql = 'SELECT COUNT(attach_id) as num_attachments
				FROM ' . ATTACHMENTS_TABLE . " a\n\t\t\t\t{$sql_where}\n\t\t\t\t\tAND a.is_orphan = 0";
            $result = $this->db->sql_query($sql);
            $num_attachments = $this->db->sql_fetchfield('num_attachments');
            $this->db->sql_freeresult($result);
        }
        // Ensure start is a valid value
        $start = $this->pagination->validate_start($start, $this->config['topics_per_page'], $num_attachments);
        $sql = 'SELECT a.*, t.forum_id, t.topic_title
			FROM ' . ATTACHMENTS_TABLE . ' a
				LEFT JOIN ' . TOPICS_TABLE . ' t ON (a.topic_id = t.topic_id AND a.in_message = 0)
			' . $sql_where . "\n\t\t\t\tAND a.is_orphan = 0\n\t\t\tORDER BY {$order_by}";
        $result = $this->db->sql_query_limit($sql, $this->config['topics_per_page'], $start);
        $row_count = 0;
        while ($row = $this->db->sql_fetchrow($result)) {
            $view_topic = append_sid("{$this->phpbb_root_path}viewtopic.{$this->php_ext}", "t={$row['topic_id']}&amp;p={$row['post_msg_id']}") . "#p{$row['post_msg_id']}";
            $this->template->assign_block_vars('attachrow', array('ROW_NUMBER' => $row_count + ($start + 1), 'FILENAME' => $row['real_filename'], 'COMMENT' => bbcode_nl2br($row['attach_comment']), 'EXTENSION' => $row['extension'], 'SIZE' => get_formatted_filesize($row['filesize']), 'DOWNLOAD_COUNT' => $row['download_count'], 'POST_TIME' => $this->user->format_date($row['filetime']), 'TOPIC_TITLE' => $row['topic_title'], 'ATTACH_ID' => $row['attach_id'], 'POST_ID' => $row['post_msg_id'], 'TOPIC_ID' => $row['topic_id'], 'AUTH_DOWNLOAD' => $this->auth->acl_get('f_download', $row['forum_id']), 'U_VIEW_ATTACHMENT' => $this->helper->route("bb3mobi_attach_file", array('attach_id' => $row['attach_id'])), 'U_DOWN_ATTACHMENT' => append_sid("{$this->phpbb_root_path}download/file.{$this->php_ext}", 'id=' . $row['attach_id']), 'U_VIEW_TOPIC' => $view_topic));
            $row_count++;
        }
        $this->db->sql_freeresult($result);
        if ($cat_id) {
            $route = "bb3mobi_attach_view";
            $view_ary = array('cat_id' => $cat_id);
            $view_ary += $topic_id ? array('t' => $topic_id) : array();
        } else {
            $route = "bb3mobi_attach_cat";
            $view_ary = $topic_id ? array('t' => $topic_id) : array();
        }
        $base_url = $this->helper->route($route, array_merge($view_ary, array('sk' => $sort_key, 'sd' => $sort_dir)));
        $this->pagination->generate_template_pagination($base_url, 'pagination', 'start', $num_attachments, $this->config['topics_per_page'], $start);
        if ($start) {
            $view_ary = array_merge($view_ary, array('start' => $start));
        }
        $this->template->assign_vars(array('DESCRIPTION' => $this->user->lang('ATTACHMENTS_EXPLAIN'), 'NUM_ATTACHMENTS' => $this->user->lang('NUM_ATTACHMENTS', $num_attachments), 'ATTACHMENTS_BY' => $row_count ? $this->user->lang('ATTACHMENTS_BY', '<a href="http://bb3.mobi">Download by</a>') : '', 'CAT_ID' => $cat_id, 'U_CANONICAL' => $this->helper->route($route, $view_ary, false, '', true), 'U_SORT_FILENAME' => $this->helper->route($route, array_merge($view_ary, array('sk' => 'a', 'sd' => $sort_key == 'a' && $sort_dir == 'a' ? 'd' : 'a'))), 'U_SORT_FILE_COMMENT' => $this->helper->route($route, array_merge($view_ary, array('sk' => 'b', 'sd' => $sort_key == 'b' && $sort_dir == 'a' ? 'd' : 'a'))), 'U_SORT_EXTENSION' => $this->helper->route($route, array_merge($view_ary, array('sk' => 'c', 'sd' => $sort_key == 'c' && $sort_dir == 'a' ? 'd' : 'a'))), 'U_SORT_FILESIZE' => $this->helper->route($route, array_merge($view_ary, array('sk' => 'd', 'sd' => $sort_key == 'd' && $sort_dir == 'a' ? 'd' : 'a'))), 'U_SORT_DOWNLOADS' => $this->helper->route($route, array_merge($view_ary, array('sk' => 'e', 'sd' => $sort_key == 'e' && $sort_dir == 'a' ? 'd' : 'a'))), 'U_SORT_POST_TIME' => $this->helper->route($route, array_merge($view_ary, array('sk' => 'f', 'sd' => $sort_key == 'f' && $sort_dir == 'a' ? 'd' : 'a'))), 'U_SORT_TOPIC_TITLE' => $this->helper->route($route, array_merge($view_ary, array('sk' => 'g', 'sd' => $sort_key == 'g' && $sort_dir == 'a' ? 'd' : 'a'))), 'S_DISPLAY_MARK_ALL' => $num_attachments ? true : false, 'S_DISPLAY_PAGINATION' => $num_attachments ? true : false, 'S_ATTACH_ACTION' => $this->helper->route($route, $view_ary), 'S_SORT_OPTIONS' => $s_sort_key, 'S_ORDER_SELECT' => $s_sort_dir));
        return $start ? ' - ' . $this->user->lang('PAGE_TITLE_NUMBER', $this->pagination->get_on_page($this->config['topics_per_page'], $start)) : '';
    }
开发者ID:bb3mobi,项目名称:attachments,代码行数:77,代码来源:route.php

示例15: parse_attachments

 /**
  * General attachment parsing
  * From phpBB (includes/functions_content.php)
  *
  * @param string &$message The message
  * @param string $tpl The template file to use
  * @param bool $preview true if previewing from the posting page
  * @param string|bool $template_block If not false we will output the parsed attachments to this template block
  *
  * @return array the parsed attachments
  */
 public function parse_attachments(&$message, $tpl = 'common/attachment.html', $preview = false, $template_block = false)
 {
     if (!sizeof($this->attachments)) {
         return array();
     }
     phpbb::$user->add_lang('viewtopic');
     $compiled_attachments = array();
     if ($tpl !== false && !isset(phpbb::$template->filename['titania_attachment_tpl'])) {
         phpbb::$template->set_filenames(array('titania_attachment_tpl' => $tpl));
     }
     // Sort correctly
     if (phpbb::$config['display_order']) {
         // Ascending sort
         krsort($this->attachments);
     } else {
         // Descending sort
         ksort($this->attachments);
     }
     foreach ($this->attachments as $attachment_id => $attachment) {
         if (!sizeof($attachment)) {
             continue;
         }
         // We need to reset/empty the _file block var, because this function might be called more than once
         phpbb::$template->destroy_block_vars('_file');
         $block_array = array();
         // Some basics...
         $attachment['extension'] = strtolower(trim($attachment['extension']));
         $filename = titania::$config->upload_path . $attachment['attachment_directory'] . '/' . utf8_basename($attachment['attachment_directory']) . '/' . utf8_basename($attachment['physical_filename']);
         $thumbnail_filename = titania::$config->upload_path . $attachment['attachment_directory'] . '/' . utf8_basename($attachment['attachment_directory']) . '/thumb_' . utf8_basename($attachment['physical_filename']);
         $filesize = get_formatted_filesize($attachment['filesize'], false);
         if ($preview) {
             $comment = bbcode_nl2br(censor_text(utf8_normalize_nfc(request_var('attachment_comment_' . $attachment_id, (string) $attachment['attachment_comment'], true))));
         } else {
             $comment = bbcode_nl2br(censor_text($attachment['attachment_comment']));
         }
         $block_array += array('FILESIZE' => $filesize['value'], 'SIZE_LANG' => $filesize['unit'], 'DOWNLOAD_NAME' => utf8_basename($attachment['real_filename']), 'COMMENT' => $comment);
         $l_downloaded_viewed = $download_link = '';
         $display_cat = strpos($attachment['mimetype'], 'image') === 0 ? ATTACHMENT_CATEGORY_IMAGE : ATTACHMENT_CATEGORY_NONE;
         // @todo Probably should add support for more types...
         if ($display_cat == ATTACHMENT_CATEGORY_IMAGE) {
             if ($attachment['thumbnail']) {
                 $display_cat = ATTACHMENT_CATEGORY_THUMB;
             } else {
                 if (phpbb::$config['img_display_inlined']) {
                     if (phpbb::$config['img_link_width'] || phpbb::$config['img_link_height']) {
                         $dimension = @getimagesize($filename);
                         // If the dimensions could not be determined or the image being 0x0 we display it as a link for safety purposes
                         if ($dimension === false || empty($dimension[0]) || empty($dimension[1])) {
                             $display_cat = ATTACHMENT_CATEGORY_NONE;
                         } else {
                             $display_cat = $dimension[0] <= phpbb::$config['img_link_width'] && $dimension[1] <= phpbb::$config['img_link_height'] ? ATTACHMENT_CATEGORY_IMAGE : ATTACHMENT_CATEGORY_NONE;
                         }
                     }
                 } else {
                     $display_cat = ATTACHMENT_CATEGORY_NONE;
                 }
             }
         }
         // Make some descisions based on user options being set.
         if (($display_cat == ATTACHMENT_CATEGORY_IMAGE || $display_cat == ATTACHMENT_CATEGORY_THUMB) && !phpbb::$user->optionget('viewimg')) {
             $display_cat = ATTACHMENT_CATEGORY_NONE;
         }
         if ($display_cat == ATTACHMENT_CATEGORY_FLASH && !phpbb::$user->optionget('viewflash')) {
             $display_cat = ATTACHMENT_CATEGORY_NONE;
         }
         $download_link = titania_url::build_url('download', array('id' => $attachment['attachment_id']));
         switch ($display_cat) {
             // Images
             case ATTACHMENT_CATEGORY_IMAGE:
                 $l_downloaded_viewed = 'VIEWED_COUNT';
                 $download_link = titania_url::append_url($download_link, array('mode' => 'view'));
                 $block_array += array('S_IMAGE' => true, 'U_INLINE_LINK' => titania_url::append_url($download_link, array('mode' => 'view')));
                 break;
                 // Images, but display Thumbnail
             // Images, but display Thumbnail
             case ATTACHMENT_CATEGORY_THUMB:
                 $l_downloaded_viewed = 'VIEWED_COUNT';
                 $download_link = titania_url::append_url($download_link, array('mode' => 'view'));
                 $block_array += array('S_THUMBNAIL' => true, 'THUMB_IMAGE' => titania_url::append_url($download_link, array('mode' => 'view', 'thumb' => 1)));
                 break;
                 // Windows Media Streams
             // Windows Media Streams
             case ATTACHMENT_CATEGORY_WM:
                 $l_downloaded_viewed = 'VIEWED_COUNT';
                 // Giving the filename directly because within the wm object all variables are in local context making it impossible
                 // to validate against a valid session (all params can differ)
                 // $download_link = $filename;
                 $block_array += array('ATTACH_ID' => $attachment['attachment_id'], 'S_WM_FILE' => true);
                 break;
//.........这里部分代码省略.........
开发者ID:Gfksx,项目名称:customisation-db,代码行数:101,代码来源:attachment.php


注:本文中的get_formatted_filesize函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。