indvdum@0: get('config')) !== false) indvdum@0: { indvdum@0: $sql = 'SELECT config_name, config_value indvdum@0: FROM ' . CONFIG_TABLE . ' indvdum@0: WHERE is_dynamic = 1'; indvdum@0: $result = $db->sql_query($sql); indvdum@0: indvdum@0: while ($row = $db->sql_fetchrow($result)) indvdum@0: { indvdum@0: $config[$row['config_name']] = $row['config_value']; indvdum@0: } indvdum@0: $db->sql_freeresult($result); indvdum@0: } indvdum@0: else indvdum@0: { indvdum@0: $config = $cached_config = array(); indvdum@0: indvdum@0: $sql = 'SELECT config_name, config_value, is_dynamic indvdum@0: FROM ' . CONFIG_TABLE; indvdum@0: $result = $db->sql_query($sql); indvdum@0: indvdum@0: while ($row = $db->sql_fetchrow($result)) indvdum@0: { indvdum@0: if (!$row['is_dynamic']) indvdum@0: { indvdum@0: $cached_config[$row['config_name']] = $row['config_value']; indvdum@0: } indvdum@0: indvdum@0: $config[$row['config_name']] = $row['config_value']; indvdum@0: } indvdum@0: $db->sql_freeresult($result); indvdum@0: indvdum@0: $this->put('config', $cached_config); indvdum@0: } indvdum@0: indvdum@0: return $config; indvdum@0: } indvdum@0: indvdum@0: /** indvdum@0: * Obtain list of naughty words and build preg style replacement arrays for use by the indvdum@0: * calling script indvdum@0: */ indvdum@0: function obtain_word_list() indvdum@0: { indvdum@0: global $db; indvdum@0: indvdum@0: if (($censors = $this->get('_word_censors')) === false) indvdum@0: { indvdum@0: $sql = 'SELECT word, replacement indvdum@0: FROM ' . WORDS_TABLE; indvdum@0: $result = $db->sql_query($sql); indvdum@0: indvdum@0: $censors = array(); indvdum@0: while ($row = $db->sql_fetchrow($result)) indvdum@0: { indvdum@0: $censors['match'][] = get_censor_preg_expression($row['word']); indvdum@0: $censors['replace'][] = $row['replacement']; indvdum@0: } indvdum@0: $db->sql_freeresult($result); indvdum@0: indvdum@0: $this->put('_word_censors', $censors); indvdum@0: } indvdum@0: indvdum@0: return $censors; indvdum@0: } indvdum@0: indvdum@0: /** indvdum@0: * Obtain currently listed icons indvdum@0: */ indvdum@0: function obtain_icons() indvdum@0: { indvdum@0: if (($icons = $this->get('_icons')) === false) indvdum@0: { indvdum@0: global $db; indvdum@0: indvdum@0: // Topic icons indvdum@0: $sql = 'SELECT * indvdum@0: FROM ' . ICONS_TABLE . ' indvdum@0: ORDER BY icons_order'; indvdum@0: $result = $db->sql_query($sql); indvdum@0: indvdum@0: $icons = array(); indvdum@0: while ($row = $db->sql_fetchrow($result)) indvdum@0: { indvdum@0: $icons[$row['icons_id']]['img'] = $row['icons_url']; indvdum@0: $icons[$row['icons_id']]['width'] = (int) $row['icons_width']; indvdum@0: $icons[$row['icons_id']]['height'] = (int) $row['icons_height']; indvdum@0: $icons[$row['icons_id']]['display'] = (bool) $row['display_on_posting']; indvdum@0: } indvdum@0: $db->sql_freeresult($result); indvdum@0: indvdum@0: $this->put('_icons', $icons); indvdum@0: } indvdum@0: indvdum@0: return $icons; indvdum@0: } indvdum@0: indvdum@0: /** indvdum@0: * Obtain ranks indvdum@0: */ indvdum@0: function obtain_ranks() indvdum@0: { indvdum@0: if (($ranks = $this->get('_ranks')) === false) indvdum@0: { indvdum@0: global $db; indvdum@0: indvdum@0: $sql = 'SELECT * indvdum@0: FROM ' . RANKS_TABLE . ' indvdum@0: ORDER BY rank_min DESC'; indvdum@0: $result = $db->sql_query($sql); indvdum@0: indvdum@0: $ranks = array(); indvdum@0: while ($row = $db->sql_fetchrow($result)) indvdum@0: { indvdum@0: if ($row['rank_special']) indvdum@0: { indvdum@0: $ranks['special'][$row['rank_id']] = array( indvdum@0: 'rank_title' => $row['rank_title'], indvdum@0: 'rank_image' => $row['rank_image'] indvdum@0: ); indvdum@0: } indvdum@0: else indvdum@0: { indvdum@0: $ranks['normal'][] = array( indvdum@0: 'rank_title' => $row['rank_title'], indvdum@0: 'rank_min' => $row['rank_min'], indvdum@0: 'rank_image' => $row['rank_image'] indvdum@0: ); indvdum@0: } indvdum@0: } indvdum@0: $db->sql_freeresult($result); indvdum@0: indvdum@0: $this->put('_ranks', $ranks); indvdum@0: } indvdum@0: indvdum@0: return $ranks; indvdum@0: } indvdum@0: indvdum@0: /** indvdum@0: * Obtain allowed extensions indvdum@0: * indvdum@0: * @param mixed $forum_id If false then check for private messaging, if int then check for forum id. If true, then only return extension informations. indvdum@0: * indvdum@0: * @return array allowed extensions array. indvdum@0: */ indvdum@0: function obtain_attach_extensions($forum_id) indvdum@0: { indvdum@0: if (($extensions = $this->get('_extensions')) === false) indvdum@0: { indvdum@0: global $db; indvdum@0: indvdum@0: $extensions = array( indvdum@0: '_allowed_post' => array(), indvdum@0: '_allowed_pm' => array(), indvdum@0: ); indvdum@0: indvdum@0: // The rule is to only allow those extensions defined. ;) indvdum@0: $sql = 'SELECT e.extension, g.* indvdum@0: FROM ' . EXTENSIONS_TABLE . ' e, ' . EXTENSION_GROUPS_TABLE . ' g indvdum@0: WHERE e.group_id = g.group_id indvdum@0: AND (g.allow_group = 1 OR g.allow_in_pm = 1)'; indvdum@0: $result = $db->sql_query($sql); indvdum@0: indvdum@0: while ($row = $db->sql_fetchrow($result)) indvdum@0: { indvdum@0: $extension = strtolower(trim($row['extension'])); indvdum@0: indvdum@0: $extensions[$extension] = array( indvdum@0: 'display_cat' => (int) $row['cat_id'], indvdum@0: 'download_mode' => (int) $row['download_mode'], indvdum@0: 'upload_icon' => trim($row['upload_icon']), indvdum@0: 'max_filesize' => (int) $row['max_filesize'], indvdum@0: 'allow_group' => $row['allow_group'], indvdum@0: 'allow_in_pm' => $row['allow_in_pm'], indvdum@0: ); indvdum@0: indvdum@0: $allowed_forums = ($row['allowed_forums']) ? unserialize(trim($row['allowed_forums'])) : array(); indvdum@0: indvdum@0: // Store allowed extensions forum wise indvdum@0: if ($row['allow_group']) indvdum@0: { indvdum@0: $extensions['_allowed_post'][$extension] = (!sizeof($allowed_forums)) ? 0 : $allowed_forums; indvdum@0: } indvdum@0: indvdum@0: if ($row['allow_in_pm']) indvdum@0: { indvdum@0: $extensions['_allowed_pm'][$extension] = 0; indvdum@0: } indvdum@0: } indvdum@0: $db->sql_freeresult($result); indvdum@0: indvdum@0: $this->put('_extensions', $extensions); indvdum@0: } indvdum@0: indvdum@0: // Forum post indvdum@0: if ($forum_id === false) indvdum@0: { indvdum@0: // We are checking for private messages, therefore we only need to get the pm extensions... indvdum@0: $return = array('_allowed_' => array()); indvdum@0: indvdum@0: foreach ($extensions['_allowed_pm'] as $extension => $check) indvdum@0: { indvdum@0: $return['_allowed_'][$extension] = 0; indvdum@0: $return[$extension] = $extensions[$extension]; indvdum@0: } indvdum@0: indvdum@0: $extensions = $return; indvdum@0: } indvdum@0: else if ($forum_id === true) indvdum@0: { indvdum@0: return $extensions; indvdum@0: } indvdum@0: else indvdum@0: { indvdum@0: $forum_id = (int) $forum_id; indvdum@0: $return = array('_allowed_' => array()); indvdum@0: indvdum@0: foreach ($extensions['_allowed_post'] as $extension => $check) indvdum@0: { indvdum@0: // Check for allowed forums indvdum@0: if (is_array($check)) indvdum@0: { indvdum@0: $allowed = (!in_array($forum_id, $check)) ? false : true; indvdum@0: } indvdum@0: else indvdum@0: { indvdum@0: $allowed = true; indvdum@0: } indvdum@0: indvdum@0: if ($allowed) indvdum@0: { indvdum@0: $return['_allowed_'][$extension] = 0; indvdum@0: $return[$extension] = $extensions[$extension]; indvdum@0: } indvdum@0: } indvdum@0: indvdum@0: $extensions = $return; indvdum@0: } indvdum@0: indvdum@0: if (!isset($extensions['_allowed_'])) indvdum@0: { indvdum@0: $extensions['_allowed_'] = array(); indvdum@0: } indvdum@0: indvdum@0: return $extensions; indvdum@0: } indvdum@0: indvdum@0: /** indvdum@0: * Obtain active bots indvdum@0: */ indvdum@0: function obtain_bots() indvdum@0: { indvdum@0: if (($bots = $this->get('_bots')) === false) indvdum@0: { indvdum@0: global $db; indvdum@0: indvdum@0: switch ($db->sql_layer) indvdum@0: { indvdum@0: case 'mssql': indvdum@0: case 'mssql_odbc': indvdum@0: case 'mssqlnative': indvdum@0: $sql = 'SELECT user_id, bot_agent, bot_ip indvdum@0: FROM ' . BOTS_TABLE . ' indvdum@0: WHERE bot_active = 1 indvdum@0: ORDER BY LEN(bot_agent) DESC'; indvdum@0: break; indvdum@0: indvdum@0: case 'firebird': indvdum@0: $sql = 'SELECT user_id, bot_agent, bot_ip indvdum@0: FROM ' . BOTS_TABLE . ' indvdum@0: WHERE bot_active = 1 indvdum@0: ORDER BY CHAR_LENGTH(bot_agent) DESC'; indvdum@0: break; indvdum@0: indvdum@0: // LENGTH supported by MySQL, IBM DB2 and Oracle for sure... indvdum@0: default: indvdum@0: $sql = 'SELECT user_id, bot_agent, bot_ip indvdum@0: FROM ' . BOTS_TABLE . ' indvdum@0: WHERE bot_active = 1 indvdum@0: ORDER BY LENGTH(bot_agent) DESC'; indvdum@0: break; indvdum@0: } indvdum@0: $result = $db->sql_query($sql); indvdum@0: indvdum@0: $bots = array(); indvdum@0: while ($row = $db->sql_fetchrow($result)) indvdum@0: { indvdum@0: $bots[] = $row; indvdum@0: } indvdum@0: $db->sql_freeresult($result); indvdum@0: indvdum@0: $this->put('_bots', $bots); indvdum@0: } indvdum@0: indvdum@0: return $bots; indvdum@0: } indvdum@0: indvdum@0: /** indvdum@0: * Obtain cfg file data indvdum@0: */ indvdum@0: function obtain_cfg_items($theme) indvdum@0: { indvdum@0: global $config, $phpbb_root_path; indvdum@0: indvdum@0: $parsed_items = array( indvdum@0: 'theme' => array(), indvdum@0: 'template' => array(), indvdum@0: 'imageset' => array() indvdum@0: ); indvdum@0: indvdum@0: foreach ($parsed_items as $key => $parsed_array) indvdum@0: { indvdum@0: $parsed_array = $this->get('_cfg_' . $key . '_' . $theme[$key . '_path']); indvdum@0: indvdum@0: if ($parsed_array === false) indvdum@0: { indvdum@0: $parsed_array = array(); indvdum@0: } indvdum@0: indvdum@0: $reparse = false; indvdum@0: $filename = $phpbb_root_path . 'styles/' . $theme[$key . '_path'] . '/' . $key . '/' . $key . '.cfg'; indvdum@0: indvdum@0: if (!file_exists($filename)) indvdum@0: { indvdum@0: continue; indvdum@0: } indvdum@0: indvdum@0: if (!isset($parsed_array['filetime']) || (($config['load_tplcompile'] && @filemtime($filename) > $parsed_array['filetime']))) indvdum@0: { indvdum@0: $reparse = true; indvdum@0: } indvdum@0: indvdum@0: // Re-parse cfg file indvdum@0: if ($reparse) indvdum@0: { indvdum@0: $parsed_array = parse_cfg_file($filename); indvdum@0: $parsed_array['filetime'] = @filemtime($filename); indvdum@0: indvdum@0: $this->put('_cfg_' . $key . '_' . $theme[$key . '_path'], $parsed_array); indvdum@0: } indvdum@0: $parsed_items[$key] = $parsed_array; indvdum@0: } indvdum@0: indvdum@0: return $parsed_items; indvdum@0: } indvdum@0: indvdum@0: /** indvdum@0: * Obtain disallowed usernames indvdum@0: */ indvdum@0: function obtain_disallowed_usernames() indvdum@0: { indvdum@0: if (($usernames = $this->get('_disallowed_usernames')) === false) indvdum@0: { indvdum@0: global $db; indvdum@0: indvdum@0: $sql = 'SELECT disallow_username indvdum@0: FROM ' . DISALLOW_TABLE; indvdum@0: $result = $db->sql_query($sql); indvdum@0: indvdum@0: $usernames = array(); indvdum@0: while ($row = $db->sql_fetchrow($result)) indvdum@0: { indvdum@0: $usernames[] = str_replace('%', '.*?', preg_quote(utf8_clean_string($row['disallow_username']), '#')); indvdum@0: } indvdum@0: $db->sql_freeresult($result); indvdum@0: indvdum@0: $this->put('_disallowed_usernames', $usernames); indvdum@0: } indvdum@0: indvdum@0: return $usernames; indvdum@0: } indvdum@0: indvdum@0: /** indvdum@0: * Obtain hooks... indvdum@0: */ indvdum@0: function obtain_hooks() indvdum@0: { indvdum@0: global $phpbb_root_path, $phpEx; indvdum@0: indvdum@0: if (($hook_files = $this->get('_hooks')) === false) indvdum@0: { indvdum@0: $hook_files = array(); indvdum@0: indvdum@0: // Now search for hooks... indvdum@0: $dh = @opendir($phpbb_root_path . 'includes/hooks/'); indvdum@0: indvdum@0: if ($dh) indvdum@0: { indvdum@0: while (($file = readdir($dh)) !== false) indvdum@0: { indvdum@0: if (strpos($file, 'hook_') === 0 && substr($file, -(strlen($phpEx) + 1)) === '.' . $phpEx) indvdum@0: { indvdum@0: $hook_files[] = substr($file, 0, -(strlen($phpEx) + 1)); indvdum@0: } indvdum@0: } indvdum@0: closedir($dh); indvdum@0: } indvdum@0: indvdum@0: $this->put('_hooks', $hook_files); indvdum@0: } indvdum@0: indvdum@0: return $hook_files; indvdum@0: } indvdum@0: } indvdum@0: indvdum@0: ?>