示例#1
0
文件: helper.php 项目: hgchen/phpbb
 /**
  * Automate setting up the page and creating the response object.
  *
  * @param string $template_file The template handle to render
  * @param string $page_title The title of the page to output
  * @param int $status_code The status code to be sent to the page header
  * @param bool $display_online_list Do we display online users list
  *
  * @return Response object containing rendered page
  */
 public function render($template_file, $page_title = '', $status_code = 200, $display_online_list = false)
 {
     page_header($page_title, $display_online_list);
     $this->template->set_filenames(array('body' => $template_file));
     page_footer(true, false, false);
     return new Response($this->template->assign_display('body'), $status_code);
 }
 public function main()
 {
     $topic_id = $this->request->variable('t', 0);
     $post_id = $this->request->variable('p', 0);
     $forum_id = $this->request->variable('f', 0);
     $mode = $this->request->variable('mode', '');
     $book_submit = $this->request->variable('book', false);
     $viewtopic_url = append_sid("{$this->phpbb_root_path}viewtopic." . $this->php_ext . "", "f={$forum_id}&t={$topic_id}");
     $return_link = '<br /><br />' . sprintf($this->user->lang['RETURN_TOPIC'], '<a href="' . $viewtopic_url . '">', '</a>');
     $body = 'add_bookmark';
     if ($mode == 'delete') {
         $sql = 'DELETE FROM ' . $this->postbookmark_table . "\n\t\t\t\tWHERE user_id = {$this->user->data['user_id']}\n\t\t\t\t\tAND post_id = {$post_id}";
         $this->db->sql_query($sql);
         $message = $this->user->lang['POST_BOOKMARK_REMOVED'];
         $this->helper->output_response($message, $return_link, $viewtopic_url);
     } else {
         if ($mode == 'find') {
             $body = 'find_bookmark';
             $this->helper->get_bookmarks($mode);
         } else {
             $bookmark_desc = $this->request->variable('bookmark_desc', '', true);
             if ($book_submit) {
                 $sql = 'INSERT INTO ' . $this->postbookmark_table . ' ' . $this->db->sql_build_array('INSERT', array('user_id' => $this->user->data['user_id'], 'post_id' => $post_id, 'topic_id' => $topic_id, 'bookmark_time' => time(), 'bookmark_desc' => $bookmark_desc));
                 $this->db->sql_query($sql);
                 $message = $this->user->lang['POST_BOOKMARK_ADDED'];
                 $this->helper->output_response($message, $return_link, $viewtopic_url);
             }
         }
     }
     $this->template->assign_vars(array('U_POST_ACTION' => append_sid("{$this->phpbb_root_path}postbookmark", "f={$forum_id}&amp;t={$topic_id}&amp;p={$post_id}&amp;mode={$mode}")));
     page_header($this->user->lang['POST_BOOKMARK_ADD']);
     $this->template->set_filenames(array('body' => $body . '.html'));
     page_footer();
     return new Response('', 200);
 }
 /**
  * This listener is run when the KernelEvents::EXCEPTION event is triggered
  *
  * @param GetResponseForExceptionEvent $event
  * @return null
  */
 public function on_kernel_exception(GetResponseForExceptionEvent $event)
 {
     $exception = $event->getException();
     $message = $exception->getMessage();
     if ($exception instanceof \phpbb\exception\exception_interface) {
         $message = $this->language->lang_array($message, $exception->get_parameters());
     }
     if (!$event->getRequest()->isXmlHttpRequest()) {
         page_header($this->language->lang('INFORMATION'));
         $this->template->assign_vars(array('MESSAGE_TITLE' => $this->language->lang('INFORMATION'), 'MESSAGE_TEXT' => $message));
         $this->template->set_filenames(array('body' => 'message_body.html'));
         page_footer(true, false, false);
         $response = new Response($this->template->assign_display('body'), 500);
     } else {
         $data = array();
         if (!empty($message)) {
             $data['message'] = $message;
         }
         if (defined('DEBUG')) {
             $data['trace'] = $exception->getTrace();
         }
         $response = new JsonResponse($data, 500);
     }
     if ($exception instanceof HttpExceptionInterface) {
         $response->setStatusCode($exception->getStatusCode());
         $response->headers->add($exception->getHeaders());
     }
     $event->setResponse($response);
 }
    function main()
    {
        $sql = 'SELECT *
				FROM ' . $this->points_values_table;
        $result = $this->db->sql_query($sql);
        $points_values = $this->db->sql_fetchrow($result);
        $this->db->sql_freeresult($result);
        // Add part to bar
        $this->template->assign_block_vars('navlinks', array('U_VIEW_FORUM' => $this->helper->route('dmzx_ultimatepoints_controller', array('mode' => 'info')), 'FORUM_NAME' => sprintf($this->user->lang['POINTS_INFO'], $this->config['points_name'])));
        // Read out all the need values
        $info_attach = $points_values['points_per_attach'] == 0 ? sprintf($this->user->lang['INFO_NO_POINTS'], $this->config['points_name']) : sprintf($this->functions_points->number_format_points($points_values['points_per_attach']) . '&nbsp;' . $this->config['points_name']);
        $info_addtional_attach = $points_values['points_per_attach_file'] == 0 ? sprintf($this->user->lang['INFO_NO_POINTS'], $this->config['points_name']) : sprintf($this->functions_points->number_format_points($points_values['points_per_attach_file']) . '&nbsp;' . $this->config['points_name']);
        $info_poll = $points_values['points_per_poll'] == 0 ? sprintf($this->user->lang['INFO_NO_POINTS'], $this->config['points_name']) : sprintf($this->functions_points->number_format_points($points_values['points_per_poll']) . '&nbsp;' . $this->config['points_name']);
        $info_poll_option = $points_values['points_per_poll_option'] == 0 ? sprintf($this->user->lang['INFO_NO_POINTS'], $this->config['points_name']) : sprintf($this->functions_points->number_format_points($points_values['points_per_poll_option']) . '&nbsp;' . $this->config['points_name']);
        $info_topic_word = $points_values['points_per_topic_word'] == 0 ? sprintf($this->user->lang['INFO_NO_POINTS'], $this->config['points_name']) : sprintf($this->functions_points->number_format_points($points_values['points_per_topic_word']) . '&nbsp;' . $this->config['points_name']);
        $info_topic_character = $points_values['points_per_topic_character'] == 0 ? sprintf($this->user->lang['INFO_NO_POINTS'], $this->config['points_name']) : sprintf($this->functions_points->number_format_points($points_values['points_per_topic_character']) . '&nbsp;' . $this->config['points_name']);
        $info_post_word = $points_values['points_per_post_word'] == 0 ? sprintf($this->user->lang['INFO_NO_POINTS'], $this->config['points_name']) : sprintf($this->functions_points->number_format_points($points_values['points_per_post_word']) . '&nbsp;' . $this->config['points_name']);
        $info_post_character = $points_values['points_per_post_character'] == 0 ? sprintf($this->user->lang['INFO_NO_POINTS'], $this->config['points_name']) : sprintf($this->functions_points->number_format_points($points_values['points_per_post_character']) . '&nbsp;' . $this->config['points_name']);
        $info_cost_warning = $points_values['points_per_warn'] == 0 ? sprintf($this->user->lang['INFO_NO_COST'], $this->config['points_name']) : sprintf($this->functions_points->number_format_points($points_values['points_per_warn']) . '&nbsp;' . $this->config['points_name']);
        $info_reg_bonus = $points_values['reg_points_bonus'] == 0 ? sprintf($this->user->lang['INFO_NO_POINTS'], $this->config['points_name']) : sprintf($this->functions_points->number_format_points($points_values['reg_points_bonus']) . '&nbsp;' . $this->config['points_name']);
        $info_points_bonus = $points_values['points_bonus_chance'] == 0 ? sprintf($this->user->lang['INFO_NO_POINTS'], $this->config['points_name']) : sprintf($this->user->lang['INFO_BONUS_CHANCE_EXPLAIN'], $this->functions_points->number_format_points($points_values['points_bonus_chance']), $this->functions_points->number_format_points($points_values['points_bonus_min']), $this->functions_points->number_format_points($points_values['points_bonus_max']), $this->config['points_name']);
        $this->template->assign_vars(array('USER_POINTS' => sprintf($this->functions_points->number_format_points($this->user->data['user_points'])), 'POINTS_NAME' => $this->config['points_name'], 'LOTTERY_NAME' => $points_values['lottery_name'], 'BANK_NAME' => $points_values['bank_name'], 'POINTS_INFO_DESCRIPTION' => sprintf($this->user->lang['POINTS_INFO_DESCRIPTION'], $this->config['points_name']), 'INFO_ATTACH' => $info_attach, 'INFO_ADD_ATTACH' => $info_addtional_attach, 'INFO_POLL' => $info_poll, 'INFO_POLL_OPTION' => $info_poll_option, 'INFO_TOPIC_WORD' => $info_topic_word, 'INFO_TOPIC_CHARACTER' => $info_topic_character, 'INFO_POST_WORD' => $info_post_word, 'INFO_POST_CHARACTER' => $info_post_character, 'INFO_COST_WARNING' => $info_cost_warning, 'INFO_REG_BONUS' => $info_reg_bonus, 'INFO_POINTS_BONUS' => $info_points_bonus, 'U_TRANSFER_USER' => $this->helper->route('dmzx_ultimatepoints_controller', array('mode' => 'transfer_user')), 'U_LOGS' => $this->helper->route('dmzx_ultimatepoints_controller', array('mode' => 'logs')), 'U_LOTTERY' => $this->helper->route('dmzx_ultimatepoints_controller', array('mode' => 'lottery')), 'U_BANK' => $this->helper->route('dmzx_ultimatepoints_controller', array('mode' => 'bank')), 'U_ROBBERY' => $this->helper->route('dmzx_ultimatepoints_controller', array('mode' => 'robbery')), 'U_INFO' => $this->helper->route('dmzx_ultimatepoints_controller', array('mode' => 'info')), 'U_USE_TRANSFER' => $this->auth->acl_get('u_use_transfer'), 'U_USE_LOGS' => $this->auth->acl_get('u_use_logs'), 'U_USE_LOTTERY' => $this->auth->acl_get('u_use_lottery'), 'U_USE_BANK' => $this->auth->acl_get('u_use_bank'), 'U_USE_ROBBERY' => $this->auth->acl_get('u_use_robbery')));
        // Generate the page
        page_header($this->user->lang['POINTS_INFO']);
        // Generate the page template
        $this->template->set_filenames(array('body' => 'points/points_info.html'));
        page_footer();
    }
示例#5
0
文件: helper.php 项目: ErnadoO/phpbb
 /**
  * Automate setting up the page and creating the response object.
  *
  * @param string $template_file The template handle to render
  * @param string $page_title The title of the page to output
  * @param int $status_code The status code to be sent to the page header
  * @param bool $display_online_list Do we display online users list
  * @param int $item_id Restrict online users to item id
  * @param string $item Restrict online users to a certain session item, e.g. forum for session_forum_id
  * @param bool $send_headers Whether headers should be sent by page_header(). Defaults to false for controllers.
  *
  * @return Response object containing rendered page
  */
 public function render($template_file, $page_title = '', $status_code = 200, $display_online_list = false, $item_id = 0, $item = 'forum', $send_headers = false)
 {
     page_header($page_title, $display_online_list, $item_id, $item, $send_headers);
     $this->template->set_filenames(array('body' => $template_file));
     page_footer(true, false, false);
     $headers = !empty($this->user->data['is_bot']) ? array('X-PHPBB-IS-BOT' => 'yes') : array();
     return new Response($this->template->assign_display('body'), $status_code, $headers);
 }
 /**
  * @param array $block_data
  * @param array $default_settings
  * @return template|string
  */
 public function get_edit_form(array $block_data, array $default_settings)
 {
     global $module;
     if (!function_exists('build_cfg_template')) {
         include $this->phpbb_root_path . 'includes/functions_acp.' . $this->php_ext;
     }
     // We fake this class as it is needed by the build_cfg_template function
     $module = new \stdClass();
     $module->module = $this;
     $this->_generate_config_fields($block_data['settings'], $default_settings);
     $this->template->assign_vars(array('S_ACTIVE' => $block_data['status'], 'S_TYPE' => $block_data['type'], 'S_NO_WRAP' => $block_data['no_wrap'], 'S_HIDE_TITLE' => $block_data['hide_title'], 'S_BLOCK_CLASS' => trim($block_data['class']), 'S_GROUP_OPS' => $this->_get_group_options($block_data['permission'])));
     $this->template->set_filenames(array('block_settings' => 'block_settings.html'));
     return $this->template->assign_display('block_settings');
 }
示例#7
0
 /**
  * @param int  $user_id
  * @param bool $admin
  * @param bool $auto_login
  * @param bool $viewonline
  * @param string $redirect
  */
 public function generate_page($user_id, $admin, $auto_login, $viewonline, $redirect)
 {
     $this->user->add_lang_ext('paul999/tfa', 'common');
     $modules = $this->getModules();
     /**
      * @var module_interface $row
      */
     foreach ($modules as $row) {
         if ($row->is_usable($user_id)) {
             $this->template->assign_block_vars('tfa_options', array_merge(array('ID' => $row->get_name(), 'NAME' => $this->user->lang($row->get_translatable_name()), 'U_SUBMIT_AUTH' => $this->controller_helper->route('paul999_tfa_read_controller_submit', array('user_id' => (int) $user_id, 'admin' => (int) $admin, 'auto_login' => (int) $auto_login, 'viewonline' => (int) $viewonline, 'class' => $row->get_name()))), $row->login_start($user_id)));
         }
     }
     add_form_key('tfa_login_page');
     $random = sha1(random_bytes(32));
     if (!empty($this->user->data['tfa_random'])) {
         throw new http_exception(400, 'TFA_SOMETHING_WENT_WRONG');
     }
     $sql_ary = array('tfa_random' => $random, 'tfa_uid' => $user_id);
     $sql = 'UPDATE ' . SESSIONS_TABLE . ' SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . "\n\t\t\tWHERE\n\t\t\t\tsession_id = '" . $this->db->sql_escape($this->user->data['session_id']) . "' AND\n\t\t\t\tsession_user_id = " . (int) $this->user->data['user_id'];
     $this->db->sql_query($sql);
     $this->template->assign_vars(array('REDIRECT' => $redirect, 'RANDOM' => $random));
     page_header('TFA_KEY_REQUIRED');
     $this->template->set_filenames(array('body' => '@paul999_tfa/authenticate_main.html'));
     page_footer(false);
     // Do not include cron on this page!
 }
示例#8
0
 /**
  * Get the html form
  *
  * @param array $block_data
  * @return string
  */
 private function _get_form(array $block_data)
 {
     $selected_groups = $this->_ensure_array($block_data['permission']);
     $this->template->assign_vars(array('S_ACTIVE' => $block_data['status'], 'S_TYPE' => $block_data['type'], 'S_NO_WRAP' => $block_data['no_wrap'], 'S_HIDE_TITLE' => $block_data['hide_title'], 'S_BLOCK_CLASS' => trim($block_data['class']), 'S_GROUP_OPS' => $this->groups->get_options('special', $selected_groups)));
     $this->template->set_filenames(array('block_settings' => 'block_settings.html'));
     return $this->template->assign_display('block_settings');
 }
示例#9
0
 /**
  * Display the panels (tabs)
  */
 public function display_panels()
 {
     foreach ($this->posting_panels as $name => $lang) {
         $this->template->set_filenames(array($name => 'posting/panels/' . $name . '.html'));
         $this->template->assign_block_vars('panels', array('NAME' => $name, 'TITLE' => $this->user->lang($lang), 'OUTPUT' => $this->template->assign_display($name)));
     }
 }
示例#10
0
 /**
  * {@inheritdoc}
  */
 public function add_user_form_group($title, $form)
 {
     $this->template->assign_var('S_FORM_ELEM_COUNT', sizeof($form));
     $this->template->assign_block_vars('options', array('LEGEND' => $this->language->lang($title), 'S_LEGEND' => true));
     foreach ($form as $input_name => $input_options) {
         if (!isset($input_options['type'])) {
             continue;
         }
         $tpl_ary = array();
         $tpl_ary['TYPE'] = $input_options['type'];
         $tpl_ary['TITLE'] = $this->language->lang($input_options['label']);
         $tpl_ary['KEY'] = $input_name;
         $tpl_ary['S_EXPLAIN'] = false;
         if (isset($input_options['default'])) {
             $default = $input_options['default'];
             $default = preg_replace_callback('#\\{L_([A-Z0-9\\-_]*)\\}#s', array($this, 'lang_replace_callback'), $default);
             $tpl_ary['DEFAULT'] = $default;
         }
         if (isset($input_options['description'])) {
             $tpl_ary['TITLE_EXPLAIN'] = $this->language->lang($input_options['description']);
             $tpl_ary['S_EXPLAIN'] = true;
         }
         if (in_array($input_options['type'], array('select', 'radio'))) {
             for ($i = 0, $total = sizeof($input_options['options']); $i < $total; $i++) {
                 if (isset($input_options['options'][$i]['label'])) {
                     $input_options['options'][$i]['label'] = $this->language->lang($input_options['options'][$i]['label']);
                 }
             }
             $tpl_ary['OPTIONS'] = $input_options['options'];
         }
         $this->template->assign_block_vars('options', $tpl_ary);
     }
     $this->template->set_filenames(array('form_install' => 'installer_form.html'));
     $this->form = $this->template->assign_display('form_install');
 }
示例#11
0
    public function handle_downloadlog()
    {
        if (!$this->auth->acl_get('a_')) {
            trigger_error('Access Denied');
        } else {
            $this->user->add_lang_ext('dmzx/downloadlog', 'common');
            $fileid = $this->request->variable('file', 0);
            $start = $this->request->variable('start', 0);
            // Pagination number from ACP
            $dll = $this->config['downloadlog_value'];
            // Generate pagination
            $sql = 'SELECT COUNT(downloadslog_id) AS total_downloadlogs
				FROM ' . $this->userdownloadslog_table . '
				WHERE user_id = user_id
				AND file_id = ' . $fileid;
            $result = $this->db->sql_query($sql);
            $total_downloadlogs = (int) $this->db->sql_fetchfield('total_downloadlogs');
            $sql = 'SELECT d.user_id, d.down_date, u.user_id, u.username, u.user_colour
				FROM ' . $this->userdownloadslog_table . ' d, ' . USERS_TABLE . ' u
				WHERE u.user_id = d.user_id
				AND file_id = ' . $fileid . '
				ORDER BY d.down_date DESC';
            $top_result = $this->db->sql_query_limit($sql, $dll, $start);
            while ($row = $this->db->sql_fetchrow($top_result)) {
                $this->template->assign_block_vars('downloaders', array('D_USERNAME' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']), 'D_TIME' => $this->user->format_date($row['down_date'])));
            }
        }
        $pagination_url = $this->helper->route('dmzx_downloadlog_controller', array('file' => $fileid));
        //Start pagination
        $this->pagination->generate_template_pagination($pagination_url, 'pagination', 'start', $total_downloadlogs, $dll, $start);
        $this->template->assign_vars(array('DOWNLOADERS_USERS' => $total_downloadlogs == 1 ? $this->user->lang['DOWNLOADERS_COUNT'] : sprintf($this->user->lang['DOWNLOADERS_COUNTS'], $total_downloadlogs), 'DOWNLOADERS_VERSION' => $this->config['downloadlog_version']));
        page_header('Downloaders Log', false);
        $this->template->set_filenames(array('body' => 'DownloadLog.html'));
        page_footer();
    }
 /**
  * Set email template to use
  */
 function template($template_file, $template_lang = '', $template_path = '')
 {
     global $config, $phpbb_root_path, $phpEx, $user, $phpbb_extension_manager;
     $this->setup_template();
     if (!trim($template_file)) {
         trigger_error('No template file for emailing set.', E_USER_ERROR);
     }
     if (!trim($template_lang)) {
         // fall back to board default language if the user's language is
         // missing $template_file.  If this does not exist either,
         // $this->template->set_filenames will do a trigger_error
         $template_lang = basename($config['default_lang']);
     }
     if ($template_path) {
         $template_paths = array($template_path);
     } else {
         $template_path = !empty($user->lang_path) ? $user->lang_path : $phpbb_root_path . 'language/';
         $template_path .= $template_lang . '/email';
         $template_paths = array($template_path);
         // we can only specify default language fallback when the path is not a custom one for which we
         // do not know the default language alternative
         if ($template_lang !== basename($config['default_lang'])) {
             $fallback_template_path = !empty($user->lang_path) ? $user->lang_path : $phpbb_root_path . 'language/';
             $fallback_template_path .= basename($config['default_lang']) . '/email';
             $template_paths[] = $fallback_template_path;
         }
     }
     $this->set_template_paths(array(array('name' => $template_lang . '_email', 'ext_path' => 'language/' . $template_lang . '/email')), $template_paths);
     $this->template->set_filenames(array('body' => $template_file . '.txt'));
     return true;
 }
示例#13
0
文件: rating.php 项目: bb3mobi/bb3top
 public function stats($top_id, $action)
 {
     if (!$this->config['top_rating_type'] && !isset($this->user->data['user_type'])) {
         trigger_error($this->user->lang['NOT_VIEW_RATING']);
     }
     $statrow = $this->rating->view_stat($top_id);
     if ($action && $statrow['top_type'] == 2) {
         trigger_error($this->user->lang['TOP_CLOSED']);
     }
     switch ($action) {
         case 'hosts':
             if (!$statrow['top_id'] || !$statrow['top_hosts']) {
                 trigger_error('TOP_NOT');
             }
             $this->rating->view_stat_hosts($statrow['top_id'], $statrow['top_hosts']);
             $page_title = $this->user->lang['TOP_HOSTS'] . str_replace(array('http://', 'https://'), ' ', $statrow['top_url']);
             $this->template->assign_vars(array('S_STATS_HOSTS' => true));
             break;
         case 'online':
             if (!$statrow['top_id'] || !$statrow['top_online']) {
                 trigger_error('TOP_NOT');
             }
             $this->rating->view_stat_online($statrow['top_id'], $statrow['top_online']);
             $page_title = $this->user->lang['TOP_ONLINE'] . str_replace(array('http://', 'https://'), ' ', $statrow['top_url']);
             $this->template->assign_vars(array('S_STATS_ONLINE' => true));
             break;
         case 'click':
             if (!$statrow['top_id'] || !$statrow['top_in'] && !$statrow['top_out']) {
                 trigger_error('TOP_NOT');
             }
             $top_count = $statrow['top_in'] + $statrow['top_out'];
             $this->rating->view_stat_click($statrow['top_id'], $top_count);
             $page_title = $this->user->lang['TOP_OUT'] . str_replace(array('http://', 'https://'), ' ', $statrow['top_url']);
             $this->template->assign_vars(array('S_STATS_CLICK' => true));
             break;
         case 'country':
             if (!$statrow['top_id'] || !$statrow['top_in'] && !$statrow['top_out']) {
                 trigger_error('TOP_NOT');
             }
             $this->rating->view_country($statrow['top_id']);
             $page_title = $this->user->lang['TOP_COUNTRYS'] . str_replace(array('http://', 'https://'), ' ', $statrow['top_url']);
             $this->template->assign_vars(array('S_STATS_COUNTRY' => true));
             break;
         default:
             $page_title = $this->user->lang['STATISTICS'] . str_replace(array('http://', 'https://'), ' ', $statrow['top_url']);
             $catrow = $this->rating->view_cat($statrow['cat_id']);
             $description = $statrow['post_text'];
             strip_bbcode($description);
             $description = str_replace(array("&quot;", "/", "\n", "\t", "\r"), ' ', $description);
             $this->template->assign_vars(array('DESCRIPTION' => $description, 'CAT_NAME' => $catrow[$statrow['cat_id']]['cat_title'], 'CAT_URL' => $this->helper->route("bb3top_rating_cat", array('cat_id' => $statrow['cat_id'])), 'S_STATS_DEFAULT' => true));
             break;
     }
     $this->template->assign_vars(array('U_STAT_DEFAULT' => $this->helper->route("bb3top_rating_stats", array('top_id' => $top_id)), 'U_STAT_HOSTS' => $this->helper->route("bb3top_rating_hosts", array('top_id' => $top_id)), 'U_STAT_ONLINE' => $this->helper->route("bb3top_rating_online", array('top_id' => $top_id)), 'U_STAT_CLICK' => $this->helper->route("bb3top_rating_click", array('top_id' => $top_id)), 'U_STAT_COUNTRY' => $this->helper->route("bb3top_rating_country", array('top_id' => $top_id)), 'U_CANONICAL' => $this->helper->route("bb3top_rating_stats", array('top_id' => $top_id), false, '', true)));
     $this->template->assign_block_vars('navlinks', array('FORUM_NAME' => $this->user->lang['RATING'], 'U_VIEW_FORUM' => $this->helper->route("bb3top_rating_category")));
     $this->template->assign_block_vars('navlinks', array('FORUM_NAME' => $page_title, 'U_VIEW_FORUM' => $this->helper->route("bb3top_rating_stats", array('top_id' => $top_id))));
     page_header($page_title);
     $this->template->set_filenames(array('body' => '@bb3top_rating/rating_stats.html'));
     page_footer();
 }
示例#14
0
文件: helper.php 项目: joe80/ads
    public function my()
    {
        // HAX (don't add to the view count every time this page is viewed)
        // It doesn't look good to the advertisers since this is the only (in a vanilla install) page that would add to the view count but not display them it is fine
        $this->config['ads_count_views'] = false;
        $this->template->assign_vars(array('S_POSITION_LIST' => true, 'S_AD_LIST' => true));
        // Positions
        $positions = array();
        $sql = 'SELECT position_id, lang_key FROM ' . ADS_POSITIONS_TABLE . ' ORDER BY position_id ASC';
        $result = $this->db->sql_query($sql);
        while ($row = $this->db->sql_fetchrow($result)) {
            $positions[$row['position_id']] = isset($this->user->lang[$row['lang_key']]) ? $this->user->lang[$row['lang_key']] : $row['lang_key'];
        }
        $this->db->sql_freeresult($result);
        // Forums
        $forums = array();
        $sql = 'SELECT forum_id, forum_name FROM ' . FORUMS_TABLE . ' ORDER BY forum_id ASC';
        $result = $this->db->sql_query($sql);
        while ($row = $this->db->sql_fetchrow($result)) {
            $forums[$row['forum_id']] = $row['forum_name'];
        }
        $this->db->sql_freeresult($result);
        // Advertisements
        $ads = array();
        $sql = 'SELECT * FROM ' . ADS_TABLE . '
			WHERE ad_owner = ' . $this->user->data['user_id'] . '
			ORDER BY ad_enabled DESC, ad_time DESC';
        $result = $this->db->sql_query($sql);
        while ($row = $this->db->sql_fetchrow($result)) {
            $ads[$row['ad_id']] = $row;
            $ads[$row['ad_id']]['positions'] = array();
            $ads[$row['ad_id']]['forums'] = array();
        }
        $this->db->sql_freeresult($result);
        if (sizeof($ads)) {
            $sql = 'SELECT * FROM ' . ADS_IN_POSITIONS_TABLE . '
				WHERE ' . $this->db->sql_in_set('ad_id', array_keys($ads));
            $result = $this->db->sql_query($sql);
            while ($row = $this->db->sql_fetchrow($result)) {
                $ads[$row['ad_id']]['positions'][] = $positions[$row['position_id']];
            }
            $this->db->sql_freeresult($result);
            $sql = 'SELECT * FROM ' . ADS_FORUMS_TABLE . '
				WHERE ' . $this->db->sql_in_set('ad_id', array_keys($ads));
            $result = $this->db->sql_query($sql);
            while ($row = $this->db->sql_fetchrow($result)) {
                $ads[$row['ad_id']]['forums'][] = $forums[$row['forum_id']];
            }
            $this->db->sql_freeresult($result);
        }
        foreach ($ads as $row) {
            $ads_in_positions = implode('<br />', $row['positions']);
            $ads_in_forums = implode('<br />', $row['forums']);
            $this->template->assign_block_vars('ads', array('AD_ID' => $row['ad_id'], 'AD_ENABLED' => $row['ad_enabled'] ? $this->user->lang['TRUE'] : $this->user->lang['FALSE'], 'AD_CODE' => $row['ad_code'], 'AD_CODE_DISPLAY' => htmlspecialchars_decode($row['ad_code']), 'AD_TIME' => date('d F Y', $row['ad_time']), 'AD_TIME_END' => $row['ad_time_end'] ? date('d F Y', $row['ad_time_end']) : 0, 'AD_VIEW_LIMIT' => $row['ad_view_limit'], 'AD_VIEWS' => $row['ad_views'], 'AD_CLICK_LIMIT' => $row['ad_click_limit'], 'AD_CLICKS' => $row['ad_clicks'] ? $row['ad_clicks'] : $this->user->lang['0_OR_NA'], 'AD_IN_POSITIONS' => $ads_in_positions, 'AD_IN_FORUMS' => $row['all_forums'] ? $this->user->lang['ALL_FORUMS'] : $ads_in_forums));
        }
        page_header($this->user->lang['MY_ADS']);
        $this->template->set_filenames(array('body' => '@bb3mobi_ads/acp_ads.html'));
        page_footer();
    }
 /**
  * Changes the regex replacement for second pass
  *
  * @param object $event
  * @return null
  * @access public
  */
 public function modify_case_img($event)
 {
     $bbcode_id = 4;
     // [img] has bbcode_id 4 hardcoded
     $bbcode_cache = $event['bbcode_cache'];
     if (!isset($bbcode_cache[$bbcode_id]) || !$this->user->optionget('viewimg')) {
         return;
     }
     $this->template->set_filenames(array('bbcode.html' => 'bbcode.html'));
     $bbcode = new \bbcode();
     // We need these otherwise we cannot use $bbcode->bbcode_tpl()
     $bbcode->template_bitfield = new \bitfield($this->user->style['bbcode_bitfield']);
     $bbcode->template_filename = $this->template->get_source_file_for_handle('bbcode.html');
     $extimgaslink_boardurl = generate_board_url() . '/';
     $bbcode_cache[$bbcode_id] = array('preg' => array('#\\[img:$uid\\](' . preg_quote($extimgaslink_boardurl, '#') . '.*?)\\[/img:$uid\\]#s' => $bbcode->bbcode_tpl('img', $bbcode_id), '#\\[img:$uid\\](.*?)\\[/img:$uid\\]#s' => str_replace('$2', $this->user->lang('EXTIMGLINK'), $bbcode->bbcode_tpl('url', $bbcode_id, true))));
     $event['bbcode_cache'] = $bbcode_cache;
 }
示例#16
0
 /**
  * Display progress bar for syncinc categories
  *
  * @return null
  */
 public function action_progress_bar()
 {
     $start = $this->request->variable('start', 0);
     $total = $this->request->variable('total', 0);
     adm_page_header($this->user->lang['SYNC_IN_PROGRESS']);
     $this->template->set_filenames(array('body' => 'progress_bar.html'));
     $this->template->assign_vars(array('L_PROGRESS' => $this->user->lang['SYNC_IN_PROGRESS'], 'L_PROGRESS_EXPLAIN' => $start && $total ? $this->user->lang('SYNC_IN_PROGRESS_EXPLAIN', $start, $total) : $this->user->lang['SYNC_IN_PROGRESS']));
     adm_page_footer();
 }
示例#17
0
 /**
  * Handle the requests
  *
  * @return null
  * @access public
  */
 public function handle()
 {
     switch ($this->request->variable('mode', '')) {
         case 'who_is_online':
             // Output page
             page_header('', true);
             $this->template->set_filenames(array('body' => 'ajax_base/who_is_online.html'));
             page_footer();
             break;
         case 'statistics':
             $this->template->assign_vars(array('TOTAL_POSTS' => $this->user->lang('TOTAL_POSTS_COUNT', (int) $this->config['num_posts']), 'TOTAL_TOPICS' => $this->user->lang('TOTAL_TOPICS', (int) $this->config['num_topics']), 'TOTAL_USERS' => $this->user->lang('TOTAL_USERS', (int) $this->config['num_users']), 'NEWEST_USER' => $this->user->lang('NEWEST_USER', get_username_string('full', $this->config['newest_user_id'], $this->config['newest_username'], $this->config['newest_user_colour']))));
             // Output page
             page_header('');
             $this->template->set_filenames(array('body' => 'ajax_base/statistics.html'));
             page_footer();
             break;
     }
 }
示例#18
0
 /**
  * Changes the regex replacement for second pass
  *
  * Based on phpBB.de - External Image as Link from Christian Schnegelberger<*****@*****.**> and Oliver Schramm <*****@*****.**>
  *
  * @param object $event
  * @return null
  * @access public
  */
 public function bbcode_cache_init_end($event)
 {
     $bbcode_id = 4;
     // [img] has bbcode_id 4 hardcoded
     $bbcode_cache = $event['bbcode_cache'];
     if (!isset($bbcode_cache[$bbcode_id]) || !$this->user->optionget('viewimg')) {
         return;
     }
     $this->template->set_filenames(array('bbcode.html' => 'bbcode.html'));
     $bbcode = new \bbcode();
     // We need these otherwise we cannot use $bbcode->bbcode_tpl()
     $bbcode->template_bitfield = new \bitfield($this->user->style['bbcode_bitfield']);
     $bbcode->template_filename = $this->template->get_source_file_for_handle('bbcode.html');
     $extimgaslink_boardurl = generate_board_url() . '/';
     $url = $this->helper->route('tas2580_imageproxy_main', array());
     $bbcode_cache[$bbcode_id] = array('preg' => array('#\\[img:$uid\\](' . preg_quote($extimgaslink_boardurl, '#') . '.*?)\\[/img:$uid\\]#s' => $bbcode->bbcode_tpl('img', $bbcode_id), '#\\[img:$uid\\](.*?)\\[/img:$uid\\]#s' => str_replace('$1', $url . '?img=$1', $bbcode->bbcode_tpl('img', $bbcode_id, true))));
     $event['bbcode_cache'] = $bbcode_cache;
 }
示例#19
0
 /**
  * Extension front handler method. This is called automatically when your extension is accessed
  * through index.php?ext=example/foobar
  *
  * @param array $columns Columns to display
  *
  * @return null
  */
 public function handle($columns = array())
 {
     // Do not run portal if it's already active
     if ($this->portal_active) {
         return;
     }
     $this->controller_helper->run_initial_tasks();
     // Set portal active
     $this->portal_active = true;
     // Check if we should limit the columns to display
     $this->set_allowed_columns($columns);
     // Set default data
     $this->portal_modules = obtain_portal_modules();
     $display_online = false;
     /**
      * set up column_count array
      * with this we can hide unneeded parts of the portal
      */
     $this->module_count = array('total' => 0, 'top' => 0, 'left' => 0, 'center' => 0, 'right' => 0, 'bottom' => 0);
     /**
      * start assigning block vars
      */
     foreach ($this->portal_modules as $row) {
         if (!($module = $this->controller_helper->get_portal_module($row))) {
             continue;
         }
         // Load module language file
         $this->controller_helper->load_module_language($module);
         $template_module = $this->get_module_template($row, $module);
         if (empty($template_module)) {
             continue;
         }
         // Custom Blocks that have been defined in the ACP will return an array instead of just the name of the template file
         $this->controller_helper->assign_module_vars($row, $template_module);
         // Check if we need to show the online list
         $display_online = $this->controller_helper->check_online_list($row['module_classname'], $display_online);
         unset($template_module);
     }
     // Redirect to index if there are currently no active modules
     $this->check_redirect();
     // Assign specific vars
     $this->assign_template_vars();
     // Return if columns were specified. Columns are only specified if
     // portal columns are displayed on pages other than the portal itself.
     if ($this->allowed_columns !== 0) {
         $this->template->assign_var('S_PORTAL_ALL', true);
         return;
     }
     // And now to output the page.
     page_header($this->user->lang('PORTAL'), $display_online);
     // foobar_body.html is in ./ext/foobar/example/styles/prosilver/template/foobar_body.html
     $this->template->set_filenames(array('body' => 'portal/portal_body.html'));
     $this->make_jumpbox($this->config['board3_display_jumpbox']);
     page_footer();
 }
示例#20
0
 /**
  * Run AutoMOD test.
  *
  * @param \phpbb\titania\entity\package $package
  * @param string $phpbb_path Path to phpBB files we run the test on
  * @param string $details Will hold the details of the mod
  * @param string $results Will hold the results for output
  * @param string $bbcode_results Will hold the results for storage
  * @return bool true on success, false on failure
  */
 public function run_automod_test($package, $phpbb_path, &$details, &$results, &$bbcode_results)
 {
     require $this->phpbb_root_path . 'includes/functions_transfer.' . $this->php_ext;
     require $this->phpbb_root_path . 'includes/functions_admin.' . $this->php_ext;
     require $this->ext_root_path . 'includes/library/automod/acp_mods.' . $this->php_ext;
     require $this->ext_root_path . 'includes/library/automod/editor.' . $this->php_ext;
     require $this->ext_root_path . 'includes/library/automod/mod_parser.' . $this->php_ext;
     require $this->ext_root_path . 'includes/library/automod/functions_mods.' . $this->php_ext;
     $this->user->add_lang_ext('phpbb/titania', 'automod');
     // Find the main modx file
     $modx_root = $package->find_directory(array('files' => array('required' => 'install*.xml')));
     if ($modx_root === null) {
         $this->user->add_lang_ext('phpbb/titania', 'contributions');
         $this->errors[] = $this->user->lang['COULD_NOT_FIND_ROOT'];
         return false;
     }
     $modx_root = $package->get_temp_path() . '/' . $modx_root . '/';
     $modx_file = false;
     if (file_exists($modx_root . 'install.xml')) {
         $modx_file = $modx_root . 'install.xml';
     } else {
         $finder = new \Symfony\Component\Finder\Finder();
         $finder->name('install*.xml')->depth(0)->in($modx_root);
         if ($finder->count()) {
             foreach ($finder as $file) {
                 $modx_file = $file->getPathname();
                 break;
             }
         }
     }
     if (!$modx_file) {
         $this->user->add_lang_ext('phpbb/titania', 'contributions');
         $this->errors[] = $this->user->lang['COULD_NOT_FIND_ROOT'];
         return false;
     }
     // HAX
     global $phpbb_root_path;
     $phpbb_root_path = $phpbb_path;
     // The real stuff
     $acp_mods = new \acp_mods();
     $acp_mods->mods_dir = $this->ext_config->__get('contrib_temp_path');
     $acp_mods->mod_root = $modx_root;
     $editor = new \editor_direct();
     $details = $acp_mods->mod_details($modx_file, false);
     $actions = $acp_mods->mod_actions($modx_file);
     $installed = $acp_mods->process_edits($editor, $actions, $details, false, true, false);
     // Reverse HAX
     $phpbb_root_path = $this->phpbb_root_path;
     $this->template->set_filenames(array('automod' => 'contributions/automod.html', 'automod_bbcode' => 'contributions/automod_bbcode.html'));
     $this->template->assign_var('S_AUTOMOD_SUCCESS', $installed);
     $results = $this->template->assign_display('automod');
     $bbcode_results = $this->template->assign_display('automod_bbcode');
     return $installed;
 }
 function main()
 {
     // Only registered users can go beyond this point
     if (!$this->user->data['is_registered']) {
         if ($this->user->data['is_bot']) {
             redirect(append_sid("{$this->phpbb_root_path}index.{$this->phpEx}"));
         }
         login_box('', $this->user->lang['LOGIN_INFO']);
     }
     $adm_points = $this->request->variable('adm_points', false);
     $u_id = $this->request->variable('user_id', 0);
     $post_id = $this->request->variable('post_id', 0);
     if (empty($u_id)) {
         $message = $this->user->lang['EDIT_NO_ID_SPECIFIED'] . '<br /><br /><a href="' . $this->helper->route('dmzx_ultimatepoints_controller', array('mode' => 'bank_edit')) . '">&laquo; ' . $this->user->lang['BACK_TO_PREV'] . '</a>';
         trigger_error($message);
     }
     $user_id = $u_id;
     add_form_key('bank_edit');
     if ($adm_points != false && ($this->auth->acl_get('a_') || $this->auth->acl_get('m_chg_bank'))) {
         $this->template->assign_block_vars('administer_bank', array());
         $submit = isset($_POST['submit']) ? true : false;
         if ($submit) {
             if (!check_form_key('bank_edit')) {
                 trigger_error('FORM_INVALID');
             }
             $new_points = round($this->request->variable('points', 0.0), 2);
             $this->functions_points->set_bank($u_id, $new_points);
             $sql_array = array('SELECT' => 'user_id, username, user_points, user_colour', 'FROM' => array(USERS_TABLE => 'u'), 'WHERE' => 'user_id = ' . (int) $u_id);
             $sql = $this->db->sql_build_query('SELECT', $sql_array);
             $result = $this->db->sql_query($sql);
             $points_user = $this->db->sql_fetchrow($result);
             // Add logs
             $this->log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_MOD_BANK', false, array($points_user['username']));
             $message = $post_id ? sprintf($this->user->lang['EDIT_P_RETURN_POST'], '<a href="' . append_sid("{$this->phpbb_root_path}viewtopic.{$this->phpEx}", "p=" . $post_id) . '">', '</a>') : sprintf($this->user->lang['EDIT_P_RETURN_INDEX'], '<a href="' . append_sid("{$this->phpbb_root_path}index.{$this->phpEx}") . '">', '</a>');
             trigger_error(sprintf($this->user->lang['EDIT_POINTS_SET'], $this->config['points_name']) . $message);
         } else {
             $sql_array = array('SELECT' => 'u.user_id, u.username, u.user_points, u.user_colour, b.holding', 'FROM' => array(USERS_TABLE => 'u'), 'LEFT_JOIN' => array(array('FROM' => array($this->points_bank_table => 'b'), 'ON' => 'u.user_id = b.user_id')), 'WHERE' => 'u.user_id = ' . (int) $u_id);
             $sql = $this->db->sql_build_query('SELECT', $sql_array);
             $result = $this->db->sql_query($sql);
             $row = $this->db->sql_fetchrow($result);
             if (empty($u_id)) {
                 $message = $this->user->lang['EDIT_USER_NOT_EXIST'] . '<br /><br /><a href="' . $this->helper->route('dmzx_ultimatepoints_controller', array('mode' => 'bank_edit')) . '">&laquo; ' . $this->user->lang['BACK_TO_PREV'] . '</a>';
                 trigger_error($message);
             }
             $hidden_fields = build_hidden_fields(array('user_id' => $u_id, 'post_id' => $post_id));
             $this->template->assign_vars(array('USER_NAME' => get_username_string('full', $u_id, $row['username'], $row['user_colour']), 'BANK_POINTS' => sprintf($this->functions_points->number_format_points($row['holding'])), 'POINTS_NAME' => $this->config['points_name'], 'CURRENT_VALUE' => $row['holding'], 'L_POINTS_MODIFY' => sprintf($this->user->lang['EDIT_BANK_MODIFY'], $this->config['points_name']), 'L_P_BANK_TITLE' => sprintf($this->user->lang['EDIT_P_BANK_TITLE'], $this->config['points_name']), 'L_USERNAME' => $this->user->lang['USERNAME'], 'L_SET_AMOUNT' => $this->user->lang['EDIT_SET_AMOUNT'], 'U_USER_LINK' => append_sid("{$this->phpbb_root_path}memberlist.{$this->phpEx}", "mode=viewprofile&amp;u=" . $u_id), 'S_ACTION' => $this->helper->route('dmzx_ultimatepoints_controller', array('mode' => 'bank_edit', 'adm_points' => '1')), 'S_HIDDEN_FIELDS' => $hidden_fields));
         }
     }
     // Generate the page
     page_header($this->user->lang['EDIT_POINTS_ADMIN']);
     // Generate the page template
     $this->template->set_filenames(array('body' => 'points/points_bank_edit.html'));
     page_footer();
 }
示例#22
0
 /**
  * Return templated value/field. Possible values for $mode are:
  * change == user is able to set/enter profile values; preview == just show the value
  */
 public function process_field_row($mode, $profile_row)
 {
     $preview_options = $mode == 'preview' ? $profile_row['lang_options'] : false;
     // set template filename
     $this->template->set_filenames(array('cp_body' => $this->get_template_filename()));
     // empty previously filled blockvars
     $this->template->destroy_block_vars($this->get_name_short());
     // Assign template variables
     $this->generate_field($profile_row, $preview_options);
     return $this->template->assign_display('cp_body');
 }
示例#23
0
 /**
  * {@inheritdoc}
  */
 public function render_update_file_status($status_array)
 {
     $this->template->assign_vars(array('T_IMAGE_PATH' => $this->path_helper->get_web_root_path() . 'adm/images/'));
     foreach ($status_array as $block => $list) {
         foreach ($list as $filename) {
             $dirname = dirname($filename);
             $this->template->assign_block_vars($block, array('STATUS' => $block, 'FILENAME' => $filename, 'DIR_PART' => !empty($dirname) && $dirname !== '.' ? dirname($filename) . '/' : false, 'FILE_PART' => basename($filename)));
         }
     }
     $this->template->set_filenames(array('file_status' => 'installer_update_file_status.html'));
     $this->file_status = $this->template->assign_display('file_status');
 }
	/**
	* This listener is run when the KernelEvents::EXCEPTION event is triggered
	*
	* @param GetResponseForExceptionEvent $event
	* @return null
	*/
	public function on_kernel_exception(GetResponseForExceptionEvent $event)
	{
		page_header($this->user->lang('INFORMATION'));

		$exception = $event->getException();

		$this->template->assign_vars(array(
			'MESSAGE_TITLE'		=> $this->user->lang('INFORMATION'),
			'MESSAGE_TEXT'		=> $exception->getMessage(),
		));

		$this->template->set_filenames(array(
			'body'	=> 'message_body.html',
		));

		page_footer(true, false, false);

		$status_code = $exception instanceof HttpException ? $exception->getStatusCode() : 500;
		$response = new Response($this->template->assign_display('body'), $status_code);
		$event->setResponse($response);
	}
示例#25
0
 /**
  * Alter preview output for ajax request
  *
  * @param object $event The event object
  * @return null
  * @access public
  */
 public function output_ajax_post_preview($event)
 {
     if ($this->request->is_ajax() && $event['preview']) {
         if (empty($event['message_parser']->message)) {
             exit_handler();
         } else {
             if (sizeof($event['error'])) {
                 // seems to be the best HTTP code
                 header('HTTP/1.1 412 Precondition Failed');
                 echo implode('<br />', $event['error']);
                 exit_handler();
             } else {
                 $this->template->assign_vars($event['page_data']);
                 // we can't use helper's render method, because it refreshes the page
                 page_header('');
                 $this->template->set_filenames(array('body' => '@senky_ajaxbase/ajax_posting_preview.html'));
                 page_footer();
             }
         }
     }
 }
示例#26
0
文件: helper.php 项目: MrAdder/phpbb
 /**
  * Automate setting up the page and creating the response object.
  *
  * @param string	$template_file		The template handle to render
  * @param string	$page_title			The title of the page to output
  * @param bool		$selected_language	True to enable language selector it, false otherwise
  * @param int		$status_code		The status code to be sent to the page header
  *
  * @return Response object containing rendered page
  */
 public function render($template_file, $page_title = '', $selected_language = false, $status_code = 200)
 {
     $this->page_header($page_title, $selected_language);
     $this->template->set_filenames(array('body' => $template_file));
     $response = new Response($this->template->assign_display('body'), $status_code);
     // Set language cookie
     if ($this->language_cookie !== false) {
         $cookie = new Cookie('lang', $this->language_cookie, time() + 3600);
         $response->headers->setCookie($cookie);
         $this->language_cookie = false;
     }
     return $response;
 }
示例#27
0
 public function cat($cat_id = 0, $attach_id = 0)
 {
     if (!$this->auth->acl_get('u_download')) {
         trigger_error($this->user->lang['RULES_DOWNLOAD_CANNOT']);
     }
     $this->user->setup('acp/attachments');
     $this->user->add_lang_ext('bb3mobi/attachments', 'attachments');
     $topic_id = $this->request->variable('t', 0);
     if ($attach_id) {
         $page_title = $this->file($attach_id);
     } else {
         $page_title_number = $this->view($cat_id, $topic_id);
     }
     $sql_topic = $topic_id ? " AND a.topic_id = " . (int) $topic_id : '';
     $sql = "SELECT eg.*, COUNT(a.attach_id) AS count_file\n\t\t\tFROM " . EXTENSION_GROUPS_TABLE . " eg,\n\t\t\t\t" . EXTENSIONS_TABLE . " e,\n\t\t\t\t" . ATTACHMENTS_TABLE . " a\n\t\t\tWHERE eg.group_id = e.group_id\n\t\t\tAND e.extension = a.extension\n\t\t\tAND eg.allow_group = 1\n\t\t\tAND a.is_orphan = 0\n\t\t\tAND a.in_message = 0\n\t\t\t{$sql_topic}\n\t\tGROUP BY group_id";
     $result = $this->db->sql_query($sql);
     $catrow = array();
     $count_download = '';
     while ($row = $this->db->sql_fetchrow($result)) {
         $view_ary = $topic_id ? array('t' => $topic_id) : array();
         $cat_icon = '';
         if ($row['upload_icon']) {
             $cat_icon = '<img src="' . generate_board_url() . '/images/upload_icons/' . $row['upload_icon'] . '" alt="" style="vertical-align: middle" />';
         }
         $title = isset($this->user->lang['EXT_GROUP_' . $row['group_name']]) ? $this->user->lang['EXT_GROUP_' . $row['group_name']] : $row['group_name'];
         $selected = false;
         if ($row['group_id'] == $cat_id) {
             $page_title = $title . $page_title_number;
             $selected = true;
         }
         $this->template->assign_block_vars('catrow', array('CAT_ID' => $row['group_id'], 'CAT_TITLE' => $title, 'CAT_COUNT' => $row['count_file'], 'CAT_ICON' => $cat_icon, 'CAT_SELECT' => $selected, 'U_CAT_VIEW' => $this->helper->route("bb3mobi_attach_view", array_merge(array('cat_id' => $row['group_id']), $view_ary))));
     }
     $this->db->sql_freeresult($result);
     $this->template->assign_var('S_ATTACH_CAT', !$cat_id && !$attach_id ? true : false);
     $page_title = !isset($page_title) ? $this->user->lang['ATTACHMENTS_FORUMS'] : $page_title;
     page_header($page_title);
     $this->template->set_filenames(array('body' => '@bb3mobi_attachments/download.html'));
     page_footer();
 }
示例#28
0
 /**
  * Set email template to use
  */
 function template($template_file, $template_lang = '', $template_path = '', $template_dir_prefix = '')
 {
     global $config, $phpbb_root_path, $user;
     $template_dir_prefix = !$template_dir_prefix || $template_dir_prefix[0] === '/' ? $template_dir_prefix : '/' . $template_dir_prefix;
     $this->setup_template();
     if (!trim($template_file)) {
         trigger_error('No template file for emailing set.', E_USER_ERROR);
     }
     if (!trim($template_lang)) {
         // fall back to board default language if the user's language is
         // missing $template_file.  If this does not exist either,
         // $this->template->set_filenames will do a trigger_error
         $template_lang = basename($config['default_lang']);
     }
     $ext_template_paths = array(array('name' => $template_lang . '_email', 'ext_path' => 'language/' . $template_lang . '/email' . $template_dir_prefix));
     if ($template_path) {
         $template_paths = array($template_path . $template_dir_prefix);
     } else {
         $template_path = !empty($user->lang_path) ? $user->lang_path : $phpbb_root_path . 'language/';
         $template_path .= $template_lang . '/email';
         $template_paths = array($template_path . $template_dir_prefix);
         $board_language = basename($config['default_lang']);
         // we can only specify default language fallback when the path is not a custom one for which we
         // do not know the default language alternative
         if ($template_lang !== $board_language) {
             $fallback_template_path = !empty($user->lang_path) ? $user->lang_path : $phpbb_root_path . 'language/';
             $fallback_template_path .= $board_language . '/email';
             $template_paths[] = $fallback_template_path . $template_dir_prefix;
             $ext_template_paths[] = array('name' => $board_language . '_email', 'ext_path' => 'language/' . $board_language . '/email' . $template_dir_prefix);
         }
         // If everything fails just fall back to en template
         if ($template_lang !== 'en' && $board_language !== 'en') {
             $fallback_template_path = !empty($user->lang_path) ? $user->lang_path : $phpbb_root_path . 'language/';
             $fallback_template_path .= 'en/email';
             $template_paths[] = $fallback_template_path . $template_dir_prefix;
             $ext_template_paths[] = array('name' => 'en_email', 'ext_path' => 'language/en/email' . $template_dir_prefix);
         }
     }
     $this->set_template_paths($ext_template_paths, $template_paths);
     $this->template->set_filenames(array('body' => $template_file . '.txt'));
     return true;
 }
示例#29
0
 /**
  * Parse the uploader
  *
  * @param string $tpl_file The name of the template file to use to create the uploader
  * @param bool $custom_sort Function used to sort the attachments
  * @return string The parsed HTML code ready for output
  */
 public function parse_uploader($tpl_file = 'posting/attachments/default.html', $custom_sort = false)
 {
     // If the upload max filesize is less than 0, do not show the uploader (0 = unlimited)
     if (!$this->access->is_team()) {
         if (isset($this->ext_config->upload_max_filesize[$this->object_type]) && $this->ext_config->upload_max_filesize[$this->object_type] < 0) {
             return '';
         }
     }
     $this->template->assign_vars(array('FORM_NAME' => $this->form_name, 'MAX_LENGTH' => $this->access->is_team() ? $this->config['max_filesize'] : false, 'S_FORM_ENCTYPE' => ' enctype="multipart/form-data"', 'S_INLINE_ATTACHMENT_OPTIONS' => true, 'S_PLUPLOAD_ENABLED' => $this->use_plupload, 'S_SET_CUSTOM_ORDER' => $this->set_custom_order, 'S_UPLOADER_KEY' => generate_link_hash('uploader_key'), 'SELECT_PREVIEW' => $this->object_type == TITANIA_SCREENSHOT, 'SELECT_REVIEW_VAR' => 'set_preview_file' . $this->object_type));
     $index_dir = '-';
     $index = $this->operator->get_count() - 1;
     if ($custom_sort == false && !$this->config['display_order']) {
         $index_dir = '+';
         $index = 0;
     }
     $this->operator->sort($custom_sort);
     // Delete previous attachments list
     $this->template->destroy_block_vars('attach_row');
     $base_url = $this->controller_helper->get_current_url();
     $hash = generate_link_hash('attach_manage');
     $comments = $this->get_request_comments();
     $hidden_data = $this->get_basic_attachment_data();
     $index_prefix = $this->use_plupload ? '' : $this->form_name . '_';
     foreach ($this->operator->get_all() as $attachment_id => $attach) {
         $params = array('a' => $attachment_id, 'hash' => $hash);
         $_hidden_data = array();
         foreach ($hidden_data[$attachment_id] as $property => $value) {
             $_hidden_data["attachment_data[{$index_prefix}{$index}][{$property}]"] = $value;
         }
         $output = array_merge($attach->get_display_vars(''), array('FILENAME' => $attach->get_filename(), 'FILE_COMMENT' => isset($comments[$attachment_id]) ? $comments[$attachment_id] : $attach->get('attachment_comment'), 'ATTACH_ID' => $attachment_id, 'INDEX' => $index_prefix . $index, 'FILESIZE' => get_formatted_filesize($attach->get('filesize')), 'S_HIDDEN' => build_hidden_fields($_hidden_data), 'S_PREVIEW' => $attach->is_preview(), 'U_VIEW_ATTACHMENT' => $attach->get_url(), 'U_DELETE' => $this->path_helper->append_url_params($base_url, array_merge($params, array('action' => 'delete_attach')))));
         if ($attach->is_type(TITANIA_SCREENSHOT)) {
             $output = array_merge($output, array('U_MOVE_UP' => $this->path_helper->append_url_params($base_url, array_merge($params, array('action' => 'attach_up'))), 'U_MOVE_DOWN' => $this->path_helper->append_url_params($base_url, array_merge($params, array('action' => 'attach_down')))));
         }
         $index += $index_dir == '+' ? 1 : -1;
         $this->template->assign_block_vars('attach_row', $output);
     }
     $this->template->assign_var('S_ATTACH_DATA', json_encode(array_values($hidden_data)));
     $this->template->set_filenames(array($tpl_file => $tpl_file));
     return $this->template->assign_display($tpl_file);
 }
    public function handle_ultimatepoints_list()
    {
        // UPlist disabled
        if (!$this->config['points_enable']) {
            trigger_error($this->user->lang['POINTS_LIST_DISABLE'], E_USER_NOTICE);
        }
        // Get some values
        $sql_array = array('SELECT' => '*', 'FROM' => array($this->points_values_table => 'v'));
        $sql = $this->db->sql_build_query('SELECT', $sql_array);
        $result = $this->db->sql_query($sql);
        $points_values = $this->db->sql_fetchrow($result);
        $this->db->sql_freeresult($result);
        // Generate donors list
        $start = $this->request->variable('start', 0);
        $limit = $points_values['number_show_per_page'];
        $sql = 'SELECT *
			FROM ' . USERS_TABLE . '
			WHERE user_points > 0
			ORDER BY user_points DESC';
        $result = $this->db->sql_query_limit($sql, $limit, $start);
        while ($row = $this->db->sql_fetchrow($result)) {
            $this->template->assign_block_vars('ultimatelist', array('USERNAME' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']), 'POINT' => sprintf($this->functions_points->number_format_points($row['user_points']))));
        }
        $this->db->sql_freeresult($result);
        // Generate pagination
        $sql = 'SELECT COUNT(user_points) AS ultimatepoints_total
			FROM ' . USERS_TABLE . '
			WHERE user_points > 0';
        $result = $this->db->sql_query($sql);
        $ultimatepoints_total = (int) $this->db->sql_fetchfield('ultimatepoints_total');
        //Start pagination
        $pagination_url = $this->helper->route('dmzx_ultimatepoints_list_controller');
        $this->pagination->generate_template_pagination($pagination_url, 'pagination', 'start', $ultimatepoints_total, $limit, $start);
        $this->template->assign_vars(array('TOTAL_ULTIMATEPOINTS_LIST' => $ultimatepoints_total == 1 ? $this->user->lang['POINTS_LIST_USER'] : sprintf($this->user->lang['POINTS_LIST_USERS'], $ultimatepoints_total), 'POINTSLIST' => $this->config['points_name']));
        // Output the page
        page_header($this->user->lang['POINTS_LIST_TOTAL']);
        $this->template->set_filenames(array('body' => 'points/points_list.html'));
        page_footer();
    }