@@ -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 | * @param boolean $temporary temporary failure? |
36 | 36 | * @param Exception $parent parent exception |
37 | 37 | */ |
38 | - public function __construct($message, $temporary=false, Exception $parent=null) |
|
38 | + public function __construct($message, $temporary = false, Exception $parent = null) |
|
39 | 39 | { |
40 | 40 | parent::__construct($message, $parent); |
41 | 41 | $this->_temporary = $temporary; |
@@ -97,9 +97,9 @@ |
||
97 | 97 | |
98 | 98 | // Wait and retry once in case of a 502 Bad Gateway error |
99 | 99 | if ($statusCode === 502 && !($retry)) { |
100 | - sleep(2); |
|
101 | - $this->_sendFirebase($deviceToken, $alert, $challenge, $apiKey, true); |
|
102 | - return; |
|
100 | + sleep(2); |
|
101 | + $this->_sendFirebase($deviceToken, $alert, $challenge, $apiKey, true); |
|
102 | + return; |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | if ($statusCode !== 200) { |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | * |
58 | 58 | * @throws Tiqr_Message_Exception_SendFailure |
59 | 59 | */ |
60 | - private function _sendFirebase($deviceToken, $alert, $challenge, $apiKey, $retry=false) |
|
60 | + private function _sendFirebase($deviceToken, $alert, $challenge, $apiKey, $retry = false) |
|
61 | 61 | { |
62 | 62 | $msg = array( |
63 | 63 | 'challenge' => $challenge, |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | ); |
72 | 72 | |
73 | 73 | $headers = array( |
74 | - 'Authorization: key=' . $apiKey, |
|
74 | + 'Authorization: key='.$apiKey, |
|
75 | 75 | 'Content-Type: application/json', |
76 | 76 | ); |
77 | 77 | |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | $result = curl_exec($ch); |
85 | 85 | $errors = curl_error($ch); |
86 | 86 | $statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); |
87 | - $remoteip = curl_getinfo($ch,CURLINFO_PRIMARY_IP); |
|
87 | + $remoteip = curl_getinfo($ch, CURLINFO_PRIMARY_IP); |
|
88 | 88 | curl_close($ch); |
89 | 89 | |
90 | 90 | if ($result === false) { |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | } |
93 | 93 | |
94 | 94 | if (!empty($errors)) { |
95 | - throw new Tiqr_Message_Exception_SendFailure("Http error occurred: ". $errors, true); |
|
95 | + throw new Tiqr_Message_Exception_SendFailure("Http error occurred: ".$errors, true); |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | // Wait and retry once in case of a 502 Bad Gateway error |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | $response = json_decode($result, true); |
111 | 111 | foreach ($response['results'] as $k => $v) { |
112 | 112 | if (isset($v['error'])) { |
113 | - throw new Tiqr_Message_Exception_SendFailure("Error in GCM response: " . $v['error'], true); |
|
113 | + throw new Tiqr_Message_Exception_SendFailure("Error in GCM response: ".$v['error'], true); |
|
114 | 114 | } |
115 | 115 | } |
116 | 116 | } |
@@ -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 . 'qrlib.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 . 'qrlib.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 | } |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | } |
24 | 24 | |
25 | 25 | public static function autoload($className) { |
26 | - if($className === NULL) { |
|
26 | + if ($className === NULL) { |
|
27 | 27 | return; |
28 | 28 | } |
29 | 29 | |
@@ -32,11 +32,11 @@ discard block |
||
32 | 32 | $substr5 = substr($className, 0, 5); |
33 | 33 | |
34 | 34 | if ($substr5 === 'Tiqr_' || $substr5 === 'OATH_') { |
35 | - $file = $self->tiqrPath . DIRECTORY_SEPARATOR . str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php'; |
|
35 | + $file = $self->tiqrPath.DIRECTORY_SEPARATOR.str_replace('_', DIRECTORY_SEPARATOR, $className).'.php'; |
|
36 | 36 | } elseif ($className === 'QRcode') { |
37 | - $file = $self->qrcodePath . DIRECTORY_SEPARATOR . 'qrlib.php'; |
|
37 | + $file = $self->qrcodePath.DIRECTORY_SEPARATOR.'qrlib.php'; |
|
38 | 38 | } elseif ($substr5 === 'Zend_') { |
39 | - $file = $self->zendPath . DIRECTORY_SEPARATOR . str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php'; |
|
39 | + $file = $self->zendPath.DIRECTORY_SEPARATOR.str_replace('_', DIRECTORY_SEPARATOR, $className).'.php'; |
|
40 | 40 | } else { |
41 | 41 | return; |
42 | 42 | } |
@@ -57,34 +57,34 @@ discard block |
||
57 | 57 | if (is_dir($tiqr_path)) { |
58 | 58 | $this->tiqrPath = $tiqr_path; |
59 | 59 | } else { |
60 | - throw new Exception('Directory not found: ' . var_export($tiqr_dir, TRUE)); |
|
60 | + throw new Exception('Directory not found: '.var_export($tiqr_dir, TRUE)); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | if (isset($options["phpqrcode.path"])) { |
64 | 64 | $qrcode_dir = $options["phpqrcode.path"]; |
65 | 65 | $qrcode_path = realpath($qrcode_dir); |
66 | 66 | } else { |
67 | - $qrcode_dir = dirname(dirname(dirname(__FILE__))) . '/phpqrcode'; |
|
67 | + $qrcode_dir = dirname(dirname(dirname(__FILE__))).'/phpqrcode'; |
|
68 | 68 | $qrcode_path = $qrcode_dir; |
69 | 69 | } |
70 | 70 | |
71 | 71 | if (is_dir($qrcode_path)) { |
72 | 72 | $this->qrcodePath = $qrcode_path; |
73 | 73 | } else { |
74 | - throw new Exception('Directory not found: ' . var_export($qrcode_dir, TRUE)); |
|
74 | + throw new Exception('Directory not found: '.var_export($qrcode_dir, TRUE)); |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | if (isset($options["zend.path"])) { |
78 | 78 | $zend_dir = $options["zend.path"]; |
79 | 79 | $zend_path = realpath($zend_dir); |
80 | 80 | } else { |
81 | - $zend_dir = dirname(dirname(dirname(__FILE__))) . "/zend"; |
|
81 | + $zend_dir = dirname(dirname(dirname(__FILE__)))."/zend"; |
|
82 | 82 | $zend_path = $zend_dir; |
83 | 83 | } |
84 | 84 | if (is_dir($zend_path)) { |
85 | 85 | $this->zendPath = $zend_path; |
86 | 86 | } else { |
87 | - throw new Exception('Directory not found: ' . var_export($zend_dir, TRUE)); |
|
87 | + throw new Exception('Directory not found: '.var_export($zend_dir, TRUE)); |
|
88 | 88 | } |
89 | 89 | } |
90 | 90 |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | * (non-PHPdoc) |
46 | 46 | * @see library/tiqr/Tiqr/StateStorage/Tiqr_StateStorage_Abstract::setValue() |
47 | 47 | */ |
48 | - public function setValue($key, $value, $expire=0) |
|
48 | + public function setValue($key, $value, $expire = 0) |
|
49 | 49 | { |
50 | 50 | if ($this->keyExists($key)) { |
51 | 51 | $sth = $this->handle->prepare("UPDATE ".$this->tablename." SET `value` = ?, `expire` = ? WHERE `key` = ?"); |
@@ -54,9 +54,9 @@ discard block |
||
54 | 54 | } |
55 | 55 | // $expire == 0 means never expire |
56 | 56 | if ($expire != 0) { |
57 | - $expire+=time(); // Store unix timestamp after which the expires |
|
57 | + $expire += time(); // Store unix timestamp after which the expires |
|
58 | 58 | } |
59 | - $res = $sth->execute(array(serialize($value),$expire,$key)); |
|
59 | + $res = $sth->execute(array(serialize($value), $expire, $key)); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | /** |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | if (false === $sth) { |
84 | 84 | return NULL; |
85 | 85 | } |
86 | - if (false === $sth->execute(array($key, time())) ) { |
|
86 | + if (false === $sth->execute(array($key, time()))) { |
|
87 | 87 | return NULL; |
88 | 88 | } |
89 | 89 | $result = $sth->fetchColumn(); |
@@ -92,10 +92,10 @@ discard block |
||
92 | 92 | return NULL; |
93 | 93 | } |
94 | 94 | |
95 | - public function __construct($config=array()) |
|
95 | + public function __construct($config = array()) |
|
96 | 96 | { |
97 | 97 | $this->tablename = $config['table']; |
98 | - $this->handle = new PDO($config['dsn'],$config['username'],$config['password']); |
|
98 | + $this->handle = new PDO($config['dsn'], $config['username'], $config['password']); |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | } |