Passed
Push — master ( dd1a63...86ad47 )
by IRFA
06:29 queued 02:48
created
src/Func/Core.php 1 patch
Spacing   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -26,36 +26,36 @@  discard block
 block discarded – undo
26 26
      * @param string $username
27 27
      * @return void
28 28
      */
29
-    protected function eventFailedLogin($username=null){
29
+    protected function eventFailedLogin($username = null) {
30 30
         
31
-        if($username !== null){
31
+        if ($username !== null) {
32 32
             $this->setPath($username);
33 33
         }
34
-        if(!File::exists($this->dir)){
34
+        if (!File::exists($this->dir)) {
35 35
                 File::makeDirectory($this->dir, 0755, true);
36 36
         }
37 37
 
38
-        if(!File::exists($this->path))
38
+        if (!File::exists($this->path))
39 39
         {
40 40
             $login_fail = 1;
41
-        } else{
41
+        } else {
42 42
 
43 43
             $get = json_decode(File::get($this->path));
44 44
             $ip_list = $get->ip;
45
-            if(!$this->checkIp($ip_list,$this->ip)){
46
-                array_push($ip_list,$this->ip);
45
+            if (!$this->checkIp($ip_list, $this->ip)) {
46
+                array_push($ip_list, $this->ip);
47 47
             }
48
-            if($get->attemps == "lock"){
48
+            if ($get->attemps == "lock") {
49 49
                 $login_fail = "lock";
50
-            } else{
50
+            } else {
51 51
                 $login_fail = $get->attemps+1;
52 52
             }
53 53
         }
54 54
         
55
-            $content = ['username' => $this->input,'attemps' => $login_fail,'ip' => isset($ip_list)?$ip_list:[$this->ip],'last_attemps' => date("Y-m-d H:i:s",time())];
56
-            File::put($this->path,json_encode($content));
57
-            if(File::exists($this->path)){
58
-                chmod($this->path,0755);
55
+            $content = ['username' => $this->input, 'attemps' => $login_fail, 'ip' => isset($ip_list) ? $ip_list : [$this->ip], 'last_attemps' => date("Y-m-d H:i:s", time())];
56
+            File::put($this->path, json_encode($content));
57
+            if (File::exists($this->path)) {
58
+                chmod($this->path, 0755);
59 59
             }
60 60
           
61 61
     }
@@ -90,17 +90,17 @@  discard block
 block discarded – undo
90 90
          * @param  string  $username
91 91
          * @return boolean
92 92
          */
93
-    protected function is_locked($username){
93
+    protected function is_locked($username) {
94 94
         $this->setPath($username);
95
-        if(File::exists($this->path))
95
+        if (File::exists($this->path))
96 96
         {
97 97
             $get = json_decode(File::get($this->path));
98
-            if($get->attemps > $this->attemps || $get->attemps == "lock"){
98
+            if ($get->attemps > $this->attemps || $get->attemps == "lock") {
99 99
                 return true;
100
-            } else{
100
+            } else {
101 101
                 return false;
102 102
             }
103
-        } else{
103
+        } else {
104 104
             return false;
105 105
         }
106 106
     }
@@ -123,19 +123,19 @@  discard block
 block discarded – undo
123 123
      *
124 124
      * @return boolean
125 125
      */
126
-    protected function lockLogin($username = null){
126
+    protected function lockLogin($username = null) {
127 127
         
128
-        if(php_sapi_name() == "cli" AND $username != null){
128
+        if (php_sapi_name() == "cli" AND $username != null) {
129 129
             $this->setPath($username);
130 130
         }
131 131
 
132
-        if(File::exists($this->path))
132
+        if (File::exists($this->path))
133 133
         {
134 134
                 $get = json_decode(File::get($this->path));
135
-                if($get->attemps == "lock"){
135
+                if ($get->attemps == "lock") {
136 136
                 return true;
137 137
                 }
138
-                if($get->attemps > $this->attemps){
138
+                if ($get->attemps > $this->attemps) {
139 139
                     // if($matchip){
140 140
                     // if($this->checkIp($ip_list,$this->ip)){
141 141
                     //     return true;
@@ -159,10 +159,10 @@  discard block
 block discarded – undo
159 159
          *
160 160
          * @return boolean
161 161
          */
162
-    private function checkIp($ip_list,$ip){
163
-        if(collect($ip_list)->contains($ip)){
162
+    private function checkIp($ip_list, $ip) {
163
+        if (collect($ip_list)->contains($ip)) {
164 164
             return true;
165
-        } else{
165
+        } else {
166 166
             return false;
167 167
         }
168 168
 
@@ -173,11 +173,11 @@  discard block
 block discarded – undo
173 173
          *
174 174
          * @return boolean
175 175
          */
176
-    public function clear_all(){
176
+    public function clear_all() {
177 177
         $file = new Filesystem();
178
-        if($file->cleanDirectory($this->path)){
178
+        if ($file->cleanDirectory($this->path)) {
179 179
         return true;
180
-        } else{
180
+        } else {
181 181
         return false;
182 182
         }
183 183
     }
@@ -188,23 +188,23 @@  discard block
 block discarded – undo
188 188
          * @param string $username
189 189
          * @return mixed
190 190
          */
191
-    public function unlock_account($username){
191
+    public function unlock_account($username) {
192 192
         $this->setPath($username);
193
-            if(File::exists($this->path)){
193
+            if (File::exists($this->path)) {
194 194
             $readf = File::get($this->path);
195 195
                 File::delete($this->path);
196
-            if(php_sapi_name() == "cli"){
196
+            if (php_sapi_name() == "cli") {
197 197
                 echo Lang::get('lockoutMessage.user_unlock_success')."\n";
198 198
                 return $readf;
199 199
               
200
-            } else{
200
+            } else {
201 201
                 return true;
202 202
             }
203
-        } else{
204
-            if(php_sapi_name() == "cli"){
203
+        } else {
204
+            if (php_sapi_name() == "cli") {
205 205
                 echo Lang::get('lockoutMessage.user_lock_404')."\n";
206 206
                 return false;
207
-            } else{
207
+            } else {
208 208
                 return false;
209 209
             }
210 210
         }
@@ -215,21 +215,21 @@  discard block
 block discarded – undo
215 215
      *
216 216
      * @return mixed
217 217
      */
218
-    public function test_unlock_account($username){
218
+    public function test_unlock_account($username) {
219 219
         $this->setPath($username);
220
-            if(File::exists($this->path)){
220
+            if (File::exists($this->path)) {
221 221
             $readf = File::get($this->path);
222 222
                 File::delete($this->path);
223
-            if(php_sapi_name() == "cli"){
223
+            if (php_sapi_name() == "cli") {
224 224
                 return true;
225 225
               
226
-            } else{
226
+            } else {
227 227
                 return true;
228 228
             }
229
-        } else{
230
-            if(php_sapi_name() == "cli"){
229
+        } else {
230
+            if (php_sapi_name() == "cli") {
231 231
                 return false;
232
-            } else{
232
+            } else {
233 233
                 return false;
234 234
             }
235 235
         }
@@ -241,22 +241,22 @@  discard block
 block discarded – undo
241 241
      * @param string $username
242 242
      * @return mixed
243 243
      */
244
-    public function check_account($username){
244
+    public function check_account($username) {
245 245
         $this->setPath($username);
246
-        if(File::exists($this->path)){
246
+        if (File::exists($this->path)) {
247 247
                 $readf = File::get($this->path);
248
-                if(php_sapi_name() == "cli"){
248
+                if (php_sapi_name() == "cli") {
249 249
                 
250 250
                     return $readf;
251 251
                 
252
-                } else{
252
+                } else {
253 253
                     return $readf;
254 254
                 }
255
-            } else{
256
-                if(php_sapi_name() == "cli"){
255
+            } else {
256
+                if (php_sapi_name() == "cli") {
257 257
                     echo Lang::get('lockoutMessage.user_lock_404')."\n";
258 258
                     exit();
259
-                } else{
259
+                } else {
260 260
                     return false;
261 261
                 }
262 262
             }
@@ -268,31 +268,31 @@  discard block
 block discarded – undo
268 268
          * @param string $username
269 269
          * @return mixed
270 270
          */
271
-    public function lock_account($username){
272
-        $sapi = php_sapi_name() == "cli"?"lock-via-cli":"lock-via-web";
271
+    public function lock_account($username) {
272
+        $sapi = php_sapi_name() == "cli" ? "lock-via-cli" : "lock-via-web";
273 273
         $this->setPath($username);
274
-        try{
275
-            if(!File::exists($this->dir)){
274
+        try {
275
+            if (!File::exists($this->dir)) {
276 276
                 File::makeDirectory($this->dir, 0755, true);
277 277
             }
278 278
                 $login_fail = "lock";
279 279
         
280
-                $content = ['username' => $this->input,'attemps' => $login_fail,'ip' => [$sapi],'last_attemps' => date("Y-m-d H:i:s",time())];
281
-                File::put($this->path,json_encode($content));
282
-                if(File::exists($this->path)){
283
-                chmod($this->path,0755);
280
+                $content = ['username' => $this->input, 'attemps' => $login_fail, 'ip' => [$sapi], 'last_attemps' => date("Y-m-d H:i:s", time())];
281
+                File::put($this->path, json_encode($content));
282
+                if (File::exists($this->path)) {
283
+                chmod($this->path, 0755);
284 284
                 }
285
-                if(php_sapi_name() == "cli"){
285
+                if (php_sapi_name() == "cli") {
286 286
                 return Lang::get('lockoutMessage.user_lock_success')."\n";
287 287
                 
288
-                } else{
288
+                } else {
289 289
                 return true;
290 290
                 }
291
-            } catch(\Exception $e){
292
-                if(php_sapi_name() == "cli"){
291
+            } catch (\Exception $e) {
292
+                if (php_sapi_name() == "cli") {
293 293
                 return "error";
294 294
                 
295
-                } else{
295
+                } else {
296 296
                 return false;
297 297
                 }
298 298
             }
Please login to merge, or discard this patch.