コード例 #1
4
ファイル: listener.php プロジェクト: edipdincer/QuickReply
 /**
  * Show bbcodes and smilies in the quickreply
  * Template data for Ajax submit
  *
  * @param object $event The event object
  * @return null
  * @access public
  */
 public function viewtopic_modify_data($event)
 {
     $forum_id = $event['forum_id'];
     $topic_data = $event['topic_data'];
     $post_list = $event['post_list'];
     $topic_id = $topic_data['topic_id'];
     $s_quick_reply = false;
     if (($this->user->data['is_registered'] || $this->config['qr_allow_for_guests']) && $this->config['allow_quick_reply'] && $topic_data['forum_flags'] & FORUM_FLAG_QUICK_REPLY && $this->auth->acl_get('f_reply', $forum_id)) {
         // Quick reply enabled forum
         $s_quick_reply = $topic_data['forum_status'] == ITEM_UNLOCKED && $topic_data['topic_status'] == ITEM_UNLOCKED || $this->auth->acl_get('m_edit', $forum_id) ? true : false;
     }
     if (!$this->user->data['is_registered'] && $s_quick_reply) {
         add_form_key('posting');
         $s_attach_sig = $this->config['allow_sig'] && $this->user->optionget('attachsig') && $this->auth->acl_get('f_sigs', $forum_id) && $this->auth->acl_get('u_sig');
         $s_smilies = $this->config['allow_smilies'] && $this->user->optionget('smilies') && $this->auth->acl_get('f_smilies', $forum_id);
         $s_bbcode = $this->config['allow_bbcode'] && $this->user->optionget('bbcode') && $this->auth->acl_get('f_bbcode', $forum_id);
         $s_notify = false;
         $qr_hidden_fields = array('topic_cur_post_id' => (int) $topic_data['topic_last_post_id'], 'lastclick' => (int) time(), 'topic_id' => (int) $topic_data['topic_id'], 'forum_id' => (int) $forum_id);
         // Originally we use checkboxes and check with isset(), so we only provide them if they would be checked
         !$s_bbcode ? $qr_hidden_fields['disable_bbcode'] = 1 : true;
         !$s_smilies ? $qr_hidden_fields['disable_smilies'] = 1 : true;
         !$this->config['allow_post_links'] ? $qr_hidden_fields['disable_magic_url'] = 1 : true;
         $s_attach_sig ? $qr_hidden_fields['attach_sig'] = 1 : true;
         $s_notify ? $qr_hidden_fields['notify'] = 1 : true;
         $topic_data['topic_status'] == ITEM_LOCKED ? $qr_hidden_fields['lock_topic'] = 1 : true;
         $this->template->assign_vars(array('S_QUICK_REPLY' => true, 'U_QR_ACTION' => append_sid("{$this->phpbb_root_path}posting.{$this->php_ext}", "mode=reply&f={$forum_id}&t={$topic_id}"), 'QR_HIDDEN_FIELDS' => build_hidden_fields($qr_hidden_fields), 'USERNAME' => $this->request->variable('username', '', true)));
         if ($this->config['enable_post_confirm']) {
             $captcha = $this->captcha->get_instance($this->config['captcha_plugin']);
             $captcha->init(CONFIRM_POST);
         }
         if ($this->config['enable_post_confirm'] && (isset($captcha) && $captcha->is_solved() === false)) {
             $this->template->assign_vars(array('S_CONFIRM_CODE' => true, 'CAPTCHA_TEMPLATE' => $captcha->get_template()));
         }
         // Add the confirm id/code pair to the hidden fields, else an error is displayed on next submit/preview
         if (isset($captcha) && $captcha->is_solved() !== false) {
             $this->template->append_var('QR_HIDDEN_FIELDS', build_hidden_fields($captcha->get_hidden_fields()));
         }
     }
     // Ajaxify viewtopic data
     if ($this->request->is_ajax() && $this->request->is_set('qr_request')) {
         if (!$this->user->data['is_registered'] && $this->config['enable_post_confirm']) {
             $captcha = $this->captcha->get_instance($this->config['captcha_plugin']);
             $captcha->init(CONFIRM_POST);
             // Add the confirm id/code pair to the hidden fields, else an error is displayed on next submit/preview
             if (isset($captcha) && $captcha->is_solved() !== false) {
                 $this->template->append_var('QR_HIDDEN_FIELDS', build_hidden_fields($captcha->get_hidden_fields()));
             }
         }
         // Fix issues if the inserted post is not the first.
         if ($this->qr_insert && !$this->qr_first) {
             $this->template->alter_block_array('postrow', array('S_FIRST_ROW' => false), false, 'change');
         }
         $page_title = $event['page_title'];
         $this->template->assign_vars(array('S_QUICKREPLY_REQUEST' => true, 'S_QR_NO_FIRST_POST' => $this->qr_insert, 'S_QR_FULL_QUOTE' => $this->config['qr_full_quote']));
         $this->template->append_var('QR_HIDDEN_FIELDS', build_hidden_fields(array('qr' => 1, 'qr_cur_post_id' => (int) max($post_list))));
         // Output the page
         page_header($page_title, false, $forum_id);
         page_footer(false, false, false);
         $json_response = new \phpbb\json_response();
         $json_response->send(array('success' => true, 'result' => $this->template->assign_display('@tatiana5_quickreply/quickreply_template.html', '', true), 'insert' => $this->qr_insert));
     }
     if ($s_quick_reply) {
         include_once $this->phpbb_root_path . 'includes/functions_posting.' . $this->php_ext;
         // HTML, BBCode, Smilies, Images and Flash status
         $bbcode_status = $this->config['allow_bbcode'] && $this->config['qr_bbcode'] && $this->auth->acl_get('f_bbcode', $forum_id) ? true : false;
         $smilies_status = $this->config['allow_smilies'] && $this->config['qr_smilies'] && $this->auth->acl_get('f_smilies', $forum_id) ? true : false;
         $img_status = $bbcode_status && $this->auth->acl_get('f_img', $forum_id) ? true : false;
         $url_status = $this->config['allow_post_links'] ? true : false;
         $flash_status = $bbcode_status && $this->auth->acl_get('f_flash', $forum_id) && $this->config['allow_post_flash'] ? true : false;
         $quote_status = true;
         // Build custom bbcodes array
         if ($bbcode_status) {
             display_custom_bbcodes();
         }
         // Generate smiley listing
         if ($smilies_status) {
             generate_smilies('inline', $forum_id);
         }
         // Show attachment box for adding attachments if true
         $form_enctype = @ini_get('file_uploads') == '0' || strtolower(@ini_get('file_uploads')) == 'off' || !$this->config['allow_attachments'] || !$this->auth->acl_get('u_attach') || !$this->auth->acl_get('f_attach', $forum_id) ? '' : '" enctype="multipart/form-data';
         $allowed = $this->auth->acl_get('f_attach', $forum_id) && $this->auth->acl_get('u_attach') && $this->config['allow_attachments'] && $form_enctype;
         $attachment_data = false;
         if ($bbcode_status || $smilies_status || $this->config['qr_attach'] && $allowed) {
             $this->user->add_lang('posting');
         }
         if ($this->config['qr_attach'] && $allowed) {
             $this->template->assign_vars(array('U_QR_ACTION' => append_sid("{$this->phpbb_root_path}posting.{$this->php_ext}", "mode=reply&f={$forum_id}&t={$topic_id}") . $form_enctype));
             include_once $this->phpbb_root_path . 'includes/message_parser.' . $this->php_ext;
             $message_parser = new \parse_message();
             $message_parser->set_plupload($this->plupload);
             $message_parser->set_mimetype_guesser($this->mimetype_guesser);
             $message_parser->get_submitted_attachment_data($this->user->data['user_id']);
             $attachment_data = $message_parser->attachment_data;
             $filename_data = $message_parser->filename_data;
             posting_gen_inline_attachments($attachment_data);
             $max_files = $this->auth->acl_get('a_') || $this->auth->acl_get('m_', $forum_id) ? 0 : (int) $this->config['max_attachments'];
             $topic_id = $topic_data['topic_id'];
             $s_action = append_sid("{$this->phpbb_root_path}posting.{$this->php_ext}", "mode=reply&f={$forum_id}&t={$topic_id}");
             $this->plupload->configure($this->cache, $this->template, $s_action, $forum_id, $max_files);
             posting_gen_attachment_entry($attachment_data, $filename_data, $allowed);
         }
         $this->template->append_var('QR_HIDDEN_FIELDS', build_hidden_fields(array('qr' => 1, 'qr_cur_post_id' => (int) max($post_list))));
         if ($this->phpbb_extension_manager->is_enabled('rxu/PostsMerging') && $this->user->data['is_registered'] && $this->config['merge_interval']) {
             // Always show the checkbox if PostsMerging extension is installed.
             $this->user->add_lang_ext('rxu/PostsMerging', 'posts_merging');
             $this->template->assign_var('POSTS_MERGING_OPTION', true);
         }
         $this->template->assign_vars(array('S_QR_COLOUR_NICKNAME' => $this->config['qr_color_nickname'], 'S_QR_NOT_CHANGE_SUBJECT' => $this->auth->acl_get('f_qr_change_subject', $forum_id) ? false : true, 'S_QR_COMMA_ENABLE' => $this->config['qr_comma'], 'S_QR_QUICKNICK_ENABLE' => $this->config['qr_quicknick'], 'S_QR_QUICKNICK_REF' => $this->config['qr_quicknick_ref'], 'S_QR_QUICKNICK_PM' => $this->config['qr_quicknick_pm'], 'S_QR_QUICKQUOTE_ENABLE' => $this->config['qr_quickquote'], 'S_QR_QUICKQUOTE_LINK' => $this->config['qr_quickquote_link'], 'S_QR_FULL_QUOTE' => $this->config['qr_full_quote'], 'S_QR_CE_ENABLE' => $this->config['qr_ctrlenter'], 'QR_SOURCE_POST' => $this->config['qr_source_post'], 'S_DISPLAY_USERNAME' => !$this->user->data['is_registered'], 'S_BBCODE_ALLOWED' => $bbcode_status ? 1 : 0, 'S_SMILIES_ALLOWED' => $smilies_status, 'S_BBCODE_IMG' => $img_status, 'S_LINKS_ALLOWED' => $url_status, 'S_BBCODE_FLASH' => $flash_status, 'S_BBCODE_QUOTE' => $quote_status, 'MESSAGE' => $this->request->variable('message', '', true), 'READ_POST_IMG' => $this->user->img('icon_post_target', 'POST'), 'S_QR_CAPS_ENABLE' => $this->config['qr_capslock_transfer'], 'S_QR_SHOW_BUTTON_TRANSLIT' => $this->config['qr_show_button_translit'], 'L_FULL_EDITOR' => $this->config['qr_ajax_submit'] ? $this->user->lang['PREVIEW'] : $this->user->lang['FULL_EDITOR'], 'S_QR_AJAX_SUBMIT' => $this->config['qr_ajax_submit'], 'S_QR_AJAX_PAGINATION' => $this->config['qr_ajax_pagination'] && $this->user->data['ajax_pagination'], 'S_QR_ENABLE_SCROLL' => $this->user->data['qr_enable_scroll'], 'S_QR_SCROLL_INTERVAL' => $this->config['qr_scroll_time'], 'S_QR_SOFT_SCROLL' => $this->config['qr_scroll_time'] && $this->user->data['qr_soft_scroll'], 'S_QR_ALLOWED_GUEST' => $this->config['qr_allow_for_guests'] && $this->user->data['user_id'] == ANONYMOUS, 'S_ABBC3_INSTALLED' => $this->phpbb_extension_manager->is_enabled('vse/abbc3'), 'S_QR_SHOW_ATTACH_BOX' => $this->config['qr_attach'] && $allowed, 'S_ATTACH_DATA' => $attachment_data ? json_encode($attachment_data) : '[]'));
         $add_re = $this->config['qr_enable_re'] ? 'Re: ' : '';
         $this->template->assign_var('SUBJECT', $this->request->variable('subject', $add_re . censor_text($topic_data['topic_title']), true));
     }
     $this->template->assign_vars(array('QR_HIDE_POSTS_SUBJECT' => $this->config['qr_show_subjects'] ? false : true));
 }
コード例 #2
0
ファイル: functions.php プロジェクト: tas2580/wiki
 /**
  * Display the edit form
  *
  * @param bool $preview
  */
 protected function display_edit_form($preview = false)
 {
     generate_smilies('inline', 0);
     display_custom_bbcodes();
     add_form_key('article');
     $this->template->assign_vars(array('S_PREVIEW' => $preview, 'TITLE' => $this->data['article_title'], 'MESSAGE' => $preview ? $this->data['article_text'] : $this->message_parser->message, 'PREVIEW_MESSAGE' => $this->message_parser->message, 'SOURCES' => $this->data['article_sources'], 'S_BBCODE_ALLOWED' => $this->option['bbcode'], 'S_LINKS_ALLOWED' => $this->option['url'], 'S_BBCODE_IMG' => $this->option['img'], 'S_BBCODE_FLASH' => $this->option['flash'], 'S_BBCODE_QUOTE' => $this->option['quote'], 'BBCODE_STATUS' => $this->option['bbcode'] ? sprintf($this->user->lang['BBCODE_IS_ON'], '<a href="' . append_sid("{$this->phpbb_root_path}faq.{$this->php_ext}", 'mode=bbcode') . '">', '</a>') : sprintf($this->user->lang['BBCODE_IS_OFF'], '<a href="' . append_sid("{$this->phpbb_root_path}faq.{$this->php_ext}", 'mode=bbcode') . '">', '</a>'), 'IMG_STATUS' => $this->option['img'] ? $this->user->lang['IMAGES_ARE_ON'] : $this->user->lang['IMAGES_ARE_OFF'], 'FLASH_STATUS' => $this->option['flash'] ? $this->user->lang['FLASH_IS_ON'] : $this->user->lang['FLASH_IS_OFF'], 'SMILIES_STATUS' => $this->option['smilies'] ? $this->user->lang['SMILIES_ARE_ON'] : $this->user->lang['SMILIES_ARE_OFF'], 'URL_STATUS' => $this->option['bbcode'] && $this->option['url'] ? $this->user->lang['URL_IS_ON'] : $this->user->lang['URL_IS_OFF'], 'EDIT_REASON' => $this->data['article_edit_reason'], 'TOPIC_ID' => (int) $this->data['article_topic_id'], 'S_AUTH_ACTIVATE' => $this->auth->acl_get('u_wiki_set_active'), 'S_AUTH_EDIT_TOPIC' => $this->auth->acl_get('u_wiki_edit_topic'), 'S_AUTH_REDIRECT' => $this->auth->acl_get('u_wiki_set_redirect'), 'S_AUTH_STICKY' => $this->auth->acl_get('u_wiki_set_sticky'), 'S_ACTIVE' => $preview ? $this->data['article_approved'] : 1, 'S_STICKY' => $this->data['article_sticky'], 'ARTICLE_REDIRECT' => $this->data['article_redirect'], 'ARTICLE_DESCRIPTION' => $this->data['article_description']));
 }
コード例 #3
0
 /**
  * Controller for /post
  *
  * @throws http_exception
  * @return \Symfony\Component\HttpFoundation\Response A Symfony Response object
  */
 public function post()
 {
     if (!$this->is_available()) {
         throw new http_exception(404, 'IDEAS_NOT_AVAILABLE');
     }
     if ($this->user->data['user_id'] == ANONYMOUS) {
         throw new http_exception(404, 'LOGGED_OUT');
     }
     $this->language->add_lang('posting');
     if (!function_exists('submit_post')) {
         include $this->root_path . 'includes/functions_posting.' . $this->php_ext;
     }
     if (!function_exists('display_custom_bbcodes')) {
         include $this->root_path . 'includes/functions_display.' . $this->php_ext;
     }
     $mode = $this->request->variable('mode', '');
     $title = $this->request->variable('title', '', true);
     $message = $this->request->variable('message', '', true);
     if ($mode === 'submit') {
         $submit = $this->ideas->submit($title, $message, $this->user->data['user_id']);
         if (is_array($submit)) {
             $this->template->assign_vars(array('ERROR' => implode('<br />', $submit), 'MESSAGE' => $message));
         } else {
             return new RedirectResponse($this->helper->route('phpbb_ideas_idea_controller', array('idea_id' => $submit)));
         }
     }
     display_custom_bbcodes();
     generate_smilies('inline', 0);
     // BBCode, Smilies, Images URL, and Flash statuses
     $bbcode_status = (bool) $this->config['allow_bbcode'] && $this->auth->acl_get('f_bbcode', $this->config['ideas_forum_id']);
     $smilies_status = (bool) $this->config['allow_smilies'] && $this->auth->acl_get('f_smilies', $this->config['ideas_forum_id']);
     $img_status = (bool) $bbcode_status && $this->auth->acl_get('f_img', $this->config['ideas_forum_id']);
     $url_status = (bool) $this->config['allow_post_links'];
     $flash_status = (bool) $bbcode_status && $this->auth->acl_get('f_flash', $this->config['ideas_forum_id']) && $this->config['allow_post_flash'];
     $this->template->assign_vars(array('TITLE' => $title, 'S_POST_ACTION' => $this->helper->route('phpbb_ideas_post_controller', array('mode' => 'submit')), 'S_BBCODE_ALLOWED' => $bbcode_status, 'S_SMILIES_ALLOWED' => $smilies_status, 'S_LINKS_ALLOWED' => $url_status, 'S_BBCODE_IMG' => $img_status, 'S_BBCODE_FLASH' => $flash_status, 'S_BBCODE_QUOTE' => true, 'BBCODE_STATUS' => $this->language->lang($bbcode_status ? 'BBCODE_IS_ON' : 'BBCODE_IS_OFF', '<a href="' . $this->helper->route('phpbb_help_bbcode_controller') . '">', '</a>'), 'IMG_STATUS' => $img_status ? $this->language->lang('IMAGES_ARE_ON') : $this->language->lang('IMAGES_ARE_OFF'), 'FLASH_STATUS' => $flash_status ? $this->language->lang('FLASH_IS_ON') : $this->language->lang('FLASH_IS_OFF'), 'URL_STATUS' => $bbcode_status && $url_status ? $this->language->lang('URL_IS_ON') : $this->language->lang('URL_IS_OFF'), 'SMILIES_STATUS' => $smilies_status ? $this->language->lang('SMILIES_ARE_ON') : $this->language->lang('SMILIES_ARE_OFF')));
     // Assign breadcrumb template vars
     $this->template->assign_block_vars_array('navlinks', array(array('U_VIEW_FORUM' => $this->helper->route('phpbb_ideas_index_controller'), 'FORUM_NAME' => $this->language->lang('IDEAS')), array('U_VIEW_FORUM' => $this->helper->route('phpbb_ideas_post_controller'), 'FORUM_NAME' => $this->language->lang('NEW_IDEA'))));
     return $this->helper->render('idea_new.html', $this->language->lang('NEW_IDEA'));
 }
コード例 #4
0
ファイル: render_helper.php プロジェクト: ezpz-cz/web-plugins
    /**
     * Method to render the page data
     *
     * @var bool		Bool if the rendering is only for index
     * @return array	Data for page rendering
     */
    public function render_data_for_page($only_for_index = false)
    {
        $include_on_index = $only_for_index === true;
        // Add lang file
        $this->user->add_lang('posting');
        //chat enabled
        if (!$this->config['mchat_enable']) {
            trigger_error($this->user->lang['MCHAT_ENABLE'], E_USER_NOTICE);
        }
        //	avatars
        if (!function_exists('get_user_avatar')) {
            include $this->phpbb_root_path . 'includes/functions_display.' . $this->phpEx;
        }
        if (($this->config_mchat = $this->cache->get('_mchat_config')) === false) {
            $this->functions_mchat->mchat_cache();
        }
        $this->config_mchat = $this->cache->get('_mchat_config');
        // Access rights
        $mchat_allow_bbcode = $this->config['allow_bbcode'] && $this->auth->acl_get('u_mchat_bbcode') ? true : false;
        $mchat_smilies = $this->config['allow_smilies'] && $this->auth->acl_get('u_mchat_smilies') ? true : false;
        $mchat_urls = $this->config['allow_post_links'] && $this->auth->acl_get('u_mchat_urls') ? true : false;
        $mchat_ip = $this->auth->acl_get('u_mchat_ip') ? true : false;
        $mchat_pm = $this->auth->acl_get('u_mchat_pm') ? true : false;
        $mchat_like = $this->auth->acl_get('u_mchat_like') ? true : false;
        $mchat_quote = $this->auth->acl_get('u_mchat_quote') ? true : false;
        $mchat_add_mess = $this->auth->acl_get('u_mchat_use') ? true : false;
        $mchat_view = $this->auth->acl_get('u_mchat_view') ? true : false;
        $mchat_no_flood = $this->auth->acl_get('u_mchat_flood_ignore') ? true : false;
        $mchat_read_archive = $this->auth->acl_get('u_mchat_archive') ? true : false;
        $mchat_founder = $this->user->data['user_type'] == USER_FOUNDER ? true : false;
        $mchat_session_time = !empty($this->config_mchat['timeout']) ? $this->config_mchat['timeout'] : (!empty($this->config['load_online_time']) ? $this->config['load_online_time'] * 60 : $this->config['session_length']);
        $mchat_rules = !empty($this->config_mchat['rules']) || isset($this->user->lang[strtoupper('mchat_rules')]) ? true : false;
        $mchat_avatars = !empty($this->config_mchat['avatars']) && $this->user->optionget('viewavatars') && $this->user->data['user_mchat_avatars'] ? true : false;
        // needed variables
        // Request options.
        $mchat_mode = $this->request->variable('mode', '');
        $mchat_read_mode = $mchat_archive_mode = $mchat_custom_page = $mchat_no_message = false;
        // set redirect if on index or custom page
        $on_page = $include_on_index ? 'index' : 'mchat';
        // grab fools..uhmmm, foes the user has
        $foes_array = array();
        $sql = 'SELECT * FROM ' . ZEBRA_TABLE . '
			WHERE user_id = ' . $this->user->data['user_id'] . '	AND foe = 1';
        $result = $this->db->sql_query($sql);
        while ($row = $this->db->sql_fetchrow($result)) {
            $foes_array[] = $row['zebra_id'];
        }
        $this->db->sql_freeresult($result);
        // Request mode...
        switch ($mchat_mode) {
            // rules popup..
            case 'rules':
                // If the rules are defined in the language file use them, else just use the entry in the database
                if ($mchat_rules || isset($this->user->lang[strtoupper('mchat_rules')])) {
                    if (isset($this->user->lang[strtoupper('mchat_rules')])) {
                        $this->template->assign_var('MCHAT_RULES', $this->user->lang[strtoupper('mchat_rules')]);
                    } else {
                        $mchat_rules = $this->config_mchat['rules'];
                        $mchat_rules = explode("\n", $mchat_rules);
                        foreach ($mchat_rules as $mchat_rule) {
                            $mchat_rule = utf8_htmlspecialchars($mchat_rule);
                            $this->template->assign_block_vars('rule', array('MCHAT_RULE' => $mchat_rule));
                        }
                    }
                    // Output the page
                    // Return for: \$this->helper->render(filename, lang_title);
                    return array('filename' => 'mchat_rules.html', 'lang_title' => $this->user->lang['MCHAT_HELP']);
                } else {
                    // Show no rules
                    trigger_error('MCHAT_NO_RULES', E_USER_NOTICE);
                }
                break;
                // whois function..
            // whois function..
            case 'whois':
                // Must have auths
                if ($mchat_mode == 'whois' && $mchat_ip) {
                    // function already exists..
                    if (!function_exists('user_ipwhois')) {
                        include $this->phpbb_root_path . 'includes/functions_user.' . $this->phpEx;
                    }
                    $this->user_ip = $this->request->variable('ip', '');
                    $this->template->assign_var('WHOIS', user_ipwhois($this->user_ip));
                    // Output the page
                    // Return for: \$this->helper->render(filename, lang_title);
                    return array('filename' => 'viewonline_whois.html', 'lang_title' => $this->user->lang['WHO_IS_ONLINE']);
                } else {
                    // Show not authorized
                    trigger_error('NO_AUTH_OPERATION', E_USER_NOTICE);
                }
                break;
                // Clean function...
            // Clean function...
            case 'clean':
                // User logged in?
                if (!$this->user->data['is_registered'] || !$mchat_founder) {
                    if (!$this->user->data['is_registered']) {
                        // Login box...
                        login_box('', $this->user->lang['LOGIN']);
                    } else {
                        if (!$mchat_founder) {
                            // Show not authorized
                            trigger_error('NO_AUTH_OPERATION', E_USER_NOTICE);
                        }
                    }
                }
                $mchat_redirect = $this->request->variable('redirect', '');
                $mchat_redirect = $mchat_redirect == 'index' ? append_sid("{$this->phpbb_root_path}index.{$this->phpEx}") : $this->helper->route('dmzx_mchat_controller', array('#mChat'));
                if (confirm_box(true)) {
                    // Run cleaner
                    $sql = 'TRUNCATE TABLE ' . $this->mchat_table;
                    $this->db->sql_query($sql);
                    meta_refresh(3, $mchat_redirect);
                    trigger_error($this->user->lang['MCHAT_CLEANED'] . '<br /><br />' . sprintf($this->user->lang['RETURN_PAGE'], '<a href="' . $mchat_redirect . '">', '</a>'));
                } else {
                    // Display confirm box
                    confirm_box(false, $this->user->lang['MCHAT_DELALLMESS']);
                }
                $this->phpbb_log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_MCHAT_TABLE_PRUNED');
                redirect($mchat_redirect);
                break;
                // Archive function...
            // Archive function...
            case 'archive':
                if (!$mchat_read_archive || !$mchat_view) {
                    // redirect to correct page
                    $mchat_redirect = append_sid("{$this->phpbb_root_path}index.{$this->phpEx}");
                    // Redirect to previous page
                    meta_refresh(3, $mchat_redirect);
                    trigger_error($this->user->lang['MCHAT_NOACCESS_ARCHIVE'] . '<br /><br />' . sprintf($this->user->lang['RETURN_PAGE'], '<a href="' . $mchat_redirect . '">', '</a>'));
                }
                if ($this->config['mchat_enable'] && $mchat_read_archive && $mchat_view) {
                    // how many chats do we have?
                    $sql = 'SELECT COUNT(message_id) AS messages FROM ' . $this->mchat_table;
                    $result = $this->db->sql_query($sql);
                    $mchat_total_messages = $this->db->sql_fetchfield('messages');
                    $this->db->sql_freeresult($result);
                    // prune the chats if necessary and amount in ACP not empty
                    if ($this->config_mchat['prune_enable'] && ($mchat_total_messages > $this->config_mchat['prune_num'] && $this->config_mchat['prune_num'] > 0)) {
                        $this->functions_mchat->mchat_prune((int) $this->config_mchat['prune_num']);
                    }
                    // Reguest...
                    $mchat_archive_start = $this->request->variable('start', 0);
                    $sql_where = $this->user->data['user_mchat_topics'] ? '' : 'WHERE m.forum_id = 0';
                    // Message row
                    $sql = 'SELECT m.*, u.username, u.user_colour, u.user_avatar, u.user_avatar_type, u.user_avatar_width, u.user_avatar_height, u.user_allow_pm
						FROM ' . $this->mchat_table . ' m
							LEFT JOIN ' . USERS_TABLE . ' u ON m.user_id = u.user_id
						' . $sql_where . '
						ORDER BY m.message_id DESC';
                    $result = $this->db->sql_query_limit($sql, (int) $this->config_mchat['archive_limit'], $mchat_archive_start);
                    $rows = $this->db->sql_fetchrowset($result);
                    $this->db->sql_freeresult($result);
                    foreach ($rows as $row) {
                        // auth check
                        if ($row['forum_id'] != 0 && !$this->auth->acl_get('f_read', $row['forum_id'])) {
                            continue;
                        }
                        // edit, delete and permission auths
                        $mchat_ban = $this->auth->acl_get('a_authusers') && $this->user->data['user_id'] != $row['user_id'] ? true : false;
                        $mchat_edit = $this->auth->acl_get('u_mchat_edit') && ($this->auth->acl_get('m_') || $this->user->data['user_id'] == $row['user_id']) ? true : false;
                        $mchat_del = $this->auth->acl_get('u_mchat_delete') && ($this->auth->acl_get('m_') || $this->user->data['user_id'] == $row['user_id']) ? true : false;
                        $mchat_avatar = $row['user_avatar'] ? get_user_avatar($row['user_avatar'], $row['user_avatar_type'], $row['user_avatar_width'] > $row['user_avatar_height'] ? 40 : 40 / $row['user_avatar_height'] * $row['user_avatar_width'], $row['user_avatar_height'] > $row['user_avatar_width'] ? 40 : 40 / $row['user_avatar_width'] * $row['user_avatar_height']) : '';
                        $message_edit = $row['message'];
                        decode_message($message_edit, $row['bbcode_uid']);
                        $message_edit = str_replace('"', '&quot;', $message_edit);
                        // Edit Fix ;)
                        if (sizeof($foes_array)) {
                            if (in_array($row['user_id'], $foes_array)) {
                                $row['message'] = sprintf($this->user->lang['MCHAT_FOE'], get_username_string('full', $row['user_id'], $row['username'], $row['user_colour'], $this->user->lang['GUEST']));
                            }
                        }
                        $row['username'] = mb_ereg_replace("'", "&#146;", $row['username']);
                        $this->template->assign_block_vars('mchatrow', array('MCHAT_ALLOW_BAN' => $mchat_ban, 'MCHAT_ALLOW_EDIT' => $mchat_edit, 'MCHAT_ALLOW_DEL' => $mchat_del, 'MCHAT_USER_AVATAR' => $mchat_avatar, 'U_VIEWPROFILE' => $row['user_id'] != ANONYMOUS ? append_sid("{$this->phpbb_root_path}memberlist.{$this->phpEx}", 'mode=viewprofile&amp;u=' . $row['user_id']) : '', 'U_USER_IDS' => $row['user_id'] != ANONYMOUS && $this->user->data['user_id'] != $row['user_id'] ? append_sid("{$this->phpbb_root_path}ucp.{$this->phpEx}", 'i=pm&amp;mode=compose&amp;u=' . $row['user_id']) : '', 'BOT_USER_ID' => $row['user_id'] != '1', 'U_USER_ID' => $row['user_id'] != ANONYMOUS && $this->config['allow_privmsg'] && $this->auth->acl_get('u_sendpm') && $this->user->data['user_id'] != $row['user_id'] && $row['user_id'] != '1' && ($row['user_allow_pm'] || $this->auth->acl_gets('a_', 'm_') || $this->auth->acl_getf_global('m_')) ? append_sid("{$this->phpbb_root_path}ucp.{$this->phpEx}", 'i=pm&amp;mode=compose&amp;u=' . $row['user_id']) : '', 'MCHAT_MESSAGE_EDIT' => $message_edit, 'MCHAT_MESSAGE_ID' => $row['message_id'], 'MCHAT_USERNAME_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour'], $this->user->lang['GUEST']), 'MCHAT_USERNAME' => get_username_string('username', $row['user_id'], $row['username'], $row['user_colour'], $this->user->lang['GUEST']), 'MCHAT_USERNAME_COLOR' => get_username_string('colour', $row['user_id'], $row['username'], $row['user_colour'], $this->user->lang['GUEST']), 'MCHAT_USER_IP' => $row['user_ip'], 'MCHAT_U_WHOIS' => $this->helper->route('dmzx_mchat_controller', array('mode' => 'whois', 'ip' => $row['user_ip'])), 'MCHAT_U_BAN' => append_sid("{$this->phpbb_root_path}adm/index.{$this->phpEx}", 'i=permissions&amp;mode=setting_user_global&amp;user_id[0]=' . $row['user_id'], true, $this->user->session_id), 'MCHAT_MESSAGE' => generate_text_for_display($row['message'], $row['bbcode_uid'], $row['bbcode_bitfield'], $row['bbcode_options']), 'MCHAT_TIME' => $this->user->format_date($row['message_time'], $this->config_mchat['date']), 'MCHAT_CLASS' => $row['message_id'] % 2 ? 1 : 2));
                    }
                    // Write no message
                    if (empty($rows)) {
                        $mchat_no_message = true;
                    }
                }
                // Run query again to get the total message rows...
                $sql = 'SELECT COUNT(message_id) AS mess_id FROM ' . $this->mchat_table;
                $result = $this->db->sql_query($sql);
                $mchat_total_message = $this->db->sql_fetchfield('mess_id');
                $this->db->sql_freeresult($result);
                // Page list function...
                $pagination_url = $this->helper->route('dmzx_mchat_controller', array('mode' => 'archive'));
                $start = $this->request->variable('start', 0);
                $this->pagination->generate_template_pagination($pagination_url, 'pagination', 'start', $mchat_total_message, (int) $this->config_mchat['archive_limit'], $mchat_archive_start);
                $this->template->assign_vars(array('MCHAT_TOTAL_MESSAGES' => sprintf($this->user->lang['MCHAT_TOTALMESSAGES'], $mchat_total_message)));
                //add to navlinks
                $this->template->assign_block_vars('navlinks', array('FORUM_NAME' => $this->user->lang['MCHAT_ARCHIVE_PAGE'], 'U_VIEW_FORUM' => $this->helper->route('dmzx_mchat_controller', array('mode' => 'archive'))));
                // If archive mode request set true
                $mchat_archive_mode = true;
                $old_mode = 'archive';
                break;
                // Read function...
            // Read function...
            case 'read':
                // If mChat disabled or user can't view the chat
                if (!$this->config['mchat_enable'] || !$mchat_view) {
                    // Forbidden (for jQ AJAX request)
                    throw new \phpbb\exception\http_exception(403, 'MCHAT_ERROR_FORBIDDEN');
                }
                // if we're reading on the custom page, then we are chatting
                if ($mchat_custom_page) {
                    // insert user into the mChat sessions table
                    $this->functions_mchat->mchat_sessions($mchat_session_time, true);
                }
                // Request
                $mchat_message_last_id = $this->request->variable('message_last_id', 0);
                $sql_and = $this->user->data['user_mchat_topics'] ? '' : 'AND m.forum_id = 0';
                $sql = 'SELECT m.*, u.username, u.user_colour, u.user_avatar, u.user_avatar_type, u.user_avatar_width, u.user_avatar_height, u.user_allow_pm
					FROM ' . $this->mchat_table . ' m, ' . USERS_TABLE . ' u
					WHERE m.user_id = u.user_id
					AND m.message_id > ' . (int) $mchat_message_last_id . '
					' . $sql_and . '
					ORDER BY m.message_id DESC';
                $result = $this->db->sql_query_limit($sql, (int) $this->config_mchat['message_limit']);
                $rows = $this->db->sql_fetchrowset($result);
                $this->db->sql_freeresult($result);
                // Reverse the array wanting messages appear in reverse
                if ($this->config['mchat_message_top']) {
                    $rows = array_reverse($rows);
                }
                foreach ($rows as $row) {
                    // auth check
                    if ($row['forum_id'] != 0 && !$this->auth->acl_get('f_read', $row['forum_id'])) {
                        continue;
                    }
                    // edit auths
                    if ($this->user->data['user_id'] == ANONYMOUS && $this->user->data['user_id'] == $row['user_id']) {
                        $chat_auths = $this->user->data['session_ip'] == $row['user_ip'] ? true : false;
                    } else {
                        $chat_auths = $this->user->data['user_id'] == $row['user_id'] ? true : false;
                    }
                    // edit, delete and permission auths
                    $mchat_ban = $this->auth->acl_get('a_authusers') && $this->user->data['user_id'] != $row['user_id'] ? true : false;
                    $mchat_edit = $this->auth->acl_get('u_mchat_edit') && ($this->auth->acl_get('m_') || $chat_auths) ? true : false;
                    $mchat_del = $this->auth->acl_get('u_mchat_delete') && ($this->auth->acl_get('m_') || $chat_auths) ? true : false;
                    $mchat_avatar = $row['user_avatar'] ? get_user_avatar($row['user_avatar'], $row['user_avatar_type'], $row['user_avatar_width'] > $row['user_avatar_height'] ? 40 : 40 / $row['user_avatar_height'] * $row['user_avatar_width'], $row['user_avatar_height'] > $row['user_avatar_width'] ? 40 : 40 / $row['user_avatar_width'] * $row['user_avatar_height']) : '';
                    $message_edit = $row['message'];
                    decode_message($message_edit, $row['bbcode_uid']);
                    $message_edit = str_replace('"', '&quot;', $message_edit);
                    $message_edit = mb_ereg_replace("'", "&#146;", $message_edit);
                    // Edit Fix ;)
                    if (sizeof($foes_array)) {
                        if (in_array($row['user_id'], $foes_array)) {
                            $row['message'] = sprintf($this->user->lang['MCHAT_FOE'], get_username_string('full', $row['user_id'], $row['username'], $row['user_colour'], $this->user->lang['GUEST']));
                        }
                    }
                    $row['username'] = mb_ereg_replace("'", "&#146;", $row['username']);
                    $this->template->assign_block_vars('mchatrow', array('MCHAT_ALLOW_BAN' => $mchat_ban, 'MCHAT_ALLOW_EDIT' => $mchat_edit, 'MCHAT_ALLOW_DEL' => $mchat_del, 'MCHAT_USER_AVATAR' => $mchat_avatar, 'U_VIEWPROFILE' => $row['user_id'] != ANONYMOUS ? append_sid("{$this->phpbb_root_path}memberlist.{$this->phpEx}", 'mode=viewprofile&amp;u=' . $row['user_id']) : '', 'U_USER_IDS' => $row['user_id'] != ANONYMOUS && $this->user->data['user_id'] != $row['user_id'] ? append_sid("{$this->phpbb_root_path}ucp.{$this->phpEx}", 'i=pm&amp;mode=compose&amp;u=' . $row['user_id']) : '', 'BOT_USER_ID' => $row['user_id'] != '1', 'U_USER_ID' => $row['user_id'] != ANONYMOUS && $this->config['allow_privmsg'] && $this->auth->acl_get('u_sendpm') && $this->user->data['user_id'] != $row['user_id'] && $row['user_id'] != '1' && ($row['user_allow_pm'] || $this->auth->acl_gets('a_', 'm_') || $this->auth->acl_getf_global('m_')) ? append_sid("{$this->phpbb_root_path}ucp.{$this->phpEx}", 'i=pm&amp;mode=compose&amp;u=' . $row['user_id']) : '', 'MCHAT_MESSAGE_EDIT' => $message_edit, 'MCHAT_MESSAGE_ID' => $row['message_id'], 'MCHAT_USERNAME_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour'], $this->user->lang['GUEST']), 'MCHAT_USERNAME' => get_username_string('username', $row['user_id'], $row['username'], $row['user_colour'], $this->user->lang['GUEST']), 'MCHAT_USERNAME_COLOR' => get_username_string('colour', $row['user_id'], $row['username'], $row['user_colour'], $this->user->lang['GUEST']), 'MCHAT_USER_IP' => $row['user_ip'], 'MCHAT_U_WHOIS' => $this->helper->route('dmzx_mchat_controller', array('mode' => 'whois', 'ip' => $row['user_ip'])), 'MCHAT_U_BAN' => append_sid("{$this->phpbb_root_path}adm/index.{$this->phpEx}", 'i=permissions&amp;mode=setting_user_global&amp;user_id[0]=' . $row['user_id'], true, $this->user->session_id), 'MCHAT_MESSAGE' => generate_text_for_display($row['message'], $row['bbcode_uid'], $row['bbcode_bitfield'], $row['bbcode_options']), 'MCHAT_TIME' => $this->user->format_date($row['message_time'], $this->config_mchat['date']), 'MCHAT_CLASS' => $row['message_id'] % 2 ? 1 : 2));
                }
                // Write no message
                if (empty($rows)) {
                    $mchat_no_message = true;
                }
                // If read mode request set true
                $mchat_read_mode = true;
                break;
                // Stats function...
            // Stats function...
            case 'stats':
                // If mChat disabled or user can't view the chat
                if (!$this->config['mchat_enable'] || !$mchat_view || !$this->config_mchat['whois']) {
                    // Forbidden (for jQ AJAX request)
                    throw new \phpbb\exception\http_exception(403, 'MCHAT_ERROR_FORBIDDEN');
                }
                $mchat_stats = $this->functions_mchat->mchat_users($mchat_session_time);
                if (!empty($mchat_stats['online_userlist'])) {
                    $message = '<div class="mChatStats" id="mChatStats"><a href="#" onclick="mChat.toggle(\'UserList\'); return false;">' . $mchat_stats['mchat_users_count'] . '</a>&nbsp;' . $mchat_stats['refresh_message'] . '<br /><span id="mChatUserList" style="display: none; float: left;">' . $mchat_stats['online_userlist'] . '</span></div>';
                } else {
                    $message = '<div class="mChatStats" id="Div1">' . $this->user->lang['MCHAT_NO_CHATTERS'] . '&nbsp;(' . $mchat_stats['refresh_message'] . ')</div>';
                }
                if ($this->request->is_ajax()) {
                    // Return for: \Symfony\Component\HttpFoundation\JsonResponse
                    return array('json' => true, 'message' => $message);
                } else {
                    throw new \phpbb\exception\http_exception(501, 'MCHAT_ERROR_NOT_IMPLEMENTED');
                }
                break;
                // Add function...
            // Add function...
            case 'add':
                // If mChat disabled
                if (!$this->config['mchat_enable'] || !$mchat_add_mess || !check_form_key('mchat_posting', -1)) {
                    // Forbidden (for jQ AJAX request)
                    if ($this->request->is_ajax()) {
                        // FOR DEBUG
                        throw new \phpbb\exception\http_exception(403, 'MCHAT_ERROR_FORBIDDEN');
                    }
                }
                // Reguest...
                $message = utf8_ucfirst(utf8_normalize_nfc($this->request->variable('message', '', true)));
                // must have something other than bbcode in the message
                if (empty($mchatregex)) {
                    //let's strip all the bbcode
                    $mchatregex = '#\\[/?[^\\[\\]]+\\]#mi';
                }
                $message_chars = preg_replace($mchatregex, '', $message);
                $message_chars = utf8_strlen(trim($message_chars)) > 0 ? true : false;
                if (!$message || !$message_chars) {
                    // Not Implemented (for jQ AJAX request)
                    throw new \phpbb\exception\http_exception(501, 'MCHAT_ERROR_NOT_IMPLEMENTED');
                }
                // Flood control
                if (!$mchat_no_flood && $this->config_mchat['flood_time']) {
                    $mchat_flood_current_time = time();
                    $sql = 'SELECT message_time FROM ' . $this->mchat_table . '
						WHERE user_id = ' . (int) $this->user->data['user_id'] . '
						ORDER BY message_time DESC';
                    $result = $this->db->sql_query_limit($sql, 1);
                    $row = $this->db->sql_fetchrow($result);
                    $this->db->sql_freeresult($result);
                    if ($row['message_time'] > 0 && $mchat_flood_current_time - $row['message_time'] < (int) $this->config_mchat['flood_time']) {
                        // Locked (for jQ AJAX request)
                        throw new \phpbb\exception\http_exception(400, 'MCHAT_BAD_REQUEST');
                    }
                }
                // insert user into the mChat sessions table
                $this->functions_mchat->mchat_sessions($mchat_session_time, true);
                // we override the $this->config['min_post_chars'] entry?
                if ($this->config_mchat['override_min_post_chars']) {
                    $old_cfg['min_post_chars'] = $this->config['min_post_chars'];
                    $this->config['min_post_chars'] = 0;
                }
                //we do the same for the max number of smilies?
                if ($this->config_mchat['override_smilie_limit']) {
                    $old_cfg['max_post_smilies'] = $this->config['max_post_smilies'];
                    $this->config['max_post_smilies'] = 0;
                }
                // Add function part code from http://wiki.phpbb.com/Parsing_text
                $uid = $bitfield = $options = '';
                // will be modified by generate_text_for_storage
                generate_text_for_storage($message, $uid, $bitfield, $options, $mchat_allow_bbcode, $mchat_urls, $mchat_smilies);
                // Not allowed bbcodes
                if (!$mchat_allow_bbcode || $this->config_mchat['bbcode_disallowed']) {
                    if (!$mchat_allow_bbcode) {
                        $bbcode_remove = '#\\[/?[^\\[\\]]+\\]#Usi';
                        $message = preg_replace($bbcode_remove, '', $message);
                    } else {
                        if ($this->config_mchat['bbcode_disallowed']) {
                            if (empty($bbcode_replace)) {
                                $bbcode_replace = array('#\\[(' . $this->config_mchat['bbcode_disallowed'] . ')[^\\[\\]]+\\]#Usi', '#\\[/(' . $this->config_mchat['bbcode_disallowed'] . ')[^\\[\\]]+\\]#Usi');
                            }
                            $message = preg_replace($bbcode_replace, '', $message);
                        }
                    }
                }
                $sql_ary = array('forum_id' => 0, 'post_id' => 0, 'user_id' => $this->user->data['user_id'], 'user_ip' => $this->user->data['session_ip'], 'message' => str_replace('\'', '&rsquo;', $message), 'bbcode_bitfield' => $bitfield, 'bbcode_uid' => $uid, 'bbcode_options' => $options, 'message_time' => time());
                $sql = 'INSERT INTO ' . $this->mchat_table . ' ' . $this->db->sql_build_array('INSERT', $sql_ary);
                $this->db->sql_query($sql);
                // reset the config settings
                if (isset($old_cfg['min_post_chars'])) {
                    $this->config['min_post_chars'] = $old_cfg['min_post_chars'];
                    unset($old_cfg['min_post_chars']);
                }
                if (isset($old_cfg['max_post_smilies'])) {
                    $this->config['max_post_smilies'] = $old_cfg['max_post_smilies'];
                    unset($old_cfg['max_post_smilies']);
                }
                // Stop run code!
                if ($this->request->is_ajax()) {
                    // Return for: \Symfony\Component\HttpFoundation\JsonResponse
                    return array('json' => true, 'success' => true);
                } else {
                    exit_handler();
                }
                break;
                // Edit function...
            // Edit function...
            case 'edit':
                $message_id = $this->request->variable('message_id', 0);
                // If mChat disabled and not edit
                if (!$this->config['mchat_enable'] || !$message_id) {
                    // Forbidden (for jQ AJAX request)
                    throw new \phpbb\exception\http_exception(403, 'MCHAT_ERROR_FORBIDDEN');
                }
                // check for the correct user
                $sql = 'SELECT *
					FROM ' . $this->mchat_table . '
					WHERE message_id = ' . (int) $message_id;
                $result = $this->db->sql_query($sql);
                $row = $this->db->sql_fetchrow($result);
                $this->db->sql_freeresult($result);
                // edit and delete auths
                $mchat_edit = $this->auth->acl_get('u_mchat_edit') && ($this->auth->acl_get('m_') || $this->user->data['user_id'] == $row['user_id']) ? true : false;
                $mchat_del = $this->auth->acl_get('u_mchat_delete') && ($this->auth->acl_get('m_') || $this->user->data['user_id'] == $row['user_id']) ? true : false;
                // If mChat disabled and not edit
                if (!$mchat_edit) {
                    // Forbidden (for jQ AJAX request)
                    throw new \phpbb\exception\http_exception(403, 'MCHAT_ERROR_FORBIDDEN');
                }
                // Reguest...
                $message = $this->request->variable('message', '', true);
                // must have something other than bbcode in the message
                if (empty($mchatregex)) {
                    //let's strip all the bbcode
                    $mchatregex = '#\\[/?[^\\[\\]]+\\]#mi';
                }
                $message_chars = preg_replace($mchatregex, '', $message);
                $message_chars = utf8_strlen(trim($message_chars)) > 0 ? true : false;
                if (!$message || !$message_chars) {
                    // Not Implemented (for jQ AJAX request)
                    throw new \phpbb\exception\http_exception(501, 'MCHAT_ERROR_NOT_IMPLEMENTED');
                }
                // Message limit
                $message = $this->config_mchat['max_message_lngth'] != 0 && utf8_strlen($message) >= $this->config_mchat['max_message_lngth'] + 3 ? utf8_substr($message, 0, $this->config_mchat['max_message_lngth']) . '...' : $message;
                // we override the $this->config['min_post_chars'] entry?
                if ($this->config_mchat['override_min_post_chars']) {
                    $old_cfg['min_post_chars'] = $this->config['min_post_chars'];
                    $this->config['min_post_chars'] = 0;
                }
                //we do the same for the max number of smilies?
                if ($this->config_mchat['override_smilie_limit']) {
                    $old_cfg['max_post_smilies'] = $this->config['max_post_smilies'];
                    $this->config['max_post_smilies'] = 0;
                }
                // Edit function part code from http://wiki.phpbb.com/Parsing_text
                $uid = $bitfield = $options = '';
                // will be modified by generate_text_for_storage
                generate_text_for_storage($message, $uid, $bitfield, $options, $mchat_allow_bbcode, $mchat_urls, $mchat_smilies);
                // Not allowed bbcodes
                if (!$mchat_allow_bbcode || $this->config_mchat['bbcode_disallowed']) {
                    if (!$mchat_allow_bbcode) {
                        $bbcode_remove = '#\\[/?[^\\[\\]]+\\]#Usi';
                        $message = preg_replace($bbcode_remove, '', $message);
                    } else {
                        if ($this->config_mchat['bbcode_disallowed']) {
                            if (empty($bbcode_replace)) {
                                $bbcode_replace = array('#\\[(' . $this->config_mchat['bbcode_disallowed'] . ')[^\\[\\]]+\\]#Usi', '#\\[/(' . $this->config_mchat['bbcode_disallowed'] . ')[^\\[\\]]+\\]#Usi');
                            }
                            $message = preg_replace($bbcode_replace, '', $message);
                        }
                    }
                }
                $sql_ary = array('message' => str_replace('\'', '&rsquo;', $message), 'bbcode_bitfield' => $bitfield, 'bbcode_uid' => $uid, 'bbcode_options' => $options);
                $sql = 'UPDATE ' . $this->mchat_table . ' SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . '
					WHERE message_id = ' . (int) $message_id;
                $this->db->sql_query($sql);
                // Message edited...now read it
                $sql = 'SELECT m.*, u.username, u.user_colour, u.user_avatar, u.user_avatar_type, u.user_avatar_width, u.user_avatar_height, u.user_allow_pm
					FROM ' . $this->mchat_table . ' m, ' . USERS_TABLE . ' u
					WHERE m.user_id = u.user_id
						AND m.message_id = ' . (int) $message_id . '
					ORDER BY m.message_id DESC';
                $result = $this->db->sql_query($sql);
                $row = $this->db->sql_fetchrow($result);
                $this->db->sql_freeresult($result);
                $message_edit = $row['message'];
                decode_message($message_edit, $row['bbcode_uid']);
                $message_edit = str_replace('"', '&quot;', $message_edit);
                // Edit Fix ;)
                $message_edit = mb_ereg_replace("'", "&#146;", $message_edit);
                // Edit Fix ;)
                $mchat_ban = $this->auth->acl_get('a_authusers') && $this->user->data['user_id'] != $row['user_id'] ? true : false;
                $mchat_avatar = $row['user_avatar'] ? get_user_avatar($row['user_avatar'], $row['user_avatar_type'], $row['user_avatar_width'] > $row['user_avatar_height'] ? 40 : 40 / $row['user_avatar_height'] * $row['user_avatar_width'], $row['user_avatar_height'] > $row['user_avatar_width'] ? 40 : 40 / $row['user_avatar_width'] * $row['user_avatar_height']) : '';
                $this->template->assign_block_vars('mchatrow', array('MCHAT_ALLOW_BAN' => $mchat_ban, 'MCHAT_ALLOW_EDIT' => $mchat_edit, 'MCHAT_ALLOW_DEL' => $mchat_del, 'MCHAT_MESSAGE_EDIT' => $message_edit, 'MCHAT_USER_AVATAR' => $mchat_avatar, 'U_VIEWPROFILE' => $row['user_id'] != ANONYMOUS ? append_sid("{$this->phpbb_root_path}memberlist.{$this->phpEx}", 'mode=viewprofile&amp;u=' . $row['user_id']) : '', 'U_USER_IDS' => $row['user_id'] != ANONYMOUS && $this->user->data['user_id'] != $row['user_id'] ? append_sid("{$this->phpbb_root_path}ucp.{$this->phpEx}", 'i=pm&amp;mode=compose&amp;u=' . $row['user_id']) : '', 'BOT_USER_ID' => $row['user_id'] != '1', 'U_USER_ID' => $row['user_id'] != ANONYMOUS && $this->config['allow_privmsg'] && $this->auth->acl_get('u_sendpm') && $this->user->data['user_id'] != $row['user_id'] && $row['user_id'] != '1' && ($row['user_allow_pm'] || $this->auth->acl_gets('a_', 'm_') || $this->auth->acl_getf_global('m_')) ? append_sid("{$this->phpbb_root_path}ucp.{$this->phpEx}", 'i=pm&amp;mode=compose&amp;u=' . $row['user_id']) : '', 'MCHAT_MESSAGE_ID' => $row['message_id'], 'MCHAT_USERNAME_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour'], $this->user->lang['GUEST']), 'MCHAT_USERNAME' => get_username_string('username', $row['user_id'], $row['username'], $row['user_colour'], $this->user->lang['GUEST']), 'MCHAT_USERNAME_COLOR' => get_username_string('colour', $row['user_id'], $row['username'], $row['user_colour'], $this->user->lang['GUEST']), 'MCHAT_USER_IP' => $row['user_ip'], 'MCHAT_U_WHOIS' => $this->helper->route('dmzx_mchat_controller', array('mode' => 'whois', 'ip' => $row['user_ip'])), 'MCHAT_U_BAN' => append_sid("{$this->phpbb_root_path}adm/index.{$this->phpEx}", 'i=permissions&amp;mode=setting_user_global&amp;user_id[0]=' . $row['user_id'], true, $this->user->session_id), 'MCHAT_MESSAGE' => censor_text(generate_text_for_display($row['message'], $row['bbcode_uid'], $row['bbcode_bitfield'], $row['bbcode_options'])), 'MCHAT_TIME' => $this->user->format_date($row['message_time'], $this->config_mchat['date']), 'MCHAT_CLASS' => $row['message_id'] % 2 ? 1 : 2));
                // reset the config settings
                if (isset($old_cfg['min_post_chars'])) {
                    $this->config['min_post_chars'] = $old_cfg['min_post_chars'];
                    unset($old_cfg['min_post_chars']);
                }
                if (isset($old_cfg['max_post_smilies'])) {
                    $this->config['max_post_smilies'] = $old_cfg['max_post_smilies'];
                    unset($old_cfg['max_post_smilies']);
                }
                //adds a log
                //	$message_author = get_username_string('no_profile', $row['user_id'], $row['username'], $row['user_colour'], $this->user->lang['GUEST']);
                //	add_log('admin', 'LOG_EDITED_MCHAT', $message_author);
                $this->phpbb_log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_EDITED_MCHAT', false, array($row['username']));
                // insert user into the mChat sessions table
                $this->functions_mchat->mchat_sessions($mchat_session_time, true);
                // If read mode request set true
                $mchat_read_mode = true;
                break;
                // Delete function...
            // Delete function...
            case 'delete':
                $message_id = $this->request->variable('message_id', 0);
                // If mChat disabled
                if (!$this->config['mchat_enable'] || !$message_id) {
                    // Forbidden (for jQ AJAX request)
                    throw new \phpbb\exception\http_exception(403, 'MCHAT_ERROR_FORBIDDEN');
                }
                // check for the correct user
                $sql = 'SELECT m.*, u.username, u.user_colour
					FROM ' . $this->mchat_table . ' m
					LEFT JOIN ' . USERS_TABLE . ' u ON m.user_id = u.user_id
					WHERE m.message_id = ' . (int) $message_id;
                $result = $this->db->sql_query($sql);
                $row = $this->db->sql_fetchrow($result);
                $this->db->sql_freeresult($result);
                // edit and delete auths
                $mchat_edit = $this->auth->acl_get('u_mchat_edit') && ($this->auth->acl_get('m_') || $this->user->data['user_id'] == $row['user_id']) ? true : false;
                $mchat_del = $this->auth->acl_get('u_mchat_delete') && ($this->auth->acl_get('m_') || $this->user->data['user_id'] == $row['user_id']) ? true : false;
                // If mChat disabled
                if (!$mchat_del) {
                    // Forbidden (for jQ AJAX request)
                    throw new \phpbb\exception\http_exception(403, 'MCHAT_ERROR_FORBIDDEN');
                }
                // Run delete!
                $sql = 'DELETE FROM ' . $this->mchat_table . '
					WHERE message_id = ' . (int) $message_id;
                $this->db->sql_query($sql);
                //adds a log
                $this->phpbb_log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_DELETED_MCHAT', false, array($row['username']));
                // insert user into the mChat sessions table
                $this->functions_mchat->mchat_sessions($mchat_session_time, true);
                // Stop running code
                if ($this->request->is_ajax()) {
                    // Return for: \Symfony\Component\HttpFoundation\JsonResponse
                    return array('json' => true, 'success' => true);
                } else {
                    exit_handler();
                }
                break;
                // Default function...
            // Default function...
            default:
                // If not include in index.php set mchat.php page true
                if (!$include_on_index) {
                    // Yes its custom page...
                    $mchat_custom_page = true;
                    // If custom page false mchat.php page redirect to index...
                    if (!$this->config_mchat['custom_page'] && $mchat_custom_page) {
                        $mchat_redirect = append_sid("{$this->phpbb_root_path}index.{$this->phpEx}");
                        // Redirect to previous page
                        meta_refresh(3, $mchat_redirect);
                        trigger_error($this->user->lang['MCHAT_NO_CUSTOM_PAGE'] . '<br /><br />' . sprintf($this->user->lang['RETURN_PAGE'], '<a href="' . $mchat_redirect . '">', '</a>'));
                    }
                    // user has permissions to view the custom chat?
                    if (!$mchat_view && $mchat_custom_page) {
                        trigger_error('NOT_AUTHORISED', E_USER_NOTICE);
                    }
                    // if whois true
                    if ($this->config_mchat['whois']) {
                        // Grab group details for legend display for who is online on the custom page.
                        $order_legend = $this->config['legend_sort_groupname'] ? 'group_name' : 'group_legend';
                        if ($this->auth->acl_gets('a_group', 'a_groupadd', 'a_groupdel')) {
                            $sql = 'SELECT group_id, group_name, group_colour, group_type FROM ' . GROUPS_TABLE . '
						WHERE group_legend <> 0
							ORDER BY ' . $order_legend . ' ASC';
                        } else {
                            $sql = 'SELECT g.group_id, g.group_name, g.group_colour, g.group_type FROM ' . GROUPS_TABLE . ' g
						LEFT JOIN ' . USER_GROUP_TABLE . ' ug ON (g.group_id = ug.group_id AND ug.user_id = ' . $this->user->data['user_id'] . ' AND ug.user_pending = 0)
							WHERE g.group_legend <> 0
								AND (g.group_type <> ' . GROUP_HIDDEN . '
									OR ug.user_id = ' . (int) $this->user->data['user_id'] . ')
							ORDER BY g.' . $order_legend . ' ASC';
                        }
                        $result = $this->db->sql_query($sql);
                        $legend = array();
                        while ($row = $this->db->sql_fetchrow($result)) {
                            $colour_text = $row['group_colour'] ? ' style="color:#' . $row['group_colour'] . '"' : '';
                            $group_name = $row['group_type'] == GROUP_SPECIAL ? $this->user->lang['G_' . $row['group_name']] : $row['group_name'];
                            if ($row['group_name'] == 'BOTS' || $this->user->data['user_id'] != ANONYMOUS && !$this->auth->acl_get('u_viewprofile')) {
                                $legend[] = '<span' . $colour_text . '>' . $group_name . '</span>';
                            } else {
                                $legend[] = '<a' . $colour_text . ' href="' . append_sid("{$this->phpbb_root_path}memberlist.{$this->phpEx}", 'mode=group&amp;g=' . $row['group_id']) . '">' . $group_name . '</a>';
                            }
                        }
                        $this->db->sql_freeresult($result);
                        $legend = implode(', ', $legend);
                        // Assign index specific vars
                        $this->template->assign_vars(array('LEGEND' => $legend));
                    }
                    $this->template->assign_block_vars('navlinks', array('FORUM_NAME' => $this->user->lang['MCHAT_TITLE'], 'U_VIEW_FORUM' => $this->helper->route('dmzx_mchat_controller')));
                }
                // Run code...
                if ($mchat_view) {
                    $message_number = $mchat_custom_page ? $this->config_mchat['message_limit'] : $this->config_mchat['message_num'];
                    $sql_where = $this->user->data['user_mchat_topics'] ? '' : 'WHERE m.forum_id = 0';
                    // Message row
                    $sql = 'SELECT m.*, u.username, u.user_colour, u.user_avatar, u.user_avatar_type, u.user_avatar_width, u.user_avatar_height, u.user_allow_pm
						FROM ' . $this->mchat_table . ' m
							LEFT JOIN ' . USERS_TABLE . ' u ON m.user_id = u.user_id
						' . $sql_where . '
						ORDER BY message_id DESC';
                    $result = $this->db->sql_query_limit($sql, $message_number);
                    $rows = $this->db->sql_fetchrowset($result);
                    $this->db->sql_freeresult($result);
                    if ($this->config['mchat_message_top']) {
                        $rows = array_reverse($rows, true);
                    }
                    foreach ($rows as $row) {
                        // auth check
                        if ($row['forum_id'] != 0 && !$this->auth->acl_get('f_read', $row['forum_id'])) {
                            continue;
                        }
                        // edit, delete and permission auths
                        $mchat_ban = $this->auth->acl_get('a_authusers') && $this->user->data['user_id'] != $row['user_id'] ? true : false;
                        // edit auths
                        if ($this->user->data['user_id'] == ANONYMOUS && $this->user->data['user_id'] == $row['user_id']) {
                            $chat_auths = $this->user->data['session_ip'] == $row['user_ip'] ? true : false;
                        } else {
                            $chat_auths = $this->user->data['user_id'] == $row['user_id'] ? true : false;
                        }
                        $mchat_edit = $this->auth->acl_get('u_mchat_edit') && ($this->auth->acl_get('m_') || $chat_auths) ? true : false;
                        $mchat_del = $this->auth->acl_get('u_mchat_delete') && ($this->auth->acl_get('m_') || $chat_auths) ? true : false;
                        $mchat_avatar = $row['user_avatar'] ? get_user_avatar($row['user_avatar'], $row['user_avatar_type'], $row['user_avatar_width'] > $row['user_avatar_height'] ? 40 : 40 / $row['user_avatar_height'] * $row['user_avatar_width'], $row['user_avatar_height'] > $row['user_avatar_width'] ? 40 : 40 / $row['user_avatar_width'] * $row['user_avatar_height']) : '';
                        $message_edit = $row['message'];
                        decode_message($message_edit, $row['bbcode_uid']);
                        $message_edit = str_replace('"', '&quot;', $message_edit);
                        // Edit Fix ;)
                        $message_edit = mb_ereg_replace("'", "&#146;", $message_edit);
                        if (sizeof($foes_array)) {
                            if (in_array($row['user_id'], $foes_array)) {
                                $row['message'] = sprintf($this->user->lang['MCHAT_FOE'], get_username_string('full', $row['user_id'], $row['username'], $row['user_colour'], $this->user->lang['GUEST']));
                            }
                        }
                        $row['username'] = mb_ereg_replace("'", "&#146;", $row['username']);
                        $message = str_replace('\'', '&rsquo;', $row['message']);
                        $this->template->assign_block_vars('mchatrow', array('MCHAT_ALLOW_BAN' => $mchat_ban, 'MCHAT_ALLOW_EDIT' => $mchat_edit, 'MCHAT_ALLOW_DEL' => $mchat_del, 'MCHAT_USER_AVATAR' => $mchat_avatar, 'U_VIEWPROFILE' => $row['user_id'] != ANONYMOUS ? append_sid("{$this->phpbb_root_path}memberlist.{$this->phpEx}", 'mode=viewprofile&amp;u=' . $row['user_id']) : '', 'U_USER_IDS' => $row['user_id'] != ANONYMOUS && $this->user->data['user_id'] != $row['user_id'] ? append_sid("{$this->phpbb_root_path}ucp.{$this->phpEx}", 'i=pm&amp;mode=compose&amp;u=' . $row['user_id']) : '', 'BOT_USER_ID' => $row['user_id'] != '1', 'U_USER_ID' => $row['user_id'] != ANONYMOUS && $this->config['allow_privmsg'] && $this->auth->acl_get('u_sendpm') && $this->user->data['user_id'] != $row['user_id'] && $row['user_id'] != '1' && ($row['user_allow_pm'] || $this->auth->acl_gets('a_', 'm_') || $this->auth->acl_getf_global('m_')) ? append_sid("{$this->phpbb_root_path}ucp.{$this->phpEx}", 'i=pm&amp;mode=compose&amp;u=' . $row['user_id']) : '', 'MCHAT_MESSAGE_EDIT' => $message_edit, 'MCHAT_MESSAGE_ID' => $row['message_id'], 'MCHAT_USERNAME_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour'], $this->user->lang['GUEST']), 'MCHAT_USERNAME' => get_username_string('username', $row['user_id'], $row['username'], $row['user_colour'], $this->user->lang['GUEST']), 'MCHAT_USERNAME_COLOR' => get_username_string('colour', $row['user_id'], $row['username'], $row['user_colour'], $this->user->lang['GUEST']), 'MCHAT_USER_IP' => $row['user_ip'], 'MCHAT_U_WHOIS' => $this->helper->route('dmzx_mchat_controller', array('mode' => 'whois', 'ip' => $row['user_ip'])), 'MCHAT_U_BAN' => append_sid("{$this->phpbb_root_path}adm/index.{$this->phpEx}", 'i=permissions&amp;mode=setting_user_global&amp;user_id[0]=' . $row['user_id'], true, $this->user->session_id), 'MCHAT_MESSAGE' => generate_text_for_display($message, $row['bbcode_uid'], $row['bbcode_bitfield'], $row['bbcode_options']), 'MCHAT_TIME' => $this->user->format_date($row['message_time'], $this->config_mchat['date']), 'MCHAT_CLASS' => $row['message_id'] % 2 ? 1 : 2));
                    }
                    // Write no message
                    if (empty($rows)) {
                        $mchat_no_message = true;
                    }
                    // display custom bbcodes
                    if ($mchat_allow_bbcode && $this->config['allow_bbcode']) {
                        $this->functions_mchat->display_mchat_bbcodes();
                    }
                    // Smile row
                    if ($mchat_smilies) {
                        if (!function_exists('generate_smilies')) {
                            include $this->phpbb_root_path . 'includes/functions_posting.' . $this->phpEx;
                        }
                        generate_smilies('inline', 0);
                    }
                    // If the static message is defined in the language file use it, else just use the entry in the database
                    if (isset($this->user->lang[strtoupper('static_message')]) || !empty($this->config_mchat['static_message'])) {
                        $this->config_mchat['static_message'] = $this->config_mchat['static_message'];
                        if (isset($this->user->lang[strtoupper('static_message')])) {
                            $this->config_mchat['static_message'] = $this->user->lang[strtoupper('static_message')];
                        }
                    }
                    // If the static message is defined in the language file use it, else just use the entry in the database
                    if (isset($this->user->lang[strtoupper('mchat_rules')]) || !empty($this->config_mchat['rules'])) {
                        if (isset($this->user->lang[strtoupper('mchat_rules')])) {
                            $this->config_mchat['rules'] = $this->user->lang[strtoupper('mchat_rules')];
                        }
                    }
                    // a list of users using the chat
                    if ($mchat_custom_page) {
                        $mchat_users = $this->functions_mchat->mchat_users($mchat_session_time, true);
                    } else {
                        $mchat_users = $this->functions_mchat->mchat_users($mchat_session_time);
                    }
                    $this->template->assign_vars(array('MCHAT_USERS_COUNT' => $mchat_users['mchat_users_count'], 'MCHAT_USERS_LIST' => $mchat_users['online_userlist']));
                }
                break;
        }
        // show index stats
        if (!empty($this->config['mchat_stats_index']) && !empty($this->user->data['user_mchat_stats_index'])) {
            // stats display
            $mchat_session_time = !empty($this->config_mchat['timeout']) ? $this->config_mchat['timeout'] : $this->config['session_length'];
            $mchat_stats = $this->functions_mchat->mchat_users($mchat_session_time);
            $this->template->assign_vars(array('MCHAT_INDEX_STATS' => true, 'MCHAT_INDEX_USERS_COUNT' => $mchat_stats['mchat_users_count'], 'MCHAT_INDEX_USERS_LIST' => !empty($mchat_stats['online_userlist']) ? $mchat_stats['online_userlist'] : '', 'L_MCHAT_ONLINE_EXPLAIN' => $mchat_stats['refresh_message']));
        }
        $copyright = base64_decode('PGEgaHJlZj0iaHR0cDovL3JtY2dpcnI4My5vcmciPlJNY0dpcnI4MzwvYT4gJmNvcHk7IDxhIGhyZWY9Imh0dHA6Ly93d3cuZG16eC13ZWIubmV0IiB0aXRsZT0id3d3LmRtengtd2ViLm5ldCI+ZG16eDwvYT4=');
        add_form_key('mchat_posting');
        // Template function...
        $this->template->assign_vars(array('MCHAT_FILE_NAME' => $this->helper->route('dmzx_mchat_controller'), 'MCHAT_REFRESH_JS' => 1000 * $this->config_mchat['refresh'], 'MCHAT_ADD_MESSAGE' => $mchat_add_mess, 'MCHAT_READ_MODE' => $mchat_read_mode, 'MCHAT_ARCHIVE_MODE' => $mchat_archive_mode, 'MCHAT_INPUT_TYPE' => $this->user->data['user_mchat_input_area'], 'MCHAT_RULES' => $mchat_rules, 'MCHAT_ALLOW_SMILES' => $mchat_smilies, 'MCHAT_ALLOW_IP' => $mchat_ip, 'MCHAT_ALLOW_PM' => $mchat_pm, 'MCHAT_ALLOW_LIKE' => $mchat_like, 'MCHAT_ALLOW_QUOTE' => $mchat_quote, 'MCHAT_NOMESSAGE_MODE' => $mchat_no_message, 'MCHAT_ALLOW_BBCODES' => $mchat_allow_bbcode && $this->config['allow_bbcode'] ? true : false, 'MCHAT_MESSAGE_TOP' => $this->config['mchat_message_top'] ? true : false, 'MCHAT_ENABLE' => $this->config['mchat_enable'], 'MCHAT_ARCHIVE_URL' => $this->helper->route('dmzx_mchat_controller', array('mode' => 'archive')), 'MCHAT_CUSTOM_PAGE' => $mchat_custom_page, 'MCHAT_INDEX_HEIGHT' => $this->config_mchat['index_height'], 'MCHAT_CUSTOM_HEIGHT' => $this->config_mchat['custom_height'], 'MCHAT_READ_ARCHIVE_BUTTON' => $mchat_read_archive, 'MCHAT_FOUNDER' => $mchat_founder, 'MCHAT_CLEAN_URL' => $this->helper->route('dmzx_mchat_controller', array('mode' => 'clean', 'redirect' => $on_page)), 'MCHAT_STATIC_MESS' => !empty($this->config_mchat['static_message']) ? htmlspecialchars_decode($this->config_mchat['static_message']) : '', 'L_MCHAT_COPYRIGHT' => $copyright, 'MCHAT_WHOIS' => $this->config_mchat['whois'], 'MCHAT_MESSAGE_LNGTH' => $this->config_mchat['max_message_lngth'], 'L_MCHAT_MESSAGE_LNGTH_EXPLAIN' => intval($this->config_mchat['max_message_lngth']) ? sprintf($this->user->lang['MCHAT_MESSAGE_LNGTH_EXPLAIN'], intval($this->config_mchat['max_message_lngth'])) : '', 'MCHAT_MESS_LONG' => sprintf($this->user->lang['MCHAT_MESS_LONG'], $this->config_mchat['max_message_lngth']), 'MCHAT_USER_TIMEOUT' => $this->config_mchat['timeout'] ? 1000 * $this->config_mchat['timeout'] : false, 'MCHAT_WHOIS_REFRESH' => 1000 * $this->config_mchat['whois_refresh'], 'MCHAT_PAUSE_ON_INPUT' => $this->config_mchat['pause_on_input'] ? true : false, 'L_MCHAT_ONLINE_EXPLAIN' => $this->functions_mchat->mchat_session_time($mchat_session_time), 'MCHAT_REFRESH_YES' => sprintf($this->user->lang['MCHAT_REFRESH_YES'], $this->config_mchat['refresh']), 'L_MCHAT_WHOIS_REFRESH_EXPLAIN' => sprintf($this->user->lang['WHO_IS_REFRESH_EXPLAIN'], $this->config_mchat['whois_refresh']), 'S_MCHAT_AVATARS' => $mchat_avatars, 'S_MCHAT_LOCATION' => $this->config_mchat['location'], 'S_MCHAT_SOUND_YES' => $this->user->data['user_mchat_sound'], 'S_MCHAT_INDEX_STATS' => $this->user->data['user_mchat_stats_index'], 'U_MORE_SMILIES' => append_sid("{$this->phpbb_root_path}posting.{$this->phpEx}", 'mode=smilies'), 'U_MCHAT_RULES' => $this->helper->route('dmzx_mchat_controller', array('mode' => 'rules')), 'S_MCHAT_ON_INDEX' => $this->config['mchat_on_index'] && !empty($this->user->data['user_mchat_index']) ? true : false));
        // Return for: \$this->helper->render(filename, lang_title);
        return array('filename' => 'mchat_body.html', 'lang_title' => $this->user->lang['MCHAT_TITLE']);
    }
コード例 #5
0
ファイル: cms.php プロジェクト: ALTUN69/icy_phoenix
$access_allowed = get_cms_access_auth('cms', $cms_admin->mode, $cms_admin->action, $cms_admin->l_id, $cms_admin->b_id);
if (!$access_allowed) {
    message_die(GENERAL_MESSAGE, $lang['Not_Auth_View']);
}
include IP_ROOT_PATH . 'includes/class_db.' . PHP_EXT;
$class_db = new class_db();
include IP_ROOT_PATH . 'includes/class_form.' . PHP_EXT;
$class_form = new class_form();
include_once IP_ROOT_PATH . 'includes/functions_selects.' . PHP_EXT;
include_once IP_ROOT_PATH . 'includes/functions_post.' . PHP_EXT;
include_once IP_ROOT_PATH . 'includes/bbcode.' . PHP_EXT;
$page_title = $lang['CMS_TITLE'];
$cms_type = 'cms_standard';
$preview_block = isset($_POST['preview']) ? true : false;
if ($cms_admin->mode == 'smilies') {
    generate_smilies('window');
    exit;
}
if (isset($_POST['block_reset'])) {
    if ($cms_admin->ls_id == false) {
        redirect(append_sid($cms_admin->root . '?mode=blocks&l_id=' . $cms_admin->l_id, true));
    } else {
        redirect(append_sid($cms_admin->root . '?mode=blocks&ls_id=' . $cms_admin->ls_id, true));
    }
}
if (isset($_POST['cancel'])) {
    redirect(append_sid($cms_admin->root, true));
}
$template->assign_vars(array('S_CMS_AUTH' => true, 'S_EDIT_SETTINGS' => true, 'S_L_ADD' => true, 'S_L_EDIT' => true, 'S_L_DELETE' => true, 'S_B_ADD' => true, 'S_B_EDIT' => true, 'S_B_DELETE' => true));
$cms_admin->s_hidden_fields = '';
$cms_admin->s_append_url = '';
コード例 #6
0
ファイル: codebase.php プロジェクト: phill104/branches
function fix_displayimage()
{
    // no specifics for Thumbnail page today.
    if (!defined("DISPLAYIMAGE_PHP")) {
        return;
    }
    global $CONFIG, $film_strip;
    global $CURRENT_PIC_DATA, $CURRENT_ALBUM_DATA, $comments, $picture, $votes, $pic_info, $template_display_media, $THEME_DIR;
    global $saved_template_image_comments, $saved_template_add_your_comment, $lang_display_comments, $lang_contest, $template_image_rating;
    if (!array_key_exists('aid', $CURRENT_ALBUM_DATA)) {
        return;
    }
    //checks if current album is a contest - not extracted in displayimage.php
    $result = cpg_db_query("SELECT contest FROM {$CONFIG['TABLE_ALBUMS']} WHERE aid='{$CURRENT_ALBUM_DATA['aid']}'");
    if ($row = mysql_fetch_row($result)) {
        $CURRENT_ALBUM_DATA['contest'] = $row[0];
    } else {
        return;
    }
    // display the votes as a voting page.
    if ($CURRENT_ALBUM_DATA['votes'] != 'YES' && $CURRENT_ALBUM_DATA['contest'] == 'YES') {
        if (!defined('MAX_RATING')) {
            define('MAX_RATING', 5);
        }
        $title = $lang_contest['result'];
        $votetext = $CURRENT_PIC_DATA['votes'] ? sprintf($lang_contest['evaluation'], round($CURRENT_PIC_DATA['pic_rating'] / 2000, 1), MAX_RATING, $CURRENT_PIC_DATA['votes']) : $lang_rate_pic['no_votes'];
        $votes = $template_image_rating;
        $pattern = "#(<a href)(.*?)(</a>)#s";
        if (preg_match_all($pattern, $votes, $matches)) {
            foreach ($matches[0] as $key => $match) {
                if (preg_match("rating", $match)) {
                    $votes = ereg_replace(preg_quote($match), "", $votes);
                }
            }
        }
        $votes = ereg_replace("{VOTES}", $votetext, $votes);
        $votes = ereg_replace("{TITLE}", $title, $votes);
        $votes = ereg_replace("{LOCATION}", $THEME_DIR, $votes);
        if (preg_match("<!-- BEGIN rating_boxes -->", $votes)) {
            template_extract_block($votes, 'rating_boxes', '');
        }
    }
    //to be used only for contests in progress
    if ($CURRENT_ALBUM_DATA['votes'] == 'YES' && $CURRENT_ALBUM_DATA['contest'] == 'YES') {
        // do not display pic infos,owner names, captions
        $pic_info = "";
        $pattern = "#(<!-- BEGIN img_desc -->)(.*?)(<!-- END img_desc -->)#s";
        if (preg_match($pattern, $picture, $matches)) {
            $picture = str_replace($matches[0], $matches[1] . $matches[3], $picture);
        }
        //findout which image has already been noted by user in the contest and show them with a square in the film strip
        $myvotes = array();
        $query = "SELECT concat(filepath,'{$CONFIG['thumb_pfx']}',filename) FROM `{$CONFIG['TABLE_PREFIX']}user_votes` AS T1, `{$CONFIG['TABLE_PREFIX']}pictures` AS T2 WHERE T1.pid=T2.pid AND user_id  = " . USER_ID;
        $result = cpg_db_query($query);
        while ($row = mysql_fetch_row($result)) {
            $myvotes[] = $row[0];
        }
        $pattern = "#(<img )(.*?albums.*?)(\" border=\"0\")(.*?)(/>)#s";
        if (preg_match_all($pattern, $film_strip, $matches)) {
            foreach ($matches[0] as $key => $match) {
                foreach ($myvotes as $v) {
                    if (strpos($match, $v) !== FALSE) {
                        $matches[3][$key] = " style=\"border:1pix;border-color:grey;\"";
                        break;
                    }
                }
                $film_strip = ereg_replace(preg_quote($match), $matches[1][$key] . $matches[2][$key] . $matches[3][$key] . $matches[4][$key] . $matches[5][$key], $film_strip);
            }
            $film_strip = ereg_replace("class=\"image\"", "", $film_strip);
        }
        //removes alt and title from film_strip
        $pattern = "#(alt=\")(.*?)(\")#s";
        if (preg_match_all($pattern, $film_strip, $matches)) {
            foreach ($matches[0] as $key => $match) {
                $film_strip = ereg_replace(preg_quote($match), "", $film_strip);
            }
        }
        $pattern = "#(title=\")(.*?)(\")#s";
        if (preg_match_all($pattern, $film_strip, $matches)) {
            foreach ($matches[0] as $key => $match) {
                $film_strip = ereg_replace(preg_quote($match), "", $film_strip);
            }
        }
        //and try to set a border on current vote
        $result = cpg_db_query("SELECT rating FROM `{$CONFIG['TABLE_PREFIX']}user_votes` WHERE pid = {$CURRENT_PIC_DATA['pid']} AND user_id  = " . USER_ID);
        if ($row = mysql_fetch_row($result)) {
            $pattern = "#(<img.*?rating{$row[0]}.*?)(border=\"0\")(.*?/>)#s";
            if (preg_match($pattern, $votes, $matches)) {
                $votes = ereg_replace(preg_quote($matches[0]), $matches[1] . "border=\"2\"" . $matches[3], $votes);
            }
        }
        // find if user can vote (not own image) and if can vote verifies that the voting block is not hidden
        if ($CURRENT_PIC_DATA['owner_id'] == USER_ID || !USER_CAN_RATE_PICTURES) {
            //<a href="javascript:location.href='./ratepic.php?pic=22&amp;rate=1'" title="Beurk"><img src="themes/alphadxd/images/rating1.gif" border="0" alt="Beurk" /></a>
            $pattern = "#(<a href.*?ratepic.*?\\>)(.*?)(</a>)#s";
            if (preg_match_all($pattern, $votes, $matches)) {
                foreach ($matches[0] as $key => $match) {
                    $votes = ereg_replace(preg_quote($match), $matches[2][$key], $votes);
                }
            }
        } else {
            $votes = ereg_replace(preg_quote("display: none;"), "", $votes);
        }
        // only display current user's comments in a contest
        if ($CURRENT_ALBUM_DATA['comments'] != 'YES') {
            return;
        }
        $comments = '';
        $pid = $CURRENT_PIC_DATA['pid'];
        if (!$CONFIG['enable_smilies']) {
            $tmpl_comment_edit_box = template_extract_block($saved_template_image_comments, 'edit_box_no_smilies', '{EDIT}');
            template_extract_block($saved_template_image_comments, 'edit_box_smilies');
            template_extract_block($saved_template_add_your_comment, 'input_box_smilies');
        } else {
            $tmpl_comment_edit_box = template_extract_block($saved_template_image_comments, 'edit_box_smilies', '{EDIT}');
            template_extract_block($saved_template_image_comments, 'edit_box_no_smilies');
            template_extract_block($saved_template_add_your_comment, 'input_box_no_smilies');
        }
        $tmpl_comments_buttons = template_extract_block($saved_template_image_comments, 'buttons', '{BUTTONS}');
        template_extract_block($saved_template_image_comments, 'ipinfo', '');
        //suppressed by PL
        template_extract_block($saved_template_image_comments, 'report_comment_button');
        // won't report on own comment, would we?
        $newpostok = true;
        $query = "SELECT msg_id, msg_author, msg_body, UNIX_TIMESTAMP(msg_date) AS msg_date, author_id, author_md5_id, msg_raw_ip, msg_hdr_ip, pid FROM {$CONFIG['TABLE_COMMENTS']} WHERE pid='{$pid}' AND msg_author='" . USER_NAME . "' ORDER BY msg_id DESC LIMIT 1";
        $result = cpg_db_query($query);
        if ($row = mysql_fetch_array($result)) {
            $user_can_edit = true;
            $comment_buttons = $tmpl_comments_buttons;
            $comment_edit_box = $tmpl_comment_edit_box;
            if ($CONFIG['enable_smilies']) {
                $comment_body = process_smilies(make_clickable($row['msg_body']));
                $smilies = generate_smilies("f{$row['msg_id']}", 'msg_body');
            } else {
                $comment_body = make_clickable($row['msg_body']);
                $smilies = '';
            }
            $params = array('{EDIT}' => &$tmpl_comment_edit_box, '{BUTTONS}' => &$tmpl_comments_buttons);
            $template = template_eval($saved_template_image_comments, $params);
            $params = array('{MSG_AUTHOR}' => stripslashes($row['msg_author']), '{MSG_ID}' => $row['msg_id'], '{PID}' => $row['pid'], '{EDIT_TITLE}' => &$lang_display_comments['edit_title'], '{CONFIRM_DELETE}' => &$lang_display_comments['confirm_delete'], '{MSG_DATE}' => localised_date($row['msg_date'], '%d %B %Y'), '{MSG_BODY}' => bb_decode($comment_body), '{MSG_BODY_RAW}' => $row['msg_body'], '{OK}' => &$lang_display_comments['OK'], '{SMILIES}' => $smilies, '{REPORT_COMMENT_TITLE}' => &$lang_display_comments['report_comment_title'], '{WIDTH}' => $CONFIG['picture_table_width']);
            $comments .= template_eval($template, $params);
            $newpostok = false;
            // only 1 comment per author
        }
        if (USER_ID == $CURRENT_PIC_DATA['owner_id'] || USER_ID == 0) {
            $newpostok = false;
        }
        if ($newpostok) {
            $user_name_input = '<tr><td><input type="hidden" name="msg_author" value="' . stripslashes(USER_NAME) . '" /></td>';
            template_extract_block($saved_template_add_your_comment, 'user_name_input', $user_name_input);
            $user_name = '';
            $params = array('{ADD_YOUR_COMMENT}' => $lang_display_comments['add_your_comment'], '{NAME}' => $lang_display_comments['name'], '{COMMENT}' => "", '{PIC_ID}' => $pid, '{USER_NAME}' => $user_name, '{MAX_COM_LENGTH}' => $CONFIG['max_com_size'], '{OK}' => $lang_display_comments['OK'], '{SMILIES}' => '', '{WIDTH}' => $CONFIG['picture_table_width']);
            if ($CONFIG['enable_smilies']) {
                $params['{SMILIES}'] = generate_smilies();
            } else {
                template_extract_block($saved_template_add_your_comment, 'smilies');
            }
            $comments .= template_eval($saved_template_add_your_comment, $params);
        }
    }
}
コード例 #7
0
ファイル: comment.php プロジェクト: here-we-go/phpbbgallery
 public function rate($image_id)
 {
     $this->user->add_lang_ext('phpbbgallery/core', array('gallery'));
     add_form_key('gallery');
     $submit = $this->request->variable('submit', false);
     $error = $message = '';
     // load Image Data
     $image_data = $this->image->get_image_data($image_id);
     $album_id = (int) $image_data['image_album_id'];
     $album_data = $this->loader->get($album_id);
     $this->display->generate_navigation($album_data);
     $page_title = $image_data['image_name'];
     $image_backlink = $this->helper->route('phpbbgallery_image', array('image_id' => $image_id));
     $album_backlink = $this->helper->route('phpbbgallery_album', array('album_id' => $album_id));
     $image_loginlink = $this->url->append_sid('relative', 'image_page', "album_id={$album_id}&amp;image_id={$image_id}");
     $this->gallery_auth->load_user_premissions($this->user->data['user_id']);
     $rating = new \phpbbgallery\core\rating($image_id, $image_data, $album_data);
     if (!($this->gallery_config->get('allow_rates') && $rating->is_able())) {
         // The user is unable to rate.
         $this->misc->not_authorised($image_backlink, $image_loginlink);
     }
     $this->user->add_lang('posting');
     include_once $this->phpbb_root_path . 'includes/functions_posting.' . $this->php_ext;
     $bbcode_status = $this->config['allow_bbcode'] ? true : false;
     $smilies_status = $this->config['allow_smilies'] ? true : false;
     $img_status = $bbcode_status ? true : false;
     $url_status = $this->config['allow_post_links'] ? true : false;
     $flash_status = false;
     $quote_status = true;
     include_once $this->phpbb_root_path . 'includes/functions_display.' . $this->php_ext;
     // Build custom bbcodes array
     display_custom_bbcodes();
     // Build smilies array
     generate_smilies('inline', 0);
     /**
      * Rating-System: now you can comment and rate in one form
      */
     $s_user_rated = false;
     if ($this->gallery_config->get('allow_rates')) {
         $user_rating = $rating->get_user_rating($this->user->data['user_id']);
         // Check: User didn't rate yet, has permissions, it's not the users own image and the user is logged in
         if (!$user_rating && $rating->is_allowed()) {
             $rating->display_box();
             // User just rated the image, so we store it
             $rate_point = $this->request->variable('rating', 0);
             if ($rating->rating_enabled && $rate_point > 0) {
                 $rating->submit_rating();
                 $s_user_rated = true;
                 $message .= $this->user->lang['RATING_SUCCESSFUL'] . '<br />';
             }
             $this->template->assign_vars(array('S_ALLOWED_TO_RATE' => $rating->is_allowed()));
         }
     }
     $message .= '<br />' . sprintf($this->user->lang['CLICK_RETURN_IMAGE'], '<a href="' . $image_backlink . '">', '</a>');
     $message .= '<br />' . sprintf($this->user->lang['CLICK_RETURN_ALBUM'], '<a href="' . $album_backlink . '">', '</a>');
     $this->url->meta_refresh(3, $image_backlink);
     trigger_error($message);
     return $this->helper->render('gallery/comment_body.html', $page_title);
 }
コード例 #8
0
ファイル: theme.php プロジェクト: phill104/branches
function theme_html_comments($pid)
{
    global $CONFIG, $USER, $CURRENT_ALBUM_DATA, $comment_date_fmt, $HTML_SUBST;
    global $template_image_comments, $template_add_your_comment, $lang_display_comments, $lang_common, $REFERER;
    $html = '';
    //report to moderator buttons
    if (!($CONFIG['report_post'] == 1 && USER_CAN_SEND_ECARDS)) {
        template_extract_block($template_image_comments, 'report_comment_button');
    }
    if (!$CONFIG['enable_smilies']) {
        $tmpl_comment_edit_box = template_extract_block($template_image_comments, 'edit_box_no_smilies', '{EDIT}');
        template_extract_block($template_image_comments, 'edit_box_smilies');
        template_extract_block($template_add_your_comment, 'input_box_smilies');
    } else {
        $tmpl_comment_edit_box = template_extract_block($template_image_comments, 'edit_box_smilies', '{EDIT}');
        template_extract_block($template_image_comments, 'edit_box_no_smilies');
        template_extract_block($template_add_your_comment, 'input_box_no_smilies');
    }
    $tmpl_comments_buttons = template_extract_block($template_image_comments, 'buttons', '{BUTTONS}');
    $tmpl_comments_ipinfo = template_extract_block($template_image_comments, 'ipinfo', '{IPINFO}');
    if ($CONFIG['comments_sort_descending'] == 1) {
        $comment_sort_order = 'DESC';
    } else {
        $comment_sort_order = 'ASC';
    }
    $result = cpg_db_query("SELECT msg_id, msg_author, msg_body, UNIX_TIMESTAMP(msg_date) AS msg_date, author_id, author_md5_id, msg_raw_ip, msg_hdr_ip, pid, approval FROM {$CONFIG['TABLE_COMMENTS']} WHERE pid='{$pid}' ORDER BY msg_id {$comment_sort_order}");
    while ($row = mysql_fetch_array($result)) {
        // while-loop start
        $user_can_edit = GALLERY_ADMIN_MODE || USER_ID && USER_ID == $row['author_id'] && USER_CAN_POST_COMMENTS || !USER_ID && USER_CAN_POST_COMMENTS && $USER['ID'] == $row['author_md5_id'];
        if ($user_can_edit != '' && $CONFIG['comment_user_edit'] != 0 || GALLERY_ADMIN_MODE) {
            $comment_buttons = $tmpl_comments_buttons;
            $comment_edit_box = $tmpl_comment_edit_box;
        } else {
            $comment_buttons = '';
            $comment_edit_box = '';
        }
        $comment_ipinfo = $row['msg_raw_ip'] && GALLERY_ADMIN_MODE ? $tmpl_comments_ipinfo : '';
        $hide_comment = 0;
        // comment approval
        $pending_approval = '';
        if (USER_IS_ADMIN) {
            //display the selector approve/disapprove
            if ($row['approval'] == 'NO') {
                $pending_approval = '<a href="reviewcom.php?pos=-{PID}&amp;msg_id={MSG_ID}&amp;what=approve" title="' . $lang_display_comments['approve'] . '"><img src="images/approve.gif" border="0" alt="" align="middle" /></a>';
            } else {
                $pending_approval = '<a href="reviewcom.php?pos=-{PID}&amp;msg_id={MSG_ID}&amp;what=disapprove" title="' . $lang_display_comments['disapprove'] . '"><img src="images/disapprove.gif" border="0" alt="" align="middle" /></a>';
            }
        } else {
            // user or guest is logged in - start
            if ($row['approval'] == 'NO') {
                // the comment is not approved - start
                if ($user_can_edit) {
                    // the comment comes from the current visitor, display it with a warning that it needs admin approval
                    $pending_approval = '<img src="images/approve.gif" border="0" alt="" title="' . $lang_display_comments['pending_approval'] . '" align="middle" />';
                } else {
                    // the comment comes from someone else - don't display it at all
                    if ($CONFIG['comment_placeholder'] == 0) {
                        $hide_comment = 1;
                    } else {
                        $row['msg_author'] = $lang_display_comments['unapproved_comment'];
                        $row['msg_body'] = $lang_display_comments['pending_approval_message'];
                        $row['author_id'] = 0;
                    }
                }
            }
            // the comment is not approved - end
        }
        // user or guest is logged in - end
        if ($CONFIG['enable_smilies']) {
            $comment_body = process_smilies(make_clickable($row['msg_body']));
            $smilies = generate_smilies("f{$row['msg_id']}", 'msg_body');
        } else {
            $comment_body = make_clickable($row['msg_body']);
            $smilies = '';
        }
        // wrap the comment into italics if it isn't approved
        if ($row['approval'] == 'NO') {
            $comment_body = '<em>' . $comment_body . '</em>';
            $row['msg_author'] = $row['msg_author'];
        }
        $ip = $row['msg_hdr_ip'];
        if ($row['msg_hdr_ip'] != $row['msg_raw_ip']) {
            $ip .= ' [' . $row['msg_raw_ip'] . ']';
        }
        $params = array('{EDIT}' => &$comment_edit_box, '{BUTTONS}' => &$comment_buttons, '{IPINFO}' => &$comment_ipinfo, '{PENDING_APPROVAL}' => &$pending_approval);
        $template = template_eval($template_image_comments, $params);
        if ($row['author_id'] == 0) {
            $profile_lnk = stripslashes($row['msg_author']);
        } else {
            $profile_lnk = '<a href="profile.php?uid=' . $row['author_id'] . '">' . stripslashes($row['msg_author']) . '</a>';
        }
        $params = array('{MSG_AUTHOR_LNK}' => $profile_lnk, '{MSG_AUTHOR}' => $row['msg_author'], '{MSG_ID}' => $row['msg_id'], '{PID}' => $row['pid'], '{EDIT_TITLE}' => &$lang_display_comments['edit_title'], '{DELETE_TITLE}' => &$lang_display_comments['delete_title'], '{CONFIRM_DELETE}' => &$lang_display_comments['confirm_delete'], '{MSG_DATE}' => localised_date($row['msg_date'], $comment_date_fmt), '{MSG_BODY}' => bb_decode($comment_body), '{MSG_BODY_RAW}' => $row['msg_body'], '{OK}' => &$lang_display_comments['OK'], '{SMILIES}' => $smilies, '{IP}' => $ip, '{REPORT_COMMENT_TITLE}' => &$lang_display_comments['report_comment_title'], '{WIDTH}' => $CONFIG['picture_table_width']);
        if ($hide_comment != 1) {
            $html .= template_eval($template, $params);
        }
    }
    // while-loop end
    if (USER_CAN_POST_COMMENTS && $CURRENT_ALBUM_DATA['comments'] == 'YES') {
        if (USER_ID) {
            $user_name_input = '<tr><td><input type="hidden" name="msg_author" value="' . stripslashes(USER_NAME) . '" /></td>';
            template_extract_block($template_add_your_comment, 'user_name_input', $user_name_input);
            $user_name = '';
        } else {
            $user_name = isset($USER['name']) ? '"' . strtr($USER['name'], $HTML_SUBST) . '"' : $lang_display_comments['your_name'] . '" onclick="javascript:this.value=\'\';';
        }
        if ($CONFIG['comment_captcha'] == 0 || $CONFIG['comment_captcha'] == 1 && USER_ID) {
            template_extract_block($template_add_your_comment, 'comment_captcha');
        }
        $params = array('{ADD_YOUR_COMMENT}' => $lang_display_comments['add_your_comment'], '{NAME}' => $lang_display_comments['name'], '{COMMENT}' => $lang_display_comments['comment'], '{CONFIRM}' => $lang_common['confirm'] . '&nbsp;' . cpg_display_help('f=empty.htm&amp;base=64&amp;h=' . urlencode(base64_encode(serialize($lang_common['captcha_help_title']))) . '&amp;t=' . urlencode(base64_encode(serialize($lang_common['captcha_help']))), 470, 245), '{PIC_ID}' => $pid, '{USER_NAME}' => $user_name, '{MAX_COM_LENGTH}' => $CONFIG['max_com_size'], '{OK}' => $lang_display_comments['OK'], '{SMILIES}' => '', '{WIDTH}' => $CONFIG['picture_table_width']);
        if ($CONFIG['enable_smilies']) {
            $params['{SMILIES}'] = generate_smilies();
        } else {
            template_extract_block($template_add_your_comment, 'smilies');
        }
        template_extract_block($template_add_your_comment, 'login_to_comment');
        $html .= template_eval($template_add_your_comment, $params);
    } else {
        // user can not post comments
        if ($CONFIG['comment_promote_registration'] == 1 && $CURRENT_ALBUM_DATA['comments'] == 'YES') {
            template_extract_block($template_add_your_comment, 'user_name_input');
            template_extract_block($template_add_your_comment, 'input_box_smilies');
            template_extract_block($template_add_your_comment, 'comment_captcha');
            template_extract_block($template_add_your_comment, 'smilies');
            template_extract_block($template_add_your_comment, 'submit');
            $params = array('{ADD_YOUR_COMMENT}' => $lang_display_comments['add_your_comment'], '{WIDTH}' => $CONFIG['picture_table_width'], '{LOGIN_TO_COMMENT}' => sprintf($lang_display_comments['log_in_to_comment'], '<a href="login.php?referer=' . $REFERER . '">', '</a>'));
            $html .= template_eval($template_add_your_comment, $params);
        }
    }
    return $html;
}
コード例 #9
0
ファイル: ucp_profile.php プロジェクト: hgchen/phpbb
    function main($id, $mode)
    {
        global $cache, $config, $db, $user, $auth, $template, $phpbb_root_path, $phpEx;
        global $request, $phpbb_container, $phpbb_log, $phpbb_dispatcher;
        $user->add_lang('posting');
        $submit = $request->variable('submit', false, false, \phpbb\request\request_interface::POST);
        $delete = $request->variable('delete', false, false, \phpbb\request\request_interface::POST);
        $error = $data = array();
        $s_hidden_fields = '';
        switch ($mode) {
            case 'reg_details':
                $data = array('username' => $request->variable('username', $user->data['username'], true), 'email' => strtolower($request->variable('email', $user->data['user_email'])), 'new_password' => $request->variable('new_password', '', true), 'cur_password' => $request->variable('cur_password', '', true), 'password_confirm' => $request->variable('password_confirm', '', true));
                /**
                 * Modify user registration data on editing account settings in UCP
                 *
                 * @event core.ucp_profile_reg_details_data
                 * @var	array	data		Array with current or updated user registration data
                 * @var	bool	submit		Flag indicating if submit button has been pressed
                 * @since 3.1.4-RC1
                 */
                $vars = array('data', 'submit');
                extract($phpbb_dispatcher->trigger_event('core.ucp_profile_reg_details_data', compact($vars)));
                add_form_key('ucp_reg_details');
                if ($submit) {
                    // Do not check cur_password, it is the old one.
                    $check_ary = array('new_password' => array(array('string', true, $config['min_pass_chars'], $config['max_pass_chars']), array('password')), 'password_confirm' => array('string', true, $config['min_pass_chars'], $config['max_pass_chars']), 'email' => array(array('string', false, 6, 60), array('user_email')));
                    if ($auth->acl_get('u_chgname') && $config['allow_namechange']) {
                        $check_ary['username'] = array(array('string', false, $config['min_name_chars'], $config['max_name_chars']), array('username'));
                    }
                    $error = validate_data($data, $check_ary);
                    if ($auth->acl_get('u_chgpasswd') && $data['new_password'] && $data['password_confirm'] != $data['new_password']) {
                        $error[] = $data['password_confirm'] ? 'NEW_PASSWORD_ERROR' : 'NEW_PASSWORD_CONFIRM_EMPTY';
                    }
                    // Instantiate passwords manager
                    /* @var $passwords_manager \phpbb\passwords\manager */
                    $passwords_manager = $phpbb_container->get('passwords.manager');
                    // Only check the new password against the previous password if there have been no errors
                    if (!sizeof($error) && $auth->acl_get('u_chgpasswd') && $data['new_password'] && $passwords_manager->check($data['new_password'], $user->data['user_password'])) {
                        $error[] = 'SAME_PASSWORD_ERROR';
                    }
                    if (!$passwords_manager->check($data['cur_password'], $user->data['user_password'])) {
                        $error[] = $data['cur_password'] ? 'CUR_PASSWORD_ERROR' : 'CUR_PASSWORD_EMPTY';
                    }
                    if (!check_form_key('ucp_reg_details')) {
                        $error[] = 'FORM_INVALID';
                    }
                    /**
                     * Validate user data on editing registration data in UCP
                     *
                     * @event core.ucp_profile_reg_details_validate
                     * @var	array	data			Array with user profile data
                     * @var	bool	submit			Flag indicating if submit button has been pressed
                     * @var array	error			Array of any generated errors
                     * @since 3.1.4-RC1
                     */
                    $vars = array('data', 'submit', 'error');
                    extract($phpbb_dispatcher->trigger_event('core.ucp_profile_reg_details_validate', compact($vars)));
                    if (!sizeof($error)) {
                        $sql_ary = array('username' => $auth->acl_get('u_chgname') && $config['allow_namechange'] ? $data['username'] : $user->data['username'], 'username_clean' => $auth->acl_get('u_chgname') && $config['allow_namechange'] ? utf8_clean_string($data['username']) : $user->data['username_clean'], 'user_email' => $auth->acl_get('u_chgemail') ? $data['email'] : $user->data['user_email'], 'user_email_hash' => $auth->acl_get('u_chgemail') ? phpbb_email_hash($data['email']) : $user->data['user_email_hash'], 'user_password' => $auth->acl_get('u_chgpasswd') && $data['new_password'] ? $passwords_manager->hash($data['new_password']) : $user->data['user_password'], 'user_passchg' => $auth->acl_get('u_chgpasswd') && $data['new_password'] ? time() : 0);
                        if ($auth->acl_get('u_chgname') && $config['allow_namechange'] && $data['username'] != $user->data['username']) {
                            $phpbb_log->add('user', $user->data['user_id'], $user->ip, 'LOG_USER_UPDATE_NAME', false, array('reportee_id' => $user->data['user_id'], $user->data['username'], $data['username']));
                        }
                        if ($auth->acl_get('u_chgpasswd') && $data['new_password'] && !$passwords_manager->check($data['new_password'], $user->data['user_password'])) {
                            $user->reset_login_keys();
                            $phpbb_log->add('user', $user->data['user_id'], $user->ip, 'LOG_USER_NEW_PASSWORD', false, array('reportee_id' => $user->data['user_id'], $user->data['username']));
                        }
                        if ($auth->acl_get('u_chgemail') && $data['email'] != $user->data['user_email']) {
                            $phpbb_log->add('user', $user->data['user_id'], $user->ip, 'LOG_USER_UPDATE_EMAIL', false, array('reportee_id' => $user->data['user_id'], $user->data['username'], $data['user_email'], $data['email']));
                        }
                        $message = 'PROFILE_UPDATED';
                        if ($auth->acl_get('u_chgemail') && $config['email_enable'] && $data['email'] != $user->data['user_email'] && $user->data['user_type'] != USER_FOUNDER && ($config['require_activation'] == USER_ACTIVATION_SELF || $config['require_activation'] == USER_ACTIVATION_ADMIN)) {
                            $message = $config['require_activation'] == USER_ACTIVATION_SELF ? 'ACCOUNT_EMAIL_CHANGED' : 'ACCOUNT_EMAIL_CHANGED_ADMIN';
                            include_once $phpbb_root_path . 'includes/functions_messenger.' . $phpEx;
                            $server_url = generate_board_url();
                            $user_actkey = gen_rand_string(mt_rand(6, 10));
                            $messenger = new messenger(false);
                            $template_file = $config['require_activation'] == USER_ACTIVATION_ADMIN ? 'user_activate_inactive' : 'user_activate';
                            $messenger->template($template_file, $user->data['user_lang']);
                            $messenger->to($data['email'], $data['username']);
                            $messenger->anti_abuse_headers($config, $user);
                            $messenger->assign_vars(array('USERNAME' => htmlspecialchars_decode($data['username']), 'U_ACTIVATE' => "{$server_url}/ucp.{$phpEx}?mode=activate&u={$user->data['user_id']}&k={$user_actkey}"));
                            $messenger->send(NOTIFY_EMAIL);
                            if ($config['require_activation'] == USER_ACTIVATION_ADMIN) {
                                // Grab an array of user_id's with a_user permissions ... these users can activate a user
                                $admin_ary = $auth->acl_get_list(false, 'a_user', false);
                                $admin_ary = !empty($admin_ary[0]['a_user']) ? $admin_ary[0]['a_user'] : array();
                                // Also include founders
                                $where_sql = ' WHERE user_type = ' . USER_FOUNDER;
                                if (sizeof($admin_ary)) {
                                    $where_sql .= ' OR ' . $db->sql_in_set('user_id', $admin_ary);
                                }
                                $sql = 'SELECT user_id, username, user_email, user_lang, user_jabber, user_notify_type
									FROM ' . USERS_TABLE . ' ' . $where_sql;
                                $result = $db->sql_query($sql);
                                while ($row = $db->sql_fetchrow($result)) {
                                    $messenger->template('admin_activate', $row['user_lang']);
                                    $messenger->set_addresses($row);
                                    $messenger->assign_vars(array('USERNAME' => htmlspecialchars_decode($data['username']), 'U_USER_DETAILS' => "{$server_url}/memberlist.{$phpEx}?mode=viewprofile&u={$user->data['user_id']}", 'U_ACTIVATE' => "{$server_url}/ucp.{$phpEx}?mode=activate&u={$user->data['user_id']}&k={$user_actkey}"));
                                    $messenger->send($row['user_notify_type']);
                                }
                                $db->sql_freeresult($result);
                            }
                            user_active_flip('deactivate', $user->data['user_id'], INACTIVE_PROFILE);
                            // Because we want the profile to be reactivated we set user_newpasswd to empty (else the reactivation will fail)
                            $sql_ary['user_actkey'] = $user_actkey;
                            $sql_ary['user_newpasswd'] = '';
                        }
                        /**
                         * Modify user registration data before submitting it to the database
                         *
                         * @event core.ucp_profile_reg_details_sql_ary
                         * @var	array	data		Array with current or updated user registration data
                         * @var	array	sql_ary		Array with user registration data to submit to the database
                         * @since 3.1.4-RC1
                         */
                        $vars = array('data', 'sql_ary');
                        extract($phpbb_dispatcher->trigger_event('core.ucp_profile_reg_details_sql_ary', compact($vars)));
                        if (sizeof($sql_ary)) {
                            $sql = 'UPDATE ' . USERS_TABLE . '
								SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '
								WHERE user_id = ' . $user->data['user_id'];
                            $db->sql_query($sql);
                        }
                        // Need to update config, forum, topic, posting, messages, etc.
                        if ($data['username'] != $user->data['username'] && $auth->acl_get('u_chgname') && $config['allow_namechange']) {
                            user_update_name($user->data['username'], $data['username']);
                        }
                        // Now, we can remove the user completely (kill the session) - NOT BEFORE!!!
                        if (!empty($sql_ary['user_actkey'])) {
                            meta_refresh(5, append_sid($phpbb_root_path . 'index.' . $phpEx));
                            $message = $user->lang[$message] . '<br /><br />' . sprintf($user->lang['RETURN_INDEX'], '<a href="' . append_sid($phpbb_root_path . 'index.' . $phpEx) . '">', '</a>');
                            // Because the user gets deactivated we log him out too, killing his session
                            $user->session_kill();
                        } else {
                            meta_refresh(3, $this->u_action);
                            $message = $user->lang[$message] . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], '<a href="' . $this->u_action . '">', '</a>');
                        }
                        trigger_error($message);
                    }
                    // Replace "error" strings with their real, localised form
                    $error = array_map(array($user, 'lang'), $error);
                }
                $template->assign_vars(array('ERROR' => sizeof($error) ? implode('<br />', $error) : '', 'USERNAME' => $data['username'], 'EMAIL' => $data['email'], 'PASSWORD_CONFIRM' => $data['password_confirm'], 'NEW_PASSWORD' => $data['new_password'], 'CUR_PASSWORD' => '', 'L_USERNAME_EXPLAIN' => $user->lang($config['allow_name_chars'] . '_EXPLAIN', $user->lang('CHARACTERS', (int) $config['min_name_chars']), $user->lang('CHARACTERS', (int) $config['max_name_chars'])), 'L_CHANGE_PASSWORD_EXPLAIN' => $user->lang($config['pass_complex'] . '_EXPLAIN', $user->lang('CHARACTERS', (int) $config['min_pass_chars']), $user->lang('CHARACTERS', (int) $config['max_pass_chars'])), 'S_FORCE_PASSWORD' => $auth->acl_get('u_chgpasswd') && $config['chg_passforce'] && $user->data['user_passchg'] < time() - $config['chg_passforce'] * 86400 ? true : false, 'S_CHANGE_USERNAME' => $config['allow_namechange'] && $auth->acl_get('u_chgname') ? true : false, 'S_CHANGE_EMAIL' => $auth->acl_get('u_chgemail') ? true : false, 'S_CHANGE_PASSWORD' => $auth->acl_get('u_chgpasswd') ? true : false));
                break;
            case 'profile_info':
                // Do not display profile information panel if not authed to do so
                if (!$auth->acl_get('u_chgprofileinfo')) {
                    trigger_error('NO_AUTH_PROFILEINFO');
                }
                /* @var $cp \phpbb\profilefields\manager */
                $cp = $phpbb_container->get('profilefields.manager');
                $cp_data = $cp_error = array();
                $data = array('jabber' => $request->variable('jabber', $user->data['user_jabber'], true));
                if ($config['allow_birthdays']) {
                    $data['bday_day'] = $data['bday_month'] = $data['bday_year'] = 0;
                    if ($user->data['user_birthday']) {
                        list($data['bday_day'], $data['bday_month'], $data['bday_year']) = explode('-', $user->data['user_birthday']);
                    }
                    $data['bday_day'] = $request->variable('bday_day', $data['bday_day']);
                    $data['bday_month'] = $request->variable('bday_month', $data['bday_month']);
                    $data['bday_year'] = $request->variable('bday_year', $data['bday_year']);
                    $data['user_birthday'] = sprintf('%2d-%2d-%4d', $data['bday_day'], $data['bday_month'], $data['bday_year']);
                }
                /**
                 * Modify user data on editing profile in UCP
                 *
                 * @event core.ucp_profile_modify_profile_info
                 * @var	array	data		Array with user profile data
                 * @var	bool	submit		Flag indicating if submit button has been pressed
                 * @since 3.1.4-RC1
                 */
                $vars = array('data', 'submit');
                extract($phpbb_dispatcher->trigger_event('core.ucp_profile_modify_profile_info', compact($vars)));
                add_form_key('ucp_profile_info');
                if ($submit) {
                    $validate_array = array('jabber' => array(array('string', true, 5, 255), array('jabber')));
                    if ($config['allow_birthdays']) {
                        $validate_array = array_merge($validate_array, array('bday_day' => array('num', true, 1, 31), 'bday_month' => array('num', true, 1, 12), 'bday_year' => array('num', true, 1901, gmdate('Y', time()) + 50), 'user_birthday' => array('date', true)));
                    }
                    $error = validate_data($data, $validate_array);
                    // validate custom profile fields
                    $cp->submit_cp_field('profile', $user->get_iso_lang_id(), $cp_data, $cp_error);
                    if (sizeof($cp_error)) {
                        $error = array_merge($error, $cp_error);
                    }
                    if (!check_form_key('ucp_profile_info')) {
                        $error[] = 'FORM_INVALID';
                    }
                    /**
                     * Validate user data on editing profile in UCP
                     *
                     * @event core.ucp_profile_validate_profile_info
                     * @var	array	data			Array with user profile data
                     * @var	bool	submit			Flag indicating if submit button has been pressed
                     * @var array	error			Array of any generated errors
                     * @since 3.1.4-RC1
                     */
                    $vars = array('data', 'submit', 'error');
                    extract($phpbb_dispatcher->trigger_event('core.ucp_profile_validate_profile_info', compact($vars)));
                    if (!sizeof($error)) {
                        $data['notify'] = $user->data['user_notify_type'];
                        if ($data['notify'] == NOTIFY_IM && (!$config['jab_enable'] || !$data['jabber'] || !@extension_loaded('xml'))) {
                            // User has not filled in a jabber address (Or one of the modules is disabled or jabber is disabled)
                            // Disable notify by Jabber now for this user.
                            $data['notify'] = NOTIFY_EMAIL;
                        }
                        $sql_ary = array('user_jabber' => $data['jabber'], 'user_notify_type' => $data['notify']);
                        if ($config['allow_birthdays']) {
                            $sql_ary['user_birthday'] = $data['user_birthday'];
                        }
                        /**
                         * Modify profile data in UCP before submitting to the database
                         *
                         * @event core.ucp_profile_info_modify_sql_ary
                         * @var	array	cp_data		Array with the user custom profile fields data
                         * @var	array	data		Array with user profile data
                         * @var  array	sql_ary		user options data we update
                         * @since 3.1.4-RC1
                         */
                        $vars = array('cp_data', 'data', 'sql_ary');
                        extract($phpbb_dispatcher->trigger_event('core.ucp_profile_info_modify_sql_ary', compact($vars)));
                        $sql = 'UPDATE ' . USERS_TABLE . '
							SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '
							WHERE user_id = ' . $user->data['user_id'];
                        $db->sql_query($sql);
                        // Update Custom Fields
                        $cp->update_profile_field_data($user->data['user_id'], $cp_data);
                        meta_refresh(3, $this->u_action);
                        $message = $user->lang['PROFILE_UPDATED'] . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], '<a href="' . $this->u_action . '">', '</a>');
                        trigger_error($message);
                    }
                    // Replace "error" strings with their real, localised form
                    $error = array_map(array($user, 'lang'), $error);
                }
                if ($config['allow_birthdays']) {
                    $s_birthday_day_options = '<option value="0"' . (!$data['bday_day'] ? ' selected="selected"' : '') . '>--</option>';
                    for ($i = 1; $i < 32; $i++) {
                        $selected = $i == $data['bday_day'] ? ' selected="selected"' : '';
                        $s_birthday_day_options .= "<option value=\"{$i}\"{$selected}>{$i}</option>";
                    }
                    $s_birthday_month_options = '<option value="0"' . (!$data['bday_month'] ? ' selected="selected"' : '') . '>--</option>';
                    for ($i = 1; $i < 13; $i++) {
                        $selected = $i == $data['bday_month'] ? ' selected="selected"' : '';
                        $s_birthday_month_options .= "<option value=\"{$i}\"{$selected}>{$i}</option>";
                    }
                    $s_birthday_year_options = '';
                    $now = getdate();
                    $s_birthday_year_options = '<option value="0"' . (!$data['bday_year'] ? ' selected="selected"' : '') . '>--</option>';
                    for ($i = $now['year'] - 100; $i <= $now['year']; $i++) {
                        $selected = $i == $data['bday_year'] ? ' selected="selected"' : '';
                        $s_birthday_year_options .= "<option value=\"{$i}\"{$selected}>{$i}</option>";
                    }
                    unset($now);
                    $template->assign_vars(array('S_BIRTHDAY_DAY_OPTIONS' => $s_birthday_day_options, 'S_BIRTHDAY_MONTH_OPTIONS' => $s_birthday_month_options, 'S_BIRTHDAY_YEAR_OPTIONS' => $s_birthday_year_options, 'S_BIRTHDAYS_ENABLED' => true));
                }
                $template->assign_vars(array('ERROR' => sizeof($error) ? implode('<br />', $error) : '', 'S_JABBER_ENABLED' => $config['jab_enable'], 'JABBER' => $data['jabber']));
                // Get additional profile fields and assign them to the template block var 'profile_fields'
                $user->get_profile_fields($user->data['user_id']);
                $cp->generate_profile_fields('profile', $user->get_iso_lang_id());
                break;
            case 'signature':
                if (!$auth->acl_get('u_sig')) {
                    trigger_error('NO_AUTH_SIGNATURE');
                }
                include $phpbb_root_path . 'includes/functions_posting.' . $phpEx;
                include $phpbb_root_path . 'includes/functions_display.' . $phpEx;
                $enable_bbcode = $config['allow_sig_bbcode'] ? $user->optionget('sig_bbcode') : false;
                $enable_smilies = $config['allow_sig_smilies'] ? $user->optionget('sig_smilies') : false;
                $enable_urls = $config['allow_sig_links'] ? $user->optionget('sig_links') : false;
                $decoded_message = generate_text_for_edit($user->data['user_sig'], $user->data['user_sig_bbcode_uid'], $user->data['user_sig_bbcode_bitfield']);
                $signature = $request->variable('signature', $decoded_message['text'], true);
                $signature_preview = '';
                if ($submit || $request->is_set_post('preview')) {
                    $enable_bbcode = $config['allow_sig_bbcode'] ? !$request->variable('disable_bbcode', false) : false;
                    $enable_smilies = $config['allow_sig_smilies'] ? !$request->variable('disable_smilies', false) : false;
                    $enable_urls = $config['allow_sig_links'] ? !$request->variable('disable_magic_url', false) : false;
                    if (!check_form_key('ucp_sig')) {
                        $error[] = 'FORM_INVALID';
                    }
                }
                $bbcode_uid = $bbcode_bitfield = $bbcode_flags = '';
                $warn_msg = generate_text_for_storage($signature, $bbcode_uid, $bbcode_bitfield, $bbcode_flags, $enable_bbcode, $enable_urls, $enable_smilies);
                if (sizeof($warn_msg)) {
                    $error += $warn_msg;
                }
                if (!$submit) {
                    // Parse it for displaying
                    $signature_preview = generate_text_for_display($signature, $bbcode_uid, $bbcode_bitfield, $bbcode_flags);
                } else {
                    if (!sizeof($error)) {
                        $user->optionset('sig_bbcode', $enable_bbcode);
                        $user->optionset('sig_smilies', $enable_smilies);
                        $user->optionset('sig_links', $enable_urls);
                        $sql_ary = array('user_sig' => $signature, 'user_options' => $user->data['user_options'], 'user_sig_bbcode_uid' => $bbcode_uid, 'user_sig_bbcode_bitfield' => $bbcode_bitfield);
                        $sql = 'UPDATE ' . USERS_TABLE . '
							SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '
							WHERE user_id = ' . $user->data['user_id'];
                        $db->sql_query($sql);
                        $message = $user->lang['PROFILE_UPDATED'] . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], '<a href="' . $this->u_action . '">', '</a>');
                        trigger_error($message);
                    }
                }
                // Replace "error" strings with their real, localised form
                $error = array_map(array($user, 'lang'), $error);
                $decoded_message = generate_text_for_edit($signature, $bbcode_uid, $bbcode_bitfield);
                /** @var \phpbb\controller\helper $controller_helper */
                $controller_helper = $phpbb_container->get('controller.helper');
                $template->assign_vars(array('ERROR' => sizeof($error) ? implode('<br />', $error) : '', 'SIGNATURE' => $decoded_message['text'], 'SIGNATURE_PREVIEW' => $signature_preview, 'S_BBCODE_CHECKED' => !$enable_bbcode ? ' checked="checked"' : '', 'S_SMILIES_CHECKED' => !$enable_smilies ? ' checked="checked"' : '', 'S_MAGIC_URL_CHECKED' => !$enable_urls ? ' checked="checked"' : '', 'BBCODE_STATUS' => $user->lang($config['allow_sig_bbcode'] ? 'BBCODE_IS_ON' : 'BBCODE_IS_OFF', '<a href="' . $controller_helper->route('phpbb_help_bbcode_controller') . '">', '</a>'), 'SMILIES_STATUS' => $config['allow_sig_smilies'] ? $user->lang['SMILIES_ARE_ON'] : $user->lang['SMILIES_ARE_OFF'], 'IMG_STATUS' => $config['allow_sig_img'] ? $user->lang['IMAGES_ARE_ON'] : $user->lang['IMAGES_ARE_OFF'], 'FLASH_STATUS' => $config['allow_sig_flash'] ? $user->lang['FLASH_IS_ON'] : $user->lang['FLASH_IS_OFF'], 'URL_STATUS' => $config['allow_sig_links'] ? $user->lang['URL_IS_ON'] : $user->lang['URL_IS_OFF'], 'MAX_FONT_SIZE' => (int) $config['max_sig_font_size'], 'L_SIGNATURE_EXPLAIN' => $user->lang('SIGNATURE_EXPLAIN', (int) $config['max_sig_chars']), 'S_BBCODE_ALLOWED' => $config['allow_sig_bbcode'], 'S_SMILIES_ALLOWED' => $config['allow_sig_smilies'], 'S_BBCODE_IMG' => $config['allow_sig_img'] ? true : false, 'S_BBCODE_FLASH' => $config['allow_sig_flash'] ? true : false, 'S_LINKS_ALLOWED' => $config['allow_sig_links'] ? true : false));
                add_form_key('ucp_sig');
                // Build custom bbcodes array
                display_custom_bbcodes();
                // Generate smiley listing
                generate_smilies('inline', 0);
                break;
            case 'avatar':
                add_form_key('ucp_avatar');
                $avatars_enabled = false;
                if ($config['allow_avatar'] && $auth->acl_get('u_chgavatar')) {
                    /* @var $phpbb_avatar_manager \phpbb\avatar\manager */
                    $phpbb_avatar_manager = $phpbb_container->get('avatar.manager');
                    $avatar_drivers = $phpbb_avatar_manager->get_enabled_drivers();
                    // This is normalised data, without the user_ prefix
                    $avatar_data = \phpbb\avatar\manager::clean_row($user->data, 'user');
                    if ($submit) {
                        if (check_form_key('ucp_avatar')) {
                            $driver_name = $phpbb_avatar_manager->clean_driver_name($request->variable('avatar_driver', ''));
                            if (in_array($driver_name, $avatar_drivers) && !$request->is_set_post('avatar_delete')) {
                                $driver = $phpbb_avatar_manager->get_driver($driver_name);
                                $result = $driver->process_form($request, $template, $user, $avatar_data, $error);
                                if ($result && empty($error)) {
                                    // Success! Lets save the result in the database
                                    $result = array('user_avatar_type' => $driver_name, 'user_avatar' => $result['avatar'], 'user_avatar_width' => $result['avatar_width'], 'user_avatar_height' => $result['avatar_height']);
                                    $sql = 'UPDATE ' . USERS_TABLE . '
										SET ' . $db->sql_build_array('UPDATE', $result) . '
										WHERE user_id = ' . (int) $user->data['user_id'];
                                    $db->sql_query($sql);
                                    meta_refresh(3, $this->u_action);
                                    $message = $user->lang['PROFILE_UPDATED'] . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], '<a href="' . $this->u_action . '">', '</a>');
                                    trigger_error($message);
                                }
                            }
                        } else {
                            $error[] = 'FORM_INVALID';
                        }
                    }
                    // Handle deletion of avatars
                    if ($request->is_set_post('avatar_delete')) {
                        if (!confirm_box(true)) {
                            confirm_box(false, $user->lang('CONFIRM_AVATAR_DELETE'), build_hidden_fields(array('avatar_delete' => true, 'i' => $id, 'mode' => $mode)));
                        } else {
                            $phpbb_avatar_manager->handle_avatar_delete($db, $user, $avatar_data, USERS_TABLE, 'user_');
                            meta_refresh(3, $this->u_action);
                            $message = $user->lang['PROFILE_UPDATED'] . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], '<a href="' . $this->u_action . '">', '</a>');
                            trigger_error($message);
                        }
                    }
                    $selected_driver = $phpbb_avatar_manager->clean_driver_name($request->variable('avatar_driver', $user->data['user_avatar_type']));
                    foreach ($avatar_drivers as $current_driver) {
                        $driver = $phpbb_avatar_manager->get_driver($current_driver);
                        $avatars_enabled = true;
                        $template->set_filenames(array('avatar' => $driver->get_template_name()));
                        if ($driver->prepare_form($request, $template, $user, $avatar_data, $error)) {
                            $driver_name = $phpbb_avatar_manager->prepare_driver_name($current_driver);
                            $driver_upper = strtoupper($driver_name);
                            $template->assign_block_vars('avatar_drivers', array('L_TITLE' => $user->lang($driver_upper . '_TITLE'), 'L_EXPLAIN' => $user->lang($driver_upper . '_EXPLAIN'), 'DRIVER' => $driver_name, 'SELECTED' => $current_driver == $selected_driver, 'OUTPUT' => $template->assign_display('avatar')));
                        }
                    }
                    // Replace "error" strings with their real, localised form
                    $error = $phpbb_avatar_manager->localize_errors($user, $error);
                }
                $avatar = phpbb_get_user_avatar($user->data, 'USER_AVATAR', true);
                $template->assign_vars(array('ERROR' => sizeof($error) ? implode('<br />', $error) : '', 'AVATAR' => $avatar, 'S_FORM_ENCTYPE' => ' enctype="multipart/form-data"', 'L_AVATAR_EXPLAIN' => phpbb_avatar_explanation_string(), 'S_AVATARS_ENABLED' => $config['allow_avatar'] && $avatars_enabled));
                break;
            case 'autologin_keys':
                add_form_key('ucp_autologin_keys');
                if ($submit) {
                    $keys = $request->variable('keys', array(''));
                    if (!check_form_key('ucp_autologin_keys')) {
                        $error[] = 'FORM_INVALID';
                    }
                    if (!sizeof($error)) {
                        if (!empty($keys)) {
                            foreach ($keys as $key => $id) {
                                $keys[$key] = $db->sql_like_expression($id . $db->get_any_char());
                            }
                            $sql_where = '(key_id ' . implode(' OR key_id ', $keys) . ')';
                            $sql = 'DELETE FROM ' . SESSIONS_KEYS_TABLE . '
								WHERE user_id = ' . (int) $user->data['user_id'] . '
								AND ' . $sql_where;
                            $db->sql_query($sql);
                            meta_refresh(3, $this->u_action);
                            $message = $user->lang['AUTOLOGIN_SESSION_KEYS_DELETED'] . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], '<a href="' . $this->u_action . '">', '</a>');
                            trigger_error($message);
                        }
                    }
                    // Replace "error" strings with their real, localised form
                    $error = array_map(array($user, 'lang'), $error);
                }
                $sql = 'SELECT key_id, last_ip, last_login
					FROM ' . SESSIONS_KEYS_TABLE . '
					WHERE user_id = ' . (int) $user->data['user_id'] . '
					ORDER BY last_login ASC';
                $result = $db->sql_query($sql);
                while ($row = $db->sql_fetchrow($result)) {
                    $template->assign_block_vars('sessions', array('KEY' => substr($row['key_id'], 0, 8), 'IP' => $row['last_ip'], 'LOGIN_TIME' => $user->format_date($row['last_login'])));
                }
                $db->sql_freeresult($result);
                break;
        }
        $template->assign_vars(array('ERROR' => sizeof($error) ? implode('<br />', $error) : '', 'L_TITLE' => $user->lang['UCP_PROFILE_' . strtoupper($mode)], 'S_HIDDEN_FIELDS' => $s_hidden_fields, 'S_UCP_ACTION' => $this->u_action));
        // Set desired template
        $this->tpl_name = 'ucp_profile_' . $mode;
        $this->page_title = 'UCP_PROFILE_' . strtoupper($mode);
    }
コード例 #10
0
 /**
  * Populate form when an error occurred
  *
  * @param	int		$link_id		The link ID
  * @param	string	$mode			add|edit
  * @return	null
  */
 private function _populate_form($link_id, $mode)
 {
     if (!$this->user->data['is_registered'] && $this->config['dir_visual_confirm'] && $mode != 'edit') {
         $this->s_hidden_fields = array_merge($this->s_hidden_fields, $this->captcha->get_hidden_fields());
         $this->template->assign_vars(array('S_CONFIRM_CODE' => true, 'CAPTCHA_TEMPLATE' => $this->captcha->get_template()));
     }
     if (!function_exists('generate_smilies')) {
         include $this->root_path . 'includes/functions_posting.' . $this->php_ext;
     }
     if (!function_exists('display_custom_bbcodes')) {
         include $this->root_path . 'includes/functions_display.' . $this->php_ext;
     }
     generate_smilies('inline', 0);
     display_custom_bbcodes();
     add_form_key('dir_form_comment');
     $this->template->assign_vars(array('S_AUTH_COMM' => $this->auth->acl_get('u_comment_dir'), 'BBCODE_STATUS' => $this->config['dir_allow_bbcode'] ? $this->user->lang('BBCODE_IS_ON', '<a href="' . append_sid($this->root_path . "faq.{$this->php_ext}", 'mode=bbcode') . '">', '</a>') : $this->user->lang('BBCODE_IS_OFF', '<a href="' . append_sid($this->root_path . "faq.{$this->php_ext}", 'mode=bbcode') . '">', '</a>'), 'IMG_STATUS' => $this->config['dir_allow_bbcode'] ? $this->user->lang['IMAGES_ARE_ON'] : $this->user->lang['IMAGES_ARE_OFF'], 'SMILIES_STATUS' => $this->config['dir_allow_smilies'] ? $this->user->lang['SMILIES_ARE_ON'] : $this->user->lang['SMILIES_ARE_OFF'], 'URL_STATUS' => $this->config['dir_allow_links'] ? $this->user->lang['URL_IS_ON'] : $this->user->lang['URL_IS_OFF'], 'FLASH_STATUS' => $this->config['dir_allow_bbcode'] && $this->config['dir_allow_flash'] ? $this->user->lang['FLASH_IS_ON'] : $this->user->lang['FLASH_IS_OFF'], 'L_DIR_REPLY_EXP' => $this->user->lang('DIR_REPLY_EXP', $this->config['dir_length_comments']), 'S_COMMENT' => isset($this->s_comment) ? $this->s_comment : '', 'S_BBCODE_ALLOWED' => (bool) $this->config['dir_allow_bbcode'], 'S_BBCODE_IMG' => (bool) $this->config['dir_allow_bbcode'], 'S_BBCODE_FLASH' => $this->config['dir_allow_bbcode'] && $this->config['dir_allow_flash'] ? true : false, 'S_BBCODE_QUOTE' => true, 'S_LINKS_ALLOWED' => (bool) $this->config['dir_allow_links'], 'S_SMILIES_ALLOWED' => (bool) $this->config['dir_allow_smilies'], 'S_HIDDEN_FIELDS' => build_hidden_fields($this->s_hidden_fields), 'S_BUTTON_NAME' => $mode == 'edit' ? 'update_comment' : 'submit_comment', 'S_POST_ACTION' => $mode == 'edit' ? '' : $this->helper->route('ernadoo_phpbbdirectory_comment_new_controller', array('link_id' => (int) $link_id))));
 }
コード例 #11
0
ファイル: image.php プロジェクト: vodis/phpbbgallery
    /**
     * Image Controller
     *	Route: gallery/image_id/{image_id}
     *
     * @param int	$image_id	Image ID
     * @return Symfony\Component\HttpFoundation\Response A Symfony Response object
     */
    public function base($image_id, $page = 0)
    {
        $this->user->add_lang_ext('phpbbgallery/core', array('gallery'));
        try {
            $sql = 'SELECT *
			FROM ' . $this->table_images . '
			WHERE image_id = ' . (int) $image_id;
            $result = $this->db->sql_query($sql);
            $this->data = $this->db->sql_fetchrow($result);
            $this->db->sql_freeresult($result);
            if (!$this->data) {
                // Image does not exist
                throw new \OutOfBoundsException('INVALID_IMAGE');
            }
            $this->loader->load($this->data['image_album_id']);
        } catch (\Exception $e) {
            return $this->error($e->getMessage(), 404);
        }
        $album_id = (int) $this->data['image_album_id'];
        $album_data = $this->loader->get($album_id);
        $this->check_permissions($album_id, $album_data['album_user_id'], $this->data['image_status'], $album_data['album_auth_access']);
        $this->display->generate_navigation($album_data);
        if (!$this->user->data['is_bot'] && isset($this->user->data['session_page']) && (strpos($this->user->data['session_page'], '&image_id=' . $image_id) === false || isset($this->user->data['session_created']))) {
            $sql = 'UPDATE ' . $this->table_images . '
				SET image_view_count = image_view_count + 1
				WHERE image_id = ' . $image_id;
            $this->db->sql_query($sql);
        }
        // Do stuff here
        $page_title = $this->data['image_name'];
        if ($page > 1) {
            $page_title .= ' - ' . $this->user->lang('PAGE_TITLE_NUMBER', $page);
        }
        $s_allowed_delete = $s_allowed_edit = $s_allowed_status = false;
        if (($this->gallery_auth->acl_check('m_', $album_id, $album_data['album_user_id']) || $this->data['image_user_id'] == $this->user->data['user_id']) && $this->user->data['user_id'] != ANONYMOUS) {
            //$s_user_allowed = (($this->data['image_user_id'] == $this->user->data['user_id']) && ($album_data['album_status'] != phpbb_ext_gallery_core_album::STATUS_LOCKED));
            $s_user_allowed = $this->data['image_user_id'] == $this->user->data['user_id'] && $album_data['album_status'] != 1;
            $s_allowed_delete = $this->gallery_auth->acl_check('i_delete', $album_id, $album_data['album_user_id']) && $s_user_allowed || $this->gallery_auth->acl_check('m_delete', $album_id, $album_data['album_user_id']);
            $s_allowed_edit = $this->gallery_auth->acl_check('i_edit', $album_id, $album_data['album_user_id']) && $s_user_allowed || $this->gallery_auth->acl_check('m_edit', $album_id, $album_data['album_user_id']);
            $s_quick_mod = $s_allowed_delete || $s_allowed_edit || $this->gallery_auth->acl_check('m_status', $album_id, $album_data['album_user_id']) || $this->gallery_auth->acl_check('m_move', $album_id, $album_data['album_user_id']);
            $this->user->add_lang_ext('phpbbgallery/core', 'gallery_mcp');
            $this->template->assign_vars(array('S_MOD_ACTION' => $this->helper->route('phpbbgallery_moderate_image', array('image_id' => $image_id)), 'S_QUICK_MOD' => $s_quick_mod, 'S_QM_MOVE' => $this->gallery_auth->acl_check('m_move', $album_id, $album_data['album_user_id']), 'S_QM_EDIT' => $s_allowed_edit, 'S_QM_DELETE' => $s_allowed_delete, 'S_QM_REPORT' => $this->gallery_auth->acl_check('m_report', $album_id, $album_data['album_user_id']), 'S_QM_STATUS' => $this->gallery_auth->acl_check('m_status', $album_id, $album_data['album_user_id']), 'S_IMAGE_REPORTED' => $this->data['image_reported'] ? true : false, 'U_IMAGE_REPORTED' => $this->data['image_reported'] ? $this->helper->route('phpbbgallery_moderate_image', array('image_id' => $image_id)) : '', 'S_STATUS_APPROVED' => $this->data['image_status'] == \phpbbgallery\core\image\image::STATUS_APPROVED, 'S_STATUS_UNAPPROVED' => $this->data['image_status'] == \phpbbgallery\core\image\image::STATUS_UNAPPROVED, 'S_STATUS_LOCKED' => $this->data['image_status'] == \phpbbgallery\core\image\image::STATUS_LOCKED));
        }
        $image_desc = generate_text_for_display($this->data['image_desc'], $this->data['image_desc_uid'], $this->data['image_desc_bitfield'], 7);
        // Let's see if we can get next end prev
        $sort_key = $this->request->variable('sk', $album_data['album_sort_key'] ? $album_data['album_sort_key'] : $this->config['phpbb_gallery_default_sort_key']);
        $sort_dir = $this->request->variable('sd', $album_data['album_sort_dir'] ? $album_data['album_sort_dir'] : $this->config['phpbb_gallery_default_sort_dir']);
        if (in_array($sort_key, array('r', 'ra'))) {
            $sql_help_sort = ', image_id ' . ($sort_dir == 'd' ? 'ASC' : 'DESC');
        } else {
            $sql_help_sort = ', image_id ' . ($sort_dir == 'd' ? 'DESC' : 'ASC');
        }
        $limit_days = array();
        $sort_by_text = array('t' => $this->user->lang['TIME'], 'n' => $this->user->lang['IMAGE_NAME'], 'vc' => $this->user->lang['GALLERY_VIEWS'], 'u' => $this->user->lang['SORT_USERNAME']);
        $sort_by_sql = array('t' => 'image_time', 'n' => 'image_name_clean', 'vc' => 'image_view_count', 'u' => 'image_username_clean');
        if ($this->config['phpbb_gallery_allow_rates']) {
            $sort_by_text['ra'] = $this->user->lang['RATING'];
            $sort_by_sql['ra'] = 'image_rate_points';
            $sort_by_text['r'] = $this->user->lang['RATES_COUNT'];
            $sort_by_sql['r'] = 'image_rates';
        }
        if ($this->config['phpbb_gallery_allow_comments']) {
            $sort_by_text['c'] = $this->user->lang['COMMENTS'];
            $sort_by_sql['c'] = 'image_comments';
            $sort_by_text['lc'] = $this->user->lang['NEW_COMMENT'];
            $sort_by_sql['lc'] = 'image_last_comment';
        }
        gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param);
        $sql_sort_order = $sort_by_sql[$sort_key] . ' ' . ($sort_dir == 'd' ? 'DESC' : 'ASC');
        $sql_sort_order .= $sql_help_sort;
        // Let's see if there is prieveus image
        $sql = 'SELECT *
			FROM ' . $this->table_images . '
			WHERE image_album_id = ' . (int) $album_id . "\n\t\t\t\tAND image_status <> 3\n\t\t\tORDER BY {$sql_sort_order}" . $sql_help_sort;
        $result = $this->db->sql_query($sql);
        $images_array = array();
        while ($row = $this->db->sql_fetchrow($result)) {
            $images_array[] = $row;
        }
        $cur = 0;
        foreach ($images_array as $id => $var) {
            if ($var['image_id'] == $image_id) {
                $cur = $id;
            }
        }
        $next = $prev = false;
        if (count($images_array) > $cur + 1) {
            $next = array('image_id' => $images_array[$cur + 1]['image_id'], 'image_name' => $images_array[$cur + 1]['image_name']);
        }
        if ($cur > 0) {
            $prev = array('image_id' => $images_array[$cur - 1]['image_id'], 'image_name' => $images_array[$cur - 1]['image_name']);
        }
        $this->db->sql_freeresult($result);
        $this->template->assign_vars(array('UC_NEXT_IMAGE' => $next ? $this->gallery_config->get('disp_nextprev_thumbnail') ? '<a href="' . $this->helper->route('phpbbgallery_image', array('image_id' => $next['image_id'])) . '"><img style="max-width: 70px; max-height: 70px;" src="' . $this->helper->route('phpbbgallery_image_file_mini', array('image_id' => $next['image_id'])) . '" alt="' . $next['image_name'] . '"></a>' : '<a href="' . $this->helper->route('phpbbgallery_image', array('image_id' => $next['image_id'])) . '">' . $next['image_name'] . ' &raquo;&raquo; </a>' : '', 'UC_PREV_IMAGE' => $prev ? $this->gallery_config->get('disp_nextprev_thumbnail') ? '<a href="' . $this->helper->route('phpbbgallery_image', array('image_id' => $prev['image_id'])) . '"><img style="max-width: 70px; max-height: 70px;" src="' . $this->helper->route('phpbbgallery_image_file_mini', array('image_id' => $prev['image_id'])) . '" alt="' . $prev['image_name'] . '"></a>' : '<a href="' . $this->helper->route('phpbbgallery_image', array('image_id' => $prev['image_id'])) . '">&laquo;&laquo; ' . $prev['image_name'] . '</a>' : '', 'U_VIEW_ALBUM' => $this->helper->route('phpbbgallery_album', array('album_id' => $album_id)), 'UC_IMAGE' => $this->helper->route('phpbbgallery_image_file_medium', array('image_id' => $image_id)), 'U_DELETE' => $s_allowed_delete ? $this->helper->route('phpbbgallery_image_delete', array('image_id' => $image_id)) : '', 'U_EDIT' => $s_allowed_edit ? $this->helper->route('phpbbgallery_image_edit', array('image_id' => $image_id)) : '', 'U_REPORT' => $this->gallery_auth->acl_check('i_report', $album_id, $album_data['album_user_id']) && $this->data['image_user_id'] != $this->user->data['user_id'] ? $this->helper->route('phpbbgallery_image_report', array('image_id' => $image_id)) : '', 'U_STATUS' => $s_allowed_status ? $this->helper->route('phpbbgallery_moderate_image', array('image_id' => $image_id)) : '', 'CONTEST_RANK' => $this->data['image_contest_rank'] ? $this->user->lang('CONTEST_RESULT_' . $this->data['image_contest_rank']) : '', 'IMAGE_NAME' => $this->data['image_name'], 'IMAGE_DESC' => $image_desc, 'IMAGE_BBCODE' => $this->config['allow_bbcode'] ? '[image]' . $image_id . '[/image]' : '', 'IMAGE_IMGURL_BBCODE' => $this->config['phpbb_gallery_disp_image_url'] ? '[url=' . $this->url->get_uri($this->helper->route('phpbbgallery_image', array('image_id' => $image_id))) . '][img]' . $this->url->get_uri($this->helper->route('phpbbgallery_image_file_mini', array('image_id' => $image_id))) . '[/img][/url]' : '', 'IMAGE_URL' => $this->config['phpbb_gallery_disp_image_url'] ? $this->url->get_uri($this->helper->route('phpbbgallery_image', array('image_id' => $image_id))) : '', 'IMAGE_TIME' => $this->user->format_date($this->data['image_time']), 'IMAGE_VIEW' => $this->data['image_view_count'], 'POSTER_IP' => $this->auth->acl_get('a_') ? $this->data['image_user_ip'] : '', 'U_POSTER_WHOIS' => $this->auth->acl_get('a_') ? append_sid('mcp', 'mode=whois&amp;ip=' . $this->data['image_user_ip']) : '', 'S_ALBUM_ACTION' => $this->helper->route('phpbbgallery_image', array('image_id' => $image_id)), 'U_RETURN_LINK' => $this->helper->route('phpbbgallery_album', array('album_id' => $album_id)), 'S_RETURN_LINK' => $this->user->lang('RETURN_TO', $album_data['album_name'])));
        switch ($this->gallery_config->get('link_imagepage')) {
            case 'image':
                $this->template->assign_vars(array('UC_IMAGE_ACTION' => $this->helper->route('phpbbgallery_image_file_source', array('image_id' => $image_id))));
                break;
            case 'next':
                if ($next) {
                    $this->template->assign_vars(array('UC_IMAGE_ACTION' => $this->helper->route('phpbbgallery_image', array('image_id' => $next['image_id']))));
                }
                break;
        }
        $image_data = $this->data;
        /**
         * Event view image
         *
         * @event phpbbgallery.core.viewimage
         * @var	int		image_id		id of the image we are viewing
         * @var	array	image_data		All the data related to the image
         * @var	array	album_data		All the data related to the album image is part of
         * @var	string	page_title		Page title
         * @since 1.2.0
         */
        $vars = array('image_id', 'image_data', 'album_data', 'page_title');
        extract($this->dispatcher->trigger_event('phpbbgallery.core.viewimage', compact($vars)));
        $this->data = $image_data;
        $user_id = $this->data['image_user_id'];
        $sql = $this->db->sql_build_query('SELECT', array('SELECT' => 'u.*, gu.personal_album_id, gu.user_images', 'FROM' => array(USERS_TABLE => 'u'), 'LEFT_JOIN' => array(array('FROM' => array($this->table_users => 'gu'), 'ON' => 'gu.user_id = u.user_id')), 'WHERE' => 'u.user_id = ' . $this->data['image_user_id']));
        $result = $this->db->sql_query($sql);
        $user_cache = array();
        while ($row = $this->db->sql_fetchrow($result)) {
            \phpbbgallery\core\user::add_user_to_cache($user_cache, $row);
        }
        $this->db->sql_freeresult($result);
        $user_cache[$user_id]['username'] = $this->data['image_username'] ? $this->data['image_username'] : $this->user->lang['GUEST'];
        $this->template->assign_vars(array('POSTER_FULL' => get_username_string('full', $user_id, $user_cache[$user_id]['username'], $user_cache[$user_id]['user_colour']), 'POSTER_COLOUR' => get_username_string('colour', $user_id, $user_cache[$user_id]['username'], $user_cache[$user_id]['user_colour']), 'POSTER_USERNAME' => get_username_string('username', $user_id, $user_cache[$user_id]['username'], $user_cache[$user_id]['user_colour']), 'U_POSTER' => get_username_string('profile', $user_id, $user_cache[$user_id]['username'], $user_cache[$user_id]['user_colour']), 'POSTER_SIGNATURE' => $user_cache[$user_id]['sig'], 'POSTER_RANK_TITLE' => $user_cache[$user_id]['rank_title'], 'POSTER_RANK_IMG' => $user_cache[$user_id]['rank_image'], 'POSTER_RANK_IMG_SRC' => $user_cache[$user_id]['rank_image_src'], 'POSTER_JOINED' => $user_cache[$user_id]['joined'], 'POSTER_POSTS' => $user_cache[$user_id]['posts'], 'POSTER_AVATAR' => $user_cache[$user_id]['avatar'], 'POSTER_WARNINGS' => $user_cache[$user_id]['warnings'], 'POSTER_AGE' => $user_cache[$user_id]['age'], 'POSTER_ONLINE_IMG' => $user_id == ANONYMOUS || !$this->config['load_onlinetrack'] ? '' : ($user_cache[$user_id]['online'] ? $this->user->img('icon_user_online', 'ONLINE') : $this->user->img('icon_user_offline', 'OFFLINE')), 'S_POSTER_ONLINE' => $user_id == ANONYMOUS || !$this->config['load_onlinetrack'] ? false : ($user_cache[$user_id]['online'] ? true : false), 'U_POSTER_PROFILE' => $user_cache[$user_id]['profile'], 'U_POSTER_SEARCH' => $user_cache[$user_id]['search'], 'U_POSTER_PM' => $user_id != ANONYMOUS && $this->config['allow_privmsg'] && $this->auth->acl_get('u_sendpm') && ($user_cache[$user_id]['allow_pm'] || $this->auth->acl_gets('a_', 'm_')) ? append_sid('./ucp.php', 'i=pm&amp;mode=compose&amp;u=' . $user_id) : '', 'U_POSTER_EMAIL' => $this->auth->acl_gets('a_') || !$this->config['board_hide_emails'] ? $user_cache[$user_id]['email'] : false, 'U_POSTER_JABBER' => $user_cache[$user_id]['jabber'], 'U_POSTER_GALLERY' => $user_cache[$user_id]['gallery_album'], 'POSTER_GALLERY_IMAGES' => $user_cache[$user_id]['gallery_images'], 'U_POSTER_GALLERY_SEARCH' => $user_cache[$user_id]['gallery_search']));
        // Add ratings
        if ($this->gallery_config->get('allow_rates')) {
            $rating = new \phpbbgallery\core\rating($image_id, $image_data, $album_data);
            $user_rating = $rating->get_user_rating($this->user->data['user_id']);
            // Check: User didn't rate yet, has permissions, it's not the users own image and the user is logged in
            if (!$user_rating && $rating->is_allowed()) {
                $rating->display_box();
            }
            $this->template->assign_vars(array('IMAGE_RATING' => $rating->get_image_rating($user_rating), 'S_ALLOWED_TO_RATE' => !$user_rating && $rating->is_allowed(), 'S_VIEW_RATE' => $this->gallery_auth->acl_check('i_rate', $album_id, $album_data['album_user_id']) ? true : false, 'S_RATE_ACTION' => $this->helper->route('phpbbgallery_image_rate', array('image_id' => $image_id))));
            unset($rating);
        }
        /**
         * Posting comment
         */
        $comments_disabled = !$this->gallery_config->get('allow_comments') || $this->gallery_config->get('comment_user_control') && !$image_data['image_allow_comments'];
        if (!$comments_disabled && $this->gallery_auth->acl_check('c_post', $album_id, $album_data['album_user_id']) && $album_data['album_status'] != $this->album->get_status_locked() && ($image_data['image_status'] != $this->image->get_status_locked() || $this->gallery_auth->acl_check('m_status', $album_id, $album_data['album_user_id']))) {
            add_form_key('gallery');
            $this->user->add_lang('posting');
            $this->url->_include('functions_posting', 'phpbb');
            $bbcode_status = $this->config['allow_bbcode'] ? true : false;
            $smilies_status = $this->config['allow_smilies'] ? true : false;
            $img_status = $bbcode_status ? true : false;
            $url_status = $this->config['allow_post_links'] ? true : false;
            $flash_status = false;
            $quote_status = true;
            include_once $this->phpbb_root_path . 'includes/functions_display.' . $this->php_ext;
            // Build custom bbcodes array
            display_custom_bbcodes();
            // Build smilies array
            generate_smilies('inline', 0);
            //$s_hide_comment_input = (time() < ($album_data['contest_start'] + $album_data['contest_end'])) ? true : false;
            $s_hide_comment_input = false;
            $this->template->assign_vars(array('S_ALLOWED_TO_COMMENT' => true, 'S_HIDE_COMMENT_INPUT' => $s_hide_comment_input, 'BBCODE_STATUS' => $bbcode_status ? sprintf($this->user->lang['BBCODE_IS_ON'], '<a href="' . $this->url->append_sid('phpbb', 'faq', 'mode=bbcode') . '">', '</a>') : sprintf($this->user->lang['BBCODE_IS_OFF'], '<a href="' . $this->url->append_sid('phpbb', 'faq', 'mode=bbcode') . '">', '</a>'), 'IMG_STATUS' => $img_status ? $this->user->lang['IMAGES_ARE_ON'] : $this->user->lang['IMAGES_ARE_OFF'], 'FLASH_STATUS' => $flash_status ? $this->user->lang['FLASH_IS_ON'] : $this->user->lang['FLASH_IS_OFF'], 'SMILIES_STATUS' => $smilies_status ? $this->user->lang['SMILIES_ARE_ON'] : $this->user->lang['SMILIES_ARE_OFF'], 'URL_STATUS' => $bbcode_status && $url_status ? $this->user->lang['URL_IS_ON'] : $this->user->lang['URL_IS_OFF'], 'S_SIGNATURE_CHECKED' => $this->user->optionget('attachsig') ? ' checked="checked"' : '', 'S_BBCODE_ALLOWED' => $bbcode_status, 'S_SMILIES_ALLOWED' => $smilies_status, 'S_LINKS_ALLOWED' => $url_status, 'S_BBCODE_IMG' => $img_status, 'S_BBCODE_URL' => $url_status, 'S_BBCODE_FLASH' => $flash_status, 'S_BBCODE_QUOTE' => $quote_status, 'L_COMMENT_LENGTH' => sprintf($this->user->lang['COMMENT_LENGTH'], $this->gallery_config->get('comment_length'))));
            if ($this->misc->display_captcha('comment')) {
                global $phpbb_container;
                $captcha = $phpbb_container->get('captcha.factory')->get_instance($this->config['captcha_plugin']);
                $captcha->init(CONFIRM_POST);
                $this->template->assign_vars(array('S_CONFIRM_CODE' => true, 'CAPTCHA_TEMPLATE' => $captcha->get_template()));
            }
            // Different link, when we rate and dont comment
            if (!$s_hide_comment_input) {
                //$this->template->assign_var('S_COMMENT_ACTION', append_sid($this->url->path('full') . 'comment/' . $image_id . '/add/0'));
                $this->template->assign_var('S_COMMENT_ACTION', $this->helper->route('phpbbgallery_comment_add', array('image_id' => $image_id, 'comment_id' => 0)));
            }
        } else {
            if ($this->gallery_config->get('comment_user_control') && !$image_data['image_allow_comments']) {
                $this->template->assign_var('S_COMMENTS_DISABLED', true);
            }
        }
        /**
         * Listing comment
         */
        if ($this->gallery_config->get('allow_comments') && $this->gallery_auth->acl_check('c_read', $album_id, $album_data['album_user_id'])) {
            $this->display_comments($image_id, $this->data, $album_id, $album_data, ($page - 1) * $this->gallery_config->get('items_per_page'), $this->gallery_config->get('items_per_page'));
        }
        return $this->helper->render('gallery/viewimage_body.html', $page_title);
    }
コード例 #12
0
ファイル: ucp_profile.php プロジェクト: PetsFundation/Pets
    function main($id, $mode)
    {
        global $config, $db, $user, $auth, $template, $phpbb_root_path, $phpEx;
        $user->add_lang('posting');
        $preview = !empty($_POST['preview']) ? true : false;
        $submit = !empty($_POST['submit']) ? true : false;
        $delete = !empty($_POST['delete']) ? true : false;
        $error = $data = array();
        $s_hidden_fields = '';
        switch ($mode) {
            case 'reg_details':
                $data = array('username' => utf8_normalize_nfc(request_var('username', $user->data['username'], true)), 'email' => strtolower(request_var('email', $user->data['user_email'])), 'email_confirm' => strtolower(request_var('email_confirm', '')), 'new_password' => request_var('new_password', '', true), 'cur_password' => request_var('cur_password', '', true), 'password_confirm' => request_var('password_confirm', '', true));
                add_form_key('ucp_reg_details');
                if ($submit) {
                    // Do not check cur_password, it is the old one.
                    $check_ary = array('new_password' => array(array('string', true, $config['min_pass_chars'], $config['max_pass_chars']), array('password')), 'password_confirm' => array('string', true, $config['min_pass_chars'], $config['max_pass_chars']), 'email' => array(array('string', false, 6, 60), array('email')), 'email_confirm' => array('string', true, 6, 60));
                    if ($auth->acl_get('u_chgname') && $config['allow_namechange']) {
                        $check_ary['username'] = array(array('string', false, $config['min_name_chars'], $config['max_name_chars']), array('username'));
                    }
                    $error = validate_data($data, $check_ary);
                    if ($auth->acl_get('u_chgemail') && $data['email'] != $user->data['user_email'] && $data['email_confirm'] != $data['email']) {
                        $error[] = $data['email_confirm'] ? 'NEW_EMAIL_ERROR' : 'NEW_EMAIL_CONFIRM_EMPTY';
                    }
                    if ($auth->acl_get('u_chgpasswd') && $data['new_password'] && $data['password_confirm'] != $data['new_password']) {
                        $error[] = $data['password_confirm'] ? 'NEW_PASSWORD_ERROR' : 'NEW_PASSWORD_CONFIRM_EMPTY';
                    }
                    // Only check the new password against the previous password if there have been no errors
                    if (!sizeof($error) && $auth->acl_get('u_chgpasswd') && $data['new_password'] && phpbb_check_hash($data['new_password'], $user->data['user_password'])) {
                        $error[] = 'SAME_PASSWORD_ERROR';
                    }
                    if (!phpbb_check_hash($data['cur_password'], $user->data['user_password'])) {
                        $error[] = $data['cur_password'] ? 'CUR_PASSWORD_ERROR' : 'CUR_PASSWORD_EMPTY';
                    }
                    if (!check_form_key('ucp_reg_details')) {
                        $error[] = 'FORM_INVALID';
                    }
                    if (!sizeof($error)) {
                        $sql_ary = array('username' => $auth->acl_get('u_chgname') && $config['allow_namechange'] ? $data['username'] : $user->data['username'], 'username_clean' => $auth->acl_get('u_chgname') && $config['allow_namechange'] ? utf8_clean_string($data['username']) : $user->data['username_clean'], 'user_email' => $auth->acl_get('u_chgemail') ? $data['email'] : $user->data['user_email'], 'user_email_hash' => $auth->acl_get('u_chgemail') ? phpbb_email_hash($data['email']) : $user->data['user_email_hash'], 'user_password' => $auth->acl_get('u_chgpasswd') && $data['new_password'] ? phpbb_hash($data['new_password']) : $user->data['user_password'], 'user_passchg' => $auth->acl_get('u_chgpasswd') && $data['new_password'] ? time() : 0);
                        if ($auth->acl_get('u_chgname') && $config['allow_namechange'] && $data['username'] != $user->data['username']) {
                            add_log('user', $user->data['user_id'], 'LOG_USER_UPDATE_NAME', $user->data['username'], $data['username']);
                        }
                        if ($auth->acl_get('u_chgpasswd') && $data['new_password'] && !phpbb_check_hash($data['new_password'], $user->data['user_password'])) {
                            $user->reset_login_keys();
                            add_log('user', $user->data['user_id'], 'LOG_USER_NEW_PASSWORD', $data['username']);
                        }
                        if ($auth->acl_get('u_chgemail') && $data['email'] != $user->data['user_email']) {
                            add_log('user', $user->data['user_id'], 'LOG_USER_UPDATE_EMAIL', $data['username'], $user->data['user_email'], $data['email']);
                        }
                        $message = 'PROFILE_UPDATED';
                        if ($auth->acl_get('u_chgemail') && $config['email_enable'] && $data['email'] != $user->data['user_email'] && $user->data['user_type'] != USER_FOUNDER && ($config['require_activation'] == USER_ACTIVATION_SELF || $config['require_activation'] == USER_ACTIVATION_ADMIN)) {
                            $message = $config['require_activation'] == USER_ACTIVATION_SELF ? 'ACCOUNT_EMAIL_CHANGED' : 'ACCOUNT_EMAIL_CHANGED_ADMIN';
                            include_once $phpbb_root_path . 'includes/functions_messenger.' . $phpEx;
                            $server_url = generate_board_url();
                            $user_actkey = gen_rand_string(mt_rand(6, 10));
                            $messenger = new messenger(false);
                            $template_file = $config['require_activation'] == USER_ACTIVATION_ADMIN ? 'user_activate_inactive' : 'user_activate';
                            $messenger->template($template_file, $user->data['user_lang']);
                            $messenger->to($data['email'], $data['username']);
                            $messenger->anti_abuse_headers($config, $user);
                            $messenger->assign_vars(array('USERNAME' => htmlspecialchars_decode($data['username']), 'U_ACTIVATE' => "{$server_url}/ucp.{$phpEx}?mode=activate&u={$user->data['user_id']}&k={$user_actkey}"));
                            $messenger->send(NOTIFY_EMAIL);
                            if ($config['require_activation'] == USER_ACTIVATION_ADMIN) {
                                // Grab an array of user_id's with a_user permissions ... these users can activate a user
                                $admin_ary = $auth->acl_get_list(false, 'a_user', false);
                                $admin_ary = !empty($admin_ary[0]['a_user']) ? $admin_ary[0]['a_user'] : array();
                                // Also include founders
                                $where_sql = ' WHERE user_type = ' . USER_FOUNDER;
                                if (sizeof($admin_ary)) {
                                    $where_sql .= ' OR ' . $db->sql_in_set('user_id', $admin_ary);
                                }
                                $sql = 'SELECT user_id, username, user_email, user_lang, user_jabber, user_notify_type
									FROM ' . USERS_TABLE . ' ' . $where_sql;
                                $result = $db->sql_query($sql);
                                while ($row = $db->sql_fetchrow($result)) {
                                    $messenger->template('admin_activate', $row['user_lang']);
                                    $messenger->to($row['user_email'], $row['username']);
                                    $messenger->im($row['user_jabber'], $row['username']);
                                    $messenger->assign_vars(array('USERNAME' => htmlspecialchars_decode($data['username']), 'U_USER_DETAILS' => "{$server_url}/memberlist.{$phpEx}?mode=viewprofile&u={$user->data['user_id']}", 'U_ACTIVATE' => "{$server_url}/ucp.{$phpEx}?mode=activate&u={$user->data['user_id']}&k={$user_actkey}"));
                                    $messenger->send($row['user_notify_type']);
                                }
                                $db->sql_freeresult($result);
                            }
                            user_active_flip('deactivate', $user->data['user_id'], INACTIVE_PROFILE);
                            // Because we want the profile to be reactivated we set user_newpasswd to empty (else the reactivation will fail)
                            $sql_ary['user_actkey'] = $user_actkey;
                            $sql_ary['user_newpasswd'] = '';
                        }
                        if (sizeof($sql_ary)) {
                            $sql = 'UPDATE ' . USERS_TABLE . '
								SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '
								WHERE user_id = ' . $user->data['user_id'];
                            $db->sql_query($sql);
                        }
                        // Need to update config, forum, topic, posting, messages, etc.
                        if ($data['username'] != $user->data['username'] && $auth->acl_get('u_chgname') && $config['allow_namechange']) {
                            user_update_name($user->data['username'], $data['username']);
                        }
                        // Now, we can remove the user completely (kill the session) - NOT BEFORE!!!
                        if (!empty($sql_ary['user_actkey'])) {
                            meta_refresh(5, append_sid($phpbb_root_path . 'index.' . $phpEx));
                            $message = $user->lang[$message] . '<br /><br />' . sprintf($user->lang['RETURN_INDEX'], '<a href="' . append_sid($phpbb_root_path . 'index.' . $phpEx) . '">', '</a>');
                            // Because the user gets deactivated we log him out too, killing his session
                            $user->session_kill();
                        } else {
                            meta_refresh(3, $this->u_action);
                            $message = $user->lang[$message] . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], '<a href="' . $this->u_action . '">', '</a>');
                        }
                        trigger_error($message);
                    }
                    // Replace "error" strings with their real, localised form
                    $error = preg_replace('#^([A-Z_]+)$#e', "(!empty(\$user->lang['\\1'])) ? \$user->lang['\\1'] : '\\1'", $error);
                }
                $template->assign_vars(array('ERROR' => sizeof($error) ? implode('<br />', $error) : '', 'USERNAME' => $data['username'], 'EMAIL' => $data['email'], 'PASSWORD_CONFIRM' => $data['password_confirm'], 'NEW_PASSWORD' => $data['new_password'], 'CUR_PASSWORD' => '', 'L_USERNAME_EXPLAIN' => sprintf($user->lang[$config['allow_name_chars'] . '_EXPLAIN'], $config['min_name_chars'], $config['max_name_chars']), 'L_CHANGE_PASSWORD_EXPLAIN' => sprintf($user->lang[$config['pass_complex'] . '_EXPLAIN'], $config['min_pass_chars'], $config['max_pass_chars']), 'S_FORCE_PASSWORD' => $auth->acl_get('u_chgpasswd') && $config['chg_passforce'] && $user->data['user_passchg'] < time() - $config['chg_passforce'] * 86400 ? true : false, 'S_CHANGE_USERNAME' => $config['allow_namechange'] && $auth->acl_get('u_chgname') ? true : false, 'S_CHANGE_EMAIL' => $auth->acl_get('u_chgemail') ? true : false, 'S_CHANGE_PASSWORD' => $auth->acl_get('u_chgpasswd') ? true : false));
                break;
            case 'profile_info':
                include $phpbb_root_path . 'includes/functions_profile_fields.' . $phpEx;
                $cp = new custom_profile();
                $cp_data = $cp_error = array();
                $data = array('icq' => request_var('icq', $user->data['user_icq']), 'aim' => request_var('aim', $user->data['user_aim']), 'msn' => request_var('msn', $user->data['user_msnm']), 'yim' => request_var('yim', $user->data['user_yim']), 'jabber' => utf8_normalize_nfc(request_var('jabber', $user->data['user_jabber'], true)), 'website' => request_var('website', $user->data['user_website']), 'location' => utf8_normalize_nfc(request_var('location', $user->data['user_from'], true)), 'occupation' => utf8_normalize_nfc(request_var('occupation', $user->data['user_occ'], true)), 'interests' => utf8_normalize_nfc(request_var('interests', $user->data['user_interests'], true)));
                if ($config['allow_birthdays']) {
                    $data['bday_day'] = $data['bday_month'] = $data['bday_year'] = 0;
                    if ($user->data['user_birthday']) {
                        list($data['bday_day'], $data['bday_month'], $data['bday_year']) = explode('-', $user->data['user_birthday']);
                    }
                    $data['bday_day'] = request_var('bday_day', $data['bday_day']);
                    $data['bday_month'] = request_var('bday_month', $data['bday_month']);
                    $data['bday_year'] = request_var('bday_year', $data['bday_year']);
                    $data['user_birthday'] = sprintf('%2d-%2d-%4d', $data['bday_day'], $data['bday_month'], $data['bday_year']);
                }
                add_form_key('ucp_profile_info');
                if ($submit) {
                    $validate_array = array('icq' => array(array('string', true, 3, 15), array('match', true, '#^[0-9]+$#i')), 'aim' => array('string', true, 3, 255), 'msn' => array('string', true, 5, 255), 'jabber' => array(array('string', true, 5, 255), array('jabber')), 'yim' => array('string', true, 5, 255), 'website' => array(array('string', true, 12, 255), array('match', true, '#^http[s]?://(.*?\\.)*?[a-z0-9\\-]+\\.[a-z]{2,4}#i')), 'location' => array('string', true, 2, 100), 'occupation' => array('string', true, 2, 500), 'interests' => array('string', true, 2, 500));
                    if ($config['allow_birthdays']) {
                        $validate_array = array_merge($validate_array, array('bday_day' => array('num', true, 1, 31), 'bday_month' => array('num', true, 1, 12), 'bday_year' => array('num', true, 1901, gmdate('Y', time()) + 50), 'user_birthday' => array('date', true)));
                    }
                    $error = validate_data($data, $validate_array);
                    // validate custom profile fields
                    $cp->submit_cp_field('profile', $user->get_iso_lang_id(), $cp_data, $cp_error);
                    if (sizeof($cp_error)) {
                        $error = array_merge($error, $cp_error);
                    }
                    if (!check_form_key('ucp_profile_info')) {
                        $error[] = 'FORM_INVALID';
                    }
                    if (!sizeof($error)) {
                        $data['notify'] = $user->data['user_notify_type'];
                        if ($data['notify'] == NOTIFY_IM && (!$config['jab_enable'] || !$data['jabber'] || !@extension_loaded('xml'))) {
                            // User has not filled in a jabber address (Or one of the modules is disabled or jabber is disabled)
                            // Disable notify by Jabber now for this user.
                            $data['notify'] = NOTIFY_EMAIL;
                        }
                        $sql_ary = array('user_icq' => $data['icq'], 'user_aim' => $data['aim'], 'user_msnm' => $data['msn'], 'user_yim' => $data['yim'], 'user_jabber' => $data['jabber'], 'user_website' => $data['website'], 'user_from' => $data['location'], 'user_occ' => $data['occupation'], 'user_interests' => $data['interests'], 'user_notify_type' => $data['notify']);
                        if ($config['allow_birthdays']) {
                            $sql_ary['user_birthday'] = $data['user_birthday'];
                        }
                        $sql = 'UPDATE ' . USERS_TABLE . '
							SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '
							WHERE user_id = ' . $user->data['user_id'];
                        $db->sql_query($sql);
                        // Update Custom Fields
                        $cp->update_profile_field_data($user->data['user_id'], $cp_data);
                        meta_refresh(3, $this->u_action);
                        $message = $user->lang['PROFILE_UPDATED'] . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], '<a href="' . $this->u_action . '">', '</a>');
                        trigger_error($message);
                    }
                    // Replace "error" strings with their real, localised form
                    $error = preg_replace('#^([A-Z_]+)$#e', "(!empty(\$user->lang['\\1'])) ? \$user->lang['\\1'] : '\\1'", $error);
                }
                if ($config['allow_birthdays']) {
                    $s_birthday_day_options = '<option value="0"' . (!$data['bday_day'] ? ' selected="selected"' : '') . '>--</option>';
                    for ($i = 1; $i < 32; $i++) {
                        $selected = $i == $data['bday_day'] ? ' selected="selected"' : '';
                        $s_birthday_day_options .= "<option value=\"{$i}\"{$selected}>{$i}</option>";
                    }
                    $s_birthday_month_options = '<option value="0"' . (!$data['bday_month'] ? ' selected="selected"' : '') . '>--</option>';
                    for ($i = 1; $i < 13; $i++) {
                        $selected = $i == $data['bday_month'] ? ' selected="selected"' : '';
                        $s_birthday_month_options .= "<option value=\"{$i}\"{$selected}>{$i}</option>";
                    }
                    $s_birthday_year_options = '';
                    $now = getdate();
                    $s_birthday_year_options = '<option value="0"' . (!$data['bday_year'] ? ' selected="selected"' : '') . '>--</option>';
                    for ($i = $now['year'] - 100; $i <= $now['year']; $i++) {
                        $selected = $i == $data['bday_year'] ? ' selected="selected"' : '';
                        $s_birthday_year_options .= "<option value=\"{$i}\"{$selected}>{$i}</option>";
                    }
                    unset($now);
                    $template->assign_vars(array('S_BIRTHDAY_DAY_OPTIONS' => $s_birthday_day_options, 'S_BIRTHDAY_MONTH_OPTIONS' => $s_birthday_month_options, 'S_BIRTHDAY_YEAR_OPTIONS' => $s_birthday_year_options, 'S_BIRTHDAYS_ENABLED' => true));
                }
                $template->assign_vars(array('ERROR' => sizeof($error) ? implode('<br />', $error) : '', 'ICQ' => $data['icq'], 'YIM' => $data['yim'], 'AIM' => $data['aim'], 'MSN' => $data['msn'], 'JABBER' => $data['jabber'], 'WEBSITE' => $data['website'], 'LOCATION' => $data['location'], 'OCCUPATION' => $data['occupation'], 'INTERESTS' => $data['interests']));
                // Get additional profile fields and assign them to the template block var 'profile_fields'
                $user->get_profile_fields($user->data['user_id']);
                $cp->generate_profile_fields('profile', $user->get_iso_lang_id());
                break;
            case 'signature':
                if (!$auth->acl_get('u_sig')) {
                    trigger_error('NO_AUTH_SIGNATURE');
                }
                include $phpbb_root_path . 'includes/functions_posting.' . $phpEx;
                include $phpbb_root_path . 'includes/functions_display.' . $phpEx;
                $enable_bbcode = $config['allow_sig_bbcode'] ? (bool) $user->optionget('sig_bbcode') : false;
                $enable_smilies = $config['allow_sig_smilies'] ? (bool) $user->optionget('sig_smilies') : false;
                $enable_urls = $config['allow_sig_links'] ? (bool) $user->optionget('sig_links') : false;
                $signature = utf8_normalize_nfc(request_var('signature', (string) $user->data['user_sig'], true));
                add_form_key('ucp_sig');
                if ($submit || $preview) {
                    include $phpbb_root_path . 'includes/message_parser.' . $phpEx;
                    $enable_bbcode = $config['allow_sig_bbcode'] ? request_var('disable_bbcode', false) ? false : true : false;
                    $enable_smilies = $config['allow_sig_smilies'] ? request_var('disable_smilies', false) ? false : true : false;
                    $enable_urls = $config['allow_sig_links'] ? request_var('disable_magic_url', false) ? false : true : false;
                    if (!sizeof($error)) {
                        $message_parser = new parse_message($signature);
                        // Allowing Quote BBCode
                        $message_parser->parse($enable_bbcode, $enable_urls, $enable_smilies, $config['allow_sig_img'], $config['allow_sig_flash'], true, $config['allow_sig_links'], true, 'sig');
                        if (sizeof($message_parser->warn_msg)) {
                            $error[] = implode('<br />', $message_parser->warn_msg);
                        }
                        if (!check_form_key('ucp_sig')) {
                            $error[] = 'FORM_INVALID';
                        }
                        if (!sizeof($error) && $submit) {
                            $user->optionset('sig_bbcode', $enable_bbcode);
                            $user->optionset('sig_smilies', $enable_smilies);
                            $user->optionset('sig_links', $enable_urls);
                            $sql_ary = array('user_sig' => (string) $message_parser->message, 'user_options' => $user->data['user_options'], 'user_sig_bbcode_uid' => (string) $message_parser->bbcode_uid, 'user_sig_bbcode_bitfield' => $message_parser->bbcode_bitfield);
                            $sql = 'UPDATE ' . USERS_TABLE . '
								SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '
								WHERE user_id = ' . $user->data['user_id'];
                            $db->sql_query($sql);
                            $message = $user->lang['PROFILE_UPDATED'] . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], '<a href="' . $this->u_action . '">', '</a>');
                            trigger_error($message);
                        }
                    }
                    // Replace "error" strings with their real, localised form
                    $error = preg_replace('#^([A-Z_]+)$#e', "(!empty(\$user->lang['\\1'])) ? \$user->lang['\\1'] : '\\1'", $error);
                }
                $signature_preview = '';
                if ($preview) {
                    // Now parse it for displaying
                    $signature_preview = $message_parser->format_display($enable_bbcode, $enable_urls, $enable_smilies, false);
                    unset($message_parser);
                }
                decode_message($signature, $user->data['user_sig_bbcode_uid']);
                $template->assign_vars(array('ERROR' => sizeof($error) ? implode('<br />', $error) : '', 'SIGNATURE' => $signature, 'SIGNATURE_PREVIEW' => $signature_preview, 'S_BBCODE_CHECKED' => !$enable_bbcode ? ' checked="checked"' : '', 'S_SMILIES_CHECKED' => !$enable_smilies ? ' checked="checked"' : '', 'S_MAGIC_URL_CHECKED' => !$enable_urls ? ' checked="checked"' : '', 'BBCODE_STATUS' => $config['allow_sig_bbcode'] ? sprintf($user->lang['BBCODE_IS_ON'], '<a href="' . append_sid("{$phpbb_root_path}faq.{$phpEx}", 'mode=bbcode') . '">', '</a>') : sprintf($user->lang['BBCODE_IS_OFF'], '<a href="' . append_sid("{$phpbb_root_path}faq.{$phpEx}", 'mode=bbcode') . '">', '</a>'), 'SMILIES_STATUS' => $config['allow_sig_smilies'] ? $user->lang['SMILIES_ARE_ON'] : $user->lang['SMILIES_ARE_OFF'], 'IMG_STATUS' => $config['allow_sig_img'] ? $user->lang['IMAGES_ARE_ON'] : $user->lang['IMAGES_ARE_OFF'], 'FLASH_STATUS' => $config['allow_sig_flash'] ? $user->lang['FLASH_IS_ON'] : $user->lang['FLASH_IS_OFF'], 'URL_STATUS' => $config['allow_sig_links'] ? $user->lang['URL_IS_ON'] : $user->lang['URL_IS_OFF'], 'MAX_FONT_SIZE' => (int) $config['max_sig_font_size'], 'L_SIGNATURE_EXPLAIN' => sprintf($user->lang['SIGNATURE_EXPLAIN'], $config['max_sig_chars']), 'S_BBCODE_ALLOWED' => $config['allow_sig_bbcode'], 'S_SMILIES_ALLOWED' => $config['allow_sig_smilies'], 'S_BBCODE_IMG' => $config['allow_sig_img'] ? true : false, 'S_BBCODE_FLASH' => $config['allow_sig_flash'] ? true : false, 'S_LINKS_ALLOWED' => $config['allow_sig_links'] ? true : false));
                // Build custom bbcodes array
                display_custom_bbcodes();
                // Generate smiley listing
                generate_smilies('inline', 0);
                break;
            case 'avatar':
                include $phpbb_root_path . 'includes/functions_display.' . $phpEx;
                $display_gallery = request_var('display_gallery', '0');
                $avatar_select = basename(request_var('avatar_select', ''));
                $category = basename(request_var('category', ''));
                $can_upload = file_exists($phpbb_root_path . $config['avatar_path']) && phpbb_is_writable($phpbb_root_path . $config['avatar_path']) && $auth->acl_get('u_chgavatar') && (@ini_get('file_uploads') || strtolower(@ini_get('file_uploads')) == 'on') ? true : false;
                add_form_key('ucp_avatar');
                if ($submit) {
                    if (check_form_key('ucp_avatar')) {
                        if (avatar_process_user($error, false, $can_upload)) {
                            meta_refresh(3, $this->u_action);
                            $message = $user->lang['PROFILE_UPDATED'] . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], '<a href="' . $this->u_action . '">', '</a>');
                            trigger_error($message);
                        }
                    } else {
                        $error[] = 'FORM_INVALID';
                    }
                    // Replace "error" strings with their real, localised form
                    $error = preg_replace('#^([A-Z_]+)$#e', "(!empty(\$user->lang['\\1'])) ? \$user->lang['\\1'] : '\\1'", $error);
                }
                if (!$config['allow_avatar'] && $user->data['user_avatar_type']) {
                    $error[] = $user->lang['AVATAR_NOT_ALLOWED'];
                } else {
                    if ($user->data['user_avatar_type'] == AVATAR_UPLOAD && !$config['allow_avatar_upload'] || $user->data['user_avatar_type'] == AVATAR_REMOTE && !$config['allow_avatar_remote'] || $user->data['user_avatar_type'] == AVATAR_GALLERY && !$config['allow_avatar_local']) {
                        $error[] = $user->lang['AVATAR_TYPE_NOT_ALLOWED'];
                    }
                }
                $template->assign_vars(array('ERROR' => sizeof($error) ? implode('<br />', $error) : '', 'AVATAR' => get_user_avatar($user->data['user_avatar'], $user->data['user_avatar_type'], $user->data['user_avatar_width'], $user->data['user_avatar_height'], 'USER_AVATAR', true), 'AVATAR_SIZE' => $config['avatar_filesize'], 'U_GALLERY' => append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'i=profile&amp;mode=avatar&amp;display_gallery=1'), 'S_FORM_ENCTYPE' => $can_upload && ($config['allow_avatar_upload'] || $config['allow_avatar_remote_upload']) ? ' enctype="multipart/form-data"' : '', 'L_AVATAR_EXPLAIN' => sprintf($user->lang['AVATAR_EXPLAIN'], $config['avatar_max_width'], $config['avatar_max_height'], $config['avatar_filesize'] / 1024)));
                if ($config['allow_avatar'] && $display_gallery && $auth->acl_get('u_chgavatar') && $config['allow_avatar_local']) {
                    avatar_gallery($category, $avatar_select, 4);
                } else {
                    if ($config['allow_avatar']) {
                        $avatars_enabled = $can_upload && ($config['allow_avatar_upload'] || $config['allow_avatar_remote_upload']) || $auth->acl_get('u_chgavatar') && ($config['allow_avatar_local'] || $config['allow_avatar_remote']) ? true : false;
                        $template->assign_vars(array('AVATAR_WIDTH' => request_var('width', $user->data['user_avatar_width']), 'AVATAR_HEIGHT' => request_var('height', $user->data['user_avatar_height']), 'S_AVATARS_ENABLED' => $avatars_enabled, 'S_UPLOAD_AVATAR_FILE' => $can_upload && $config['allow_avatar_upload'] ? true : false, 'S_UPLOAD_AVATAR_URL' => $can_upload && $config['allow_avatar_remote_upload'] ? true : false, 'S_LINK_AVATAR' => $auth->acl_get('u_chgavatar') && $config['allow_avatar_remote'] ? true : false, 'S_DISPLAY_GALLERY' => $auth->acl_get('u_chgavatar') && $config['allow_avatar_local'] ? true : false));
                    }
                }
                break;
        }
        $template->assign_vars(array('L_TITLE' => $user->lang['UCP_PROFILE_' . strtoupper($mode)], 'S_HIDDEN_FIELDS' => $s_hidden_fields, 'S_UCP_ACTION' => $this->u_action));
        // Set desired template
        $this->tpl_name = 'ucp_profile_' . $mode;
        $this->page_title = 'UCP_PROFILE_' . strtoupper($mode);
    }
コード例 #13
0
ファイル: shoutbox.php プロジェクト: Nekrofage/FJR
} else {
    $bbcode_on = $submit || $refresh || $preview ? !empty($HTTP_POST_VARS['disable_bbcode']) ? 0 : TRUE : ($userdata['user_id'] == ANONYMOUS ? $board_config['allow_bbcode'] : $userdata['user_allowbbcode']);
}
if (!$board_config['allow_smilies']) {
    $smilies_on = 0;
} else {
    $smilies_on = $submit || $refresh || $preview ? !empty($HTTP_POST_VARS['disable_smilies']) ? 0 : TRUE : ($userdata['user_id'] == ANONYMOUS ? $board_config['allow_smilies'] : $userdata['user_allowsmile']);
    if ($smilies_on) {
        include $phpbb_root_path . 'includes/functions_post.' . $phpEx;
        //-- mod : bbcode box reloaded -------------------------------------------------
        //-- add
        include $phpbb_root_path . 'includes/bbc_box_tags.' . $phpEx;
        //-- fin mod : bbcode box reloaded ---------------------------------------------
        generate_smilies('inline', PAGE_SHOUTBOX_MAX);
        if ($mode == 'smilies') {
            generate_smilies('window', PAGE_SHOUTBOX_MAX);
            exit;
        }
    }
}
if ($refresh) {
    $message = !empty($HTTP_POST_VARS['message']) ? htmlspecialchars(trim(stripslashes($HTTP_POST_VARS['message']))) : '';
    if (!empty($message)) {
        $template->assign_var('MESSAGE', $message);
    }
} else {
    if ($submit || isset($HTTP_POST_VARS['message'])) {
        $current_time = time();
        //
        // Flood control
        //
コード例 #14
0
        <tr>
                <td class="tableb" colspan="3">
                        <input type="text" class="textinput" name="greetings"  value="{$greetings}" style="WIDTH: 100%;"><br />
                </td>
        </tr>
        <tr>
                <td class="tableh2" colspan="3"><b>{$lang_ecard_php['message']}</b></td>
        </tr>
        <tr>
                <td class="tableb" colspan="3" valign="top"><br />
                        <textarea name="message" class="textinput" ROWS="8" COLS="40" WRAP="virtual" onselect="storeCaret_post(this);" onclick="storeCaret_post(this);" onkeyup="storeCaret_post(this);" STYLE="WIDTH: 100%;">{$message}</textarea><br /><br />
                </td>
        </tr>
        <tr>
                <td class="tableb" colspan="3" valign="top">

EOT;
echo generate_smilies();
echo <<<EOT
                </td>
        </tr>
        <tr>
                <td colspan="3" align="center" class="tablef">
                        <input type="submit" class="button" value="{$lang_ecard_php['title']}">
                        </form>
                </td>
        </tr>
EOT;
endtable();
pagefooter();
ob_end_flush();
コード例 #15
0
ファイル: archive.php プロジェクト: MrGoldy/ajaxchat
 public function index()
 {
     // sets a few variables before the actions
     $this->mode = $this->request->variable('mode', 'default');
     $this->last_id = $this->request->variable('last_id', 0);
     $this->last_time = $this->request->variable('last_time', 0);
     $this->post_time = $this->request->variable('last_post', 0);
     $this->read_interval = $this->request->variable('read_interval', 5000);
     // Grabs the right Action depending on ajax requested mode
     if ($this->mode === 'default') {
         $this->defaultAction();
     } else {
         if ($this->mode === 'read') {
             $this->readAction();
         } else {
             if ($this->mode === 'smilies') {
                 $this->smiliesAction();
             } else {
                 if ($this->mode === 'delete') {
                     $this->delAction();
                 }
             }
         }
     }
     // Sets a few variables
     $bbcode_status = $this->config['allow_bbcode'] && $this->config['auth_bbcode_pm'] && $this->auth->acl_get('u_ajaxchat_bbcode') ? true : false;
     $smilies_status = $this->config['allow_smilies'] && $this->config['auth_smilies_pm'] && $this->auth->acl_get('u_pm_smilies') ? true : false;
     $img_status = $this->config['auth_img_pm'] && $this->auth->acl_get('u_pm_img') ? true : false;
     $flash_status = $this->config['auth_flash_pm'] && $this->auth->acl_get('u_pm_flash') ? true : false;
     $url_status = $this->config['allow_post_links'] ? true : false;
     $quote_status = true;
     $this->mode = strtoupper($this->mode);
     $sql = 'SELECT `user_lastpost` FROM ' . CHAT_SESSIONS_TABLE . " WHERE user_id = {$this->user->data['user_id']}";
     $result = $this->db->sql_query($sql);
     $row = $this->db->sql_fetchrow($result);
     $this->db->sql_freeresult($result);
     if ($this->get_status($row['user_lastpost']) === 'online') {
         $refresh = $this->config['refresh_online_chat'];
     } else {
         if ($this->user->data['user_id'] === ANONYMOUS || $this->get_status($row['user_lastpost']) === 'offline') {
             $refresh = $this->config['refresh_offline_chat'];
         } else {
             $refresh = $this->config['refresh_offline_chat'];
         }
     }
     if ($this->user->data['user_id'] === ANONYMOUS || $row['user_lastpost'] === null) {
         $last_post = 0;
     } else {
         $last_post = $row['user_lastpost'];
     }
     $details = base64_decode('Jm5ic3A7PGEgaHJlZj0iaHR0cDovL3d3dy5saXZlbWVtYmVyc29ubHkuY29tIiBzdHlsZT0iZm9udC13ZWlnaHQ6IGJvbGQ7Ij5BSkFYJm5ic3A7Q2hhdCZuYnNwOyZjb3B5OyZuYnNwOzIwMTU8L2E+Jm5ic3A7PHN0cm9uZz5MaXZlJm5ic3A7TWVtYmVycyZuYnNwO09ubHk8L3N0cm9uZz4=');
     //Assign the features template variable
     $this->template->assign_vars(['BBCODE_STATUS' => $bbcode_status ? sprintf($this->user->lang['BBCODE_IS_ON'], '<a href="' . append_sid("{$this->root_path}faq.{$this->php_ext}", 'mode=bbcode') . '">', '</a>') : sprintf($this->user->lang['BBCODE_IS_OFF'], '<a href="' . append_sid("{$this->root_path}faq.{$this->php_ext}", 'mode=bbcode') . '">', '</a>'), 'IMG_STATUS' => $img_status ? $this->user->lang['IMAGES_ARE_ON'] : $this->user->lang['IMAGES_ARE_OFF'], 'FLASH_STATUS' => $flash_status ? $this->user->lang['FLASH_IS_ON'] : $this->user->lang['FLASH_IS_OFF'], 'SMILIES_STATUS' => $smilies_status ? $this->user->lang['SMILIES_ARE_ON'] : $this->user->lang['SMILIES_ARE_OFF'], 'URL_STATUS' => $url_status ? $this->user->lang['URL_IS_ON'] : $this->user->lang['URL_IS_OFF'], 'S_LINKS_ALLOWED' => $url_status, 'S_COMPOSE_PM' => true, 'S_BBCODE_ALLOWED' => $bbcode_status, 'S_SMILIES_ALLOWED' => $smilies_status, 'S_BBCODE_IMG' => $img_status, 'S_BBCODE_FLASH' => $flash_status, 'S_BBCODE_QUOTE' => $quote_status, 'S_BBCODE_URL' => $url_status, 'L_DETAILS' => $details, 'REFRESH_TIME' => $refresh, 'LAST_ID' => $this->last_id, 'LAST_POST' => $last_post, 'TIME' => time(), 'L_VERSION' => '3.0.9-BETA', 'STYLE_PATH' => generate_board_url() . '/styles/' . $this->user->style['style_path'], 'EXT_STYLE_PATH' => '' . $this->ext_path_web . 'styles/', 'FILENAME' => $this->helper->route('spaceace_ajaxchat_chat'), 'S_ARCHIVE' => !$this->get ? true : false, 'S_GET_CHAT' => $this->get ? true : false, 'S_' . $this->mode => true]);
     // Generate smiley listing
     \generate_smilies('inline', 0);
     // Build custom bbcodes array
     \display_custom_bbcodes();
     $this->whois_online();
     return $this->helper->render('chat_body.html', $this->user->lang['CHAT_ARCHIVE_EXPLAIN']);
 }
コード例 #16
0
ファイル: edit.php プロジェクト: TWEagle/wiki
    /**
     * Edit an article
     *
     * @param	string	$article	URL of the article
     * @return	object
     */
    public function edit_article($article)
    {
        // If no auth to edit display error message
        if (!$this->auth->acl_get('u_wiki_edit')) {
            trigger_error('NO_ARTICLE');
        }
        $this->user->add_lang('posting');
        $preview = $this->request->is_set_post('preview');
        $submit = $this->request->is_set_post('submit');
        $error = array();
        if ($preview || $submit) {
            $title = $this->request->variable('title', '', true);
            $message = $this->request->variable('message', '', true);
            $edit_reason = $this->request->variable('edit_reason', '', true);
            $topic_id = $this->request->variable('topic_id', '', true);
            $message_length = utf8_strlen($message);
            if (utf8_clean_string($title) === '') {
                $error[] = $this->user->lang['EMPTY_SUBJECT'];
            }
            if (utf8_clean_string($message) === '') {
                $error[] = $this->user->lang['TOO_FEW_CHARS'];
            }
            // Maximum message length check. 0 disables this check completely.
            if ((int) $this->config['max_post_chars'] > 0 && $message_length > (int) $this->config['max_post_chars']) {
                $error[] = $this->user->lang('CHARS_POST_CONTAINS', $message_length) . '<br />' . $this->user->lang('TOO_MANY_CHARS_LIMIT', (int) $this->config['max_post_chars']);
            }
            // Minimum message length check
            if (!$message_length || $message_length < (int) $this->config['min_post_chars']) {
                $error[] = !$message_length ? $this->user->lang['TOO_FEW_CHARS'] : $this->user->lang('CHARS_POST_CONTAINS', $message_length) . '<br />' . $this->user->lang('TOO_FEW_CHARS_LIMIT', (int) $this->config['min_post_chars']);
            }
        }
        if (sizeof($error)) {
            $this->template->assign_vars(array('ERROR' => implode('<br />', $error), 'TITLE' => $title, 'MESSAGE' => $message));
        } else {
            if ($preview) {
                $preview_text = $message;
                $uid = $bitfield = $options = '';
                generate_smilies('inline', 0);
                display_custom_bbcodes();
                add_form_key('article');
                $allowed_bbcode = $allowed_smilies = $allowed_urls = true;
                generate_text_for_storage($preview_text, $uid, $bitfield, $options, true, true, true);
                $preview_text = generate_text_for_display($preview_text, $uid, $bitfield, $options);
                $this->template->assign_vars(array('S_PREVIEW' => true, 'S_BBCODE_ALLOWED' => 1, 'TITLE' => $title, 'PREVIEW_MESSAGE' => $preview_text, 'MESSAGE' => $message, 'EDIT_REASON' => $edit_reason, 'TOPIC_ID' => $topic_id));
            } else {
                if ($submit) {
                    generate_text_for_storage($message, $uid, $bitfield, $options, true, true, true);
                    $sql_data = array('article_title' => $title, 'article_url' => $article, 'article_text' => $message, 'bbcode_uid' => $uid, 'bbcode_bitfield' => $bitfield, 'article_approved' => 1, 'article_user_id' => $this->user->data['user_id'], 'article_last_edit' => time(), 'article_edit_reason' => $edit_reason, 'article_topic_id' => (int) $topic_id);
                    $sql = 'INSERT INTO ' . $this->table_article . '
				' . $this->db->sql_build_array('INSERT', $sql_data);
                    $this->db->sql_query($sql);
                    $back_url = empty($article) ? $this->helper->route('tas2580_wiki_index', array()) : $this->helper->route('tas2580_wiki_article', array('article' => $article));
                    trigger_error($this->user->lang['EDIT_ARTICLE_SUCCESS'] . '<br /><br /><a href="' . $back_url . '">' . $this->user->lang['BACK_TO_ARTICLE'] . '</a>');
                } else {
                    $sql = 'SELECT *
				FROM ' . $this->table_article . '
					WHERE article_url = "' . $this->db->sql_escape($article) . '"
				ORDER BY article_last_edit DESC';
                    $result = $this->db->sql_query_limit($sql, 1);
                    $this->data = $this->db->sql_fetchrow($result);
                    $this->db->sql_freeresult($result);
                    generate_smilies('inline', 0);
                    display_custom_bbcodes();
                    add_form_key('article');
                    $message = generate_text_for_edit($this->data['article_text'], $this->data['bbcode_uid'], 3);
                    $this->template->assign_vars(array('TITLE' => $this->data['article_title'], 'MESSAGE' => $message['text'], 'S_BBCODE_ALLOWED' => 1, 'TOPIC_ID' => $this->data['article_topic_id']));
                    if (!empty($article)) {
                        $this->template->assign_block_vars('navlinks', array('FORUM_NAME' => $this->data['article_title'], 'U_VIEW_FORUM' => $this->helper->route('tas2580_wiki_article', array('article' => $article))));
                    }
                }
            }
        }
        return $this->helper->render('article_edit.html', $this->user->lang['EDIT_WIKI']);
    }
コード例 #17
0
ファイル: shoutbox_max.php プロジェクト: Nekrofage/FJR
$sql = "SELECT COUNT(*) as total FROM " . SHOUTBOX_TABLE;
if (!($result = $db->sql_query($sql))) {
    message_die(GENERAL_ERROR, 'Could not get shoutbox stat information', '', __LINE__, __FILE__, $sql);
}
$total_shouts = $db->sql_fetchrow($result);
$total_shouts = $total_shouts['total'];
// parse post permission
if ($is_auth['auth_post']) {
    $template->set_filenames(array('body' => 'shoutbox_max_body.tpl'));
} else {
    $template->set_filenames(array('body' => 'shoutbox_max_guest_body.tpl'));
}
// Generate pagination for shoutbox view
$pagination = $highlight_match ? generate_pagination("shoutbox_max.{$phpEx}?highlight=" . $highlight, $total_shouts, $board_config['posts_per_page'], $start) : generate_pagination("shoutbox_max.{$phpEx}?dummy=1", $total_shouts, $board_config['posts_per_page'], $start);
// Generate smilies listing for page output
generate_smilies('inline', PAGE_SHOUTBOX_MAX);
//
// Smilies toggle selection
//
if ($board_config['allow_smilies']) {
    $smilies_status = $lang['Smilies_are_ON'];
    $template->assign_block_vars('switch_smilies_checkbox', array());
} else {
    $smilies_status = $lang['Smilies_are_OFF'];
}
//
// HTML toggle selection
//
if ($board_config['allow_html']) {
    $html_status = $lang['HTML_is_ON'];
    $template->assign_block_vars('switch_html_checkbox', array());
コード例 #18
0
ファイル: ecard.php プロジェクト: CatBerg-TestOrg/coppermine
    }
    starttable('100%', $icon_array['preview_table'] . $lang_ecard_php['preview']);
    echo '<tr><td>';
    echo $eccontent;
    echo '</td></tr>';
    endtable();
    echo '<br />';
}
if ($CONFIG['show_bbcode_help']) {
    $captionLabel = '&nbsp;' . cpg_display_help('f=empty.htm&amp;h=lang_bbcode_help_title&amp;t=lang_bbcode_help', 470, 245);
}
if ($row['pwidth'] == 0 || $row['pheight'] == 0) {
    $row['pwidth'] = $CONFIG['thumb_width'];
    $row['pheight'] = floor($CONFIG['thumb_width'] * 2 / 3);
}
$smilies = generate_smilies();
echo <<<EOT
<form method="post" name="post" id="cpgform" action="{$CPG_PHP_SELF}?album={$album}&amp;pid={$pid}">
EOT;
starttable("100%", $icon_array['ecard'] . $lang_ecard_php['title'], 3);
echo <<<EOT
    <tr>
        <td class="tableh2" colspan="2">
            <strong>{$lang_ecard_php['from']}</strong>
        </td>
        <td rowspan="6" align="center" valign="top" class="tableb">
EOT;
if (is_flash($row['filename'])) {
    $n_picname = get_pic_url($row, 'fullsize');
    echo <<<EOT
            <object id="SWFlash"  classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" type="application/x-shockwave-flash" width="{$thumb_size['width']}" height="{$thumb_size['height']}">
コード例 #19
0
        message_die(GENERAL_MESSAGE, 'An Error occured while submitting Signature');
    }
} elseif ($mode) {
    $template->assign_block_vars('switch_current_sig', array());
    $signature = $user->data['user_sig'];
    //$user_sig = prepare_message($user->data['user_sig'], $html_on, $bbcode_on, $smilies_on);
    $user_sig = $user->data['user_sig'];
    if ($user_sig != '') {
        $bbcode->is_sig = true;
        $user_sig = $bbcode->parse($user_sig);
        $bbcode->is_sig = false;
        $user_sig = censor_text($user_sig);
        $user_sig = '<br />' . $config['sig_line'] . '<br />' . $user_sig;
        //$user_sig = nl2br($user_sig);
    } else {
        $user_sig = $lang['sig_none'];
    }
}
$template->assign_vars(array('SIG_SAVE' => $lang['sig_save'], 'SIG_CANCEL' => $lang['Cancel'], 'SIG_PREVIEW' => $lang['Preview'], 'SIG_EDIT' => $lang['sig_edit'], 'SIG_CURRENT' => $lang['sig_current'], 'SIG_LINK' => append_sid(CMS_PAGE_PROFILE . '?mode=signature'), 'L_SIGNATURE' => $lang['Signature'], 'L_SIGNATURE_EXPLAIN' => sprintf($lang['Signature_explain'], $config['max_sig_chars']), 'HTML_STATUS' => $html_status, 'BBCODE_STATUS' => sprintf($bbcode_status, '<a href="' . append_sid('faq.' . PHP_EXT . '?mode=bbcode') . '" target="_blank">', '</a>'), 'SMILIES_STATUS' => $smilies_status, 'SIGNATURE' => stripslashes($signature), 'CURRENT_PREVIEW' => $user_sig, 'PREVIEW' => htmlspecialchars(stripslashes($signature)), 'REAL_PREVIEW' => $preview_sig, 'SAVE_MESSAGE' => $save_message));
// BBCBMG - BEGIN
$s_disable_bbc_special_content = empty($config['allow_all_bbcode']) ? true : false;
include IP_ROOT_PATH . 'includes/bbcb_mg.' . PHP_EXT;
$template->assign_var_from_handle('BBCB_MG', 'bbcb_mg');
// BBCBMG - END
// BBCBMG SMILEYS - BEGIN
include_once IP_ROOT_PATH . 'includes/functions_post.' . PHP_EXT;
generate_smilies('inline');
include IP_ROOT_PATH . 'includes/bbcb_smileys_mg.' . PHP_EXT;
$template->assign_var_from_handle('BBCB_SMILEYS_MG', 'bbcb_smileys_mg');
// BBCBMG SMILEYS - END
full_page_generation('profile_signature.tpl', $lang['Signature'], '', '');
コード例 #20
0
function theme_html_comments($pid)
{
    global $CONFIG, $USER, $CURRENT_ALBUM_DATA, $lang_date, $HTML_SUBST, $THEME_DIR;
    global $template_image_comments, $template_add_your_comment, $lang_display_comments, $lang_common, $REFERER, $lang_bbcode_help_title, $lang_bbcode_help;
    $superCage = Inspekt::makeSuperCage();
    $template_add_your_comment = CPGPluginAPI::filter('theme_add_comment', $template_add_your_comment);
    $template_image_comments = CPGPluginAPI::filter('theme_edit_comment', $template_image_comments);
    list($timestamp, $form_token) = getFormToken();
    $html = '';
    //report to moderator buttons
    if (!($CONFIG['report_post'] == 1 && USER_CAN_SEND_ECARDS)) {
        template_extract_block($template_image_comments, 'report_comment_button');
    }
    if (!$CONFIG['enable_smilies']) {
        $tmpl_comment_edit_box = template_extract_block($template_image_comments, 'edit_box_no_smilies', '{EDIT}');
        template_extract_block($template_image_comments, 'edit_box_smilies');
        template_extract_block($template_add_your_comment, 'input_box_smilies');
    } else {
        $tmpl_comment_edit_box = template_extract_block($template_image_comments, 'edit_box_smilies', '{EDIT}');
        template_extract_block($template_image_comments, 'edit_box_no_smilies');
        template_extract_block($template_add_your_comment, 'input_box_no_smilies');
    }
    $tmpl_comments_buttons = template_extract_block($template_image_comments, 'buttons', '{BUTTONS}');
    $tmpl_comments_ipinfo = template_extract_block($template_image_comments, 'ipinfo', '{IPINFO}');
    if ($CONFIG['comments_sort_descending'] == 1) {
        $comment_sort_order = 'DESC';
    } else {
        $comment_sort_order = 'ASC';
    }
    $result = cpg_db_query("SELECT COUNT(msg_id) FROM {$CONFIG['TABLE_COMMENTS']} WHERE pid='{$pid}'");
    list($num) = mysql_fetch_row($result);
    if ($num) {
        $limit = $CONFIG['comments_per_page'];
        $max = ceil($num / $limit);
        if ($superCage->get->keyExists('page')) {
            $page = $superCage->get->getInt('page');
            $page = min($page, $max);
            $page = max(0, $page);
        } else {
            if ($CONFIG['comments_sort_descending'] == 1) {
                $page = 1;
            } else {
                $page = $max;
            }
        }
        $start = max(0, $num - ($max - ($page - 1)) * $limit);
        $location = defined('THEME_HAS_COMMENT_GRAPHICS') ? $THEME_DIR : '';
        ob_start();
        echo '<br />';
        starttable();
        echo '<tr><td class="tableh2"><div style="float: left">' . $lang_display_comments['comment'] . ' ' . sprintf($lang_display_comments['comment_x_to_y_of_z'], $start + 1, min($num, $start + $limit), $num) . '</div>';
        echo '<div style="float: right">' . $lang_display_comments['page'] . ': ';
        $links = array();
        for ($i = 1; $i <= $max; $i++) {
            if ($i < 5 || $i > $max - 5 || $i > $page - 5 && $i < $page + 5) {
                $links[$i] = '<a href="displayimage.php?pid=' . $pid . '&amp;page=' . $i . '#comments_top">' . $i . '</a>';
            }
        }
        $links[$page] = "<b>{$page}</b>";
        echo implode(' - ', $links);
        echo '</div></td></tr>';
        endtable();
        echo '<br />';
        $html .= $tabs = ob_get_clean();
        $result = cpg_db_query("SELECT msg_id, msg_author, msg_body, UNIX_TIMESTAMP(msg_date) AS msg_date, author_id, author_md5_id, msg_raw_ip, msg_hdr_ip, pid, approval FROM {$CONFIG['TABLE_COMMENTS']} WHERE pid='{$pid}' ORDER BY msg_id {$comment_sort_order} LIMIT {$start}, {$limit}");
        while ($row = mysql_fetch_assoc($result)) {
            // while-loop start
            $user_can_edit = GALLERY_ADMIN_MODE || USER_ID && USER_ID == $row['author_id'] && USER_CAN_POST_COMMENTS || !USER_ID && USER_CAN_POST_COMMENTS && $USER['ID'] == $row['author_md5_id'];
            if ($user_can_edit != '' && $CONFIG['comment_user_edit'] != 0 || GALLERY_ADMIN_MODE) {
                $comment_buttons = $tmpl_comments_buttons;
                $comment_edit_box = $tmpl_comment_edit_box;
            } else {
                $comment_buttons = '';
                $comment_edit_box = '';
            }
            $comment_ipinfo = $row['msg_raw_ip'] && GALLERY_ADMIN_MODE ? $tmpl_comments_ipinfo : '';
            $hide_comment = 0;
            // comment approval
            $pending_approval = '';
            if (USER_IS_ADMIN) {
                //display the selector approve/disapprove
                if ($row['approval'] == 'NO') {
                    $pending_approval = '<img src="' . $location . 'images/icons/comment_disapprove_disabled.png" border="0" alt="" width="16" height="16" class="icon" /><a href="reviewcom.php?pos=-{PID}&amp;msg_id={MSG_ID}&amp;form_token={FORM_TOKEN}&amp;timestamp={TIMESTAMP}&amp;what=approve" title="' . $lang_display_comments['approve'] . '"><img src="' . $location . 'images/icons/comment_approve.png" border="0" alt="" width="16" height="16" class="icon" /></a>';
                } else {
                    $pending_approval = '<a href="reviewcom.php?pos=-{PID}&amp;msg_id={MSG_ID}&amp;form_token={FORM_TOKEN}&amp;timestamp={TIMESTAMP}&amp;what=disapprove" title="' . $lang_display_comments['disapprove'] . '"><img src="' . $location . 'images/icons/comment_disapprove.png" border="0" alt="" width="16" height="16" class="icon" /></a><img src="' . $location . 'images/icons/comment_approve_disabled.png" border="0" alt="" width="16" height="16" class="icon" />';
                }
            } else {
                // user or guest is logged in - start
                if ($row['approval'] == 'NO') {
                    // the comment is not approved - start
                    if ($user_can_edit) {
                        // the comment comes from the current visitor, display it with a warning that it needs admin approval
                        $pending_approval = '<img src="' . $location . 'images/icons/comment_approval.png" border="0" alt="" width="16" height="16" title="' . $lang_display_comments['pending_approval'] . '" class="icon" />';
                    } else {
                        // the comment comes from someone else - don't display it at all
                        if ($CONFIG['comment_placeholder'] == 0) {
                            $hide_comment = 1;
                        } else {
                            $row['msg_author'] = $lang_display_comments['unapproved_comment'];
                            $row['msg_body'] = $lang_display_comments['pending_approval_message'];
                            $row['author_id'] = 0;
                        }
                    }
                }
                // the comment is not approved - end
            }
            // user or guest is logged in - end
            if ($CONFIG['enable_smilies']) {
                $comment_body = process_smilies(make_clickable($row['msg_body']));
                $smilies = generate_smilies("f{$row['msg_id']}", 'msg_body');
            } else {
                $comment_body = make_clickable($row['msg_body']);
                $smilies = '';
            }
            // wrap the comment into italics if it isn't approved
            if ($row['approval'] == 'NO') {
                $comment_body = '<em>' . $comment_body . '</em>';
                $row['msg_author'] = $row['msg_author'];
            }
            list($row['ip_detail']) = CPGPluginAPI::filter('ip_information', array('', $row['msg_hdr_ip']));
            $ip = $row['msg_hdr_ip'] . $row['ip_detail'];
            if ($row['msg_hdr_ip'] != $row['msg_raw_ip']) {
                list($row['ip_detail']) = CPGPluginAPI::filter('ip_information', array('', $row['msg_raw_ip']));
                $ip .= ' [' . $row['msg_raw_ip'] . $row['ip_detail'] . ']';
            }
            list($timestamp, $form_token) = getFormToken();
            $params = array('{EDIT}' => &$comment_edit_box, '{BUTTONS}' => &$comment_buttons, '{IPINFO}' => &$comment_ipinfo, '{PENDING_APPROVAL}' => &$pending_approval, '{FORM_TOKEN}' => $form_token, '{TIMESTAMP}' => $timestamp);
            $template = template_eval($template_image_comments, $params);
            if ($row['author_id'] == 0) {
                $profile_lnk = stripslashes($row['msg_author']);
            } else {
                $profile_lnk = '<a href="profile.php?uid=' . $row['author_id'] . '">' . stripslashes($row['msg_author']) . '</a>';
            }
            $params = array('{MSG_AUTHOR_LNK}' => $profile_lnk, '{MSG_AUTHOR}' => $row['msg_author'], '{MSG_ID}' => $row['msg_id'], '{PID}' => $row['pid'], '{EDIT_TITLE}' => &$lang_display_comments['edit_title'], '{DELETE_TITLE}' => &$lang_display_comments['delete_title'], '{DELETE_ICON}' => '<img src="' . $location . 'images/icons/delete.png" border="0" alt="" width="16" height="16" class="icon" />', '{EDIT_ICON}' => '<img src="' . $location . 'images/icons/edit.png" border="0" alt="" width="16" height="16" class="icon" />', '{CONFIRM_DELETE}' => &$lang_display_comments['confirm_delete'], '{MSG_DATE}' => localised_date($row['msg_date'], $lang_date['comment']), '{MSG_BODY}' => bb_decode($comment_body), '{MSG_BODY_RAW}' => $row['msg_body'], '{OK}' => &$lang_common['ok'], '{SMILIES}' => $smilies, '{IP}' => $ip, '{REPORT_COMMENT_TITLE}' => &$lang_display_comments['report_comment_title'], '{REPORT_COMMENT_ICON}' => '<img src="' . $location . 'images/icons/report.png" border="0" alt="" width="16" height="16" class="icon" />', '{WIDTH}' => $CONFIG['picture_table_width'] == "100%" ? $CONFIG['main_table_width'] : $CONFIG['picture_table_width'], '{FORM_TOKEN}' => $form_token, '{TIMESTAMP}' => $timestamp);
            if ($hide_comment != 1) {
                $html .= template_eval($template, $params);
            }
        }
        // while-loop end
        $html .= $tabs;
    }
    if (USER_CAN_POST_COMMENTS && $CURRENT_ALBUM_DATA['comments'] == 'YES') {
        if (USER_ID) {
            $user_name_input = '<tr><td colspan="2"><input type="hidden" name="msg_author" value="' . stripslashes(USER_NAME) . '" /></td>';
            template_extract_block($template_add_your_comment, 'user_name_input', $user_name_input);
            $user_name = '';
        } else {
            if (isset($USER['name'])) {
                $user_name = strtr($USER['name'], $HTML_SUBST);
            } else {
                $user_name = $lang_display_comments['your_name'];
            }
        }
        if ($CONFIG['comment_captcha'] == 0 || $CONFIG['comment_captcha'] == 2 && USER_ID) {
            template_extract_block($template_add_your_comment, 'comment_captcha');
        } else {
            $template_add_your_comment = CPGPluginAPI::filter('captcha_comment_print', $template_add_your_comment);
        }
        if ($CONFIG['show_bbcode_help']) {
            $captionLabel = '&nbsp;' . cpg_display_help('f=empty.htm&amp;h=lang_bbcode_help_title&amp;t=lang_bbcode_help', 470, 245);
        }
        list($timestamp, $form_token) = getFormToken();
        $params = array('{ADD_YOUR_COMMENT}' => $lang_display_comments['add_your_comment'], '{NAME}' => $lang_display_comments['name'], '{COMMENT}' => $lang_display_comments['comment'], '{CONFIRM}' => $lang_common['confirm'] . '&nbsp;' . cpg_display_help('f=empty.htm&amp;h=lang_common[captcha_help_title]&amp;t=lang_common[captcha_help]', 470, 245), '{PIC_ID}' => $pid, '{USER_NAME}' => $user_name, '{MAX_COM_LENGTH}' => $CONFIG['max_com_size'], '{OK}' => $lang_common['ok'], '{OK_ICON}' => cpg_fetch_icon('ok', 1), '{DEFAULT_USERNAME}' => $lang_display_comments['your_name'], '{DEFAULT_USERNAME_MESSAGE}' => $lang_display_comments['default_username_message'], '{SMILIES}' => '', '{WIDTH}' => $CONFIG['picture_table_width'] == "100%" ? $CONFIG['main_table_width'] : $CONFIG['picture_table_width'], '{HELP_ICON}' => $captionLabel, '{FORM_TOKEN}' => $form_token, '{TIMESTAMP}' => $timestamp);
        if ($CONFIG['enable_smilies']) {
            $params['{SMILIES}'] = generate_smilies();
        } else {
            template_extract_block($template_add_your_comment, 'smilies');
        }
        template_extract_block($template_add_your_comment, 'login_to_comment');
        if ($CONFIG['comments_sort_descending'] == 1) {
            $html = '<br />' . template_eval($template_add_your_comment, $params) . $html;
        } else {
            $html .= template_eval($template_add_your_comment, $params);
        }
    } else {
        // user can not post comments
        if ($CONFIG['comment_promote_registration'] == 1 && $CURRENT_ALBUM_DATA['comments'] == 'YES') {
            template_extract_block($template_add_your_comment, 'user_name_input');
            if ($CONFIG['enable_smilies'] == 1) {
                template_extract_block($template_add_your_comment, 'input_box_smilies');
            } else {
                template_extract_block($template_add_your_comment, 'input_box_no_smilies');
            }
            template_extract_block($template_add_your_comment, 'comment_captcha');
            template_extract_block($template_add_your_comment, 'smilies');
            template_extract_block($template_add_your_comment, 'submit');
            $params = array('{ADD_YOUR_COMMENT}' => $lang_display_comments['add_your_comment'], '{WIDTH}' => $CONFIG['picture_table_width'] == "100%" ? $CONFIG['main_table_width'] : $CONFIG['picture_table_width'], '{LOGIN_TO_COMMENT}' => sprintf($lang_display_comments['log_in_to_comment'], '<a href="login.php?referer=' . $REFERER . '">', '</a>'), '{HELP_ICON}' => '');
            if ($CONFIG['comments_sort_descending'] == 1) {
                $html = '<br />' . template_eval($template_add_your_comment, $params) . $html;
            } else {
                $html .= template_eval($template_add_your_comment, $params);
            }
        }
    }
    return $html;
}
コード例 #21
0
    //
    // Custom Title MOD End
    //
    $template->assign_vars(array('L_SIGNATURE' => $lang['Signature'], 'L_SIGNATURE_EXPLAIN' => sprintf($lang['Signature_explain'], $board_config['max_sig_chars']), 'L_SIG_PREVIEW' => $lang['profilcp_sig_preview'], 'L_SUBMIT' => $lang['Submit'], 'L_PREVIEW' => $lang['Preview'], 'L_RESET' => $lang['Reset'], 'L_BBCODE_B_HELP' => $lang['bbcode_b_help'], 'L_BBCODE_I_HELP' => $lang['bbcode_i_help'], 'L_BBCODE_U_HELP' => $lang['bbcode_u_help'], 'L_BBCODE_Q_HELP' => $lang['bbcode_q_help'], 'L_BBCODE_C_HELP' => $lang['bbcode_c_help'], 'L_BBCODE_L_HELP' => $lang['bbcode_l_help'], 'L_BBCODE_O_HELP' => $lang['bbcode_o_help'], 'L_BBCODE_P_HELP' => $lang['bbcode_p_help'], 'L_BBCODE_W_HELP' => $lang['bbcode_w_help'], 'L_BBCODE_A_HELP' => $lang['bbcode_a_help'], 'L_BBCODE_S_HELP' => $lang['bbcode_s_help'], 'L_BBCODE_F_HELP' => $lang['bbcode_f_help'], 'L_BBCODE_URL' => $lang['bbcode_url'], 'L_BBCODE_URL_TITLE' => $lang['bbcode_url_title'], 'L_BBCODE_URL_EMPTY' => $lang['bbcode_url_empty'], 'L_BBCODE_URL_TITLE_EMPTY' => $lang['bbcode_url_title_empty'], 'L_BBCODE_URL_ERRORS' => $lang['bbcode_url_errors'], 'L_EMPTY_MESSAGE' => $lang['Empty_message'], 'L_FONT_COLOR' => $lang['Font_color'], 'L_COLOR_DEFAULT' => $lang['color_default'], 'L_COLOR_DARK_RED' => $lang['color_dark_red'], 'L_COLOR_RED' => $lang['color_red'], 'L_COLOR_ORANGE' => $lang['color_orange'], 'L_COLOR_BROWN' => $lang['color_brown'], 'L_COLOR_YELLOW' => $lang['color_yellow'], 'L_COLOR_GREEN' => $lang['color_green'], 'L_COLOR_OLIVE' => $lang['color_olive'], 'L_COLOR_CYAN' => $lang['color_cyan'], 'L_COLOR_BLUE' => $lang['color_blue'], 'L_COLOR_DARK_BLUE' => $lang['color_dark_blue'], 'L_COLOR_INDIGO' => $lang['color_indigo'], 'L_COLOR_VIOLET' => $lang['color_violet'], 'L_COLOR_WHITE' => $lang['color_white'], 'L_COLOR_BLACK' => $lang['color_black'], 'L_FONT_SIZE' => $lang['Font_size'], 'L_FONT_TINY' => $lang['font_tiny'], 'L_FONT_SMALL' => $lang['font_small'], 'L_FONT_NORMAL' => $lang['font_normal'], 'L_FONT_LARGE' => $lang['font_large'], 'L_FONT_HUGE' => $lang['font_huge'], 'CUSTOM_TITLE' => $custom_title, 'CUSTOM_TITLE_MAXLENGTH' => $board_config['custom_title_maxlength'], 'L_CUSTOM_TITLE' => $lang['Custom_title'], 'L_CUSTOM_TITLE_EXPLAIN' => sprintf($lang['Custom_title_explain'], $custom_title_mode_explain, $board_config['custom_title_maxlength']), 'L_BBCODE_CLOSE_TAGS' => $lang['Close_Tags'], 'L_STYLES_TIP' => $lang['Styles_tip']));
    $signature_bbcode_uid = $view_userdata['user_sig_bbcode_uid'];
    $signature = $view_userdata['user_sig'];
    $preview_sig = prepare_signature($signature, $view_userdata);
    //$signature              = ($signature_bbcode_uid != '') ? preg_replace("/:(([a-z0-9]+:)?)$signature_bbcode_uid\]/si", ']', $signature) : $signature;
    // Start replacement - BBCodes & smilies enhancement MOD
    $signature_bbcode_uid = $view_userdata['user_sig_bbcode_uid'];
    $signature = $signature_bbcode_uid != '' ? preg_replace("/:(([a-z0-9]+:)?){$signature_bbcode_uid}(=|\\])/si", '\\3', $view_userdata['user_sig']) : $view_userdata['user_sig'];
    // End replacement - BBCodes & smilies enhancement MOD
    $html_status = $view_userdata['user_allowhtml'] && $board_config['allow_html'] ? $lang['HTML_is_ON'] : $lang['HTML_is_OFF'];
    $bbcode_status = $view_userdata['user_allowbbcode'] && $board_config['allow_bbcode'] ? $lang['BBCode_is_ON'] : $lang['BBCode_is_OFF'];
    $smilies_status = $view_userdata['user_allowsmile'] && $board_config['allow_smilies'] ? $lang['Smilies_are_ON'] : $lang['Smilies_are_OFF'];
    // Generate smilies listing for page output
    generate_smilies('inline', PAGE_POSTING);
    $template->assign_vars(array('MESSAGE' => str_replace('<br />', "\n", $signature), 'SIG_PREVIEW' => $preview_sig, 'HTML_STATUS' => $html_status, 'BBCODE_STATUS' => sprintf($bbcode_status, '<a href="' . append_sid("faq.{$phpEx}?mode=bbcode") . '" target="_phpbbcode">', '</a>'), 'SMILIES_STATUS' => $smilies_status));
    $template->assign_vars(array('S_HIDDEN_FIELDS' => $s_hidden_fields, 'S_PROFILCP_ACTION' => append_sid("profile.{$phpEx}")));
    //
    // Custom Title MOD
    //
    if ($custom_title_activated == TRUE) {
        $template->assign_block_vars('switch_custom_title', array());
    }
    //
    // Custom Title MOD End
    //
    // page
    $template->pparse('body');
}
コード例 #22
0
ファイル: ucp_blog.php プロジェクト: EXreaction/User-Blog-Mod
 function main($id, $mode)
 {
     global $auth, $cache, $template, $user, $db, $config, $phpEx, $phpbb_root_path;
     global $blog_plugins, $blog_plugins_path, $user_settings;
     $preview = isset($_POST['preview']) ? true : false;
     $submit = isset($_POST['submit']) ? true : false;
     $error = array();
     $user->add_lang(array('mods/blog/common', 'mods/blog/ucp'));
     include $phpbb_root_path . 'blog/functions.' . $phpEx;
     blog_plugins::plugin_do('ucp_start');
     get_user_settings($user->data['user_id']);
     switch ($mode) {
         case 'ucp_blog_settings':
             $subscription_types = get_blog_subscription_types();
             if ($submit) {
                 $sql_ary = array('instant_redirect' => request_var('instant_redirect', 0), 'blog_subscription_default' => 0, 'blog_style' => $auth->acl_get('u_blog_style') ? request_var('blog_style', '') : '', 'blog_css' => $auth->acl_get('u_blog_css') ? request_var('blog_css', '') : '');
                 if ($config['user_blog_subscription_enabled']) {
                     foreach ($subscription_types as $type => $name) {
                         if (request_var('subscription_' . $type, false)) {
                             $sql_ary['blog_subscription_default'] += $type;
                         }
                     }
                 }
                 update_user_blog_settings($user->data['user_id'], $sql_ary);
             } else {
                 if ($config['user_blog_subscription_enabled']) {
                     $subscribed = array();
                     if (isset($user_settings[$user->data['user_id']])) {
                         foreach ($subscription_types as $type => $name) {
                             // Bitwise check
                             if ($user_settings[$user->data['user_id']]['blog_subscription_default'] & $type) {
                                 $subscribed[$type] = true;
                             }
                         }
                     }
                     foreach ($subscription_types as $type => $name) {
                         $template->assign_block_vars('subscriptions', array('TYPE' => 'subscription_' . $type, 'NAME' => isset($user->lang[$name]) ? $user->lang[$name] : $name, 'S_CHECKED' => isset($subscribed[$type]) ? true : false));
                     }
                 }
                 if ($auth->acl_get('u_blog_style')) {
                     $available_styles = array(array('name' => $user->lang['NONE'], 'value' => 0, 'demo' => $phpbb_root_path . 'images/spacer.gif'));
                     $sql = 'SELECT * FROM ' . STYLES_TABLE . ' s, ' . STYLES_TEMPLATE_TABLE . ' st WHERE style_active = 1 AND s.template_id = st.template_id';
                     $result = $db->sql_query($sql);
                     while ($row = $db->sql_fetchrow($result)) {
                         $demo = $phpbb_root_path . 'images/spacer.gif';
                         if (@file_exists($phpbb_root_path . 'styles/' . $row['template_path'] . '/template/blog/demo.png')) {
                             $demo = $phpbb_root_path . 'styles/' . $row['template_path'] . '/template/blog/demo.png';
                         } else {
                             if (@file_exists($phpbb_root_path . 'styles/' . $row['template_path'] . '/template/blog/demo.gif')) {
                                 $demo = $phpbb_root_path . 'styles/' . $row['template_path'] . '/template/blog/demo.gif';
                             } else {
                                 if (@file_exists($phpbb_root_path . 'styles/' . $row['template_path'] . '/template/blog/demo.jpg')) {
                                     $demo = $phpbb_root_path . 'styles/' . $row['template_path'] . '/template/blog/demo.jpg';
                                 }
                             }
                         }
                         $available_styles[] = array('name' => $row['style_name'], 'value' => $row['style_id'], 'demo' => $demo);
                     }
                     $db->sql_freeresult($result);
                     $dh = @opendir($phpbb_root_path . 'blog/styles/');
                     if ($dh) {
                         while (($file = readdir($dh)) !== false) {
                             if (file_exists($phpbb_root_path . 'blog/styles/' . $file . '/style.' . $phpEx)) {
                                 // Inside of the style.php file, add to the $available_styles array
                                 include $phpbb_root_path . 'blog/styles/' . $file . '/style.' . $phpEx;
                             }
                         }
                         closedir($dh);
                     }
                     foreach ($available_styles as $row) {
                         if (isset($user_settings[$user->data['user_id']]) && $user_settings[$user->data['user_id']]['blog_style'] == $row['value'] && isset($row['demo']) && $row['demo']) {
                             $default_demo = $row['demo'];
                         }
                         $template->assign_block_vars('blog_styles', array('VALUE' => $row['value'], 'SELECTED' => isset($user_settings[$user->data['user_id']]) && $user_settings[$user->data['user_id']]['blog_style'] == $row['value'] ? true : false, 'NAME' => $row['name'], 'BLOG_CSS' => isset($row['blog_css']) && $row['blog_css'] ? true : false, 'DEMO' => isset($row['demo']) && $row['demo'] ? $row['demo'] : ''));
                     }
                 }
                 $template->assign_vars(array('S_BLOG_INSTANT_REDIRECT' => isset($user_settings[$user->data['user_id']]) ? $user_settings[$user->data['user_id']]['instant_redirect'] : 0, 'S_SUBSCRIPTIONS' => $config['user_blog_subscription_enabled'] ? true : false, 'S_BLOG_STYLE' => isset($available_styles) && sizeof($available_styles) > 1 ? true : false, 'S_BLOG_CSS' => $auth->acl_get('u_blog_css') ? true : false, 'DEFAULT_DEMO' => isset($default_demo) ? $default_demo : $phpbb_root_path . 'images/spacer.gif', 'BLOG_CSS' => isset($user_settings[$user->data['user_id']]) ? $user_settings[$user->data['user_id']]['blog_css'] : ''));
             }
             break;
         case 'ucp_blog_permissions':
             if (!$config['user_blog_user_permissions']) {
                 $error[] = $user->lang['USER_PERMISSIONS_DISABLED'];
                 $template->assign_vars(array('PERMISSIONS_DISABLED' => true));
             } else {
                 if ($submit) {
                     $sql_ary = array('perm_guest' => request_var('perm_guest', 1), 'perm_registered' => request_var('perm_registered', 2), 'perm_foe' => request_var('perm_foe', 0), 'perm_friend' => request_var('perm_friend', 2));
                     update_user_blog_settings($user->data['user_id'], $sql_ary, isset($_POST['resync']) ? true : false);
                 } else {
                     permission_settings_builder();
                 }
             }
             break;
         case 'ucp_blog_title_description':
             include $phpbb_root_path . 'includes/functions_posting.' . $phpEx;
             include $phpbb_root_path . 'includes/message_parser.' . $phpEx;
             include $phpbb_root_path . 'blog/includes/functions_posting.' . $phpEx;
             if (!function_exists('display_custom_bbcodes')) {
                 include $phpbb_root_path . 'includes/functions_display.' . $phpEx;
             }
             $user->add_lang('posting');
             $post_options = new post_options();
             $post_options->set_status(true, true, true);
             $post_options->set_in_template();
             if ($submit || $preview) {
                 // see if they tried submitting a message or suject(if they hit preview or submit) put it in an array for consistency with the edit mode
                 $blog_title = utf8_normalize_nfc(request_var('title', '', true));
                 $blog_description = utf8_normalize_nfc(request_var('message', '', true));
                 // set up the message parser to parse BBCode, Smilies, etc
                 $message_parser = new parse_message();
                 $message_parser->message = $blog_description;
                 $message_parser->parse($post_options->enable_bbcode, $post_options->enable_magic_url, $post_options->enable_smilies, $post_options->img_status, $post_options->flash_status, $post_options->bbcode_status, $post_options->url_status);
             } else {
                 if (isset($user_settings[$user->data['user_id']])) {
                     $blog_title = $user_settings[$user->data['user_id']]['title'];
                     $blog_description = $user_settings[$user->data['user_id']]['description'];
                     decode_message($blog_description, $user_settings[$user->data['user_id']]['description_bbcode_uid']);
                 } else {
                     $blog_title = $blog_description = '';
                 }
             }
             if (!$submit || sizeof($error)) {
                 if ($preview && !sizeof($error)) {
                     $preview_message = $message_parser->format_display($post_options->enable_bbcode, $post_options->enable_magic_url, $post_options->enable_smilies, false);
                     // output some data to the template parser
                     $template->assign_vars(array('S_DISPLAY_PREVIEW' => true, 'PREVIEW_SUBJECT' => censor_text($blog_title), 'PREVIEW_MESSAGE' => $preview_message, 'POST_DATE' => $user->format_date(time())));
                 }
                 // Generate smiley listing
                 generate_smilies('inline', false);
                 // Build custom bbcodes array
                 display_custom_bbcodes();
                 $template->assign_vars(array('S_PREVIEW_BUTTON' => true, 'TITLE' => $blog_title, 'MESSAGE' => $blog_description));
             } else {
                 if ($submit) {
                     $sql_ary = array('user_id' => $user->data['user_id'], 'title' => $blog_title, 'description' => $message_parser->message, 'description_bbcode_bitfield' => $message_parser->bbcode_bitfield, 'description_bbcode_uid' => $message_parser->bbcode_uid);
                     unset($message_parser);
                     update_user_blog_settings($user->data['user_id'], $sql_ary);
                 }
             }
             break;
         default:
             $default = true;
             $temp = compact('mode', 'error', 'default');
             blog_plugins::plugin_do_ref('ucp_default', $temp);
             // make sure you set default to false if you use your own page
             extract($temp);
             if ($default) {
                 trigger_error('NO_MODE');
             }
     }
     blog_plugins::plugin_do('ucp_end');
     if ($submit && !sizeof($error)) {
         //$cache->destroy('_blog_settings_' . $user->data['user_id']);
         meta_refresh(3, $this->u_action);
         $message = $user->lang['PREFERENCES_UPDATED'] . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], '<a href="' . $this->u_action . '">', '</a>');
         trigger_error($message);
     }
     $template->assign_vars(array('L_TITLE' => $user->lang[strtoupper($mode)], 'L_TITLE_EXPLAIN' => $user->lang[strtoupper($mode) . '_EXPLAIN'], 'ERROR' => sizeof($error) ? implode($error, '<br />') : false, 'MODE' => $mode, 'S_UCP_ACTION' => $this->u_action));
     $this->tpl_name = 'blog/ucp_blog';
     $this->page_title = strtoupper($mode);
 }
コード例 #23
0
ファイル: message.php プロジェクト: kairion/customisation-db
 /**
  * Display the message box
  */
 public function display()
 {
     $for_edit = $this->post_object->generate_text_for_edit();
     // Initialize our post options class
     $post_options = new post_options();
     $post_options->set_auth($this->auth['bbcode'], $this->auth['smilies'], true, true, true);
     $post_options->set_status($for_edit['allow_bbcode'], $for_edit['allow_smilies'], $for_edit['allow_urls']);
     // Setup the attachments!
     $this->setup_attachments();
     if ($this->auth['polls']) {
         $this->posting_panels['poll-panel'] = 'POLL';
     }
     // Add the forum key
     add_form_key($this->settings['form_name']);
     // Generate smiley listing
     if ($post_options->get_status('smilies')) {
         phpbb::_include('functions_posting', 'generate_smilies');
         generate_smilies('inline', false);
     }
     // Build custom bbcodes array
     if ($post_options->get_status('bbcode')) {
         phpbb::_include('functions_display', 'display_custom_bbcodes');
         display_custom_bbcodes();
     }
     // Display the Captcha if required
     if ($this->settings['display_captcha']) {
         phpbb::_include('captcha/captcha_factory', false, 'phpbb_captcha_factory');
         $captcha =& phpbb_captcha_factory::get_instance(phpbb::$config['captcha_plugin']);
         $captcha->init(CONFIRM_POST);
         if ($captcha->validate($this->request_data()) !== false) {
             phpbb::reset_template();
             // Parse the captcha template
             phpbb::$template->set_filenames(array('captcha' => $captcha->get_template()));
             // Correct confirm image link
             phpbb::$template->assign_var('CONFIRM_IMAGE_LINK', phpbb::append_sid('ucp', 'mode=confirm&amp;confirm_id=' . $captcha->confirm_id . '&amp;type=' . $captcha->type));
             phpbb::$template->assign_display('captcha', 'CAPTCHA', false);
             titania::set_custom_template();
         }
         $this->s_hidden_fields = array_merge($this->s_hidden_fields, $captcha->get_hidden_fields());
     }
     $post_options->set_in_template();
     // Save the opened panel to show again
     $default_panel = request_var('open_panel', 'options-panel');
     $default_panel = isset($this->posting_panels[$default_panel]) ? $default_panel : 'options-panel';
     phpbb::$template->assign_vars(array('ACCESS_OPTIONS' => titania_access_select(isset($for_edit['access']) ? $for_edit['access'] : TITANIA_ACCESS_PUBLIC), 'EDIT_REASON' => isset($for_edit['edit_reason']) ? $for_edit['edit_reason'] : '', 'POSTING_FORM_NAME' => $this->settings['form_name'], 'POSTING_TEXT_NAME' => $this->settings['text_name'], 'POSTING_SUBJECT_NAME' => $this->settings['subject_name'], 'POSTING_PANELS_DEFAULT' => $default_panel, 'POSTING_TEXT' => $this->settings['text_default_override'] !== false ? $this->settings['text_default_override'] : $for_edit['text'], 'SUBJECT' => $this->settings['subject_default_override'] !== false ? $this->settings['subject_default_override'] : (isset($for_edit['subject']) ? $for_edit['subject'] : ''), 'S_ENHANCED_EDITOR' => phpbb::$user->data['titania_enhanced_editor'], 'S_DISPLAY_ERROR' => $this->settings['display_error'], 'S_DISPLAY_SUBJECT' => $this->settings['display_subject'], 'S_STICKY_TOPIC_ALLOWED' => $this->auth['sticky_topic'], 'S_STICKY_TOPIC_CHECKED' => isset($for_edit['topic_sticky']) ? $for_edit['topic_sticky'] : false, 'S_LOCK_TOPIC_ALLOWED' => $this->auth['lock_topic'], 'S_LOCK_TOPIC_CHECKED' => isset($for_edit['topic_locked']) ? $for_edit['topic_locked'] : false, 'S_LOCK_POST_ALLOWED' => $this->auth['lock'], 'S_LOCK_POST_CHECKED' => isset($for_edit['locked']) ? $for_edit['locked'] : false, 'S_EDIT_REASON' => $this->settings['display_edit_reason'], 'S_HIDDEN_FIELDS' => build_hidden_fields($this->s_hidden_fields)));
     if ($this->attachments) {
         phpbb::$template->assign_vars(array('UPLOADER' => $this->attachments->parse_uploader($this->settings['attachment_tpl']), 'S_FORM_ENCTYPE' => ' enctype="multipart/form-data"'));
     }
     $this->display_panels();
 }
コード例 #24
0
/**
* Handle basic posting setup and some basic checks
*/
function handle_basic_posting_data($check = false, $page = 'blog', $mode = 'add')
{
    global $auth, $blog_attachment, $blog_id, $config, $db, $template, $user, $phpbb_root_path, $phpEx, $category_ary;
    $submit = isset($_POST['submit']) ? true : false;
    $preview = isset($_POST['preview']) ? true : false;
    $refresh = isset($_POST['add_file']) || isset($_POST['delete_file']) || isset($_POST['cancel_unglobalise']) ? true : false;
    $submitted = $submit || $preview || $refresh ? true : false;
    // shortcut for any of the 3 above
    if ($check) {
        $error = array();
        // check the captcha
        if ($mode == 'add') {
            if (!handle_captcha('check')) {
                $error[] = $user->lang['CONFIRM_CODE_WRONG'];
            }
        }
        // check the form key
        if (!check_form_key('postform')) {
            $error[] = $user->lang['FORM_INVALID'];
        }
        return $error;
    } else {
        $above_subject = $above_message = $above_submit = $panel_data = '';
        $panels = array('options-panel' => $user->lang['OPTIONS']);
        if ($page == 'blog') {
            $category_list = make_category_select($category_ary);
            if ($category_list) {
                $panels['categories-panel'] = $user->lang['CATEGORIES'];
            }
            $panels['poll-panel'] = $user->lang['ADD_POLL'];
            if ($user->data['is_registered']) {
                // Build permissions box
                permission_settings_builder(true, $mode);
                $panels['permissions-panel'] = $user->lang['PERMISSIONS'];
            }
            // Some variables
            $template->assign_vars(array('CATEGORY_LIST' => $category_list, 'S_CAT_0_SELECTED' => is_array($category_ary) && in_array(0, $category_ary), 'S_SHOW_POLL_BOX' => true));
        }
        if ($mode == 'add') {
            // setup the captcha
            handle_captcha('build');
        }
        // Subscriptions
        if ($config['user_blog_subscription_enabled'] && $user->data['is_registered']) {
            $panels['subscriptions-panel'] = $user->lang['SUBSCRIPTION'];
            $subscription_types = get_blog_subscription_types();
            $subscribed = array();
            if ($page == 'blog' && $mode == 'add' && !$submitted) {
                // check default subscription settings from user_settings
                global $user_settings;
                get_user_settings($user->data['user_id']);
                if (isset($user_settings[$user->data['user_id']])) {
                    foreach ($subscription_types as $type => $name) {
                        // Bitwise check
                        if ($user_settings[$user->data['user_id']]['blog_subscription_default'] & $type) {
                            $subscribed[$type] = true;
                        }
                    }
                }
            } else {
                if (!$submitted) {
                    // check set subscription settings
                    $sql = 'SELECT * FROM ' . BLOGS_SUBSCRIPTION_TABLE . '
					WHERE sub_user_id = ' . $user->data['user_id'] . '
						AND blog_id = ' . intval($blog_id);
                    $result = $db->sql_query($sql);
                    while ($row = $db->sql_fetchrow($result)) {
                        $subscribed[$row['sub_type']] = true;
                    }
                }
            }
            foreach ($subscription_types as $type => $name) {
                $template->assign_block_vars('subscriptions', array('TYPE' => 'subscription_' . $type, 'NAME' => isset($user->lang[$name]) ? $user->lang[$name] : $name, 'S_CHECKED' => $submitted && request_var('subscription_' . $type, false) || isset($subscribed[$type]) ? true : false));
            }
        }
        // Attachments
        $attachment_data = $blog_attachment->attachment_data;
        $filename_data = $blog_attachment->filename_data;
        $form_enctype = @ini_get('file_uploads') == '0' || strtolower(@ini_get('file_uploads')) == 'off' || @ini_get('file_uploads') == '0' || !$config['allow_attachments'] || !$auth->acl_get('u_attach') ? '' : ' enctype="multipart/form-data"';
        posting_gen_inline_attachments($attachment_data);
        if ($auth->acl_get('u_blogattach') && $config['allow_attachments'] && $form_enctype) {
            $allowed_extensions = $blog_attachment->obtain_blog_attach_extensions();
            if (sizeof($allowed_extensions['_allowed_'])) {
                $blog_attachment->posting_gen_attachment_entry($attachment_data, $filename_data);
                $panels['attach-panel'] = $user->lang['ADD_ATTACHMENT'];
            }
        }
        // Add the forum key
        add_form_key('postform');
        // Generate smiley listing
        generate_smilies('inline', false);
        // Build custom bbcodes array
        display_custom_bbcodes();
        $temp = compact('page', 'mode', 'panels', 'panel_data', 'above_subject', 'above_message', 'above_submit');
        blog_plugins::plugin_do_ref('function_handle_basic_posting_data', $temp);
        extract($temp);
        $template->assign_vars(array('EXTRA_ABOVE_SUBJECT' => $above_subject, 'EXTRA_ABOVE_MESSAGE' => $above_message, 'EXTRA_ABOVE_SUBMIT' => $above_submit, 'EXTRA_PANELS' => $panel_data, 'JS_PANELS_LIST' => "'" . implode("', '", array_keys($panels)) . "'", 'UA_PROGRESS_BAR' => append_sid("{$phpbb_root_path}posting.{$phpEx}", "mode=popup", false), 'S_BLOG' => $page == 'blog' ? true : false, 'S_REPLY' => $page == 'reply' ? true : false, 'S_CLOSE_PROGRESS_WINDOW' => isset($_POST['add_file']) ? true : false, 'S_FORM_ENCTYPE' => $form_enctype));
        foreach ($panels as $name => $title) {
            $template->assign_vars(array('S_' . strtoupper(str_replace('-', '_', $name)) => true));
            $template->assign_block_vars('panel_list', array('NAME' => $name, 'TITLE' => $title));
        }
    }
}
コード例 #25
0
ファイル: ucp_pm_compose.php プロジェクト: Voxel37/phpbb
/**
* Compose private message
* Called from ucp_pm with mode == 'compose'
*/
function compose_pm($id, $mode, $action, $user_folders = array())
{
    global $template, $db, $auth, $user, $cache;
    global $phpbb_root_path, $phpEx, $config;
    global $request, $phpbb_dispatcher, $phpbb_container;
    // Damn php and globals - i know, this is horrible
    // Needed for handle_message_list_actions()
    global $refresh, $submit, $preview;
    include $phpbb_root_path . 'includes/functions_posting.' . $phpEx;
    include $phpbb_root_path . 'includes/functions_display.' . $phpEx;
    include $phpbb_root_path . 'includes/message_parser.' . $phpEx;
    if (!$action) {
        $action = 'post';
    }
    add_form_key('ucp_pm_compose');
    // Grab only parameters needed here
    $to_user_id = request_var('u', 0);
    $to_group_id = request_var('g', 0);
    $msg_id = request_var('p', 0);
    $draft_id = request_var('d', 0);
    $lastclick = request_var('lastclick', 0);
    // Reply to all triggered (quote/reply)
    $reply_to_all = request_var('reply_to_all', 0);
    $address_list = $request->variable('address_list', array('' => array(0 => '')));
    $submit = isset($_POST['post']) ? true : false;
    $preview = isset($_POST['preview']) ? true : false;
    $save = isset($_POST['save']) ? true : false;
    $load = isset($_POST['load']) ? true : false;
    $cancel = isset($_POST['cancel']) && !isset($_POST['save']) ? true : false;
    $delete = isset($_POST['delete']) ? true : false;
    $remove_u = isset($_REQUEST['remove_u']) ? true : false;
    $remove_g = isset($_REQUEST['remove_g']) ? true : false;
    $add_to = isset($_REQUEST['add_to']) ? true : false;
    $add_bcc = isset($_REQUEST['add_bcc']) ? true : false;
    $refresh = isset($_POST['add_file']) || isset($_POST['delete_file']) || $save || $load || $remove_u || $remove_g || $add_to || $add_bcc;
    $action = $delete && !$preview && !$refresh && $submit ? 'delete' : $action;
    $select_single = $config['allow_mass_pm'] && $auth->acl_get('u_masspm') ? false : true;
    $error = array();
    $current_time = time();
    // Was cancel pressed? If so then redirect to the appropriate page
    if ($cancel || $current_time - $lastclick < 2 && $submit) {
        if ($msg_id) {
            redirect(append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'i=pm&amp;mode=view&amp;action=view_message&amp;p=' . $msg_id));
        }
        redirect(append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'i=pm'));
    }
    // Since viewtopic.php language entries are used in several modes,
    // we include the language file here
    $user->add_lang('viewtopic');
    /**
     * Modify the default vars before composing a PM
     *
     * @event core.ucp_pm_compose_modify_data
     * @var	int		msg_id					post_id in the page request
     * @var	int		to_user_id				The id of whom the message is to
     * @var	int		to_group_id				The id of the group the message is to
     * @var	bool	submit					Whether the form has been submitted
     * @var	bool	preview					Whether the user is previewing the PM or not
     * @var	string	action					One of: post, reply, quote, forward, quotepost, edit, delete, smilies
     * @var	bool	delete					Whether the user is deleting the PM
     * @var	int		reply_to_all			Value of reply_to_all request variable.
     * @since 3.1.4-RC1
     */
    $vars = array('msg_id', 'to_user_id', 'to_group_id', 'submit', 'preview', 'action', 'delete', 'reply_to_all');
    extract($phpbb_dispatcher->trigger_event('core.ucp_pm_compose_modify_data', compact($vars)));
    // Output PM_TO box if message composing
    if ($action != 'edit') {
        // Add groups to PM box
        if ($config['allow_mass_pm'] && $auth->acl_get('u_masspm_group')) {
            $sql = 'SELECT g.group_id, g.group_name, g.group_type
				FROM ' . GROUPS_TABLE . ' g';
            if (!$auth->acl_gets('a_group', 'a_groupadd', 'a_groupdel')) {
                $sql .= ' LEFT JOIN ' . USER_GROUP_TABLE . ' ug
					ON (
						g.group_id = ug.group_id
						AND ug.user_id = ' . $user->data['user_id'] . '
						AND ug.user_pending = 0
					)
					WHERE (g.group_type <> ' . GROUP_HIDDEN . ' OR ug.user_id = ' . $user->data['user_id'] . ')';
            }
            $sql .= $auth->acl_gets('a_group', 'a_groupadd', 'a_groupdel') ? ' WHERE ' : ' AND ';
            $sql .= 'g.group_receive_pm = 1
				ORDER BY g.group_type DESC, g.group_name ASC';
            $result = $db->sql_query($sql);
            $group_options = '';
            while ($row = $db->sql_fetchrow($result)) {
                $group_options .= '<option' . ($row['group_type'] == GROUP_SPECIAL ? ' class="sep"' : '') . ' value="' . $row['group_id'] . '">' . ($row['group_type'] == GROUP_SPECIAL ? $user->lang['G_' . $row['group_name']] : $row['group_name']) . '</option>';
            }
            $db->sql_freeresult($result);
        }
        $template->assign_vars(array('S_SHOW_PM_BOX' => true, 'S_ALLOW_MASS_PM' => $config['allow_mass_pm'] && $auth->acl_get('u_masspm') ? true : false, 'S_GROUP_OPTIONS' => $config['allow_mass_pm'] && $auth->acl_get('u_masspm_group') ? $group_options : '', 'U_FIND_USERNAME' => append_sid("{$phpbb_root_path}memberlist.{$phpEx}", "mode=searchuser&amp;form=postform&amp;field=username_list&amp;select_single={$select_single}")));
    }
    $sql = '';
    $folder_id = 0;
    // What is all this following SQL for? Well, we need to know
    // some basic information in all cases before we do anything.
    switch ($action) {
        case 'post':
            if (!$auth->acl_get('u_sendpm')) {
                trigger_error('NO_AUTH_SEND_MESSAGE');
            }
            break;
        case 'reply':
        case 'quote':
        case 'forward':
        case 'quotepost':
            if (!$msg_id) {
                trigger_error('NO_MESSAGE');
            }
            if (!$auth->acl_get('u_sendpm')) {
                trigger_error('NO_AUTH_SEND_MESSAGE');
            }
            if ($action == 'quotepost') {
                $sql = 'SELECT p.post_id as msg_id, p.forum_id, p.post_text as message_text, p.poster_id as author_id, p.post_time as message_time, p.bbcode_bitfield, p.bbcode_uid, p.enable_sig, p.enable_smilies, p.enable_magic_url, t.topic_title as message_subject, u.username as quote_username
					FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t, ' . USERS_TABLE . " u\n\t\t\t\t\tWHERE p.post_id = {$msg_id}\n\t\t\t\t\t\tAND t.topic_id = p.topic_id\n\t\t\t\t\t\tAND u.user_id = p.poster_id";
            } else {
                $sql = 'SELECT t.folder_id, p.*, u.username as quote_username
					FROM ' . PRIVMSGS_TO_TABLE . ' t, ' . PRIVMSGS_TABLE . ' p, ' . USERS_TABLE . ' u
					WHERE t.user_id = ' . $user->data['user_id'] . "\n\t\t\t\t\t\tAND p.author_id = u.user_id\n\t\t\t\t\t\tAND t.msg_id = p.msg_id\n\t\t\t\t\t\tAND p.msg_id = {$msg_id}";
            }
            break;
        case 'edit':
            if (!$msg_id) {
                trigger_error('NO_MESSAGE');
            }
            // check for outbox (not read) status, we do not allow editing if one user already having the message
            $sql = 'SELECT p.*, t.folder_id
				FROM ' . PRIVMSGS_TO_TABLE . ' t, ' . PRIVMSGS_TABLE . ' p
				WHERE t.user_id = ' . $user->data['user_id'] . '
					AND t.folder_id = ' . PRIVMSGS_OUTBOX . "\n\t\t\t\t\tAND t.msg_id = {$msg_id}\n\t\t\t\t\tAND t.msg_id = p.msg_id";
            break;
        case 'delete':
            if (!$auth->acl_get('u_pm_delete')) {
                trigger_error('NO_AUTH_DELETE_MESSAGE');
            }
            if (!$msg_id) {
                trigger_error('NO_MESSAGE');
            }
            $sql = 'SELECT msg_id, pm_unread, pm_new, author_id, folder_id
				FROM ' . PRIVMSGS_TO_TABLE . '
				WHERE user_id = ' . $user->data['user_id'] . "\n\t\t\t\t\tAND msg_id = {$msg_id}";
            break;
        case 'smilies':
            generate_smilies('window', 0);
            break;
        default:
            trigger_error('NO_ACTION_MODE', E_USER_ERROR);
            break;
    }
    if ($action == 'forward' && (!$config['forward_pm'] || !$auth->acl_get('u_pm_forward'))) {
        trigger_error('NO_AUTH_FORWARD_MESSAGE');
    }
    if ($action == 'edit' && !$auth->acl_get('u_pm_edit')) {
        trigger_error('NO_AUTH_EDIT_MESSAGE');
    }
    if ($sql) {
        /**
         * Alter sql query to get message for user to write the PM
         *
         * @event core.ucp_pm_compose_compose_pm_basic_info_query_before
         * @var	string	sql						String with the query to be executed
         * @var	array	forum_list				List of forums that contain the posts
         * @var	int		visibility_const		Integer with one of the possible ITEM_* constant values
         * @var	int		msg_id					topic_id in the page request
         * @var	int		to_user_id				The id of whom the message is to
         * @var	int		to_group_id				The id of the group whom the message is to
         * @var	bool	submit					Whether the user is sending the PM or not
         * @var	bool	preview					Whether the user is previewing the PM or not
         * @var	string	action					One of: post, reply, quote, forward, quotepost, edit, delete, smilies
         * @var	bool	delete					Whether the user is deleting the PM
         * @var	int		reply_to_all			Value of reply_to_all request variable.
         * @var	string	limit_time_sql			String with the SQL code to limit the time interval of the post (Note: May be empty string)
         * @var	string	sort_order_sql			String with the ORDER BY SQL code used in this query
         * @since 3.1.0-RC5
         */
        $vars = array('sql', 'forum_list', 'visibility_const', 'msg_id', 'to_user_id', 'to_group_id', 'submit', 'preview', 'action', 'delete', 'reply_to_all', 'limit_time_sql', 'sort_order_sql');
        extract($phpbb_dispatcher->trigger_event('core.ucp_pm_compose_compose_pm_basic_info_query_before', compact($vars)));
        $result = $db->sql_query($sql);
        $post = $db->sql_fetchrow($result);
        $db->sql_freeresult($result);
        if (!$post) {
            // If editing it could be the recipient already read the message...
            if ($action == 'edit') {
                $sql = 'SELECT p.*, t.folder_id
					FROM ' . PRIVMSGS_TO_TABLE . ' t, ' . PRIVMSGS_TABLE . ' p
					WHERE t.user_id = ' . $user->data['user_id'] . "\n\t\t\t\t\t\tAND t.msg_id = {$msg_id}\n\t\t\t\t\t\tAND t.msg_id = p.msg_id";
                $result = $db->sql_query($sql);
                $post = $db->sql_fetchrow($result);
                $db->sql_freeresult($result);
                if ($post) {
                    trigger_error('NO_EDIT_READ_MESSAGE');
                }
            }
            trigger_error('NO_MESSAGE');
        }
        if ($action == 'quotepost') {
            if ($post['forum_id'] && !$auth->acl_get('f_read', $post['forum_id']) || !$post['forum_id'] && !$auth->acl_getf_global('f_read')) {
                trigger_error('NOT_AUTHORISED');
            }
            /**
             * Get the result of querying for the post to be quoted in the pm message
             *
             * @event core.ucp_pm_compose_quotepost_query_after
             * @var	string	sql					The original SQL used in the query
             * @var	array	post				Associative array with the data of the quoted post
             * @var	array	msg_id				The post_id that was searched to get the message for quoting
             * @var	int		visibility_const	Visibility of the quoted post (one of the possible ITEM_* constant values)
             * @var	int		topic_id			Topic ID of the quoted post
             * @var	int		to_user_id			Users the message is sent to
             * @var	int		to_group_id			Groups the message is sent to
             * @var	bool	submit				Whether the user is sending the PM or not
             * @var	bool	preview				Whether the user is previewing the PM or not
             * @var	string	action				One of: post, reply, quote, forward, quotepost, edit, delete, smilies
             * @var	bool	delete				If deleting message
             * @var	int		reply_to_all		Value of reply_to_all request variable.
             * @since 3.1.0-RC5
             */
            $vars = array('sql', 'post', 'msg_id', 'visibility_const', 'topic_id', 'to_user_id', 'to_group_id', 'submit', 'preview', 'action', 'delete', 'reply_to_all');
            extract($phpbb_dispatcher->trigger_event('core.ucp_pm_compose_quotepost_query_after', compact($vars)));
            // Passworded forum?
            if ($post['forum_id']) {
                $sql = 'SELECT forum_id, forum_name, forum_password
					FROM ' . FORUMS_TABLE . '
					WHERE forum_id = ' . (int) $post['forum_id'];
                $result = $db->sql_query($sql);
                $forum_data = $db->sql_fetchrow($result);
                $db->sql_freeresult($result);
                if (!empty($forum_data['forum_password'])) {
                    login_forum_box($forum_data);
                }
            }
        }
        $msg_id = (int) $post['msg_id'];
        $folder_id = isset($post['folder_id']) ? $post['folder_id'] : 0;
        $message_text = isset($post['message_text']) ? $post['message_text'] : '';
        if ((!$post['author_id'] || $post['author_id'] == ANONYMOUS && $action != 'delete') && $msg_id) {
            trigger_error('NO_AUTHOR');
        }
        if ($action == 'quotepost') {
            // Decode text for message display
            decode_message($message_text, $post['bbcode_uid']);
        }
        if ($action != 'delete') {
            $enable_urls = $post['enable_magic_url'];
            $enable_sig = isset($post['enable_sig']) ? $post['enable_sig'] : 0;
            $message_attachment = isset($post['message_attachment']) ? $post['message_attachment'] : 0;
            $message_subject = $post['message_subject'];
            $message_time = $post['message_time'];
            $bbcode_uid = $post['bbcode_uid'];
            $quote_username = isset($post['quote_username']) ? $post['quote_username'] : '';
            $icon_id = isset($post['icon_id']) ? $post['icon_id'] : 0;
            if (($action == 'reply' || $action == 'quote' || $action == 'quotepost') && !sizeof($address_list) && !$refresh && !$submit && !$preview) {
                // Add the original author as the recipient if quoting a post or only replying and not having checked "reply to all"
                if ($action == 'quotepost' || !$reply_to_all) {
                    $address_list = array('u' => array($post['author_id'] => 'to'));
                } else {
                    // We try to include every previously listed member from the TO Header - Reply to all
                    $address_list = rebuild_header(array('to' => $post['to_address']));
                    // Add the author (if he is already listed then this is no shame (it will be overwritten))
                    $address_list['u'][$post['author_id']] = 'to';
                    // Now, make sure the user itself is not listed. ;)
                    if (isset($address_list['u'][$user->data['user_id']])) {
                        unset($address_list['u'][$user->data['user_id']]);
                    }
                }
            } else {
                if ($action == 'edit' && !sizeof($address_list) && !$refresh && !$submit && !$preview) {
                    // Rebuild TO and BCC Header
                    $address_list = rebuild_header(array('to' => $post['to_address'], 'bcc' => $post['bcc_address']));
                }
            }
            if ($action == 'quotepost') {
                $check_value = 0;
            } else {
                $check_value = ($post['enable_bbcode'] + 1 << 8) + ($post['enable_smilies'] + 1 << 4) + ($enable_urls + 1 << 2) + ($post['enable_sig'] + 1 << 1);
            }
        }
    } else {
        $message_attachment = 0;
        $message_text = $message_subject = '';
        if ($to_user_id && $to_user_id != ANONYMOUS && $action == 'post') {
            $address_list['u'][$to_user_id] = 'to';
        } else {
            if ($to_group_id && $action == 'post') {
                $address_list['g'][$to_group_id] = 'to';
            }
        }
        $check_value = 0;
    }
    if (($to_group_id || isset($address_list['g'])) && (!$config['allow_mass_pm'] || !$auth->acl_get('u_masspm_group'))) {
        trigger_error('NO_AUTH_GROUP_MESSAGE');
    }
    if ($action == 'edit' && !$refresh && !$preview && !$submit) {
        if (!($message_time > time() - $config['pm_edit_time'] * 60 || !$config['pm_edit_time'])) {
            trigger_error('CANNOT_EDIT_MESSAGE_TIME');
        }
    }
    if ($action == 'post') {
        $template->assign_var('S_NEW_MESSAGE', true);
    }
    if (!isset($icon_id)) {
        $icon_id = 0;
    }
    $message_parser = new parse_message();
    $plupload = $phpbb_container->get('plupload');
    $message_parser->set_plupload($plupload);
    $message_parser->message = $action == 'reply' ? '' : $message_text;
    unset($message_text);
    $s_action = append_sid("{$phpbb_root_path}ucp.{$phpEx}", "i={$id}&amp;mode={$mode}&amp;action={$action}", true, $user->session_id);
    $s_action .= ($folder_id ? "&amp;f={$folder_id}" : '') . ($msg_id ? "&amp;p={$msg_id}" : '');
    // Delete triggered ?
    if ($action == 'delete') {
        // Folder id has been determined by the SQL Statement
        // $folder_id = request_var('f', PRIVMSGS_NO_BOX);
        // Do we need to confirm ?
        if (confirm_box(true)) {
            delete_pm($user->data['user_id'], $msg_id, $folder_id);
            // jump to next message in "history"? nope, not for the moment. But able to be included later.
            $meta_info = append_sid("{$phpbb_root_path}ucp.{$phpEx}", "i=pm&amp;folder={$folder_id}");
            $message = $user->lang['MESSAGE_DELETED'];
            meta_refresh(3, $meta_info);
            $message .= '<br /><br />' . sprintf($user->lang['RETURN_FOLDER'], '<a href="' . $meta_info . '">', '</a>');
            trigger_error($message);
        } else {
            $s_hidden_fields = array('p' => $msg_id, 'f' => $folder_id, 'action' => 'delete');
            // "{$phpbb_root_path}ucp.$phpEx?i=pm&amp;mode=compose"
            confirm_box(false, 'DELETE_MESSAGE', build_hidden_fields($s_hidden_fields));
        }
        redirect(append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'i=pm&amp;mode=view&amp;action=view_message&amp;p=' . $msg_id));
    }
    // Get maximum number of allowed recipients
    $sql = 'SELECT MAX(g.group_max_recipients) as max_recipients
		FROM ' . GROUPS_TABLE . ' g, ' . USER_GROUP_TABLE . ' ug
		WHERE ug.user_id = ' . $user->data['user_id'] . '
			AND ug.user_pending = 0
			AND ug.group_id = g.group_id';
    $result = $db->sql_query($sql);
    $max_recipients = (int) $db->sql_fetchfield('max_recipients');
    $db->sql_freeresult($result);
    $max_recipients = !$max_recipients ? $config['pm_max_recipients'] : $max_recipients;
    // If this is a quote/reply "to all"... we may increase the max_recpients to the number of original recipients
    if (($action == 'reply' || $action == 'quote') && $max_recipients && $reply_to_all) {
        // We try to include every previously listed member from the TO Header
        $list = rebuild_header(array('to' => $post['to_address']));
        // Can be an empty array too ;)
        $list = !empty($list['u']) ? $list['u'] : array();
        $list[$post['author_id']] = 'to';
        if (isset($list[$user->data['user_id']])) {
            unset($list[$user->data['user_id']]);
        }
        $max_recipients = $max_recipients < sizeof($list) ? sizeof($list) : $max_recipients;
        unset($list);
    }
    // Handle User/Group adding/removing
    handle_message_list_actions($address_list, $error, $remove_u, $remove_g, $add_to, $add_bcc);
    // Check mass pm to group permission
    if ((!$config['allow_mass_pm'] || !$auth->acl_get('u_masspm_group')) && !empty($address_list['g'])) {
        $address_list = array();
        $error[] = $user->lang['NO_AUTH_GROUP_MESSAGE'];
    }
    // Check mass pm to users permission
    if ((!$config['allow_mass_pm'] || !$auth->acl_get('u_masspm')) && num_recipients($address_list) > 1) {
        $address_list = get_recipients($address_list, 1);
        $error[] = $user->lang('TOO_MANY_RECIPIENTS', 1);
    }
    // Check for too many recipients
    if (!empty($address_list['u']) && $max_recipients && sizeof($address_list['u']) > $max_recipients) {
        $address_list = get_recipients($address_list, $max_recipients);
        $error[] = $user->lang('TOO_MANY_RECIPIENTS', $max_recipients);
    }
    // Always check if the submitted attachment data is valid and belongs to the user.
    // Further down (especially in submit_post()) we do not check this again.
    $message_parser->get_submitted_attachment_data();
    if ($message_attachment && !$submit && !$refresh && !$preview && $action == 'edit') {
        // Do not change to SELECT *
        $sql = 'SELECT attach_id, is_orphan, attach_comment, real_filename, filesize
			FROM ' . ATTACHMENTS_TABLE . "\n\t\t\tWHERE post_msg_id = {$msg_id}\n\t\t\t\tAND in_message = 1\n\t\t\t\tAND is_orphan = 0\n\t\t\tORDER BY filetime DESC";
        $result = $db->sql_query($sql);
        $message_parser->attachment_data = array_merge($message_parser->attachment_data, $db->sql_fetchrowset($result));
        $db->sql_freeresult($result);
    }
    if (!in_array($action, array('quote', 'edit', 'delete', 'forward'))) {
        $enable_sig = $config['allow_sig'] && $config['allow_sig_pm'] && $auth->acl_get('u_sig') && $user->optionget('attachsig');
        $enable_smilies = $config['allow_smilies'] && $auth->acl_get('u_pm_smilies') && $user->optionget('smilies');
        $enable_bbcode = $config['allow_bbcode'] && $auth->acl_get('u_pm_bbcode') && $user->optionget('bbcode');
        $enable_urls = true;
    }
    $enable_magic_url = $drafts = false;
    // User own some drafts?
    if ($auth->acl_get('u_savedrafts') && $action != 'delete') {
        $sql = 'SELECT draft_id
			FROM ' . DRAFTS_TABLE . '
			WHERE forum_id = 0
				AND topic_id = 0
				AND user_id = ' . $user->data['user_id'] . ($draft_id ? " AND draft_id <> {$draft_id}" : '');
        $result = $db->sql_query_limit($sql, 1);
        $row = $db->sql_fetchrow($result);
        $db->sql_freeresult($result);
        if ($row) {
            $drafts = true;
        }
    }
    if ($action == 'edit') {
        $message_parser->bbcode_uid = $bbcode_uid;
    }
    $bbcode_status = $config['allow_bbcode'] && $config['auth_bbcode_pm'] && $auth->acl_get('u_pm_bbcode') ? true : false;
    $smilies_status = $config['allow_smilies'] && $config['auth_smilies_pm'] && $auth->acl_get('u_pm_smilies') ? true : false;
    $img_status = $config['auth_img_pm'] && $auth->acl_get('u_pm_img') ? true : false;
    $flash_status = $config['auth_flash_pm'] && $auth->acl_get('u_pm_flash') ? true : false;
    $url_status = $config['allow_post_links'] ? true : false;
    // Save Draft
    if ($save && $auth->acl_get('u_savedrafts')) {
        $subject = utf8_normalize_nfc(request_var('subject', '', true));
        $subject = !$subject && $action != 'post' ? $user->lang['NEW_MESSAGE'] : $subject;
        $message = utf8_normalize_nfc(request_var('message', '', true));
        if ($subject && $message) {
            if (confirm_box(true)) {
                $sql = 'INSERT INTO ' . DRAFTS_TABLE . ' ' . $db->sql_build_array('INSERT', array('user_id' => $user->data['user_id'], 'topic_id' => 0, 'forum_id' => 0, 'save_time' => $current_time, 'draft_subject' => $subject, 'draft_message' => $message));
                $db->sql_query($sql);
                $redirect_url = append_sid("{$phpbb_root_path}ucp.{$phpEx}", "i=pm&amp;mode={$mode}");
                meta_refresh(3, $redirect_url);
                $message = $user->lang['DRAFT_SAVED'] . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], '<a href="' . $redirect_url . '">', '</a>');
                trigger_error($message);
            } else {
                $s_hidden_fields = build_hidden_fields(array('mode' => $mode, 'action' => $action, 'save' => true, 'subject' => $subject, 'message' => $message, 'u' => $to_user_id, 'g' => $to_group_id, 'p' => $msg_id));
                $s_hidden_fields .= build_address_field($address_list);
                confirm_box(false, 'SAVE_DRAFT', $s_hidden_fields);
            }
        } else {
            if (utf8_clean_string($subject) === '') {
                $error[] = $user->lang['EMPTY_MESSAGE_SUBJECT'];
            }
            if (utf8_clean_string($message) === '') {
                $error[] = $user->lang['TOO_FEW_CHARS'];
            }
        }
        unset($subject, $message);
    }
    // Load Draft
    if ($draft_id && $auth->acl_get('u_savedrafts')) {
        $sql = 'SELECT draft_subject, draft_message
			FROM ' . DRAFTS_TABLE . "\n\t\t\tWHERE draft_id = {$draft_id}\n\t\t\t\tAND topic_id = 0\n\t\t\t\tAND forum_id = 0\n\t\t\t\tAND user_id = " . $user->data['user_id'];
        $result = $db->sql_query_limit($sql, 1);
        if ($row = $db->sql_fetchrow($result)) {
            $message_parser->message = $row['draft_message'];
            $message_subject = $row['draft_subject'];
            $template->assign_var('S_DRAFT_LOADED', true);
        } else {
            $draft_id = 0;
        }
        $db->sql_freeresult($result);
    }
    // Load Drafts
    if ($load && $drafts) {
        load_drafts(0, 0, $id, $action, $msg_id);
    }
    if ($submit || $preview || $refresh) {
        if (($submit || $preview) && !check_form_key('ucp_pm_compose')) {
            $error[] = $user->lang['FORM_INVALID'];
        }
        $subject = utf8_normalize_nfc(request_var('subject', '', true));
        $message_parser->message = utf8_normalize_nfc(request_var('message', '', true));
        $icon_id = request_var('icon', 0);
        $enable_bbcode = !$bbcode_status || isset($_POST['disable_bbcode']) ? false : true;
        $enable_smilies = !$smilies_status || isset($_POST['disable_smilies']) ? false : true;
        $enable_urls = isset($_POST['disable_magic_url']) ? 0 : 1;
        $enable_sig = !$config['allow_sig'] || !$config['allow_sig_pm'] ? false : (isset($_POST['attach_sig']) ? true : false);
        if ($submit) {
            $status_switch = ($enable_bbcode + 1 << 8) + ($enable_smilies + 1 << 4) + ($enable_urls + 1 << 2) + ($enable_sig + 1 << 1);
            $status_switch = $status_switch != $check_value;
        } else {
            $status_switch = 1;
        }
        // Parse Attachments - before checksum is calculated
        $message_parser->parse_attachments('fileupload', $action, 0, $submit, $preview, $refresh, true);
        if (sizeof($message_parser->warn_msg) && !($remove_u || $remove_g || $add_to || $add_bcc)) {
            $error[] = implode('<br />', $message_parser->warn_msg);
            $message_parser->warn_msg = array();
        }
        // Parse message
        $message_parser->parse($enable_bbcode, $config['allow_post_links'] ? $enable_urls : false, $enable_smilies, $img_status, $flash_status, true, $config['allow_post_links']);
        // On a refresh we do not care about message parsing errors
        if (sizeof($message_parser->warn_msg) && !$refresh) {
            $error[] = implode('<br />', $message_parser->warn_msg);
        }
        if ($action != 'edit' && !$preview && !$refresh && $config['flood_interval'] && !$auth->acl_get('u_ignoreflood')) {
            // Flood check
            $last_post_time = $user->data['user_lastpost_time'];
            if ($last_post_time) {
                if ($last_post_time && $current_time - $last_post_time < intval($config['flood_interval'])) {
                    $error[] = $user->lang['FLOOD_ERROR'];
                }
            }
        }
        // Subject defined
        if ($submit) {
            if (utf8_clean_string($subject) === '') {
                $error[] = $user->lang['EMPTY_MESSAGE_SUBJECT'];
            }
            if (!sizeof($address_list)) {
                $error[] = $user->lang['NO_RECIPIENT'];
            }
        }
        // Store message, sync counters
        if (!sizeof($error) && $submit) {
            $pm_data = array('msg_id' => (int) $msg_id, 'from_user_id' => $user->data['user_id'], 'from_user_ip' => $user->ip, 'from_username' => $user->data['username'], 'reply_from_root_level' => isset($post['root_level']) ? (int) $post['root_level'] : 0, 'reply_from_msg_id' => (int) $msg_id, 'icon_id' => (int) $icon_id, 'enable_sig' => (bool) $enable_sig, 'enable_bbcode' => (bool) $enable_bbcode, 'enable_smilies' => (bool) $enable_smilies, 'enable_urls' => (bool) $enable_urls, 'bbcode_bitfield' => $message_parser->bbcode_bitfield, 'bbcode_uid' => $message_parser->bbcode_uid, 'message' => $message_parser->message, 'attachment_data' => $message_parser->attachment_data, 'filename_data' => $message_parser->filename_data, 'address_list' => $address_list);
            // ((!$message_subject) ? $subject : $message_subject)
            $msg_id = submit_pm($action, $subject, $pm_data);
            $return_message_url = append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'i=pm&amp;mode=view&amp;p=' . $msg_id);
            $inbox_folder_url = append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'i=pm&amp;folder=inbox');
            $outbox_folder_url = append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'i=pm&amp;folder=outbox');
            $folder_url = '';
            if ($folder_id > 0 && isset($user_folders[$folder_id])) {
                $folder_url = append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'i=pm&amp;folder=' . $folder_id);
            }
            $return_box_url = $action === 'post' || $action === 'edit' ? $outbox_folder_url : $inbox_folder_url;
            $return_box_lang = $action === 'post' || $action === 'edit' ? 'PM_OUTBOX' : 'PM_INBOX';
            $save_message = $action === 'edit' ? $user->lang['MESSAGE_EDITED'] : $user->lang['MESSAGE_STORED'];
            $message = $save_message . '<br /><br />' . $user->lang('VIEW_PRIVATE_MESSAGE', '<a href="' . $return_message_url . '">', '</a>');
            $last_click_type = 'CLICK_RETURN_FOLDER';
            if ($folder_url) {
                $message .= '<br /><br />' . sprintf($user->lang['CLICK_RETURN_FOLDER'], '<a href="' . $folder_url . '">', '</a>', $user_folders[$folder_id]['folder_name']);
                $last_click_type = 'CLICK_GOTO_FOLDER';
            }
            $message .= '<br /><br />' . sprintf($user->lang[$last_click_type], '<a href="' . $return_box_url . '">', '</a>', $user->lang[$return_box_lang]);
            meta_refresh(3, $return_message_url);
            trigger_error($message);
        }
        $message_subject = $subject;
    }
    // Preview
    if (!sizeof($error) && $preview) {
        $preview_message = $message_parser->format_display($enable_bbcode, $enable_urls, $enable_smilies, false);
        $preview_signature = $user->data['user_sig'];
        $preview_signature_uid = $user->data['user_sig_bbcode_uid'];
        $preview_signature_bitfield = $user->data['user_sig_bbcode_bitfield'];
        // Signature
        if ($enable_sig && $config['allow_sig'] && $preview_signature) {
            $parse_sig = new parse_message($preview_signature);
            $parse_sig->bbcode_uid = $preview_signature_uid;
            $parse_sig->bbcode_bitfield = $preview_signature_bitfield;
            $parse_sig->format_display($config['allow_sig_bbcode'], $config['allow_sig_links'], $config['allow_sig_smilies']);
            $preview_signature = $parse_sig->message;
            unset($parse_sig);
        } else {
            $preview_signature = '';
        }
        // Attachment Preview
        if (sizeof($message_parser->attachment_data)) {
            $template->assign_var('S_HAS_ATTACHMENTS', true);
            $update_count = array();
            $attachment_data = $message_parser->attachment_data;
            parse_attachments(false, $preview_message, $attachment_data, $update_count, true);
            foreach ($attachment_data as $i => $attachment) {
                $template->assign_block_vars('attachment', array('DISPLAY_ATTACHMENT' => $attachment));
            }
            unset($attachment_data);
        }
        $preview_subject = censor_text($subject);
        if (!sizeof($error)) {
            $template->assign_vars(array('PREVIEW_SUBJECT' => $preview_subject, 'PREVIEW_MESSAGE' => $preview_message, 'PREVIEW_SIGNATURE' => $preview_signature, 'S_DISPLAY_PREVIEW' => true));
        }
        unset($message_text);
    }
    // Decode text for message display
    $bbcode_uid = ($action == 'quote' || $action == 'forward') && !$preview && !$refresh && (!sizeof($error) || sizeof($error) && !$submit) ? $bbcode_uid : $message_parser->bbcode_uid;
    $message_parser->decode_message($bbcode_uid);
    if (($action == 'quote' || $action == 'quotepost') && !$preview && !$refresh && !$submit) {
        if ($action == 'quotepost') {
            $post_id = request_var('p', 0);
            if ($config['allow_post_links']) {
                $message_link = "[url=" . generate_board_url() . "/viewtopic.{$phpEx}?p={$post_id}#p{$post_id}]{$user->lang['SUBJECT']}{$user->lang['COLON']} {$message_subject}[/url]\n\n";
            } else {
                $message_link = $user->lang['SUBJECT'] . $user->lang['COLON'] . ' ' . $message_subject . " (" . generate_board_url() . "/viewtopic.{$phpEx}?p={$post_id}#p{$post_id})\n\n";
            }
        } else {
            $message_link = '';
        }
        $message_parser->message = $message_link . '[quote=&quot;' . $quote_username . '&quot;]' . censor_text(trim($message_parser->message)) . "[/quote]\n";
    }
    if (($action == 'reply' || $action == 'quote' || $action == 'quotepost') && !$preview && !$refresh) {
        $message_subject = (!preg_match('/^Re:/', $message_subject) ? 'Re: ' : '') . censor_text($message_subject);
    }
    if ($action == 'forward' && !$preview && !$refresh && !$submit) {
        $fwd_to_field = write_pm_addresses(array('to' => $post['to_address']), 0, true);
        if ($config['allow_post_links']) {
            $quote_username_text = '[url=' . generate_board_url() . "/memberlist.{$phpEx}?mode=viewprofile&amp;u={$post['author_id']}]{$quote_username}[/url]";
        } else {
            $quote_username_text = $quote_username . ' (' . generate_board_url() . "/memberlist.{$phpEx}?mode=viewprofile&amp;u={$post['author_id']})";
        }
        $forward_text = array();
        $forward_text[] = $user->lang['FWD_ORIGINAL_MESSAGE'];
        $forward_text[] = sprintf($user->lang['FWD_SUBJECT'], censor_text($message_subject));
        $forward_text[] = sprintf($user->lang['FWD_DATE'], $user->format_date($message_time, false, true));
        $forward_text[] = sprintf($user->lang['FWD_FROM'], $quote_username_text);
        $forward_text[] = sprintf($user->lang['FWD_TO'], implode($user->lang['COMMA_SEPARATOR'], $fwd_to_field['to']));
        $message_parser->message = implode("\n", $forward_text) . "\n\n[quote=&quot;{$quote_username}&quot;]\n" . censor_text(trim($message_parser->message)) . "\n[/quote]";
        $message_subject = (!preg_match('/^Fwd:/', $message_subject) ? 'Fwd: ' : '') . censor_text($message_subject);
    }
    $attachment_data = $message_parser->attachment_data;
    $filename_data = $message_parser->filename_data;
    $message_text = $message_parser->message;
    // MAIN PM PAGE BEGINS HERE
    // Generate smiley listing
    generate_smilies('inline', 0);
    // Generate PM Icons
    $s_pm_icons = false;
    if ($config['enable_pm_icons']) {
        $s_pm_icons = posting_gen_topic_icons($action, $icon_id);
    }
    // Generate inline attachment select box
    posting_gen_inline_attachments($attachment_data);
    // Build address list for display
    // array('u' => array($author_id => 'to'));
    if (sizeof($address_list)) {
        // Get Usernames and Group Names
        $result = array();
        if (!empty($address_list['u'])) {
            $sql = 'SELECT user_id as id, username as name, user_colour as colour
				FROM ' . USERS_TABLE . '
				WHERE ' . $db->sql_in_set('user_id', array_map('intval', array_keys($address_list['u']))) . '
				ORDER BY username_clean ASC';
            $result['u'] = $db->sql_query($sql);
        }
        if (!empty($address_list['g'])) {
            $sql = 'SELECT g.group_id AS id, g.group_name AS name, g.group_colour AS colour, g.group_type
				FROM ' . GROUPS_TABLE . ' g';
            if (!$auth->acl_gets('a_group', 'a_groupadd', 'a_groupdel')) {
                $sql .= ' LEFT JOIN ' . USER_GROUP_TABLE . ' ug
					ON (
						g.group_id = ug.group_id
						AND ug.user_id = ' . $user->data['user_id'] . '
						AND ug.user_pending = 0
					)
					WHERE (g.group_type <> ' . GROUP_HIDDEN . ' OR ug.user_id = ' . $user->data['user_id'] . ')';
            }
            $sql .= $auth->acl_gets('a_group', 'a_groupadd', 'a_groupdel') ? ' WHERE ' : ' AND ';
            $sql .= 'g.group_receive_pm = 1
				AND ' . $db->sql_in_set('g.group_id', array_map('intval', array_keys($address_list['g']))) . '
				ORDER BY g.group_name ASC';
            $result['g'] = $db->sql_query($sql);
        }
        $u = $g = array();
        $_types = array('u', 'g');
        foreach ($_types as $type) {
            if (isset($result[$type]) && $result[$type]) {
                while ($row = $db->sql_fetchrow($result[$type])) {
                    if ($type == 'g') {
                        $row['name'] = $row['group_type'] == GROUP_SPECIAL ? $user->lang['G_' . $row['name']] : $row['name'];
                    }
                    ${$type}[$row['id']] = array('name' => $row['name'], 'colour' => $row['colour']);
                }
                $db->sql_freeresult($result[$type]);
            }
        }
        // Now Build the address list
        $plain_address_field = '';
        foreach ($address_list as $type => $adr_ary) {
            foreach ($adr_ary as $id => $field) {
                if (!isset(${$type}[$id])) {
                    unset($address_list[$type][$id]);
                    continue;
                }
                $field = $field == 'to' ? 'to' : 'bcc';
                $type = $type == 'u' ? 'u' : 'g';
                $id = (int) $id;
                $tpl_ary = array('IS_GROUP' => $type == 'g' ? true : false, 'IS_USER' => $type == 'u' ? true : false, 'UG_ID' => $id, 'NAME' => ${$type}[$id]['name'], 'COLOUR' => ${$type}[$id]['colour'] ? '#' . ${$type}[$id]['colour'] : '', 'TYPE' => $type);
                if ($type == 'u') {
                    $tpl_ary = array_merge($tpl_ary, array('U_VIEW' => get_username_string('profile', $id, ${$type}[$id]['name'], ${$type}[$id]['colour']), 'NAME_FULL' => get_username_string('full', $id, ${$type}[$id]['name'], ${$type}[$id]['colour'])));
                } else {
                    $tpl_ary = array_merge($tpl_ary, array('U_VIEW' => append_sid("{$phpbb_root_path}memberlist.{$phpEx}", 'mode=group&amp;g=' . $id)));
                }
                $template->assign_block_vars($field . '_recipient', $tpl_ary);
            }
        }
    }
    // Build hidden address list
    $s_hidden_address_field = build_address_field($address_list);
    $bbcode_checked = isset($enable_bbcode) ? !$enable_bbcode : ($config['allow_bbcode'] && $auth->acl_get('u_pm_bbcode') ? !$user->optionget('bbcode') : 1);
    $smilies_checked = isset($enable_smilies) ? !$enable_smilies : ($config['allow_smilies'] && $auth->acl_get('u_pm_smilies') ? !$user->optionget('smilies') : 1);
    $urls_checked = isset($enable_urls) ? !$enable_urls : 0;
    $sig_checked = $enable_sig;
    switch ($action) {
        case 'post':
            $page_title = $user->lang['POST_NEW_PM'];
            break;
        case 'quote':
            $page_title = $user->lang['POST_QUOTE_PM'];
            break;
        case 'quotepost':
            $page_title = $user->lang['POST_PM_POST'];
            break;
        case 'reply':
            $page_title = $user->lang['POST_REPLY_PM'];
            break;
        case 'edit':
            $page_title = $user->lang['POST_EDIT_PM'];
            break;
        case 'forward':
            $page_title = $user->lang['POST_FORWARD_PM'];
            break;
        default:
            trigger_error('NO_ACTION_MODE', E_USER_ERROR);
            break;
    }
    $s_hidden_fields = '<input type="hidden" name="lastclick" value="' . $current_time . '" />';
    $s_hidden_fields .= isset($check_value) ? '<input type="hidden" name="status_switch" value="' . $check_value . '" />' : '';
    $s_hidden_fields .= $draft_id || isset($_REQUEST['draft_loaded']) ? '<input type="hidden" name="draft_loaded" value="' . (isset($_REQUEST['draft_loaded']) ? $request->variable('draft_loaded', 0) : $draft_id) . '" />' : '';
    $form_enctype = @ini_get('file_uploads') == '0' || strtolower(@ini_get('file_uploads')) == 'off' || !$config['allow_pm_attach'] || !$auth->acl_get('u_pm_attach') ? '' : ' enctype="multipart/form-data"';
    // Start assigning vars for main posting page ...
    $template->assign_vars(array('L_POST_A' => $page_title, 'L_ICON' => $user->lang['PM_ICON'], 'L_MESSAGE_BODY_EXPLAIN' => $user->lang('MESSAGE_BODY_EXPLAIN', (int) $config['max_post_chars']), 'SUBJECT' => isset($message_subject) ? $message_subject : '', 'MESSAGE' => $message_text, 'BBCODE_STATUS' => $bbcode_status ? sprintf($user->lang['BBCODE_IS_ON'], '<a href="' . append_sid("{$phpbb_root_path}faq.{$phpEx}", 'mode=bbcode') . '">', '</a>') : sprintf($user->lang['BBCODE_IS_OFF'], '<a href="' . append_sid("{$phpbb_root_path}faq.{$phpEx}", 'mode=bbcode') . '">', '</a>'), 'IMG_STATUS' => $img_status ? $user->lang['IMAGES_ARE_ON'] : $user->lang['IMAGES_ARE_OFF'], 'FLASH_STATUS' => $flash_status ? $user->lang['FLASH_IS_ON'] : $user->lang['FLASH_IS_OFF'], 'SMILIES_STATUS' => $smilies_status ? $user->lang['SMILIES_ARE_ON'] : $user->lang['SMILIES_ARE_OFF'], 'URL_STATUS' => $url_status ? $user->lang['URL_IS_ON'] : $user->lang['URL_IS_OFF'], 'MAX_FONT_SIZE' => (int) $config['max_post_font_size'], 'MINI_POST_IMG' => $user->img('icon_post_target', $user->lang['PM']), 'ERROR' => sizeof($error) ? implode('<br />', $error) : '', 'MAX_RECIPIENTS' => $config['allow_mass_pm'] && ($auth->acl_get('u_masspm') || $auth->acl_get('u_masspm_group')) ? $max_recipients : 0, 'S_COMPOSE_PM' => true, 'S_EDIT_POST' => $action == 'edit', 'S_SHOW_PM_ICONS' => $s_pm_icons, 'S_BBCODE_ALLOWED' => $bbcode_status ? 1 : 0, 'S_BBCODE_CHECKED' => $bbcode_checked ? ' checked="checked"' : '', 'S_SMILIES_ALLOWED' => $smilies_status, 'S_SMILIES_CHECKED' => $smilies_checked ? ' checked="checked"' : '', 'S_SIG_ALLOWED' => $config['allow_sig'] && $config['allow_sig_pm'] && $auth->acl_get('u_sig'), 'S_SIGNATURE_CHECKED' => $sig_checked ? ' checked="checked"' : '', 'S_LINKS_ALLOWED' => $url_status, 'S_MAGIC_URL_CHECKED' => $urls_checked ? ' checked="checked"' : '', 'S_SAVE_ALLOWED' => $auth->acl_get('u_savedrafts') && $action != 'edit' ? true : false, 'S_HAS_DRAFTS' => $auth->acl_get('u_savedrafts') && $drafts, 'S_FORM_ENCTYPE' => $form_enctype, 'S_ATTACH_DATA' => json_encode($message_parser->attachment_data), 'S_BBCODE_IMG' => $img_status, 'S_BBCODE_FLASH' => $flash_status, 'S_BBCODE_QUOTE' => true, 'S_BBCODE_URL' => $url_status, 'S_POST_ACTION' => $s_action, 'S_HIDDEN_ADDRESS_FIELD' => $s_hidden_address_field, 'S_HIDDEN_FIELDS' => $s_hidden_fields, 'S_CLOSE_PROGRESS_WINDOW' => isset($_POST['add_file']), 'U_PROGRESS_BAR' => append_sid("{$phpbb_root_path}posting.{$phpEx}", 'f=0&amp;mode=popup'), 'UA_PROGRESS_BAR' => addslashes(append_sid("{$phpbb_root_path}posting.{$phpEx}", 'f=0&amp;mode=popup'))));
    // Build custom bbcodes array
    display_custom_bbcodes();
    // Show attachment box for adding attachments if true
    $allowed = $auth->acl_get('u_pm_attach') && $config['allow_pm_attach'] && $form_enctype;
    if ($allowed) {
        $max_files = $auth->acl_gets('a_', 'm_') ? 0 : (int) $config['max_attachments_pm'];
        $plupload->configure($cache, $template, $s_action, false, $max_files);
    }
    // Attachment entry
    posting_gen_attachment_entry($attachment_data, $filename_data, $allowed);
    // Message History
    if ($action == 'reply' || $action == 'quote' || $action == 'forward') {
        if (message_history($msg_id, $user->data['user_id'], $post, array(), true)) {
            $template->assign_var('S_DISPLAY_HISTORY', true);
        }
    }
}
コード例 #26
0
    public function handle_video()
    {
        if (!$this->auth->acl_get('u_video_view_full')) {
            trigger_error($this->user->lang['UNAUTHED']);
        }
        // Initial var setup
        $video_id = $this->request->variable('id', 0);
        $video_url = $this->request->variable('video_url', '', true);
        $video_title = $this->request->variable('video_title', '', true);
        $video_cat_id = $this->request->variable('cid', 0);
        $video_cat_ids = $this->request->variable('id', 0);
        $username = $this->request->variable('username', '', true);
        $user_id = $this->request->variable('user_id', 0);
        $youtube_id = $this->request->variable('youtube_id', '', true);
        $create_time = $this->request->variable('create_time', '');
        $video_views = $this->request->variable('video_views', 0);
        $sql_start = $this->request->variable('start', 0);
        $sql_limit = $this->request->variable('limit', 10);
        $sql_limits = $this->request->variable('limit', $this->config['comments_per_page']);
        //comments
        // Comments
        $cmnt_id = $this->request->variable('cmntid', 0);
        $cmnt_video_id = $this->request->variable('v', 0);
        $cmnt_text = utf8_normalize_nfc($this->request->variable('cmnt_text', '', true));
        $mode = $this->request->variable('mode', '');
        $submit = isset($_POST['submit']) ? true : false;
        // Determine board url - we may need it later
        $board_url = generate_board_url() . '/';
        $web_path = defined('PHPBB_USE_BOARD_URL_PATH') && PHPBB_USE_BOARD_URL_PATH ? $board_url : $this->phpbb_root_path;
        if (!$this->config['google_api_key']) {
            if ($this->auth->acl_get('a_')) {
                trigger_error($this->user->lang['NO_KEY_ADMIN']);
            } else {
                trigger_error($this->user->lang['NO_KEY_USER']);
            }
        }
        /**
         * Get youtube video ID from URL
         * From: http://halgatewood.com/php-get-the-youtube-video-id-from-a-youtube-url/
         */
        function getYouTubeIdFromURL($url)
        {
            $pattern = '/(?:youtube\\.com\\/(?:[^\\/]+\\/.+\\/|(?:v|e(?:mbed)?)\\/|.*[?&]v=)|youtu\\.be\\/)([^"&?\\/ ]{11})/i';
            preg_match($pattern, $url, $matches);
            return isset($matches[1]) ? $matches[1] : false;
        }
        $youtube_id = getYouTubeIdFromURL($video_url);
        $jsonURL = file_get_contents("https://www.googleapis.com/youtube/v3/videos?id={$youtube_id}&key={$this->config['google_api_key']}&type=video&part=snippet");
        $json = json_decode($jsonURL);
        if (isset($json->items[0]->snippet)) {
            $video_title = $json->items[0]->snippet->title;
        }
        $sql_ary = array('video_id' => $video_id, 'video_url' => $video_url, 'video_title' => $video_title, 'video_cat_id' => $video_cat_id, 'username' => $username, 'user_id' => $user_id, 'youtube_id' => $youtube_id, 'create_time' => (int) time(), 'video_views' => $video_views);
        $error = $row = array();
        $current_time = time();
        $this->template->assign_vars(array('S_NEW_VIDEO' => $this->auth->acl_get('u_video_post') ? true : false, 'SCRIPT_NAME' => 'video', 'U_VIDEO' => $this->helper->route('dmzx_youtubegallery_controller')));
        $this->template->assign_block_vars('navlinks', array('FORUM_NAME' => $this->user->lang['VIDEO_INDEX'], 'U_VIEW_FORUM' => $this->helper->route('dmzx_youtubegallery_controller')));
        switch ($mode) {
            case 'submit':
                // User is a bot?!
                if ($this->user->data['is_bot']) {
                    redirect(append_sid("{$this->phpbb_root_path}index.{$this->phpEx}"));
                }
                $redirect_url = $this->helper->route('dmzx_youtubegallery_controller', array('mode' => 'submit'));
                // Is a guest?!
                if ($this->user->data['user_id'] == ANONYMOUS) {
                    login_box($redirect_url);
                }
                // Can post?!
                if (!$this->auth->acl_get('u_video_post')) {
                    trigger_error($this->user->lang['UNAUTHED']);
                }
                $l_title = $this->user->lang['VIDEO_SUBMIT'];
                $template_html = 'video_editor.html';
                $s_action = $this->helper->route('dmzx_youtubegallery_controller', array('mode' => 'submit'));
                $s_hidden_fields = '';
                $form_enctype = '';
                add_form_key('postform');
                // List of categories
                $sql = 'SELECT *
					FROM ' . $this->video_cat_table . '
					ORDER BY video_cat_id DESC';
                $result = $this->db->sql_query($sql);
                while ($row = $this->db->sql_fetchrow($result)) {
                    $this->template->assign_block_vars('cat', array('VIDEO_CAT_ID' => censor_text($row['video_cat_id']), 'VIDEO_CAT_TITLE' => censor_text($row['video_cat_title'])));
                }
                // Start assigning vars for main posting page ...
                $this->template->assign_vars(array('S_USER_ID' => $this->user->data['user_id'], 'S_USERNAME' => $this->user->data['username'], 'S_FORM_ENCTYPE' => $form_enctype, 'S_POST_ACTION' => $s_action, 'S_HIDDEN_FIELDS' => $s_hidden_fields, 'ERROR' => sizeof($error) ? implode('<br />', $error) : ''));
                $this->template->assign_block_vars('navlinks', array('FORUM_NAME' => $this->user->lang['VIDEO_SUBMIT']));
                add_form_key('postform');
                if ($submit) {
                    if (!check_form_key('postform')) {
                        trigger_error('FORM_INVALID');
                    }
                }
                switch ($submit) {
                    case 'add':
                        if ($video_url == '') {
                            $meta_info = $this->helper->route('dmzx_youtubegallery_controller', array('mode' => 'submit'));
                            $message = $this->user->lang['NEED_VIDEO_URL'];
                            meta_refresh(3, $meta_info);
                            $message .= '<br /><br />' . sprintf($this->user->lang['PAGE_RETURN'], '<a href="' . $meta_info . '">', '</a>');
                            trigger_error($message);
                        } else {
                            $this->db->sql_query('INSERT INTO ' . $this->video_table . ' ' . $this->db->sql_build_array('INSERT', $sql_ary));
                            $u_action = $this->helper->route('dmzx_youtubegallery_controller');
                            $meta_info = $this->helper->route('dmzx_youtubegallery_controller');
                            $message = $this->user->lang['VIDEO_CREATED'];
                            meta_refresh(3, $meta_info);
                            $message .= '<br /><br />' . sprintf($this->user->lang['PAGE_RETURN'], '<a href="' . $meta_info . '">', '</a>');
                            trigger_error($message);
                        }
                        break;
                }
                break;
            case 'comment':
                $l_title = $this->user->lang['VIDEO_CMNT_SUBMIT'];
                $template_html = '@dmzx_youtubegallery/video_cmnt_editor.html';
                if (!$this->config['enable_comments']) {
                    trigger_error($this->user->lang['COMMENTS_DISABLED']);
                }
                // User is a bot?!
                if ($this->user->data['is_bot']) {
                    redirect(append_sid("{$this->phpbb_root_path}index.{$this->phpEx}"));
                }
                // Can post?!
                if (!$this->auth->acl_get('u_video_comment')) {
                    trigger_error($this->user->lang['UNAUTHED']);
                }
                $redirect_url = $this->helper->route('dmzx_youtubegallery_controller', array('mode' => 'comment', 'v' => (int) $video_id));
                // Is a guest?!
                if ($this->user->data['user_id'] == ANONYMOUS) {
                    login_box($redirect_url);
                }
                if (!function_exists('generate_smilies')) {
                    include $this->phpbb_root_path . 'includes/functions_posting.' . $this->phpEx;
                }
                if (!function_exists('display_custom_bbcodes')) {
                    include $this->phpbb_root_path . 'includes/functions_display.' . $this->phpEx;
                }
                //Settings for comments
                $this->user->setup('posting');
                display_custom_bbcodes();
                generate_smilies('inline', 0);
                $bbcode_status = $this->config['allow_bbcode'] ? true : false;
                $smilies_status = $this->config['allow_smilies'] ? true : false;
                $img_status = $bbcode_status ? true : false;
                $url_status = $this->config['allow_post_links'] ? true : false;
                $flash_status = $bbcode_status && $this->config['allow_post_flash'] ? true : false;
                $quote_status = true;
                $video_id = $this->request->variable('v', 0);
                $uid = $bitfield = $options = '';
                $allow_bbcode = $allow_urls = $allow_smilies = true;
                $s_action = $this->helper->route('dmzx_youtubegallery_controller', array('mode' => 'comment', 'v' => (int) $video_id));
                $s_hidden_fields = '';
                $form_enctype = '';
                add_form_key('postform');
                // Start assigning vars for main posting page ...
                $this->template->assign_vars(array('VIDEO_ID' => (int) $video_id, 'S_FORM_ENCTYPE' => $form_enctype, 'S_POST_ACTION' => $s_action, 'S_HIDDEN_FIELDS' => $s_hidden_fields, 'ERROR' => sizeof($error) ? implode('<br />', $error) : '', 'S_BBCODE_ALLOWED' => $bbcode_status ? 1 : 0, 'S_SMILIES_ALLOWED' => $smilies_status, 'S_BBCODE_IMG' => $img_status, 'S_BBCODE_URL' => $url_status, 'S_LINKS_ALLOWED' => $url_status, 'S_BBCODE_QUOTE' => $quote_status));
                if (isset($_POST['submit'])) {
                    if (!check_form_key('postform')) {
                        trigger_error('FORM_INVALID');
                    }
                    $video_id = $this->request->variable('v', 0);
                    // Get video to redirect :D
                    $message = $this->request->variable('cmnt_text', '', true);
                    generate_text_for_storage($message, $uid, $bitfield, $options, $allow_bbcode, $allow_urls, $allow_smilies);
                    $data = array('cmnt_video_id' => $this->request->variable('cmnt_video_id', 0), 'cmnt_poster_id' => $this->user->data['user_id'], 'cmnt_text' => $message, 'create_time' => time(), 'bbcode_uid' => $uid, 'bbcode_bitfield' => $bitfield, 'bbcode_options' => $options);
                    if ($message == '') {
                        $meta_info = $this->helper->route('dmzx_youtubegallery_controller', array('mode' => 'comment', 'v' => (int) $video_id));
                        $message = $this->user->lang['NEED_VIDEO_MESSAGE'];
                        meta_refresh(3, $meta_info);
                        $message .= '<br /><br />' . sprintf($this->user->lang['PAGE_RETURN'], '<a href="' . $meta_info . '">', '</a>');
                        trigger_error($message);
                    } else {
                        $this->db->sql_query('INSERT INTO ' . $this->video_cmnts_table . ' ' . $this->db->sql_build_array('INSERT', $data));
                        $meta_info = $this->helper->route('dmzx_youtubegallery_controller', array('mode' => 'view', 'id' => (int) $video_id));
                        $message = $this->user->lang['COMMENT_CREATED'];
                        meta_refresh(3, $meta_info);
                        $message .= '<br /><br />' . sprintf($this->user->lang['PAGE_RETURN'], '<a href="' . $meta_info . '">', '</a>');
                        trigger_error($message);
                    }
                }
                $this->template->assign_block_vars('navlinks', array('FORUM_NAME' => $this->user->lang['VIDEO_CMNT_SUBMIT']));
                break;
            case 'delcmnt':
                if (!$this->auth->acl_get('u_video_comment_delete')) {
                    trigger_error($this->user->lang['UNAUTHED']);
                }
                $video_id = $this->request->variable('v', 0);
                // Get video to redirect :D
                if (confirm_box(true)) {
                    $sql = 'DELETE FROM ' . $this->video_cmnts_table . '
						WHERE cmnt_id = ' . (int) $cmnt_id;
                    $this->db->sql_query($sql);
                    $meta_info = $this->helper->route('dmzx_youtubegallery_controller', array('mode' => 'view', 'id' => (int) $video_id));
                    $message = $this->user->lang['COMMENT_DELETED_SUCCESS'];
                    meta_refresh(1, $meta_info);
                    $message .= '<br /><br />' . sprintf($this->user->lang['PAGE_RETURN'], '<a href="' . $meta_info . '">', '</a>');
                    trigger_error($message);
                } else {
                    $s_hidden_fields = build_hidden_fields(array('id' => $cmnt_id, 'mode' => 'delcmnt'));
                    confirm_box(false, $this->user->lang['DELETE_COMMENT_CONFIRM'], $s_hidden_fields);
                    $meta_info = $this->helper->route('dmzx_youtubegallery_controller', array('mode' => 'view', 'id' => (int) $video_id));
                    meta_refresh(1, $meta_info);
                }
                break;
            case 'delete':
                if (!$this->auth->acl_get('u_video_delete')) {
                    trigger_error($this->user->lang['UNAUTHED']);
                }
                $l_title = $this->user->lang['DELETE_VIDEO'];
                if (confirm_box(true)) {
                    $sql = 'DELETE FROM ' . $this->video_table . '
						WHERE video_id = ' . $video_id;
                    $this->db->sql_query($sql);
                    $meta_info = $this->helper->route('dmzx_youtubegallery_controller');
                    $message = $this->user->lang['VIDEO_DELETED'];
                    meta_refresh(3, $meta_info);
                    $message .= '<br /><br />' . sprintf($this->user->lang['PAGE_RETURN'], '<a href="' . $meta_info . '">', '</a>');
                    trigger_error($message);
                } else {
                    $s_hidden_fields = build_hidden_fields(array('mode' => 'delete', 'submit' => true, 'video_id' => $video_id));
                    confirm_box(false, $this->user->lang['DELETE_VIDEO'], $s_hidden_fields);
                    $meta_info = $this->helper->route('dmzx_youtubegallery_controller');
                    $message = $this->user->lang['RETURN_TO_VIDEO_INDEX'];
                    meta_refresh(3, $meta_info);
                    $message .= '<br /><br />' . sprintf($this->user->lang['PAGE_RETURN'], '<a href="' . $meta_info . '">', '</a>');
                    trigger_error($message);
                }
                break;
            case 'view':
                if (!$this->auth->acl_get('u_video_view')) {
                    trigger_error($this->user->lang['VIDEO_UNAUTHED']);
                }
                // Update video view... but only for humans
                if (isset($this->user->data['session_page']) && !$this->user->data['is_bot']) {
                    $sql = 'UPDATE ' . $this->video_table . '
					SET video_views = video_views + 1
					WHERE video_id = ' . $video_id;
                    $this->db->sql_query($sql);
                }
                $sql_ary = array('SELECT' => 'v.*, u.*', 'FROM' => array($this->video_table => 'v', USERS_TABLE => 'u'), 'WHERE' => 'v.video_id = ' . (int) $video_id . ' and u.user_id = v.user_id', 'ORDER_BY' => 'v.video_id DESC');
                $sql = $this->db->sql_build_query('SELECT', $sql_ary);
                $result = $this->db->sql_query($sql);
                $row = $this->db->sql_fetchrow($result);
                $this->db->sql_freeresult($result);
                $page_title = $row['video_title'];
                $user_id = $row['user_id'];
                $flash_status = $this->config['allow_post_flash'] ? true : false;
                $delete_allowed = ($this->auth->acl_get('a_') or $this->auth->acl_get('m_') || $this->user->data['is_registered'] && $this->user->data['user_id'] == $row['user_id'] && $this->auth->acl_get('u_video_delete'));
                $this->template->assign_vars(array('VIDEO_ID' => censor_text($row['video_id']), 'VIDEO_TITLE' => censor_text($row['video_title']), 'VIDEO_VIEWS' => $row['video_views'], 'USERNAME' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']), 'YOUTUBE_ID' => censor_text($row['youtube_id']), 'VIDEO_TIME' => $this->user->format_date($row['create_time']), 'YOUTUBE_VIDEO' => 'http://www.youtube.com/watch?v=' . $row['youtube_id'], 'VIDEO_LINK' => generate_board_url() . $this->helper->route('dmzx_youtubegallery_controller', array('mode' => 'view', 'id' => $row['video_id'])), 'VIDEO_LINK_FLASH' => 'http://www.youtube.com/v/' . $row['youtube_id'], 'U_USER_VIDEOS' => $this->helper->route('dmzx_youtubegallery_controller', array('mode' => 'user_videos', 'user_id' => $this->user->data['user_id'])), 'U_DELETE' => $this->helper->route('dmzx_youtubegallery_controller', array('mode' => 'delete', 'id' => $row['video_id'])), 'DELETE_ALLOW' => $delete_allowed, 'S_BBCODE_FLASH' => $flash_status, 'FLASH_STATUS' => $flash_status ? $this->user->lang['FLASH_IS_ON'] : $this->user->lang['FLASH_IS_OFF'], 'S_VIDEO_WIDTH' => $this->config['video_width'], 'S_VIDEO_HEIGHT' => $this->config['video_height'], 'U_POST_COMMENT' => $this->helper->route('dmzx_youtubegallery_controller', array('mode' => 'comment', 'v' => $row['video_id'])), 'S_ENABLE_COMMENTS' => $this->config['enable_comments'], 'S_POST_COMMENT' => $this->auth->acl_get('u_video_comment')));
                // Comments
                $pagination_url = $this->helper->route('dmzx_youtubegallery_controller', array('mode' => 'view', 'id' => $video_id));
                $sql_ary = array('SELECT' => 'v.*, cmnt.*, u.username,u.user_colour,u.user_id', 'FROM' => array($this->video_table => 'v', $this->video_cmnts_table => 'cmnt', USERS_TABLE => 'u'), 'WHERE' => 'v.video_id = ' . (int) $video_id . '
						AND cmnt.cmnt_video_id = v.video_id
						AND u.user_id = cmnt.cmnt_poster_id', 'ORDER_BY' => 'cmnt.cmnt_id DESC');
                $sql = $this->db->sql_build_query('SELECT', $sql_ary);
                $result = $this->db->sql_query_limit($sql, $sql_limits, $sql_start);
                while ($row = $this->db->sql_fetchrow($result)) {
                    $delete_cmnt_allowed = ($this->auth->acl_get('a_') or $this->auth->acl_get('m_') || $this->user->data['is_registered'] && $this->user->data['user_id'] == $row['user_id'] && $this->auth->acl_get('u_video_comment_delete'));
                    $text = generate_text_for_display($row['cmnt_text'], $row['bbcode_uid'], $row['bbcode_bitfield'], $row['bbcode_options']);
                    $this->template->assign_block_vars('commentrow', array('COMMENT_ID' => $row['cmnt_id'], 'COMMENT_TEXT' => $text, 'COMMENT_TIME' => $this->user->format_date($row['create_time']), 'USERNAME' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']), 'S_DELETE_ALLOWED' => $delete_cmnt_allowed, 'U_DELETE' => $this->helper->route('dmzx_youtubegallery_controller', array('mode' => 'delcmnt', 'cmntid' => (int) $row['cmnt_id'], 'v' => (int) $row['cmnt_video_id']))));
                }
                $this->db->sql_freeresult($result);
                // We need another query for the video count
                $sql = 'SELECT COUNT(*) as comment_count
				FROM ' . $this->video_cmnts_table . '
				WHERE cmnt_video_id = ' . (int) $video_id;
                $result = $this->db->sql_query($sql);
                $videorow['comment_count'] = $this->db->sql_fetchfield('comment_count');
                $this->db->sql_freeresult($result);
                //Start pagination
                $start = $this->request->variable('start', 0);
                $this->pagination->generate_template_pagination($pagination_url, 'pagination', 'start', $videorow['comment_count'], $sql_limits, $sql_start);
                $this->template->assign_vars(array('TOTAL_COMMENTS' => $videorow['comment_count'] == 1 ? $this->user->lang['LIST_COMMENT'] : sprintf($this->user->lang['LIST_COMMENTS'], $videorow['comment_count'])));
                //End pagination
                // Count the videos user video ...
                $sql = 'SELECT COUNT(video_id) AS total_videos
				FROM ' . $this->video_table . '
				WHERE user_id = ' . (int) $user_id;
                $result = $this->db->sql_query($sql);
                $total_videos = (int) $this->db->sql_fetchfield('total_videos');
                $this->db->sql_freeresult($result);
                $this->template->assign_vars(array('TOTAL_VIDEOS' => $total_videos));
                // Count the video comments ...
                $sql_cmnts = 'SELECT COUNT(cmnt_id) AS total_comments
				FROM ' . $this->video_cmnts_table . '
				WHERE cmnt_video_id = ' . (int) $video_id;
                $result = $this->db->sql_query($sql_cmnts);
                $total_comments = (int) $this->db->sql_fetchfield('total_comments');
                $this->db->sql_freeresult($result);
                $this->template->assign_vars(array('TOTAL_COMMENTS_TITLE' => $total_comments));
                $l_title = $page_title;
                $template_html = 'video_view.html';
                $this->template->assign_block_vars('navlinks', array('FORUM_NAME' => $page_title));
                break;
            case 'cat':
                $sql_limit = $sql_limit > 10 ? 10 : $sql_limit;
                $pagination_url = $this->helper->route('dmzx_youtubegallery_controller', array('mode' => 'cat', 'id' => $video_cat_ids));
                $sql_ary = array('SELECT' => 'v.*,
				ct.video_cat_title,ct.video_cat_id,
				u.username,u.user_colour,u.user_id', 'FROM' => array($this->video_table => 'v', $this->video_cat_table => 'ct', USERS_TABLE => 'u'), 'WHERE' => 'v.video_cat_id = ' . $video_cat_ids . '
					AND ct.video_cat_id = ' . $video_cat_ids . '
					AND v.user_id = u.user_id', 'ORDER_BY' => 'v.video_id DESC');
                $sql = $this->db->sql_build_query('SELECT', $sql_ary);
                $result = $this->db->sql_query_limit($sql, $sql_limit, $sql_start);
                while ($row = $this->db->sql_fetchrow($result)) {
                    $this->template->assign_block_vars('video', array('VIDEO_TITLE' => $row['video_title'], 'VIDEO_CAT_ID' => $row['video_cat_id'], 'VIDEO_CAT_TITLE' => $row['video_cat_title'], 'VIDEO_VIEWS' => $row['video_views'], 'U_CAT' => $this->helper->route('dmzx_youtubegallery_controller', array('mode' => 'cat', 'id' => $row['video_cat_id'])), 'VIDEO_TIME' => $this->user->format_date($row['create_time']), 'VIDEO_ID' => censor_text($row['video_id']), 'U_VIEW_VIDEO' => $this->helper->route('dmzx_youtubegallery_controller', array('mode' => 'view', 'id' => $row['video_id'])), 'U_POSTER' => append_sid("{$this->phpbb_root_path}memberlist.{$this->phpEx}", array('mode' => 'viewprofile', 'u' => $row['user_id'])), 'USERNAME' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']), 'S_VIDEO_THUMBNAIL' => 'http://img.youtube.com/vi/' . censor_text($row['youtube_id']) . '/default.jpg'));
                }
                $this->db->sql_freeresult($result);
                // We need another query for the video count
                $sql = 'SELECT COUNT(*) as video_count
				FROM ' . $this->video_table . '
				WHERE video_cat_id = ' . (int) $video_cat_ids;
                $result = $this->db->sql_query($sql);
                $videorow['video_count'] = $this->db->sql_fetchfield('video_count');
                $this->db->sql_freeresult($result);
                $start = $this->request->variable('start', 0);
                $this->pagination->generate_template_pagination($pagination_url, 'pagination', 'start', $videorow['video_count'], $sql_limit, $sql_start);
                $this->template->assign_vars(array('TOTAL_VIDEOS' => $videorow['video_count'] == 1 ? $this->user->lang['LIST_VIDEO'] : sprintf($this->user->lang['LIST_VIDEOS'], $videorow['video_count'])));
                $sql = 'SELECT *
				FROM ' . $this->video_cat_table . '
				WHERE video_cat_id = ' . (int) $video_cat_ids;
                $result = $this->db->sql_query($sql);
                $row = $this->db->sql_fetchrow($result);
                $this->db->sql_freeresult($result);
                $this->template->assign_vars(array('CAT_NAME' => $row['video_cat_title']));
                $l_title = $row['video_cat_title'];
                $template_html = 'video_cat.html';
                $this->template->assign_block_vars('navlinks', array('FORUM_NAME' => $row['video_cat_title']));
                break;
            case 'user_videos':
                $this->template->assign_vars(array('S_SEARCH_USER_VIDEO' => true));
                $sql_limit = $sql_limit > 10 ? 10 : $sql_limit;
                $pagination_url = $this->helper->route('dmzx_youtubegallery_controller', array('mode' => 'user_videos', 'user_id' => $user_id));
                $sql_ary = array('SELECT' => 'v.*,
				ct.video_cat_title,ct.video_cat_id,
				u.username,u.user_colour,u.user_id', 'FROM' => array($this->video_table => 'v', $this->video_cat_table => 'ct', USERS_TABLE => 'u'), 'WHERE' => 'u.user_id = v.user_id
					AND ct.video_cat_id = v.video_cat_id
					AND u.user_id = ' . $user_id, 'ORDER_BY' => 'v.video_id DESC');
                $sql = $this->db->sql_build_query('SELECT', $sql_ary);
                $result = $this->db->sql_query_limit($sql, $sql_limit, $sql_start);
                while ($row = $this->db->sql_fetchrow($result)) {
                    $this->template->assign_block_vars('video', array('VIDEO_TITLE' => $row['video_title'], 'VIDEO_CAT_ID' => $row['video_cat_id'], 'VIDEO_CAT_TITLE' => $row['video_cat_title'], 'VIDEO_VIEWS' => $row['video_views'], 'U_CAT' => $this->helper->route('dmzx_youtubegallery_controller', array('mode' => 'cat', 'id' => $row['video_cat_id'])), 'VIDEO_TIME' => $this->user->format_date($row['create_time']), 'VIDEO_ID' => censor_text($row['video_id']), 'U_VIEW_VIDEO' => $this->helper->route('dmzx_youtubegallery_controller', array('mode' => 'view', 'id' => $row['video_id'])), 'U_POSTER' => append_sid("{$this->phpbb_root_path}memberlist.{$this->phpEx}", array('mode' => 'viewprofile', 'u' => $row['user_id'])), 'USERNAME' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']), 'S_VIDEO_THUMBNAIL' => 'http://img.youtube.com/vi/' . censor_text($row['youtube_id']) . '/default.jpg'));
                }
                $this->db->sql_freeresult($result);
                // We need another query for the video count
                $sql = 'SELECT COUNT(*) as video_count
				FROM ' . $this->video_table . '
				WHERE user_id = ' . $user_id;
                $result = $this->db->sql_query($sql);
                $videorow['video_count'] = $this->db->sql_fetchfield('video_count');
                $this->db->sql_freeresult($result);
                $start = $this->request->variable('start', 0);
                $this->pagination->generate_template_pagination($pagination_url, 'pagination', 'start', $videorow['video_count'], $sql_limit, $sql_start);
                $this->template->assign_vars(array('TOTAL_VIDEOS' => $videorow['video_count'] == 1 ? $this->user->lang['LIST_VIDEO'] : sprintf($this->user->lang['LIST_VIDEOS'], $videorow['video_count'])));
                $l_title = $this->user->lang['USER_VIDEOS'];
                $template_html = 'video_search.html';
                break;
            default:
                //Listing categories
                $sql = 'SELECT *
				FROM ' . $this->video_cat_table . "\n\t\t\t\tORDER BY video_cat_id";
                $res = $this->db->sql_query($sql);
                while ($row = $this->db->sql_fetchrow($res)) {
                    $this->template->assign_block_vars('videocat', array('VIDEO_CAT_ID' => $row['video_cat_id'], 'VIDEO_CAT_TITLE' => $row['video_cat_title'], 'U_CAT' => $this->helper->route('dmzx_youtubegallery_controller', array('mode' => 'cat', 'id' => $row['video_cat_id']))));
                }
                // Count the videos ...
                $sql = 'SELECT COUNT(video_id) AS total_videos
				FROM ' . $this->video_table;
                $result = $this->db->sql_query($sql);
                $total_videos = (int) $this->db->sql_fetchfield('total_videos');
                $this->db->sql_freeresult($result);
                // Count the videos categories ...
                $sql = 'SELECT COUNT(video_cat_id) AS total_categories
				FROM ' . $this->video_cat_table . '';
                $result = $this->db->sql_query($sql);
                $total_categories = (int) $this->db->sql_fetchfield('total_categories');
                $this->db->sql_freeresult($result);
                // Count the videos views ...
                $sql = 'SELECT SUM(video_views) AS total_views
				FROM ' . $this->video_table;
                $result = $this->db->sql_query($sql);
                $total_views = (int) $this->db->sql_fetchfield('total_views');
                $this->db->sql_freeresult($result);
                $total_videos;
                // Count the videos comments ...
                $sql = 'SELECT COUNT(cmnt_id) AS total_comments
				FROM ' . $this->video_cmnts_table;
                $result = $this->db->sql_query($sql);
                $total_comments = (int) $this->db->sql_fetchfield('total_comments');
                $this->db->sql_freeresult($result);
                $l_title = $this->user->lang['VIDEO_INDEX'];
                $template_html = 'video_body.html';
                $l_total_video_s = $total_videos == 0 ? 'TOTAL_VIDEO_ZERO' : 'TOTAL_VIDEOS_OTHER';
                $l_total_category_s = $total_categories == 0 ? 'TOTAL_CATEGORY_ZERO' : 'TOTAL_CATEGORIES_OTHER';
                $l_total_view_s = $total_views == 0 ? 'TOTAL_VIEW_ZERO' : 'TOTAL_VIEWS_OTHER';
                $l_total_comment_s = $total_comments == 0 ? 'TOTAL_COMMENT_ZERO' : 'TOTAL_COMMENTS_OTHER';
                $this->template->assign_vars(array('U_VIDEO_SUBMIT' => $this->helper->route('dmzx_youtubegallery_controller', array('mode' => 'submit')), 'VIDEOSUBMIT' => $this->auth->acl_get('u_video_post'), 'U_MY_VIDEOS' => $this->helper->route('dmzx_youtubegallery_controller', array('mode' => 'user_videos', 'user_id' => $this->user->data['user_id'])), 'BUTTON_VIDEO_NEW' => "{$web_path}styles/" . $this->user->lang_name . '/button_video_new.gif', 'TOTAL_VIDEOS_INDEX' => sprintf($this->user->lang[$l_total_video_s], $total_videos), 'TOTAL_CATEGORIES' => sprintf($this->user->lang[$l_total_category_s], $total_categories), 'TOTAL_VIEWS' => sprintf($this->user->lang[$l_total_view_s], $total_views), 'TOTAL_COMMENTS' => sprintf($this->user->lang[$l_total_comment_s], $total_comments)));
                $sql_limit = $sql_limit > 10 ? 10 : $sql_limit;
                $pagination_url = $this->helper->route('dmzx_youtubegallery_controller');
                $sql_ary = array('SELECT' => 'v.*,
				ct.video_cat_title,ct.video_cat_id,
				u.username,u.user_colour,u.user_id', 'FROM' => array($this->video_table => 'v', $this->video_cat_table => 'ct', USERS_TABLE => 'u'), 'WHERE' => 'ct.video_cat_id = v.video_cat_id AND u.user_id = v.user_id', 'ORDER_BY' => 'v.video_id DESC');
                $sql = $this->db->sql_build_query('SELECT', $sql_ary);
                $result = $this->db->sql_query_limit($sql, $sql_limit, $sql_start);
                while ($row = $this->db->sql_fetchrow($result)) {
                    $this->template->assign_block_vars('video', array('VIDEO_TITLE' => $row['video_title'], 'VIDEO_CAT_ID' => $row['video_cat_id'], 'VIDEO_CAT_TITLE' => $row['video_cat_title'], 'VIDEO_VIEWS' => $row['video_views'], 'U_CAT' => $this->helper->route('dmzx_youtubegallery_controller', array('mode' => 'cat', 'id' => $row['video_cat_id'])), 'VIDEO_TIME' => $this->user->format_date($row['create_time']), 'VIDEO_ID' => censor_text($row['video_id']), 'U_VIEW_VIDEO' => $this->helper->route('dmzx_youtubegallery_controller', array('mode' => 'view', 'id' => $row['video_id'])), 'U_POSTER' => append_sid("{$this->phpbb_root_path}memberlist.{$this->phpEx}", array('mode' => 'viewprofile', 'u' => $row['user_id'])), 'USERNAME' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']), 'YOUTUBE_ID' => censor_text($row['youtube_id'])));
                }
                $this->db->sql_freeresult($result);
                // We need another query for the video count
                $sql = 'SELECT COUNT(*) as video_count
				FROM ' . $this->video_table;
                $result = $this->db->sql_query($sql);
                $videorow['video_count'] = $this->db->sql_fetchfield('video_count');
                $this->db->sql_freeresult($result);
                $start = $this->request->variable('start', 0);
                $this->pagination->generate_template_pagination($pagination_url, 'pagination', 'start', $videorow['video_count'], $sql_limit, $sql_start);
                $this->template->assign_vars(array('TOTAL_VIDEOS' => $videorow['video_count'] == 1 ? $this->user->lang['LIST_VIDEO'] : sprintf($this->user->lang['LIST_VIDEOS'], $videorow['video_count'])));
                break;
        }
        if (!$row) {
            $this->template->assign_vars(array('NO_ENTRY' => $this->user->lang['NO_VIDEOS']));
        }
        // Output page
        page_header($l_title, false);
        $this->template->set_filenames(array('body' => $template_html));
        make_jumpbox(append_sid("{$this->phpbb_root_path}viewforum.{$this->phpEx}"));
        page_footer();
    }
コード例 #27
0
ファイル: posting.php プロジェクト: PetsFundation/Pets
    $message_parser->message = $post_data['poll_title'];
    $message_parser->bbcode_uid = $post_data['bbcode_uid'];
    $message_parser->decode_message();
    $post_data['poll_title'] = $message_parser->message;
    $message_parser->message = implode("\n", $post_data['poll_options']);
    $message_parser->decode_message();
    $post_data['poll_options'] = explode("\n", $message_parser->message);
}
// MAIN POSTING PAGE BEGINS HERE
// Forum moderators?
$moderators = array();
if ($config['load_moderators']) {
    get_moderators($moderators, $forum_id);
}
// Generate smiley listing
generate_smilies('inline', $forum_id);
// Generate inline attachment select box
posting_gen_inline_attachments($attachment_data);
// Do show topic type selection only in first post.
$topic_type_toggle = false;
if ($mode == 'post' || $mode == 'edit' && $post_id == $post_data['topic_first_post_id']) {
    $topic_type_toggle = posting_gen_topic_types($forum_id, $post_data['topic_type']);
}
$s_topic_icons = false;
if ($post_data['enable_icons'] && $auth->acl_get('f_icons', $forum_id)) {
    $s_topic_icons = posting_gen_topic_icons($mode, $post_data['icon_id']);
}
$bbcode_checked = isset($post_data['enable_bbcode']) ? !$post_data['enable_bbcode'] : ($config['allow_bbcode'] ? !$user->optionget('bbcode') : 1);
$smilies_checked = isset($post_data['enable_smilies']) ? !$post_data['enable_smilies'] : ($config['allow_smilies'] ? !$user->optionget('smilies') : 1);
$urls_checked = isset($post_data['enable_urls']) ? !$post_data['enable_urls'] : 0;
$sig_checked = $post_data['enable_sig'];
コード例 #28
0
ファイル: functions.php プロジェクト: MrGoldy/ultimateblog
    function comment_edit($blog_id, $comment_id)
    {
        // Grab comment details
        $sql = 'SELECT c.*, b.blog_subject
				FROM ' . $this->ub_comments_table . ' c
				LEFT JOIN ' . $this->ub_blogs_table . ' b
					ON c.blog_id = b.blog_id
				WHERE c.comment_id = ' . (int) $comment_id . '
					AND c.blog_id = ' . (int) $blog_id;
        $result = $this->db->sql_query($sql);
        $comment = $this->db->sql_fetchrow($result);
        $this->db->sql_freeresult($result);
        if (!$comment) {
            trigger_error($this->user->lang['BLOG_COMMENT_NOT_EXIST'] . '<br><br><a href="' . $this->helper->route('posey_ultimateblog_blog_display', ['blog_id' => (int) $blog_id]) . '">&laquo; ' . $this->user->lang['BACK_TO_PREV'] . '</a>');
        }
        // Check if authorised to edit this comment
        if (!$this->auth->acl_gets('u_blog_comment_edit', 'm_blog_comment_edit')) {
            trigger_error($this->user->lang['AUTH_COMMENT_EDIT'] . '<br><br><a href="' . $this->helper->route('posey_ultimateblog_blog_display', ['blog_id' => (int) $blog_id]) . '">&laquo; ' . $this->user->lang['BLOG_BACK'] . '</a>');
        }
        if ($this->auth->acl_get('u_blog_edit') && $comment['poster_id'] != $this->user->data['user_id'] && !$this->auth->acl_get('m_blog_comment_edit')) {
            trigger_error($this->user->lang['AUTH_COMMENT_EDIT_ELSE'] . '<br><br><a href="' . $this->helper->route('posey_ultimateblog_blog_display', ['blog_id' => (int) $blog_id]) . '">&laquo; ' . $this->user->lang['BLOG_BACK'] . '</a>');
        }
        if (!function_exists('generate_smilies')) {
            include $this->phpbb_root_path . 'includes/functions_posting.' . $this->php_ext;
        }
        if (!function_exists('display_custom_bbcodes')) {
            include $this->phpbb_root_path . 'includes/functions_display.' . $this->php_ext;
        }
        // Add lang file
        $this->user->add_lang('posting');
        display_custom_bbcodes();
        generate_smilies('inline', 0);
        // Generate text for editing
        decode_message($comment['comment_text'], $comment['bbcode_uid']);
        $this->template->assign_vars(['MESSAGE' => $comment['comment_text'], 'S_FORM_ENCTYPE' => '', 'S_BBCODE_ALLOWED' => $this->config['allow_bbcode'] ? true : false, 'S_SMILIES_STATUS' => $this->config['allow_smilies'] ? true : false]);
        add_form_key('edit_comment');
        if ($this->request->is_set_post('submit')) {
            if (!check_form_key('edit_comment')) {
                // Invalid form key
                trigger_error($this->user->lang['FORM_INVALID'] . '<br><br><a href="' . $this->helper->route('posey_ultimateblog_comment', ['blog_id' => (int) $blog_id, 'comment_id' => (int) $comment_id, 'action' => 'edit']) . '">&laquo; ' . $this->user->lang['BACK_TO_PREV'] . '</a>');
            } else {
                if ($this->request->variable('comment_text', '', true) == '') {
                    // Empty comment message
                    trigger_error($this->user->lang['BLOG_COMMENT_EMPTY'] . '<br><br><a href="' . $this->helper->route('posey_ultimateblog_comment', ['blog_id' => (int) $blog_id, 'comment_id' => (int) $comment_id, 'action' => 'edit']) . '">&laquo; ' . $this->user->lang['BACK_TO_PREV'] . '</a>');
                } else {
                    // Generate text for storage
                    $comment_text = $this->request->variable('comment_text', '', true);
                    $uid = $bitfield = $options = '';
                    $allow_bbcode = $this->config['allow_bbcode'];
                    $allow_smilies = $this->config['allow_smilies'];
                    $allow_urls = $this->config['allow_post_links'];
                    generate_text_for_storage($comment_text, $uid, $bitfield, $options, $allow_bbcode, $allow_smilies, $allow_urls);
                    $comment_row = ['comment_text' => $comment_text, 'bbcode_uid' => $uid, 'bbcode_bitfield' => $bitfield, 'bbcode_options' => $options];
                    // Update the blog
                    $sql = 'UPDATE ' . $this->ub_comments_table . ' SET ' . $this->db->sql_build_array('UPDATE', $comment_row) . ' WHERE comment_id = ' . (int) $comment_id;
                    $this->db->sql_query($sql);
                    // Add it to the log
                    $this->log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_COMMENT_EDITED', false, array($comment_id));
                    // Send success message
                    trigger_error($this->user->lang['BLOG_COMMENT_EDITED'] . '<br><br><a href="' . $this->helper->route('posey_ultimateblog_blog_display', ['blog_id' => (int) $blog_id]) . '#c' . (int) $comment_id . '">' . $this->user->lang['BLOG_COMMENT_VIEW'] . ' &raquo;</a>');
                }
            }
        }
        // Assign breadcrumb template vars
        $navlinks_array = [['U_VIEW_FORUM' => $this->helper->route('posey_ultimateblog_blog'), 'FORUM_NAME' => $this->user->lang('BLOG')], ['U_VIEW_FORUM' => $this->helper->route('posey_ultimateblog_blog_display', ['blog_id' => (int) $blog_id]), 'FORUM_NAME' => $comment['blog_subject']]];
        foreach ($navlinks_array as $name) {
            $this->template->assign_block_vars('navlinks', ['FORUM_NAME' => $name['FORUM_NAME'], 'U_VIEW_FORUM' => $name['U_VIEW_FORUM']]);
        }
    }
コード例 #29
0
ファイル: privmsg.php プロジェクト: Nekrofage/FJR
                        } else {
                            if ($mode == 'edit') {
                                $post_a = $lang['Edit_message'];
                            }
                        }
                    }
                    $s_hidden_fields = '<input type="hidden" name="folder" value="' . $folder . '" />';
                    $s_hidden_fields .= '<input type="hidden" name="mode" value="' . $mode . '" />';
                    $s_hidden_fields .= '<input type="hidden" name="sid" value="' . $userdata['session_id'] . '" />';
                    if ($mode == 'edit') {
                        $s_hidden_fields .= '<input type="hidden" name="' . POST_POST_URL . '" value="' . $privmsg_id . '" />';
                    }
                    //
                    // Send smilies to template
                    //
                    generate_smilies('inline', PAGE_PRIVMSGS);
                    $template->assign_vars(array('SUBJECT' => $privmsg_subject, 'USERNAME' => $to_username, 'MESSAGE' => $privmsg_message, 'HTML_STATUS' => $html_status, 'SMILIES_STATUS' => $smilies_status, 'BBCODE_STATUS' => sprintf($bbcode_status, '<a href="' . append_sid("faq.{$phpEx}?mode=bbcode") . '" target="_phpbbcode">', '</a>'), 'FORUM_NAME' => $lang['Private_Message'], 'BOX_NAME' => $l_box_name, 'INBOX_IMG' => $inbox_img, 'SENTBOX_IMG' => $sentbox_img, 'OUTBOX_IMG' => $outbox_img, 'SAVEBOX_IMG' => $savebox_img, 'INBOX' => $inbox_url, 'SENTBOX' => $sentbox_url, 'OUTBOX' => $outbox_url, 'SAVEBOX' => $savebox_url, 'L_SUBJECT' => $lang['Subject'], 'L_MESSAGE_BODY' => $lang['Message_body'], 'L_OPTIONS' => $lang['Options'], 'L_SPELLCHECK' => $lang['Spellcheck'], 'L_PREVIEW' => $lang['Preview'], 'L_SUBMIT' => $lang['Submit'], 'L_CANCEL' => $lang['Cancel'], 'L_POST_A' => $post_a, 'L_FIND_USERNAME' => $lang['Find_username'], 'L_FIND' => $lang['Find'], 'L_DISABLE_HTML' => $lang['Disable_HTML_pm'], 'L_DISABLE_BBCODE' => $lang['Disable_BBCode_pm'], 'L_DISABLE_SMILIES' => $lang['Disable_Smilies_pm'], 'L_ATTACH_SIGNATURE' => $lang['Attach_signature'], 'L_BBCODE_B_HELP' => $lang['bbcode_b_help'], 'L_BBCODE_I_HELP' => $lang['bbcode_i_help'], 'L_BBCODE_U_HELP' => $lang['bbcode_u_help'], 'L_BBCODE_Q_HELP' => $lang['bbcode_q_help'], 'L_BBCODE_C_HELP' => $lang['bbcode_c_help'], 'L_BBCODE_L_HELP' => $lang['bbcode_l_help'], 'L_BBCODE_O_HELP' => $lang['bbcode_o_help'], 'L_BBCODE_P_HELP' => $lang['bbcode_p_help'], 'L_BBCODE_W_HELP' => $lang['bbcode_w_help'], 'L_BBCODE_A_HELP' => $lang['bbcode_a_help'], 'L_BBCODE_S_HELP' => $lang['bbcode_s_help'], 'L_BBCODE_F_HELP' => $lang['bbcode_f_help'], 'L_BBCODE_T1_HELP' => $lang['bbcode_t1_help'], 'L_EMPTY_MESSAGE' => $lang['Empty_message'], 'L_FONT_COLOR' => $lang['Font_color'], 'L_COLOR_DEFAULT' => $lang['color_default'], 'L_COLOR_DARK_RED' => $lang['color_dark_red'], 'L_COLOR_RED' => $lang['color_red'], 'L_COLOR_ORANGE' => $lang['color_orange'], 'L_COLOR_BROWN' => $lang['color_brown'], 'L_COLOR_YELLOW' => $lang['color_yellow'], 'L_COLOR_GREEN' => $lang['color_green'], 'L_COLOR_OLIVE' => $lang['color_olive'], 'L_COLOR_CYAN' => $lang['color_cyan'], 'L_COLOR_BLUE' => $lang['color_blue'], 'L_COLOR_DARK_BLUE' => $lang['color_dark_blue'], 'L_COLOR_INDIGO' => $lang['color_indigo'], 'L_COLOR_VIOLET' => $lang['color_violet'], 'L_COLOR_WHITE' => $lang['color_white'], 'L_COLOR_BLACK' => $lang['color_black'], 'L_FONT_SIZE' => $lang['Font_size'], 'L_FONT_TINY' => $lang['font_tiny'], 'L_FONT_SMALL' => $lang['font_small'], 'L_FONT_NORMAL' => $lang['font_normal'], 'L_FONT_LARGE' => $lang['font_large'], 'L_FONT_HUGE' => $lang['font_huge'], 'L_BBCODE_CLOSE_TAGS' => $lang['Close_Tags'], 'L_STYLES_TIP' => $lang['Styles_tip'], 'S_HTML_CHECKED' => !$html_on ? ' checked="checked"' : '', 'S_BBCODE_CHECKED' => !$bbcode_on ? ' checked="checked"' : '', 'S_SMILIES_CHECKED' => !$smilies_on ? ' checked="checked"' : '', 'S_SIGNATURE_CHECKED' => $attach_sig ? ' checked="checked"' : '', 'S_HIDDEN_FORM_FIELDS' => $s_hidden_fields, 'S_POST_ACTION' => append_sid("privmsg.{$phpEx}"), 'U_SEARCH_USER' => append_sid("search.{$phpEx}?mode=searchuser"), 'U_VIEW_FORUM' => append_sid("privmsg.{$phpEx}")));
                    $template->pparse('body');
                    include $phpbb_root_path . 'includes/page_tail.' . $phpEx;
                }
            }
        }
    }
}
//
// Default page
//
if (!$userdata['session_logged_in']) {
    redirect(append_sid("login.{$phpEx}?redirect=privmsg.{$phpEx}&folder=inbox", true));
}
//
コード例 #30
0
ファイル: theme.php プロジェクト: alencarmo/OCF
function theme_html_comments($pid)
{
    global $CONFIG, $USER, $CURRENT_ALBUM_DATA, $comment_date_fmt, $HTML_SUBST;
    global $template_image_comments, $template_add_your_comment, $lang_display_comments;
    $html = '';
    //report to moderator buttons
    if (!($CONFIG['report_post'] == 1 && USER_CAN_SEND_ECARDS)) {
        template_extract_block($template_image_comments, 'report_comment_button');
    }
    if (!$CONFIG['enable_smilies']) {
        $tmpl_comment_edit_box = template_extract_block($template_image_comments, 'edit_box_no_smilies', '{EDIT}');
        template_extract_block($template_image_comments, 'edit_box_smilies');
        template_extract_block($template_add_your_comment, 'input_box_smilies');
    } else {
        $tmpl_comment_edit_box = template_extract_block($template_image_comments, 'edit_box_smilies', '{EDIT}');
        template_extract_block($template_image_comments, 'edit_box_no_smilies');
        template_extract_block($template_add_your_comment, 'input_box_no_smilies');
    }
    $tmpl_comments_buttons = template_extract_block($template_image_comments, 'buttons', '{BUTTONS}');
    $tmpl_comments_ipinfo = template_extract_block($template_image_comments, 'ipinfo', '{IPINFO}');
    if ($CONFIG['comments_sort_descending'] == 1) {
        $comment_sort_order = 'DESC';
    } else {
        $comment_sort_order = 'ASC';
    }
    $result = cpg_db_query("SELECT msg_id, msg_author, msg_body, UNIX_TIMESTAMP(msg_date) AS msg_date, author_id, author_md5_id, msg_raw_ip, msg_hdr_ip, pid FROM {$CONFIG['TABLE_COMMENTS']} WHERE pid='{$pid}' ORDER BY msg_id {$comment_sort_order}");
    while ($row = mysql_fetch_array($result)) {
        $user_can_edit = GALLERY_ADMIN_MODE || USER_ID && USER_ID == $row['author_id'] && USER_CAN_POST_COMMENTS || !USER_ID && USER_CAN_POST_COMMENTS && $USER['ID'] == $row['author_md5_id'];
        $comment_buttons = $user_can_edit ? $tmpl_comments_buttons : '';
        $comment_edit_box = $user_can_edit ? $tmpl_comment_edit_box : '';
        $comment_ipinfo = $row['msg_raw_ip'] && GALLERY_ADMIN_MODE ? $tmpl_comments_ipinfo : '';
        if ($CONFIG['enable_smilies']) {
            $comment_body = process_smilies(make_clickable($row['msg_body']));
            $smilies = generate_smilies("f{$row['msg_id']}", 'msg_body');
        } else {
            $comment_body = make_clickable($row['msg_body']);
            $smilies = '';
        }
        $ip = $row['msg_hdr_ip'];
        if ($row['msg_hdr_ip'] != $row['msg_raw_ip']) {
            $ip .= ' [' . $row['msg_raw_ip'] . ']';
        }
        $params = array('{EDIT}' => &$comment_edit_box, '{BUTTONS}' => &$comment_buttons, '{IPINFO}' => &$comment_ipinfo);
        $template = template_eval($template_image_comments, $params);
        $params = array('{MSG_AUTHOR}' => stripslashes($row['msg_author']), '{MSG_ID}' => $row['msg_id'], '{PID}' => $row['pid'], '{EDIT_TITLE}' => &$lang_display_comments['edit_title'], '{CONFIRM_DELETE}' => &$lang_display_comments['confirm_delete'], '{MSG_DATE}' => localised_date($row['msg_date'], $comment_date_fmt), '{MSG_BODY}' => bb_decode($comment_body), '{MSG_BODY_RAW}' => $row['msg_body'], '{OK}' => &$lang_display_comments['OK'], '{SMILIES}' => $smilies, '{IP}' => $ip, '{REPORT_COMMENT_TITLE}' => &$lang_display_comments['report_comment_title'], '{WIDTH}' => $CONFIG['picture_table_width']);
        $html .= template_eval($template, $params);
    }
    if (USER_CAN_POST_COMMENTS && $CURRENT_ALBUM_DATA['comments'] == 'YES') {
        if (USER_ID) {
            $user_name_input = '<tr><td><input type="hidden" name="msg_author" value="' . stripslashes(USER_NAME) . '" /></td>';
            template_extract_block($template_add_your_comment, 'user_name_input', $user_name_input);
            $user_name = '';
        } else {
            if (isset($USER['name'])) {
                $user_name = strtr($USER['name'], $HTML_SUBST);
            } else {
                $user_name = $lang_display_comments['your_name'];
            }
        }
        $params = array('{ADD_YOUR_COMMENT}' => $lang_display_comments['add_your_comment'], '{NAME}' => $lang_display_comments['name'], '{COMMENT}' => $lang_display_comments['comment'], '{PIC_ID}' => $pid, '{USER_NAME}' => $user_name, '{MAX_COM_LENGTH}' => $CONFIG['max_com_size'], '{OK}' => $lang_display_comments['OK'], '{SMILIES}' => '', '{WIDTH}' => $CONFIG['picture_table_width']);
        if ($CONFIG['enable_smilies']) {
            $params['{SMILIES}'] = generate_smilies();
        } else {
            template_extract_block($template_add_your_comment, 'smilies');
        }
        $html .= template_eval($template_add_your_comment, $params);
    }
    return $html;
}