Make WordPress Core

Ticket #2888: wp_reset_vars.diff

File wp_reset_vars.diff, 15.2 KB (added by Sewar, 20 years ago)
  • Sewar/WordPress/SVN/wp-admin/admin-functions.php

     
    19531953                return array((int) ($width / $height * 96), 96);
    19541954}
    19551955
     1956function wp_reset_vars($vars) {
     1957        for ($i=0; $i<count($vars); $i += 1) {
     1958                $var = $vars[$i];
     1959                global $$var;
     1960
     1961                if (!isset($$var)) {
     1962                        if (empty($_REQUEST["$var"])) {
     1963                                $$var = '';
     1964                        } else {
     1965                                $$var = $_REQUEST["$var"];
     1966                                unset($_REQUEST["$wpvar"]);
     1967                        }
     1968                }
     1969        }
     1970}
     1971
    19561972?>
  • Sewar/WordPress/SVN/wp-admin/admin.php

     
    2424$date_format = get_settings('date_format');
    2525$time_format = get_settings('time_format');
    2626
    27 $wpvarstoreset = array('profile','redirect','redirect_url','a','popuptitle','popupurl','text', 'trackback', 'pingback');
    28 for ($i=0; $i<count($wpvarstoreset); $i += 1) {
    29     $wpvar = $wpvarstoreset[$i];
    30     if (!isset($$wpvar)) {
    31         if (empty($_POST["$wpvar"])) {
    32             if (empty($_GET["$wpvar"])) {
    33                 $$wpvar = '';
    34             } else {
    35                 $$wpvar = $_GET["$wpvar"];
    36             }
    37         } else {
    38             $$wpvar = $_POST["$wpvar"];
    39         }
    40     }
    41 }
     27wp_reset_vars(array('profile', 'redirect', 'redirect_url', 'a', 'popuptitle', 'popupurl', 'text', 'trackback', 'pingback'));
    4228
    4329wp_enqueue_script( 'fat' );
    4430
  • Sewar/WordPress/SVN/wp-admin/categories.php

     
    44$title = __('Categories');
    55$parent_file = 'edit.php';
    66
    7 $wpvarstoreset = array('action','cat');
    8 for ($i=0; $i<count($wpvarstoreset); $i += 1) {
    9     $wpvar = $wpvarstoreset[$i];
    10     if (!isset($$wpvar)) {
    11         if (empty($_POST["$wpvar"])) {
    12             if (empty($_GET["$wpvar"])) {
    13                 $$wpvar = '';
    14             } else {
    15                 $$wpvar = $_GET["$wpvar"];
    16             }
    17         } else {
    18             $$wpvar = $_POST["$wpvar"];
    19         }
    20     }
    21 }
     7wp_reset_vars(array('action', 'cat'));
    228
    239switch($action) {
    2410
  • Sewar/WordPress/SVN/wp-admin/comment.php

     
    33
    44$parent_file = 'edit.php';
    55$submenu_file = 'edit-comments.php';
    6 $wpvarstoreset = array('action');
    76
    8 for ($i=0; $i<count($wpvarstoreset); $i += 1) {
    9         $wpvar = $wpvarstoreset[$i];
    10         if (!isset($$wpvar)) {
    11                 if (empty($_POST["$wpvar"])) {
    12                         if (empty($_GET["$wpvar"])) {
    13                                 $$wpvar = '';
    14                         } else {
    15                         $$wpvar = $_GET["$wpvar"];
    16                         }
    17                 } else {
    18                         $$wpvar = $_POST["$wpvar"];
    19                 }
    20         }
    21 }
     7wp_reset_vars(array('action'));
    228
    239if ( isset( $_POST['deletecomment'] ) )
    2410        $action = 'deletecomment';
  • Sewar/WordPress/SVN/wp-admin/inline-uploading.php

     
    77if (!current_user_can('upload_files'))
    88        die(__('You do not have permission to upload files.'));
    99
    10 $wpvarstoreset = array('action', 'post', 'all', 'last', 'link', 'sort', 'start', 'imgtitle', 'descr', 'attachment');
     10wp_reset_vars(array('action', 'post', 'all', 'last', 'link', 'sort', 'start', 'imgtitle', 'descr', 'attachment'));
    1111
    12 for ($i=0; $i<count($wpvarstoreset); $i += 1) {
    13         $wpvar = $wpvarstoreset[$i];
    14         if (!isset($$wpvar)) {
    15                 if (empty($_POST["$wpvar"])) {
    16                         if (empty($_GET["$wpvar"])) {
    17                                 $$wpvar = '';
    18                         } else {
    19                         $$wpvar = $_GET["$wpvar"];
    20                         }
    21                 } else {
    22                         $$wpvar = $_POST["$wpvar"];
    23                 }
    24         }
    25 }
    26 
    2712$post = (int) $post;
    2813$images_width = 1;
    2914
  • Sewar/WordPress/SVN/wp-admin/link-add.php

     
    66$parent_file = 'link-manager.php';
    77
    88
    9 $wpvarstoreset = array('action', 'cat_id', 'linkurl', 'name', 'image',
     9wp_reset_vars(array('action', 'cat_id', 'linkurl', 'name', 'image',
    1010                       'description', 'visible', 'target', 'category', 'link_id',
    1111                       'submit', 'order_by', 'links_show_cat_id', 'rating', 'rel',
    12                        'notes', 'linkcheck[]');
    13 for ($i=0; $i<count($wpvarstoreset); $i += 1) {
    14     $wpvar = $wpvarstoreset[$i];
    15     if (!isset($$wpvar)) {
    16         if (empty($_POST["$wpvar"])) {
    17             if (empty($_GET["$wpvar"])) {
    18                 $$wpvar = '';
    19             } else {
    20                 $$wpvar = $_GET["$wpvar"];
    21             }
    22         } else {
    23             $$wpvar = $_POST["$wpvar"];
    24         }
    25     }
    26 }
     12                       'notes', 'linkcheck[]'));
    2713
    2814wp_enqueue_script( array('xfn', 'dbx-admin-key?pagenow=link.php') );
    2915if ( current_user_can( 'manage_categories' ) )
  • Sewar/WordPress/SVN/wp-admin/link-manager.php

     
    1010$this_file = $parent_file = 'link-manager.php';
    1111wp_enqueue_script( 'listman' );
    1212
    13 $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[]');
     13wp_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[]'));
    1414
    15 for ($i = 0; $i < count($wpvarstoreset); $i += 1) {
    16         $wpvar = $wpvarstoreset[$i];
    17         if (!isset ($$wpvar)) {
    18                 if (empty ($_POST["$wpvar"])) {
    19                         if (empty ($_GET["$wpvar"])) {
    20                                 $$wpvar = '';
    21                         } else {
    22                                 $$wpvar = $_GET["$wpvar"];
    23                         }
    24                 } else {
    25                         $$wpvar = $_POST["$wpvar"];
    26                 }
    27         }
    28 }
    29 
    3015if (empty ($cat_id))
    3116        $cat_id = 'all';
    3217
  • Sewar/WordPress/SVN/wp-admin/link.php

     
    11<?php
    22require_once ('admin.php');
    33
    4 $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[]');
     4wp_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[]'));
    55
    6 for ($i = 0; $i < count($wpvarstoreset); $i += 1) {
    7         $wpvar = $wpvarstoreset[$i];
    8         if (!isset ($$wpvar)) {
    9                 if (empty ($_POST["$wpvar"])) {
    10                         if (empty ($_GET["$wpvar"])) {
    11                                 $$wpvar = '';
    12                         } else {
    13                                 $$wpvar = $_GET["$wpvar"];
    14                         }
    15                 } else {
    16                         $$wpvar = $_POST["$wpvar"];
    17                 }
    18         }
    19 }
    20 
    216if ('' != $_POST['deletebookmarks'])
    227        $action = 'deletebookmarks';
    238if ('' != $_POST['move'])
  • Sewar/WordPress/SVN/wp-admin/moderation.php

     
    55$parent_file = 'edit.php';
    66wp_enqueue_script( 'admin-comments' );
    77
    8 $wpvarstoreset = array('action', 'item_ignored', 'item_deleted', 'item_approved', 'item_spam', 'feelinglucky');
    9 for ($i=0; $i<count($wpvarstoreset); $i += 1) {
    10         $wpvar = $wpvarstoreset[$i];
    11         if (!isset($$wpvar)) {
    12                 if (empty($_POST["$wpvar"])) {
    13                         if (empty($_GET["$wpvar"])) {
    14                                 $$wpvar = '';
    15                         } else {
    16                                 $$wpvar = $_GET["$wpvar"];
    17                         }
    18                 } else {
    19                         $$wpvar = $_POST["$wpvar"];
    20                 }
    21         }
    22 }
     8wp_reset_vars(array('action', 'item_ignored', 'item_deleted', 'item_approved', 'item_spam', 'feelinglucky'));
    239
    2410$comment = array();
    2511if (isset($_POST["comment"])) {
  • Sewar/WordPress/SVN/wp-admin/options-head.php

     
    1 <?php
     1<?php wp_reset_vars(array('action', 'standalone', 'option_group_id')); ?>
    22
    3 $wpvarstoreset = array('action','standalone', 'option_group_id');
    4 for ($i=0; $i<count($wpvarstoreset); $i += 1) {
    5         $wpvar = $wpvarstoreset[$i];
    6         if (!isset($$wpvar)) {
    7                 if (empty($_POST["$wpvar"])) {
    8                         if (empty($_GET["$wpvar"])) {
    9                                 $$wpvar = '';
    10                         } else {
    11                                 $$wpvar = $_GET["$wpvar"];
    12                         }
    13                 } else {
    14                         $$wpvar = $_POST["$wpvar"];
    15                 }
    16         }
    17 }
    18 ?>
    19 
    203<br clear="all" />
    214
    225<?php if (isset($_GET['updated'])) : ?>
  • Sewar/WordPress/SVN/wp-admin/options.php

     
    55$this_file = 'options.php';
    66$parent_file = 'options-general.php';
    77
    8 $wpvarstoreset = array('action');
    9 for ($i=0; $i<count($wpvarstoreset); $i += 1) {
    10         $wpvar = $wpvarstoreset[$i];
    11         if (!isset($$wpvar)) {
    12                 if (empty($_POST["$wpvar"])) {
    13                         if (empty($_GET["$wpvar"])) {
    14                                 $$wpvar = '';
    15                         } else {
    16                                 $$wpvar = $_GET["$wpvar"];
    17                         }
    18                 } else {
    19                         $$wpvar = $_POST["$wpvar"];
    20                 }
    21         }
    22 }
     8wp_reset_vars(array('action'));
    239
    2410if ( !current_user_can('manage_options') )
    2511        die ( __('Cheatin&#8217; uh?') );
  • Sewar/WordPress/SVN/wp-admin/page.php

     
    33
    44$parent_file = 'edit.php';
    55$submenu_file = 'edit-pages.php';
    6 $wpvarstoreset = array('action');
    76
    8 for ($i=0; $i<count($wpvarstoreset); $i += 1) {
    9         $wpvar = $wpvarstoreset[$i];
    10         if (!isset($$wpvar)) {
    11                 if (empty($_POST["$wpvar"])) {
    12                         if (empty($_GET["$wpvar"])) {
    13                                 $$wpvar = '';
    14                         } else {
    15                         $$wpvar = $_GET["$wpvar"];
    16                         }
    17                 } else {
    18                         $$wpvar = $_POST["$wpvar"];
    19                 }
    20         }
    21 }
     7wp_reset_vars(array('action'));
    228
    239if (isset($_POST['deletepost'])) {
    2410$action = "delete";
  • Sewar/WordPress/SVN/wp-admin/plugin-editor.php

     
    44$title = __("Edit Plugins");
    55$parent_file = 'plugins.php';
    66
    7 $wpvarstoreset = array('action','redirect','profile','error','warning','a','file');
    8 for ($i=0; $i<count($wpvarstoreset); $i += 1) {
    9         $wpvar = $wpvarstoreset[$i];
    10         if (!isset($$wpvar)) {
    11                 if (empty($_POST["$wpvar"])) {
    12                         if (empty($_GET["$wpvar"])) {
    13                                 $$wpvar = '';
    14                         } else {
    15                                 $$wpvar = $_GET["$wpvar"];
    16                         }
    17                 } else {
    18                         $$wpvar = $_POST["$wpvar"];
    19                 }
    20         }
    21 }
     7wp_reset_vars(array('action', 'redirect', 'profile', 'error', 'warning', 'a', 'file'));
    228
    239$plugins = get_plugins();
    2410$plugin_files = array_keys($plugins);
  • Sewar/WordPress/SVN/wp-admin/post.php

     
    33
    44$parent_file = 'edit.php';
    55$submenu_file = 'edit.php';
    6 $wpvarstoreset = array('action', 'safe_mode', 'withcomments', 'posts', 'content', 'edited_post_title', 'comment_error', 'profile', 'trackback_url', 'excerpt', 'showcomments', 'commentstart', 'commentend', 'commentorder' );
    76
    8 for ($i=0; $i<count($wpvarstoreset); $i += 1) {
    9         $wpvar = $wpvarstoreset[$i];
    10         if (!isset($$wpvar)) {
    11                 if (empty($_POST["$wpvar"])) {
    12                         if (empty($_GET["$wpvar"])) {
    13                                 $$wpvar = '';
    14                         } else {
    15                         $$wpvar = $_GET["$wpvar"];
    16                         }
    17                 } else {
    18                         $$wpvar = $_POST["$wpvar"];
    19                 }
    20         }
    21 }
     7wp_reset_vars(array('action', 'safe_mode', 'withcomments', 'posts', 'content', 'edited_post_title', 'comment_error', 'profile', 'trackback_url', 'excerpt', 'showcomments', 'commentstart', 'commentend', 'commentorder'));
    228
    239if ( isset( $_POST['deletepost'] ) )
    2410        $action = 'delete';
  • Sewar/WordPress/SVN/wp-admin/templates.php

     
    33$title = __('Template &amp; File Editing');
    44$parent_file =  'edit.php';
    55
    6 $wpvarstoreset = array('action','redirect','profile','error','warning','a','file');
    7 for ($i=0; $i<count($wpvarstoreset); $i += 1) {
    8         $wpvar = $wpvarstoreset[$i];
    9         if (!isset($$wpvar)) {
    10                 if (empty($_POST["$wpvar"])) {
    11                         if (empty($_GET["$wpvar"])) {
    12                                 $$wpvar = '';
    13                         } else {
    14                                 $$wpvar = $_GET["$wpvar"];
    15                         }
    16                 } else {
    17                         $$wpvar = $_POST["$wpvar"];
    18                 }
    19         }
    20 }
     6wp_reset_vars(array('action', 'redirect', 'profile', 'error', 'warning', 'a', 'file'));
    217
    228$recents = get_option('recently_edited');
    239
  • Sewar/WordPress/SVN/wp-admin/theme-editor.php

     
    44$title = __("Edit Themes");
    55$parent_file = 'themes.php';
    66
    7 $wpvarstoreset = array('action','redirect','profile','error','warning','a','file', 'theme');
    8 for ($i=0; $i<count($wpvarstoreset); $i += 1) {
    9         $wpvar = $wpvarstoreset[$i];
    10         if (!isset($$wpvar)) {
    11                 if (empty($_POST["$wpvar"])) {
    12                         if (empty($_GET["$wpvar"])) {
    13                                 $$wpvar = '';
    14                         } else {
    15                                 $$wpvar = $_GET["$wpvar"];
    16                         }
    17                 } else {
    18                         $$wpvar = $_POST["$wpvar"];
    19                 }
    20         }
    21 }
     7wp_reset_vars(array('action', 'redirect', 'profile', 'error', 'warning', 'a', 'file', 'theme'));
    228
    239$themes = get_themes();
    2410
  • Sewar/WordPress/SVN/wp-admin/user-edit.php

     
    88        $parent_file = 'profile.php';
    99$submenu_file = 'users.php';
    1010
    11 $wpvarstoreset = array('action', 'redirect', 'profile', 'user_id', 'wp_http_referer');
    12 for ($i=0; $i<count($wpvarstoreset); $i += 1) {
    13         $wpvar = $wpvarstoreset[$i];
    14         if (!isset($$wpvar)) {
    15                 if (empty($_POST["$wpvar"])) {
    16                         if (empty($_GET["$wpvar"])) {
    17                                 $$wpvar = '';
    18                         } else {
    19                                 $$wpvar = $_GET["$wpvar"];
    20                         }
    21                 } else {
    22                         $$wpvar = $_POST["$wpvar"];
    23                 }
    24         }
    25 }
     11wp_reset_vars(array('action', 'redirect', 'profile', 'user_id', 'wp_http_referer'));
    2612
    2713$wp_http_referer = remove_query_arg(array('update', 'delete_count'), stripslashes($wp_http_referer));
    2814