Update of /cvsroot/mxbb/core/includes/sessions/smf2 In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv27354 Added Files: auth.php bbcode.php constants.php core.php functions.php login.php readme.html session.php Log Message: Experimental smf2 backend files based on smf2 api in shared folder --- NEW FILE: login.php --- <?php /** * * @package MX-Publisher Core * @version $Id: login.php,v 1.1 2014/05/18 06:26:59 orynider Exp $ * @copyright (c) 2002-2008 MX-Publisher Project Team * @license http://opensource.org/licenses/gpl-license.php GNU General Public License v2 * @link http://mxpcms.sourceforge.net/ * */ if ( !defined('IN_PORTAL') ) { die("Hacking attempt"); } 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', MX_TYPE_NO_TAGS)) : ''; $password = $mx_request_vars->post('password', MX_TYPE_NO_TAGS); // Set the randomly generated code. if (!isset($_SESSION['session_var'])) { $_SESSION['session_value'] = md5(session_id() . mt_rand()); $_SESSION['session_var'] = substr(preg_replace('~^\d+~', '', sha1(mt_rand() . session_id() . mt_rand())), 0, rand(7, 12)); } $sc = isset($_SESSION['session_value']) ? $_SESSION['session_value'] : ''; $sql = "SELECT * FROM " . USERS_TABLE . " WHERE member_name = '" . str_replace("\\'", "''", $username) . "'"; if ( !($result = $db->sql_query($sql) ) ) { mx_message_die(GENERAL_ERROR, 'Error in obtaining userdata', '', __LINE__, __FILE__, $sql); } if( $row = $db->sql_fetchrow($result) ) { if( $row['id_group'] != ADMIN && $board_config['board_disable'] ) { mx_redirect(mx_append_sid("index.$phpEx", false)); } else { // If the last login is more than x minutes ago, then reset the login tries/time if (isset($_SESSION['failed_login']) && ($board_config['failed_login_threshold'] * 3 >= $_SESSION['failed_login'])) { $db->sql_query('UPDATE ' . USERS_TABLE . ' SET last_login = 0 WHERE user_id = ' . $row['user_id']); // Reset the login threshold. unset($_SESSION['failed_login']); } // Check to see if user is allowed to login again... if his tries are exceeded if (isset($_SESSION['failed_login']) && ($_SESSION['failed_login'] >= $board_config['failed_login_threshold'] * 3)) { // Reset the login threshold. mx_message_die(GENERAL_MESSAGE, sprintf($lang['Login_attempts_exceeded'], $board_config['max_login_attempts'], $board_config['login_reset_time'])); } // Figure out the password using SMF's encryption - if what they typed is right. /* if (isset($password) && strlen($password) == 40) { // Needs upgrading? if (strlen($user_settings['passwd']) != 40) { } } */ // Challenge passed. if ($password == sha1($row['passwd'] . $sc) && $row['is_activated']) { $sha_passwd = $row['passwd']; //if( md5($password) == $row['passwd'] && $row['user_active'] ) //{ $autologin = $mx_request_vars->is_post('autologin'); $admin = $mx_request_vars->is_post('admin'); $session_id = $mx_user->session_begin($row['user_id'], $user_ip, PAGE_INDEX, FALSE, $autologin, $admin); // Reset login tries $db->sql_query('UPDATE ' . USERS_TABLE . ' SET last_login = 0 WHERE user_id = ' . $row['user_id']); if($session_id) { $fromurl = ( !empty($HTTP_REFERER) ) ? str_replace('&', '&', htmlspecialchars($HTTP_REFERER)) : "index.$phpEx"; $url = $mx_request_vars->post('redirect', MX_TYPE_NO_TAGS); $url = ( !empty($url) ) ? str_replace('&', '&', $url) : $fromurl; mx_redirect(mx3_append_sid($url, false, false, $session_id)); } else { mx_message_die(CRITICAL_ERROR, "Couldn't start session : login", "", __LINE__, __FILE__); } } // Only store a failed login attempt for an active user - inactive users can't login even with a correct password elseif($row['is_activated']) { // Save login tries and last login if ($row['id_member'] != ANONYMOUS) { $sql = 'UPDATE ' . USERS_TABLE . ' SET last_login = ' . time() . ' WHERE id_member = ' . $row['id_member']; $db->sql_query($sql); } $redirect = $mx_request_vars->post('redirect', MX_TYPE_NO_TAGS); if (!empty($redirect)) { $redirect = str_replace('&', '&', $redirect); $redirect = str_replace('?', '&', $redirect); } if (strstr(urldecode($redirect), "\n") || strstr(urldecode($redirect), "\r")) { mx_message_die(GENERAL_ERROR, 'Tried to redirect to potentially insecure url.'); } $template->assign_vars(array( 'META' => "<meta http-equiv=\"refresh\" content=\"3;url=login.$phpEx?redirect=$redirect\">") ); $message = $lang['Error_login'] . '<br /><br />' . sprintf($lang['Click_return_login'], "<a href=\"login.$phpEx?redirect=$redirect\">", '</a>') . '<br /><br />' . sprintf($lang['Click_return_index'], '<a href="' . mx_append_sid("index.$phpEx") . '">', '</a>'); mx_message_die(GENERAL_MESSAGE, $message); } } } else { $redirect = $mx_request_vars->post('redirect', MX_TYPE_NO_TAGS); if (!empty($redirect)) { $redirect = str_replace('&', '&', $redirect); $redirect = str_replace('?', '&', $redirect); } if (strstr(urldecode($redirect), "\n") || strstr(urldecode($redirect), "\r")) { mx_message_die(GENERAL_ERROR, 'Tried to redirect to potentially insecure url.'); } $template->assign_vars(array( 'META' => "<meta http-equiv=\"refresh\" content=\"3;url=login.$phpEx?redirect=$redirect\">") ); $message = $lang['Error_login'] . '<br /><br />' . sprintf($lang['Click_return_login'], "<a href=\"login.$phpEx?redirect=$redirect\">", '</a>') . '<br /><br />' . sprintf($lang['Click_return_index'], '<a href="' . mx_append_sid("index.$phpEx") . '">', '</a>'); mx_message_die(GENERAL_MESSAGE, $message); } } else if ($mx_request_vars->is_request('logout') && $userdata['session_logged_in'] ) { // session id check if ($sid == '' || $sid != $userdata['session_id']) { mx_message_die(GENERAL_ERROR, 'Invalid_session'); } if( $userdata['session_logged_in'] ) { $mx_user->session_end($userdata['session_id'], $userdata['user_id']); } if (!$mx_request_vars->is_empty_request('redirect')) { $fromurl = ( !empty($HTTP_REFERER) ) ? str_replace('&', '&', htmlspecialchars($HTTP_REFERER)) : "index.$phpEx"; $url = !$mx_request_vars->is_empty_post('redirect') ? str_replace('&', '&', $mx_request_vars->post('redirect', MX_TYPE_NO_TAGS)) : $fromurl; mx_redirect(mx3_append_sid($url, false, false, $session_id)); } else { mx_redirect(mx_append_sid("index.$phpEx", false)); } } else { $url = !$mx_request_vars->is_empty_post('redirect') ? str_replace('&', '&', $mx_request_vars->post('redirect', MX_TYPE_NO_TAGS)) : "index.$phpEx"; mx_redirect(mx_append_sid($url, false)); } ?> --- NEW FILE: functions.php --- <?php /** * * @package Auth * @version $Id: functions.php,v 1.1 2014/05/18 06:26:59 orynider Exp $ * @copyright (c) 2002-2008 MX-Publisher Project Team * @license http://opensource.org/licenses/gpl-license.php GNU General Public License v2 * @link http://mxpcms.sourceforge.net/ * */ if ( !defined( 'IN_PORTAL' ) ) { die( "Hacking attempt" ); } /** * Olympus Parse cfg file */ function mx_parse_cfg_file($filename, $lines = false) { $parsed_items = array(); if ($lines === false) { $lines = file($filename); } foreach ($lines as $line) { $line = trim($line); if (!$line || $line[0] == '#' || ($delim_pos = strpos($line, '=')) === false) { continue; } // Determine first occurrence, since in values the equal sign is allowed $key = strtolower(trim(substr($line, 0, $delim_pos))); $value = trim(substr($line, $delim_pos + 1)); if (in_array($value, array('off', 'false', '0'))) { $value = false; } else if (in_array($value, array('on', 'true', '1'))) { $value = true; } else if (!trim($value)) { $value = ''; } else if (($value[0] == "'" && $value[sizeof($value) - 1] == "'") || ($value[0] == '"' && $value[sizeof($value) - 1] == '"')) { $value = substr($value, 1, sizeof($value)-2); } $parsed_items[$key] = $value; } return $parsed_items; } /** * Add log event */ function mx_add_log() { global $db, $mx_user; $args = func_get_args(); $mode = array_shift($args); $reportee_id = ($mode == 'user') ? intval(array_shift($args)) : ''; $forum_id = ($mode == 'mod') ? intval(array_shift($args)) : ''; $topic_id = ($mode == 'mod') ? intval(array_shift($args)) : ''; $action = array_shift($args); $data = (!sizeof($args)) ? '' : serialize($args); $sql_ary = array( 'user_id' => (empty($mx_user->data)) ? ANONYMOUS : $mx_user->data['user_id'], 'log_ip' => $mx_user->ip, 'log_time' => time(), 'log_operation' => $action, 'log_data' => $data, ); switch ($mode) { case 'admin': $sql_ary['log_type'] = LOG_ADMIN; break; case 'mod': $sql_ary += array( 'log_type' => LOG_MOD, 'forum_id' => $forum_id, 'topic_id' => $topic_id ); break; case 'user': $sql_ary += array( 'log_type' => LOG_USERS, 'reportee_id' => $reportee_id ); break; case 'critical': $sql_ary['log_type'] = LOG_CRITICAL; break; default: return false; } $db->sql_query('INSERT INTO ' . LOG_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary)); return $db->sql_nextid(); } /** * Generate sort selection fields */ function mx_gen_sort_selects(&$limit_days, &$sort_by_text, &$sort_days, &$sort_key, &$sort_dir, &$s_limit_days, &$s_sort_key, &$s_sort_dir, &$u_sort_param) { global $mx_user; $sort_dir_text = array('a' => $mx_user->lang['ASCENDING'], 'd' => $mx_user->lang['DESCENDING']); // Check if the key is selectable. If not, we reset to the first key found. // This ensures the values are always valid. if (!isset($limit_days[$sort_days])) { @reset($limit_days); $sort_days = key($limit_days); } if (!isset($sort_by_text[$sort_key])) { @reset($sort_by_text); $sort_key = key($sort_by_text); } if (!isset($sort_dir_text[$sort_dir])) { @reset($sort_dir_text); $sort_dir = key($sort_dir_text); } $s_limit_days = '<select name="st">'; foreach ($limit_days as $day => $text) { $selected = ($sort_days == $day) ? ' selected="selected"' : ''; $s_limit_days .= '<option value="' . $day . '"' . $selected . '>' . $text . '</option>'; } $s_limit_days .= '</select>'; $s_sort_key = '<select name="sk">'; foreach ($sort_by_text as $key => $text) { $selected = ($sort_key == $key) ? ' selected="selected"' : ''; $s_sort_key .= '<option value="' . $key . '"' . $selected . '>' . $text . '</option>'; } $s_sort_key .= '</select>'; $s_sort_dir = '<select name="sd">'; foreach ($sort_dir_text as $key => $value) { $selected = ($sort_dir == $key) ? ' selected="selected"' : ''; $s_sort_dir .= '<option value="' . $key . '"' . $selected . '>' . $value . '</option>'; } $s_sort_dir .= '</select>'; $u_sort_param = "st=$sort_days&sk=$sort_key&sd=$sort_dir"; return; } /** * Get username details for placing into templates. * * @param string $mode Can be profile (for getting an url to the profile), username (for obtaining the username), colour (for obtaining the user colour) or full (for obtaining a html string representing a coloured link to the users profile). * @param int $user_id The users id * @param string $username The users name * @param string $username_colour The users colour * @param string $guest_username optional parameter to specify the guest username. It will be used in favor of the GUEST language variable then. * @param string $custom_profile_url optional parameter to specify a profile url. The user id get appended to this url as &u={user_id} * * @return string A string consisting of what is wanted based on $mode. */ function mx_get_username_string($mode, $user_id, $username, $username_colour = '', $guest_username = false, $custom_profile_url = false) { global $smf_root_path, $phpEx, $mx_user, $phpbb_auth; $profile_url = ''; $username_colour = ($username_colour) ? '#' . $username_colour : ''; if ($guest_username === false) { $username = ($username) ? $username : $mx_user->lang['GUEST']; } else { $username = ($user_id && $user_id != ANONYMOUS) ? $username : ((!empty($guest_username)) ? $guest_username : $mx_user->lang['GUEST']); } // Only show the link if not anonymous if ($user_id && $user_id != ANONYMOUS) { // Do not show the link if the user is already logged in but do not have u_viewprofile permissions (relevant for bots mostly). // For all others the link leads to a login page or the profile. if ($mx_user->data['user_id'] != ANONYMOUS && !$phpbb_auth->acl_get('u_viewprofile')) { $profile_url = ''; } else { $profile_url = ($custom_profile_url !== false) ? $custom_profile_url : mx3_append_sid("{$smf_root_path}memberlist.$phpEx", 'mode=viewprofile'); $profile_url .= '&u=' . (int) $user_id; } } else { $profile_url = ''; } switch ($mode) { case 'profile': return $profile_url; break; case 'username': return $username; break; case 'colour': return $username_colour; break; case 'full': default: $tpl = ''; if (!$profile_url && !$username_colour) { $tpl = '{USERNAME}'; } else if (!$profile_url && $username_colour) { $tpl = '<span style="color: {USERNAME_COLOUR};" class="username-coloured">{USERNAME}</span>'; } else if ($profile_url && !$username_colour) { $tpl = '<a href="{PROFILE_URL}">{USERNAME}</a>'; } else if ($profile_url && $username_colour) { $tpl = '<a href="{PROFILE_URL}" style="color: {USERNAME_COLOUR};" class="username-coloured">{USERNAME}</a>'; } return str_replace(array('{PROFILE_URL}', '{USERNAME_COLOUR}', '{USERNAME}'), array($profile_url, $username_colour, $username), $tpl); break; } } ?> --- NEW FILE: core.php --- <?php /** * * @package Auth * @version $Id: core.php,v 1.1 2014/05/18 06:26:59 orynider Exp $ * @copyright (c) 2002-2008 MX-Publisher Project Team * @license http://opensource.org/licenses/gpl-license.php GNU General Public License v2 * @link http://mxpcms.sourceforge.net/ * */ if (!defined('IN_PORTAL')) { die("Hacking attempt"); } // don't do anything if SMF is already loaded if (defined('SMF')) { [...1298 lines suppressed...] } /** * Enter description here... * * @return unknown */ function backend_version_check() { return ''; } } // // Now load some bbcodes, to be extended for this backend (see below) // include_once($mx_root_path . 'includes/sessions/smf2/bbcode.'.$phpEx); // BBCode associated functions ?> --- NEW FILE: constants.php --- <?php /** * * @package Style * @version $Id: constants.php,v 1.1 2014/05/18 06:26:59 orynider Exp $ * @copyright (c) 2002-2008 MX-Publisher Project Team * @license http://opensource.org/licenses/gpl-license.php GNU General Public License v2 * @link http://mxpcms.sourceforge.net/ * */ if ( !defined('IN_PHPBB') ) { die("Hacking attempt"); } // Debug Level //@define('DEBUG', 1); // Debugging on @define('DEBUG', 0); // Debugging off // User Levels <- Do not change the values of USER or ADMIN @define('DELETED', -1); @define('ANONYMOUS', 0); @define('GUEST', 0); @define('USER', 0); @define('ADMIN', 1); @define('MOD', 2); // User related @define('USER_ACTIVATION_NONE', 0); @define('USER_ACTIVATION_SELF', 1); @define('USER_ACTIVATION_ADMIN', 2); @define('USER_AVATAR_NONE', 0); @define('USER_AVATAR_UPLOAD', 1); @define('USER_AVATAR_REMOTE', 2); @define('USER_AVATAR_GALLERY', 3); // Group settings @define('GROUP_OPEN', 0); @define('GROUP_CLOSED', 1); @define('GROUP_HIDDEN', 2); // Forum state @define('FORUM_UNLOCKED', 0); @define('FORUM_LOCKED', 1); // Topic status @define('TOPIC_UNLOCKED', 0); @define('TOPIC_LOCKED', 1); @define('TOPIC_MOVED', 2); @define('TOPIC_WATCH_NOTIFIED', 1); @define('TOPIC_WATCH_UN_NOTIFIED', 0); // Topic types @define('POST_NORMAL', 0); @define('POST_STICKY', 1); @define('POST_ANNOUNCE', 2); @define('POST_GLOBAL_ANNOUNCE', 3); // SQL codes @define('BEGIN_TRANSACTION', 1); @define('END_TRANSACTION', 2); // Error codes @define('GENERAL_MESSAGE', 200); @define('GENERAL_ERROR', 202); @define('CRITICAL_MESSAGE', 203); @define('CRITICAL_ERROR', 204); // Private messaging @define('PRIVMSGS_READ_MAIL', 0); @define('PRIVMSGS_NEW_MAIL', 1); @define('PRIVMSGS_SENT_MAIL', 2); @define('PRIVMSGS_SAVED_IN_MAIL', 3); @define('PRIVMSGS_SAVED_OUT_MAIL', 4); @define('PRIVMSGS_UNREAD_MAIL', 5); // URL PARAMETERS @define('POST_TOPIC_URL', 't'); @define('POST_CAT_URL', 'c'); @define('POST_FORUM_URL', 'f'); @define('POST_USERS_URL', 'u'); @define('POST_POST_URL', 'p'); @define('POST_GROUPS_URL', 'g'); // Session parameters @define('SESSION_METHOD_COOKIE', 100); @define('SESSION_METHOD_GET', 101); // Page numbers for session handling @define('PAGE_INDEX', 0); @define('PAGE_LOGIN', -1); @define('PAGE_SEARCH', -2); @define('PAGE_REGISTER', -3); @define('PAGE_PROFILE', -4); @define('PAGE_VIEWONLINE', -6); @define('PAGE_VIEWMEMBERS', -7); @define('PAGE_FAQ', -8); @define('PAGE_POSTING', -9); @define('PAGE_PRIVMSGS', -10); @define('PAGE_GROUPCP', -11); @define('PAGE_TOPIC_OFFSET', 5000); // Auth settings @define('AUTH_LIST_ALL', 0); @define('AUTH_ALL', 0); @define('AUTH_REG', 1); @define('AUTH_ACL', 2); @define('AUTH_MOD', 3); @define('AUTH_ADMIN', 5); @define('AUTH_VIEW', 1); @define('AUTH_READ', 2); @define('AUTH_POST', 3); @define('AUTH_REPLY', 4); @define('AUTH_EDIT', 5); @define('AUTH_DELETE', 6); @define('AUTH_ANNOUNCE', 7); @define('AUTH_STICKY', 8); @define('AUTH_POLLCREATE', 9); @define('AUTH_VOTE', 10); @define('AUTH_ATTACH', 11); // Table names //@define('CONFIRM_TABLE', $table_prefix.'confirm'); //@define('AUTH_ACCESS_TABLE', $table_prefix.'auth_access'); //@define('BANLIST_TABLE', $table_prefix.'banlist'); //@define('CATEGORIES_TABLE', $table_prefix.'categories'); @define('CONFIG_TABLE', $table_prefix.'settings'); //@define('DISALLOW_TABLE', $table_prefix.'disallow'); //@define('FORUMS_TABLE', $table_prefix.'forums'); @define('GROUPS_TABLE', $mx_table_prefix.'groups'); //@define('POSTS_TABLE', $table_prefix.'posts'); //@define('POSTS_TEXT_TABLE', $table_prefix.'posts_text'); //@define('PRIVMSGS_TABLE', $table_prefix.'privmsgs'); //@define('PRIVMSGS_TEXT_TABLE', $table_prefix.'privmsgs_text'); //@define('PRIVMSGS_IGNORE_TABLE', $table_prefix.'privmsgs_ignore'); //@define('PRUNE_TABLE', $table_prefix.'forum_prune'); //@define('RANKS_TABLE', $table_prefix.'ranks'); //@define('SEARCH_TABLE', $table_prefix.'search_results'); //@define('SEARCH_WORD_TABLE', $table_prefix.'search_wordlist'); //@define('SEARCH_MATCH_TABLE', $table_prefix.'search_wordmatch'); @define('SESSIONS_TABLE', $table_prefix.'sessions'); @define('SESSIONS_KEYS_TABLE', $mx_table_prefix.'sessions_keys'); @define('SMILIES_TABLE', $mx_table_prefix.'smilies'); //@define('THEMES_TABLE', $table_prefix.'themes'); //@define('THEMES_NAME_TABLE', $table_prefix.'themes_name'); //@define('TOPICS_TABLE', $table_prefix.'topics'); //@define('TOPICS_WATCH_TABLE', $table_prefix.'topics_watch'); @define('USER_GROUP_TABLE', $mx_table_prefix.'user_group'); @define('USERS_TABLE', $table_prefix.'members'); @define('WORDS_TABLE', $mx_table_prefix.'words'); //@define('VOTE_DESC_TABLE', $table_prefix.'vote_desc'); //@define('VOTE_RESULTS_TABLE', $table_prefix.'vote_results'); //@define('VOTE_USERS_TABLE', $table_prefix.'vote_voters'); ?> --- NEW FILE: bbcode.php --- <?php /** * * @package Functions_phpBB * @version $Id: bbcode.php,v 1.1 2014/05/18 06:26:59 orynider Exp $ * @copyright (c) 2002-2008 MX-Publisher Project Team * @license http://opensource.org/licenses/gpl-license.php GNU General Public License v2 * @link http://mxpcms.sourceforge.net/ * */ if (!defined('IN_PORTAL')) { exit; } // // 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 /** * MXP BBcodes * @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'; var $smiley_id = 'smilies_id'; 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. * * Convert the bbcode to html * * @param string $bbtext * @param string $bbcode_uid * @param boolean $smilies_on * @return string */ function decode($bbtext, $bbcode_uid, $smilies_on = true) { global $mx_root_path, $phpbb_root_path, $phpEx, $mx_page; $mytext = stripslashes($bbtext); if (!empty($bbcode_uid)) { $mytext = $this->bbencode_second_pass($mytext, $bbcode_uid); } if ($smilies_on) { $mytext = $this->smilies_pass($mytext); } $mytext = str_replace("\n", "\n<br />\n", $mytext); return $this->make_clickable($mytext); } // // This function will prepare a posted message for // entry into the database. // function prepare_message($message, $html_on, $bbcode_on, $smile_on, $bbcode_uid = 0) { global $board_config, $html_entities_match, $html_entities_replace; // // Clean up the message // $message = trim($message); if ($html_on) { // If HTML is on, we try to make it safe // This approach is quite agressive and anything that does not look like a valid tag // is going to get converted to HTML entities $message = stripslashes($message); $html_match = '#<[^\w<]*(\w+)((?:"[^"]*"|\'[^\']*\'|[^<>\'"])+)?>#'; $matches = array(); $message_split = preg_split($html_match, $message); preg_match_all($html_match, $message, $matches); $message = ''; foreach ($message_split as $part) { $tag = array(array_shift($matches[0]), array_shift($matches[1]), array_shift($matches[2])); $message .= preg_replace($html_entities_match, $html_entities_replace, $part) . clean_html($tag); } $message = addslashes($message); $message = str_replace('"', '\"', $message); } else { $message = preg_replace($html_entities_match, $html_entities_replace, $message); } if($bbcode_on && $bbcode_uid != '') { $message = $this->bbencode_first_pass($message, $bbcode_uid); } return $message; } /** * 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. * * Hacking generate_smilies from phpbb/includes/functions_post(ing).php * * @param string $mode * @param integer $page_id * * Fill smiley templates (or just the variables) with smilies, either in a window or inline */ function generate_smilies($mode, $forum_id) { global $mx_page, $board_config, $template, $mx_root_path, $phpbb_root_path, $phpEx; global $db, $lang, $images, $theme; global $user_ip, $session_length, $starttime; global $userdata, $phpbb_auth, $mx_user; $inline_columns = 4; $inline_rows = 5; $window_columns = 8; if ($mode == 'window') { $mx_user->init($user_ip, PAGE_INDEX); $gen_simple_header = TRUE; $page_title = $lang['Emoticons']; include($mx_root_path . 'includes/page_header.'.$phpEx); $template->set_filenames(array( 'smiliesbody' => 'posting_smilies.tpl') ); } $sql = "SELECT emoticon, code, smile_url FROM " . SMILIES_TABLE . " ORDER BY smilies_id"; if ($result = $db->sql_query($sql)) { $num_smilies = 0; $rowset = array(); while ($row = $db->sql_fetchrow($result)) { if (empty($rowset[$row['smile_url']])) { $rowset[$row['smile_url']]['code'] = str_replace("'", "\\'", str_replace('\\', '\\\\', $row['code'])); $rowset[$row['smile_url']]['emoticon'] = $row['emoticon']; $num_smilies++; } } if ($num_smilies) { $smilies_count = ($mode == 'inline') ? min(19, $num_smilies) : $num_smilies; $smilies_split_row = ($mode == 'inline') ? $inline_columns - 1 : $window_columns - 1; $s_colspan = 0; $row = 0; $col = 0; while (list($smile_url, $data) = @each($rowset)) { if (!$col) { $template->assign_block_vars('smilies_row', array()); } $template->assign_block_vars('smilies_row.smilies_col', array( 'SMILEY_CODE' => $data['code'], 'SMILEY_IMG' => $this->smiley_path_url . $board_config['smilies_path'] . '/' . $smile_url, 'SMILEY_DESC' => $data['emoticon']) ); $s_colspan = max($s_colspan, $col + 1); if ($col == $smilies_split_row) { if ($mode == 'inline' && $row == $inline_rows - 1) { break; } $col = 0; $row++; } else { $col++; } } if ($mode == 'inline' && $num_smilies > $inline_rows * $inline_columns) { $template->assign_block_vars('switch_smilies_extra', array()); $template->assign_vars(array( 'L_MORE_SMILIES' => $lang['More_emoticons'], 'U_MORE_SMILIES' => mx3_append_sid(PHPBB_URL . "posting.$phpEx", "mode=smilies")) ); } $template->assign_vars(array( 'L_EMOTICONS' => $lang['Emoticons'], 'L_CLOSE_WINDOW' => $lang['Close_window'], 'S_SMILIES_COLSPAN' => $s_colspan) ); } } if ($mode == 'window') { $template->pparse('smiliesbody'); include($mx_root_path . 'includes/page_tail.'.$phpEx); } } } ?> --- NEW FILE: session.php --- <?php /** * * @package Style * @version $Id: session.php,v 1.1 2014/05/18 06:26:59 orynider Exp $ * @copyright (c) 2002-2008 MX-Publisher Project Team & (C) 2001 The phpBB Group * @license http://opensource.org/licenses/gpl-license.php GNU General Public License v2 * @link http://mxpcms.sourceforge.net/ * */ /** * Modifications: * * Class wrapper * mx_dss_rand */ /** [...2081 lines suppressed...] // globalize cookies across domains (filter out IP-addresses)? if ($global && preg_match('~^\d{1,3}(\.\d{1,3}){3}$~', $parsed_url['host']) == 0 && preg_match('~(?:[^\.]+\.)?([^\.]{2,}\..+)\z~i', $parsed_url['host'], $parts) == 1) { $parsed_url['host'] = '.' . $parts[1]; } // we shouldn't use a host at all if both options are off elseif (!$local && !$global) { $parsed_url['host'] = ''; } // the host also shouldn't be set if there aren't any dots in it elseif (!isset($parsed_url['host']) || strpos($parsed_url['host'], '.') === false) { $parsed_url['host'] = ''; } return array($parsed_url['host'], $parsed_url['path'] . '/'); } ?> --- NEW FILE: readme.html --- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <title>mxpcms Bridge Installation Guide</title> <style type="text/css"> body { background-color: #E5E5E8; margin: 0px; padding: 0px; } body, td { color: #000000; font-size: small; font-family: verdana, sans-serif; } div#header { background-image: url('Themes/default/images/catbg.jpg'); background-repeat: repeat-x; background-color: #88A6C0; color: white; font-family: Georgia, serif; font-size: xx-large; border-bottom: 1px solid black; height: 40px; padding-left:4%; padding-right:4%; padding-top:22px; padding-bottom:12px } div#content { padding: 20px 30px; } div.panel { border: 1px solid gray; background-color: #F6F6F6; margin: 1ex 0 3ex 0; padding: 1.2ex; } div.panel h2 { margin: 0; margin-bottom: 2ex; padding-bottom: 3px; border-bottom: 1px dashed black; font-size: 14pt; font-weight: normal; } dl { margin-left: 3ex; } dt { font-style: italic; } dd { margin-bottom: 1ex; } div.code { margin: 1ex 3ex 2ex 3ex; padding: 3px; background-color: #FAFAFA; font-family: monospace; overflow: auto; } div.code span.comment { font-style: italic; color: #000066; } </style> </head> <body> <div id="header"> <div title="Millenia">SMF-Mx-Publisher CMS bridge</div> </div> <div id="content"> <div class="panel"> <h2 id="contents">Before you start</h2> Make sure you have both MXP-CMS and Simple Machines Forum (SMF) installed. Realize that SMF is not a component, but a stand-alone forum. The bridge will only integrate your SMF-forum with your mxpcms site.<br /> <b>Please do not remove any of the copyrights of your SMF-forum.</b><br /> <br /> Always <b>back up your database</b> and site prior to installations and test any additions you make to your site locally first and do NOT add anything to your live site unless tested thoroughly, extensively, securely and wisely! <br /> Make sure the following folders are writable (chmod 777) before installing the component: <br /> /includes<br /> /modules <br /> /includes <br /> /templates<br /> /admin </div> </div> <div id="content"> <div class="panel"> <h2 id="contents">Installing the SMF Bridge Component in MXP-CMS</h2> <b>Install unpacking the zip and running the MX-Publisher-IWizard.</b><br /><br /> Go to your mxpcms admin cpanel. Go to your Installer menu, and validate your "smf2" installation.<br /> ...<br /> </div> </div> <div id="content"> <div class="panel"> <h2 id="contents">Configuring the SMF Core Blocks in MXP-CMS</h2> <h2 id="contents"> <b>Change the values in the configuration via the mxpcms backend.</b><br /><br /> It is important you use the absolute path to your SMF installation. This tells mxpcms where SMF is, so if you get this wrong, mxpcms will not be able to find SMF.<br /><br /> If you don't know your SMF path, you can find it by following these instructions:<br /><br /> Go to your stand alone SMF forum. Make sure you are logged in as the administrator.<br /> Go to the SMF admin panel.<br /> Click on "Server Settings".<br /> Your path to SMF will be in the field labelled "SMF Directory". Copy it from here, and paste it into your bridge config.<br /> <br /> There are two formats to display your mxpcms/forum integration: </h2> <ul type="none" style="list-style-type: none;"> <li>» <b>Wrapped</b><br /> You are using SMF through the mxpcms bridge. The Forum appears "wrapped" in the mxpcms tables. You might have to make some necessery changes in your theme and template files in order to show a fitting lay-out.</li> <li>» <b>Unwrapped</b><br /> You are still using SMF through mxpcms, but it doesn't have the look of a wrapped forum. It looks stand-alone, but it is actually loading through mxpcms. This is set in the mxpcms config for the component. </ul> <br /> There are several options for the user registration form: Bridge, SMF, mxpcms default, Community Builder, and mxpcmsCharge. The bridge registration form looks very much like the default mxpcms registration, but functions quite differently. If you choose to use this option, make sure to configure the registration component as well. All registration types will register new users into both mxpcms and SMF, but some users may not appear in SMF until after their first login. <br /><br /> </div> </div> <div id="content"> <div class="panel"> <h2 id="contents">Login Module Options in MXP-CMS</h2> MXP-CMS 4.6 provides a new alternative authentication method, which facilitates the use of the mxpcms default login module with the bridge.<br /> If you wish to use the mxpcms default login module with the bridge, all you need to do is make sure that the SMF_login mxpcmst is published.<br /> Despite the fact that if you choose to use the default mxpcms login module, you should still configure the mod_smf_login module. Some of the options applied in the module's configuration are used elsewhere.<br /> </div> </div> <div id="content"> <div class="panel"> <h2 id="contents">Separate Databases:</h2> If you have installed mxpcms and SMF with Fantastico, or you installed them in separate databases intentionally, you will need to grant permission to the database users to access each others' databases. If you have your forum and CMS installed in separate databases, and you have not granted access properly, you will most likely run into the "_LOGIN_INCOMPLETE" error in mxpcms. <br /><br /> Here's how to grant database permissions: <br /><br /> 1) Go to your site's cPanel. Click on MySQL databases. (Do not Proceed to PhpMyAdmin!) <br /><br /> 2) Near the bottom of the page, you will find two dropdown menus side-by-side. One is labelled "User:" and the other "Db:". <br /><br /> 3) In the first dropdown, select your SMF database user, and in the second dropdown, select the mxpcms database. Click the button that is labelled "Add User to Db". <br /><br /> 4) Now go back to the same page again, and do the same, adding your mxpcms User to your SMF database. <br /><br /> Now you are set up to run your forum and CMS in separate databases. <br /><br /> </div> </div> <div id="content"> <div class="panel"> <h2 id="contents">3rd Party Developer Tabs in Admin Panel</h2> This bridge comes with the capability for 3rd party developers to add their own tabs to the bridge config panel. This can be done by adding a tab file to include by the bridge, and defining it in the bridge config table appropriately. For example, if you have a component called com_example, and you want to have a tab in the bridge define something in the com_example component, you can create the tab in a file called example_tab.php. You'll need to add that file to your com_example.xml installer, and also a query to let the bridge config know it's there: <div class="code"> INSERT INTO #__smf_config (`variable`, `value1`) VALUES ('3rdPartyTab', 'administrator/components/com_example/example_tab.php') </div> And that's all! It will be included in the SMF bridge component configuration. </div> </div> </body> </html> --- NEW FILE: auth.php --- <?php /** * * @package Auth * @version $Id: auth.php,v 1.1 2014/05/18 06:26:59 orynider Exp $ * @copyright (c) 2002-2008 MX-Publisher Project Team * @license http://opensource.org/licenses/gpl-license.php GNU General Public License v2 * @link http://mxpcms.sourceforge.net/ * */ if ( !defined( 'IN_PORTAL' ) ) { die( "Hacking attempt" ); } /** * Permission/Auth class for SMF3 forums [...961 lines suppressed...] $sql = array(); foreach ($auth_options as $option) { if (strpos($option, '%') !== false) { $sql[] = $key . ' ' . $db->sql_like_expression(str_replace('%', $db->any_char, $option)); } else { $sql[] = $key . " = '" . $db->sql_escape($option) . "'"; } } $sql_opts = 'AND (' . implode(' OR ', $sql) . ')'; } } } } ?> |