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(); }
/** * Print admin area errors * * @param string $msg The message of error * @param bool $navigation [optional] Show the side mneu or not * @param string $title [optional] The title of the error * @param bool $exit [optional] halt after showing the error * @param bool|string $redirect [optional] if link given it will redirected to it after $rs seconds * @param int $rs [optional] if $redirected is given and not false, this will be the time in seconds * @param string $style [optional] this is just here to use it inside kleeja_admin_info to use admin_info */ function kleeja_admin_err($msg, $navigation = true, $title = '', $exit = true, $redirect = false, $rs = 5, $style = 'error.php') { global $text, $tpl, $SHOW_LIST, $adm_extensions, $adm_extensions_menu; global $STYLE_PATH_ADMIN, $lang, $plugin, $SQL, $MINI_MENU; ($hook = $plugin->run_hook('kleeja_admin_err_func')) ? eval($hook) : null; //run hook #Exception for ajax if (isset($_GET['_ajax_'])) { $text = $msg . ($redirect ? "\n" . '<script type="text/javascript"> setTimeout("location.href=\'' . str_replace('&', '&', $redirect) . '\';", ' . $rs * 1000 . ');</script>' : ''); echo_ajax(1, $tpl->display($style)); $SQL->close(); exit; } #assign {text} in err template $text = $msg . ($redirect != false ? redirect($redirect, false, false, $rs, true) : ''); $SHOW_LIST = $navigation; #header include get_template_path('header.php'); #show tpl include get_template_path($style); #footer include get_template_path('footer.php'); #show tpl //echo $tpl->display($style); #footer //echo $tpl->display("admin_footer"); #if exit, clean it if ($exit) { garbage_collection(); exit; } }
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>® Forum Software © phpBB Limited </div> </div> </div> </body> </html> <?php garbage_collection(); exit_handler(); }
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() . '&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(); }
/** * 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(); } }
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(); }
/** * Entry point for delivering image CAPTCHAs in the ACP. */ function deliver_demo($selected) { global $db, $user, $config, $src_container; $captcha = $src_container->get('captcha.factory')->get_instance($selected); $captcha->init(CONFIRM_REG); $captcha->execute_demo(); garbage_collection(); exit_handler(); }
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(); }
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(); }
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(); } }
/** * 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(); }
/** * 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>® Forum Software © 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("'", ''', $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("'", ''', $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(); }
function main($id, $mode) { global $db, $user, $template, $cache; global $config, $phpbb_root_path; global $request, $phpbb_container; $user->add_lang('acp/posting'); // Set up general vars $action = $request->variable('action', ''); $action = isset($_POST['add']) ? 'add' : $action; $action = isset($_POST['edit']) ? 'edit' : $action; $action = isset($_POST['import']) ? 'import' : $action; $icon_id = $request->variable('id', 0); $submit = $request->is_set_post('submit', false); $form_key = 'acp_icons'; add_form_key($form_key); $mode = $mode == 'smilies' ? 'smilies' : 'icons'; $this->tpl_name = 'acp_icons'; // What are we working on? switch ($mode) { case 'smilies': $table = SMILIES_TABLE; $lang = 'SMILIES'; $fields = 'smiley'; $img_path = $config['smilies_path']; break; case 'icons': $table = ICONS_TABLE; $lang = 'ICONS'; $fields = 'icons'; $img_path = $config['icons_path']; break; } $this->page_title = 'ACP_' . $lang; // Clear some arrays $_images = $_paks = array(); $notice = ''; // Grab file list of paks and images if ($action == 'edit' || $action == 'add' || $action == 'import') { $imglist = filelist($phpbb_root_path . $img_path, ''); foreach ($imglist as $path => $img_ary) { if (empty($img_ary)) { continue; } asort($img_ary, SORT_STRING); foreach ($img_ary as $img) { $img_size = getimagesize($phpbb_root_path . $img_path . '/' . $path . $img); if (!$img_size[0] || !$img_size[1] || strlen($img) > 255) { continue; } // adjust the width and height to be lower than 128px while perserving the aspect ratio (for icons) if ($mode == 'icons') { if ($img_size[0] > 127 && $img_size[0] > $img_size[1]) { $img_size[1] = (int) ($img_size[1] * (127 / $img_size[0])); $img_size[0] = 127; } else { if ($img_size[1] > 127) { $img_size[0] = (int) ($img_size[0] * (127 / $img_size[1])); $img_size[1] = 127; } } } $_images[$path . $img]['file'] = $path . $img; $_images[$path . $img]['width'] = $img_size[0]; $_images[$path . $img]['height'] = $img_size[1]; } } unset($imglist); if ($dir = @opendir($phpbb_root_path . $img_path)) { while (($file = readdir($dir)) !== false) { if (is_file($phpbb_root_path . $img_path . '/' . $file) && preg_match('#\\.pak$#i', $file)) { $_paks[] = $file; } } closedir($dir); if (!empty($_paks)) { asort($_paks, SORT_STRING); } } } // What shall we do today? Oops, I believe that's trademarked ... switch ($action) { case 'edit': unset($_images); $_images = array(); // no break; // no break; case 'add': $smilies = $default_row = array(); $smiley_options = $order_list = $add_order_list = ''; if ($action == 'add' && $mode == 'smilies') { $sql = 'SELECT * FROM ' . SMILIES_TABLE . ' ORDER BY smiley_order'; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { if (empty($smilies[$row['smiley_url']])) { $smilies[$row['smiley_url']] = $row; } } $db->sql_freeresult($result); if (sizeof($smilies)) { foreach ($smilies as $row) { $selected = false; if (!$smiley_options) { $selected = true; $default_row = $row; } $smiley_options .= '<option value="' . $row['smiley_url'] . '"' . ($selected ? ' selected="selected"' : '') . '>' . $row['smiley_url'] . '</option>'; $template->assign_block_vars('smile', array('SMILEY_URL' => addslashes($row['smiley_url']), 'CODE' => addslashes($row['code']), 'EMOTION' => addslashes($row['emotion']), 'WIDTH' => $row['smiley_width'], 'HEIGHT' => $row['smiley_height'], 'ORDER' => $row['smiley_order'] + 1)); } } } $sql = "SELECT *\n\t\t\t\t\tFROM {$table}\n\t\t\t\t\tORDER BY {$fields}_order " . ($icon_id || $action == 'add' ? 'DESC' : 'ASC'); $result = $db->sql_query($sql); $data = array(); $after = false; $order_lists = array('', ''); $add_order_lists = array('', ''); $display_count = 0; while ($row = $db->sql_fetchrow($result)) { if ($action == 'add') { unset($_images[$row[$fields . '_url']]); } if ($row[$fields . '_id'] == $icon_id) { $after = true; $data[$row[$fields . '_url']] = $row; } else { if ($action == 'edit' && !$icon_id) { $data[$row[$fields . '_url']] = $row; } $selected = ''; if (!empty($after)) { $selected = ' selected="selected"'; $after = false; } if ($row['display_on_posting']) { $display_count++; } $after_txt = $mode == 'smilies' ? $row['code'] : $row['icons_url']; $order_lists[$row['display_on_posting']] = '<option value="' . ($row[$fields . '_order'] + 1) . '"' . $selected . '>' . sprintf($user->lang['AFTER_' . $lang], ' -> ' . $after_txt) . '</option>' . $order_lists[$row['display_on_posting']]; if (!empty($default_row)) { $add_order_lists[$row['display_on_posting']] = '<option value="' . ($row[$fields . '_order'] + 1) . '"' . ($row[$fields . '_id'] == $default_row['smiley_id'] ? ' selected="selected"' : '') . '>' . sprintf($user->lang['AFTER_' . $lang], ' -> ' . $after_txt) . '</option>' . $add_order_lists[$row['display_on_posting']]; } } } $db->sql_freeresult($result); $order_list = '<option value="1"' . (!isset($after) ? ' selected="selected"' : '') . '>' . $user->lang['FIRST'] . '</option>'; $add_order_list = '<option value="1">' . $user->lang['FIRST'] . '</option>'; if ($action == 'add') { $data = $_images; } $colspan = $mode == 'smilies' ? 7 : 6; $colspan += $icon_id ? 1 : 0; $colspan += $action == 'add' ? 2 : 0; $template->assign_vars(array('S_EDIT' => true, 'S_SMILIES' => $mode == 'smilies' ? true : false, 'S_ADD' => $action == 'add' ? true : false, 'S_ORDER_LIST_DISPLAY' => $order_list . $order_lists[1], 'S_ORDER_LIST_UNDISPLAY' => $order_list . $order_lists[0], 'S_ORDER_LIST_DISPLAY_COUNT' => $display_count + 1, 'L_TITLE' => $user->lang['ACP_' . $lang], 'L_EXPLAIN' => $user->lang['ACP_' . $lang . '_EXPLAIN'], 'L_CONFIG' => $user->lang[$lang . '_CONFIG'], 'L_URL' => $user->lang[$lang . '_URL'], 'L_LOCATION' => $user->lang[$lang . '_LOCATION'], 'L_WIDTH' => $user->lang[$lang . '_WIDTH'], 'L_HEIGHT' => $user->lang[$lang . '_HEIGHT'], 'L_ORDER' => $user->lang[$lang . '_ORDER'], 'L_NO_ICONS' => $user->lang['NO_' . $lang . '_' . strtoupper($action)], 'COLSPAN' => $colspan, 'ID' => $icon_id, 'U_BACK' => $this->u_action, 'U_ACTION' => $this->u_action . '&action=' . ($action == 'add' ? 'create' : 'modify'))); foreach ($data as $img => $img_row) { $template->assign_block_vars('items', array('IMG' => $img, 'A_IMG' => addslashes($img), 'IMG_SRC' => $phpbb_root_path . $img_path . '/' . $img, 'CODE' => $mode == 'smilies' && isset($img_row['code']) ? $img_row['code'] : '', 'EMOTION' => $mode == 'smilies' && isset($img_row['emotion']) ? $img_row['emotion'] : '', 'S_ID' => isset($img_row[$fields . '_id']) ? true : false, 'ID' => isset($img_row[$fields . '_id']) ? $img_row[$fields . '_id'] : 0, 'WIDTH' => !empty($img_row[$fields . '_width']) ? $img_row[$fields . '_width'] : $img_row['width'], 'HEIGHT' => !empty($img_row[$fields . '_height']) ? $img_row[$fields . '_height'] : $img_row['height'], 'TEXT_ALT' => $mode == 'icons' && !empty($img_row['icons_alt']) ? $img_row['icons_alt'] : $img, 'ALT' => $mode == 'icons' && !empty($img_row['icons_alt']) ? $img_row['icons_alt'] : '', 'POSTING_CHECKED' => !empty($img_row['display_on_posting']) || $action == 'add' ? ' checked="checked"' : '')); } // Ok, another row for adding an addition code for a pre-existing image... if ($action == 'add' && $mode == 'smilies' && sizeof($smilies)) { $template->assign_vars(array('S_ADD_CODE' => true, 'S_IMG_OPTIONS' => $smiley_options, 'S_ADD_ORDER_LIST_DISPLAY' => $add_order_list . $add_order_lists[1], 'S_ADD_ORDER_LIST_UNDISPLAY' => $add_order_list . $add_order_lists[0], 'IMG_SRC' => $phpbb_root_path . $img_path . '/' . $default_row['smiley_url'], 'IMG_PATH' => $img_path, 'CODE' => $default_row['code'], 'EMOTION' => $default_row['emotion'], 'WIDTH' => $default_row['smiley_width'], 'HEIGHT' => $default_row['smiley_height'])); } return; break; case 'create': case 'modify': if (!check_form_key($form_key)) { trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING); } // Get items to create/modify $images = isset($_POST['image']) ? array_keys($request->variable('image', array('' => 0))) : array(); // Now really get the items $image_id = isset($_POST['id']) ? $request->variable('id', array('' => 0)) : array(); $image_order = isset($_POST['order']) ? $request->variable('order', array('' => 0)) : array(); $image_width = isset($_POST['width']) ? $request->variable('width', array('' => 0)) : array(); $image_height = isset($_POST['height']) ? $request->variable('height', array('' => 0)) : array(); $image_add = isset($_POST['add_img']) ? $request->variable('add_img', array('' => 0)) : array(); $image_emotion = $request->variable('emotion', array('' => ''), true); $image_code = $request->variable('code', array('' => ''), true); $image_alt = $request->is_set_post('alt') ? $request->variable('alt', array('' => ''), true) : array(); $image_display_on_posting = isset($_POST['display_on_posting']) ? $request->variable('display_on_posting', array('' => 0)) : array(); // Ok, add the relevant bits if we are adding new codes to existing emoticons... if ($request->variable('add_additional_code', false, false, \phpbb\request\request_interface::POST)) { $add_image = $request->variable('add_image', ''); $add_code = $request->variable('add_code', '', true); $add_emotion = $request->variable('add_emotion', '', true); if ($add_image && $add_emotion && $add_code) { $images[] = $add_image; $image_add[$add_image] = true; $image_code[$add_image] = $add_code; $image_emotion[$add_image] = $add_emotion; $image_width[$add_image] = $request->variable('add_width', 0); $image_height[$add_image] = $request->variable('add_height', 0); if ($request->variable('add_display_on_posting', false, false, \phpbb\request\request_interface::POST)) { $image_display_on_posting[$add_image] = 1; } $image_order[$add_image] = $request->variable('add_order', 0); } } if ($mode == 'smilies' && $action == 'create') { $smiley_count = $this->item_count($table); $addable_smileys_count = sizeof($images); foreach ($images as $image) { if (!isset($image_add[$image])) { --$addable_smileys_count; } } if ($smiley_count + $addable_smileys_count > SMILEY_LIMIT) { trigger_error($user->lang('TOO_MANY_SMILIES', SMILEY_LIMIT) . adm_back_link($this->u_action), E_USER_WARNING); } } $icons_updated = 0; $errors = array(); foreach ($images as $image) { if ($mode == 'smilies' && ($image_emotion[$image] == '' || $image_code[$image] == '')) { $errors[$image] = 'SMILIE_NO_' . ($image_emotion[$image] == '' ? 'EMOTION' : 'CODE'); } else { if ($action == 'create' && !isset($image_add[$image])) { // skip images where add wasn't checked } else { if (!file_exists($phpbb_root_path . $img_path . '/' . $image)) { $errors[$image] = 'SMILIE_NO_FILE'; } else { if ($image_width[$image] == 0 || $image_height[$image] == 0) { $img_size = getimagesize($phpbb_root_path . $img_path . '/' . $image); $image_width[$image] = $img_size[0]; $image_height[$image] = $img_size[1]; } // Adjust image width/height for icons if ($mode == 'icons') { if ($image_width[$image] > 127 && $image_width[$image] > $image_height[$image]) { $image_height[$image] = (int) ($image_height[$image] * (127 / $image_width[$image])); $image_width[$image] = 127; } else { if ($image_height[$image] > 127) { $image_width[$image] = (int) ($image_width[$image] * (127 / $image_height[$image])); $image_height[$image] = 127; } } } $img_sql = array($fields . '_url' => $image, $fields . '_width' => $image_width[$image], $fields . '_height' => $image_height[$image], 'display_on_posting' => isset($image_display_on_posting[$image]) ? 1 : 0); if ($mode == 'smilies') { $img_sql = array_merge($img_sql, array('emotion' => $image_emotion[$image], 'code' => $image_code[$image])); } if ($mode == 'icons') { $img_sql = array_merge($img_sql, array('icons_alt' => $image_alt[$image])); } // Image_order holds the 'new' order value if (!empty($image_order[$image])) { $img_sql = array_merge($img_sql, array($fields . '_order' => $image_order[$image])); // Since we always add 'after' an item, we just need to increase all following + the current by one $sql = "UPDATE {$table}\n\t\t\t\t\t\t\t\tSET {$fields}_order = {$fields}_order + 1\n\t\t\t\t\t\t\t\tWHERE {$fields}_order >= {$image_order[$image]}"; $db->sql_query($sql); // If we adjust the order, we need to adjust all other orders too - they became inaccurate... foreach ($image_order as $_image => $_order) { if ($_image == $image) { continue; } if ($_order >= $image_order[$image]) { $image_order[$_image]++; } } } if ($action == 'modify' && !empty($image_id[$image])) { $sql = "UPDATE {$table}\n\t\t\t\t\t\t\t\tSET " . $db->sql_build_array('UPDATE', $img_sql) . "\n\t\t\t\t\t\t\t\tWHERE {$fields}_id = " . $image_id[$image]; $db->sql_query($sql); $icons_updated++; } else { if ($action !== 'modify') { $sql = "INSERT INTO {$table} " . $db->sql_build_array('INSERT', $img_sql); $db->sql_query($sql); $icons_updated++; } } } } } } $cache->destroy('_icons'); $cache->destroy('sql', $table); $phpbb_container->get('text_formatter.cache')->invalidate(); $level = $icons_updated ? E_USER_NOTICE : E_USER_WARNING; $errormsgs = ''; foreach ($errors as $img => $error) { $errormsgs .= '<br />' . sprintf($user->lang[$error], $img); } if ($action == 'modify') { trigger_error($user->lang($lang . '_EDITED', $icons_updated) . $errormsgs . adm_back_link($this->u_action), $level); } else { trigger_error($user->lang($lang . '_ADDED', $icons_updated) . $errormsgs . adm_back_link($this->u_action), $level); } break; case 'import': $pak = $request->variable('pak', ''); $current = $request->variable('current', ''); if ($pak != '') { $order = 0; if (!check_form_key($form_key)) { trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING); } if (!($pak_ary = @file($phpbb_root_path . $img_path . '/' . $pak))) { trigger_error($user->lang['PAK_FILE_NOT_READABLE'] . adm_back_link($this->u_action), E_USER_WARNING); } // Make sure the pak_ary is valid foreach ($pak_ary as $pak_entry) { if (preg_match_all("#'(.*?)', ?#", $pak_entry, $data)) { if (sizeof($data[1]) != 4 && $mode == 'icons' || (sizeof($data[1]) != 6 || (empty($data[1][4]) || empty($data[1][5]))) && $mode == 'smilies') { trigger_error($user->lang['WRONG_PAK_TYPE'] . adm_back_link($this->u_action), E_USER_WARNING); } } else { trigger_error($user->lang['WRONG_PAK_TYPE'] . adm_back_link($this->u_action), E_USER_WARNING); } } // The user has already selected a smilies_pak file if ($current == 'delete') { switch ($db->get_sql_layer()) { case 'sqlite3': $db->sql_query('DELETE FROM ' . $table); break; default: $db->sql_query('TRUNCATE TABLE ' . $table); break; } switch ($mode) { case 'smilies': break; case 'icons': // Reset all icon_ids $db->sql_query('UPDATE ' . TOPICS_TABLE . ' SET icon_id = 0'); $db->sql_query('UPDATE ' . POSTS_TABLE . ' SET icon_id = 0'); break; } } else { $cur_img = array(); $field_sql = $mode == 'smilies' ? 'code' : 'icons_url'; $sql = "SELECT {$field_sql}\n\t\t\t\t\t\t\tFROM {$table}"; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { ++$order; $cur_img[$row[$field_sql]] = 1; } $db->sql_freeresult($result); } if ($mode == 'smilies') { $smiley_count = $this->item_count($table); if ($smiley_count + sizeof($pak_ary) > SMILEY_LIMIT) { trigger_error($user->lang('TOO_MANY_SMILIES', SMILEY_LIMIT) . adm_back_link($this->u_action), E_USER_WARNING); } } foreach ($pak_ary as $pak_entry) { $data = array(); if (preg_match_all("#'(.*?)', ?#", $pak_entry, $data)) { if (sizeof($data[1]) != 4 && $mode == 'icons' || sizeof($data[1]) != 6 && $mode == 'smilies') { trigger_error($user->lang['WRONG_PAK_TYPE'] . adm_back_link($this->u_action), E_USER_WARNING); } // Stripslash here because it got addslashed before... (on export) $img = stripslashes($data[1][0]); $width = stripslashes($data[1][1]); $height = stripslashes($data[1][2]); $display_on_posting = stripslashes($data[1][3]); if (isset($data[1][4]) && isset($data[1][5])) { $emotion = stripslashes($data[1][4]); $code = stripslashes($data[1][5]); } if ($current == 'replace' && ($mode == 'smilies' && !empty($cur_img[$code]) || $mode == 'icons' && !empty($cur_img[$img]))) { $replace_sql = $mode == 'smilies' ? $code : $img; $sql = array($fields . '_url' => $img, $fields . '_height' => (int) $height, $fields . '_width' => (int) $width, 'display_on_posting' => (int) $display_on_posting); if ($mode == 'smilies') { $sql = array_merge($sql, array('emotion' => $emotion)); } $sql = "UPDATE {$table} SET " . $db->sql_build_array('UPDATE', $sql) . "\n\t\t\t\t\t\t\t\t\tWHERE {$field_sql} = '" . $db->sql_escape($replace_sql) . "'"; $db->sql_query($sql); } else { ++$order; $sql = array($fields . '_url' => $img, $fields . '_height' => (int) $height, $fields . '_width' => (int) $width, $fields . '_order' => (int) $order, 'display_on_posting' => (int) $display_on_posting); if ($mode == 'smilies') { $sql = array_merge($sql, array('code' => $code, 'emotion' => $emotion)); } $db->sql_query("INSERT INTO {$table} " . $db->sql_build_array('INSERT', $sql)); } } } $cache->destroy('_icons'); $cache->destroy('sql', $table); $phpbb_container->get('text_formatter.cache')->invalidate(); trigger_error($user->lang[$lang . '_IMPORT_SUCCESS'] . adm_back_link($this->u_action)); } else { $pak_options = ''; foreach ($_paks as $pak) { $pak_options .= '<option value="' . $pak . '">' . htmlspecialchars($pak) . '</option>'; } $template->assign_vars(array('S_CHOOSE_PAK' => true, 'S_PAK_OPTIONS' => $pak_options, 'L_TITLE' => $user->lang['ACP_' . $lang], 'L_EXPLAIN' => $user->lang['ACP_' . $lang . '_EXPLAIN'], 'L_NO_PAK_OPTIONS' => $user->lang['NO_' . $lang . '_PAK'], 'L_CURRENT' => $user->lang['CURRENT_' . $lang], 'L_CURRENT_EXPLAIN' => $user->lang['CURRENT_' . $lang . '_EXPLAIN'], 'L_IMPORT_SUBMIT' => $user->lang['IMPORT_' . $lang], 'U_BACK' => $this->u_action, 'U_ACTION' => $this->u_action . '&action=import')); } break; case 'export': $this->page_title = 'EXPORT_' . $lang; $this->tpl_name = 'message_body'; $template->assign_vars(array('MESSAGE_TITLE' => $user->lang['EXPORT_' . $lang], 'MESSAGE_TEXT' => sprintf($user->lang['EXPORT_' . $lang . '_EXPLAIN'], '<a href="' . $this->u_action . '&action=send&hash=' . generate_link_hash('acp_icons') . '">', '</a>'), 'S_USER_NOTICE' => true)); return; break; case 'send': if (!check_link_hash($request->variable('hash', ''), 'acp_icons')) { trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING); } $sql = "SELECT *\n\t\t\t\t\tFROM {$table}\n\t\t\t\t\tORDER BY {$fields}_order"; $result = $db->sql_query($sql); $pak = ''; while ($row = $db->sql_fetchrow($result)) { $pak .= "'" . addslashes($row[$fields . '_url']) . "', "; $pak .= "'" . addslashes($row[$fields . '_width']) . "', "; $pak .= "'" . addslashes($row[$fields . '_height']) . "', "; $pak .= "'" . addslashes($row['display_on_posting']) . "', "; if ($mode == 'smilies') { $pak .= "'" . addslashes($row['emotion']) . "', "; $pak .= "'" . addslashes($row['code']) . "', "; } $pak .= "\n"; } $db->sql_freeresult($result); if ($pak != '') { garbage_collection(); header('Cache-Control: public'); // Send out the Headers header('Content-Type: text/x-delimtext; name="' . $mode . '.pak"'); header('Content-Disposition: inline; filename="' . $mode . '.pak"'); echo $pak; flush(); exit; } else { trigger_error($user->lang['NO_' . strtoupper($fields) . '_EXPORT'] . adm_back_link($this->u_action), E_USER_WARNING); } break; case 'delete': if (confirm_box(true)) { $sql = "DELETE FROM {$table}\n\t\t\t\t\t\tWHERE {$fields}_id = {$icon_id}"; $db->sql_query($sql); switch ($mode) { case 'smilies': break; case 'icons': // Reset appropriate icon_ids $db->sql_query('UPDATE ' . TOPICS_TABLE . "\n\t\t\t\t\t\t\t\tSET icon_id = 0\n\t\t\t\t\t\t\t\tWHERE icon_id = {$icon_id}"); $db->sql_query('UPDATE ' . POSTS_TABLE . "\n\t\t\t\t\t\t\t\tSET icon_id = 0\n\t\t\t\t\t\t\t\tWHERE icon_id = {$icon_id}"); break; } $notice = $user->lang[$lang . '_DELETED']; $cache->destroy('_icons'); $cache->destroy('sql', $table); $phpbb_container->get('text_formatter.cache')->invalidate(); if ($request->is_ajax()) { $json_response = new \phpbb\json_response(); $json_response->send(array('MESSAGE_TITLE' => $user->lang['INFORMATION'], 'MESSAGE_TEXT' => $notice, 'REFRESH_DATA' => array('time' => 3))); } } else { confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array('i' => $id, 'mode' => $mode, 'id' => $icon_id, 'action' => 'delete'))); } break; case 'move_up': case 'move_down': if (!check_link_hash($request->variable('hash', ''), 'acp_icons')) { trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING); } // Get current order id... $sql = "SELECT {$fields}_order as current_order\n\t\t\t\t\tFROM {$table}\n\t\t\t\t\tWHERE {$fields}_id = {$icon_id}"; $result = $db->sql_query($sql); $current_order = (int) $db->sql_fetchfield('current_order'); $db->sql_freeresult($result); if ($current_order == 0 && $action == 'move_up') { break; } // on move_down, switch position with next order_id... // on move_up, switch position with previous order_id... $switch_order_id = $action == 'move_down' ? $current_order + 1 : $current_order - 1; // $sql = "UPDATE {$table}\n\t\t\t\t\tSET {$fields}_order = {$current_order}\n\t\t\t\t\tWHERE {$fields}_order = {$switch_order_id}\n\t\t\t\t\t\tAND {$fields}_id <> {$icon_id}"; $db->sql_query($sql); $move_executed = (bool) $db->sql_affectedrows(); // Only update the other entry too if the previous entry got updated if ($move_executed) { $sql = "UPDATE {$table}\n\t\t\t\t\t\tSET {$fields}_order = {$switch_order_id}\n\t\t\t\t\t\tWHERE {$fields}_order = {$current_order}\n\t\t\t\t\t\t\tAND {$fields}_id = {$icon_id}"; $db->sql_query($sql); } $cache->destroy('_icons'); $cache->destroy('sql', $table); $phpbb_container->get('text_formatter.cache')->invalidate(); if ($request->is_ajax()) { $json_response = new \phpbb\json_response(); $json_response->send(array('success' => $move_executed)); } break; } // By default, check that image_order is valid and fix it if necessary $sql = "SELECT {$fields}_id AS order_id, {$fields}_order AS fields_order\n\t\t\tFROM {$table}\n\t\t\tORDER BY display_on_posting DESC, {$fields}_order"; $result = $db->sql_query($sql); if ($row = $db->sql_fetchrow($result)) { $order = 0; do { ++$order; if ($row['fields_order'] != $order) { $db->sql_query("UPDATE {$table}\n\t\t\t\t\t\tSET {$fields}_order = {$order}\n\t\t\t\t\t\tWHERE {$fields}_id = " . $row['order_id']); } } while ($row = $db->sql_fetchrow($result)); } $db->sql_freeresult($result); $template->assign_vars(array('L_TITLE' => $user->lang['ACP_' . $lang], 'L_EXPLAIN' => $user->lang['ACP_' . $lang . '_EXPLAIN'], 'L_IMPORT' => $user->lang['IMPORT_' . $lang], 'L_EXPORT' => $user->lang['EXPORT_' . $lang], 'L_NOT_DISPLAYED' => $user->lang[$lang . '_NOT_DISPLAYED'], 'L_ICON_ADD' => $user->lang['ADD_' . $lang], 'L_ICON_EDIT' => $user->lang['EDIT_' . $lang], 'NOTICE' => $notice, 'COLSPAN' => $mode == 'smilies' ? 5 : 3, 'S_SMILIES' => $mode == 'smilies' ? true : false, 'U_ACTION' => $this->u_action, 'U_IMPORT' => $this->u_action . '&action=import', 'U_EXPORT' => $this->u_action . '&action=export')); /* @var $pagination \phpbb\pagination */ $pagination = $phpbb_container->get('pagination'); $pagination_start = $request->variable('start', 0); $spacer = false; $item_count = $this->item_count($table); $sql = "SELECT *\n\t\t\tFROM {$table}\n\t\t\tORDER BY {$fields}_order ASC"; $result = $db->sql_query_limit($sql, $config['smilies_per_page'], $pagination_start); while ($row = $db->sql_fetchrow($result)) { $alt_text = $mode == 'smilies' ? $row['code'] : ($mode == 'icons' && !empty($row['icons_alt']) ? $row['icons_alt'] : $row['icons_url']); $template->assign_block_vars('items', array('S_SPACER' => !$spacer && !$row['display_on_posting'] ? true : false, 'ALT_TEXT' => $alt_text, 'IMG_SRC' => $phpbb_root_path . $img_path . '/' . $row[$fields . '_url'], 'WIDTH' => $row[$fields . '_width'], 'HEIGHT' => $row[$fields . '_height'], 'CODE' => isset($row['code']) ? $row['code'] : '', 'EMOTION' => isset($row['emotion']) ? $row['emotion'] : '', 'U_EDIT' => $this->u_action . '&action=edit&id=' . $row[$fields . '_id'], 'U_DELETE' => $this->u_action . '&action=delete&id=' . $row[$fields . '_id'], 'U_MOVE_UP' => $this->u_action . '&action=move_up&id=' . $row[$fields . '_id'] . '&start=' . $pagination_start . '&hash=' . generate_link_hash('acp_icons'), 'U_MOVE_DOWN' => $this->u_action . '&action=move_down&id=' . $row[$fields . '_id'] . '&start=' . $pagination_start . '&hash=' . generate_link_hash('acp_icons'))); if (!$spacer && !$row['display_on_posting']) { $spacer = true; } } $db->sql_freeresult($result); $pagination->generate_template_pagination($this->u_action, 'pagination', 'start', $item_count, $config['smilies_per_page'], $pagination_start); }
/** * 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(); }
/** * 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(); }
/** * Custom HTTP 301 redirections. * To kill duplicates */ function seo_redirect($url, $header = '301 Moved Permanently', $code = 301, $replace = true) { global $db; if (!$this->seo_opt['zero_dupe']['on'] || @headers_sent()) { return false; } garbage_collection(); $url = str_replace('&', '&', $url); // Behave as redirect() for checks to provide with the same level of protection // Make sure no linebreaks are there... to prevent http response splitting for PHP < 4.4.2 if (strpos(urldecode($url), "\n") !== false || strpos(urldecode($url), "\r") !== false || strpos($url, ';') !== false) { trigger_error('Tried to redirect to potentially insecure url.', E_USER_ERROR); } // Now, also check the protocol and for a valid url the last time... $allowed_protocols = array('http', 'https'); $url_parts = parse_url($url); if ($url_parts === false || empty($url_parts['scheme']) || !in_array($url_parts['scheme'], $allowed_protocols)) { trigger_error('Tried to redirect to potentially insecure url.', E_USER_ERROR); } $http = 'HTTP/1.1 '; header($http . $header, $replace, $code); header('Cache-Control: no-store, no-cache, must-revalidate'); header('Pragma: no-cache'); header('Expires: -1'); header('Location: ' . $url); 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>® Forum Software © 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(); }
/** * 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 © 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; }
function main($id, $mode) { global $db, $user, $auth, $template, $cache; global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx; $user->add_lang('acp/posting'); // Set up general vars $action = request_var('action', ''); $action = (isset($_POST['add'])) ? 'add' : $action; $action = (isset($_POST['edit'])) ? 'edit' : $action; $action = (isset($_POST['import'])) ? 'import' : $action; $icon_id = request_var('id', 0); $mode = ($mode == 'smilies') ? 'smilies' : 'icons'; $this->tpl_name = 'acp_icons'; // What are we working on? switch ($mode) { case 'smilies': $table = SMILIES_TABLE; $lang = 'SMILIES'; $fields = 'smiley'; $img_path = $config['smilies_path']; break; case 'icons': $table = ICONS_TABLE; $lang = 'ICONS'; $fields = 'icons'; $img_path = $config['icons_path']; break; } $this->page_title = 'ACP_' . $lang; // Clear some arrays $_images = $_paks = array(); $notice = ''; // Grab file list of paks and images if ($action == 'edit' || $action == 'add' || $action == 'import') { $imglist = filelist($phpbb_root_path . $img_path, ''); foreach ($imglist as $path => $img_ary) { foreach ($img_ary as $img) { $img_size = getimagesize($phpbb_root_path . $img_path . '/' . $path . $img); if (!$img_size[0] || !$img_size[1] || strlen($img) > 255) { continue; } $_images[$path . $img]['file'] = $path . $img; $_images[$path . $img]['width'] = $img_size[0]; $_images[$path . $img]['height'] = $img_size[1]; } } unset($imglist); if ($dir = @opendir($phpbb_root_path . $img_path)) { while (($file = readdir($dir)) !== false) { if (is_file($phpbb_root_path . $img_path . '/' . $file) && preg_match('#\.pak$#i', $file)) { $_paks[] = $file; } } closedir($dir); } } // What shall we do today? Oops, I believe that's trademarked ... switch ($action) { case 'edit': unset($_images); $_images = array(); // no break; case 'add': $smilies = $default_row = array(); $smiley_options = $order_list = $add_order_list = ''; if ($action == 'add' && $mode == 'smilies') { $sql = 'SELECT * FROM ' . SMILIES_TABLE . ' ORDER BY smiley_order'; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { if (empty($smilies[$row['smiley_url']])) { $smilies[$row['smiley_url']] = $row; } } $db->sql_freeresult($result); if (sizeof($smilies)) { foreach ($smilies as $row) { $selected = false; if (!$smiley_options) { $selected = true; $default_row = $row; } $smiley_options .= '<option value="' . $row['smiley_url'] . '"' . (($selected) ? ' selected="selected"' : '') . '>' . $row['smiley_url'] . '</option>'; $template->assign_block_vars('smile', array( 'SMILEY_URL' => addslashes($row['smiley_url']), 'CODE' => addslashes($row['code']), 'EMOTION' => addslashes($row['emotion']), 'WIDTH' => $row['smiley_width'], 'HEIGHT' => $row['smiley_height'], 'ORDER' => $row['smiley_order'] + 1, )); } } } $sql = "SELECT * FROM $table ORDER BY {$fields}_order " . (($icon_id || $action == 'add') ? 'DESC' : 'ASC'); $result = $db->sql_query($sql); $data = array(); $after = false; $display = 0; $order_lists = array('', ''); $add_order_lists = array('', ''); $display_count = 0; while ($row = $db->sql_fetchrow($result)) { if ($action == 'add') { unset($_images[$row[$fields . '_url']]); } if ($row[$fields . '_id'] == $icon_id) { $after = true; $display = $row['display_on_posting']; $data[$row[$fields . '_url']] = $row; } else { if ($action == 'edit' && !$icon_id) { $data[$row[$fields . '_url']] = $row; } $selected = ''; if (!empty($after)) { $selected = ' selected="selected"'; $after = false; } if ($row['display_on_posting']) { $display_count++; } $after_txt = ($mode == 'smilies') ? $row['code'] : $row['icons_url']; $order_lists[$row['display_on_posting']] = '<option value="' . ($row[$fields . '_order'] + 1) . '"' . $selected . '>' . sprintf($user->lang['AFTER_' . $lang], ' -> ' . $after_txt) . '</option>' . $order_lists[$row['display_on_posting']]; if (!empty($default_row)) { $add_order_lists[$row['display_on_posting']] = '<option value="' . ($row[$fields . '_order'] + 1) . '"' . (($row[$fields . '_id'] == $default_row['smiley_id']) ? ' selected="selected"' : '') . '>' . sprintf($user->lang['AFTER_' . $lang], ' -> ' . $after_txt) . '</option>' . $add_order_lists[$row['display_on_posting']]; } } } $db->sql_freeresult($result); $order_list = '<option value="1"' . ((!isset($after)) ? ' selected="selected"' : '') . '>' . $user->lang['FIRST'] . '</option>'; $add_order_list = '<option value="1">' . $user->lang['FIRST'] . '</option>'; if ($action == 'add') { $data = $_images; } $colspan = (($mode == 'smilies') ? '7' : '5'); $colspan += ($icon_id) ? 1 : 0; $colspan += ($action == 'add') ? 2 : 0; $template->assign_vars(array( 'S_EDIT' => true, 'S_SMILIES' => ($mode == 'smilies') ? true : false, 'S_ADD' => ($action == 'add') ? true : false, 'S_ORDER_LIST_DISPLAY' => $order_list . $order_lists[1], 'S_ORDER_LIST_UNDISPLAY' => $order_list . $order_lists[0], 'S_ORDER_LIST_DISPLAY_COUNT' => $display_count + 1, 'L_TITLE' => $user->lang['ACP_' . $lang], 'L_EXPLAIN' => $user->lang['ACP_' . $lang . '_EXPLAIN'], 'L_CONFIG' => $user->lang[$lang . '_CONFIG'], 'L_URL' => $user->lang[$lang . '_URL'], 'L_LOCATION' => $user->lang[$lang . '_LOCATION'], 'L_WIDTH' => $user->lang[$lang . '_WIDTH'], 'L_HEIGHT' => $user->lang[$lang . '_HEIGHT'], 'L_ORDER' => $user->lang[$lang . '_ORDER'], 'L_NO_ICONS' => $user->lang['NO_' . $lang . '_' . strtoupper($action)], 'COLSPAN' => $colspan, 'ID' => $icon_id, 'U_BACK' => $this->u_action, 'U_ACTION' => $this->u_action . '&action=' . (($action == 'add') ? 'create' : 'modify'), )); foreach ($data as $img => $img_row) { $template->assign_block_vars('items', array( 'IMG' => $img, 'A_IMG' => addslashes($img), 'IMG_SRC' => $phpbb_root_path . $img_path . '/' . $img, 'CODE' => ($mode == 'smilies' && isset($img_row['code'])) ? $img_row['code'] : '', 'EMOTION' => ($mode == 'smilies' && isset($img_row['emotion'])) ? $img_row['emotion'] : '', 'S_ID' => (isset($img_row[$fields . '_id'])) ? true : false, 'ID' => (isset($img_row[$fields . '_id'])) ? $img_row[$fields . '_id'] : 0, 'WIDTH' => (!empty($img_row[$fields .'_width'])) ? $img_row[$fields .'_width'] : $img_row['width'], 'HEIGHT' => (!empty($img_row[$fields .'_height'])) ? $img_row[$fields .'_height'] : $img_row['height'], 'POSTING_CHECKED' => (!empty($img_row['display_on_posting']) || $action == 'add') ? ' checked="checked"' : '', )); } // Ok, another row for adding an addition code for a pre-existing image... if ($action == 'add' && $mode == 'smilies' && sizeof($smilies)) { $template->assign_vars(array( 'S_ADD_CODE' => true, 'S_IMG_OPTIONS' => $smiley_options, 'S_ADD_ORDER_LIST_DISPLAY' => $add_order_list . $add_order_lists[1], 'S_ADD_ORDER_LIST_UNDISPLAY' => $add_order_list . $add_order_lists[0], 'IMG_SRC' => $phpbb_root_path . $img_path . '/' . $default_row['smiley_url'], 'IMG_PATH' => $img_path, 'PHPBB_ROOT_PATH' => $phpbb_root_path, 'CODE' => $default_row['code'], 'EMOTION' => $default_row['emotion'], 'WIDTH' => $default_row['smiley_width'], 'HEIGHT' => $default_row['smiley_height'], )); } return; break; case 'create': case 'modify': // Get items to create/modify $images = (isset($_POST['image'])) ? array_keys(request_var('image', array('' => 0))) : array(); // Now really get the items $image_id = (isset($_POST['id'])) ? request_var('id', array('' => 0)) : array(); $image_order = (isset($_POST['order'])) ? request_var('order', array('' => 0)) : array(); $image_width = (isset($_POST['width'])) ? request_var('width', array('' => 0)) : array(); $image_height = (isset($_POST['height'])) ? request_var('height', array('' => 0)) : array(); $image_add = (isset($_POST['add_img'])) ? request_var('add_img', array('' => 0)) : array(); $image_emotion = utf8_normalize_nfc(request_var('emotion', array('' => ''), true)); $image_code = utf8_normalize_nfc(request_var('code', array('' => ''), true)); $image_display_on_posting = (isset($_POST['display_on_posting'])) ? request_var('display_on_posting', array('' => 0)) : array(); // Ok, add the relevant bits if we are adding new codes to existing emoticons... if (!empty($_POST['add_additional_code'])) { $add_image = request_var('add_image', ''); $add_code = utf8_normalize_nfc(request_var('add_code', '', true)); $add_emotion = utf8_normalize_nfc(request_var('add_emotion', '', true)); if ($add_image && $add_emotion && $add_code) { $images[] = $add_image; $image_add[$add_image] = true; $image_code[$add_image] = $add_code; $image_emotion[$add_image] = $add_emotion; $image_width[$add_image] = request_var('add_width', 0); $image_height[$add_image] = request_var('add_height', 0); if (!empty($_POST['add_display_on_posting'])) { $image_display_on_posting[$add_image] = 1; } $image_order[$add_image] = request_var('add_order', 0); } } $icons_updated = 0; foreach ($images as $image) { if (($mode == 'smilies' && ($image_emotion[$image] == '' || $image_code[$image] == '')) || ($action == 'create' && !isset($image_add[$image]))) { } else { if ($image_width[$image] == 0 || $image_height[$image] == 0) { $img_size = getimagesize($phpbb_root_path . $img_path . '/' . $image); $image_width[$image] = $img_size[0]; $image_height[$image] = $img_size[1]; } $img_sql = array( $fields . '_url' => $image, $fields . '_width' => $image_width[$image], $fields . '_height' => $image_height[$image], 'display_on_posting' => (isset($image_display_on_posting[$image])) ? 1 : 0, ); if ($mode == 'smilies') { $img_sql = array_merge($img_sql, array( 'emotion' => $image_emotion[$image], 'code' => $image_code[$image]) ); } // Image_order holds the 'new' order value if (!empty($image_order[$image])) { $img_sql = array_merge($img_sql, array( $fields . '_order' => $image_order[$image]) ); // Since we always add 'after' an item, we just need to increase all following + the current by one $sql = "UPDATE $table SET {$fields}_order = {$fields}_order + 1 WHERE {$fields}_order >= {$image_order[$image]}"; $db->sql_query($sql); // If we adjust the order, we need to adjust all other orders too - they became inaccurate... foreach ($image_order as $_image => $_order) { if ($_image == $image) { continue; } if ($_order >= $image_order[$image]) { $image_order[$_image]++; } } } if ($action == 'modify' && !empty($image_id[$image])) { $sql = "UPDATE $table SET " . $db->sql_build_array('UPDATE', $img_sql) . " WHERE {$fields}_id = " . $image_id[$image]; $db->sql_query($sql); $icons_updated++; } else if ($action !== 'modify') { $sql = "INSERT INTO $table " . $db->sql_build_array('INSERT', $img_sql); $db->sql_query($sql); $icons_updated++; } } } $cache->destroy('_icons'); $cache->destroy('sql', $table); $level = E_USER_NOTICE; switch ($icons_updated) { case 0: $suc_lang = "{$lang}_NONE"; $level = E_USER_WARNING; break; case 1: $suc_lang = "{$lang}_ONE"; break; default: $suc_lang = $lang; } if ($action == 'modify') { trigger_error($user->lang[$suc_lang . '_EDITED'] . adm_back_link($this->u_action), $level); } else { trigger_error($user->lang[$suc_lang . '_ADDED'] . adm_back_link($this->u_action), $level); } break; case 'import': $pak = request_var('pak', ''); $current = request_var('current', ''); if ($pak != '') { $order = 0; if (!($pak_ary = @file($phpbb_root_path . $img_path . '/' . $pak))) { trigger_error($user->lang['PAK_FILE_NOT_READABLE'] . adm_back_link($this->u_action), E_USER_WARNING); } // Make sure the pak_ary is valid foreach ($pak_ary as $pak_entry) { if (preg_match_all("#'(.*?)', ?#", $pak_entry, $data)) { if ((sizeof($data[1]) != 4 && $mode == 'icons') || (sizeof($data[1]) != 6 && $mode == 'smilies')) { trigger_error($user->lang['WRONG_PAK_TYPE'] . adm_back_link($this->u_action), E_USER_WARNING); } } else { trigger_error($user->lang['WRONG_PAK_TYPE'] . adm_back_link($this->u_action), E_USER_WARNING); } } // The user has already selected a smilies_pak file if ($current == 'delete') { switch ($db->sql_layer) { case 'sqlite': case 'firebird': $db->sql_query('DELETE FROM ' . $table); break; default: $db->sql_query('TRUNCATE TABLE ' . $table); break; } switch ($mode) { case 'smilies': break; case 'icons': // Reset all icon_ids $db->sql_query('UPDATE ' . TOPICS_TABLE . ' SET icon_id = 0'); $db->sql_query('UPDATE ' . POSTS_TABLE . ' SET icon_id = 0'); break; } } else { $cur_img = array(); $field_sql = ($mode == 'smilies') ? 'code' : 'icons_url'; $sql = "SELECT $field_sql FROM $table"; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { ++$order; $cur_img[$row[$field_sql]] = 1; } $db->sql_freeresult($result); } foreach ($pak_ary as $pak_entry) { $data = array(); if (preg_match_all("#'(.*?)', ?#", $pak_entry, $data)) { if ((sizeof($data[1]) != 4 && $mode == 'icons') || (sizeof($data[1]) != 6 && $mode == 'smilies')) { trigger_error($user->lang['WRONG_PAK_TYPE'] . adm_back_link($this->u_action), E_USER_WARNING); } // Stripslash here because it got addslashed before... (on export) $img = stripslashes($data[1][0]); $width = stripslashes($data[1][1]); $height = stripslashes($data[1][2]); $display_on_posting = stripslashes($data[1][3]); if (isset($data[1][4]) && isset($data[1][5])) { $emotion = stripslashes($data[1][4]); $code = stripslashes($data[1][5]); } if ($current == 'replace' && (($mode == 'smilies' && !empty($cur_img[$code])) || ($mode == 'icons' && !empty($cur_img[$img])))) { $replace_sql = ($mode == 'smilies') ? $code : $img; $sql = array( $fields . '_url' => $img, $fields . '_height' => (int) $height, $fields . '_width' => (int) $width, 'display_on_posting' => (int) $display_on_posting, ); if ($mode == 'smilies') { $sql = array_merge($sql, array( 'emotion' => $emotion, )); } $sql = "UPDATE $table SET " . $db->sql_build_array('UPDATE', $sql) . " WHERE $field_sql = '" . $db->sql_escape($replace_sql) . "'"; $db->sql_query($sql); } else { ++$order; $sql = array( $fields . '_url' => $img, $fields . '_height' => (int) $height, $fields . '_width' => (int) $width, $fields . '_order' => (int) $order, 'display_on_posting'=> (int) $display_on_posting, ); if ($mode == 'smilies') { $sql = array_merge($sql, array( 'code' => $code, 'emotion' => $emotion, )); } $db->sql_query("INSERT INTO $table " . $db->sql_build_array('INSERT', $sql)); } } } $cache->destroy('_icons'); $cache->destroy('sql', $table); trigger_error($user->lang[$lang . '_IMPORT_SUCCESS'] . adm_back_link($this->u_action)); } else { $pak_options = ''; foreach ($_paks as $pak) { $pak_options .= '<option value="' . $pak . '">' . htmlspecialchars($pak) . '</option>'; } $template->assign_vars(array( 'S_CHOOSE_PAK' => true, 'S_PAK_OPTIONS' => $pak_options, 'L_TITLE' => $user->lang['ACP_' . $lang], 'L_EXPLAIN' => $user->lang['ACP_' . $lang . '_EXPLAIN'], 'L_NO_PAK_OPTIONS' => $user->lang['NO_' . $lang . '_PAK'], 'L_CURRENT' => $user->lang['CURRENT_' . $lang], 'L_CURRENT_EXPLAIN' => $user->lang['CURRENT_' . $lang . '_EXPLAIN'], 'L_IMPORT_SUBMIT' => $user->lang['IMPORT_' . $lang], 'U_BACK' => $this->u_action, 'U_ACTION' => $this->u_action . '&action=import', ) ); } break; case 'export': $this->page_title = 'EXPORT_' . $lang; $this->tpl_name = 'message_body'; $template->assign_vars(array( 'MESSAGE_TITLE' => $user->lang['EXPORT_' . $lang], 'MESSAGE_TEXT' => sprintf($user->lang['EXPORT_' . $lang . '_EXPLAIN'], '<a href="' . $this->u_action . '&action=send">', '</a>'), 'S_USER_NOTICE' => true, ) ); return; break; case 'send': $sql = "SELECT * FROM $table ORDER BY {$fields}_order"; $result = $db->sql_query($sql); $pak = ''; while ($row = $db->sql_fetchrow($result)) { $pak .= "'" . addslashes($row[$fields . '_url']) . "', "; $pak .= "'" . addslashes($row[$fields . '_width']) . "', "; $pak .= "'" . addslashes($row[$fields . '_height']) . "', "; $pak .= "'" . addslashes($row['display_on_posting']) . "', "; if ($mode == 'smilies') { $pak .= "'" . addslashes($row['emotion']) . "', "; $pak .= "'" . addslashes($row['code']) . "', "; } $pak .= "\n"; } $db->sql_freeresult($result); if ($pak != '') { garbage_collection(); header('Pragma: public'); // Send out the Headers header('Content-Type: text/x-delimtext; name="' . $mode . '.pak"'); header('Content-Disposition: inline; filename="' . $mode . '.pak"'); echo $pak; flush(); exit; } else { trigger_error($user->lang['NO_' . strtoupper($fields) . '_EXPORT'] . adm_back_link($this->u_action), E_USER_WARNING); } break; case 'delete': if (confirm_box(true)) { $sql = "DELETE FROM $table WHERE {$fields}_id = $icon_id"; $db->sql_query($sql); switch ($mode) { case 'smilies': break; case 'icons': // Reset appropriate icon_ids $db->sql_query('UPDATE ' . TOPICS_TABLE . " SET icon_id = 0 WHERE icon_id = $icon_id"); $db->sql_query('UPDATE ' . POSTS_TABLE . " SET icon_id = 0 WHERE icon_id = $icon_id"); break; } $notice = $user->lang[$lang . '_DELETED']; $cache->destroy('_icons'); $cache->destroy('sql', $table); } else { confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array( 'i' => $id, 'mode' => $mode, 'id' => $icon_id, 'action' => 'delete', ))); } break; case 'move_up': case 'move_down': // Get current order id... $sql = "SELECT {$fields}_order as current_order FROM $table WHERE {$fields}_id = $icon_id"; $result = $db->sql_query($sql); $current_order = (int) $db->sql_fetchfield('current_order'); $db->sql_freeresult($result); if ($current_order == 0 && $action == 'move_up') { break; } // on move_down, switch position with next order_id... // on move_up, switch position with previous order_id... $switch_order_id = ($action == 'move_down') ? $current_order + 1 : $current_order - 1; // $sql = "UPDATE $table SET {$fields}_order = $current_order WHERE {$fields}_order = $switch_order_id AND {$fields}_id <> $icon_id"; $db->sql_query($sql); // Only update the other entry too if the previous entry got updated if ($db->sql_affectedrows()) { $sql = "UPDATE $table SET {$fields}_order = $switch_order_id WHERE {$fields}_order = $current_order AND {$fields}_id = $icon_id"; $db->sql_query($sql); } $cache->destroy('_icons'); $cache->destroy('sql', $table); break; } // By default, check that image_order is valid and fix it if necessary $sql = "SELECT {$fields}_id AS order_id, {$fields}_order AS fields_order FROM $table ORDER BY display_on_posting DESC, {$fields}_order"; $result = $db->sql_query($sql); if ($row = $db->sql_fetchrow($result)) { $order = 0; do { ++$order; if ($row['fields_order'] != $order) { $db->sql_query("UPDATE $table SET {$fields}_order = $order WHERE {$fields}_id = " . $row['order_id']); } } while ($row = $db->sql_fetchrow($result)); } $db->sql_freeresult($result); $template->assign_vars(array( 'L_TITLE' => $user->lang['ACP_' . $lang], 'L_EXPLAIN' => $user->lang['ACP_' . $lang . '_EXPLAIN'], 'L_IMPORT' => $user->lang['IMPORT_' . $lang], 'L_EXPORT' => $user->lang['EXPORT_' . $lang], 'L_NOT_DISPLAYED' => $user->lang[$lang . '_NOT_DISPLAYED'], 'L_ICON_ADD' => $user->lang['ADD_' . $lang], 'L_ICON_EDIT' => $user->lang['EDIT_' . $lang], 'NOTICE' => $notice, 'COLSPAN' => ($mode == 'smilies') ? 5 : 3, 'S_SMILIES' => ($mode == 'smilies') ? true : false, 'U_ACTION' => $this->u_action, 'U_IMPORT' => $this->u_action . '&action=import', 'U_EXPORT' => $this->u_action . '&action=export', ) ); $spacer = false; $sql = "SELECT * FROM $table ORDER BY {$fields}_order ASC"; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { $alt_text = ($mode == 'smilies') ? $row['code'] : ''; $template->assign_block_vars('items', array( 'S_SPACER' => (!$spacer && !$row['display_on_posting']) ? true : false, 'ALT_TEXT' => $alt_text, 'IMG_SRC' => $phpbb_root_path . $img_path . '/' . $row[$fields . '_url'], 'WIDTH' => $row[$fields . '_width'], 'HEIGHT' => $row[$fields . '_height'], 'CODE' => (isset($row['code'])) ? $row['code'] : '', 'EMOTION' => (isset($row['emotion'])) ? $row['emotion'] : '', 'U_EDIT' => $this->u_action . '&action=edit&id=' . $row[$fields . '_id'], 'U_DELETE' => $this->u_action . '&action=delete&id=' . $row[$fields . '_id'], 'U_MOVE_UP' => $this->u_action . '&action=move_up&id=' . $row[$fields . '_id'], 'U_MOVE_DOWN' => $this->u_action . '&action=move_down&id=' . $row[$fields . '_id']) ); if (!$spacer && !$row['display_on_posting']) { $spacer = true; } } $db->sql_freeresult($result); }
/** * 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() . '&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(); }
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(); }
/** * Page footer function handling the phpBB tasks */ public static function page_footer($run_cron = true) { self::$template->assign_vars(array('RUN_CRON_TASK' => !defined('IN_CRON') && $run_cron && !self::$config['board_disable'] ? '<img src="' . titania_url::build_url('cron') . '" width="1" height="1" alt="cron" />' : '', 'TRANSLATION_INFO' => !empty(self::$user->lang['TRANSLATION_INFO']) ? self::$user->lang['TRANSLATION_INFO'] : '', 'U_ACP' => self::$auth->acl_get('a_') && !empty(self::$user->data['is_registered']) ? self::append_sid('adm/index', false, true, self::$user->session_id) : '')); self::$template->display('body'); garbage_collection(); exit_handler(); }
} $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 {
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(); } }
/** * 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(); }
/** * Quick Edit a post * * @param mixed $post_id */ public function quick_edit($post_id) { $submit = isset($_POST['submit']) ? true : false; $full_editor = isset($_POST['full_editor']) ? true : false; // AJAX output if (!$submit && !$full_editor) { phpbb::$user->add_lang('viewtopic'); // Load the stuff we need $post_object = $this->load_post($post_id); // Check permissions if (!$post_object->acl_get('edit')) { echo phpbb::$user->lang['NO_AUTH']; garbage_collection(); exit_handler(); } $post_message = $post_object->post_text; titania_decode_message($post_message, $post_object->post_text_uid); add_form_key('postform'); phpbb::$template->assign_vars(array('MESSAGE' => $post_message, 'U_QR_ACTION' => $post_object->get_url('quick_edit'))); phpbb::$template->set_filenames(array('quick_edit' => 'posting/quickedit_editor.html')); // application/xhtml+xml not used because of IE header('Content-type: text/html; charset=UTF-8'); header('Cache-Control: private, no-cache="set-cookie"'); header('Expires: 0'); header('Pragma: no-cache'); phpbb::$template->display('quick_edit'); garbage_collection(); exit_handler(); } if ($full_editor || !check_form_key('postform')) { $this->edit($post_id); return; } // Load the stuff we need $post_object = $this->load_post($post_id); // Check permissions if (!$post_object->acl_get('edit')) { titania::needs_auth(); } // Grab some data $for_edit = $post_object->generate_text_for_edit(); // Set the post text $post_object->post_text = utf8_normalize_nfc(request_var('message', '', true)); // Generate for storage based on previous options $post_object->generate_text_for_storage($for_edit['allow_bbcode'], $for_edit['allow_urls'], $for_edit['allow_smilies']); // Submit $post_object->submit(); // Load attachments $attachments = new titania_attachment($post_object->post_type, $post_object->post_id); $attachments->load_attachments(); // Parse the mesage $message = $post_object->generate_text_for_display(); $parsed_attachments = $attachments->parse_attachments($message); // echo the message (returned to the JS to display in the place of the old message) echo $message; garbage_collection(); exit_handler(); }
/** * 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; }
/** * 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() . '&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>® Forum Software © phpBB Group'), 'VERSION' => $config['version'])); $template->display('body'); garbage_collection(); exit_handler(); }