Make WordPress Core

Changeset 1810


Ignore:
Timestamp:
10/18/2004 04:50:08 AM (20 years ago)
Author:
rboren
Message:

Do not stomp permalink setting. Bug 372.

Location:
trunk/wp-admin
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/admin-functions.php

    r1792 r1810  
    623623}
    624624
     625function user_can_access_admin_page() {
     626    global $parent_file;
     627    global $pagenow;
     628    global $menu;
     629    global $submenu;
     630    global $user_level;
     631
     632    if (! isset($parent_file)) {
     633        $parent = $pagenow;
     634    } else {
     635        $parent = $parent_file;
     636    }
     637
     638    foreach ($menu as $menu_array) {
     639        //echo "parent array: " . $menu_array[2];
     640        if ($menu_array[2] == $parent) {
     641            if ($user_level < $menu_array[1]) {
     642                return false;
     643            } else {
     644                break;
     645            }
     646        }
     647    }
     648
     649    if (isset($submenu[$parent])) {
     650        foreach ($submenu[$parent] as $submenu_array) {
     651            if ($submenu_array[2] == $pagenow) {
     652                if ($user_level < $submenu_array[1]) {
     653                    return false;
     654                } else {
     655                    return true;
     656                }
     657            }
     658        }
     659    }
     660   
     661    return true;
     662}
     663
     664function add_options_menu($title, $access_level, $file) {
     665    global $submenu;
     666   
     667    $submenu['options-general.php'][] = array($title, $access_level, $file);
     668}
     669
    625670?>
  • trunk/wp-admin/admin-header.php

    r1743 r1810  
    11<?php
    22
    3 require_once('../wp-config.php');
     3if (strstr($_SERVER['PHP_SELF'], 'plugins/')) {
     4    $wp_admin_path = '../../wp-admin/';
     5    $wp_path = '../../';
     6} else {
     7    $wp_admin_path = './';
     8    $wp_path = '../';
     9}
     10
     11require_once($wp_path . 'wp-config.php');
     12
    413require_once(ABSPATH . '/wp-admin/auth.php');
    514require(ABSPATH . '/wp-admin/admin-functions.php');
     
    3948<head>
    4049<title><?php bloginfo('name') ?> &rsaquo; <?php echo $title; ?> &#8212; WordPress</title>
    41 <link rel="stylesheet" href="wp-admin.css" type="text/css" />
    42 <link rel="shortcut icon" href="../wp-images/wp-favicon.png" />
     50<link rel="stylesheet" href="<?php echo $wp_admin_path; ?>wp-admin.css" type="text/css" />
     51<link rel="shortcut icon" href="<?php echo $wp_path; ?>wp-images/wp-favicon.png" />
    4352<meta http-equiv="Content-Type" content="text/html; charset=<?php echo get_settings('blog_charset'); ?>" />
    4453
     
    111120
    112121<?php
    113 require('./menu.php');
     122require(ABSPATH . '/wp-admin/menu.php');
    114123endif;
    115124?>
  • trunk/wp-admin/auth.php

    r1807 r1810  
    11<?php
    2 require_once('../wp-config.php');
     2require_once(ABSPATH . '/wp-config.php');
    33
    44if ( (!empty($_COOKIE['wordpressuser_' . COOKIEHASH]) && !wp_login($_COOKIE['wordpressuser_' . COOKIEHASH], $_COOKIE['wordpresspass_' . COOKIEHASH], true))
  • trunk/wp-admin/menu.php

    r1703 r1810  
    4444$submenu['themes.php'][15] = array(__('Other Files'), 5, 'templates.php');
    4545
    46 $self = preg_replace('|.*/wp-admin/|i', '', $_SERVER['PHP_SELF']);
     46do_action('admin_menu', '');
     47
     48if (! user_can_access_admin_page()) {
     49    die( __('You have do not have sufficient permissions to access this page.') );
     50}
     51
     52$self = preg_replace('|^.*/wp-admin/|i', '', $_SERVER['PHP_SELF']);
     53$self = preg_replace('|^.*/plugins/|i', '', $self);
     54
    4755if (!isset($parent_file)) $parent_file = '';
    4856foreach ($menu as $item) {
     
    5866($user_level >= get_settings('fileupload_minlevel'))
    5967             ) || 'upload.php' != $item[2])
    60             echo "\n\t<li><a href='{$item[2]}'$class>{$item[0]}</a></li>";
     68                    echo "\n\t<li><a href='" . get_settings('siteurl') . "/wp-admin/{$item[2]}'$class>{$item[0]}</a></li>";
    6169    }
    6270}
     
    7482<?php
    7583foreach ($submenu["$parent_file"] as $item) :
     84     if ($user_level < $item[1]) {
     85         continue;
     86     }
     87
    7688    if ( substr($self, -10) == substr($item[2], -10) ) $class = ' class="current"';
    7789    else $class = '';
    78     echo "\n\t<li><a href='{$item[2]}'$class>{$item[0]}</a></li>";
     90    echo "\n\t<li><a href='" . get_settings('siteurl') . "/wp-admin/{$item[2]}'$class>{$item[0]}</a></li>";
    7991endforeach;
    8092?>
  • trunk/wp-admin/options-discussion.php

    r1737 r1810  
    33
    44$title = __('Discussion Options');
    5 $parent_file = 'options-general.php';
    6 
    7 function add_magic_quotes($array) {
    8     foreach ($array as $k => $v) {
    9         if (is_array($v)) {
    10             $array[$k] = add_magic_quotes($v);
    11         } else {
    12             $array[$k] = addslashes($v);
    13         }
    14     }
    15     return $array;
    16 }
    17 
    18 if (!get_magic_quotes_gpc()) {
    19     $_GET    = add_magic_quotes($_GET);
    20     $_POST   = add_magic_quotes($_POST);
    21     $_COOKIE = add_magic_quotes($_COOKIE);
    22 }
    23 
    24 $wpvarstoreset = array('action','standalone', 'option_group_id');
    25 for ($i=0; $i<count($wpvarstoreset); $i += 1) {
    26     $wpvar = $wpvarstoreset[$i];
    27     if (!isset($$wpvar)) {
    28         if (empty($_POST["$wpvar"])) {
    29             if (empty($_GET["$wpvar"])) {
    30                 $$wpvar = '';
    31             } else {
    32                 $$wpvar = $_GET["$wpvar"];
    33             }
    34         } else {
    35             $$wpvar = $_POST["$wpvar"];
    36         }
    37     }
    38 }
    39 
    40 $standalone = 0;
    41 include_once('admin-header.php');
    425include('options-head.php');
    436
  • trunk/wp-admin/options-general.php

    r1656 r1810  
    33
    44$title = __('General Options');
    5 $parent_file = 'options-general.php';
    65
    7 function add_magic_quotes($array) {
    8     foreach ($array as $k => $v) {
    9         if (is_array($v)) {
    10             $array[$k] = add_magic_quotes($v);
    11         } else {
    12             $array[$k] = addslashes($v);
    13         }
    14     }
    15     return $array;
    16 }
    17 
    18 if (!get_magic_quotes_gpc()) {
    19     $_GET    = add_magic_quotes($_GET);
    20     $_POST   = add_magic_quotes($_POST);
    21     $_COOKIE = add_magic_quotes($_COOKIE);
    22 }
    23 
    24 $wpvarstoreset = array('action','standalone', 'option_group_id');
    25 for ($i=0; $i<count($wpvarstoreset); $i += 1) {
    26     $wpvar = $wpvarstoreset[$i];
    27     if (!isset($$wpvar)) {
    28         if (empty($_POST["$wpvar"])) {
    29             if (empty($_GET["$wpvar"])) {
    30                 $$wpvar = '';
    31             } else {
    32                 $$wpvar = $_GET["$wpvar"];
    33             }
    34         } else {
    35             $$wpvar = $_POST["$wpvar"];
    36         }
    37     }
    38 }
    39 
    40 
    41 $standalone = 0;
    42 include_once('admin-header.php');
    436include('options-head.php');
    447?>
  • trunk/wp-admin/options-head.php

    r1596 r1810  
    11<?php
    22
    3 if ($user_level <= 6) {
    4     die( __('You have do not have sufficient permissions to edit the options for this blog.') );
     3$parent_file = 'options-general.php';
     4
     5function add_magic_quotes($array) {
     6    foreach ($array as $k => $v) {
     7        if (is_array($v)) {
     8            $array[$k] = add_magic_quotes($v);
     9        } else {
     10            $array[$k] = addslashes($v);
     11        }
     12    }
     13    return $array;
    514}
     15
     16if (!get_magic_quotes_gpc()) {
     17    $_GET    = add_magic_quotes($_GET);
     18    $_POST   = add_magic_quotes($_POST);
     19    $_COOKIE = add_magic_quotes($_COOKIE);
     20}
     21
     22$wpvarstoreset = array('action','standalone', 'option_group_id');
     23for ($i=0; $i<count($wpvarstoreset); $i += 1) {
     24    $wpvar = $wpvarstoreset[$i];
     25    if (!isset($$wpvar)) {
     26        if (empty($_POST["$wpvar"])) {
     27            if (empty($_GET["$wpvar"])) {
     28                $$wpvar = '';
     29            } else {
     30                $$wpvar = $_GET["$wpvar"];
     31            }
     32        } else {
     33            $$wpvar = $_POST["$wpvar"];
     34        }
     35    }
     36}
     37
     38$standalone = 0;
     39include_once('admin-header.php');
    640?>
    741
  • trunk/wp-admin/options-misc.php

    r1664 r1810  
    33
    44$title = __('Miscellaneous Options');
    5 $parent_file = 'options-general.php';
    6 
    7 function add_magic_quotes($array) {
    8     foreach ($array as $k => $v) {
    9         if (is_array($v)) {
    10             $array[$k] = add_magic_quotes($v);
    11         } else {
    12             $array[$k] = addslashes($v);
    13         }
    14     }
    15     return $array;
    16 }
    17 
    18 if (!get_magic_quotes_gpc()) {
    19     $_GET    = add_magic_quotes($_GET);
    20     $_POST   = add_magic_quotes($_POST);
    21     $_COOKIE = add_magic_quotes($_COOKIE);
    22 }
    23 
    24 $wpvarstoreset = array('action','standalone');
    25 for ($i=0; $i<count($wpvarstoreset); $i += 1) {
    26     $wpvar = $wpvarstoreset[$i];
    27     if (!isset($$wpvar)) {
    28         if (empty($_POST["$wpvar"])) {
    29             if (empty($_GET["$wpvar"])) {
    30                 $$wpvar = '';
    31             } else {
    32                 $$wpvar = $_GET["$wpvar"];
    33             }
    34         } else {
    35             $$wpvar = $_POST["$wpvar"];
    36         }
    37     }
    38 }
    39 
    40 
    41 $standalone = 0;
    42 include_once('admin-header.php');
    435include('options-head.php');
    446?>
  • trunk/wp-admin/options-permalink.php

    r1798 r1810  
    77require_once('./admin-header.php');
    88if ($user_level <= 8)
    9     die(__('You have do not have sufficient permissions to edit the options for this blog.'));
     9    die(__('You have do not have sufficient permissions to edit the options
     10for this blog.'));
    1011
    1112require('./options-head.php');
     
    2223
    2324if ( isset($_POST) ) {
    24     if ( $_POST['permalink_structure'] )
    25         $permalink_structure = preg_replace('#/+#', '/', '/' . $_POST['permalink_structure']);
    26     else
     25    if ( isset($_POST['permalink_structure']) ) {
    2726        $permalink_structure = $_POST['permalink_structure'];
     27        if (! empty($permalink_structure) )
     28            $permalink_structure = preg_replace('#/+#', '/', '/' . $_POST['permalink_structure']);
     29        update_option('permalink_structure', $permalink_structure);
     30    }
    2831   
    29     if ( $_POST['category_base'] )
    30         $category_base = preg_replace('#/+#', '/', '/' . $_POST['category_base']);
    31     else
     32    if ( isset($_POST['category_base']) ) {
    3233        $category_base = $_POST['category_base'];
     34        if (! empty($category_base) )
     35            $category_base = preg_replace('#/+#', '/', '/' . $_POST['category_base']);
     36        update_option('category_base', $category_base);
     37    }
     38}
    3339   
    34     update_option('permalink_structure', $permalink_structure);
    35     update_option('category_base', $category_base);
    36 }
    37 
    3840$permalink_structure = get_settings('permalink_structure');
    3941$category_base = get_settings('category_base');
  • trunk/wp-admin/options-reading.php

    r1599 r1810  
    33
    44$title = __('Reading Options');
    5 $parent_file = 'options-general.php';
    6 
    7 function add_magic_quotes($array) {
    8     foreach ($array as $k => $v) {
    9         if (is_array($v)) {
    10             $array[$k] = add_magic_quotes($v);
    11         } else {
    12             $array[$k] = addslashes($v);
    13         }
    14     }
    15     return $array;
    16 }
    17 
    18 if (!get_magic_quotes_gpc()) {
    19     $_GET    = add_magic_quotes($_GET);
    20     $_POST   = add_magic_quotes($_POST);
    21     $_COOKIE = add_magic_quotes($_COOKIE);
    22 }
    23 
    24 $wpvarstoreset = array('action','standalone', 'option_group_id');
    25 for ($i=0; $i<count($wpvarstoreset); $i += 1) {
    26     $wpvar = $wpvarstoreset[$i];
    27     if (!isset($$wpvar)) {
    28         if (empty($_POST["$wpvar"])) {
    29             if (empty($_GET["$wpvar"])) {
    30                 $$wpvar = '';
    31             } else {
    32                 $$wpvar = $_GET["$wpvar"];
    33             }
    34         } else {
    35             $$wpvar = $_POST["$wpvar"];
    36         }
    37     }
    38 }
    39 
    40 $standalone = 0;
    41 include_once('admin-header.php');
    425include('options-head.php');
    436?>
  • trunk/wp-admin/options-writing.php

    r1664 r1810  
    33
    44$title = __('Writing Options');
    5 $parent_file = 'options-general.php';
    6 
    7 $standalone = 0;
    8 include_once('./admin-header.php');
    95include('./options-head.php');
    106?>
Note: See TracChangeset for help on using the changeset viewer.