Skip to content

Commit

Permalink
Change the deprecated $HTTP_XXX_VARS to super global ones $_XXX
Browse files Browse the repository at this point in the history
  • Loading branch information
unknown authored and unknown committed Aug 14, 2011
1 parent 3b3c151 commit c54aa28
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 50 deletions.
30 changes: 15 additions & 15 deletions catalog/admin/includes/functions/general.php
Expand Up @@ -117,14 +117,14 @@ function tep_get_path($current_category_id = '') {
}

function tep_get_all_get_params($exclude_array = '') {
global $HTTP_GET_VARS;
global $_GET;

if ($exclude_array == '') $exclude_array = array();

$get_url = '';

reset($HTTP_GET_VARS);
while (list($key, $value) = each($HTTP_GET_VARS)) {
reset($_GET);
while (list($key, $value) = each($_GET)) {
if (($key != tep_session_name()) && ($key != 'error') && (!in_array($key, $exclude_array))) $get_url .= $key . '=' . $value . '&';
}

Expand Down Expand Up @@ -821,7 +821,7 @@ function tep_mod_select_option($select_array, $key_name, $key_value) {
////
// Retreive server information
function tep_get_system_information() {
global $HTTP_SERVER_VARS;
global $_SERVER;

$db_query = tep_db_query("select now() as datetime");
$db = tep_db_fetch_array($db_query);
Expand All @@ -836,7 +836,7 @@ function tep_get_system_information() {
'os' => PHP_OS,
'kernel' => $kernel,
'uptime' => @exec('uptime'),
'http_server' => $HTTP_SERVER_VARS['SERVER_SOFTWARE']);
'http_server' => $_SERVER['SERVER_SOFTWARE']);

$data['mysql'] = array('version' => (function_exists('mysql_get_server_info') ? mysql_get_server_info() : ''),
'date' => $db['datetime']);
Expand Down Expand Up @@ -1408,13 +1408,13 @@ function tep_validate_ip_address($ip_address) {
}

function tep_get_ip_address() {
global $HTTP_SERVER_VARS;
global $_SERVER;

$ip_address = null;
$ip_addresses = array();

if (isset($HTTP_SERVER_VARS['HTTP_X_FORWARDED_FOR']) && !empty($HTTP_SERVER_VARS['HTTP_X_FORWARDED_FOR'])) {
foreach ( array_reverse(explode(',', $HTTP_SERVER_VARS['HTTP_X_FORWARDED_FOR'])) as $x_ip ) {
if (isset($_SERVER['HTTP_X_FORWARDED_FOR']) && !empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
foreach ( array_reverse(explode(',', $_SERVER['HTTP_X_FORWARDED_FOR'])) as $x_ip ) {
$x_ip = trim($x_ip);

if (tep_validate_ip_address($x_ip)) {
Expand All @@ -1423,19 +1423,19 @@ function tep_get_ip_address() {
}
}

if (isset($HTTP_SERVER_VARS['HTTP_CLIENT_IP']) && !empty($HTTP_SERVER_VARS['HTTP_CLIENT_IP'])) {
$ip_addresses[] = $HTTP_SERVER_VARS['HTTP_CLIENT_IP'];
if (isset($_SERVER['HTTP_CLIENT_IP']) && !empty($_SERVER['HTTP_CLIENT_IP'])) {
$ip_addresses[] = $_SERVER['HTTP_CLIENT_IP'];
}

if (isset($HTTP_SERVER_VARS['HTTP_X_CLUSTER_CLIENT_IP']) && !empty($HTTP_SERVER_VARS['HTTP_X_CLUSTER_CLIENT_IP'])) {
$ip_addresses[] = $HTTP_SERVER_VARS['HTTP_X_CLUSTER_CLIENT_IP'];
if (isset($_SERVER['HTTP_X_CLUSTER_CLIENT_IP']) && !empty($_SERVER['HTTP_X_CLUSTER_CLIENT_IP'])) {
$ip_addresses[] = $_SERVER['HTTP_X_CLUSTER_CLIENT_IP'];
}

if (isset($HTTP_SERVER_VARS['HTTP_PROXY_USER']) && !empty($HTTP_SERVER_VARS['HTTP_PROXY_USER'])) {
$ip_addresses[] = $HTTP_SERVER_VARS['HTTP_PROXY_USER'];
if (isset($_SERVER['HTTP_PROXY_USER']) && !empty($_SERVER['HTTP_PROXY_USER'])) {
$ip_addresses[] = $_SERVER['HTTP_PROXY_USER'];
}

$ip_addresses[] = $HTTP_SERVER_VARS['REMOTE_ADDR'];
$ip_addresses[] = $_SERVER['REMOTE_ADDR'];

foreach ( $ip_addresses as $ip ) {
if (!empty($ip) && tep_validate_ip_address($ip)) {
Expand Down
52 changes: 26 additions & 26 deletions catalog/admin/includes/functions/html_output.php
Expand Up @@ -172,15 +172,15 @@ function tep_draw_form($name, $action, $parameters = '', $method = 'post', $para
////
// Output a form input field
function tep_draw_input_field($name, $value = '', $parameters = '', $required = false, $type = 'text', $reinsert_value = true) {
global $HTTP_GET_VARS, $HTTP_POST_VARS;
global $_GET, $_POST;

$field = '<input type="' . tep_output_string($type) . '" name="' . tep_output_string($name) . '"';

if ( ($reinsert_value == true) && ( (isset($HTTP_GET_VARS[$name]) && is_string($HTTP_GET_VARS[$name])) || (isset($HTTP_POST_VARS[$name]) && is_string($HTTP_POST_VARS[$name])) ) ) {
if (isset($HTTP_GET_VARS[$name]) && is_string($HTTP_GET_VARS[$name])) {
$value = stripslashes($HTTP_GET_VARS[$name]);
} elseif (isset($HTTP_POST_VARS[$name]) && is_string($HTTP_POST_VARS[$name])) {
$value = stripslashes($HTTP_POST_VARS[$name]);
if ( ($reinsert_value == true) && ( (isset($_GET[$name]) && is_string($_GET[$name])) || (isset($_POST[$name]) && is_string($_POST[$name])) ) ) {
if (isset($_GET[$name]) && is_string($_GET[$name])) {
$value = stripslashes($_GET[$name]);
} elseif (isset($_POST[$name]) && is_string($_POST[$name])) {
$value = stripslashes($_POST[$name]);
}
}

Expand Down Expand Up @@ -216,13 +216,13 @@ function tep_draw_file_field($name, $required = false) {
////
// Output a selection field - alias function for tep_draw_checkbox_field() and tep_draw_radio_field()
function tep_draw_selection_field($name, $type, $value = '', $checked = false, $compare = '') {
global $HTTP_GET_VARS, $HTTP_POST_VARS;
global $_GET, $_POST;

$selection = '<input type="' . tep_output_string($type) . '" name="' . tep_output_string($name) . '"';

if (tep_not_null($value)) $selection .= ' value="' . tep_output_string($value) . '"';

if ( ($checked == true) || (isset($HTTP_GET_VARS[$name]) && is_string($HTTP_GET_VARS[$name]) && (($HTTP_GET_VARS[$name] == 'on') || (stripslashes($HTTP_GET_VARS[$name]) == $value))) || (isset($HTTP_POST_VARS[$name]) && is_string($HTTP_POST_VARS[$name]) && (($HTTP_POST_VARS[$name] == 'on') || (stripslashes($HTTP_POST_VARS[$name]) == $value))) || (tep_not_null($compare) && ($value == $compare)) ) {
if ( ($checked == true) || (isset($_GET[$name]) && is_string($_GET[$name]) && (($_GET[$name] == 'on') || (stripslashes($_GET[$name]) == $value))) || (isset($_POST[$name]) && is_string($_POST[$name]) && (($_POST[$name] == 'on') || (stripslashes($_POST[$name]) == $value))) || (tep_not_null($compare) && ($value == $compare)) ) {
$selection .= ' checked="checked"';
}

Expand All @@ -247,19 +247,19 @@ function tep_draw_radio_field($name, $value = '', $checked = false, $compare = '
// Output a form textarea field
// The $wrap parameter is no longer used in the core xhtml template
function tep_draw_textarea_field($name, $wrap, $width, $height, $text = '', $parameters = '', $reinsert_value = true) {
global $HTTP_GET_VARS, $HTTP_POST_VARS;
global $_GET, $_POST;

$field = '<textarea name="' . tep_output_string($name) . '" cols="' . tep_output_string($width) . '" rows="' . tep_output_string($height) . '"';

if (tep_not_null($parameters)) $field .= ' ' . $parameters;

$field .= '>';

if ( ($reinsert_value == true) && ( (isset($HTTP_GET_VARS[$name]) && is_string($HTTP_GET_VARS[$name])) || (isset($HTTP_POST_VARS[$name]) && is_string($HTTP_POST_VARS[$name])) ) ) {
if (isset($HTTP_GET_VARS[$name]) && is_string($HTTP_GET_VARS[$name])) {
$field .= tep_output_string_protected(stripslashes($HTTP_GET_VARS[$name]));
} elseif (isset($HTTP_POST_VARS[$name]) && is_string($HTTP_POST_VARS[$name])) {
$field .= tep_output_string_protected(stripslashes($HTTP_POST_VARS[$name]));
if ( ($reinsert_value == true) && ( (isset($_GET[$name]) && is_string($_GET[$name])) || (isset($_POST[$name]) && is_string($_POST[$name])) ) ) {
if (isset($_GET[$name]) && is_string($_GET[$name])) {
$field .= tep_output_string_protected(stripslashes($_GET[$name]));
} elseif (isset($_POST[$name]) && is_string($_POST[$name])) {
$field .= tep_output_string_protected(stripslashes($_POST[$name]));
}
} elseif (tep_not_null($text)) {
$field .= tep_output_string_protected($text);
Expand All @@ -273,17 +273,17 @@ function tep_draw_textarea_field($name, $wrap, $width, $height, $text = '', $par
////
// Output a form hidden field
function tep_draw_hidden_field($name, $value = '', $parameters = '') {
global $HTTP_GET_VARS, $HTTP_POST_VARS;
global $_GET, $_POST;

$field = '<input type="hidden" name="' . tep_output_string($name) . '"';

if (tep_not_null($value)) {
$field .= ' value="' . tep_output_string($value) . '"';
} elseif ( (isset($HTTP_GET_VARS[$name]) && is_string($HTTP_GET_VARS[$name])) || (isset($HTTP_POST_VARS[$name]) && is_string($HTTP_POST_VARS[$name])) ) {
if ( (isset($HTTP_GET_VARS[$name]) && is_string($HTTP_GET_VARS[$name])) ) {
$field .= ' value="' . tep_output_string(stripslashes($HTTP_GET_VARS[$name])) . '"';
} elseif ( (isset($HTTP_POST_VARS[$name]) && is_string($HTTP_POST_VARS[$name])) ) {
$field .= ' value="' . tep_output_string(stripslashes($HTTP_POST_VARS[$name])) . '"';
} elseif ( (isset($_GET[$name]) && is_string($_GET[$name])) || (isset($_POST[$name]) && is_string($_POST[$name])) ) {
if ( (isset($_GET[$name]) && is_string($_GET[$name])) ) {
$field .= ' value="' . tep_output_string(stripslashes($_GET[$name])) . '"';
} elseif ( (isset($_POST[$name]) && is_string($_POST[$name])) ) {
$field .= ' value="' . tep_output_string(stripslashes($_POST[$name])) . '"';
}
}

Expand All @@ -309,19 +309,19 @@ function tep_hide_session_id() {
////
// Output a form pull down menu
function tep_draw_pull_down_menu($name, $values, $default = '', $parameters = '', $required = false) {
global $HTTP_GET_VARS, $HTTP_POST_VARS;
global $_GET, $_POST;

$field = '<select name="' . tep_output_string($name) . '"';

if (tep_not_null($parameters)) $field .= ' ' . $parameters;

$field .= '>';

if (empty($default) && ( (isset($HTTP_GET_VARS[$name]) && is_string($HTTP_GET_VARS[$name])) || (isset($HTTP_POST_VARS[$name]) && is_string($HTTP_POST_VARS[$name])) ) ) {
if (isset($HTTP_GET_VARS[$name]) && is_string($HTTP_GET_VARS[$name])) {
$default = stripslashes($HTTP_GET_VARS[$name]);
} elseif (isset($HTTP_POST_VARS[$name]) && is_string($HTTP_POST_VARS[$name])) {
$default = stripslashes($HTTP_POST_VARS[$name]);
if (empty($default) && ( (isset($_GET[$name]) && is_string($_GET[$name])) || (isset($_POST[$name]) && is_string($_POST[$name])) ) ) {
if (isset($_GET[$name]) && is_string($_GET[$name])) {
$default = stripslashes($_GET[$name]);
} elseif (isset($_POST[$name]) && is_string($_POST[$name])) {
$default = stripslashes($_POST[$name]);
}
}

Expand Down
18 changes: 9 additions & 9 deletions catalog/admin/includes/functions/sessions.php
Expand Up @@ -69,24 +69,24 @@ function _sess_gc($maxlifetime) {
}

function tep_session_start() {
global $HTTP_GET_VARS, $HTTP_POST_VARS, $HTTP_COOKIE_VARS;
global $_GET, $_POST, $_COOKIE;

$sane_session_id = true;

if (isset($HTTP_GET_VARS[tep_session_name()])) {
if (preg_match('/^[a-zA-Z0-9]+$/', $HTTP_GET_VARS[tep_session_name()]) == false) {
unset($HTTP_GET_VARS[tep_session_name()]);
if (isset($_GET[tep_session_name()])) {
if (preg_match('/^[a-zA-Z0-9]+$/', $_GET[tep_session_name()]) == false) {
unset($_GET[tep_session_name()]);

$sane_session_id = false;
}
} elseif (isset($HTTP_POST_VARS[tep_session_name()])) {
if (preg_match('/^[a-zA-Z0-9]+$/', $HTTP_POST_VARS[tep_session_name()]) == false) {
unset($HTTP_POST_VARS[tep_session_name()]);
} elseif (isset($_POST[tep_session_name()])) {
if (preg_match('/^[a-zA-Z0-9]+$/', $_POST[tep_session_name()]) == false) {
unset($_POST[tep_session_name()]);

$sane_session_id = false;
}
} elseif (isset($HTTP_COOKIE_VARS[tep_session_name()])) {
if (preg_match('/^[a-zA-Z0-9]+$/', $HTTP_COOKIE_VARS[tep_session_name()]) == false) {
} elseif (isset($_COOKIE[tep_session_name()])) {
if (preg_match('/^[a-zA-Z0-9]+$/', $_COOKIE[tep_session_name()]) == false) {
$session_data = session_get_cookie_params();

setcookie(tep_session_name(), '', time()-42000, $session_data['path'], $session_data['domain']);
Expand Down

0 comments on commit c54aa28

Please sign in to comment.