@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | public function ldapSlashes($str) { |
104 | 104 | return preg_replace_callback( |
105 | 105 | '/([\x00-\x1F\*\(\)\\\\])/', |
106 | - function ($matches) { |
|
106 | + function($matches) { |
|
107 | 107 | return "\\".join("", unpack("H2", $matches[1])); |
108 | 108 | }, |
109 | 109 | $str |
@@ -150,14 +150,14 @@ discard block |
||
150 | 150 | $auth = hexdec(substr($hex_sid, 4, 12)); |
151 | 151 | $result = "$rev-$auth"; |
152 | 152 | |
153 | - for ($x=0;$x < $subcount; $x++) { |
|
153 | + for ($x = 0; $x < $subcount; $x++) { |
|
154 | 154 | $subauth[$x] = |
155 | 155 | hexdec($this->littleEndian(substr($hex_sid, 16 + ($x * 8), 8))); |
156 | - $result .= "-" . $subauth[$x]; |
|
156 | + $result .= "-".$subauth[$x]; |
|
157 | 157 | } |
158 | 158 | |
159 | 159 | // Cheat by tacking on the S- |
160 | - return 'S-' . $result; |
|
160 | + return 'S-'.$result; |
|
161 | 161 | } |
162 | 162 | |
163 | 163 | /** |
@@ -129,14 +129,14 @@ |
||
129 | 129 | public function groups($computerName, $recursive = NULL) { |
130 | 130 | if ($computerName === NULL) { return false; } |
131 | 131 | if ($recursive === NULL) { $recursive = $this->adldap->getRecursiveGroups(); } //use the default option if they haven't set it |
132 | - if (!$this->adldap->getLdapBind()){ return false; } |
|
132 | + if (!$this->adldap->getLdapBind()) { return false; } |
|
133 | 133 | |
134 | 134 | //search the directory for their information |
135 | 135 | $info = @$this->info($computerName, array("memberof", "primarygroupid")); |
136 | 136 | $groups = $this->adldap->utilities()->niceNames($info[0]["memberof"]); //presuming the entry returned is our guy (unique usernames) |
137 | 137 | |
138 | 138 | if ($recursive === true) { |
139 | - foreach ($groups as $id => $groupName){ |
|
139 | + foreach ($groups as $id => $groupName) { |
|
140 | 140 | $extraGroups = $this->adldap->group()->recursiveGroups($groupName); |
141 | 141 | $groups = array_merge($groups, $extraGroups); |
142 | 142 | } |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | public $nested_transactions_count = 0; |
161 | 161 | |
162 | 162 | |
163 | - public function __construct($host=null, $user=null, $password=null, $dbName=null, $port=null, $encoding=null) { |
|
163 | + public function __construct($host = null, $user = null, $password = null, $dbName = null, $port = null, $encoding = null) { |
|
164 | 164 | if ($host === null) $host = DB::$host; |
165 | 165 | if ($user === null) $user = DB::$user; |
166 | 166 | if ($password === null) $password = DB::$password; |
@@ -180,13 +180,13 @@ discard block |
||
180 | 180 | $mysql = $this->internal_mysql; |
181 | 181 | |
182 | 182 | if (!($mysql instanceof MySQLi)) { |
183 | - if (! $this->port) $this->port = ini_get('mysqli.default_port'); |
|
183 | + if (!$this->port) $this->port = ini_get('mysqli.default_port'); |
|
184 | 184 | $this->current_db = $this->dbName; |
185 | 185 | |
186 | 186 | $mysql = new mysqli($this->host, $this->user, $this->password, $this->dbName, $this->port); |
187 | 187 | |
188 | 188 | if ($mysql->connect_error) { |
189 | - $this->nonSQLError('Unable to connect to MySQL server! Error: ' . $mysql->connect_error); |
|
189 | + $this->nonSQLError('Unable to connect to MySQL server! Error: '.$mysql->connect_error); |
|
190 | 190 | } |
191 | 191 | |
192 | 192 | $mysql->set_charset($this->encoding); |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | public function useDB() { $args = func_get_args(); return call_user_func_array(array($this, 'setDB'), $args); } |
235 | 235 | public function setDB($dbName) { |
236 | 236 | $db = $this->get(); |
237 | - if (! $db->select_db($dbName)) { |
|
237 | + if (!$db->select_db($dbName)) { |
|
238 | 238 | $this->nonSQLError("Unable to set database to $dbName"); |
239 | 239 | } |
240 | 240 | $this->current_db = $dbName; |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | |
244 | 244 | public function startTransaction() { |
245 | 245 | if ($this->nested_transactions && $this->serverVersion() < '5.5') { |
246 | - return $this->nonSQLError("Nested transactions are only available on MySQL 5.5 and greater. You are using MySQL " . $this->serverVersion()); |
|
246 | + return $this->nonSQLError("Nested transactions are only available on MySQL 5.5 and greater. You are using MySQL ".$this->serverVersion()); |
|
247 | 247 | } |
248 | 248 | |
249 | 249 | if (!$this->nested_transactions || $this->nested_transactions_count == 0) { |
@@ -257,9 +257,9 @@ discard block |
||
257 | 257 | return $this->nested_transactions_count; |
258 | 258 | } |
259 | 259 | |
260 | - public function commit($all=false) { |
|
260 | + public function commit($all = false) { |
|
261 | 261 | if ($this->nested_transactions && $this->serverVersion() < '5.5') { |
262 | - return $this->nonSQLError("Nested transactions are only available on MySQL 5.5 and greater. You are using MySQL " . $this->serverVersion()); |
|
262 | + return $this->nonSQLError("Nested transactions are only available on MySQL 5.5 and greater. You are using MySQL ".$this->serverVersion()); |
|
263 | 263 | } |
264 | 264 | |
265 | 265 | if ($this->nested_transactions && $this->nested_transactions_count > 0) |
@@ -275,9 +275,9 @@ discard block |
||
275 | 275 | return $this->nested_transactions_count; |
276 | 276 | } |
277 | 277 | |
278 | - public function rollback($all=false) { |
|
278 | + public function rollback($all = false) { |
|
279 | 279 | if ($this->nested_transactions && $this->serverVersion() < '5.5') { |
280 | - return $this->nonSQLError("Nested transactions are only available on MySQL 5.5 and greater. You are using MySQL " . $this->serverVersion()); |
|
280 | + return $this->nonSQLError("Nested transactions are only available on MySQL 5.5 and greater. You are using MySQL ".$this->serverVersion()); |
|
281 | 281 | } |
282 | 282 | |
283 | 283 | if ($this->nested_transactions && $this->nested_transactions_count > 0) |
@@ -297,7 +297,7 @@ discard block |
||
297 | 297 | $table = trim($table, '`'); |
298 | 298 | |
299 | 299 | if (strpos($table, '.')) return implode('.', array_map(array($this, 'formatTableName'), explode('.', $table))); |
300 | - else return '`' . str_replace('`', '``', $table) . '`'; |
|
300 | + else return '`'.str_replace('`', '``', $table).'`'; |
|
301 | 301 | } |
302 | 302 | |
303 | 303 | public function update() { |
@@ -317,14 +317,14 @@ discard block |
||
317 | 317 | /** |
318 | 318 | * @param string $which |
319 | 319 | */ |
320 | - public function insertOrReplace($which, $table, $datas, $options=array()) { |
|
320 | + public function insertOrReplace($which, $table, $datas, $options = array()) { |
|
321 | 321 | $datas = unserialize(serialize($datas)); // break references within array |
322 | 322 | $keys = $values = array(); |
323 | 323 | |
324 | 324 | if (isset($datas[0]) && is_array($datas[0])) { |
325 | 325 | foreach ($datas as $datum) { |
326 | 326 | ksort($datum); |
327 | - if (! $keys) { |
|
327 | + if (!$keys) { |
|
328 | 328 | $keys = array_keys($datum); |
329 | 329 | } |
330 | 330 | $values[] = array_values($datum); |
@@ -425,20 +425,20 @@ discard block |
||
425 | 425 | $named_seperator_length = strlen($this->named_param_seperator); |
426 | 426 | |
427 | 427 | $types = array( |
428 | - $this->param_char . 'll', // list of literals |
|
429 | - $this->param_char . 'ls', // list of strings |
|
430 | - $this->param_char . 'l', // literal |
|
431 | - $this->param_char . 'li', // list of integers |
|
432 | - $this->param_char . 'ld', // list of decimals |
|
433 | - $this->param_char . 'lb', // list of backticks |
|
434 | - $this->param_char . 'lt', // list of timestamps |
|
435 | - $this->param_char . 's', // string |
|
436 | - $this->param_char . 'i', // integer |
|
437 | - $this->param_char . 'd', // double / decimal |
|
438 | - $this->param_char . 'b', // backtick |
|
439 | - $this->param_char . 't', // timestamp |
|
440 | - $this->param_char . '?', // infer type |
|
441 | - $this->param_char . 'ss' // search string (like string, surrounded with %'s) |
|
428 | + $this->param_char.'ll', // list of literals |
|
429 | + $this->param_char.'ls', // list of strings |
|
430 | + $this->param_char.'l', // literal |
|
431 | + $this->param_char.'li', // list of integers |
|
432 | + $this->param_char.'ld', // list of decimals |
|
433 | + $this->param_char.'lb', // list of backticks |
|
434 | + $this->param_char.'lt', // list of timestamps |
|
435 | + $this->param_char.'s', // string |
|
436 | + $this->param_char.'i', // integer |
|
437 | + $this->param_char.'d', // double / decimal |
|
438 | + $this->param_char.'b', // backtick |
|
439 | + $this->param_char.'t', // timestamp |
|
440 | + $this->param_char.'?', // infer type |
|
441 | + $this->param_char.'ss' // search string (like string, surrounded with %'s) |
|
442 | 442 | ); |
443 | 443 | |
444 | 444 | // generate list of all MeekroDB variables in our query, and their position |
@@ -513,7 +513,7 @@ discard block |
||
513 | 513 | return $chunkyQuery; |
514 | 514 | } |
515 | 515 | |
516 | - protected function escape($str) { return "'" . $this->get()->real_escape_string(strval($str)) . "'"; } |
|
516 | + protected function escape($str) { return "'".$this->get()->real_escape_string(strval($str))."'"; } |
|
517 | 517 | |
518 | 518 | protected function sanitize($value) { |
519 | 519 | if (is_object($value)) { |
@@ -531,12 +531,12 @@ discard block |
||
531 | 531 | // non-assoc array? |
532 | 532 | if (array_values($value) === $value) { |
533 | 533 | if (is_array($value[0])) return implode(', ', array_map(array($this, 'sanitize'), $value)); |
534 | - else return '(' . implode(', ', array_map(array($this, 'sanitize'), $value)) . ')'; |
|
534 | + else return '('.implode(', ', array_map(array($this, 'sanitize'), $value)).')'; |
|
535 | 535 | } |
536 | 536 | |
537 | 537 | $pairs = array(); |
538 | 538 | foreach ($value as $k => $v) { |
539 | - $pairs[] = $this->formatTableName($k) . '=' . $this->sanitize($v); |
|
539 | + $pairs[] = $this->formatTableName($k).'='.$this->sanitize($v); |
|
540 | 540 | } |
541 | 541 | |
542 | 542 | return implode(', ', $pairs); |
@@ -712,7 +712,7 @@ discard block |
||
712 | 712 | if ($full_names) { |
713 | 713 | $infos = array(); |
714 | 714 | foreach ($result->fetch_fields() as $info) { |
715 | - if (strlen($info->table)) $infos[] = $info->table . '.' . $info->name; |
|
715 | + if (strlen($info->table)) $infos[] = $info->table.'.'.$info->name; |
|
716 | 716 | else $infos[] = $info->name; |
717 | 717 | } |
718 | 718 | } |
@@ -843,12 +843,12 @@ discard block |
||
843 | 843 | if ($this->clauses[$i] instanceof WhereClause) { |
844 | 844 | $this->clauses[$i]->negate(); |
845 | 845 | } else { |
846 | - $this->clauses[$i]['sql'] = 'NOT (' . $this->clauses[$i]['sql'] . ')'; |
|
846 | + $this->clauses[$i]['sql'] = 'NOT ('.$this->clauses[$i]['sql'].')'; |
|
847 | 847 | } |
848 | 848 | } |
849 | 849 | |
850 | 850 | function negate() { |
851 | - $this->negate = ! $this->negate; |
|
851 | + $this->negate = !$this->negate; |
|
852 | 852 | } |
853 | 853 | |
854 | 854 | function addClause($type) { |
@@ -900,7 +900,7 @@ discard block |
||
900 | 900 | DB::startTransaction(); |
901 | 901 | } |
902 | 902 | function __destruct() { |
903 | - if (! $this->committed) DB::rollback(); |
|
903 | + if (!$this->committed) DB::rollback(); |
|
904 | 904 | } |
905 | 905 | function commit() { |
906 | 906 | DB::commit(); |
@@ -913,7 +913,7 @@ discard block |
||
913 | 913 | class MeekroDBException extends Exception { |
914 | 914 | protected $query = ''; |
915 | 915 | |
916 | - function __construct($message='', $query='', $code = 0) { |
|
916 | + function __construct($message = '', $query = '', $code = 0) { |
|
917 | 917 | parent::__construct($message); |
918 | 918 | $this->query = $query; |
919 | 919 | $this->code = $code; |
@@ -934,10 +934,10 @@ discard block |
||
934 | 934 | |
935 | 935 | $R = array(); |
936 | 936 | foreach ($array as $obj) { |
937 | - if (! array_key_exists($field, $obj)) die("verticalSlice: array doesn't have requested field\n"); |
|
937 | + if (!array_key_exists($field, $obj)) die("verticalSlice: array doesn't have requested field\n"); |
|
938 | 938 | |
939 | 939 | if ($keyfield) { |
940 | - if (! array_key_exists($keyfield, $obj)) die("verticalSlice: array doesn't have requested field\n"); |
|
940 | + if (!array_key_exists($keyfield, $obj)) die("verticalSlice: array doesn't have requested field\n"); |
|
941 | 941 | $R[$obj[$keyfield]] = $obj[$field]; |
942 | 942 | } else { |
943 | 943 | $R[] = $obj[$field]; |
@@ -958,13 +958,13 @@ discard block |
||
958 | 958 | |
959 | 959 | $R = array(); |
960 | 960 | foreach ($array as $obj) { |
961 | - $target =& $R; |
|
961 | + $target = & $R; |
|
962 | 962 | |
963 | 963 | foreach ($fields as $field) { |
964 | - if (! array_key_exists($field, $obj)) die("reIndex: array doesn't have requested field\n"); |
|
964 | + if (!array_key_exists($field, $obj)) die("reIndex: array doesn't have requested field\n"); |
|
965 | 965 | |
966 | 966 | $nextkey = $obj[$field]; |
967 | - $target =& $target[$nextkey]; |
|
967 | + $target = & $target[$nextkey]; |
|
968 | 968 | } |
969 | 969 | $target = $obj; |
970 | 970 | } |
@@ -979,7 +979,7 @@ discard block |
||
979 | 979 | } |
980 | 980 | |
981 | 981 | function meekrodb_debugmode_handler($params) { |
982 | - echo "QUERY: " . $params['query'] . " [" . $params['runtime'] . " ms]"; |
|
982 | + echo "QUERY: ".$params['query']." [".$params['runtime']." ms]"; |
|
983 | 983 | if (php_sapi_name() == 'cli' && empty($_SERVER['REMOTE_ADDR'])) { |
984 | 984 | echo "\n"; |
985 | 985 | } else { |
@@ -18,7 +18,7 @@ |
||
18 | 18 | $PHPMAILER_LANG['invalid_address'] = 'الإرسال غير ممكن لأن عنوان البريد الإلكتروني غير صالح: '; |
19 | 19 | $PHPMAILER_LANG['mailer_not_supported'] = ' برنامج الإرسال غير مدعوم.'; |
20 | 20 | $PHPMAILER_LANG['provide_address'] = 'يجب توفير عنوان البريد الإلكتروني لمستلم واحد على الأقل.'; |
21 | -$PHPMAILER_LANG['recipients_failed'] = 'خطأ SMTP: الأخطاء التالية ' . |
|
21 | +$PHPMAILER_LANG['recipients_failed'] = 'خطأ SMTP: الأخطاء التالية '. |
|
22 | 22 | 'فشل في الارسال لكل من : '; |
23 | 23 | $PHPMAILER_LANG['signing'] = 'خطأ في التوقيع: '; |
24 | 24 | $PHPMAILER_LANG['smtp_connect_failed'] = 'SMTP Connect() غير ممكن.'; |
@@ -17,17 +17,17 @@ discard block |
||
17 | 17 | const ERR_SKEY = 'ERR|The Duo secret key passed to sign_request() is invalid.'; |
18 | 18 | const ERR_AKEY = 'ERR|The application secret key passed to sign_request() must be at least 40 characters.'; |
19 | 19 | |
20 | - private static function sign_vals($key, $vals, $prefix, $expire, $time=NULL) { |
|
20 | + private static function sign_vals($key, $vals, $prefix, $expire, $time = NULL) { |
|
21 | 21 | $exp = ($time ? $time : time()) + $expire; |
22 | - $val = $vals . '|' . $exp; |
|
22 | + $val = $vals.'|'.$exp; |
|
23 | 23 | $b64 = base64_encode($val); |
24 | - $cookie = $prefix . '|' . $b64; |
|
24 | + $cookie = $prefix.'|'.$b64; |
|
25 | 25 | |
26 | 26 | $sig = hash_hmac("sha1", $cookie, $key); |
27 | - return $cookie . '|' . $sig; |
|
27 | + return $cookie.'|'.$sig; |
|
28 | 28 | } |
29 | 29 | |
30 | - private static function parse_vals($key, $val, $prefix, $ikey, $time=NULL) { |
|
30 | + private static function parse_vals($key, $val, $prefix, $ikey, $time = NULL) { |
|
31 | 31 | $ts = ($time ? $time : time()); |
32 | 32 | |
33 | 33 | $parts = explode('|', $val); |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | } |
37 | 37 | list($u_prefix, $u_b64, $u_sig) = $parts; |
38 | 38 | |
39 | - $sig = hash_hmac("sha1", $u_prefix . '|' . $u_b64, $key); |
|
39 | + $sig = hash_hmac("sha1", $u_prefix.'|'.$u_b64, $key); |
|
40 | 40 | if (hash_hmac("sha1", $sig, $key) !== hash_hmac("sha1", $u_sig, $key)) { |
41 | 41 | return null; |
42 | 42 | } |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | return $user; |
62 | 62 | } |
63 | 63 | |
64 | - public static function signRequest($ikey, $skey, $akey, $username, $time=NULL) { |
|
64 | + public static function signRequest($ikey, $skey, $akey, $username, $time = NULL) { |
|
65 | 65 | if (!isset($username) || strlen($username) === 0) { |
66 | 66 | return self::ERR_USER; |
67 | 67 | } |
@@ -78,15 +78,15 @@ discard block |
||
78 | 78 | return self::ERR_AKEY; |
79 | 79 | } |
80 | 80 | |
81 | - $vals = $username . '|' . $ikey; |
|
81 | + $vals = $username.'|'.$ikey; |
|
82 | 82 | |
83 | 83 | $duo_sig = self::sign_vals($skey, $vals, self::DUO_PREFIX, self::DUO_EXPIRE, $time); |
84 | 84 | $app_sig = self::sign_vals($akey, $vals, self::APP_PREFIX, self::APP_EXPIRE, $time); |
85 | 85 | |
86 | - return $duo_sig . ':' . $app_sig; |
|
86 | + return $duo_sig.':'.$app_sig; |
|
87 | 87 | } |
88 | 88 | |
89 | - public static function verifyResponse($ikey, $skey, $akey, $sig_response, $time=NULL) { |
|
89 | + public static function verifyResponse($ikey, $skey, $akey, $sig_response, $time = NULL) { |
|
90 | 90 | list($auth_sig, $app_sig) = explode(':', $sig_response); |
91 | 91 | |
92 | 92 | $auth_user = self::parse_vals($skey, $auth_sig, self::AUTH_PREFIX, $ikey, $time); |
@@ -389,7 +389,7 @@ discard block |
||
389 | 389 | elseif ($this->_key <> "") { |
390 | 390 | /* Case 2. Verify signature first */ |
391 | 391 | $rows = explode("\r\n", trim($str)); |
392 | - $response=array(); |
|
392 | + $response = array(); |
|
393 | 393 | while (list($key, $val) = each($rows)) { |
394 | 394 | /* = is also used in BASE64 encoding so we only replace the first = by # which is not used in BASE64 */ |
395 | 395 | $val = preg_replace('/=/', '#', $val, 1); |
@@ -397,13 +397,13 @@ discard block |
||
397 | 397 | $response[$row[0]] = $row[1]; |
398 | 398 | } |
399 | 399 | |
400 | - $parameters=array('nonce','otp', 'sessioncounter', 'sessionuse', 'sl', 'status', 't', 'timeout', 'timestamp'); |
|
400 | + $parameters = array('nonce', 'otp', 'sessioncounter', 'sessionuse', 'sl', 'status', 't', 'timeout', 'timestamp'); |
|
401 | 401 | sort($parameters); |
402 | - $check=Null; |
|
402 | + $check = Null; |
|
403 | 403 | foreach ($parameters as $param) { |
404 | 404 | if (array_key_exists($param, $response)) { |
405 | - if ($check) $check = $check . '&'; |
|
406 | - $check = $check . $param . '=' . $response[$param]; |
|
405 | + if ($check) $check = $check.'&'; |
|
406 | + $check = $check.$param.'='.$response[$param]; |
|
407 | 407 | } |
408 | 408 | } |
409 | 409 | |
@@ -411,25 +411,25 @@ discard block |
||
411 | 411 | base64_encode(hash_hmac('sha1', utf8_encode($check), |
412 | 412 | $this->_key, true)); |
413 | 413 | |
414 | - if($response['h'] == $checksignature) { |
|
414 | + if ($response['h'] == $checksignature) { |
|
415 | 415 | if ($status == 'REPLAYED_OTP') { |
416 | 416 | if (!$wait_for_all) { $this->_response = $str; } |
417 | - $replay=True; |
|
417 | + $replay = True; |
|
418 | 418 | } |
419 | 419 | if ($status == 'OK') { |
420 | 420 | if (!$wait_for_all) { $this->_response = $str; } |
421 | - $valid=True; |
|
421 | + $valid = True; |
|
422 | 422 | } |
423 | 423 | } |
424 | 424 | } else { |
425 | 425 | /* Case 3. We check the status directly */ |
426 | 426 | if ($status == 'REPLAYED_OTP') { |
427 | 427 | if (!$wait_for_all) { $this->_response = $str; } |
428 | - $replay=True; |
|
428 | + $replay = True; |
|
429 | 429 | } |
430 | 430 | if ($status == 'OK') { |
431 | 431 | if (!$wait_for_all) { $this->_response = $str; } |
432 | - $valid=True; |
|
432 | + $valid = True; |
|
433 | 433 | } |
434 | 434 | } |
435 | 435 | } |
@@ -448,7 +448,7 @@ discard block |
||
448 | 448 | |
449 | 449 | curl_multi_remove_handle($mh, $info['handle']); |
450 | 450 | curl_close($info['handle']); |
451 | - unset ($ch[(int)$info['handle']]); |
|
451 | + unset ($ch[(int) $info['handle']]); |
|
452 | 452 | } |
453 | 453 | curl_multi_select($mh); |
454 | 454 | } |
@@ -460,10 +460,10 @@ discard block |
||
460 | 460 | */ |
461 | 461 | |
462 | 462 | foreach ($ch as $h) { |
463 | - curl_multi_remove_handle ($mh, $h); |
|
464 | - curl_close ($h); |
|
463 | + curl_multi_remove_handle($mh, $h); |
|
464 | + curl_close($h); |
|
465 | 465 | } |
466 | - curl_multi_close ($mh); |
|
466 | + curl_multi_close($mh); |
|
467 | 467 | |
468 | 468 | if ($replay) return PEAR::raiseError('REPLAYED_OTP'); |
469 | 469 | if ($valid) return true; |
@@ -52,21 +52,21 @@ discard block |
||
52 | 52 | // get frame delay from GET request, default to "safe speed" if delay not |
53 | 53 | // defined or invalid. delay is specified in ms in the request and needs |
54 | 54 | // to be converted to 1/100s for use in GIF files |
55 | - $delay = isset($_GET['delay']) ? ($_GET['delay']+0)/10 : 8; |
|
55 | + $delay = isset($_GET['delay']) ? ($_GET['delay'] + 0) / 10 : 8; |
|
56 | 56 | $delay = ($delay > 0) ? $delay : 8; |
57 | 57 | |
58 | 58 | // code string must only contain hex characters, code length is limited to |
59 | 59 | // 1024 characters (512 frames) |
60 | 60 | $codelen = strlen($code); |
61 | - if ( ctype_xdigit($code) && $codelen < 1024 ) { |
|
61 | + if (ctype_xdigit($code) && $codelen < 1024) { |
|
62 | 62 | |
63 | 63 | // get prepared gif file header |
64 | - $gif = file_get_contents($path.'/head.bin'); |
|
64 | + $gif = file_get_contents($path.'/head.bin'); |
|
65 | 65 | |
66 | 66 | // build graphic control extension block |
67 | 67 | // disposal method = 0 |
68 | 68 | // transparent color = 255 |
69 | - $ext = "\x21\xf9\x04\x01".chr($delay&0xff).chr(($delay>>8)&0xff)."\xff\x00"; |
|
69 | + $ext = "\x21\xf9\x04\x01".chr($delay & 0xff).chr(($delay >> 8) & 0xff)."\xff\x00"; |
|
70 | 70 | |
71 | 71 | // output image header |
72 | 72 | header('Content-type:image/gif'); |
@@ -74,28 +74,28 @@ discard block |
||
74 | 74 | |
75 | 75 | // append image data blocks as necessary |
76 | 76 | $size = filesize($path.'/data.bin'); |
77 | - $data = fopen($path.'/data.bin','r'); |
|
77 | + $data = fopen($path.'/data.bin', 'r'); |
|
78 | 78 | if ($data) { |
79 | 79 | |
80 | 80 | // load the index from the data file and unpack it into a PHP array. |
81 | 81 | // the index array contains the file offsets of the 4096 delta and |
82 | 82 | // base images inside the data file. |
83 | - $index = unpack("V*", fread($data, 64*64*4)); |
|
83 | + $index = unpack("V*", fread($data, 64 * 64 * 4)); |
|
84 | 84 | |
85 | 85 | // when a code is repeated (prev and curr have the same value) a |
86 | 86 | // base image is inserted instead of a delta image. the first frame |
87 | 87 | // in the animation must be a base image, so we peek at the flicker |
88 | 88 | // code and set $prev to the first value in the string |
89 | 89 | $prev = hexdec(substr($code, 0, 2)); |
90 | - for ($i = 0; $i < $codelen; $i+=2) { |
|
90 | + for ($i = 0; $i < $codelen; $i += 2) { |
|
91 | 91 | |
92 | 92 | // get current code |
93 | 93 | $curr = hexdec(substr($code, $i, 2)); |
94 | 94 | |
95 | 95 | // locate image block in data file |
96 | - $blockIdx = $prev*64+$curr+1; // array starts at 1 |
|
96 | + $blockIdx = $prev * 64 + $curr + 1; // array starts at 1 |
|
97 | 97 | $blockPos = $index[$blockIdx]; |
98 | - $blockLen = ($blockIdx < 4096 ? $index[$blockIdx+1] : $size) - $blockPos; |
|
98 | + $blockLen = ($blockIdx < 4096 ? $index[$blockIdx + 1] : $size) - $blockPos; |
|
99 | 99 | |
100 | 100 | // output extension header |
101 | 101 | print($ext); |
@@ -95,12 +95,12 @@ |
||
95 | 95 | session_cache_limiter(''); |
96 | 96 | session_start(); |
97 | 97 | |
98 | - $v = (isset($_SERVER) ? self::safe_serialize($_SERVER) : '') . |
|
99 | - (isset($_POST) ? self::safe_serialize($_POST) : '') . |
|
100 | - (isset($_GET) ? self::safe_serialize($_GET) : '') . |
|
101 | - (isset($_COOKIE) ? self::safe_serialize($_COOKIE) : '') . |
|
102 | - self::safe_serialize($GLOBALS) . |
|
103 | - self::safe_serialize($_SESSION) . |
|
98 | + $v = (isset($_SERVER) ? self::safe_serialize($_SERVER) : ''). |
|
99 | + (isset($_POST) ? self::safe_serialize($_POST) : ''). |
|
100 | + (isset($_GET) ? self::safe_serialize($_GET) : ''). |
|
101 | + (isset($_COOKIE) ? self::safe_serialize($_COOKIE) : ''). |
|
102 | + self::safe_serialize($GLOBALS). |
|
103 | + self::safe_serialize($_SESSION). |
|
104 | 104 | self::safe_serialize($_OLD_SESSION); |
105 | 105 | $v = $seed = $_SESSION['seed'] = sha1($v, true); |
106 | 106 | if (!isset($_SESSION['count'])) { |
@@ -419,18 +419,18 @@ discard block |
||
419 | 419 | $l = $in[1]; |
420 | 420 | $r = $in[2]; |
421 | 421 | |
422 | - for ($i = 0; $i < 16; $i+= 2) { |
|
423 | - $l^= $p[$i]; |
|
424 | - $r^= ($sb_0[$l >> 24 & 0xff] + |
|
425 | - $sb_1[$l >> 16 & 0xff] ^ |
|
426 | - $sb_2[$l >> 8 & 0xff]) + |
|
427 | - $sb_3[$l & 0xff]; |
|
428 | - |
|
429 | - $r^= $p[$i + 1]; |
|
430 | - $l^= ($sb_0[$r >> 24 & 0xff] + |
|
431 | - $sb_1[$r >> 16 & 0xff] ^ |
|
432 | - $sb_2[$r >> 8 & 0xff]) + |
|
433 | - $sb_3[$r & 0xff]; |
|
422 | + for ($i = 0; $i < 16; $i += 2) { |
|
423 | + $l ^= $p[$i]; |
|
424 | + $r ^= ($sb_0[$l >> 24 & 0xff] + |
|
425 | + $sb_1[$l >> 16 & 0xff] ^ |
|
426 | + $sb_2[$l >> 8 & 0xff]) + |
|
427 | + $sb_3[$l & 0xff]; |
|
428 | + |
|
429 | + $r ^= $p[$i + 1]; |
|
430 | + $l ^= ($sb_0[$r >> 24 & 0xff] + |
|
431 | + $sb_1[$r >> 16 & 0xff] ^ |
|
432 | + $sb_2[$r >> 8 & 0xff]) + |
|
433 | + $sb_3[$r & 0xff]; |
|
434 | 434 | } |
435 | 435 | return pack("N*", $r ^ $p[17], $l ^ $p[16]); |
436 | 436 | } |
@@ -454,18 +454,18 @@ discard block |
||
454 | 454 | $l = $in[1]; |
455 | 455 | $r = $in[2]; |
456 | 456 | |
457 | - for ($i = 17; $i > 2; $i-= 2) { |
|
458 | - $l^= $p[$i]; |
|
459 | - $r^= ($sb_0[$l >> 24 & 0xff] + |
|
460 | - $sb_1[$l >> 16 & 0xff] ^ |
|
461 | - $sb_2[$l >> 8 & 0xff]) + |
|
462 | - $sb_3[$l & 0xff]; |
|
463 | - |
|
464 | - $r^= $p[$i - 1]; |
|
465 | - $l^= ($sb_0[$r >> 24 & 0xff] + |
|
466 | - $sb_1[$r >> 16 & 0xff] ^ |
|
467 | - $sb_2[$r >> 8 & 0xff]) + |
|
468 | - $sb_3[$r & 0xff]; |
|
457 | + for ($i = 17; $i > 2; $i -= 2) { |
|
458 | + $l ^= $p[$i]; |
|
459 | + $r ^= ($sb_0[$l >> 24 & 0xff] + |
|
460 | + $sb_1[$l >> 16 & 0xff] ^ |
|
461 | + $sb_2[$l >> 8 & 0xff]) + |
|
462 | + $sb_3[$l & 0xff]; |
|
463 | + |
|
464 | + $r ^= $p[$i - 1]; |
|
465 | + $l ^= ($sb_0[$r >> 24 & 0xff] + |
|
466 | + $sb_1[$r >> 16 & 0xff] ^ |
|
467 | + $sb_2[$r >> 8 & 0xff]) + |
|
468 | + $sb_3[$r & 0xff]; |
|
469 | 469 | } |
470 | 470 | return pack("N*", $r ^ $p[0], $l ^ $p[1]); |
471 | 471 | } |