function html_get_forum_file_path($file_path, $allow_cdn = true) { // Cache of requested file paths. static $file_path_cache_array = array(); // Check if the path is in the cache. if (!isset($file_path_cache_array[$file_path])) { // Get the BH_FORUM_PATH prefix. $forum_path = server_get_forum_path(); // HTTP schema $http_scheme = isset($_SERVER['HTTPS']) && mb_strtolower($_SERVER['HTTPS']) == 'on' ? 'https' : 'http'; // Disable CDN for everything but CSS, icons, images and Javascript if ($url_file_path = @parse_url($file_path, PHP_URL_PATH)) { $allow_cdn = preg_match('/\\.png$|\\.css$|\\.ico$|\\.js$/Diu', $url_file_path) > 0 ? $allow_cdn : false; } // If CDN is allowed, get the CDN path including the domain. if ($allow_cdn === true && ($cdn_domain = forum_get_content_delivery_path($file_path))) { $final_file_path = sprintf('%s://%s/%s', $http_scheme, trim($cdn_domain, '/'), ltrim($file_path, '/')); } else { $final_file_path = preg_replace('/^.\\//', '', sprintf('%s/%s', $forum_path, ltrim($file_path, '/'))); } // Add final file path to the cache. $file_path_cache_array[$file_path] = $final_file_path; } // Return the cached entry. return $file_path_cache_array[$file_path]; }
function install_draw_top() { $forum_path = rtrim(server_get_forum_path(), '/'); echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"; echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n"; echo "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en-gb\" lang=\"en-gb\" dir=\"ltr\">\n"; echo "<head>\n"; echo "<title>Beehive Forum ", BEEHIVE_VERSION, " Installation</title>\n"; echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n"; echo "<link rel=\"icon\" href=\"", $forum_path, "/styles/images/favicon.ico\" type=\"image/ico\" />\n"; echo "<link rel=\"stylesheet\" href=\"", $forum_path, "/styles/default/style.css?", md5(uniqid(rand())), "\" type=\"text/css\" />\n"; $arg_array = func_get_args(); foreach ($arg_array as $script_file_path) { echo "<script type=\"text/javascript\" src=\"", $forum_path, "/", $script_file_path, "\"></script>\n"; } echo "</head>\n"; echo "<body>\n"; echo "<h1>Beehive Forum ", BEEHIVE_VERSION, " Installation</h1>\n"; echo "<div align=\"center\">\n"; echo "<br />\n"; }
function bh_exception_handler(Exception $exception) { $config = server_get_config(); if (isset($config['error_report_verbose']) && $config['error_report_verbose'] == true) { $error_report_verbose = true; } else { $error_report_verbose = false; } cache_disable(); while (@ob_end_clean()) { } ob_start(); ob_implicit_flush(0); bh_error_send_email($exception); $error_msg_array = bh_error_process($exception); $error_log_message = sprintf('BEEHIVE_ERROR: %s', strip_tags(implode(". ", $error_msg_array))); @error_log($error_log_message); header_status(500, 'Internal Server Error'); if ($exception->getCode() == MYSQL_ERROR_NO_SUCH_TABLE || $exception->getCode() == MYSQL_ERROR_WRONG_COLUMN_NAME) { if (function_exists('install_incomplete') && !defined('BEEHIVE_DEVELOPER_MODE')) { install_incomplete(); } } if (preg_match('/include|include_once/u', $exception->getMessage()) > 0) { if (function_exists('install_missing_files') && !defined('BEEHIVE_DEVELOPER_MODE')) { install_missing_files(); } } $forum_path = server_get_forum_path(); echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"; echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n"; echo "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"utf-8\" lang=\"en\" dir=\"ltr\">\n"; echo "<head>\n"; echo "<title>Beehive Forum - Error Handler</title>\n"; echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n"; echo "<link rel=\"icon\" href=\"images/favicon.ico\" type=\"image/ico\" />\n"; echo "<link rel=\"stylesheet\" href=\"", $forum_path, "/styles/default/style.css?", md5(uniqid(rand())), "\" type=\"text/css\" />\n"; echo "</head>\n"; echo "<body>\n"; echo "<h1>Error</h1>\n"; echo "<br />\n"; if (defined('BEEHIVEMODE_LIGHT') && !defined('BEEHIVE_DEVELOPER_MODE')) { echo '<p>An error has occured. Please wait a few moments before trying again.</p>'; echo '<p>Details of the error have been saved to the default error log.</p>'; if (isset($error_report_verbose) && $error_report_verbose == true) { echo '<p>When reporting a bug in Project Beehive or when requesting support please include the details below.</p>'; echo "<table cellpadding=\"0\" cellspacing=\"0\" class=\"warning_msg\">\n"; echo " <tr>\n"; echo " <td valign=\"top\" width=\"25\" class=\"warning_msg_icon\"><img src=\"styles/default/images/warning.png\" alt=\"Warning\" title=\"Warning\" /></td>\n"; echo " <td valign=\"top\" class=\"warning_msg_text\">Please note that there may be sensitive information such as passwords displayed here.</td>\n"; echo " </tr>\n"; echo "</table>\n"; echo "<p>", implode("</p><p>", $error_msg_array), "</p>\n"; } } else { echo "<div align=\"center\">\n"; echo "<form accept-charset=\"utf-8\" name=\"f_error\" method=\"post\" action=\"\" target=\"_self\">\n"; echo " ", form_input_hidden_array($_POST), "\n"; echo " <table cellpadding=\"0\" cellspacing=\"0\" width=\"600\">\n"; echo " <tr>\n"; echo " <td align=\"left\">\n"; echo " <table class=\"box\" width=\"100%\">\n"; echo " <tr>\n"; echo " <td align=\"left\" class=\"posthead\">\n"; echo " <table class=\"posthead\" width=\"100%\">\n"; echo " <tr>\n"; echo " <td align=\"left\" class=\"subhead\" colspan=\"2\">Error</td>\n"; echo " </tr>\n"; echo " <tr>\n"; echo " <td align=\"center\">\n"; echo " <table class=\"posthead\" width=\"95%\">\n"; echo " <tr>\n"; echo " <td align=\"left\" class=\"postbody\">An error has occured. Please wait a few moments and then click the Retry button below. Details of the error have been saved to the default error log.</td>\n"; echo " </tr>\n"; echo " <tr>\n"; echo " <td align=\"left\"> </td>\n"; echo " </tr>\n"; echo " </table>\n"; echo " </td>\n"; echo " </tr>\n"; echo " </table>\n"; echo " </td>\n"; echo " </tr>\n"; echo " </table>\n"; echo " </td>\n"; echo " </tr>\n"; echo " </table>\n"; if (isset($error_report_verbose) && $error_report_verbose == true || defined('BEEHIVE_DEVELOPER_MODE')) { echo " <br />\n"; echo " <table cellpadding=\"0\" cellspacing=\"0\" width=\"600\">\n"; echo " <tr>\n"; echo " <td align=\"left\">\n"; echo " <table class=\"box\" width=\"100%\">\n"; echo " <tr>\n"; echo " <td align=\"left\" class=\"posthead\">\n"; echo " <table class=\"posthead\" width=\"100%\">\n"; echo " <tr>\n"; echo " <td align=\"left\" class=\"subhead\" colspan=\"2\">Error Details</td>\n"; echo " </tr>\n"; echo " <tr>\n"; echo " <td align=\"center\">\n"; echo " <table class=\"posthead\" width=\"95%\">\n"; echo " <tr>\n"; echo " <td align=\"left\">\n"; echo " <div align=\"center\">\n"; echo " <table cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" class=\"warning_msg\">\n"; echo " <tr>\n"; echo " <td valign=\"top\" width=\"25\" class=\"warning_msg_icon\"><img src=\"styles/default/images/warning.png\" alt=\"Warning\" title=\"Warning\" /></td>\n"; echo " <td valign=\"top\" class=\"warning_msg_text\">When reporting a bug in Project Beehive or when requesting support please include the details below.</td>\n"; echo " </tr>\n"; echo " </table>\n"; echo " </div>\n"; echo " </td>\n"; echo " </tr>\n"; echo " <tr>\n"; echo " <td align=\"left\">\n"; echo " <div align=\"center\">\n"; echo " <table cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" class=\"warning_msg\">\n"; echo " <tr>\n"; echo " <td valign=\"top\" width=\"25\" class=\"warning_msg_icon\"><img src=\"styles/default/images/warning.png\" alt=\"Warning\" title=\"Warning\" /></td>\n"; echo " <td valign=\"top\" class=\"warning_msg_text\">Please note that there may be sensitive information such as passwords displayed here.</td>\n"; echo " </tr>\n"; echo " </table>\n"; echo " </div>\n"; echo " </td>\n"; echo " </tr>\n"; echo " <tr>\n"; echo " <td>\n"; echo " <div class=\"error_handler_details\">", implode("\n", $error_msg_array), "</div>\n"; echo " </td>\n"; echo " </tr>\n"; echo " <tr>\n"; echo " <td align=\"left\"> </td>\n"; echo " </tr>\n"; echo " </table>\n"; echo " </td>\n"; echo " </tr>\n"; echo " </table>\n"; echo " </td>\n"; echo " </tr>\n"; echo " </table>\n"; echo " </td>\n"; echo " </tr>\n"; echo " </table>\n"; } echo " <br />\n"; echo " <table cellpadding=\"0\" cellspacing=\"0\" width=\"600\">\n"; echo " <tr>\n"; echo " <td align=\"center\"><input class=\"button\" type=\"submit\" name=\"", md5(uniqid(mt_rand())), "\" value=\"Retry\" /></td>\n"; echo " </tr>\n"; echo " </table>\n"; echo "</form>\n"; echo "</div>\n"; } echo "</body>\n"; echo "</html>\n"; exit; }
function bh_exception_handler(Exception $exception) { try { $config = server_get_config(); if (isset($config['error_report_verbose']) && $config['error_report_verbose'] == true) { $error_report_verbose = true; } else { $error_report_verbose = false; } cache_disable(); while (@ob_end_clean()) { } ob_start(); ob_implicit_flush(0); bh_error_send_email($exception); $error_msg_array = bh_error_process($exception); $error_log_message = sprintf('BEEHIVE_ERROR: %s', strip_tags(implode(". ", $error_msg_array))); @error_log($error_log_message); header_status(500, 'Internal Server Error'); $forum_path = server_get_forum_path(); echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"; echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n"; echo "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en-gb\" lang=\"en-gb\" dir=\"ltr\">\n"; echo "<head>\n"; echo "<title>Beehive Forum - Error Handler</title>\n"; echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n"; echo "<link rel=\"icon\" href=\"", rtrim($forum_path, '/'), "/styles/images/favicon.ico\" type=\"image/ico\" />\n"; echo "<link rel=\"stylesheet\" href=\"", rtrim($forum_path, '/'), "/styles/default/style.css?", md5(uniqid(rand())), "\" type=\"text/css\" />\n"; echo "<link rel=\"stylesheet\" href=\"", rtrim($forum_path, '/'), "/styles/default/images.css?", md5(uniqid(rand())), "\" type=\"text/css\" />\n"; echo "</head>\n"; echo "<body>\n"; echo "<h1>Error</h1>\n"; echo "<br />\n"; if (defined('BEEHIVEMODE_LIGHT') && !defined('BEEHIVE_DEVELOPER_MODE')) { echo '<p>An error has occurred. Please wait a few moments before trying again.</p>'; echo '<p>Details of the error have been saved to the default error log.</p>'; if (isset($error_report_verbose) && $error_report_verbose == true) { echo '<p>When reporting a bug in Project Beehive or when requesting support please include the details below.</p>'; echo "<table cellpadding=\"0\" cellspacing=\"0\" class=\"warning_msg\">\n"; echo " <tr>\n"; echo " <td valign=\"top\" width=\"25\" class=\"warning_msg_icon\"><span class=\"image warning\"></span></td>\n"; echo " <td valign=\"top\" class=\"warning_msg_text\">Please note that there may be sensitive information such as passwords displayed here.</td>\n"; echo " </tr>\n"; echo "</table>\n"; echo "<p>", implode("</p><p>", $error_msg_array), "</p>\n"; } } else { echo "<div align=\"center\">\n"; echo " <table cellpadding=\"0\" cellspacing=\"0\" width=\"800\">\n"; echo " <tr>\n"; echo " <td align=\"left\">\n"; echo " <table class=\"box\" width=\"100%\">\n"; echo " <tr>\n"; echo " <td align=\"left\" class=\"posthead\">\n"; echo " <table class=\"posthead\" width=\"100%\">\n"; echo " <tr>\n"; echo " <td align=\"left\" class=\"subhead\" colspan=\"2\">Error</td>\n"; echo " </tr>\n"; echo " <tr>\n"; echo " <td align=\"center\">\n"; echo " <table class=\"posthead\" width=\"98%\">\n"; echo " <tr>\n"; echo " <td align=\"left\" class=\"postbody\">An error has occured. Please wait a few moments and then click the Retry button below. Details of the error have been saved to the default error log.</td>\n"; echo " </tr>\n"; echo " <tr>\n"; echo " <td align=\"left\"> </td>\n"; echo " </tr>\n"; echo " </table>\n"; echo " </td>\n"; echo " </tr>\n"; echo " </table>\n"; echo " </td>\n"; echo " </tr>\n"; echo " </table>\n"; echo " </td>\n"; echo " </tr>\n"; echo " </table>\n"; if (isset($error_report_verbose) && $error_report_verbose == true || defined('BEEHIVE_DEVELOPER_MODE')) { echo " <br />\n"; echo " <table cellpadding=\"0\" cellspacing=\"0\" width=\"800\">\n"; echo " <tr>\n"; echo " <td align=\"left\">\n"; echo " <table class=\"box\" width=\"100%\">\n"; echo " <tr>\n"; echo " <td align=\"left\" class=\"posthead\">\n"; echo " <table class=\"posthead\" width=\"100%\">\n"; echo " <tr>\n"; echo " <td align=\"left\" class=\"subhead\" colspan=\"2\">Error Details</td>\n"; echo " </tr>\n"; echo " <tr>\n"; echo " <td align=\"center\">\n"; echo " <table class=\"posthead\" width=\"98%\">\n"; echo " <tr>\n"; echo " <td align=\"left\">\n"; echo " <div align=\"center\">\n"; echo " <table cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" class=\"warning_msg\">\n"; echo " <tr>\n"; echo " <td valign=\"top\" width=\"25\" class=\"warning_msg_icon\"><span class=\"image warning\"></span></td>\n"; echo " <td valign=\"top\" class=\"warning_msg_text\">When reporting a bug in Project Beehive or when requesting support please include the details below.</td>\n"; echo " </tr>\n"; echo " </table>\n"; echo " </div>\n"; echo " </td>\n"; echo " </tr>\n"; echo " <tr>\n"; echo " <td align=\"left\">\n"; echo " <div align=\"center\">\n"; echo " <table cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" class=\"warning_msg\">\n"; echo " <tr>\n"; echo " <td valign=\"top\" width=\"25\" class=\"warning_msg_icon\"><span class=\"image warning\"></span></td>\n"; echo " <td valign=\"top\" class=\"warning_msg_text\">Please note that there may be sensitive information such as passwords displayed here.</td>\n"; echo " </tr>\n"; echo " </table>\n"; echo " </div>\n"; echo " </td>\n"; echo " </tr>\n"; echo " <tr>\n"; echo " <td>\n"; echo " <div class=\"error_handler_details\">", implode("\n", $error_msg_array), "</div>\n"; echo " </td>\n"; echo " </tr>\n"; echo " <tr>\n"; echo " <td align=\"left\"> </td>\n"; echo " </tr>\n"; echo " </table>\n"; echo " </td>\n"; echo " </tr>\n"; echo " </table>\n"; echo " </td>\n"; echo " </tr>\n"; echo " </table>\n"; echo " </td>\n"; echo " </tr>\n"; echo " </table>\n"; } echo " <br />\n"; echo " <table cellpadding=\"0\" cellspacing=\"0\" width=\"800\">\n"; echo " <tr>\n"; echo " <td align=\"center\">\n"; echo " <button class=\"button\" type=\"button\" onclick=\"window.location.reload()\">Retry</button>\n"; echo " </td>\n"; echo " </tr>\n"; echo " </table>\n"; echo "</div>\n"; } echo "</body>\n"; echo "</html>\n"; exit; } catch (Exception $e) { printf('Exception thrown when handling an exception: %s', $exception->getMessage()); exit; } }
$user_emoticons = $_SESSION['EMOTICONS']; } else { $user_emoticons = forum_get_setting('default_emoticons', 'strlen', 'default'); } // Get the user's saved left frame width. if (isset($_SESSION['LEFT_FRAME_WIDTH']) && is_numeric($_SESSION['LEFT_FRAME_WIDTH'])) { $left_frame_width = max(100, $_SESSION['LEFT_FRAME_WIDTH']); } else { $left_frame_width = 280; } // Get the attachment max file size (default: 2MB) if (($attachment_size_limit = forum_get_setting('attachment_size_limit', 'is_numeric', false)) === false) { $attachment_size_limit = convert_shorthand_filesize(ini_get('upload_max_filesize')); } // Construct the Javascript / JSON array $json_data = array('webtag' => $webtag, 'uid' => $_SESSION['UID'], 'lang' => array('loadingdotdotdot' => gettext("Loading..."), 'imageresized' => gettext("This image has been resized (original size %dx%d). To view the full-size image click here."), 'deleteattachmentconfirmation' => gettext("Are you sure you want to delete the selected attachments?"), 'deletemessagesconfirmation' => gettext("Are you sure you want to delete all of the selected messages?"), 'unquote' => gettext("Unquote"), 'quote' => gettext("Quote"), 'searchsuccessfullycompleted' => gettext("Search successfully completed."), 'confirmmarkasread' => gettext("Are you sure you want to mark the selected threads as read?"), 'waitdotdotdot' => gettext("Wait..."), 'more' => gettext("More"), 'pollquestion' => gettext("Poll Question"), 'deletequestion' => gettext("Delete question"), 'allowmultipleoptions' => gettext("Allow multiple options to be selected"), 'addnewoption' => gettext("Add new option"), 'deleteoption' => gettext("Delete option"), 'code' => gettext('Code'), 'retry' => gettext('Retry'), 'cancel' => gettext('Cancel'), 'delete' => gettext('Delete'), 'upload' => gettext('Upload'), 'preferencesnotsaved' => gettext('Your preferences have not been saved')), 'font_size' => $font_size, 'user_style' => $user_style, 'emoticons' => $user_emoticons, 'top_frame' => html_get_top_page(), 'left_frame_width' => max(100, $left_frame_width), 'forum_path' => server_get_forum_path(), 'use_mover_spoiler' => isset($_SESSION['USE_MOVER_SPOILER']) && $_SESSION['USE_MOVER_SPOILER'] == 'Y' ? 'Y' : 'N', 'show_share_links' => isset($_SESSION['SHOW_SHARE_LINKS']) && $_SESSION['SHOW_SHARE_LINKS'] == 'Y' ? 'Y' : 'N', 'auto_scroll_messages' => isset($_SESSION['AUTO_SCROLL_MESSAGES']) && $_SESSION['AUTO_SCROLL_MESSAGES'] == 'Y' ? 'Y' : 'N', 'attachment_size_limit' => $attachment_size_limit, 'frames' => array('index' => html_get_frame_name('index'), 'admin' => html_get_frame_name('admin'), 'start' => html_get_frame_name('start'), 'discussion' => html_get_frame_name('discussion'), 'user' => html_get_frame_name('user'), 'pm' => html_get_frame_name('pm'), 'main' => html_get_frame_name('main'), 'ftop' => html_get_frame_name('ftop'), 'fnav' => html_get_frame_name('fnav'), 'left' => html_get_frame_name('left'), 'right' => html_get_frame_name('right'), 'pm_folders' => html_get_frame_name('pm_folders'), 'pm_messages' => html_get_frame_name('pm_messages'))); // Decide on the correct Content-Type and encoding // of the content. This allows Beehive to reload the // JSON data via the same script, either for use // in a <script> tag or via AJAX. if (isset($_GET['json'])) { $content_type = 'application/json'; $content = json_encode($json_data); } else { $content_type = 'text/javascript'; $content = sprintf('top.window.beehive = $.extend({}, top.window.beehive, %s); $(document).ready(function() { $(top.window.beehive).trigger("init"); });', json_encode($json_data)); } // Send correct Content-Type header
$font_size = 10; } // User style if (($user_style = session::get_value('STYLE')) === false) { $user_style = html_get_cookie("forum_style", null, forum_get_setting('default_style', null, 'default')); } // User emoticons if (($user_emoticons = session::get_value('EMOTICONS')) === false) { $user_emoticons = forum_get_setting('default_emoticons'); } // Get the user's saved left frame width. if (($left_frame_width = session::get_value('LEFT_FRAME_WIDTH')) === false) { $left_frame_width = 280; } // Construct the Javascript / JSON array $json_data = array('webtag' => $webtag, 'uid' => session::get_value('UID'), 'lang' => array('imageresized' => gettext("This image has been resized (original size %dx%d). To view the full-size image click here."), 'deletemessagesconfirmation' => gettext("Are you sure you want to delete all of the selected messages?"), 'unquote' => gettext("Unquote"), 'quote' => gettext("Quote"), 'searchsuccessfullycompleted' => gettext("Search successfully completed."), 'confirmmarkasread' => gettext("Are you sure you want to mark the selected threads as read?"), 'waitdotdotdot' => gettext("Wait..."), 'more' => gettext("More"), 'pollquestion' => gettext("Poll Question"), 'deletequestion' => gettext("Delete question"), 'allowmultipleoptions' => gettext("Allow multiple options to be selected"), 'addnewoption' => gettext("Add new option"), 'deleteoption' => gettext("Delete option"), 'code' => gettext('code'), 'quote' => gettext('quote')), 'images' => array(), 'font_size' => $font_size, 'user_style' => $user_style, 'emoticons' => $user_emoticons, 'top_frame' => html_get_top_page(), 'left_frame_width' => $left_frame_width, 'forum_path' => server_get_forum_path(), 'use_mover_spoiler' => session::get_value('USE_MOVER_SPOILER'), 'frames' => array('index' => html_get_frame_name('index'), 'admin' => html_get_frame_name('admin'), 'start' => html_get_frame_name('start'), 'discussion' => html_get_frame_name('discussion'), 'user' => html_get_frame_name('user'), 'pm' => html_get_frame_name('pm'), 'main' => html_get_frame_name('main'), 'ftop' => html_get_frame_name('ftop'), 'fnav' => html_get_frame_name('fnav'), 'left' => html_get_frame_name('left'), 'right' => html_get_frame_name('right'), 'pm_folders' => html_get_frame_name('pm_folders'), 'pm_messages' => html_get_frame_name('pm_messages'))); if ($images_array = glob("styles/{$user_style}/images/*.png")) { foreach ($images_array as $image_filename) { $image_filename = basename($image_filename); $json_data['images'][$image_filename] = html_style_image($image_filename); } } // Decide on the correct Content-Type and encoding // of the content. This allows Beehive to reload the // JSON data via the same script, either for use // in a <script> tag or via AJAX. if (isset($_GET['json'])) { $content_type = 'application/json'; $content = json_encode($json_data); } else { $content_type = 'text/javascript';