@@ -39,8 +39,8 @@ discard block |
||
| 39 | 39 | public function setValue($key, $value, $expire=0) |
| 40 | 40 | { |
| 41 | 41 | $envelope = array("expire"=>$expire, |
| 42 | - "createdAt"=>time(), |
|
| 43 | - "value"=>$value); |
|
| 42 | + "createdAt"=>time(), |
|
| 43 | + "value"=>$value); |
|
| 44 | 44 | $filename = $this->_stateFilename($key); |
| 45 | 45 | |
| 46 | 46 | file_put_contents($filename, serialize($envelope)); |
@@ -70,11 +70,11 @@ discard block |
||
| 70 | 70 | if (file_exists($filename)) { |
| 71 | 71 | $envelope = unserialize(file_get_contents($filename)); |
| 72 | 72 | if ($envelope["expire"]!=0) { |
| 73 | - // This data is time-limited. If it's too old we discard it. |
|
| 74 | - if (time()-$envelope["createdAt"] > $envelope["expire"]) { |
|
| 75 | - $this->unsetValue($key); |
|
| 76 | - return NULL; |
|
| 77 | - } |
|
| 73 | + // This data is time-limited. If it's too old we discard it. |
|
| 74 | + if (time()-$envelope["createdAt"] > $envelope["expire"]) { |
|
| 75 | + $this->unsetValue($key); |
|
| 76 | + return NULL; |
|
| 77 | + } |
|
| 78 | 78 | } |
| 79 | 79 | return $envelope["value"]; |
| 80 | 80 | } |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | */ |
| 39 | 39 | public static function randomBytes($length) |
| 40 | 40 | { |
| 41 | - if(function_exists('openssl_random_pseudo_bytes')) { |
|
| 41 | + if(function_exists('openssl_random_pseudo_bytes')) { |
|
| 42 | 42 | $rnd = openssl_random_pseudo_bytes($length, $strong); |
| 43 | 43 | if($strong === TRUE && $rnd !== FALSE) { |
| 44 | 44 | return $rnd; |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | */ |
| 66 | 66 | public static function randomHexString($length) |
| 67 | 67 | { |
| 68 | - $result = bin2hex(self::randomBytes($length)); |
|
| 69 | - return $result; |
|
| 68 | + $result = bin2hex(self::randomBytes($length)); |
|
| 69 | + return $result; |
|
| 70 | 70 | } |
| 71 | 71 | } |
| 72 | 72 | \ No newline at end of file |
@@ -41,7 +41,7 @@ |
||
| 41 | 41 | public function encrypt($data); |
| 42 | 42 | |
| 43 | 43 | /** |
| 44 | - * Decrypts the given data. |
|
| 44 | + * Decrypts the given data. |
|
| 45 | 45 | * |
| 46 | 46 | * @param String $data Data to decrypt. |
| 47 | 47 | * |
@@ -57,7 +57,7 @@ |
||
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | /** |
| 60 | - * Decrypts the given data. |
|
| 60 | + * Decrypts the given data. |
|
| 61 | 61 | * |
| 62 | 62 | * @param String $data Data to decrypt. |
| 63 | 63 | * |
@@ -35,7 +35,7 @@ |
||
| 35 | 35 | protected $_userSecretStorage; |
| 36 | 36 | |
| 37 | 37 | /** |
| 38 | - * Constructor. |
|
| 38 | + * Constructor. |
|
| 39 | 39 | */ |
| 40 | 40 | public function __construct($config, $secretconfig = array()) |
| 41 | 41 | { |
@@ -127,7 +127,7 @@ |
||
| 127 | 127 | */ |
| 128 | 128 | public function __construct($config, $secretconfig = array()) |
| 129 | 129 | { |
| 130 | - parent::__construct($config, $secretconfig); |
|
| 130 | + parent::__construct($config, $secretconfig); |
|
| 131 | 131 | |
| 132 | 132 | $this->_userClass = isset($config['userClass']) ? $config['userClass'] : "tiqrPerson"; |
| 133 | 133 | $this->_dnPattern = isset($config['dnPattern']) ? $config['dnPattern'] : "%s"; |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | public function createUser($userId, $displayName) |
| 44 | 44 | { |
| 45 | 45 | $user = array("userId"=>$userId, |
| 46 | - "displayName"=>$displayName); |
|
| 46 | + "displayName"=>$displayName); |
|
| 47 | 47 | return $this->_saveUser($userId, $user); |
| 48 | 48 | } |
| 49 | 49 | |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | { |
| 78 | 78 | if ($data = $this->_loadUser($userId)) { |
| 79 | 79 | if (isset($data["notificationType"])) { |
| 80 | - return $data["notificationType"]; |
|
| 80 | + return $data["notificationType"]; |
|
| 81 | 81 | } |
| 82 | 82 | } |
| 83 | 83 | return NULL; |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | { |
| 103 | 103 | if ($data = $this->_loadUser($userId)) { |
| 104 | 104 | if (isset($data["notificationAddress"])) { |
| 105 | - return $data["notificationAddress"]; |
|
| 105 | + return $data["notificationAddress"]; |
|
| 106 | 106 | } |
| 107 | 107 | } |
| 108 | 108 | return NULL; |
@@ -94,8 +94,8 @@ |
||
| 94 | 94 | */ |
| 95 | 95 | public function getPath() |
| 96 | 96 | { |
| 97 | - if (substr($this->_path, -1)!="/") return $this->_path."/"; |
|
| 98 | - return $this->_path; |
|
| 97 | + if (substr($this->_path, -1)!="/") return $this->_path."/"; |
|
| 98 | + return $this->_path; |
|
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | } |
@@ -1,100 +1,100 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | class Tiqr_AutoLoader { |
| 3 | 3 | |
| 4 | - protected static $instance; |
|
| 5 | - |
|
| 6 | - protected $tiqrPath; |
|
| 7 | - protected $qrcodePath; |
|
| 8 | - protected $zendPath; |
|
| 9 | - |
|
| 10 | - protected function __construct($options) { |
|
| 11 | - if ($options !== NULL) { |
|
| 12 | - $this->setOptions($options); |
|
| 13 | - } |
|
| 14 | - spl_autoload_register(array(__CLASS__, 'autoload')); |
|
| 15 | - } |
|
| 16 | - |
|
| 17 | - public static function getInstance($options = NULL) { |
|
| 18 | - if (null === self::$instance) { |
|
| 19 | - self::$instance = new self($options); |
|
| 20 | - } |
|
| 21 | - |
|
| 22 | - return self::$instance; |
|
| 23 | - } |
|
| 24 | - |
|
| 25 | - public static function autoload($className) { |
|
| 26 | - if($className === NULL) { |
|
| 27 | - return; |
|
| 28 | - } |
|
| 29 | - |
|
| 30 | - $self = self::getInstance(); |
|
| 31 | - |
|
| 32 | - $substr5 = substr($className, 0, 5); |
|
| 33 | - |
|
| 34 | - if ($substr5 === 'Tiqr_' || $substr5 === 'OATH_') { |
|
| 35 | - $file = $self->tiqrPath . DIRECTORY_SEPARATOR . str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php'; |
|
| 36 | - } elseif ($className === 'QRcode') { |
|
| 37 | - $file = $self->qrcodePath . DIRECTORY_SEPARATOR . 'phpqrcode.php'; |
|
| 38 | - } elseif ($substr5 === 'Zend_') { |
|
| 39 | - $file = $self->zendPath . DIRECTORY_SEPARATOR . str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php'; |
|
| 40 | - } else { |
|
| 41 | - return; |
|
| 42 | - } |
|
| 43 | - |
|
| 44 | - if (file_exists($file)) { |
|
| 45 | - require_once($file); |
|
| 46 | - } |
|
| 47 | - } |
|
| 48 | - |
|
| 49 | - public function setOptions($options) { |
|
| 50 | - if (isset($options["tiqr.path"])) { |
|
| 51 | - $tiqr_dir = $options["tiqr.path"]; |
|
| 52 | - $tiqr_path = realpath($tiqr_dir); |
|
| 53 | - } else { |
|
| 54 | - $tiqr_dir = dirname(__FILE__); |
|
| 55 | - $tiqr_path = $tiqr_dir; |
|
| 56 | - } |
|
| 57 | - if (is_dir($tiqr_path)) { |
|
| 58 | - $this->tiqrPath = $tiqr_path; |
|
| 59 | - } else { |
|
| 60 | - throw new Exception('Directory not found: ' . var_export($tiqr_dir, TRUE)); |
|
| 61 | - } |
|
| 62 | - |
|
| 63 | - if (isset($options["phpqrcode.path"])) { |
|
| 64 | - $qrcode_dir = $options["phpqrcode.path"]; |
|
| 65 | - $qrcode_path = realpath($qrcode_dir); |
|
| 66 | - } else { |
|
| 67 | - $qrcode_dir = dirname(dirname(dirname(__FILE__))) . '/phpqrcode'; |
|
| 68 | - $qrcode_path = $qrcode_dir; |
|
| 69 | - } |
|
| 70 | - |
|
| 71 | - if (is_dir($qrcode_path)) { |
|
| 72 | - $this->qrcodePath = $qrcode_path; |
|
| 73 | - } else { |
|
| 74 | - throw new Exception('Directory not found: ' . var_export($qrcode_dir, TRUE)); |
|
| 75 | - } |
|
| 76 | - |
|
| 77 | - if (isset($options["zend.path"])) { |
|
| 78 | - $zend_dir = $options["zend.path"]; |
|
| 79 | - $zend_path = realpath($zend_dir); |
|
| 80 | - } else { |
|
| 81 | - $zend_dir = dirname(dirname(dirname(__FILE__))) . "/zend"; |
|
| 82 | - $zend_path = $zend_dir; |
|
| 83 | - } |
|
| 84 | - if (is_dir($zend_path)) { |
|
| 85 | - $this->zendPath = $zend_path; |
|
| 86 | - } else { |
|
| 87 | - throw new Exception('Directory not found: ' . var_export($zend_dir, TRUE)); |
|
| 88 | - } |
|
| 89 | - } |
|
| 90 | - |
|
| 91 | - |
|
| 92 | - public function setIncludePath() { |
|
| 93 | - set_include_path(implode(PATH_SEPARATOR, array( |
|
| 94 | - $this->tiqrPath, |
|
| 95 | - $this->zendPath, |
|
| 96 | - $this->qrcodePath, |
|
| 97 | - get_include_path(), |
|
| 98 | - ))); |
|
| 99 | - } |
|
| 4 | + protected static $instance; |
|
| 5 | + |
|
| 6 | + protected $tiqrPath; |
|
| 7 | + protected $qrcodePath; |
|
| 8 | + protected $zendPath; |
|
| 9 | + |
|
| 10 | + protected function __construct($options) { |
|
| 11 | + if ($options !== NULL) { |
|
| 12 | + $this->setOptions($options); |
|
| 13 | + } |
|
| 14 | + spl_autoload_register(array(__CLASS__, 'autoload')); |
|
| 15 | + } |
|
| 16 | + |
|
| 17 | + public static function getInstance($options = NULL) { |
|
| 18 | + if (null === self::$instance) { |
|
| 19 | + self::$instance = new self($options); |
|
| 20 | + } |
|
| 21 | + |
|
| 22 | + return self::$instance; |
|
| 23 | + } |
|
| 24 | + |
|
| 25 | + public static function autoload($className) { |
|
| 26 | + if($className === NULL) { |
|
| 27 | + return; |
|
| 28 | + } |
|
| 29 | + |
|
| 30 | + $self = self::getInstance(); |
|
| 31 | + |
|
| 32 | + $substr5 = substr($className, 0, 5); |
|
| 33 | + |
|
| 34 | + if ($substr5 === 'Tiqr_' || $substr5 === 'OATH_') { |
|
| 35 | + $file = $self->tiqrPath . DIRECTORY_SEPARATOR . str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php'; |
|
| 36 | + } elseif ($className === 'QRcode') { |
|
| 37 | + $file = $self->qrcodePath . DIRECTORY_SEPARATOR . 'phpqrcode.php'; |
|
| 38 | + } elseif ($substr5 === 'Zend_') { |
|
| 39 | + $file = $self->zendPath . DIRECTORY_SEPARATOR . str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php'; |
|
| 40 | + } else { |
|
| 41 | + return; |
|
| 42 | + } |
|
| 43 | + |
|
| 44 | + if (file_exists($file)) { |
|
| 45 | + require_once($file); |
|
| 46 | + } |
|
| 47 | + } |
|
| 48 | + |
|
| 49 | + public function setOptions($options) { |
|
| 50 | + if (isset($options["tiqr.path"])) { |
|
| 51 | + $tiqr_dir = $options["tiqr.path"]; |
|
| 52 | + $tiqr_path = realpath($tiqr_dir); |
|
| 53 | + } else { |
|
| 54 | + $tiqr_dir = dirname(__FILE__); |
|
| 55 | + $tiqr_path = $tiqr_dir; |
|
| 56 | + } |
|
| 57 | + if (is_dir($tiqr_path)) { |
|
| 58 | + $this->tiqrPath = $tiqr_path; |
|
| 59 | + } else { |
|
| 60 | + throw new Exception('Directory not found: ' . var_export($tiqr_dir, TRUE)); |
|
| 61 | + } |
|
| 62 | + |
|
| 63 | + if (isset($options["phpqrcode.path"])) { |
|
| 64 | + $qrcode_dir = $options["phpqrcode.path"]; |
|
| 65 | + $qrcode_path = realpath($qrcode_dir); |
|
| 66 | + } else { |
|
| 67 | + $qrcode_dir = dirname(dirname(dirname(__FILE__))) . '/phpqrcode'; |
|
| 68 | + $qrcode_path = $qrcode_dir; |
|
| 69 | + } |
|
| 70 | + |
|
| 71 | + if (is_dir($qrcode_path)) { |
|
| 72 | + $this->qrcodePath = $qrcode_path; |
|
| 73 | + } else { |
|
| 74 | + throw new Exception('Directory not found: ' . var_export($qrcode_dir, TRUE)); |
|
| 75 | + } |
|
| 76 | + |
|
| 77 | + if (isset($options["zend.path"])) { |
|
| 78 | + $zend_dir = $options["zend.path"]; |
|
| 79 | + $zend_path = realpath($zend_dir); |
|
| 80 | + } else { |
|
| 81 | + $zend_dir = dirname(dirname(dirname(__FILE__))) . "/zend"; |
|
| 82 | + $zend_path = $zend_dir; |
|
| 83 | + } |
|
| 84 | + if (is_dir($zend_path)) { |
|
| 85 | + $this->zendPath = $zend_path; |
|
| 86 | + } else { |
|
| 87 | + throw new Exception('Directory not found: ' . var_export($zend_dir, TRUE)); |
|
| 88 | + } |
|
| 89 | + } |
|
| 90 | + |
|
| 91 | + |
|
| 92 | + public function setIncludePath() { |
|
| 93 | + set_include_path(implode(PATH_SEPARATOR, array( |
|
| 94 | + $this->tiqrPath, |
|
| 95 | + $this->zendPath, |
|
| 96 | + $this->qrcodePath, |
|
| 97 | + get_include_path(), |
|
| 98 | + ))); |
|
| 99 | + } |
|
| 100 | 100 | } |