public function linkData($link)
 {
     $results = array();
     $contents = \ipinga\crypto::printableDecrypt($link);
     if (is_array($contents) == true) {
         $linkUserId = $contents['u'];
         $linkTime = (double) $contents['t'];
         $t = \ipinga\options::get('password_link_timeout');
         if (empty($t) == true) {
             $timeout = 10;
         } else {
             $timeout = (double) $t;
         }
         $now = (double) microtime(true);
         $elapsedMinutes = ($now - $linkTime) / 60;
         if ($elapsedMinutes > $timeout) {
             $results['error'] = 1;
             $results['message'] = 'Password reset link has expired';
         } else {
             $results['error'] = 0;
             $results['message'] = 'No error.  Link is good.';
             $u = new \ipinga\userTable('users');
             $u->loadById($linkUserId);
             $results['user'] = $u;
         }
     } else {
         $results['error'] = 2;
         $results['message'] = 'Password reset link is invalid';
     }
     return $results;
 }
Example #2
0
 public static function decrypt($encryptedString)
 {
     $clearText = \ipinga\crypto::decrypt($encryptedString);
     $a = json_decode($clearText, true);
     return $a;
 }
Example #3
0
 /**
  * @param string $encryptedString (created by printableEncrypt())
  *
  * @return array Decrypted original value
  */
 public static function printableDecrypt($encryptedString)
 {
     $a = json_decode(\ipinga\crypto::decrypt(hex2bin($encryptedString)), true);
     return $a['k'];
 }
Example #4
0
 /**
  * Some other function prepares this and does all the binding.  All I am doing here is executing it in a common
  * fashion and populating all the fields() array
  *
  * @param \PDOStatement $stmt
  */
 protected function _process_loadby_execute($stmt)
 {
     try {
         $stmt->execute();
         $row = $stmt->fetch(\PDO::FETCH_ASSOC);
         foreach ($this->fieldTypes as $fieldName => $fieldType) {
             if ($fieldName == 'passwd') {
                 $this->field[$fieldName] = \ipinga\crypto::decrypt(hex2bin($row['passwd']));
             } else {
                 $this->field[$fieldName] = $row[$fieldName];
             }
         }
         if ($this->field['id'] < 1) {
             $this->saved = false;
         } else {
             $this->saved = true;
         }
     } catch (\Exception $e) {
         echo $e->getMessage() . '<br><hr>';
         $this->saved = false;
     }
 }