Passed
Push — master ( f2f9fb...1cd2da )
by Fran
02:56
created
src/base/types/helpers/GeneratorHelper.php 1 patch
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -26,10 +26,10 @@  discard block
 block discarded – undo
26 26
             $objects = scandir($dir);
27 27
             foreach ($objects as $object) {
28 28
                 if ($object != "." && $object != "..") {
29
-                    if (filetype($dir . "/" . $object) == "dir") {
30
-                        self::deleteDir($dir . "/" . $object);
31
-                    } else {
32
-                        unlink($dir . "/" . $object);
29
+                    if (filetype($dir."/".$object) == "dir") {
30
+                        self::deleteDir($dir."/".$object);
31
+                    }else {
32
+                        unlink($dir."/".$object);
33 33
                     }
34 34
                 }
35 35
             }
@@ -44,10 +44,10 @@  discard block
 block discarded – undo
44 44
     {
45 45
         $rootDirs = array("css", "js", "media", "font");
46 46
         foreach ($rootDirs as $dir) {
47
-            if (file_exists(WEB_DIR . DIRECTORY_SEPARATOR . $dir)) {
47
+            if (file_exists(WEB_DIR.DIRECTORY_SEPARATOR.$dir)) {
48 48
                 try {
49
-                    self::deleteDir(WEB_DIR . DIRECTORY_SEPARATOR . $dir);
50
-                } catch (Exception $e) {
49
+                    self::deleteDir(WEB_DIR.DIRECTORY_SEPARATOR.$dir);
50
+                }catch (Exception $e) {
51 51
                     syslog(LOG_INFO, $e->getMessage());
52 52
                 }
53 53
             }
@@ -64,12 +64,12 @@  discard block
 block discarded – undo
64 64
         if (!empty($dir)) {
65 65
             try {
66 66
                 if (!is_dir($dir) && @mkdir($dir, 0775, true) === false) {
67
-                    throw new Exception(t('Can\'t create directory ') . $dir);
67
+                    throw new Exception(t('Can\'t create directory ').$dir);
68 68
                 }
69
-            } catch (Exception $e) {
69
+            }catch (Exception $e) {
70 70
                 syslog(LOG_WARNING, $e->getMessage());
71 71
                 if (!file_exists(dirname($dir))) {
72
-                    throw new GeneratorException($e->getMessage() . $dir);
72
+                    throw new GeneratorException($e->getMessage().$dir);
73 73
                 }
74 74
             }
75 75
         }
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
      */
82 82
     public static function getTemplatePath(): string
83 83
     {
84
-        $path = __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR;
84
+        $path = __DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'templates'.DIRECTORY_SEPARATOR;
85 85
         return realpath($path);
86 86
     }
87 87
 
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
                 } elseif (!$reflector->isAbstract()) {
110 110
                     throw new GeneratorException(t('La clase definida debe ser abstracta'), 501);
111 111
                 }
112
-            } else {
112
+            }else {
113 113
                 throw new GeneratorException(t('La clase definida para extender la API no existe'), 501);
114 114
             }
115 115
         }
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
         GeneratorHelper::createDir($path);
132 132
         $paths = array("js", "css", "img", "media", "font");
133 133
         foreach ($paths as $htmlPath) {
134
-            GeneratorHelper::createDir($path . DIRECTORY_SEPARATOR . $htmlPath);
134
+            GeneratorHelper::createDir($path.DIRECTORY_SEPARATOR.$htmlPath);
135 135
         }
136 136
 
137 137
         // Generates the root needed files
@@ -141,35 +141,35 @@  discard block
 block discarded – undo
141 141
             'crossdomain' => 'crossdomain.xml',
142 142
             'humans' => 'humans.txt',
143 143
             'robots' => 'robots.txt',
144
-            'docker' => '..' . DIRECTORY_SEPARATOR . 'docker-compose.yml',
144
+            'docker' => '..'.DIRECTORY_SEPARATOR.'docker-compose.yml',
145 145
         ];
146 146
         $verificable = ['humans', 'robots', 'docker'];
147 147
         if (!$quiet) {
148 148
             $output->writeln('Start creating html files');
149 149
         }
150 150
         foreach ($files as $template => $filename) {
151
-            if (in_array($template, $verificable) && file_exists($path . DIRECTORY_SEPARATOR . $filename)) {
151
+            if (in_array($template, $verificable) && file_exists($path.DIRECTORY_SEPARATOR.$filename)) {
152 152
                 if (!$quiet) {
153
-                    $output->writeln($filename . ' already exists');
153
+                    $output->writeln($filename.' already exists');
154 154
                 }
155 155
                 continue;
156 156
             }
157
-            $text = Template::getInstance()->dump("generator/html/" . $template . '.html.twig');
158
-            if (false === file_put_contents($path . DIRECTORY_SEPARATOR . $filename, $text)) {
157
+            $text = Template::getInstance()->dump("generator/html/".$template.'.html.twig');
158
+            if (false === file_put_contents($path.DIRECTORY_SEPARATOR.$filename, $text)) {
159 159
                 if (!$quiet) {
160
-                    $output->writeln('Can\t create the file ' . $filename);
160
+                    $output->writeln('Can\t create the file '.$filename);
161 161
                 }
162
-            } else {
162
+            }else {
163 163
                 if (!$quiet) {
164
-                    $output->writeln($filename . ' created successfully');
164
+                    $output->writeln($filename.' created successfully');
165 165
                 }
166 166
             }
167 167
         }
168 168
 
169 169
         //Export base locale translations
170
-        if (!file_exists(BASE_DIR . DIRECTORY_SEPARATOR . 'locale')) {
171
-            GeneratorHelper::createDir(BASE_DIR . DIRECTORY_SEPARATOR . 'locale');
172
-            self::copyr(SOURCE_DIR . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'locale', BASE_DIR . DIRECTORY_SEPARATOR . 'locale');
170
+        if (!file_exists(BASE_DIR.DIRECTORY_SEPARATOR.'locale')) {
171
+            GeneratorHelper::createDir(BASE_DIR.DIRECTORY_SEPARATOR.'locale');
172
+            self::copyr(SOURCE_DIR.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'locale', BASE_DIR.DIRECTORY_SEPARATOR.'locale');
173 173
         }
174 174
     }
175 175
 
@@ -185,12 +185,12 @@  discard block
 block discarded – undo
185 185
     {
186 186
         if (file_exists($filenamePath)) {
187 187
             $destfolder = basename($filenamePath);
188
-            if (!file_exists(WEB_DIR . $dest . DIRECTORY_SEPARATOR . $destfolder) || $debug || $force) {
188
+            if (!file_exists(WEB_DIR.$dest.DIRECTORY_SEPARATOR.$destfolder) || $debug || $force) {
189 189
                 if (is_dir($filenamePath)) {
190
-                    self::copyr($filenamePath, WEB_DIR . $dest . DIRECTORY_SEPARATOR . $destfolder);
191
-                } else {
192
-                    if (@copy($filenamePath, WEB_DIR . $dest . DIRECTORY_SEPARATOR . $destfolder) === FALSE) {
193
-                        throw new ConfigException("Can't copy " . $filenamePath . " to " . WEB_DIR . $dest . DIRECTORY_SEPARATOR . $destfolder);
190
+                    self::copyr($filenamePath, WEB_DIR.$dest.DIRECTORY_SEPARATOR.$destfolder);
191
+                }else {
192
+                    if (@copy($filenamePath, WEB_DIR.$dest.DIRECTORY_SEPARATOR.$destfolder) === FALSE) {
193
+                        throw new ConfigException("Can't copy ".$filenamePath." to ".WEB_DIR.$dest.DIRECTORY_SEPARATOR.$destfolder);
194 194
                     }
195 195
                 }
196 196
             }
@@ -209,10 +209,10 @@  discard block
 block discarded – undo
209 209
         self::createDir($dst);
210 210
         while (false !== ($file = readdir($dir))) {
211 211
             if (($file != '.') && ($file != '..')) {
212
-                if (is_dir($src . '/' . $file)) {
213
-                    self::copyr($src . '/' . $file, $dst . '/' . $file);
214
-                } elseif (@copy($src . '/' . $file, $dst . '/' . $file) === false) {
215
-                    throw new ConfigException("Can't copy " . $src . " to " . $dst);
212
+                if (is_dir($src.'/'.$file)) {
213
+                    self::copyr($src.'/'.$file, $dst.'/'.$file);
214
+                } elseif (@copy($src.'/'.$file, $dst.'/'.$file) === false) {
215
+                    throw new ConfigException("Can't copy ".$src." to ".$dst);
216 216
                 }
217 217
             }
218 218
         }
Please login to merge, or discard this patch.
src/base/types/helpers/AuthHelper.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
         if (NULL === $user || (array_key_exists($user, $admins) && empty($admins[$user]))) {
48 48
             list($user, $pass) = self::getAdminFromCookie();
49 49
         }
50
-        return array_key_exists($user, $admins) ? [$user, sha1($user . $pass)] : [null, null];
50
+        return array_key_exists($user, $admins) ? [$user, sha1($user.$pass)] : [null, null];
51 51
     }
52 52
 
53 53
     public static function checkComplexAuth(array $admins)
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
         return base64_encode($encrypted_data);
87 87
     }
88 88
 
89
-    public static function decrypt(string $encrypted_data, string $key): false|string
89
+    public static function decrypt(string $encrypted_data, string $key): false | string
90 90
     {
91 91
         $encrypted_data = base64_decode($encrypted_data);
92 92
         $data = '';
@@ -104,15 +104,15 @@  discard block
 block discarded – undo
104 104
         $tz = new \DateTimeZone('UTC');
105 105
         $timestamp = new \DateTime('now', $tz);
106 106
         $timestamp->modify(Config::getParam('auth.expiration', '+1 day'));
107
-        $data = $user . Security::LOGGED_USER_TOKEN . $timestamp->format(self::EXPIRATION_TIMESTAMP_FORMAT);
108
-        return self::encrypt($data, sha1($user . $password));
107
+        $data = $user.Security::LOGGED_USER_TOKEN.$timestamp->format(self::EXPIRATION_TIMESTAMP_FORMAT);
108
+        return self::encrypt($data, sha1($user.$password));
109 109
     }
110 110
 
111 111
     public static function decodeToken(string $token, string $password): array
112 112
     {
113 113
         $user = $timestamp = null;
114 114
         $secret = self::decrypt($token, $password);
115
-        if(!empty($secret) && str_contains($secret, Security::LOGGED_USER_TOKEN)) {
115
+        if (!empty($secret) && str_contains($secret, Security::LOGGED_USER_TOKEN)) {
116 116
             list($user, $timestamp) = explode(Security::LOGGED_USER_TOKEN, $secret);
117 117
         }
118 118
         return [$user, $timestamp];
Please login to merge, or discard this patch.
src/base/Security.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
      */
61 61
     public function getAdmins()
62 62
     {
63
-        return Cache::getInstance()->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json', Cache::JSONGZ, true);
63
+        return Cache::getInstance()->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR.'admins.json', Cache::JSONGZ, true);
64 64
     }
65 65
 
66 66
     /**
@@ -77,12 +77,12 @@  discard block
 block discarded – undo
77 77
             $admins = $this->getAdmins();
78 78
             $token = null;
79 79
             if (null !== $admins) {
80
-                if(empty($user)) {
80
+                if (empty($user)) {
81 81
                     // First try, traditional basic auth
82 82
                     Inspector::stats('[Auth] Checking Basic Auth');
83 83
                     list($user, $token) = AuthHelper::checkBasicAuth($user, $pass, $admins);
84 84
                 }
85
-                if(empty($user)) {
85
+                if (empty($user)) {
86 86
                     // Second try, cookie auth
87 87
                     Inspector::stats('[Auth] Checking Basic Auth PSFS');
88 88
                     list($user, $token) = AuthHelper::checkComplexAuth($admins);
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
                         ]);
104 104
                         $this->setSessionKey(AuthHelper::SESSION_TOKEN, $encrypted);
105 105
                     }
106
-                } else {
106
+                }else {
107 107
                     $this->admin = null;
108 108
                     $this->setSessionKey(AuthHelper::SESSION_TOKEN, null);
109 109
                 }
Please login to merge, or discard this patch.