|
From: Jon O. <jon...@us...> - 2008-07-12 20:24:22
|
Update of /cvsroot/mxbb/core/includes/sessions/phpbb3 In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv21282/sessions/phpbb3 Modified Files: core.php Log Message: Removed mx_functions_phpbb.php -> backend loaded. Index: core.php =================================================================== RCS file: /cvsroot/mxbb/core/includes/sessions/phpbb3/core.php,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** core.php 11 Jul 2008 23:03:30 -0000 1.5 --- core.php 12 Jul 2008 20:24:17 -0000 1.6 *************** *** 82,85 **** --- 82,152 ---- return $auth_data_sql; } + + /** + * function mx_acl_getfignore() + * $auth_level_read can be a value or array; + * $ignore_forum_ids can have this sintax: forum_id(1), forum_id(2), ..., forum_is(n); + * 1st test 25.06.2008 by FlorinCB + */ + function mx_acl_getfignore($auth_level_read, $ignore_forum_ids) + { + global $phpbb_root_path, $mx_user; + + $ignore_forum_ids = ($ignore_forum_ids) ? $ignore_forum_ids : ''; + + $auth_user = array(); + + if (is_array($auth_level_read)) + { + foreach ($auth_level_read as $auth_level) + { + $auth_user = $this->acl_getf('!' . $auth_level, true); + + if ($num_forums = count($auth_user)) + { + while ( list($forum_id, $auth_mod) = each($auth_user) ) + { + $unauthed = false; + + if (!$auth_mod[$auth_level] && ( strstr($ignore_forum_ids,$auth_mod['forum_id']) === FALSE)) + { + $unauthed = true; + } + + if ($unauthed) + { + $ignore_forum_ids .= ($ignore_forum_ids) ? ',' . $forum_id : $forum_id; + } + } + } + unset($auth_level_read); + } + } + elseif ($auth_level_read) + { + $auth_user = $this->acl_getf('!' . $auth_level_read, true); + + if ($num_forums = count($auth_user)) + { + while ( list($forum_id, $auth_mod) = each($auth_user) ) + { + $unauthed = false; + + if (!$auth_mod[$auth_level] && ( strstr($ignore_forum_ids,$auth_mod['forum_id']) === FALSE)) + { + $unauthed = true; + } + + if ($unauthed) + { + $ignore_forum_ids .= ($ignore_forum_ids) ? ',' . $forum_id : $forum_id; + } + } + } + + } + $ignore_forum_ids = ($ignore_forum_ids) ? $ignore_forum_ids : 0; + return $ignore_forum_ids; + } } *************** *** 294,303 **** /** ! * _load_file * * @param unknown_type $force_shared * @access private */ ! function _load_file($force_shared) { global $mx_root_path, $phpbb_root_path, $phpEx; --- 361,370 ---- /** ! * load_file * * @param unknown_type $force_shared * @access private */ ! function load_file($force_shared) { global $mx_root_path, $phpbb_root_path, $phpEx; *************** *** 325,328 **** --- 392,528 ---- /** + * dss_rand + * + * @param unknown_type $force_shared + * @access private + */ + function dss_rand($force_shared) + { + global $db, $portal_config, $board_config, $dss_seeded; + + $val = $board_config['rand_seed'] . microtime(); + $val = md5($val); + $board_config['rand_seed'] = md5($board_config['rand_seed'] . $val . 'a'); + + if($dss_seeded !== true) + { + $sql = "UPDATE " . CONFIG_TABLE . " SET + config_value = '" . $board_config['rand_seed'] . "' + WHERE config_name = 'rand_seed'"; + + if( !$db->sql_query($sql) ) + { + mx_message_die(GENERAL_ERROR, "Unable to reseed PRNG", "", __LINE__, __FILE__, $sql); + } + + $dss_seeded = true; + } + + return substr($val, 4, 16); + } + + function make_jumpbox($action, $match_forum_id = 0) + { + global $template, $userdata, $lang, $db, $nav_links, $phpEx, $SID; + + $sql = 'SELECT forum_id, forum_name, parent_id, forum_type, left_id, right_id + FROM ' . FORUMS_TABLE . ' + ORDER BY left_id ASC'; + $result = $db->sql_query($sql, 600); + + $right = $padding = 0; + $padding_store = array('0' => 0); + $display_jumpbox = false; + $iteration = 0; + + // Sometimes it could happen that forums will be displayed here not be displayed within the index page + // This is the result of forums not displayed at index, having list permissions and a parent of a forum with no permissions. + // If this happens, the padding could be "broken" + + $forum_rows = array(); + while ($row = $db->sql_fetchrow($result)) + { + $forum_rows[] = $row; + + if ($forum_rows['left_id'] < $right) + { + $padding++; + $padding_store[$row['parent_id']] = $padding; + } + else if ($row['left_id'] > $right + 1) + { + // Ok, if the $padding_store for this parent is empty there is something wrong. For now we will skip over it. + // @todo digging deep to find out "how" this can happen. + $padding = (isset($padding_store[$row['parent_id']])) ? $padding_store[$row['parent_id']] : $padding; + } + + $right = $forum_rows['right_id']; + + if ($forum_rows['forum_type'] == FORUM_CAT && ($forum_rows['left_id'] + 1 == $forum_rows['right_id'])) + { + // Non-postable forum with no subforums, don't display + continue; + } + + if ( $total_forums = count($forum_rows) ) + { + for($i = 0; $i < $total_categories; $i++) + { + $boxstring_forums = ''; + for($j = 0; $j < $total_forums; $j++) + { + $selected = ( $forum_rows[$j]['forum_id'] == $match_forum_id ) ? 'selected="selected"' : ''; + $boxstring_forums .= '<option value="' . $forum_rows[$j]['forum_id'] . '"' . $selected . '>' . $forum_rows[$j]['forum_name'] . '</option>'; + + // + // Add an array to $nav_links for the Mozilla navigation bar. + // 'chapter' and 'forum' can create multiple items, therefore we are using a nested array. + // + $nav_links['chapter forum'][$forum_rows[$j]['forum_id']] = array ( + 'url' => mx_append_sid(PHPBB_URL . "viewforum.$phpEx?" . POST_FORUM_URL . "=" . $forum_rows[$j]['forum_id']), + 'title' => $forum_rows[$j]['forum_name'] + ); + + } + + if ( $boxstring_forums != '' ) + { + $boxstring .= '<option value="-1"> </option>'; + $boxstring .= '<option value="-1">' . $forum_rows[$i]['forum_type'] == FORUM_CAT . '</option>'; + $boxstring .= '<option value="-1">----------------</option>'; + $boxstring .= $boxstring_forums; + } + } + } + + $boxstring .= '</select>'; + } + + // Let the jumpbox work again in sites having additional session id checks. + // if ( !empty($SID) ) + // { + $boxstring .= '<input type="hidden" name="sid" value="' . $userdata['session_id'] . '" />'; + // } + + $template->set_filenames(array( + 'jumpbox' => 'jumpbox.tpl') + ); + + $template->assign_vars(array( + 'L_GO' => $lang['Go'], + 'L_JUMP_TO' => $lang['Jump_to'], + 'L_SELECT_FORUM' => $lang['Select_forum'], + + 'S_JUMPBOX_SELECT' => $boxstring, + 'S_JUMPBOX_ACTION' => mx_append_sid($action), + 'S_FORUM_COUNT' => $j) + ); + + $template->assign_var_from_handle('JUMPBOX', 'jumpbox'); + + return; + } + + /** * Backend specific Page Header data * *************** *** 604,606 **** --- 804,1101 ---- } } + + /** + * 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 $phpbb_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("{$phpbb_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; + } + } + + /** + * For display of custom parsed text on user-facing pages + * Expects $text to be the value directly from the database (stored value) + */ + function mx_generate_text_for_display($text, $uid, $bitfield, $flags) + { + static $bbcode; + + if (!$text) + { + return ''; + } + + $text = phpbb3::censor_text($text); + + // Parse bbcode if bbcode uid stored and bbcode enabled + if ($uid && ($flags & OPTION_FLAG_BBCODE)) + { + if (!class_exists('bbcode')) + { + global $phpbb_root_path, $phpEx; + mx_cache::load_file('bbcode', 'phpbb3'); + } + + if (empty($bbcode)) + { + $bbcode = new bbcode($bitfield); + } + else + { + $bbcode->bbcode($bitfield); + } + + $bbcode->bbcode_second_pass($text, $uid); + } + + $text = str_replace("\n", '<br />', $text); + + $text = mx_smilies_pass($text, !($flags & OPTION_FLAG_SMILIES)); + + return $text; + } ?> \ No newline at end of file |