Skip to content

Commit

Permalink
Add some CYA cap checks.
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.automattic.com/wordpress/branches/2.8@11762 1a063a9b-81f0-0310-95a4-ce76da25c4cd
  • Loading branch information
ryan committed Aug 1, 2009
1 parent 0bdae51 commit 82fbf69
Show file tree
Hide file tree
Showing 11 changed files with 46 additions and 0 deletions.
3 changes: 3 additions & 0 deletions wp-admin/options-discussion.php
Expand Up @@ -9,6 +9,9 @@
/** WordPress Administration Bootstrap */
require_once('admin.php');

if ( ! current_user_can('manage_options') )
wp_die(__('You do not have sufficient permissions to manage options for this blog.'));

$title = __('Discussion Settings');
$parent_file = 'options-general.php';

Expand Down
3 changes: 3 additions & 0 deletions wp-admin/options-general.php
Expand Up @@ -9,6 +9,9 @@
/** WordPress Administration Bootstrap */
require_once('./admin.php');

if ( ! current_user_can('manage_options') )
wp_die(__('You do not have sufficient permissions to manage options for this blog.'));

$title = __('General Settings');
$parent_file = 'options-general.php';
/* translators: date and time format for exact current time, mainly about timezones, see http://php.net/date */
Expand Down
3 changes: 3 additions & 0 deletions wp-admin/options-media.php
Expand Up @@ -9,6 +9,9 @@
/** WordPress Administration Bootstrap */
require_once('admin.php');

if ( ! current_user_can('manage_options') )
wp_die(__('You do not have sufficient permissions to manage options for this blog.'));

$title = __('Media Settings');
$parent_file = 'options-general.php';

Expand Down
3 changes: 3 additions & 0 deletions wp-admin/options-misc.php
Expand Up @@ -9,6 +9,9 @@
/** WordPress Administration Bootstrap */
require_once('admin.php');

if ( ! current_user_can('manage_options') )
wp_die(__('You do not have sufficient permissions to manage options for this blog.'));

$title = __('Miscellaneous Settings');
$parent_file = 'options-general.php';

Expand Down
3 changes: 3 additions & 0 deletions wp-admin/options-permalink.php
Expand Up @@ -9,6 +9,9 @@
/** WordPress Administration Bootstrap */
require_once('admin.php');

if ( ! current_user_can('manage_options') )
wp_die(__('You do not have sufficient permissions to manage options for this blog.'));

$title = __('Permalink Settings');
$parent_file = 'options-general.php';

Expand Down
3 changes: 3 additions & 0 deletions wp-admin/options-privacy.php
Expand Up @@ -9,6 +9,9 @@
/** Load WordPress Administration Bootstrap */
require_once('./admin.php');

if ( ! current_user_can('manage_options') )
wp_die(__('You do not have sufficient permissions to manage options for this blog.'));

$title = __('Privacy Settings');
$parent_file = 'options-general.php';

Expand Down
3 changes: 3 additions & 0 deletions wp-admin/options-reading.php
Expand Up @@ -9,6 +9,9 @@
/** WordPress Administration Bootstrap */
require_once('admin.php');

if ( ! current_user_can('manage_options') )
wp_die(__('You do not have sufficient permissions to manage options for this blog.'));

$title = __('Reading Settings');
$parent_file = 'options-general.php';

Expand Down
3 changes: 3 additions & 0 deletions wp-admin/options-writing.php
Expand Up @@ -9,6 +9,9 @@
/** WordPress Administration Bootstrap */
require_once('admin.php');

if ( ! current_user_can('manage_options') )
wp_die(__('You do not have sufficient permissions to manage options for this blog.'));

$title = __('Writing Settings');
$parent_file = 'options-general.php';

Expand Down
18 changes: 18 additions & 0 deletions wp-admin/plugins.php
Expand Up @@ -9,6 +9,9 @@
/** WordPress Administration Bootstrap */
require_once('admin.php');

if ( ! current_user_can('activate_plugins') )
wp_die(__('You do not have sufficient permissions to manage plugins for this blog.'));

if ( isset($_POST['clear-recent-list']) )
$action = 'clear-recent-list';
elseif ( !empty($_REQUEST['action']) )
Expand Down Expand Up @@ -37,6 +40,9 @@
if ( !empty($action) ) {
switch ( $action ) {
case 'activate':
if ( ! current_user_can('activate_plugins') )
wp_die(__('You do not have sufficient permissions to activate plugins for this blog.'));

check_admin_referer('activate-plugin_' . $plugin);

$result = activate_plugin($plugin, 'plugins.php?error=true&plugin=' . $plugin);
Expand All @@ -53,6 +59,9 @@
exit;
break;
case 'activate-selected':
if ( ! current_user_can('activate_plugins') )
wp_die(__('You do not have sufficient permissions to activate plugins for this blog.'));

check_admin_referer('bulk-manage-plugins');

$plugins = (array) $_POST['checked'];
Expand All @@ -75,6 +84,9 @@
exit;
break;
case 'error_scrape':
if ( ! current_user_can('activate_plugins') )
wp_die(__('You do not have sufficient permissions to activate plugins for this blog.'));

check_admin_referer('plugin-activation-error_' . $plugin);

$valid = validate_plugin($plugin);
Expand All @@ -88,13 +100,19 @@
exit;
break;
case 'deactivate':
if ( ! current_user_can('activate_plugins') )
wp_die(__('You do not have sufficient permissions to deactivate plugins for this blog.'));

check_admin_referer('deactivate-plugin_' . $plugin);
deactivate_plugins($plugin);
update_option('recently_activated', array($plugin => time()) + (array)get_option('recently_activated'));
wp_redirect("plugins.php?deactivate=true&plugin_status=$status&paged=$page");
exit;
break;
case 'deactivate-selected':
if ( ! current_user_can('activate_plugins') )
wp_die(__('You do not have sufficient permissions to deactivate plugins for this blog.'));

check_admin_referer('bulk-manage-plugins');

$plugins = (array) $_POST['checked'];
Expand Down
3 changes: 3 additions & 0 deletions wp-admin/themes.php
Expand Up @@ -9,6 +9,9 @@
/** WordPress Administration Bootstrap */
require_once('admin.php');

if ( !current_user_can('switch_themes') )
wp_die( __( 'Cheatin’ uh?' ) );

if ( isset($_GET['action']) ) {
if ( 'activate' == $_GET['action'] ) {
check_admin_referer('switch-theme_' . $_GET['template']);
Expand Down
1 change: 1 addition & 0 deletions wp-includes/vars.php
Expand Up @@ -17,6 +17,7 @@
// wp-admin pages are checked more carefully
preg_match('#/wp-admin/?(.*?)$#i', $PHP_SELF, $self_matches);
$pagenow = $self_matches[1];
$pagenow = trim($pagenow, '/');
$pagenow = preg_replace('#\?.*?$#', '', $pagenow);
if ( '' === $pagenow || 'index' === $pagenow || 'index.php' === $pagenow ) {
$pagenow = 'index.php';
Expand Down

0 comments on commit 82fbf69

Please sign in to comment.