wp_reset_vars() from Sewar. fixes #2888

git-svn-id: http://svn.automattic.com/wordpress/trunk@3946 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2006-07-03 19:03:37 +00:00
parent 4de7f261cb
commit 55af15d623
16 changed files with 32 additions and 232 deletions

View File

@ -1953,4 +1953,20 @@ function get_udims($width, $height) {
return array((int) ($width / $height * 96), 96); return array((int) ($width / $height * 96), 96);
} }
function wp_reset_vars($vars) {
for ($i=0; $i<count($vars); $i += 1) {
$var = $vars[$i];
global $$var;
if (!isset($$var)) {
if (empty($_REQUEST["$var"])) {
$$var = '';
} else {
$$var = $_REQUEST["$var"];
unset($_REQUEST["$wpvar"]);
}
}
}
}
?> ?>

View File

@ -24,21 +24,7 @@ $what_to_show = get_settings('what_to_show');
$date_format = get_settings('date_format'); $date_format = get_settings('date_format');
$time_format = get_settings('time_format'); $time_format = get_settings('time_format');
$wpvarstoreset = array('profile','redirect','redirect_url','a','popuptitle','popupurl','text', 'trackback', 'pingback'); wp_reset_vars(array('profile', 'redirect', 'redirect_url', 'a', 'popuptitle', 'popupurl', 'text', 'trackback', 'pingback'));
for ($i=0; $i<count($wpvarstoreset); $i += 1) {
$wpvar = $wpvarstoreset[$i];
if (!isset($$wpvar)) {
if (empty($_POST["$wpvar"])) {
if (empty($_GET["$wpvar"])) {
$$wpvar = '';
} else {
$$wpvar = $_GET["$wpvar"];
}
} else {
$$wpvar = $_POST["$wpvar"];
}
}
}
wp_enqueue_script( 'fat' ); wp_enqueue_script( 'fat' );

View File

@ -4,21 +4,7 @@ require_once('admin.php');
$title = __('Categories'); $title = __('Categories');
$parent_file = 'edit.php'; $parent_file = 'edit.php';
$wpvarstoreset = array('action','cat'); wp_reset_vars(array('action', 'cat'));
for ($i=0; $i<count($wpvarstoreset); $i += 1) {
$wpvar = $wpvarstoreset[$i];
if (!isset($$wpvar)) {
if (empty($_POST["$wpvar"])) {
if (empty($_GET["$wpvar"])) {
$$wpvar = '';
} else {
$$wpvar = $_GET["$wpvar"];
}
} else {
$$wpvar = $_POST["$wpvar"];
}
}
}
switch($action) { switch($action) {

View File

@ -7,22 +7,7 @@ header('Content-Type: text/html; charset=' . get_option('blog_charset'));
if (!current_user_can('upload_files')) if (!current_user_can('upload_files'))
die(__('You do not have permission to upload files.')); die(__('You do not have permission to upload files.'));
$wpvarstoreset = array('action', 'post', 'all', 'last', 'link', 'sort', 'start', 'imgtitle', 'descr', 'attachment'); wp_reset_vars(array('action', 'post', 'all', 'last', 'link', 'sort', 'start', 'imgtitle', 'descr', 'attachment'));
for ($i=0; $i<count($wpvarstoreset); $i += 1) {
$wpvar = $wpvarstoreset[$i];
if (!isset($$wpvar)) {
if (empty($_POST["$wpvar"])) {
if (empty($_GET["$wpvar"])) {
$$wpvar = '';
} else {
$$wpvar = $_GET["$wpvar"];
}
} else {
$$wpvar = $_POST["$wpvar"];
}
}
}
$post = (int) $post; $post = (int) $post;
$images_width = 1; $images_width = 1;

View File

@ -6,24 +6,10 @@ $this_file = 'link-manager.php';
$parent_file = 'link-manager.php'; $parent_file = 'link-manager.php';
$wpvarstoreset = array('action', 'cat_id', 'linkurl', 'name', 'image', wp_reset_vars(array('action', 'cat_id', 'linkurl', 'name', 'image',
'description', 'visible', 'target', 'category', 'link_id', 'description', 'visible', 'target', 'category', 'link_id',
'submit', 'order_by', 'links_show_cat_id', 'rating', 'rel', 'submit', 'order_by', 'links_show_cat_id', 'rating', 'rel',
'notes', 'linkcheck[]'); 'notes', 'linkcheck[]'));
for ($i=0; $i<count($wpvarstoreset); $i += 1) {
$wpvar = $wpvarstoreset[$i];
if (!isset($$wpvar)) {
if (empty($_POST["$wpvar"])) {
if (empty($_GET["$wpvar"])) {
$$wpvar = '';
} else {
$$wpvar = $_GET["$wpvar"];
}
} else {
$$wpvar = $_POST["$wpvar"];
}
}
}
wp_enqueue_script( array('xfn', 'dbx-admin-key?pagenow=link.php') ); wp_enqueue_script( array('xfn', 'dbx-admin-key?pagenow=link.php') );
if ( current_user_can( 'manage_categories' ) ) if ( current_user_can( 'manage_categories' ) )

View File

@ -10,22 +10,7 @@ $title = __('Manage Bookmarks');
$this_file = $parent_file = 'link-manager.php'; $this_file = $parent_file = 'link-manager.php';
wp_enqueue_script( 'listman' ); wp_enqueue_script( 'listman' );
$wpvarstoreset = array ('action', 'cat_id', 'linkurl', 'name', 'image', 'description', 'visible', 'target', 'category', 'link_id', 'submit', 'order_by', 'links_show_cat_id', 'rating', 'rel', 'notes', 'linkcheck[]'); wp_reset_vars(array('action', 'cat_id', 'linkurl', 'name', 'image', 'description', 'visible', 'target', 'category', 'link_id', 'submit', 'order_by', 'links_show_cat_id', 'rating', 'rel', 'notes', 'linkcheck[]'));
for ($i = 0; $i < count($wpvarstoreset); $i += 1) {
$wpvar = $wpvarstoreset[$i];
if (!isset ($$wpvar)) {
if (empty ($_POST["$wpvar"])) {
if (empty ($_GET["$wpvar"])) {
$$wpvar = '';
} else {
$$wpvar = $_GET["$wpvar"];
}
} else {
$$wpvar = $_POST["$wpvar"];
}
}
}
if (empty ($cat_id)) if (empty ($cat_id))
$cat_id = 'all'; $cat_id = 'all';

View File

@ -1,22 +1,7 @@
<?php <?php
require_once ('admin.php'); require_once ('admin.php');
$wpvarstoreset = array ('action', 'cat_id', 'linkurl', 'name', 'image', 'description', 'visible', 'target', 'category', 'link_id', 'submit', 'order_by', 'links_show_cat_id', 'rating', 'rel', 'notes', 'linkcheck[]'); wp_reset_vars(array('action', 'cat_id', 'linkurl', 'name', 'image', 'description', 'visible', 'target', 'category', 'link_id', 'submit', 'order_by', 'links_show_cat_id', 'rating', 'rel', 'notes', 'linkcheck[]'));
for ($i = 0; $i < count($wpvarstoreset); $i += 1) {
$wpvar = $wpvarstoreset[$i];
if (!isset ($$wpvar)) {
if (empty ($_POST["$wpvar"])) {
if (empty ($_GET["$wpvar"])) {
$$wpvar = '';
} else {
$$wpvar = $_GET["$wpvar"];
}
} else {
$$wpvar = $_POST["$wpvar"];
}
}
}
if ('' != $_POST['deletebookmarks']) if ('' != $_POST['deletebookmarks'])
$action = 'deletebookmarks'; $action = 'deletebookmarks';

View File

@ -5,21 +5,7 @@ $title = __('Moderate comments');
$parent_file = 'edit.php'; $parent_file = 'edit.php';
wp_enqueue_script( 'admin-comments' ); wp_enqueue_script( 'admin-comments' );
$wpvarstoreset = array('action', 'item_ignored', 'item_deleted', 'item_approved', 'item_spam', 'feelinglucky'); wp_reset_vars(array('action', 'item_ignored', 'item_deleted', 'item_approved', 'item_spam', 'feelinglucky'));
for ($i=0; $i<count($wpvarstoreset); $i += 1) {
$wpvar = $wpvarstoreset[$i];
if (!isset($$wpvar)) {
if (empty($_POST["$wpvar"])) {
if (empty($_GET["$wpvar"])) {
$$wpvar = '';
} else {
$$wpvar = $_GET["$wpvar"];
}
} else {
$$wpvar = $_POST["$wpvar"];
}
}
}
$comment = array(); $comment = array();
if (isset($_POST["comment"])) { if (isset($_POST["comment"])) {

View File

@ -1,21 +1,4 @@
<?php <?php wp_reset_vars(array('action', 'standalone', 'option_group_id')); ?>
$wpvarstoreset = array('action','standalone', 'option_group_id');
for ($i=0; $i<count($wpvarstoreset); $i += 1) {
$wpvar = $wpvarstoreset[$i];
if (!isset($$wpvar)) {
if (empty($_POST["$wpvar"])) {
if (empty($_GET["$wpvar"])) {
$$wpvar = '';
} else {
$$wpvar = $_GET["$wpvar"];
}
} else {
$$wpvar = $_POST["$wpvar"];
}
}
}
?>
<br clear="all" /> <br clear="all" />

View File

@ -5,21 +5,7 @@ $title = __('Options');
$this_file = 'options.php'; $this_file = 'options.php';
$parent_file = 'options-general.php'; $parent_file = 'options-general.php';
$wpvarstoreset = array('action'); wp_reset_vars(array('action'));
for ($i=0; $i<count($wpvarstoreset); $i += 1) {
$wpvar = $wpvarstoreset[$i];
if (!isset($$wpvar)) {
if (empty($_POST["$wpvar"])) {
if (empty($_GET["$wpvar"])) {
$$wpvar = '';
} else {
$$wpvar = $_GET["$wpvar"];
}
} else {
$$wpvar = $_POST["$wpvar"];
}
}
}
if ( !current_user_can('manage_options') ) if ( !current_user_can('manage_options') )
die ( __('Cheatin&#8217; uh?') ); die ( __('Cheatin&#8217; uh?') );

View File

@ -3,22 +3,8 @@ require_once('admin.php');
$parent_file = 'edit.php'; $parent_file = 'edit.php';
$submenu_file = 'edit-pages.php'; $submenu_file = 'edit-pages.php';
$wpvarstoreset = array('action');
for ($i=0; $i<count($wpvarstoreset); $i += 1) { wp_reset_vars(array('action'));
$wpvar = $wpvarstoreset[$i];
if (!isset($$wpvar)) {
if (empty($_POST["$wpvar"])) {
if (empty($_GET["$wpvar"])) {
$$wpvar = '';
} else {
$$wpvar = $_GET["$wpvar"];
}
} else {
$$wpvar = $_POST["$wpvar"];
}
}
}
if (isset($_POST['deletepost'])) { if (isset($_POST['deletepost'])) {
$action = "delete"; $action = "delete";

View File

@ -4,21 +4,7 @@ require_once('admin.php');
$title = __("Edit Plugins"); $title = __("Edit Plugins");
$parent_file = 'plugins.php'; $parent_file = 'plugins.php';
$wpvarstoreset = array('action','redirect','profile','error','warning','a','file'); wp_reset_vars(array('action', 'redirect', 'profile', 'error', 'warning', 'a', 'file'));
for ($i=0; $i<count($wpvarstoreset); $i += 1) {
$wpvar = $wpvarstoreset[$i];
if (!isset($$wpvar)) {
if (empty($_POST["$wpvar"])) {
if (empty($_GET["$wpvar"])) {
$$wpvar = '';
} else {
$$wpvar = $_GET["$wpvar"];
}
} else {
$$wpvar = $_POST["$wpvar"];
}
}
}
$plugins = get_plugins(); $plugins = get_plugins();
$plugin_files = array_keys($plugins); $plugin_files = array_keys($plugins);

View File

@ -3,22 +3,8 @@ require_once('admin.php');
$parent_file = 'edit.php'; $parent_file = 'edit.php';
$submenu_file = 'edit.php'; $submenu_file = 'edit.php';
$wpvarstoreset = array('action', 'safe_mode', 'withcomments', 'posts', 'content', 'edited_post_title', 'comment_error', 'profile', 'trackback_url', 'excerpt', 'showcomments', 'commentstart', 'commentend', 'commentorder' );
for ($i=0; $i<count($wpvarstoreset); $i += 1) { wp_reset_vars(array('action', 'safe_mode', 'withcomments', 'posts', 'content', 'edited_post_title', 'comment_error', 'profile', 'trackback_url', 'excerpt', 'showcomments', 'commentstart', 'commentend', 'commentorder'));
$wpvar = $wpvarstoreset[$i];
if (!isset($$wpvar)) {
if (empty($_POST["$wpvar"])) {
if (empty($_GET["$wpvar"])) {
$$wpvar = '';
} else {
$$wpvar = $_GET["$wpvar"];
}
} else {
$$wpvar = $_POST["$wpvar"];
}
}
}
if ( isset( $_POST['deletepost'] ) ) if ( isset( $_POST['deletepost'] ) )
$action = 'delete'; $action = 'delete';

View File

@ -3,21 +3,7 @@ require_once('admin.php');
$title = __('Template &amp; File Editing'); $title = __('Template &amp; File Editing');
$parent_file = 'edit.php'; $parent_file = 'edit.php';
$wpvarstoreset = array('action','redirect','profile','error','warning','a','file'); wp_reset_vars(array('action', 'redirect', 'profile', 'error', 'warning', 'a', 'file'));
for ($i=0; $i<count($wpvarstoreset); $i += 1) {
$wpvar = $wpvarstoreset[$i];
if (!isset($$wpvar)) {
if (empty($_POST["$wpvar"])) {
if (empty($_GET["$wpvar"])) {
$$wpvar = '';
} else {
$$wpvar = $_GET["$wpvar"];
}
} else {
$$wpvar = $_POST["$wpvar"];
}
}
}
$recents = get_option('recently_edited'); $recents = get_option('recently_edited');

View File

@ -4,21 +4,7 @@ require_once('admin.php');
$title = __("Edit Themes"); $title = __("Edit Themes");
$parent_file = 'themes.php'; $parent_file = 'themes.php';
$wpvarstoreset = array('action','redirect','profile','error','warning','a','file', 'theme'); wp_reset_vars(array('action', 'redirect', 'profile', 'error', 'warning', 'a', 'file', 'theme'));
for ($i=0; $i<count($wpvarstoreset); $i += 1) {
$wpvar = $wpvarstoreset[$i];
if (!isset($$wpvar)) {
if (empty($_POST["$wpvar"])) {
if (empty($_GET["$wpvar"])) {
$$wpvar = '';
} else {
$$wpvar = $_GET["$wpvar"];
}
} else {
$$wpvar = $_POST["$wpvar"];
}
}
}
$themes = get_themes(); $themes = get_themes();

View File

@ -8,21 +8,7 @@ else
$parent_file = 'profile.php'; $parent_file = 'profile.php';
$submenu_file = 'users.php'; $submenu_file = 'users.php';
$wpvarstoreset = array('action', 'redirect', 'profile', 'user_id', 'wp_http_referer'); wp_reset_vars(array('action', 'redirect', 'profile', 'user_id', 'wp_http_referer'));
for ($i=0; $i<count($wpvarstoreset); $i += 1) {
$wpvar = $wpvarstoreset[$i];
if (!isset($$wpvar)) {
if (empty($_POST["$wpvar"])) {
if (empty($_GET["$wpvar"])) {
$$wpvar = '';
} else {
$$wpvar = $_GET["$wpvar"];
}
} else {
$$wpvar = $_POST["$wpvar"];
}
}
}
$wp_http_referer = remove_query_arg(array('update', 'delete_count'), stripslashes($wp_http_referer)); $wp_http_referer = remove_query_arg(array('update', 'delete_count'), stripslashes($wp_http_referer));