Example #1
0
/**
 * Get an array of all the installed languages that can be found in root/lang/ and root/lang_custom/
 *
 * @param  boolean			Whether to even find empty languages
 * @return array				The installed languages (map, lang=>type)
 */
function _find_all_langs($even_empty_langs = false)
{
    $_dir = opendir(get_file_base() . '/lang/');
    $_langs = array();
    while (false !== ($file = readdir($_dir))) {
        if (!should_ignore_file('lang/' . $file, IGNORE_ACCESS_CONTROLLERS) && strlen($file) <= 5) {
            if (is_dir(get_file_base() . '/lang/' . $file)) {
                $_langs[$file] = 'lang';
            }
        }
    }
    closedir($_dir);
    if (!in_safe_mode()) {
        $_dir = @opendir(get_custom_file_base() . '/lang_custom/');
        if ($_dir !== false) {
            while (false !== ($file = readdir($_dir))) {
                if (!should_ignore_file('lang_custom/' . $file, IGNORE_ACCESS_CONTROLLERS) && strlen($file) <= 5) {
                    if (is_dir(get_custom_file_base() . '/lang_custom/' . $file)) {
                        if ($even_empty_langs || is_file(get_custom_file_base() . '/lang_custom/' . $file . '/global.ini')) {
                            $_langs[$file] = 'lang_custom';
                        } else {
                            $_dir2 = opendir(get_custom_file_base() . '/lang_custom/' . $file);
                            while (false !== ($file2 = readdir($_dir2))) {
                                if (substr($file2, -4) == '.ini' || substr($file2, -3) == '.po') {
                                    $_langs[$file] = 'lang_custom';
                                    break;
                                }
                            }
                        }
                    }
                }
            }
            closedir($_dir);
        }
        if (get_custom_file_base() != get_file_base()) {
            $_dir = opendir(get_file_base() . '/lang_custom/');
            while (false !== ($file = readdir($_dir))) {
                if (!should_ignore_file('lang_custom/' . $file, IGNORE_ACCESS_CONTROLLERS) && strlen($file) <= 5) {
                    if ($even_empty_langs) {
                        $_langs[$file] = 'lang_custom';
                    } else {
                        $_dir2 = opendir(get_file_base() . '/lang_custom/' . $file);
                        while (false !== ($file2 = readdir($_dir2))) {
                            if (substr($file2, -4) == '.ini' || substr($file2, -3) == '.po') {
                                $_langs[$file] = 'lang_custom';
                                break;
                            }
                        }
                    }
                }
            }
            closedir($_dir);
        }
    }
    return $_langs;
}
Example #2
0
function require_javascript($javascript)
{
    if ($javascript == 'javascript_swfupload' && !in_safe_mode()) {
        if (!function_exists('tacit_https') || !tacit_https()) {
            global $EXTRA_HEAD;
            $EXTRA_HEAD->attach('
				<!-- Third party script for BrowserPlus runtime (Google Gears included in Gears runtime now) -->
				<script type="text/javascript" src="http://bp.yahooapis.com/2.4.21/browserplus-min.js"></script>
			');
        }
        $javascript = 'javascript_plupload';
    }
    non_overrided__require_javascript($javascript);
}
Example #3
0
 /**
  * Standard modular run function for do_next_menu hooks. They find links to put on standard navigation menus of the system.
  *
  * @return array			Array of links and where to show
  */
 function run()
 {
     $has_langs = false;
     $_dir = opendir(get_file_base() . '/lang/');
     $_langs = array();
     while (false !== ($file = readdir($_dir))) {
         if ($file == fallback_lang()) {
             continue;
         }
         if (!should_ignore_file('lang/' . $file, IGNORE_ACCESS_CONTROLLERS) && strlen($file) <= 5) {
             if (is_dir(get_file_base() . '/lang/' . $file)) {
                 $has_langs = true;
             }
         }
     }
     closedir($_dir);
     if (!in_safe_mode()) {
         $_dir = @opendir(get_custom_file_base() . '/lang_custom/');
         if ($_dir !== false) {
             while (false !== ($file = readdir($_dir))) {
                 if ($file == fallback_lang()) {
                     continue;
                 }
                 if (!should_ignore_file('lang_custom/' . $file, IGNORE_ACCESS_CONTROLLERS) && strlen($file) <= 5) {
                     if (is_dir(get_custom_file_base() . '/lang_custom/' . $file)) {
                         $has_langs = true;
                     }
                 }
             }
             closedir($_dir);
         }
         if (get_custom_file_base() != get_file_base()) {
             $_dir = opendir(get_file_base() . '/lang_custom/');
             while (false !== ($file = readdir($_dir))) {
                 if ($file == fallback_lang()) {
                     continue;
                 }
                 if (!should_ignore_file('lang_custom/' . $file, IGNORE_ACCESS_CONTROLLERS) && strlen($file) <= 5) {
                     $has_langs = true;
                 }
             }
             closedir($_dir);
         }
     }
     return array(array('style', 'language', array('admin_lang', array('type' => 'misc'), get_module_zone('admin_lang')), do_lang_tempcode('TRANSLATE_CODE'), 'DOC_TRANSLATE'), multi_lang() ? array('style', 'language', array('admin_lang', array('type' => 'content'), get_module_zone('admin_lang')), do_lang_tempcode('TRANSLATE_CONTENT'), 'DOC_TRANSLATE_CONTENT') : NULL, !$has_langs ? NULL : array('style', 'criticise_language', array('admin_lang', array('type' => 'criticise'), get_module_zone('admin_lang')), do_lang_tempcode('CRITICISE_LANGUAGE_PACK'), 'DOC_CRITICISE_LANGUAGE_PACK'));
 }
Example #4
0
 function testRelationsdefined()
 {
     require_code('relations');
     if (in_safe_mode()) {
         $this->assertTrue(false, 'Cannot work in safe mode');
         return;
     }
     /* Actually only done for complex ones
     		$all_tables=$GLOBALS['SITE_DB']->query('SELECT DISTINCT m_table FROM '.get_table_prefix().'db_meta WHERE m_type LIKE \''.db_encode_like('%AUTO_LINK%').'\' ORDER BY m_table');
     		$table_descriptions=get_table_descriptions();
     
     		foreach ($all_tables as $t)
     		{
     			$this->assertFalse(!array_key_exists($t['m_table'],$table_descriptions),'Table not described: '.$t['m_table']);
     		}*/
     $all_links = $GLOBALS['SITE_DB']->query('SELECT m_table,m_name FROM ' . get_table_prefix() . 'db_meta WHERE m_type LIKE \'' . db_encode_like('%AUTO_LINK%') . '\' ORDER BY m_table');
     $links = get_relation_map();
     foreach ($all_links as $l) {
         $_l = $l['m_table'] . '.' . $l['m_name'];
         $this->assertFalse(!array_key_exists($_l, $links), 'Link not described: ' . $_l);
     }
 }
Example #5
0
/**
 * Search for a template.
 *
 * @param  ID_TEXT			The codename of the template being loaded
 * @param  ?LANGUAGE_NAME 	The language to load the template in (templates can embed language references) (NULL: users own language)
 * @param  ID_TEXT			The theme to use
 * @param  string				File type suffix of template file (e.g. .tpl)
 * @param  string				Subdirectory type to look in
 * @set    templates css
 * @return ?array				List of parameters needed for the _do_template function to be able to load the template (NULL: could not find the template)
 */
function find_template_place($codename, $lang, $theme, $suffix, $type)
{
    global $FILE_ARRAY, $CURRENT_SHARE_USER;
    static $tp_cache = array();
    $sz = serialize(array($codename, $lang, $theme, $suffix, $type));
    if (isset($tp_cache[$sz])) {
        return $tp_cache[$sz];
    }
    $prefix_default = get_file_base() . '/themes/';
    $prefix = $theme == 'default' ? $prefix_default : get_custom_file_base() . '/themes/';
    if (!isset($FILE_ARRAY)) {
        if (is_file($prefix . $theme . '/' . $type . '_custom/' . $codename . $suffix) && !in_safe_mode()) {
            $place = array($theme, '/' . $type . '_custom/');
        } elseif (is_file($prefix . $theme . '/' . $type . '/' . $codename . $suffix)) {
            $place = array($theme, '/' . $type . '/');
        } elseif ($CURRENT_SHARE_USER !== NULL && $theme != 'default' && is_file(get_file_base() . '/themes/' . $theme . '/' . $type . '_custom/' . $codename . $suffix)) {
            $place = array($theme, '/' . $type . '_custom/');
        } elseif ($CURRENT_SHARE_USER !== NULL && $theme != 'default' && is_file(get_file_base() . '/themes/' . $theme . '/' . $type . '/' . $codename . $suffix)) {
            $place = array($theme, '/' . $type . '/');
        } elseif ($CURRENT_SHARE_USER !== NULL && is_file(get_custom_file_base() . '/themes/default/' . $type . '_custom/' . $codename . $suffix)) {
            $place = array('default', '/' . $type . '_custom/');
        } elseif ($CURRENT_SHARE_USER !== NULL && is_file(get_custom_file_base() . '/themes/default/' . $type . '/' . $codename . $suffix)) {
            $place = array('default', '/' . $type . '/');
        } elseif (is_file($prefix_default . 'default' . '/' . $type . '_custom/' . $codename . $suffix) && !in_safe_mode()) {
            $place = array('default', '/' . $type . '_custom/');
        } elseif (is_file($prefix_default . 'default' . '/' . $type . '/' . $codename . $suffix)) {
            $place = array('default', '/' . $type . '/');
        } else {
            $place = NULL;
        }
        if ($place === NULL) {
            $dh = opendir(get_file_base() . '/themes');
            while ($possible_theme = readdir($dh)) {
                if (substr($possible_theme, 0, 1) != '.' && $possible_theme != 'default' && $possible_theme != $theme && $possible_theme != 'map.ini' && $possible_theme != 'index.html') {
                    $fullpath = get_custom_file_base() . '/themes/' . $possible_theme . '/' . $type . '_custom/' . $codename . $suffix;
                    if (is_file($fullpath)) {
                        $place = array($possible_theme, '/' . $type . '_custom/');
                        break;
                    }
                }
            }
            closedir($dh);
        }
    } else {
        $place = array('default', '/' . $type . '/');
    }
    $tp_cache[$sz] = $place;
    return $place;
}
Example #6
0
/**
 * Take the specified parameters, and try to find the corresponding page
 *
 * @param  ID_TEXT			The codename of the page to load
 * @param  ID_TEXT			The zone the page is being loaded in
 * @param  ?ID_TEXT			The type of page - for if you know it (NULL: don't know it)
 * @param  ?LANGUAGE_NAME	Language name (NULL: users language)
 * @param  boolean			Whether to not check for redirects (normally you would)
 * @return ~array				A list of details (false: page not found)
 */
function _request_page($codename, $zone, $page_type = NULL, $lang = NULL, $no_redirect_check = false)
{
    if ($lang === NULL) {
        $lang = user_lang();
    }
    if ($codename == 'login') {
        $login_zone = get_module_zone('login');
        $path = zone_black_magic_filterer($login_zone . ($login_zone == '' ? '' : '/') . 'pages/modules_custom/' . $codename . '.php', true);
        if (is_file(get_file_base() . '/' . $path)) {
            return array('MODULES_CUSTOM', $login_zone, $codename, $path);
        }
        $path = zone_black_magic_filterer($login_zone . ($login_zone == '' ? '' : '/') . 'pages/modules/' . $codename . '.php', true);
        if (is_file(get_file_base() . '/' . $path)) {
            return array('MODULES', $login_zone, $codename, $path);
        }
    }
    // Redirect
    if (!$no_redirect_check && addon_installed('redirects_editor')) {
        global $REDIRECT_CACHE;
        if (array_key_exists($zone, $REDIRECT_CACHE)) {
            $redirect = array_key_exists($codename, $REDIRECT_CACHE[$zone]) ? array($REDIRECT_CACHE[$zone][$codename]) : array();
        } else {
            $redirect = $GLOBALS['SITE_DB']->query_select('redirects', array('*'), array('r_from_zone' => $zone, 'r_from_page' => $codename), '', 1);
        }
        if (array_key_exists(0, $redirect)) {
            return array('REDIRECT', $redirect[0]);
        }
    }
    //If we know the page type
    if ($page_type !== NULL) {
        switch ($page_type) {
            case 'modules_custom':
                if (!in_safe_mode()) {
                    $path = zone_black_magic_filterer($zone . ($zone == '' ? '' : '/') . 'pages/modules_custom/' . $codename . '.php', true);
                    if (is_file(get_file_base() . '/' . $path)) {
                        return array('MODULES_CUSTOM', $zone, $codename, $path);
                    }
                }
                break;
            case 'modules':
                $path = zone_black_magic_filterer($zone . ($zone == '' ? '' : '/') . 'pages/modules/' . $codename . '.php', true);
                if (is_file(get_file_base() . '/' . $path)) {
                    return array('MODULES', $zone, $codename, $path);
                }
                break;
            case 'comcode_custom':
                if (!in_safe_mode()) {
                    if (get_param_integer('keep_theme_test', 0) == 1) {
                        $path = zone_black_magic_filterer($zone . ($zone == '' ? '' : '/') . 'pages/comcode_custom/' . $lang . '/' . $GLOBALS['FORUM_DRIVER']->get_theme() . '__' . $codename . '.txt', true);
                        if (is_file(get_custom_file_base() . '/' . $path)) {
                            return array('COMCODE_CUSTOM', $zone, $GLOBALS['FORUM_DRIVER']->get_theme() . '__' . $codename, $lang, $path);
                        }
                    }
                    $path = zone_black_magic_filterer($zone . ($zone == '' ? '' : '/') . 'pages/comcode_custom/' . $lang . '/' . $codename . '.txt', true);
                    if (is_file(get_custom_file_base() . '/' . $path)) {
                        return array('COMCODE_CUSTOM', $zone, $codename, $lang, $path);
                    }
                    if ($GLOBALS['CURRENT_SHARE_USER'] !== NULL) {
                        $path = zone_black_magic_filterer($zone . ($zone == '' ? '' : '/') . 'pages/comcode_custom/' . $lang . '/' . $codename . '.txt', true);
                        if (is_file(get_file_base() . '/' . $path)) {
                            return array('COMCODE_CUSTOM_PURE', $zone, $codename, $lang, $path);
                        }
                    }
                }
                //break;
            //break;
            case 'comcode':
                $path = zone_black_magic_filterer($zone . ($zone == '' ? '' : '/') . 'pages/comcode/' . $lang . '/' . $codename . '.txt', true);
                if (is_file(get_file_base() . '/' . $path)) {
                    return array('COMCODE', $zone, $codename, $lang, $path);
                }
                break;
            case 'html_custom':
                if (!in_safe_mode()) {
                    $path = zone_black_magic_filterer($zone . ($zone == '' ? '' : '/') . 'pages/html_custom/' . $lang . '/' . $codename . '.htm', true);
                    if (is_file(get_custom_file_base() . '/' . $path)) {
                        return array('HTML_CUSTOM', $zone, $codename, $lang, $path);
                    }
                }
                break;
            case 'html':
                $path = zone_black_magic_filterer($zone . ($zone == '' ? '' : '/') . 'pages/html/' . $lang . '/' . $codename . '.htm', true);
                if (is_file(get_file_base() . '/' . $path)) {
                    return array('HTML', $zone, $codename, $lang, $path);
                }
                break;
            case 'minimodules_custom':
                if (!in_safe_mode()) {
                    $path = zone_black_magic_filterer($zone . ($zone == '' ? '' : '/') . 'pages/minimodules_custom/' . $lang . '/' . $codename . '.php', true);
                    if (is_file(get_file_base() . '/' . $path)) {
                        return array('MINIMODULES_CUSTOM', $zone, $codename, $path);
                    }
                }
                break;
            case 'minimodules':
                $path = zone_black_magic_filterer($zone . ($zone == '' ? '' : '/') . 'pages/minimodules/' . $lang . '/' . $codename . '.php', true);
                if (is_file(get_file_base() . '/' . $path)) {
                    return array('MINIMODULES', $zone, $codename, $path);
                }
                break;
        }
        return false;
    }
    // We have a priority list to find our page
    if (!in_safe_mode()) {
        $path = zone_black_magic_filterer($zone . ($zone == '' ? '' : '/') . 'pages/modules_custom/' . $codename . '.php', true);
        if (is_file(get_file_base() . '/' . $path)) {
            return array('MODULES_CUSTOM', $zone, $codename, $path);
        }
    }
    $path = zone_black_magic_filterer($zone . ($zone == '' ? '' : '/') . 'pages/modules/' . $codename . '.php', true);
    if (is_file(get_file_base() . '/' . $path)) {
        return array('MODULES', $zone, $codename, $path);
    }
    if (!in_safe_mode()) {
        if (get_param_integer('keep_theme_test', 0) == 1) {
            $path = zone_black_magic_filterer($zone . ($zone == '' ? '' : '/') . 'pages/comcode_custom/' . $lang . '/' . $GLOBALS['FORUM_DRIVER']->get_theme() . '__' . $codename . '.txt', true);
            if (is_file(get_custom_file_base() . '/' . $path)) {
                return array('COMCODE_CUSTOM', $zone, $GLOBALS['FORUM_DRIVER']->get_theme() . '__' . $codename, $lang, $path);
            }
        }
        $path = zone_black_magic_filterer($zone . ($zone == '' ? '' : '/') . 'pages/comcode_custom/' . $lang . '/' . $codename . '.txt', true);
        if (is_file(get_custom_file_base() . '/' . $path)) {
            return array('COMCODE_CUSTOM', $zone, $codename, $lang, $path);
        }
        if ($GLOBALS['CURRENT_SHARE_USER'] !== NULL) {
            $path = zone_black_magic_filterer($zone . ($zone == '' ? '' : '/') . 'pages/comcode_custom/' . $lang . '/' . $codename . '.txt', true);
            if (is_file(get_file_base() . '/' . $path)) {
                return array('COMCODE_CUSTOM_PURE', $zone, $codename, $lang, $path);
            }
        }
    }
    $path = zone_black_magic_filterer($zone . ($zone == '' ? '' : '/') . 'pages/comcode/' . $lang . '/' . $codename . '.txt', true);
    if (is_file(get_file_base() . '/' . $path)) {
        return array('COMCODE', $zone, $codename, $lang, $path);
    }
    if (!in_safe_mode()) {
        $path = zone_black_magic_filterer($zone . ($zone == '' ? '' : '/') . 'pages/html_custom/' . $lang . '/' . $codename . '.htm', true);
        if (is_file(get_custom_file_base() . '/' . $path)) {
            return array('HTML_CUSTOM', $zone, $codename, $lang, $path);
        }
    }
    $path = zone_black_magic_filterer($zone . ($zone == '' ? '' : '/') . 'pages/html/' . $lang . '/' . $codename . '.htm', true);
    if (is_file(get_file_base() . '/' . $path)) {
        return array('HTML', $zone, $codename, $lang, $path);
    }
    if (!in_safe_mode()) {
        $path = zone_black_magic_filterer($zone . ($zone == '' ? '' : '/') . 'pages/minimodules_custom/' . $codename . '.php', true);
        if (is_file(get_file_base() . '/' . $path)) {
            return array('MINIMODULES_CUSTOM', $zone, $codename, $path);
        }
    }
    $path = zone_black_magic_filterer($zone . ($zone == '' ? '' : '/') . 'pages/minimodules/' . $codename . '.php', true);
    if (is_file(get_file_base() . '/' . $path)) {
        return array('MINIMODULES', $zone, $codename, $path);
    }
    // As a last resort, consider it might not yet have been translated
    $fallback_lang = fallback_lang();
    $site_lang = get_site_default_lang();
    $langs_to_try = array();
    if ($lang != $site_lang) {
        $langs_to_try[] = $site_lang;
    }
    if ($lang != $fallback_lang) {
        $langs_to_try[] = $fallback_lang;
    }
    foreach ($langs_to_try as $fallback_lang) {
        if (!in_safe_mode()) {
            $path = zone_black_magic_filterer($zone . ($zone == '' ? '' : '/') . 'pages/comcode_custom/' . $fallback_lang . '/' . $codename . '.txt', true);
            if (is_file(get_custom_file_base() . '/' . $path)) {
                return array('COMCODE_CUSTOM', $zone, $codename, $fallback_lang, $path);
            }
            if ($GLOBALS['CURRENT_SHARE_USER'] !== NULL) {
                $path = zone_black_magic_filterer($zone . ($zone == '' ? '' : '/') . 'pages/comcode_custom/' . $fallback_lang . '/' . $codename . '.txt', true);
                if (is_file(get_file_base() . '/' . $path)) {
                    return array('COMCODE_CUSTOM_PURE', $zone, $codename, $fallback_lang, $path);
                }
            }
        }
        $path = zone_black_magic_filterer($zone . ($zone == '' ? '' : '/') . 'pages/comcode/' . $fallback_lang . '/' . $codename . '.txt', true);
        if (is_file(get_file_base() . '/' . $path)) {
            return array('COMCODE', $zone, $codename, $fallback_lang, $path);
        }
        if (!in_safe_mode()) {
            $path = zone_black_magic_filterer($zone . ($zone == '' ? '' : '/') . 'pages/html_custom/' . $fallback_lang . '/' . $codename . '.htm', true);
            if (is_file(get_custom_file_base() . '/' . $path)) {
                return array('HTML_CUSTOM', $zone, $codename, $fallback_lang, $path);
            }
        }
        $path = zone_black_magic_filterer($zone . ($zone == '' ? '' : '/') . 'pages/html/' . $fallback_lang . '/' . $codename . '.htm', true);
        if (is_file(get_file_base() . '/' . $path)) {
            return array('HTML', $zone, $codename, $fallback_lang, $path);
        }
    }
    return false;
}
Example #7
0
/**
 * Find whether the specified page is to use HTTPS (if not -- it will use HTTP).
 * All images (etc) on a HTTPS page should use HTTPS to avoid mixed-content browser notices.
 *
 * @param  ID_TEXT		The zone the page is in
 * @param  ID_TEXT		The page codename
 * @return boolean		Whether the page is to run across an HTTPS connection
 */
function is_page_https($zone, $page)
{
    if (get_option('enable_https', true) == '0') {
        return false;
    }
    if (in_safe_mode()) {
        return false;
    }
    if ($page == 'login' && get_page_name() == 'login') {
        if (tacit_https()) {
            return true;
        }
    }
    global $HTTPS_PAGES;
    if ($HTTPS_PAGES === NULL && function_exists('persistant_cache_get')) {
        $HTTPS_PAGES = persistant_cache_get('HTTPS_PAGES');
    }
    if ($HTTPS_PAGES === NULL) {
        $results = $GLOBALS['SITE_DB']->query('SELECT * FROM ' . get_table_prefix() . 'https_pages', NULL, NULL, true);
        if ($results === false || $results === NULL) {
            $HTTPS_PAGES = array();
            return false;
        }
        $HTTPS_PAGES = collapse_1d_complexity('https_page_name', $results);
        if (function_exists('persistant_cache_set')) {
            persistant_cache_set('HTTPS_PAGES', $HTTPS_PAGES);
        }
    }
    return in_array($zone . ':' . $page, $HTTPS_PAGES);
}
Example #8
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));
 }
Example #9
0
/**
 * Force a CSS file to be cached.
 *
 * @param  string			The CSS file required
 * @param  ?ID_TEXT		The name of the theme (NULL: current theme)
 * @param  ?boolean		Whether to minify (NULL: read from environment)
 * @return string			The path to the CSS file in the cache (blank: no file)
 */
function css_enforce($c, $theme = NULL, $minify = NULL)
{
    $text_only = get_param_integer('keep_textonly', 0) == 1;
    if ($text_only) {
        $c .= '_textonly';
    }
    if ($minify === NULL) {
        $minify = get_param_integer('keep_no_minify', 0) == 0;
    }
    global $SITE_INFO;
    // Make sure the CSS file exists
    if ($theme === NULL) {
        $theme = @method_exists($GLOBALS['FORUM_DRIVER'], 'get_theme') ? $GLOBALS['FORUM_DRIVER']->get_theme() : 'default';
    }
    $active_theme = $theme;
    $dir = get_custom_file_base() . '/themes/' . $theme . '/templates_cached/' . filter_naughty(user_lang());
    if (!isset($SITE_INFO['no_disk_sanity_checks']) || $SITE_INFO['no_disk_sanity_checks'] == '0') {
        if (!is_dir($dir)) {
            if (@mkdir($dir, 0777) === false) {
                warn_exit(do_lang_tempcode('WRITE_ERROR_DIRECTORY_REPAIR', escape_html($dir)));
            }
            fix_permissions($dir, 0777);
            sync_file($dir);
        }
    }
    $css_cache_path = $dir . '/' . filter_naughty_harsh($c);
    if (!$minify) {
        $css_cache_path .= '_non_minified';
    }
    if (get_option('enable_https', true) == '1' && function_exists('is_page_https') && function_exists('get_zone_name') && (tacit_https() || is_page_https(get_zone_name(), get_page_name()))) {
        $css_cache_path .= '_ssl';
    }
    if (is_mobile()) {
        $css_cache_path .= '_mobile';
    }
    $css_cache_path .= '.css';
    global $CACHE_TEMPLATES;
    $support_smart_decaching = !isset($SITE_INFO['disable_smart_decaching']) || $SITE_INFO['disable_smart_decaching'] == '0';
    $is_cached = ($CACHE_TEMPLATES || !running_script('index')) && @(filesize($css_cache_path) != 0) && !is_browser_decacheing() && !in_safe_mode();
    if ($support_smart_decaching || !$is_cached || $text_only) {
        $found = find_template_place($c, '', $theme, '.css', 'css');
        if ($found === NULL) {
            return '';
        }
        $theme = $found[0];
        $fullpath = get_custom_file_base() . '/themes/' . $theme . $found[1] . $c . '.css';
        if (!is_file($fullpath)) {
            $fullpath = get_file_base() . '/themes/' . $theme . $found[1] . $c . '.css';
        }
        if ($text_only && !is_file($fullpath)) {
            return '';
        }
    }
    if (!$is_cached || $support_smart_decaching && (@(filemtime($css_cache_path) < filemtime($fullpath)) && @filemtime($fullpath) < time())) {
        require_code('css_and_js');
        css_compile($active_theme, $theme, $c, $fullpath, $css_cache_path, $minify);
    }
    if (@filesize($css_cache_path) == 0) {
        return '';
    }
    return $css_cache_path;
}
Example #10
0
/**
 * Get a tempcoded version of a normal XHTML template. It is perhaps the most common ocPortal function to load up templates using do_template, and then attach them together either as parameters to each other, or via the tempcode attach method.
 *
 * @param  ID_TEXT			The codename of the template being loaded
 * @param  ?array				A map of parameters for the template (key to value) (NULL: no parameters)
 * @param  ?LANGUAGE_NAME 	The language to load the template in (templates can embed language references) (NULL: users own language)
 * @param  boolean			Whether to not produce a stack dump if the template is missing
 * @param  ?ID_TEXT			Alternate template to use if the primary one does not exist (NULL: none)
 * @param  string				File type suffix of template file (e.g. .tpl)
 * @param  string				Subdirectory type to look in
 * @set    templates css
 * @param  ?ID_TEXT			Theme to use (NULL: current theme)
 * @return tempcode			The tempcode for this template
 */
function do_template($codename, $parameters = NULL, $lang = NULL, $light_error = false, $fallback = NULL, $suffix = '.tpl', $type = 'templates', $theme = NULL)
{
    if (!isset($lang) || $lang == '') {
        global $USER_LANG_CACHED;
        $lang = isset($USER_LANG_CACHED) ? $USER_LANG_CACHED : (function_exists('user_lang') ? user_lang() : 'EN');
    }
    if ($GLOBALS['SEMI_DEBUG_MODE']) {
        if ($codename == strtolower($codename) && $type != 'css' && $codename != 'tempcode_test' && $codename != 'handle_conflict_resolution') {
            fatal_exit('Template names should be in upper case, and the files should be stored in upper case.');
        }
        if (substr($codename, -7) == '_SCREEN' || substr($codename, -8) == '_OVERLAY' || $codename == 'POOR_XHTML_WRAPPER' || $codename == 'OCF_WRAPPER') {
            $GLOBALS['SCREEN_TEMPLATE_CALLED'] = $codename;
        }
    }
    global $TEMPLATE_PREVIEW_OP, $RECORD_TEMPLATES_USED, $RECORDED_TEMPLATES_USED, $FILE_ARRAY, $MEM_CACHE, $KEEP_MARKERS, $SHOW_EDIT_LINKS, $XHTML_SPIT_OUT, $CACHE_TEMPLATES, $FORUM_DRIVER, $POSSIBLY_IN_SAFE_MODE, $CACHED_THEME, $CACHED_FOUND, $LOADED_TPL_CACHE;
    $special_treatment = ($KEEP_MARKERS || $SHOW_EDIT_LINKS) && is_null($XHTML_SPIT_OUT);
    if ($RECORD_TEMPLATES_USED) {
        $RECORDED_TEMPLATES_USED[] = $codename;
    }
    // Variables we'll need
    if (!isset($theme)) {
        $theme = isset($CACHED_THEME) ? $CACHED_THEME : (isset($FORUM_DRIVER) && is_object($FORUM_DRIVER) && method_exists($FORUM_DRIVER, 'get_theme') ? filter_naughty($FORUM_DRIVER->get_theme()) : 'default');
    }
    $prefix_default = get_file_base() . '/themes/';
    $prefix = $theme == 'default' ? $prefix_default : get_custom_file_base() . '/themes/';
    // Is it structurally cached on disk yet?
    if (!isset($CACHED_FOUND[$codename][$lang][$theme][$suffix][$type])) {
        $loaded_this_once = false;
    } else {
        $loaded_this_once = true;
    }
    $_data = false;
    if ($CACHE_TEMPLATES && !$TEMPLATE_PREVIEW_OP && (!$POSSIBLY_IN_SAFE_MODE || !in_safe_mode())) {
        $tcp_path = $prefix . $theme . '/templates_cached/' . $lang . '/' . $codename . $suffix . '.tcp';
        if ($loaded_this_once) {
            if (isset($LOADED_TPL_CACHE[$codename][$theme])) {
                $_data = $LOADED_TPL_CACHE[$codename][$theme];
            } else {
                $_data = new ocp_tempcode();
                $test = $_data->from_assembly_executed($tcp_path, array($codename, $codename, $lang, $theme, $suffix, $type, $fallback));
                if (!$test) {
                    $_data = false;
                }
                // failed
            }
        } else {
            global $SITE_INFO;
            $support_smart_decaching = !isset($SITE_INFO['disable_smart_decaching']) || $SITE_INFO['disable_smart_decaching'] == '0';
            if ($support_smart_decaching) {
                if (!isset($CACHED_FOUND[$codename][$lang][$theme][$suffix][$type])) {
                    $found = find_template_place($codename, $lang, $theme, $suffix, $type);
                    $CACHED_FOUND[$codename][$lang][$theme][$suffix][$type] = $found;
                } else {
                    $found = $CACHED_FOUND[$codename][$lang][$theme][$suffix][$type];
                }
                if (!is_null($found)) {
                    if (isset($GLOBALS['CURRENT_SHARE_USER'])) {
                        $file_path = get_custom_file_base() . '/themes/' . $found[0] . $found[1] . $codename . $suffix;
                        if (!is_file($file_path)) {
                            $file_path = get_file_base() . '/themes/' . $found[0] . $found[1] . $codename . $suffix;
                        }
                    } else {
                        $file_path = ($theme == 'default' && $suffix != '.css' ? get_file_base() : get_custom_file_base()) . '/themes/' . $found[0] . $found[1] . $codename . $suffix;
                    }
                    $tcp_time = @filemtime($tcp_path);
                } else {
                    $tcp_time = false;
                }
            }
            if (!$support_smart_decaching || $tcp_time !== false && is_file($file_path) && $found !== NULL) {
                if (!$support_smart_decaching || filemtime($file_path) < $tcp_time) {
                    $_data = new ocp_tempcode();
                    $test = $_data->from_assembly_executed($tcp_path, array($codename, $codename, $lang, $theme, $suffix, $type, $fallback));
                    if (!$test) {
                        $_data = false;
                    }
                    // failed
                }
            }
        }
    }
    if ($_data === false) {
        if (!isset($CACHED_FOUND[$codename][$lang][$theme][$suffix][$type])) {
            $found = find_template_place($codename, $lang, $theme, $suffix, $type);
            $CACHED_FOUND[$codename][$lang][$theme][$suffix][$type] = $found;
        } else {
            $found = $CACHED_FOUND[$codename][$lang][$theme][$suffix][$type];
        }
        unset($CACHED_FOUND[$codename][$lang][$theme][$suffix][$type]);
        if (is_null($found)) {
            if (is_null($fallback)) {
                if ($light_error) {
                    return paragraph(do_lang_tempcode('MISSING_TEMPLATE_FILE', escape_html($codename)), '34rwefwfdee');
                }
                fatal_exit(do_lang_tempcode('MISSING_TEMPLATE_FILE', escape_html($codename)));
            } else {
                $result = do_template($fallback, $parameters, $lang);
                return $result;
            }
        } else {
            require_code('tempcode_compiler');
            $_data = _do_template($found[0], $found[1], $codename, $codename, $lang, $suffix, $theme);
        }
    }
    if ($loaded_this_once) {
        // On 3rd load (and onwards) it will be fully cached
        $LOADED_TPL_CACHE[$codename][$theme] = $_data;
    }
    if (!isset($parameters)) {
        $out = new ocp_tempcode();
        $out->codename = $codename;
        $out->code_to_preexecute = $_data->code_to_preexecute;
        $out->preprocessable_bits = $_data->preprocessable_bits;
        $out->seq_parts = $_data->seq_parts;
        foreach ($out->seq_parts as $i => $bit) {
            if ($bit[1] != array()) {
                $out->seq_parts[$i][1] = array();
            }
        }
        return $out;
    }
    $ret = $_data->bind($parameters, $codename);
    if ($special_treatment) {
        $ret->codename = '(mixed)';
        // Stop optimisation that assumes the codename represents the sole content of it
    }
    if ($special_treatment) {
        if ($KEEP_MARKERS) {
            $__data = new ocp_tempcode();
            $__data->attach('<!-- START-TEMPLATE=' . escape_html($codename) . ' -->');
            $__data->attach($ret);
            $__data->attach('<!-- END-TEMPLATE=' . escape_html($codename) . ' -->');
            $ret = $__data;
        }
        if ($SHOW_EDIT_LINKS && $codename != 'PARAM_INFO') {
            $edit_url = build_url(array('page' => 'admin_themes', 'type' => '_edit_templates', 'theme' => $theme, 'f0file' => $codename), 'adminzone');
            $parameters2 = array();
            foreach ($parameters as $k => $v) {
                if (is_array($v)) {
                    $parameters2[$k] = '(array)';
                } elseif (!is_object($v)) {
                    $parameters2[$k] = $v;
                } else {
                    $parameters2[$k] = $v->evaluate();
                    if (strlen($parameters2[$k]) > 100) {
                        $parameters2[$k] = substr($parameters2[$k], 0, 100) . '...';
                    }
                }
            }
            $param_info = do_template('PARAM_INFO', array('MAP' => $parameters2));
            $SHOW_EDIT_LINKS = false;
            $ret = do_template('TEMPLATE_EDIT_LINK', array('_GUID' => '511ae911d31a5b237a4371ff22fc78fd', 'PARAM_INFO' => $param_info, 'CONTENTS' => $ret, 'CODENAME' => $codename, 'EDIT_URL' => $edit_url));
            $SHOW_EDIT_LINKS = true;
        }
    }
    return $ret;
}
Example #11
0
/**
 * Get an array of all the modules.
 *
 * @param  ID_TEXT		The zone name
 * @return array			A map of page name to type (modules_custom, etc)
 */
function _find_all_modules($zone)
{
    if (in_safe_mode()) {
        return find_all_pages($zone, 'modules');
    }
    return find_all_pages($zone, 'modules') + find_all_pages($zone, 'modules_custom');
}
Example #12
0
/**
 * Gets the path to a block code file for a block code name
 *
 * @param  ID_TEXT		The name of the block
 * @return PATH			The path to the block
 */
function _get_block_path($block)
{
    $block_path = get_file_base() . '/sources_custom/blocks/' . filter_naughty_harsh($block) . '.php';
    if (in_safe_mode() || !is_file($block_path)) {
        $block_path = get_file_base() . '/sources/blocks/' . filter_naughty_harsh($block) . '.php';
        if (!is_file($block_path)) {
            $block_path = get_file_base() . '/sources_custom/miniblocks/' . filter_naughty_harsh($block) . '.php';
        }
    }
    return $block_path;
}
Example #13
0
 /**
  * Get the current member's theme identifier.
  *
  * @param  ?ID_TEXT		The zone we are getting the theme for (NULL: current zone)
  * @return ID_TEXT		The theme identifier
  */
 function get_theme($zone_for = NULL)
 {
     global $SITE_INFO;
     if ($zone_for !== NULL) {
         $zone_theme = $GLOBALS['SITE_DB']->query_value('zones', 'zone_theme', array('zone_name' => $zone_for));
         if ($zone_theme != '-1') {
             if (!isset($SITE_INFO['no_disk_sanity_checks']) || $SITE_INFO['no_disk_sanity_checks'] == '0') {
                 if (!is_dir(get_custom_file_base() . '/themes/' . $zone_theme)) {
                     return $this->get_theme();
                 }
             }
             return $zone_theme;
         }
         return $this->get_theme();
     }
     global $CACHED_THEME;
     if ($CACHED_THEME !== NULL) {
         return $CACHED_THEME;
     }
     global $IN_MINIKERNEL_VERSION;
     if ($IN_MINIKERNEL_VERSION == 1 || in_safe_mode()) {
         return 'default';
     }
     // Try hardcoded in URL
     $CACHED_THEME = filter_naughty(get_param('keep_theme', get_param('utheme', '-1')));
     if ($CACHED_THEME != '-1') {
         if (!is_dir(get_file_base() . '/themes/' . $CACHED_THEME) && !is_dir(get_custom_file_base() . '/themes/' . $CACHED_THEME)) {
             $theme = $CACHED_THEME;
             $CACHED_THEME = 'default';
             require_code('site');
             attach_message(do_lang_tempcode('NO_SUCH_THEME', escape_html($theme)), 'warn');
             $CACHED_THEME = NULL;
         } else {
             global $ZONE;
             $zone_theme = $ZONE === NULL ? $GLOBALS['SITE_DB']->query_value_null_ok('zones', 'zone_theme', array('zone_name' => get_zone_name())) : $ZONE['zone_theme'];
             if ($CACHED_THEME == 'default' || $CACHED_THEME == $zone_theme || has_category_access(get_member(), 'theme', $CACHED_THEME)) {
                 return $CACHED_THEME;
             } else {
                 $theme = $CACHED_THEME;
                 $CACHED_THEME = 'default';
                 require_code('site');
                 attach_message(do_lang_tempcode('NO_THEME_PERMISSION', escape_html($theme)), 'warn');
                 $CACHED_THEME = NULL;
             }
         }
     } else {
         $CACHED_THEME = NULL;
     }
     // Try hardcoded in ocPortal
     global $ZONE;
     $zone_theme = $ZONE === NULL ? $GLOBALS['SITE_DB']->query_value_null_ok('zones', 'zone_theme', array('zone_name' => get_zone_name())) : $ZONE['zone_theme'];
     $default_theme = get_page_name() == 'login' && get_option('root_zone_login_theme') == '1' ? $GLOBALS['SITE_DB']->query_value('zones', 'zone_theme', array('zone_name' => '')) : $zone_theme;
     if ($default_theme !== NULL && $default_theme != '-1') {
         if (!isset($SITE_INFO['no_disk_sanity_checks']) || $SITE_INFO['no_disk_sanity_checks'] == '0') {
             if (!is_dir(get_custom_file_base() . '/themes/' . $default_theme)) {
                 $default_theme = '-1';
             }
         }
     }
     if ($default_theme != '-1') {
         $CACHED_THEME = $default_theme;
         if ($CACHED_THEME == '') {
             $CACHED_THEME = 'default';
         }
         return $CACHED_THEME;
     }
     if ($default_theme == '-1') {
         $default_theme = 'default';
     }
     // Get from forums
     $CACHED_THEME = filter_naughty($this->_get_theme());
     if ($CACHED_THEME == '' || $CACHED_THEME != 'default' && !is_dir(get_custom_file_base() . '/themes/' . $CACHED_THEME)) {
         $CACHED_THEME = 'default';
     }
     if ($CACHED_THEME == '-1') {
         $CACHED_THEME = 'default';
     }
     require_code('permissions');
     if ($CACHED_THEME != 'default' && !has_category_access(get_member(), 'theme', $CACHED_THEME)) {
         $CACHED_THEME = 'default';
     }
     if ($CACHED_THEME == '') {
         $CACHED_THEME = 'default';
     }
     return $CACHED_THEME;
 }
Example #14
0
/**
 * This function is a very important one when coding. It allows you to include a source code file (from root/sources/ or root/sources_custom/) through the proper channels.
 * You should remember this function, and not substitute anything else for it, as that will likely make your code unstable.
 * It is key to source code modularity in ocPortal.
 *
 * @param  string			The codename for the source module to load (or a full relative path, ending with .php; if custom checking is needed, this must be the custom version)
 * @param  boolean		Whether to cleanly fail when a source file is missing
 */
function require_code($codename, $light_exit = false)
{
    $hphp = defined('HIPHOP_PHP');
    if ($hphp) {
        if ($codename == 'tempcode') {
            $codename = 'tempcode__runtime';
        }
        if ($codename == 'tempcode_compiler') {
            $codename = 'tempcode_compiler__runtime';
        }
    }
    global $_REQUIRED_CODE, $FILE_BASE, $SITE_INFO;
    if (isset($_REQUIRED_CODE[$codename])) {
        return;
    }
    $_REQUIRED_CODE[$codename] = 1;
    $shorthand = strpos($codename, '.php') === false;
    if (!$shorthand) {
        $non_custom_codename = str_replace('_custom/', '/', $codename);
        $_REQUIRED_CODE[$non_custom_codename] = 1;
    }
    $codename = filter_naughty($codename);
    static $mue = NULL;
    if ($mue === NULL) {
        $mue = function_exists('memory_get_usage');
    }
    if ($mue && isset($_GET['keep_show_loading']) && $_GET['keep_show_loading'] == '1') {
        if (function_exists('memory_get_usage')) {
            $before = memory_get_usage();
        }
    }
    $worked = false;
    $path_a = $FILE_BASE . '/' . ($shorthand ? 'sources_custom/' . $codename . '.php' : $codename);
    $path_b = $FILE_BASE . '/' . ($shorthand ? 'sources/' . $codename . '.php' : $non_custom_codename);
    $has_original = NULL;
    if (isset($GLOBALS['MEM_CACHE'])) {
        global $CODE_OVERRIDES;
        if (!isset($CODE_OVERRIDES)) {
            $CODE_OVERRIDES = persistant_cache_get('CODE_OVERRIDES');
            if ($CODE_OVERRIDES === NULL) {
                $CODE_OVERRIDES = array();
            }
        }
        if (isset($CODE_OVERRIDES[$codename])) {
            $has_override = $CODE_OVERRIDES[$codename];
            $has_original = $CODE_OVERRIDES['!' . $codename];
        } else {
            $has_override = is_file($path_a);
            $has_original = is_file($path_b);
            $CODE_OVERRIDES[$codename] = $has_override;
            $CODE_OVERRIDES['!' . $codename] = $has_original;
            persistant_cache_set('CODE_OVERRIDES', $CODE_OVERRIDES, true);
        }
    } else {
        $has_override = is_file($path_a);
    }
    if (isset($SITE_INFO['safe_mode']) && $SITE_INFO['safe_mode'] == '1') {
        $has_override = false;
    }
    if ($has_override && (!function_exists('in_safe_mode') || !in_safe_mode() || !is_file($path_b))) {
        $done_init = false;
        $init_func = 'init__' . str_replace('/', '__', str_replace('.php', '', $codename));
        if (!isset($has_original)) {
            $has_original = is_file($path_b);
        }
        if ($path_a != $path_b && $has_original) {
            $orig = str_replace(array('?' . '>', '<?php'), array('', ''), file_get_contents($path_b));
            $a = file_get_contents($path_a);
            if ((strpos($codename, '.php') === false || strpos($a, 'class Mx_') === false) && (function_exists('quercus_version') || !$hphp)) {
                $functions_before = get_defined_functions();
                $classes_before = get_declared_classes();
                include $path_a;
                // Include our overrride
                $functions_after = get_defined_functions();
                $classes_after = get_declared_classes();
                $functions_diff = array_diff($functions_after['user'], $functions_before['user']);
                // Our override defined these functions
                $classes_diff = array_diff($classes_after, $classes_before);
                $pure = true;
                // We will set this to false if it does not have all functions the main one has. If it does have all functions we know we should not run the original init, as it will almost certainly just have been the same code copy&pasted through.
                $overlaps = false;
                foreach ($functions_diff as $function) {
                    if (strpos($orig, 'function ' . $function . '(') !== false) {
                        $orig = str_replace('function ' . $function . '(', 'function non_overrided__' . $function . '(', $orig);
                        $overlaps = true;
                    } else {
                        $pure = false;
                    }
                }
                foreach ($classes_diff as $class) {
                    if (substr(strtolower($class), 0, 6) == 'module') {
                        $class = ucfirst($class);
                    }
                    if (substr(strtolower($class), 0, 4) == 'hook') {
                        $class = ucfirst($class);
                    }
                    if (strpos($orig, 'class ' . $class) !== false) {
                        $orig = str_replace('class ' . $class, 'class non_overrided__' . $class, $orig);
                        $overlaps = true;
                    } else {
                        $pure = false;
                    }
                }
                // See if we can get away with loading init function early. If we can we do a special version of it that supports fancy code modification. Our override isn't allowed to call the non-overridden init function as it won't have been loaded up by PHP in time. Instead though we will call it ourselves if it still exists (hasn't been removed by our own init function) because it likely serves a different purpose to our code-modification init function and copy&paste coding is bad.
                $doing_code_modifier_init = function_exists($init_func);
                if ($doing_code_modifier_init) {
                    $test = call_user_func_array($init_func, array($orig));
                    if (is_string($test)) {
                        $orig = $test;
                    }
                    $done_init = true;
                }
                if (!$doing_code_modifier_init && !$overlaps) {
                    include $path_b;
                } else {
                    eval($orig);
                    // Load up modified original
                }
                if (!$pure && $doing_code_modifier_init && function_exists('non_overrided__init__' . str_replace('/', '__', str_replace('.php', '', $codename)))) {
                    call_user_func('non_overrided__init__' . str_replace('/', '__', str_replace('.php', '', $codename)));
                }
            } else {
                // Note we load the original and then the override. This is so function_exists can be used in the overrides (as we can't support the re-definition) OR in the case of Mx_ class derivation, so that the base class is loaded first.
                if (isset($_GET['keep_show_parse_errors']) && (function_exists('quercus_version') || !$hphp)) {
                    @ini_set('display_errors', '0');
                    $orig = str_replace('?' . '>', '', str_replace('<?php', '', file_get_contents($path_b)));
                    if (eval($orig) === false) {
                        if (!function_exists('fatal_exit') || $codename == 'failure') {
                            critical_error('PASSON', @strval($php_errormsg) . ' [sources/' . $codename . '.php]');
                        }
                        fatal_exit(@strval($php_errormsg) . ' [sources/' . $codename . '.php]');
                    }
                } else {
                    include $path_b;
                }
                if (isset($_GET['keep_show_parse_errors']) && (function_exists('quercus_version') || !$hphp)) {
                    @ini_set('display_errors', '0');
                    $orig = str_replace('?' . '>', '', str_replace('<?php', '', file_get_contents($path_a)));
                    if (eval($orig) === false) {
                        if (!function_exists('fatal_exit') || $codename == 'failure') {
                            critical_error('PASSON', @strval($php_errormsg) . ' [sources_custom/' . $codename . '.php]');
                        }
                        fatal_exit(@strval($php_errormsg) . ' [sources_custom/' . $codename . '.php]');
                    }
                } else {
                    include $path_a;
                }
            }
        } else {
            if (isset($_GET['keep_show_parse_errors']) && (function_exists('quercus_version') || !$hphp)) {
                @ini_set('display_errors', '0');
                $orig = str_replace('?' . '>', '', str_replace('<?php', '', file_get_contents($path_a)));
                if (eval($orig) === false) {
                    if (!function_exists('fatal_exit') || $codename == 'failure') {
                        critical_error('PASSON', @strval($php_errormsg) . ' [sources_custom/' . $codename . '.php]');
                    }
                    fatal_exit(@strval($php_errormsg) . ' [sources_custom/' . $codename . '.php]');
                }
            } else {
                include $path_a;
            }
        }
        if ($mue && isset($_GET['keep_show_loading']) && $_GET['keep_show_loading'] == '1') {
            if (function_exists('memory_get_usage')) {
                print '<!-- require_code: ' . htmlentities($codename) . ' (' . number_format(memory_get_usage() - $before) . ' bytes used, now at ' . number_format(memory_get_usage()) . ') -->' . "\n";
                flush();
            }
        }
        if (!$done_init) {
            if (function_exists($init_func)) {
                call_user_func($init_func);
            }
        }
        $worked = true;
    } else {
        if (isset($_GET['keep_show_parse_errors']) && (function_exists('quercus_version') || !$hphp)) {
            $contents = @file_get_contents($path_b);
            if ($contents !== false) {
                @ini_set('display_errors', '0');
                $orig = str_replace(array('?' . '>', '<' . '?php'), array('', ''), $contents);
                if (eval($orig) === false) {
                    if (!function_exists('fatal_exit') || $codename == 'failure') {
                        critical_error('PASSON', @strval($php_errormsg) . ' [sources/' . $codename . '.php]');
                    }
                    fatal_exit(@strval($php_errormsg) . ' [sources/' . $codename . '.php]');
                }
                $worked = true;
            }
        } else {
            $php_errormsg = '';
            @(include $path_b);
            if ($php_errormsg == '') {
                $worked = true;
            }
        }
        if ($worked) {
            if ($mue && isset($_GET['keep_show_loading']) && $_GET['keep_show_loading'] == '1') {
                if (function_exists('memory_get_usage')) {
                    print '<!-- require_code: ' . htmlentities($codename) . ' (' . number_format(memory_get_usage() - $before) . ' bytes used, now at ' . number_format(memory_get_usage()) . ') -->' . "\n";
                    flush();
                }
            }
            $init_func = 'init__' . str_replace(array('/', '.php'), array('__', ''), $codename);
            if (function_exists($init_func)) {
                call_user_func($init_func);
            }
        }
    }
    if ($worked) {
        return;
    }
    if ($light_exit) {
        warn_exit(do_lang_tempcode('MISSING_SOURCE_FILE', escape_html($codename), escape_html($path_b)));
    }
    if (!function_exists('do_lang')) {
        if ($codename == 'critical_errors') {
            exit('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">' . chr(10) . '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="EN" lang="EN"><head><title>Critical startup error</title></head><body><h1>ocPortal startup error</h1><p>The ocPortal critical error message file, sources/critical_errors.php, could not be located. This is almost always due to an incomplete upload of the ocPortal system, so please check all files are uploaded correctly.</p><p>Once all ocPortal files are in place, ocPortal must actually be installed by running the installer. You must be seeing this message either because your system has become corrupt since installation, or because you have uploaded some but not all files from our manual installer package: the quick installer is easier, so you might consider using that instead.</p><p>ocProducts maintains full documentation for all procedures and tools, especially those for installation. These may be found on the <a href="http://ocportal.com">ocPortal website</a>. If you are unable to easily solve this problem, we may be contacted from our website and can help resolve it for you.</p><hr /><p style="font-size: 0.8em">ocPortal is a website engine created by ocProducts.</p></body></html>');
            require $GLOBALS['FILE_BASE'] . '/sources/global.php';
        }
        critical_error('MISSING_SOURCE', $codename);
    }
    fatal_exit(do_lang_tempcode('MISSING_SOURCE_FILE', escape_html($codename), escape_html($path_b)));
}
Example #15
0
/**
 * Find whether to run in multi-lang mode.
 *
 * @return boolean		Whether to run in multi-lang mode.
 */
function multi_lang()
{
    global $MULTI_LANG;
    if ($MULTI_LANG !== NULL) {
        return $MULTI_LANG;
    }
    $MULTI_LANG = false;
    if (get_option('allow_international', true) !== '1') {
        return false;
    }
    $_dir = opendir(get_file_base() . '/lang/');
    $_langs = array();
    while (false !== ($file = readdir($_dir))) {
        if ($file != fallback_lang() && $file[0] != '.' && $file[0] != '_' && $file != 'index.html' && $file != 'langs.ini' && $file != 'map.ini') {
            if (is_dir(get_file_base() . '/lang/' . $file)) {
                $_langs[$file] = 'lang';
            }
        }
    }
    closedir($_dir);
    if (!in_safe_mode()) {
        $_dir = @opendir(get_custom_file_base() . '/lang_custom/');
        if ($_dir !== false) {
            while (false !== ($file = readdir($_dir))) {
                if ($file != fallback_lang() && $file[0] != '.' && $file[0] != '_' && $file != 'index.html' && $file != 'langs.ini' && $file != 'map.ini' && !isset($_langs[$file])) {
                    if (is_dir(get_custom_file_base() . '/lang_custom/' . $file)) {
                        $_langs[$file] = 'lang_custom';
                    }
                }
            }
            closedir($_dir);
        }
        if (get_custom_file_base() != get_file_base()) {
            $_dir = opendir(get_file_base() . '/lang_custom/');
            while (false !== ($file = readdir($_dir))) {
                if ($file != fallback_lang() && $file[0] != '.' && $file[0] != '_' && $file != 'index.html' && $file != 'langs.ini' && $file != 'map.ini' && !isset($_langs[$file])) {
                    if (is_dir(get_file_base() . '/lang_custom/' . $file)) {
                        $_langs[$file] = 'lang_custom';
                    }
                }
            }
            closedir($_dir);
        }
    }
    foreach ($_langs as $lang => $dir) {
        if (is_file(($dir == 'lang_custom' ? get_custom_file_base() : get_file_base()) . '/' . $dir . '/' . $lang . '/global.ini')) {
            $MULTI_LANG = true;
            break;
        }
        $_dir2 = @opendir(($dir == 'lang_custom' ? get_custom_file_base() : get_file_base()) . '/' . $dir . '/' . $lang);
        if ($_dir2 !== false) {
            while (false !== ($file2 = readdir($_dir2))) {
                if (substr($file2, -4) == '.ini' || substr($file2, -3) == '.po') {
                    $MULTI_LANG = true;
                    break;
                }
            }
        }
    }
    return $MULTI_LANG;
}