Test Failed
Push — master ( c8eeb1...8dcff2 )
by Fran
03:30
created
src/base/Security.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -122,12 +122,12 @@  discard block
 block discarded – undo
122 122
     {
123 123
         $saved = true;
124 124
         try {
125
-            $admins = Cache::getInstance()->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json', Cache::JSONGZ, true) ?: [];
126
-            $admins[$user['username']]['hash'] = sha1($user['username'] . $user['password']);
125
+            $admins = Cache::getInstance()->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR.'admins.json', Cache::JSONGZ, true) ?: [];
126
+            $admins[$user['username']]['hash'] = sha1($user['username'].$user['password']);
127 127
             $admins[$user['username']]['profile'] = $user['profile'];
128 128
 
129
-            Cache::getInstance()->storeData(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json', $admins, Cache::JSONGZ, true);
130
-        } catch(\Exception $e) {
129
+            Cache::getInstance()->storeData(CONFIG_DIR.DIRECTORY_SEPARATOR.'admins.json', $admins, Cache::JSONGZ, true);
130
+        }catch (\Exception $e) {
131 131
             Logger::log($e->getMessage(), LOG_ERR);
132 132
             $saved = false;
133 133
         }
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
      */
165 165
     public function getAdmins()
166 166
     {
167
-        return Cache::getInstance()->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json', Cache::JSONGZ, true);
167
+        return Cache::getInstance()->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR.'admins.json', Cache::JSONGZ, true);
168 168
     }
169 169
 
170 170
     /**
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
                 }
192 192
                 if (!empty($user) && !empty($admins[$user])) {
193 193
                     $auth = $admins[$user]['hash'];
194
-                    $this->authorized = ($auth == sha1($user . $pass));
194
+                    $this->authorized = ($auth == sha1($user.$pass));
195 195
                     if ($this->authorized) {
196 196
                         $this->admin = array(
197 197
                             'alias' => $user,
Please login to merge, or discard this patch.
src/base/types/helpers/SecurityHelper.php 1 patch
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
         if (!Config::getInstance()->checkTryToSaveConfig()
30 30
             && (preg_match('/^\/(admin|setup\-admin)/i', $route) || NULL !== Config::getInstance()->get('restricted'))
31 31
         ) {
32
-            if (null === Cache::getInstance()->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json', Cache::JSONGZ, true)) {
32
+            if (null === Cache::getInstance()->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR.'admins.json', Cache::JSONGZ, true)) {
33 33
                 throw new AdminCredentialsException();
34 34
             }
35 35
             if (!Security::getInstance()->checkAdmin()) {
@@ -49,8 +49,8 @@  discard block
 block discarded – undo
49 49
         $token = '';
50 50
         $ct = strlen($ts);
51 51
         for ($i = 0; $i < $ct; $i++) {
52
-            $token = substr($hash, $i, 1) .
53
-                    substr($ts, $i, 1) .
52
+            $token = substr($hash, $i, 1).
53
+                    substr($ts, $i, 1).
54 54
                     $token;
55 55
         }
56 56
         return $token;
@@ -68,16 +68,16 @@  discard block
 block discarded – undo
68 68
         $charsLength = strlen(self::RAND_SEP) - 1;
69 69
         $tsLength = strlen($ts);
70 70
         $i = 0;
71
-        $ct = ceil($hashRest / 4);
72
-        $part = substr($hash, $tsLength + $ct * $i, $ct);
73
-        while(false !== $part) {
74
-            $mixedToken .= $part .
75
-                substr(self::RAND_SEP, round(rand(0, $charsLength), 0, PHP_ROUND_HALF_DOWN), 1) .
71
+        $ct = ceil($hashRest/4);
72
+        $part = substr($hash, $tsLength + $ct*$i, $ct);
73
+        while (false !== $part) {
74
+            $mixedToken .= $part.
75
+                substr(self::RAND_SEP, round(rand(0, $charsLength), 0, PHP_ROUND_HALF_DOWN), 1).
76 76
                 substr(self::RAND_SEP, round(rand(0, $charsLength), 0, PHP_ROUND_HALF_DOWN), 1);
77
-            $part = substr($hash, $tsLength + $ct * $i, $ct);
77
+            $part = substr($hash, $tsLength + $ct*$i, $ct);
78 78
             $i++;
79 79
         }
80
-        return $mixedToken . $token;
80
+        return $mixedToken.$token;
81 81
     }
82 82
 
83 83
     /**
@@ -86,10 +86,10 @@  discard block
 block discarded – undo
86 86
      */
87 87
     private static function getTs($isOdd = null) {
88 88
         $ts = time();
89
-        $tsIsOdd = (bool)((int)substr($ts, -1) % 2);
90
-        if(false === $isOdd && !$tsIsOdd) {
89
+        $tsIsOdd = (bool)((int)substr($ts, -1)%2);
90
+        if (false === $isOdd && !$tsIsOdd) {
91 91
             $ts--;
92
-        } elseif(true === $isOdd && !$tsIsOdd) {
92
+        } elseif (true === $isOdd && !$tsIsOdd) {
93 93
             $ts--;
94 94
         }
95 95
         return $ts;
@@ -121,10 +121,10 @@  discard block
 block discarded – undo
121 121
         $partToken = '';
122 122
         $ts = '';
123 123
         $part = strrev($part);
124
-        for($i = 0, $ct = strlen($part); $i < $ct; $i++) {
125
-            if($i % 2 == 0) {
124
+        for ($i = 0, $ct = strlen($part); $i < $ct; $i++) {
125
+            if ($i%2 == 0) {
126 126
                 $ts .= substr($part, $i, 1);
127
-            } else {
127
+            }else {
128 128
                 $partToken .= substr($part, $i, 1);
129 129
             }
130 130
         }
@@ -139,11 +139,11 @@  discard block
 block discarded – undo
139 139
     private static function parseTokenParts(array $parts) {
140 140
         $token = '';
141 141
         list($partToken, $ts) = self::extractTs(array_pop($parts));
142
-        if($ts > 0) {
143
-            foreach($parts as $part) {
142
+        if ($ts > 0) {
143
+            foreach ($parts as $part) {
144 144
                 $token .= $part;
145 145
             }
146
-            $token = $partToken . $token;
146
+            $token = $partToken.$token;
147 147
         }
148 148
         return [$token, $ts];
149 149
     }
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
      * @return array
172 172
      */
173 173
     private static function extractTokenParts($token) {
174
-        for($i = 0, $ct = strlen(self::RAND_SEP); $i < $ct; $i++) {
174
+        for ($i = 0, $ct = strlen(self::RAND_SEP); $i < $ct; $i++) {
175 175
             $token = str_replace(self::RAND_SEP[$i], "|", $token);
176 176
         }
177 177
         return array_unique(explode('||', $token));
Please login to merge, or discard this patch.
src/Dispatcher.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 use PSFS\controller\ConfigController;
19 19
 use PSFS\controller\UserController;
20 20
 
21
-require_once __DIR__ . DIRECTORY_SEPARATOR . "bootstrap.php";
21
+require_once __DIR__.DIRECTORY_SEPARATOR."bootstrap.php";
22 22
 
23 23
 /**
24 24
  * Class Dispatcher
@@ -79,13 +79,13 @@  discard block
 block discarded – undo
79 79
     private function setLocale()
80 80
     {
81 81
         $this->locale = $this->config->get("default_language");
82
-        Logger::log('Set locale to project [' . $this->locale . ']');
82
+        Logger::log('Set locale to project ['.$this->locale.']');
83 83
         // Load translations
84
-        putenv("LC_ALL=" . $this->locale);
84
+        putenv("LC_ALL=".$this->locale);
85 85
         setlocale(LC_ALL, $this->locale);
86 86
         // Load the locale path
87
-        $locale_path = BASE_DIR . DIRECTORY_SEPARATOR . 'locale';
88
-        Logger::log('Set locale dir ' . $locale_path);
87
+        $locale_path = BASE_DIR.DIRECTORY_SEPARATOR.'locale';
88
+        Logger::log('Set locale dir '.$locale_path);
89 89
         GeneratorHelper::createDir($locale_path);
90 90
         bindtextdomain('translations', $locale_path);
91 91
         textdomain('translations');
@@ -106,20 +106,20 @@  discard block
 block discarded – undo
106 106
                 if (!$this->parser->isFile()) {
107 107
                     return $this->router->execute($this->actualUri);
108 108
                 }
109
-            } else {
109
+            }else {
110 110
                 return ConfigController::getInstance()->config();
111 111
             }
112
-        } catch (AdminCredentialsException $a) {
112
+        }catch (AdminCredentialsException $a) {
113 113
             return UserController::showAdminManager();
114
-        } catch (ConfigException $c) {
114
+        }catch (ConfigException $c) {
115 115
             return $this->dumpException($c);
116
-        } catch (SecurityException $s) {
116
+        }catch (SecurityException $s) {
117 117
             return $this->security->notAuthorized($this->actualUri);
118
-        } catch (UserAuthException $u) {
118
+        }catch (UserAuthException $u) {
119 119
             $this->redirectToHome();
120
-        } catch (RouterException $r) {
120
+        }catch (RouterException $r) {
121 121
             return $this->router->httpNotFound($r);
122
-        } catch (\Exception $e) {
122
+        }catch (\Exception $e) {
123 123
             return $this->dumpException($e);
124 124
         }
125 125
     }
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
                 $use /= 1024;
167 167
                 break;
168 168
             case "MBytes":
169
-                $use /= (1024 * 1024);
169
+                $use /= (1024*1024);
170 170
                 break;
171 171
             case "Bytes":
172 172
             default:
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
         if ($this->config->getDebugMode() && $this->config->get('errors.strict', false)) {
193 193
             Logger::log('Added handlers for errors');
194 194
             //Warning & Notice handler
195
-            set_error_handler(function ($errno, $errstr, $errfile, $errline) {
195
+            set_error_handler(function($errno, $errstr, $errfile, $errline) {
196 196
                 Logger::log($errstr, LOG_CRIT, ['file' => $errfile, 'line' => $errline]);
197 197
                 throw new \Exception($errstr, 500);
198 198
             });
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
         Logger::log('Initializing stats (mem + ts)');
208 208
         if (null !== $_SERVER && array_key_exists('REQUEST_TIME_FLOAT', $_SERVER)) {
209 209
             $this->ts = (float)$_SERVER['REQUEST_TIME_FLOAT'];
210
-        } else {
210
+        }else {
211 211
             $this->ts = $this->parser->getTs();
212 212
         }
213 213
         $this->mem = memory_get_usage();
Please login to merge, or discard this patch.