public static function get($password, $passHash)
 {
     // Gather Important Values
     $exp = explode("\$", $passHash, 2);
     $hashAlgo = $exp[0];
     // Prepare Salt
     $salt = SITE_SALT;
     // Prepare the Hash Algorithm to use
     $hashAlgo = "getPassAlgo_" . Sanitize::word($exp[0]);
     // Check if hash algorithm selected is valid
     if (method_exists("Password", $hashAlgo)) {
         return self::$hashAlgo($password, $passHash, $salt);
     }
     return self::getPassAlgo_default($password, $passHash, $salt);
 }
예제 #2
0
 public static function createHashColumn($table, $columnName)
 {
     // Sanitize
     $table = Sanitize::variable($table);
     $columnName = Sanitize::variable($columnName);
     $prefix = Sanitize::word(substr($table, 0, 4) . ucfirst(substr($columnName, 0, 6)));
     // Make sure table exists
     if (Database::tableExists($table)) {
         $colExists = false;
         // Add the hash column if it doesn't exist
         if (!Database::columnExists($table, $columnName)) {
             $colExists = Database::addColumn($table, $columnName . '_crc', "int(10) unsigned not null", 0);
         }
         if ($colExists) {
             // Create a Trigger
             self::exec('CREATE TRIGGER ' . $prefix . '_ins BEFORE INSERT ON ' . $table . ' FOR EACH ROW BEGIN SET NEW.' . $columnName . '_crc=crc32(NEW.' . $columnName . '); END;');
             return self::exec('CREATE TRIGGER ' . $prefix . '_upd BEFORE UPDATE ON ' . $table . ' FOR EACH ROW BEGIN SET NEW.' . $columnName . '_crc=crc32(NEW.' . $columnName . '); END; ');
         }
     }
     return false;
 }