Permalink
Browse files

Removed deprecated code and improved performance with foreach loops (…

…needs testing on payment platform)
  • Loading branch information...
acidvertigo committed Aug 16, 2011
1 parent d3908ff commit 26a13b436d00147354c673e3b2b28c7c09333e2e
@@ -100,13 +100,13 @@ function selection() {
}
function pre_confirmation_check() {
- global $HTTP_GET_VARS, $order, $ppe_token;
+ global $order, $ppe_token;
if (!tep_session_is_registered('ppe_token')) {
tep_redirect(tep_href_link('ext/modules/payment/paypal/express.php', '', 'SSL'));
}
- if (!isset($HTTP_GET_VARS['do'])) {
+ if (!isset($_GET['do'])) {
$response_array = $this->getExpressCheckoutDetails($ppe_token);
if (($response_array['ACK'] == 'Success') || ($response_array['ACK'] == 'SuccessWithWarning')) {
@@ -149,11 +149,11 @@ function process_button() {
}
function before_process() {
- global $customer_id, $order, $sendto, $ppe_token, $ppe_payerid, $HTTP_POST_VARS, $comments, $response_array;
+ global $customer_id, $order, $sendto, $ppe_token, $ppe_payerid, $comments, $response_array;
if (empty($comments)) {
- if (isset($HTTP_POST_VARS['ppecomments']) && tep_not_null($HTTP_POST_VARS['ppecomments'])) {
- $comments = tep_db_prepare_input($HTTP_POST_VARS['ppecomments']);
+ if (isset($_POST['ppecomments']) && tep_not_null($_POST['ppecomments'])) {
+ $comments = tep_db_prepare_input($_POST['ppecomments']);
$order->info['comments'] = $comments;
}
@@ -481,18 +481,17 @@ function doExpressCheckoutPayment($parameters) {
}
function sendDebugEmail() {
- global $HTTP_POST_VARS, $HTTP_GET_VARS;
-
+
if (tep_not_null(MODULE_PAYMENT_PAYPAL_EXPRESS_DEBUG_EMAIL)) {
- $email_body = '$HTTP_POST_VARS:' . "\n\n";
+ $email_body = '$_POST:' . "\n\n";
- foreach ($HTTP_POST_VARS as $key => $value) {
+ foreach ($_POST as $key => $value) {
$email_body .= $key . '=' . $value . "\n";
}
- $email_body .= "\n" . '$HTTP_GET_VARS:' . "\n\n";
+ $email_body .= "\n" . '$_GET:' . "\n\n";
- foreach ($HTTP_GET_VARS as $key => $value) {
+ foreach ($_GET as $key => $value) {
$email_body .= $key . '=' . $value . "\n";
}
@@ -77,7 +77,7 @@ function selection() {
global $order;
$types_array = array();
- while (list($key, $value) = each($this->cc_types)) {
+ foreach ($this->cc_types as $key => $value) {
if ($this->isCardAccepted($key)) {
$types_array[] = array('id' => $key,
'text' => $value);
@@ -125,10 +125,9 @@ function selection() {
function pre_confirmation_check() {
if (MODULE_PAYMENT_PAYPAL_PRO_DP_CARD_INPUT_PAGE == 'Payment') {
- global $HTTP_POST_VARS;
-
- if (!isset($HTTP_POST_VARS['cc_owner']) || empty($HTTP_POST_VARS['cc_owner']) || (strlen($HTTP_POST_VARS['cc_owner']) < CC_OWNER_MIN_LENGTH) || !isset($HTTP_POST_VARS['cc_type']) || !$this->isCardAccepted($HTTP_POST_VARS['cc_type']) || !isset($HTTP_POST_VARS['cc_number_nh-dns']) || empty($HTTP_POST_VARS['cc_number_nh-dns']) || (strlen($HTTP_POST_VARS['cc_number_nh-dns']) < CC_NUMBER_MIN_LENGTH)) {
- $payment_error_return = 'payment_error=' . $this->code . '&error=' . urlencode(MODULE_PAYMENT_PAYPAL_PRO_DP_ERROR_ALL_FIELDS_REQUIRED) . '&cc_owner=' . urlencode($HTTP_POST_VARS['cc_owner']) . '&cc_starts_month=' . $HTTP_POST_VARS['cc_starts_month'] . '&cc_starts_year=' . $HTTP_POST_VARS['cc_starts_year'] . '&cc_expires_month=' . $HTTP_POST_VARS['cc_expires_month'] . '&cc_expires_year=' . $HTTP_POST_VARS['cc_expires_year'];
+
+ if (!isset($_POST['cc_owner']) || empty($_POST['cc_owner']) || (strlen($_POST['cc_owner']) < CC_OWNER_MIN_LENGTH) || !isset($_POST['cc_type']) || !$this->isCardAccepted($_POST['cc_type']) || !isset($_POST['cc_number_nh-dns']) || empty($_POST['cc_number_nh-dns']) || (strlen($_POST['cc_number_nh-dns']) < CC_NUMBER_MIN_LENGTH)) {
+ $payment_error_return = 'payment_error=' . $this->code . '&error=' . urlencode(MODULE_PAYMENT_PAYPAL_PRO_DP_ERROR_ALL_FIELDS_REQUIRED) . '&cc_owner=' . urlencode($_POST['cc_owner']) . '&cc_starts_month=' . $_POST['cc_starts_month'] . '&cc_starts_year=' . $_POST['cc_starts_year'] . '&cc_expires_month=' . $_POST['cc_expires_month'] . '&cc_expires_year=' . $_POST['cc_expires_year'];
tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, $payment_error_return, 'SSL', true, false));
}
@@ -141,32 +140,31 @@ function confirmation() {
$confirmation = array();
if (MODULE_PAYMENT_PAYPAL_PRO_DP_CARD_INPUT_PAGE == 'Payment') {
- global $HTTP_POST_VARS;
-
+
$confirmation['fields'] = array(array('title' => MODULE_PAYMENT_PAYPAL_PRO_DP_CARD_OWNER,
- 'field' => $HTTP_POST_VARS['cc_owner']),
+ 'field' => $_POST['cc_owner']),
array('title' => MODULE_PAYMENT_PAYPAL_PRO_DP_CARD_TYPE,
- 'field' => $this->cc_types[$HTTP_POST_VARS['cc_type']]),
+ 'field' => $this->cc_types[$_POST['cc_type']]),
array('title' => MODULE_PAYMENT_PAYPAL_PRO_DP_CARD_NUMBER,
- 'field' => str_repeat('X', strlen($HTTP_POST_VARS['cc_number_nh-dns']) - 4) . substr($HTTP_POST_VARS['cc_number_nh-dns'], -4)),
+ 'field' => str_repeat('X', strlen($_POST['cc_number_nh-dns']) - 4) . substr($_POST['cc_number_nh-dns'], -4)),
array('title' => MODULE_PAYMENT_PAYPAL_PRO_DP_CARD_VALID_FROM,
- 'field' => $HTTP_POST_VARS['cc_starts_month'] . '/' . $HTTP_POST_VARS['cc_starts_year']),
+ 'field' => $_POST['cc_starts_month'] . '/' . $_POST['cc_starts_year']),
array('title' => MODULE_PAYMENT_PAYPAL_PRO_DP_CARD_EXPIRES,
- 'field' => $HTTP_POST_VARS['cc_expires_month'] . '/' . $HTTP_POST_VARS['cc_expires_year']),
+ 'field' => $_POST['cc_expires_month'] . '/' . $_POST['cc_expires_year']),
array('title' => MODULE_PAYMENT_PAYPAL_PRO_DP_CARD_CVC,
- 'field' => $HTTP_POST_VARS['cc_cvc_nh-dns']));
+ 'field' => $_POST['cc_cvc_nh-dns']));
- if ( (($HTTP_POST_VARS['cc_type'] == 'SWITCH') && $this->isCardAccepted('SWITCH')) || (($HTTP_POST_VARS['cc_type'] == 'SOLO') && $this->isCardAccepted('SOLO')) ) {
- if (isset($HTTP_POST_VARS['cc_issue_nh-dns']) && !empty($HTTP_POST_VARS['cc_issue_nh-dns'])) {
+ if ( (($_POST['cc_type'] == 'SWITCH') && $this->isCardAccepted('SWITCH')) || (($_POST['cc_type'] == 'SOLO') && $this->isCardAccepted('SOLO')) ) {
+ if (isset($_POST['cc_issue_nh-dns']) && !empty($_POST['cc_issue_nh-dns'])) {
$confirmation['fields'][] = array('title' => MODULE_PAYMENT_PAYPAL_PRO_DP_CARD_ISSUE_NUMBER,
- 'field' => $HTTP_POST_VARS['cc_issue_nh-dns']);
+ 'field' => $_POST['cc_issue_nh-dns']);
}
}
} else {
global $order;
$types_array = array();
- while (list($key, $value) = each($this->cc_types)) {
+ foreach ($this->cc_types as $key => $value) {
if ($this->isCardAccepted($key)) {
$types_array[] = array('id' => $key,
'text' => $value);
@@ -214,19 +212,18 @@ function confirmation() {
function process_button() {
if (MODULE_PAYMENT_PAYPAL_PRO_DP_CARD_INPUT_PAGE == 'Payment') {
- global $HTTP_POST_VARS;
-
- $process_button_string = tep_draw_hidden_field('cc_owner', $HTTP_POST_VARS['cc_owner']) .
- tep_draw_hidden_field('cc_type', $HTTP_POST_VARS['cc_type']) .
- tep_draw_hidden_field('cc_number_nh-dns', $HTTP_POST_VARS['cc_number_nh-dns']) .
- tep_draw_hidden_field('cc_starts_month', $HTTP_POST_VARS['cc_starts_month']) .
- tep_draw_hidden_field('cc_starts_year', $HTTP_POST_VARS['cc_starts_year']) .
- tep_draw_hidden_field('cc_expires_month', $HTTP_POST_VARS['cc_expires_month']) .
- tep_draw_hidden_field('cc_expires_year', $HTTP_POST_VARS['cc_expires_year']) .
- tep_draw_hidden_field('cc_cvc_nh-dns', $HTTP_POST_VARS['cc_cvc_nh-dns']);
-
- if ( (($HTTP_POST_VARS['cc_type'] == 'SWITCH') && $this->isCardAccepted('SWITCH')) || (($HTTP_POST_VARS['cc_type'] == 'SOLO') && $this->isCardAccepted('SOLO')) ) {
- $process_button_string .= tep_draw_hidden_field('cc_issue_nh-dns', $HTTP_POST_VARS['cc_issue_nh-dns']);
+
+ $process_button_string = tep_draw_hidden_field('cc_owner', $_POST['cc_owner']) .
+ tep_draw_hidden_field('cc_type', $_POST['cc_type']) .
+ tep_draw_hidden_field('cc_number_nh-dns', $_POST['cc_number_nh-dns']) .
+ tep_draw_hidden_field('cc_starts_month', $_POST['cc_starts_month']) .
+ tep_draw_hidden_field('cc_starts_year', $_POST['cc_starts_year']) .
+ tep_draw_hidden_field('cc_expires_month', $_POST['cc_expires_month']) .
+ tep_draw_hidden_field('cc_expires_year', $_POST['cc_expires_year']) .
+ tep_draw_hidden_field('cc_cvc_nh-dns', $_POST['cc_cvc_nh-dns']);
+
+ if ( (($_POST['cc_type'] == 'SWITCH') && $this->isCardAccepted('SWITCH')) || (($_POST['cc_type'] == 'SOLO') && $this->isCardAccepted('SOLO')) ) {
+ $process_button_string .= tep_draw_hidden_field('cc_issue_nh-dns', $_POST['cc_issue_nh-dns']);
}
return $process_button_string;
@@ -236,16 +233,16 @@ function process_button() {
}
function before_process() {
- global $HTTP_POST_VARS, $order, $sendto;
+ global $order, $sendto;
- if (isset($HTTP_POST_VARS['cc_owner']) && !empty($HTTP_POST_VARS['cc_owner']) && isset($HTTP_POST_VARS['cc_type']) && $this->isCardAccepted($HTTP_POST_VARS['cc_type']) && isset($HTTP_POST_VARS['cc_number_nh-dns']) && !empty($HTTP_POST_VARS['cc_number_nh-dns'])) {
+ if (isset($_POST['cc_owner']) && !empty($_POST['cc_owner']) && isset($_POST['cc_type']) && $this->isCardAccepted($_POST['cc_type']) && isset($_POST['cc_number_nh-dns']) && !empty($_POST['cc_number_nh-dns'])) {
if (MODULE_PAYMENT_PAYPAL_PRO_DP_TRANSACTION_SERVER == 'Live') {
$api_url = 'https://api-3t.paypal.com/nvp';
} else {
$api_url = 'https://api-3t.sandbox.paypal.com/nvp';
}
- $card_type = $HTTP_POST_VARS['cc_type'];
+ $card_type = $_POST['cc_type'];
if ( ($card_type == 'VISA_DEBIT') || ($card_type == 'VISA_ELECTRON') ) {
$card_type = 'VISA';
}
@@ -259,12 +256,12 @@ function before_process() {
'IPADDRESS' => tep_get_ip_address(),
'AMT' => $this->format_raw($order->info['total']),
'CREDITCARDTYPE' => $card_type,
- 'ACCT' => $HTTP_POST_VARS['cc_number_nh-dns'],
- 'STARTDATE' => $HTTP_POST_VARS['cc_starts_month'] . $HTTP_POST_VARS['cc_starts_year'],
- 'EXPDATE' => $HTTP_POST_VARS['cc_expires_month'] . $HTTP_POST_VARS['cc_expires_year'],
- 'CVV2' => $HTTP_POST_VARS['cc_cvc_nh-dns'],
- 'FIRSTNAME' => substr($HTTP_POST_VARS['cc_owner'], 0, strpos($HTTP_POST_VARS['cc_owner'], ' ')),
- 'LASTNAME' => substr($HTTP_POST_VARS['cc_owner'], strpos($HTTP_POST_VARS['cc_owner'], ' ')+1),
+ 'ACCT' => $_POST['cc_number_nh-dns'],
+ 'STARTDATE' => $_POST['cc_starts_month'] . $_POST['cc_starts_year'],
+ 'EXPDATE' => $_POST['cc_expires_month'] . $_POST['cc_expires_year'],
+ 'CVV2' => $_POST['cc_cvc_nh-dns'],
+ 'FIRSTNAME' => substr($_POST['cc_owner'], 0, strpos($_POST['cc_owner'], ' ')),
+ 'LASTNAME' => substr($_POST['cc_owner'], strpos($_POST['cc_owner'], ' ')+1),
'STREET' => $order->billing['street_address'],
'CITY' => $order->billing['city'],
'STATE' => tep_get_zone_code($order->billing['country']['id'], $order->billing['zone_id'], $order->billing['state']),
@@ -275,8 +272,8 @@ function before_process() {
'CURRENCYCODE' => $order->info['currency'],
'BUTTONSOURCE' => 'osCommerce22_Default_DP');
- if ( (($HTTP_POST_VARS['cc_type'] == 'SWITCH') && $this->isCardAccepted('SWITCH')) || (($HTTP_POST_VARS['cc_type'] == 'SOLO') && $this->isCardAccepted('SOLO')) ) {
- $params['ISSUENUMBER'] = $HTTP_POST_VARS['cc_issue_nh-dns'];
+ if ( (($_POST['cc_type'] == 'SWITCH') && $this->isCardAccepted('SWITCH')) || (($_POST['cc_type'] == 'SOLO') && $this->isCardAccepted('SOLO')) ) {
+ $params['ISSUENUMBER'] = $_POST['cc_issue_nh-dns'];
}
if (is_numeric($sendto) && ($sendto > 0)) {
@@ -314,9 +311,8 @@ function after_process() {
function get_error() {
if (MODULE_PAYMENT_PAYPAL_PRO_DP_CARD_INPUT_PAGE == 'Payment') {
- global $HTTP_GET_VARS;
-
- $error = array('error' => stripslashes(urldecode($HTTP_GET_VARS['error'])));
+
+ $error = array('error' => stripslashes(urldecode($_GET['error'])));
return $error;
}

0 comments on commit 26a13b4

Please sign in to comment.