Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Committing main modifications

Files should be showing correct diffs now.
  • Loading branch information...
commit 4fb35659c231f67a34e0079de0aeaeb71d5e46bc 1 parent 90c5c9d
FwrMedia authored
2  catalog/account_newsletters.php
View
@@ -23,7 +23,7 @@
$newsletter_query = tep_db_query("select customers_newsletter from " . TABLE_CUSTOMERS . " where customers_id = '" . (int)$customer_id . "'");
$newsletter = tep_db_fetch_array($newsletter_query);
- if (isset($HTTP_POST_VARS['action']) && ($HTTP_POST_VARS['action'] == 'process') && isset($HTTP_POST_VARS['formid']) && ($HTTP_POST_VARS['formid'] == $sessiontoken)) {
+ if (false !== tep_validate_form(array('action' => 'process'))) {
if (isset($HTTP_POST_VARS['newsletter_general']) && is_numeric($HTTP_POST_VARS['newsletter_general'])) {
$newsletter_general = tep_db_prepare_input($HTTP_POST_VARS['newsletter_general']);
} else {
2  catalog/account_notifications.php
View
@@ -23,7 +23,7 @@
$global_query = tep_db_query("select global_product_notifications from " . TABLE_CUSTOMERS_INFO . " where customers_info_id = '" . (int)$customer_id . "'");
$global = tep_db_fetch_array($global_query);
- if (isset($HTTP_POST_VARS['action']) && ($HTTP_POST_VARS['action'] == 'process') && isset($HTTP_POST_VARS['formid']) && ($HTTP_POST_VARS['formid'] == $sessiontoken)) {
+ if (false !== tep_validate_form(array('action' => 'process'))) {
if (isset($HTTP_POST_VARS['product_global']) && is_numeric($HTTP_POST_VARS['product_global'])) {
$product_global = tep_db_prepare_input($HTTP_POST_VARS['product_global']);
} else {
6 catalog/account_password.php
View
@@ -20,10 +20,8 @@
// needs to be included earlier to set the success message in the messageStack
require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_ACCOUNT_PASSWORD);
- if (isset($HTTP_POST_VARS['action']) && ($HTTP_POST_VARS['action'] == 'process') && isset($HTTP_POST_VARS['formid']) && ($HTTP_POST_VARS['formid'] == $sessiontoken)) {
- $password_current = tep_db_prepare_input($HTTP_POST_VARS['password_current']);
- $password_new = tep_db_prepare_input($HTTP_POST_VARS['password_new']);
- $password_confirmation = tep_db_prepare_input($HTTP_POST_VARS['password_confirmation']);
+ if (false !== $validated = tep_validate_form(array('action' => 'process','password_current' => 'string','password_new' => 'string','password_confirmation' => 'string'))) {
+ extract($validated,EXTR_OVERWRITE);
$error = false;
16 catalog/address_book_process.php
View
@@ -20,11 +20,12 @@
// needs to be included earlier to set the success message in the messageStack
require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_ADDRESS_BOOK_PROCESS);
- if (isset($HTTP_GET_VARS['action']) && ($HTTP_GET_VARS['action'] == 'deleteconfirm') && isset($HTTP_GET_VARS['delete']) && is_numeric($HTTP_GET_VARS['delete']) && isset($HTTP_GET_VARS['formid']) && ($HTTP_GET_VARS['formid'] == md5($sessiontoken))) {
- if ((int)$HTTP_GET_VARS['delete'] == $customer_default_address_id) {
+ if (false !== $validated = tep_validate_form_get(array('action' => 'deleteconfirm','delete' => 'int'))) {
+ extract($validated,EXTR_OVERWRITE);
+ if ($delete == $customer_default_address_id) {
$messageStack->add_session('addressbook', WARNING_PRIMARY_ADDRESS_DELETION, 'warning');
} else {
- tep_db_query("delete from " . TABLE_ADDRESS_BOOK . " where address_book_id = '" . (int)$HTTP_GET_VARS['delete'] . "' and customers_id = '" . (int)$customer_id . "'");
+ tep_db_query("delete from " . TABLE_ADDRESS_BOOK . " where address_book_id = '" . $delete . "' and customers_id = '" . (int)$customer_id . "'");
$messageStack->add_session('addressbook', SUCCESS_ADDRESS_BOOK_ENTRY_DELETED, 'success');
}
@@ -34,19 +35,14 @@
// error checking when updating or adding an entry
$process = false;
- if (isset($HTTP_POST_VARS['action']) && (($HTTP_POST_VARS['action'] == 'process') || ($HTTP_POST_VARS['action'] == 'update')) && isset($HTTP_POST_VARS['formid']) && ($HTTP_POST_VARS['formid'] == $sessiontoken)) {
+ if (false !== $validated = tep_validate_form(array('action' => array( 'process', 'update' ),'firstname' => 'strip_tags','lastname' => 'strip_tags','street_address' => 'strip_tags','postcode' => 'strip_tags','city' => 'strip_tags','country' => 'strip_tags'))) {
+ extract($validated,EXTR_OVERWRITE);
$process = true;
$error = false;
if (ACCOUNT_GENDER == 'true') $gender = tep_db_prepare_input($HTTP_POST_VARS['gender']);
if (ACCOUNT_COMPANY == 'true') $company = tep_db_prepare_input($HTTP_POST_VARS['company']);
- $firstname = tep_db_prepare_input($HTTP_POST_VARS['firstname']);
- $lastname = tep_db_prepare_input($HTTP_POST_VARS['lastname']);
- $street_address = tep_db_prepare_input($HTTP_POST_VARS['street_address']);
if (ACCOUNT_SUBURB == 'true') $suburb = tep_db_prepare_input($HTTP_POST_VARS['suburb']);
- $postcode = tep_db_prepare_input($HTTP_POST_VARS['postcode']);
- $city = tep_db_prepare_input($HTTP_POST_VARS['city']);
- $country = tep_db_prepare_input($HTTP_POST_VARS['country']);
if (ACCOUNT_STATE == 'true') {
if (isset($HTTP_POST_VARS['zone_id'])) {
$zone_id = tep_db_prepare_input($HTTP_POST_VARS['zone_id']);
13 catalog/checkout_payment_address.php
View
@@ -28,20 +28,15 @@
$error = false;
$process = false;
- if (isset($HTTP_POST_VARS['action']) && ($HTTP_POST_VARS['action'] == 'submit') && isset($HTTP_POST_VARS['formid']) && ($HTTP_POST_VARS['formid'] == $sessiontoken)) {
-// process a new billing address
- if (tep_not_null($HTTP_POST_VARS['firstname']) && tep_not_null($HTTP_POST_VARS['lastname']) && tep_not_null($HTTP_POST_VARS['street_address'])) {
+ if (false !== $validated = tep_validate_form(array('action' => 'submit','firstname' => 'strip_tags','lastname' => 'strip_tags','street_address' => 'strip_tags','postcode' => 'strip_tags','city' => 'strip_tags','country' => 'strip_tags'))) {
+ extract($validated,EXTR_OVERWRITE);
+ // process a new billing address
+ if (tep_not_null($firstname) && tep_not_null($lastname) && tep_not_null($street_address)) {
$process = true;
if (ACCOUNT_GENDER == 'true') $gender = tep_db_prepare_input($HTTP_POST_VARS['gender']);
if (ACCOUNT_COMPANY == 'true') $company = tep_db_prepare_input($HTTP_POST_VARS['company']);
- $firstname = tep_db_prepare_input($HTTP_POST_VARS['firstname']);
- $lastname = tep_db_prepare_input($HTTP_POST_VARS['lastname']);
- $street_address = tep_db_prepare_input($HTTP_POST_VARS['street_address']);
if (ACCOUNT_SUBURB == 'true') $suburb = tep_db_prepare_input($HTTP_POST_VARS['suburb']);
- $postcode = tep_db_prepare_input($HTTP_POST_VARS['postcode']);
- $city = tep_db_prepare_input($HTTP_POST_VARS['city']);
- $country = tep_db_prepare_input($HTTP_POST_VARS['country']);
if (ACCOUNT_STATE == 'true') {
if (isset($HTTP_POST_VARS['zone_id'])) {
$zone_id = tep_db_prepare_input($HTTP_POST_VARS['zone_id']);
7 catalog/checkout_shipping.php
View
@@ -95,12 +95,9 @@
}
// process the selected shipping method
- if ( isset($HTTP_POST_VARS['action']) && ($HTTP_POST_VARS['action'] == 'process') && isset($HTTP_POST_VARS['formid']) && ($HTTP_POST_VARS['formid'] == $sessiontoken) ) {
+ if (false !== tep_validate_form(array('action' => 'process', 'comments' => 'tep_db_prepare_input'))) {
+ extract($validated,EXTR_OVERWRITE);
if (!tep_session_is_registered('comments')) tep_session_register('comments');
- if (tep_not_null($HTTP_POST_VARS['comments'])) {
- $comments = tep_db_prepare_input($HTTP_POST_VARS['comments']);
- }
-
if (!tep_session_is_registered('shipping')) tep_session_register('shipping');
if ( (tep_count_shipping_modules() > 0) || ($free_shipping == true) ) {
11 catalog/checkout_shipping_address.php
View
@@ -41,20 +41,15 @@
$error = false;
$process = false;
- if (isset($HTTP_POST_VARS['action']) && ($HTTP_POST_VARS['action'] == 'submit') && isset($HTTP_POST_VARS['formid']) && ($HTTP_POST_VARS['formid'] == $sessiontoken)) {
+ if (false !== $validated = tep_validate_form(array('action' => 'submit','firstname' => 'strip_tags','lastname' => 'strip_tags','street_address' => 'strip_tags','postcode' => 'strip_tags','city' => 'strip_tags','country' => 'strip_tags'))) {
+ extract($validated,EXTR_OVERWRITE);
// process a new shipping address
- if (tep_not_null($HTTP_POST_VARS['firstname']) && tep_not_null($HTTP_POST_VARS['lastname']) && tep_not_null($HTTP_POST_VARS['street_address'])) {
+ if (tep_not_null($firstname) && tep_not_null($lastname) && tep_not_null($street_address)) {
$process = true;
if (ACCOUNT_GENDER == 'true') $gender = tep_db_prepare_input($HTTP_POST_VARS['gender']);
if (ACCOUNT_COMPANY == 'true') $company = tep_db_prepare_input($HTTP_POST_VARS['company']);
- $firstname = tep_db_prepare_input($HTTP_POST_VARS['firstname']);
- $lastname = tep_db_prepare_input($HTTP_POST_VARS['lastname']);
- $street_address = tep_db_prepare_input($HTTP_POST_VARS['street_address']);
if (ACCOUNT_SUBURB == 'true') $suburb = tep_db_prepare_input($HTTP_POST_VARS['suburb']);
- $postcode = tep_db_prepare_input($HTTP_POST_VARS['postcode']);
- $city = tep_db_prepare_input($HTTP_POST_VARS['city']);
- $country = tep_db_prepare_input($HTTP_POST_VARS['country']);
if (ACCOUNT_STATE == 'true') {
if (isset($HTTP_POST_VARS['zone_id'])) {
$zone_id = tep_db_prepare_input($HTTP_POST_VARS['zone_id']);
11 catalog/contact_us.php
View
@@ -14,14 +14,11 @@
require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_CONTACT_US);
- if (isset($HTTP_GET_VARS['action']) && ($HTTP_GET_VARS['action'] == 'send') && isset($HTTP_POST_VARS['formid']) && ($HTTP_POST_VARS['formid'] == $sessiontoken)) {
+ if (isset($HTTP_GET_VARS['action']) && ($HTTP_GET_VARS['action'] == 'send') && (false !== $validated = tep_validate_form(array('name' => 'strip_tags','email' => 'strip_tags','enquiry' => 'strip_tags')))) {
+ extract($validated,EXTR_OVERWRITE);
$error = false;
- $name = tep_db_prepare_input($HTTP_POST_VARS['name']);
- $email_address = tep_db_prepare_input($HTTP_POST_VARS['email']);
- $enquiry = tep_db_prepare_input($HTTP_POST_VARS['enquiry']);
-
- if (!tep_validate_email($email_address)) {
+ if (!tep_validate_email($email)) {
$error = true;
$messageStack->add('contact', ENTRY_EMAIL_ADDRESS_CHECK_ERROR);
@@ -37,7 +34,7 @@
}
if ($error == false) {
- tep_mail(STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS, EMAIL_SUBJECT, $enquiry, $name, $email_address);
+ tep_mail(STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS, EMAIL_SUBJECT, $enquiry, $name, $email);
$actionRecorder->record();
14 catalog/create_account.php
View
@@ -16,7 +16,8 @@
require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_CREATE_ACCOUNT);
$process = false;
- if (isset($HTTP_POST_VARS['action']) && ($HTTP_POST_VARS['action'] == 'process') && isset($HTTP_POST_VARS['formid']) && ($HTTP_POST_VARS['formid'] == $sessiontoken)) {
+ if (false !== $validated = tep_validate_form(array('action' => 'process','firstname' => 'strip_tags','lastname' => 'strip_tags','email_address' => 'strip_tags','street_address' => 'strip_tags','postcode' => 'strip_tags','city' => 'strip_tags','country' => 'strip_tags','telephone' => 'strip_tags','fax' => 'strip_tags','password' => 'strip_tags','confirmation' => 'strip_tags'))) {
+ extract($validated,EXTR_OVERWRITE);
$process = true;
if (ACCOUNT_GENDER == 'true') {
@@ -26,15 +27,9 @@
$gender = false;
}
}
- $firstname = tep_db_prepare_input($HTTP_POST_VARS['firstname']);
- $lastname = tep_db_prepare_input($HTTP_POST_VARS['lastname']);
if (ACCOUNT_DOB == 'true') $dob = tep_db_prepare_input($HTTP_POST_VARS['dob']);
- $email_address = tep_db_prepare_input($HTTP_POST_VARS['email_address']);
if (ACCOUNT_COMPANY == 'true') $company = tep_db_prepare_input($HTTP_POST_VARS['company']);
- $street_address = tep_db_prepare_input($HTTP_POST_VARS['street_address']);
if (ACCOUNT_SUBURB == 'true') $suburb = tep_db_prepare_input($HTTP_POST_VARS['suburb']);
- $postcode = tep_db_prepare_input($HTTP_POST_VARS['postcode']);
- $city = tep_db_prepare_input($HTTP_POST_VARS['city']);
if (ACCOUNT_STATE == 'true') {
$state = tep_db_prepare_input($HTTP_POST_VARS['state']);
if (isset($HTTP_POST_VARS['zone_id'])) {
@@ -43,16 +38,11 @@
$zone_id = false;
}
}
- $country = tep_db_prepare_input($HTTP_POST_VARS['country']);
- $telephone = tep_db_prepare_input($HTTP_POST_VARS['telephone']);
- $fax = tep_db_prepare_input($HTTP_POST_VARS['fax']);
if (isset($HTTP_POST_VARS['newsletter'])) {
$newsletter = tep_db_prepare_input($HTTP_POST_VARS['newsletter']);
} else {
$newsletter = false;
}
- $password = tep_db_prepare_input($HTTP_POST_VARS['password']);
- $confirmation = tep_db_prepare_input($HTTP_POST_VARS['confirmation']);
$error = false;
130 catalog/includes/functions/general.php
View
@@ -1393,4 +1393,132 @@ function tep_convert_linefeeds($from, $to, $string) {
return str_replace($from, $to, $string);
}
}
-?>
+
+ /**
+ * Format the superglobal values extracted from form _GET or _POST
+ *
+ * @param string $key - key passed by the $args array
+ * @param mixed $value - value passed by the $args array
+ * @param array - passed by reference array of key => values extracted from the _GET or _POST superglobal
+ * @return mixed bool false - void
+ */
+ function tep_enforce_form_values($key, $value, &$form_data) {
+ /**
+ * Type cast if requested or use functions on the value, if not the value must match e.g. action = process
+ */
+ switch($form_data) {
+ case 'int':
+ $form_data[$key] = (int)$form_data[$key];
+ break;
+ case 'numeric':
+ if (!is_numeric($form_data[$key])) $form_data[$key] = (int)$form_data[$key];
+ break;
+ case 'real':
+ case 'double':
+ case 'float':
+ $form_data[$key] = (float)$form_data[$key];
+ break;
+ case 'string':
+ $form_data[$key] = tep_db_prepare_input((string)$form_data[$key]);
+ break;
+ case 'strip_tags':
+ $form_data[$key] = tep_db_prepare_input(strip_tags((string)$form_data[$key]));
+ break;
+ case 'array':
+ $form_data[$key] = tep_db_prepare_input((array)$form_data[$key]);
+ break;
+ case 'empty':
+ case 'null':
+ if(tep_not_null( $form_data[$key])) {
+ $form_data[$key] = is_array($form_data[$key]) ? array() : '';
+ }
+ break;
+ case 'boolean':
+ case 'bool':
+ $form_data[$key] = (bool)$form_data[$key];
+ break;
+ case 'email':
+ if (tep_validate_email($form_data[$key]) == false) return false;
+ break;
+ case 'bypass':
+ // For some unknown reason we don't want this one formatted
+ break;
+ case false !== strpos($value, 'tep_'):
+ if (function_exists($value)) {
+ $form_data[$key] = $value(tep_db_prepare_input($form_data[$key])); // Pass the value through a tep_ function e.g. tep_output_string()
+ }
+ break;
+ case false !== strpos($value, 'php_'):
+ $possible_function = substr($value, 4, strlen($value));
+ $disallowed = array( 'eval','exec','shell_exec','escapeshellarg','escapeshellcmd','system',
+ 'passthru','readfile','proc_close','proc_open','ini_alter','dl','popen',
+ 'parse_ini_file','show_source', 'curl_exec' );
+ if (in_array($possible_function,$disallowed)) return false; // Many PHP functions are dangerous
+ if (function_exists($possible_function)) {
+ $form_data[$key] = $possible_function(tep_db_prepare_input($form_data[$key]));
+ }
+ break;
+ /**
+ * When the value is an array it could be confusing unless explained
+ *
+ * @example address_book_process.php
+ * if (isset($HTTP_POST_VARS['action']) && (($HTTP_POST_VARS['action'] == 'process') || ($HTTP_POST_VARS['action'] == 'update'))
+ * action is checked against the array e.g array( 'process', 'update' ) and if the action doesn't match any this returns false
+ */
+ case is_array($form_data[$key]):
+ if (!in_array((string)$value,$form_data[$key])) return false; // Effectively an OR
+ break;
+ default:
+ if((string)$value != (string)$form_data[$key]) return false; // Checking simple matches like action => process
+ break;
+ }
+ return true;
+ } // end function tep_form_validations
+
+ /**
+ * Handles _GET as opposed to _POST
+ * tep_form_validate_get( array, [,$csrf_protection = true] [,$csrf_check_only = false])
+ * @see tep_form_validate()
+ */
+ function tep_validate_form_get(array $args = array(), $csrf_protection = true, $csrf_check_only = false) {
+ return tep_validate_form($args, $csrf_protection, $csrf_check_only, 'get');
+ } // end function tep_form_validate_get
+ /**
+ * validates forms, validates CSRF, typecasts values and applies tep_db_prepare_input()
+ * also can apply tep_ or PHP simple one argument functions to values if required
+ *
+ * tep_form_validate( array, [,$csrf_protection = true] [,$csrf_check_only = false] [,$type = 'post'])
+ * @param array $args - array keys to extract from _GET or _POST the values can be: -
+ * string - a simple string like "process"
+ * array - array( process, update )
+ * Type to enforce e.g. int string array etc.
+ * A call to a function to run on the superglobal value, either tep_ or php_
+ * @param bool $csrf_protection - whether checking for CSRF
+ * @param bool $csrf_check_only - return based on the CSRF check only, $csrf_protection must be true also
+ * @param string $type - post or get
+ * @return mixed - bool false or array of typecast key=>values
+ */
+ function tep_validate_form(array $args = array(), $csrf_protection = true, $csrf_check_only = false, $type = 'post') {
+ global $sessiontoken;
+ if($csrf_protection) $args['formid'] = 1; // Add form_id manually which we will use to extract from the superglobal
+ $superglobal = $type == 'post' ? $_POST : $_GET; // Which type of form are we validating
+ $expected = array_intersect_key($superglobal, $args); // Extract the expected keys from the superglobal
+ if(count($expected) !== count($args)) return false; // If we did not find all of the expected keys the form did not validate
+ if($csrf_protection) { // If CSRF form protection is set to on
+ $new_session_token = md5(tep_rand() . tep_rand() . tep_rand() . tep_rand()); // prepare new token
+ if(((string)$expected['formid'] != $sessiontoken)) { // Does the superglobal token match _SESSION?
+ $sessiontoken = $new_session_token; // Reset $sessiontoken due to failed form
+ return false; // or do other stuff like redirect and exit etc.
+ } else { // The tokens matched
+ unset($expected['formid']); // we don't want to return this as a part of the $expected array
+ $sessiontoken = $new_session_token; // Reset $sessiontoken as the form was successful and won't be needed again
+ if($csrf_check_only) return true; // We were only asked to validate the tokens so return here
+ }
+ }
+ foreach($args as $key => $value) { // enforce form types and tep_db_prepare_input()
+ if($key == 'formid') continue;
+ if (false === tep_enforce_form_values($key, $value, $expected)) return false;
+ } // end foreach
+ return (array)$expected; // array of validated and type cast superglobal key=>values
+ } // end function tep_form_validate
+?>
5 catalog/login.php
View
@@ -20,9 +20,8 @@
require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_LOGIN);
$error = false;
- if (isset($HTTP_GET_VARS['action']) && ($HTTP_GET_VARS['action'] == 'process') && isset($HTTP_POST_VARS['formid']) && ($HTTP_POST_VARS['formid'] == $sessiontoken)) {
- $email_address = tep_db_prepare_input($HTTP_POST_VARS['email_address']);
- $password = tep_db_prepare_input($HTTP_POST_VARS['password']);
+ if (isset($HTTP_GET_VARS['action']) && ($HTTP_GET_VARS['action'] == 'process') && (false !== $validated = tep_validate_form(array('email_address' => 'strip_tags','password' => 'strip_tags')))) {
+ extract($validated,EXTR_OVERWRITE);
// Check if email exists
$check_customer_query = tep_db_query("select customers_id, customers_firstname, customers_password, customers_email_address, customers_default_address_id from " . TABLE_CUSTOMERS . " where customers_email_address = '" . tep_db_input($email_address) . "'");
4 catalog/password_forgotten.php
View
@@ -16,8 +16,8 @@
$password_reset_initiated = false;
- if (isset($HTTP_GET_VARS['action']) && ($HTTP_GET_VARS['action'] == 'process') && isset($HTTP_POST_VARS['formid']) && ($HTTP_POST_VARS['formid'] == $sessiontoken)) {
- $email_address = tep_db_prepare_input($HTTP_POST_VARS['email_address']);
+ if (isset($HTTP_GET_VARS['action']) && ($HTTP_GET_VARS['action'] == 'process') && (false !== $validated = tep_validate_form(array('email_address' => 'strip_tags')))) {
+ extract($validated,EXTR_OVERWRITE);
$check_customer_query = tep_db_query("select customers_firstname, customers_lastname, customers_id from " . TABLE_CUSTOMERS . " where customers_email_address = '" . tep_db_input($email_address) . "'");
if (tep_db_num_rows($check_customer_query)) {
12 catalog/password_reset.php
View
@@ -55,23 +55,21 @@
if ($error == true) {
tep_redirect(tep_href_link(FILENAME_PASSWORD_FORGOTTEN));
}
+ if (isset($HTTP_GET_VARS['action']) && ($HTTP_GET_VARS['action'] == 'process') && (false !== $validated = tep_validate_form(array('password' => 'strip_tags','confirmation' => 'strip_tags')))) {
+ extract($validated,EXTR_OVERWRITE);
- if (isset($HTTP_GET_VARS['action']) && ($HTTP_GET_VARS['action'] == 'process') && isset($HTTP_POST_VARS['formid']) && ($HTTP_POST_VARS['formid'] == $sessiontoken)) {
- $password_new = tep_db_prepare_input($HTTP_POST_VARS['password']);
- $password_confirmation = tep_db_prepare_input($HTTP_POST_VARS['confirmation']);
-
- if (strlen($password_new) < ENTRY_PASSWORD_MIN_LENGTH) {
+ if (strlen($password) < ENTRY_PASSWORD_MIN_LENGTH) {
$error = true;
$messageStack->add('password_reset', ENTRY_PASSWORD_NEW_ERROR);
- } elseif ($password_new != $password_confirmation) {
+ } elseif ($password != $confirmation) {
$error = true;
$messageStack->add('password_reset', ENTRY_PASSWORD_NEW_ERROR_NOT_MATCHING);
}
if ($error == false) {
- tep_db_query("update " . TABLE_CUSTOMERS . " set customers_password = '" . tep_encrypt_password($password_new) . "' where customers_id = '" . (int)$check_customer['customers_id'] . "'");
+ tep_db_query("update " . TABLE_CUSTOMERS . " set customers_password = '" . tep_encrypt_password($password) . "' where customers_id = '" . (int)$check_customer['customers_id'] . "'");
tep_db_query("update " . TABLE_CUSTOMERS_INFO . " set customers_info_date_account_last_modified = now(), password_reset_key = null, password_reset_date = null where customers_info_id = '" . (int)$check_customer['customers_id'] . "'");
5 catalog/product_reviews_write.php
View
@@ -29,9 +29,8 @@
$customer_query = tep_db_query("select customers_firstname, customers_lastname from " . TABLE_CUSTOMERS . " where customers_id = '" . (int)$customer_id . "'");
$customer = tep_db_fetch_array($customer_query);
- if (isset($HTTP_GET_VARS['action']) && ($HTTP_GET_VARS['action'] == 'process') && isset($HTTP_POST_VARS['formid']) && ($HTTP_POST_VARS['formid'] == $sessiontoken)) {
- $rating = tep_db_prepare_input($HTTP_POST_VARS['rating']);
- $review = tep_db_prepare_input($HTTP_POST_VARS['review']);
+ if (isset($HTTP_GET_VARS['action']) && ($HTTP_GET_VARS['action'] == 'process') && (false !== $validated = tep_validate_form(array('rating' => 'int','review' => 'strip_tags')))) {
+ extract($validated,EXTR_OVERWRITE);
$error = false;
if (strlen($review) < REVIEW_TEXT_MIN_LENGTH) {
9 catalog/tell_a_friend.php
View
@@ -33,15 +33,10 @@
require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_TELL_A_FRIEND);
- if (isset($HTTP_GET_VARS['action']) && ($HTTP_GET_VARS['action'] == 'process') && isset($HTTP_POST_VARS['formid']) && ($HTTP_POST_VARS['formid'] == $sessiontoken)) {
+ if (isset($HTTP_GET_VARS['action']) && ($HTTP_GET_VARS['action'] == 'process') && (false !== $validated = tep_validate_form(array('to_email_address' => 'strip_tags','to_name' => 'strip_tags','from_email_address' => 'strip_tags','from_name' => 'strip_tags','message' => 'strip_tags')))) {
+ extract($validated,EXTR_OVERWRITE);
$error = false;
- $to_email_address = tep_db_prepare_input($HTTP_POST_VARS['to_email_address']);
- $to_name = tep_db_prepare_input($HTTP_POST_VARS['to_name']);
- $from_email_address = tep_db_prepare_input($HTTP_POST_VARS['from_email_address']);
- $from_name = tep_db_prepare_input($HTTP_POST_VARS['from_name']);
- $message = tep_db_prepare_input($HTTP_POST_VARS['message']);
-
if (empty($from_name)) {
$error = true;
Please sign in to comment.
Something went wrong with that request. Please try again.