Changeset 447 for branches


Ignore:
Timestamp:
Dec 13, 2013 11:24:08 PM (10 years ago)
Author:
anonymous
Message:

Changed some global constants to class constants (in cases where backwards compatability wouldn't break).

Location:
branches/eli_branch
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • branches/eli_branch/lib/App.inc.php

    r446 r447  
    3030 */
    3131
    32 //ob_start();
    33 
    3432// Message Types.
    3533define('MSG_ERR', 1);
     
    321319
    322320            // Session parameters.
    323             /*
    324321            ini_set('session.gc_probability', 1);
    325322            ini_set('session.gc_divisor', 1000);
     
    330327            ini_set('session.entropy_length', '512');
    331328            ini_set('session.cookie_httponly', true);
    332              * */
    333329            session_name($this->getParam('session_name'));
    334330
     
    343339
    344340            // Start the session.
    345             //session_start();
     341            session_start();
    346342
    347343            if (!isset($_SESSION['_app'][$this->_ns])) {
     
    378374
    379375        // Character set. This should also be printed in the html header template.
    380         //header('Content-type: text/html; charset=' . $this->getParam('character_set'));
     376        header('Content-type: text/html; charset=' . $this->getParam('character_set'));
    381377
    382378        // Set the version of the codebase we're using.
     
    385381            $codebase_version = trim(file_get_contents($codebase_version_file));
    386382            $this->setParam(array('codebase_version' => $codebase_version));
    387             //header('X-Codebase-Version: ' . $codebase_version);
     383            header('X-Codebase-Version: ' . $codebase_version);
    388384        }
    389385
     
    472468            return false;
    473469        }
    474         //die($_SESSION['_app'][$this->_ns]['messages']);
    475470        return isset($_SESSION['_app'][$this->_ns]['messages']) ? $_SESSION['_app'][$this->_ns]['messages'] : array();
    476471    }
  • branches/eli_branch/lib/Auth_File.inc.php

    r445 r447  
    4040// ));
    4141
    42 // Available encryption types for class Auth_SQL.
    43 define('AUTH_ENCRYPT_MD5', 'md5');
    44 define('AUTH_ENCRYPT_CRYPT', 'crypt');
    45 define('AUTH_ENCRYPT_SHA1', 'sha1');
    46 define('AUTH_ENCRYPT_PLAINTEXT', 'plaintext');
    47 
    4842class Auth_File {
     43
     44    // Available encryption types for class Auth_File.
     45    const ENCRYPT_MD5 = 'md5';
     46    const ENCRYPT_CRYPT = 'crypt';
     47    const ENCRYPT_SHA1 = 'sha1';
     48    const ENCRYPT_PLAINTEXT = 'plaintext';
    4949
    5050    // Namespace of this auth object.
     
    5858        'htpasswd_file' => null,
    5959
    60         // The type of encryption to use for passwords stored in the db_table. Use one of the AUTH_ENCRYPT_* types specified above.
    61         'encryption_type' => AUTH_ENCRYPT_CRYPT,
     60        // The type of encryption to use for passwords stored in the db_table. Use one of the self::ENCRYPT_* types specified above.
     61        'encryption_type' => self::ENCRYPT_CRYPT,
    6262
    6363        // The URL to the login script.
     
    390390    {
    391391        switch ($this->_params['encryption_type']) {
    392         case AUTH_ENCRYPT_PLAINTEXT :
     392        case self::ENCRYPT_PLAINTEXT :
    393393            return $password;
    394394            break;
    395395
    396         case AUTH_ENCRYPT_SHA1 :
     396        case self::ENCRYPT_SHA1 :
    397397            return sha1($password);
    398398            break;
    399399
    400         case AUTH_ENCRYPT_MD5 :
     400        case self::ENCRYPT_MD5 :
    401401            return md5($password);
    402402            break;
    403403
    404         case AUTH_ENCRYPT_CRYPT :
     404        case self::ENCRYPT_CRYPT :
    405405        default :
    406406            return crypt($password, $encrypted_password);
  • branches/eli_branch/lib/Auth_SQL.inc.php

    r439 r447  
    44 * For details visit the project site: <http://trac.strangecode.com/codebase/>
    55 * Copyright 2001-2012 Strangecode, LLC
    6  * 
     6 *
    77 * This file is part of The Strangecode Codebase.
    88 *
     
    1111 * Free Software Foundation, either version 3 of the License, or (at your option)
    1212 * any later version.
    13  * 
     13 *
    1414 * The Strangecode Codebase is distributed in the hope that it will be useful, but
    1515 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1616 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
    1717 * details.
    18  * 
     18 *
    1919 * You should have received a copy of the GNU General Public License along with
    2020 * The Strangecode Codebase. If not, see <http://www.gnu.org/licenses/>.
     
    2828*/
    2929
    30 // Available encryption types for class Auth_SQL.
    31 define('AUTH_ENCRYPT_PLAINTEXT', 1);
    32 define('AUTH_ENCRYPT_CRYPT', 2);
    33 define('AUTH_ENCRYPT_SHA1', 3);
    34 define('AUTH_ENCRYPT_SHA1_HARDENED', 4);
    35 define('AUTH_ENCRYPT_MD5', 5);
    36 define('AUTH_ENCRYPT_MD5_HARDENED', 6);
    37 
    3830require_once dirname(__FILE__) . '/Email.inc.php';
    3931
    4032class Auth_SQL {
    41        
     33
     34    // Available encryption types for class Auth_SQL.
     35    const ENCRYPT_PLAINTEXT = 1;
     36    const ENCRYPT_CRYPT = 2;
     37    const ENCRYPT_SHA1 = 3;
     38    const ENCRYPT_SHA1_HARDENED = 4;
     39    const ENCRYPT_MD5 = 5;
     40    const ENCRYPT_MD5_HARDENED = 6;
     41
    4242    // Namespace of this auth object.
    4343    private $_ns;
    44    
     44
    4545    // Static var for test.
    4646    private $_authentication_tested;
     
    6666        'db_login_table' => 'user_login_tbl',
    6767
    68         // The type of encryption to use for passwords stored in the db_table. Use one of the AUTH_ENCRYPT_* types specified above.
     68        // The type of encryption to use for passwords stored in the db_table. Use one of the Auth_SQL::ENCRYPT_* types specified above.
    6969        // Hardened password hashes rely on the same key/salt being used to compare encryptions.
    7070        // Be aware that when using one of the hardened types the App signing_key or $more_salt below cannot change!
    71         'encryption_type' => AUTH_ENCRYPT_MD5,
     71        'encryption_type' => self::ENCRYPT_MD5,
    7272
    7373        // The URL to the login script.
     
    130130    {
    131131        $app =& App::getInstance();
    132        
     132
    133133        $this->_ns = $namespace;
    134        
     134
    135135        // Initialize default parameters.
    136136        $this->setParam($this->_default_params);
     
    157157        $app =& App::getInstance();
    158158        $db =& DB::getInstance();
    159    
    160    
     159
     160
    161161        static $_db_tested = false;
    162162
     
    277277    {
    278278        $app =& App::getInstance();
    279    
     279
    280280        if (isset($this->_params[$param])) {
    281281            return $this->_params[$param];
     
    294294    {
    295295        $db =& DB::getInstance();
    296    
     296
    297297        $this->initDB();
    298298
     
    369369
    370370        switch ($this->_params['encryption_type']) {
    371         case AUTH_ENCRYPT_CRYPT :
     371        case self::ENCRYPT_CRYPT :
    372372            // Query DB for user matching credentials. Compare cyphertext with salted-encrypted password.
    373373            $qid = $db->query("
     
    378378            ");
    379379            break;
    380         case AUTH_ENCRYPT_PLAINTEXT :
    381         case AUTH_ENCRYPT_MD5 :
    382         case AUTH_ENCRYPT_SHA1 :
     380        case self::ENCRYPT_PLAINTEXT :
     381        case self::ENCRYPT_MD5 :
     382        case self::ENCRYPT_SHA1 :
    383383        default :
    384384            // Query DB for user matching credentials. Directly compare cyphertext with result from encryptPassword().
     
    416416        $app =& App::getInstance();
    417417        $db =& DB::getInstance();
    418    
     418
    419419        $this->initDB();
    420420
    421421        $this->clear();
    422422
    423         if (!$user_data = $this->authenticate($username, $password)) {
     423        if ((!$user_data = $this->authenticate($username, $password))) {
    424424            // No login: failed authentication!
    425425            return false;
    426426        }
    427        
     427
    428428        // Register authenticated session.
    429429        $_SESSION['_auth_sql'][$this->_ns] = array(
     
    563563        $this->_authentication_tested = true;
    564564
    565         // Some users will access from networks with a changing IP number (i.e. behind a proxy server). 
     565        // Some users will access from networks with a changing IP number (i.e. behind a proxy server).
    566566        // These users must be allowed entry by adding their IP to the list of trusted_networks, or their usernames to the list of match_remote_ip_exempt_usernames.
    567567        if ($trusted_net = ipInRange(getRemoteAddr(), $this->_params['trusted_networks'])) {
     
    579579            $user_in_trusted_network = false;
    580580        }
    581        
     581
    582582        // Do we match the user's remote IP at all? Yes, if set in config and not disabled for specific user.
    583583        if ($this->getParam('match_remote_ip') && !$this->get('match_remote_ip_exempt')) {
    584584            $remote_ip_is_matched = (isset($_SESSION['_auth_sql'][$this->_ns]['remote_ip']) && $_SESSION['_auth_sql'][$this->_ns]['remote_ip'] == getRemoteAddr()) || $user_in_trusted_network;
    585585        } else {
    586             $app->logMsg(sprintf('User_id %s exempt from remote_ip match (comparing %s == %s)', 
     586            $app->logMsg(sprintf('User_id %s exempt from remote_ip match (comparing %s == %s)',
    587587                ($this->get('user_id') ? $this->get('user_id') . ' (' .  $this->get('username') . ')' : 'unknown'),
    588588                $_SESSION['_auth_sql'][$this->_ns]['remote_ip'],
     
    593593
    594594        // Test login with information stored in session. Skip IP matching for users from trusted networks.
    595         if (isset($_SESSION['_auth_sql'][$this->_ns]['authenticated']) 
     595        if (isset($_SESSION['_auth_sql'][$this->_ns]['authenticated'])
    596596            && true === $_SESSION['_auth_sql'][$this->_ns]['authenticated']
    597597            && isset($_SESSION['_auth_sql'][$this->_ns]['username'])
     
    671671    {
    672672        $app =& App::getInstance();
    673    
     673
    674674        if (!$this->isLoggedIn()) {
    675675            // Display message for requiring login. (RaiseMsg will ignore empty strings.)
     
    694694        $app =& App::getInstance();
    695695        $db =& DB::getInstance();
    696    
     696
    697697        $this->initDB();
    698698
     
    730730            $user_id = isset($user_id) ? $user_id : $this->getVal('user_id');
    731731            $qid = $db->query("
    732                 SELECT 1 
     732                SELECT 1
    733733                FROM " . $this->_params['db_table'] . "
    734734                WHERE blocked = 'true'
     
    745745    {
    746746        $db =& DB::getInstance();
    747    
     747
    748748        $this->initDB();
    749    
     749
    750750        if ($this->getParam('blocking')) {
    751751            // Get user_id if specified.
     
    769769    {
    770770        $db =& DB::getInstance();
    771    
     771
    772772        $this->initDB();
    773773
     
    789789    {
    790790        $db =& DB::getInstance();
    791    
     791
    792792        $this->initDB();
    793793
     
    846846    {
    847847        $app =& App::getInstance();
    848        
     848
    849849        // Existing password hashes rely on the same key/salt being used to compare encryptions.
    850850        // Don't change this (or the value applied to signing_key) unless you know existing hashes or signatures will not be affected!
    851851        $more_salt = 'B36D18E5-3FE4-4D58-8150-F26642852B81';
    852        
     852
    853853        switch ($this->_params['encryption_type']) {
    854         case AUTH_ENCRYPT_PLAINTEXT :
     854        case self::ENCRYPT_PLAINTEXT :
    855855            return $password;
    856856            break;
    857857
    858         case AUTH_ENCRYPT_CRYPT :
     858        case self::ENCRYPT_CRYPT :
    859859            // If comparing plaintext password with a hash, provide first two chars of the hash as the salt.
    860860            return isset($salt) ? crypt($password, mb_substr($salt, 0, 2)) : crypt($password);
    861861            break;
    862862
    863         case AUTH_ENCRYPT_SHA1 :
     863        case self::ENCRYPT_SHA1 :
    864864            return sha1($password);
    865865            break;
    866866
    867         case AUTH_ENCRYPT_SHA1_HARDENED :
     867        case self::ENCRYPT_SHA1_HARDENED :
    868868            $hash = sha1($app->getParam('signing_key') . $password . $more_salt);
    869869            // Increase key strength by 12 bits.
    870             for ($i=0; $i < 4096; $i++) { 
    871                 $hash = sha1($hash); 
    872             } 
     870            for ($i=0; $i < 4096; $i++) {
     871                $hash = sha1($hash);
     872            }
    873873            return $hash;
    874874            break;
    875875
    876         case AUTH_ENCRYPT_MD5 :
     876        case self::ENCRYPT_MD5 :
    877877            return md5($password);
    878878            break;
    879879
    880         case AUTH_ENCRYPT_MD5_HARDENED :
     880        case self::ENCRYPT_MD5_HARDENED :
    881881            // Include salt to improve hash
    882882            $hash = md5($app->getParam('signing_key') . $password . $more_salt);
    883883            // Increase key strength by 12 bits.
    884             for ($i=0; $i < 4096; $i++) { 
    885                 $hash = md5($hash); 
    886             } 
     884            for ($i=0; $i < 4096; $i++) {
     885                $hash = md5($hash);
     886            }
    887887            return $hash;
    888888            break;
     
    902902        $app =& App::getInstance();
    903903        $db =& DB::getInstance();
    904    
     904
    905905        $this->initDB();
    906906
     
    909909
    910910        // Get old password.
    911         $qid = $db->query(" 
     911        $qid = $db->query("
    912912            SELECT userpass
    913913            FROM " . $this->_params['db_table'] . "
     
    918918            return false;
    919919        }
    920        
     920
    921921        // Compare old with new to ensure we're actually *changing* the password.
    922922        $encrypted_password = $this->encryptPassword($password);
     
    932932            WHERE " . $this->_params['db_primary_key'] . " = '" . $db->escapeString($user_id) . "'
    933933        ");
    934        
     934
    935935        if (mysql_affected_rows($db->getDBH()) != 1) {
    936936            $app->logMsg(sprintf('Failed to update password for user_id %s', $user_id), LOG_WARNING, __FILE__, __LINE__);
    937937            return false;
    938938        }
    939        
     939
    940940        return true;
    941941    }
     
    952952        $app =& App::getInstance();
    953953        $db =& DB::getInstance();
    954    
     954
    955955        $this->initDB();
    956956
     
    10391039    {
    10401040        $app =& App::getInstance();
    1041    
     1041
    10421042        // return true; /// WTF?
    10431043        $zone_members = preg_split('/,\s*/', $security_zone);
  • branches/eli_branch/lib/AuthorizeNet.inc.php

    r439 r447  
    44 * For details visit the project site: <http://trac.strangecode.com/codebase/>
    55 * Copyright 2001-2012 Strangecode, LLC
    6  * 
     6 *
    77 * This file is part of The Strangecode Codebase.
    88 *
     
    1111 * Free Software Foundation, either version 3 of the License, or (at your option)
    1212 * any later version.
    13  * 
     13 *
    1414 * The Strangecode Codebase is distributed in the hope that it will be useful, but
    1515 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1616 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
    1717 * details.
    18  * 
     18 *
    1919 * You should have received a copy of the GNU General Public License along with
    2020 * The Strangecode Codebase. If not, see <http://www.gnu.org/licenses/>.
     
    3131 * @date 2004-04-06
    3232 */
    33  
     33
    3434// Example usage
    3535// require_once 'codebase/lib/AuthorizeNet.inc.php';
     
    143143        $this->_params = $this->_default_params;
    144144        $this->setParam($params);
    145        
     145
    146146        $this->setParam(array('md5_hash_salt' => $app->getParam('signing_key')));
    147147    }
     
    156156    {
    157157        $app =& App::getInstance();
    158    
     158
    159159        if (isset($params) && is_array($params)) {
    160160            // Merge new parameters with old overriding only those passed.
     
    175175    {
    176176        $app =& App::getInstance();
    177    
     177
    178178        if (isset($this->_params[$param])) {
    179179            return $this->_params[$param];
     
    195195    {
    196196        $app =& App::getInstance();
    197    
     197
    198198        if (empty($this->_params['x_login'])) {
    199199            $this->_results['x_response_reason_text'] = _("Transaction gateway temporarily not available. Please try again later.");
  • branches/eli_branch/lib/FormValidator.inc.php

    r439 r447  
    44 * For details visit the project site: <http://trac.strangecode.com/codebase/>
    55 * Copyright 2001-2012 Strangecode, LLC
    6  * 
     6 *
    77 * This file is part of The Strangecode Codebase.
    88 *
     
    1111 * Free Software Foundation, either version 3 of the License, or (at your option)
    1212 * any later version.
    13  * 
     13 *
    1414 * The Strangecode Codebase is distributed in the hope that it will be useful, but
    1515 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1616 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
    1717 * details.
    18  * 
     18 *
    1919 * You should have received a copy of the GNU General Public License along with
    2020 * The Strangecode Codebase. If not, see <http://www.gnu.org/licenses/>.
     
    7070    // Array filling with error messages.
    7171    public $errors = array();
    72    
     72
    7373    /**
    7474     * Set (or overwrite existing) parameters by passing an array of new parameters.
     
    8080    {
    8181        $app =& App::getInstance();
    82    
     82
    8383        if (isset($params) && is_array($params)) {
    8484            // Merge new parameters with old overriding only those passed.
     
    9999    {
    100100        $app =& App::getInstance();
    101    
     101
    102102        if (isset($this->_params[$param])) {
    103103            return $this->_params[$param];
     
    107107        }
    108108    }
    109    
     109
    110110    /**
    111111     * Return the current list of errors.
     
    159159            return false;
    160160        } else {
    161             return (sizeof($this->errors) > 0);           
     161            return (sizeof($this->errors) > 0);
    162162        }
    163163    }
     
    283283        }
    284284    }
    285    
     285
    286286    /*
    287287    * We were using the isEmpty method *wrong* all these years and should have been using notEmpty.
    288     * But the fact is the only use is to ensure a value is not empty, so this function simply becomes 
     288    * But the fact is the only use is to ensure a value is not empty, so this function simply becomes
    289289    * an alias of the one-true notEmpty() function.
    290290    * @since    03 Jun 2006 22:56:46
     
    474474        }
    475475
    476         // Validator::validateEmail() returns a value that relates to the VALIDATE_EMAIL_* constants (defined in Validator.inc.php).
     476        // Validator::validateEmail() returns a value that relates to the Validate::EMAIL_* constants (defined in Validator.inc.php).
    477477        switch (parent::validateEmail($email)) {
    478         case VALIDATE_EMAIL_REGEX_FAIL:
     478        case parent::EMAIL_REGEX_FAIL:
    479479            // Failed regex match.
    480480            $this->addError($form_name, sprintf(_("The email address <em>%s</em> is formatted incorrectly."), oTxt($email)));
     
    482482            return false;
    483483            break;
    484            
    485         case VALIDATE_EMAIL_LENGTH_FAIL :
     484
     485        case parent::EMAIL_LENGTH_FAIL :
    486486            // Failed length requirements.
    487487            $this->addError($form_name, sprintf(_("The email address <em>%s</em> is too long (email addresses must have fewer than 256 characters)."), oTxt($email)));
     
    489489            return false;
    490490            break;
    491            
    492         case VALIDATE_EMAIL_MX_FAIL :
     491
     492        case parent::EMAIL_MX_FAIL :
    493493            // Failed MX record test.
    494494            $this->addError($form_name, sprintf(_("The email address <em>%s</em> does not have a valid domain name"), oTxt($email)));
     
    496496            return false;
    497497            break;
    498            
    499         case VALIDATE_EMAIL_SUCCESS :
     498
     499        case parent::EMAIL_SUCCESS :
    500500        default :
    501501            return true;
     
    550550     *
    551551     * @param  string  $form_name   The name of the incoming form variable.
    552      * @param  string  $cc_type     Optional, card type to do specific checks. One of the CC_TYPE_* constants.
     552     * @param  string  $cc_type     Optional, card type to do specific checks. One of the Validator::CC_TYPE_* constants.
    553553     *
    554554     * @return bool    true if no errors found, false otherwise
     
    557557    {
    558558        $cc_num = getFormData($form_name);
    559        
     559
    560560        if (parent::validateCCNumber($cc_num, $cc_type)) {
    561561            return true;
  • branches/eli_branch/lib/Validator.inc.php

    r439 r447  
    44 * For details visit the project site: <http://trac.strangecode.com/codebase/>
    55 * Copyright 2001-2012 Strangecode, LLC
    6  * 
     6 *
    77 * This file is part of The Strangecode Codebase.
    88 *
     
    1111 * Free Software Foundation, either version 3 of the License, or (at your option)
    1212 * any later version.
    13  * 
     13 *
    1414 * The Strangecode Codebase is distributed in the hope that it will be useful, but
    1515 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1616 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
    1717 * details.
    18  * 
     18 *
    1919 * You should have received a copy of the GNU General Public License along with
    2020 * The Strangecode Codebase. If not, see <http://www.gnu.org/licenses/>.
     
    2424 * Validator.inc.php
    2525 *
    26  * The Validator class provides a methods for validating input against different criteria. 
     26 * The Validator class provides a methods for validating input against different criteria.
    2727 * All functions return true if the input passes the test.
    2828 *
     
    3131 */
    3232
    33 // Known credit card types.
    34 define('CC_TYPE_VISA', 1);
    35 define('CC_TYPE_MASTERCARD', 2);
    36 define('CC_TYPE_AMEX', 3);
    37 define('CC_TYPE_DISCOVER', 4);
    38 define('CC_TYPE_DINERS', 5);
    39 define('CC_TYPE_JCB', 6);
    40 
    41 // validateEmail return types.
    42 define('VALIDATE_EMAIL_SUCCESS', 0);
    43 define('VALIDATE_EMAIL_REGEX_FAIL', 1);
    44 define('VALIDATE_EMAIL_LENGTH_FAIL', 2);
    45 define('VALIDATE_EMAIL_MX_FAIL', 3);
    46 
    4733class Validator {
     34
     35    // Known credit card types.
     36    const CC_TYPE_VISA = 1;
     37    const CC_TYPE_MASTERCARD = 2;
     38    const CC_TYPE_AMEX = 3;
     39    const CC_TYPE_DISCOVER = 4;
     40    const CC_TYPE_DINERS = 5;
     41    const CC_TYPE_JCB = 6;
     42
     43    // Validator::validateEmail() return types.
     44    const EMAIL_SUCCESS = 0;
     45    const EMAIL_REGEX_FAIL = 1;
     46    const EMAIL_LENGTH_FAIL = 2;
     47    const EMAIL_MX_FAIL = 3;
    4848
    4949    /**
     
    180180     * @access  public
    181181     * @param   string  $val    The input data to validate..
    182      * @return  const           One of the constant values: VALIDATE_EMAIL_SUCCESS|VALIDATE_EMAIL_REGEX_FAIL|VALIDATE_EMAIL_LENGTH_FAIL|VALIDATE_EMAIL_MX_FAIL
     182     * @return  const           One of the constant values: Validate::EMAIL_SUCCESS|Validate::EMAIL_REGEX_FAIL|Validate::EMAIL_LENGTH_FAIL|Validate::EMAIL_MX_FAIL
    183183     * @author  Quinn Comendant <quinn@strangecode.com>
    184184     */
     
    190190        // Test email address format.
    191191        if (!preg_match($e->getParam('regex'), $val, $e_parts)) {
    192             return VALIDATE_EMAIL_REGEX_FAIL;
    193         }
    194        
     192            return self::EMAIL_REGEX_FAIL;
     193        }
     194
    195195        // We have a match! Here are the captured subpatterns, on which further tests are run.
    196         // The part before the @. 
     196        // The part before the @.
    197197        $local = $e_parts[2];
    198198
    199         // The part after the @. 
     199        // The part after the @.
    200200        // If domain is an IP [XXX.XXX.XXX.XXX] strip off the brackets.
    201201        $domain = $e_parts[3]{0} == '[' ? mb_substr($e_parts[3], 1, -1) : $e_parts[3];
     
    203203        // Test length.
    204204        if (mb_strlen($local) > 64 || mb_strlen($domain) > 191) {
    205             return VALIDATE_EMAIL_LENGTH_FAIL;
     205            return self::EMAIL_LENGTH_FAIL;
    206206        }
    207207
     
    210210        if ((ip2long($domain) == '-1' || ip2long($domain) === false) && function_exists('checkdnsrr') && !checkdnsrr($domain . '.', 'MX') && gethostbyname($domain) == $domain) {
    211211            // FIXME: Do we care?
    212             // return VALIDATE_EMAIL_MX_FAIL;
    213         }
    214 
    215         return VALIDATE_EMAIL_SUCCESS;
     212            // return self::EMAIL_MX_FAIL;
     213        }
     214
     215        return self::EMAIL_SUCCESS;
    216216    }
    217217
     
    225225    {
    226226        $app =& App::getInstance();
    227        
     227
    228228        if ('' == trim($val)) {
    229229            // Don't be too bothered about empty strings.
     
    257257         // Perform card-specific checks, if applicable
    258258         switch ($cc_type) {
    259              case CC_TYPE_VISA :
     259             case self::CC_TYPE_VISA :
    260260                 $regex = '/^4\d{15}$|^4\d{12}$/';
    261261                 break;
    262              case CC_TYPE_MASTERCARD :
     262             case self::CC_TYPE_MASTERCARD :
    263263                 $regex = '/^5[1-5]\d{14}$/';
    264264                 break;
    265              case CC_TYPE_AMEX :
     265             case self::CC_TYPE_AMEX :
    266266                 $regex = '/^3[47]\d{13}$/';
    267267                 break;
    268              case CC_TYPE_DISCOVER :
     268             case self::CC_TYPE_DISCOVER :
    269269                 $regex = '/^6011\d{12}$/';
    270270                 break;
    271              case CC_TYPE_DINERS :
     271             case self::CC_TYPE_DINERS :
    272272                 $regex = '/^30[0-5]\d{11}$|^3[68]\d{12}$/';
    273273                 break;
    274              case CC_TYPE_JCB :
     274             case self::CC_TYPE_JCB :
    275275                 $regex = '/^3\d{15}$|^2131|1800\d{11}$/';
    276276                 break;
     
    279279                 break;
    280280         }
    281          
     281
    282282         if ('' != $regex && !preg_match($regex, $cc_num)) {
    283283             // Invalid format.
     
    324324            return false;
    325325        }
    326        
     326
    327327        if (is_array($_FILES[$form_name]['name'])) {
    328328            foreach($_FILES[$form_name]['name'] as $f) {
     
    336336            }
    337337        }
    338        
     338
    339339        return true;
    340340    }
  • branches/eli_branch/services/login.php

    r438 r447  
    44 * For details visit the project site: <http://trac.strangecode.com/codebase/>
    55 * Copyright 2001-2012 Strangecode, LLC
    6  * 
     6 *
    77 * This file is part of The Strangecode Codebase.
    88 *
     
    1111 * Free Software Foundation, either version 3 of the License, or (at your option)
    1212 * any later version.
    13  * 
     13 *
    1414 * The Strangecode Codebase is distributed in the hope that it will be useful, but
    1515 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1616 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
    1717 * details.
    18  * 
     18 *
    1919 * You should have received a copy of the GNU General Public License along with
    2020 * The Strangecode Codebase. If not, see <http://www.gnu.org/licenses/>.
  • branches/eli_branch/tests/AppTest.php

    r446 r447  
    113113    {
    114114        ob_start();
    115         //$this->test_raisemsg();  //had to add this line for phpunit ver. 3.7
     115        $this->test_raisemsg();  //had to add this line for phpunit ver. 3.7 ///
    116116        $app =& App::getInstance();
    117117        $app->printraisedmessages();
  • branches/eli_branch/tests/AuthSQLTest.php

    r446 r447  
    4747            'login_url'         => '/login.php',
    4848            'blocking'          => true,
    49             'encryption_type' => AUTH_ENCRYPT_MD5_HARDENED,
     49            'encryption_type' => Auth_SQL::ENCRYPT_MD5_HARDENED,
    5050        ));
    5151
     
    212212    function test_encryptpassword()
    213213    {
    214         $this->Auth_SQL->setParam(array('encryption_type' => AUTH_ENCRYPT_MD5));
     214        $this->Auth_SQL->setParam(array('encryption_type' => Auth_SQL::ENCRYPT_MD5));
    215215        $result = $this->Auth_SQL->encryptpassword('123');
    216216        $this->assertEquals('202cb962ac59075b964b07152d234b70', $result);
    217217
    218         $this->Auth_SQL->setParam(array('encryption_type' => AUTH_ENCRYPT_MD5_HARDENED));
     218        $this->Auth_SQL->setParam(array('encryption_type' => Auth_SQL::ENCRYPT_MD5_HARDENED));
    219219        $result = $this->Auth_SQL->encryptpassword('123');
    220220        $this->assertEquals('c55e4ac608a8768ecd758fab971b0646', $result);
    221221
    222         $this->Auth_SQL->setParam(array('encryption_type' => AUTH_ENCRYPT_SHA1));
     222        $this->Auth_SQL->setParam(array('encryption_type' => Auth_SQL::ENCRYPT_SHA1));
    223223        $result = $this->Auth_SQL->encryptpassword('123');
    224224        $this->assertEquals('40bd001563085fc35165329ea1ff5c5ecbdbbeef', $result);
    225225
    226         $this->Auth_SQL->setParam(array('encryption_type' => AUTH_ENCRYPT_SHA1_HARDENED));
     226        $this->Auth_SQL->setParam(array('encryption_type' => Auth_SQL::ENCRYPT_SHA1_HARDENED));
    227227        $result = $this->Auth_SQL->encryptpassword('123');
    228228        $this->assertEquals('33d90af96a5928ac93cbd41fc436e8c55d2768c2', $result);
    229229
    230         $this->Auth_SQL->setParam(array('encryption_type' => AUTH_ENCRYPT_PLAINTEXT));
     230        $this->Auth_SQL->setParam(array('encryption_type' => Auth_SQL::ENCRYPT_PLAINTEXT));
    231231        $result = $this->Auth_SQL->encryptpassword('123');
    232232        $this->assertEquals('123', $result);
    233233
    234         $this->Auth_SQL->setParam(array('encryption_type' => AUTH_ENCRYPT_CRYPT));
     234        $this->Auth_SQL->setParam(array('encryption_type' => Auth_SQL::ENCRYPT_CRYPT));
    235235        $result = $this->Auth_SQL->encryptpassword('123', 'saltstring');
    236236        $this->assertEquals('saEZ6MlWYV9nQ', $result);
     
    241241        $db =& DB::getInstance();
    242242
    243         $this->Auth_SQL->setParam(array('encryption_type' => AUTH_ENCRYPT_SHA1_HARDENED));
     243        $this->Auth_SQL->setParam(array('encryption_type' => Auth_SQL::ENCRYPT_SHA1_HARDENED));
    244244        $this->Auth_SQL->setpassword(null, '123');
    245245        $qid = $db->query("
  • branches/eli_branch/tests/Auth_SQLTest.php

    r446 r447  
    44 * For details visit the project site: <http://trac.strangecode.com/codebase/>
    55 * Copyright 2001-2012 Strangecode, LLC
    6  * 
     6 *
    77 * This file is part of The Strangecode Codebase.
    88 *
     
    1111 * Free Software Foundation, either version 3 of the License, or (at your option)
    1212 * any later version.
    13  * 
     13 *
    1414 * The Strangecode Codebase is distributed in the hope that it will be useful, but
    1515 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1616 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
    1717 * details.
    18  * 
     18 *
    1919 * You should have received a copy of the GNU General Public License along with
    2020 * The Strangecode Codebase. If not, see <http://www.gnu.org/licenses/>.
     
    5151            'login_url'         => '/login.php',
    5252            'blocking'          => true,
    53             'encryption_type' => AUTH_ENCRYPT_MD5_HARDENED,
     53            'encryption_type' => Auth_SQL::ENCRYPT_MD5_HARDENED,
    5454        ));
    5555
     
    8080    {
    8181        $db =& DB::getInstance();
    82    
     82
    8383        unset($this->Auth_SQL);
    8484        $db->query("DROP TABLE IF EXISTS test_user_tbl");
     
    145145        $after_logged_in = $this->Auth_SQL->isloggedin();
    146146        $this->assertFalse($after_logged_in, '3. User is still logged in but should not be.');
    147        
     147
    148148        // Testing wrong password.
    149149        $login2 = $this->Auth_SQL->login('testuser', 'wrongpass');
     
    164164    {
    165165        $db =& DB::getInstance();
    166    
     166
    167167        $this->Auth_SQL->login('testuser', 'testpass');
    168168        $this->Auth_SQL->blockaccount(null, 'blocktestuser');
     
    178178    {
    179179        $db =& DB::getInstance();
    180    
     180
    181181        $db->query("
    182182            UPDATE test_user_tbl SET blocked_reason = 'blocktestuser'
     
    212212    function test_encryptpassword()
    213213    {
    214         $this->Auth_SQL->setParam(array('encryption_type' => AUTH_ENCRYPT_MD5));
     214        $this->Auth_SQL->setParam(array('encryption_type' => Auth_SQL::ENCRYPT_MD5));
    215215        $result = $this->Auth_SQL->encryptpassword('123');
    216216        $this->assertEquals('202cb962ac59075b964b07152d234b70', $result);
    217217
    218         $this->Auth_SQL->setParam(array('encryption_type' => AUTH_ENCRYPT_MD5_HARDENED));
     218        $this->Auth_SQL->setParam(array('encryption_type' => Auth_SQL::ENCRYPT_MD5_HARDENED));
    219219        $result = $this->Auth_SQL->encryptpassword('123');
    220220        $this->assertEquals('c55e4ac608a8768ecd758fab971b0646', $result);
    221221
    222         $this->Auth_SQL->setParam(array('encryption_type' => AUTH_ENCRYPT_SHA1));
     222        $this->Auth_SQL->setParam(array('encryption_type' => Auth_SQL::ENCRYPT_SHA1));
    223223        $result = $this->Auth_SQL->encryptpassword('123');
    224224        $this->assertEquals('40bd001563085fc35165329ea1ff5c5ecbdbbeef', $result);
    225225
    226         $this->Auth_SQL->setParam(array('encryption_type' => AUTH_ENCRYPT_SHA1_HARDENED));
     226        $this->Auth_SQL->setParam(array('encryption_type' => Auth_SQL::ENCRYPT_SHA1_HARDENED));
    227227        $result = $this->Auth_SQL->encryptpassword('123');
    228228        $this->assertEquals('33d90af96a5928ac93cbd41fc436e8c55d2768c2', $result);
    229229
    230         $this->Auth_SQL->setParam(array('encryption_type' => AUTH_ENCRYPT_PLAINTEXT));
     230        $this->Auth_SQL->setParam(array('encryption_type' => Auth_SQL::ENCRYPT_PLAINTEXT));
    231231        $result = $this->Auth_SQL->encryptpassword('123');
    232232        $this->assertEquals('123', $result);
    233233
    234         $this->Auth_SQL->setParam(array('encryption_type' => AUTH_ENCRYPT_CRYPT));
     234        $this->Auth_SQL->setParam(array('encryption_type' => Auth_SQL::ENCRYPT_CRYPT));
    235235        $result = $this->Auth_SQL->encryptpassword('123', 'saltstring');
    236236        $this->assertEquals('saEZ6MlWYV9nQ', $result);
     
    240240    {
    241241        $db =& DB::getInstance();
    242    
    243         $this->Auth_SQL->setParam(array('encryption_type' => AUTH_ENCRYPT_SHA1_HARDENED));
     242
     243        $this->Auth_SQL->setParam(array('encryption_type' => Auth_SQL::ENCRYPT_SHA1_HARDENED));
    244244        $this->Auth_SQL->setpassword(null, '123');
    245245        $qid = $db->query("
  • branches/eli_branch/tests/DBSessionHandlerTest.php

    r442 r447  
    44 * For details visit the project site: <http://trac.strangecode.com/codebase/>
    55 * Copyright 2001-2012 Strangecode, LLC
    6  * 
     6 *
    77 * This file is part of The Strangecode Codebase.
    88 *
     
    1111 * Free Software Foundation, either version 3 of the License, or (at your option)
    1212 * any later version.
    13  * 
     13 *
    1414 * The Strangecode Codebase is distributed in the hope that it will be useful, but
    1515 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1616 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
    1717 * details.
    18  * 
     18 *
    1919 * You should have received a copy of the GNU General Public License along with
    2020 * The Strangecode Codebase. If not, see <http://www.gnu.org/licenses/>.
Note: See TracChangeset for help on using the changeset viewer.