Example #1
0
/**
 * Build menu based off of site tree branch.
 *
 * @param  array			Where to get the site-tree under
 * @return array			Faked database rows
 */
function build_sitetree_menu($specifier)
{
    if (count($specifier) < 2) {
        return array();
    }
    $zone = $specifier[0];
    $page = $specifier[1];
    require_code('zones2');
    $page_link = implode(':', $specifier);
    $items = array();
    $parents = array();
    $_pagelinks = extract_module_functions_page($zone, $page, array('get_page_links'), array(NULL, false, $page_link));
    if (!is_null($_pagelinks[0])) {
        $pagelinks = is_array($_pagelinks[0]) ? call_user_func_array($_pagelinks[0][0], $_pagelinks[0][1]) : eval($_pagelinks[0]);
        if (!is_null($pagelinks[1])) {
            foreach ($pagelinks[0] as $pagelink) {
                $this_id = mt_rand(0, mt_getrandmax());
                $parent = NULL;
                $keys = array_keys($pagelink);
                if (is_string($keys[0])) {
                    $module_the_name = array_key_exists(3, $pagelinks) ? $pagelinks[3] : NULL;
                    $category_name = is_string($pagelink['id']) ? $pagelink['id'] : strval($pagelink['id']);
                    $actual_page_link = str_replace('!', $category_name, $pagelinks[2]);
                    $actual_page_link = str_replace('_SELF:_SELF', get_module_zone($page) . ':' . $page, $actual_page_link);
                    // Support for lazy notation
                    $title = $pagelink['title'];
                    if (array_key_exists('children', $pagelink)) {
                        $items = array_merge($items, _build_sitetree_menu_deep($actual_page_link != $page_link ? $this_id : NULL, $pagelink['children'], $pagelinks, $page_link, $page));
                    }
                    if (array_key_exists('second_cat', $pagelink) && $pagelink['second_cat'] != '') {
                        if (!array_key_exists($pagelink['second_cat'], $parents)) {
                            $new_parent_id = mt_rand(0, mt_getrandmax());
                            $items[] = array('id' => $new_parent_id, 'i_parent' => NULL, 'cap' => $pagelink['second_cat'], 'i_url' => '', 'i_check_permissions' => 0, 'i_expanded' => 0, 'i_new_window' => 0, 'i_page_only' => '');
                            $parents[$pagelink['second_cat']] = $new_parent_id;
                        }
                        $parent = $parents[$pagelink['second_cat']];
                    }
                } else {
                    $module_the_name = $pagelink[1];
                    $actual_page_link = $pagelink[0];
                    $actual_page_link = str_replace('_SELF:_SELF', get_module_zone($page) . ':' . $page, $actual_page_link);
                    // Support for lazy notation
                    $title = $pagelink[3];
                }
                if ($actual_page_link != $page_link) {
                    // We only want children
                    $items[] = array('id' => $this_id, 'i_parent' => $parent, 'cap' => $title, 'i_url' => $actual_page_link, 'i_check_permissions' => 0, 'i_expanded' => 0, 'i_new_window' => 0, 'i_page_only' => '');
                }
            }
        }
    }
    return $items;
}
 }
 if ($page == '404') {
     continue;
 }
 if ($page == 'sitemap') {
     continue;
 }
 if ($page == 'forums' && substr($page_type, 0, 7) == 'modules' && (get_forum_type() == 'ocf' || get_forum_type() == 'none')) {
     continue;
 }
 if ($page == 'join' && substr($page_type, 0, 7) == 'modules' && !is_guest()) {
     continue;
 }
 if (has_page_access(get_member(), $page, $zone)) {
     $_entrypoints = array();
     $__entrypoints = extract_module_functions_page($zone, $page, array('get_entry_points'));
     if (!is_null($__entrypoints[0])) {
         $entrypoints = is_array($__entrypoints[0]) ? call_user_func_array($__entrypoints[0][0], $__entrypoints[0][1]) : (strpos($__entrypoints[0], '::') !== false ? NULL : eval($__entrypoints[0]));
         // The strpos thing is a little hack that allows it to work for base-class derived modules
         if (is_null($entrypoints)) {
             require_code(zone_black_magic_filterer($zone . '/pages/' . $page_type . '/' . $page . '.php', true));
             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));
             }
             $entrypoints = $object->get_entry_points();
         }
     } else {
         $entrypoints = array('!');
     }
Example #3
0
 /**
  * Standard modular run function.
  *
  * @param  array		A map of parameters.
  * @return tempcode	The result of execution.
  */
 function run($map)
 {
     require_all_lang();
     require_code('zones2');
     $skip_pages = array_key_exists('skip', $map) ? explode(',', $map['skip']) : array();
     $comcode_page_rows = $GLOBALS['SITE_DB']->query_select('comcode_pages', array('*'));
     $_zones = array();
     $zones = find_all_zones(false, true);
     $GLOBALS['MEMORY_OVER_SPEED'] = true;
     $low_memory = ini_get('memory_limit') != '-1' && ini_get('memory_limit') != '0' && ini_get('memory_limit') != '' && intval(preg_replace('#M$#', '', ini_get('memory_limit'))) < 26 || get_option('has_low_memory_limit') === '1';
     // Reorder a bit
     $zones2 = array();
     foreach (array('', 'site') as $zone_match) {
         foreach ($zones as $i => $zone) {
             if ($zone[0] == $zone_match) {
                 $zones2[] = $zone;
                 unset($zones[$i]);
             }
         }
     }
     $zones2 = array_merge($zones2, $zones);
     foreach ($zones2 as $z) {
         list($zone, $zone_title, , $zone_default_page) = $z;
         if (has_zone_access(get_member(), $zone)) {
             $_pages = array();
             $pages = find_all_pages_wrap($zone);
             if (isset($pages[$zone_default_page])) {
                 $default = $pages[$zone_default_page];
                 $pages = array($zone_default_page => $default) + $pages;
             }
             foreach ($pages as $page => $page_type) {
                 if (is_integer($page)) {
                     $page = strval($page);
                 }
                 if (substr($page, 0, 6) == 'panel_') {
                     continue;
                 }
                 if (substr($page, 0, 1) == '_') {
                     continue;
                 }
                 if (in_array($page, $skip_pages)) {
                     continue;
                 }
                 if (in_array($zone . ':' . $page, $skip_pages)) {
                     continue;
                 }
                 if ($page == '404') {
                     continue;
                 }
                 if (strpos($page, '_tree_made') !== false) {
                     continue;
                 }
                 if ($page == 'sitemap') {
                     continue;
                 }
                 if ($page == 'forums' && substr($page_type, 0, 7) == 'modules' && (get_forum_type() == 'ocf' || get_forum_type() == 'none')) {
                     continue;
                 }
                 if ($page == 'join' && substr($page_type, 0, 7) == 'modules' && !is_guest()) {
                     continue;
                 }
                 if (has_page_access(get_member(), $page, $zone)) {
                     $_entrypoints = array();
                     $__entrypoints = $low_memory ? array(NULL) : extract_module_functions_page($zone, $page, array('get_entry_points'));
                     if (!is_null($__entrypoints[0])) {
                         $entrypoints = is_array($__entrypoints[0]) ? call_user_func_array($__entrypoints[0][0], $__entrypoints[0][1]) : (strpos($__entrypoints[0], '::') !== false ? NULL : eval($__entrypoints[0]));
                         // The strpos thing is a little hack that allows it to work for base-class derived modules
                         if (is_null($entrypoints)) {
                             $path = zone_black_magic_filterer($zone . ($zone == '' ? '' : '/') . 'pages/' . $page_type . '/' . $page . '.php', true);
                             if ($low_memory && !defined('HIPHOP_PHP') && 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;
                                 }
                                 $entrypoints = 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));
                                 }
                                 $entrypoints = $object->get_entry_points();
                             }
                         }
                     } else {
                         $entrypoints = array('!');
                     }
                     if (!is_array($entrypoints)) {
                         $entrypoints = array('!');
                     }
                     if ($entrypoints == array('!')) {
                         $url = build_url(array('page' => $page), $zone, NULL, false, false, true);
                         $title = ucwords(str_replace('_', ' ', $page));
                         if (substr($page_type, 0, 7) == 'comcode') {
                             foreach ($comcode_page_rows as $page_row) {
                                 if ($page_row['p_validated'] == 0 && $page_row['the_page'] == $page && $page_row['the_zone'] == $zone) {
                                     continue 2;
                                 }
                             }
                             $path = zone_black_magic_filterer((strpos($page_type, '_custom') !== false ? get_custom_file_base() : get_file_base()) . '/' . filter_naughty($zone) . '/pages/' . filter_naughty($page_type) . '/' . $page . '.txt');
                             if (!is_file($path)) {
                                 $path = zone_black_magic_filterer(get_file_base() . '/' . filter_naughty($zone) . '/pages/' . filter_naughty($page_type) . '/' . $page . '.txt');
                             }
                             $page_contents = file_get_contents($path);
                             $matches = array();
                             if (preg_match('#\\[title[^\\]]*\\]#', $page_contents, $matches) != 0) {
                                 $start = strpos($page_contents, $matches[0]) + strlen($matches[0]);
                                 $end = strpos($page_contents, '[/title]', $start);
                                 $matches = array();
                                 $title_portion = str_replace('{$SITE_NAME}', get_site_name(), substr($page_contents, $start, $end - $start));
                                 if (preg_match('#\\{\\!([\\w:]+)\\}#', $title_portion, $matches) != 0) {
                                     $title_portion = str_replace($matches[0], do_lang($matches[1]), $title_portion);
                                 }
                                 if (preg_match('#^[^<>\\[\\{\\&]*$#', $title_portion, $matches) != 0) {
                                     $title = $matches[0];
                                 } elseif (!$low_memory) {
                                     $_title = comcode_to_tempcode($title_portion);
                                     $title = strip_tags(@html_entity_decode($_title->evaluate(), ENT_QUOTES, get_charset()));
                                 }
                             }
                         } elseif (substr($page_type, 0, 4) == 'html') {
                             $path = zone_black_magic_filterer((strpos($page_type, '_custom') !== false ? get_custom_file_base() : get_file_base()) . '/' . filter_naughty($zone) . '/pages/' . filter_naughty($page_type) . '/' . $page . '.htm');
                             $page_contents = file_get_contents($path);
                             $matches = array();
                             if (preg_match('#\\<title[^\\>]*\\>#', $page_contents, $matches) != 0) {
                                 $start = strpos($page_contents, $matches[0]) + strlen($matches[0]);
                                 $end = strpos($page_contents, '</title>', $start);
                                 $title = strip_tags(@html_entity_decode(substr($page_contents, $start, $end - $start), ENT_QUOTES, get_charset()));
                             }
                         }
                         $temp = do_template('BLOCK_MAIN_SITEMAP_NEST', array('_GUID' => '92e657f8b9a3642df053f54e724e66f6', 'URL' => $url, 'NAME' => $title, 'CHILDREN' => array()));
                         $_pages[$title] = $temp->evaluate();
                         // FUDGEFUDGE
                     } elseif (count($entrypoints) != 0) {
                         foreach ($entrypoints as $entrypoint => $title) {
                             if (($entrypoint == 'concede' || $entrypoint == 'invisible' || $entrypoint == 'logout') && is_guest()) {
                                 continue;
                             }
                             if ($entrypoint == '!') {
                                 $url = build_url(array('page' => $page), $zone, NULL, false, false, true);
                             } else {
                                 $url = build_url(array('page' => $page, 'type' => $entrypoint), $zone, NULL, false, false, true);
                             }
                             $_entrypoints[$title] = do_template('BLOCK_MAIN_SITEMAP_NEST', array('_GUID' => 'ae2ed2549644a8e699e0938b3ab98ddb', 'URL' => $url, 'NAME' => do_lang_tempcode($title), 'CHILDREN' => array()));
                         }
                         //ksort($_entrypoints);
                         $title = do_lang('MODULE_TRANS_NAME_' . $page, NULL, NULL, NULL, NULL, false);
                         if (is_null($title)) {
                             $title = ucwords(str_replace('_', ' ', preg_replace('#^ocf\\_#', '', preg_replace('#^' . str_replace('#', '\\#', preg_quote($zone)) . '_#', '', preg_replace('#^' . str_replace('#', '\\#', preg_quote(str_replace('zone', '', $zone))) . '_#', '', $page)))));
                         }
                         if (count($_entrypoints) == 1) {
                             $temp_keys = array_keys($_entrypoints);
                             $temp = $_entrypoints[$temp_keys[0]];
                         } else {
                             $temp = do_template('BLOCK_MAIN_SITEMAP_NEST', array('_GUID' => 'dfc5cc7db0301acd938d3b2e3fceaab8', 'URL' => new ocp_tempcode(), 'NAME' => $title, 'CHILDREN' => $_entrypoints));
                         }
                         $_pages[$title] = $temp->evaluate();
                         // FUDGEFUDGE
                     }
                 }
             }
             $url = new ocp_tempcode();
             if ($_pages != array()) {
                 $keys = array_keys($_pages);
                 $first = $_pages[$keys[0]];
                 ksort($_pages);
                 $_pages = array($keys[0] => $first) + $_pages;
             }
             $temp = do_template('BLOCK_MAIN_SITEMAP_NEST', array('_GUID' => '38abb0a0e5bec968b28b4791320dd0dc', 'URL' => $url, 'NAME' => $zone_title, 'CHILDREN' => $_pages));
             $_zones[] = $temp->evaluate();
             // FUDGEFUDGE
         }
     }
     // To avoid running out of memory
     $out = do_template('BLOCK_MAIN_SITEMAP', array('_GUID' => 'd0807b30925e47d10cdb2c36231436ab', 'CHILDREN' => $_zones));
     $e = $out->evaluate();
     $explode = explode('__keep__', $e);
     // the URLs are build without keep and the templates tack it on the end
     if (strpos($e, '__keep__') !== false) {
         $out = new ocp_tempcode();
         foreach ($explode as $i => $bit) {
             if ($i != 0) {
                 $out->attach(symbol_tempcode('KEEP', NULL, array(ENTITY_ESCAPED)));
             }
             if ($GLOBALS['XSS_DETECT']) {
                 ocp_mark_as_escaped($bit);
             }
             $out->attach($bit);
         }
     }
     $e = $out->evaluate();
     if (strpos($e, '__keep1__') !== false) {
         $explode = explode('__keep1__', $e);
         $out = new ocp_tempcode();
         foreach ($explode as $i => $bit) {
             if ($i != 0) {
                 $out->attach(symbol_tempcode('KEEP', array('1'), array(ENTITY_ESCAPED)));
             }
             if ($GLOBALS['XSS_DETECT']) {
                 ocp_mark_as_escaped($bit);
             }
             $out->attach($bit);
         }
     }
     return $out;
 }
Example #4
0
/**
 * AJAX script for dynamically extended sitetree.
 */
function site_tree_script()
{
    header("Cache-Control: no-cache, must-revalidate");
    // HTTP/1.1
    header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
    // Date in the past
    $root_perms = array('submit_cat_highrange_content' => 0, 'edit_cat_highrange_content' => 0, 'edit_own_cat_highrange_content' => 0, 'delete_cat_highrange_content' => 0, 'delete_own_cat_highrange_content' => 0, 'submit_highrange_content' => 1, 'bypass_validation_highrange_content' => 1, 'edit_own_highrange_content' => 1, 'edit_highrange_content' => 1, 'delete_own_highrange_content' => 1, 'delete_highrange_content' => 1, 'submit_cat_midrange_content' => 0, 'edit_cat_midrange_content' => 0, 'edit_own_cat_midrange_content' => 0, 'delete_cat_midrange_content' => 0, 'delete_own_cat_midrange_content' => 0, 'submit_midrange_content' => 1, 'bypass_validation_midrange_content' => 1, 'edit_own_midrange_content' => 1, 'edit_midrange_content' => 1, 'delete_own_midrange_content' => 1, 'delete_midrange_content' => 1, 'submit_cat_lowrange_content' => 0, 'edit_cat_lowrange_content' => 0, 'edit_own_cat_lowrange_content' => 0, 'delete_cat_lowrange_content' => 0, 'delete_own_cat_lowrange_content' => 0, 'submit_lowrange_content' => 1, 'bypass_validation_lowrange_content' => 1, 'edit_own_lowrange_content' => 1, 'edit_lowrange_content' => 1, 'delete_own_lowrange_content' => 1, 'delete_lowrange_content' => 1);
    require_code('zones2');
    require_code('zones3');
    // Usergroups we have
    $admin_groups = $GLOBALS['FORUM_DRIVER']->get_super_admin_groups();
    $groups = $GLOBALS['FORUM_DRIVER']->get_usergroup_list(false, true);
    if (!has_actual_page_access(get_member(), 'admin_site_tree', 'adminzone')) {
        exit;
    }
    if (function_exists('set_time_limit')) {
        @set_time_limit(30);
    }
    disable_php_memory_limit();
    // Needed for loading large amount of permissions (potentially)
    // ======
    // Saving
    // ======
    if (get_param_integer('set_perms', 0) == 1) {
        if (!has_actual_page_access(get_member(), 'admin_permissions', 'adminzone')) {
            exit;
        }
        // Build a map of every page link we are setting permissions for
        $map = array();
        foreach (array_merge($_GET, $_POST) as $i => $page_link) {
            if (get_magic_quotes_gpc()) {
                $page_link = stripslashes($page_link);
            }
            if (substr($i, 0, 4) == 'map_') {
                $map[intval(substr($i, 4))] = $page_link;
            }
        }
        // Read it all in
        foreach ($map as $i => $page_link) {
            // Decode page link
            $matches = array();
            $type = '';
            if ($page_link == '_root') {
                $type = 'root';
            } elseif (preg_match('#^([^:]*):([^:]+):.+$#', $page_link, $matches) != 0) {
                $type = 'cat';
            } elseif (preg_match('#^([^:]*):([^:]+)$#', $page_link, $matches) != 0) {
                $type = 'page';
            } elseif (preg_match('#^([^:]*):?$#', $page_link, $matches) != 0) {
                $type = 'zone';
            } else {
                $type = 'root';
            }
            // Working out what we're doing with privilege overrides
            if ($type == 'page' || $type == 'cat') {
                $zone = $matches[1];
                $page = $matches[2];
                list($overridables, $sp_page) = get_module_overridables($zone, $page);
            }
            if ($type == 'root') {
                // Insertion
                foreach ($groups as $group => $group_name) {
                    if (!in_array($group, $admin_groups)) {
                        // SP's
                        foreach (array_keys($root_perms) as $overide) {
                            $val = post_param_integer(strval($i) . 'gsp_' . $overide . '_' . strval($group), -2);
                            if ($val != -2) {
                                $GLOBALS['SITE_DB']->query_delete('gsp', array('specific_permission' => $overide, 'group_id' => $group, 'the_page' => '', 'module_the_name' => '', 'category_name' => ''));
                                if ($val != -1) {
                                    $GLOBALS['SITE_DB']->query_insert('gsp', array('specific_permission' => $overide, 'group_id' => $group, 'module_the_name' => '', 'category_name' => '', 'the_page' => '', 'the_value' => $val));
                                }
                            }
                        }
                    }
                }
            } elseif ($type == 'zone') {
                $zone = $matches[1];
                // Insertion
                foreach ($groups as $group => $group_name) {
                    if (!in_array($group, $admin_groups)) {
                        // View access
                        $view = post_param_integer(strval($i) . 'g_view_' . strval($group), -1);
                        if ($view != -1) {
                            $GLOBALS['SITE_DB']->query_delete('group_zone_access', array('zone_name' => $zone, 'group_id' => $group));
                            if ($view == 1) {
                                $GLOBALS['SITE_DB']->query_insert('group_zone_access', array('zone_name' => $zone, 'group_id' => $group));
                            }
                        }
                    }
                }
            } elseif ($type == 'page') {
                // Insertion
                foreach ($groups as $group => $group_name) {
                    if (!in_array($group, $admin_groups)) {
                        // View access
                        $view = post_param_integer(strval($i) . 'g_view_' . strval($group), -1);
                        if ($view != -1) {
                            $GLOBALS['SITE_DB']->query_delete('group_page_access', array('zone_name' => $zone, 'page_name' => $page, 'group_id' => $group));
                            if ($view == 0) {
                                // Pages have access by row non-presence, for good reason
                                $GLOBALS['SITE_DB']->query_insert('group_page_access', array('zone_name' => $zone, 'page_name' => $page, 'group_id' => $group));
                            }
                        }
                        // SP's
                        foreach (array_keys($overridables) as $overide) {
                            $val = post_param_integer(strval($i) . 'gsp_' . $overide . '_' . strval($group), -2);
                            if ($val != -2) {
                                $GLOBALS['SITE_DB']->query_delete('gsp', array('specific_permission' => $overide, 'group_id' => $group, 'the_page' => $sp_page));
                                if ($val != -1) {
                                    $GLOBALS['SITE_DB']->query_insert('gsp', array('specific_permission' => $overide, 'group_id' => $group, 'module_the_name' => '', 'category_name' => '', 'the_page' => $sp_page, 'the_value' => $val));
                                }
                            }
                        }
                    }
                }
            } elseif ($type == 'cat') {
                $_pagelinks = extract_module_functions_page($zone, $page, array('extract_page_link_permissions'), array($page_link));
                list($category, $module) = is_array($_pagelinks[0]) ? call_user_func_array($_pagelinks[0][0], $_pagelinks[0][1]) : eval($_pagelinks[0]);
                // If $_pagelinks[0] is NULL then it's an error: extract_page_link_permissions is always there when there are cat permissions
                // Insertion
                foreach ($groups as $group => $group_name) {
                    if (!in_array($group, $admin_groups)) {
                        // View access
                        $view = post_param_integer(strval($i) . 'g_view_' . strval($group), -1);
                        if ($view != -1) {
                            $GLOBALS['SITE_DB']->query_delete('group_category_access', array('module_the_name' => $module, 'category_name' => $category, 'group_id' => $group));
                            if ($view == 1) {
                                $GLOBALS['SITE_DB']->query_insert('group_category_access', array('module_the_name' => $module, 'category_name' => $category, 'group_id' => $group));
                            }
                        }
                        // SP's
                        foreach ($overridables as $overide => $cat_support) {
                            if (is_array($cat_support)) {
                                $cat_support = $cat_support[0];
                            }
                            if ($cat_support == 0) {
                                continue;
                            }
                            $val = post_param_integer(strval($i) . 'gsp_' . $overide . '_' . strval($group), -2);
                            if ($val != -2) {
                                $GLOBALS['SITE_DB']->query_delete('gsp', array('specific_permission' => $overide, 'group_id' => $group, 'module_the_name' => $module, 'category_name' => $category, 'the_page' => ''));
                                if ($val != -1) {
                                    $new_settings = array('specific_permission' => $overide, 'group_id' => $group, 'module_the_name' => $module, 'category_name' => $category, 'the_page' => '', 'the_value' => $val);
                                    $GLOBALS['SITE_DB']->query_insert('gsp', $new_settings);
                                }
                            }
                        }
                    }
                }
            }
        }
        decache('main_sitemap');
        $GLOBALS['SITE_DB']->query_delete('cache');
        if (function_exists('persistant_cache_empty')) {
            persistant_cache_empty();
        }
        // Tra la la tada
        return;
    }
    // =======
    // Loading
    // =======
    $default = get_param('default', NULL, true);
    header('Content-Type: text/xml');
    $permissions_needed = get_param_integer('get_perms', 0) == 1;
    // Whether we are limiting our tree to permission-supporting
    @ini_set('ocproducts.xss_detect', '0');
    echo '<' . '?xml version="1.0" encoding="' . get_charset() . '"?' . '>';
    echo '<request><result>';
    require_lang('permissions');
    require_lang('zones');
    $page_link = get_param('id', NULL, true);
    $_sp_access = $GLOBALS['SITE_DB']->query_select('gsp', array('*'));
    $sp_access = array();
    foreach ($_sp_access as $a) {
        if (!isset($sp_access[$a['group_id']])) {
            $sp_access[$a['group_id']] = array();
        }
        $sp_access[$a['group_id']][] = $a;
    }
    if (!is_null($page_link) && $page_link != '' && (strpos($page_link, ':') === false || strpos($page_link, ':') === strlen($page_link) - 1)) {
        if (strpos($page_link, ':') === strlen($page_link) - 1) {
            $page_link = substr($page_link, 0, strlen($page_link) - 1);
        }
        // Pages in the zone
        $zone = $page_link;
        $page_type = get_param('page_type', NULL);
        $pages = find_all_pages_wrap($zone, false, true, FIND_ALL_PAGES__NEWEST, $page_type);
        ksort($pages);
        if ($permissions_needed) {
            $zone_access = $GLOBALS['SITE_DB']->query_select('group_zone_access', array('*'), array('zone_name' => $zone));
            $page_access = $GLOBALS['SITE_DB']->query_select('group_page_access', array('*'), array('zone_name' => $zone));
        }
        foreach ($pages as $page => $page_type) {
            if (!is_string($page)) {
                $page = strval($page);
            }
            $full_page_type = $page_type;
            $description = '';
            if (strpos($full_page_type, '/') !== false) {
                $full_page_type = substr($full_page_type, 0, strpos($full_page_type, '/'));
            }
            if (strpos($full_page_type, ':') !== false) {
                $full_page_type = substr($full_page_type, 0, strpos($full_page_type, ':'));
            }
            switch ($full_page_type) {
                case 'redirect':
                    list(, $redir_zone, $redir_page) = explode(':', $page_type);
                    $page_title = html_entity_decode(strip_tags(str_replace(array('<kbd>', '</kbd>'), array('"', '"'), do_lang('REDIRECT_PAGE_TO', xmlentities($redir_zone), xmlentities($redir_page)))), ENT_QUOTES) . ': ' . (is_string($page) ? $page : strval($page));
                    break;
                case 'comcode':
                case 'comcode_custom':
                    $page_title = do_lang('COMCODE_PAGE') . ': ' . (is_string($page) ? $page : strval($page));
                    break;
                case 'html':
                case 'html_custom':
                    $page_title = 'HTML: ' . $page;
                    break;
                case 'modules':
                case 'modules_custom':
                    $page_title = do_lang('MODULE') . ': ' . $page;
                    $matches = array();
                    if (preg_match('#@package\\s+(\\w+)#', file_get_contents(zone_black_magic_filterer(get_file_base() . '/' . $zone . '/pages/' . $page_type . '/' . $page . '.php')), $matches) != 0) {
                        $package = $matches[1];
                        $path = get_file_base() . '/sources_custom/hooks/systems/addon_registry/' . $package . '.php';
                        if (!file_exists($path)) {
                            $path = get_file_base() . '/sources/hooks/systems/addon_registry/' . $package . '.php';
                        }
                        if (file_exists($path)) {
                            require_lang('zones');
                            require_code('zones2');
                            $functions = extract_module_functions($path, array('get_description'));
                            $description = is_array($functions[0]) ? call_user_func_array($functions[0][0], $functions[0][1]) : eval($functions[0]);
                            $description = do_lang('FROM_ADDON', $package, $description);
                        }
                    }
                    break;
                case 'minimodules':
                case 'minimodules_custom':
                    $page_title = do_lang('MINIMODULE') . ': ' . $page;
                    break;
                default:
                    $page_title = do_lang('PAGE') . ': ' . $page;
                    break;
            }
            if ($permissions_needed) {
                $view_perms = '';
                foreach ($groups as $group => $group_name) {
                    if (!in_array($group, $admin_groups)) {
                        $view_perms .= 'g_view_' . strval($group) . '="' . (!in_array(array('zone_name' => $zone, 'page_name' => is_string($page) ? $page : strval($page), 'group_id' => $group), $page_access) ? 'true' : 'false') . '" ';
                    }
                }
                $pagelinks = NULL;
                if (substr($page_type, 0, 7) != 'modules') {
                    $overridables = array();
                } else {
                    list($overridables, $sp_page) = get_module_overridables($zone, $page);
                }
                $sp_perms = '';
                foreach ($overridables as $overridable => $cat_support) {
                    $lang_string = do_lang('PT_' . $overridable);
                    if (is_array($cat_support)) {
                        $lang_string = do_lang($cat_support[1]);
                    }
                    if (strlen($lang_string) > 20 && strpos($lang_string, '(') !== false) {
                        $lang_string = preg_replace('# \\([^\\)]*\\)#', '', $lang_string);
                    }
                    $sp_perms .= 'sp_' . $overridable . '="' . xmlentities($lang_string) . '" ';
                    foreach ($groups as $group => $group_name) {
                        if (!in_array($group, $admin_groups)) {
                            $override_value = -1;
                            foreach ($sp_access[$group] as $test) {
                                if ($test['specific_permission'] == $overridable && $test['the_page'] == $sp_page) {
                                    $override_value = $test['the_value'];
                                }
                            }
                            if ($override_value != -1) {
                                $sp_perms .= 'gsp_' . $overridable . '_' . strval($group) . '="' . strval($override_value) . '" ';
                            }
                        }
                    }
                }
                if (count($overridables) == 0) {
                    $sp_perms = 'no_sps="1" ';
                }
                $has_children = $sp_perms != '';
                if (count(array_diff(array_keys($overridables), array('submit_highrange_content', 'submit_midrange_content', 'submit_lowrange_content'))) != 0) {
                    $sp_perms .= 'inherits_something="1" ';
                }
                $serverid = $zone . ':' . (is_string($page) ? $page : strval($page));
                echo '<category ' . ($serverid == $default ? 'selected="yes" ' : '') . 'description="' . xmlentities($description) . '" img_func_1="permissions_img_func_1" img_func_2="permissions_img_func_2" highlighted="true" ' . $view_perms . $sp_perms . ' id="' . uniqid('', true) . '" serverid="' . xmlentities($serverid) . '" title="' . xmlentities($page_title) . '" has_children="' . ($has_children ? 'true' : 'false') . '" selectable="true">';
            } else {
                $extra = '';
                if (strpos($page_type, 'modules') === 0) {
                    $info = extract_module_info(zone_black_magic_filterer(get_file_base() . '/' . $zone . ($zone == '' ? '' : '/') . 'pages/' . $page_type . '/' . $page . '.php'));
                    if (!is_null($info) && array_key_exists('author', $info)) {
                        $extra = 'author="' . xmlentities($info['author']) . '" organisation="' . xmlentities($info['organisation']) . '" version="' . xmlentities(integer_format($info['version'])) . '" ';
                    }
                }
                $has_children = false;
                // For a normal tree, we have children if we have entry points. We have children if we have categories also - but where there are categories there are also entry points
                if (strpos($page_type, 'modules') === 0) {
                    $_entrypoints = extract_module_functions_page($zone, $page, array('get_entry_points'));
                    if (!is_null($_entrypoints[0])) {
                        $entrypoints = is_string($_entrypoints[0]) && strpos($_entrypoints[0], '::') !== false ? array('whatever' => 1) : (is_array($_entrypoints[0]) ? call_user_func_array($_entrypoints[0][0], $_entrypoints[0][1]) : eval($_entrypoints[0]));
                        // The strpos thing is a little hack that allows it to work for base-class derived modules
                        if (!is_array($entrypoints)) {
                            $entrypoints = array('whatever' => 1);
                        }
                        $has_children = array_keys($entrypoints) != array('!');
                    }
                }
                global $MODULES_ZONES;
                $not_draggable = array_key_exists($page, $MODULES_ZONES) || $zone == 'adminzone' && substr($page, 0, 6) == 'admin_' && substr($page_type, 0, 6) == 'module';
                $serverid = $zone . ':' . $page;
                echo '<category ' . ($serverid == $default ? 'selected="yes" ' : '') . '' . $extra . 'type="' . xmlentities($page_type) . '" description="' . xmlentities($description) . '" draggable="' . ($not_draggable ? 'false' : 'page') . '" droppable="' . ($page_type == 'zone' ? 'page' : 'false') . '" id="' . uniqid('', true) . '" serverid="' . xmlentities($serverid) . '" title="' . xmlentities($page_title) . '" has_children="' . ($has_children ? 'true' : 'false') . '" selectable="true">';
            }
            echo '</category>';
        }
    } elseif (!is_null($page_link) && $page_link != '') {
        $matches = array();
        preg_match('#^([^:]*):([^:]*)#', $page_link, $matches);
        $zone = $matches[1];
        $page = $matches[2];
        if ($permissions_needed) {
            $category_access = $GLOBALS['SITE_DB']->query_select('group_category_access', array('*'));
        }
        $_pagelinks = extract_module_functions_page($zone, $page, array('get_page_links'), array(1, true, $page_link));
        if (!is_null($_pagelinks[0])) {
            $pagelinks = is_array($_pagelinks[0]) ? call_user_func_array($_pagelinks[0][0], $_pagelinks[0][1]) : eval($_pagelinks[0]);
            if (!is_null($pagelinks[0]) && !is_null($pagelinks[1])) {
                $_overridables = extract_module_functions_page(get_module_zone($pagelinks[1]), $pagelinks[1], array('get_sp_overrides'));
                if (!is_null($_overridables[0])) {
                    $overridables = is_array($_overridables[0]) ? call_user_func_array($_overridables[0][0], $_overridables[0][1]) : eval($_overridables[0]);
                } else {
                    $overridables = array();
                }
            } else {
                $overridables = array();
            }
        } else {
            $pagelinks = NULL;
        }
        $_pagelinks = extract_module_functions_page($zone, $page, array('extract_page_link_permissions'), array($page_link));
        list($category, $module) = is_null($_pagelinks[0]) || strlen($matches[0]) == strlen($page_link) ? array('!', '') : (is_array($_pagelinks[0]) ? call_user_func_array($_pagelinks[0][0], $_pagelinks[0][1]) : eval($_pagelinks[0]));
        // If $_pagelinks[0] is NULL then it's an error: extract_page_link_permissions is always there when there are cat permissions
        // Entry points under here
        if (!$permissions_needed && $zone . ':' . $page == $page_link) {
            $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);
            }
            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));
            }
            require_all_lang();
            $entrypoints = $object->get_entry_points();
            foreach ($entrypoints as $entry_point => $lang_string) {
                $serverid = $zone . ':' . $page;
                echo '<category ' . ($serverid == $default ? 'selected="yes" ' : '') . 'type="entry_point" id="' . uniqid('', true) . '" serverid="' . xmlentities($serverid) . ':type=' . $entry_point . '" title="' . xmlentities(do_lang('ENTRY_POINT') . ': ' . do_lang($lang_string)) . '" has_children="false" selectable="true">';
                echo '</category>';
            }
        }
        // Categories under here
        if (!is_null($pagelinks)) {
            foreach ($pagelinks[0] as $pagelink) {
                $keys = array_keys($pagelink);
                if (is_string($keys[0])) {
                    $module_the_name = array_key_exists(3, $pagelinks) ? $pagelinks[3] : NULL;
                    $category_name = is_string($pagelink['id']) ? $pagelink['id'] : strval($pagelink['id']);
                    $actual_page_link = str_replace('!', $category_name, $pagelinks[2]);
                    $title = $pagelink['title'];
                    $has_children = $pagelink['child_count'] != 0;
                } else {
                    $cms_module_name = NULL;
                    $module_the_name = $pagelink[1];
                    $category_name = is_null($pagelink[2]) ? '' : (is_string($pagelink[2]) ? $pagelink[2] : strval($pagelink[2]));
                    $actual_page_link = $pagelink[0];
                    $title = $pagelink[3];
                    $has_children = array_key_exists(7, $pagelink) ? $pagelink[7] : NULL;
                }
                $cms_module_name = $pagelinks[1];
                if ($category_name == $category) {
                    continue;
                }
                if ($module_the_name == 'catalogues_category' && $category_name == '') {
                    continue;
                }
                if (!is_null($cms_module_name)) {
                    $edit_type = '_ec';
                    if ($module_the_name == 'catalogues_catalogue') {
                        $edit_type = '_ev';
                    }
                    $actual_edit_link = preg_replace('#^[\\w\\_]+:[\\w\\_]+:type=[\\w\\_]+:(id|catalogue\\_name)=#', get_module_zone($cms_module_name) . ':' . $cms_module_name . ':' . $edit_type . ':', $actual_page_link);
                } else {
                    $actual_edit_link = '';
                }
                $actual_page_link = str_replace('_SELF:_SELF', $zone . ':' . $page, $actual_page_link);
                // Support for lazy notation
                if ($permissions_needed) {
                    $highlight = $module_the_name == 'catalogues_catalogue' ? 'true' : 'false';
                    $view_perms = '';
                    $sp_perms = '';
                    if (!is_null($module_the_name)) {
                        foreach ($groups as $group => $group_name) {
                            if (!in_array($group, $admin_groups)) {
                                $view_perms .= 'g_view_' . strval($group) . '="' . (in_array(array('module_the_name' => $module_the_name, 'category_name' => $category_name, 'group_id' => $group), $category_access) ? 'true' : 'false') . '" ';
                            }
                        }
                        foreach ($overridables as $overridable => $cat_support) {
                            $lang_string = do_lang('PT_' . $overridable);
                            if (is_array($cat_support)) {
                                $lang_string = do_lang($cat_support[1]);
                            }
                            if (strlen($lang_string) > 20 && strpos($lang_string, '(') !== false) {
                                $lang_string = preg_replace('# \\([^\\)]*\\)#', '', $lang_string);
                            }
                            if (is_array($cat_support)) {
                                $cat_support = $cat_support[0];
                            }
                            if ($cat_support == 0) {
                                continue;
                            }
                            $sp_perms .= 'sp_' . $overridable . '="' . xmlentities($lang_string) . '" ';
                            foreach ($groups as $group => $group_name) {
                                if (!in_array($group, $admin_groups)) {
                                    $override_value = -1;
                                    foreach ($sp_access[$group] as $test) {
                                        if ($test['specific_permission'] == $overridable && $test['the_page'] == '' && $test['category_name'] == $category_name && $test['module_the_name'] == $module_the_name) {
                                            $override_value = $test['the_value'];
                                        }
                                    }
                                    if ($override_value != -1) {
                                        $sp_perms .= 'gsp_' . $overridable . '_' . strval($group) . '="' . strval($override_value) . '" ';
                                    }
                                }
                            }
                        }
                    }
                    if (count(array_diff(array_keys($overridables), array('submit_highrange_content', 'submit_midrange_content', 'submit_lowrange_content'))) != 0) {
                        $sp_perms .= 'inherits_something="1" ';
                    }
                    $serverid = $actual_page_link;
                    echo '<category ' . ($serverid == $default ? 'selected="yes" ' : '') . 'img_func_1="permissions_img_func_1" img_func_2="permissions_img_func_2" highlighted="' . $highlight . '" ' . $view_perms . $sp_perms . ' id="' . uniqid('', true) . '" serverid="' . xmlentities($serverid) . '" title="' . xmlentities($title) . '" has_children="' . ($has_children ? 'true' : 'false') . '" selectable="' . (!is_null($module_the_name) ? 'true' : 'false') . '">';
                } else {
                    $serverid = $actual_page_link;
                    echo '<category ' . ($serverid == $default ? 'selected="yes" ' : '') . 'type="category" id="' . uniqid('', true) . '" edit="' . xmlentities($actual_edit_link) . '" serverid="' . xmlentities($serverid) . '" title="' . xmlentities($title) . '" has_children="' . ($has_children ? 'true' : 'false') . '" selectable="true">';
                }
                echo '</category>';
            }
        }
    } else {
        // Start of tree
        if ($permissions_needed) {
            $view_perms = '';
            foreach ($groups as $group => $group_name) {
                if (!in_array($group, $admin_groups)) {
                    $view_perms .= 'g_view_' . strval($group) . '="true" ';
                }
                // This isn't actually displayed in the editor
            }
            $sp_perms = '';
            $sp_perms_opera_hack = '';
            foreach (array_keys($root_perms) as $overridable) {
                $sp_perms .= 'sp_' . $overridable . '="' . xmlentities(do_lang('PT_' . $overridable)) . '" ';
                $sp_perms_opera_hack .= '<attribute key="' . 'sp_' . $overridable . '" value="' . xmlentities(do_lang('PT_' . $overridable)) . '" />';
                foreach ($groups as $group => $group_name) {
                    if (!in_array($group, $admin_groups)) {
                        $override_value = 0;
                        foreach ($sp_access[$group] as $test) {
                            if ($test['specific_permission'] == $overridable && $test['the_page'] == '' && $test['module_the_name'] == '' && $test['category_name'] == '') {
                                $override_value = $test['the_value'];
                            }
                        }
                        $sp_perms .= 'gsp_' . $overridable . '_' . strval($group) . '="' . strval($override_value) . '" ';
                        $sp_perms_opera_hack .= '<attribute key="' . 'gsp_' . $overridable . '_' . strval($group) . '" value="' . strval($override_value) . '" />';
                    }
                }
            }
            echo '<category serverid="_root" expanded="true" title="' . do_lang('ROOT') . '" has_children="true" selectable="true" img_func_1="permissions_img_func_1" img_func_2="permissions_img_func_2" id="' . uniqid('', true) . '" ' . $view_perms . '>';
            echo $sp_perms_opera_hack;
        } else {
            echo '<category serverid="_root" expanded="true" title="' . do_lang('ROOT') . '" has_children="true" selectable="false" type="root" id="' . uniqid('', true) . '">';
        }
        // Zones
        $zones = $GLOBALS['SITE_DB']->query_select('zones', array('zone_title', 'zone_name', 'zone_default_page'), NULL, 'ORDER BY zone_title', 50);
        if ($permissions_needed) {
            $zone_access = $GLOBALS['SITE_DB']->query_select('group_zone_access', array('*'));
            $page_access = $GLOBALS['SITE_DB']->query_select('group_page_access', array('*'));
        }
        $start_links = get_param_integer('start_links', 0) == 1;
        foreach ($zones as $_zone) {
            if (get_option('collapse_user_zones') == '1' && $_zone['zone_name'] == 'site') {
                continue;
            }
            $_zone['text_original'] = get_translated_text($_zone['zone_title']);
            $zone = $_zone['zone_name'];
            $zone_title = $_zone['text_original'];
            $serverid = $zone;
            if ($start_links) {
                $serverid = $zone . ':';
            }
            $pages = find_all_pages_wrap($zone, false, true, FIND_ALL_PAGES__NEWEST);
            if ($permissions_needed) {
                $view_perms = '';
                foreach ($groups as $group => $group_name) {
                    if (!in_array($group, $admin_groups)) {
                        $view_perms .= 'g_view_' . strval($group) . '="' . (in_array(array('zone_name' => $zone, 'group_id' => $group), $zone_access) ? 'true' : 'false') . '" ';
                    }
                }
                echo '<category ' . ($serverid == $default ? 'selected="yes" ' : '') . 'img_func_1="permissions_img_func_1" img_func_2="permissions_img_func_2" no_sps="1" highlighted="true" ' . $view_perms . ' id="' . uniqid('', true) . '" serverid="' . xmlentities($serverid) . '" title="' . xmlentities(do_lang('ZONE') . ': ' . $zone_title) . '" has_children="' . (count($pages) != 0 ? 'true' : 'false') . '" selectable="true">';
            } else {
                echo '<category ' . ($serverid == $default ? 'selected="yes" ' : '') . 'type="zone" droppable="page" id="' . uniqid('', true) . '" serverid="' . xmlentities($serverid) . '" title="' . xmlentities(do_lang('ZONE') . ': ' . $zone_title) . '" has_children="' . (count($pages) != 0 ? 'true' : 'false') . '" selectable="true">';
            }
            echo '</category>';
        }
        echo '</category>';
    }
    // Mark parent cats for pre-expansion
    if (!is_null($default) && $default != '' && strpos($default, ':') !== false) {
        list($zone, $page) = explode(':', $default, 2);
        echo "\n" . '<expand>' . $zone . '</expand>';
        echo "\n" . '<expand>' . $zone . ':</expand>';
        echo "\n" . '<expand>' . $zone . ':' . $page . '</expand>';
    }
    echo '</result></request>';
}
Example #5
0
/**
 * Assuming that permission details are POSTed, set the permissions for the specified category, in the current page
 *
 * @param  ID_TEXT		The ID code for the module being checked for category access
 * @param  ID_TEXT		The ID code for the category being checked for access (often, a number cast to a string)
 * @param  ?ID_TEXT		The page this is for (NULL: current page)
 */
function set_category_permissions_from_environment($module, $category, $page = NULL)
{
    if (is_null($page)) {
        $page = get_page_name();
    }
    require_code('zones2');
    $admin_groups = $GLOBALS['FORUM_DRIVER']->get_super_admin_groups();
    $groups = $GLOBALS['FORUM_DRIVER']->get_usergroup_list(false, true);
    // Based on old access settings, we may need to look at additional groups (clubs) that have permissions here
    $access = array();
    $access_rows = $GLOBALS[$module == 'forums' ? 'FORUM_DB' : 'SITE_DB']->query_select('group_category_access', array('group_id'), array('module_the_name' => $module, 'category_name' => $category));
    foreach ($access_rows as $row) {
        $access[$row['group_id']] = 1;
    }
    $all_groups = $GLOBALS['FORUM_DRIVER']->get_usergroup_list(true);
    foreach (array_keys($access) as $id) {
        if (!array_key_exists($id, $groups) && array_key_exists($id, $all_groups)) {
            $groups[$id] = $all_groups[$id];
        }
    }
    foreach (array_keys($groups) as $group_id) {
        if (in_array($group_id, $admin_groups)) {
            continue;
        }
        $GLOBALS[$module == 'forums' ? 'FORUM_DB' : 'SITE_DB']->query_delete('group_category_access', array('module_the_name' => $module, 'category_name' => $category, 'group_id' => $group_id));
    }
    $_overridables = extract_module_functions_page(get_module_zone($page), $page, array('get_sp_overrides'));
    if (is_null($_overridables[0])) {
        $overridables = array();
    } else {
        $overridables = is_array($_overridables[0]) ? call_user_func_array($_overridables[0][0], $_overridables[0][1]) : eval($_overridables[0]);
    }
    foreach ($overridables as $override => $cat_support) {
        if (is_array($cat_support)) {
            $cat_support = $cat_support[0];
        }
        $GLOBALS[$module == 'forums' ? 'FORUM_DB' : 'SITE_DB']->query_delete('gsp', array('specific_permission' => $override, 'module_the_name' => $module, 'category_name' => $category));
    }
    foreach (array_keys($groups) as $group_id) {
        if (in_array($group_id, $admin_groups)) {
            continue;
        }
        $value = post_param_integer('access_' . strval($group_id), 0);
        if ($value == 1) {
            $GLOBALS[$module == 'forums' ? 'FORUM_DB' : 'SITE_DB']->query_insert('group_category_access', array('module_the_name' => $module, 'category_name' => $category, 'group_id' => $group_id), false, true);
            // Race/corruption condition
        }
        foreach ($overridables as $override => $cat_support) {
            if (is_array($cat_support)) {
                $cat_support = $cat_support[0];
            }
            if ($cat_support == 0) {
                continue;
            }
            $value = post_param_integer('access_' . strval($group_id) . '_sp_' . $override, -1);
            if ($value != -1) {
                $GLOBALS[$module == 'forums' ? 'FORUM_DB' : 'SITE_DB']->query_insert('gsp', array('specific_permission' => $override, 'group_id' => $group_id, 'module_the_name' => $module, 'category_name' => $category, 'the_page' => '', 'the_value' => $value));
            }
        }
    }
    decache('main_sitemap');
}
Example #6
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 #7
0
/**
 * Get a list of overridable SP's for a module.
 *
 * @param  ID_TEXT		The zone it is in
 * @param  ID_TEXT		The page name
 * @return array			A pair: List of overridable SP's, SP-page
 */
function get_module_overridables($zone, $page)
{
    $overridables = array();
    $sp_page = $page;
    $_pagelinks = extract_module_functions_page($zone, $page, array('get_page_links'), array(NULL, false, NULL, true));
    if (!is_null($_pagelinks[0])) {
        $pagelinks = is_array($_pagelinks[0]) ? call_user_func_array($_pagelinks[0][0], $_pagelinks[0][1]) : eval($_pagelinks[0]);
        if (!is_null($pagelinks[0]) && !is_null($pagelinks[1])) {
            $_overridables = extract_module_functions_page(get_module_zone($pagelinks[1]), $pagelinks[1], array('get_sp_overrides'));
            if (!is_null($_overridables[0])) {
                $overridables = is_array($_overridables[0]) ? call_user_func_array($_overridables[0][0], $_overridables[0][1]) : eval($_overridables[0]);
            }
            $sp_page = $pagelinks[1];
        }
    } else {
        $_overridables = extract_module_functions_page($zone, $page, array('get_sp_overrides'));
        if (!is_null($_overridables[0])) {
            $overridables = is_array($_overridables[0]) ? call_user_func_array($_overridables[0][0], $_overridables[0][1]) : eval($_overridables[0]);
        }
    }
    return array($overridables, $sp_page);
}
Example #8
0
/**
 * AJAX script for finding out privileges for the queried resource.
 */
function find_permissions_script()
{
    header("Cache-Control: no-cache, must-revalidate");
    // HTTP/1.1
    header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
    // Date in the past
    header('Content-Type: text/plain');
    require_code('zones2');
    require_code('permissions2');
    $serverid = get_param('serverid');
    $x = get_param('x');
    $matches = array();
    preg_match('#^access_(\\d+)_sp_(.+)$#', $x, $matches);
    $group_id = intval($matches[1]);
    $sp = $matches[2];
    require_all_lang();
    echo do_lang('PT_' . $sp) . '=';
    if ($serverid == '_root') {
        echo has_specific_permission_group($group_id, $sp) ? do_lang('YES') : do_lang('NO');
    } else {
        preg_match('#^([^:]*):([^:]*)(:|$)#', $serverid, $matches);
        $zone = $matches[1];
        $page = $matches[2];
        $_pagelinks = extract_module_functions_page($zone, $page, array('get_page_links'), array(NULL, false, NULL, true));
        $bits = is_null($_pagelinks[0]) ? array('!', '') : (is_array($_pagelinks[0]) ? call_user_func_array($_pagelinks[0][0], $_pagelinks[0][1]) : eval($_pagelinks[0]));
        // If $_pagelinks[0] is NULL then it's an error: extract_page_link_permissions is always there when there are cat permissions
        $module = $bits[1];
        echo has_specific_permission_group($group_id, $sp, $module) ? do_lang('YES') : do_lang('NO');
    }
}
Example #9
0
/**
 * Start up a search for page-links, writing results into the callback. Usually we pass a callback that builds a Sitemap XML file, but we don't need to- it can be anything.
 *
 * @param  string  	Callback function to send discovered page-links to.
 * @param  MEMBER		The member we are finding stuff for (we only find what the member can view).
 * @param  ?array		Page-links to skip (NULL: none). Currently this only works on pages, but may be expanded in the future.
 * @param  integer	Code for how deep we are tunnelling down, in terms of what kinds of things we'll go so far as to collect. Use DEPTH__* constants for the values.
 */
function spawn_page_crawl($callback, $member_id, $extra_filters = NULL, $depth = 1)
{
    require_all_lang();
    require_code('zones2');
    if (is_null($extra_filters)) {
        $extra_filters = array();
    }
    $comcode_page_rows = $GLOBALS['SITE_DB']->query_select('comcode_pages', array('*'));
    $_zones = array();
    $zones = find_all_zones(false, true, true);
    // Reorder a bit
    $zones2 = array();
    foreach (array('', 'site') as $zone_match) {
        foreach ($zones as $i => $zone) {
            if ($zone[0] == $zone_match) {
                $zones2[] = $zone;
                unset($zones[$i]);
            }
        }
    }
    $zones2 = array_merge($zones2, $zones);
    if (function_exists('set_time_limit')) {
        @set_time_limit(0);
    }
    disable_php_memory_limit();
    $GLOBALS['MEMORY_OVER_SPEED'] = true;
    foreach ($zones2 as $z) {
        list($zone, $zone_title, , $zone_default_page) = $z;
        if (has_zone_access($member_id, $zone)) {
            $done_zone_level = false;
            $_pages = array();
            $pages = find_all_pages_wrap($zone, false, false, FIND_ALL_PAGES__ALL);
            foreach ($pages as $page => $page_type) {
                if (is_integer($page)) {
                    $page = strval($page);
                }
                if (substr($page, 0, 6) == 'panel_') {
                    continue;
                }
                if (substr($page, 0, 1) == '_') {
                    continue;
                }
                if (in_array($zone . ':' . $page, $extra_filters)) {
                    continue;
                }
                if ($page == '404') {
                    continue;
                }
                if ($page == 'forums' && substr($page_type, 0, 7) == 'modules' && (get_forum_type() == 'ocf' || get_forum_type() == 'none')) {
                    continue;
                }
                if ($page == 'join' && substr($page_type, 0, 7) == 'modules' && !is_guest($member_id)) {
                    continue;
                }
                if (has_page_access($member_id, $page, $zone)) {
                    // Page level
                    $_entrypoints = array();
                    $__entrypoints = extract_module_functions_page($zone, $page, array('get_entry_points'));
                    if (!is_null($__entrypoints[0])) {
                        $entrypoints = is_array($__entrypoints[0]) ? call_user_func_array($__entrypoints[0][0], $__entrypoints[0][1]) : (strpos($__entrypoints[0], '::') !== false ? NULL : eval($__entrypoints[0]));
                        // The strpos thing is a little hack that allows it to work for base-class derived modules
                        if (is_null($entrypoints)) {
                            $path = zone_black_magic_filterer($zone . ($zone == '' ? '' : '/') . 'pages/' . $page_type . '/' . $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;
                                }
                                $entrypoints = 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));
                                }
                                $entrypoints = $object->get_entry_points();
                            }
                        }
                    } else {
                        $entrypoints = array('!');
                    }
                    if (!is_array($entrypoints)) {
                        $entrypoints = array('!');
                    }
                    if ($entrypoints == array('!')) {
                        if ($zone_default_page == $page) {
                            $done_zone_level = true;
                        }
                        $add_date = NULL;
                        $edit_date = NULL;
                        $pagelink = $zone_default_page == $page ? $zone : $zone . ':' . $page;
                        $title = ucwords(str_replace('_', ' ', $page));
                        if (substr($page_type, 0, 7) == 'comcode') {
                            foreach ($comcode_page_rows as $page_row) {
                                if ($page_row['p_validated'] == 0 && $page_row['the_page'] == $page && $page_row['the_zone'] == $zone) {
                                    continue 2;
                                }
                            }
                            $path = zone_black_magic_filterer((strpos($page_type, '_custom') !== false ? get_custom_file_base() : get_file_base()) . '/' . filter_naughty($zone) . '/pages/' . filter_naughty($page_type) . '/' . $page . '.txt');
                            $add_date = filectime($path);
                            $edit_date = filemtime($path);
                            $page_contents = file_get_contents($path);
                            $matches = array();
                            if (preg_match('#\\[title[^\\]]*\\]#', $page_contents, $matches) != 0) {
                                $start = strpos($page_contents, $matches[0]) + strlen($matches[0]);
                                $end = strpos($page_contents, '[/title]', $start);
                                $matches = array();
                                if (preg_match('#^[^\\[\\{\\&]*$#', substr($page_contents, $start, $end - $start), $matches) != 0) {
                                    $title = $matches[0];
                                } else {
                                    $_title = comcode_to_tempcode(substr($page_contents, $start, $end - $start), NULL, true);
                                    $title = strip_tags(@html_entity_decode($_title->evaluate(), ENT_QUOTES, get_charset()));
                                }
                            }
                        } elseif (substr($page_type, 0, 4) == 'html') {
                            $path = zone_black_magic_filterer((strpos($page_type, '_custom') !== false ? get_custom_file_base() : get_file_base()) . '/' . filter_naughty($zone) . '/pages/' . filter_naughty($page_type) . '/' . $page . '.htm');
                            $add_date = filectime($path);
                            $edit_date = filemtime($path);
                            $page_contents = file_get_contents($path);
                            $matches = array();
                            if (preg_match('#\\<title[^\\>]*\\>#', $page_contents, $matches) != 0) {
                                $start = strpos($page_contents, $matches[0]) + strlen($matches[0]);
                                $end = strpos($page_contents, '</title>', $start);
                                $title = strip_tags(@html_entity_decode(substr($page_contents, $start, $end - $start), ENT_QUOTES, get_charset()));
                            }
                        }
                        // Callback
                        call_user_func_array($callback, array($pagelink, $zone, $add_date, $edit_date, $zone_default_page == $page ? 1.0 : 0.8, $title));
                    } elseif (count($entrypoints) != 0) {
                        // Entry point level
                        $done_top = false;
                        if ($depth >= DEPTH__ENTRY_POINTS) {
                            foreach ($entrypoints as $entrypoint => $title) {
                                if ($entrypoint == '!') {
                                    $pagelink = $zone . ':' . $page;
                                    $done_top = true;
                                    if ($zone_default_page == $page) {
                                        $done_zone_level = true;
                                    }
                                } else {
                                    $pagelink = $zone . ':' . $page . ':' . $entrypoint;
                                    if ($zone_default_page == $page && $entrypoint == 'misc') {
                                        $done_zone_level = true;
                                    }
                                }
                                // Callback
                                call_user_func_array($callback, array($pagelink, count($_entrypoints) > 1 && $entrypoint != '!' ? $zone . ':' . $page : $zone, NULL, NULL, $entrypoint == '!' || $entrypoint == 'misc' ? 0.8 : 0.7, $title));
                            }
                        }
                        //ksort($_entrypoints);
                        $title = do_lang('MODULE_TRANS_NAME_' . $page, NULL, NULL, NULL, NULL, false);
                        if (is_null($title)) {
                            $title = ucwords(str_replace('_', ' ', preg_replace('#^ocf\\_#', '', preg_replace('#^' . str_replace('#', '\\#', preg_quote($zone)) . '_#', '', preg_replace('#^' . str_replace('#', '\\#', preg_quote(str_replace('zone', '', $zone))) . '_#', '', $page)))));
                        }
                        if (count($_entrypoints) > 1 && !$done_top) {
                            // Callback
                            call_user_func_array($callback, array($zone . ':' . $page, $zone, NULL, NULL, 0.8, $title, false));
                        }
                    }
                    // Categories
                    if ($depth >= DEPTH__CATEGORIES) {
                        $__sitemap_pagelinks = extract_module_functions_page($zone, $page, array('get_sitemap_pagelinks'), array($callback, $member_id, $depth, $zone . ':' . $page . ':'));
                        if (!is_null($__sitemap_pagelinks[0])) {
                            if (is_array($__sitemap_pagelinks[0])) {
                                call_user_func_array($__sitemap_pagelinks[0][0], $__sitemap_pagelinks[0][1]);
                            } else {
                                eval($__sitemap_pagelinks[0]);
                            }
                        }
                    }
                }
            }
            // Zone level
            if (!$done_zone_level) {
                // Callback
                call_user_func_array($callback, array($zone, '', filectime(get_file_base() . '/' . $zone), NULL, 1.0, $zone_title));
            }
        }
    }
}