@@ -13,6 +13,7 @@ |
||
13 | 13 | * Returns a hash of the given filename. |
14 | 14 | * |
15 | 15 | * Ignores file line endings |
16 | + * @param string $filename |
|
16 | 17 | */ |
17 | 18 | public function hash($filename) { |
18 | 19 | if (file_exists($filename)) { |
@@ -43,7 +43,7 @@ |
||
43 | 43 | * @return string|false |
44 | 44 | */ |
45 | 45 | public function getCache($filename) { |
46 | - $cache = false;//cache_get($this->getCacheKey($filename), HACKED_CACHE_TABLE); |
|
46 | + $cache = false; //cache_get($this->getCacheKey($filename), HACKED_CACHE_TABLE); |
|
47 | 47 | |
48 | 48 | if (!empty($cache->data)) { |
49 | 49 | return $cache->data; |
@@ -18,8 +18,7 @@ |
||
18 | 18 | if (file_exists($filename)) { |
19 | 19 | if ($hash = $this->getCache($filename)) { |
20 | 20 | return $hash; |
21 | - } |
|
22 | - else { |
|
21 | + } else { |
|
23 | 22 | $hash = $this->performHash($filename); |
24 | 23 | $this->setCache($filename, $hash); |
25 | 24 |
@@ -67,7 +67,7 @@ |
||
67 | 67 | * |
68 | 68 | * If the file has already been downloaded, returns the the local path. |
69 | 69 | * |
70 | - * @param $url |
|
70 | + * @param string $url |
|
71 | 71 | * The URL of the file on the server. |
72 | 72 | * |
73 | 73 | * @return string |
@@ -53,8 +53,7 @@ |
||
53 | 53 | |
54 | 54 | try { |
55 | 55 | $this->extractArchive($local_file, $dir); |
56 | - } |
|
57 | - catch (\Exception $e) { |
|
56 | + } catch (\Exception $e) { |
|
58 | 57 | echo $e->getMessage() . "\n"; |
59 | 58 | return FALSE; |
60 | 59 | } |
@@ -174,8 +174,12 @@ discard block |
||
174 | 174 | */ |
175 | 175 | public static function isBinary($file) { |
176 | 176 | if (file_exists($file)) { |
177 | - if (!is_file($file)) return 0; |
|
178 | - if (!is_readable($file)) return 1; |
|
177 | + if (!is_file($file)) { |
|
178 | + return 0; |
|
179 | + } |
|
180 | + if (!is_readable($file)) { |
|
181 | + return 1; |
|
182 | + } |
|
179 | 183 | |
180 | 184 | $fh = fopen($file, "r"); |
181 | 185 | $blk = fread($fh, 512); |
@@ -213,8 +217,7 @@ discard block |
||
213 | 217 | if (is_dir($dir . DIRECTORY_SEPARATOR . $file) && $recurse) { |
214 | 218 | // Give priority to files in this folder by merging them in after any subdirectory files. |
215 | 219 | $files = array_merge(self::scanDirectory($dir . DIRECTORY_SEPARATOR . $file, $mask, $nomask, $callback, $recurse, $key, $min_depth, $depth + 1), $files); |
216 | - } |
|
217 | - elseif ($depth >= $min_depth && preg_match($mask, $file)) { |
|
220 | + } elseif ($depth >= $min_depth && preg_match($mask, $file)) { |
|
218 | 221 | // Always use this match over anything already set in $files with the same $$key. |
219 | 222 | $filename = $dir . DIRECTORY_SEPARATOR . $file; |
220 | 223 | $basename = basename($file); |
@@ -91,8 +91,7 @@ |
||
91 | 91 | protected function removeDir($path) { |
92 | 92 | if (is_file($path) || is_link($path)) { |
93 | 93 | @unlink($path); |
94 | - } |
|
95 | - elseif (is_dir($path)) { |
|
94 | + } elseif (is_dir($path)) { |
|
96 | 95 | $d = dir($path); |
97 | 96 | |
98 | 97 | while (($entry = $d->read()) !== FALSE) { |
@@ -211,14 +211,11 @@ discard block |
||
211 | 211 | foreach ($this->remote_files->getFiles() as $file) { |
212 | 212 | if ($this->remote_files->getFileHash($file) == $this->local_files->getFileHash($file)) { |
213 | 213 | $results['same'][] = $file; |
214 | - } |
|
215 | - elseif (!$this->local_files->fileExists($file)) { |
|
214 | + } elseif (!$this->local_files->fileExists($file)) { |
|
216 | 215 | $results['missing'][] = $file; |
217 | - } |
|
218 | - elseif (!$this->local_files->isReadable($file)) { |
|
216 | + } elseif (!$this->local_files->isReadable($file)) { |
|
219 | 217 | $results['access_denied'][] = $file; |
220 | - } |
|
221 | - else { |
|
218 | + } else { |
|
222 | 219 | $results['different'][] = $file; |
223 | 220 | } |
224 | 221 | } |
@@ -265,14 +262,11 @@ discard block |
||
265 | 262 | |
266 | 263 | if ($report['counts']['access_denied'] > 0) { |
267 | 264 | $report['status'] = self::STATUS_PERMISSION_DENIED; |
268 | - } |
|
269 | - elseif ($report['counts']['missing'] > 0) { |
|
265 | + } elseif ($report['counts']['missing'] > 0) { |
|
270 | 266 | $report['status'] = self::STATUS_HACKED; |
271 | - } |
|
272 | - elseif ($report['counts']['different'] > 0) { |
|
267 | + } elseif ($report['counts']['different'] > 0) { |
|
273 | 268 | $report['status'] = self::STATUS_HACKED; |
274 | - } |
|
275 | - elseif ($report['counts']['same'] > 0) { |
|
269 | + } elseif ($report['counts']['same'] > 0) { |
|
276 | 270 | $report['status'] = self::STATUS_UNHACKED; |
277 | 271 | } |
278 | 272 |
@@ -11,8 +11,7 @@ |
||
11 | 11 | if (!HackedFileGroup::isBinary($filename)) { |
12 | 12 | $file = file($filename, FILE_IGNORE_NEW_LINES); |
13 | 13 | return sha1(serialize($file)); |
14 | - } |
|
15 | - else { |
|
14 | + } else { |
|
16 | 15 | return sha1_file($filename); |
17 | 16 | } |
18 | 17 | } |