[TEP-COMMIT] [CVS catalog] move password_funcs.php and validations.php functions to general.php
anonymous-OfajU3CKLf1/[email protected] 13 Apr 2004 07:59:11 -0000
| Newsgroups | gmane.comp.web.oscommerce.cvs |
|---|---|
| Message-ID | <[email protected]> |
Commit in catalog/catalog/includes/functions on MAIN
general.php +114 1.237 -> 1.238
password_funcs.php 1.10 removed
validations.php 1.11 removed
+114
2 removed + 1 modified, total 3 files
move password_funcs.php and validations.php functions to general.php
----------
catalog /catalog /includes /functions
general.php 1.237 -> 1.238
diff -u -r1.237 -r1.238
--- general.php 2004/04/13 07:57:50 1.237
+++ general.php 2004/04/13 07:59:08 1.238
@@ -1239,4 +1239,118 @@
return str_replace($from, $to, $string);
}
}
+
+////
+// This funstion validates a plain text password with an
+// encrpyted password
+ function tep_validate_password($plain, $encrypted) {
+ if (tep_not_null($plain) && tep_not_null($encrypted)) {
+// split apart the hash / salt
+ $stack = explode(':', $encrypted);
+
+ if (sizeof($stack) != 2) return false;
+
+ if (md5($stack[1] . $plain) == $stack[0]) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+////
+// This function makes a new password from a plaintext password.
+ function tep_encrypt_password($plain) {
+ $password = '';
+
+ for ($i=0; $i<10; $i++) {
+ $password .= tep_rand();
+ }
+
+ $salt = substr(md5($password), 0, 2);
+
+ $password = md5($salt . $plain) . ':' . $salt;
+
+ return $password;
+ }
+
+ function tep_validate_email($email) {
+ $valid_address = true;
+
+ $mail_pat = '^(.+)@(.+)$';
+ $valid_chars = "[^] \(\)<>@,;:\.\\\"\[]";
+ $atom = "$valid_chars+";
+ $quoted_user='(\"[^\"]*\")';
+ $word = "($atom|$quoted_user)";
+ $user_pat = "^$word(\.$word)*$";
+ $ip_domain_pat='^\[([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\]$';
+ $domain_pat = "^$atom(\.$atom)*$";
+
+ if (eregi($mail_pat, $email, $components)) {
+ $user = $components[1];
+ $domain = $components[2];
+ // validate user
+ if (eregi($user_pat, $user)) {
+ // validate domain
+ if (eregi($ip_domain_pat, $domain, $ip_components)) {
+ // this is an IP address
+ for ($i=1;$i<=4;$i++) {
+ if ($ip_components[$i] > 255) {
+ $valid_address = false;
+ break;
+ }
+ }
+ }
+ else {
+ // Domain is a name, not an IP
+ if (eregi($domain_pat, $domain)) {
+ /* domain name seems valid, but now make sure that it ends in a valid TLD or ccTLD
+ and that there's a hostname preceding the domain or country. */
+ $domain_components = explode(".", $domain);
+ // Make sure there's a host name preceding the domain.
+ if (sizeof($domain_components) < 2) {
+ $valid_address = false;
+ } else {
+ $top_level_domain = strtolower($domain_components[sizeof($domain_components)-1]);
+ // Allow all 2-letter TLDs (ccTLDs)
+ if (eregi('^[a-z][a-z]$', $top_level_domain) != 1) {
+ $tld_pattern = '';
+ // Get authorized TLDs from text file
+ $tlds = file(DIR_WS_INCLUDES . 'tld.txt');
+ while (list(,$line) = each($tlds)) {
+ // Get rid of comments
+ $words = explode('#', $line);
+ $tld = trim($words[0]);
+ // TLDs should be 3 letters or more
+ if (eregi('^[a-z]{3,}$', $tld) == 1) {
+ $tld_pattern .= '^' . $tld . '$|';
+ }
+ }
+ // Remove last '|'
+ $tld_pattern = substr($tld_pattern, 0, -1);
+ if (eregi("$tld_pattern", $top_level_domain) == 0) {
+ $valid_address = false;
+ }
+ }
+ }
+ }
+ else {
+ $valid_address = false;
+ }
+ }
+ }
+ else {
+ $valid_address = false;
+ }
+ }
+ else {
+ $valid_address = false;
+ }
+ if ($valid_address && ENTRY_EMAIL_ADDRESS_CHECK == 'true') {
+ if (!checkdnsrr($domain, "MX") && !checkdnsrr($domain, "A")) {
+ $valid_address = false;
+ }
+ }
+ return $valid_address;
+ }
?>
----------
catalog /catalog /includes /functions
password_funcs.php removed after 1.10
diff -N password_funcs.php
--- /tmp/cvsAAA8Qa4gw Tue Apr 13 09:59:09 2004
+++ /dev/null Tue Apr 13 09:59:09 2004
@@ -1,46 +0,0 @@
-<?php
-/*
- $Id$
-
- osCommerce, Open Source E-Commerce Solutions
- http://www.oscommerce.com
-
- Copyright (c) 2003 osCommerce
-
- Released under the GNU General Public License
-*/
-
-////
-// This funstion validates a plain text password with an
-// encrpyted password
- function tep_validate_password($plain, $encrypted) {
- if (tep_not_null($plain) && tep_not_null($encrypted)) {
-// split apart the hash / salt
- $stack = explode(':', $encrypted);
-
- if (sizeof($stack) != 2) return false;
-
- if (md5($stack[1] . $plain) == $stack[0]) {
- return true;
- }
- }
-
- return false;
- }
-
-////
-// This function makes a new password from a plaintext password.
- function tep_encrypt_password($plain) {
- $password = '';
-
- for ($i=0; $i<10; $i++) {
- $password .= tep_rand();
- }
-
- $salt = substr(md5($password), 0, 2);
-
- $password = md5($salt . $plain) . ':' . $salt;
-
- return $password;
- }
-?>
----------
catalog /catalog /includes /functions
validations.php removed after 1.11
diff -N validations.php
--- /tmp/cvsAAAWTaihw Tue Apr 13 09:59:09 2004
+++ /dev/null Tue Apr 13 09:59:09 2004
@@ -1,122 +0,0 @@
-<?php
-/*
- $Id$
-
- osCommerce, Open Source E-Commerce Solutions
- http://www.oscommerce.com
-
- Copyright (c) 2003 osCommerce
-
- Released under the GNU General Public License
-*/
-
- ////////////////////////////////////////////////////////////////////////////////////////////////
- //
- // Function : tep_validate_email
- //
- // Arguments : email email address to be checked
- //
- // Return : true - valid email address
- // false - invalid email address
- //
- // Description : function for validating email address that conforms to RFC 822 specs
- //
- // This function is converted from a JavaScript written by
- // Sandeep V. Tamhankar ([email protected]). The original JavaScript
- // is available at http://javascript.internet.com
- //
- // Sample Valid Addresses:
- //
- // [email protected]
- // [email protected]
- // "first last"@host.com
- // "[email protected]"@host.com
- // [email protected]
- // first.last@[123.123.123.123]
- //
- // Invalid Addresses:
- //
- // first [email protected]
- //
- //
- ////////////////////////////////////////////////////////////////////////////////////////////////
- function tep_validate_email($email) {
- $valid_address = true;
-
- $mail_pat = '^(.+)@(.+)$';
- $valid_chars = "[^] \(\)<>@,;:\.\\\"\[]";
- $atom = "$valid_chars+";
- $quoted_user='(\"[^\"]*\")';
- $word = "($atom|$quoted_user)";
- $user_pat = "^$word(\.$word)*$";
- $ip_domain_pat='^\[([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\]$';
- $domain_pat = "^$atom(\.$atom)*$";
-
- if (eregi($mail_pat, $email, $components)) {
- $user = $components[1];
- $domain = $components[2];
- // validate user
- if (eregi($user_pat, $user)) {
- // validate domain
- if (eregi($ip_domain_pat, $domain, $ip_components)) {
- // this is an IP address
- for ($i=1;$i<=4;$i++) {
- if ($ip_components[$i] > 255) {
- $valid_address = false;
- break;
- }
- }
- }
- else {
- // Domain is a name, not an IP
- if (eregi($domain_pat, $domain)) {
- /* domain name seems valid, but now make sure that it ends in a valid TLD or ccTLD
- and that there's a hostname preceding the domain or country. */
- $domain_components = explode(".", $domain);
- // Make sure there's a host name preceding the domain.
- if (sizeof($domain_components) < 2) {
- $valid_address = false;
- } else {
- $top_level_domain = strtolower($domain_components[sizeof($domain_components)-1]);
- // Allow all 2-letter TLDs (ccTLDs)
- if (eregi('^[a-z][a-z]$', $top_level_domain) != 1) {
- $tld_pattern = '';
- // Get authorized TLDs from text file
- $tlds = file(DIR_WS_INCLUDES . 'tld.txt');
- while (list(,$line) = each($tlds)) {
- // Get rid of comments
- $words = explode('#', $line);
- $tld = trim($words[0]);
- // TLDs should be 3 letters or more
- if (eregi('^[a-z]{3,}$', $tld) == 1) {
- $tld_pattern .= '^' . $tld . '$|';
- }
- }
- // Remove last '|'
- $tld_pattern = substr($tld_pattern, 0, -1);
- if (eregi("$tld_pattern", $top_level_domain) == 0) {
- $valid_address = false;
- }
- }
- }
- }
- else {
- $valid_address = false;
- }
- }
- }
- else {
- $valid_address = false;
- }
- }
- else {
- $valid_address = false;
- }
- if ($valid_address && ENTRY_EMAIL_ADDRESS_CHECK == 'true') {
- if (!checkdnsrr($domain, "MX") && !checkdnsrr($domain, "A")) {
- $valid_address = false;
- }
- }
- return $valid_address;
- }
-?>
CVSspam 0.2.8
-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click