Exemplo n.º 1
0
 /**
  * Standard modular run function.
  *
  * @return tempcode	Results
  */
 function run()
 {
     $GLOBALS['SITE_DB']->query_delete('cache_on');
     $GLOBALS['SITE_DB']->query_delete('cache');
     if (function_exists('persistant_cache_empty')) {
         persistant_cache_empty();
     }
     return new ocp_tempcode();
 }
Exemplo n.º 2
0
/**
 * Erase the comcode page cache
 */
function erase_comcode_page_cache()
{
    $GLOBALS['NO_QUERY_LIMIT'] = true;
    do {
        $rows = $GLOBALS['SITE_DB']->query_select('cached_comcode_pages', array('string_index'), NULL, '', 50, NULL, true, array());
        if (is_null($rows)) {
            $rows = array();
        }
        foreach ($rows as $row) {
            delete_lang($row['string_index']);
            $GLOBALS['SITE_DB']->query_delete('cached_comcode_pages', array('string_index' => $row['string_index']));
        }
    } while (count($rows) != 0);
    persistant_cache_empty();
    $GLOBALS['NO_QUERY_LIMIT'] = false;
}
Exemplo n.º 3
0
 /**
  * The actualiser to set privileges.
  *
  * @return tempcode		The UI
  */
 function set_specific_permissions()
 {
     require_all_lang();
     $GLOBALS['HELPER_PANEL_PIC'] = 'pagepics/privileges';
     $GLOBALS['HELPER_PANEL_TUTORIAL'] = 'tut_permissions';
     if (count($_POST) == 0 && strtolower(ocp_srv('REQUEST_METHOD')) != 'post') {
         warn_exit(do_lang_tempcode('PERMISSION_TRAGEDY_PREVENTED'));
     }
     $title = get_page_title('SPECIFIC_PERMISSIONS');
     $p_section = get_param('id');
     $_sections = $this->_get_ordered_sections();
     $array_keys = array_keys($_sections);
     $next_section = $array_keys[0];
     $counter = 0;
     foreach ($_sections as $s) {
         if (is_null($s)) {
             continue;
         }
         if ($counter > array_search($p_section, $array_keys)) {
             $next_section = $s['p_section'];
             break;
         }
         $counter++;
     }
     $groups = $GLOBALS['FORUM_DRIVER']->get_usergroup_list(false, true);
     $permissions = collapse_1d_complexity('the_name', $GLOBALS['SITE_DB']->query_select('sp_list', array('the_name'), array('p_section' => $p_section)));
     $admin_groups = $GLOBALS['FORUM_DRIVER']->get_super_admin_groups();
     foreach ($permissions as $permission) {
         foreach (array_keys($groups) as $id) {
             if (in_array($id, $admin_groups)) {
                 continue;
             }
             $val = post_param_integer($permission . '__' . strval($id), 0);
             // Delete to cleanup
             $GLOBALS['SITE_DB']->query_delete('gsp', array('specific_permission' => $permission, 'group_id' => $id, 'the_page' => '', 'module_the_name' => '', 'category_name' => ''), '', 1);
             if ($val == 1) {
                 $GLOBALS['SITE_DB']->query_insert('gsp', array('specific_permission' => $permission, 'group_id' => $id, 'the_page' => '', 'module_the_name' => '', 'category_name' => '', 'the_value' => 1));
             }
         }
     }
     breadcrumb_set_parents(array(array('_SELF:_SELF:specific', do_lang_tempcode('CHOOSE'))));
     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' => 'specific', 'id' => $next_section), '_SELF');
     return redirect_screen($title, $url, do_lang_tempcode('SUCCESS_NOW_NEXT_SCREEN'));
 }
Exemplo n.º 4
0
 /**
  * The actualiser to move a page.
  *
  * @return tempcode		The UI
  */
 function _move()
 {
     $title = get_page_title('MOVE_PAGES');
     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';
     $zone = post_param('zone', NULL);
     if (is_null($zone)) {
         $post_url = build_url(array('page' => '_SELF', 'type' => get_param('type')), '_SELF', NULL, true);
         $hidden = build_keep_form_fields('', true);
         return do_template('YESNO_SCREEN', array('_GUID' => 'c6e872cc62bdc7cf1c5157fbfdb2dfd6', 'TITLE' => $title, 'TEXT' => do_lang_tempcode('Q_SURE'), 'URL' => $post_url, 'HIDDEN' => $hidden));
     }
     $new_zone = post_param('destination_zone', '');
     if (substr($new_zone, -1) == ':') {
         $new_zone = substr($new_zone, 0, strlen($new_zone) - 1);
     }
     //$pages=find_all_pages_wrap($zone);
     $pages = array();
     require_code('site');
     foreach ($_POST as $key => $val) {
         if (substr($key, 0, 6) == 'page__' && $val === '1') {
             $page = substr($key, 6);
             $page_details = _request_page($page, $zone, NULL, NULL, true);
             if ($page_details === false) {
                 warn_exit(do_lang_tempcode('MISSING_RESOURCE'));
             }
             $pages[$page] = strtolower($page_details[0]);
             if (array_key_exists(3, $page_details)) {
                 $pages[$page] .= '/' . $page_details[3];
             }
         }
     }
     $afm_needed = false;
     foreach ($pages as $page => $type) {
         if (post_param_integer('page__' . $page, 0) == 1) {
             if ($type != 'comcode_custom') {
                 $afm_needed = true;
             }
         }
     }
     if ($afm_needed) {
         require_code('abstract_file_manager');
         force_have_afm_details();
     }
     $cannot_move = new ocp_tempcode();
     foreach ($pages as $page => $type) {
         if (!is_string($page)) {
             $page = strval($page);
         }
         if (post_param_integer('page__' . $page, 0) == 1) {
             if (substr($type, 0, 7) == 'modules') {
                 $_page = $page . '.php';
             } elseif (substr($type, 0, 7) == 'comcode') {
                 $_page = $page . '.txt';
             } elseif (substr($type, 0, 4) == 'html') {
                 $_page = $page . '.htm';
             }
             if (file_exists(zone_black_magic_filterer(get_custom_file_base() . '/' . filter_naughty($new_zone) . ($new_zone != '' ? '/' : '') . 'pages/' . filter_naughty($type) . '/' . $_page))) {
                 if (!$cannot_move->is_empty()) {
                     $cannot_move->attach(do_lang_tempcode('LIST_SEP'));
                 }
                 $cannot_move->attach(do_lang_tempcode('PAGE_WRITE', escape_html($page)));
                 continue;
             }
         }
     }
     $moved_something = NULL;
     foreach ($pages as $page => $type) {
         if (!is_string($page)) {
             $page = strval($page);
         }
         if (post_param_integer('page__' . $page, 0) == 1) {
             $moved_something = $page;
             if (substr($type, 0, 7) == 'modules') {
                 $_page = $page . '.php';
             } elseif (substr($type, 0, 7) == 'comcode') {
                 $_page = $page . '.txt';
             } elseif (substr($type, 0, 4) == 'html') {
                 $_page = $page . '.htm';
             }
             if (file_exists(zone_black_magic_filterer(get_custom_file_base() . '/' . filter_naughty($new_zone) . ($new_zone != '' ? '/' : '') . 'pages/' . filter_naughty($type) . '/' . $_page))) {
                 continue;
             }
             if (file_exists(zone_black_magic_filterer(get_custom_file_base() . '/' . filter_naughty($zone) . ($zone != '' ? '/' : '') . 'pages/' . filter_naughty($type) . '/' . $_page))) {
                 if ($afm_needed) {
                     afm_move(zone_black_magic_filterer(filter_naughty($zone) . ($zone != '' ? '/' : '') . 'pages/' . filter_naughty($type) . '/' . $_page, true), zone_black_magic_filterer(filter_naughty($new_zone) . ($new_zone != '' ? '/' : '') . 'pages/' . filter_naughty($type) . '/' . $_page, true));
                 } else {
                     rename(zone_black_magic_filterer(get_custom_file_base() . '/' . filter_naughty($zone) . ($zone != '' ? '/' : '') . 'pages/' . filter_naughty($type) . '/' . $_page), zone_black_magic_filterer(get_custom_file_base() . '/' . filter_naughty($new_zone) . ($new_zone != '' ? '/' : '') . 'pages/' . filter_naughty($type) . '/' . $_page));
                 }
             }
             // If a non-overridden one is there too, need to move that too
             if (strpos($type, '_custom') !== false && file_exists(zone_black_magic_filterer(get_custom_file_base() . '/' . filter_naughty($zone) . ($zone != '' ? '/' : '') . 'pages/' . filter_naughty(str_replace('_custom', '', $type)) . '/' . $_page)) && !file_exists(zone_black_magic_filterer(get_custom_file_base() . '/' . filter_naughty($new_zone) . ($new_zone != '' ? '/' : '') . 'pages/' . filter_naughty(str_replace('_custom', '', $type)) . '/' . $_page))) {
                 if ($afm_needed) {
                     afm_move(zone_black_magic_filterer(filter_naughty($zone) . ($zone != '' ? '/' : '') . 'pages/' . filter_naughty(str_replace('_custom', '', $type)) . '/' . $_page, true), zone_black_magic_filterer(filter_naughty($new_zone) . ($new_zone != '' ? '/' : '') . 'pages/' . filter_naughty(str_replace('_custom', '', $type)) . '/' . $_page, true));
                 } else {
                     rename(zone_black_magic_filterer(get_custom_file_base() . '/' . filter_naughty($zone) . ($zone != '' ? '/' : '') . 'pages/' . filter_naughty(str_replace('_custom', '', $type)) . '/' . $_page), zone_black_magic_filterer(get_custom_file_base() . '/' . filter_naughty($new_zone) . ($new_zone != '' ? '/' : '') . 'pages/' . filter_naughty(str_replace('_custom', '', $type)) . '/' . $_page));
                 }
             }
             log_it('MOVE_PAGES', $page);
         }
     }
     if (is_null($moved_something)) {
         warn_exit(do_lang_tempcode('NOTHING_SELECTED'));
     }
     persistant_cache_empty();
     require_lang('addons');
     if ($cannot_move->is_empty()) {
         $message = do_lang_tempcode('SUCCESS');
     } else {
         $message = do_lang_tempcode('WOULD_NOT_OVERWRITE_BUT_SUCCESS', $cannot_move);
     }
     breadcrumb_set_self(do_lang_tempcode('DONE'));
     breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('PAGES')), array('_SELF:_SELF:move', do_lang_tempcode('MOVE_PAGES'))));
     decache('main_sitemap');
     if (has_js()) {
         return inform_screen($title, $message);
         // Came from site-tree editor, so want to just close this window when done
     }
     return $this->do_next_manager($title, $moved_something, $new_zone, new ocp_tempcode());
 }
Exemplo n.º 5
0
/**
 * Make a theme. Note that this will trigger the AFM.
 *
 * @param  string		Name of the theme.
 * @param  ID_TEXT	The theme it's being generated from
 * @param  ID_TEXT	The algorithm to use
 * @set equations hsv
 * @param  string		Seed colour to use.
 * @param  boolean	Whether to use the theme immediately.
 * @param  ?boolean  Whether it will be a dark theme (NULL: autodetect).
 * @param  boolean	Whether to inherit the CSS, for easier theme upgrading.
 */
function make_theme($themename, $source_theme, $algorithm, $seed, $use, $dark = false, $inherit_css = false)
{
    $GLOBALS['NO_QUERY_LIMIT'] = true;
    load_themewizard_params_from_theme($source_theme, $algorithm == 'hsv');
    if (file_exists(get_custom_file_base() . '/themes/' . $themename)) {
        require_code('abstract_file_manager');
        force_have_afm_details();
        $extending_existing = true;
    } else {
        if ($source_theme == 'default') {
            actual_add_theme($themename);
        } else {
            require_code('themes3');
            actual_copy_theme($source_theme, $themename);
        }
        $extending_existing = false;
    }
    if ($seed != find_theme_seed($source_theme) || $dark != find_theme_dark($source_theme)) {
        list($colours, $landscape) = calculate_theme($seed, $source_theme, $algorithm, 'colours', $dark);
        // Make images
        global $THEME_WIZARD_IMAGES, $THEME_WIZARD_IMAGES_NO_WILD, $IMG_CODES;
        if (function_exists('imagecolorallocatealpha')) {
            require_code('themes2');
            $full_img_set = array();
            foreach ($THEME_WIZARD_IMAGES as $expression) {
                if (substr($expression, -1) == '*') {
                    $expression = substr($expression, 0, strlen($expression) - 2);
                    // remove "/*"
                    $full_img_set = array_merge($full_img_set, array_keys(get_all_image_codes(get_file_base() . '/themes/' . filter_naughty($source_theme) . '/images', $expression)));
                    $full_img_set = array_merge($full_img_set, array_keys(get_all_image_codes(get_file_base() . '/themes/' . filter_naughty($source_theme) . '/images/' . fallback_lang(), $expression)));
                } else {
                    $full_img_set[] = $expression;
                }
            }
            if ($extending_existing) {
                $temp_all_ids = collapse_2d_complexity('id', 'path', $GLOBALS['SITE_DB']->query_select('theme_images', array('id', 'path'), array('theme' => $themename)));
            } else {
                $temp_all_ids = array();
            }
            $_langs = find_all_langs(true);
            foreach ($full_img_set as $image_code) {
                if (!in_array($image_code, $THEME_WIZARD_IMAGES_NO_WILD)) {
                    if ($extending_existing && array_key_exists($image_code, $temp_all_ids) && strpos($temp_all_ids[$image_code], $themename . '/images_custom/') !== false && (!url_is_local($temp_all_ids[$image_code]) || file_exists(get_custom_file_base() . '/' . $temp_all_ids[$image_code]))) {
                        continue;
                    }
                    foreach (array_keys($_langs) as $lang) {
                        $orig_path = find_theme_image($image_code, true, true, $source_theme, $lang);
                        if ($orig_path == '') {
                            continue;
                        }
                        // Theme has specified non-existent image as themewizard-compatible
                        if (strpos($orig_path, '/' . $lang . '/') === false && $lang != fallback_lang()) {
                            continue;
                        }
                        if (strpos($orig_path, '/' . fallback_lang() . '/') !== false) {
                            $composite = 'themes/' . filter_naughty($themename) . '/images/' . $lang . '/';
                        } else {
                            $composite = 'themes/' . filter_naughty($themename) . '/images/';
                        }
                        $saveat = get_custom_file_base() . '/' . $composite . $image_code . '.png';
                        $saveat_url = $composite . $image_code . '.png';
                        // Wipe out ones that might have been copied from source theme
                        if ($source_theme != 'default' && strpos($orig_path, 'images_custom') !== false) {
                            @unlink(str_replace('/images/', '/images_custom/', basename($saveat, '.png')) . '.png');
                            @unlink(str_replace('/images/', '/images_custom/', basename($saveat, '.png')) . '.jpg');
                            @unlink(str_replace('/images/', '/images_custom/', basename($saveat, '.png')) . '.gif');
                            @unlink(str_replace('/images/', '/images_custom/', basename($saveat, '.png')) . '.jpeg');
                        }
                        if (!file_exists($saveat) || $source_theme != 'default' || $algorithm == 'hsv') {
                            $image = calculate_theme($seed, $source_theme, $algorithm, $image_code, $dark, $colours, $landscape, $lang);
                            if (!is_null($image)) {
                                $pos = strpos($image_code, '/');
                                if ($pos !== false || strpos($orig_path, '/' . fallback_lang() . '/') !== false) {
                                    afm_make_directory($composite . substr($image_code, 0, $pos), true, true);
                                }
                                @imagepng($image, $saveat) or intelligent_write_error($saveat);
                                imagedestroy($image);
                                fix_permissions($saveat);
                                sync_file($saveat);
                                actual_edit_theme_image($image_code, $themename, $lang, $image_code, $saveat_url, true);
                                //if ($lang==fallback_lang()) $IMG_CODES['site'][$image_code]=$saveat_url;
                            }
                        } else {
                            actual_edit_theme_image($image_code, $themename, $lang, $image_code, $saveat_url, true);
                        }
                    }
                }
            }
        }
        // Make sheets
        $dh = opendir(get_file_base() . '/themes/' . filter_naughty($source_theme) . ($source_theme == 'default' ? '/css/' : '/css_custom/'));
        while (($sheet = readdir($dh)) !== false) {
            if (substr($sheet, -4) == '.css') {
                $saveat = get_custom_file_base() . '/themes/' . filter_naughty($themename) . '/css_custom/' . $sheet;
                if (!file_exists($saveat) || $source_theme != 'default' || $algorithm == 'hsv') {
                    $fp = @fopen($saveat, 'wt') or intelligent_write_error(get_custom_file_base() . '/themes/' . filter_naughty($themename) . '/css_custom/' . $sheet);
                    if ($inherit_css) {
                        $output = '{+START,CSS_INHERIT,' . basename($sheet, '.css') . ',' . filter_naughty($source_theme) . ',' . $seed . ',' . ($dark ? '1' : '0') . ',' . $algorithm . '}{+END}';
                    } else {
                        $output = theme_wizard_colours_to_sheet($sheet, $landscape, $source_theme, $algorithm, $seed);
                    }
                    if (fwrite($fp, $output) < strlen($output)) {
                        warn_exit(do_lang_tempcode('COULD_NOT_SAVE_FILE'));
                    }
                    fclose($fp);
                    fix_permissions($saveat);
                    sync_file($saveat);
                    if (!$inherit_css) {
                        $c_success = @copy(get_file_base() . '/themes/' . filter_naughty($source_theme) . '/css/' . $sheet, $saveat . '.editfrom');
                        if ($c_success !== false) {
                            fix_permissions($saveat . '.editfrom');
                            sync_file($saveat . '.editfrom');
                        }
                    } else {
                        @unlink($saveat . '.editfrom');
                    }
                }
            }
        }
    }
    // Use it, if requested
    if ($use) {
        $GLOBALS['SITE_DB']->query('UPDATE ' . get_table_prefix() . 'zones SET zone_theme=\'' . db_escape_string($themename) . '\' WHERE ' . db_string_not_equal_to('zone_name', 'cms') . ' AND ' . db_string_not_equal_to('zone_name', 'adminzone'));
        $admin_groups = $GLOBALS['FORUM_DRIVER']->get_super_admin_groups();
        $groups = $GLOBALS['FORUM_DRIVER']->get_usergroup_list(false, true);
        $GLOBALS['SITE_DB']->query_delete('group_category_access', array('module_the_name' => 'theme', 'category_name' => $themename));
        foreach (array_keys($groups) as $group_id) {
            if (in_array($group_id, $admin_groups)) {
                continue;
            }
            $GLOBALS['SITE_DB']->query_insert('group_category_access', array('module_the_name' => 'theme', 'category_name' => $themename, 'group_id' => $group_id));
        }
        persistant_cache_empty();
    }
}
Exemplo n.º 6
0
/**
 * Standard code module initialisation function.
 */
function init__global2()
{
    global $BOOTSTRAPPING, $CHECKING_SAFEMODE, $BAD_WORD_CHARS, $FIXED_WORD_CHARS, $FIXED_WORD_CHARS_HTML, $BROWSER_DECACHEING, $CHARSET, $TEMP_CHARSET, $RELATIVE_PATH, $CURRENTLY_HTTPS, $RUNNING_SCRIPT_CACHE, $SERVER_TIMEZONE, $HAS_SET_ERROR_HANDLER, $DYING_BADLY, $XSS_DETECT, $SITE_INFO, $JAVASCRIPTS, $JAVASCRIPT, $CSSS, $IN_MINIKERNEL_VERSION, $EXITING, $FILE_BASE, $MOBILE, $CACHE_TEMPLATES, $BASE_URL_HTTP, $BASE_URL_HTTPS, $WORDS_TO_FILTER, $FIELD_RESTRICTIONS, $VALID_ENCODING, $CONVERTED_ENCODING, $MICRO_BOOTUP, $MICRO_AJAX_BOOTUP, $QUERY_LOG, $_CREATED_FILES, $CURRENT_SHARE_USER, $CACHE_FIND_SCRIPT;
    if (str_replace(array('on', 'true', 'yes'), array('1', '1', '1'), strtolower(ini_get('output_buffering'))) == '1') {
        @ob_end_clean();
    }
    if (array_key_exists('HTTP_X_REWRITE_URL', $_SERVER)) {
        foreach ($_GET as $key => $val) {
            if ($key[0] == '?') {
                unset($_GET[$key]);
                $_GET[substr($key, 1)] = $val;
            }
        }
        $_SERVER['REQUEST_URI'] = $_SERVER['HTTP_X_REWRITE_URL'];
    } elseif (!array_key_exists('REQUEST_URI', $_SERVER) && !array_key_exists('REQUEST_URI', $_ENV)) {
        $_SERVER['REQUEST_URI'] = $_SERVER['PHP_SELF'];
        $first = true;
        foreach ($_GET as $key => $val) {
            $_SERVER['REQUEST_URI'] .= $first ? '?' : '&';
            $_SERVER['REQUEST_URI'] .= urlencode($key) . '=' . urlencode($val);
            $first = false;
        }
    }
    if (array_key_exists('SCRIPT_FILENAME', $_SERVER) && !array_key_exists('PHP_SELF', $_SERVER)) {
        $_SERVER['PHP_SELF'] = $_SERVER['SCRIPT_FILENAME'];
    } elseif (array_key_exists('SCRIPT_NAME', $_SERVER) && defined('HIPHOP_PHP')) {
        $_SERVER['PHP_SELF'] = $_SERVER['SCRIPT_NAME'];
    }
    @header('Expires: Mon, 20 Dec 1998 01:00:00 GMT');
    @header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
    @header('Cache-Control: no-cache, max-age=0');
    @header('Pragma: no-cache');
    // for proxies, and also IE
    if (is_file('closed.html') && get_param_integer('keep_force_open', 0) == 0) {
        if (strpos($_SERVER['PHP_SELF'], 'upgrader.php') === false && strpos($_SERVER['PHP_SELF'], 'execute_temp.php') === false && (!isset($SITE_INFO['no_extra_closed_file']) || $SITE_INFO['no_extra_closed_file'] == '0')) {
            if (@strpos($_SERVER['SERVER_SOFTWARE'], 'IIS') === false) {
                header('HTTP/1.0 503 Service Temporarily Unavailable');
            }
            header('Location: ' . (is_file($RELATIVE_PATH . 'closed.html') ? 'closed.html' : '../closed.html'));
            exit;
        }
    }
    // Cover up holes in old PHP versions functionality
    if (!function_exists('str_word_count')) {
        /**
         * Isolate the words in the input string.
         *
         * @param  string			String to count words in
         * @param  integer		The format
         * @set    0 1 2
         * @return mixed			Typically a list - the words of the input string
         */
        function str_word_count($input, $format = 0)
        {
            //count words
            $pattern = "/[^(\\w|\\d|\\'|\"|\\.|\\!|\\?|;|,|\\|\\/|\\-\\-|:|\\&|@)]+/";
            $all_words = trim(preg_replace($pattern, ' ', $input));
            $a = array();
            $pos = 0;
            while (true) {
                $old_pos = $pos;
                $pos = strpos($all_words, ' ', $pos);
                if ($pos === false) {
                    $a[$old_pos] = substr($all_words, $old_pos);
                    break;
                }
                $a[$old_pos] = substr($all_words, $old_pos, $pos - $old_pos);
            }
            if ($format == 0) {
                return count($a);
            }
            return $a;
        }
    }
    if (!function_exists('html_entity_decode')) {
        /**
         * Decode the HTML entitity encoded input string.
         *
         * @param  string			The text to decode
         * @param  integer		The quote style code
         * @param  ?string		Character set to decode to (NULL: default)
         * @return string			The decoded text
         */
        function html_entity_decode($input, $quote_style, $charset = NULL)
        {
            unset($quote_style);
            unset($charset);
            /*			// NB: &nbsp does not go to <space>. It's not something you use with html escaping, it's for hard-space-formatting. URL's don't contain spaces, but that's due to URL escaping (%20)
            			$replace_array=array(
            				'&amp;'=>'&',
            				'&gt;'=>'>',
            				'&lt;'=>'<',
            				'&#039;'=>'\'',
            				'&quot;'=>'"',
            			);
            
            			foreach ($replace_array as $from=>$to)
            			{
            				$input=str_replace($from,$to,$input);
            			}
            
            			return $input;*/
            $trans_tbl = get_html_translation_table(HTML_ENTITIES);
            $trans_tbl = array_flip($trans_tbl);
            return strtr($input, $trans_tbl);
        }
    }
    if (version_compare(phpversion(), '4.3.0') >= 0) {
        if (!function_exists('unichrm_hex')) {
            /**
             * Convert a unicode character number to a unicode string. Callback for preg_replace.
             *
             * @param  array					Regular expression match array.
             * @return ~string				Converted data (false: could not convert).
             */
            function unichrm_hex($matches)
            {
                return unichr(hexdec($matches[1]));
            }
        }
        if (!function_exists('unichrm')) {
            /**
             * Convert a unicode character number to a unicode string. Callback for preg_replace.
             *
             * @param  array					Regular expression match array.
             * @return ~string				Converted data (false: could not convert).
             */
            function unichrm($matches)
            {
                return unichr(intval($matches[1]));
            }
        }
        if (!function_exists('unichr')) {
            /**
             * Convert a unicode character number to a HTML-entity enabled string, using lower ASCII characters where possible.
             *
             * @param  integer				Character number.
             * @return ~string				Converted data (false: could not convert).
             */
            function unichr($c)
            {
                if ($c <= 0x7f) {
                    return chr($c);
                } else {
                    return '#&' . strval($c) . ';';
                }
            }
        }
    }
    $BOOTSTRAPPING = 1;
    $CHECKING_SAFEMODE = false;
    $BAD_WORD_CHARS = array(chr(128), chr(130), chr(131), chr(132), chr(133), chr(134), chr(135), chr(136), chr(137), chr(138), chr(139), chr(140), chr(142), chr(145), chr(146), chr(147), chr(148), chr(149), chr(150), chr(151), chr(152), chr(153), chr(154), chr(155), chr(156), chr(158), chr(159));
    $FIXED_WORD_CHARS = array('(EUR-)', ',', '{f.}', '"', '...', '-|-', '=|=', '^', '{%o}', '{~S}', '<', 'CE', '{~Z}', "'", "'", '"', '"', '-', '-', '--', '~', '(TM)', '{~s}', '>', 'ce', '{~z}', '{.Y.}');
    // some of these are Comcode shortcuts. We can't use entities as we can't assume we're converting into Comcode.
    $FIXED_WORD_CHARS_HTML = array('&#8364;', '&#8218;', '&#402;', '&#8222;', '&hellip;', '&#8224;', '&#8225;', '&#710;', '&#8240;', '&#352;', '&#8249;', '&#338;', '&#381;', "&lsquo;", "&rsquo;", '&ldquo;', '&rdquo;', '&bull;', '&ndash;', '&mdash;', '&#732;', '&trade;', '&#353;', '&#8250;', '&#339;', '&#382;', '&#376;');
    $RUNNING_SCRIPT_CACHE = array();
    $BROWSER_DECACHEING = NULL;
    $CHARSET = NULL;
    $TEMP_CHARSET = NULL;
    $CURRENTLY_HTTPS = NULL;
    $CACHE_FIND_SCRIPT = array();
    error_reporting(E_ALL);
    @ini_set('html_errors', '1');
    @ini_set('docref_root', 'http://www.php.net/manual/en/');
    @ini_set('docref_ext', '.php');
    $SERVER_TIMEZONE = function_exists('date_default_timezone_get') ? @date_default_timezone_get() : ini_get('date.timezone');
    @ini_set('date.timezone', 'UTC');
    if (function_exists('date_default_timezone_set')) {
        date_default_timezone_set('UTC');
    }
    // Needed for HPHP
    $HAS_SET_ERROR_HANDLER = false;
    $DYING_BADLY = false;
    // If ocPortal is bailing out uncontrollably, setting this will make sure the error hander does not try and suppress
    $XSS_DETECT = function_exists('ocp_mark_as_escaped');
    $GLOBALS['DEBUG_MODE'] = (!array_key_exists('debug_mode', $SITE_INFO) || $SITE_INFO['debug_mode'] == '1') && (is_dir(get_file_base() . '/.svn') || is_dir(get_file_base() . '/.git') || function_exists('ocp_mark_as_escaped')) && (!array_key_exists('keep_no_debug_mode', $_GET) || $_GET['keep_no_debug_mode'] == '0');
    $GLOBALS['SEMI_DEBUG_MODE'] = (!array_key_exists('debug_mode', $SITE_INFO) || $SITE_INFO['debug_mode'] == '1') && (is_dir(get_file_base() . '/.svn') || is_dir(get_file_base() . '/.git') || function_exists('ocp_mark_as_escaped'));
    if (function_exists('set_time_limit')) {
        @set_time_limit(60);
    }
    if ($GLOBALS['DEBUG_MODE']) {
        if (function_exists('set_time_limit')) {
            @set_time_limit(10);
        }
        @ini_set('ocproducts.type_strictness', '1');
        @ini_set('ocproducts.xss_detect', '1');
    }
    if ($GLOBALS['DEBUG_MODE']) {
        require_code('developer_tools');
    }
    $JAVASCRIPTS = array('javascript' => 1, 'javascript_thumbnails' => 1);
    if ($GLOBALS['CURRENT_SHARE_USER'] !== NULL || get_domain() == 'myocp.com') {
        $JAVASCRIPTS['javascript_ajax'] = 1;
    }
    $CSSS = array('no_cache' => 1, 'global' => 1);
    // Try and make the PHP environment as we need it
    if (function_exists('set_magic_quotes_runtime')) {
        @set_magic_quotes_runtime(0);
    }
    // @'d because it's deprecated and PHP 5.3 may give an error
    @ini_set('auto_detect_line_endings', '0');
    @ini_set('include_path', '');
    @ini_set('default_socket_timeout', '60');
    @ini_set('allow_url_fopen', '0');
    @ini_set('suhosin.executor.disable_emodifier', '1');
    // Extra security if suhosin is available
    @ini_set('suhosin.executor.multiheader', '1');
    // Extra security if suhosin is available
    @ini_set('suhosin.executor.disable_eval', '0');
    @ini_set('suhosin.executor.eval.whitelist', '');
    @ini_set('suhosin.executor.func.whitelist', '');
    // Load most basic config
    $IN_MINIKERNEL_VERSION = 0;
    $EXITING = 0;
    if (array_key_exists('use_ocf', $_GET) && running_script('upgrader')) {
        $SITE_INFO['forum_type'] = 'ocf';
        $SITE_INFO['ocf_table_prefix'] = $SITE_INFO['table_prefix'];
    }
    $CACHE_TEMPLATES = true;
    // The URL to our install (no trailing /)
    $BASE_URL_HTTP = NULL;
    $BASE_URL_HTTPS = NULL;
    $WORDS_TO_FILTER = NULL;
    $FIELD_RESTRICTIONS = NULL;
    $VALID_ENCODING = false;
    $CONVERTED_ENCODING = false;
    if (!isset($MICRO_BOOTUP)) {
        $MICRO_BOOTUP = 0;
    }
    if (!isset($MICRO_AJAX_BOOTUP)) {
        $MICRO_AJAX_BOOTUP = 0;
    }
    require_code_no_override('version');
    if ($MICRO_BOOTUP == 0 && $MICRO_AJAX_BOOTUP == 0) {
        //@header('X-Powered-By: ocPortal '.ocp_version_full().' (PHP '.phpversion().')');
        @header('X-Powered-By: ocPortal');
        // Better to keep it vague, for security reasons
        $QUERY_LOG = false;
        if (isset($_REQUEST['special_page_type']) && $_REQUEST['special_page_type'] == 'query') {
            $QUERY_LOG = true;
        }
    }
    // Most critical things
    require_code('support');
    // A lot of support code is present in this
    srand(make_seed());
    mt_srand(make_seed());
    if ($MICRO_BOOTUP == 0 && $MICRO_AJAX_BOOTUP == 0) {
        if (running_script('index') && count($_POST) == 0) {
            $bot_type = get_bot_type();
            if ($bot_type !== NULL && isset($SITE_INFO['fast_spider_cache']) && $SITE_INFO['fast_spider_cache'] != '0') {
                fast_spider_cache(true);
            }
        }
    }
    require_code('caches');
    // Recently taken out of 'support' so makes sense to load it here
    require_code('database');
    // There's nothing without the database
    if ((!isset($SITE_INFO['known_suexec']) || $SITE_INFO['known_suexec'] == '0') && !is_writable_wrap(get_file_base() . '/.htaccess')) {
        require_code('support2');
        if (ip_banned(get_ip_address())) {
            critical_error('BANNED');
        }
    }
    if (running_script('messages') && get_param('action', 'new') == 'new' && get_param_integer('routine_refresh', 0) == 0) {
        require_code('chat_poller');
        chat_poller();
    }
    if ($MICRO_BOOTUP == 0) {
        load_user_stuff();
    }
    // For any kind of niceness we need these. The order is chosen for complex dependency reasons - don't mess with it
    if ($MICRO_AJAX_BOOTUP == 0) {
        require_code('themes');
        // Output needs to know about themes
        require_code('templates');
        // So that we can do error templates
        require_code('tempcode');
        // Output is done with tempcode
        if ($MICRO_BOOTUP == 0) {
            require_code('comcode');
            // Much output goes through comcode
        }
    }
    require_code('zones');
    // Zone is needed because zones are where all ocPortal pages reside
    require_code('config');
    // Config is needed for much active stuff
    if (get_option('collapse_user_zones', true) === '1' && $RELATIVE_PATH == 'site') {
        get_base_url();
        /*force calculation first*/
        $RELATIVE_PATH = '';
    }
    require_code('users');
    // Users are important due to permissions
    if ($MICRO_BOOTUP == 0 && $MICRO_AJAX_BOOTUP == 0) {
        if (running_script('index') && count($_POST) == 0) {
            if (isset($SITE_INFO['any_guest_cached_too']) && $SITE_INFO['any_guest_cached_too'] == '1' && is_guest(NULL, true)) {
                fast_spider_cache(false);
            }
        }
    }
    $CACHE_TEMPLATES = (get_option('is_on_template_cache') == '1' || get_param_integer('keep_cache', 0) == 1 || get_param_integer('cache', 0) == 1) && get_param_integer('keep_cache', NULL) !== 0 && get_param_integer('cache', NULL) !== 0;
    if ($MICRO_AJAX_BOOTUP == 0) {
        require_code('temporal');
        // Date/time functions
        require_code('files');
        // Contains fix_permissions, needed for 'lang'
        require_code('lang');
        // So that we can do language stuff (e.g. errors)
        convert_data_encodings();
        if ($MICRO_BOOTUP == 0) {
            require_code('permissions');
            // So we can check access
        }
    }
    // At this point we can display errors nicely
    $GLOBALS['SUPPRESS_ERROR_DEATH'] = false;
    set_error_handler('ocportal_error_handler');
    if (function_exists('error_get_last')) {
        register_shutdown_function('catch_fatal_errors');
    }
    $HAS_SET_ERROR_HANDLER = true;
    if ($MICRO_BOOTUP == 0) {
        if (method_exists($GLOBALS['FORUM_DRIVER'], 'forum_layer_initialise')) {
            $GLOBALS['FORUM_DRIVER']->forum_layer_initialise();
        }
    }
    if ($MICRO_AJAX_BOOTUP == 0) {
        $JAVASCRIPT = new ocp_tempcode();
    }
    if ($MICRO_BOOTUP == 0) {
        if ($IN_MINIKERNEL_VERSION != 1 && $MICRO_AJAX_BOOTUP == 0) {
            has_cookies();
            // Will determine at early point whether we have cookie support
            get_num_users_site();
            // Will kill site if there are too many users
        }
    }
    require_code('urls');
    // URL building is crucial
    @header('Content-type: text/html; charset=' . get_charset());
    if ($MICRO_AJAX_BOOTUP == 0 && $MICRO_BOOTUP == 0) {
        // Before anything gets outputted
        handle_logins();
        require_code('site');
        // This powers the site (top level page generation)
        // Are we installed?
        get_option('site_name');
    }
    // Our logging (change false to true for temporarily changing it so staff get logging)
    if (get_option('log_php_errors') == '1') {
        @ini_set('log_errors', '1');
        if (addon_installed('errorlog')) {
            @ini_set('error_log', get_custom_file_base() . '/data_custom/errorlog.php');
        }
    }
    if ($MICRO_BOOTUP == 0 && $MICRO_AJAX_BOOTUP == 0 && (get_option('display_php_errors') == '1' || running_script('upgrader') || has_specific_permission(get_member(), 'see_php_errors'))) {
        @ini_set('display_errors', '1');
    } elseif (!$GLOBALS['DEBUG_MODE']) {
        @ini_set('display_errors', '0');
    }
    // G-zip?
    @ini_set('zlib.output_compression', get_option('gzip_output') == '1' ? 'On' : 'Off');
    if (function_exists('setlocale') && $MICRO_AJAX_BOOTUP == 0) {
        $locales = explode(',', do_lang('locale'));
        setlocale(LC_ALL, $locales[0]);
        @setlocale(LC_ALL, $locales);
        unset($locales);
    }
    if ($MICRO_AJAX_BOOTUP == 0 && $MICRO_BOOTUP == 0 && (!isset($SITE_INFO['no_installer_checks']) || $SITE_INFO['no_installer_checks'] == '0')) {
        if (is_file(get_file_base() . '/install.php') && !is_file(get_file_base() . '/install_ok') && running_script('index')) {
            warn_exit(do_lang_tempcode('MUST_DELETE_INSTALLER'));
        }
    }
    if ($MICRO_AJAX_BOOTUP == 0 && $MICRO_BOOTUP == 0) {
        $changed_base_url = !array_key_exists('base_url', $SITE_INFO) && get_long_value('last_base_url') !== get_base_url(false);
        if (running_script('index') && (is_browser_decacheing() || $changed_base_url)) {
            require_code('view_modes');
            erase_tempcode_cache();
            erase_cached_templates(!$changed_base_url);
            erase_comcode_cache();
            erase_cached_language();
            persistant_cache_empty();
            if ($changed_base_url) {
                require_lang('zones');
                require_code('zones3');
                erase_comcode_page_cache();
                set_long_value('last_base_url', get_base_url(false));
            }
        }
        if (has_zone_access(get_member(), 'adminzone')) {
            $JAVASCRIPTS['javascript_staff'] = 1;
            $JAVASCRIPTS['javascript_ajax'] = 1;
            if (addon_installed('occle')) {
                $JAVASCRIPTS['javascript_button_occle'] = 1;
            }
        }
        if (addon_installed('realtime_rain') && get_option('bottom_show_realtime_rain_button', true) === '1') {
            $JAVASCRIPTS['javascript_button_realtime_rain'] = 1;
        }
    }
    /*ocp_memory_profile('startup');
    	$func=get_defined_functions();
    	print_r($func['user']);*/
    if (tacit_https() || is_page_https(get_zone_name(), get_page_name())) {
        @header('Cache-Control: private');
        @header('Pragma: private');
    }
    $BOOTSTRAPPING = 0;
    if ($GLOBALS['SEMI_DEBUG_MODE'] && $MICRO_AJAX_BOOTUP == 0) {
        if ($GLOBALS['SEMI_DEBUG_MODE']) {
            /*if ((mt_rand(0,2)==1) && ($GLOBALS['DEBUG_MODE']) && (running_script('index')))	We know this works now, so let's stop messing up our development speed
            		{
            			require_code('view_modes');
            			erase_cached_templates(true); // Stop anything trying to read a template cache item (E.g. CSS, JS) that might not exist!
            		}*/
            if (strpos(ocp_srv('HTTP_REFERER'), ocp_srv('HTTP_HOST')) !== false && strpos(ocp_srv('HTTP_REFERER'), 'keep_devtest') !== false && !running_script('attachment') && !running_script('upgrader') && strpos(ocp_srv('HTTP_REFERER'), 'login') === false && is_null(get_param('keep_devtest', NULL))) {
                $_GET['keep_devtest'] = '1';
                fatal_exit('URL not constructed properly: development mode in use but keep_devtest was not specified. This indicates that links have been made without build_url (in PHP) or keep_stub (in Javascript). Whilst not fatal this time, failure to use these functions can cause problems when your site goes live. See the ocPortal codebook for more details.');
            } else {
                $_GET['keep_devtest'] = '1';
            }
        }
        if (browser_matches('true_xhtml') && get_value('html5') !== '1' && get_value('html5') !== '_true' && get_param_integer('keep_no_xhtml', 0) == 0 && !running_script('upgrader')) {
            @header('Content-type: application/xhtml+xml; charset=' . get_charset());
        }
        if (isset($_CREATED_FILES)) {
            /**
             * Run after-tests for debug mode, to make sure coding standards are met.
             */
            function debug_mode_aftertests()
            {
                global $_CREATED_FILES, $_MODIFIED_FILES;
                // Use the info from ocProduct's custom PHP version to make sure that all files that were created/modified got synched as they should have been.
                foreach ($_CREATED_FILES as $file) {
                    if (substr($file, 0, strlen(get_file_base())) == get_file_base() && substr($file, -4) != '.log' && basename($file) != 'permissioncheckslog.php') {
                        @exit(escape_html('File not permission-synched: ' . $file));
                    }
                }
                foreach ($_MODIFIED_FILES as $file) {
                    if (strpos($file, '_cache') === false && substr($file, 0, strlen(get_file_base())) == get_file_base() && substr($file, -4) != '.log' && basename($file) != 'permissioncheckslog.php') {
                        @exit(escape_html('File not change-synched: ' . $file));
                    }
                }
                global $TITLE_CALLED, $SCREEN_TEMPLATE_CALLED, $EXITING;
                if (is_null($SCREEN_TEMPLATE_CALLED) && $EXITING == 0 && strpos(ocp_srv('PHP_SELF'), 'index.php') !== false) {
                    @exit(escape_html('No screen template called.'));
                }
                if (!$TITLE_CALLED && (is_null($SCREEN_TEMPLATE_CALLED) || $SCREEN_TEMPLATE_CALLED != '') && $EXITING == 0 && strpos(ocp_srv('PHP_SELF'), 'index.php') !== false) {
                    @exit(escape_html('No title used on screen.'));
                }
            }
            register_shutdown_function('debug_mode_aftertests');
        }
        if (ocp_srv('SCRIPT_FILENAME') != '' && $GLOBALS['DEBUG_MODE'] && strpos(ocp_srv('SCRIPT_FILENAME'), 'data_custom') === false) {
            if (@strlen(file_get_contents(ocp_srv('SCRIPT_FILENAME'), FILE_TEXT)) > 4500) {
                fatal_exit('Entry scripts (front controllers) should not be shoved full of code.');
            }
        }
    }
    // FirePHP console support, only for administrators
    if ((get_param_integer('keep_firephp', 0) == 1 || get_param_integer('keep_queries', 0) == 1) && ($GLOBALS['FORUM_DRIVER']->is_super_admin(get_member()) || $GLOBALS['IS_ACTUALLY_ADMIN'])) {
        require_code('firephp');
    }
    $default_memory_limit = get_value('memory_limit');
    if (is_null($default_memory_limit) || $default_memory_limit == '' || $default_memory_limit == '0' || $default_memory_limit == '-1') {
        $default_memory_limit = '64M';
    }
    @ini_set('memory_limit', $default_memory_limit);
    if (isset($GLOBALS['FORUM_DRIVER']) && $GLOBALS['FORUM_DRIVER']->is_super_admin(get_member())) {
        if (get_param_integer('keep_avoid_memory_limit', 0) == 1) {
            disable_php_memory_limit();
        }
        $memory_test = get_param_integer('keep_memory_limit_test', 0);
        if ($memory_test != 0 && $memory_test <= 32) {
            @ini_set('memory_limit', strval($memory_test) . 'M');
        }
    }
    if (get_option('sitewide_im', true) === '1' && running_script('index') && get_param('type', 'misc', true) != 'room') {
        require_code('chat');
        enter_chat_lobby();
    }
    // Startup hooks
    if (!running_script('upgrader')) {
        $startup_hooks = find_all_hooks('systems', 'startup');
        foreach (array_keys($startup_hooks) as $hook) {
            require_code('hooks/systems/startup/' . filter_naughty_harsh($hook));
            $ob = object_factory('Hook_startup_' . filter_naughty_harsh($hook), true);
            if ($ob === NULL) {
                continue;
            }
            $ob->run($MICRO_BOOTUP, $MICRO_AJAX_BOOTUP, 0);
        }
        if ($CURRENT_SHARE_USER !== NULL && float_to_raw_string(ocp_version_number()) != get_value('version')) {
            require_code('upgrade');
            clear_caches_2();
            version_specific();
            upgrade_modules();
            ocf_upgrade();
        }
    }
}
Exemplo n.º 7
0
 /**
  * The actualiser to translate content.
  *
  * @return tempcode		The UI
  */
 function set_lang_content()
 {
     $title = get_page_title('TRANSLATE_CONTENT');
     $lang = choose_language($title);
     if (is_object($lang)) {
         return $lang;
     }
     foreach ($_POST as $key => $val) {
         if (!is_string($val)) {
             continue;
         }
         if (substr($key, 0, 6) != 'trans_') {
             continue;
         }
         $lang_id = intval(substr($key, 6));
         if (get_magic_quotes_gpc()) {
             $val = stripslashes($val);
         }
         if ($val != '') {
             $GLOBALS['SITE_DB']->query_delete('translate', array('language' => $lang, 'id' => $lang_id), '', 1);
             $importance_level = $GLOBALS['SITE_DB']->query_value_null_ok('translate', 'importance_level', array('id' => $lang_id));
             if (!is_null($importance_level)) {
                 $GLOBALS['SITE_DB']->query_insert('translate', array('id' => $lang_id, 'source_user' => get_member(), 'language' => $lang, 'importance_level' => $importance_level, 'text_original' => $val, 'text_parsed' => '', 'broken' => 0));
             }
         }
     }
     log_it('TRANSLATE_CONTENT');
     require_code('view_modes');
     erase_tempcode_cache();
     persistant_cache_empty();
     if (get_param_integer('contextual', 0) == 1) {
         return inform_screen($title, do_lang_tempcode('SUCCESS'));
     }
     // Show it worked / Refresh
     $url = post_param('redirect', NULL);
     if (is_null($url)) {
         $_url = build_url(array('page' => '_SELF', 'type' => 'content'), '_SELF');
         $url = $_url->evaluate();
     }
     return redirect_screen($title, $url, do_lang_tempcode('SUCCESS'));
 }
Exemplo n.º 8
0
/**
 * AJAX script for dynamically extended sitetree.
 */
function site_tree_script()
{
    header("Cache-Control: no-cache, must-revalidate");
    // HTTP/1.1
    header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
    // Date in the past
    $root_perms = array('submit_cat_highrange_content' => 0, 'edit_cat_highrange_content' => 0, 'edit_own_cat_highrange_content' => 0, 'delete_cat_highrange_content' => 0, 'delete_own_cat_highrange_content' => 0, 'submit_highrange_content' => 1, 'bypass_validation_highrange_content' => 1, 'edit_own_highrange_content' => 1, 'edit_highrange_content' => 1, 'delete_own_highrange_content' => 1, 'delete_highrange_content' => 1, 'submit_cat_midrange_content' => 0, 'edit_cat_midrange_content' => 0, 'edit_own_cat_midrange_content' => 0, 'delete_cat_midrange_content' => 0, 'delete_own_cat_midrange_content' => 0, 'submit_midrange_content' => 1, 'bypass_validation_midrange_content' => 1, 'edit_own_midrange_content' => 1, 'edit_midrange_content' => 1, 'delete_own_midrange_content' => 1, 'delete_midrange_content' => 1, 'submit_cat_lowrange_content' => 0, 'edit_cat_lowrange_content' => 0, 'edit_own_cat_lowrange_content' => 0, 'delete_cat_lowrange_content' => 0, 'delete_own_cat_lowrange_content' => 0, 'submit_lowrange_content' => 1, 'bypass_validation_lowrange_content' => 1, 'edit_own_lowrange_content' => 1, 'edit_lowrange_content' => 1, 'delete_own_lowrange_content' => 1, 'delete_lowrange_content' => 1);
    require_code('zones2');
    require_code('zones3');
    // Usergroups we have
    $admin_groups = $GLOBALS['FORUM_DRIVER']->get_super_admin_groups();
    $groups = $GLOBALS['FORUM_DRIVER']->get_usergroup_list(false, true);
    if (!has_actual_page_access(get_member(), 'admin_site_tree', 'adminzone')) {
        exit;
    }
    if (function_exists('set_time_limit')) {
        @set_time_limit(30);
    }
    disable_php_memory_limit();
    // Needed for loading large amount of permissions (potentially)
    // ======
    // Saving
    // ======
    if (get_param_integer('set_perms', 0) == 1) {
        if (!has_actual_page_access(get_member(), 'admin_permissions', 'adminzone')) {
            exit;
        }
        // Build a map of every page link we are setting permissions for
        $map = array();
        foreach (array_merge($_GET, $_POST) as $i => $page_link) {
            if (get_magic_quotes_gpc()) {
                $page_link = stripslashes($page_link);
            }
            if (substr($i, 0, 4) == 'map_') {
                $map[intval(substr($i, 4))] = $page_link;
            }
        }
        // Read it all in
        foreach ($map as $i => $page_link) {
            // Decode page link
            $matches = array();
            $type = '';
            if ($page_link == '_root') {
                $type = 'root';
            } elseif (preg_match('#^([^:]*):([^:]+):.+$#', $page_link, $matches) != 0) {
                $type = 'cat';
            } elseif (preg_match('#^([^:]*):([^:]+)$#', $page_link, $matches) != 0) {
                $type = 'page';
            } elseif (preg_match('#^([^:]*):?$#', $page_link, $matches) != 0) {
                $type = 'zone';
            } else {
                $type = 'root';
            }
            // Working out what we're doing with privilege overrides
            if ($type == 'page' || $type == 'cat') {
                $zone = $matches[1];
                $page = $matches[2];
                list($overridables, $sp_page) = get_module_overridables($zone, $page);
            }
            if ($type == 'root') {
                // Insertion
                foreach ($groups as $group => $group_name) {
                    if (!in_array($group, $admin_groups)) {
                        // SP's
                        foreach (array_keys($root_perms) as $overide) {
                            $val = post_param_integer(strval($i) . 'gsp_' . $overide . '_' . strval($group), -2);
                            if ($val != -2) {
                                $GLOBALS['SITE_DB']->query_delete('gsp', array('specific_permission' => $overide, 'group_id' => $group, 'the_page' => '', 'module_the_name' => '', 'category_name' => ''));
                                if ($val != -1) {
                                    $GLOBALS['SITE_DB']->query_insert('gsp', array('specific_permission' => $overide, 'group_id' => $group, 'module_the_name' => '', 'category_name' => '', 'the_page' => '', 'the_value' => $val));
                                }
                            }
                        }
                    }
                }
            } elseif ($type == 'zone') {
                $zone = $matches[1];
                // Insertion
                foreach ($groups as $group => $group_name) {
                    if (!in_array($group, $admin_groups)) {
                        // View access
                        $view = post_param_integer(strval($i) . 'g_view_' . strval($group), -1);
                        if ($view != -1) {
                            $GLOBALS['SITE_DB']->query_delete('group_zone_access', array('zone_name' => $zone, 'group_id' => $group));
                            if ($view == 1) {
                                $GLOBALS['SITE_DB']->query_insert('group_zone_access', array('zone_name' => $zone, 'group_id' => $group));
                            }
                        }
                    }
                }
            } elseif ($type == 'page') {
                // Insertion
                foreach ($groups as $group => $group_name) {
                    if (!in_array($group, $admin_groups)) {
                        // View access
                        $view = post_param_integer(strval($i) . 'g_view_' . strval($group), -1);
                        if ($view != -1) {
                            $GLOBALS['SITE_DB']->query_delete('group_page_access', array('zone_name' => $zone, 'page_name' => $page, 'group_id' => $group));
                            if ($view == 0) {
                                // Pages have access by row non-presence, for good reason
                                $GLOBALS['SITE_DB']->query_insert('group_page_access', array('zone_name' => $zone, 'page_name' => $page, 'group_id' => $group));
                            }
                        }
                        // SP's
                        foreach (array_keys($overridables) as $overide) {
                            $val = post_param_integer(strval($i) . 'gsp_' . $overide . '_' . strval($group), -2);
                            if ($val != -2) {
                                $GLOBALS['SITE_DB']->query_delete('gsp', array('specific_permission' => $overide, 'group_id' => $group, 'the_page' => $sp_page));
                                if ($val != -1) {
                                    $GLOBALS['SITE_DB']->query_insert('gsp', array('specific_permission' => $overide, 'group_id' => $group, 'module_the_name' => '', 'category_name' => '', 'the_page' => $sp_page, 'the_value' => $val));
                                }
                            }
                        }
                    }
                }
            } elseif ($type == 'cat') {
                $_pagelinks = extract_module_functions_page($zone, $page, array('extract_page_link_permissions'), array($page_link));
                list($category, $module) = is_array($_pagelinks[0]) ? call_user_func_array($_pagelinks[0][0], $_pagelinks[0][1]) : eval($_pagelinks[0]);
                // If $_pagelinks[0] is NULL then it's an error: extract_page_link_permissions is always there when there are cat permissions
                // Insertion
                foreach ($groups as $group => $group_name) {
                    if (!in_array($group, $admin_groups)) {
                        // View access
                        $view = post_param_integer(strval($i) . 'g_view_' . strval($group), -1);
                        if ($view != -1) {
                            $GLOBALS['SITE_DB']->query_delete('group_category_access', array('module_the_name' => $module, 'category_name' => $category, 'group_id' => $group));
                            if ($view == 1) {
                                $GLOBALS['SITE_DB']->query_insert('group_category_access', array('module_the_name' => $module, 'category_name' => $category, 'group_id' => $group));
                            }
                        }
                        // SP's
                        foreach ($overridables as $overide => $cat_support) {
                            if (is_array($cat_support)) {
                                $cat_support = $cat_support[0];
                            }
                            if ($cat_support == 0) {
                                continue;
                            }
                            $val = post_param_integer(strval($i) . 'gsp_' . $overide . '_' . strval($group), -2);
                            if ($val != -2) {
                                $GLOBALS['SITE_DB']->query_delete('gsp', array('specific_permission' => $overide, 'group_id' => $group, 'module_the_name' => $module, 'category_name' => $category, 'the_page' => ''));
                                if ($val != -1) {
                                    $new_settings = array('specific_permission' => $overide, 'group_id' => $group, 'module_the_name' => $module, 'category_name' => $category, 'the_page' => '', 'the_value' => $val);
                                    $GLOBALS['SITE_DB']->query_insert('gsp', $new_settings);
                                }
                            }
                        }
                    }
                }
            }
        }
        decache('main_sitemap');
        $GLOBALS['SITE_DB']->query_delete('cache');
        if (function_exists('persistant_cache_empty')) {
            persistant_cache_empty();
        }
        // Tra la la tada
        return;
    }
    // =======
    // Loading
    // =======
    $default = get_param('default', NULL, true);
    header('Content-Type: text/xml');
    $permissions_needed = get_param_integer('get_perms', 0) == 1;
    // Whether we are limiting our tree to permission-supporting
    @ini_set('ocproducts.xss_detect', '0');
    echo '<' . '?xml version="1.0" encoding="' . get_charset() . '"?' . '>';
    echo '<request><result>';
    require_lang('permissions');
    require_lang('zones');
    $page_link = get_param('id', NULL, true);
    $_sp_access = $GLOBALS['SITE_DB']->query_select('gsp', array('*'));
    $sp_access = array();
    foreach ($_sp_access as $a) {
        if (!isset($sp_access[$a['group_id']])) {
            $sp_access[$a['group_id']] = array();
        }
        $sp_access[$a['group_id']][] = $a;
    }
    if (!is_null($page_link) && $page_link != '' && (strpos($page_link, ':') === false || strpos($page_link, ':') === strlen($page_link) - 1)) {
        if (strpos($page_link, ':') === strlen($page_link) - 1) {
            $page_link = substr($page_link, 0, strlen($page_link) - 1);
        }
        // Pages in the zone
        $zone = $page_link;
        $page_type = get_param('page_type', NULL);
        $pages = find_all_pages_wrap($zone, false, true, FIND_ALL_PAGES__NEWEST, $page_type);
        ksort($pages);
        if ($permissions_needed) {
            $zone_access = $GLOBALS['SITE_DB']->query_select('group_zone_access', array('*'), array('zone_name' => $zone));
            $page_access = $GLOBALS['SITE_DB']->query_select('group_page_access', array('*'), array('zone_name' => $zone));
        }
        foreach ($pages as $page => $page_type) {
            if (!is_string($page)) {
                $page = strval($page);
            }
            $full_page_type = $page_type;
            $description = '';
            if (strpos($full_page_type, '/') !== false) {
                $full_page_type = substr($full_page_type, 0, strpos($full_page_type, '/'));
            }
            if (strpos($full_page_type, ':') !== false) {
                $full_page_type = substr($full_page_type, 0, strpos($full_page_type, ':'));
            }
            switch ($full_page_type) {
                case 'redirect':
                    list(, $redir_zone, $redir_page) = explode(':', $page_type);
                    $page_title = html_entity_decode(strip_tags(str_replace(array('<kbd>', '</kbd>'), array('"', '"'), do_lang('REDIRECT_PAGE_TO', xmlentities($redir_zone), xmlentities($redir_page)))), ENT_QUOTES) . ': ' . (is_string($page) ? $page : strval($page));
                    break;
                case 'comcode':
                case 'comcode_custom':
                    $page_title = do_lang('COMCODE_PAGE') . ': ' . (is_string($page) ? $page : strval($page));
                    break;
                case 'html':
                case 'html_custom':
                    $page_title = 'HTML: ' . $page;
                    break;
                case 'modules':
                case 'modules_custom':
                    $page_title = do_lang('MODULE') . ': ' . $page;
                    $matches = array();
                    if (preg_match('#@package\\s+(\\w+)#', file_get_contents(zone_black_magic_filterer(get_file_base() . '/' . $zone . '/pages/' . $page_type . '/' . $page . '.php')), $matches) != 0) {
                        $package = $matches[1];
                        $path = get_file_base() . '/sources_custom/hooks/systems/addon_registry/' . $package . '.php';
                        if (!file_exists($path)) {
                            $path = get_file_base() . '/sources/hooks/systems/addon_registry/' . $package . '.php';
                        }
                        if (file_exists($path)) {
                            require_lang('zones');
                            require_code('zones2');
                            $functions = extract_module_functions($path, array('get_description'));
                            $description = is_array($functions[0]) ? call_user_func_array($functions[0][0], $functions[0][1]) : eval($functions[0]);
                            $description = do_lang('FROM_ADDON', $package, $description);
                        }
                    }
                    break;
                case 'minimodules':
                case 'minimodules_custom':
                    $page_title = do_lang('MINIMODULE') . ': ' . $page;
                    break;
                default:
                    $page_title = do_lang('PAGE') . ': ' . $page;
                    break;
            }
            if ($permissions_needed) {
                $view_perms = '';
                foreach ($groups as $group => $group_name) {
                    if (!in_array($group, $admin_groups)) {
                        $view_perms .= 'g_view_' . strval($group) . '="' . (!in_array(array('zone_name' => $zone, 'page_name' => is_string($page) ? $page : strval($page), 'group_id' => $group), $page_access) ? 'true' : 'false') . '" ';
                    }
                }
                $pagelinks = NULL;
                if (substr($page_type, 0, 7) != 'modules') {
                    $overridables = array();
                } else {
                    list($overridables, $sp_page) = get_module_overridables($zone, $page);
                }
                $sp_perms = '';
                foreach ($overridables as $overridable => $cat_support) {
                    $lang_string = do_lang('PT_' . $overridable);
                    if (is_array($cat_support)) {
                        $lang_string = do_lang($cat_support[1]);
                    }
                    if (strlen($lang_string) > 20 && strpos($lang_string, '(') !== false) {
                        $lang_string = preg_replace('# \\([^\\)]*\\)#', '', $lang_string);
                    }
                    $sp_perms .= 'sp_' . $overridable . '="' . xmlentities($lang_string) . '" ';
                    foreach ($groups as $group => $group_name) {
                        if (!in_array($group, $admin_groups)) {
                            $override_value = -1;
                            foreach ($sp_access[$group] as $test) {
                                if ($test['specific_permission'] == $overridable && $test['the_page'] == $sp_page) {
                                    $override_value = $test['the_value'];
                                }
                            }
                            if ($override_value != -1) {
                                $sp_perms .= 'gsp_' . $overridable . '_' . strval($group) . '="' . strval($override_value) . '" ';
                            }
                        }
                    }
                }
                if (count($overridables) == 0) {
                    $sp_perms = 'no_sps="1" ';
                }
                $has_children = $sp_perms != '';
                if (count(array_diff(array_keys($overridables), array('submit_highrange_content', 'submit_midrange_content', 'submit_lowrange_content'))) != 0) {
                    $sp_perms .= 'inherits_something="1" ';
                }
                $serverid = $zone . ':' . (is_string($page) ? $page : strval($page));
                echo '<category ' . ($serverid == $default ? 'selected="yes" ' : '') . 'description="' . xmlentities($description) . '" img_func_1="permissions_img_func_1" img_func_2="permissions_img_func_2" highlighted="true" ' . $view_perms . $sp_perms . ' id="' . uniqid('', true) . '" serverid="' . xmlentities($serverid) . '" title="' . xmlentities($page_title) . '" has_children="' . ($has_children ? 'true' : 'false') . '" selectable="true">';
            } else {
                $extra = '';
                if (strpos($page_type, 'modules') === 0) {
                    $info = extract_module_info(zone_black_magic_filterer(get_file_base() . '/' . $zone . ($zone == '' ? '' : '/') . 'pages/' . $page_type . '/' . $page . '.php'));
                    if (!is_null($info) && array_key_exists('author', $info)) {
                        $extra = 'author="' . xmlentities($info['author']) . '" organisation="' . xmlentities($info['organisation']) . '" version="' . xmlentities(integer_format($info['version'])) . '" ';
                    }
                }
                $has_children = false;
                // For a normal tree, we have children if we have entry points. We have children if we have categories also - but where there are categories there are also entry points
                if (strpos($page_type, 'modules') === 0) {
                    $_entrypoints = extract_module_functions_page($zone, $page, array('get_entry_points'));
                    if (!is_null($_entrypoints[0])) {
                        $entrypoints = is_string($_entrypoints[0]) && strpos($_entrypoints[0], '::') !== false ? array('whatever' => 1) : (is_array($_entrypoints[0]) ? call_user_func_array($_entrypoints[0][0], $_entrypoints[0][1]) : eval($_entrypoints[0]));
                        // The strpos thing is a little hack that allows it to work for base-class derived modules
                        if (!is_array($entrypoints)) {
                            $entrypoints = array('whatever' => 1);
                        }
                        $has_children = array_keys($entrypoints) != array('!');
                    }
                }
                global $MODULES_ZONES;
                $not_draggable = array_key_exists($page, $MODULES_ZONES) || $zone == 'adminzone' && substr($page, 0, 6) == 'admin_' && substr($page_type, 0, 6) == 'module';
                $serverid = $zone . ':' . $page;
                echo '<category ' . ($serverid == $default ? 'selected="yes" ' : '') . '' . $extra . 'type="' . xmlentities($page_type) . '" description="' . xmlentities($description) . '" draggable="' . ($not_draggable ? 'false' : 'page') . '" droppable="' . ($page_type == 'zone' ? 'page' : 'false') . '" id="' . uniqid('', true) . '" serverid="' . xmlentities($serverid) . '" title="' . xmlentities($page_title) . '" has_children="' . ($has_children ? 'true' : 'false') . '" selectable="true">';
            }
            echo '</category>';
        }
    } elseif (!is_null($page_link) && $page_link != '') {
        $matches = array();
        preg_match('#^([^:]*):([^:]*)#', $page_link, $matches);
        $zone = $matches[1];
        $page = $matches[2];
        if ($permissions_needed) {
            $category_access = $GLOBALS['SITE_DB']->query_select('group_category_access', array('*'));
        }
        $_pagelinks = extract_module_functions_page($zone, $page, array('get_page_links'), array(1, true, $page_link));
        if (!is_null($_pagelinks[0])) {
            $pagelinks = is_array($_pagelinks[0]) ? call_user_func_array($_pagelinks[0][0], $_pagelinks[0][1]) : eval($_pagelinks[0]);
            if (!is_null($pagelinks[0]) && !is_null($pagelinks[1])) {
                $_overridables = extract_module_functions_page(get_module_zone($pagelinks[1]), $pagelinks[1], array('get_sp_overrides'));
                if (!is_null($_overridables[0])) {
                    $overridables = is_array($_overridables[0]) ? call_user_func_array($_overridables[0][0], $_overridables[0][1]) : eval($_overridables[0]);
                } else {
                    $overridables = array();
                }
            } else {
                $overridables = array();
            }
        } else {
            $pagelinks = NULL;
        }
        $_pagelinks = extract_module_functions_page($zone, $page, array('extract_page_link_permissions'), array($page_link));
        list($category, $module) = is_null($_pagelinks[0]) || strlen($matches[0]) == strlen($page_link) ? array('!', '') : (is_array($_pagelinks[0]) ? call_user_func_array($_pagelinks[0][0], $_pagelinks[0][1]) : eval($_pagelinks[0]));
        // If $_pagelinks[0] is NULL then it's an error: extract_page_link_permissions is always there when there are cat permissions
        // Entry points under here
        if (!$permissions_needed && $zone . ':' . $page == $page_link) {
            $path = zone_black_magic_filterer(filter_naughty($zone) . ($zone == '' ? '' : '/') . 'pages/modules_custom/' . filter_naughty($page) . '.php', true);
            if (!file_exists(get_file_base() . '/' . $path)) {
                $path = zone_black_magic_filterer(filter_naughty($zone) . '/pages/modules/' . filter_naughty($page) . '.php', true);
            }
            require_code($path);
            if (class_exists('Mx_' . filter_naughty_harsh($page))) {
                $object = object_factory('Mx_' . filter_naughty_harsh($page));
            } else {
                $object = object_factory('Module_' . filter_naughty_harsh($page));
            }
            require_all_lang();
            $entrypoints = $object->get_entry_points();
            foreach ($entrypoints as $entry_point => $lang_string) {
                $serverid = $zone . ':' . $page;
                echo '<category ' . ($serverid == $default ? 'selected="yes" ' : '') . 'type="entry_point" id="' . uniqid('', true) . '" serverid="' . xmlentities($serverid) . ':type=' . $entry_point . '" title="' . xmlentities(do_lang('ENTRY_POINT') . ': ' . do_lang($lang_string)) . '" has_children="false" selectable="true">';
                echo '</category>';
            }
        }
        // Categories under here
        if (!is_null($pagelinks)) {
            foreach ($pagelinks[0] as $pagelink) {
                $keys = array_keys($pagelink);
                if (is_string($keys[0])) {
                    $module_the_name = array_key_exists(3, $pagelinks) ? $pagelinks[3] : NULL;
                    $category_name = is_string($pagelink['id']) ? $pagelink['id'] : strval($pagelink['id']);
                    $actual_page_link = str_replace('!', $category_name, $pagelinks[2]);
                    $title = $pagelink['title'];
                    $has_children = $pagelink['child_count'] != 0;
                } else {
                    $cms_module_name = NULL;
                    $module_the_name = $pagelink[1];
                    $category_name = is_null($pagelink[2]) ? '' : (is_string($pagelink[2]) ? $pagelink[2] : strval($pagelink[2]));
                    $actual_page_link = $pagelink[0];
                    $title = $pagelink[3];
                    $has_children = array_key_exists(7, $pagelink) ? $pagelink[7] : NULL;
                }
                $cms_module_name = $pagelinks[1];
                if ($category_name == $category) {
                    continue;
                }
                if ($module_the_name == 'catalogues_category' && $category_name == '') {
                    continue;
                }
                if (!is_null($cms_module_name)) {
                    $edit_type = '_ec';
                    if ($module_the_name == 'catalogues_catalogue') {
                        $edit_type = '_ev';
                    }
                    $actual_edit_link = preg_replace('#^[\\w\\_]+:[\\w\\_]+:type=[\\w\\_]+:(id|catalogue\\_name)=#', get_module_zone($cms_module_name) . ':' . $cms_module_name . ':' . $edit_type . ':', $actual_page_link);
                } else {
                    $actual_edit_link = '';
                }
                $actual_page_link = str_replace('_SELF:_SELF', $zone . ':' . $page, $actual_page_link);
                // Support for lazy notation
                if ($permissions_needed) {
                    $highlight = $module_the_name == 'catalogues_catalogue' ? 'true' : 'false';
                    $view_perms = '';
                    $sp_perms = '';
                    if (!is_null($module_the_name)) {
                        foreach ($groups as $group => $group_name) {
                            if (!in_array($group, $admin_groups)) {
                                $view_perms .= 'g_view_' . strval($group) . '="' . (in_array(array('module_the_name' => $module_the_name, 'category_name' => $category_name, 'group_id' => $group), $category_access) ? 'true' : 'false') . '" ';
                            }
                        }
                        foreach ($overridables as $overridable => $cat_support) {
                            $lang_string = do_lang('PT_' . $overridable);
                            if (is_array($cat_support)) {
                                $lang_string = do_lang($cat_support[1]);
                            }
                            if (strlen($lang_string) > 20 && strpos($lang_string, '(') !== false) {
                                $lang_string = preg_replace('# \\([^\\)]*\\)#', '', $lang_string);
                            }
                            if (is_array($cat_support)) {
                                $cat_support = $cat_support[0];
                            }
                            if ($cat_support == 0) {
                                continue;
                            }
                            $sp_perms .= 'sp_' . $overridable . '="' . xmlentities($lang_string) . '" ';
                            foreach ($groups as $group => $group_name) {
                                if (!in_array($group, $admin_groups)) {
                                    $override_value = -1;
                                    foreach ($sp_access[$group] as $test) {
                                        if ($test['specific_permission'] == $overridable && $test['the_page'] == '' && $test['category_name'] == $category_name && $test['module_the_name'] == $module_the_name) {
                                            $override_value = $test['the_value'];
                                        }
                                    }
                                    if ($override_value != -1) {
                                        $sp_perms .= 'gsp_' . $overridable . '_' . strval($group) . '="' . strval($override_value) . '" ';
                                    }
                                }
                            }
                        }
                    }
                    if (count(array_diff(array_keys($overridables), array('submit_highrange_content', 'submit_midrange_content', 'submit_lowrange_content'))) != 0) {
                        $sp_perms .= 'inherits_something="1" ';
                    }
                    $serverid = $actual_page_link;
                    echo '<category ' . ($serverid == $default ? 'selected="yes" ' : '') . 'img_func_1="permissions_img_func_1" img_func_2="permissions_img_func_2" highlighted="' . $highlight . '" ' . $view_perms . $sp_perms . ' id="' . uniqid('', true) . '" serverid="' . xmlentities($serverid) . '" title="' . xmlentities($title) . '" has_children="' . ($has_children ? 'true' : 'false') . '" selectable="' . (!is_null($module_the_name) ? 'true' : 'false') . '">';
                } else {
                    $serverid = $actual_page_link;
                    echo '<category ' . ($serverid == $default ? 'selected="yes" ' : '') . 'type="category" id="' . uniqid('', true) . '" edit="' . xmlentities($actual_edit_link) . '" serverid="' . xmlentities($serverid) . '" title="' . xmlentities($title) . '" has_children="' . ($has_children ? 'true' : 'false') . '" selectable="true">';
                }
                echo '</category>';
            }
        }
    } else {
        // Start of tree
        if ($permissions_needed) {
            $view_perms = '';
            foreach ($groups as $group => $group_name) {
                if (!in_array($group, $admin_groups)) {
                    $view_perms .= 'g_view_' . strval($group) . '="true" ';
                }
                // This isn't actually displayed in the editor
            }
            $sp_perms = '';
            $sp_perms_opera_hack = '';
            foreach (array_keys($root_perms) as $overridable) {
                $sp_perms .= 'sp_' . $overridable . '="' . xmlentities(do_lang('PT_' . $overridable)) . '" ';
                $sp_perms_opera_hack .= '<attribute key="' . 'sp_' . $overridable . '" value="' . xmlentities(do_lang('PT_' . $overridable)) . '" />';
                foreach ($groups as $group => $group_name) {
                    if (!in_array($group, $admin_groups)) {
                        $override_value = 0;
                        foreach ($sp_access[$group] as $test) {
                            if ($test['specific_permission'] == $overridable && $test['the_page'] == '' && $test['module_the_name'] == '' && $test['category_name'] == '') {
                                $override_value = $test['the_value'];
                            }
                        }
                        $sp_perms .= 'gsp_' . $overridable . '_' . strval($group) . '="' . strval($override_value) . '" ';
                        $sp_perms_opera_hack .= '<attribute key="' . 'gsp_' . $overridable . '_' . strval($group) . '" value="' . strval($override_value) . '" />';
                    }
                }
            }
            echo '<category serverid="_root" expanded="true" title="' . do_lang('ROOT') . '" has_children="true" selectable="true" img_func_1="permissions_img_func_1" img_func_2="permissions_img_func_2" id="' . uniqid('', true) . '" ' . $view_perms . '>';
            echo $sp_perms_opera_hack;
        } else {
            echo '<category serverid="_root" expanded="true" title="' . do_lang('ROOT') . '" has_children="true" selectable="false" type="root" id="' . uniqid('', true) . '">';
        }
        // Zones
        $zones = $GLOBALS['SITE_DB']->query_select('zones', array('zone_title', 'zone_name', 'zone_default_page'), NULL, 'ORDER BY zone_title', 50);
        if ($permissions_needed) {
            $zone_access = $GLOBALS['SITE_DB']->query_select('group_zone_access', array('*'));
            $page_access = $GLOBALS['SITE_DB']->query_select('group_page_access', array('*'));
        }
        $start_links = get_param_integer('start_links', 0) == 1;
        foreach ($zones as $_zone) {
            if (get_option('collapse_user_zones') == '1' && $_zone['zone_name'] == 'site') {
                continue;
            }
            $_zone['text_original'] = get_translated_text($_zone['zone_title']);
            $zone = $_zone['zone_name'];
            $zone_title = $_zone['text_original'];
            $serverid = $zone;
            if ($start_links) {
                $serverid = $zone . ':';
            }
            $pages = find_all_pages_wrap($zone, false, true, FIND_ALL_PAGES__NEWEST);
            if ($permissions_needed) {
                $view_perms = '';
                foreach ($groups as $group => $group_name) {
                    if (!in_array($group, $admin_groups)) {
                        $view_perms .= 'g_view_' . strval($group) . '="' . (in_array(array('zone_name' => $zone, 'group_id' => $group), $zone_access) ? 'true' : 'false') . '" ';
                    }
                }
                echo '<category ' . ($serverid == $default ? 'selected="yes" ' : '') . 'img_func_1="permissions_img_func_1" img_func_2="permissions_img_func_2" no_sps="1" highlighted="true" ' . $view_perms . ' id="' . uniqid('', true) . '" serverid="' . xmlentities($serverid) . '" title="' . xmlentities(do_lang('ZONE') . ': ' . $zone_title) . '" has_children="' . (count($pages) != 0 ? 'true' : 'false') . '" selectable="true">';
            } else {
                echo '<category ' . ($serverid == $default ? 'selected="yes" ' : '') . 'type="zone" droppable="page" id="' . uniqid('', true) . '" serverid="' . xmlentities($serverid) . '" title="' . xmlentities(do_lang('ZONE') . ': ' . $zone_title) . '" has_children="' . (count($pages) != 0 ? 'true' : 'false') . '" selectable="true">';
            }
            echo '</category>';
        }
        echo '</category>';
    }
    // Mark parent cats for pre-expansion
    if (!is_null($default) && $default != '' && strpos($default, ':') !== false) {
        list($zone, $page) = explode(':', $default, 2);
        echo "\n" . '<expand>' . $zone . '</expand>';
        echo "\n" . '<expand>' . $zone . ':</expand>';
        echo "\n" . '<expand>' . $zone . ':' . $page . '</expand>';
    }
    echo '</result></request>';
}
Exemplo n.º 9
0
 /**
  * Actualiser to do an import.
  *
  * @return tempcode	The results.
  */
 function _import()
 {
     $title = get_page_title('IMPORT');
     $xml = post_param('xml');
     $ops = import_from_xml($xml);
     $ops_nice = array();
     foreach ($ops as $op) {
         $ops_nice[] = array('OP' => $op[0], 'PARAM_A' => $op[1], 'PARAM_B' => array_key_exists(2, $op) ? $op[2] : '');
     }
     // Clear some cacheing
     require_code('view_modes');
     require_code('zones2');
     require_code('zones3');
     erase_comcode_page_cache();
     require_code('view_modes');
     erase_tempcode_cache();
     persistant_cache_empty();
     breadcrumb_set_self(do_lang_tempcode('_RESULTS'));
     breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('XML_DATA_MANAGEMENT'))));
     return do_template('XML_STORAGE_IMPORT_RESULTS_SCREEN', array('TITLE' => $title, 'OPS' => $ops_nice));
 }
Exemplo n.º 10
0
/**
 * Uninstall an addon.
 *
 * @param  string			Name of the addon
 */
function uninstall_addon($name)
{
    $addon_row = read_addon_info($name);
    require_code('zones2');
    require_code('zones3');
    require_code('abstract_file_manager');
    // Clear some cacheing
    require_code('view_modes');
    require_code('zones2');
    require_code('zones3');
    erase_comcode_page_cache();
    erase_tempcode_cache();
    persistant_cache_empty();
    erase_cached_templates();
    erase_cached_language();
    global $HOOKS_CACHE;
    $HOOKS_CACHE = array();
    // Remove addon info from database, modules, blocks, and files
    $last = array();
    foreach ($addon_row['addon_files'] as $filename) {
        if (@file_exists(get_file_base() . '/' . $filename)) {
            $test = $GLOBALS['SITE_DB']->query_value('addons_files', 'COUNT(*)', array('filename' => $filename));
            if ($test <= 1) {
                if (substr($filename, 0, 37) == 'sources/hooks/systems/addon_registry/') {
                    $last[] = $filename;
                    continue;
                }
                $matches = array();
                if (preg_match('#([^/]*)/?pages/modules(_custom)?/(.*)\\.php#', $filename, $matches) != 0) {
                    uninstall_module($matches[1], $matches[3]);
                }
                if (preg_match('#sources(_custom)?/blocks/(.*)\\.php#', $filename, $matches) != 0) {
                    uninstall_block($matches[2]);
                }
                if (preg_match('#^([^/]*)/index.php#', $filename, $matches) != 0) {
                    actual_delete_zone_lite($matches[1]);
                }
                if ($filename != 'mod.inf' && $filename != 'mod.php' && $filename != '' && substr($filename, -1) != '/') {
                    $last[] = $filename;
                }
            }
        }
    }
    foreach ($last as $filename) {
        afm_delete_file($filename);
    }
    $GLOBALS['SITE_DB']->query_delete('addons_files', array('addon_name' => $addon_row['addon_name']));
    $GLOBALS['SITE_DB']->query_delete('addons_dependencies', array('addon_name' => $addon_row['addon_name']));
    $GLOBALS['SITE_DB']->query_delete('addons', array('addon_name' => $addon_row['addon_name']), '', 1);
    global $ADDON_INSTALLED_CACHE;
    unset($ADDON_INSTALLED_CACHE[$addon_row['addon_name']]);
    if (function_exists('persistent_cache_set')) {
        persistent_cache_set('ADDONS_INSTALLED', $ADDON_INSTALLED_CACHE, true);
    }
    log_it('UNINSTALL_ADDON', $addon_row['addon_name']);
}
Exemplo n.º 11
0
 /**
  * UI for a setup wizard step (done).
  *
  * @return tempcode		The UI
  */
 function step10()
 {
     $title = get_page_title('SETUP_WIZARD_STEP', true, array(integer_format(10), integer_format(10)));
     $GLOBALS['NO_QUERY_LIMIT'] = true;
     require_code('abstract_file_manager');
     force_have_afm_details();
     if (function_exists('set_time_limit')) {
         @set_time_limit(600);
     }
     require_code('config2');
     require_code('menus2');
     require_code('themes2');
     require_lang('zones');
     $header_text = post_param('header_text');
     $name = post_param('site_name');
     $theme = substr(preg_replace('#[^A-Za-z\\d]#', '_', $name), 0, 40);
     $installprofile = post_param('installprofile', '');
     if ($installprofile != '') {
         // Simplify down to a single menu
         foreach (array('main_community', 'main_content', 'main_features', 'main_website', 'root_website') as $merge_item) {
             $GLOBALS['SITE_DB']->query_update('menu_items', array('i_menu' => 'site'), array('i_menu' => $merge_item));
         }
         $duplicates = $GLOBALS['SITE_DB']->query_select('menu_items', array('id', 'COUNT(*) AS cnt'), array('i_menu' => 'site'), 'GROUP BY i_url');
         foreach ($duplicates as $duplicate) {
             if ($duplicate['cnt'] > 1) {
                 delete_menu_item($duplicate['id']);
             }
         }
         delete_menu_item_simple('site:');
         // Remove panel_top
         if (addon_installed('redirects_editor')) {
             $GLOBALS['SITE_DB']->query_delete('redirects', array('r_to_page' => 'panel_top'));
         }
         $fullpath = get_custom_file_base() . '/pages/comcode_custom/' . get_site_default_lang() . '/panel_top.txt';
         if (file_exists($fullpath)) {
             @copy($fullpath, $fullpath . '.' . strval(time()));
         }
         $myfile = @fopen($fullpath, 'wt');
         if ($myfile !== false) {
             fwrite($myfile, '');
             fclose($myfile);
             fix_permissions($fullpath);
             sync_file($fullpath);
         }
         // Run any specific code for the profile
         $object = mixed();
         if (is_file(get_file_base() . '/sources/hooks/modules/admin_setupwizard_installprofiles/' . $installprofile . '.php') || is_file(get_file_base() . '/sources_custom/hooks/modules/admin_setupwizard_installprofiles/' . $installprofile . '.php')) {
             require_code('hooks/modules/admin_setupwizard_installprofiles/' . $installprofile);
             $object = object_factory('Hook_admin_setupwizard_installprofiles_' . $installprofile, true);
         }
         if (!is_null($object)) {
             $object->install_code();
             $installprofileblocks = $object->default_blocks();
         } else {
             $installprofileblocks = array();
         }
     } else {
         $installprofileblocks = array();
     }
     if (post_param_integer('skip_8', 0) == 0 && function_exists('imagecreatefromstring') && addon_installed('themewizard')) {
         require_code('themewizard');
         // Make theme
         global $IMG_CODES;
         $old_img_codes_site = $GLOBALS['SITE_DB']->query_select('theme_images', array('id', 'path'), array('theme' => $GLOBALS['FORUM_DRIVER']->get_theme(), 'lang' => user_lang()));
         if (!file_exists(get_custom_file_base() . '/themes/' . $theme)) {
             make_theme($theme, 'default', 'equations', post_param('seed_hex'), true, post_param_integer('dark', 0) == 1);
         }
         foreach (array($theme, 'default') as $logo_save_theme) {
             $logo = generate_logo($name, $header_text, false, $logo_save_theme, 'logo-template');
             $path = 'themes/' . $logo_save_theme . '/images_custom/-logo.png';
             @imagepng($logo, get_custom_file_base() . '/' . $path) or intelligent_write_error($path);
             actual_edit_theme_image('logo/-logo', $logo_save_theme, get_site_default_lang(), 'logo/-logo', $path, true);
             if (addon_installed('collaboration_zone')) {
                 actual_edit_theme_image('logo/collaboration-logo', $logo_save_theme, get_site_default_lang(), 'logo/collaboration-logo', $path, true);
             }
             imagedestroy($logo);
             $logo = generate_logo($name, $header_text, false, $logo_save_theme, 'trimmed-logo-template');
             $path = 'themes/' . $logo_save_theme . '/images_custom/trimmed-logo.png';
             @imagepng($logo, get_custom_file_base() . '/' . $path) or intelligent_write_error($path);
             actual_edit_theme_image('logo/trimmed-logo', $logo_save_theme, get_site_default_lang(), 'logo/trimmed-logo', $path, true);
             imagedestroy($logo);
         }
         $myfile = fopen(get_custom_file_base() . '/themes/' . filter_naughty($theme) . '/theme.ini', 'wt');
         fwrite($myfile, 'title=' . $name . chr(10));
         fwrite($myfile, 'description=' . do_lang('NA') . chr(10));
         if (fwrite($myfile, 'author=ocPortal' . chr(10)) == 0) {
             warn_exit(do_lang_tempcode('COULD_NOT_SAVE_FILE'));
         }
         fclose($myfile);
         sync_file(get_custom_file_base() . '/themes/' . filter_naughty($theme) . '/theme.ini');
         $IMG_CODES['site'] = $old_img_codes_site;
         // Just so it renders with the old theme
     }
     // Set options
     if (post_param_integer('skip_3', 0) == 0) {
         set_option('site_name', $name);
         set_option('copyright', 'Copyright &copy; ' . $name . ' ' . date('Y'));
         set_option('description', post_param('description'));
         set_option('site_scope', post_param('site_scope'));
         set_option('copyright', post_param('copyright'));
         set_option('staff_address', post_param('staff_address'));
         set_option('keywords', post_param('keywords'));
         set_option('google_analytics', post_param('google_analytics'));
         set_option('fixed_width', post_param('fixed_width', '0'));
         $a = $GLOBALS['SITE_DB']->query_value('zones', 'zone_header_text', array('zone_name' => ''));
         lang_remap($a, $header_text);
         $b = $GLOBALS['SITE_DB']->query_value_null_ok('zones', 'zone_header_text', array('zone_name' => 'site'));
         if (!is_null($b)) {
             lang_remap($b, $header_text);
         }
     }
     if (post_param_integer('skip_9', 0) == 0) {
         set_option('site_closed', strval(post_param_integer('site_closed', 0)));
         set_option('closed', post_param('closed', ''));
     }
     // Set addons
     if (post_param_integer('skip_4', 0) == 0 && get_file_base() == get_custom_file_base()) {
         require_lang('addons');
         require_code('addons');
         $addons_installed = find_installed_addons();
         $uninstalling = array();
         foreach ($addons_installed as $addon_row) {
             if (post_param_integer('addon_' . $addon_row['addon_name'], 0) == 0) {
                 $uninstalling[$addon_row['addon_name']] = $addon_row;
             }
         }
         if (!file_exists(get_file_base() . '/.svn')) {
             do {
                 $cnt = count($uninstalling);
                 foreach ($addons_installed as $addon_row) {
                     if (array_key_exists($addon_row['addon_name'], $uninstalling)) {
                         $addon_row += read_addon_info($addon_row['addon_name']);
                         $addon_row['addon_author'] = '';
                         // Fudge, to stop it dying on warnings for official addons
                         // Check dependencies
                         $dependencies = $addon_row['addon_dependencies_on_this'];
                         foreach (array_keys($uninstalling) as $d) {
                             if (in_array($d, $dependencies)) {
                                 // Can mark this dependency as irrelevant, as we are uninstalling the addon for it anyway
                                 unset($dependencies[array_search($d, $dependencies)]);
                             }
                         }
                         if (count($dependencies) != 0) {
                             unset($uninstalling[$addon_row['addon_name']]);
                         }
                     }
                 }
             } while ($cnt != count($uninstalling));
             // Dependency chains can be complex, so loop until we're stopped finding anything changing
             foreach ($uninstalling as $addon_row) {
                 // Archive it off to exports/addons
                 if ($addon_row['addon_files'] != '') {
                     $file = preg_replace('#^[\\_\\.\\-]#', 'x', preg_replace('#[^\\w\\.\\-]#', '_', $addon_row['addon_name'])) . '.tar';
                     create_addon($file, explode(chr(10), $addon_row['addon_files']), $addon_row['addon_name'], implode(',', $addon_row['addon_incompatibilities']), implode(',', $addon_row['addon_dependencies']), $addon_row['addon_author'], $addon_row['addon_organisation'], $addon_row['addon_version'], $addon_row['addon_description'], 'imports/addons');
                 }
                 uninstall_addon($addon_row['addon_name']);
             }
         }
     }
     // Set features
     if (post_param_integer('skip_5', 0) == 0) {
         $hooks = find_all_hooks('modules', 'admin_setupwizard');
         foreach (array_keys($hooks) as $hook) {
             if (post_param_integer('addon_' . $hook, 0) == 1) {
                 $path = get_file_base() . '/sources_custom/modules/systems/admin_setupwizard/' . filter_naughty_harsh($hook) . '.php';
                 if (!file_exists($path)) {
                     $path = get_file_base() . '/sources/hooks/modules/admin_setupwizard/' . filter_naughty_harsh($hook) . '.php';
                 }
                 $_hook_bits = extract_module_functions($path, array('set_fields'));
                 if (is_array($_hook_bits[0])) {
                     call_user_func_array($_hook_bits[0][0], $_hook_bits[0][1]);
                 } else {
                     @eval($_hook_bits[0]);
                 }
             }
         }
         set_option('show_content_tagging', post_param('show_content_tagging', '0'));
         set_option('show_content_tagging_inline', post_param('show_content_tagging_inline', '0'));
         set_option('show_screen_actions', post_param('show_screen_actions', '0'));
     }
     // Zone structure
     $collapse_zones = post_param_integer('collapse_user_zones', 0) == 1;
     if (post_param_integer('skip_5', 0) == 0) {
         require_code('config2');
         set_option('collapse_user_zones', strval($collapse_zones));
         /*if (addon_installed('redirects_editor')) Old method
         		{
         			if ($collapse_zones)
         			{
         				$test=$GLOBALS['SITE_DB']->query_value_null_ok('redirects','r_from_page',array('r_from_page'=>'panel_left','r_from_zone'=>'site'));
         				if (is_null($test)) $GLOBALS['SITE_DB']->query_insert('redirects',array('r_from_page'=>'panel_left','r_from_zone'=>'site','r_to_page'=>'panel_left','r_to_zone'=>'','r_is_transparent'=>1));
         				$test=$GLOBALS['SITE_DB']->query_value_null_ok('redirects','r_from_page',array('r_from_page'=>'panel_right','r_from_zone'=>'site'));
         				if (is_null($test)) $GLOBALS['SITE_DB']->query_insert('redirects',array('r_from_page'=>'panel_right','r_from_zone'=>'site','r_to_page'=>'panel_right','r_to_zone'=>'','r_is_transparent'=>1));
         				$test=$GLOBALS['SITE_DB']->query_value_null_ok('redirects','r_from_page',array('r_from_page'=>'start','r_from_zone'=>'site'));
         				if (is_null($test)) $GLOBALS['SITE_DB']->query_insert('redirects',array('r_from_page'=>'start','r_from_zone'=>'site','r_to_page'=>'start','r_to_zone'=>'','r_is_transparent'=>1));
         			} else
         			{
         				$GLOBALS['SITE_DB']->query_delete('redirects',array('r_from_page'=>'panel_left','r_from_zone'=>'site','r_to_page'=>'panel_left','r_to_zone'=>''),'',1);
         				$GLOBALS['SITE_DB']->query_delete('redirects',array('r_from_page'=>'panel_right','r_from_zone'=>'site','r_to_page'=>'panel_right','r_to_zone'=>''),'',1);
         				$GLOBALS['SITE_DB']->query_delete('redirects',array('r_from_page'=>'start','r_from_zone'=>'site','r_to_page'=>'start','r_to_zone'=>''),'',1);
         			}
         		}*/
         if (post_param_integer('guest_zone_access', 0) == 1) {
             $guest_groups = $GLOBALS['FORUM_DRIVER']->get_members_groups($GLOBALS['FORUM_DRIVER']->get_guest_id());
             $test = $GLOBALS['SITE_DB']->query_value_null_ok('group_zone_access', 'zone_name', array('zone_name' => 'site', 'group_id' => $guest_groups[0]));
             if (is_null($test)) {
                 $GLOBALS['SITE_DB']->query_insert('group_zone_access', array('zone_name' => 'site', 'group_id' => $guest_groups[0]));
             }
         }
     }
     // Rules
     if (post_param_integer('skip_7', 0) == 0) {
         $fullpath = get_custom_file_base() . '/pages/comcode_custom/' . get_site_default_lang() . '/rules.txt';
         if (file_exists($fullpath)) {
             @copy($fullpath, $fullpath . '.' . strval(time()));
             fix_permissions($fullpath . '.' . strval(time()));
             sync_file($fullpath . '.' . strval(time()));
         }
         $myfile = @fopen($fullpath, 'wt') or intelligent_write_error(get_custom_file_base() . '/pages/comcode_custom/' . get_site_default_lang() . '/rules.txt');
         $rf = $this->get_rules_file(post_param('rules'));
         if (fwrite($myfile, $rf) < strlen($rf)) {
             warn_exit(do_lang_tempcode('COULD_NOT_SAVE_FILE'));
         }
         fclose($myfile);
         fix_permissions($fullpath);
         sync_file($fullpath);
     }
     $block_options = mixed();
     if ($installprofile != '' && !is_null($object)) {
         $block_options = $object->block_options();
     }
     // Blocks
     if (post_param_integer('skip_6', 0) == 0) {
         require_code('setupwizard');
         $page_structure = _get_zone_pages($installprofileblocks, $block_options, $collapse_zones, $installprofile);
         foreach ($page_structure as $zone => $zone_pages) {
             // Start
             $fullpath = get_custom_file_base() . '/' . $zone . '/pages/comcode_custom/' . get_site_default_lang() . '/start.txt';
             if (file_exists($fullpath)) {
                 @copy($fullpath, $fullpath . '.' . strval(time()));
             }
             $myfile = @fopen($fullpath, 'wt') or intelligent_write_error($fullpath);
             if ($myfile !== false) {
                 if ($zone_pages['start'] != '') {
                     if (fwrite($myfile, $zone_pages['start']) == 0) {
                         warn_exit(do_lang_tempcode('COULD_NOT_SAVE_FILE'));
                     }
                 }
                 fclose($myfile);
                 fix_permissions($fullpath);
                 sync_file($fullpath);
             }
             // Left
             $fullpath = get_custom_file_base() . '/' . $zone . '/pages/comcode_custom/' . get_site_default_lang() . '/panel_left.txt';
             if (file_exists($fullpath)) {
                 @copy($fullpath, $fullpath . '.' . strval(time()));
             }
             $myfile = @fopen($fullpath, 'wt');
             if ($myfile !== false) {
                 if ($zone_pages['left'] != '') {
                     if (fwrite($myfile, $zone_pages['left']) == 0) {
                         warn_exit(do_lang_tempcode('COULD_NOT_SAVE_FILE'));
                     }
                 }
                 fclose($myfile);
                 fix_permissions($fullpath);
                 sync_file($fullpath);
             }
             // Right
             $fullpath = get_custom_file_base() . '/' . $zone . '/pages/comcode_custom/' . get_site_default_lang() . '/panel_right.txt';
             if (file_exists($fullpath)) {
                 @copy($fullpath, $fullpath . '.' . strval(time()));
             }
             $myfile = fopen($fullpath, 'wt');
             if ($myfile !== false) {
                 if ($zone_pages['right'] != '') {
                     if (fwrite($myfile, $zone_pages['right']) == 0) {
                         warn_exit(do_lang_tempcode('COULD_NOT_SAVE_FILE'));
                     }
                 }
                 fclose($myfile);
                 fix_permissions($fullpath);
                 sync_file($fullpath);
             }
         }
     }
     // We're done
     set_value('setup_wizard_completed', '1');
     // Clear some cacheing
     require_code('view_modes');
     require_code('zones3');
     erase_comcode_page_cache();
     erase_tempcode_cache();
     //persistant_cache_delete('OPTIONS');  Done by set_option
     persistant_cache_empty();
     erase_cached_templates();
     //breadcrumb_set_parents(array(array('_SELF:_SELF:misc',do_lang_tempcode('START'))));
     //breadcrumb_set_self(do_lang_tempcode('SETUP_WIZARD_STEP',integer_format(10),integer_format(10)));
     $url = build_url(array('page' => '_SELF', 'type' => 'step11'), '_SELF');
     return redirect_screen($title, $url, do_lang_tempcode('SUCCESS'));
 }
Exemplo n.º 12
0
 /**
  * The UI to uninstall an addon.
  *
  * @return tempcode		The UI
  */
 function _addon_uninstall()
 {
     $title = get_page_title('UNINSTALL_ADDON');
     require_code('abstract_file_manager');
     force_have_afm_details();
     $name = post_param('name');
     $addon_row = read_addon_info($name);
     // Archive it off to exports/mods
     if (file_exists(get_file_base() . '/sources/hooks/systems/addon_registry/' . $name . '.php')) {
         $file = preg_replace('#^[\\_\\.\\-]#', 'x', preg_replace('#[^\\w\\.\\-]#', '_', $name)) . '.tar';
     } else {
         $file = preg_replace('#^[\\_\\.\\-]#', 'x', preg_replace('#[^\\w\\.\\-]#', '_', $name)) . date('-dmY-Hm', time()) . '.tar';
     }
     $new_addon_files = array();
     foreach ($addon_row['addon_files'] as $_file) {
         if (substr($_file, -9) != '.editfrom') {
             // This would have been added back in automatically
             $new_addon_files[] = $_file;
         }
     }
     create_addon($file, $new_addon_files, $addon_row['addon_name'], implode(',', $addon_row['addon_incompatibilities']), implode(',', $addon_row['addon_dependencies']), $addon_row['addon_author'], $addon_row['addon_organisation'], $addon_row['addon_version'], $addon_row['addon_description'], 'imports/mods');
     uninstall_addon($name);
     // Clear some cacheing
     require_code('view_modes');
     require_code('zones2');
     require_code('zones3');
     erase_comcode_page_cache();
     erase_tempcode_cache();
     //persistant_cache_delete('OPTIONS');  Done by set_option
     persistant_cache_empty();
     erase_cached_templates();
     // Show it worked / Refresh
     $url = build_url(array('page' => '_SELF', 'type' => 'misc'), '_SELF');
     return redirect_screen($title, $url, do_lang_tempcode('SUCCESS'));
 }
Exemplo n.º 13
0
/**
 * Erase the tempcode cache.
 */
function erase_tempcode_cache()
{
    $GLOBALS['SITE_DB']->query_delete('cache_on', NULL, '', NULL, NULL, true);
    $GLOBALS['SITE_DB']->query_delete('cache');
    if (function_exists('persistant_cache_empty')) {
        persistant_cache_empty();
    }
}
Exemplo n.º 14
0
/**
 * Assuming that permission details are POSTed, set the permissions for the specified category, in the current page
 *
 * @param  ID_TEXT		The ID code for the zone
 * @param  ID_TEXT		The ID code for the page
 */
function set_page_permissions_from_environment($zone, $page)
{
    if (is_null($page)) {
        $page = get_page_name();
    }
    $admin_groups = $GLOBALS['FORUM_DRIVER']->get_super_admin_groups();
    $groups = $GLOBALS['FORUM_DRIVER']->get_usergroup_list(false, true);
    $GLOBALS['SITE_DB']->query_delete('group_page_access', array('zone_name' => $zone, 'page_name' => $page));
    foreach (array_keys($groups) as $group_id) {
        if (in_array($group_id, $admin_groups)) {
            continue;
        }
        $value = post_param_integer('access_' . strval($group_id), 0);
        if ($value == 0) {
            $GLOBALS['SITE_DB']->query_insert('group_page_access', array('zone_name' => $zone, 'page_name' => $page, 'group_id' => $group_id), false, true);
            // Race/corruption condition
        }
    }
    decache('main_sitemap');
    $GLOBALS['SITE_DB']->query_delete('cache');
    if (function_exists('persistant_cache_empty')) {
        persistant_cache_empty();
    }
}
Exemplo n.º 15
0
/**
 * Clear more caches. This is intentionally done after db upgrading.
 */
function clear_caches_2()
{
    require_code('view_modes');
    require_code('zones2');
    if (file_exists(get_file_base() . '/sources/zones3.php')) {
        // If is for back-compatibility, was introduced in newer version and function moved into here
        require_code('zones3');
    }
    erase_comcode_cache();
    erase_tempcode_cache();
    erase_comcode_page_cache();
    persistant_cache_empty();
}
Exemplo n.º 16
0
 /**
  * Set zone access permissions from info in the POST request.
  *
  * @param  ID_TEXT		The zone that we're setting permissions for
  */
 function set_permissions($zone)
 {
     $groups = $GLOBALS['FORUM_DRIVER']->get_usergroup_list(false, true);
     $admin_groups = $GLOBALS['FORUM_DRIVER']->get_super_admin_groups();
     foreach (array_keys($groups) as $id) {
         if (in_array($id, $admin_groups)) {
             continue;
         }
         $value = post_param_integer('access_' . strval($id), 0);
         $GLOBALS['SITE_DB']->query_delete('group_zone_access', array('zone_name' => $zone, 'group_id' => $id), '', 1);
         if ($value == 1) {
             $GLOBALS['SITE_DB']->query_insert('group_zone_access', array('zone_name' => $zone, 'group_id' => $id));
         }
     }
     decache('main_sitemap');
     $GLOBALS['SITE_DB']->query_delete('cache');
     if (function_exists('persistant_cache_empty')) {
         persistant_cache_empty();
     }
 }
Exemplo n.º 17
0
 /**
  * The actualiser to edit a comcode page.
  *
  * @return tempcode		The UI
  */
 function __ed()
 {
     $simple_add = get_param_integer('simple_add', 0) == 1;
     $title = get_page_title($simple_add ? 'COMCODE_PAGE_ADD' : 'COMCODE_PAGE_EDIT');
     $GLOBALS['HELPER_PANEL_PIC'] = 'pagepics/comcode_page_edit';
     $file = filter_naughty(post_param('file'));
     $lang = filter_naughty(post_param('lang'));
     $zone = filter_naughty(post_param('zone'));
     if (addon_installed('page_management')) {
         $new_file = filter_naughty(has_actual_page_access(get_member(), 'admin_sitetree') ? post_param('title', $file) : $file);
     } else {
         $new_file = filter_naughty($file);
     }
     if ($file == '') {
         $file = $new_file;
     }
     require_code('type_validation');
     if (!is_alphanumeric($file, true)) {
         warn_exit(do_lang_tempcode('BAD_CODENAME'));
     }
     $fullpath = zone_black_magic_filterer(get_custom_file_base() . '/' . $zone . '/pages/comcode_custom/' . $lang . '/' . $file . '.txt');
     $renaming_page = $new_file != $file;
     if ($renaming_page) {
         if (!is_alphanumeric($new_file, true)) {
             warn_exit(do_lang_tempcode('BAD_CODENAME'));
         }
         $langs = find_all_langs(true);
         $rename_map = array();
         $afm_needed = false;
         // Actually will stay false as we don't allow renaming original-pages at the moment
         foreach (array_keys($langs) as $lang) {
             $path = zone_black_magic_filterer(filter_naughty($zone) . ($zone != '' ? '/' : '') . 'pages/comcode_custom/' . $lang . '/' . $file . '.txt', true);
             if (is_file(get_file_base() . '/' . $path)) {
                 $new_path = zone_black_magic_filterer(filter_naughty($zone) . ($zone != '' ? '/' : '') . 'pages/comcode_custom/' . $lang . '/' . $new_file . '.txt', true);
                 if (is_file($new_path)) {
                     warn_exit(do_lang_tempcode('ALREADY_EXISTS', escape_html($zone . ':' . $new_file)));
                 }
                 $rename_map[$path] = $new_path;
             }
             if (is_file(get_file_base() . '/' . str_replace('/comcode_custom/', '/comcode/', $path))) {
                 $completion_text = do_lang_tempcode('ORIGINAL_PAGE_NO_RENAME');
             }
         }
         if ($afm_needed) {
             require_code('abstract_file_manager');
             force_have_afm_details();
         }
     }
     $validated = post_param_integer('validated', 0);
     if (!has_specific_permission(get_member(), 'bypass_validation_highrange_content')) {
         $validated = 0;
     }
     $parent_page = post_param('parent_page', '');
     $show_as_edit = post_param_integer('show_as_edit', 0);
     $resource_owner = $GLOBALS['SITE_DB']->query_value_null_ok('comcode_pages', 'p_submitter', array('the_zone' => $zone, 'the_page' => $file));
     check_edit_permission('high', $resource_owner);
     if ($GLOBALS['FORUM_DRIVER']->is_super_admin(get_member())) {
         $_owner = post_param('owner', $GLOBALS['FORUM_DRIVER']->get_username(get_member()));
         $owner = $GLOBALS['FORUM_DRIVER']->get_member_from_username($_owner);
         if (is_null($owner)) {
             $owner = get_member();
         }
     } else {
         $owner = get_member();
     }
     if (is_null($resource_owner)) {
         check_submit_permission('high');
         require_code('submit');
         give_submit_points('COMCODE_PAGE_ADD');
         if (!addon_installed('unvalidated')) {
             $validated = 1;
         }
         $GLOBALS['SITE_DB']->query_insert('comcode_pages', array('the_zone' => $zone, 'the_page' => $file, 'p_parent_page' => $parent_page, 'p_validated' => $validated, 'p_edit_date' => NULL, 'p_add_date' => time(), 'p_submitter' => $owner, 'p_show_as_edit' => 0));
     } else {
         if (!has_actual_page_access(get_member(), $file, $zone)) {
             access_denied('PAGE_ACCESS');
         }
         require_code('submit');
         $just_validated = !content_validated('comcode_page', $zone . ':' . $file) && $validated == 1;
         if ($just_validated) {
             send_content_validated_notification('comcode_page', $zone . ':' . $file);
         }
         if (!addon_installed('unvalidated')) {
             $validated = 1;
         }
         $GLOBALS['SITE_DB']->query_update('comcode_pages', array('p_parent_page' => $parent_page, 'p_validated' => $validated, 'p_edit_date' => time(), 'p_submitter' => $owner, 'p_show_as_edit' => $show_as_edit), array('the_zone' => $zone, 'the_page' => $file), '', 1);
     }
     if ($validated == 0) {
         require_code('submit');
         $edit_url = build_url(array('page' => '_SELF', 'type' => '_ed', 'page_link' => $zone . ':' . $new_file), '_SELF', NULL, false, false, true);
         if (addon_installed('unvalidated')) {
             send_validation_request('COMCODE_PAGE_EDIT', 'comcode_pages', true, $zone . ':' . $new_file, $edit_url);
         }
     }
     $new = post_param('post');
     require_code('attachments2');
     $_new = do_comcode_attachments($new, 'comcode_page', $zone . ':' . $file);
     $new = $_new['comcode'];
     if (!file_exists($fullpath) || $new != file_get_contents($fullpath, FILE_TEXT)) {
         $myfile = @fopen($fullpath, 'wt');
         if ($myfile === false) {
             intelligent_write_error($fullpath);
         }
         final_attachments_from_preview($zone . ':' . $file);
         if (fwrite($myfile, $new) < strlen($new)) {
             warn_exit(do_lang_tempcode('COULD_NOT_SAVE_FILE'));
         }
         fclose($myfile);
         sync_file($fullpath);
         $file_changed = true;
     } else {
         $file_changed = false;
     }
     require_code('seo2');
     $new_keywords = post_param('meta_keywords', '');
     $new_description = post_param('meta_description', '');
     if ($new_keywords == '' && $new_description == '') {
         seo_meta_set_for_implicit('comcode_page', $zone . ':' . $file, array($new), $new);
     } else {
         seo_meta_set_for_explicit('comcode_page', $zone . ':' . $file, $new_keywords, $new_description);
     }
     $completion_text = $validated == 0 ? do_lang_tempcode('SUBMIT_UNVALIDATED') : do_lang_tempcode('SUCCESS');
     // Update cache  NO WE CAN'T - THEY'RE MULTI-THEME NOW
     /*	$string_index=$GLOBALS['SITE_DB']->query_value_null_ok('cached_comcode_pages','string_index',array('the_zone'=>$zone,'the_page'=>$file));
     		if (!is_null($string_index))
     		{
     			lang_remap_comcode($string_index,$new);
     		} else
     		{
     			$string_index=insert_lang_comcode($new,1,NULL,false,NULL,NULL,false,NULL,NULL,60,true,true);
     			$GLOBALS['SITE_DB']->query_insert('cached_comcode_pages',array('the_zone'=>$zone,'the_page'=>$file,'string_index'=>$string_index));
     		}*/
     require_code('permissions2');
     set_page_permissions_from_environment($zone, $file);
     $caches = $GLOBALS['SITE_DB']->query_select('cached_comcode_pages', array('string_index'), array('the_zone' => $zone, 'the_page' => $file));
     $GLOBALS['SITE_DB']->query_delete('cached_comcode_pages', array('the_zone' => $zone, 'the_page' => $file));
     foreach ($caches as $cache) {
         delete_lang($cache['string_index']);
     }
     persistant_cache_empty();
     persistant_cache_delete(array('PAGE_INFO'));
     decache('main_comcode_page_children');
     fix_permissions($fullpath);
     if (is_file($fullpath) && get_option('store_revisions') == '1' && $file_changed) {
         $time = time();
         @copy($fullpath, $fullpath . '.' . strval($time)) or intelligent_write_error($fullpath . '.' . strval($time));
         fix_permissions($fullpath . '.' . strval($time));
         sync_file($fullpath . '.' . strval($time));
     }
     log_it('COMCODE_PAGE_EDIT', $file, $zone);
     require_code('autosave');
     clear_ocp_autosave();
     if ($renaming_page) {
         $GLOBALS['SITE_DB']->query_delete('comcode_pages', array('the_zone' => $zone, 'the_page' => $new_file), '', 1);
         $GLOBALS['SITE_DB']->query_update('comcode_pages', array('the_page' => $new_file), array('the_zone' => $zone, 'the_page' => $file), '', 1);
         $GLOBALS['SITE_DB']->query_update('comcode_pages', array('p_parent_page' => $new_file), array('the_zone' => $zone, 'p_parent_page' => $file));
         foreach ($rename_map as $path => $new_path) {
             if ($afm_needed) {
                 afm_move($path, $new_path);
             } else {
                 rename(get_custom_file_base() . '/' . $path, get_custom_file_base() . '/' . $new_path);
             }
         }
         if (addon_installed('awards')) {
             $types = $GLOBALS['SITE_DB']->query_select('award_types', array('id'), array('a_content_type' => 'comcode_page'));
             foreach ($types as $type) {
                 $GLOBALS['SITE_DB']->query_update('award_archive', array('content_id' => $new_file), array('content_id' => $file, 'a_type_id' => $type['id']));
             }
         }
         $file = $new_file;
     }
     if (post_param_integer('delete', 0) == 1) {
         unlink(get_custom_file_base() . '/' . $path);
     }
     if (addon_installed('awards')) {
         require_code('awards');
         handle_award_setting('comcode_page', $zone . ':' . $file);
     }
     decache('main_sitemap');
     breadcrumb_set_self(do_lang_tempcode('DONE'));
     // Look for bad title semantics
     $_new['html'] = $_new['tempcode']->evaluate();
     if (substr($file, 0, 1) != '_' && substr($file, 0, 6) != 'panel_' && trim($_new['html']) != '') {
         if (strpos($_new['html'], '<h1') === false && strpos($_new['comcode'], '[title]') === false && strpos($_new['comcode'], '[title="1"]') === false) {
             attach_message(do_lang_tempcode('NO_LEVEL_1_HEADERS'), 'notice');
         }
         $matches = array();
         if (strpos($_new['html'], '<h2') === false && preg_match_all('#\\n\\[(b|font|size)\\][^\\.]+\\[/(b|font|size)\\]\\n#', $_new['comcode'], $matches) >= 2) {
             attach_message(do_lang_tempcode('NO_LEVEL_2_HEADERS'), 'inform');
         }
     }
     // Show it worked / Refresh
     $url = post_param('redirect', '');
     if ($url != '') {
         return redirect_screen($title, $url, $completion_text);
     }
     return $this->do_next_manager($title, $file, $zone, $completion_text);
 }
Exemplo n.º 18
0
 /**
  * The actualiser to edit a configuration page.
  *
  * @return tempcode		The UI
  */
 function config_set()
 {
     $page = get_param('id', 'MAIN');
     $title = get_page_title(do_lang_tempcode('CONFIG_CATEGORY_' . $page), false);
     // Make sure we haven't locked ourselves out due to clean URL support
     if (post_param_integer('mod_rewrite', 0) == 1 && substr(ocp_srv('SERVER_SOFTWARE'), 0, 6) == 'Apache' && (!file_exists(get_file_base() . '/.htaccess') || strpos(file_get_contents(get_file_base() . '/.htaccess'), 'RewriteEngine on') === false)) {
         warn_exit(do_lang_tempcode('BEFORE_MOD_REWRITE'));
     }
     // Make sure we haven't just locked staff out
     $new_site_name = substr(post_param('site_name', ''), 0, 200);
     if ($new_site_name != '' && get_option('is_on_sync_staff', true) === '1') {
         $admin_groups = array_merge($GLOBALS['FORUM_DRIVER']->get_super_admin_groups(), $GLOBALS['FORUM_DRIVER']->get_moderator_groups());
         $staff = $GLOBALS['FORUM_DRIVER']->member_group_query($admin_groups, 100);
         if (count($staff) < 100) {
             foreach ($staff as $row_staff) {
                 $member = $GLOBALS['FORUM_DRIVER']->pname_id($row_staff);
                 if ($GLOBALS['FORUM_DRIVER']->is_staff($member)) {
                     $sites = get_ocp_cpf('sites');
                     $sites = str_replace(', ' . get_site_name(), '', $sites);
                     $sites = str_replace(',' . get_site_name(), '', $sites);
                     $sites = str_replace(get_site_name() . ', ', '', $sites);
                     $sites = str_replace(get_site_name() . ',', '', $sites);
                     $sites = str_replace(get_site_name(), '', $sites);
                     if ($sites != '') {
                         $sites .= ', ';
                     }
                     $sites .= $new_site_name;
                     $GLOBALS['FORUM_DRIVER']->set_custom_field($member, 'sites', $sites);
                 }
             }
         }
     }
     // Empty thumbnail cache if needed
     if (get_option('is_on_gd') == '1' && function_exists('imagetypes')) {
         if (!is_null(post_param('thumb_width', NULL)) && post_param('thumb_width') != get_option('thumb_width')) {
             $thumb_fields = $GLOBALS['SITE_DB']->query('SELECT m_name,m_table FROM ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'db_meta WHERE m_name LIKE \'' . db_encode_like('%thumb_url') . '\'');
             $GLOBALS['NO_DB_SCOPE_CHECK'] = true;
             foreach ($thumb_fields as $field) {
                 if ($field['m_table'] == 'videos') {
                     continue;
                 }
                 $GLOBALS['SITE_DB']->query_update($field['m_table'], array($field['m_name'] => ''));
             }
             $GLOBALS['NO_DB_SCOPE_CHECK'] = false;
         }
     }
     $rows = $GLOBALS['SITE_DB']->query_select('config', array('*'), array('the_page' => $page));
     if ($page == 'SITE') {
         $rows[] = array('the_name' => 'timezone', 'shared_hosting_restricted' => 0, 'the_type' => 'special', 'eval' => '');
     }
     foreach ($rows as $myrow) {
         if ($myrow['eval'] != '') {
             if (defined('HIPHOP_PHP')) {
                 require_code('hooks/systems/config_default/' . $myrow['the_name']);
                 $hook = object_factory('Hook_config_default_' . $myrow['the_name']);
                 if (is_null($hook->get_default())) {
                     continue;
                 }
             } else {
                 $GLOBALS['REQUIRE_LANG_LOOP'] = 10;
                 // LEGACY Workaround for corrupt webhost installers
                 if (is_null(@eval($myrow['eval'] . ';'))) {
                     continue;
                 }
                 // @'d in case default is corrupt, don't want it to give errors forever
                 $GLOBALS['REQUIRE_LANG_LOOP'] = 0;
                 // LEGACY
             }
         }
         if ($myrow['shared_hosting_restricted'] == 1 && !is_null($GLOBALS['CURRENT_SHARE_USER'])) {
             continue;
         }
         if ($myrow['the_type'] == 'tick') {
             $value = strval(post_param_integer($myrow['the_name'], 0));
         } elseif ($myrow['the_type'] == 'date') {
             $date_value = get_input_date($myrow['the_name']);
             $value = is_null($date_value) ? '' : strval($date_value);
         } elseif (($myrow['the_type'] == 'forum' || $myrow['the_type'] == '?forum') && get_forum_type() == 'ocf') {
             $value = post_param($myrow['the_name']);
             if (is_numeric($value)) {
                 $value = $GLOBALS['FORUM_DB']->query_value_null_ok('f_forums', 'f_name', array('id' => post_param_integer($myrow['the_name'])));
             }
             if (is_null($value)) {
                 $value = '';
             }
         } elseif ($myrow['the_type'] == 'category' && get_forum_type() == 'ocf') {
             $value = post_param($myrow['the_name']);
             if (is_numeric($value)) {
                 $value = $GLOBALS['FORUM_DB']->query_value_null_ok('f_categories', 'c_title', array('id' => post_param_integer($myrow['the_name'])));
             }
             if (is_null($value)) {
                 $value = '';
             }
         } elseif ($myrow['the_type'] == 'usergroup' && get_forum_type() == 'ocf') {
             $value = $GLOBALS['FORUM_DB']->query_value_null_ok('f_groups g LEFT JOIN ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'translate t ON t.id=g.g_name', 'text_original', array('g.id' => post_param_integer($myrow['the_name'])));
             if (is_null($value)) {
                 $value = '';
             }
         } else {
             $value = post_param($myrow['the_name'], '');
         }
         if ($myrow['the_type'] == 'special') {
             if ($myrow['the_name'] == 'timezone') {
                 set_value('timezone', $value);
             }
         } else {
             if (($myrow['the_type'] == 'transline' || $myrow['the_type'] == 'transtext') && is_numeric($myrow['config_value'])) {
                 $old_value = get_translated_text(intval($myrow['config_value']));
             } else {
                 $old_value = $myrow['config_value'];
             }
             // If the option was changed
             if ($old_value != $value || $myrow['c_set'] == 0) {
                 set_option($myrow['the_name'], $value, $myrow['the_type'], $myrow['config_value']);
             }
         }
     }
     // Clear some cacheing
     require_code('view_modes');
     require_code('zones2');
     require_code('zones3');
     erase_comcode_page_cache();
     erase_tempcode_cache();
     //persistant_cache_delete('OPTIONS');  Done by set_option
     persistant_cache_empty();
     erase_cached_templates();
     // Show it worked / Refresh
     $redirect = get_param('redirect', NULL);
     if ($redirect === NULL) {
         $url = build_url(array('page' => '_SELF', 'type' => 'misc'), '_SELF');
         // ,'type'=>'category','id'=>$page
     } else {
         $url = make_string_tempcode($redirect);
     }
     return redirect_screen($title, $url, do_lang_tempcode('SUCCESS'));
 }
Exemplo n.º 19
0
 /**
  * Common theme change saving for adding and editing themes.
  *
  * @param  ID_TEXT			The name of the theme
  */
 function save_theme_changes($theme)
 {
     if (!file_exists(($theme == 'default' ? get_file_base() : get_custom_file_base()) . '/themes/' . filter_naughty($theme) . '/theme.ini')) {
         warn_exit(do_lang_tempcode('MISSING_RESOURCE'));
     }
     if (post_param_integer('use_on_all', 0) == 1) {
         $GLOBALS['SITE_DB']->query('UPDATE ' . get_table_prefix() . 'zones SET zone_theme=\'' . db_escape_string($theme) . '\' WHERE ' . db_string_not_equal_to('zone_name', 'cms') . ' AND ' . db_string_not_equal_to('zone_name', 'adminzone'));
     }
     persistant_cache_empty();
     $before = better_parse_ini_file(($theme == 'default' ? get_file_base() : get_custom_file_base()) . '/themes/' . filter_naughty($theme) . '/theme.ini');
     $myfile = @fopen(($theme == 'default' ? get_file_base() : get_custom_file_base()) . '/themes/' . filter_naughty($theme) . '/theme.ini', 'wt') or intelligent_write_error(get_custom_file_base() . '/themes/' . filter_naughty($theme) . '/theme.ini');
     if (fwrite($myfile, 'title=' . post_param('title') . chr(10)) == 0) {
         warn_exit(do_lang_tempcode('COULD_NOT_SAVE_FILE'));
     }
     if (fwrite($myfile, 'description=' . post_param('description') . chr(10)) == 0) {
         warn_exit(do_lang_tempcode('COULD_NOT_SAVE_FILE'));
     }
     foreach ($before as $key => $val) {
         if ($key != 'title' && $key != 'description' && $key != 'author' && $key != 'mobile_pages' && $key != 'supports_wide') {
             fwrite($myfile, $key . '=' . $val . chr(10));
         }
     }
     if (fwrite($myfile, 'author=' . post_param('author') . chr(10)) == 0) {
         warn_exit(do_lang_tempcode('COULD_NOT_SAVE_FILE'));
     }
     if (fwrite($myfile, 'mobile_pages=' . post_param('mobile_pages') . chr(10)) == 0) {
         warn_exit(do_lang_tempcode('COULD_NOT_SAVE_FILE'));
     }
     if (fwrite($myfile, 'supports_wide=' . strval(post_param_integer('supports_wide', 0)) . chr(10)) == 0) {
         warn_exit(do_lang_tempcode('COULD_NOT_SAVE_FILE'));
     }
     fclose($myfile);
     sync_file(($theme == 'default' ? get_file_base() : get_custom_file_base()) . '/themes/' . filter_naughty($theme) . '/theme.ini');
     require_code('permissions2');
     set_category_permissions_from_environment('theme', $theme);
     $map = file_exists(get_file_base() . '/themes/map.ini') ? better_parse_ini_file(get_file_base() . '/themes/map.ini') : array();
     $new_map = array();
     foreach ($map as $key => $val) {
         if ($val != $theme) {
             $new_map[$key] = $val;
         }
     }
     if (array_key_exists('mapping', $_POST)) {
         foreach ($_POST['mapping'] as $val) {
             if (get_magic_quotes_gpc()) {
                 $val = stripslashes($val);
             }
             $new_map[$val] = $theme;
         }
     }
     $myfile = @fopen(get_file_base() . '/themes/map.ini', 'wt') or intelligent_write_error(get_file_base() . '/themes/map.ini');
     foreach ($new_map as $key => $val) {
         if (fwrite($myfile, $key . '=' . $val . chr(10)) == 0) {
             warn_exit(do_lang_tempcode('COULD_NOT_SAVE_FILE'));
         }
     }
     fclose($myfile);
     sync_file('themes/map.ini');
 }
Exemplo n.º 20
0
 /**
  * The actualiser for managing redirects.
  *
  * @return tempcode		The UI
  */
 function actual()
 {
     $title = get_page_title('REDIRECTS');
     $found = array();
     foreach ($_POST as $key => $val) {
         if (!is_string($val)) {
             continue;
         }
         if (get_magic_quotes_gpc()) {
             $val = stripslashes($val);
         }
         if (substr($key, 0, 10) == 'from_page_' && $val != '') {
             $their_i = array_search($val, $found);
             $i = substr($key, 10);
             if ($their_i !== false && post_param('from_zone_' . $i) == post_param('from_zone_' . strval($their_i))) {
                 warn_exit(do_lang_tempcode('DUPLICATE_PAGE_REDIRECT', post_param('from_zone_' . $i) . ':' . $val));
             }
             $found[$i] = $val;
         }
     }
     $GLOBALS['SITE_DB']->query_delete('redirects');
     persistant_cache_empty();
     foreach ($found as $i => $val) {
         if (!is_string($i)) {
             $i = strval($i);
         }
         if ($val != '') {
             $GLOBALS['SITE_DB']->query_insert('redirects', array('r_from_page' => post_param('from_page_' . $i), 'r_from_zone' => post_param('from_zone_' . $i), 'r_to_page' => post_param('to_page_' . $i), 'r_to_zone' => post_param('to_zone_' . $i), 'r_is_transparent' => post_param_integer('is_transparent_' . $i, 0)), false, true);
             // Avoid problem when same key entered twice
         }
     }
     require_code('view_modes');
     erase_tempcode_cache();
     // Personal notes
     if (!is_null(post_param('notes', NULL))) {
         $notes = post_param('notes');
         set_long_value('notes', $notes);
     }
     // Redirect them back to editing screen
     $url = build_url(array('page' => '_SELF', 'type' => 'misc'), '_SELF');
     return redirect_screen($title, $url, do_lang_tempcode('SUCCESS'));
 }
Exemplo n.º 21
0
 /**
  * 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'));
 }