Ejemplo n.º 1
0
 /**
  * The UI to edit a configuration page.
  *
  * @return tempcode		The UI
  */
 function config_category()
 {
     require_javascript('javascript_validation');
     /*$GLOBALS['HELPER_PANEL_PIC']='pagepics/config';
     		$GLOBALS['HELPER_PANEL_TUTORIAL']='tut_adv_configuration';*/
     $page = get_param('id');
     $title = get_page_title(do_lang_tempcode('CONFIG_CATEGORY_' . $page), false);
     $post_url = build_url(array('page' => '_SELF', 'type' => 'set', 'id' => $page, 'redirect' => get_param('redirect', NULL)), '_SELF');
     $category_description = do_lang_tempcode('CONFIG_CATEGORY_DESCRIPTION__' . $page);
     $rows = $GLOBALS['SITE_DB']->query_select('config', array('*'), array('the_page' => $page));
     // Addin special ones
     if ($page == 'SITE') {
         $rows[] = array('the_name' => 'timezone', 'human_name' => 'TIME_ZONE', 'config_value' => '', 'the_type' => 'special', 'eval' => '', 'the_page' => 'SITE', 'section' => 'GENERAL', 'explanation' => '', 'shared_hosting_restricted' => 0);
     }
     /*global $M_SORT_KEY;	This is a lame sort - it doesn't preserve internal order
     		$M_SORT_KEY='section';
     		usort($rows,'multi_sort');*/
     // Better sort
     $all_known_groups = array();
     foreach ($rows as $myrow) {
         $_group = do_lang($myrow['section'], NULL, NULL, NULL, NULL, false);
         if (is_null($_group)) {
             $_group = $myrow['section'];
         }
         $_group = strtolower(trim(preg_replace('#(&.*;)|[^\\w\\d\\s]#U', '', $_group)));
         if (array_key_exists($_group, $all_known_groups) && $all_known_groups[$_group] != $myrow['section']) {
             $_group = 'std_' . $myrow['section'];
         }
         // If cat names translate to same things or are in non-latin characters like Cyrillic
         $all_known_groups[$_group] = $myrow['section'];
     }
     $old_rows = $rows;
     $rows = array();
     ksort($all_known_groups);
     foreach ($all_known_groups as $group_codename) {
         foreach ($old_rows as $myrow) {
             if ($myrow['section'] == $group_codename) {
                 $rows[] = $myrow;
             }
         }
     }
     // Move advanced group options to the end
     $rows2 = array();
     foreach ($rows as $i => $row) {
         if ($row['section'] == 'ADVANCED') {
             $rows2[] = $row;
             unset($rows[$i]);
         }
     }
     $rows = array_merge($rows, $rows2);
     // UI hooks
     $ui_hooks = find_all_hooks('modules', 'admin_config');
     $upload_max_filesize = ini_get('upload_max_filesize') == '0' ? do_lang('NA') : clean_file_size(php_return_bytes(ini_get('upload_max_filesize')));
     $post_max_size = ini_get('post_max_size') == '0' ? do_lang('NA') : clean_file_size(php_return_bytes(ini_get('post_max_size')));
     $groups = new ocp_tempcode();
     require_code('form_templates');
     $current_group = '';
     $out = '';
     $_groups = array();
     foreach ($rows as $myrow) {
         if ($myrow['eval'] != '' && $myrow['the_name'] != 'detect_lang_forum') {
             if (defined('HIPHOP_PHP')) {
                 require_code('hooks/systems/config_default/' . $myrow['the_name']);
                 $hook = object_factory('Hook_config_default_' . $myrow['the_name']);
                 if (is_null($hook->get_default())) {
                     continue;
                 }
             } else {
                 $GLOBALS['REQUIRE_LANG_LOOP'] = 10;
                 // LEGACY Workaround for corrupt webhost installers
                 if (is_null(@eval($myrow['eval'] . ';'))) {
                     continue;
                 }
                 // @'d in case default is corrupt, don't want it to give errors forever
                 $GLOBALS['REQUIRE_LANG_LOOP'] = 0;
                 // LEGACY
             }
         }
         $_group = do_lang($myrow['section'], NULL, NULL, NULL, NULL, false);
         $name = do_lang($myrow['human_name'], NULL, NULL, NULL, NULL, false);
         $_group_tempcode = is_null($_group) ? make_string_tempcode($myrow['section']) : do_lang_tempcode($myrow['section']);
         $name_tempcode = is_null($name) ? make_string_tempcode($myrow['human_name']) : do_lang_tempcode($myrow['human_name']);
         if (get_forum_type() == 'ocf' && $myrow['explanation'] == 'CONFIG_OPTION_forum_in_portal') {
             $exp_string = $myrow['explanation'] . '__ocf';
         } else {
             $exp_string = $myrow['explanation'];
         }
         $_explanation = do_lang($exp_string, NULL, NULL, NULL, NULL, false);
         if (is_null($_explanation)) {
             $_explanation = do_lang('CONFIG_GROUP_DEFAULT_DESCRIP_' . $myrow['section'], NULL, NULL, NULL, NULL, false);
             if (is_null($_explanation)) {
                 $explanation = new ocp_tempcode();
             } else {
                 $explanation = do_lang_tempcode('CONFIG_GROUP_DEFAULT_DESCRIP_' . $myrow['section']);
             }
         } else {
             $explanation = do_lang_tempcode($exp_string);
         }
         if ($myrow['shared_hosting_restricted'] == 1 && !is_null($GLOBALS['CURRENT_SHARE_USER'])) {
             continue;
         }
         if ($myrow['section'] != $current_group && $current_group != '') {
             $_current_group = do_lang_tempcode($current_group);
             $_group_description = do_lang('CONFIG_GROUP_DESCRIP_' . $current_group, escape_html($post_max_size), escape_html($upload_max_filesize), NULL, NULL, false);
             if (is_null($_group_description)) {
                 $group_description = new ocp_tempcode();
             } else {
                 $group_description = do_lang_tempcode('CONFIG_GROUP_DESCRIP_' . $current_group, escape_html($post_max_size), escape_html($upload_max_filesize));
             }
             $group = do_template('CONFIG_GROUP', array('_GUID' => 'af4c31daa1bc39714ab83b11bd6d3e51', 'GROUP_DESCRIPTION' => $group_description, 'GROUP_NAME' => $current_group, 'GROUP' => $out, 'CURRENT_GROUP' => $_current_group));
             $groups->attach($group->evaluate());
             $out = '';
         }
         $_groups[$myrow['section']] = $_group_tempcode;
         switch ($myrow['the_type']) {
             case 'special':
                 switch ($myrow['the_name']) {
                     case 'timezone':
                         $list = '';
                         $timezone = get_site_timezone();
                         foreach (get_timezone_list() as $_timezone => $timezone_nice) {
                             $list .= static_evaluate_tempcode(form_input_list_entry($_timezone, $_timezone == $timezone, $timezone_nice));
                         }
                         $out .= static_evaluate_tempcode(form_input_list(do_lang_tempcode('TIME_ZONE'), do_lang_tempcode('DESCRIPTION_TIMEZONE_SITE'), 'timezone', make_string_tempcode($list)));
                         break;
                     default:
                         require_code('hooks/modules/admin_config/' . filter_naughty_harsh($myrow['the_name']));
                         $hook_ob = object_factory('Hook_admin_config_' . filter_naughty_harsh($myrow['the_name']));
                         $out .= static_evaluate_tempcode($hook_ob->run($myrow));
                         break;
                 }
                 break;
             case 'integer':
                 $out .= static_evaluate_tempcode(form_input_integer($name_tempcode, $explanation, $myrow['the_name'], intval(get_option($myrow['the_name'])), false));
                 break;
             case 'line':
                 if (strpos($myrow['the_name'], 'colour') !== false && substr(get_option($myrow['the_name']), 0, 1) == '#') {
                     $out .= static_evaluate_tempcode(form_input_colour($name_tempcode, $explanation, $myrow['the_name'], get_option($myrow['the_name']), false, NULL, true));
                 } elseif ($myrow['the_name'] == 'currency') {
                     $list = '';
                     require_code('currency');
                     $currencies = array_keys(get_currency_map());
                     foreach ($currencies as $currency) {
                         $list .= static_evaluate_tempcode(form_input_list_entry($currency, $currency == get_option($myrow['the_name'])));
                     }
                     $out .= static_evaluate_tempcode(form_input_list($name_tempcode, $explanation, $myrow['the_name'], make_string_tempcode($list)));
                 } elseif ($myrow['the_name'] == 'payment_gateway') {
                     $list = '';
                     $all_via = find_all_hooks('systems', 'ecommerce_via');
                     foreach (array_keys($all_via) as $via) {
                         $list .= static_evaluate_tempcode(form_input_list_entry($via, $via == get_option($myrow['the_name'])));
                     }
                     $out .= static_evaluate_tempcode(form_input_list($name_tempcode, $explanation, $myrow['the_name'], make_string_tempcode($list)));
                 } else {
                     /*if (strpos($myrow['the_name'],'password')!==false)  password fields can't take defaults
                     			$out.=static_evaluate_tempcode(form_input_password($name_tempcode,$explanation,$myrow['the_name'],get_option($myrow['the_name']),false));
                     		else
                     			*/
                     $out .= static_evaluate_tempcode(form_input_line($name_tempcode, $explanation, $myrow['the_name'], get_option($myrow['the_name']), false));
                 }
                 break;
             case 'list':
                 $list = '';
                 $_value = get_option($myrow['the_name']);
                 $values = explode('|', $myrow['c_data']);
                 foreach ($values as $value) {
                     $_option_text = do_lang('CONFIG_OPTION_' . $myrow['the_name'] . '_VALUE_' . $value, NULL, NULL, NULL, NULL, false);
                     if (!is_null($_option_text)) {
                         $option_text = do_lang_tempcode('CONFIG_OPTION_' . $myrow['the_name'] . '_VALUE_' . $value);
                     } else {
                         $option_text = make_string_tempcode($value);
                     }
                     $list .= static_evaluate_tempcode(form_input_list_entry($value, $_value == $value, $option_text));
                 }
                 $out .= static_evaluate_tempcode(form_input_list($name_tempcode, $explanation, $myrow['the_name'], make_string_tempcode($list), NULL, false, false));
                 break;
             case 'transline':
                 $out .= static_evaluate_tempcode(form_input_line($name_tempcode, $explanation, $myrow['the_name'], get_option($myrow['the_name']), false));
                 break;
             case 'text':
                 $out .= static_evaluate_tempcode(form_input_text($name_tempcode, $explanation, $myrow['the_name'], get_option($myrow['the_name']), false, NULL, true));
                 break;
             case 'transtext':
                 $out .= static_evaluate_tempcode(form_input_text($name_tempcode, $explanation, $myrow['the_name'], get_option($myrow['the_name']), false, NULL, true));
                 break;
             case 'float':
                 $out .= static_evaluate_tempcode(form_input_float($name_tempcode, $explanation, $myrow['the_name'], floatval(get_option($myrow['the_name'])), false));
                 break;
             case 'tick':
                 $out .= static_evaluate_tempcode(form_input_tick($name_tempcode, $explanation, $myrow['the_name'], get_option($myrow['the_name']) == '1'));
                 break;
             case 'date':
                 $out .= static_evaluate_tempcode(form_input_date($name_tempcode, $explanation, $myrow['the_name'], false, false, false, intval(get_option($myrow['the_name'])), 40, intval(date('Y')) - 20, NULL, false));
                 break;
             case 'forum':
             case '?forum':
                 if (get_forum_type() == 'ocf' && addon_installed('ocf_forum')) {
                     $current_setting = get_option($myrow['the_name']);
                     if (!is_numeric($current_setting)) {
                         $_current_setting = $GLOBALS['FORUM_DB']->query_value_null_ok('f_forums', 'id', array('f_name' => $current_setting));
                         if (is_null($_current_setting)) {
                             if ($myrow['the_type'] == '?forum') {
                                 $current_setting = NULL;
                             } else {
                                 $current_setting = strval(db_get_first_id());
                                 attach_message(do_lang_tempcode('FORUM_CURRENTLY_UNSET', $name_tempcode), 'notice');
                             }
                         } else {
                             $current_setting = strval($_current_setting);
                         }
                     }
                     $out .= static_evaluate_tempcode(form_input_tree_list($name_tempcode, $explanation, $myrow['the_name'], NULL, 'choose_forum', array(), false, $current_setting));
                 } else {
                     $out .= static_evaluate_tempcode(form_input_line($name_tempcode, $explanation, $myrow['the_name'], get_option($myrow['the_name']), false));
                 }
                 break;
             case 'category':
                 if (get_forum_type() == 'ocf') {
                     $tmp_value = $GLOBALS['FORUM_DB']->query_value_null_ok('f_categories', 'id', array('c_title' => get_option($myrow['the_name'])));
                     require_code('ocf_forums2');
                     $_list = ocf_nice_get_categories(NULL, $tmp_value);
                     $out .= static_evaluate_tempcode(form_input_list($name_tempcode, $explanation, $myrow['the_name'], $_list));
                 } else {
                     $out .= static_evaluate_tempcode(form_input_line($name_tempcode, $explanation, $myrow['the_name'], get_option($myrow['the_name']), false));
                 }
                 break;
             case 'usergroup':
                 if (get_forum_type() == 'ocf') {
                     $tmp_value = $GLOBALS['FORUM_DB']->query_value_null_ok('f_groups g LEFT JOIN ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'translate t ON t.id=g.g_name', 'g.id', array('text_original' => get_option($myrow['the_name'])));
                     require_code('ocf_groups');
                     $_list = ocf_nice_get_usergroups($tmp_value);
                     $out .= static_evaluate_tempcode(form_input_list($name_tempcode, $explanation, $myrow['the_name'], $_list));
                 } else {
                     $out .= static_evaluate_tempcode(form_input_line($name_tempcode, $explanation, $myrow['the_name'], get_option($myrow['the_name']), false));
                 }
                 break;
         }
         $current_group = $myrow['section'];
     }
     if ($out != '') {
         $_group_description = do_lang('CONFIG_GROUP_DESCRIP_' . $current_group, escape_html($post_max_size), escape_html($upload_max_filesize), NULL, NULL, false);
         if (is_null($_group_description)) {
             $group_description = new ocp_tempcode();
         } else {
             $group_description = do_lang_tempcode('CONFIG_GROUP_DESCRIP_' . $current_group, escape_html($post_max_size), escape_html($upload_max_filesize));
         }
         $group = do_template('CONFIG_GROUP', array('_GUID' => '84c0db86002a33a383a7c2e195dd3913', 'GROUP_DESCRIPTION' => $group_description, 'GROUP_NAME' => $current_group, 'GROUP' => $out, 'CURRENT_GROUP' => $_group_tempcode));
         $groups->attach($group->evaluate());
     }
     list($warning_details, $ping_url) = handle_conflict_resolution();
     breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('CONFIGURATION'))));
     breadcrumb_set_self(do_lang_tempcode('CONFIG_CATEGORY_' . $page));
     return do_template('CONFIG_CATEGORY_SCREEN', array('_GUID' => 'd01b28b71c38bbb52b6aaf877c7f7b0e', 'CATEGORY_DESCRIPTION' => $category_description, '_GROUPS' => $_groups, 'PING_URL' => $ping_url, 'WARNING_DETAILS' => $warning_details, 'TITLE' => $title, 'URL' => $post_url, 'GROUPS' => $groups, 'SUBMIT_NAME' => do_lang_tempcode('SAVE')));
 }
Ejemplo n.º 2
0
/**
 * Get the maximum allowed image size, as set in the configuration.
 *
 * @return integer		The maximum image size
 */
function get_max_image_size()
{
    $a = php_return_bytes(ini_get('upload_max_filesize'));
    $b = php_return_bytes(ini_get('post_max_size'));
    $c = intval(get_option('max_download_size')) * 1024;
    if (has_specific_permission(get_member(), 'exceed_filesize_limit')) {
        $c = 0;
    }
    $possibilities = array();
    if ($a != 0) {
        $possibilities[] = $a;
    }
    if ($b != 0) {
        $possibilities[] = $b;
    }
    if ($c != 0) {
        $possibilities[] = $c;
    }
    return min($possibilities);
}
Ejemplo n.º 3
0
/**
 * Complain about a POST field being missing.
 *
 * @param  string			The name of the parameter
 */
function improperly_filled_in_post($name)
{
    $GLOBALS['HTTP_STATUS_CODE'] = '400';
    if (!headers_sent()) {
        if (!browser_matches('ie') && strpos(ocp_srv('SERVER_SOFTWARE'), 'IIS') === false) {
            header('HTTP/1.0 400 Bad Request');
        }
    }
    if (count($_POST) == 0 && get_option('user_postsize_errors') == '1') {
        $upload_max_filesize = ini_get('upload_max_filesize') == '0' ? do_lang('NA') : clean_file_size(php_return_bytes(ini_get('upload_max_filesize')));
        $post_max_size = ini_get('post_max_size') == '0' ? do_lang('NA') : clean_file_size(php_return_bytes(ini_get('post_max_size')));
        warn_exit(do_lang_tempcode(get_param_integer('uploading', 0) == 1 ? 'SHOULD_HAVE_BEEN_POSTED_FILE_ERROR' : 'SHOULD_HAVE_BEEN_POSTED', escape_html($name), escape_html($post_max_size), escape_html($upload_max_filesize)));
    }
    // We didn't give some required input
    warn_exit(do_lang_tempcode('IMPROPERLY_FILLED_IN'));
}
Ejemplo n.º 4
0
 /**
  * Actualiser to perform Admin Zone search.
  *
  * @return tempcode	Interface.
  */
 function search()
 {
     require_all_lang();
     require_code('zones2');
     disable_php_memory_limit();
     if (function_exists('set_time_limit')) {
         @set_time_limit(100);
     }
     $n = mixed();
     $default_theme = $GLOBALS['FORUM_DRIVER']->get_theme('');
     // Mess around to find our search keywords (takes synonyms into account, and generally tidies up)
     $raw_search_string = get_param('search_content', false, true);
     // Work out our keywords
     $keyword_string = $raw_search_string;
     $_keywords = array();
     $current_word = '';
     $in_quotes = false;
     for ($xi = 0; $xi < strlen($keyword_string); $xi++) {
         if ($in_quotes || trim($keyword_string[$xi]) != '') {
             if ($keyword_string[$xi] == '"') {
                 $in_quotes = !$in_quotes;
             } else {
                 $current_word .= $keyword_string[$xi];
             }
         } else {
             if ($current_word != '') {
                 $_keywords[] = $current_word;
             }
             $current_word = '';
         }
     }
     if ($current_word != '') {
         $_keywords[] = $current_word;
     }
     $_keywords = $this->_strip_junk_words($_keywords);
     if (count($_keywords) == 0) {
         return do_template('INDEX_SCREEN_FANCIER_SCREEN', array('TITLE' => get_page_title('ADMIN_ZONE_SEARCH_RESULTS'), 'EMPTY' => true, 'ARRAY' => true, 'CONTENT' => '', 'PRE' => '', 'POST' => ''));
     }
     $keywords = array();
     $synonym_rows = $this->_synonyms();
     // Only in English by default. To do for another language, override this file using inheritance
     $section_limitations = array();
     foreach ($_keywords as $xi => $keyword) {
         $_keywords = array();
         $keyword = trim($keyword);
         if ($keyword == '') {
             continue;
         }
         if (substr($keyword, 0, 1) == '@') {
             $section_limitations[] = substr($keyword, 1);
             continue;
         }
         foreach ($synonym_rows as $synonyms) {
             if (in_array(strtolower($keyword), $synonyms) || array_key_exists($xi + 1, $_keywords) && in_array(strtolower($_keywords[$xi] . ' ' . $_keywords[$xi + 1]), $synonyms)) {
                 $_keywords = array_merge($_keywords, $synonyms);
             }
         }
         $_keywords[] = $keyword;
         $keywords[] = $_keywords;
     }
     // Stemming, if available (needs Stemmer class like http://www.chuggnutt.com/stemmer-source.php which we can't redistribute due to it being GPL not LGPL)
     if (file_exists(get_file_base() . '/sources_custom/stemmer_' . user_lang() . '.php') && !in_safe_mode()) {
         require_code('stemmer_' . user_lang());
         $stemmer = object_factory('Stemmer_' . user_lang());
         foreach ($keywords as $i => $keyword_group) {
             $_keyword_group = $keyword_group;
             foreach ($keyword_group as $keyword) {
                 // Special stemmer exceptions
                 if ($keyword == 'news') {
                     continue;
                 }
                 if ($keyword == 'defaultness') {
                     continue;
                 }
                 $_keyword_group[] = $stemmer->stem($keyword);
             }
             $keywords[$i] = array_unique($_keyword_group);
         }
     } else {
         foreach ($keywords as $i => $keyword_group) {
             $_keyword_group = $keyword_group;
             foreach ($keyword_group as $keyword) {
                 if (strlen($keyword) > 3 && substr($keyword, -1) == 's') {
                     $_keyword_group[] = substr($keyword, 0, strlen($keyword) - 1);
                 } else {
                     $_keyword_group[] = $keyword . 's';
                 }
             }
             $keywords[$i] = array_unique($_keyword_group);
         }
     }
     $this->keywords = $keywords;
     $content = array();
     // Admin/CMS menu icons
     $current_results_type = do_lang('ADMIN_MODULES');
     if ($this->_section_match($section_limitations, $current_results_type)) {
         $content[$current_results_type] = new ocp_tempcode();
         $hooks = find_all_hooks('systems', 'do_next_menus');
         foreach (array_keys($hooks) as $hook) {
             require_code('hooks/systems/do_next_menus/' . filter_naughty_harsh($hook));
             $object = object_factory('Hook_do_next_menus_' . filter_naughty_harsh($hook), true);
             if (is_null($object)) {
                 continue;
             }
             $info = $object->run(true);
             foreach ($info as $i) {
                 if (is_null($i)) {
                     continue;
                 }
                 $n = $i[3];
                 if ($i[0] != '' && $this->_keyword_match(is_object($n) ? $n->evaluate() : $n) && has_actual_page_access(get_member(), $i[2][0], $i[2][2])) {
                     $_url = build_url(array('page' => $i[2][0]) + $i[2][1], $i[2][2]);
                     $tree = new ocp_tempcode();
                     $tree->attach(hyperlink(build_url(array('page' => 'admin', 'type' => $i[0]), 'adminzone'), do_lang(strtoupper($i[0]))));
                     $sup = do_lang_tempcode('LOCATED_IN', $tree);
                     $content[$current_results_type]->attach(do_template('INDEX_SCREEN_FANCIER_ENTRY', array('NAME' => $n, 'URL' => $_url, 'TITLE' => '', 'DESCRIPTION' => '', 'SUP' => $sup)));
                 }
             }
         }
     }
     // Module entry points
     $current_results_type = do_lang('SCREENS');
     if ($this->_section_match($section_limitations, $current_results_type)) {
         $content[$current_results_type] = new ocp_tempcode();
         foreach (find_all_zones(false, true) as $zone => $zone_details) {
             $modules = find_all_modules($zone);
             foreach (array_keys($modules) as $page) {
                 $_entrypoints = extract_module_functions_page($zone, $page, array('get_entry_points'));
                 if (!is_null($_entrypoints[0])) {
                     if (is_array($_entrypoints[0]) || strpos($_entrypoints[0], '::') === false) {
                         $entry_points = is_array($_entrypoints[0]) ? call_user_func_array($_entrypoints[0][0], $_entrypoints[0][1]) : eval($_entrypoints[0]);
                     } else {
                         $path = zone_black_magic_filterer(filter_naughty($zone) . ($zone == '' ? '' : '/') . 'pages/modules_custom/' . filter_naughty($page) . '.php', true);
                         if (!file_exists(get_file_base() . '/' . $path)) {
                             $path = zone_black_magic_filterer(filter_naughty($zone) . '/pages/modules/' . filter_naughty($page) . '.php', true);
                         }
                         if (!defined('HIPHOP_PHP') && (ini_get('memory_limit') != '-1' && ini_get('memory_limit') != '0' || get_option('has_low_memory_limit') === '1') && strpos(file_get_contents(get_file_base() . '/' . $path), ' extends standard_aed_module') !== false) {
                             $new_code = str_replace(',parent::get_entry_points()', '', str_replace('parent::get_entry_points(),', '', $_entrypoints[0]));
                             if (strpos($new_code, 'parent::') !== false) {
                                 continue;
                             }
                             $entry_points = eval($new_code);
                         } else {
                             require_code($path);
                             if (class_exists('Mx_' . filter_naughty_harsh($page))) {
                                 $object = object_factory('Mx_' . filter_naughty_harsh($page));
                             } else {
                                 $object = object_factory('Module_' . filter_naughty_harsh($page));
                             }
                             $entry_points = $object->get_entry_points();
                         }
                     }
                     if ($page == 'admin_themes') {
                         $entry_points['!themes'] = 'EDIT_CSS';
                         $entry_points['!!themes'] = 'EDIT_TEMPLATES';
                         $entry_points['!!!themes'] = 'MANAGE_THEME_IMAGES';
                     }
                     if (is_null($entry_points)) {
                         $entry_points = array();
                     }
                     foreach ($entry_points as $type => $lang) {
                         $type = str_replace('!', '', $type);
                         // The ! was a hackerish thing just to multiply-up possibilities for the single entry-point
                         $n = do_lang_tempcode($lang);
                         if ($this->_keyword_match($n->evaluate()) && has_actual_page_access(get_member(), $page, $zone)) {
                             $tree = new ocp_tempcode();
                             $tree->attach(hyperlink(build_url(array('page' => ''), $zone), $zone_details[1]));
                             if ($zone == 'cms' || $zone == 'adminzone') {
                                 if ($page != 'admin' && $page != 'cms') {
                                     $hooks = find_all_hooks('systems', 'do_next_menus');
                                     foreach (array_keys($hooks) as $hook) {
                                         require_code('hooks/systems/do_next_menus/' . filter_naughty_harsh($hook));
                                         $object = object_factory('Hook_do_next_menus_' . filter_naughty_harsh($hook), true);
                                         if (is_null($object)) {
                                             continue;
                                         }
                                         $info = $object->run();
                                         foreach ($info as $i) {
                                             if (is_null($i)) {
                                                 continue;
                                             }
                                             if ($page == $i[2][0] && (!array_key_exists('type', $i[2][1]) && $type == 'misc' || array_key_exists('type', $i[2][1]) && $type == $i[2][1]['type']) && $zone == $i[2][2]) {
                                                 if ($i[0] == 'cms') {
                                                     $_url = build_url(array('page' => 'cms', 'type' => $i[0]), 'cms');
                                                 } else {
                                                     $_url = build_url(array('page' => 'admin', 'type' => $i[0]), 'adminzone');
                                                 }
                                                 require_lang('menus');
                                                 require_lang('security');
                                                 $tree->attach(do_template('BREADCRUMB_ESCAPED'));
                                                 $tree->attach(hyperlink($_url, do_lang_tempcode(strtoupper($i[0]))));
                                                 if ($type != 'misc') {
                                                     $tree->attach(do_template('BREADCRUMB_ESCAPED'));
                                                     $tree->attach(hyperlink(build_url(array('page' => $page, 'type' => 'misc'), $zone), $i[3]));
                                                 }
                                                 break 2;
                                             }
                                         }
                                     }
                                 } else {
                                     $tree->attach(do_template('BREADCRUMB_ESCAPED'));
                                     $tree->attach(hyperlink(build_url(array('page' => $page), $zone), $page));
                                 }
                             }
                             $_url = build_url(array('page' => $page, 'type' => $type), $zone);
                             $sup = $tree->is_empty() ? NULL : do_lang_tempcode('LOCATED_IN', $tree);
                             $site_tree_editor_url = build_url(array('page' => 'admin_sitetree', 'type' => 'site_tree', 'id' => $zone . ':' . $page), 'adminzone');
                             $permission_tree_editor_url = build_url(array('page' => 'admin_permissions', 'id' => $zone . ':' . $page), 'adminzone');
                             $content[$current_results_type]->attach(do_template('INDEX_SCREEN_FANCIER_ENTRY', array('NAME' => $n, 'URL' => $_url, 'TITLE' => '', 'DESCRIPTION' => do_lang_tempcode('FIND_IN_SITE_TREE_EDITOR', escape_html($site_tree_editor_url->evaluate()), escape_html($permission_tree_editor_url->evaluate())), 'SUP' => $sup)));
                         }
                     }
                 }
             }
         }
     }
     $current_results_type = do_lang('IMPORT');
     if ($this->_section_match($section_limitations, $current_results_type) && has_actual_page_access(get_member(), 'admin_import')) {
         // Importers
         $content[$current_results_type] = new ocp_tempcode();
         $hooks = find_all_hooks('modules', 'admin_import');
         foreach (array_keys($hooks) as $hook) {
             if ($this->_keyword_match($hook)) {
                 require_code('hooks/modules/admin_import/' . filter_naughty_harsh($hook));
                 $_hook = object_factory('Hook_' . filter_naughty_harsh($hook));
                 $info = $_hook->info();
                 $name = $info['product'];
                 $_url = build_url(array('page' => 'admin_import', 'type' => 'session', 'importer' => $hook), get_module_zone('admin_import'));
                 $content[$current_results_type]->attach(do_template('INDEX_SCREEN_FANCIER_ENTRY', array('NAME' => $name, 'URL' => $_url, 'TITLE' => '', 'DESCRIPTION' => '', 'SUP' => '')));
             }
         }
     }
     $current_results_type = do_lang('CONFIGURATION');
     if (($this->_section_match($section_limitations, $current_results_type) || $this->_section_match($section_limitations, do_lang('OPTION_CATEGORIES')) || $this->_section_match($section_limitations, do_lang('OPTION_GROUPS'))) && has_actual_page_access(get_member(), 'admin_config')) {
         // Config options- names, descriptions, groups, categories
         $content[$current_results_type] = new ocp_tempcode();
         $map = array();
         if (!is_null($GLOBALS['CURRENT_SHARE_USER'])) {
             $map['shared_hosting_restricted'] = 0;
         }
         $all_options = $GLOBALS['SITE_DB']->query_select('config', array('the_name', 'human_name', 'the_page', 'section', 'explanation', 'eval'), $map);
         $all_options[] = array('the_name' => 'timezone', 'human_name' => 'TIME_ZONE', 'config_value' => '', 'the_type' => 'special', 'eval' => '', 'the_page' => 'SITE', 'section' => 'GENERAL', 'explanation' => '', 'shared_hosting_restricted' => 0);
         $config_categories = array();
         $conf_found_count = 0;
         foreach ($all_options as $p) {
             if (defined('HIPHOP_PHP')) {
                 require_code('hooks/systems/config_default/' . $p['the_name']);
                 $hook = object_factory('Hook_config_default_' . $p['the_name']);
                 $null_test = $hook->get_default();
             } else {
                 $GLOBALS['REQUIRE_LANG_LOOP'] = 10;
                 // LEGACY Workaround for corrupt webhost installers
                 $null_test = eval($p['eval']);
                 $GLOBALS['REQUIRE_LANG_LOOP'] = 0;
                 // LEGACY
             }
             if (!is_null($null_test)) {
                 $n = do_lang_tempcode($p['human_name']);
                 switch ($p['the_name']) {
                     case 'timezone':
                         $t = do_lang('DESCRIPTION_TIMEZONE_SITE');
                         break;
                     default:
                         $t = do_lang($p['explanation'], NULL, NULL, NULL, NULL, false);
                         break;
                 }
                 if (is_null($n)) {
                     continue;
                 }
                 $config_value = array_key_exists('config_value', $p) ? $p['config_value'] : get_option($p['the_name']);
                 if ($config_value === false) {
                     continue;
                 }
                 if ($this->_keyword_match($p['the_name']) || $this->_keyword_match($n->evaluate()) || $this->_keyword_match($t) || $this->_keyword_match($config_value)) {
                     $_url = build_url(array('page' => 'admin_config', 'type' => 'category', 'id' => $p['the_page']), 'adminzone');
                     $url = $_url->evaluate();
                     $url .= '#group_' . $p['section'];
                     if (is_null($t)) {
                         $t = '';
                     }
                     $tree = new ocp_tempcode();
                     $tree->attach(hyperlink(build_url(array('page' => 'admin', 'type' => 'setup'), 'adminzone'), do_lang_tempcode('SETUP')));
                     $tree->attach(do_template('BREADCRUMB_ESCAPED'));
                     $tree->attach(hyperlink(build_url(array('page' => 'admin_config', 'type' => 'misc'), 'adminzone'), do_lang_tempcode('CONFIGURATION')));
                     $tree->attach(do_template('BREADCRUMB_ESCAPED'));
                     $tree->attach(hyperlink(build_url(array('page' => 'admin_config', 'type' => 'category', 'id' => $p['the_page']), 'adminzone'), do_lang('CONFIG_CATEGORY_' . $p['the_page'])));
                     $tree->attach(do_template('BREADCRUMB_ESCAPED'));
                     $tree->attach(hyperlink($url, do_lang($p['section'])));
                     $sup = do_lang_tempcode('LOCATED_IN', $tree);
                     $content[$current_results_type]->attach(do_template('INDEX_SCREEN_FANCIER_ENTRY', array('NAME' => $n, 'URL' => $url, 'TITLE' => '', 'DESCRIPTION' => protect_from_escaping($t), 'SUP' => $sup)));
                     if ($conf_found_count > 100) {
                         $content[$current_results_type] = do_template('INDEX_SCREEN_FANCIER_ENTRY', array('NAME' => do_lang_tempcode('TOO_MANY_TO_CHOOSE_FROM'), 'URL' => '', 'TITLE' => '', 'DESCRIPTION' => '', 'SUP' => ''));
                         break;
                     }
                     $conf_found_count++;
                     if (!array_key_exists($p['the_page'], $config_categories)) {
                         $config_categories[$p['the_page']] = array();
                     }
                     $config_categories[$p['the_page']][$p['section']] = 1;
                 }
             }
         }
         $current_results_type = do_lang('OPTION_CATEGORIES');
         $content[$current_results_type] = new ocp_tempcode();
         $current_results_type_2 = do_lang('OPTION_GROUPS');
         $content[$current_results_type_2] = new ocp_tempcode();
         foreach ($config_categories as $p => $groups) {
             $_n = do_lang('CONFIG_CATEGORY_' . $p, NULL, NULL, NULL, NULL, false);
             if (is_null($_n)) {
                 continue;
             }
             $n = do_lang_tempcode('CONFIG_CATEGORY_' . $p);
             if ($this->_keyword_match($n->evaluate())) {
                 $_url = build_url(array('page' => 'admin_config', 'type' => 'category', 'id' => $p), 'adminzone');
                 $description = do_lang_tempcode('CONFIG_CATEGORY_DESCRIPTION__' . $p);
                 $tree = new ocp_tempcode();
                 $tree->attach(hyperlink(build_url(array('page' => 'admin', 'type' => 'setup'), 'adminzone'), do_lang_tempcode('SETUP')));
                 $tree->attach(do_template('BREADCRUMB_ESCAPED'));
                 $tree->attach(hyperlink(build_url(array('page' => 'admin_config', 'type' => 'misc'), 'adminzone'), do_lang_tempcode('CONFIGURATION')));
                 $sup = do_lang_tempcode('LOCATED_IN', $tree);
                 $content[$current_results_type]->attach(do_template('INDEX_SCREEN_FANCIER_ENTRY', array('NAME' => $n, 'URL' => $_url, 'TITLE' => '', 'DESCRIPTION' => $description, 'SUP' => $sup)));
             }
             foreach (array_keys($groups) as $group) {
                 $n2 = do_lang($group, NULL, NULL, NULL, NULL, false);
                 if (is_null($n2)) {
                     continue;
                 }
                 if ($this->_keyword_match($n2)) {
                     $upload_max_filesize = ini_get('upload_max_filesize') == '0' ? do_lang('NA') : clean_file_size(php_return_bytes(ini_get('upload_max_filesize')));
                     $post_max_size = ini_get('post_max_size') == '0' ? do_lang('NA') : clean_file_size(php_return_bytes(ini_get('post_max_size')));
                     $_group_description = do_lang('CONFIG_GROUP_DESCRIP_' . $group, escape_html($post_max_size), escape_html($upload_max_filesize), NULL, NULL, false);
                     if (is_null($_group_description)) {
                         $group_description = new ocp_tempcode();
                     } else {
                         $group_description = do_lang_tempcode('CONFIG_GROUP_DESCRIP_' . $group, escape_html($post_max_size), escape_html($upload_max_filesize), false);
                     }
                     $_url = build_url(array('page' => 'admin_config', 'type' => 'category', 'id' => $p), 'adminzone');
                     $url = $_url->evaluate();
                     $url .= '#group_' . $group;
                     $tree = new ocp_tempcode();
                     $tree->attach(hyperlink(build_url(array('page' => 'admin', 'type' => 'setup'), 'adminzone'), do_lang_tempcode('SETUP')));
                     $tree->attach(do_template('BREADCRUMB_ESCAPED'));
                     $tree->attach(hyperlink(build_url(array('page' => 'admin_config', 'type' => 'misc'), 'adminzone'), do_lang_tempcode('CONFIGURATION')));
                     $tree->attach(do_template('BREADCRUMB_ESCAPED'));
                     $tree->attach(hyperlink(build_url(array('page' => 'admin_config', 'type' => 'category', 'id' => $p), 'adminzone'), do_lang('CONFIG_CATEGORY_' . $p)));
                     $sup = do_lang_tempcode('LOCATED_IN', $tree);
                     $content[$current_results_type_2]->attach(do_template('INDEX_SCREEN_FANCIER_ENTRY', array('NAME' => $n2, 'URL' => $url, 'TITLE' => '', 'DESCRIPTION' => $group_description, 'SUP' => $sup)));
                 }
             }
         }
     }
     $current_results_type = do_lang('USERGROUPS');
     if ($this->_section_match($section_limitations, $current_results_type) && has_actual_page_access(get_member(), 'admin_ocf_groups') && get_forum_type() == 'ocf') {
         // Usergroups
         $content[$current_results_type] = new ocp_tempcode();
         $map = array('g_is_private_club' => 0);
         $all_groups = $GLOBALS['FORUM_DB']->query_select('f_groups', array('id', 'g_name'), $map);
         foreach ($all_groups as $p) {
             $n = get_translated_text($p['g_name']);
             if ($this->_keyword_match($n)) {
                 $_url = build_url(array('page' => 'admin_ocf_groups', 'type' => '_ed', 'id' => $p['id']), 'adminzone');
                 $url = $_url->evaluate();
                 $tree = new ocp_tempcode();
                 $tree->attach(hyperlink(build_url(array('page' => 'admin', 'type' => 'security'), 'adminzone'), do_lang_tempcode('SECURITY')));
                 $tree->attach(do_template('BREADCRUMB_ESCAPED'));
                 $tree->attach(hyperlink(build_url(array('page' => 'admin_ocf_groups', 'type' => 'misc'), 'adminzone'), do_lang_tempcode('USERGROUPS')));
                 $tree->attach(do_template('BREADCRUMB_ESCAPED'));
                 $tree->attach(hyperlink(build_url(array('page' => 'admin_ocf_groups', 'type' => 'ed'), 'adminzone'), do_lang_tempcode('EDIT_GROUP')));
                 $sup = do_lang_tempcode('LOCATED_IN', $tree);
                 $content[$current_results_type]->attach(do_template('INDEX_SCREEN_FANCIER_ENTRY', array('NAME' => $n, 'URL' => $url, 'TITLE' => '', 'DESCRIPTION' => '', 'SUP' => $sup)));
             }
         }
     }
     $current_results_type = do_lang('THEMES');
     if ($this->_section_match($section_limitations, $current_results_type) && has_actual_page_access(get_member(), 'admin_themes')) {
         // Themes
         $content[$current_results_type] = new ocp_tempcode();
         $map = array();
         foreach (array(do_lang('SUPPORTS_WIDE'), do_lang('MOBILE_PAGES')) as $n) {
             if ($this->_keyword_match($n)) {
                 $_url = build_url(array('page' => 'admin_themes', 'type' => 'edit_theme', 'theme' => $GLOBALS['FORUM_DRIVER']->get_theme('')), 'adminzone');
                 $url = $_url->evaluate();
                 $tree = new ocp_tempcode();
                 $tree->attach(hyperlink(build_url(array('page' => 'admin', 'type' => 'style'), 'adminzone'), do_lang_tempcode('STYLE')));
                 $tree->attach(do_template('BREADCRUMB_ESCAPED'));
                 $tree->attach(hyperlink(build_url(array('page' => 'admin_themes', 'type' => 'misc'), 'adminzone'), do_lang_tempcode('THEMES')));
                 $sup = do_lang_tempcode('LOCATED_IN', $tree);
                 $content[$current_results_type]->attach(do_template('INDEX_SCREEN_FANCIER_ENTRY', array('NAME' => $n, 'URL' => $url, 'TITLE' => '', 'DESCRIPTION' => '', 'SUP' => $sup)));
                 break;
             }
         }
     }
     $current_results_type = do_lang('ZONES');
     if ($this->_section_match($section_limitations, $current_results_type) && has_actual_page_access(get_member(), 'admin_zones')) {
         // Zones
         $content[$current_results_type] = new ocp_tempcode();
         $map = array();
         $all_groups = $GLOBALS['SITE_DB']->query_select('zones', array('zone_name', 'zone_title', 'zone_header_text'), $map, 'ORDER BY zone_title', 50);
         foreach ($all_groups as $p) {
             $n = $p['zone_name'];
             $t = get_translated_text($p['zone_title']);
             $ht = get_translated_text($p['zone_header_text']);
             if ($this->_keyword_match($n) || $this->_keyword_match($t) || $this->_keyword_match($ht)) {
                 $_url = build_url(array('page' => 'admin_zones', 'type' => '_edit', 'id' => $p['zone_name']), 'adminzone');
                 $url = $_url->evaluate();
                 $tree = new ocp_tempcode();
                 $tree->attach(hyperlink(build_url(array('page' => 'admin', 'type' => 'setup'), 'adminzone'), do_lang_tempcode('STRUCTURE')));
                 $tree->attach(do_template('BREADCRUMB_ESCAPED'));
                 $tree->attach(hyperlink(build_url(array('page' => 'admin_zones', 'type' => 'misc'), 'adminzone'), do_lang_tempcode('ZONES')));
                 $tree->attach(do_template('BREADCRUMB_ESCAPED'));
                 $tree->attach(hyperlink(build_url(array('page' => 'admin_zones', 'type' => 'edit'), 'adminzone'), do_lang_tempcode('EDIT_ZONE')));
                 $sup = do_lang_tempcode('LOCATED_IN', $tree);
                 $content[$current_results_type]->attach(do_template('INDEX_SCREEN_FANCIER_ENTRY', array('NAME' => $n, 'URL' => $url, 'TITLE' => '', 'DESCRIPTION' => escape_html($t), 'SUP' => $sup)));
             }
         }
     }
     // Blocks
     $current_results_type = do_lang('_BLOCKS');
     if ($this->_section_match($section_limitations, $current_results_type)) {
         $content[$current_results_type] = new ocp_tempcode();
         $map = array();
         require_code('zones2');
         $all_blocks = find_all_blocks();
         foreach (array_keys($all_blocks) as $p) {
             $t = do_lang('BLOCK_' . $p . '_DESCRIPTION');
             if ($this->_keyword_match($p) || $this->_keyword_match($t)) {
                 $url = '';
                 $content[$current_results_type]->attach(do_template('INDEX_SCREEN_FANCIER_ENTRY', array('NAME' => $p, 'URL' => $url, 'TITLE' => '', 'DESCRIPTION' => escape_html($t))));
             }
         }
     }
     $current_results_type = do_lang('SPECIFIC_PERMISSIONS');
     if ($this->_section_match($section_limitations, $current_results_type) && has_actual_page_access(get_member(), 'admin_permissions')) {
         // Privileges- sections/names/descriptions
         $content[$current_results_type] = new ocp_tempcode();
         $all_permissions = $GLOBALS['SITE_DB']->query_select('sp_list', array('the_name', 'p_section'));
         $pt_sections = array();
         foreach ($all_permissions as $p) {
             $n = do_lang('PT_' . $p['the_name'], NULL, NULL, NULL, NULL, false);
             if (is_null($n)) {
                 continue;
             }
             if ($this->_keyword_match($n) || $this->_keyword_match($p['the_name'])) {
                 $_url = build_url(array('page' => 'admin_permissions', 'type' => 'specific', 'id' => $p['p_section']), 'adminzone');
                 $tree = new ocp_tempcode();
                 $tree->attach(hyperlink(build_url(array('page' => 'admin', 'type' => 'security'), 'adminzone'), do_lang_tempcode('SECURITY')));
                 $tree->attach(do_template('BREADCRUMB_ESCAPED'));
                 $tree->attach(hyperlink(build_url(array('page' => 'admin_permissions', 'type' => 'specific'), 'adminzone'), do_lang_tempcode('SPECIFIC_PERMISSIONS')));
                 $tree->attach(do_template('BREADCRUMB_ESCAPED'));
                 $tree->attach(hyperlink($_url, do_lang($p['p_section'])));
                 $sup = do_lang_tempcode('LOCATED_IN', $tree);
                 $content[$current_results_type]->attach(do_template('INDEX_SCREEN_FANCIER_ENTRY', array('NAME' => $n, 'URL' => $_url, 'TITLE' => '', 'DESCRIPTION' => '', 'SUP' => $sup)));
             }
             $pt_sections[$p['p_section']] = 1;
         }
         $current_results_type = do_lang('SPECIFIC_PERMISSION_SECTIONS');
         $content[$current_results_type] = new ocp_tempcode();
         foreach (array_keys($pt_sections) as $p) {
             $n = do_lang($p, NULL, NULL, NULL, NULL, false);
             if (is_null($n)) {
                 continue;
             }
             if ($this->_keyword_match($n) || $this->_keyword_match($p)) {
                 $_url = build_url(array('page' => 'admin_permissions', 'type' => 'specific', 'id' => $p), 'adminzone');
                 $tree = new ocp_tempcode();
                 $tree->attach(hyperlink(build_url(array('page' => 'admin', 'type' => 'security'), 'adminzone'), do_lang_tempcode('SECURITY')));
                 $tree->attach(do_template('BREADCRUMB_ESCAPED'));
                 $tree->attach(hyperlink(build_url(array('page' => 'admin_permissions', 'type' => 'specific'), 'adminzone'), do_lang_tempcode('SPECIFIC_PERMISSIONS')));
                 $sup = do_lang_tempcode('LOCATED_IN', $tree);
                 $content[$current_results_type]->attach(do_template('INDEX_SCREEN_FANCIER_ENTRY', array('NAME' => $n, 'URL' => $_url, 'TITLE' => '', 'DESCRIPTION' => '', 'SUP' => $sup)));
             }
         }
     }
     $current_results_type = do_lang('USERGROUP_SETTINGS');
     if ($this->_section_match($section_limitations, $current_results_type) && get_forum_type() == 'ocf' && has_actual_page_access(get_member(), 'admin_ocf_groups', 'adminzone')) {
         // Usergroup settings
         $content[$current_results_type] = new ocp_tempcode();
         $applicable_langstrings = array(array('ENQUIRE_ON_NEW_IPS', 'DESCRIPTION_ENQUIRE_ON_NEW_IPS'), array('FLOOD_CONTROL_ACCESS_SECS', 'DESCRIPTION_FLOOD_CONTROL_ACCESS_SECS'), array('FLOOD_CONTROL_SUBMIT_SECS', 'DESCRIPTION_FLOOD_CONTROL_SUBMIT_SECS'), array('MAX_ATTACHMENTS_PER_POST', 'DESCRIPTION_MAX_ATTACHMENTS_PER_POST'), array('MAX_DAILY_UPLOAD_MB', 'DESCRIPTION_MAX_DAILY_UPLOAD_MB'), array('MAX_AVATAR_WIDTH', 'DESCRIPTION_MAX_AVATAR_WIDTH'), array('MAX_AVATAR_HEIGHT', 'DESCRIPTION_MAX_AVATAR_HEIGHT'), array('MAX_POST_LENGTH_COMCODE', 'DESCRIPTION_MAX_POST_LENGTH_COMCODE'), array('MAX_SIG_LENGTH_COMCODE', 'DESCRIPTION_MAX_SIG_LENGTH_COMCODE'));
         if (addon_installed('points')) {
             $applicable_langstrings = array_merge($applicable_langstrings, array(array('GIFT_POINTS_BASE', 'DESCRIPTION_GIFT_POINTS_BASE'), array('GIFT_POINTS_PER_DAY', 'DESCRIPTION_GIFT_POINTS_PER_DAY')));
         }
         foreach ($applicable_langstrings as $_langstring) {
             $array = is_array($_langstring) ? $_langstring : array($_langstring);
             foreach ($array as $langstring) {
                 $n = do_lang($langstring);
                 if ($this->_keyword_match($n)) {
                     $n = do_lang_tempcode($array[0]);
                     $_url = build_url(array('page' => 'admin_ocf_groups', 'type' => 'ed'), 'adminzone');
                     $descrip = array_key_exists(1, $array) ? do_lang_tempcode($array[1]) : new ocp_tempcode();
                     $tree = new ocp_tempcode();
                     $tree->attach(hyperlink(build_url(array('page' => 'admin', 'type' => 'security'), 'adminzone'), do_lang_tempcode('SECURITY')));
                     $tree->attach(do_template('BREADCRUMB_ESCAPED'));
                     $tree->attach(hyperlink(build_url(array('page' => 'admin_ocf_groups', 'type' => 'misc'), 'adminzone'), do_lang_tempcode('USERGROUPS')));
                     $sup = do_lang_tempcode('LOCATED_IN', $tree);
                     $content[$current_results_type]->attach(do_template('INDEX_SCREEN_FANCIER_ENTRY', array('NAME' => $n, 'URL' => $_url, 'TITLE' => '', 'DESCRIPTION' => $descrip, 'SUP' => $sup)));
                     continue 2;
                 }
             }
         }
     }
     $current_results_type = do_lang('MEMBER_SETTINGS');
     if ($this->_section_match($section_limitations, $current_results_type) && get_forum_type() == 'ocf' && has_actual_page_access(get_member(), 'members')) {
         // Member settings
         $content[$current_results_type] = new ocp_tempcode();
         $applicable_langstrings = array(array('WIDE', 'DESCRIPTION_WIDE'), array('REVEAL_AGE', 'DESCRIPTION_REVEAL_AGE'), array('PREVIEW_POSTS', 'DESCRIPTION_PREVIEW_POSTS'), array('AUTO_NOTIFICATION_CONTRIB_CONTENT', 'DESCRIPTION_AUTO_NOTIFICATION_CONTRIB_CONTENT'), array('PT_RULES_TEXT', 'PT_RULES_TEXT_DESCRIPTION'));
         foreach ($applicable_langstrings as $_langstring) {
             $array = is_array($_langstring) ? $_langstring : array($_langstring);
             foreach ($array as $langstring) {
                 $n = do_lang($langstring);
                 if ($this->_keyword_match($n)) {
                     $n = do_lang_tempcode($array[0]);
                     $descrip = array_key_exists(1, $array) ? do_lang_tempcode($array[1]) : new ocp_tempcode();
                     $_url = build_url(array('page' => 'members', 'type' => 'view'), get_module_zone('members'), NULL, false, false, false, 'tab__edit');
                     $url = $_url->evaluate();
                     $content[$current_results_type]->attach(do_template('INDEX_SCREEN_FANCIER_ENTRY', array('NAME' => $n, 'URL' => $url, 'TITLE' => '', 'DESCRIPTION' => $descrip)));
                     continue 2;
                 }
             }
         }
     }
     // Zone options
     $current_results_type = do_lang('ZONE_OPTIONS');
     if ($this->_section_match($section_limitations, $current_results_type) && has_actual_page_access(get_member(), 'admin_zones', 'adminzone')) {
         $content[$current_results_type] = new ocp_tempcode();
         $applicable_langstrings = array(array('DEFAULT_PAGE', 'DESCRIPTION_DEFAULT_PAGE'), array('HEADER_TEXT', 'DESCRIPTION_HEADER_TEXT'), array('WIDE', 'DESCRIPTION_WIDE'), array('REQUIRE_SESSION', 'DESCRIPTION_REQUIRE_SESSION'), array('DISPLAYED_IN_MENU', 'DESCRIPTION_DISPLAYED_IN_MENU'), array('THEME', get_forum_type() == 'ocf' ? '_DESCRIPTION_THEME_OCF' : '_DESCRIPTION_THEME'));
         foreach ($applicable_langstrings as $_langstring) {
             $array = is_array($_langstring) ? $_langstring : array($_langstring);
             foreach ($array as $langstring) {
                 $n = do_lang($langstring);
                 if ($this->_keyword_match($n)) {
                     $n = do_lang_tempcode($array[0]);
                     $_url = build_url(array('page' => 'admin_zones', 'type' => 'edit'), 'adminzone');
                     $descrip = array_key_exists(1, $array) ? do_lang_tempcode($array[1]) : new ocp_tempcode();
                     $tree = new ocp_tempcode();
                     $tree->attach(hyperlink(build_url(array('page' => 'admin', 'type' => 'structure'), 'adminzone'), do_lang_tempcode('STRUCTURE')));
                     $tree->attach(do_template('BREADCRUMB_ESCAPED'));
                     $tree->attach(hyperlink(build_url(array('page' => 'admin_zones', 'type' => 'misc'), 'adminzone'), do_lang_tempcode('ZONES')));
                     $sup = do_lang_tempcode('LOCATED_IN', $tree);
                     $content[$current_results_type]->attach(do_template('INDEX_SCREEN_FANCIER_ENTRY', array('NAME' => $n, 'URL' => $_url, 'TITLE' => '', 'DESCRIPTION' => $descrip, 'SUP' => $sup)));
                     continue 2;
                 }
             }
         }
     }
     // Install options
     $current_results_type = do_lang('BASE_CONFIGURATION');
     if ($this->_section_match($section_limitations, $current_results_type) && $GLOBALS['FORUM_DRIVER']->is_super_admin(get_member())) {
         $content[$current_results_type] = new ocp_tempcode();
         if (file_exists(get_file_base() . '/config_editor.php')) {
             $file_contents = file_get_contents(get_file_base() . '/config_editor.php');
             $matches = array();
             $num_matches = preg_match_all('#case \'([^\']+)\':\\n\\s*\\$notes=\'([^\']+)\';#', $file_contents, $matches);
             for ($i = 0; $i < $num_matches; $i++) {
                 $n = stripslashes($matches[2][$i]);
                 if ($this->_keyword_match($n)) {
                     $url = get_base_url() . '/config_editor.php';
                     $content[$current_results_type]->attach(do_template('INDEX_SCREEN_FANCIER_ENTRY', array('NAME' => stripslashes($matches[1][$i]), 'URL' => $url, 'TITLE' => '', 'DESCRIPTION' => $n)));
                 }
             }
         }
     }
     // Language string names and contents
     $current_results_type = do_lang('MODULE_TRANS_NAME_admin_lang');
     if ($this->_section_match($section_limitations, $current_results_type) && has_actual_page_access(get_member(), 'admin_lang', 'adminzone')) {
         $content[$current_results_type] = new ocp_tempcode();
         if (user_lang() != fallback_lang()) {
             $content[$current_results_type]->attach(paragraph(do_lang_tempcode('SEARCH_LAUNCHPAD', escape_html(urlencode($raw_search_string)), escape_html(urlencode(user_lang())))));
         }
         global $LANGUAGE;
         $lang_file_contents = array();
         $lang_found = array();
         foreach ($LANGUAGE[user_lang()] as $n => $n_value) {
             if ($this->_keyword_match($n) || $this->_keyword_match($n_value)) {
                 $lang_found[$n] = $n_value;
                 if (count($lang_found) > 100) {
                     $content[$current_results_type]->attach(do_template('INDEX_SCREEN_FANCIER_ENTRY', array('NAME' => do_lang_tempcode('TOO_MANY_TO_CHOOSE_FROM'), 'URL' => '', 'TITLE' => '', 'DESCRIPTION' => '', 'SUP' => '')));
                     $lang_found = array();
                     break;
                 }
             }
         }
         foreach ($lang_found as $n => $n_value) {
             // Try and find what lang file it came from
             $lang_file = 'global';
             foreach (array('lang', 'lang_custom') as $lang_dir) {
                 $dh = @opendir(get_file_base() . '/' . $lang_dir . '/' . fallback_lang() . '/');
                 if ($dh !== false) {
                     while (($file = readdir($dh)) !== false) {
                         if (substr(strtolower($file), -4) == '.ini') {
                             if (!array_key_exists($file, $lang_file_contents)) {
                                 $lang_file_contents[$file] = file_get_contents(get_file_base() . '/' . $lang_dir . '/' . fallback_lang() . '/' . $file);
                             }
                             if (preg_match('#^' . str_replace('#', '\\#', preg_quote($n)) . '=#m', $lang_file_contents[$file]) != 0 || file_exists(get_custom_file_base() . '/lang_custom/' . user_lang() . '/' . $file) && preg_match('#^' . str_replace('#', '\\#', preg_quote($n)) . '=#m', file_get_contents(get_custom_file_base() . '/lang_custom/' . user_lang() . '/' . $file)) != 0) {
                                 $lang_file = basename($file, '.ini');
                                 break;
                             }
                         }
                     }
                 }
             }
             $_url = build_url(array('page' => 'admin_lang', 'type' => 'misc', 'lang' => user_lang(), 'lang_file' => $lang_file), 'adminzone');
             $url = $_url->evaluate();
             $url .= '#jmp_' . $n;
             $tree = new ocp_tempcode();
             $tree->attach(hyperlink(build_url(array('page' => 'admin', 'type' => 'style'), 'adminzone'), do_lang_tempcode('STYLE')));
             $tree->attach(do_template('BREADCRUMB_ESCAPED'));
             $tree->attach(hyperlink(build_url(array('page' => 'admin_lang', 'type' => 'misc'), 'adminzone'), do_lang_tempcode('TRANSLATE_CONTENT')));
             $tree->attach(do_template('BREADCRUMB_ESCAPED'));
             $tree->attach(hyperlink(build_url(array('page' => 'admin_lang', 'type' => 'misc', 'lang' => user_lang(), 'lang_file' => $lang_file), 'adminzone'), $lang_file));
             $sup = do_lang_tempcode('LOCATED_IN', $tree);
             $content[$current_results_type]->attach(do_template('INDEX_SCREEN_FANCIER_ENTRY', array('NAME' => $n, 'URL' => $url, 'TITLE' => '', 'DESCRIPTION' => escape_html($n_value), 'SUP' => $sup)));
         }
         $lang_file_contents = array();
     }
     // Theme images
     $current_results_type = do_lang('MANAGE_THEME_IMAGES');
     if ($this->_section_match($section_limitations, $current_results_type) && has_actual_page_access(get_member(), 'admin_themes', 'adminzone')) {
         $content[$current_results_type] = new ocp_tempcode();
         $images = $GLOBALS['SITE_DB']->query_select('theme_images', array('id', 'theme', 'lang'));
         foreach ($images as $image) {
             $n = $image['id'];
             if ($this->_keyword_match($n)) {
                 $_url = build_url(array('page' => 'admin_themes', 'type' => 'edit_image', 'theme' => $image['theme'], 'lang' => $image['lang'], 'id' => $n), 'adminzone');
                 $tree = new ocp_tempcode();
                 $tree->attach(hyperlink(build_url(array('page' => 'admin', 'type' => 'style'), 'adminzone'), do_lang_tempcode('STYLE')));
                 $tree->attach(do_template('BREADCRUMB_ESCAPED'));
                 $tree->attach(hyperlink(build_url(array('page' => 'admin_themes', 'type' => 'misc'), 'adminzone'), do_lang_tempcode('THEMES')));
                 $tree->attach(do_template('BREADCRUMB_ESCAPED'));
                 $tree->attach(hyperlink(build_url(array('page' => 'admin_themes', 'type' => 'edit_css', 'theme' => $image['theme']), 'adminzone'), do_lang_tempcode('EDIT_THEME_IMAGE')));
                 $tree->attach(do_template('BREADCRUMB_ESCAPED'));
                 $tree->attach(escape_html($image['theme']));
                 $sup = do_lang_tempcode('LOCATED_IN', $tree);
                 $lang = $image['lang'];
                 $lang_map = better_parse_ini_file(file_exists(get_file_base() . '/lang_custom/langs.ini') ? get_file_base() . '/lang_custom/langs.ini' : get_file_base() . '/lang/langs.ini');
                 $lang = array_key_exists($lang, $lang_map) ? $lang_map[$lang] : $lang;
                 $content[$current_results_type]->attach(do_template('INDEX_SCREEN_FANCIER_ENTRY', array('NAME' => $n, 'URL' => $_url, 'TITLE' => '', 'DESCRIPTION' => $lang, 'SUP' => $sup)));
             }
         }
     }
     // Template names
     $current_results_type = do_lang('TEMPLATES');
     if ($this->_section_match($section_limitations, $current_results_type) && has_actual_page_access(get_member(), 'admin_themes', 'adminzone')) {
         $content[$current_results_type] = new ocp_tempcode();
         $tpl_found = array();
         foreach (array('templates_custom', 'templates') as $template_dir) {
             $dh = opendir(get_file_base() . '/themes/default/' . $template_dir . '/');
             while (($file = readdir($dh)) !== false) {
                 if (substr(strtolower($file), -4) == '.tpl' && !array_key_exists($file, $tpl_found)) {
                     $n = $file;
                     if ($this->_keyword_match(basename($n, '.tpl')) || $this->_keyword_match($n) || $template_dir == 'templates_custom' && $this->_keyword_match(file_get_contents(get_file_base() . '/themes/default/' . $template_dir . '/' . $n))) {
                         $_url = build_url(array('page' => 'admin_themes', 'type' => '_edit_templates', 'theme' => $default_theme, 'f0file' => $file), 'adminzone');
                         $tree = new ocp_tempcode();
                         $tree->attach(hyperlink(build_url(array('page' => 'admin', 'type' => 'style'), 'adminzone'), do_lang_tempcode('STYLE')));
                         $tree->attach(do_template('BREADCRUMB_ESCAPED'));
                         $tree->attach(hyperlink(build_url(array('page' => 'admin_themes', 'type' => 'misc'), 'adminzone'), do_lang_tempcode('THEMES')));
                         $tree->attach(do_template('BREADCRUMB_ESCAPED'));
                         $tree->attach(hyperlink(build_url(array('page' => 'admin_themes', 'type' => 'edit_templates', 'theme' => $default_theme), 'adminzone'), do_lang_tempcode('EDIT_TEMPLATES')));
                         $sup = do_lang_tempcode('LOCATED_IN', $tree);
                         $content[$current_results_type]->attach(do_template('INDEX_SCREEN_FANCIER_ENTRY', array('NAME' => $n, 'URL' => $_url, 'TITLE' => '', 'DESCRIPTION' => '', 'SUP' => $sup)));
                         $tpl_found[$file] = 1;
                     }
                 }
             }
         }
     }
     // CSS file contents
     $current_results_type = 'CSS';
     if ($this->_section_match($section_limitations, $current_results_type) && has_actual_page_access(get_member(), 'admin_themes', 'adminzone')) {
         $content[$current_results_type] = new ocp_tempcode();
         $dh = opendir(get_file_base() . '/themes/default/css/');
         while (($file = readdir($dh)) !== false) {
             if (substr(strtolower($file), -4) == '.css') {
                 $n = $file;
                 if ($this->_keyword_match(file_get_contents(get_file_base() . '/themes/default/css/' . $n))) {
                     $_url = build_url(array('page' => 'admin_themes', 'type' => 'edit_css', 'theme' => $default_theme, 'file' => $file), 'adminzone');
                     $url = $_url->evaluate();
                     if (isset($keywords[0])) {
                         $url .= '#' . $keywords[0][0];
                     }
                     $tree = new ocp_tempcode();
                     $tree->attach(hyperlink(build_url(array('page' => 'admin', 'type' => 'style'), 'adminzone'), do_lang_tempcode('STYLE')));
                     $tree->attach(do_template('BREADCRUMB_ESCAPED'));
                     $tree->attach(hyperlink(build_url(array('page' => 'admin_themes', 'type' => 'misc'), 'adminzone'), do_lang_tempcode('THEMES')));
                     $tree->attach(do_template('BREADCRUMB_ESCAPED'));
                     $tree->attach(hyperlink(build_url(array('page' => 'admin_themes', 'type' => 'choose_css', 'theme' => $default_theme), 'adminzone'), do_lang_tempcode('EDIT_CSS')));
                     $sup = do_lang_tempcode('LOCATED_IN', $tree);
                     $content[$current_results_type]->attach(do_template('INDEX_SCREEN_FANCIER_ENTRY', array('NAME' => $n, 'URL' => $url, 'TITLE' => '', 'DESCRIPTION' => '', 'SUP' => $sup)));
                 }
             }
         }
     }
     //ksort($content);		Don't sort, we have an implicit good order in this code file
     // And show results...
     if (addon_installed('search')) {
         $_search_url = build_url(array('page' => 'search', 'type' => 'results', 'content' => $raw_search_string, 'days' => '-1', 'search_comcode_pages' => 1, 'all_defaults' => 1), get_module_zone('search'));
         $search_url = $_search_url->evaluate();
         $software_search_url = brand_base_url() . '/site/index.php?page=search&type=results&search_under=docs&search_comcode_pages=1&days=-1&content=' . urlencode($raw_search_string);
         $software_search_url_2 = brand_base_url() . '/site/index.php?page=search&type=results&search_ocf_posts=1&days=-1&content=' . urlencode($raw_search_string);
         $pre = do_lang_tempcode('ADMINZONE_SEARCH_RESULTS', escape_html($raw_search_string), escape_html($search_url), array(escape_html($software_search_url), escape_html($software_search_url_2)));
     } else {
         $pre = new ocp_tempcode();
     }
     $found_some = false;
     foreach ($content as $c) {
         if (!$c->is_empty()) {
             $found_some = true;
             break;
         }
     }
     $post = strpos($raw_search_string, '"') !== false || !$found_some ? new ocp_tempcode() : do_lang_tempcode('ADMINZONE_SEARCH_TIP', escape_html(preg_replace('#\\s@\\w+#', '', $raw_search_string)));
     if (!$found_some && $this->and_query) {
         $this->and_query = false;
         return $this->search();
     }
     return do_template('INDEX_SCREEN_FANCIER_SCREEN', array('TITLE' => get_page_title('ADMIN_ZONE_SEARCH_RESULTS'), 'EMPTY' => $found_some ? NULL : true, 'ARRAY' => true, 'CONTENT' => $content, 'PRE' => $pre, 'POST' => $post));
 }
Ejemplo n.º 5
0
/**
 * Get the maximum allowed upload filesize, as specified in the configuration
 *
 * @param  ?MEMBER		Member we consider quota for (NULL: do not consider quota)
 * @param  ?object		Database connection to get quota from (NULL: site DB)
 * @return integer		The maximum allowed upload filesize, in bytes
 */
function get_max_file_size($source_member = NULL, $connection = NULL)
{
    $possibilities = array();
    $a = php_return_bytes(ini_get('upload_max_filesize'));
    $b = php_return_bytes(ini_get('post_max_size'));
    $c = intval(get_option('max_download_size')) * 1024;
    if (has_specific_permission(get_member(), 'exceed_filesize_limit')) {
        $c = 0;
    }
    $d = mixed();
    if (!is_null($source_member) && !has_specific_permission(get_member(), 'exceed_filesize_limit')) {
        if (get_forum_type() == 'ocf') {
            require_code('ocf_groups');
            $daily_quota = ocf_get_member_best_group_property($source_member, 'max_daily_upload_mb');
        } else {
            $daily_quota = 5;
            // 5 is a hard-coded default for non-OCF forums
        }
        if (is_null($connection)) {
            $connection = $GLOBALS['SITE_DB'];
        }
        $_size_uploaded_today = $connection->query('SELECT SUM(a_file_size) AS the_answer FROM ' . $connection->get_table_prefix() . 'attachments WHERE a_member_id=' . strval((int) $source_member) . ' AND a_add_time>' . strval(time() - 60 * 60 * 24));
        $size_uploaded_today = intval($_size_uploaded_today[0]['the_answer']);
        $d = $daily_quota * 1024 * 1024 - $size_uploaded_today;
    }
    if ($a != 0) {
        $possibilities[] = $a;
    }
    if ($b != 0) {
        $possibilities[] = $b;
    }
    if ($c != 0) {
        $possibilities[] = $c;
    }
    if ($d !== NULL) {
        $possibilities[] = $d;
    }
    return min($possibilities);
}