Exemple #1
0
function phpbb_end_update($cache, $config)
{
    $cache->purge();
    $config->increment('assets_version', 1);
    ?>
								</p>
							</div>
						</div>
					<span class="corners-bottom"><span></span></span>
				</div>
			</div>
		</div>

		<div id="page-footer">
			<div class="copyright">
				Powered by <a href="https://www.phpbb.com/">phpBB</a>&reg; Forum Software &copy; phpBB Limited
			</div>
		</div>
	</div>
</body>
</html>

<?php 
    garbage_collection();
    exit_handler();
}
    function main($id, $mode)
    {
        global $db, $user, $phpbb_root_path, $config, $phpEx;
        // Do we have an id? No, then just exit
        $confirm_id = request_var('id', '');
        $type = request_var('type', 0);
        if (!$confirm_id || !$type) {
            exit;
        }
        // Try and grab code for this id and session
        $sql = 'SELECT code, seed
			FROM ' . CONFIRM_TABLE . "\n\t\t\tWHERE session_id = '" . $db->sql_escape($user->session_id) . "'\n\t\t\t\tAND confirm_id = '" . $db->sql_escape($confirm_id) . "'\n\t\t\t\tAND confirm_type = {$type}";
        $result = $db->sql_query($sql);
        $row = $db->sql_fetchrow($result);
        $db->sql_freeresult($result);
        // If we have a row then grab data else create a new id
        if (!$row) {
            exit;
        }
        if ($config['captcha_gd']) {
            include $phpbb_root_path . 'includes/captcha/captcha_gd.' . $phpEx;
        } else {
            include $phpbb_root_path . 'includes/captcha/captcha_non_gd.' . $phpEx;
        }
        $captcha = new captcha();
        $captcha->execute($row['code'], $row['seed']);
        garbage_collection();
        exit_handler();
    }
Exemple #3
0
function src_end_update($cache, $config)
{
    $cache->purge();
    $config->increment('assets_version', 1);
    ?>
								</p>
							</div>
						</div>
					<span class="corners-bottom"><span></span></span>
				</div>
			</div>
		</div>

		<div id="page-footer">
			<div class="copyright">
				Powered by SourceFlan
			</div>
		</div>
	</div>
</body>
</html>

<?php 
    garbage_collection();
    exit_handler();
}
/**
* Page footer for acp pages
*/
function adm_page_footer($copyright_html = true)
{
    global $db, $config, $template, $user, $auth, $cache;
    global $starttime, $phpbb_admin_path;
    // Output page creation time
    if (defined('DEBUG')) {
        $mtime = explode(' ', microtime());
        $totaltime = $mtime[0] + $mtime[1] - $starttime;
        // Let's remove $auth->acl_get('a_') until I finish coding permissions properly... and also add/remove 'a_' when users are added/removed from administrators in ACP
        //$is_admin = (($user->data['user_level'] == ADMIN) || $auth->acl_get('a_')) ? true : false;
        $is_admin = $user->data['user_level'] == ADMIN ? true : false;
        if (!empty($_REQUEST['explain']) && $is_admin && defined('DEBUG_EXTRA') && method_exists($db, 'sql_report')) {
            $db->sql_report('display');
        }
        $debug_output = sprintf('Time : %.3fs | ' . $db->sql_num_queries() . ' Queries | GZIP : ' . ($config['gzip_compress'] ? 'On' : 'Off') . ($user->load ? ' | Load : ' . $user->load : ''), $totaltime);
        if ($is_admin && defined('DEBUG_EXTRA')) {
            if (function_exists('memory_get_usage')) {
                if ($memory_usage = memory_get_usage()) {
                    global $base_memory_usage;
                    $memory_usage -= $base_memory_usage;
                    $memory_usage = get_formatted_filesize($memory_usage);
                    $debug_output .= ' | Memory Usage: ' . $memory_usage;
                }
            }
            $debug_output .= ' | <a href="' . build_url() . '&amp;explain=1">Explain</a>';
        }
    }
    $template->assign_vars(array('DEBUG_OUTPUT' => defined('DEBUG') ? $debug_output : '', 'TRANSLATION_INFO' => !empty($user->lang['TRANSLATION_INFO']) ? $user->lang['TRANSLATION_INFO'] : '', 'S_COPYRIGHT_HTML' => $copyright_html, 'VERSION' => $config['version']));
    $template->display('body');
    garbage_collection();
    exit_handler();
}
 function main($id, $mode)
 {
     global $db, $user, $phpbb_root_path, $config, $phpEx, $phpbb_container;
     $captcha = $phpbb_container->get('captcha.factory')->get_instance($config['captcha_plugin']);
     $captcha->init(request_var('type', 0));
     $captcha->execute();
     garbage_collection();
     exit_handler();
 }
Exemple #6
0
 /**
  * Send the data to the client and exit the script.
  *
  * @param array $data Any additional data to send.
  * @param bool $exit Will exit the script if true.
  */
 public function send($data, $exit = true)
 {
     header('Content-Type: application/json');
     echo json_encode($data);
     if ($exit) {
         garbage_collection();
         exit_handler();
     }
 }
Exemple #7
0
 function main($id, $mode)
 {
     global $config, $phpbb_container, $request;
     $captcha = $phpbb_container->get('captcha.factory')->get_instance($config['captcha_plugin']);
     $captcha->init($request->variable('type', 0));
     $captcha->execute();
     garbage_collection();
     exit_handler();
 }
Exemple #8
0
 function main($id, $mode)
 {
     global $db, $user, $phpbb_root_path, $config, $phpEx;
     include $phpbb_root_path . 'includes/captcha/captcha_factory.' . $phpEx;
     $captcha = phpbb_captcha_factory::get_instance($config['captcha_plugin']);
     $captcha->init(request_var('type', 0));
     $captcha->execute();
     garbage_collection();
     exit_handler();
 }
Exemple #9
0
 /**
  * Alter preview output for ajax request
  *
  * @param object $event The event object
  * @return null
  * @access public
  */
 public function output_ajax_post_preview($event)
 {
     if ($this->request->is_ajax() && $event['preview']) {
         if (empty($event['message_parser']->message)) {
             exit_handler();
         } else {
             if (sizeof($event['error'])) {
                 // seems to be the best HTTP code
                 header('HTTP/1.1 412 Precondition Failed');
                 echo implode('<br />', $event['error']);
                 exit_handler();
             } else {
                 $this->template->assign_vars($event['page_data']);
                 // we can't use helper's render method, because it refreshes the page
                 page_header('');
                 $this->template->set_filenames(array('body' => '@senky_ajaxbase/ajax_posting_preview.html'));
                 page_footer();
             }
         }
     }
 }
Exemple #10
0
 public function disabled_board($event)
 {
     $style_id = !$this->config['override_user_style'] ? $this->user->data['user_style'] : $this->config['default_style'];
     $sql = 'SELECT style_id FROM ' . STYLES_TABLE . ' WHERE style_copyright LIKE "© SiteSplat.com%"';
     $result = $this->db->sql_query($sql);
     $row = $this->db->sql_fetchrow($result);
     $in_sitesplat = in_array($style_id, $row);
     $this->template->assign_vars(array('PM_NEW_COUNT_BADGE' => $this->user->lang('PM_NEW_MSG_BUBBLE', (int) $this->user->data['user_new_privmsg']), 'PM_NEW_COUNT' => $this->user->lang('PM_NEW_MSG', (int) $this->user->data['user_new_privmsg']), 'PM_UNREAD_COUNT' => $this->user->lang('PM_UNREAD_MSG', (int) $this->user->data['user_unread_privmsg'])));
     if ($this->config['board_disable'] && !defined('IN_LOGIN') && $in_sitesplat && !$this->auth->acl_get('a_')) {
         global $phpbb_path_helper, $phpbb_root_path;
         // Determine board url - we may need it later
         $board_url = generate_board_url() . '/';
         // This path is sent with the base template paths in the assign_vars()
         // call below. We need to correct it in case we are accessing from a
         // controller because the web paths will be incorrect otherwise.
         $phpbb_path_helper = $this->phpbb_container->get('path_helper');
         $corrected_path = $phpbb_path_helper->get_web_root_path();
         $web_path = defined('PHPBB_USE_BOARD_URL_PATH') && PHPBB_USE_BOARD_URL_PATH ? $board_url : $corrected_path;
         // Send a proper content-language to the output
         $user_lang = $this->user->lang['USER_LANG'];
         if (strpos($user_lang, '-x-') !== false) {
             $user_lang = substr($user_lang, 0, strpos($user_lang, '-x-'));
         }
         $file = $phpbb_root_path . 'ext/sitesplat/BBCore/styles/all/template/offline_board_body.html';
         $fp = fopen($file, 'r');
         $content = fread($fp, filesize($file));
         fclose($fp);
         $match = array('#\\{S_CONTENT_DIRECTION\\}#', '#\\{S_USER_LANG\\}#', '#\\{S_CONTENT_ENCODING\\}#', '#\\{SITENAME\\}#', '#\\{PAGE_TITLE\\}#', '#\\{T_STYLESHEET_LINK\\}#', '#\\{T_THEME_PATH\\}#', '#\\{SCRIPT_NAME\\}#', '#\\{L_BOARD_DISABLED\\}#', '#\\{ACP_DISABLE_MESSAGE\\}#', '#\\{L_LOGIN_LOGOUT\\}#', '#\\{U_LOGIN_LOGOUT\\}#');
         $replace = array($this->user->lang['DIRECTION'], $user_lang, 'UTF-8', $this->config['sitename'], 'Website offline', "{$web_path}styles/" . rawurlencode($this->user->style['style_path']) . '/theme/stylesheet.css?assets_version=' . $this->config['assets_version'], "{$web_path}styles/" . rawurlencode($this->user->style['style_path']) . '/theme', str_replace('.' . 'php', '', $this->user->page['page_name']), 'board disabled', $this->config['board_disable_msg'], $this->user->lang['LOGIN'], append_sid("{$phpbb_root_path}ucp.php", 'mode=login'));
         $content = preg_replace($match, $replace, $content);
         $response = new Response('Content', 200, array('content-type' => 'text/html'));
         $response->setContent($content);
         $response->send();
         garbage_collection();
         exit_handler();
     }
 }
/**
* Generate page footer
*
* @param bool $run_cron Whether or not to run the cron
* @param bool $display_template Whether or not to display the template
* @param bool $exit_handler Whether or not to run the exit_handler()
*/
function page_footer($run_cron = true, $display_template = true, $exit_handler = true)
{
    global $db, $config, $template, $user, $auth, $cache, $starttime, $phpbb_root_path, $phpEx;
    global $request, $phpbb_dispatcher, $phpbb_admin_path;
    // A listener can set this variable to `true` when it overrides this function
    $page_footer_override = false;
    /**
     * Execute code and/or overwrite page_footer()
     *
     * @event core.page_footer
     * @var	bool	run_cron			Shall we run cron tasks
     * @var	bool	page_footer_override	Shall we return instead of running
     *										the rest of page_footer()
     * @since 3.1.0-a1
     */
    $vars = array('run_cron', 'page_footer_override');
    extract($phpbb_dispatcher->trigger_event('core.page_footer', compact($vars)));
    if ($page_footer_override) {
        return;
    }
    phpbb_check_and_display_sql_report($request, $auth, $db);
    $template->assign_vars(array('DEBUG_OUTPUT' => phpbb_generate_debug_output($db, $config, $auth, $user, $phpbb_dispatcher), 'TRANSLATION_INFO' => !empty($user->lang['TRANSLATION_INFO']) ? $user->lang['TRANSLATION_INFO'] : '', 'CREDIT_LINE' => $user->lang('POWERED_BY', '<a href="https://www.phpbb.com/">phpBB</a>&reg; Forum Software &copy; phpBB Limited'), 'U_ACP' => $auth->acl_get('a_') && !empty($user->data['is_registered']) ? append_sid("{$phpbb_admin_path}index.{$phpEx}", false, true, $user->session_id) : ''));
    // Call cron-type script
    $call_cron = false;
    if (!defined('IN_CRON') && !$config['use_system_cron'] && $run_cron && !$config['board_disable'] && !$user->data['is_bot'] && !$cache->get('_cron.lock_check')) {
        $call_cron = true;
        $time_now = !empty($user->time_now) && is_int($user->time_now) ? $user->time_now : time();
        // Any old lock present?
        if (!empty($config['cron_lock'])) {
            $cron_time = explode(' ', $config['cron_lock']);
            // If 1 hour lock is present we do not call cron.php
            if ($cron_time[0] + 3600 >= $time_now) {
                $call_cron = false;
            }
        }
    }
    // Call cron job?
    if ($call_cron) {
        global $phpbb_container;
        $cron = $phpbb_container->get('cron.manager');
        $task = $cron->find_one_ready_task();
        if ($task) {
            $url = $task->get_url();
            $template->assign_var('RUN_CRON_TASK', '<img src="' . $url . '" width="1" height="1" alt="cron" />');
        } else {
            $cache->put('_cron.lock_check', true, 60);
        }
    }
    /**
     * Execute code and/or modify output before displaying the template.
     *
     * @event core.page_footer_after
     * @var	bool display_template	Whether or not to display the template
     * @var	bool exit_handler		Whether or not to run the exit_handler()
     *
     * @since 3.1.0-RC5
     */
    $vars = array('display_template', 'exit_handler');
    extract($phpbb_dispatcher->trigger_event('core.page_footer_after', compact($vars)));
    if ($display_template) {
        $template->display('body');
    }
    garbage_collection();
    if ($exit_handler) {
        exit_handler();
    }
}
/**
* Outputs data as a Feed.
*
* @param int|array $blog_ids The id's of blogs that are going to get outputted,
* @param string $feed_type The type of feed we are outputting
*/
function feed_output($ids, $feed_type)
{
    global $template, $phpbb_root_path, $phpEx, $page, $mode, $limit, $config, $user, $blog_data, $user_id, $blog_id;
    // Feed explanation page
    if ($feed_type == 'explain') {
        $available_feeds = array('RSS 0.91' => blog_url(false, false, false, array_merge($_GET, array('feed' => 'RSS_0.91'))), 'RSS 1.0' => blog_url(false, false, false, array_merge($_GET, array('feed' => 'RSS_1.0'))), 'RSS 2.0' => blog_url(false, false, false, array_merge($_GET, array('feed' => 'RSS_2.0'))), 'ATOM' => blog_url(false, false, false, array_merge($_GET, array('feed' => 'ATOM'))), 'JAVASCRIPT' => array('url' => blog_url(false, false, false, array_merge($_GET, array('feed' => 'JAVASCRIPT'))), 'text' => htmlspecialchars('<script type="text/javascript" src="' . blog_url(false, false, false, array_merge($_GET, array('feed' => 'JAVASCRIPT', 'output' => 'true'))) . '"></script>'), 'demo' => '<script type="text/javascript" src="' . blog_url(false, false, false, array_merge($_GET, array('feed' => 'JAVASCRIPT', 'output' => 'true'))) . '"></script>'));
        blog_plugins::plugin_do_ref('available_feeds', $available_feeds);
        $message = '<strong>' . $user->lang['AVAILABLE_FEEDS'] . '</strong><br /><br />';
        foreach ($available_feeds as $feed_name => $data) {
            if (!is_array($data)) {
                $message .= '<br /><h2><a href="' . $data . '">' . $feed_name . '</a></h2><div><a href="' . $data . '">' . $data . '</a></div><br />';
            } else {
                $message .= '<br /><h2><a href="' . $data['url'] . '">' . $feed_name . '</a></h2><div><dl class="codebox"><dt>' . $user->lang['CODE'] . ': <a href="#" onclick="selectCode(this); return false;">Select all</a></dt><dd><code style="font-size: 12px;">' . $data['text'] . '</code></dd></dl></div><br />';
                if (isset($data['demo'])) {
                    $message .= $data['demo'];
                }
            }
        }
        trigger_error($message);
    }
    $title = $feed_type == 'JAVASCRIPT' ? str_replace("'", "\\'", $template->_tpldata['navlinks'][sizeof($template->_tpldata['navlinks']) - 1]['FORUM_NAME']) : $template->_tpldata['navlinks'][sizeof($template->_tpldata['navlinks']) - 1]['FORUM_NAME'];
    $template->assign_vars(array('FEED' => $feed_type, 'SELF_URL' => blog_url(false, false, false, array('page' => $page, 'mode' => $mode)), 'SELF_FULL_URL' => blog_url(false, false, false, array('page' => $page, 'mode' => $mode, 'feed' => $feed_type, 'limit' => $limit)), 'TITLE' => $config['sitename'] . ' ' . $title . ' ' . $user->lang['FEED'], 'SITE_URL' => generate_board_url(), 'SITE_DESC' => $config['site_desc'], 'SITE_LANG' => $config['default_lang'], 'CURRENT_TIME' => $feed_type == 'ATOM' ? date3339() : date('r'), 'IMG_MIN' => generate_board_url() . '/styles/' . $user->theme['theme_path'] . '/theme/images/blog/min_dark_blue.gif', 'IMG_MAX' => generate_board_url() . '/styles/' . $user->theme['theme_path'] . '/theme/images/blog/max_dark_blue.gif', 'S_OUTPUT' => isset($_GET['output']) ? true : false));
    if ($ids !== false) {
        if (!is_array($ids)) {
            $ids = array(intval($ids));
        }
        // the items section is only used in RSS 1.0
        if ($feed_type == 'RSS_1.0') {
            if (strpos($mode, 'comments') === false) {
                // output the URLS for the items section
                foreach ($ids as $id) {
                    $template->assign_block_vars('items', array('URL' => blog_url(blog_data::$blog[$id]['user_id'], $id)));
                }
            } else {
                // output the URLS for the items section
                foreach ($ids as $id) {
                    $template->assign_block_vars('items', array('URL' => blog_url(blog_data::$reply[$id]['user_id'], $id)));
                }
            }
        }
        if (strpos($mode, 'comments') === false) {
            // Output the main data
            foreach ($ids as $id) {
                $blog_row = $blog_data->handle_blog_data($id, true);
                $row = array('URL' => blog_url(blog_data::$blog[$id]['user_id'], $id), 'USERNAME' => blog_data::$user[blog_data::$blog[$id]['user_id']]['username'], 'MESSAGE' => str_replace("'", '&#039;', $blog_row['MESSAGE']), 'PUB_DATE' => date('r', blog_data::$blog[$id]['blog_time']), 'DATE_3339' => $feed_type == 'ATOM' ? date3339(blog_data::$blog[$id]['blog_time']) : '');
                $template->assign_block_vars('item', array_merge($blog_row, $row));
            }
        } else {
            // Output the main data
            foreach ($ids as $id) {
                $reply_row = $blog_data->handle_reply_data($id, true);
                $row = array('URL' => blog_url(blog_data::$reply[$id]['user_id'], blog_data::$reply[$id]['blog_id'], $id), 'USERNAME' => blog_data::$user[blog_data::$reply[$id]['user_id']]['username'], 'MESSAGE' => str_replace("'", '&#039;', $reply_row['MESSAGE']), 'PUB_DATE' => date('r', blog_data::$reply[$id]['reply_time']), 'DATE_3339' => $feed_type == 'ATOM' ? date3339(blog_data::$reply[$id]['reply_time']) : '');
                $template->assign_block_vars('item', array_merge($reply_row, $row));
            }
        }
        blog_plugins::plugin_do_arg('function_feed_output', compact('ids', 'feed_type', 'mode'));
    }
    // Output time
    if ($feed_type == 'JAVASCRIPT') {
        header('Content-type: text/html; charset=UTF-8');
    } else {
        header('Content-type: application/xml; charset=UTF-8');
    }
    header('Cache-Control: private, no-cache="set-cookie"');
    header('Expires: 0');
    header('Pragma: no-cache');
    $template->set_template();
    $template->set_filenames(array('body' => 'blog/blog_feed.xml'));
    $template->display('body');
    garbage_collection();
    exit_handler();
}
 /**
  * Download the MySQL Upgrader script
  * @access private
  * @return void
  */
 function _download_result()
 {
     global $cache;
     // Read from the cache
     $result = $cache->get('_stk_mysql_upgrader_result');
     if ($result === false) {
         return;
     }
     // Write the file
     header('Content-Type: text/x-delimtext; name="mysql_upgrader.sql"');
     header('Content-disposition: attachment; filename=mysql_upgrader.sql');
     print $result;
     // Exit
     garbage_collection();
     exit_handler();
 }
Exemple #14
0
/**
 * Perform all quick tasks that has to be ran before we authenticate
 *
 * @param	String	$action	The action to perform
 */
function perform_unauthed_quick_tasks($action)
{
    global $template, $user;
    switch ($action) {
        // If the user wants to destroy their STK login cookie
        case 'stklogout':
            setcookie('stk_token', '', time() - 31536000);
            $user->unset_admin();
            meta_refresh(3, append_sid(PHPBB_ROOT_PATH . 'index.' . PHP_EXT));
            trigger_error('STK_LOGOUT_SUCCESS');
            break;
            // Generate the passwd file
        // Generate the passwd file
        case 'genpasswdfile':
            // Create a 25 character alphanumeric password (easier to select with a browser and won't cause confusion like it could if it ends in "." or something).
            $_pass_string = substr(preg_replace(array('#([^a-zA-Z0-9])#', '#0#', '#O#'), array('', 'Z', 'Y'), phpbb_hash(unique_id())), 2, 25);
            // The password is usable for 6 hours from now
            $_pass_exprire = time() + 21600;
            // Print a message and tell the user what to do and where to download this page
            page_header($user->lang['GEN_PASS_FILE'], false);
            $template->assign_vars(array('PASS_GENERATED' => sprintf($user->lang['PASS_GENERATED'], $_pass_string, $user->format_date($_pass_exprire, false, true)), 'PASS_GENERATED_REDIRECT' => sprintf($user->lang['PASS_GENERATED_REDIRECT'], append_sid(STK_ROOT_PATH . 'index.' . PHP_EXT)), 'S_HIDDEN_FIELDS' => build_hidden_fields(array('pass_string' => $_pass_string, 'pass_exp' => $_pass_exprire)), 'U_ACTION' => append_sid(STK_INDEX, array('action' => 'downpasswdfile'))));
            $template->set_filenames(array('body' => 'gen_password.html'));
            page_footer(false);
            break;
            // Download the passwd file
        // Download the passwd file
        case 'downpasswdfile':
            $_pass_string = request_var('pass_string', '', true);
            $_pass_exprire = request_var('pass_exp', 0);
            // Something went wrong, stop execution
            if (!isset($_POST['download_passwd']) || empty($_pass_string) || $_pass_exprire <= 0) {
                trigger_error($user->lang['GEN_PASS_FAILED'], E_USER_ERROR);
            }
            // Create the file and let the user download it
            header('Content-Type: text/x-delimtext; name="passwd.' . PHP_EXT . '"');
            header('Content-disposition: attachment; filename=passwd.' . PHP_EXT);
            print "<?php\n/**\n* Support Toolkit emergency password.\n* The file was generated on: " . $user->format_date($_pass_exprire - 21600, 'd/M/Y H:i.s', true) . " and will expire on: " . $user->format_date($_pass_exprire, 'd/M/Y H:i.s', true) . ".\n*/\n\n// This file can only be from inside the Support Toolkit\nif (!defined('IN_PHPBB') || !defined('STK_VERSION'))\n{\n\texit;\n}\n\n\$stk_passwd\t\t\t\t= '{$_pass_string}';\n\$stk_passwd_expiration\t= {$_pass_exprire};\n";
            exit_handler();
            break;
    }
}
Exemple #15
0
    /**
     * Explain queries
     */
    function sql_report($mode, $query = '')
    {
        global $cache, $starttime, $phpbb_root_path, $user;
        if (empty($_REQUEST['explain'])) {
            return false;
        }
        if (!$query && $this->query_hold != '') {
            $query = $this->query_hold;
        }
        switch ($mode) {
            case 'display':
                if (!empty($cache)) {
                    $cache->unload();
                }
                $this->sql_close();
                $mtime = explode(' ', microtime());
                $totaltime = $mtime[0] + $mtime[1] - $starttime;
                echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
					<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr">
					<head>
						<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
						<meta http-equiv="Content-Style-Type" content="text/css" />
						<meta http-equiv="imagetoolbar" content="no" />
						<title>SQL Report</title>
						<link href="' . $phpbb_root_path . 'adm/style/admin.css" rel="stylesheet" type="text/css" media="screen" />
					</head>
					<body id="errorpage">
					<div id="wrap">
						<div id="page-header">
							<a href="' . build_url('explain') . '">Return to previous page</a>
						</div>
						<div id="page-body">
							<div id="acp">
							<div class="panel">
								<span class="corners-top"><span></span></span>
								<div id="content">
									<h1>SQL Report</h1>
									<br />
									<p><b>Page generated in ' . round($totaltime, 4) . " seconds with {$this->num_queries['normal']} queries" . ($this->num_queries['cached'] ? " + {$this->num_queries['cached']} " . ($this->num_queries['cached'] == 1 ? 'query' : 'queries') . ' returning data from cache' : '') . '</b></p>

									<p>Time spent on ' . $this->sql_layer . ' queries: <b>' . round($this->sql_time, 5) . 's</b> | Time spent on PHP: <b>' . round($totaltime - $this->sql_time, 5) . 's</b></p>

									<br /><br />
									' . $this->sql_report . '
								</div>
								<span class="corners-bottom"><span></span></span>
							</div>
							</div>
						</div>
						<div id="page-footer">
							Powered by phpBB &copy; 2000, 2002, 2005, 2007 <a href="http://www.phpbb.com/">phpBB Group</a>
						</div>
					</div>
					</body>
					</html>';
                exit_handler();
                break;
            case 'stop':
                $endtime = explode(' ', microtime());
                $endtime = $endtime[0] + $endtime[1];
                $this->sql_report .= '

					<table cellspacing="1">
					<thead>
					<tr>
						<th>Query #' . $this->num_queries['total'] . '</th>
					</tr>
					</thead>
					<tbody>
					<tr>
						<td class="row3"><textarea style="font-family:\'Courier New\',monospace;width:99%" rows="5" cols="10">' . preg_replace('/\\t(AND|OR)(\\W)/', "\$1\$2", htmlspecialchars(preg_replace('/[\\s]*[\\n\\r\\t]+[\\n\\r\\s\\t]*/', "\n", $query))) . '</textarea></td>
					</tr>
					</tbody>
					</table>

					' . $this->html_hold . '

					<p style="text-align: center;">
				';
                if ($this->query_result) {
                    if (preg_match('/^(UPDATE|DELETE|REPLACE)/', $query)) {
                        $this->sql_report .= 'Affected rows: <b>' . $this->sql_affectedrows($this->query_result) . '</b> | ';
                    }
                    $this->sql_report .= 'Before: ' . sprintf('%.5f', $this->curtime - $starttime) . 's | After: ' . sprintf('%.5f', $endtime - $starttime) . 's | Elapsed: <b>' . sprintf('%.5f', $endtime - $this->curtime) . 's</b>';
                } else {
                    $error = $this->sql_error();
                    $this->sql_report .= '<b style="color: red">FAILED</b> - ' . $this->sql_layer . ' Error ' . $error['code'] . ': ' . htmlspecialchars($error['message']);
                }
                $this->sql_report .= '</p><br /><br />';
                $this->sql_time += $endtime - $this->curtime;
                break;
            case 'start':
                $this->query_hold = $query;
                $this->html_hold = '';
                $this->_sql_report($mode, $query);
                $this->curtime = explode(' ', microtime());
                $this->curtime = $this->curtime[0] + $this->curtime[1];
                break;
            case 'add_select_row':
                $html_table = func_get_arg(2);
                $row = func_get_arg(3);
                if (!$html_table && sizeof($row)) {
                    $html_table = true;
                    $this->html_hold .= '<table cellspacing="1"><tr>';
                    foreach (array_keys($row) as $val) {
                        $this->html_hold .= '<th>' . ($val ? ucwords(str_replace('_', ' ', $val)) : '&nbsp;') . '</th>';
                    }
                    $this->html_hold .= '</tr>';
                }
                $this->html_hold .= '<tr>';
                $class = 'row1';
                foreach (array_values($row) as $val) {
                    $class = $class == 'row1' ? 'row2' : 'row1';
                    $this->html_hold .= '<td class="' . $class . '">' . ($val ? $val : '&nbsp;') . '</td>';
                }
                $this->html_hold .= '</tr>';
                return $html_table;
                break;
            case 'fromcache':
                $this->_sql_report($mode, $query);
                break;
            case 'record_fromcache':
                $endtime = func_get_arg(2);
                $splittime = func_get_arg(3);
                $time_cache = $endtime - $this->curtime;
                $time_db = $splittime - $endtime;
                $color = $time_db > $time_cache ? 'green' : 'red';
                $this->sql_report .= '<table cellspacing="1"><thead><tr><th>Query results obtained from the cache</th></tr></thead><tbody><tr>';
                $this->sql_report .= '<td class="row3"><textarea style="font-family:\'Courier New\',monospace;width:99%" rows="5" cols="10">' . preg_replace('/\\t(AND|OR)(\\W)/', "\$1\$2", htmlspecialchars(preg_replace('/[\\s]*[\\n\\r\\t]+[\\n\\r\\s\\t]*/', "\n", $query))) . '</textarea></td></tr></tbody></table>';
                $this->sql_report .= '<p style="text-align: center;">';
                $this->sql_report .= 'Before: ' . sprintf('%.5f', $this->curtime - $starttime) . 's | After: ' . sprintf('%.5f', $endtime - $starttime) . 's | Elapsed [cache]: <b style="color: ' . $color . '">' . sprintf('%.5f', $time_cache) . 's</b> | Elapsed [db]: <b>' . sprintf('%.5f', $time_db) . 's</b></p><br /><br />';
                // Pad the start time to not interfere with page timing
                $starttime += $time_db;
                break;
            default:
                $this->_sql_report($mode, $query);
                break;
        }
        return true;
    }
Exemple #16
0
    /**
     * 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']);
    }
Exemple #17
0
/**
* Show upload popup (progress bar)
*/
function upload_popup($forum_style = 0)
{
    global $template, $user;
    $forum_style ? $user->setup('posting', $forum_style) : $user->setup('posting');
    page_header($user->lang['PROGRESS_BAR'], false);
    $template->set_filenames(array('popup' => 'posting_progress_bar.html'));
    $template->assign_vars(array('PROGRESS_BAR' => $user->img('upload_bar', $user->lang['UPLOAD_IN_PROGRESS'])));
    $template->display('popup');
    garbage_collection();
    exit_handler();
}
Exemple #18
0
 /**
  * Entry point for delivering image CAPTCHAs in the ACP.
  */
 function deliver_demo($selected)
 {
     global $db, $user, $config;
     $captcha =& phpbb_captcha_factory::get_instance($selected);
     $captcha->init(CONFIRM_REG);
     $captcha->execute_demo();
     garbage_collection();
     exit_handler();
 }
Exemple #19
0
 /**
  * This listener is run when the KernelEvents::TERMINATE event is triggered
  * This comes after a Response has been sent to the server; this is
  * primarily cleanup stuff.
  *
  * @param PostResponseEvent $event
  * @return null
  */
 public function on_kernel_terminate(PostResponseEvent $event)
 {
     exit_handler();
 }
    function repair()
    {
        global $db;
        $stylelist = filelist(PHPBB_ROOT_PATH . 'styles/', '', 'cfg');
        ksort($stylelist);
        // Loop throught the files and try to find a style we can use.
        // To be usable the directory name in the style.cfg is the same as the directory.
        foreach (array_keys($stylelist) as $styledirname) {
            if (!in_array('style.cfg', $stylelist[$styledirname])) {
                continue;
            }
            // Read the cfg, should always be index 0
            $items = parse_cfg_file(PHPBB_ROOT_PATH . 'styles/' . $styledirname . 'style.cfg');
            // Unify the name in the cfg to something used as a directory
            // Spaces -> '_'
            // All lowercase
            $stylename = utf8_clean_string(str_replace(' ', '_', $items['name']));
            // Clean up the dirname
            $dirname = substr($styledirname, -1) == '/' ? substr($styledirname, 0, -1) : $styledirname;
            // If not the same switch to the next one
            if ($dirname != $stylename) {
                continue;
            }
            // If this style isn't installed we will install the style at this point.
            $sql = 'SELECT style_id
				FROM ' . STYLES_TABLE . "\n\t\t\t\tWHERE style_name = '" . $db->sql_escape($items['name']) . "'";
            $result = $db->sql_query($sql);
            $this->sid = $db->sql_fetchfield('style_id', false, $result);
            $db->sql_freeresult($result);
            if (empty($this->sid)) {
                // Nasty, but the style installer fetches these in the method o_0
                $GLOBALS['_REQUEST']['path'] = $stylename;
                $GLOBALS['_POST']['update'] = true;
                // Call the style installer
                $this->ac->install('style');
                // Fetch the id
                $sql = 'SELECT style_id
					FROM ' . STYLES_TABLE . "\n\t\t\t\t\tWHERE style_name = '" . $db->sql_escape($items['name']) . "'";
                $result = $db->sql_query($sql);
                $this->sid = $db->sql_fetchfield('style_id', false, $result);
                $db->sql_freeresult($result);
            }
            // Set this style as the active style
            set_config('default_style', $this->sid);
            set_config('override_user_style', 1);
            // Overriding the style should enable the board for everyone
            return;
        }
        echo 'The support toolkit couldn\'t find an available style. Please seek further assistance in the support forums on <a href="http://www.phpbb.com/community/viewforum.php?f=46" title="phpBB.com Support forum">phpbb.com</a>';
        garbage_collection();
        exit_handler();
    }
Exemple #21
0
 /**
  * Output an error message
  * If skip is true, return and continue execution, else exit
  */
 function error($error, $line, $file, $skip = false)
 {
     global $lang, $db, $template, $phpbb_admin_path;
     if ($skip) {
         $template->assign_block_vars('checks', array('S_LEGEND' => true, 'LEGEND' => $lang['INST_ERR']));
         $template->assign_block_vars('checks', array('TITLE' => basename($file) . ' [ ' . $line . ' ]', 'RESULT' => '<b style="color:red">' . $error . '</b>'));
         return;
     }
     echo '<!DOCTYPE html>';
     echo '<html dir="ltr">';
     echo '<head>';
     echo '<meta charset="utf-8">';
     echo '<title>' . $lang['INST_ERR_FATAL'] . '</title>';
     echo '<link href="' . htmlspecialchars($phpbb_admin_path) . 'style/admin.css" rel="stylesheet" type="text/css" media="screen" />';
     echo '</head>';
     echo '<body id="errorpage">';
     echo '<div id="wrap">';
     echo '	<div id="page-header">';
     echo '	</div>';
     echo '	<div id="page-body">';
     echo '		<div id="acp">';
     echo '		<div class="panel">';
     echo '			<span class="corners-top"><span></span></span>';
     echo '			<div id="content">';
     echo '				<h1>' . $lang['INST_ERR_FATAL'] . '</h1>';
     echo '		<p>' . $lang['INST_ERR_FATAL'] . "</p>\n";
     echo '		<p>' . basename($file) . ' [ ' . $line . " ]</p>\n";
     echo '		<p><b>' . $error . "</b></p>\n";
     echo '			</div>';
     echo '			<span class="corners-bottom"><span></span></span>';
     echo '		</div>';
     echo '		</div>';
     echo '	</div>';
     echo '	<div id="page-footer">';
     echo '		Powered by <a href="https://www.phpbb.com/">phpBB</a>&reg; Forum Software &copy; phpBB Limited';
     echo '	</div>';
     echo '</div>';
     echo '</body>';
     echo '</html>';
     if (!empty($db) && is_object($db)) {
         $db->sql_close();
     }
     exit_handler();
 }
Exemple #22
0
/**
* Page footer for acp pages
*/
function adm_page_footer($copyright_html = true)
{
    global $db, $config, $template, $user, $auth, $cache;
    global $starttime, $phpbb_root_path, $phpbb_admin_path, $phpEx;
    // Output page creation time
    if (defined('DEBUG')) {
        $mtime = explode(' ', microtime());
        $totaltime = $mtime[0] + $mtime[1] - $starttime;
        if (!empty($_REQUEST['explain']) && $auth->acl_get('a_') && defined('DEBUG_EXTRA') && method_exists($db, 'sql_report')) {
            $db->sql_report('display');
        }
        $debug_output = sprintf('Time : %.3fs | ' . $db->sql_num_queries() . ' Queries | GZIP : ' . ($config['gzip_compress'] ? 'On' : 'Off') . ($user->load ? ' | Load : ' . $user->load : ''), $totaltime);
        if ($auth->acl_get('a_') && defined('DEBUG_EXTRA')) {
            if (function_exists('memory_get_usage')) {
                if ($memory_usage = memory_get_usage()) {
                    global $base_memory_usage;
                    $memory_usage -= $base_memory_usage;
                    $memory_usage = get_formatted_filesize($memory_usage);
                    $debug_output .= ' | Memory Usage: ' . $memory_usage;
                }
            }
            $debug_output .= ' | <a href="' . build_url() . '&amp;explain=1">Explain</a>';
        }
    }
    $template->assign_vars(array('DEBUG_OUTPUT' => defined('DEBUG') ? $debug_output : '', 'TRANSLATION_INFO' => !empty($user->lang['TRANSLATION_INFO']) ? $user->lang['TRANSLATION_INFO'] : '', 'S_COPYRIGHT_HTML' => $copyright_html, 'CREDIT_LINE' => $user->lang('POWERED_BY', '<a href="https://www.phpbb.com/">phpBB</a>&reg; Forum Software &copy; phpBB Group'), 'VERSION' => $config['version']));
    $template->display('body');
    garbage_collection();
    exit_handler();
}
Exemple #23
0
     $template->assign_vars(array('S_BLOCKS_ACTION' => append_sid($cms_admin->root), 'S_HIDDEN_FIELDS' => $cms_admin->s_hidden_fields));
     // Old Version...
     /*
     if ($cms_admin->mode_layout_name == 'layouts_special')
     {
     	$cms_admin->show_blocks_list();
     }
     else
     {
     */
     $result = $cms_admin->show_blocks_list_ajax();
     if (is_array($result)) {
         // json data
         echo json_encode($result);
         garbage_collection();
         exit_handler();
         exit;
     }
     if ($result === false) {
         // no blocks found: show form to add a block
         $template_to_parse = CMS_TPL . 'cms_block_content_body.tpl';
         $cms_admin->manage_block();
     } elseif (defined('AJAX_CMS')) {
         // ajax data present. show new page
         $template_to_parse = CMS_TPL . 'cms_blocks_list_body_ajax.tpl';
     }
     /*
     }
     */
 } else {
     message_die(GENERAL_MESSAGE, $lang['No_layout_selected']);
/**
 * Error and message handler, call with trigger_error
 */
function titania_msg_handler($errno, $msg_text, $errfile, $errline)
{
    global $msg_title, $msg_long_text;
    // Do not display notices if we suppress them via @
    if (error_reporting() == 0) {
        return;
    }
    // Message handler is stripping text. In case we need it, we are possible to define long text...
    if (isset($msg_long_text) && $msg_long_text && !$msg_text) {
        $msg_text = $msg_long_text;
    }
    switch ($errno) {
        case E_NOTICE:
        case E_WARNING:
            // Check the error reporting level and return if the error level does not match
            // If DEBUG is defined the default level is E_ALL
            if (($errno & (defined('DEBUG') ? E_ALL : error_reporting())) == 0) {
                return;
            }
            if (strpos($errfile, 'cache') === false && strpos($errfile, 'template.') === false) {
                // flush the content, else we get a white page if output buffering is on
                if ((int) @ini_get('output_buffering') === 1 || strtolower(@ini_get('output_buffering')) === 'on') {
                    @ob_flush();
                }
                // Another quick fix for those having gzip compression enabled, but do not flush if the coder wants to catch "something". ;)
                if (!empty(phpbb::$config['gzip_compress'])) {
                    if (@extension_loaded('zlib') && !headers_sent() && !ob_get_level()) {
                        @ob_flush();
                    }
                }
                // remove complete path to installation, with the risk of changing backslashes meant to be there
                $errfile = str_replace(array(phpbb_realpath(PHPBB_ROOT_PATH), '\\'), array('', '/'), $errfile);
                $msg_text = str_replace(array(phpbb_realpath(PHPBB_ROOT_PATH), '\\'), array('', '/'), $msg_text);
                echo '<b>[phpBB Debug] PHP Notice</b>: in file <b>' . $errfile . '</b> on line <b>' . $errline . '</b>: <b>' . $msg_text . '</b><br />' . "\n";
                // echo '<br /><br />BACKTRACE<br />' . get_backtrace() . '<br />' . "\n";
            }
            return;
            break;
        case E_USER_ERROR:
            if (!empty(phpbb::$user) && !empty(phpbb::$user->lang)) {
                $msg_text = !empty(phpbb::$user->lang[$msg_text]) ? phpbb::$user->lang[$msg_text] : $msg_text;
                $msg_title = !isset($msg_title) ? phpbb::$user->lang['GENERAL_ERROR'] : (!empty(phpbb::$user->lang[$msg_title]) ? phpbb::$user->lang[$msg_title] : $msg_title);
                $l_return_index = sprintf(phpbb::$user->lang['RETURN_INDEX'], '<a href="' . titania::$absolute_path . '">', '</a>');
                $l_notify = '';
                if (!empty(phpbb::$config['board_contact'])) {
                    $l_notify = '<p>' . sprintf(phpbb::$user->lang['NOTIFY_ADMIN_EMAIL'], phpbb::$config['board_contact']) . '</p>';
                }
            } else {
                $msg_title = 'General Error';
                $l_return_index = '<a href="' . titania::$absolute_path . '">Return to index page</a>';
                $l_notify = '';
                if (!empty(phpbb::$config['board_contact'])) {
                    $l_notify = '<p>Please notify the board administrator or webmaster: <a href="mailto:' . phpbb::$config['board_contact'] . '">' . phpbb::$config['board_contact'] . '</a></p>';
                }
            }
            garbage_collection();
            // Try to not call the adm page data...
            echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">';
            echo '<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr">';
            echo '<head>';
            echo '<meta http-equiv="content-type" content="text/html; charset=utf-8" />';
            echo '<title>' . $msg_title . '</title>';
            echo '<style type="text/css">' . "\n" . '/* <![CDATA[ */' . "\n";
            echo '* { margin: 0; padding: 0; } html { font-size: 100%; height: 100%; margin-bottom: 1px; background-color: #E4EDF0; } body { font-family: "Lucida Grande", Verdana, Helvetica, Arial, sans-serif; color: #536482; background: #E4EDF0; font-size: 62.5%; margin: 0; } ';
            echo 'a:link, a:active, a:visited { color: #006699; text-decoration: none; } a:hover { color: #DD6900; text-decoration: underline; } ';
            echo '#wrap { padding: 0 20px 15px 20px; min-width: 615px; } #page-header { text-align: right; height: 40px; } #page-footer { clear: both; font-size: 1em; text-align: center; } ';
            echo '.panel { margin: 4px 0; background-color: #FFFFFF; border: solid 1px  #A9B8C2; } ';
            echo '#errorpage #page-header a { font-weight: bold; line-height: 6em; } #errorpage #content { padding: 10px; } #errorpage #content h1 { line-height: 1.2em; margin-bottom: 0; color: #DF075C; } ';
            echo '#errorpage #content div { margin-top: 20px; margin-bottom: 5px; border-bottom: 1px solid #CCCCCC; padding-bottom: 5px; color: #333333; font: bold 1.2em "Lucida Grande", Arial, Helvetica, sans-serif; text-decoration: none; line-height: 120%; text-align: left; } ';
            echo "\n" . '/* ]]> */' . "\n";
            echo '</style>';
            echo '</head>';
            echo '<body id="errorpage">';
            echo '<div id="wrap">';
            echo '	<div id="page-header">';
            echo '		' . $l_return_index;
            echo '	</div>';
            echo '	<div id="acp">';
            echo '	<div class="panel">';
            echo '		<div id="content">';
            echo '			<h1>' . $msg_title . '</h1>';
            echo '			<div>' . $msg_text . '</div>';
            echo '			<div>' . get_backtrace() . '</div>';
            echo $l_notify;
            echo '		</div>';
            echo '	</div>';
            echo '	</div>';
            echo '	<div id="page-footer">';
            echo '		Powered by phpBB &copy; 2000, 2002, 2005, 2007 <a href="http://www.phpbb.com/">phpBB Group</a>';
            echo '	</div>';
            echo '</div>';
            echo '</body>';
            echo '</html>';
            exit_handler();
            // On a fatal error (and E_USER_ERROR *is* fatal) we never want other scripts to continue and force an exit here.
            exit;
            break;
        case E_USER_WARNING:
        case E_USER_NOTICE:
            define('IN_ERROR_HANDLER', true);
            if (empty(phpbb::$user->data)) {
                phpbb::$user->session_begin();
            }
            // We re-init the auth array to get correct results on login/logout
            phpbb::$auth->acl(phpbb::$user->data);
            if (empty(phpbb::$user->lang)) {
                phpbb::$user->setup();
            }
            $msg_text = !empty(phpbb::$user->lang[$msg_text]) ? phpbb::$user->lang[$msg_text] : $msg_text;
            $msg_title = !isset($msg_title) ? phpbb::$user->lang['INFORMATION'] : (!empty(phpbb::$user->lang[$msg_title]) ? phpbb::$user->lang[$msg_title] : $msg_title);
            if (!defined('HEADER_INC')) {
                if (defined('IN_ADMIN') && isset(phpbb::$user->data['session_admin']) && phpbb::$user->data['session_admin']) {
                    adm_page_header($msg_title);
                } else {
                    titania::page_header($msg_title);
                }
            }
            phpbb::$template->set_filenames(array('body' => 'common/message_body.html'));
            phpbb::$template->assign_vars(array('MESSAGE_TITLE' => $msg_title, 'MESSAGE_TEXT' => $msg_text . titania_backtrace(), 'S_USER_WARNING' => $errno == E_USER_WARNING ? true : false, 'S_USER_NOTICE' => $errno == E_USER_NOTICE ? true : false));
            // We do not want the cron script to be called on error messages
            define('IN_CRON', true);
            if (defined('IN_ADMIN') && isset(phpbb::$user->data['session_admin']) && phpbb::$user->data['session_admin']) {
                adm_page_footer();
            } else {
                titania::page_footer(false);
            }
            exit_handler();
            break;
    }
    // If we notice an error not handled here we pass this back to PHP by returning false
    // This may not work for all php versions
    return false;
}
Exemple #25
0
	/**
	* Output an error message
	* If skip is true, return and continue execution, else exit
	*/
	function error($error, $line, $file, $skip = false)
	{
		global $lang, $db, $template;

		if ($skip)
		{
			$template->assign_block_vars('checks', array(
				'S_LEGEND'	=> true,
				'LEGEND'	=> $lang['INST_ERR'],
			));

			$template->assign_block_vars('checks', array(
				'TITLE'		=> basename($file) . ' [ ' . $line . ' ]',
				'RESULT'	=> '<b style="color:red">' . $error . '</b>',
			));

			return;
		}

		echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">';
		echo '<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr">';
		echo '<head>';
		echo '<meta http-equiv="content-type" content="text/html; charset=utf-8" />';
		echo '<title>' . $lang['INST_ERR_FATAL'] . '</title>';
		echo '<link href="../adm/style/admin.css" rel="stylesheet" type="text/css" media="screen" />';
		echo '</head>';
		echo '<body id="errorpage">';
		echo '<div id="wrap">';
		echo '	<div id="page-header">';
		echo '	</div>';
		echo '	<div id="page-body">';
		echo '		<div id="acp">';
		echo '		<div class="panel">';
		echo '			<span class="corners-top"><span></span></span>';
		echo '			<div id="content">';
		echo '				<h1>' . $lang['INST_ERR_FATAL'] . '</h1>';
		echo '		<p>' . $lang['INST_ERR_FATAL'] . "</p>\n";
		echo '		<p>' . basename($file) . ' [ ' . $line . " ]</p>\n";
		echo '		<p><b>' . $error . "</b></p>\n";
		echo '			</div>';
		echo '			<span class="corners-bottom"><span></span></span>';
		echo '		</div>';
		echo '		</div>';
		echo '	</div>';
		echo '	<div id="page-footer">';
		echo '		Powered by phpBB &copy; 2000, 2002, 2005, 2007 <a href="http://www.phpbb.com/">phpBB Group</a>';
		echo '	</div>';
		echo '</div>';
		echo '</body>';
		echo '</html>';

		if (!empty($db) && is_object($db))
		{
			$db->sql_close();
		}

		exit_handler();
	}
/**
* Page footer for acp pages
*/
function adm_page_footer($copyright_html = true)
{
    global $db, $config, $template, $user, $auth, $cache;
    global $starttime, $phpbb_root_path, $phpbb_admin_path, $phpEx;
    global $request, $phpbb_dispatcher;
    // A listener can set this variable to `true` when it overrides this function
    $adm_page_footer_override = false;
    /**
     * Execute code and/or overwrite adm_page_footer()
     *
     * @event core.adm_page_footer
     * @var	bool	copyright_html			Shall we display the copyright?
     * @var	bool	adm_page_footer_override	Shall we return instead of
     *									running the rest of adm_page_footer()
     * @since 3.1.0-a1
     */
    $vars = array('copyright_html', 'adm_page_footer_override');
    extract($phpbb_dispatcher->trigger_event('core.adm_page_footer', compact($vars)));
    if ($adm_page_footer_override) {
        return;
    }
    phpbb_check_and_display_sql_report($request, $auth, $db);
    $template->assign_vars(array('DEBUG_OUTPUT' => phpbb_generate_debug_output($db, $config, $auth, $user, $phpbb_dispatcher), 'TRANSLATION_INFO' => !empty($user->lang['TRANSLATION_INFO']) ? $user->lang['TRANSLATION_INFO'] : '', 'S_COPYRIGHT_HTML' => $copyright_html, 'CREDIT_LINE' => $user->lang('POWERED_BY', '<a href="https://www.phpbb.com/">phpBB</a>&reg; Forum Software &copy; phpBB Limited'), 'T_JQUERY_LINK' => !empty($config['allow_cdn']) && !empty($config['load_jquery_url']) ? $config['load_jquery_url'] : "{$phpbb_root_path}assets/javascript/jquery.min.js", 'S_ALLOW_CDN' => !empty($config['allow_cdn']), 'VERSION' => $config['version']));
    $template->display('body');
    garbage_collection();
    exit_handler();
}
Exemple #27
0
/**
* Generate page footer
*/
function page_footer($run_cron = true)
{
    global $db, $config, $template, $user, $auth, $cache, $starttime, $phpbb_root_path, $phpEx;
    // Output page creation time
    if (defined('DEBUG')) {
        $mtime = explode(' ', microtime());
        $totaltime = $mtime[0] + $mtime[1] - $starttime;
        if (!empty($_REQUEST['explain']) && $auth->acl_get('a_') && defined('DEBUG_EXTRA') && method_exists($db, 'sql_report')) {
            $db->sql_report('display');
        }
        $debug_output = sprintf('Time : %.3fs | ' . $db->sql_num_queries() . ' Queries | GZIP : ' . ($config['gzip_compress'] ? 'On' : 'Off') . ($user->load ? ' | Load : ' . $user->load : ''), $totaltime);
        if ($auth->acl_get('a_') && defined('DEBUG_EXTRA')) {
            if (function_exists('memory_get_usage')) {
                if ($memory_usage = memory_get_usage()) {
                    global $base_memory_usage;
                    $memory_usage -= $base_memory_usage;
                    $memory_usage = get_formatted_filesize($memory_usage);
                    $debug_output .= ' | Memory Usage: ' . $memory_usage;
                }
            }
            $debug_output .= ' | <a href="' . build_url() . '&amp;explain=1">Explain</a>';
        }
    }
    $template->assign_vars(array('DEBUG_OUTPUT' => defined('DEBUG') ? $debug_output : '', 'TRANSLATION_INFO' => !empty($user->lang['TRANSLATION_INFO']) ? $user->lang['TRANSLATION_INFO'] : '', 'U_ACP' => $auth->acl_get('a_') && !empty($user->data['is_registered']) ? append_sid("{$phpbb_root_path}adm/index.{$phpEx}", false, true, $user->session_id) : ''));
    // Call cron-type script
    if (!defined('IN_CRON') && $run_cron && !$config['board_disable']) {
        $cron_type = '';
        if (time() - $config['queue_interval'] > $config['last_queue_run'] && !defined('IN_ADMIN') && file_exists($phpbb_root_path . 'cache/queue.' . $phpEx)) {
            // Process email queue
            $cron_type = 'queue';
        } else {
            if (method_exists($cache, 'tidy') && time() - $config['cache_gc'] > $config['cache_last_gc']) {
                // Tidy the cache
                $cron_type = 'tidy_cache';
            } else {
                if (time() - $config['warnings_gc'] > $config['warnings_last_gc']) {
                    $cron_type = 'tidy_warnings';
                } else {
                    if (time() - $config['database_gc'] > $config['database_last_gc']) {
                        // Tidy the database
                        $cron_type = 'tidy_database';
                    } else {
                        if (time() - $config['search_gc'] > $config['search_last_gc']) {
                            // Tidy the search
                            $cron_type = 'tidy_search';
                        } else {
                            if (time() - $config['session_gc'] > $config['session_last_gc']) {
                                $cron_type = 'tidy_sessions';
                            }
                        }
                    }
                }
            }
        }
        if ($cron_type) {
            $template->assign_var('RUN_CRON_TASK', '<img src="' . append_sid($phpbb_root_path . 'cron.' . $phpEx, 'cron_type=' . $cron_type) . '" width="1" height="1" alt="cron" />');
        }
    }
    $template->display('body');
    garbage_collection();
    exit_handler();
}
Exemple #28
0
 function rss_feed()
 {
     if (!$this->config['ub_rss_enabled']) {
         trigger_error($this->user->lang['BLOG_RSS_FEED_DISABLED']);
     } else {
         // Set up standard feed information
         $feed_vars = ['TITLE' => html_entity_decode($this->config['ub_rss_title']), 'DESCRIPTION' => html_entity_decode($this->config['ub_rss_desc']), 'WEBMASTER' => $this->config['ub_rss_email'], 'EMAIL' => $this->config['board_contact'], 'CATEGORY' => html_entity_decode($this->config['ub_rss_cat']), 'COPYRIGHT' => html_entity_decode($this->config['ub_rss_copy']), 'LANGUAGE' => html_entity_decode($this->config['ub_rss_lang']), 'LINK' => generate_board_url($without_script_path = true) . $this->helper->route('posey_ultimateblog_rss'), 'IMAGE' => $this->config['ub_rss_img'], 'AUTHOR' => $this->config['sitename']];
         // Set up SQL array
         $sql_ary = ['SELECT' => 'b.blog_id, b.blog_subject, b.blog_text, b.post_time, b.bbcode_uid, b.bbcode_bitfield, b.enable_bbcode, b.enable_smilies, b.enable_magic_url, u.username_clean, c.cat_name', 'FROM' => [$this->ub_blogs_table => 'b', $this->ub_cats_table => 'c'], 'LEFT_JOIN' => [['FROM' => [USERS_TABLE => 'u'], 'ON' => 'b.poster_id = u.user_id']], 'WHERE' => 'b.cat_id = c.cat_id', 'ORDER_BY' => 'b.post_time DESC'];
         // Run SQL and get 10 latest blogs
         $sql = $this->db->sql_build_query('SELECT', $sql_ary);
         $result = $this->db->sql_query_limit($sql, 10);
         while ($row = $this->db->sql_fetchrow($result)) {
             // Set up blog text for Feed display
             $flags = ($row['enable_bbcode'] ? OPTION_FLAG_BBCODE : 0) + ($row['enable_smilies'] ? OPTION_FLAG_SMILIES : 0) + ($row['enable_magic_url'] ? OPTION_FLAG_LINKS : 0);
             $blog_text = generate_text_for_display($row['blog_text'], $row['bbcode_uid'], $row['bbcode_bitfield'], $flags);
             # Set up images source properly for regular images:
             $blog_text = str_replace('<img src="./', '<img src="' . generate_board_url(), $blog_text);
             # Censor the text:
             $blog_text = censor_text($blog_text);
             # Remove smilies from the text:
             $blog_text = preg_replace('/<img class="smilies"(.*?) \\/>/', '', $blog_text);
             # Decode HTML characters:
             $blog_text = htmlentities($blog_text);
             // Assign block vars
             $item_row = ['link' => generate_board_url($without_script_path = true) . $this->helper->route('posey_ultimateblog_blog_display', ['blog_id' => (int) $row['blog_id']]), 'author' => html_entity_decode($row['username_clean']), 'published' => $this->user->format_date($row['post_time'], 'D, d M Y H:i:s O'), 'category' => html_entity_decode($row['cat_name']), 'title' => html_entity_decode(censor_text($row['blog_subject'])), 'description' => $blog_text];
             $item_vars[] = $item_row;
         }
         // OUTPUT THE RSS PAGE
         header("Content-Type: application/atom+xml; charset=UTF-8");
         if (!empty($this->user->data['is_bot'])) {
             // Let reverse proxies know we detected a bot.
             header('X-PHPBB-IS-BOT: yes');
         }
         echo '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
         echo '<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="' . $feed_vars['LANGUAGE'] . '">' . "\n";
         echo '	<link rel="self" type="application/atom+xml" href="' . $feed_vars['LINK'] . '" />' . "\n\n";
         echo !empty($feed_vars['TITLE']) ? '	<title>' . $feed_vars['TITLE'] . '</title>' . "\n" : '';
         echo !empty($feed_vars['DESCRIPTION']) ? '	<description>' . $feed_vars['DESCRIPTION'] . '</description>' . "\n" : '';
         echo !empty($feed_vars['LINK']) ? '	<link href="' . $feed_vars['LINK'] . '" />' . "\n" : '';
         echo !empty($feed_vars['WEBMASTER']) ? '	<webMaster>' . $feed_vars['EMAIL'] . '</webMaster>' . "\n" : '';
         echo !empty($feed_vars['CATEGORY']) ? '	<category>' . $feed_vars['CATEGORY'] . '</category>' . "\n" : '';
         echo !empty($feed_vars['COPYRIGHT']) ? '	<copyright>' . $feed_vars['COPYRIGHT'] . '</copyright>' . "\n" : '';
         echo '	<author><name><![CDATA[' . $feed_vars['AUTHOR'] . ']]></name></author>' . "\n\n";
         foreach ($item_vars as $row) {
             echo '	<entry>' . "\n";
             if (!empty($row['author'])) {
                 echo '		<author><name><![CDATA[' . $row['author'] . ']]></name></author>' . "\n";
             }
             if (!empty($row['published'])) {
                 echo '		<published>' . $row['published'] . '</published>' . "\n";
             }
             echo '		<id>' . $row['link'] . '</id>' . "\n";
             echo '		<link href="' . $row['link'] . '"/>' . "\n";
             echo '		<title type="html"><![CDATA[' . $row['title'] . ']]></title>' . "\n";
             if (!empty($row['category'])) {
                 echo '		<category term="' . $row['category'] . '" label="' . $row['category'] . '"/>' . "\n";
             }
             echo '		<content type="html" xml:base="' . $row['link'] . '"><![CDATA[' . "\n";
             echo '			' . $row['description'];
             echo "\n" . '			<hr />' . "\n" . '		]]></content>' . "\n";
             echo '	</entry>' . "\n";
         }
         echo '</feed>';
         garbage_collection();
         exit_handler();
     }
 }
Exemple #29
0
    /**
     * Check for banned user
     *
     * Checks whether the supplied user is banned by id, ip or email. If no parameters
     * are passed to the method pre-existing session data is used.
     *
     * @param int|false		$user_id		The user id
     * @param mixed			$user_ips		Can contain a string with one IP or an array of multiple IPs
     * @param string|false	$user_email		The user email
     * @param bool			$return			If $return is false this routine does not return on finding a banned user,
     *	it outputs a relevant message and stops execution.
     */
    function check_ban($user_id = false, $user_ips = false, $user_email = false, $return = false)
    {
        global $config, $db, $phpbb_dispatcher;
        if (defined('IN_CHECK_BAN') || defined('SKIP_CHECK_BAN')) {
            return;
        }
        $banned = false;
        $cache_ttl = 3600;
        $where_sql = array();
        $sql = 'SELECT ban_ip, ban_userid, ban_email, ban_exclude, ban_give_reason, ban_end
			FROM ' . BANLIST_TABLE . '
			WHERE ';
        // Determine which entries to check, only return those
        if ($user_email === false) {
            $where_sql[] = "ban_email = ''";
        }
        if ($user_ips === false) {
            $where_sql[] = "(ban_ip = '' OR ban_exclude = 1)";
        }
        if ($user_id === false) {
            $where_sql[] = '(ban_userid = 0 OR ban_exclude = 1)';
        } else {
            $cache_ttl = $user_id == ANONYMOUS ? 3600 : 0;
            $_sql = '(ban_userid = ' . $user_id;
            if ($user_email !== false) {
                $_sql .= " OR ban_email <> ''";
            }
            if ($user_ips !== false) {
                $_sql .= " OR ban_ip <> ''";
            }
            $_sql .= ')';
            $where_sql[] = $_sql;
        }
        $sql .= sizeof($where_sql) ? implode(' AND ', $where_sql) : '';
        $result = $db->sql_query($sql, $cache_ttl);
        $ban_triggered_by = 'user';
        while ($row = $db->sql_fetchrow($result)) {
            if ($row['ban_end'] && $row['ban_end'] < time()) {
                continue;
            }
            $ip_banned = false;
            if (!empty($row['ban_ip'])) {
                if (!is_array($user_ips)) {
                    $ip_banned = preg_match('#^' . str_replace('\\*', '.*?', preg_quote($row['ban_ip'], '#')) . '$#i', $user_ips);
                } else {
                    foreach ($user_ips as $user_ip) {
                        if (preg_match('#^' . str_replace('\\*', '.*?', preg_quote($row['ban_ip'], '#')) . '$#i', $user_ip)) {
                            $ip_banned = true;
                            break;
                        }
                    }
                }
            }
            if (!empty($row['ban_userid']) && intval($row['ban_userid']) == $user_id || $ip_banned || !empty($row['ban_email']) && preg_match('#^' . str_replace('\\*', '.*?', preg_quote($row['ban_email'], '#')) . '$#i', $user_email)) {
                if (!empty($row['ban_exclude'])) {
                    $banned = false;
                    break;
                } else {
                    $banned = true;
                    $ban_row = $row;
                    if (!empty($row['ban_userid']) && intval($row['ban_userid']) == $user_id) {
                        $ban_triggered_by = 'user';
                    } else {
                        if ($ip_banned) {
                            $ban_triggered_by = 'ip';
                        } else {
                            $ban_triggered_by = 'email';
                        }
                    }
                    // Don't break. Check if there is an exclude rule for this user
                }
            }
        }
        $db->sql_freeresult($result);
        /**
         * Event to set custom ban type
         *
         * @event core.session_set_custom_ban
         * @var	bool		return				If $return is false this routine does not return on finding a banned user, it outputs a relevant message and stops execution
         * @var	bool		banned				Check if user already banned
         * @var	array|false	ban_row				Ban data
         * @var	string		ban_triggered_by	Method that caused ban, can be your custom method
         * @since 3.1.3-RC1
         */
        $ban_row = isset($ban_row) ? $ban_row : false;
        $vars = array('return', 'banned', 'ban_row', 'ban_triggered_by');
        extract($phpbb_dispatcher->trigger_event('core.session_set_custom_ban', compact($vars)));
        if ($banned && !$return) {
            global $template, $phpbb_root_path, $phpEx;
            // If the session is empty we need to create a valid one...
            if (empty($this->session_id)) {
                // This seems to be no longer needed? - #14971
                //				$this->session_create(ANONYMOUS);
            }
            // Initiate environment ... since it won't be set at this stage
            $this->setup();
            // Logout the user, banned users are unable to use the normal 'logout' link
            if ($this->data['user_id'] != ANONYMOUS) {
                $this->session_kill();
            }
            // We show a login box here to allow founders accessing the board if banned by IP
            if (defined('IN_LOGIN') && $this->data['user_id'] == ANONYMOUS) {
                $this->setup('ucp');
                $this->data['is_registered'] = $this->data['is_bot'] = false;
                // Set as a precaution to allow login_box() handling this case correctly as well as this function not being executed again.
                define('IN_CHECK_BAN', 1);
                login_box("index.{$phpEx}");
                // The false here is needed, else the user is able to circumvent the ban.
                $this->session_kill(false);
            }
            // Ok, we catch the case of an empty session id for the anonymous user...
            // This can happen if the user is logging in, banned by username and the login_box() being called "again".
            if (empty($this->session_id) && defined('IN_CHECK_BAN')) {
                $this->session_create(ANONYMOUS);
            }
            // Determine which message to output
            $till_date = $ban_row['ban_end'] ? $this->format_date($ban_row['ban_end']) : '';
            $message = $ban_row['ban_end'] ? 'BOARD_BAN_TIME' : 'BOARD_BAN_PERM';
            $contact_link = phpbb_get_board_contact_link($config, $phpbb_root_path, $phpEx);
            $message = sprintf($this->lang[$message], $till_date, '<a href="' . $contact_link . '">', '</a>');
            $message .= $ban_row['ban_give_reason'] ? '<br /><br />' . sprintf($this->lang['BOARD_BAN_REASON'], $ban_row['ban_give_reason']) : '';
            $message .= '<br /><br /><em>' . $this->lang['BAN_TRIGGERED_BY_' . strtoupper($ban_triggered_by)] . '</em>';
            // To circumvent session_begin returning a valid value and the check_ban() not called on second page view, we kill the session again
            $this->session_kill(false);
            // A very special case... we are within the cron script which is not supposed to print out the ban message... show blank page
            if (defined('IN_CRON')) {
                garbage_collection();
                exit_handler();
                exit;
            }
            trigger_error($message);
        }
        return $banned && $ban_row['ban_give_reason'] ? $ban_row['ban_give_reason'] : $banned;
    }
/**
 * Does final clean-up of the integrated page, and sends it to the browser.
 * @param string $content The fully integrated page.
 */
function wpu_output_page($content)
{
    global $wpuNoHead, $wpu_page_title, $wpu_dtd, $wpuSetWPSignature;
    //Add title back
    $content = str_replace("<!--[**PAGE_TITLE**]-->", $wpu_page_title, $content);
    //Add DTD if needed
    if (isset($wpu_dtd)) {
        $content = str_replace("<!--[**WP_DTD**]-->", $wpu_dtd, $content);
    }
    global $wpuDebug;
    // Add login debugging if requested
    if (defined('WPU_DEBUG') && WPU_DEBUG && !$wpuNoHead) {
        $content = $wpuDebug->add_debug_box($content, 'login');
    }
    // Add stats if requested
    if (defined('WPU_SHOW_STATS') && WPU_SHOW_STATS && !$wpuNoHead) {
        $content = $wpuDebug->add_stats_box($content);
    }
    echo $content . $wpuSetWPSignature;
    // Finally -- clean up
    define('WPU_FINISHED', true);
    garbage_collection();
    exit_handler();
}