コード例 #1
0
 /**
  * Standard modular run function for OcCLE hooks.
  *
  * @param  array	The options with which the command was called
  * @param  array	The parameters with which the command was called
  * @param  array	A reference to the OcCLE filesystem object
  * @return array	Array of stdcommand, stdhtml, stdout, and stderr responses
  */
 function run($options, $parameters, &$occle_fs)
 {
     if (array_key_exists('h', $options) || array_key_exists('help', $options)) {
         return array('', do_command_help('find_entry_points', array('h'), array(true)), '', '');
     } else {
         if (!array_key_exists(0, $parameters)) {
             return array('', '', '', do_lang('MISSING_PARAM', '1', 'find_entry_points'));
         }
         // NOTE: this code assumes the search-string is contained within the zone:page portion of the entry point, not any part of the parameterisation
         $entry_points = array();
         $zones = find_all_zones();
         require_all_lang();
         foreach ($zones as $zone) {
             $pages = find_all_pages_wrap($zone);
             foreach ($pages as $page => $type) {
                 if (strpos($zone . ':' . $page, $parameters[0]) !== false) {
                     if ($type == 'modules' || $type == 'modules_custom') {
                         require_code(zone_black_magic_filterer(filter_naughty_harsh($zone) . '/pages/' . filter_naughty_harsh($type) . '/' . filter_naughty_harsh($page) . '.php'));
                         if (class_exists('Mx_' . filter_naughty_harsh($page))) {
                             $object = object_factory('Mx_' . filter_naughty_harsh($page), true);
                         } else {
                             $object = object_factory('Module_' . filter_naughty_harsh($page), true);
                         }
                         if (!is_null($object) && method_exists($object, 'get_entry_points')) {
                             $_entry_points = $object->get_entry_points();
                             foreach ($_entry_points as $key => $val) {
                                 $entry_points[$zone . ':' . $page . ':' . $key] = do_lang($val);
                             }
                         }
                     } else {
                         $entry_points[$zone . ':' . $page] = $page;
                     }
                 }
             }
         }
         return array('', do_template('OCCLE_ENTRY_POINTS', array('_GUID' => 'afaf0b0451ccbdae399dd56e39359c0e', 'ENTRY_POINTS' => $entry_points)), '', '');
     }
 }
コード例 #2
0
$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);
require_code('zones2');
foreach ($zones2 as $z) {
    list($zone, $zone_title, , ) = $z;
    if (has_zone_access(get_member(), $zone)) {
        $_pages = array();
        $pages = find_all_pages_wrap($zone);
        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 ($page == '404') {
                continue;
            }
            if ($page == 'sitemap') {
                continue;
コード例 #3
0
ファイル: main_sitemap.php プロジェクト: erico-deh/ocPortal
 /**
  * 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;
 }
コード例 #4
0
ファイル: site_tree.php プロジェクト: erico-deh/ocPortal
/**
 * 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>';
}
コード例 #5
0
 /**
  * The actualiser to set page access.
  *
  * @return tempcode		The UI
  */
 function set_page_access()
 {
     $GLOBALS['HELPER_PANEL_PIC'] = 'pagepics/permissionstree';
     $GLOBALS['HELPER_PANEL_TUTORIAL'] = 'tut_permissions';
     $title = get_page_title('PAGE_ACCESS');
     // Delete to cleanup
     $zone = post_param('zone');
     $GLOBALS['SITE_DB']->query('DELETE FROM ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'group_page_access WHERE page_name NOT LIKE \'' . db_encode_like('%:%') . '\' AND ' . db_string_equal_to('zone_name', $zone));
     $groups = $GLOBALS['FORUM_DRIVER']->get_usergroup_list(false, true);
     //	$zones=find_all_zones();
     $admin_groups = $GLOBALS['FORUM_DRIVER']->get_super_admin_groups();
     $zones = array($zone);
     foreach ($zones as $zone) {
         $pages = find_all_pages_wrap($zone);
         foreach (array_keys($pages) as $page) {
             foreach (array_keys($groups) as $id) {
                 if (in_array($id, $admin_groups)) {
                     continue;
                 }
                 $val = post_param_integer('p_' . $zone . '__' . $page . '__' . strval($id), 0);
                 if ($val == 0) {
                     $GLOBALS['SITE_DB']->query_insert('group_page_access', array('zone_name' => $zone, 'page_name' => $page, 'group_id' => $id));
                 }
             }
         }
     }
     breadcrumb_set_parents(array(array('_SELF:_SELF:page', do_lang_tempcode('CHOOSE')), array('_SELF:_SELF:page:zone=' . $zone, do_lang_tempcode('PAGE_ACCESS'))));
     breadcrumb_set_self(do_lang_tempcode('DONE'));
     decache('main_sitemap');
     $GLOBALS['SITE_DB']->query_delete('cache');
     if (function_exists('persistant_cache_empty')) {
         persistant_cache_empty();
     }
     // Show it worked / Refresh
     $url = build_url(array('page' => '_SELF', 'type' => 'page'), '_SELF');
     return redirect_screen($title, $url, do_lang_tempcode('SUCCESS'));
 }
コード例 #6
0
ファイル: admin_sitetree.php プロジェクト: erico-deh/ocPortal
 /**
  * The UI to move a page.
  *
  * @return tempcode		The UI
  */
 function move()
 {
     if (get_file_base() != get_custom_file_base()) {
         warn_exit(do_lang_tempcode('SHARED_INSTALL_PROHIBIT'));
     }
     $GLOBALS['HELPER_PANEL_PIC'] = 'pagepics/move';
     $GLOBALS['HELPER_PANEL_TUTORIAL'] = 'tut_structure';
     $title = get_page_title('MOVE_PAGES');
     $zone = get_param('zone', NULL);
     if (is_null($zone)) {
         return $this->choose_zone($title);
     }
     require_code('form_templates');
     $post_url = build_url(array('page' => '_SELF', 'type' => '_move'), '_SELF');
     $submit_name = do_lang_tempcode('MOVE_PAGES');
     $fields = new ocp_tempcode();
     $pages = find_all_pages_wrap($zone);
     foreach ($pages as $page => $type) {
         if (is_integer($page)) {
             $page = strval($page);
         }
         // We can't move admin modules
         if ($zone == 'adminzone' && substr($page, 0, 6) == 'admin_' && substr($type, 0, 6) == 'module') {
             continue;
         }
         // We can't move modules we've hard-optimised to be in a certain place
         global $MODULES_ZONES_DEFAULT;
         if (array_key_exists($page, $MODULES_ZONES_DEFAULT)) {
             continue;
         }
         $fields->attach(form_input_tick($page, do_lang_tempcode('_TYPE', escape_html($type)), 'page__' . $page, false));
     }
     require_code('zones2');
     require_code('zones3');
     $zones = nice_get_zones();
     $fields->attach(form_input_list(do_lang_tempcode('DESTINATION'), do_lang_tempcode('DESCRIPTION_DESTINATION_ZONE'), 'destination_zone', $zones, NULL, true));
     $hidden = form_input_hidden('zone', $zone);
     breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('PAGES'))));
     return do_template('FORM_SCREEN', array('_GUID' => '79869440ede2482fe51839df04b9d880', 'SKIP_VALIDATION' => true, 'FIELDS' => $fields, 'TITLE' => $title, 'SUBMIT_NAME' => $submit_name, 'TEXT' => paragraph(do_lang_tempcode('SELECT_PAGES_MOVE')), 'URL' => $post_url, 'HIDDEN' => $hidden));
 }
コード例 #7
0
ファイル: upgrade.php プロジェクト: erico-deh/ocPortal
/**
 * Rename a zone in the database and move any custom pages in it.
 *
 * @param  ID_TEXT		The old name of the zone
 * @param  ID_TEXT		The new name of the zone
 * @param  boolean		Whether to assume the main zone row has already been renamed as part of a wider editing operation
 */
function fu_rename_zone($zone, $new_zone, $dont_bother_with_main_row = false)
{
    if (function_exists('set_time_limit')) {
        @set_time_limit(0);
    }
    require_code('zones2');
    if (file_exists(get_file_base() . '/sources/zones3.php')) {
        require_code('zones3');
    }
    actual_rename_zone_lite($zone, $new_zone, $dont_bother_with_main_row);
    $pages = find_all_pages_wrap($zone, true, false, FIND_ALL_PAGES__ALL);
    foreach ($pages as $page => $type) {
        $path = get_file_base() . '/' . $zone . '/pages/' . $type . '/' . $page;
        $new_path = get_file_base() . '/' . $new_zone . '/pages/' . $type . '/' . $page;
        if (is_writable_wrap($path) && is_writable_wrap($new_path)) {
            rename($path, $new_path);
            sync_file_move($path, $new_path);
        }
    }
}
コード例 #8
0
ファイル: site2.php プロジェクト: erico-deh/ocPortal
/**
 * Render that the page wasn't found. Show alternate likely candidates based on misspellings.
 *
 * @param  ID_TEXT		The codename of the page to load
 * @param  ID_TEXT		The zone the page is being loaded in
 * @return tempcode		Message
 */
function page_not_found($codename, $zone)
{
    $GLOBALS['HTTP_STATUS_CODE'] = '404';
    if (!headers_sent()) {
        if (!browser_matches('ie') && strpos(ocp_srv('SERVER_SOFTWARE'), 'IIS') === false) {
            header('HTTP/1.0 404 Not Found');
        }
    }
    // Maybe problem with SEO URLs
    if (get_zone_name() == '' && get_option('htm_short_urls') == '1' && has_zone_access(get_member(), 'adminzone')) {
        $self_url = get_self_url_easy();
        $zones = find_all_zones();
        foreach ($zones as $_zone) {
            if ($_zone != '' && $_zone != 'site' && strpos($self_url, '/' . $_zone . '/') !== false) {
                attach_message(do_lang_tempcode('HTACCESS_SEO_PROBLEM'), 'warn');
            }
        }
    }
    // "Did you mean?" support
    $all_pages_in_zone = array_keys(find_all_pages_wrap($zone));
    $did_mean = array();
    foreach ($all_pages_in_zone as $possibility) {
        if (is_integer($possibility)) {
            $possibility = strval($possibility);
        }
        // e.g. '404' page has been converted to integer by PHP, grr
        $from = str_replace('cms_', '', str_replace('admin_', '', $possibility));
        $to = str_replace('cms_', '', str_replace('admin_', '', $codename));
        //$dist=levenshtein($from,$to);  If we use this, change > to < also
        //$threshold=4;
        $dist = 0.0;
        similar_text($from, $to, $dist);
        $threshold = 75.0;
        if ($dist > $threshold && has_page_access(get_member(), $codename, $zone)) {
            $did_mean[$dist] = $possibility;
        }
    }
    ksort($did_mean);
    $_did_mean = array_pop($did_mean);
    if ($_did_mean == '') {
        $_did_mean = NULL;
    }
    if (ocp_srv('HTTP_REFERER') != '' && !handle_has_checked_recently('request-' . $zone . ':' . $codename)) {
        require_code('failure');
        relay_error_notification(do_lang('_MISSING_RESOURCE', $zone . ':' . $codename) . ' ' . do_lang('REFERRER', ocp_srv('HTTP_REFERER'), substr(get_browser_string(), 0, 255)), false, 'error_occurred_missing_page');
    }
    $title = get_page_title('ERROR_OCCURRED');
    $add_access = has_actual_page_access(get_member(), 'cms_comcode_pages', NULL, NULL, 'submit_highrange_content');
    $redirect_access = addon_installed('redirects_editor') && has_actual_page_access(get_member(), 'admin_redirects');
    require_lang('zones');
    $add_url = $add_access ? build_url(array('page' => 'cms_comcode_pages', 'type' => '_ed', 'page_link' => $zone . ':' . $codename), get_module_zone('cms_comcode_pages')) : new ocp_tempcode();
    $add_redirect_url = $redirect_access ? build_url(array('page' => 'admin_redirects', 'type' => 'misc', 'page_link' => $zone . ':' . $codename), get_module_zone('admin_redirects')) : new ocp_tempcode();
    return do_template('MISSING_SCREEN', array('_GUID' => '22f371577cd2ba437e7b0cb241931575', 'TITLE' => $title, 'DID_MEAN' => $_did_mean, 'ADD_URL' => $add_url, 'ADD_REDIRECT_URL' => $add_redirect_url, 'PAGE' => $codename));
}
コード例 #9
0
ファイル: cms_galleries.php プロジェクト: erico-deh/ocPortal
 /**
  * Get tempcode for a gallery adding/editing form.
  *
  * @param  ID_TEXT			The gallery codename
  * @param  SHORT_TEXT		The full human-readeable name of the gallery
  * @param  LONG_TEXT			The description of the gallery
  * @param  SHORT_TEXT		Teaser text for the gallery
  * @param  LONG_TEXT			Hidden notes associated with the gallery
  * @param  ID_TEXT			The parent gallery (blank: no parent)
  * @param  BINARY				Whether images may be put in this gallery
  * @param  BINARY				Whether videos may be put in this gallery
  * @param  BINARY				Whether the gallery serves as a container for automatically created member galleries
  * @param  ?BINARY			Whether the gallery uses the flow mode interface (NULL: pick statistically based on current usage of other galleries)
  * @param  ?URLPATH			The representative image of the gallery (NULL: none)
  * @param  ?URLPATH			Watermark (NULL: none)
  * @param  ?URLPATH			Watermark (NULL: none)
  * @param  ?URLPATH			Watermark (NULL: none)
  * @param  ?URLPATH			Watermark (NULL: none)
  * @param  ?BINARY			Whether rating is allowed (NULL: decide statistically, based on existing choices)
  * @param  ?SHORT_INTEGER	Whether comments are allowed (0=no, 1=yes, 2=review style) (NULL: decide statistically, based on existing choices)
  * @return array				A pair: the tempcode for the visible fields, and the tempcode for the hidden fields
  */
 function get_form_fields($name = '', $fullname = '', $description = '', $teaser = '', $notes = '', $parent_id = '', $accept_images = 1, $accept_videos = 1, $is_member_synched = 0, $flow_mode_interface = NULL, $rep_image = NULL, $watermark_top_left = NULL, $watermark_top_right = NULL, $watermark_bottom_left = NULL, $watermark_bottom_right = NULL, $allow_rating = NULL, $allow_comments = NULL)
 {
     list($allow_rating, $allow_comments, ) = $this->choose_feedback_fields_statistically($allow_rating, $allow_comments, 1);
     global $NON_CANONICAL_PARAMS;
     $NON_CANONICAL_PARAMS[] = 'cat';
     $NON_CANONICAL_PARAMS[] = 'validated';
     if (is_null($flow_mode_interface)) {
         $cnt = $GLOBALS['SITE_DB']->query_value('galleries', 'COUNT(*)');
         if ($cnt < 5000) {
             $flow_mode_interface = intval(round($GLOBALS['SITE_DB']->query_value('galleries', 'AVG(flow_mode_interface)')));
             // Determine default based on what is 'the norm' currently. Sometimes maths is beautiful :)
         } else {
             $flow_mode_interface = intval(round($GLOBALS['SITE_DB']->query_value('galleries', 'AVG(flow_mode_interface)', array('parent_id' => 'root'))));
             // Determine default based on what is 'the norm' currently. Sometimes maths is beautiful :)
         }
     }
     $fields = new ocp_tempcode();
     require_code('form_templates');
     $fields->attach(form_input_line(do_lang_tempcode('TITLE'), do_lang_tempcode('DESCRIPTION_TITLE'), 'fullname', $fullname, true));
     if ($name != 'root') {
         $fields->attach(form_input_codename(do_lang_tempcode('CODENAME'), do_lang_tempcode('DESCRIPTION_CODENAME'), 'name', $name, true));
     }
     $fields->attach(form_input_text_comcode(do_lang_tempcode('DESCRIPTION'), do_lang_tempcode('DESCRIPTION_DESCRIPTION'), 'description', $description, false));
     if ($parent_id == '') {
         $parent_id = get_param('cat', '');
     }
     if ($name != 'root') {
         $fields->attach(form_input_tree_list(do_lang_tempcode('PARENT'), do_lang_tempcode('DESCRIPTION_PARENT'), 'parent_id', NULL, 'choose_gallery', array('filter' => 'only_conventional_galleries', 'purity' => true, 'addable_filter' => true), true, $parent_id));
     }
     $fields->attach(form_input_various_ticks(array(array(do_lang_tempcode('ACCEPT_IMAGES'), 'accept_images', $accept_images == 1, do_lang_tempcode('DESCRIPTION_ACCEPT_IMAGES')), array(do_lang_tempcode('ACCEPT_VIDEOS'), 'accept_videos', $accept_videos == 1, do_lang_tempcode('DESCRIPTION_ACCEPT_VIDEOS'))), new ocp_tempcode(), NULL, do_lang_tempcode('ACCEPTED_MEDIA_TYPES')));
     $fields->attach(form_input_tick(do_lang_tempcode('FLOW_MODE_INTERFACE'), do_lang_tempcode('DESCRIPTION_FLOW_MODE_INTERFACE'), 'flow_mode_interface', $flow_mode_interface == 1));
     $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('SECTION_HIDDEN' => $rep_image == '' && $teaser == '' && $is_member_synched == 0, 'TITLE' => do_lang_tempcode('ADVANCED'))));
     $fields->attach(form_input_upload(do_lang_tempcode('REPRESENTATIVE_IMAGE'), do_lang_tempcode('DESCRIPTION_REPRESENTATIVE_IMAGE_GALLERY'), 'rep_image', false, $rep_image, NULL, true, str_replace(' ', '', get_option('valid_images'))));
     // Only show tease option if tease block being used
     $teaser_shows = false;
     $zones = find_all_zones(false, true);
     $pages = array();
     foreach ($zones as $_zone) {
         $pages[$_zone[0]] = find_all_pages_wrap($_zone[0], true);
     }
     foreach ($pages as $zone => $under) {
         foreach ($under as $filename => $type) {
             if (substr(strtolower($filename), -4) == '.txt') {
                 $matches = array();
                 $contents = file_get_contents(zone_black_magic_filterer((substr($type, 0, 15) == 'comcode_custom/' ? get_custom_file_base() : get_file_base()) . '/' . ($zone == '' ? '' : $zone . '/') . 'pages/' . $type . '/' . $filename));
                 $fallback = get_file_base() . '/' . ($zone == '' ? '' : $zone . '/') . 'pages/comcode/' . fallback_lang() . '/' . $filename;
                 if (file_exists($fallback)) {
                     $contents .= file_get_contents($fallback);
                 }
                 if (preg_match('#\\[block[^\\]]*\\]main_gallery_tease\\[/block\\]#', $contents, $matches) != 0) {
                     $teaser_shows = true;
                 }
             }
         }
     }
     if ($teaser_shows) {
         $fields->attach(form_input_line_comcode(do_lang_tempcode('TEASER'), do_lang_tempcode('DESCRIPTION_TEASER'), 'teaser', $teaser, false));
     }
     $fields->attach(form_input_tick(do_lang_tempcode('IS_MEMBER_SYNCHED'), do_lang_tempcode('DESCRIPTION_IS_MEMBER_SYNCHED_GALLERY'), 'is_member_synched', $is_member_synched == 1));
     $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('SECTION_HIDDEN' => is_null($watermark_top_left) && is_null($watermark_top_right) && is_null($watermark_bottom_left) && is_null($watermark_bottom_right), 'TITLE' => do_lang_tempcode('WATERMARKING'))));
     $fields->attach(form_input_upload(do_lang_tempcode('_WATERMARK', do_lang_tempcode('TOP_LEFT')), do_lang_tempcode('_DESCRIPTION_WATERMARK', do_lang_tempcode('TOP_LEFT')), 'watermark_top_left', false, $watermark_top_left, NULL, true, str_replace(' ', '', get_option('valid_images'))));
     $fields->attach(form_input_upload(do_lang_tempcode('_WATERMARK', do_lang_tempcode('TOP_RIGHT')), do_lang_tempcode('_DESCRIPTION_WATERMARK', do_lang_tempcode('TOP_RIGHT')), 'watermark_top_right', false, $watermark_top_right, NULL, true, str_replace(' ', '', get_option('valid_images'))));
     $fields->attach(form_input_upload(do_lang_tempcode('_WATERMARK', do_lang_tempcode('BOTTOM_LEFT')), do_lang_tempcode('_DESCRIPTION_WATERMARK', do_lang_tempcode('BOTTOM_LEFT')), 'watermark_bottom_left', false, $watermark_bottom_left, NULL, true, str_replace(' ', '', get_option('valid_images'))));
     $fields->attach(form_input_upload(do_lang_tempcode('_WATERMARK', do_lang_tempcode('BOTTOM_RIGHT')), do_lang_tempcode('_DESCRIPTION_WATERMARK', do_lang_tempcode('BOTTOM_RIGHT')), 'watermark_bottom_right', false, $watermark_bottom_right, NULL, true, str_replace(' ', '', get_option('valid_images'))));
     $hidden = new ocp_tempcode();
     handle_max_file_size($hidden, 'image');
     require_code('feedback2');
     $fields->attach(feedback_fields($allow_rating == 1, $allow_comments == 1, NULL, false, $notes, $allow_comments == 2, true));
     // Permissions
     $fields->attach($this->get_permission_fields($name, NULL, $name == ''));
     return array($fields, $hidden);
 }
コード例 #10
0
ファイル: zones3.php プロジェクト: erico-deh/ocPortal
/**
 * Delete a zone.
 *
 * @param  ID_TEXT		The name of the zone
 */
function actual_delete_zone($zone)
{
    if (get_file_base() != get_custom_file_base()) {
        warn_exit(do_lang_tempcode('SHARED_INSTALL_PROHIBIT'));
    }
    require_code('abstract_file_manager');
    force_have_afm_details();
    if (function_exists('set_time_limit')) {
        @set_time_limit(0);
    }
    disable_php_memory_limit();
    $pages = find_all_pages_wrap($zone, false, false, FIND_ALL_PAGES__ALL);
    $bad = array();
    foreach (array_keys($pages) as $page) {
        if (substr($page, 0, 6) != 'panel_' && $page != 'start') {
            $bad[] = $page;
        }
    }
    if ($bad != array()) {
        require_lang('zones');
        warn_exit(do_lang_tempcode('DELETE_ZONE_ERROR', '<kbd>' . implode('</kbd>, <kbd>', $bad) . '</kbd>'));
    }
    actual_delete_zone_lite($zone);
    if (file_exists(get_custom_file_base() . '/' . filter_naughty($zone))) {
        afm_delete_directory(filter_naughty($zone), true);
    }
}
コード例 #11
0
ファイル: misc_scripts.php プロジェクト: erico-deh/ocPortal
/**
 * Shows an HTML page for making block Comcode.
 */
function block_helper_script()
{
    require_lang('comcode');
    require_lang('blocks');
    require_code('zones2');
    require_code('zones3');
    check_specific_permission('comcode_dangerous');
    $title = get_page_title('BLOCK_HELPER');
    require_code('form_templates');
    require_all_lang();
    $type_wanted = get_param('block_type', 'main');
    $type = get_param('type', 'step1');
    $content = new ocp_tempcode();
    if ($type == 'step1') {
        // Find what addons all our block files are in, and icons if possible
        $hooks = find_all_hooks('systems', 'addon_registry');
        $hook_keys = array_keys($hooks);
        $hook_files = array();
        foreach ($hook_keys as $hook) {
            $path = get_file_base() . '/sources_custom/hooks/systems/addon_registry/' . filter_naughty_harsh($hook) . '.php';
            if (!file_exists($path)) {
                $path = get_file_base() . '/sources/hooks/systems/addon_registry/' . filter_naughty_harsh($hook) . '.php';
            }
            $hook_files[$hook] = file_get_contents($path);
        }
        unset($hook_keys);
        $addon_icons = array();
        $addons_blocks = array();
        foreach ($hook_files as $addon_name => $hook_file) {
            $matches = array();
            if (preg_match('#function get_file_list\\(\\)\\s*\\{([^\\}]*)\\}#', $hook_file, $matches) != 0) {
                if (!defined('HIPHOP_PHP')) {
                    $addon_files = eval($matches[1]);
                } else {
                    require_code('hooks/systems/addon_registry/' . $addon_name);
                    $hook_ob = object_factory('Hook_addon_registry_' . $addon_name);
                    $addon_files = $hook_ob->get_file_list();
                }
                foreach ($addon_files as $file) {
                    if (substr($file, 0, 31) == 'themes/default/images/bigicons/' && !array_key_exists($addon_name, $addon_icons)) {
                        $addon_icons[$addon_name] = find_theme_image('bigicons/' . basename($file, '.png'), false, true);
                    }
                    if (substr($file, 0, 21) == 'sources_custom/blocks/' || substr($file, 0, 15) == 'sources/blocks/') {
                        if ($addon_name == 'staff_messaging') {
                            $addon_name = 'core_feedback_features';
                        }
                        $addons_blocks[basename($file, '.php')] = $addon_name;
                    }
                }
            }
        }
        // Find where blocks have been used
        $block_usage = array();
        $zones = find_all_zones(false, true);
        foreach ($zones as $_zone) {
            $zone = $_zone[0];
            $pages = find_all_pages_wrap($zone, true);
            foreach ($pages as $filename => $type) {
                if (substr(strtolower($filename), -4) == '.txt') {
                    $matches = array();
                    $contents = file_get_contents(zone_black_magic_filterer((substr($type, 0, 15) == 'comcode_custom/' ? get_custom_file_base() : get_file_base()) . '/' . ($zone == '' ? '' : $zone . '/') . 'pages/' . $type . '/' . $filename));
                    //$fallback=get_file_base().'/'.(($zone=='')?'':($zone.'/')).'pages/comcode/'.fallback_lang().'/'.$filename;
                    //if (file_exists($fallback)) $contents.=file_get_contents($fallback);
                    $num_matches = preg_match_all('#\\[block[^\\]]*\\](.*)\\[/block\\]#U', $contents, $matches);
                    for ($i = 0; $i < $num_matches; $i++) {
                        $block_used = $matches[1][$i];
                        if (!array_key_exists($block_used, $block_usage)) {
                            $block_usage[$block_used] = array();
                        }
                        $block_usage[$block_used][] = $zone . ':' . basename($filename, '.txt');
                    }
                }
            }
        }
        // Show block list
        $links = new ocp_tempcode();
        $blocks = find_all_blocks();
        $dh = @opendir(get_file_base() . '/sources_custom/miniblocks');
        if ($dh !== false) {
            while (($file = readdir($dh)) !== false) {
                if (substr($file, -4) == '.php' && preg_match('#^[\\w\\-]*$#', substr($file, 0, strlen($file) - 4)) != 0) {
                    $blocks[substr($file, 0, strlen($file) - 4)] = 'sources_custom';
                }
            }
            closedir($dh);
        }
        $block_types = array();
        $block_types_icon = array();
        $keep = symbol_tempcode('KEEP');
        foreach (array_keys($blocks) as $block) {
            if (array_key_exists($block, $addons_blocks)) {
                $addon_name = $addons_blocks[$block];
                $addon_icon = array_key_exists($addon_name, $addon_icons) ? $addon_icons[$addon_name] : NULL;
                $addon_name = preg_replace('#^core\\_#', '', $addon_name);
            } else {
                $addon_name = NULL;
                $addon_icon = NULL;
            }
            $this_block_type = is_null($addon_name) || strpos($addon_name, 'block') !== false || $addon_name == 'core' ? substr($block, 0, strpos($block, '_') === false ? strlen($block) : strpos($block, '_')) : $addon_name;
            if (!array_key_exists($this_block_type, $block_types)) {
                $block_types[$this_block_type] = new ocp_tempcode();
            }
            if (!is_null($addon_icon)) {
                $block_types_icon[$this_block_type] = $addon_icon;
            }
            $block_description = do_lang('BLOCK_' . $block . '_DESCRIPTION', NULL, NULL, NULL, NULL, false);
            $block_use = do_lang('BLOCK_' . $block . '_USE', NULL, NULL, NULL, NULL, false);
            if (is_null($block_description)) {
                $block_description = '';
            }
            if (is_null($block_use)) {
                $block_use = '';
            }
            $descriptiont = $block_description == '' && $block_use == '' ? new ocp_tempcode() : do_lang_tempcode('BLOCK_HELPER_1X', $block_description, $block_use);
            $url = find_script('block_helper') . '?type=step2&block=' . urlencode($block) . '&field_name=' . get_param('field_name') . $keep->evaluate();
            if (get_param('utheme', '') != '') {
                $url .= '&utheme=' . get_param('utheme');
            }
            $url .= '&block_type=' . $type_wanted;
            $link_caption = do_lang_tempcode('NICE_BLOCK_NAME', escape_html(cleanup_block_name($block)), $block);
            $usage = array_key_exists($block, $block_usage) ? $block_usage[$block] : array();
            $block_types[$this_block_type]->attach(do_template('BLOCK_HELPER_BLOCK_CHOICE', array('USAGE' => $usage, 'DESCRIPTION' => $descriptiont, 'URL' => $url, 'LINK_CAPTION' => $link_caption)));
        }
        /*if (array_key_exists($type_wanted,$block_types)) We don't do this now, as we structure by addon name
        		{
        			$x=$block_types[$type_wanted];
        			unset($block_types[$type_wanted]);
        			$block_types=array_merge(array($type_wanted=>$x),$block_types);
        		}*/
        ksort($block_types);
        // We sort now instead
        $move_after = $block_types['adminzone_frontpage'];
        unset($block_types['adminzone_frontpage']);
        $block_types['adminzone_frontpage'] = $move_after;
        foreach ($block_types as $block_type => $_links) {
            switch ($block_type) {
                case 'side':
                case 'main':
                case 'bottom':
                    $type_title = do_lang_tempcode('BLOCKS_TYPE_' . $block_type);
                    $img = NULL;
                    break;
                default:
                    $type_title = do_lang_tempcode('BLOCKS_TYPE_ADDON', escape_html(cleanup_block_name($block_type)));
                    $img = array_key_exists($block_type, $block_types_icon) ? $block_types_icon[$block_type] : NULL;
                    break;
            }
            $links->attach(do_template('BLOCK_HELPER_BLOCK_GROUP', array('IMG' => $img, 'TITLE' => $type_title, 'LINKS' => $_links)));
        }
        $content = do_template('BLOCK_HELPER_START', array('_GUID' => 'd2d6837cdd8b19d80ea95ab9f5d09c9a', 'GET' => true, 'TITLE' => $title, 'LINKS' => $links));
    } elseif ($type == 'step2') {
        require_code('comcode_text');
        $defaults = parse_single_comcode_tag(get_param('parse_defaults', '', true), 'block');
        $block = trim(get_param('block'));
        $title = get_page_title('_BLOCK_HELPER', true, array(escape_html($block)));
        $fields = new ocp_tempcode();
        $parameters = get_block_parameters($block);
        $parameters[] = 'failsafe';
        $parameters[] = 'cache';
        $parameters[] = 'quick_cache';
        if (!isset($defaults['cache'])) {
            $defaults['cache'] = block_cache_default($block);
        }
        if (is_null($parameters)) {
            $parameters = array();
        }
        $advanced_ind = do_lang('BLOCK_IND_ADVANCED');
        $param_classes = array('normal' => array(), 'advanced' => array());
        foreach ($parameters as $parameter) {
            $param_class = 'normal';
            if ($parameter == 'cache' || $parameter == 'quick_cache' || $parameter == 'failsafe' || strpos(do_lang('BLOCK_' . $block . '_PARAM_' . $parameter), $advanced_ind) !== false) {
                $param_class = 'advanced';
            }
            $param_classes[$param_class][] = $parameter;
        }
        foreach ($param_classes as $param_class => $parameters) {
            if (count($parameters) == 0) {
                if ($param_class == 'normal') {
                    $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('SECTION_HIDDEN' => false, 'TITLE' => do_lang_tempcode('PARAMETERS'), 'HELP' => protect_from_escaping(paragraph(do_lang_tempcode('BLOCK_HELPER_NO_PARAMETERS'), '', 'nothing_here')))));
                }
                continue;
            }
            if ($param_class == 'advanced') {
                $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('SECTION_HIDDEN' => true, 'TITLE' => do_lang_tempcode('ADVANCED'))));
            }
            foreach ($parameters as $parameter) {
                $matches = array();
                switch ($parameter) {
                    case 'quick_cache':
                    case 'cache':
                    case 'failsafe':
                        $description = do_lang('BLOCK_PARAM_' . $parameter);
                        break;
                    default:
                        $description = do_lang('BLOCK_' . $block . '_PARAM_' . $parameter);
                        break;
                }
                $description = str_replace(do_lang('BLOCK_IND_STRIPPABLE_1'), '', $description);
                $description = trim(str_replace(do_lang('BLOCK_IND_ADVANCED'), '', $description));
                // Work out default value for field
                $default = '';
                if (preg_match('#' . do_lang('BLOCK_IND_DEFAULT') . ': ["\']([^"]*)["\']#Ui', $description, $matches) != 0) {
                    $default = $matches[1];
                    $has_default = true;
                    $description = preg_replace('#\\s*' . do_lang('BLOCK_IND_DEFAULT') . ': ["\']([^"]*)["\'](?-U)\\.?(?U)#Ui', '', $description);
                } else {
                    $has_default = false;
                }
                if (isset($defaults[$parameter])) {
                    $default = $defaults[$parameter];
                    $has_default = true;
                }
                // Show field
                if ($block . ':' . $parameter == 'side_stored_menu:type') {
                    $matches = array();
                    $dh = opendir(get_file_base() . '/themes/default/templates/');
                    $options = array();
                    while (($file = readdir($dh)) !== false) {
                        if (preg_match('^MENU\\_([a-z]+)\\.tpl$^', $file, $matches) != 0) {
                            $options[] = $matches[1];
                        }
                    }
                    closedir($dh);
                    $dh = opendir(get_custom_file_base() . '/themes/default/templates_custom/');
                    while (($file = readdir($dh)) !== false) {
                        if (preg_match('^MENU\\_([a-z]+)\\.tpl$^', $file, $matches) != 0 && !file_exists(get_file_base() . '/themes/default/templates/' . $file)) {
                            $options[] = $matches[1];
                        }
                    }
                    closedir($dh);
                    sort($options);
                    $list = new ocp_tempcode();
                    foreach ($options as $option) {
                        $list->attach(form_input_list_entry($option, $has_default && $option == $default));
                    }
                    $fields->attach(form_input_list(ucwords(str_replace('_', ' ', $parameter)), escape_html($description), $parameter, $list, NULL, false, false));
                } elseif ($block . ':' . $parameter == 'side_stored_menu:param') {
                    $list = new ocp_tempcode();
                    $rows = $GLOBALS['SITE_DB']->query_select('menu_items', array('DISTINCT i_menu'), NULL, 'ORDER BY i_menu');
                    foreach ($rows as $row) {
                        $list->attach(form_input_list_entry($row['i_menu'], $has_default && $row['i_menu'] == $default));
                    }
                    $fields->attach(form_input_list(ucwords(str_replace('_', ' ', $parameter)), escape_html($description), $parameter, $list, NULL, false, false));
                } elseif ($block . ':' . $parameter == 'side_shoutbox:param') {
                    $list = new ocp_tempcode();
                    $rows = $GLOBALS['SITE_DB']->query_select('chat_rooms', array('id', 'room_name'), array('is_im' => 0), '', 100);
                    foreach ($rows as $row) {
                        $list->attach(form_input_list_entry(strval($row['id']), $has_default && strval($row['id']) == $default, $row['room_name']));
                    }
                    $fields->attach(form_input_list(ucwords(str_replace('_', ' ', $parameter)), escape_html($description), $parameter, $list, NULL, false, false));
                } elseif ($block . ':' . $parameter == 'main_poll:param') {
                    $list = new ocp_tempcode();
                    $rows = $GLOBALS['SITE_DB']->query_select('poll', array('id', 'question'), NULL, 'ORDER BY id DESC', 100);
                    $list->attach(form_input_list_entry('', false, do_lang('NA')));
                    foreach ($rows as $row) {
                        $list->attach(form_input_list_entry(strval($row['id']), $has_default && strval($row['id']) == $default, get_translated_text($row['question'])));
                    }
                    $fields->attach(form_input_list(ucwords(str_replace('_', ' ', $parameter)), escape_html($description), $parameter, $list, NULL, false, false));
                } elseif ($block . ':' . $parameter == 'main_awards:param') {
                    $list = new ocp_tempcode();
                    $rows = $GLOBALS['SITE_DB']->query_select('award_types', array('id', 'a_title'));
                    foreach ($rows as $row) {
                        $list->attach(form_input_list_entry(strval($row['id']), $has_default && strval($row['id']) == $default, get_translated_text($row['a_title'])));
                    }
                    $fields->attach(form_input_list(ucwords(str_replace('_', ' ', $parameter)), escape_html($description), $parameter, $list, NULL, false, false));
                } elseif ($parameter == 'zone' || $parameter == 'param' && $block == 'main_as_zone_access') {
                    $list = new ocp_tempcode();
                    $list->attach(form_input_list_entry('_SEARCH', $default == ''));
                    $list->attach(nice_get_zones($default == '' ? NULL : $default));
                    $fields->attach(form_input_list(ucwords(str_replace('_', ' ', $parameter)), escape_html($description), $parameter, $list, NULL, false, false));
                } elseif (($parameter == 'forum' || $parameter == 'param' && in_array($block, array('main_forum_topics'))) && get_forum_type() == 'ocf') {
                    require_code('ocf_forums');
                    require_code('ocf_forums2');
                    if (!addon_installed('ocf_forum')) {
                        warn_exit(do_lang_tempcode('NO_FORUM_INSTALLED'));
                    }
                    $list = ocf_get_forum_tree_secure(NULL, NULL, true, explode(',', $default));
                    $fields->attach(form_input_multi_list(ucwords(str_replace('_', ' ', $parameter)), escape_html($description), $parameter, $list));
                } elseif ($parameter == 'param' && in_array($block, array('side_root_galleries', 'main_gallery_tease', 'main_gallery_embed', 'main_image_fader'))) {
                    require_code('galleries');
                    $list = nice_get_gallery_tree($default);
                    $fields->attach(form_input_list(ucwords(str_replace('_', ' ', $parameter)), escape_html($description), $parameter, $list, NULL, false, false));
                } elseif ($parameter == 'param' && in_array($block, array('main_download_category'))) {
                    require_code('downloads');
                    $list = nice_get_download_category_tree($default == '' ? NULL : intval($default));
                    $fields->attach(form_input_list(ucwords(str_replace('_', ' ', $parameter)), escape_html($description), $parameter, $list, NULL, false, false));
                } elseif ($parameter == 'param' && in_array($block, array('main_contact_catalogues')) || $parameter == 'catalogue' && in_array($block, array('main_recent_cc_entries'))) {
                    require_code('catalogues');
                    $list = nice_get_catalogues($default, false);
                    $fields->attach(form_input_list(ucwords(str_replace('_', ' ', $parameter)), escape_html($description), $parameter, $list, NULL, false, false));
                } elseif ($parameter == 'param' && in_array($block, array('main_cc_embed')) && $GLOBALS['SITE_DB']->query_value('catalogue_categories', 'COUNT(*)') < 500) {
                    $list = new ocp_tempcode();
                    $categories = $GLOBALS['SITE_DB']->query_select('catalogue_categories', array('id', 'cc_title', 'c_name'), NULL, 'ORDER BY c_name,id');
                    $last_cat = mixed();
                    foreach ($categories as $cat) {
                        if (is_null($last_cat) || $cat['c_name'] != $last_cat) {
                            $list->attach(form_input_list_entry($cat['c_name'], $has_default && $cat['c_name'] == $default, $cat['c_name'], false, true));
                            $last_cat = $cat['c_name'];
                        }
                        $list->attach(form_input_list_entry(strval($cat['id']), $has_default && strval($cat['id']) == $default, get_translated_text($cat['cc_title'])));
                    }
                    $fields->attach(form_input_list(ucwords(str_replace('_', ' ', $parameter)), escape_html($description), $parameter, $list, NULL, false, false));
                } elseif ($parameter == 'param' && in_array($block, array('main_banner_wave', 'main_topsites'))) {
                    require_code('banners');
                    $list = nice_get_banner_types($default);
                    $fields->attach(form_input_list(ucwords(str_replace('_', ' ', $parameter)), escape_html($description), $parameter, $list, NULL, false, false));
                } elseif ($parameter == 'param' && in_array($block, array('main_newsletter_signup'))) {
                    $list = new ocp_tempcode();
                    $rows = $GLOBALS['SITE_DB']->query_select('newsletters', array('id', 'title'));
                    foreach ($rows as $newsletter) {
                        $list->attach(form_input_list_entry(strval($newsletter['id']), $has_default && strval($newsletter['id']) == $default, get_translated_text($newsletter['title'])));
                    }
                    $fields->attach(form_input_list(ucwords(str_replace('_', ' ', $parameter)), escape_html($description), $parameter, $list, NULL, false, false));
                } elseif ($parameter == 'filter' && in_array($block, array('bottom_news', 'main_news', 'side_news', 'side_news_archive'))) {
                    require_code('news');
                    $list = nice_get_news_categories($default == '' ? -1 : intval($default));
                    $fields->attach(form_input_multi_list(ucwords(str_replace('_', ' ', $parameter)), escape_html($description), $parameter, $list));
                } elseif ($parameter == 'font') {
                    $fonts = array();
                    $dh = opendir(get_file_base() . '/data/fonts');
                    while ($f = readdir($dh)) {
                        if (substr($f, -4) == '.ttf') {
                            $fonts[] = substr($f, 0, strlen($f) - 4);
                        }
                    }
                    closedir($dh);
                    $dh = opendir(get_custom_file_base() . '/data_custom/fonts');
                    while ($f = readdir($dh)) {
                        if (substr($f, -4) == '.ttf') {
                            $fonts[] = substr($f, 0, strlen($f) - 4);
                        }
                    }
                    closedir($dh);
                    $fonts = array_unique($fonts);
                    sort($fonts);
                    $list = new ocp_tempcode();
                    foreach ($fonts as $font) {
                        $list->attach(form_input_list_entry($font, $font == $default));
                    }
                    $fields->attach(form_input_list(ucwords(str_replace('_', ' ', $parameter)), escape_html($description), $parameter, $list, NULL, false, false));
                } elseif (preg_match('#' . do_lang('BLOCK_IND_EITHER') . ' (.+)#i', $description, $matches) != 0) {
                    $description = preg_replace('# \\(' . do_lang('BLOCK_IND_EITHER') . '.*\\)#U', '', $description);
                    $list = new ocp_tempcode();
                    $matches2 = array();
                    $num_matches = preg_match_all('#\'([^\']*)\'="([^"]*)"#', $matches[1], $matches2);
                    if ($num_matches != 0) {
                        for ($i = 0; $i < $num_matches; $i++) {
                            $list->attach(form_input_list_entry($matches2[1][$i], $matches2[1][$i] == $default, $matches2[2][$i]));
                        }
                    } else {
                        $num_matches = preg_match_all('#\'([^\']*)\'#', $matches[1], $matches2);
                        for ($i = 0; $i < $num_matches; $i++) {
                            $list->attach(form_input_list_entry($matches2[1][$i], $matches2[1][$i] == $default));
                        }
                    }
                    $fields->attach(form_input_list(ucwords(str_replace('_', ' ', $parameter)), escape_html($description), $parameter, $list, NULL, false, false));
                } elseif (preg_match('#\\(' . do_lang('BLOCK_IND_HOOKTYPE') . ': \'([^\'/]*)/([^\'/]*)\'\\)#i', $description, $matches) != 0) {
                    $description = preg_replace('#\\s*\\(' . do_lang('BLOCK_IND_HOOKTYPE') . ': \'([^\'/]*)/([^\'/]*)\'\\)#i', '', $description);
                    $list = new ocp_tempcode();
                    $hooks = find_all_hooks($matches[1], $matches[2]);
                    ksort($hooks);
                    if ($default == '' && $has_default) {
                        $list->attach(form_input_list_entry('', true));
                    }
                    foreach (array_keys($hooks) as $hook) {
                        if ($block == 'side_tag_cloud') {
                            if (substr($hook, -1) == 'y') {
                                $hook .= ',' . substr($hook, 0, strlen($hook) - 1) . 'ies';
                            } elseif (substr($hook, -1) != 's' && $hook != 'quiz') {
                                $hook .= ',' . $hook . 's';
                            }
                        }
                        $list->attach(form_input_list_entry($hook, $hook == $default));
                    }
                    if ($block == 'main_search' && $parameter == 'limit_to' || $block == 'side_tag_cloud') {
                        $fields->attach(form_input_multi_list(ucwords(str_replace('_', ' ', $parameter)), escape_html($description), $parameter, $list, NULL, 0));
                    } else {
                        $fields->attach(form_input_list(ucwords(str_replace('_', ' ', $parameter)), escape_html($description), $parameter, $list, NULL, false, false));
                    }
                } elseif (($default == '0' || $default == '1' || strpos($description, '\'0\'') !== false || strpos($description, '\'1\'') !== false) && do_lang('BLOCK_IND_WHETHER') != '' && strpos(strtolower($description), do_lang('BLOCK_IND_WHETHER')) !== false) {
                    $fields->attach(form_input_tick(ucwords(str_replace('_', ' ', $parameter)), escape_html($description), $parameter, $default == '1'));
                } elseif (do_lang('BLOCK_IND_NUMERIC') != '' && strpos($description, do_lang('BLOCK_IND_NUMERIC')) !== false) {
                    $fields->attach(form_input_integer(ucwords(str_replace('_', ' ', $parameter)), escape_html($description), $parameter, $default == '' ? NULL : intval($default), false));
                } else {
                    $fields->attach(form_input_line(ucwords(str_replace('_', ' ', $parameter)), escape_html($description), $parameter, $default, false));
                }
            }
        }
        $keep = symbol_tempcode('KEEP');
        $post_url = find_script('block_helper') . '?type=step3&field_name=' . get_param('field_name') . $keep->evaluate();
        if (get_param('utheme', '') != '') {
            $post_url .= '&utheme=' . get_param('utheme');
        }
        $post_url .= '&block_type=' . $type_wanted;
        if (get_param('save_to_id', '') != '') {
            $post_url .= '&save_to_id=' . urlencode(get_param('save_to_id'));
            $submit_name = do_lang_tempcode('SAVE');
            // Allow remove option
            $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('SECTION_HIDDEN' => false, 'TITLE' => do_lang_tempcode('ACTIONS'), 'HELP' => '')));
            $fields->attach(form_input_tick(do_lang_tempcode('REMOVE'), '', '_delete', false));
        } else {
            $submit_name = do_lang_tempcode('USE');
        }
        $block_description = do_lang('BLOCK_' . $block . '_DESCRIPTION', NULL, NULL, NULL, NULL, false);
        if (is_null($block_description)) {
            $block_description = '';
        }
        $block_use = do_lang('BLOCK_' . $block . '_USE', NULL, NULL, NULL, NULL, false);
        if (is_null($block_use)) {
            $block_use = '';
        }
        if ($block_description == '' && $block_use == '') {
            $text = new ocp_tempcode();
        } else {
            $text = do_lang_tempcode('BLOCK_HELPER_2', escape_html(cleanup_block_name($block)), escape_html($block_description), escape_html($block_use));
        }
        $hidden = form_input_hidden('block', $block);
        $content = do_template('FORM_SCREEN', array('_GUID' => '270058349d048a8be6570bba97c81fa2', 'TITLE' => $title, 'TARGET' => '_self', 'SKIP_VALIDATION' => true, 'FIELDS' => $fields, 'URL' => $post_url, 'TEXT' => $text, 'SUBMIT_NAME' => $submit_name, 'HIDDEN' => $hidden, 'PREVIEW' => true, 'THEME' => $GLOBALS['FORUM_DRIVER']->get_theme()));
        if ($fields->is_empty()) {
            $type = 'step3';
        }
    }
    if ($type == 'step3') {
        require_javascript('javascript_posting');
        require_javascript('javascript_editing');
        $field_name = get_param('field_name');
        $bparameters = '';
        $bparameters_xml = '';
        $bparameters_tempcode = '';
        $block = trim(either_param('block'));
        $parameters = get_block_parameters($block);
        $parameters[] = 'failsafe';
        $parameters[] = 'cache';
        $parameters[] = 'quick_cache';
        if (in_array('param', $parameters)) {
            $_parameters = array('param');
            unset($parameters[array_search('param', $parameters)]);
            $parameters = array_merge($_parameters, $parameters);
        }
        foreach ($parameters as $parameter) {
            $value = post_param($parameter, NULL);
            if (is_null($value)) {
                if (post_param_integer('tick_on_form__' . $parameter, NULL) === NULL) {
                    continue;
                }
                // If not on form, continue, otherwise must be 0
                $value = '0';
            }
            if ($value != '' && ($parameter != 'failsafe' || $value == '1') && ($parameter != 'cache' || $value != block_cache_default($block)) && ($parameter != 'quick_cache' || $value == '1')) {
                if ($parameter == 'param') {
                    $bparameters .= '="' . str_replace('"', '\\"', $value) . '"';
                } else {
                    $bparameters .= ' ' . $parameter . '="' . str_replace('"', '\\"', $value) . '"';
                }
                $bparameters_xml = '<blockParam key="' . escape_html($parameter) . '" val="' . escape_html($value) . '" />';
                $bparameters_tempcode .= ',' . $parameter . '=' . str_replace(',', '\\,', $value);
            }
        }
        $comcode = '[block' . $bparameters . ']' . $block . '[/block]';
        $comcode_xml = '<block>' . $bparameters_xml . $block . '</block>';
        $tempcode = '{$BLOCK,block=' . $block . $bparameters_tempcode . '}';
        if ($type_wanted == 'template') {
            $comcode = $tempcode;
        }
        // This is what will be written in
        $comcode_semihtml = comcode_to_tempcode($comcode, NULL, false, 60, NULL, NULL, true, false, false);
        $content = do_template('BLOCK_HELPER_DONE', array('_GUID' => '575d6c8120d6001c8156560be518f296', 'TITLE' => $title, 'FIELD_NAME' => $field_name, 'BLOCK' => $block, 'COMCODE_XML' => $comcode_xml, 'COMCODE' => $comcode, 'COMCODE_SEMIHTML' => $comcode_semihtml));
    }
    global $EXTRA_HEAD;
    if (!isset($EXTRA_HEAD)) {
        $EXTRA_HEAD = new ocp_tempcode();
    }
    $EXTRA_HEAD->attach('<meta name="robots" content="noindex" />');
    // XHTMLXHTML
    $echo = do_template('POPUP_HTML_WRAP', array('TITLE' => do_lang_tempcode('BLOCK_HELPER'), 'CONTENT' => $content));
    $echo->handle_symbol_preprocessing();
    $echo->evaluate_echo();
}
コード例 #12
0
ファイル: sitemap.php プロジェクト: erico-deh/ocPortal
/**
 * 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));
            }
        }
    }
}
コード例 #13
0
ファイル: admin_ssl.php プロジェクト: erico-deh/ocPortal
 /**
  * The actualiser for selecting HTTPS pages.
  *
  * @return tempcode		The UI
  */
 function set()
 {
     $zones = find_all_zones();
     foreach ($zones as $zone) {
         $pages = find_all_pages_wrap($zone);
         foreach (array_keys($pages) as $page) {
             if (!is_string($page)) {
                 $page = strval($page);
             }
             // strval($page) as $page could have become numeric due to array imprecision
             $id = $zone . ':' . $page;
             $value = post_param_integer('ssl_' . $zone . '__' . $page, 0);
             $GLOBALS['SITE_DB']->query_delete('https_pages', array('https_page_name' => $id), '', 1);
             if ($value == 1) {
                 $GLOBALS['SITE_DB']->query_insert('https_pages', array('https_page_name' => $id));
             }
         }
     }
     $title = get_page_title('SSL_CONFIGURATION');
     persistant_cache_empty();
     // Show it worked / Refresh
     $url = build_url(array('page' => '_SELF', 'type' => 'misc'), '_SELF');
     return redirect_screen($title, $url, do_lang_tempcode('SUCCESS'));
 }