@@ -69,17 +69,17 @@ discard block |
||
69 | 69 | |
70 | 70 | /* not really important, this one; perhaps I could've put it inline with |
71 | 71 | * the rest. */ |
72 | -function find_match($curlscore,$curcscore,$curgtlang,$langval,$charval, |
|
72 | +function find_match($curlscore, $curcscore, $curgtlang, $langval, $charval, |
|
73 | 73 | $gtlang) |
74 | 74 | { |
75 | - if($curlscore < $langval) { |
|
76 | - $curlscore=$langval; |
|
77 | - $curcscore=$charval; |
|
78 | - $curgtlang=$gtlang; |
|
75 | + if ($curlscore < $langval) { |
|
76 | + $curlscore = $langval; |
|
77 | + $curcscore = $charval; |
|
78 | + $curgtlang = $gtlang; |
|
79 | 79 | } else if ($curlscore == $langval) { |
80 | - if($curcscore < $charval) { |
|
81 | - $curcscore=$charval; |
|
82 | - $curgtlang=$gtlang; |
|
80 | + if ($curcscore < $charval) { |
|
81 | + $curcscore = $charval; |
|
82 | + $curgtlang = $gtlang; |
|
83 | 83 | } |
84 | 84 | } |
85 | 85 | return array($curlscore, $curcscore, $curgtlang); |
@@ -87,22 +87,20 @@ discard block |
||
87 | 87 | |
88 | 88 | function al2gt($gettextlangs, $mime) { |
89 | 89 | /* default to "everything is acceptable", as RFC2616 specifies */ |
90 | - $acceptLang=(($_SERVER["HTTP_ACCEPT_LANGUAGE"] == '') ? '*' : |
|
91 | - $_SERVER["HTTP_ACCEPT_LANGUAGE"]); |
|
92 | - $acceptChar=(($_SERVER["HTTP_ACCEPT_CHARSET"] == '') ? '*' : |
|
93 | - $_SERVER["HTTP_ACCEPT_CHARSET"]); |
|
94 | - $alparts=@preg_split("/,/",$acceptLang); |
|
95 | - $acparts=@preg_split("/,/",$acceptChar); |
|
90 | + $acceptLang = (($_SERVER["HTTP_ACCEPT_LANGUAGE"] == '') ? '*' : $_SERVER["HTTP_ACCEPT_LANGUAGE"]); |
|
91 | + $acceptChar = (($_SERVER["HTTP_ACCEPT_CHARSET"] == '') ? '*' : $_SERVER["HTTP_ACCEPT_CHARSET"]); |
|
92 | + $alparts = @preg_split("/,/", $acceptLang); |
|
93 | + $acparts = @preg_split("/,/", $acceptChar); |
|
96 | 94 | |
97 | 95 | /* Parse the contents of the Accept-Language header.*/ |
98 | - foreach($alparts as $part) { |
|
99 | - $part=trim($part); |
|
100 | - if(preg_match("/;/", $part)) { |
|
101 | - $lang=@preg_split("/;/",$part); |
|
102 | - $score=@preg_split("/=/",$lang[1]); |
|
103 | - $alscores[$lang[0]]=$score[1]; |
|
96 | + foreach ($alparts as $part) { |
|
97 | + $part = trim($part); |
|
98 | + if (preg_match("/;/", $part)) { |
|
99 | + $lang = @preg_split("/;/", $part); |
|
100 | + $score = @preg_split("/=/", $lang[1]); |
|
101 | + $alscores[$lang[0]] = $score[1]; |
|
104 | 102 | } else { |
105 | - $alscores[$part]=1; |
|
103 | + $alscores[$part] = 1; |
|
106 | 104 | } |
107 | 105 | } |
108 | 106 | |
@@ -116,20 +114,20 @@ discard block |
||
116 | 114 | * Making it 2 for the time being, so that we |
117 | 115 | * can distinguish between "not specified" and "specified as 1" later |
118 | 116 | * on. */ |
119 | - $acscores["ISO-8859-1"]=2; |
|
117 | + $acscores["ISO-8859-1"] = 2; |
|
120 | 118 | |
121 | - foreach($acparts as $part) { |
|
122 | - $part=trim($part); |
|
123 | - if(preg_match("/;/", $part)) { |
|
124 | - $cs=@preg_split("/;/",$part); |
|
125 | - $score=@preg_split("/=/",$cs[1]); |
|
126 | - $acscores[strtoupper($cs[0])]=$score[1]; |
|
119 | + foreach ($acparts as $part) { |
|
120 | + $part = trim($part); |
|
121 | + if (preg_match("/;/", $part)) { |
|
122 | + $cs = @preg_split("/;/", $part); |
|
123 | + $score = @preg_split("/=/", $cs[1]); |
|
124 | + $acscores[strtoupper($cs[0])] = $score[1]; |
|
127 | 125 | } else { |
128 | - $acscores[strtoupper($part)]=1; |
|
126 | + $acscores[strtoupper($part)] = 1; |
|
129 | 127 | } |
130 | 128 | } |
131 | - if($acscores["ISO-8859-1"]==2) { |
|
132 | - $acscores["ISO-8859-1"]=(isset($acscores["*"])?$acscores["*"]:1); |
|
129 | + if ($acscores["ISO-8859-1"] == 2) { |
|
130 | + $acscores["ISO-8859-1"] = (isset($acscores["*"]) ? $acscores["*"] : 1); |
|
133 | 131 | } |
134 | 132 | |
135 | 133 | /* |
@@ -137,18 +135,18 @@ discard block |
||
137 | 135 | * with the highest score, excluding the ones with a charset the user |
138 | 136 | * did not include. |
139 | 137 | */ |
140 | - $curlscore=0; |
|
141 | - $curcscore=0; |
|
142 | - $curgtlang=NULL; |
|
143 | - foreach($gettextlangs as $gtlang) { |
|
138 | + $curlscore = 0; |
|
139 | + $curcscore = 0; |
|
140 | + $curgtlang = NULL; |
|
141 | + foreach ($gettextlangs as $gtlang) { |
|
144 | 142 | |
145 | - $tmp1=preg_replace("/\_/","-",$gtlang); |
|
146 | - $tmp2=@preg_split("/\./",$tmp1); |
|
147 | - $allang=strtolower($tmp2[0]); |
|
148 | - $gtcs=strtoupper($tmp2[1]); |
|
149 | - $noct=@preg_split("/-/",$allang); |
|
143 | + $tmp1 = preg_replace("/\_/", "-", $gtlang); |
|
144 | + $tmp2 = @preg_split("/\./", $tmp1); |
|
145 | + $allang = strtolower($tmp2[0]); |
|
146 | + $gtcs = strtoupper($tmp2[1]); |
|
147 | + $noct = @preg_split("/-/", $allang); |
|
150 | 148 | |
151 | - $testvals=array( |
|
149 | + $testvals = array( |
|
152 | 150 | array(@$alscores[$allang], @$acscores[$gtcs]), |
153 | 151 | array(@$alscores[$noct[0]], @$acscores[$gtcs]), |
154 | 152 | array(@$alscores[$allang], @$acscores["*"]), |
@@ -156,15 +154,15 @@ discard block |
||
156 | 154 | array(@$alscores["*"], @$acscores[$gtcs]), |
157 | 155 | array(@$alscores["*"], @$acscores["*"])); |
158 | 156 | |
159 | - $found=FALSE; |
|
160 | - foreach($testvals as $tval) { |
|
161 | - if(!$found && isset($tval[0]) && isset($tval[1])) { |
|
162 | - $arr=find_match($curlscore, $curcscore, $curgtlang, $tval[0], |
|
157 | + $found = FALSE; |
|
158 | + foreach ($testvals as $tval) { |
|
159 | + if (!$found && isset($tval[0]) && isset($tval[1])) { |
|
160 | + $arr = find_match($curlscore, $curcscore, $curgtlang, $tval[0], |
|
163 | 161 | $tval[1], $gtlang); |
164 | - $curlscore=$arr[0]; |
|
165 | - $curcscore=$arr[1]; |
|
166 | - $curgtlang=$arr[2]; |
|
167 | - $found=TRUE; |
|
162 | + $curlscore = $arr[0]; |
|
163 | + $curcscore = $arr[1]; |
|
164 | + $curgtlang = $arr[2]; |
|
165 | + $found = TRUE; |
|
168 | 166 | } |
169 | 167 | } |
170 | 168 | } |
@@ -172,10 +170,10 @@ discard block |
||
172 | 170 | /* We must re-parse the gettext-string now, since we may have found it |
173 | 171 | * through a "*" qualifier.*/ |
174 | 172 | |
175 | - $gtparts=@preg_split("/\./",$curgtlang); |
|
176 | - $tmp=strtolower($gtparts[0]); |
|
177 | - $lang=preg_replace("/\_/", "-", $tmp); |
|
178 | - $charset=$gtparts[1]; |
|
173 | + $gtparts = @preg_split("/\./", $curgtlang); |
|
174 | + $tmp = strtolower($gtparts[0]); |
|
175 | + $lang = preg_replace("/\_/", "-", $tmp); |
|
176 | + $charset = $gtparts[1]; |
|
179 | 177 | |
180 | 178 | header("Content-Language: $lang"); |
181 | 179 | header("Content-Type: $mime; charset=$charset"); |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | // LC_MESSAGES is not available if php-gettext is not loaded |
36 | 36 | // while the other constants are already available from session extension. |
37 | 37 | if (!defined('LC_MESSAGES')) { |
38 | - define('LC_MESSAGES', 5); |
|
38 | + define('LC_MESSAGES', 5); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | require('streams.php'); |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | if (preg_match("/^(?P<lang>[a-z]{2,3})" // language code |
78 | 78 | ."(?:_(?P<country>[A-Z]{2}))?" // country code |
79 | 79 | ."(?:\.(?P<charset>[-A-Za-z0-9_]+))?" // charset |
80 | - ."(?:@(?P<modifier>[-A-Za-z0-9_]+))?$/", // @ modifier |
|
80 | + ."(?:@(?P<modifier>[-A-Za-z0-9_]+))?$/", // @ modifier |
|
81 | 81 | $locale, $matches)) { |
82 | 82 | |
83 | 83 | if (isset($matches["lang"])) $lang = $matches["lang"]; |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | /** |
114 | 114 | * Utility function to get a StreamReader for the given text domain. |
115 | 115 | */ |
116 | -function _get_reader($domain=null, $category=5, $enable_cache=true) { |
|
116 | +function _get_reader($domain = null, $category = 5, $enable_cache = true) { |
|
117 | 117 | global $text_domains, $default_domain, $LC_CATEGORIES; |
118 | 118 | if (!isset($domain)) $domain = $default_domain; |
119 | 119 | if (!isset($text_domains[$domain]->l10n)) { |
@@ -121,12 +121,12 @@ discard block |
||
121 | 121 | $locale = _setlocale(LC_MESSAGES, 0); |
122 | 122 | $bound_path = isset($text_domains[$domain]->path) ? |
123 | 123 | $text_domains[$domain]->path : './'; |
124 | - $subpath = $LC_CATEGORIES[$category] ."/$domain.mo"; |
|
124 | + $subpath = $LC_CATEGORIES[$category]."/$domain.mo"; |
|
125 | 125 | |
126 | 126 | $locale_names = get_list_of_locales($locale); |
127 | 127 | $input = null; |
128 | 128 | foreach ($locale_names as $locale) { |
129 | - $full_path = $bound_path . $locale . "/" . $subpath; |
|
129 | + $full_path = $bound_path.$locale."/".$subpath; |
|
130 | 130 | if (file_exists($full_path)) { |
131 | 131 | $input = new FileReader($full_path); |
132 | 132 | break; |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | /** |
155 | 155 | * Checks if the current locale is supported on this system. |
156 | 156 | */ |
157 | -function _check_locale_and_function($function=false) { |
|
157 | +function _check_locale_and_function($function = false) { |
|
158 | 158 | global $EMULATEGETTEXT; |
159 | 159 | if ($function and !function_exists($function)) |
160 | 160 | return false; |
@@ -164,10 +164,10 @@ discard block |
||
164 | 164 | /** |
165 | 165 | * Get the codeset for the given domain. |
166 | 166 | */ |
167 | -function _get_codeset($domain=null) { |
|
167 | +function _get_codeset($domain = null) { |
|
168 | 168 | global $text_domains, $default_domain, $LC_CATEGORIES; |
169 | 169 | if (!isset($domain)) $domain = $default_domain; |
170 | - return (isset($text_domains[$domain]->codeset))? $text_domains[$domain]->codeset : ini_get('mbstring.internal_encoding'); |
|
170 | + return (isset($text_domains[$domain]->codeset)) ? $text_domains[$domain]->codeset : ini_get('mbstring.internal_encoding'); |
|
171 | 171 | } |
172 | 172 | |
173 | 173 | /** |
@@ -241,10 +241,10 @@ discard block |
||
241 | 241 | global $text_domains; |
242 | 242 | // ensure $path ends with a slash ('/' should work for both, but lets still play nice) |
243 | 243 | if (substr(php_uname(), 0, 7) == "Windows") { |
244 | - if ($path[strlen($path)-1] != '\\' and $path[strlen($path)-1] != '/') |
|
244 | + if ($path[strlen($path) - 1] != '\\' and $path[strlen($path) - 1] != '/') |
|
245 | 245 | $path .= '\\'; |
246 | 246 | } else { |
247 | - if ($path[strlen($path)-1] != '/') |
|
247 | + if ($path[strlen($path) - 1] != '/') |
|
248 | 248 | $path .= '/'; |
249 | 249 | } |
250 | 250 | if (!array_key_exists($domain, $text_domains)) { |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | var $_pos; |
50 | 50 | var $_str; |
51 | 51 | |
52 | - function StringReader($str='') { |
|
52 | + function StringReader($str = '') { |
|
53 | 53 | $this->_str = $str; |
54 | 54 | $this->_pos = 0; |
55 | 55 | } |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | function read($bytes) { |
58 | 58 | $data = substr($this->_str, $this->_pos, $bytes); |
59 | 59 | $this->_pos += $bytes; |
60 | - if (strlen($this->_str)<$this->_pos) |
|
60 | + if (strlen($this->_str) < $this->_pos) |
|
61 | 61 | $this->_pos = strlen($this->_str); |
62 | 62 | |
63 | 63 | return $data; |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | |
66 | 66 | function seekto($pos) { |
67 | 67 | $this->_pos = $pos; |
68 | - if (strlen($this->_str)<$this->_pos) |
|
68 | + if (strlen($this->_str) < $this->_pos) |
|
69 | 69 | $this->_pos = strlen($this->_str); |
70 | 70 | return $this->_pos; |
71 | 71 | } |
@@ -89,9 +89,9 @@ discard block |
||
89 | 89 | function FileReader($filename) { |
90 | 90 | if (file_exists($filename)) { |
91 | 91 | |
92 | - $this->_length=filesize($filename); |
|
92 | + $this->_length = filesize($filename); |
|
93 | 93 | $this->_pos = 0; |
94 | - $this->_fd = fopen($filename,'rb'); |
|
94 | + $this->_fd = fopen($filename, 'rb'); |
|
95 | 95 | if (!$this->_fd) { |
96 | 96 | $this->error = 3; // Cannot read file, probably permissions |
97 | 97 | return false; |
@@ -146,8 +146,8 @@ discard block |
||
146 | 146 | function CachedFileReader($filename) { |
147 | 147 | if (file_exists($filename)) { |
148 | 148 | |
149 | - $length=filesize($filename); |
|
150 | - $fd = fopen($filename,'rb'); |
|
149 | + $length = filesize($filename); |
|
150 | + $fd = fopen($filename, 'rb'); |
|
151 | 151 | |
152 | 152 | if (!$fd) { |
153 | 153 | $this->error = 3; // Cannot read file, probably permissions |
@@ -38,17 +38,17 @@ discard block |
||
38 | 38 | var $error = 0; // public variable that holds error code (0 if no error) |
39 | 39 | |
40 | 40 | //private: |
41 | - var $BYTEORDER = 0; // 0: low endian, 1: big endian |
|
41 | + var $BYTEORDER = 0; // 0: low endian, 1: big endian |
|
42 | 42 | var $STREAM = NULL; |
43 | 43 | var $short_circuit = false; |
44 | 44 | var $enable_cache = false; |
45 | - var $originals = NULL; // offset of original table |
|
46 | - var $translations = NULL; // offset of translation table |
|
47 | - var $pluralheader = NULL; // cache header field for plural forms |
|
48 | - var $total = 0; // total string count |
|
49 | - var $table_originals = NULL; // table for original strings (offsets) |
|
50 | - var $table_translations = NULL; // table for translated strings (offsets) |
|
51 | - var $cache_translations = NULL; // original -> translation mapping |
|
45 | + var $originals = NULL; // offset of original table |
|
46 | + var $translations = NULL; // offset of translation table |
|
47 | + var $pluralheader = NULL; // cache header field for plural forms |
|
48 | + var $total = 0; // total string count |
|
49 | + var $table_originals = NULL; // table for original strings (offsets) |
|
50 | + var $table_translations = NULL; // table for translated strings (offsets) |
|
51 | + var $cache_translations = NULL; // original -> translation mapping |
|
52 | 52 | |
53 | 53 | |
54 | 54 | /* Methods */ |
@@ -63,11 +63,11 @@ discard block |
||
63 | 63 | function readint() { |
64 | 64 | if ($this->BYTEORDER == 0) { |
65 | 65 | // low endian |
66 | - $input=unpack('V', $this->STREAM->read(4)); |
|
66 | + $input = unpack('V', $this->STREAM->read(4)); |
|
67 | 67 | return array_shift($input); |
68 | 68 | } else { |
69 | 69 | // big endian |
70 | - $input=unpack('N', $this->STREAM->read(4)); |
|
70 | + $input = unpack('N', $this->STREAM->read(4)); |
|
71 | 71 | return array_shift($input); |
72 | 72 | } |
73 | 73 | } |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | */ |
101 | 101 | function __construct($Reader, $enable_cache = true) { |
102 | 102 | // If there isn't a StreamReader, turn on short circuit mode. |
103 | - if (! $Reader || isset($Reader->error) ) { |
|
103 | + if (!$Reader || isset($Reader->error)) { |
|
104 | 104 | $this->short_circuit = true; |
105 | 105 | return; |
106 | 106 | } |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | } |
155 | 155 | |
156 | 156 | if ($this->enable_cache) { |
157 | - $this->cache_translations = array (); |
|
157 | + $this->cache_translations = array(); |
|
158 | 158 | /* read all strings in the cache */ |
159 | 159 | for ($i = 0; $i < $this->total; $i++) { |
160 | 160 | $this->STREAM->seekto($this->table_originals[$i * 2 + 2]); |
@@ -176,11 +176,11 @@ discard block |
||
176 | 176 | function get_original_string($num) { |
177 | 177 | $length = $this->table_originals[$num * 2 + 1]; |
178 | 178 | $offset = $this->table_originals[$num * 2 + 2]; |
179 | - if (! $length) |
|
179 | + if (!$length) |
|
180 | 180 | return ''; |
181 | 181 | $this->STREAM->seekto($offset); |
182 | 182 | $data = $this->STREAM->read($length); |
183 | - return (string)$data; |
|
183 | + return (string) $data; |
|
184 | 184 | } |
185 | 185 | |
186 | 186 | /** |
@@ -193,11 +193,11 @@ discard block |
||
193 | 193 | function get_translation_string($num) { |
194 | 194 | $length = $this->table_translations[$num * 2 + 1]; |
195 | 195 | $offset = $this->table_translations[$num * 2 + 2]; |
196 | - if (! $length) |
|
196 | + if (!$length) |
|
197 | 197 | return ''; |
198 | 198 | $this->STREAM->seekto($offset); |
199 | 199 | $data = $this->STREAM->read($length); |
200 | - return (string)$data; |
|
200 | + return (string) $data; |
|
201 | 201 | } |
202 | 202 | |
203 | 203 | /** |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | return $this->find_string($string, $end, $start); |
228 | 228 | } else { |
229 | 229 | // Divide table in two parts |
230 | - $half = (int)(($start + $end) / 2); |
|
230 | + $half = (int) (($start + $end) / 2); |
|
231 | 231 | $cmp = strcmp($string, $this->get_original_string($half)); |
232 | 232 | if ($cmp == 0) |
233 | 233 | // string is exactly in the middle => return it |
@@ -294,7 +294,7 @@ discard block |
||
294 | 294 | $res .= ') : ('; |
295 | 295 | break; |
296 | 296 | case ';': |
297 | - $res .= str_repeat( ')', $p) . ';'; |
|
297 | + $res .= str_repeat(')', $p).';'; |
|
298 | 298 | $p = 0; |
299 | 299 | break; |
300 | 300 | default: |
@@ -330,7 +330,7 @@ discard block |
||
330 | 330 | $this->load_tables(); |
331 | 331 | |
332 | 332 | // cache header field for plural forms |
333 | - if (! is_string($this->pluralheader)) { |
|
333 | + if (!is_string($this->pluralheader)) { |
|
334 | 334 | if ($this->enable_cache) { |
335 | 335 | $header = $this->cache_translations[""]; |
336 | 336 | } else { |
@@ -352,12 +352,12 @@ discard block |
||
352 | 352 | function select_string($n) { |
353 | 353 | if (!is_int($n)) { |
354 | 354 | throw new InvalidArgumentException( |
355 | - "Select_string only accepts integers: " . $n); |
|
355 | + "Select_string only accepts integers: ".$n); |
|
356 | 356 | } |
357 | 357 | $string = $this->get_plural_forms(); |
358 | - $string = str_replace('nplurals',"\$total",$string); |
|
359 | - $string = str_replace("n",$n,$string); |
|
360 | - $string = str_replace('plural',"\$plural",$string); |
|
358 | + $string = str_replace('nplurals', "\$total", $string); |
|
359 | + $string = str_replace("n", $n, $string); |
|
360 | + $string = str_replace('plural', "\$plural", $string); |
|
361 | 361 | |
362 | 362 | $total = 0; |
363 | 363 | $plural = 0; |
@@ -388,11 +388,11 @@ discard block |
||
388 | 388 | $select = $this->select_string($number); |
389 | 389 | |
390 | 390 | // this should contains all strings separated by NULLs |
391 | - $key = $single . chr(0) . $plural; |
|
391 | + $key = $single.chr(0).$plural; |
|
392 | 392 | |
393 | 393 | |
394 | 394 | if ($this->enable_cache) { |
395 | - if (! array_key_exists($key, $this->cache_translations)) { |
|
395 | + if (!array_key_exists($key, $this->cache_translations)) { |
|
396 | 396 | return ($number != 1) ? $plural : $single; |
397 | 397 | } else { |
398 | 398 | $result = $this->cache_translations[$key]; |
@@ -412,7 +412,7 @@ discard block |
||
412 | 412 | } |
413 | 413 | |
414 | 414 | function pgettext($context, $msgid) { |
415 | - $key = $context . chr(4) . $msgid; |
|
415 | + $key = $context.chr(4).$msgid; |
|
416 | 416 | $ret = $this->translate($key); |
417 | 417 | if (strpos($ret, "\004") !== FALSE) { |
418 | 418 | return $msgid; |
@@ -422,7 +422,7 @@ discard block |
||
422 | 422 | } |
423 | 423 | |
424 | 424 | function npgettext($context, $singular, $plural, $number) { |
425 | - $key = $context . chr(4) . $singular; |
|
425 | + $key = $context.chr(4).$singular; |
|
426 | 426 | $ret = $this->ngettext($key, $plural, $number); |
427 | 427 | if (strpos($ret, "\004") !== FALSE) { |
428 | 428 | return $singular; |
@@ -12,11 +12,11 @@ |
||
12 | 12 | // we need a separate check here because functions.php might get parsed |
13 | 13 | // incorrectly before 5.3 because of :: syntax. |
14 | 14 | if (version_compare(PHP_VERSION, '5.6.0', '<')) { |
15 | - print "<b>Fatal Error</b>: PHP version 5.6.0 or newer required. You're using " . PHP_VERSION . ".\n"; |
|
15 | + print "<b>Fatal Error</b>: PHP version 5.6.0 or newer required. You're using ".PHP_VERSION.".\n"; |
|
16 | 16 | exit; |
17 | 17 | } |
18 | 18 | |
19 | - set_include_path(dirname(__FILE__) ."/include" . PATH_SEPARATOR . |
|
19 | + set_include_path(dirname(__FILE__)."/include".PATH_SEPARATOR. |
|
20 | 20 | get_include_path()); |
21 | 21 | |
22 | 22 | require_once "autoload.php"; |
@@ -6,10 +6,10 @@ |
||
6 | 6 | |
7 | 7 | $ERRORS[0] = ""; |
8 | 8 | |
9 | -$ERRORS[1] = __("This program requires XmlHttpRequest " . |
|
9 | +$ERRORS[1] = __("This program requires XmlHttpRequest ". |
|
10 | 10 | "to function properly. Your browser doesn't seem to support it."); |
11 | 11 | |
12 | -$ERRORS[2] = __("This program requires cookies " . |
|
12 | +$ERRORS[2] = __("This program requires cookies ". |
|
13 | 13 | "to function properly. Your browser doesn't seem to support them."); |
14 | 14 | |
15 | 15 | $ERRORS[3] = __("Backend sanity check failed."); |
@@ -180,12 +180,12 @@ discard block |
||
180 | 180 | /** |
181 | 181 | * Matrix index to get width from $capacity array. |
182 | 182 | */ |
183 | - define('QRCAP_WIDTH', 0); |
|
183 | + define('QRCAP_WIDTH', 0); |
|
184 | 184 | |
185 | 185 | /** |
186 | 186 | * Matrix index to get number of words from $capacity array. |
187 | 187 | */ |
188 | - define('QRCAP_WORDS', 1); |
|
188 | + define('QRCAP_WORDS', 1); |
|
189 | 189 | |
190 | 190 | /** |
191 | 191 | * Matrix index to get remainder from $capacity array. |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | /** |
196 | 196 | * Matrix index to get error correction level from $capacity array. |
197 | 197 | */ |
198 | - define('QRCAP_EC', 3); |
|
198 | + define('QRCAP_EC', 3); |
|
199 | 199 | |
200 | 200 | // ----------------------------------------------------- |
201 | 201 | |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | /** |
205 | 205 | * Number of header bits for structured mode |
206 | 206 | */ |
207 | - define('STRUCTURE_HEADER_BITS', 20); |
|
207 | + define('STRUCTURE_HEADER_BITS', 20); |
|
208 | 208 | |
209 | 209 | /** |
210 | 210 | * Max number of symbols for structured mode |
@@ -218,12 +218,12 @@ discard block |
||
218 | 218 | /** |
219 | 219 | * Down point base value for case 1 mask pattern (concatenation of same color in a line or a column) |
220 | 220 | */ |
221 | - define('N1', 3); |
|
221 | + define('N1', 3); |
|
222 | 222 | |
223 | 223 | /** |
224 | 224 | * Down point base value for case 2 mask pattern (module block of same color) |
225 | 225 | */ |
226 | - define('N2', 3); |
|
226 | + define('N2', 3); |
|
227 | 227 | |
228 | 228 | /** |
229 | 229 | * Down point base value for case 3 mask pattern (1:1:3:1:1(dark:bright:dark:bright:dark)pattern in a line or a column) |
@@ -270,7 +270,7 @@ discard block |
||
270 | 270 | * @param int $split_length Maximum length of the chunk. |
271 | 271 | * @return If the optional split_length parameter is specified, the returned array will be broken down into chunks with each being split_length in length, otherwise each chunk will be one character in length. FALSE is returned if split_length is less than 1. If the split_length length exceeds the length of string , the entire string is returned as the first (and only) array element. |
272 | 272 | */ |
273 | - public function str_split($string, $split_length=1) { |
|
273 | + public function str_split($string, $split_length = 1) { |
|
274 | 274 | if ((strlen($string) > $split_length) OR (!$split_length)) { |
275 | 275 | do { |
276 | 276 | $c = strlen($string); |
@@ -481,7 +481,7 @@ discard block |
||
481 | 481 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // |
482 | 482 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // |
483 | 483 | 36, -1, -1, -1, 37, 38, -1, -1, -1, -1, 39, 40, -1, 41, 42, 43, // |
484 | - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 44, -1, -1, -1, -1, -1, // |
|
484 | + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 44, -1, -1, -1, -1, -1, // |
|
485 | 485 | -1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, // |
486 | 486 | 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, -1, -1, -1, -1, -1, // |
487 | 487 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // |
@@ -494,47 +494,47 @@ discard block |
||
494 | 494 | * @access protected |
495 | 495 | */ |
496 | 496 | protected $capacity = array( |
497 | - array( 0, 0, 0, array( 0, 0, 0, 0)), // |
|
498 | - array( 21, 26, 0, array( 7, 10, 13, 17)), // 1 |
|
499 | - array( 25, 44, 7, array( 10, 16, 22, 28)), // |
|
500 | - array( 29, 70, 7, array( 15, 26, 36, 44)), // |
|
501 | - array( 33, 100, 7, array( 20, 36, 52, 64)), // |
|
502 | - array( 37, 134, 7, array( 26, 48, 72, 88)), // 5 |
|
503 | - array( 41, 172, 7, array( 36, 64, 96, 112)), // |
|
504 | - array( 45, 196, 0, array( 40, 72, 108, 130)), // |
|
505 | - array( 49, 242, 0, array( 48, 88, 132, 156)), // |
|
506 | - array( 53, 292, 0, array( 60, 110, 160, 192)), // |
|
507 | - array( 57, 346, 0, array( 72, 130, 192, 224)), // 10 |
|
508 | - array( 61, 404, 0, array( 80, 150, 224, 264)), // |
|
509 | - array( 65, 466, 0, array( 96, 176, 260, 308)), // |
|
510 | - array( 69, 532, 0, array( 104, 198, 288, 352)), // |
|
511 | - array( 73, 581, 3, array( 120, 216, 320, 384)), // |
|
512 | - array( 77, 655, 3, array( 132, 240, 360, 432)), // 15 |
|
513 | - array( 81, 733, 3, array( 144, 280, 408, 480)), // |
|
514 | - array( 85, 815, 3, array( 168, 308, 448, 532)), // |
|
515 | - array( 89, 901, 3, array( 180, 338, 504, 588)), // |
|
516 | - array( 93, 991, 3, array( 196, 364, 546, 650)), // |
|
517 | - array( 97, 1085, 3, array( 224, 416, 600, 700)), // 20 |
|
518 | - array(101, 1156, 4, array( 224, 442, 644, 750)), // |
|
519 | - array(105, 1258, 4, array( 252, 476, 690, 816)), // |
|
520 | - array(109, 1364, 4, array( 270, 504, 750, 900)), // |
|
521 | - array(113, 1474, 4, array( 300, 560, 810, 960)), // |
|
522 | - array(117, 1588, 4, array( 312, 588, 870, 1050)), // 25 |
|
523 | - array(121, 1706, 4, array( 336, 644, 952, 1110)), // |
|
524 | - array(125, 1828, 4, array( 360, 700, 1020, 1200)), // |
|
525 | - array(129, 1921, 3, array( 390, 728, 1050, 1260)), // |
|
526 | - array(133, 2051, 3, array( 420, 784, 1140, 1350)), // |
|
527 | - array(137, 2185, 3, array( 450, 812, 1200, 1440)), // 30 |
|
528 | - array(141, 2323, 3, array( 480, 868, 1290, 1530)), // |
|
529 | - array(145, 2465, 3, array( 510, 924, 1350, 1620)), // |
|
530 | - array(149, 2611, 3, array( 540, 980, 1440, 1710)), // |
|
531 | - array(153, 2761, 3, array( 570, 1036, 1530, 1800)), // |
|
532 | - array(157, 2876, 0, array( 570, 1064, 1590, 1890)), // 35 |
|
533 | - array(161, 3034, 0, array( 600, 1120, 1680, 1980)), // |
|
534 | - array(165, 3196, 0, array( 630, 1204, 1770, 2100)), // |
|
535 | - array(169, 3362, 0, array( 660, 1260, 1860, 2220)), // |
|
536 | - array(173, 3532, 0, array( 720, 1316, 1950, 2310)), // |
|
537 | - array(177, 3706, 0, array( 750, 1372, 2040, 2430)) // 40 |
|
497 | + array(0, 0, 0, array(0, 0, 0, 0)), // |
|
498 | + array(21, 26, 0, array(7, 10, 13, 17)), // 1 |
|
499 | + array(25, 44, 7, array(10, 16, 22, 28)), // |
|
500 | + array(29, 70, 7, array(15, 26, 36, 44)), // |
|
501 | + array(33, 100, 7, array(20, 36, 52, 64)), // |
|
502 | + array(37, 134, 7, array(26, 48, 72, 88)), // 5 |
|
503 | + array(41, 172, 7, array(36, 64, 96, 112)), // |
|
504 | + array(45, 196, 0, array(40, 72, 108, 130)), // |
|
505 | + array(49, 242, 0, array(48, 88, 132, 156)), // |
|
506 | + array(53, 292, 0, array(60, 110, 160, 192)), // |
|
507 | + array(57, 346, 0, array(72, 130, 192, 224)), // 10 |
|
508 | + array(61, 404, 0, array(80, 150, 224, 264)), // |
|
509 | + array(65, 466, 0, array(96, 176, 260, 308)), // |
|
510 | + array(69, 532, 0, array(104, 198, 288, 352)), // |
|
511 | + array(73, 581, 3, array(120, 216, 320, 384)), // |
|
512 | + array(77, 655, 3, array(132, 240, 360, 432)), // 15 |
|
513 | + array(81, 733, 3, array(144, 280, 408, 480)), // |
|
514 | + array(85, 815, 3, array(168, 308, 448, 532)), // |
|
515 | + array(89, 901, 3, array(180, 338, 504, 588)), // |
|
516 | + array(93, 991, 3, array(196, 364, 546, 650)), // |
|
517 | + array(97, 1085, 3, array(224, 416, 600, 700)), // 20 |
|
518 | + array(101, 1156, 4, array(224, 442, 644, 750)), // |
|
519 | + array(105, 1258, 4, array(252, 476, 690, 816)), // |
|
520 | + array(109, 1364, 4, array(270, 504, 750, 900)), // |
|
521 | + array(113, 1474, 4, array(300, 560, 810, 960)), // |
|
522 | + array(117, 1588, 4, array(312, 588, 870, 1050)), // 25 |
|
523 | + array(121, 1706, 4, array(336, 644, 952, 1110)), // |
|
524 | + array(125, 1828, 4, array(360, 700, 1020, 1200)), // |
|
525 | + array(129, 1921, 3, array(390, 728, 1050, 1260)), // |
|
526 | + array(133, 2051, 3, array(420, 784, 1140, 1350)), // |
|
527 | + array(137, 2185, 3, array(450, 812, 1200, 1440)), // 30 |
|
528 | + array(141, 2323, 3, array(480, 868, 1290, 1530)), // |
|
529 | + array(145, 2465, 3, array(510, 924, 1350, 1620)), // |
|
530 | + array(149, 2611, 3, array(540, 980, 1440, 1710)), // |
|
531 | + array(153, 2761, 3, array(570, 1036, 1530, 1800)), // |
|
532 | + array(157, 2876, 0, array(570, 1064, 1590, 1890)), // 35 |
|
533 | + array(161, 3034, 0, array(600, 1120, 1680, 1980)), // |
|
534 | + array(165, 3196, 0, array(630, 1204, 1770, 2100)), // |
|
535 | + array(169, 3362, 0, array(660, 1260, 1860, 2220)), // |
|
536 | + array(173, 3532, 0, array(720, 1316, 1950, 2310)), // |
|
537 | + array(177, 3706, 0, array(750, 1372, 2040, 2430)) // 40 |
|
538 | 538 | ); |
539 | 539 | |
540 | 540 | /** |
@@ -543,9 +543,9 @@ discard block |
||
543 | 543 | */ |
544 | 544 | protected $lengthTableBits = array( |
545 | 545 | array(10, 12, 14), |
546 | - array( 9, 11, 13), |
|
547 | - array( 8, 16, 16), |
|
548 | - array( 8, 10, 12) |
|
546 | + array(9, 11, 13), |
|
547 | + array(8, 16, 16), |
|
548 | + array(8, 10, 12) |
|
549 | 549 | ); |
550 | 550 | |
551 | 551 | /** |
@@ -554,47 +554,47 @@ discard block |
||
554 | 554 | * @access protected |
555 | 555 | */ |
556 | 556 | protected $eccTable = array( |
557 | - array(array( 0, 0), array( 0, 0), array( 0, 0), array( 0, 0)), // |
|
558 | - array(array( 1, 0), array( 1, 0), array( 1, 0), array( 1, 0)), // 1 |
|
559 | - array(array( 1, 0), array( 1, 0), array( 1, 0), array( 1, 0)), // |
|
560 | - array(array( 1, 0), array( 1, 0), array( 2, 0), array( 2, 0)), // |
|
561 | - array(array( 1, 0), array( 2, 0), array( 2, 0), array( 4, 0)), // |
|
562 | - array(array( 1, 0), array( 2, 0), array( 2, 2), array( 2, 2)), // 5 |
|
563 | - array(array( 2, 0), array( 4, 0), array( 4, 0), array( 4, 0)), // |
|
564 | - array(array( 2, 0), array( 4, 0), array( 2, 4), array( 4, 1)), // |
|
565 | - array(array( 2, 0), array( 2, 2), array( 4, 2), array( 4, 2)), // |
|
566 | - array(array( 2, 0), array( 3, 2), array( 4, 4), array( 4, 4)), // |
|
567 | - array(array( 2, 2), array( 4, 1), array( 6, 2), array( 6, 2)), // 10 |
|
568 | - array(array( 4, 0), array( 1, 4), array( 4, 4), array( 3, 8)), // |
|
569 | - array(array( 2, 2), array( 6, 2), array( 4, 6), array( 7, 4)), // |
|
570 | - array(array( 4, 0), array( 8, 1), array( 8, 4), array(12, 4)), // |
|
571 | - array(array( 3, 1), array( 4, 5), array(11, 5), array(11, 5)), // |
|
572 | - array(array( 5, 1), array( 5, 5), array( 5, 7), array(11, 7)), // 15 |
|
573 | - array(array( 5, 1), array( 7, 3), array(15, 2), array( 3, 13)), // |
|
574 | - array(array( 1, 5), array(10, 1), array( 1, 15), array( 2, 17)), // |
|
575 | - array(array( 5, 1), array( 9, 4), array(17, 1), array( 2, 19)), // |
|
576 | - array(array( 3, 4), array( 3, 11), array(17, 4), array( 9, 16)), // |
|
577 | - array(array( 3, 5), array( 3, 13), array(15, 5), array(15, 10)), // 20 |
|
578 | - array(array( 4, 4), array(17, 0), array(17, 6), array(19, 6)), // |
|
579 | - array(array( 2, 7), array(17, 0), array( 7, 16), array(34, 0)), // |
|
580 | - array(array( 4, 5), array( 4, 14), array(11, 14), array(16, 14)), // |
|
581 | - array(array( 6, 4), array( 6, 14), array(11, 16), array(30, 2)), // |
|
582 | - array(array( 8, 4), array( 8, 13), array( 7, 22), array(22, 13)), // 25 |
|
583 | - array(array(10, 2), array(19, 4), array(28, 6), array(33, 4)), // |
|
584 | - array(array( 8, 4), array(22, 3), array( 8, 26), array(12, 28)), // |
|
585 | - array(array( 3, 10), array( 3, 23), array( 4, 31), array(11, 31)), // |
|
586 | - array(array( 7, 7), array(21, 7), array( 1, 37), array(19, 26)), // |
|
587 | - array(array( 5, 10), array(19, 10), array(15, 25), array(23, 25)), // 30 |
|
588 | - array(array(13, 3), array( 2, 29), array(42, 1), array(23, 28)), // |
|
589 | - array(array(17, 0), array(10, 23), array(10, 35), array(19, 35)), // |
|
590 | - array(array(17, 1), array(14, 21), array(29, 19), array(11, 46)), // |
|
591 | - array(array(13, 6), array(14, 23), array(44, 7), array(59, 1)), // |
|
592 | - array(array(12, 7), array(12, 26), array(39, 14), array(22, 41)), // 35 |
|
593 | - array(array( 6, 14), array( 6, 34), array(46, 10), array( 2, 64)), // |
|
594 | - array(array(17, 4), array(29, 14), array(49, 10), array(24, 46)), // |
|
595 | - array(array( 4, 18), array(13, 32), array(48, 14), array(42, 32)), // |
|
596 | - array(array(20, 4), array(40, 7), array(43, 22), array(10, 67)), // |
|
597 | - array(array(19, 6), array(18, 31), array(34, 34), array(20, 61)) // 40 |
|
557 | + array(array(0, 0), array(0, 0), array(0, 0), array(0, 0)), // |
|
558 | + array(array(1, 0), array(1, 0), array(1, 0), array(1, 0)), // 1 |
|
559 | + array(array(1, 0), array(1, 0), array(1, 0), array(1, 0)), // |
|
560 | + array(array(1, 0), array(1, 0), array(2, 0), array(2, 0)), // |
|
561 | + array(array(1, 0), array(2, 0), array(2, 0), array(4, 0)), // |
|
562 | + array(array(1, 0), array(2, 0), array(2, 2), array(2, 2)), // 5 |
|
563 | + array(array(2, 0), array(4, 0), array(4, 0), array(4, 0)), // |
|
564 | + array(array(2, 0), array(4, 0), array(2, 4), array(4, 1)), // |
|
565 | + array(array(2, 0), array(2, 2), array(4, 2), array(4, 2)), // |
|
566 | + array(array(2, 0), array(3, 2), array(4, 4), array(4, 4)), // |
|
567 | + array(array(2, 2), array(4, 1), array(6, 2), array(6, 2)), // 10 |
|
568 | + array(array(4, 0), array(1, 4), array(4, 4), array(3, 8)), // |
|
569 | + array(array(2, 2), array(6, 2), array(4, 6), array(7, 4)), // |
|
570 | + array(array(4, 0), array(8, 1), array(8, 4), array(12, 4)), // |
|
571 | + array(array(3, 1), array(4, 5), array(11, 5), array(11, 5)), // |
|
572 | + array(array(5, 1), array(5, 5), array(5, 7), array(11, 7)), // 15 |
|
573 | + array(array(5, 1), array(7, 3), array(15, 2), array(3, 13)), // |
|
574 | + array(array(1, 5), array(10, 1), array(1, 15), array(2, 17)), // |
|
575 | + array(array(5, 1), array(9, 4), array(17, 1), array(2, 19)), // |
|
576 | + array(array(3, 4), array(3, 11), array(17, 4), array(9, 16)), // |
|
577 | + array(array(3, 5), array(3, 13), array(15, 5), array(15, 10)), // 20 |
|
578 | + array(array(4, 4), array(17, 0), array(17, 6), array(19, 6)), // |
|
579 | + array(array(2, 7), array(17, 0), array(7, 16), array(34, 0)), // |
|
580 | + array(array(4, 5), array(4, 14), array(11, 14), array(16, 14)), // |
|
581 | + array(array(6, 4), array(6, 14), array(11, 16), array(30, 2)), // |
|
582 | + array(array(8, 4), array(8, 13), array(7, 22), array(22, 13)), // 25 |
|
583 | + array(array(10, 2), array(19, 4), array(28, 6), array(33, 4)), // |
|
584 | + array(array(8, 4), array(22, 3), array(8, 26), array(12, 28)), // |
|
585 | + array(array(3, 10), array(3, 23), array(4, 31), array(11, 31)), // |
|
586 | + array(array(7, 7), array(21, 7), array(1, 37), array(19, 26)), // |
|
587 | + array(array(5, 10), array(19, 10), array(15, 25), array(23, 25)), // 30 |
|
588 | + array(array(13, 3), array(2, 29), array(42, 1), array(23, 28)), // |
|
589 | + array(array(17, 0), array(10, 23), array(10, 35), array(19, 35)), // |
|
590 | + array(array(17, 1), array(14, 21), array(29, 19), array(11, 46)), // |
|
591 | + array(array(13, 6), array(14, 23), array(44, 7), array(59, 1)), // |
|
592 | + array(array(12, 7), array(12, 26), array(39, 14), array(22, 41)), // 35 |
|
593 | + array(array(6, 14), array(6, 34), array(46, 10), array(2, 64)), // |
|
594 | + array(array(17, 4), array(29, 14), array(49, 10), array(24, 46)), // |
|
595 | + array(array(4, 18), array(13, 32), array(48, 14), array(42, 32)), // |
|
596 | + array(array(20, 4), array(40, 7), array(43, 22), array(10, 67)), // |
|
597 | + array(array(19, 6), array(18, 31), array(34, 34), array(20, 61)) // 40 |
|
598 | 598 | ); |
599 | 599 | |
600 | 600 | /** |
@@ -604,9 +604,9 @@ discard block |
||
604 | 604 | * @access protected |
605 | 605 | */ |
606 | 606 | protected $alignmentPattern = array( |
607 | - array( 0, 0), |
|
608 | - array( 0, 0), array(18, 0), array(22, 0), array(26, 0), array(30, 0), // 1- 5 |
|
609 | - array(34, 0), array(22, 38), array(24, 42), array(26, 46), array(28, 50), // 6-10 |
|
607 | + array(0, 0), |
|
608 | + array(0, 0), array(18, 0), array(22, 0), array(26, 0), array(30, 0), // 1- 5 |
|
609 | + array(34, 0), array(22, 38), array(24, 42), array(26, 46), array(28, 50), // 6-10 |
|
610 | 610 | array(30, 54), array(32, 58), array(34, 62), array(26, 46), array(26, 48), // 11-15 |
611 | 611 | array(26, 50), array(30, 54), array(30, 56), array(30, 58), array(34, 62), // 16-20 |
612 | 612 | array(28, 50), array(26, 50), array(30, 54), array(28, 54), array(32, 58), // 21-25 |
@@ -679,7 +679,7 @@ discard block |
||
679 | 679 | foreach ($qrTab as $line) { |
680 | 680 | $arrAdd = array(); |
681 | 681 | foreach (str_split($line) as $char) { |
682 | - $arrAdd[] = ($char=='1')?1:0; |
|
682 | + $arrAdd[] = ($char == '1') ? 1 : 0; |
|
683 | 683 | } |
684 | 684 | $barcode_array['bcode'][] = $arrAdd; |
685 | 685 | } |
@@ -704,8 +704,8 @@ discard block |
||
704 | 704 | $len = count($frame); |
705 | 705 | // the frame is square (width = height) |
706 | 706 | foreach ($frame as &$frameLine) { |
707 | - for ($i=0; $i<$len; $i++) { |
|
708 | - $frameLine[$i] = (ord($frameLine[$i])&1)?'1':'0'; |
|
707 | + for ($i = 0; $i < $len; $i++) { |
|
708 | + $frameLine[$i] = (ord($frameLine[$i]) & 1) ? '1' : '0'; |
|
709 | 709 | } |
710 | 710 | } |
711 | 711 | return $frame; |
@@ -755,10 +755,10 @@ discard block |
||
755 | 755 | $this->dir = -1; |
756 | 756 | $this->bit = -1; |
757 | 757 | // inteleaved data and ecc codes |
758 | - for ($i=0; $i < ($this->dataLength + $this->eccLength); $i++) { |
|
758 | + for ($i = 0; $i < ($this->dataLength + $this->eccLength); $i++) { |
|
759 | 759 | $code = $this->getCode(); |
760 | 760 | $bit = 0x80; |
761 | - for ($j=0; $j<8; $j++) { |
|
761 | + for ($j = 0; $j < 8; $j++) { |
|
762 | 762 | $addr = $this->getNextPosition(); |
763 | 763 | $this->setFrameAt($addr, 0x02 | (($bit & $code) != 0)); |
764 | 764 | $bit = $bit >> 1; |
@@ -766,7 +766,7 @@ discard block |
||
766 | 766 | } |
767 | 767 | // remainder bits |
768 | 768 | $j = $this->getRemainder($this->version); |
769 | - for ($i=0; $i<$j; $i++) { |
|
769 | + for ($i = 0; $i < $j; $i++) { |
|
770 | 770 | $addr = $this->getNextPosition(); |
771 | 771 | $this->setFrameAt($addr, 0x02); |
772 | 772 | } |
@@ -856,7 +856,7 @@ discard block |
||
856 | 856 | } |
857 | 857 | $this->x = $x; |
858 | 858 | $this->y = $y; |
859 | - } while(ord($this->frame[$y][$x]) & 0x80); |
|
859 | + } while (ord($this->frame[$y][$x]) & 0x80); |
|
860 | 860 | return array('x'=>$x, 'y'=>$y); |
861 | 861 | } |
862 | 862 | |
@@ -877,7 +877,7 @@ discard block |
||
877 | 877 | $dataPos = 0; |
878 | 878 | $eccPos = 0; |
879 | 879 | $endfor = $this->rsBlockNum1($spec); |
880 | - for ($i=0; $i < $endfor; ++$i) { |
|
880 | + for ($i = 0; $i < $endfor; ++$i) { |
|
881 | 881 | $ecc = array_slice($this->ecccode, $eccPos); |
882 | 882 | $this->rsblocks[$blockNo] = array(); |
883 | 883 | $this->rsblocks[$blockNo]['dataLength'] = $dl; |
@@ -885,7 +885,7 @@ discard block |
||
885 | 885 | $this->rsblocks[$blockNo]['eccLength'] = $el; |
886 | 886 | $ecc = $this->encode_rs_char($rs, $this->rsblocks[$blockNo]['data'], $ecc); |
887 | 887 | $this->rsblocks[$blockNo]['ecc'] = $ecc; |
888 | - $this->ecccode = array_merge(array_slice($this->ecccode,0, $eccPos), $ecc); |
|
888 | + $this->ecccode = array_merge(array_slice($this->ecccode, 0, $eccPos), $ecc); |
|
889 | 889 | $dataPos += $dl; |
890 | 890 | $eccPos += $el; |
891 | 891 | $blockNo++; |
@@ -900,7 +900,7 @@ discard block |
||
900 | 900 | return -1; |
901 | 901 | } |
902 | 902 | $endfor = $this->rsBlockNum2($spec); |
903 | - for ($i=0; $i < $endfor; ++$i) { |
|
903 | + for ($i = 0; $i < $endfor; ++$i) { |
|
904 | 904 | $ecc = array_slice($this->ecccode, $eccPos); |
905 | 905 | $this->rsblocks[$blockNo] = array(); |
906 | 906 | $this->rsblocks[$blockNo]['dataLength'] = $dl; |
@@ -953,8 +953,8 @@ discard block |
||
953 | 953 | */ |
954 | 954 | protected function writeFormatInformation($width, &$frame, $mask, $level) { |
955 | 955 | $blacks = 0; |
956 | - $format = $this->getFormatInfo($mask, $level); |
|
957 | - for ($i=0; $i<8; ++$i) { |
|
956 | + $format = $this->getFormatInfo($mask, $level); |
|
957 | + for ($i = 0; $i < 8; ++$i) { |
|
958 | 958 | if ($format & 1) { |
959 | 959 | $blacks += 2; |
960 | 960 | $v = 0x85; |
@@ -969,7 +969,7 @@ discard block |
||
969 | 969 | } |
970 | 970 | $format = $format >> 1; |
971 | 971 | } |
972 | - for ($i=0; $i<7; ++$i) { |
|
972 | + for ($i = 0; $i < 7; ++$i) { |
|
973 | 973 | if ($format & 1) { |
974 | 974 | $blacks += 2; |
975 | 975 | $v = 0x85; |
@@ -1034,7 +1034,7 @@ discard block |
||
1034 | 1034 | * @return int mask |
1035 | 1035 | */ |
1036 | 1036 | protected function mask4($x, $y) { |
1037 | - return (((int)($y / 2)) + ((int)($x / 3))) & 1; |
|
1037 | + return (((int) ($y / 2)) + ((int) ($x / 3))) & 1; |
|
1038 | 1038 | } |
1039 | 1039 | |
1040 | 1040 | /** |
@@ -1076,13 +1076,13 @@ discard block |
||
1076 | 1076 | */ |
1077 | 1077 | protected function generateMaskNo($maskNo, $width, $frame) { |
1078 | 1078 | $bitMask = array_fill(0, $width, array_fill(0, $width, 0)); |
1079 | - for ($y=0; $y<$width; ++$y) { |
|
1080 | - for ($x=0; $x<$width; ++$x) { |
|
1079 | + for ($y = 0; $y < $width; ++$y) { |
|
1080 | + for ($x = 0; $x < $width; ++$x) { |
|
1081 | 1081 | if (ord($frame[$y][$x]) & 0x80) { |
1082 | 1082 | $bitMask[$y][$x] = 0; |
1083 | 1083 | } else { |
1084 | 1084 | $maskFunc = call_user_func(array($this, 'mask'.$maskNo), $x, $y); |
1085 | - $bitMask[$y][$x] = ($maskFunc == 0)?1:0; |
|
1085 | + $bitMask[$y][$x] = ($maskFunc == 0) ? 1 : 0; |
|
1086 | 1086 | } |
1087 | 1087 | } |
1088 | 1088 | } |
@@ -1098,7 +1098,7 @@ discard block |
||
1098 | 1098 | * @param boolean $maskGenOnly |
1099 | 1099 | * @return int b |
1100 | 1100 | */ |
1101 | - protected function makeMaskNo($maskNo, $width, $s, &$d, $maskGenOnly=false) { |
|
1101 | + protected function makeMaskNo($maskNo, $width, $s, &$d, $maskGenOnly = false) { |
|
1102 | 1102 | $b = 0; |
1103 | 1103 | $bitMask = array(); |
1104 | 1104 | $bitMask = $this->generateMaskNo($maskNo, $width, $s); |
@@ -1106,12 +1106,12 @@ discard block |
||
1106 | 1106 | return; |
1107 | 1107 | } |
1108 | 1108 | $d = $s; |
1109 | - for ($y=0; $y<$width; ++$y) { |
|
1110 | - for ($x=0; $x<$width; ++$x) { |
|
1109 | + for ($y = 0; $y < $width; ++$y) { |
|
1110 | + for ($x = 0; $x < $width; ++$x) { |
|
1111 | 1111 | if ($bitMask[$y][$x] == 1) { |
1112 | - $d[$y][$x] = chr(ord($s[$y][$x]) ^ (int)$bitMask[$y][$x]); |
|
1112 | + $d[$y][$x] = chr(ord($s[$y][$x]) ^ (int) $bitMask[$y][$x]); |
|
1113 | 1113 | } |
1114 | - $b += (int)(ord($d[$y][$x]) & 1); |
|
1114 | + $b += (int) (ord($d[$y][$x]) & 1); |
|
1115 | 1115 | } |
1116 | 1116 | } |
1117 | 1117 | return $b; |
@@ -1139,20 +1139,20 @@ discard block |
||
1139 | 1139 | */ |
1140 | 1140 | protected function calcN1N3($length) { |
1141 | 1141 | $demerit = 0; |
1142 | - for ($i=0; $i<$length; ++$i) { |
|
1142 | + for ($i = 0; $i < $length; ++$i) { |
|
1143 | 1143 | if ($this->runLength[$i] >= 5) { |
1144 | 1144 | $demerit += (N1 + ($this->runLength[$i] - 5)); |
1145 | 1145 | } |
1146 | 1146 | if ($i & 1) { |
1147 | - if (($i >= 3) AND ($i < ($length-2)) AND ($this->runLength[$i] % 3 == 0)) { |
|
1148 | - $fact = (int)($this->runLength[$i] / 3); |
|
1149 | - if (($this->runLength[$i-2] == $fact) |
|
1150 | - AND ($this->runLength[$i-1] == $fact) |
|
1151 | - AND ($this->runLength[$i+1] == $fact) |
|
1152 | - AND ($this->runLength[$i+2] == $fact)) { |
|
1153 | - if (($this->runLength[$i-3] < 0) OR ($this->runLength[$i-3] >= (4 * $fact))) { |
|
1147 | + if (($i >= 3) AND ($i < ($length - 2)) AND ($this->runLength[$i] % 3 == 0)) { |
|
1148 | + $fact = (int) ($this->runLength[$i] / 3); |
|
1149 | + if (($this->runLength[$i - 2] == $fact) |
|
1150 | + AND ($this->runLength[$i - 1] == $fact) |
|
1151 | + AND ($this->runLength[$i + 1] == $fact) |
|
1152 | + AND ($this->runLength[$i + 2] == $fact)) { |
|
1153 | + if (($this->runLength[$i - 3] < 0) OR ($this->runLength[$i - 3] >= (4 * $fact))) { |
|
1154 | 1154 | $demerit += N3; |
1155 | - } elseif ((($i+3) >= $length) OR ($this->runLength[$i+3] >= (4 * $fact))) { |
|
1155 | + } elseif ((($i + 3) >= $length) OR ($this->runLength[$i + 3] >= (4 * $fact))) { |
|
1156 | 1156 | $demerit += N3; |
1157 | 1157 | } |
1158 | 1158 | } |
@@ -1171,17 +1171,17 @@ discard block |
||
1171 | 1171 | protected function evaluateSymbol($width, $frame) { |
1172 | 1172 | $head = 0; |
1173 | 1173 | $demerit = 0; |
1174 | - for ($y=0; $y<$width; ++$y) { |
|
1174 | + for ($y = 0; $y < $width; ++$y) { |
|
1175 | 1175 | $head = 0; |
1176 | 1176 | $this->runLength[0] = 1; |
1177 | 1177 | $frameY = $frame[$y]; |
1178 | 1178 | if ($y > 0) { |
1179 | - $frameYM = $frame[$y-1]; |
|
1179 | + $frameYM = $frame[$y - 1]; |
|
1180 | 1180 | } |
1181 | - for ($x=0; $x<$width; ++$x) { |
|
1181 | + for ($x = 0; $x < $width; ++$x) { |
|
1182 | 1182 | if (($x > 0) AND ($y > 0)) { |
1183 | - $b22 = ord($frameY[$x]) & ord($frameY[$x-1]) & ord($frameYM[$x]) & ord($frameYM[$x-1]); |
|
1184 | - $w22 = ord($frameY[$x]) | ord($frameY[$x-1]) | ord($frameYM[$x]) | ord($frameYM[$x-1]); |
|
1183 | + $b22 = ord($frameY[$x]) & ord($frameY[$x - 1]) & ord($frameYM[$x]) & ord($frameYM[$x - 1]); |
|
1184 | + $w22 = ord($frameY[$x]) | ord($frameY[$x - 1]) | ord($frameYM[$x]) | ord($frameYM[$x - 1]); |
|
1185 | 1185 | if (($b22 | ($w22 ^ 1)) & 1) { |
1186 | 1186 | $demerit += N2; |
1187 | 1187 | } |
@@ -1191,7 +1191,7 @@ discard block |
||
1191 | 1191 | $head = 1; |
1192 | 1192 | $this->runLength[$head] = 1; |
1193 | 1193 | } elseif ($x > 0) { |
1194 | - if ((ord($frameY[$x]) ^ ord($frameY[$x-1])) & 1) { |
|
1194 | + if ((ord($frameY[$x]) ^ ord($frameY[$x - 1])) & 1) { |
|
1195 | 1195 | $head++; |
1196 | 1196 | $this->runLength[$head] = 1; |
1197 | 1197 | } else { |
@@ -1199,18 +1199,18 @@ discard block |
||
1199 | 1199 | } |
1200 | 1200 | } |
1201 | 1201 | } |
1202 | - $demerit += $this->calcN1N3($head+1); |
|
1202 | + $demerit += $this->calcN1N3($head + 1); |
|
1203 | 1203 | } |
1204 | - for ($x=0; $x<$width; ++$x) { |
|
1204 | + for ($x = 0; $x < $width; ++$x) { |
|
1205 | 1205 | $head = 0; |
1206 | 1206 | $this->runLength[0] = 1; |
1207 | - for ($y=0; $y<$width; ++$y) { |
|
1207 | + for ($y = 0; $y < $width; ++$y) { |
|
1208 | 1208 | if (($y == 0) AND (ord($frame[$y][$x]) & 1)) { |
1209 | 1209 | $this->runLength[0] = -1; |
1210 | 1210 | $head = 1; |
1211 | 1211 | $this->runLength[$head] = 1; |
1212 | 1212 | } elseif ($y > 0) { |
1213 | - if ((ord($frame[$y][$x]) ^ ord($frame[$y-1][$x])) & 1) { |
|
1213 | + if ((ord($frame[$y][$x]) ^ ord($frame[$y - 1][$x])) & 1) { |
|
1214 | 1214 | $head++; |
1215 | 1215 | $this->runLength[$head] = 1; |
1216 | 1216 | } else { |
@@ -1218,7 +1218,7 @@ discard block |
||
1218 | 1218 | } |
1219 | 1219 | } |
1220 | 1220 | } |
1221 | - $demerit += $this->calcN1N3($head+1); |
|
1221 | + $demerit += $this->calcN1N3($head + 1); |
|
1222 | 1222 | } |
1223 | 1223 | return $demerit; |
1224 | 1224 | } |
@@ -1237,8 +1237,8 @@ discard block |
||
1237 | 1237 | $checked_masks = array(0, 1, 2, 3, 4, 5, 6, 7); |
1238 | 1238 | if (QR_FIND_FROM_RANDOM !== false) { |
1239 | 1239 | $howManuOut = 8 - (QR_FIND_FROM_RANDOM % 9); |
1240 | - for ($i = 0; $i < $howManuOut; ++$i) { |
|
1241 | - $remPos = rand (0, count($checked_masks)-1); |
|
1240 | + for ($i = 0; $i < $howManuOut; ++$i) { |
|
1241 | + $remPos = rand(0, count($checked_masks) - 1); |
|
1242 | 1242 | unset($checked_masks[$remPos]); |
1243 | 1243 | $checked_masks = array_values($checked_masks); |
1244 | 1244 | } |
@@ -1250,8 +1250,8 @@ discard block |
||
1250 | 1250 | $blacks = 0; |
1251 | 1251 | $blacks = $this->makeMaskNo($i, $width, $frame, $mask); |
1252 | 1252 | $blacks += $this->writeFormatInformation($width, $mask, $i, $level); |
1253 | - $blacks = (int)(100 * $blacks / ($width * $width)); |
|
1254 | - $demerit = (int)((int)(abs($blacks - 50) / 5) * N4); |
|
1253 | + $blacks = (int) (100 * $blacks / ($width * $width)); |
|
1254 | + $demerit = (int) ((int) (abs($blacks - 50) / 5) * N4); |
|
1255 | 1255 | $demerit += $this->evaluateSymbol($width, $mask); |
1256 | 1256 | if ($demerit < $minDemerit) { |
1257 | 1257 | $minDemerit = $demerit; |
@@ -1276,7 +1276,7 @@ discard block |
||
1276 | 1276 | if ($pos >= strlen($str)) { |
1277 | 1277 | return false; |
1278 | 1278 | } |
1279 | - return ((ord($str[$pos]) >= ord('0'))&&(ord($str[$pos]) <= ord('9'))); |
|
1279 | + return ((ord($str[$pos]) >= ord('0')) && (ord($str[$pos]) <= ord('9'))); |
|
1280 | 1280 | } |
1281 | 1281 | |
1282 | 1282 | /** |
@@ -1307,8 +1307,8 @@ discard block |
||
1307 | 1307 | } elseif ($this->isalnumat($this->dataStr, $pos)) { |
1308 | 1308 | return QR_MODE_AN; |
1309 | 1309 | } elseif ($this->hint == QR_MODE_KJ) { |
1310 | - if ($pos+1 < strlen($this->dataStr)) { |
|
1311 | - $d = $this->dataStr[$pos+1]; |
|
1310 | + if ($pos + 1 < strlen($this->dataStr)) { |
|
1311 | + $d = $this->dataStr[$pos + 1]; |
|
1312 | 1312 | $word = (ord($c) << 8) | ord($d); |
1313 | 1313 | if (($word >= 0x8140 && $word <= 0x9ffc) OR ($word >= 0xe040 && $word <= 0xebbf)) { |
1314 | 1314 | return QR_MODE_KJ; |
@@ -1325,7 +1325,7 @@ discard block |
||
1325 | 1325 | protected function eatNum() { |
1326 | 1326 | $ln = $this->lengthIndicator(QR_MODE_NM, $this->version); |
1327 | 1327 | $p = 0; |
1328 | - while($this->isdigitat($this->dataStr, $p)) { |
|
1328 | + while ($this->isdigitat($this->dataStr, $p)) { |
|
1329 | 1329 | $p++; |
1330 | 1330 | } |
1331 | 1331 | $run = $p; |
@@ -1341,7 +1341,7 @@ discard block |
||
1341 | 1341 | if ($mode == QR_MODE_AN) { |
1342 | 1342 | $dif = $this->estimateBitsModeNum($run) + 4 + $ln |
1343 | 1343 | + $this->estimateBitsModeAn(1) // + 4 + la |
1344 | - - $this->estimateBitsModeAn($run + 1);// - 4 - la |
|
1344 | + - $this->estimateBitsModeAn($run + 1); // - 4 - la |
|
1345 | 1345 | if ($dif > 0) { |
1346 | 1346 | return $this->eatAn(); |
1347 | 1347 | } |
@@ -1355,13 +1355,13 @@ discard block |
||
1355 | 1355 | * @return int run |
1356 | 1356 | */ |
1357 | 1357 | protected function eatAn() { |
1358 | - $la = $this->lengthIndicator(QR_MODE_AN, $this->version); |
|
1358 | + $la = $this->lengthIndicator(QR_MODE_AN, $this->version); |
|
1359 | 1359 | $ln = $this->lengthIndicator(QR_MODE_NM, $this->version); |
1360 | 1360 | $p = 0; |
1361 | - while($this->isalnumat($this->dataStr, $p)) { |
|
1361 | + while ($this->isalnumat($this->dataStr, $p)) { |
|
1362 | 1362 | if ($this->isdigitat($this->dataStr, $p)) { |
1363 | 1363 | $q = $p; |
1364 | - while($this->isdigitat($this->dataStr, $q)) { |
|
1364 | + while ($this->isdigitat($this->dataStr, $q)) { |
|
1365 | 1365 | $q++; |
1366 | 1366 | } |
1367 | 1367 | $dif = $this->estimateBitsModeAn($p) // + 4 + la |
@@ -1395,7 +1395,7 @@ discard block |
||
1395 | 1395 | */ |
1396 | 1396 | protected function eatKanji() { |
1397 | 1397 | $p = 0; |
1398 | - while($this->identifyMode($p) == QR_MODE_KJ) { |
|
1398 | + while ($this->identifyMode($p) == QR_MODE_KJ) { |
|
1399 | 1399 | $p += 2; |
1400 | 1400 | } |
1401 | 1401 | $this->items = $this->appendNewInputItem($this->items, QR_MODE_KJ, $p, str_split($this->dataStr)); |
@@ -1411,14 +1411,14 @@ discard block |
||
1411 | 1411 | $ln = $this->lengthIndicator(QR_MODE_NM, $this->version); |
1412 | 1412 | $p = 1; |
1413 | 1413 | $dataStrLen = strlen($this->dataStr); |
1414 | - while($p < $dataStrLen) { |
|
1414 | + while ($p < $dataStrLen) { |
|
1415 | 1415 | $mode = $this->identifyMode($p); |
1416 | 1416 | if ($mode == QR_MODE_KJ) { |
1417 | 1417 | break; |
1418 | 1418 | } |
1419 | 1419 | if ($mode == QR_MODE_NM) { |
1420 | 1420 | $q = $p; |
1421 | - while($this->isdigitat($this->dataStr, $q)) { |
|
1421 | + while ($this->isdigitat($this->dataStr, $q)) { |
|
1422 | 1422 | $q++; |
1423 | 1423 | } |
1424 | 1424 | $dif = $this->estimateBitsMode8($p) // + 4 + l8 |
@@ -1431,7 +1431,7 @@ discard block |
||
1431 | 1431 | } |
1432 | 1432 | } elseif ($mode == QR_MODE_AN) { |
1433 | 1433 | $q = $p; |
1434 | - while($this->isalnumat($this->dataStr, $q)) { |
|
1434 | + while ($this->isalnumat($this->dataStr, $q)) { |
|
1435 | 1435 | $q++; |
1436 | 1436 | } |
1437 | 1437 | $dif = $this->estimateBitsMode8($p) // + 4 + l8 |
@@ -1524,7 +1524,7 @@ discard block |
||
1524 | 1524 | * @param array $bstream |
1525 | 1525 | * @return array input item |
1526 | 1526 | */ |
1527 | - protected function newInputItem($mode, $size, $data, $bstream=null) { |
|
1527 | + protected function newInputItem($mode, $size, $data, $bstream = null) { |
|
1528 | 1528 | $setData = array_slice($data, 0, $size); |
1529 | 1529 | if (count($setData) < $size) { |
1530 | 1530 | $setData = array_merge($setData, array_fill(0, ($size - count($setData)), 0)); |
@@ -1547,23 +1547,23 @@ discard block |
||
1547 | 1547 | * @return array input item |
1548 | 1548 | */ |
1549 | 1549 | protected function encodeModeNum($inputitem, $version) { |
1550 | - $words = (int)($inputitem['size'] / 3); |
|
1550 | + $words = (int) ($inputitem['size'] / 3); |
|
1551 | 1551 | $inputitem['bstream'] = array(); |
1552 | 1552 | $val = 0x1; |
1553 | 1553 | $inputitem['bstream'] = $this->appendNum($inputitem['bstream'], 4, $val); |
1554 | 1554 | $inputitem['bstream'] = $this->appendNum($inputitem['bstream'], $this->lengthIndicator(QR_MODE_NM, $version), $inputitem['size']); |
1555 | - for ($i=0; $i < $words; ++$i) { |
|
1556 | - $val = (ord($inputitem['data'][$i*3 ]) - ord('0')) * 100; |
|
1557 | - $val += (ord($inputitem['data'][$i*3+1]) - ord('0')) * 10; |
|
1558 | - $val += (ord($inputitem['data'][$i*3+2]) - ord('0')); |
|
1555 | + for ($i = 0; $i < $words; ++$i) { |
|
1556 | + $val = (ord($inputitem['data'][$i * 3]) - ord('0')) * 100; |
|
1557 | + $val += (ord($inputitem['data'][$i * 3 + 1]) - ord('0')) * 10; |
|
1558 | + $val += (ord($inputitem['data'][$i * 3 + 2]) - ord('0')); |
|
1559 | 1559 | $inputitem['bstream'] = $this->appendNum($inputitem['bstream'], 10, $val); |
1560 | 1560 | } |
1561 | 1561 | if ($inputitem['size'] - $words * 3 == 1) { |
1562 | - $val = ord($inputitem['data'][$words*3]) - ord('0'); |
|
1562 | + $val = ord($inputitem['data'][$words * 3]) - ord('0'); |
|
1563 | 1563 | $inputitem['bstream'] = $this->appendNum($inputitem['bstream'], 4, $val); |
1564 | 1564 | } elseif (($inputitem['size'] - ($words * 3)) == 2) { |
1565 | - $val = (ord($inputitem['data'][$words*3 ]) - ord('0')) * 10; |
|
1566 | - $val += (ord($inputitem['data'][$words*3+1]) - ord('0')); |
|
1565 | + $val = (ord($inputitem['data'][$words * 3]) - ord('0')) * 10; |
|
1566 | + $val += (ord($inputitem['data'][$words * 3 + 1]) - ord('0')); |
|
1567 | 1567 | $inputitem['bstream'] = $this->appendNum($inputitem['bstream'], 7, $val); |
1568 | 1568 | } |
1569 | 1569 | return $inputitem; |
@@ -1576,13 +1576,13 @@ discard block |
||
1576 | 1576 | * @return array input item |
1577 | 1577 | */ |
1578 | 1578 | protected function encodeModeAn($inputitem, $version) { |
1579 | - $words = (int)($inputitem['size'] / 2); |
|
1579 | + $words = (int) ($inputitem['size'] / 2); |
|
1580 | 1580 | $inputitem['bstream'] = array(); |
1581 | 1581 | $inputitem['bstream'] = $this->appendNum($inputitem['bstream'], 4, 0x02); |
1582 | 1582 | $inputitem['bstream'] = $this->appendNum(v, $this->lengthIndicator(QR_MODE_AN, $version), $inputitem['size']); |
1583 | - for ($i=0; $i < $words; ++$i) { |
|
1584 | - $val = (int)$this->lookAnTable(ord($inputitem['data'][$i*2 ])) * 45; |
|
1585 | - $val += (int)$this->lookAnTable(ord($inputitem['data'][$i*2+1])); |
|
1583 | + for ($i = 0; $i < $words; ++$i) { |
|
1584 | + $val = (int) $this->lookAnTable(ord($inputitem['data'][$i * 2])) * 45; |
|
1585 | + $val += (int) $this->lookAnTable(ord($inputitem['data'][$i * 2 + 1])); |
|
1586 | 1586 | $inputitem['bstream'] = $this->appendNum($inputitem['bstream'], 11, $val); |
1587 | 1587 | } |
1588 | 1588 | if ($inputitem['size'] & 1) { |
@@ -1602,7 +1602,7 @@ discard block |
||
1602 | 1602 | $inputitem['bstream'] = array(); |
1603 | 1603 | $inputitem['bstream'] = $this->appendNum($inputitem['bstream'], 4, 0x4); |
1604 | 1604 | $inputitem['bstream'] = $this->appendNum($inputitem['bstream'], $this->lengthIndicator(QR_MODE_8B, $version), $inputitem['size']); |
1605 | - for ($i=0; $i < $inputitem['size']; ++$i) { |
|
1605 | + for ($i = 0; $i < $inputitem['size']; ++$i) { |
|
1606 | 1606 | $inputitem['bstream'] = $this->appendNum($inputitem['bstream'], 8, ord($inputitem['data'][$i])); |
1607 | 1607 | } |
1608 | 1608 | return $inputitem; |
@@ -1617,9 +1617,9 @@ discard block |
||
1617 | 1617 | protected function encodeModeKanji($inputitem, $version) { |
1618 | 1618 | $inputitem['bstream'] = array(); |
1619 | 1619 | $inputitem['bstream'] = $this->appendNum($inputitem['bstream'], 4, 0x8); |
1620 | - $inputitem['bstream'] = $this->appendNum($inputitem['bstream'], $this->lengthIndicator(QR_MODE_KJ, $version), (int)($inputitem['size'] / 2)); |
|
1621 | - for ($i=0; $i<$inputitem['size']; $i+=2) { |
|
1622 | - $val = (ord($inputitem['data'][$i]) << 8) | ord($inputitem['data'][$i+1]); |
|
1620 | + $inputitem['bstream'] = $this->appendNum($inputitem['bstream'], $this->lengthIndicator(QR_MODE_KJ, $version), (int) ($inputitem['size'] / 2)); |
|
1621 | + for ($i = 0; $i < $inputitem['size']; $i += 2) { |
|
1622 | + $val = (ord($inputitem['data'][$i]) << 8) | ord($inputitem['data'][$i + 1]); |
|
1623 | 1623 | if ($val <= 0x9ffc) { |
1624 | 1624 | $val -= 0x8140; |
1625 | 1625 | } else { |
@@ -1664,7 +1664,7 @@ discard block |
||
1664 | 1664 | $inputitem['bstream'] = $this->appendBitstream($inputitem['bstream'], $st1['bstream']); |
1665 | 1665 | $inputitem['bstream'] = $this->appendBitstream($inputitem['bstream'], $st2['bstream']); |
1666 | 1666 | } else { |
1667 | - switch($inputitem['mode']) { |
|
1667 | + switch ($inputitem['mode']) { |
|
1668 | 1668 | case QR_MODE_NM: { |
1669 | 1669 | $inputitem = $this->encodeModeNum($inputitem, $version); |
1670 | 1670 | break; |
@@ -1742,7 +1742,7 @@ discard block |
||
1742 | 1742 | $parity = 0; |
1743 | 1743 | foreach ($items as $item) { |
1744 | 1744 | if ($item['mode'] != QR_MODE_ST) { |
1745 | - for ($i=$item['size']-1; $i>=0; --$i) { |
|
1745 | + for ($i = $item['size'] - 1; $i >= 0; --$i) { |
|
1746 | 1746 | $parity ^= $item['data'][$i]; |
1747 | 1747 | } |
1748 | 1748 | } |
@@ -1757,8 +1757,8 @@ discard block |
||
1757 | 1757 | * @return boolean true or false |
1758 | 1758 | */ |
1759 | 1759 | protected function checkModeNum($size, $data) { |
1760 | - for ($i=0; $i<$size; ++$i) { |
|
1761 | - if ((ord($data[$i]) < ord('0')) OR (ord($data[$i]) > ord('9'))){ |
|
1760 | + for ($i = 0; $i < $size; ++$i) { |
|
1761 | + if ((ord($data[$i]) < ord('0')) OR (ord($data[$i]) > ord('9'))) { |
|
1762 | 1762 | return false; |
1763 | 1763 | } |
1764 | 1764 | } |
@@ -1771,9 +1771,9 @@ discard block |
||
1771 | 1771 | * @return int number of bits |
1772 | 1772 | */ |
1773 | 1773 | protected function estimateBitsModeNum($size) { |
1774 | - $w = (int)$size / 3; |
|
1774 | + $w = (int) $size / 3; |
|
1775 | 1775 | $bits = $w * 10; |
1776 | - switch($size - $w * 3) { |
|
1776 | + switch ($size - $w * 3) { |
|
1777 | 1777 | case 1: { |
1778 | 1778 | $bits += 4; |
1779 | 1779 | break; |
@@ -1795,7 +1795,7 @@ discard block |
||
1795 | 1795 | * @return value |
1796 | 1796 | */ |
1797 | 1797 | protected function lookAnTable($c) { |
1798 | - return (($c > 127)?-1:$this->anTable[$c]); |
|
1798 | + return (($c > 127) ?-1 : $this->anTable[$c]); |
|
1799 | 1799 | } |
1800 | 1800 | |
1801 | 1801 | /** |
@@ -1805,7 +1805,7 @@ discard block |
||
1805 | 1805 | * @return boolean true or false |
1806 | 1806 | */ |
1807 | 1807 | protected function checkModeAn($size, $data) { |
1808 | - for ($i=0; $i<$size; ++$i) { |
|
1808 | + for ($i = 0; $i < $size; ++$i) { |
|
1809 | 1809 | if ($this->lookAnTable(ord($data[$i])) == -1) { |
1810 | 1810 | return false; |
1811 | 1811 | } |
@@ -1819,7 +1819,7 @@ discard block |
||
1819 | 1819 | * @return int number of bits |
1820 | 1820 | */ |
1821 | 1821 | protected function estimateBitsModeAn($size) { |
1822 | - $w = (int)($size / 2); |
|
1822 | + $w = (int) ($size / 2); |
|
1823 | 1823 | $bits = $w * 11; |
1824 | 1824 | if ($size & 1) { |
1825 | 1825 | $bits += 6; |
@@ -1842,7 +1842,7 @@ discard block |
||
1842 | 1842 | * @return int number of bits |
1843 | 1843 | */ |
1844 | 1844 | protected function estimateBitsModeKanji($size) { |
1845 | - return (int)(($size / 2) * 13); |
|
1845 | + return (int) (($size / 2) * 13); |
|
1846 | 1846 | } |
1847 | 1847 | |
1848 | 1848 | /** |
@@ -1855,8 +1855,8 @@ discard block |
||
1855 | 1855 | if ($size & 1) { |
1856 | 1856 | return false; |
1857 | 1857 | } |
1858 | - for ($i=0; $i<$size; $i+=2) { |
|
1859 | - $val = (ord($data[$i]) << 8) | ord($data[$i+1]); |
|
1858 | + for ($i = 0; $i < $size; $i += 2) { |
|
1859 | + $val = (ord($data[$i]) << 8) | ord($data[$i + 1]); |
|
1860 | 1860 | if (($val < 0x8140) OR (($val > 0x9ffc) AND ($val < 0xe040)) OR ($val > 0xebbf)) { |
1861 | 1861 | return false; |
1862 | 1862 | } |
@@ -1875,7 +1875,7 @@ discard block |
||
1875 | 1875 | if ($size <= 0) { |
1876 | 1876 | return false; |
1877 | 1877 | } |
1878 | - switch($mode) { |
|
1878 | + switch ($mode) { |
|
1879 | 1879 | case QR_MODE_NM: { |
1880 | 1880 | return $this->checkModeNum($size, $data); |
1881 | 1881 | } |
@@ -1910,7 +1910,7 @@ discard block |
||
1910 | 1910 | $version = 1; |
1911 | 1911 | } |
1912 | 1912 | foreach ($items as $item) { |
1913 | - switch($item['mode']) { |
|
1913 | + switch ($item['mode']) { |
|
1914 | 1914 | case QR_MODE_NM: { |
1915 | 1915 | $bits = $this->estimateBitsModeNum($item['size']); |
1916 | 1916 | break; |
@@ -1936,7 +1936,7 @@ discard block |
||
1936 | 1936 | } |
1937 | 1937 | $l = $this->lengthIndicator($item['mode'], $version); |
1938 | 1938 | $m = 1 << $l; |
1939 | - $num = (int)(($item['size'] + $m - 1) / $m); |
|
1939 | + $num = (int) (($item['size'] + $m - 1) / $m); |
|
1940 | 1940 | $bits += $num * (4 + $l); |
1941 | 1941 | } |
1942 | 1942 | return $bits; |
@@ -1953,7 +1953,7 @@ discard block |
||
1953 | 1953 | do { |
1954 | 1954 | $prev = $version; |
1955 | 1955 | $bits = $this->estimateBitStreamSize($items, $prev); |
1956 | - $version = $this->getMinimumVersion((int)(($bits + 7) / 8), $this->level); |
|
1956 | + $version = $this->getMinimumVersion((int) (($bits + 7) / 8), $this->level); |
|
1957 | 1957 | if ($version < 0) { |
1958 | 1958 | return -1; |
1959 | 1959 | } |
@@ -1970,9 +1970,9 @@ discard block |
||
1970 | 1970 | */ |
1971 | 1971 | protected function lengthOfCode($mode, $version, $bits) { |
1972 | 1972 | $payload = $bits - 4 - $this->lengthIndicator($mode, $version); |
1973 | - switch($mode) { |
|
1973 | + switch ($mode) { |
|
1974 | 1974 | case QR_MODE_NM: { |
1975 | - $chunks = (int)($payload / 10); |
|
1975 | + $chunks = (int) ($payload / 10); |
|
1976 | 1976 | $remain = $payload - $chunks * 10; |
1977 | 1977 | $size = $chunks * 3; |
1978 | 1978 | if ($remain >= 7) { |
@@ -1983,7 +1983,7 @@ discard block |
||
1983 | 1983 | break; |
1984 | 1984 | } |
1985 | 1985 | case QR_MODE_AN: { |
1986 | - $chunks = (int)($payload / 11); |
|
1986 | + $chunks = (int) ($payload / 11); |
|
1987 | 1987 | $remain = $payload - $chunks * 11; |
1988 | 1988 | $size = $chunks * 2; |
1989 | 1989 | if ($remain >= 6) { |
@@ -1992,15 +1992,15 @@ discard block |
||
1992 | 1992 | break; |
1993 | 1993 | } |
1994 | 1994 | case QR_MODE_8B: { |
1995 | - $size = (int)($payload / 8); |
|
1995 | + $size = (int) ($payload / 8); |
|
1996 | 1996 | break; |
1997 | 1997 | } |
1998 | 1998 | case QR_MODE_KJ: { |
1999 | - $size = (int)(($payload / 13) * 2); |
|
1999 | + $size = (int) (($payload / 13) * 2); |
|
2000 | 2000 | break; |
2001 | 2001 | } |
2002 | 2002 | case QR_MODE_ST: { |
2003 | - $size = (int)($payload / 8); |
|
2003 | + $size = (int) ($payload / 8); |
|
2004 | 2004 | break; |
2005 | 2005 | } |
2006 | 2006 | default: { |
@@ -2050,7 +2050,7 @@ discard block |
||
2050 | 2050 | if ($bits < 0) { |
2051 | 2051 | return -1; |
2052 | 2052 | } |
2053 | - $ver = $this->getMinimumVersion((int)(($bits + 7) / 8), $this->level); |
|
2053 | + $ver = $this->getMinimumVersion((int) (($bits + 7) / 8), $this->level); |
|
2054 | 2054 | if ($ver < 0) { |
2055 | 2055 | return -1; |
2056 | 2056 | } elseif ($ver > $this->version) { |
@@ -2078,14 +2078,14 @@ discard block |
||
2078 | 2078 | return $this->appendNum($bstream, $maxbits - $bits, 0); |
2079 | 2079 | } |
2080 | 2080 | $bits += 4; |
2081 | - $words = (int)(($bits + 7) / 8); |
|
2081 | + $words = (int) (($bits + 7) / 8); |
|
2082 | 2082 | $padding = array(); |
2083 | 2083 | $padding = $this->appendNum($padding, $words * 8 - $bits + 4, 0); |
2084 | 2084 | $padlen = $maxwords - $words; |
2085 | 2085 | if ($padlen > 0) { |
2086 | 2086 | $padbuf = array(); |
2087 | - for ($i=0; $i<$padlen; ++$i) { |
|
2088 | - $padbuf[$i] = ($i&1)?0x11:0xec; |
|
2087 | + for ($i = 0; $i < $padlen; ++$i) { |
|
2088 | + $padbuf[$i] = ($i & 1) ? 0x11 : 0xec; |
|
2089 | 2089 | } |
2090 | 2090 | $padding = $this->appendBytes($padding, $padlen, $padbuf); |
2091 | 2091 | } |
@@ -2148,7 +2148,7 @@ discard block |
||
2148 | 2148 | protected function newFromNum($bits, $num) { |
2149 | 2149 | $bstream = $this->allocate($bits); |
2150 | 2150 | $mask = 1 << ($bits - 1); |
2151 | - for ($i=0; $i<$bits; ++$i) { |
|
2151 | + for ($i = 0; $i < $bits; ++$i) { |
|
2152 | 2152 | if ($num & $mask) { |
2153 | 2153 | $bstream[$i] = 1; |
2154 | 2154 | } else { |
@@ -2167,10 +2167,10 @@ discard block |
||
2167 | 2167 | */ |
2168 | 2168 | protected function newFromBytes($size, $data) { |
2169 | 2169 | $bstream = $this->allocate($size * 8); |
2170 | - $p=0; |
|
2171 | - for ($i=0; $i<$size; ++$i) { |
|
2170 | + $p = 0; |
|
2171 | + for ($i = 0; $i < $size; ++$i) { |
|
2172 | 2172 | $mask = 0x80; |
2173 | - for ($j=0; $j<8; ++$j) { |
|
2173 | + for ($j = 0; $j < 8; ++$j) { |
|
2174 | 2174 | if ($data[$i] & $mask) { |
2175 | 2175 | $bstream[$p] = 1; |
2176 | 2176 | } else { |
@@ -2239,12 +2239,12 @@ discard block |
||
2239 | 2239 | if ($size == 0) { |
2240 | 2240 | return array(); |
2241 | 2241 | } |
2242 | - $data = array_fill(0, (int)(($size + 7) / 8), 0); |
|
2243 | - $bytes = (int)($size / 8); |
|
2242 | + $data = array_fill(0, (int) (($size + 7) / 8), 0); |
|
2243 | + $bytes = (int) ($size / 8); |
|
2244 | 2244 | $p = 0; |
2245 | - for ($i=0; $i<$bytes; $i++) { |
|
2245 | + for ($i = 0; $i < $bytes; $i++) { |
|
2246 | 2246 | $v = 0; |
2247 | - for ($j=0; $j<8; $j++) { |
|
2247 | + for ($j = 0; $j < 8; $j++) { |
|
2248 | 2248 | $v = $v << 1; |
2249 | 2249 | $v |= $bstream[$p]; |
2250 | 2250 | $p++; |
@@ -2253,7 +2253,7 @@ discard block |
||
2253 | 2253 | } |
2254 | 2254 | if ($size & 7) { |
2255 | 2255 | $v = 0; |
2256 | - for ($j=0; $j<($size & 7); $j++) { |
|
2256 | + for ($j = 0; $j < ($size & 7); $j++) { |
|
2257 | 2257 | $v = $v << 1; |
2258 | 2258 | $v |= $bstream[$p]; |
2259 | 2259 | $p++; |
@@ -2276,8 +2276,8 @@ discard block |
||
2276 | 2276 | * @param int $replLen length of the repl string |
2277 | 2277 | * @return array srctab |
2278 | 2278 | */ |
2279 | - protected function qrstrset($srctab, $x, $y, $repl, $replLen=false) { |
|
2280 | - $srctab[$y] = substr_replace($srctab[$y], ($replLen !== false)?substr($repl,0,$replLen):$repl, $x, ($replLen !== false)?$replLen:strlen($repl)); |
|
2279 | + protected function qrstrset($srctab, $x, $y, $repl, $replLen = false) { |
|
2280 | + $srctab[$y] = substr_replace($srctab[$y], ($replLen !== false) ?substr($repl, 0, $replLen) : $repl, $x, ($replLen !== false) ? $replLen : strlen($repl)); |
|
2281 | 2281 | return $srctab; |
2282 | 2282 | } |
2283 | 2283 | |
@@ -2297,7 +2297,7 @@ discard block |
||
2297 | 2297 | * @param int $level error correction level |
2298 | 2298 | * @return int ECC size (bytes) |
2299 | 2299 | */ |
2300 | - protected function getECCLength($version, $level){ |
|
2300 | + protected function getECCLength($version, $level) { |
|
2301 | 2301 | return $this->capacity[$version][QRCAP_EC][$level]; |
2302 | 2302 | } |
2303 | 2303 | |
@@ -2326,8 +2326,8 @@ discard block |
||
2326 | 2326 | * @return int version number |
2327 | 2327 | */ |
2328 | 2328 | protected function getMinimumVersion($size, $level) { |
2329 | - for ($i=1; $i <= QRSPEC_VERSION_MAX; ++$i) { |
|
2330 | - $words = $this->capacity[$i][QRCAP_WORDS] - $this->capacity[$i][QRCAP_EC][$level]; |
|
2329 | + for ($i = 1; $i <= QRSPEC_VERSION_MAX; ++$i) { |
|
2330 | + $words = $this->capacity[$i][QRCAP_WORDS] - $this->capacity[$i][QRCAP_EC][$level]; |
|
2331 | 2331 | if ($words >= $size) { |
2332 | 2332 | return $i; |
2333 | 2333 | } |
@@ -2397,14 +2397,14 @@ discard block |
||
2397 | 2397 | $ecc = $this->getECCLength($version, $level); |
2398 | 2398 | if ($b2 == 0) { |
2399 | 2399 | $spec[0] = $b1; |
2400 | - $spec[1] = (int)($data / $b1); |
|
2401 | - $spec[2] = (int)($ecc / $b1); |
|
2400 | + $spec[1] = (int) ($data / $b1); |
|
2401 | + $spec[2] = (int) ($ecc / $b1); |
|
2402 | 2402 | $spec[3] = 0; |
2403 | 2403 | $spec[4] = 0; |
2404 | 2404 | } else { |
2405 | 2405 | $spec[0] = $b1; |
2406 | - $spec[1] = (int)($data / ($b1 + $b2)); |
|
2407 | - $spec[2] = (int)($ecc / ($b1 + $b2)); |
|
2406 | + $spec[1] = (int) ($data / ($b1 + $b2)); |
|
2407 | + $spec[2] = (int) ($ecc / ($b1 + $b2)); |
|
2408 | 2408 | $spec[3] = $b2; |
2409 | 2409 | $spec[4] = $spec[1] + 1; |
2410 | 2410 | } |
@@ -2429,8 +2429,8 @@ discard block |
||
2429 | 2429 | ); |
2430 | 2430 | $yStart = $oy - 2; |
2431 | 2431 | $xStart = $ox - 2; |
2432 | - for ($y=0; $y < 5; $y++) { |
|
2433 | - $frame = $this->qrstrset($frame, $xStart, $yStart+$y, $finder[$y]); |
|
2432 | + for ($y = 0; $y < 5; $y++) { |
|
2433 | + $frame = $this->qrstrset($frame, $xStart, $yStart + $y, $finder[$y]); |
|
2434 | 2434 | } |
2435 | 2435 | return $frame; |
2436 | 2436 | } |
@@ -2450,7 +2450,7 @@ discard block |
||
2450 | 2450 | if ($d < 0) { |
2451 | 2451 | $w = 2; |
2452 | 2452 | } else { |
2453 | - $w = (int)(($width - $this->alignmentPattern[$version][0]) / $d + 2); |
|
2453 | + $w = (int) (($width - $this->alignmentPattern[$version][0]) / $d + 2); |
|
2454 | 2454 | } |
2455 | 2455 | if ($w * $w - 3 == 1) { |
2456 | 2456 | $x = $this->alignmentPattern[$version][0]; |
@@ -2460,15 +2460,15 @@ discard block |
||
2460 | 2460 | } |
2461 | 2461 | $cx = $this->alignmentPattern[$version][0]; |
2462 | 2462 | $wo = $w - 1; |
2463 | - for ($x=1; $x < $wo; ++$x) { |
|
2463 | + for ($x = 1; $x < $wo; ++$x) { |
|
2464 | 2464 | $frame = $this->putAlignmentMarker($frame, 6, $cx); |
2465 | - $frame = $this->putAlignmentMarker($frame, $cx, 6); |
|
2465 | + $frame = $this->putAlignmentMarker($frame, $cx, 6); |
|
2466 | 2466 | $cx += $d; |
2467 | 2467 | } |
2468 | 2468 | $cy = $this->alignmentPattern[$version][0]; |
2469 | - for ($y=0; $y < $wo; ++$y) { |
|
2469 | + for ($y = 0; $y < $wo; ++$y) { |
|
2470 | 2470 | $cx = $this->alignmentPattern[$version][0]; |
2471 | - for ($x=0; $x < $wo; ++$x) { |
|
2471 | + for ($x = 0; $x < $wo; ++$x) { |
|
2472 | 2472 | $frame = $this->putAlignmentMarker($frame, $cx, $cy); |
2473 | 2473 | $cx += $d; |
2474 | 2474 | } |
@@ -2523,7 +2523,7 @@ discard block |
||
2523 | 2523 | "\xc1\xc0\xc0\xc0\xc0\xc0\xc1", |
2524 | 2524 | "\xc1\xc1\xc1\xc1\xc1\xc1\xc1" |
2525 | 2525 | ); |
2526 | - for ($y=0; $y < 7; $y++) { |
|
2526 | + for ($y = 0; $y < 7; $y++) { |
|
2527 | 2527 | $frame = $this->qrstrset($frame, $ox, ($oy + $y), $finder[$y]); |
2528 | 2528 | } |
2529 | 2529 | return $frame; |
@@ -2536,7 +2536,7 @@ discard block |
||
2536 | 2536 | */ |
2537 | 2537 | protected function createFrame($version) { |
2538 | 2538 | $width = $this->capacity[$version][QRCAP_WIDTH]; |
2539 | - $frameLine = str_repeat ("\0", $width); |
|
2539 | + $frameLine = str_repeat("\0", $width); |
|
2540 | 2540 | $frame = array_fill(0, $width, $frameLine); |
2541 | 2541 | // Finder pattern |
2542 | 2542 | $frame = $this->putFinderPattern($frame, 0, 0); |
@@ -2544,7 +2544,7 @@ discard block |
||
2544 | 2544 | $frame = $this->putFinderPattern($frame, 0, $width - 7); |
2545 | 2545 | // Separator |
2546 | 2546 | $yOffset = $width - 7; |
2547 | - for ($y=0; $y < 7; ++$y) { |
|
2547 | + for ($y = 0; $y < 7; ++$y) { |
|
2548 | 2548 | $frame[$y][7] = "\xc0"; |
2549 | 2549 | $frame[$y][$width - 8] = "\xc0"; |
2550 | 2550 | $frame[$yOffset][7] = "\xc0"; |
@@ -2552,22 +2552,22 @@ discard block |
||
2552 | 2552 | } |
2553 | 2553 | $setPattern = str_repeat("\xc0", 8); |
2554 | 2554 | $frame = $this->qrstrset($frame, 0, 7, $setPattern); |
2555 | - $frame = $this->qrstrset($frame, $width-8, 7, $setPattern); |
|
2555 | + $frame = $this->qrstrset($frame, $width - 8, 7, $setPattern); |
|
2556 | 2556 | $frame = $this->qrstrset($frame, 0, $width - 8, $setPattern); |
2557 | 2557 | // Format info |
2558 | 2558 | $setPattern = str_repeat("\x84", 9); |
2559 | 2559 | $frame = $this->qrstrset($frame, 0, 8, $setPattern); |
2560 | 2560 | $frame = $this->qrstrset($frame, $width - 8, 8, $setPattern, 8); |
2561 | 2561 | $yOffset = $width - 8; |
2562 | - for ($y=0; $y < 8; ++$y,++$yOffset) { |
|
2562 | + for ($y = 0; $y < 8; ++$y, ++$yOffset) { |
|
2563 | 2563 | $frame[$y][8] = "\x84"; |
2564 | 2564 | $frame[$yOffset][8] = "\x84"; |
2565 | 2565 | } |
2566 | 2566 | // Timing pattern |
2567 | 2567 | $wo = $width - 15; |
2568 | - for ($i=1; $i < $wo; ++$i) { |
|
2569 | - $frame[6][7+$i] = chr(0x90 | ($i & 1)); |
|
2570 | - $frame[7+$i][6] = chr(0x90 | ($i & 1)); |
|
2568 | + for ($i = 1; $i < $wo; ++$i) { |
|
2569 | + $frame[6][7 + $i] = chr(0x90 | ($i & 1)); |
|
2570 | + $frame[7 + $i][6] = chr(0x90 | ($i & 1)); |
|
2571 | 2571 | } |
2572 | 2572 | // Alignment pattern |
2573 | 2573 | $frame = $this->putAlignmentPattern($version, $frame, $width); |
@@ -2575,16 +2575,16 @@ discard block |
||
2575 | 2575 | if ($version >= 7) { |
2576 | 2576 | $vinf = $this->getVersionPattern($version); |
2577 | 2577 | $v = $vinf; |
2578 | - for ($x=0; $x<6; ++$x) { |
|
2579 | - for ($y=0; $y<3; ++$y) { |
|
2580 | - $frame[($width - 11)+$y][$x] = chr(0x88 | ($v & 1)); |
|
2578 | + for ($x = 0; $x < 6; ++$x) { |
|
2579 | + for ($y = 0; $y < 3; ++$y) { |
|
2580 | + $frame[($width - 11) + $y][$x] = chr(0x88 | ($v & 1)); |
|
2581 | 2581 | $v = $v >> 1; |
2582 | 2582 | } |
2583 | 2583 | } |
2584 | 2584 | $v = $vinf; |
2585 | - for ($y=0; $y<6; ++$y) { |
|
2586 | - for ($x=0; $x<3; ++$x) { |
|
2587 | - $frame[$y][$x+($width - 11)] = chr(0x88 | ($v & 1)); |
|
2585 | + for ($y = 0; $y < 6; ++$y) { |
|
2586 | + for ($x = 0; $x < 3; ++$x) { |
|
2587 | + $frame[$y][$x + ($width - 11)] = chr(0x88 | ($v & 1)); |
|
2588 | 2588 | $v = $v >> 1; |
2589 | 2589 | } |
2590 | 2590 | } |
@@ -2755,16 +2755,16 @@ discard block |
||
2755 | 2755 | if (($symsize < 0) OR ($symsize > 8)) { |
2756 | 2756 | return $rs; |
2757 | 2757 | } |
2758 | - if (($fcr < 0) OR ($fcr >= (1<<$symsize))) { |
|
2758 | + if (($fcr < 0) OR ($fcr >= (1 << $symsize))) { |
|
2759 | 2759 | return $rs; |
2760 | 2760 | } |
2761 | - if (($prim <= 0) OR ($prim >= (1<<$symsize))) { |
|
2761 | + if (($prim <= 0) OR ($prim >= (1 << $symsize))) { |
|
2762 | 2762 | return $rs; |
2763 | 2763 | } |
2764 | - if (($nroots < 0) OR ($nroots >= (1<<$symsize))) { |
|
2764 | + if (($nroots < 0) OR ($nroots >= (1 << $symsize))) { |
|
2765 | 2765 | return $rs; |
2766 | 2766 | } |
2767 | - if (($pad < 0) OR ($pad >= ((1<<$symsize) -1 - $nroots))) { |
|
2767 | + if (($pad < 0) OR ($pad >= ((1 << $symsize) - 1 - $nroots))) { |
|
2768 | 2768 | return $rs; |
2769 | 2769 | } |
2770 | 2770 | $rs = array(); |
@@ -2774,13 +2774,13 @@ discard block |
||
2774 | 2774 | $rs['alpha_to'] = array_fill(0, ($rs['nn'] + 1), 0); |
2775 | 2775 | $rs['index_of'] = array_fill(0, ($rs['nn'] + 1), 0); |
2776 | 2776 | // PHP style macro replacement ;) |
2777 | - $NN =& $rs['nn']; |
|
2778 | - $A0 =& $NN; |
|
2777 | + $NN = & $rs['nn']; |
|
2778 | + $A0 = & $NN; |
|
2779 | 2779 | // Generate Galois field lookup tables |
2780 | 2780 | $rs['index_of'][0] = $A0; // log(zero) = -inf |
2781 | 2781 | $rs['alpha_to'][$A0] = 0; // alpha**-inf = 0 |
2782 | 2782 | $sr = 1; |
2783 | - for ($i=0; $i<$rs['nn']; ++$i) { |
|
2783 | + for ($i = 0; $i < $rs['nn']; ++$i) { |
|
2784 | 2784 | $rs['index_of'][$sr] = $i; |
2785 | 2785 | $rs['alpha_to'][$i] = $sr; |
2786 | 2786 | $sr <<= 1; |
@@ -2800,21 +2800,21 @@ discard block |
||
2800 | 2800 | $rs['nroots'] = $nroots; |
2801 | 2801 | $rs['gfpoly'] = $gfpoly; |
2802 | 2802 | // Find prim-th root of 1, used in decoding |
2803 | - for ($iprim=1; ($iprim % $prim) != 0; $iprim += $rs['nn']) { |
|
2803 | + for ($iprim = 1; ($iprim % $prim) != 0; $iprim += $rs['nn']) { |
|
2804 | 2804 | ; // intentional empty-body loop! |
2805 | 2805 | } |
2806 | - $rs['iprim'] = (int)($iprim / $prim); |
|
2806 | + $rs['iprim'] = (int) ($iprim / $prim); |
|
2807 | 2807 | $rs['genpoly'][0] = 1; |
2808 | 2808 | |
2809 | 2809 | |
2810 | - for ($i = 0,$root=$fcr*$prim; $i < $nroots; $i++, $root += $prim) { |
|
2811 | - $rs['genpoly'][$i+1] = 1; |
|
2810 | + for ($i = 0, $root = $fcr * $prim; $i < $nroots; $i++, $root += $prim) { |
|
2811 | + $rs['genpoly'][$i + 1] = 1; |
|
2812 | 2812 | // Multiply rs->genpoly[] by @**(root + x) |
2813 | 2813 | for ($j = $i; $j > 0; --$j) { |
2814 | 2814 | if ($rs['genpoly'][$j] != 0) { |
2815 | - $rs['genpoly'][$j] = $rs['genpoly'][$j-1] ^ $rs['alpha_to'][$this->modnn($rs, $rs['index_of'][$rs['genpoly'][$j]] + $root)]; |
|
2815 | + $rs['genpoly'][$j] = $rs['genpoly'][$j - 1] ^ $rs['alpha_to'][$this->modnn($rs, $rs['index_of'][$rs['genpoly'][$j]] + $root)]; |
|
2816 | 2816 | } else { |
2817 | - $rs['genpoly'][$j] = $rs['genpoly'][$j-1]; |
|
2817 | + $rs['genpoly'][$j] = $rs['genpoly'][$j - 1]; |
|
2818 | 2818 | } |
2819 | 2819 | } |
2820 | 2820 | // rs->genpoly[0] can never be zero |
@@ -2835,26 +2835,26 @@ discard block |
||
2835 | 2835 | * @return parity array |
2836 | 2836 | */ |
2837 | 2837 | protected function encode_rs_char($rs, $data, $parity) { |
2838 | - $MM =& $rs['mm']; // bits per symbol |
|
2839 | - $NN =& $rs['nn']; // the total number of symbols in a RS block |
|
2840 | - $ALPHA_TO =& $rs['alpha_to']; // the address of an array of NN elements to convert Galois field elements in index (log) form to polynomial form |
|
2841 | - $INDEX_OF =& $rs['index_of']; // the address of an array of NN elements to convert Galois field elements in polynomial form to index (log) form |
|
2842 | - $GENPOLY =& $rs['genpoly']; // an array of NROOTS+1 elements containing the generator polynomial in index form |
|
2843 | - $NROOTS =& $rs['nroots']; // the number of roots in the RS code generator polynomial, which is the same as the number of parity symbols in a block |
|
2844 | - $FCR =& $rs['fcr']; // first consecutive root, index form |
|
2845 | - $PRIM =& $rs['prim']; // primitive element, index form |
|
2846 | - $IPRIM =& $rs['iprim']; // prim-th root of 1, index form |
|
2847 | - $PAD =& $rs['pad']; // the number of pad symbols in a block |
|
2848 | - $A0 =& $NN; |
|
2838 | + $MM = & $rs['mm']; // bits per symbol |
|
2839 | + $NN = & $rs['nn']; // the total number of symbols in a RS block |
|
2840 | + $ALPHA_TO = & $rs['alpha_to']; // the address of an array of NN elements to convert Galois field elements in index (log) form to polynomial form |
|
2841 | + $INDEX_OF = & $rs['index_of']; // the address of an array of NN elements to convert Galois field elements in polynomial form to index (log) form |
|
2842 | + $GENPOLY = & $rs['genpoly']; // an array of NROOTS+1 elements containing the generator polynomial in index form |
|
2843 | + $NROOTS = & $rs['nroots']; // the number of roots in the RS code generator polynomial, which is the same as the number of parity symbols in a block |
|
2844 | + $FCR = & $rs['fcr']; // first consecutive root, index form |
|
2845 | + $PRIM = & $rs['prim']; // primitive element, index form |
|
2846 | + $IPRIM = & $rs['iprim']; // prim-th root of 1, index form |
|
2847 | + $PAD = & $rs['pad']; // the number of pad symbols in a block |
|
2848 | + $A0 = & $NN; |
|
2849 | 2849 | $parity = array_fill(0, $NROOTS, 0); |
2850 | - for ($i=0; $i < ($NN - $NROOTS - $PAD); $i++) { |
|
2850 | + for ($i = 0; $i < ($NN - $NROOTS - $PAD); $i++) { |
|
2851 | 2851 | $feedback = $INDEX_OF[$data[$i] ^ $parity[0]]; |
2852 | 2852 | if ($feedback != $A0) { |
2853 | 2853 | // feedback term is non-zero |
2854 | 2854 | // This line is unnecessary when GENPOLY[NROOTS] is unity, as it must |
2855 | 2855 | // always be for the polynomials constructed by init_rs() |
2856 | 2856 | $feedback = $this->modnn($rs, $NN - $GENPOLY[$NROOTS] + $feedback); |
2857 | - for ($j=1; $j < $NROOTS; ++$j) { |
|
2857 | + for ($j = 1; $j < $NROOTS; ++$j) { |
|
2858 | 2858 | $parity[$j] ^= $ALPHA_TO[$this->modnn($rs, $feedback + $GENPOLY[($NROOTS - $j)])]; |
2859 | 2859 | } |
2860 | 2860 | } |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | $new_feed_id = $row['id']; |
238 | 238 | } else { |
239 | 239 | $row = $this->pdo->query("SELECT MAX(id) AS id FROM ttrss_archived_feeds")->fetch(); |
240 | - $new_feed_id = (int)$row['id'] + 1; |
|
240 | + $new_feed_id = (int) $row['id'] + 1; |
|
241 | 241 | |
242 | 242 | $sth = $this->pdo->prepare("INSERT INTO ttrss_archived_feeds |
243 | 243 | (id, owner_uid, title, feed_url, site_url, created) |
@@ -287,7 +287,7 @@ discard block |
||
287 | 287 | /* GET["cmode"] = 0 - mark as read, 1 - as unread, 2 - toggle */ |
288 | 288 | public function catchupSelected() { |
289 | 289 | $ids = explode(",", clean($_REQUEST["ids"])); |
290 | - $cmode = (int)clean($_REQUEST["cmode"]); |
|
290 | + $cmode = (int) clean($_REQUEST["cmode"]); |
|
291 | 291 | |
292 | 292 | Article::catchupArticlesById($ids, $cmode); |
293 | 293 | |
@@ -296,7 +296,7 @@ discard block |
||
296 | 296 | |
297 | 297 | public function markSelected() { |
298 | 298 | $ids = explode(",", clean($_REQUEST["ids"])); |
299 | - $cmode = (int)clean($_REQUEST["cmode"]); |
|
299 | + $cmode = (int) clean($_REQUEST["cmode"]); |
|
300 | 300 | |
301 | 301 | $this->markArticlesById($ids, $cmode); |
302 | 302 | |
@@ -305,7 +305,7 @@ discard block |
||
305 | 305 | |
306 | 306 | public function publishSelected() { |
307 | 307 | $ids = explode(",", clean($_REQUEST["ids"])); |
308 | - $cmode = (int)clean($_REQUEST["cmode"]); |
|
308 | + $cmode = (int) clean($_REQUEST["cmode"]); |
|
309 | 309 | |
310 | 310 | $this->publishArticlesById($ids, $cmode); |
311 | 311 | |
@@ -342,7 +342,7 @@ discard block |
||
342 | 342 | |
343 | 343 | print "<ul>"; |
344 | 344 | while ($line = $sth->fetch()) { |
345 | - print "<li>" . $line["caption"] . "</li>"; |
|
345 | + print "<li>".$line["caption"]."</li>"; |
|
346 | 346 | } |
347 | 347 | print "</ul>"; |
348 | 348 | } |
@@ -578,7 +578,7 @@ discard block |
||
578 | 578 | |
579 | 579 | if ($msg) { |
580 | 580 | Logger::get()->log_error(E_USER_WARNING, |
581 | - $msg, 'client-js:' . $file, $line, $context); |
|
581 | + $msg, 'client-js:'.$file, $line, $context); |
|
582 | 582 | |
583 | 583 | echo json_encode(array("message" => "HOST_ERROR_LOGGED")); |
584 | 584 | } else { |
@@ -602,7 +602,7 @@ discard block |
||
602 | 602 | $content = json_decode($content, true); |
603 | 603 | |
604 | 604 | if ($content && isset($content["changeset"])) { |
605 | - if ($git_timestamp < (int)$content["changeset"]["timestamp"] && |
|
605 | + if ($git_timestamp < (int) $content["changeset"]["timestamp"] && |
|
606 | 606 | $git_commit != $content["changeset"]["id"]) { |
607 | 607 | |
608 | 608 | $rv = $content["changeset"]; |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | public static function create_published_article($title, $url, $content, $labels_str, |
31 | 31 | $owner_uid) { |
32 | 32 | |
33 | - $guid = 'SHA1:' . sha1("ttshared:" . $url . $owner_uid); // include owner_uid to prevent global GUID clash |
|
33 | + $guid = 'SHA1:'.sha1("ttshared:".$url.$owner_uid); // include owner_uid to prevent global GUID clash |
|
34 | 34 | |
35 | 35 | if (!$content) { |
36 | 36 | $pluginhost = new PluginHost(); |
@@ -85,12 +85,12 @@ discard block |
||
85 | 85 | content = ?, content_hash = ? WHERE id = ?"); |
86 | 86 | $sth->execute([$content, $content_hash, $ref_id]); |
87 | 87 | |
88 | - if (DB_TYPE == "pgsql"){ |
|
88 | + if (DB_TYPE == "pgsql") { |
|
89 | 89 | $sth = $pdo->prepare("UPDATE ttrss_entries |
90 | 90 | SET tsvector_combined = to_tsvector( :ts_content) |
91 | 91 | WHERE id = :id"); |
92 | 92 | $params = [ |
93 | - ":ts_content" => mb_substr(strip_tags($content ), 0, 900000), |
|
93 | + ":ts_content" => mb_substr(strip_tags($content), 0, 900000), |
|
94 | 94 | ":id" => $ref_id]; |
95 | 95 | $sth->execute($params); |
96 | 96 | } |
@@ -130,12 +130,12 @@ discard block |
||
130 | 130 | |
131 | 131 | if ($row = $sth->fetch()) { |
132 | 132 | $ref_id = $row["id"]; |
133 | - if (DB_TYPE == "pgsql"){ |
|
133 | + if (DB_TYPE == "pgsql") { |
|
134 | 134 | $sth = $pdo->prepare("UPDATE ttrss_entries |
135 | 135 | SET tsvector_combined = to_tsvector( :ts_content) |
136 | 136 | WHERE id = :id"); |
137 | 137 | $params = [ |
138 | - ":ts_content" => mb_substr(strip_tags($content ), 0, 900000), |
|
138 | + ":ts_content" => mb_substr(strip_tags($content), 0, 900000), |
|
139 | 139 | ":id" => $ref_id]; |
140 | 140 | $sth->execute($params); |
141 | 141 | } |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | print_hidden("op", "article"); |
174 | 174 | print_hidden("method", "setArticleTags"); |
175 | 175 | |
176 | - print "<header class='horizontal'>" . __("Tags for this article (separated by commas):")."</header>"; |
|
176 | + print "<header class='horizontal'>".__("Tags for this article (separated by commas):")."</header>"; |
|
177 | 177 | |
178 | 178 | print "<section>"; |
179 | 179 | print "<textarea dojoType='dijit.form.SimpleTextarea' rows='4' |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | |
195 | 195 | public function setScore() { |
196 | 196 | $ids = explode(",", clean($_REQUEST['id'])); |
197 | - $score = (int)clean($_REQUEST['score']); |
|
197 | + $score = (int) clean($_REQUEST['score']); |
|
198 | 198 | |
199 | 199 | $ids_qmarks = arr_qmarks($ids); |
200 | 200 | |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | |
204 | 204 | $sth->execute(array_merge([$score], $ids, [$_SESSION['uid']])); |
205 | 205 | |
206 | - print json_encode(["id" => $ids, "score" => (int)$score]); |
|
206 | + print json_encode(["id" => $ids, "score" => (int) $score]); |
|
207 | 207 | } |
208 | 208 | |
209 | 209 | public function getScore() { |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | |
216 | 216 | $score = $row['score']; |
217 | 217 | |
218 | - print json_encode(["id" => $id, "score" => (int)$score]); |
|
218 | + print json_encode(["id" => $id, "score" => (int) $score]); |
|
219 | 219 | } |
220 | 220 | |
221 | 221 | |
@@ -293,7 +293,7 @@ discard block |
||
293 | 293 | |
294 | 294 | print "<ul>"; |
295 | 295 | while ($line = $sth->fetch()) { |
296 | - print "<li>" . $line["tag_name"] . "</li>"; |
|
296 | + print "<li>".$line["tag_name"]."</li>"; |
|
297 | 297 | } |
298 | 298 | print "</ul>"; |
299 | 299 | } |
@@ -432,21 +432,21 @@ discard block |
||
432 | 432 | if (!$hide_images) { |
433 | 433 | $encsize = ''; |
434 | 434 | if ($entry['height'] > 0) |
435 | - $encsize .= ' height="' . intval($entry['height']) . '"'; |
|
435 | + $encsize .= ' height="'.intval($entry['height']).'"'; |
|
436 | 436 | if ($entry['width'] > 0) |
437 | - $encsize .= ' width="' . intval($entry['width']) . '"'; |
|
437 | + $encsize .= ' width="'.intval($entry['width']).'"'; |
|
438 | 438 | $rv .= "<p><img |
439 | 439 | alt=\"".htmlspecialchars($entry["filename"])."\" |
440 | - src=\"" .htmlspecialchars($entry["url"]) . "\" |
|
441 | - " . $encsize . " /></p>"; |
|
440 | + src=\"" .htmlspecialchars($entry["url"])."\" |
|
441 | + " . $encsize." /></p>"; |
|
442 | 442 | } else { |
443 | 443 | $rv .= "<p><a target=\"_blank\" rel=\"noopener noreferrer\" |
444 | 444 | href=\"".htmlspecialchars($entry["url"])."\" |
445 | - >" .htmlspecialchars($entry["url"]) . "</a></p>"; |
|
445 | + >" .htmlspecialchars($entry["url"])."</a></p>"; |
|
446 | 446 | } |
447 | 447 | |
448 | 448 | if ($entry['title']) { |
449 | - $rv.= "<div class=\"enclosure_title\">${entry['title']}</div>"; |
|
449 | + $rv .= "<div class=\"enclosure_title\">${entry['title']}</div>"; |
|
450 | 450 | } |
451 | 451 | } |
452 | 452 | } |
@@ -461,13 +461,13 @@ discard block |
||
461 | 461 | } |
462 | 462 | |
463 | 463 | $rv .= "<div class=\"attachments\" dojoType=\"fox.form.DropDownButton\">". |
464 | - "<span>" . __('Attachments')."</span>"; |
|
464 | + "<span>".__('Attachments')."</span>"; |
|
465 | 465 | |
466 | 466 | $rv .= "<div dojoType=\"dijit.Menu\" style=\"display: none;\">"; |
467 | 467 | |
468 | 468 | foreach ($entries as $entry) { |
469 | 469 | if ($entry["title"]) |
470 | - $title = " — " . truncate_string($entry["title"], 30); |
|
470 | + $title = " — ".truncate_string($entry["title"], 30); |
|
471 | 471 | else |
472 | 472 | $title = ""; |
473 | 473 | |
@@ -477,7 +477,7 @@ discard block |
||
477 | 477 | $filename = ""; |
478 | 478 | |
479 | 479 | $rv .= "<div onclick='popupOpenUrl(\"".htmlspecialchars($entry["url"])."\")' |
480 | - dojoType=\"dijit.MenuItem\">".$filename . $title."</div>"; |
|
480 | + dojoType=\"dijit.MenuItem\">".$filename.$title."</div>"; |
|
481 | 481 | |
482 | 482 | }; |
483 | 483 | |
@@ -546,10 +546,10 @@ discard block |
||
546 | 546 | $tags_str = ""; |
547 | 547 | |
548 | 548 | for ($i = 0; $i < $maxtags; $i++) { |
549 | - $tags_str .= "<a class=\"tag\" href=\"#\" onclick=\"Feeds.open({feed:'".$tags[$i]."'})\">" . $tags[$i] . "</a>, "; |
|
549 | + $tags_str .= "<a class=\"tag\" href=\"#\" onclick=\"Feeds.open({feed:'".$tags[$i]."'})\">".$tags[$i]."</a>, "; |
|
550 | 550 | } |
551 | 551 | |
552 | - $tags_str = mb_substr($tags_str, 0, mb_strlen($tags_str)-2); |
|
552 | + $tags_str = mb_substr($tags_str, 0, mb_strlen($tags_str) - 2); |
|
553 | 553 | |
554 | 554 | if (count($tags) > $maxtags) |
555 | 555 | $tags_str .= ", …"; |
@@ -741,7 +741,7 @@ discard block |
||
741 | 741 | if (!$article_image && !$article_stream) { |
742 | 742 | $tmpdoc = new DOMDocument(); |
743 | 743 | |
744 | - if (@$tmpdoc->loadHTML('<?xml encoding="UTF-8">' . mb_substr($content, 0, 131070))) { |
|
744 | + if (@$tmpdoc->loadHTML('<?xml encoding="UTF-8">'.mb_substr($content, 0, 131070))) { |
|
745 | 745 | $tmpxpath = new DOMXPath($tmpdoc); |
746 | 746 | $elems = $tmpxpath->query('(//img[@src]|//video[@poster]|//iframe[contains(@src , "youtube.com/embed/")])'); |
747 | 747 | |
@@ -749,8 +749,8 @@ discard block |
||
749 | 749 | if ($e->nodeName == "iframe") { |
750 | 750 | $matches = []; |
751 | 751 | if (preg_match("/\/embed\/([\w-]+)/", $e->getAttribute("src"), $matches)) { |
752 | - $article_image = "https://img.youtube.com/vi/" . $matches[1] . "/hqdefault.jpg"; |
|
753 | - $article_stream = "https://youtu.be/" . $matches[1]; |
|
752 | + $article_image = "https://img.youtube.com/vi/".$matches[1]."/hqdefault.jpg"; |
|
753 | + $article_stream = "https://youtu.be/".$matches[1]; |
|
754 | 754 | break; |
755 | 755 | } |
756 | 756 | } else if ($e->nodeName == "video") { |