|
From: Jon O. <jon...@us...> - 2008-10-31 18:54:30
|
Update of /cvsroot/mxbb/core/includes/sessions/phpbb2 In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv6117/phpbb2 Modified Files: bbcode.php core.php login.php Log Message: http://www.mx-publisher.com/phpBB2/viewtopic.php?p=65197#65197 Massive update. Index: login.php =================================================================== RCS file: /cvsroot/mxbb/core/includes/sessions/phpbb2/login.php,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** login.php 4 Oct 2008 07:04:25 -0000 1.7 --- login.php 31 Oct 2008 18:54:23 -0000 1.8 *************** *** 17,21 **** if($mx_request_vars->is_request('login') && (!$userdata['session_logged_in'] || $mx_request_vars->is_post('admin')) ) { ! $username = $mx_request_vars->is_post('username') ? $phpBB2->phpbb_clean_username($mx_request_vars->post('username')) : ''; $password = $mx_request_vars->post('password', MX_TYPE_NO_TAGS); --- 17,21 ---- if($mx_request_vars->is_request('login') && (!$userdata['session_logged_in'] || $mx_request_vars->is_post('admin')) ) { ! $username = $mx_request_vars->is_post('username') ? phpBB2::phpbb_clean_username($mx_request_vars->post('username')) : ''; $password = $mx_request_vars->post('password', MX_TYPE_NO_TAGS); Index: core.php =================================================================== RCS file: /cvsroot/mxbb/core/includes/sessions/phpbb2/core.php,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** core.php 4 Oct 2008 07:04:25 -0000 1.18 --- core.php 31 Oct 2008 18:54:23 -0000 1.19 *************** *** 114,125 **** $unauthed = false; ! if (!$auth_mod[$auth_level] && (strstr($ignore_forum_ids,$auth_mod['forum_id']) === FALSE)) ! { ! $unauthed = true; ! } ! if (!$auth_level && !$auth_mod['auth_read'] && (strstr($ignore_forum_ids,$auth_mod['forum_id']) === FALSE)) ! { ! $unauthed = true; ! } if ($unauthed) { --- 114,125 ---- $unauthed = false; ! if (!$auth_mod[$auth_level] && (strstr($ignore_forum_ids,$auth_mod['forum_id']) === FALSE)) ! { ! $unauthed = true; ! } ! if (!$auth_level && !$auth_mod['auth_read'] && (strstr($ignore_forum_ids,$auth_mod['forum_id']) === FALSE)) ! { ! $unauthed = true; ! } if ($unauthed) { *************** *** 138,151 **** { $unauthed = true; ! if($auth_level_read && ($is_auth_row[$auth_level_read])) { $unauthed = false; } ! if(strstr($ignore_forum_ids, $forum_id)) { $unauthed = false; ! } if ($unauthed) --- 138,151 ---- { $unauthed = true; ! if($auth_level_read && ($is_auth_row[$auth_level_read])) { $unauthed = false; } ! if(strstr($ignore_forum_ids, $forum_id)) { $unauthed = false; ! } if ($unauthed) *************** *** 153,157 **** $ignore_forum_ids .= ($ignore_forum_ids) ? ',' . $forum_id : $forum_id; } ! } } --- 153,157 ---- $ignore_forum_ids .= ($ignore_forum_ids) ? ',' . $forum_id : $forum_id; } ! } } *************** *** 564,568 **** { global $db, $mx_root_path, $phpbb_root_path, $userdata, $mx_user, $lang, $images, $phpEx; ! global $phpBB2, $board_config, $gen_simple_header, $layouttemplate, $mx_page; switch ($mode) --- 564,568 ---- { global $db, $mx_root_path, $phpbb_root_path, $userdata, $mx_user, $lang, $images, $phpEx; ! global $board_config, $gen_simple_header, $layouttemplate, $mx_page; switch ($mode) *************** *** 583,587 **** } ! $s_last_visit = ( $userdata['session_logged_in'] ) ? $phpBB2->create_date($board_config['default_dateformat'], $userdata['user_lastvisit'], $board_config['board_timezone']) : ''; // --- 583,587 ---- } ! $s_last_visit = ( $userdata['session_logged_in'] ) ? phpBB2::create_date($board_config['default_dateformat'], $userdata['user_lastvisit'], $board_config['board_timezone']) : ''; // *************** *** 785,789 **** return $sql; } ! /** * Get username details for placing into templates. --- 785,852 ---- return $sql; } ! ! /** ! * Enter description here... ! * ! * @return unknown ! */ ! function generate_session_online_sql($guest = false) ! { ! if ($guest) ! { ! $sql = "SELECT * ! FROM " . SESSIONS_TABLE . " ! WHERE session_logged_in = 0 ! AND session_time >= " . ( time() - 300 ) . " ! ORDER BY session_time DESC"; ! } ! else ! { ! $sql = "SELECT u.*, s.* ! FROM " . USERS_TABLE . " u, " . SESSIONS_TABLE . " s ! WHERE s.session_logged_in = " . TRUE . " ! AND u.user_id = s.session_user_id ! AND u.user_id <> " . ANONYMOUS . " ! AND s.session_time >= " . ( time() - 300 ) . " ! ORDER BY u.user_session_time DESC"; ! } ! return $sql; ! } ! ! /** ! * Enter description here... ! * ! * @param unknown_type $str_ip ! * @return unknown ! */ ! function decode_ip($str_ip) ! { ! return phpBB2::decode_ip($str_ip); ! } ! ! /** ! * Enter description here... ! * ! * @return unknown ! */ ! function get_phpbb_version() ! { ! global $board_config; ! ! return '2' . $board_config['version']; ! } ! ! /** ! * Enter description here... ! * ! * @return unknown ! */ ! function confirm_backend() ! { ! global $portal_config; ! ! return PORTAL_BACKEND == $portal_config['portal_backend']; ! } ! /** * Get username details for placing into templates. *************** *** 801,827 **** { global $lang, $userdata; ! $lang['Guest'] = !$guest_username ? $lang['Guest'] : $guest_username; $this_userdata = mx_get_userdata($user_id, false); ! $username = ($username) ? $username : $this_userdata['username']; ! if ($this_userdata['user_level'] == ADMIN) ! { $user_color = $theme['fontcolor3']; ! $user_style = 'style="color:#' . $user_color . '; font-weight : bold;"'; ! } ! else if ($this_userdata['user_level'] == MOD) ! { $user_color = $theme['fontcolor2']; ! $user_style = 'style="color:#' . $user_color . '; font-weight : bold;"'; } ! else ! { $user_colour = $theme['fontcolor1']; ! $topic_poster_style = 'style="font-weight : bold;"'; } ! // Only show the link if not anonymous if ($user_id && $user_id != ANONYMOUS) --- 864,890 ---- { global $lang, $userdata; ! $lang['Guest'] = !$guest_username ? $lang['Guest'] : $guest_username; $this_userdata = mx_get_userdata($user_id, false); ! $username = ($username) ? $username : $this_userdata['username']; ! if ($this_userdata['user_level'] == ADMIN) ! { $user_color = $theme['fontcolor3']; ! $user_style = 'style="color:#' . $user_color . '; font-weight : bold;"'; ! } ! else if ($this_userdata['user_level'] == MOD) ! { $user_color = $theme['fontcolor2']; ! $user_style = 'style="color:#' . $user_color . '; font-weight : bold;"'; } ! else ! { $user_colour = $theme['fontcolor1']; ! $topic_poster_style = 'style="font-weight : bold;"'; } ! // Only show the link if not anonymous if ($user_id && $user_id != ANONYMOUS) *************** *** 834,839 **** $profile_url = $lang['Guest']; $full_url = $lang['Guest']; ! } ! switch ($mode) { --- 897,902 ---- $profile_url = $lang['Guest']; $full_url = $lang['Guest']; ! } ! switch ($mode) { *************** *** 854,859 **** return $full_url; break; ! } ! } } --- 917,1235 ---- return $full_url; break; ! } ! } ! ! // ! // ACP ! // ! /** ! * Enter description here... ! * ! */ ! function load_phpbb_acp_menu() ! { ! global $phpbb_root_path, $template, $lang, $phpEx, $theme, $userdata, $mx_user; ! ! $module_phpbb = read_admin($phpbb_root_path . 'admin/'); ! $template->assign_block_vars('module_phpbb', array( ! 'L_PHPBB' => $lang['Phpbb'], ! "L_FORUM_INDEX" => $lang['Main_index'], ! "L_PREVIEW_FORUM" => $lang['Preview_forum'], ! "U_FORUM_INDEX" => mx_append_sid(PHPBB_URL . "index.$phpEx"), ! )); ! ! ksort($module_phpbb); ! ! //+MOD: DHTML Menu for ACP ! $menu_cat_id = 0; ! //-MOD: DHTML Menu for ACP ! ! while( list($cat, $action_array) = each($module_phpbb) ) ! { ! $cat = ( !empty($lang[$cat]) ) ? $lang[$cat] : preg_replace("/_/", " ", $cat); ! ! $template->assign_block_vars('module_phpbb.catrow', array( ! //+MOD: DHTML Menu for ACP ! 'MENU_CAT_ID' => $menu_cat_id, ! 'MENU_CAT_ROWS' => count($action_array), ! //-MOD: DHTML Menu for ACP ! 'ADMIN_CATEGORY' => $cat) ! ); ! ! ksort($action_array); ! ! $row_count = 0; ! while( list($action, $file) = each($action_array) ) ! { ! $row_color = ( !($row_count%2) ) ? $theme['td_color1'] : $theme['td_color2']; ! $row_class = ( !($row_count%2) ) ? $theme['td_class1'] : $theme['td_class2']; ! ! $action = ( !empty($lang[$action]) ) ? $lang[$action] : preg_replace("/_/", " ", $action); ! ! $template->assign_block_vars('module_phpbb.catrow.modulerow', array( ! "ROW_COLOR" => "#" . $row_color, ! "ROW_CLASS" => $row_class, ! //+MOD: DHTML Menu for ACP ! 'ROW_COUNT' => $row_count, ! //-MOD: DHTML Menu for ACP ! "ADMIN_MODULE" => $action, ! "U_ADMIN_MODULE" => mx_append_sid(PHPBB_URL . 'admin/' . $file . ( ( strpos($file, '?') !== false ) ? '&sid=' : '?sid=' ) . $userdata['session_id'])) ! ); ! $row_count++; ! } ! //+MOD: DHTML Menu for ACP ! $menu_cat_id++; ! //-MOD: DHTML Menu for ACP ! } ! } ! ! /** ! * Enter description here... ! * ! */ ! function load_forum_stats() ! { ! global $db, $template, $board_config, $portal_config, $phpbb_root_path, $mx_root_path, $lang, $theme, $mx_user, $userdata; ! ! $template->assign_block_vars("forum_stats", array()); ! // ! // Get forum statistics ! // ! $total_posts = phpBB2::get_db_stat('postcount'); ! $total_users = phpBB2::get_db_stat('usercount'); ! $total_topics = phpBB2::get_db_stat('topiccount'); ! ! $start_date = phpBB2::create_date($board_config['default_dateformat'], $board_config['board_startdate'], $board_config['board_timezone']); ! ! $boarddays = ( time() - $board_config['board_startdate'] ) / 86400; ! ! $posts_per_day = sprintf("%.2f", $total_posts / $boarddays); ! $topics_per_day = sprintf("%.2f", $total_topics / $boarddays); ! $users_per_day = sprintf("%.2f", $total_users / $boarddays); ! ! $avatar_dir_size = 0; ! ! if ($avatar_dir = @opendir($phpbb_root_path . $board_config['avatar_path']) ) ! { ! while( $file = @readdir($avatar_dir) ) ! { ! if( $file != "." && $file != ".." ) ! { ! $avatar_dir_size += @filesize($phpbb_root_path . $board_config['avatar_path'] . "/" . $file); ! } ! } ! @closedir($avatar_dir); ! ! // ! // This bit of code translates the avatar directory size into human readable format ! // Borrowed the code from the PHP.net annoted manual, origanally written by: ! // Jesse (je...@je...) ! // ! if($avatar_dir_size >= 1048576) ! { ! $avatar_dir_size = round($avatar_dir_size / 1048576 * 100) / 100 . " MB"; ! } ! else if($avatar_dir_size >= 1024) ! { ! $avatar_dir_size = round($avatar_dir_size / 1024 * 100) / 100 . " KB"; ! } ! else ! { ! $avatar_dir_size = $avatar_dir_size . " Bytes"; ! } ! } ! else ! { ! // Couldn't open Avatar dir. ! $avatar_dir_size = $lang['Not_available']; ! } ! ! if($posts_per_day > $total_posts) ! { ! $posts_per_day = $total_posts; ! } ! ! if($topics_per_day > $total_topics) ! { ! $topics_per_day = $total_topics; ! } ! ! if($users_per_day > $total_users) ! { ! $users_per_day = $total_users; ! } ! ! // ! // DB size ... MySQL only ! // ! // This code is heavily influenced by a similar routine ! // in phpMyAdmin 2.2.0 ! // ! if( preg_match("/^mysql/", SQL_LAYER) ) ! { ! $sql = "SELECT VERSION() AS mysql_version"; ! if($result = $db->sql_query($sql)) ! { ! $row = $db->sql_fetchrow($result); ! $version = $row['mysql_version']; ! ! if( preg_match("/^(3\.23|4\.|5\.)/", $version) ) ! { ! $db_name = ( preg_match("/^(3\.23\.[6-9])|(3\.23\.[1-9][1-9])|(4\.)|(5\.)/", $version) ) ? "`$dbname`" : $dbname; ! ! $sql = "SHOW TABLE STATUS ! FROM " . $db_name; ! if($result = $db->sql_query($sql)) ! { ! $tabledata_ary = $db->sql_fetchrowset($result); ! ! $dbsize = 0; ! for($i = 0; $i < count($tabledata_ary); $i++) ! { ! if( $tabledata_ary[$i]['Type'] != "MRG_MyISAM" ) ! { ! if( $table_prefix != "" ) ! { ! if( strstr($tabledata_ary[$i]['Name'], $table_prefix) ) ! { ! $dbsize += $tabledata_ary[$i]['Data_length'] + $tabledata_ary[$i]['Index_length']; ! } ! } ! else ! { ! $dbsize += $tabledata_ary[$i]['Data_length'] + $tabledata_ary[$i]['Index_length']; ! } ! } ! } ! } // Else we couldn't get the table status. ! } ! else ! { ! $dbsize = $lang['Not_available']; ! } ! } ! else ! { ! $dbsize = $lang['Not_available']; ! } ! $db->sql_freeresult($result); ! } ! else if( preg_match("/^mssql/", SQL_LAYER) ) ! { ! $sql = "SELECT ((SUM(size) * 8.0) * 1024.0) as dbsize ! FROM sysfiles"; ! if( $result = $db->sql_query($sql) ) ! { ! $dbsize = ( $row = $db->sql_fetchrow($result) ) ? intval($row['dbsize']) : $lang['Not_available']; ! } ! else ! { ! $dbsize = $lang['Not_available']; ! } ! $db->sql_freeresult($result); ! } ! else ! { ! $dbsize = $lang['Not_available']; ! } ! ! if ( is_integer($dbsize) ) ! { ! if( $dbsize >= 1048576 ) ! { ! $dbsize = sprintf("%.2f MB", ( $dbsize / 1048576 )); ! } ! else if( $dbsize >= 1024 ) ! { ! $dbsize = sprintf("%.2f KB", ( $dbsize / 1024 )); ! } ! else ! { ! $dbsize = sprintf("%.2f Bytes", $dbsize); ! } ! } ! ! $template->assign_vars(array( ! "NUMBER_OF_POSTS" => $total_posts, ! "NUMBER_OF_TOPICS" => $total_topics, ! "NUMBER_OF_USERS" => $total_users, ! "START_DATE" => $start_date, ! "POSTS_PER_DAY" => $posts_per_day, ! "TOPICS_PER_DAY" => $topics_per_day, ! "USERS_PER_DAY" => $users_per_day, ! "AVATAR_DIR_SIZE" => $avatar_dir_size, ! "DB_SIZE" => $dbsize, ! "GZIP_COMPRESSION" => ( $board_config['gzip_compress'] ) ? $lang['ON'] : $lang['OFF']) ! ); ! } ! ! /** ! * Enter description here... ! * ! * @return unknown ! */ ! function phpbb_version_check() ! { ! global $board_config, $lang; ! ! $current_phpbb_version = explode('.', '2' . $board_config['version']); ! $minor_phpbb_revision = (int) $current_phpbb_version[2]; ! ! $errno = 0; ! $errstr = $phpbb_version_info = ''; ! ! if ($fsock = @fsockopen('www.phpbb.com', 80, $errno, $errstr, 10)) ! { ! @fputs($fsock, "GET /updatecheck/20x.txt HTTP/1.1\r\n"); ! @fputs($fsock, "HOST: www.phpbb.com\r\n"); ! @fputs($fsock, "Connection: close\r\n\r\n"); ! ! $get_info = false; ! while (!@feof($fsock)) ! { ! if ($get_info) ! { ! $phpbb_version_info .= @fread($fsock, 1024); ! } ! else ! { ! if (@fgets($fsock, 1024) == "\r\n") ! { ! $get_info = true; ! } ! } ! } ! @fclose($fsock); ! $phpbb_version_info = explode("\n", $phpbb_version_info); ! $latest_phpbb_head_revision = (int) $phpbb_version_info[0]; ! $latest_phpbb_minor_revision = (int) $phpbb_version_info[2]; ! $latest_phpbb_version = (int) $phpbb_version_info[0] . '.' . (int) $phpbb_version_info[1] . '.' . (int) $phpbb_version_info[2]; ! ! if ($latest_phpbb_head_revision == 2 && $minor_phpbb_revision == $latest_phpbb_minor_revision) ! { ! $phpbb_version_info = '<p style="color:green">' . $lang['Version_up_to_date'] . '</p>'; ! } ! else ! { ! $phpbb_version_info = '<p style="color:red">' . $lang['Version_not_up_to_date']; ! $phpbb_version_info .= '<br />' . sprintf($lang['Latest_version_info'], $latest_phpbb_version) . sprintf($lang['Current_version_info'], '2' . $board_config['version']) . '</p>'; ! } ! } ! else ! { ! if ($errstr) ! { ! $phpbb_version_info = '<p style="color:red">' . sprintf($lang['Connect_socket_error'], $errstr) . '</p>'; ! } ! else ! { ! $phpbb_version_info = '<p>' . $lang['Socket_functions_disabled'] . '</p>'; ! } ! } ! ! $phpbb_version_info .= '<p>' . $lang['Mailing_list_subscribe_reminder'] . '</p>'; ! ! return $phpbb_version_info; ! } } Index: bbcode.php =================================================================== RCS file: /cvsroot/mxbb/core/includes/sessions/phpbb2/bbcode.php,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** bbcode.php 4 Oct 2008 07:04:25 -0000 1.1 --- bbcode.php 31 Oct 2008 18:54:23 -0000 1.2 *************** *** 16,34 **** // ! // Here comes a mxp version of original phpbb2 bbcode.php ! // Last in file are the mxp wrapper functions // ! ! define("BBCODE_UID_LEN", 10); ! ! // global that holds loaded-and-prepared bbcode templates, so we only have to do ! // that stuff once. ! ! $bbcode_tpl = null; ! $bbcode_uid = null; ! ! // Need to initialize the random numbers only ONCE ! mt_srand( (double) microtime() * 1000000); ! /** --- 16,22 ---- // ! // Now load some bbcodes, to be extended for this backend (see below) // ! include_once($mx_root_path . 'includes/mx_functions_bbcode.' . $phpEx); // BBCode associated functions /** *************** *** 36,43 **** * @package MX-Publisher */ ! class mx_bbcode { var $smiley_path_url = ''; var $smiley_root_path = ''; var $smiley_url = 'smile_url'; --- 24,32 ---- * @package MX-Publisher */ ! class mx_bbcode extends bbcode_base { var $smiley_path_url = ''; var $smiley_root_path = ''; + var $smilies_path = ''; var $smiley_url = 'smile_url'; *************** *** 45,765 **** var $emotion = 'emoticon'; ! function mx_bbcode() ! { ! global $phpbb_root_path; ! ! $this->smiley_path_url = PHPBB_URL; //change this to PORTAL_URL when shared folder will be removed ! $this->smiley_root_path = $phpbb_root_path; //same here ! } ! ! /** ! * Loads bbcode templates from the bbcode.tpl file of the current template set. ! * Creates an array, keys are bbcode names like "b_open" or "url", values ! * are the associated template. ! * Probably pukes all over the place if there's something really screwed ! * with the bbcode.tpl file. ! * ! * Nathan Codding, Sept 26 2001. ! * This a temporary function ! */ ! function load_bbcode_template() ! { ! global $template; ! $tpl_filename = $template->make_filename('bbcode.tpl'); ! $tpl = fread(fopen($tpl_filename, 'r'), filesize($tpl_filename)); ! ! // replace \ with \\ and then ' with \'. ! $tpl = str_replace('\\', '\\\\', $tpl); ! $tpl = str_replace('\'', '\\\'', $tpl); ! ! // strip newlines. ! $tpl = str_replace("\n", '', $tpl); ! ! // Turn template blocks into PHP assignment statements for the values of $bbcode_tpls.. ! $tpl = preg_replace('#<!-- BEGIN (.*?) -->(.*?)<!-- END (.*?) -->#', "\n" . '$bbcode_tpls[\'\\1\'] = \'\\2\';', $tpl); ! ! $bbcode_tpls = array(); ! ! eval($tpl); ! ! return $bbcode_tpls; ! } ! ! /** ! * Prepares the loaded bbcode templates for insertion into preg_replace() ! * or str_replace() calls in the bbencode_second_pass functions. This ! * means replacing template placeholders with the appropriate preg backrefs ! * or with language vars. NOTE: If you change how the regexps work in ! * bbencode_second_pass(), you MUST change this function. ! * ! * Nathan Codding, Sept 26 2001 ! * ! * This a temporary function ! */ ! function prepare_bbcode_template($bbcode_tpl) ! { ! global $lang; ! ! $bbcode_tpl['olist_open'] = str_replace('{LIST_TYPE}', '\\1', $bbcode_tpl['olist_open']); ! ! $bbcode_tpl['color_open'] = str_replace('{COLOR}', '\\1', $bbcode_tpl['color_open']); ! ! $bbcode_tpl['size_open'] = str_replace('{SIZE}', '\\1', $bbcode_tpl['size_open']); ! ! $bbcode_tpl['quote_open'] = str_replace('{L_QUOTE}', $lang['Quote'], $bbcode_tpl['quote_open']); ! ! $bbcode_tpl['quote_username_open'] = str_replace('{L_QUOTE}', $lang['Quote'], $bbcode_tpl['quote_username_open']); ! $bbcode_tpl['quote_username_open'] = str_replace('{L_WROTE}', $lang['wrote'], $bbcode_tpl['quote_username_open']); ! $bbcode_tpl['quote_username_open'] = str_replace('{USERNAME}', '\\1', $bbcode_tpl['quote_username_open']); ! ! $bbcode_tpl['code_open'] = str_replace('{L_CODE}', $lang['Code'], $bbcode_tpl['code_open']); ! ! $bbcode_tpl['img'] = str_replace('{URL}', '\\1', $bbcode_tpl['img']); ! ! // We do URLs in several different ways.. ! $bbcode_tpl['url1'] = str_replace('{URL}', '\\1', $bbcode_tpl['url']); ! $bbcode_tpl['url1'] = str_replace('{DESCRIPTION}', '\\1', $bbcode_tpl['url1']); ! ! $bbcode_tpl['url2'] = str_replace('{URL}', 'http://\\1', $bbcode_tpl['url']); ! $bbcode_tpl['url2'] = str_replace('{DESCRIPTION}', '\\1', $bbcode_tpl['url2']); ! ! $bbcode_tpl['url3'] = str_replace('{URL}', '\\1', $bbcode_tpl['url']); ! $bbcode_tpl['url3'] = str_replace('{DESCRIPTION}', '\\2', $bbcode_tpl['url3']); ! ! $bbcode_tpl['url4'] = str_replace('{URL}', 'http://\\1', $bbcode_tpl['url']); ! $bbcode_tpl['url4'] = str_replace('{DESCRIPTION}', '\\3', $bbcode_tpl['url4']); ! ! $bbcode_tpl['email'] = str_replace('{EMAIL}', '\\1', $bbcode_tpl['email']); ! ! //Start more bbcode ! $bbcode_tpl['stream'] = str_replace('{URL}', '\\1', $bbcode_tpl['stream']); ! $bbcode_tpl['web'] = str_replace('{URL}', '\\1', $bbcode_tpl['web']); ! $bbcode_tpl['flash'] = str_replace('{WIDTH}', '\\1', $bbcode_tpl['flash']); ! $bbcode_tpl['flash'] = str_replace('{HEIGHT}', '\\2', $bbcode_tpl['flash']); ! $bbcode_tpl['flash'] = str_replace('{URL}', '\\3', $bbcode_tpl['flash']); ! $bbcode_tpl['video'] = str_replace('{URL}', '\\3', $bbcode_tpl['video']); ! $bbcode_tpl['video'] = str_replace('{WIDTH}', '\\1', $bbcode_tpl['video']); ! $bbcode_tpl['video'] = str_replace('{HEIGHT}', '\\2', $bbcode_tpl['video']); ! $bbcode_tpl['GVideo'] = str_replace('{GVIDEOID}', '\\1', $bbcode_tpl['GVideo']); ! $bbcode_tpl['GVideo'] = str_replace('{GVIDEOLINK}', $lang['Link'], $bbcode_tpl['GVideo']); ! $bbcode_tpl['youtube'] = str_replace('{YOUTUBEID}', '\\1', $bbcode_tpl['youtube']); ! $bbcode_tpl['youtube'] = str_replace('{YOUTUBELINK}', $lang['Link'], $bbcode_tpl['youtube']); ! //Stop more bbcode ! ! define("BBCODE_TPL_READY", true); ! ! return $bbcode_tpl; ! } ! ! /** ! * Does second-pass bbencoding. This should be used before displaying the message in ! * a thread. Assumes the message is already first-pass encoded, and we are given the ! * correct UID as used in first-pass encoding. ! * This a temporary function ! */ ! function bbencode_second_pass($text, $uid) ! { ! global $lang, $bbcode_tpl; ! ! $text = preg_replace('#(script|about|applet|activex|chrome):#is', "\\1:", $text); ! ! // pad it with a space so we can distinguish between FALSE and matching the 1st char (index 0). ! // This is important; bbencode_quote(), bbencode_list(), and bbencode_code() all depend on it. ! $text = " " . $text; ! ! // First: If there isn't a "[" and a "]" in the message, don't bother. ! if (! (strpos($text, "[") && strpos($text, "]")) ) ! { ! // Remove padding, return. ! $text = substr($text, 1); ! return $text; ! } ! ! // Only load the templates ONCE.. ! if (!defined("BBCODE_TPL_READY")) ! { ! // load templates from file into array. ! $bbcode_tpl = $this->load_bbcode_template(); ! ! // prepare array for use in regexps. ! $bbcode_tpl = $this->prepare_bbcode_template($bbcode_tpl); ! } ! ! // [CODE] and [/CODE] for posting code (HTML, PHP, C etc etc) in your posts. ! $text = $this->bbencode_second_pass_code($text, $uid, $bbcode_tpl); ! ! // [QUOTE] and [/QUOTE] for posting replies with quote, or just for quoting stuff. ! $text = str_replace("[quote:$uid]", $bbcode_tpl['quote_open'], $text); ! $text = str_replace("[/quote:$uid]", $bbcode_tpl['quote_close'], $text); ! ! // New one liner to deal with opening quotes with usernames... ! // replaces the two line version that I had here before.. ! $text = preg_replace("/\[quote:$uid=\"(.*?)\"\]/si", $bbcode_tpl['quote_username_open'], $text); ! ! // [list] and [list=x] for (un)ordered lists. ! // unordered lists ! $text = str_replace("[list:$uid]", $bbcode_tpl['ulist_open'], $text); ! // li tags ! $text = str_replace("[*:$uid]", $bbcode_tpl['listitem'], $text); ! // ending tags ! $text = str_replace("[/list:u:$uid]", $bbcode_tpl['ulist_close'], $text); ! $text = str_replace("[/list:o:$uid]", $bbcode_tpl['olist_close'], $text); ! // Ordered lists ! $text = preg_replace("/\[list=([a1]):$uid\]/si", $bbcode_tpl['olist_open'], $text); ! ! // colours ! $text = preg_replace("/\[color=(\#[0-9A-F]{6}|[a-z]+):$uid\]/si", $bbcode_tpl['color_open'], $text); ! $text = str_replace("[/color:$uid]", $bbcode_tpl['color_close'], $text); ! ! // size ! $text = preg_replace("/\[size=([1-2]?[0-9]):$uid\]/si", $bbcode_tpl['size_open'], $text); ! $text = str_replace("[/size:$uid]", $bbcode_tpl['size_close'], $text); ! ! // [b] and [/b] for bolding text. ! $text = str_replace("[b:$uid]", $bbcode_tpl['b_open'], $text); ! $text = str_replace("[/b:$uid]", $bbcode_tpl['b_close'], $text); ! ! // [u] and [/u] for underlining text. ! $text = str_replace("[u:$uid]", $bbcode_tpl['u_open'], $text); ! $text = str_replace("[/u:$uid]", $bbcode_tpl['u_close'], $text); ! ! // [i] and [/i] for italicizing text. ! $text = str_replace("[i:$uid]", $bbcode_tpl['i_open'], $text); ! $text = str_replace("[/i:$uid]", $bbcode_tpl['i_close'], $text); ! ! //$text = str_replace('url:' . $uid, 'url', $text); ! ! // Patterns and replacements for URL and email tags.. ! $patterns = array(); ! $replacements = array(); ! ! // [img]image_url_here[/img] code.. ! // This one gets first-passed.. ! $patterns[] = "#\[img:$uid\]([^?](?:[^\[]+|\[(?!url))*?)\[/img:$uid\]#i"; ! $replacements[] = $bbcode_tpl['img']; ! ! // matches a [url]xxxx://www.phpbb.com[/url] code.. ! $patterns[] = "#\[url\]([\w]+?://([\w\#$%&~/.\-;:=,?@\]+]+|\[(?!url=))*?)\[/url\]#is"; ! $replacements[] = $bbcode_tpl['url1']; ! ! // [url]www.phpbb.com[/url] code.. (no xxxx:// prefix). ! $patterns[] = "#\[url\]((www|ftp)\.([\w\#$%&~/.\-;:=,?@\]+]+|\[(?!url=))*?)\[/url\]#is"; ! $replacements[] = $bbcode_tpl['url2']; ! ! // [url=xxxx://www.phpbb.com]phpBB[/url] code.. ! $patterns[] = "#\[url=([\w]+?://[\w\#$%&~/.\-;:=,?@\[\]+]*?)\]([^?\n\r\t].*?)\[/url\]#is"; ! $replacements[] = $bbcode_tpl['url3']; ! ! // [url=www.phpbb.com]phpBB[/url] code.. (no xxxx:// prefix). ! $patterns[] = "#\[url=((www|ftp)\.[\w\#$%&~/.\-;:=,?@\[\]+]*?)\]([^?\n\r\t].*?)\[/url\]#is"; ! $replacements[] = $bbcode_tpl['url4']; ! ! // [email]us...@do...[/email] code.. ! $patterns[] = "#\[email\]([a-z0-9&\-_.]+?@[\w\-]+\.([\w\-\.]+\.)?[\w]+)\[/email\]#si"; ! $replacements[] = $bbcode_tpl['email']; ! ! //Strat more bbcode ! ! // [stream]Sound URL[/stream] code.. ! $patterns[] = "#\[stream:$uid\](.*?)\[/stream:$uid\]#si"; ! $replacements[] = $bbcode_tpl['stream']; ! ! // [flash width=X height=X]Flash URL[/flash] code.. ! $patterns[] = "#\[flash width=([0-6]?[0-9]?[0-9]) height=([0-4]?[0-9]?[0-9]):$uid\](.*?)\[/flash:$uid\]#si"; ! $replacements[] = $bbcode_tpl['flash']; ! ! // [video width=X height=X]Video URL[/video] code.. ! $patterns[] = "#\[video width=([0-6]?[0-9]?[0-9]) height=([0-4]?[0-9]?[0-9]):$uid\](.*?)\[/video:$uid\]#si"; ! $replacements[] = $bbcode_tpl['video']; ! $text = preg_replace($patterns, $replacements, $text); ! ! // [GVideo]GVideo URL[/GVideo] code.. ! $patterns[] = "#\[GVideo\]http://video.google.[A-Za-z0-9.]{2,5}/videoplay\?docid=([0-9A-Za-z-_]*)[^[]*\[/GVideo\]#is"; ! $replacements[] = $bbcode_tpl['GVideo']; ! ! // [youtube]YouTube URL[/youtube] code.. ! $patterns[] = "#\[youtube\]http://(?:www\.)?youtube.com/watch\?v=([0-9A-Za-z-_]{11})[^[]*\[/youtube\]#is"; ! $replacements[] = $bbcode_tpl['youtube']; ! ! //Stop more bbcode ! ! $text = preg_replace($patterns, $replacements, $text); ! ! // Remove the uid from tags that have not been transformed into HTML ! //$text = str_replace(':' . $uid, '', $text); ! ! // Remove our padding from the string.. ! $text = substr($text, 1); ! ! return $text; ! ! } // bbencode_second_pass() ! ! /** ! * This is used to change a [*] tag into a [*:$uid] tag as part ! * of the first-pass bbencoding of [list] tags. It fits the ! * standard required in order to be passed as a variable ! * function into bbencode_first_pass_pda(). ! */ ! function replace_listitems($text, $uid) ! { ! $text = str_replace("[*]", "[*:$uid]", $text); ! ! return $text; ! } ! ! function make_bbcode_uid() ! { ! global $mx_backend; ! // Unique ID for this message.. ! ! $uid = $mx_backend->dss_rand(); ! ! // BBCode UID length fix ! @define('BBCODE_UID_LEN', (PORTAL_BACKEND == 'phpbb3') ? 8 : 10); ! ! $uid = substr($uid, 0, BBCODE_UID_LEN); ! ! return $uid; ! } ! ! function bbencode_first_pass($text, $uid) ! { ! // pad it with a space so we can distinguish between FALSE and matching the 1st char (index 0). ! // This is important; bbencode_quote(), bbencode_list(), and bbencode_code() all depend on it. ! $text = " " . $text; ! ! // [CODE] and [/CODE] for posting code (HTML, PHP, C etc etc) in your posts. ! $text = $this->bbencode_first_pass_pda($text, $uid, '[code]', '[/code]', '', true, ''); ! ! // [QUOTE] and [/QUOTE] for posting replies with quote, or just for quoting stuff. ! $text = $this->bbencode_first_pass_pda($text, $uid, '[quote]', '[/quote]', '', false, ''); ! $text = $this->bbencode_first_pass_pda($text, $uid, '/\[quote=\\\\"(.*?)\\\\"\]/is', '[/quote]', '', false, '', "[quote:$uid=\\\"\\1\\\"]"); ! ! // [list] and [list=x] for (un)ordered lists. ! $open_tag = array(); ! $open_tag[0] = "[list]"; ! ! // unordered.. ! $text = $this->bbencode_first_pass_pda($text, $uid, $open_tag, "[/list]", "[/list:u]", false, 'replace_listitems'); ! ! $open_tag[0] = "[list=1]"; ! $open_tag[1] = "[list=a]"; ! ! // ordered. ! $text = $this->bbencode_first_pass_pda($text, $uid, $open_tag, "[/list]", "[/list:o]", false, 'replace_listitems'); ! ! // [color] and [/color] for setting text color ! $text = preg_replace("#\[color=(\#[0-9A-F]{6}|[a-z\-]+)\](.*?)\[/color\]#si", "[color=\\1:$uid]\\2[/color:$uid]", $text); ! ! // [size] and [/size] for setting text size ! $text = preg_replace("#\[size=([1-2]?[0-9])\](.*?)\[/size\]#si", "[size=\\1:$uid]\\2[/size:$uid]", $text); ! ! // [b] and [/b] for bolding text. ! $text = preg_replace("#\[b\](.*?)\[/b\]#si", "[b:$uid]\\1[/b:$uid]", $text); ! ! // [u] and [/u] for underlining text. ! $text = preg_replace("#\[u\](.*?)\[/u\]#si", "[u:$uid]\\1[/u:$uid]", $text); ! ! // [i] and [/i] for italicizing text. ! $text = preg_replace("#\[i\](.*?)\[/i\]#si", "[i:$uid]\\1[/i:$uid]", $text); ! ! // [img]image_url_here[/img] code.. ! $text = preg_replace("#\[img\]((http|ftp|https|ftps)://)([^ \?&=\#\"\n\r\t<]*?(\.(jpg|jpeg|gif|png)))\[/img\]#sie", "'[img:$uid]\\1' . str_replace(' ', '%20', '\\3') . '[/img:$uid]'", $text); ! ! //Start more bbcode ! $text = str_replace('url:' . $uid, 'url', $text); ! ! // [stream]Sound URL[/stream] code.. ! $text = preg_replace("#\[stream\](.*?)\[/stream\]#si", "[stream:$uid]\\1[/stream:$uid]", $text); ! ! // [flash width=X height=X]Flash URL[/flash] code.. ! $text = preg_replace("#\[flash width=([0-6]?[0-9]?[0-9]) height=([0-4]?[0-9]?[0-9])\](([a-z]+?)://([^, \n\r]+))\[\/flash\]#si","[flash width=\\1 height=\\2:$uid\]\\3[/flash:$uid]", $text); ! ! // [video width=X height=X]Video URL[/video] code.. ! $text = preg_replace("#\[video width=([0-6]?[0-9]?[0-9]) height=([0-4]?[0-9]?[0-9])\](([a-z]+?)://([^, \n\r]+))\[\/video\]#si","[video width=\\1 height=\\2:$uid\]\\3[/video:$uid]", $text); ! ! //Stop more bbcode ! ! // Remove our padding from the string.. ! return substr($text, 1);; ! ! } // bbencode_first_pass() ! ! /** ! * $text - The text to operate on. ! * $uid - The UID to add to matching tags. ! * $open_tag - The opening tag to match. Can be an array of opening tags. ! * $close_tag - The closing tag to match. ! * $close_tag_new - The closing tag to replace with. ! * $mark_lowest_level - boolean - should we specially mark the tags that occur ! * at the lowest level of nesting? (useful for [code], because ! * we need to match these tags first and transform HTML tags ! * in their contents.. ! * $func - This variable should contain a string that is the name of a function. ! * That function will be called when a match is found, and passed 2 ! * parameters: ($text, $uid). The function should return a string. ! * This is used when some transformation needs to be applied to the ! * text INSIDE a pair of matching tags. If this variable is FALSE or the ! * empty string, it will not be executed. ! * If open_tag is an array, then the pda will try to match pairs consisting of ! * any element of open_tag followed by close_tag. This allows us to match things ! * like [list=A]...[/list] and [list=1]...[/list] in one pass of the PDA. ! * ! * NOTES: - this function assumes the first character of $text is a space. ! * - every opening tag and closing tag must be of the [...] format. ! */ ! function bbencode_first_pass_pda($text, $uid, $open_tag, $close_tag, $close_tag_new, $mark_lowest_level, $func, $open_regexp_replace = false) ! { ! $open_tag_count = 0; ! ! if (!$close_tag_new || ($close_tag_new == '')) ! { ! $close_tag_new = $close_tag; ! } ! ! $close_tag_length = strlen($close_tag); ! $close_tag_new_length = strlen($close_tag_new); ! $uid_length = strlen($uid); ! ! $use_function_pointer = ($func && ($func != '')); ! ! $stack = array(); ! ! if (is_array($open_tag)) ! { ! if (0 == count($open_tag)) ! { ! // No opening tags to match, so return. ! return $text; ! } ! $open_tag_count = count($open_tag); ! } ! else ! { ! // only one opening tag. make it into a 1-element array. ! $open_tag_temp = $open_tag; ! $open_tag = array(); ! $open_tag[0] = $open_tag_temp; ! $open_tag_count = 1; ! } ! ! $open_is_regexp = false; ! ! if ($open_regexp_replace) ! { ! $open_is_regexp = true; ! if (!is_array($open_regexp_replace)) ! { ! $open_regexp_temp = $open_regexp_replace; ! $open_regexp_replace = array(); ! $open_regexp_replace[0] = $open_regexp_temp; ! } ! } ! ! if ($mark_lowest_level && $open_is_regexp) ! { ! mx_message_die(GENERAL_ERROR, "Unsupported operation for bbcode_first_pass_pda()."); ! } ! ! // Start at the 2nd char of the string, looking for opening tags. ! $curr_pos = 1; ! while ($curr_pos && ($curr_pos < strlen($text))) ! { ! $curr_pos = strpos($text, "[", $curr_pos); ! ! // If not found, $curr_pos will be 0, and the loop will end. ! if ($curr_pos) ! { ! // We found a [. It starts at $curr_pos. ! // check if it's a starting or ending tag. ! $found_start = false; ! $which_start_tag = ""; ! $start_tag_index = -1; ! ! for ($i = 0; $i < $open_tag_count; $i++) ! { ! // Grab everything until the first "]"... ! $possible_start = substr($text, $curr_pos, strpos($text, ']', $curr_pos + 1) - $curr_pos + 1); ! ! // ! // We're going to try and catch usernames with "[' characters. ! // ! if( preg_match('#\[quote=\\\"#si', $possible_start, $match) && !preg_match('#\[quote=\\\"(.*?)\\\"\]#si', $possible_start) ) ! { ! // OK we are in a quote tag that probably contains a ] bracket. ! // Grab a bit more of the string to hopefully get all of it.. ! if ($close_pos = strpos($text, '"]', $curr_pos + 14)) ! { ! if (strpos(substr($text, $curr_pos + 14, $close_pos - ($curr_pos + 14)), '[quote') === false) ! { ! $possible_start = substr($text, $curr_pos, $close_pos - $curr_pos + 7); ! } ! } ! } ! ! // Now compare, either using regexp or not. ! if ($open_is_regexp) ! { ! $match_result = array(); ! if (preg_match($open_tag[$i], $possible_start, $match_result)) ! { ! $found_start = true; ! $which_start_tag = $match_result[0]; ! $start_tag_index = $i; ! break; ! } ! } ! else ! { ! // straightforward string comparison. ! if (0 == strcasecmp($open_tag[$i], $possible_start)) ! { ! $found_start = true; ! $which_start_tag = $open_tag[$i]; ! $start_tag_index = $i; ! break; ! } ! } ! } ! ! if ($found_start) ! { ! // We have an opening tag. ! // Push its position, the text we matched, and its index in the open_tag array on to the stack, and then keep going to the right. ! $match = array("pos" => $curr_pos, "tag" => $which_start_tag, "index" => $start_tag_index); ! array_push($stack, $match); ! // ! // Rather than just increment $curr_pos ! // Set it to the ending of the tag we just found ! // Keeps error in nested tag from breaking out ! // of table structure.. ! // ! $curr_pos += strlen($possible_start); ! } ! else ! { ! // check for a closing tag.. ! $possible_end = substr($text, $curr_pos, $close_tag_length); ! if (0 == strcasecmp($close_tag, $possible_end)) ! { ! // We have an ending tag. ! // Check if we've already found a matching starting tag. ! if (sizeof($stack) > 0) ! { ! // There exists a starting tag. ! $curr_nesting_depth = sizeof($stack); ! // We need to do 2 replacements now. ! $match = array_pop($stack); ! $start_index = $match['pos']; ! $start_tag = $match['tag']; ! $start_length = strlen($start_tag); ! $start_tag_index = $match['index']; ! ! if ($open_is_regexp) ! { ! $start_tag = preg_replace($open_tag[$start_tag_index], $open_regexp_replace[$start_tag_index], $start_tag); ! } ! ! // everything before the opening tag. ! $before_start_tag = substr($text, 0, $start_index); ! ! // everything after the opening tag, but before the closing tag. ! $between_tags = substr($text, $start_index + $start_length, $curr_pos - $start_index - $start_length); ! ! // Run the given function on the text between the tags.. ! if ($use_function_pointer) ! { ! $between_tags = $this->$func($between_tags, $uid); ! } ! ! // everything after the closing tag. ! $after_end_tag = substr($text, $curr_pos + $close_tag_length); ! ! // Mark the lowest nesting level if needed. ! if ($mark_lowest_level && ($curr_nesting_depth == 1)) ! { ! if ($open_tag[0] == '[code]') ! { ! $code_entities_match = array('#<#', '#>#', '#"#', '#:#', '#\[#', '#\]#', '#\(#', '#\)#', '#\{#', '#\}#'); ! $code_entities_replace = array('<', '>', '"', ':', '[', ']', '(', ')', '{', '}'); ! $between_tags = preg_replace($code_entities_match, $code_entities_replace, $between_tags); ! } ! $text = $before_start_tag . substr($start_tag, 0, $start_length - 1) . ":$curr_nesting_depth:$uid]"; ! $text .= $between_tags . substr($close_tag_new, 0, $close_tag_new_length - 1) . ":$curr_nesting_depth:$uid]"; ! } ! else ! { ! if ($open_tag[0] == '[code]') ! { ! $text = $before_start_tag . '[code]'; ! $text .= $between_tags . '[/code]'; ! } ! else ! { ! if ($open_is_regexp) ! { ! $text = $before_start_tag . $start_tag; ! } ! else ! { ! $text = $before_start_tag . substr($start_tag, 0, $start_length - 1) . ":$uid]"; ! } ! $text .= $between_tags . substr($close_tag_new, 0, $close_tag_new_length - 1) . ":$uid]"; ! } ! } ! ! $text .= $after_end_tag; ! ! // Now.. we've screwed up the indices by changing the length of the string. ! // So, if there's anything in the stack, we want to resume searching just after it. ! // otherwise, we go back to the start. ! if (sizeof($stack) > 0) ! { ! $match = array_pop($stack); ! $curr_pos = $match['pos']; ! // bbcode_array_push($stack, $match); ! // ++$curr_pos; ! } ! else ! { ! $curr_pos = 1; ! } ! } ! else ! { ! // No matching start tag found. Increment pos, keep going. ! ++$curr_pos; ! } ! } ! else ! { ! // No starting tag or ending tag.. Increment pos, keep looping., ! ++$curr_pos; ! } ! } ! } ! } // while ! return $text; ! } // bbencode_first_pass_pda() ! /** ! * Does second-pass bbencoding of the [code] tags. This includes ! * running htmlspecialchars() over the text contained between ! * any pair of [code] tags that are at the first level of ! * nesting. Tags at the first level of nesting are indicated ! * by this format: [code:1:$uid] ... [/code:1:$uid] ! * Other tags are in this format: [code:$uid] ... [/code:$uid] ! * This a temporary function ! */ ! function bbencode_second_pass_code($text, $uid, $bbcode_tpl) { ! global $lang; ! ! $code_start_html = $bbcode_tpl['code_open']; ! $code_end_html = $bbcode_tpl['code_close']; ! ! // First, do all the 1st-level matches. These need an htmlspecialchars() run, ! // so they have to be handled differently. ! $match_count = preg_match_all("#\[code:1:$uid\](.*?)\[/code:1:$uid\]#si", $text, $matches); ! for ($i = 0; $i < $match_count; $i++) { ! $before_replace = $matches[1][$i]; ! $after_replace = $matches[1][$i]; ! ! // Replace 2 spaces with " " so non-tabbed code indents without making huge long lines. ! $after_replace = str_replace(" ", " ", $after_replace); ! // now Replace 2 spaces with " " to catch odd #s of spaces. ! $after_replace = str_replace(" ", " ", $after_replace); ! ! // Replace tabs with " " so tabbed code indents sorta right without making huge long lines. ! $after_replace = str_replace("\t", " ", $after_replace); ! ! // now Replace space occurring at the beginning of a line ! $after_replace = preg_replace("/^ {1}/m", ' ', $after_replace); ! ! $str_to_match = "[code:1:$uid]" . $before_replace . "[/code:1:$uid]"; ! ! $replacement = $code_start_html; ! $replacement .= $after_replace; ! $replacement .= $code_end_html; ! ! $text = str_replace($str_to_match, $replacement, $text); } ! // Now, do all the non-first-level matches. These are simple. ! $text = str_replace("[code:$uid]", $code_start_html, $text); ! $text = str_replace("[/code:$uid]", $code_end_html, $text); ! ! return $text; ! ! } // bbencode_second_pass_code() ! ! //phpBB Temporary code ends ! ! /** ! * Rewritten by Nathan Codding - Feb 6, 2001. ! * - Goes through the given string, and replaces xxxx://yyyy with an HTML <a> tag linking ! * to that URL ! * - Goes through the given string, and replaces www.xxxx.yyyy[zzzz] with an HTML <a> tag linking ! * to http://www.xxxx.yyyy[/zzzz] ! * - Goes through the given string, and replaces xxxx@yyyy with an HTML mailto: tag linking ! * to that email address ! * - Only matches these 2 patterns either after a space, or at the beginning of a line ! * ! * Notes: the email one might get annoying - it's easy to make it more restrictive, though.. maybe ! * have it require something like xx...@yy... or such. We'll see. ! * We can add here more phpBB3 stuff in time - Ory ! */ ! function make_clickable($text) ! { ! $text = preg_replace('#(script|about|applet|activex|chrome):#is', "\\1:", $text); ! ! // pad it with a space so we can match things at the start of the 1st line. ! $ret = ' ' . $text; ! ! // matches an "xxxx://yyyy" URL at the start of a line, or after a space. ! // xxxx can only be alpha characters. ! // yyyy is anything up to the first space, newline, comma, double quote or < ! $ret = preg_replace("#(^|[\n ])([\w]+?://[\w\#$%&~/.\-;:=,?@\[\]+]*)#is", "\\1<a href=\"\\2\" target=\"_blank\">\\2</a>", $ret); ! ! // matches a "www|ftp.xxxx.yyyy[/zzzz]" kinda lazy URL thing ! // Must contain at least 2 dots. xxxx contains either alphanum, or "-" ! // zzzz is optional.. will contain everything up to the first space, newline, ! // comma, double quote or <. ! $ret = preg_replace("#(^|[\n ])((www|ftp)\.[\w\#$%&~/.\-;:=,?@\[\]+]*)#is", "\\1<a href=\"http://\\2\" target=\"_blank\">\\2</a>", $ret); ! ! // matches an email@domain type address at the start of a line, or after a space. ! // Note: Only the followed chars are valid; alphanums, "-", "_" and or ".". ! $ret = preg_replace("#(^|[\n ])([a-z0-9&\-_.]+?)@([\w\-]+\.([\w\-\.]+\.)*[\w]+)#i", "\\1<a href=\"mailto:\\2@\\3\">\\2@\\3</a>", $ret); ! ! // Remove our padding.. ! $ret = substr($ret, 1); ! ! return($ret); ! } ! ! /** ! * Nathan Codding - Feb 6, 2001 ! * Reverses the effects of make_clickable(), for use in editpost. ! * - Does not distinguish between "www.xxxx.yyyy" and "http://aaaa.bbbb" type URLs. ! * ! */ ! function undo_make_clickable($text) ! { ! $text = preg_replace("#<!-- BBCode auto-link start --><a href=\"(.*?)\" target=\"_blank\">.*?</a><!-- BBCode auto-link end -->#i", "\\1", $text); ! $text = preg_replace("#<!-- BBcode auto-mailto start --><a href=\"mailto:(.*?)\">.*?</a><!-- BBCode auto-mailto end -->#i", "\\1", $text); ! ! return $text; } - // - // MXP Wrapper - // - /** * bbcode to html. --- 34,63 ---- var $emotion = 'emoticon'; ! var $bbcode_uid = ''; ! var $bbcode_bitfield = ''; ! var $bbcode_cache = array(); ! var $bbcode_template = array(); ! var $bbcodes = array(); ! var $template_bitfield; ! var $template_filename = ''; ! function mx_bbcode($bitfield = '') { ! global $board_config, $phpbb_root_path; ! if ($bitfield) { ! $this->bbcode_bitfield = $bitfield; ! $this->bbcode_cache_init(); } ! $this->smiley_path_url = PHPBB_URL; //change this to PORTAL_URL when shared folder will be removed ! $this->smiley_root_path = $phpbb_root_path; //same here + $this->smilies_path = str_replace("//", "/", $board_config['smilies_path']); } /** * bbcode to html. *************** *** 789,861 **** } - /** - * phpBB Smilies pass. - * - * Hacking smilies_pass from phpbb/includes/bbcode.php - * - * @param string $message - * @return string - * - */ - function smilies_pass($message) - { - static $orig, $repl; - global $board_config, $mx_root_path, $phpbb_root_path, $phpEx; - - if (!isset($orig)) - { - global $db; - $orig = $repl = array(); - - $sql = 'SELECT * FROM ' . SMILIES_TABLE; - if( !$result = $db->sql_query($sql) ) - { - mx_message_die(GENERAL_ERROR, "Couldn't obtain smilies data", "", __LINE__, __FILE__, $sql); - } - - $smilies = $db->sql_fetchrowset($result); - - if (count($smilies)) - { - @usort($smilies, 'smiley_sort'); - } - - for ($i = 0; $i < count($smilies); $i++) - { - $orig[] = "/(?<=.\W|\W.|^\W)" . preg_quote($smilies[$i]['code'], "/") . "(?=.\W|\W.|\W$)/"; - $repl[] = '<img src="' . $this->smiley_path_url . $board_config['smilies_path'] . '/' . $smilies[$i][$this->smiley_url] . '" alt="' . $smilies[$i][$this->emotion] . '" border="0" />'; - } - } - - if (count($orig)) - { - $message = preg_replace($orig, $repl, ' ' . $message . ' '); - $message = substr($message, 1, -1); - } - - return $message; - } - - /** - * phpBB Smilies pass. - * - * Hacking smilies_pass from phpbb/includes/bbcode.php - * - * NOTE: This is only kept for reference - not used. - * - * @param string $message - * @return string - */ - function mx_smilies_pass_old($message) - { - global $mx_page, $board_config, $phpbb_root_path, $phpEx; - - $smilies_path = $board_config['smilies_path']; - $board_config['smilies_path'] = PHPBB_URL . $board_config['smilies_path']; - $message = smilies_pass($message); - $board_config['smilies_path'] = $smilies_path; - return $message; - } - // // This function will prepare a posted message for --- 87,90 ---- *************** *** 907,911 **** } ! //Core BBCode Starts /** * Generate smilies. --- 136,187 ---- } ! /** ! * phpBB Smilies pass. ! * ! * Hacking smilies_pass from phpbb/includes/bbcode.php ! * ! * @param string $message ! * @return string ! * ! */ ! function smilies_pass($message) ! { ! static $orig, $repl; ! global $board_config, $mx_root_path, $phpbb_root_path, $phpEx; ! ! if (!isset($orig)) ! { ! global $db; ! $orig = $repl = array(); ! ! $sql = 'SELECT * FROM ' . SMILIES_TABLE; ! if( !$result = $db->sql_query($sql) ) ! { ! mx_message_die(GENERAL_ERROR, "Couldn't obtain smilies data", "", __LINE__, __FILE__, $sql); ! } ! ! $smilies = $db->sql_fetchrowset($result); ! ! if (count($smilies)) ! { ! @usort($smilies, 'smiley_sort'); ! } ! ! for ($i = 0; $i < count($smilies); $i++) ! { ! $orig[] = "/(?<=.\W|\W.|^\W)" . preg_quote($smilies[$i]['code'], "/") . "(?=.\W|\W.|\W$)/"; ! $repl[] = '<img src="' . $this->smiley_path_url . $board_config['smilies_path'] . '/' . $smilies[$i][$this->smiley_url] . '" alt="' . $smilies[$i][$this->emotion] . '" border="0" />'; ! } ! } ! ! if (count($orig)) ! { ! $message = preg_replace($orig, $repl, ' ' . $message . ' '); ! $message = substr($message, 1, -1); ! } ! ! return $message; ! } ! /** * Generate smilies. |