Simple Machines Community Forum

SMF Support => Language Specific Support => Hilfe zu SMF (German) => Aiheen aloitti: kleinerpyromane - joulukuu 01, 2006, 01:37:59 IP

Otsikko: Merkwürdiger ellenlanger code über dem forum
Kirjoitti: kleinerpyromane - joulukuu 01, 2006, 01:37:59 IP
Hallo ich bin neu hier und habe grade mal testweise die RC3 vom SMF auf meinem Vserver installiert. Installation hat ohne probleme geklappt nun habe ich aber nach der installation folgenden code sichtbar direkt über dem forum und weiß nich wie ich ihn weg bekomme :-( ich hoffe mir kann jmd helfen warscheinlich seh ich nur wieder den wald vor bäumen nicht *g

Hier ist der Code


db_prefix, $modSettings, $board_info; // Can't just look for no users :P. if (empty($users)) return false; // Make sure it's an array. $users = !is_array($users) ? array($users) : array_unique($users); $loaded_ids = array(); if (!$is_name && !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] == 3) { $users = array_values($users); for ($i = 0, $n = count($users); $i < $n; $i++) { $data = cache_get_data('member_data-' . $set . '-' . $users[$i], 240); if ($data == null) continue; $loaded_ids[] = $data['ID_MEMBER']; $user_profile[$data['ID_MEMBER']] = $data; unset($users[$i]); } } if ($set == 'normal') { $select_columns = " IFNULL(lo.logTime, 0) AS isOnline, IFNULL(a.ID_ATTACH, 0) AS ID_ATTACH, a.filename, a.attachmentType, mem.signature, mem.personalText, mem.location, mem.gender, mem.avatar, mem.ID_MEMBER, mem.memberName, mem.realName, mem.emailAddress, mem.hideEmail, mem.dateRegistered, mem.websiteTitle, mem.websiteUrl, mem.birthdate, mem.memberIP, mem.memberIP2, mem.ICQ, mem.AIM, mem.YIM, mem.MSN, mem.posts, mem.lastLogin, mem.karmaGood, mem.ID_POST_GROUP, mem.karmaBad, mem.lngfile, mem.ID_GROUP, mem.timeOffset, mem.showOnline, mem.buddy_list, mg.onlineColor AS member_group_color, IFNULL(mg.groupName, '') AS member_group, pg.onlineColor AS post_group_color, IFNULL(pg.groupName, '') AS post_group, mem.is_activated, IF(mem.ID_GROUP = 0 OR mg.stars = '', pg.stars, mg.stars) AS stars" . (!empty($modSettings['titlesEnable']) ? ', mem.usertitle' : ''); $select_tables = " LEFT JOIN {$db_prefix}log_online AS lo ON (lo.ID_MEMBER = mem.ID_MEMBER) LEFT JOIN {$db_prefix}attachments AS a ON (a.ID_MEMBER = mem.ID_MEMBER) LEFT JOIN {$db_prefix}membergroups AS pg ON (pg.ID_GROUP = mem.ID_POST_GROUP) LEFT JOIN {$db_prefix}membergroups AS mg ON (mg.ID_GROUP = mem.ID_GROUP)"; } elseif ($set == 'profile') { $select_columns = " IFNULL(lo.logTime, 0) AS isOnline, IFNULL(a.ID_ATTACH, 0) AS ID_ATTACH, a.filename, a.attachmentType, mem.signature, mem.personalText, mem.location, mem.gender, mem.avatar, mem.ID_MEMBER, mem.memberName, mem.realName, mem.emailAddress, mem.hideEmail, mem.dateRegistered, mem.websiteTitle, mem.websiteUrl, mem.birthdate, mem.ICQ, mem.AIM, mem.YIM, mem.MSN, mem.posts, mem.lastLogin, mem.karmaGood, mem.karmaBad, mem.memberIP, mem.memberIP2, mem.lngfile, mem.ID_GROUP, mem.ID_THEME, mem.buddy_list, mem.pm_ignore_list, mem.pm_email_notify, mem.timeOffset" . (!empty($modSettings['titlesEnable']) ? ', mem.usertitle' : '') . ", mem.timeFormat, mem.secretQuestion, mem.is_activated, mem.additionalGroups, mem.smileySet, mem.showOnline, mem.totalTimeLoggedIn, mem.ID_POST_GROUP, mem.notifyAnnouncements, mem.notifyOnce, mem.notifySendBody, mem.notifyTypes, lo.url, mg.onlineColor AS member_group_color, IFNULL(mg.groupName, '') AS member_group, pg.onlineColor AS post_group_color, IFNULL(pg.groupName, '') AS post_group, IF(mem.ID_GROUP = 0 OR mg.stars = '', pg.stars, mg.stars) AS stars, mem.passwordSalt"; $select_tables = " LEFT JOIN {$db_prefix}log_online AS lo ON (lo.ID_MEMBER = mem.ID_MEMBER) LEFT JOIN {$db_prefix}attachments AS a ON (a.ID_MEMBER = mem.ID_MEMBER) LEFT JOIN {$db_prefix}membergroups AS pg ON (pg.ID_GROUP = mem.ID_POST_GROUP) LEFT JOIN {$db_prefix}membergroups AS mg ON (mg.ID_GROUP = mem.ID_GROUP)"; } elseif ($set == 'minimal') { $select_columns = ' mem.ID_MEMBER, mem.memberName, mem.realName, mem.emailAddress, mem.hideEmail, mem.dateRegistered, mem.posts, mem.lastLogin, mem.memberIP, mem.memberIP2, mem.lngfile, mem.ID_GROUP'; $select_tables = ''; } else trigger_error('loadMemberData(): Invalid member data set \'' . $set . '\'', E_USER_WARNING); if (!empty($users)) { // Load the member's data. $request = db_query(" SELECT$select_columns FROM {$db_prefix}members AS mem$select_tables WHERE mem." . ($is_name ? 'memberName' : 'ID_MEMBER') . (count($users) == 1 ? " = '" . current($users) . "'" : " IN ('" . implode("', '", $users) . "')"), __FILE__, __LINE__); $new_loaded_ids = array(); while ($row = mysql_fetch_assoc($request)) { $new_loaded_ids[] = $row['ID_MEMBER']; $loaded_ids[] = $row['ID_MEMBER']; $row['options'] = array(); $user_profile[$row['ID_MEMBER']] = $row; } mysql_free_result($request); } if (!empty($new_loaded_ids) && $set !== 'minimal') { $request = db_query(" SELECT * FROM {$db_prefix}themes WHERE ID_MEMBER" . (count($new_loaded_ids) == 1 ? ' = ' . $new_loaded_ids[0] : ' IN (' . implode(', ', $new_loaded_ids) . ')'), __FILE__, __LINE__); while ($row = mysql_fetch_assoc($request)) $user_profile[$row['ID_MEMBER']]['options'][$row['variable']] = $row['value']; mysql_free_result($request); } if (!empty($new_loaded_ids) && !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] == 3) { for ($i = 0, $n = count($new_loaded_ids); $i < $n; $i++) cache_put_data('member_data-' . $set . '-' . $new_loaded_ids[$i], $user_profile[$new_loaded_ids[$i]], 240); } // Are we loading any moderators? If so, fix their group data... if (!empty($loaded_ids) && !empty($board_info['moderators']) && $set === 'normal' && count($temp_mods = array_intersect($loaded_ids, array_keys($board_info['moderators']))) !== 0) { if (($row = cache_get_data('moderator_group_info', 480)) == null) { $request = db_query(" SELECT groupName AS member_group, onlineColor AS member_group_color, stars FROM {$db_prefix}membergroups WHERE ID_GROUP = 3 LIMIT 1", __FILE__, __LINE__); $row = mysql_fetch_assoc($request); mysql_free_result($request); cache_put_data('moderator_group_info', $row, 480); } foreach ($temp_mods as $id) { // By popular demand, don't show admins or global moderators as moderators. if ($user_profile[$id]['ID_GROUP'] != 1 && $user_profile[$id]['ID_GROUP'] != 2) $user_profile[$id]['member_group'] = $row['member_group']; // If the Moderator group has no color or stars, but their group does... don't overwrite. if (!empty($row['stars'])) $user_profile[$id]['stars'] = $row['stars']; if (!empty($row['member_group_color'])) $user_profile[$id]['member_group_color'] = $row['member_group_color']; } } return empty($loaded_ids) ? false : $loaded_ids; } // Loads the user's basic values... meant for template/theme usage. function loadMemberContext($user) { global $memberContext, $user_profile, $txt, $scripturl, $user_info; global $context, $modSettings, $ID_MEMBER, $board_info, $settings; global $db_prefix, $func; static $dataLoaded = array(); // If this person's data is already loaded, skip it. if (isset($dataLoaded[$user])) return true; // We can't load guests or members not loaded by loadMemberData()! if ($user == 0) return false; if (!isset($user_profile[$user])) { trigger_error('loadMemberContext(): member id ' . $user . ' not previously loaded by loadMemberData()', E_USER_WARNING); return false; } // Well, it's loaded now anyhow. $dataLoaded[$user] = true; $profile = $user_profile[$user]; // Censor everything. censorText($profile['signature']); censorText($profile['personalText']); censorText($profile['location']); // Set things up to be used before hand. $gendertxt = $profile['gender'] == 2 ? $txt[239] : ($profile['gender'] == 1 ? $txt[238] : ''); $profile['signature'] = str_replace(array("\n", "\r"), array('
', ''), $profile['signature']); $profile['signature'] = parse_bbc($profile['signature'], true, 'sig' . $profile['ID_MEMBER']); $profile['is_online'] = (!empty($profile['showOnline']) || allowedTo('moderate_forum')) && $profile['isOnline'] > 0; $profile['stars'] = empty($profile['stars']) ? array('', '') : explode('#', $profile['stars']); // Setup the buddy status here (One whole in_array call saved :P) $profile['buddy'] = in_array($profile['ID_MEMBER'], $user_info['buddies']); $buddy_list = !empty($profile['buddy_list']) ? explode(',', $profile['buddy_list']) : array(); // If we're always html resizing, assume it's too large. if ($modSettings['avatar_action_too_large'] == 'option_html_resize' || $modSettings['avatar_action_too_large'] == 'option_js_resize') { $avatar_width = !empty($modSettings['avatar_max_width_external']) ? ' width="' . $modSettings['avatar_max_width_external'] . '"' : ''; $avatar_height = !empty($modSettings['avatar_max_height_external']) ? ' height="' . $modSettings['avatar_max_height_external'] . '"' : ''; } else { $avatar_width = ''; $avatar_height = ''; } // What a monstrous array... $memberContext[$user] = array( 'username' => &$profile['memberName'], 'name' => &$profile['realName'], 'id' => &$profile['ID_MEMBER'], 'is_guest' => $profile['ID_MEMBER'] == 0, 'is_buddy' => $profile['buddy'], 'is_reverse_buddy' => in_array($ID_MEMBER, $buddy_list), 'buddies' => $buddy_list, 'title' => !empty($modSettings['titlesEnable']) ? $profile['usertitle'] : '', 'href' => $scripturl . '?action=profile;u=' . $profile['ID_MEMBER'], 'link' => '' . $profile['realName'] . '', 'email' => &$profile['emailAddress'], 'hide_email' => $profile['emailAddress'] == '' || (!empty($modSettings['guest_hideContacts']) && $user_info['is_guest']) || (!empty($profile['hideEmail']) && !empty($modSettings['allow_hideEmail']) && !allowedTo('moderate_forum') && $ID_MEMBER != $profile['ID_MEMBER']), 'email_public' => (empty($profile['hideEmail']) || empty($modSettings['allow_hideEmail'])) && (empty($modSettings['guest_hideContacts']) || !$user_info['is_guest']), 'registered' => empty($profile['dateRegistered']) ? $txt[470] : timeformat($profile['dateRegistered']), 'registered_timestamp' => empty($profile['dateRegistered']) ? 0 : forum_time(true, $profile['dateRegistered']), 'blurb' => &$profile['personalText'], 'gender' => array( 'name' => $gendertxt, 'image' => !empty($profile['gender']) ? '' . $gendertxt . '' : '' ), 'website' => array( 'title' => &$profile['websiteTitle'], 'url' => &$profile['websiteUrl'], ), 'birth_date' => empty($profile['birthdate']) || $profile['birthdate'] === '0001-01-01' ? '0000-00-00' : (substr($profile['birthdate'], 0, 4) === '0004' ? '0000' . substr($profile['birthdate'], 4) : $profile['birthdate']), 'signature' => &$profile['signature'], 'location' => &$profile['location'], 'icq' => $profile['ICQ'] != '' && (empty($modSettings['guest_hideContacts']) || !$user_info['is_guest']) ? array( 'name' => &$profile['ICQ'], 'href' => 'http://www.icq.com/whitepages/about_me.php?uin=' . $profile['ICQ'], 'link' => '' . $profile['ICQ'] . '', 'link_text' => '' . $profile['ICQ'] . '', ) : array('name' => '', 'add' => '', 'href' => '', 'link' => '', 'link_text' => ''), 'aim' => $profile['AIM'] != '' && (empty($modSettings['guest_hideContacts']) || !$user_info['is_guest']) ? array( 'name' => &$profile['AIM'], 'href' => 'aim:goim?screenname=' . urlencode(strtr($profile['AIM'], array(' ' => '%20'))) . '&message=' . $txt['aim_default_message'], 'link' => '' . $profile['AIM'] . '', 'link_text' => '' . $profile['AIM'] . '' ) : array('name' => '', 'href' => '', 'link' => '', 'link_text' => ''), 'yim' => $profile['YIM'] != '' && (empty($modSettings['guest_hideContacts']) || !$user_info['is_guest']) ? array( 'name' => &$profile['YIM'], 'href' => 'http://edit.yahoo.com/config/send_webmesg?.target=' . urlencode($profile['YIM']), 'link' => '' . $profile['YIM'] . '', 'link_text' => '' . $profile['YIM'] . '' ) : array('name' => '', 'href' => '', 'link' => '', 'link_text' => ''), 'msn' => $profile['MSN'] !='' && (empty($modSettings['guest_hideContacts']) || !$user_info['is_guest']) ? array( 'name' => &$profile['MSN'], 'href' => 'http://members.msn.com/' . $profile['MSN'], 'link' => '' . $profile['MSN'] . '', 'link_text' => '' . $profile['MSN'] . '' ) : array('name' => '', 'href' => '', 'link' => '', 'link_text' => ''), 'real_posts' => $profile['posts'], 'posts' => $profile['posts'] > 100000 ? $txt[683] : ($profile['posts'] == 1337 ? 'leet' : comma_format($profile['posts'])), 'avatar' => array( 'name' => &$profile['avatar'], 'image' => $profile['avatar'] == '' ? ($profile['ID_ATTACH'] > 0 ? '' : '') : (stristr($profile['avatar'], 'http://') ? '' : ''), 'href' => $profile['avatar'] == '' ? ($profile['ID_ATTACH'] > 0 ? (empty($profile['attachmentType']) ? $scripturl . '?action=dlattach;attach=' . $profile['ID_ATTACH'] . ';type=avatar' : $modSettings['custom_avatar_url'] . '/' . $profile['filename']) : '') : (stristr($profile['avatar'], 'http://') ? $profile['avatar'] : $modSettings['avatar_url'] . '/' . $profile['avatar']), 'url' => $profile['avatar'] == '' ? '' : (stristr($profile['avatar'], 'http://') ? $profile['avatar'] : $modSettings['avatar_url'] . '/' . $profile['avatar']) ), 'last_login' => empty($profile['lastLogin']) ? $txt['never'] : timeformat($profile['lastLogin']), 'last_login_timestamp' => empty($profile['lastLogin']) ? 0 : forum_time(0, $profile['lastLogin']), 'karma' => array( 'good' => &$profile['karmaGood'], 'bad' => &$profile['karmaBad'], 'allow' => !$user_info['is_guest'] && $user_info['posts'] >= $modSettings['karmaMinPosts'] && allowedTo('karma_edit') && !empty($modSettings['karmaMode']) && $ID_MEMBER != $user ), 'ip' => htmlspecialchars($profile['memberIP']), 'ip2' => htmlspecialchars($profile['memberIP2']), 'online' => array( 'is_online' => $profile['is_online'], 'text' => &$txt[$profile['is_online'] ? 'online2' : 'online3'], 'href' => $scripturl . '?action=pm;sa=send;u=' . $profile['ID_MEMBER'], 'link' => '' . $txt[$profile['is_online'] ? 'online2' : 'online3'] . '', 'image_href' => $settings['images_url'] . '/' . ($profile['buddy'] ? 'buddy_' : '') . ($profile['is_online'] ? 'useron' : 'useroff') . '.gif', 'label' => &$txt[$profile['is_online'] ? 'online4' : 'online5'] ), 'language' => $func['ucwords'](strtr($profile['lngfile'], array('_' => ' ', '-utf8' => ''))), 'is_activated' => isset($profile['is_activated']) ? $profile['is_activated'] : 1, 'is_banned' => isset($profile['is_activated']) ? $profile['is_activated'] >= 10 : 0, 'options' => $profile['options'], 'is_guest' => false, 'group' => $profile['member_group'], 'group_color' => $profile['member_group_color'], 'group_id' => $profile['ID_GROUP'], 'post_group' => $profile['post_group'], 'post_group_color' => $profile['post_group_color'], 'group_stars' => str_repeat('*', empty($profile['stars'][0]) || empty($profile['stars'][1]) ? 0 : $profile['stars'][0]), 'local_time' => timeformat(time() + ($profile['timeOffset'] - $user_info['time_offset']) * 3600, false), ); return true; } // Load a theme, by ID. function loadTheme($ID_THEME = 0, $initialize = true) { global $ID_MEMBER, $user_info, $board_info, $sc; global $db_prefix, $txt, $boardurl, $scripturl, $mbname, $modSettings; global $context, $settings, $options; // The theme was specified by parameter. if (!empty($ID_THEME)) $ID_THEME = (int) $ID_THEME; // Use the board's specific theme. elseif (!empty($board_info['theme']) && $board_info['override_theme']) $ID_THEME = $board_info['theme']; // The theme was specified by REQUEST. elseif (!empty($_REQUEST['theme']) && (!empty($modSettings['theme_allow']) || allowedTo('admin_forum'))) { $ID_THEME = (int) $_REQUEST['theme']; $_SESSION['ID_THEME'] = $ID_THEME; } // The theme was specified by REQUEST... previously. elseif (!empty($_SESSION['ID_THEME']) && (!empty($modSettings['theme_allow']) || allowedTo('admin_forum'))) $ID_THEME = (int) $_SESSION['ID_THEME']; // The theme is just the user's choice. (might use ?board=1;theme=0 to force board theme.) elseif (!empty($user_info['theme']) && !isset($_REQUEST['theme']) && (!empty($modSettings['theme_allow']) || allowedTo('admin_forum'))) $ID_THEME = $user_info['theme']; // The theme was specified by the board. elseif (!empty($board_info['theme'])) $ID_THEME = $board_info['theme']; // The theme is the forum's default. else $ID_THEME = $modSettings['theme_guests']; // Verify the ID_THEME... no foul play. if (empty($modSettings['theme_default']) && $ID_THEME == 1 && !allowedTo('admin_forum')) $ID_THEME = $modSettings['theme_guests']; elseif (!empty($modSettings['knownThemes']) && !empty($modSettings['theme_allow']) && !allowedTo('admin_forum')) { $themes = explode(',', $modSettings['knownThemes']); if (!in_array($ID_THEME, $themes)) $ID_THEME = $modSettings['theme_guests']; else $ID_THEME = (int) $ID_THEME; } else $ID_THEME = (int) $ID_THEME; $member = empty($ID_MEMBER) ? -1 : $ID_MEMBER; if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2 && ($temp = cache_get_data('theme_settings-' . $ID_THEME . ':' . $member, 60)) != null) { $themeData = $temp; $flag = true; } elseif (($temp = cache_get_data('theme_settings-' . $ID_THEME, 90)) != null) $themeData = $temp + array($member => array()); else $themeData = array(-1 => array(), 0 => array(), $member => array()); if (empty($flag)) { // Load variables from the current or default theme, global or this user's. $result = db_query(" SELECT variable, value, ID_MEMBER, ID_THEME FROM {$db_prefix}themes WHERE ID_MEMBER" . (empty($themeData[0]) ? " IN (-1, 0, $member)" : " = $member") . " AND ID_THEME" . ($ID_THEME == 1 ? ' = 1' : " IN ($ID_THEME, 1)"), __FILE__, __LINE__); // Pick between $settings and $options depending on whose data it is. while ($row = mysql_fetch_assoc($result)) { // If this is the theme_dir of the default theme, store it. if (in_array($row['variable'], array('theme_dir', 'theme_url', 'images_url')) && $row['ID_THEME'] == '1' && empty($row['ID_MEMBER'])) $themeData[0]['default_' . $row['variable']] = $row['value']; // If this isn't set yet, is a theme option, or is not the default theme.. if (!isset($themeData[$row['ID_MEMBER']][$row['variable']]) || $row['ID_THEME'] != '1') $themeData[$row['ID_MEMBER']][$row['variable']] = substr($row['variable'], 0, 5) == 'show_' ? $row['value'] == '1' : $row['value']; } mysql_free_result($result); if (!empty($themeData[-1])) foreach ($themeData[-1] as $k => $v) { if (!isset($themeData[$member][$k])) $themeData[$member][$k] = $v; } if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) cache_put_data('theme_settings-' . $ID_THEME . ':' . $member, $themeData, 60); // Only if we didn't already load that part of the cache... elseif (!isset($temp)) cache_put_data('theme_settings-' . $ID_THEME, array(-1 => $themeData[-1], 0 => $themeData[0]), 90); } $settings = $themeData[0]; $options = $themeData[$member]; $settings['theme_id'] = $ID_THEME; $settings['actual_theme_url'] = $settings['theme_url']; $settings['actual_images_url'] = $settings['images_url']; $settings['actual_theme_dir'] = $settings['theme_dir']; if (!$initialize) return; // Check to see if they're accessing it from the wrong place. if (isset($_SERVER['HTTP_HOST']) || isset($_SERVER['SERVER_NAME'])) { $detected_url = isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on' ? 'https://' : 'http://'; $detected_url .= empty($_SERVER['HTTP_HOST']) ? $_SERVER['SERVER_NAME'] . (empty($_SERVER['SERVER_PORT']) || $_SERVER['SERVER_PORT'] == '80' ? '' : ':' . $_SERVER['SERVER_PORT']) : $_SERVER['HTTP_HOST']; $temp = preg_replace('~/' . basename($scripturl) . '(/.+)?$~', '', strtr(dirname($_SERVER['PHP_SELF']), '\\', '/')); if ($temp != '/') $detected_url .= $temp; } if (isset($detected_url) && $detected_url != $boardurl) { // Try #1 - check if it's in a list of alias addresses. if (!empty($modSettings['forum_alias_urls'])) { $aliases = explode(',', $modSettings['forum_alias_urls']); foreach ($aliases as $alias) { // Rip off all the boring parts, spaces, etc. if ($detected_url == trim($alias) || strtr($detected_url, array('http://' => '', 'https://' => '')) == trim($alias)) $do_fix = true; } } // Hmm... check #2 - is it just different by a www? Send them to the correct place!! if (empty($do_fix) && strtr($detected_url, array('://' => '://www.')) == $boardurl && (empty($_GET) || count($_GET) == 1)) { // Okay, this seems weird, but we don't want an endless loop - this will make $_GET not empty ;). if (empty($_GET)) redirectexit('www'); else { list ($k, $v) = each($_GET); if ($k != 'www') redirectexit('www;' . $k . '=' . $v); } } // #3 is just a check for SSL... if (strtr($detected_url, array('https://' => 'http://')) == $boardurl) $do_fix = true; // Okay, #4 - perhaps it's an IP address? We're gonna want to use that one, then. (assuming it's the IP or something...) if (!empty($do_fix) || preg_match('~^http[s]://[\d\.:]+($|/)~', $detected_url) == 1) { // Caching is good ;). $oldurl = $boardurl; // Fix $boardurl and $scripturl. $boardurl = $detected_url; $scripturl = strtr($scripturl, array($oldurl => $boardurl)); $_SERVER['REQUEST_URL'] = strtr($_SERVER['REQUEST_URL'], array($oldurl => $boardurl)); // Fix the theme urls... $settings['theme_url'] = strtr($settings['theme_url'], array($oldurl => $boardurl)); $settings['default_theme_url'] = strtr($settings['default_theme_url'], array($oldurl => $boardurl)); $settings['actual_theme_url'] = strtr($settings['actual_theme_url'], array($oldurl => $boardurl)); $settings['images_url'] = strtr($settings['images_url'], array($oldurl => $boardurl)); $settings['default_images_url'] = strtr($settings['default_images_url'], array($oldurl => $boardurl)); $settings['actual_images_url'] = strtr($settings['actual_images_url'], array($oldurl => $boardurl)); // And just a few mod settings :). $modSettings['smileys_url'] = strtr($modSettings['smileys_url'], array($oldurl => $boardurl)); $modSettings['avatar_url'] = strtr($modSettings['avatar_url'], array($oldurl => $boardurl)); // Clean up after loadBoard(). foreach ($board_info['moderators'] as $k => $dummy) { $board_info['moderators'][$k]['href'] = strtr($dummy['href'], array($oldurl => $boardurl));; $board_info['moderators'][$k]['link'] = strtr($dummy['link'], array('"' . $oldurl => '"' . $boardurl));; } foreach ($context['linktree'] as $k => $dummy) $context['linktree'][$k]['url'] = strtr($dummy['url'], array($oldurl => $boardurl)); } } // Set up the contextual user array. $context['user'] = array( 'id' => &$ID_MEMBER, 'is_logged' => !$user_info['is_guest'], 'is_guest' => &$user_info['is_guest'], 'is_admin' => &$user_info['is_admin'], 'is_mod' => false, 'username' => &$user_info['username'], 'language' => &$user_info['language'], 'email' => &$user_info['email'] ); if ($context['user']['is_guest']) $context['user']['name'] = &$txt[28]; else $context['user']['name'] = &$user_info['name']; // Determine the current smiley set. $user_info['smiley_set'] = (!in_array($user_info['smiley_set'], explode(',', $modSettings['smiley_sets_known'])) && $user_info['smiley_set'] != 'none') || empty($modSettings['smiley_sets_enable']) ? (!empty($settings['smiley_sets_default']) ? $settings['smiley_sets_default'] : $modSettings['smiley_sets_default']) : $user_info['smiley_set']; $context['user']['smiley_set'] = &$user_info['smiley_set']; // Some basic information... if (!isset($context['html_headers'])) $context['html_headers'] = ''; $context['menu_separator'] = !empty($settings['use_image_buttons']) ? ' ' : ' | '; $context['session_id'] = &$sc; $context['forum_name'] = &$mbname; $context['current_action'] = isset($_REQUEST['action']) ? $_REQUEST['action'] : null; $context['current_subaction'] = isset($_REQUEST['sa']) ? $_REQUEST['sa'] : null; if (isset($modSettings['load_average'])) $context['load_average'] = $modSettings['load_average']; // This determines the server... not used in many places, except for login fixing. $context['server'] = array( 'is_iis' => isset($_SERVER['SERVER_SOFTWARE']) && strpos($_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS') !== false, 'is_apache' => isset($_SERVER['SERVER_SOFTWARE']) && strpos($_SERVER['SERVER_SOFTWARE'], 'Apache') !== false, 'is_cgi' => isset($_SERVER['SERVER_SOFTWARE']) && strpos(php_sapi_name(), 'cgi') !== false, ); // A bug in some versions of IIS under CGI (older ones) makes cookie setting not work with Location: headers. $context['server']['needs_login_fix'] = $context['server']['is_cgi']; // The following determines the user agent (browser) as best it can. $context['browser'] = array( 'is_opera' => strpos($_SERVER['HTTP_USER_AGENT'], 'Opera') !== false, 'is_opera6' => strpos($_SERVER['HTTP_USER_AGENT'], 'Opera 6') !== false, 'is_opera7' => strpos($_SERVER['HTTP_USER_AGENT'], 'Opera 7') !== false || strpos($_SERVER['HTTP_USER_AGENT'], 'Opera/7') !== false, 'is_opera8' => strpos($_SERVER['HTTP_USER_AGENT'], 'Opera 8') !== false || strpos($_SERVER['HTTP_USER_AGENT'], 'Opera/8') !== false, 'is_ie4' => strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 4') !== false && strpos($_SERVER['HTTP_USER_AGENT'], 'WebTV') === false, 'is_safari' => strpos($_SERVER['HTTP_USER_AGENT'], 'Safari') !== false, 'is_mac_ie' => strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 5.') !== false && strpos($_SERVER['HTTP_USER_AGENT'], 'Mac') !== false, 'is_web_tv' => strpos($_SERVER['HTTP_USER_AGENT'], 'WebTV') !== false, 'is_konqueror' => strpos($_SERVER['HTTP_USER_AGENT'], 'Konqueror') !== false, 'is_firefox' => strpos($_SERVER['HTTP_USER_AGENT'], 'Firefox') !== false, ); $context['browser']['is_gecko'] = strpos($_SERVER['HTTP_USER_AGENT'], 'Gecko') !== false && !$context['browser']['is_safari'] && !$context['browser']['is_konqueror']; // Internet Explorer 5 and 6 are often "emulated". $context['browser']['is_ie7'] = strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 7') !== false && !$context['browser']['is_opera'] && !$context['browser']['is_gecko'] && !$context['browser']['is_web_tv']; $context['browser']['is_ie6'] = strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 6') !== false && !$context['browser']['is_opera'] && !$context['browser']['is_gecko'] && !$context['browser']['is_web_tv']; $context['browser']['is_ie5.5'] = strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 5.5') !== false && !$context['browser']['is_opera'] && !$context['browser']['is_gecko'] && !$context['browser']['is_web_tv']; $context['browser']['is_ie5'] = strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 5.0') !== false && !$context['browser']['is_opera'] && !$context['browser']['is_gecko'] && !$context['browser']['is_web_tv']; $context['browser']['is_ie'] = $context['browser']['is_ie4'] || $context['browser']['is_ie5'] || $context['browser']['is_ie5.5'] || $context['browser']['is_ie6'] || $context['browser']['is_ie7']; $context['browser']['needs_size_fix'] = ($context['browser']['is_ie5'] || $context['browser']['is_ie5.5'] || $context['browser']['is_ie4'] || $context['browser']['is_opera6']) && strpos($_SERVER['HTTP_USER_AGENT'], 'Mac') === false; // This isn't meant to be reliable, it's just meant to catch most bots to prevent PHPSESSID from showing up. $ci_user_agent = strtolower($_SERVER['HTTP_USER_AGENT']); $context['browser']['possibly_robot'] = (strpos($_SERVER['HTTP_USER_AGENT'], 'Mozilla') === false && strpos($_SERVER['HTTP_USER_AGENT'], 'Opera') === false) || strpos($ci_user_agent, 'googlebot') !== false || strpos($ci_user_agent, 'slurp') !== false || strpos($ci_user_agent, 'crawl') !== false; // Robots shouldn't be logging in or registering. So, they aren't a bot. Better to be wrong than sorry (or people won't be able to log in!), anyway. if ((isset($_REQUEST['action']) && in_array($_REQUEST['action'], array('login', 'login2', 'register'))) || !$context['user']['is_guest']) $context['browser']['possibly_robot'] = false; // Set the top level linktree up. array_unshift($context['linktree'], array( 'url' => &$scripturl, 'name' => &$context['forum_name'] )); $txt = array(); $simpleActions = array( 'findmember', 'helpadmin', 'printpage', 'quotefast', 'spellcheck', ); // Wireless mode? Load up the wireless stuff. if (WIRELESS) { $context['template_layers'] = array(WIRELESS_PROTOCOL); loadTemplate('Wireless'); loadLanguage('Wireless'); loadLanguage('index'); } // Output is fully XML, so no need for the index template. elseif (isset($_REQUEST['xml'])) { loadLanguage('index'); loadTemplate('Xml'); $context['template_layers'] = array(); } // These actions don't require the index template at all. elseif (!empty($_REQUEST['action']) && in_array($_REQUEST['action'], $simpleActions)) { loadLanguage('index'); $context['template_layers'] = array(); } else { // Custom templates to load, or just default? if (isset($settings['theme_templates'])) $templates = explode(',', $settings['theme_templates']); else $templates = array('index'); // Custom template layers? if (isset($settings['theme_layers'])) $context['template_layers'] = explode(',', $settings['theme_layers']); else $context['template_layers'] = array('main'); // Load each template.... and attempt to load its associated language file. foreach ($templates as $template) { loadTemplate($template); loadLanguage($template, '', false); } } // Load the Modifications language file, always ;). (but don't sweat it if it doesn't exist.) loadLanguage('Modifications', '', false); // Initialize the theme. loadSubTemplate('init', 'ignore'); if (isset($settings['use_default_images']) && $settings['use_default_images'] == 'always') { $settings['theme_url'] = $settings['default_theme_url']; $settings['images_url'] = $settings['default_images_url']; $settings['theme_dir'] = $settings['default_theme_dir']; } // Set the character set from the template. $context['character_set'] = empty($modSettings['global_character_set']) ? $txt['lang_character_set'] : $modSettings['global_character_set']; $context['utf8'] = $context['character_set'] === 'UTF-8' && (strpos(strtolower(PHP_OS), 'win') === false || @version_compare(PHP_VERSION, '4.2.3') != -1); $context['right_to_left'] = !empty($txt['lang_rtl']); $context['tabindex'] = 1; // Fix font size with HTML 4.01, etc. if (isset($settings['doctype'])) $context['browser']['needs_size_fix'] |= $settings['doctype'] == 'html' && $context['browser']['is_ie6']; // Compatibility. if (!isset($settings['theme_version'])) $modSettings['memberCount'] = $modSettings['totalMembers']; } // Load a template - if the theme doesn't include it, use the default. function loadTemplate($template_name, $fatal = true) { global $context, $settings, $txt, $scripturl, $boarddir, $db_show_debug; // Try the current theme's first. if (file_exists($settings['theme_dir'] . '/' . $template_name . '.template.php')) { template_include($settings['theme_dir'] . '/' . $template_name . '.template.php', true); $template_name .= ' (' . basename($settings['theme_dir']) . ')'; } // Are we using a base theme? If so, does it have the template? elseif (isset($settings['base_theme_dir']) && file_exists($settings['base_theme_dir'] . '/' . $template_name . '.template.php')) { template_include($settings['base_theme_dir'] . '/' . $template_name . '.template.php', true); $template_name .= ' (' . basename($settings['base_theme_dir']) . ')'; } // Perhaps we'll just use the default template, then... elseif (file_exists($settings['default_theme_dir'] . '/' . $template_name . '.template.php')) { // Make it known that this template uses different directories... $settings['default_template'] = true; template_include($settings['default_theme_dir'] . '/' . $template_name . '.template.php', true); $template_name .= ' (' . basename($settings['default_theme_dir']) . ')'; } // Hmmm... doesn't exist?! I don't suppose the directory is wrong, is it? elseif (!file_exists($settings['default_theme_dir']) && file_exists($boarddir . '/Themes/default')) { $settings['default_theme_dir'] = $boarddir . '/Themes/default'; if (!empty($context['user']['is_admin']) && !isset($_GET['th'])) { loadLanguage('Errors'); echo '
', $txt['theme_dir_wrong'], '
'; } loadTemplate($template_name); } // Cause an error otherwise. elseif ($template_name != 'Errors' && $template_name != 'index' && $fatal) fatal_lang_error('theme_template_error', true, array((string) $template_name)); elseif ($fatal) die(log_error(sprintf(isset($txt['theme_template_error']) ? $txt['theme_template_error'] : 'Unable to load Themes/default/%s.template.php!', (string) $template_name))); else return false; // For compatibility reasons, if this is the index template without new functions, include compatible stuff. if (substr($template_name, 0, 5) == 'index' && !function_exists('template_button_strip')) loadTemplate('Combat'); if ($db_show_debug === true) $context['debug']['templates'][] = $template_name; } // Load a sub template... fatal is for templates that shouldn't get a 'pretty' error screen. function loadSubTemplate($sub_template_name, $fatal = false) { global $context, $settings, $options, $txt, $db_show_debug; if ($db_show_debug === true) $context['debug']['sub_templates'][] = $sub_template_name; // Figure out what the template function is named. $theme_function = 'template_' . $sub_template_name; if (function_exists($theme_function)) $theme_function(); elseif ($fatal === false) fatal_lang_error('theme_template_error', true, array((string) $sub_template_name)); elseif ($fatal !== 'ignore') die(log_error(sprintf(isset($txt['theme_template_error']) ? $txt['theme_template_error'] : 'Unable to load the %s sub template!', (string) $sub_template_name))); // Are we showing debugging for templates? Just make sure not to do it before the doctype... if (allowedTo('admin_forum') && isset($_REQUEST['debug']) && !in_array($sub_template_name, array('init', 'main_below')) && ob_get_length() > 0 && !isset($_REQUEST['xml'])) { echo '
---- ', $sub_template_name, ' ends ----
'; } } // Load a language file. Tries the current and default themes as well as the user and global languages. function loadLanguage($template_name, $lang = '', $fatal = true) { global $boarddir, $boardurl, $user_info, $language_dir, $language, $settings, $context, $txt, $db_show_debug; static $already_loaded = array(); // Default to the user's language. if ($lang == '') $lang = $user_info['language']; // Obviously, the current theme is most important to check. $attempts = array( array($settings['theme_dir'], $template_name, $lang, $settings['theme_url']), array($settings['theme_dir'], $template_name, $language, $settings['theme_url']), ); // Do we have a base theme to worry about? if (isset($settings['base_theme_dir'])) { $attempts[] = array($settings['base_theme_dir'], $template_name, $lang, $settings['base_theme_url']); $attempts[] = array($settings['base_theme_dir'], $template_name, $language, $settings['base_theme_url']); } // Fallback on the default theme if necessary. $attempts[] = array($settings['default_theme_dir'], $template_name, $lang, $settings['default_theme_url']); $attempts[] = array($settings['default_theme_dir'], $template_name, $language, $settings['default_theme_url']); // Try to include the language file. foreach ($attempts as $k => $file) if (file_exists($file[0] . '/languages/' . $file[1] . '.' . $file[2] . '.php')) { $language_dir = $file[0] . '/languages'; $lang = $file[2]; // Hmmm... do we really still need this? $language_url = $file[3]; template_include($file[0] . '/languages/' . $file[1] . '.' . $file[2] . '.php'); break; } // That couldn't be found! Log the error, but *try* to continue normally. if (!isset($language_url)) { if ($fatal) log_error(sprintf($txt['theme_language_error'], $template_name . '.' . $lang)); return false; } if ($db_show_debug === true) $context['debug']['language_files'][] = $template_name . '.' . $lang . ' (' . basename($language_url) . ')'; // Return the language actually loaded. return $lang; } // Get all parent boards (requires first parent as parameter) function getBoardParents($id_parent) { global $db_prefix, $scripturl, $txt; $boards = array(); // Loop while the parent is non-zero. while ($id_parent != 0) { $result = db_query(" SELECT b.ID_PARENT, b.name, $id_parent AS ID_BOARD, IFNULL(mem.ID_MEMBER, 0) AS ID_MODERATOR, mem.realName, b.childLevel FROM {$db_prefix}boards AS b LEFT JOIN {$db_prefix}moderators AS mods ON (mods.ID_BOARD = b.ID_BOARD) LEFT JOIN {$db_prefix}members AS mem ON (mem.ID_MEMBER = mods.ID_MEMBER) WHERE b.ID_BOARD = $id_parent", __FILE__, __LINE__); // In the EXTREMELY unlikely event this happens, give an error message. if (mysql_num_rows($result) == 0) fatal_lang_error('parent_not_found'); while ($row = mysql_fetch_assoc($result)) { if (!isset($boards[$row['ID_BOARD']])) { $id_parent = $row['ID_PARENT']; $boards[$row['ID_BOARD']] = array( 'url' => $scripturl . '?board=' . $row['ID_BOARD'] . '.0', 'name' => $row['name'], 'level' => $row['childLevel'], 'moderators' => array() ); } // If a moderator exists for this board, add that moderator for all children too. if (!empty($row['ID_MODERATOR'])) foreach ($boards as $id => $dummy) { $boards[$id]['moderators'][$row['ID_MODERATOR']] = array( 'id' => $row['ID_MODERATOR'], 'name' => $row['realName'], 'href' => $scripturl . '?action=profile;u=' . $row['ID_MODERATOR'], 'link' => '' . $row['realName'] . '' ); } } mysql_free_result($result); } return $boards; } // Replace all vulgar words with respective proper words. (substring or whole words..) function &censorText(&$text) { global $modSettings, $options, $settings, $txt; static $censor_vulgar = null, $censor_proper; if ((!empty($options['show_no_censored']) && $settings['allow_no_censored']) || empty($modSettings['censor_vulgar'])) return $text; // If they haven't yet been loaded, load them. if ($censor_vulgar == null) { $censor_vulgar = explode("\n", $modSettings['censor_vulgar']); $censor_proper = explode("\n", $modSettings['censor_proper']); // Quote them for use in regular expressions. for ($i = 0, $n = count($censor_vulgar); $i < $n; $i++) { $censor_vulgar[$i] = strtr(preg_quote($censor_vulgar[$i], '/'), array('\\\\\\*' => '[*]', '\\*' => '[^\s]*?', '&' => '&')); $censor_vulgar[$i] = (empty($modSettings['censorWholeWord']) ? '/' . $censor_vulgar[$i] . '/' : '/(?<=^|\W)' . $censor_vulgar[$i] . '(?=$|\W)/') . (empty($modSettings['censorIgnoreCase']) ? '' : 'i') . ((empty($modSettings['global_character_set']) ? $txt['lang_character_set'] : $modSettings['global_character_set']) === 'UTF-8' ? 'u' : ''); if (strpos($censor_vulgar[$i], '\'') !== false) { $censor_proper[count($censor_vulgar)] = $censor_proper[$i]; $censor_vulgar[count($censor_vulgar)] = strtr($censor_vulgar[$i], array('\'' => ''')); } } } // Censoring isn't so very complicated :P. $text = preg_replace($censor_vulgar, $censor_proper, $text); return $text; } // Create a little jumpto box. function loadJumpTo() { global $db_prefix, $context, $user_info; if (isset($context['jump_to'])) return; // Find the boards/cateogories they can see. $request = db_query(" SELECT c.name AS catName, c.ID_CAT, b.ID_BOARD, b.name AS boardName, b.childLevel FROM {$db_prefix}boards AS b LEFT JOIN {$db_prefix}categories AS c ON (c.ID_CAT = b.ID_CAT) WHERE $user_info[query_see_board]", __FILE__, __LINE__); $context['jump_to'] = array(); $this_cat = array('id' => -1); while ($row = mysql_fetch_assoc($request)) { if ($this_cat['id'] != $row['ID_CAT']) { $this_cat = &$context['jump_to'][]; $this_cat['id'] = $row['ID_CAT']; $this_cat['name'] = $row['catName']; $this_cat['boards'] = array(); } $this_cat['boards'][] = array( 'id' => $row['ID_BOARD'], 'name' => $row['boardName'], 'child_level' => $row['childLevel'], 'is_current' => isset($context['current_board']) && $row['ID_BOARD'] == $context['current_board'] ); } mysql_free_result($request); } // Load the template/language file using eval or require? (with eval we can show an error message!) function template_include($filename, $once = false) { global $context, $settings, $options, $txt, $scripturl, $modSettings; global $language_dir, $user_info, $boardurl, $boarddir, $sourcedir; global $maintenance, $mtitle, $mmessage; static $templates = array(); // We want to be able to figure out any errors... @ini_set('track_errors', '1'); // Don't include the file more than once, if $once is true. if ($once && in_array($filename, $templates)) return; // Add this file to the include list, whether $once is true or not. else $templates[] = $filename; // Are we going to use eval? if (empty($modSettings['disableTemplateEval'])) { $file_found = file_exists($filename) && eval('?' . '>' . rtrim(file_get_contents($filename))) !== false; $settings['current_include_filename'] = $filename; } else { $file_found = file_exists($filename); if ($once && $file_found) require_once($filename); elseif ($file_found) require($filename); } if ($file_found !== true) { ob_end_clean(); if (!empty($modSettings['enableCompressedOutput'])) @ob_start('ob_gzhandler'); else ob_start(); if (isset($_GET['debug']) && !WIRELESS) header('Content-Type: application/xhtml+xml; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); // Don't cache error pages!! header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); header('Cache-Control: no-cache'); if (!isset($txt['template_parse_error'])) { $txt['template_parse_error'] = 'Template Parse Error!'; $txt['template_parse_error_message'] = 'It seems something has gone sour on the forum with the template system. This problem should only be temporary, so please come back later and try again. If you continue to see this message, please contact the administrator.

You can also try refreshing this page.'; $txt['template_parse_error_details'] = 'There was a problem loading the %1$s template or language file. Please check the syntax and try again - remember, single quotes (\') often have to be escaped with a slash (\\). To see more specific error information from PHP, try accessing the file directly.

You may want to try to refresh this page or use the default theme.'; } // First, let's get the doctype and language information out of the way. echo ' '; if (isset($context['character_set'])) echo ' '; if (!empty($maintenance) && !allowedTo('admin_forum')) echo '
', $mtitle, '
', $mmessage, ' '; elseif (!allowedTo('admin_forum')) echo '
', $txt['template_parse_error'], '
', $txt['template_parse_error_message'], ' '; else { require_once($sourcedir . '/Subs-Package.php'); $error = fetch_web_data($boardurl . strtr($filename, array($boarddir => '', strtr($boarddir, '\\', '/') => ''))); if (empty($error)) $error = $php_errormsg; echo '
', $txt['template_parse_error'], '
', sprintf($txt['template_parse_error_details'], strtr($filename, array($boarddir => '', strtr($boarddir, '\\', '/') => ''))); if (!empty($error)) echo '
', strtr(strtr($error, array('' . $boarddir => '...', '' . strtr($boarddir, '\\', '/') => '...')), '\\', '/'), '
'; // I know, I know... this is VERY COMPLICATED. Still, it's good. if (preg_match('~ (\d+)$~i', $error, $match) != 0) { $data = file($filename); $data2 = highlight_php_code(implode('', $data)); $data2 = preg_split('~\~', $data2); // Fix the PHP code stuff... if ($context['browser']['is_ie4'] || $context['browser']['is_ie5'] || $context['browser']['is_ie5.5']) $data2 = str_replace("\t", "

\t

", $data2); elseif (!$context['browser']['is_gecko']) $data2 = str_replace("\t", "\t", $data2); else $data2 = str_replace("

\t

", "\t", $data2); // Now we get to work around a bug in PHP where it doesn't escape
s! $j = -1; foreach ($data as $line) { $j++; if (substr_count($line, '
') == 0) continue; $n = substr_count($line, '
'); for ($i = 0; $i < $n; $i++) { $data2[$j] .= '<br />' . $data2[$j + $i + 1]; unset($data2[$j + $i + 1]); } $j += $n; } $data2 = array_values($data2); array_unshift($data2, ''); echo '

';

// Figure out what the color coding was before...
$line = max($match[1] - 9, 1);
$last_line = '';
for ($line2 = $line - 1; $line2 > 1; $line2--)
if (strpos($data2[$line2], '<') !== false)
{
if (preg_match('~(<[^/>]+>)[^<]*$~', $data2[$line2], $color_match) != 0)
$last_line = $color_match[1];
break;
}

// Show the relevant lines...
for ($n = min($match[1] + 4, count($data2) + 1); $line <= $n; $line++)
{
if ($line == $match[1])
echo '

';

echo '', sprintf('%' . strlen($n) . 's', $line), ': ';
if ($data2[$line] != '')
echo substr($data2[$line], 0, 2) == ']+>~', '', $data2[$line]) : $last_line . $data2[$line];

if (preg_match('~(<[^/>]+>)[^<]*$~', $data2[$line], $color_match) != 0)
{
$last_line = $color_match[1];
echo '';
}
elseif ($last_line != '' && strpos($data2[$line], '<') !== false)
$last_line = '';
elseif ($last_line != '' && $data2[$line] != '')
echo '';

if ($line == $match[1])
echo '

';
else
echo "\n";
}

echo '

'; } echo ' '; } die; } } // Attempt to start the session, unless it already has been. function loadSession() { global $HTTP_SESSION_VARS, $modSettings, $boardurl, $sc; // Attempt to change a few PHP settings. @ini_set('session.use_cookies', true); @ini_set('session.use_only_cookies', false); @ini_set('url_rewriter.tags', ''); @ini_set('session.use_trans_sid', false); @ini_set('arg_separator.output', '&'); if (!empty($modSettings['globalCookies'])) { $parsed_url = parse_url($boardurl); if (preg_match('~^\d{1,3}(\.\d{1,3}){3}$~', $parsed_url['host']) == 0 && preg_match('~(?:[^\.]+\.)?([^\.]{2,}\..+)\z~i', $parsed_url['host'], $parts) == 1) @ini_set('session.cookie_domain', '.' . $parts[1]); } // !!! Set the session cookie path? // If it's already been started... probably best to skip this. if ((@ini_get('session.auto_start') == 1 && !empty($modSettings['databaseSession_enable'])) || session_id() == '') { // Attempt to end the already-started session. if (@ini_get('session.auto_start') == 1) @session_write_close(); // This is here to stop people from using bad junky PHPSESSIDs. if (isset($_REQUEST[session_name()]) && preg_match('~^[A-Za-z0-9]{16,32}$~', $_REQUEST[session_name()]) == 0 && !isset($_COOKIE[session_name()])) { $_REQUEST[session_name()] = md5(md5('smf_sess_' . time()) . rand()); $_GET[session_name()] = md5(md5('smf_sess_' . time()) . rand()); $_POST[session_name()] = md5(md5('smf_sess_' . time()) . rand()); } // Use database sessions? (they don't work in 4.1.x!) if (!empty($modSettings['databaseSession_enable']) && @version_compare(PHP_VERSION, '4.2.0') != -1) session_set_save_handler('sessionOpen', 'sessionClose', 'sessionRead', 'sessionWrite', 'sessionDestroy', 'sessionGC'); elseif (@ini_get('session.gc_maxlifetime') <= 1440 && !empty($modSettings['databaseSession_lifetime'])) @ini_set('session.gc_maxlifetime', max($modSettings['databaseSession_lifetime'], 60)); // Use cache setting sessions? if (empty($modSettings['databaseSession_enable']) && !empty($modSettings['cache_enable']) && php_sapi_name() != 'cli') { if (function_exists('mmcache_set_session_handlers')) mmcache_set_session_handlers(); elseif (function_exists('eaccelerator_set_session_handlers')) eaccelerator_set_session_handlers(); } session_start(); // Change it so the cache settings are a little looser than default. if (!empty($modSettings['databaseSession_loose'])) header('Cache-Control: private'); } // While PHP 4.1.x should use $_SESSION, it seems to need this to do it right. if (@version_compare(PHP_VERSION, '4.2.0') == -1) $HTTP_SESSION_VARS['php_412_bugfix'] = true; // Set the randomly generated code. if (!isset($_SESSION['rand_code'])) $_SESSION['rand_code'] = md5(session_id() . rand()); $sc = $_SESSION['rand_code']; } function sessionOpen($save_path, $session_name) { return true; } function sessionClose() { return true; } function sessionRead($session_id) { global $db_prefix; if (preg_match('~^[A-Za-z0-9]{16,32}$~', $session_id) == 0) return false; // Look for it in the database. $result = db_query(" SELECT data FROM {$db_prefix}sessions WHERE session_id = '" . addslashes($session_id) . "' LIMIT 1", __FILE__, __LINE__); list ($sess_data) = mysql_fetch_row($result); mysql_free_result($result); return $sess_data; } function sessionWrite($session_id, $data) { global $db_prefix; if (preg_match('~^[A-Za-z0-9]{16,32}$~', $session_id) == 0) return false; // First try to update an existing row... $result = db_query(" UPDATE {$db_prefix}sessions SET data = '" . addslashes($data) . "', last_update = " . time() . " WHERE session_id = '" . addslashes($session_id) . "' LIMIT 1", __FILE__, __LINE__); // If that didn't work, try inserting a new one. if (db_affected_rows() == 0) $result = db_query(" INSERT IGNORE INTO {$db_prefix}sessions (session_id, data, last_update) VALUES ('" . addslashes($session_id) . "', '" . addslashes($data) . "', " . time() . ")", __FILE__, __LINE__); return $result; } function sessionDestroy($session_id) { global $db_prefix; if (preg_match('~^[A-Za-z0-9]{16,32}$~', $session_id) == 0) return false; // Just delete the row... return db_query(" DELETE FROM {$db_prefix}sessions WHERE session_id = '" . addslashes($session_id) . "' LIMIT 1", __FILE__, __LINE__); } function sessionGC($max_lifetime) { global $db_prefix, $modSettings; // Just set to the default or lower? Ignore it for a higher value. (hopefully) if (!empty($modSettings['databaseSession_lifetime']) && ($max_lifetime <= 1440 || $modSettings['databaseSession_lifetime'] > $max_lifetime)) $max_lifetime = max($modSettings['databaseSession_lifetime'], 60); // Clean up ;). return db_query(" DELETE FROM {$db_prefix}sessions WHERE last_update < " . (time() - $max_lifetime), __FILE__, __LINE__); } function cache_put_data($key, $value, $ttl = 120) { global $boardurl, $sourcedir, $modSettings, $memcached; global $cache_hits, $cache_count, $db_show_debug; if (empty($modSettings['cache_enable']) && !empty($modSettings)) return; $cache_count = isset($cache_count) ? $cache_count + 1 : 1; if (isset($db_show_debug) && $db_show_debug === true) { $cache_hits[$cache_count] = array('k' => $key, 'd' => 'put', 's' => $value === null ? 0 : strlen(serialize($value))); $st = microtime(); } $key = md5($boardurl . filemtime($sourcedir . '/Load.php')) . '-SMF-' . $key; $value = $value === null ? null : serialize($value); // The simple yet efficient memcached. if (isset($modSettings['cache_memcached']) && trim($modSettings['cache_memcached']) != '') { // Grab the memcached server. if (!is_resource($memcached)) get_memcached_server(); if (!$memcached) return; // !!! It almost might be best to write null to as many as possible.... if (!fwrite($memcached, 'set ' . $key . ' 0 ' . $ttl . ' ' . strlen($value) . "\r\n" . $value . "\r\n")) { $memcached = fclose($memcached); return; } fread($memcached, 128); } // eAccelerator... elseif (function_exists('eaccelerator_put')) { if (rand(0, 10) == 1) eaccelerator_gc(); if ($value === null) @eaccelerator_rm($key); else eaccelerator_put($key, $value, $ttl); } // Turck MMCache? elseif (function_exists('mmcache_put')) { if (rand(0, 10) == 1) mmcache_gc(); if ($value === null) @mmcache_rm($key); else mmcache_put($key, $value, $ttl); } // Alternative PHP Cache, ahoy! elseif (function_exists('apc_store')) { // An extended key is needed to counteract a bug in APC. if ($value === null) apc_delete($key . 'smf'); else apc_store($key . 'smf', $value, $ttl); } // Zend Platform/ZPS/etc. elseif (function_exists('output_cache_put'
Otsikko: Re: Merkwürdiger ellenlanger code über dem forum
Kirjoitti: xduugu - joulukuu 01, 2006, 01:53:54 IP
Lad mal die Load.php neu hoch.