Passed
Push — master ( 880683...7694b2 )
by IRFA
15:22 queued 11:30
created
src/Console/Commands/LockInfoPackage.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
         $this->informasi();
41 41
     }
42 42
 
43
-    private function informasi(){
43
+    private function informasi() {
44 44
             $this->line(" _____      __             _                _               _   
45 45
 |_   _|    / _|           | |              | |             | |  
46 46
   | | _ __| |_ __ _ ______| |     ___   ___| | _____  _   _| |_ 
@@ -55,12 +55,12 @@  discard block
 block discarded – undo
55 55
     $conf = config('irfa.lockout');
56 56
         $this->line('<fg=default>-------------------------------------------------------------------------------');
57 57
         $this->line('<fg=yellow>Configuration');
58
-    foreach($conf as $key => $val){
59
-        if(is_array($val)){
60
-            foreach($val as $v){
58
+    foreach ($conf as $key => $val) {
59
+        if (is_array($val)) {
60
+            foreach ($val as $v) {
61 61
                 $vl .= $v.", ";
62 62
             }
63
-        } else{
63
+        } else {
64 64
                 $vl = $val;
65 65
             }
66 66
 
Please login to merge, or discard this patch.
src/Console/Commands/UnlockCommands.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -41,15 +41,15 @@
 block discarded – undo
41 41
     { 
42 42
         $ret = $core->unlock_account($this->argument('username'));
43 43
             $table = new Table($this->output);
44
-                $read_enc = json_decode( $ret);
44
+                $read_enc = json_decode($ret);
45 45
                 $time = $read_enc->last_attemps;
46 46
                 $attemps = $read_enc->attemps;
47 47
                 $ip = $read_enc->ip;
48 48
                 $table->setRows([
49
-                        ['<fg=cyan>Login attemps',  $attemps],
50
-                        ['<fg=cyan>Last login attemps',$time],
51
-                        ['<fg=cyan>Last IP Address',empty(end($ip))? "unknown":end($ip)],
52
-                        ['<fg=cyan>Unlocked at',date('Y-m-d H:i:s', time())],
49
+                        ['<fg=cyan>Login attemps', $attemps],
50
+                        ['<fg=cyan>Last login attemps', $time],
51
+                        ['<fg=cyan>Last IP Address', empty(end($ip)) ? "unknown" : end($ip)],
52
+                        ['<fg=cyan>Unlocked at', date('Y-m-d H:i:s', time())],
53 53
                     ]);
54 54
                         $table->render();
55 55
                 // $this->line('<fg=yellow>Valid input is  lock, unlock, and attemps.');
Please login to merge, or discard this patch.
src/Console/Commands/AttempsCommands.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -41,14 +41,14 @@
 block discarded – undo
41 41
     { 
42 42
         $ret = $core->check_account($this->argument('username'));
43 43
             $table = new Table($this->output);
44
-                $read_enc = json_decode( $ret);
44
+                $read_enc = json_decode($ret);
45 45
                 $time = $read_enc->last_attemps;
46 46
                 $attemps = $read_enc->attemps;
47 47
                 $ip = $read_enc->ip;
48 48
                 $table->setRows([
49
-                        ['<fg=yellow>Login attemps',  $attemps],
50
-                        ['<fg=yellow>Last login attemps',$time],
51
-                        ['<fg=yellow>Last IP Address',empty(end($ip))? "unknown":end($ip)],]);
49
+                        ['<fg=yellow>Login attemps', $attemps],
50
+                        ['<fg=yellow>Last login attemps', $time],
51
+                        ['<fg=yellow>Last IP Address', empty(end($ip)) ? "unknown" : end($ip)], ]);
52 52
                         $table->render();
53 53
                 // $this->line('<fg=yellow>Valid input is  lock, unlock, and attemps.');
54 54
         
Please login to merge, or discard this patch.
src/Console/Commands/ClearLockCommands.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -40,14 +40,14 @@
 block discarded – undo
40 40
     public function handle(Core $core)
41 41
     {
42 42
         $this->line('Cleaning locked user...');
43
-        if($core->clear_all()){
43
+        if ($core->clear_all()) {
44 44
             $table = new Table($this->output);
45 45
             $table->setRows([
46 46
                         ['<fg=green>Locked Account(s) Cleared.'],
47 47
                        
48 48
                     ]);
49 49
                         $table->render();
50
-        } else{
50
+        } else {
51 51
                 $this->line('<fg=red> Clearing failed.');
52 52
         }
53 53
     }
Please login to merge, or discard this patch.
src/Console/Commands/LockCommands.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -40,14 +40,14 @@
 block discarded – undo
40 40
     public function handle(Core $core)
41 41
     {
42 42
         $this->line('Locking '.$this->argument('username').'...');
43
-        if($core->lock_account($this->argument('username'))!="error"){
43
+        if ($core->lock_account($this->argument('username')) != "error") {
44 44
             $table = new Table($this->output);
45 45
             $table->setRows([
46 46
                         ['<fg=green>'.$this->argument('username').' successfully locked.'],
47 47
                        
48 48
                     ]);
49 49
                         $table->render();
50
-        } else{
50
+        } else {
51 51
                 $this->line('<fg=red> Locking failed.');
52 52
         }
53 53
     }
Please login to merge, or discard this patch.
src/Func/Core.php 1 patch
Spacing   +59 added lines, -59 removed lines patch added patch discarded remove patch
@@ -2,176 +2,176 @@
 block discarded – undo
2 2
 namespace  Irfa\Lockout\Func;
3 3
 
4 4
 use Log;
5
-use Illuminate\Support\Facades\Request,File,Lang;
5
+use Illuminate\Support\Facades\Request, File, Lang;
6 6
 use Illuminate\Filesystem\Filesystem;
7 7
 use Symfony\Component\Console\Helper\Table;
8 8
 
9 9
 class Core
10 10
 {
11
-    protected function eventFailedLogin(){
11
+    protected function eventFailedLogin() {
12 12
         $ip = Request::ip();
13 13
         $input = Request::input(config('irfa.lockout.input_name'));
14
-        $matchip= config('irfa.lockout.match_ip') == true ? $ip :null;
14
+        $matchip = config('irfa.lockout.match_ip') == true ? $ip : null;
15 15
         $dir = config('irfa.lockout.lockout_file_path');
16 16
         $path = $dir.md5($input);
17 17
 
18
-        if(!File::exists($dir)){
18
+        if (!File::exists($dir)) {
19 19
                 File::makeDirectory($dir, 0750, true);
20 20
         }
21 21
 
22
-        if(!File::exists($path))
22
+        if (!File::exists($path))
23 23
         {
24 24
             $login_fail = 1;
25
-        } else{
25
+        } else {
26 26
 
27 27
             $get = json_decode(File::get($path));
28 28
             $ip_list = $get->ip;
29
-            if(!$this->checkIp($ip_list,$ip)){
30
-                array_push($ip_list,$ip);
29
+            if (!$this->checkIp($ip_list, $ip)) {
30
+                array_push($ip_list, $ip);
31 31
             }
32
-            if($get->attemps == "lock"){
32
+            if ($get->attemps == "lock") {
33 33
                 $login_fail = "lock";
34
-            } else{
34
+            } else {
35 35
                 $login_fail = $get->attemps+1;
36 36
             }
37 37
         }
38 38
         
39
-            $content = ['username' => $input,'attemps' => $login_fail,'ip' => isset($ip_list)?$ip_list:[$ip],'last_attemps' => date("Y-m-d H:i:s",time())];
40
-            File::put($path,json_encode($content));
39
+            $content = ['username' => $input, 'attemps' => $login_fail, 'ip' => isset($ip_list) ? $ip_list : [$ip], 'last_attemps' => date("Y-m-d H:i:s", time())];
40
+            File::put($path, json_encode($content));
41 41
           
42 42
     }
43
-        protected function eventCleanLockoutAccount(){
43
+        protected function eventCleanLockoutAccount() {
44 44
         $input = Request::input(config('irfa.lockout.input_name'));
45 45
         $this->unlock_account($input);
46 46
           
47 47
     }
48
-    protected function logging(){
49
-        if(config('irfa.lockout.logging')){
48
+    protected function logging() {
49
+        if (config('irfa.lockout.logging')) {
50 50
                     Log::notice("Login attemps fail | "."username : ".Request::input(config('irfa.lockout.input_name'))." | ipAddress : ".Request::ip()." | userAgent : ".$_SERVER['HTTP_USER_AGENT'].PHP_EOL);
51 51
             }
52 52
     }
53 53
 
54
-    protected function lockLogin(){
54
+    protected function lockLogin() {
55 55
         $ip = Request::ip();
56
-        $matchip= empty(config('irfa.lockout.match_ip'))?false:config('irfa.lockout.match_ip');
56
+        $matchip = empty(config('irfa.lockout.match_ip')) ?false:config('irfa.lockout.match_ip');
57 57
         $dir = config('irfa.lockout.lockout_file_path');
58 58
         $attemps = config('irfa.lockout.login_attemps');
59 59
         $path = $dir.md5(Request::input('email'));
60
-        if(File::exists($path))
60
+        if (File::exists($path))
61 61
         {
62 62
                 $get = json_decode(File::get($path));
63 63
             // dd($get->attemps.">".$attemps);
64
-                if($get->attemps == "lock"){
64
+                if ($get->attemps == "lock") {
65 65
                 return true;
66 66
                 }
67
-                if($get->attemps > $attemps){
68
-                    if($matchip){
69
-                    if($this->checkIp($ip_list,$ip)){
67
+                if ($get->attemps > $attemps) {
68
+                    if ($matchip) {
69
+                    if ($this->checkIp($ip_list, $ip)) {
70 70
                         return true;
71
-                    } else{
71
+                    } else {
72 72
                         return false;
73 73
                     }
74
-                    } else{
74
+                    } else {
75 75
                     return true;
76 76
                     }
77
-                } else{
77
+                } else {
78 78
                 return false;
79 79
                 }
80
-        } else{
80
+        } else {
81 81
             return false;
82 82
             }
83 83
     }
84
-    private function checkIp($ip_list,$ip){
85
-        if(collect($ip_list)->contains($ip)){
84
+    private function checkIp($ip_list, $ip) {
85
+        if (collect($ip_list)->contains($ip)) {
86 86
             return true;
87
-        } else{
87
+        } else {
88 88
             return false;
89 89
         }
90 90
 
91 91
     }
92
-    public function clear_all(){
92
+    public function clear_all() {
93 93
         $file = new Filesystem();
94
-        if($file->cleanDirectory(config('irfa.lockout.lockout_file_path'))){
94
+        if ($file->cleanDirectory(config('irfa.lockout.lockout_file_path'))) {
95 95
         return true;
96
-        } else{
96
+        } else {
97 97
         return false;
98 98
         }
99 99
     }
100
-    public function unlock_account($username){
100
+    public function unlock_account($username) {
101 101
         $ip = Request::ip();
102
-        $matchip= empty(config('irfa.lockout.match_ip'))?false:config('irfa.lockout.match_ip');
102
+        $matchip = empty(config('irfa.lockout.match_ip')) ?false:config('irfa.lockout.match_ip');
103 103
         $dir = config('irfa.lockout.lockout_file_path');
104 104
         $attemps = config('irfa.lockout.attemps');
105 105
         $path = $dir.md5($username);
106 106
 
107
-        if(File::exists($path)){
107
+        if (File::exists($path)) {
108 108
             $readf = File::get($path);
109 109
                 File::delete($path);
110
-            if(php_sapi_name() == "cli"){
110
+            if (php_sapi_name() == "cli") {
111 111
                 echo Lang::get('lockoutMessage.user_unlock_success')."\n";
112 112
                 return $readf;
113 113
               
114
-            } else{
114
+            } else {
115 115
                 return true;
116 116
             }
117
-        } else{
118
-            if(php_sapi_name() == "cli"){
117
+        } else {
118
+            if (php_sapi_name() == "cli") {
119 119
                 echo Lang::get('lockoutMessage.user_lock_404')."\n";
120 120
                 exit();
121
-            } else{
121
+            } else {
122 122
                 return false;
123 123
             }
124 124
         }
125 125
         }
126
-        public function check_account($username){
126
+        public function check_account($username) {
127 127
         $dir = config('irfa.lockout.lockout_file_path');
128 128
         $path = $dir.md5($username);
129 129
 
130
-        if(File::exists($path)){
130
+        if (File::exists($path)) {
131 131
             $readf = File::get($path);
132
-            if(php_sapi_name() == "cli"){
132
+            if (php_sapi_name() == "cli") {
133 133
               
134 134
                 return $readf;
135 135
               
136
-            } else{
136
+            } else {
137 137
                 return $readf;
138 138
             }
139
-        } else{
140
-            if(php_sapi_name() == "cli"){
139
+        } else {
140
+            if (php_sapi_name() == "cli") {
141 141
                 echo Lang::get('lockoutMessage.user_lock_404')."\n";
142 142
                 exit();
143
-            } else{
143
+            } else {
144 144
                 return false;
145 145
             }
146 146
         }
147 147
         }
148 148
 
149
-        public function lock_account($username){
150
-        $ip = php_sapi_name() == "cli"?"lock-via-cli":"lock-via-web";
149
+        public function lock_account($username) {
150
+        $ip = php_sapi_name() == "cli" ? "lock-via-cli" : "lock-via-web";
151 151
         $input = $username;
152
-        $matchip= empty(config('irfa.lockout.match_ip'))?false:config('irfa.lockout.match_ip');
152
+        $matchip = empty(config('irfa.lockout.match_ip')) ?false:config('irfa.lockout.match_ip');
153 153
         $dir = config('irfa.lockout.lockout_file_path');
154 154
         $attemps = config('irfa.lockout.login_attemps');
155 155
         $path = $dir.md5($username);
156
-        try{
157
-            if(!File::exists($dir)){
156
+        try {
157
+            if (!File::exists($dir)) {
158 158
                 File::makeDirectory($dir, 0750, true);
159 159
             }
160 160
                 $login_fail = "lock";
161 161
           
162
-                $content = ['username' => $input,'attemps' => $login_fail,'ip' => isset($ip_list)?$ip_list:[$ip],'last_attemps' => date("Y-m-d H:i:s",time())];
163
-                File::put($path,json_encode($content));
164
-                if(php_sapi_name() == "cli"){
162
+                $content = ['username' => $input, 'attemps' => $login_fail, 'ip' => isset($ip_list) ? $ip_list : [$ip], 'last_attemps' => date("Y-m-d H:i:s", time())];
163
+                File::put($path, json_encode($content));
164
+                if (php_sapi_name() == "cli") {
165 165
                 return Lang::get('lockoutMessage.user_lock_success')."\n";
166 166
                   
167
-                } else{
167
+                } else {
168 168
                 return true;
169 169
                 }
170
-            } catch(Exception $e){
171
-                if(php_sapi_name() == "cli"){
170
+            } catch (Exception $e) {
171
+                if (php_sapi_name() == "cli") {
172 172
                 return "error";
173 173
                   
174
-                } else{
174
+                } else {
175 175
                 return false;
176 176
                 }
177 177
             }
Please login to merge, or discard this patch.
src/Func/Lockout.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -5,53 +5,53 @@
 block discarded – undo
5 5
 
6 6
 class Lockout extends Core {
7 7
 	
8
-    public function unlock($username){
9
-        if(is_array($username)){
10
-            foreach($username as $key){
8
+    public function unlock($username) {
9
+        if (is_array($username)) {
10
+            foreach ($username as $key) {
11 11
                 $this->_unlock($key);
12 12
             }
13
-        } else{
13
+        } else {
14 14
             $this->_unlock($username);
15 15
         }
16 16
         return true;
17 17
     }
18 18
 
19
-    public function lock($username){
20
-        if(is_array($username)){
21
-            foreach($username as $key){
19
+    public function lock($username) {
20
+        if (is_array($username)) {
21
+            foreach ($username as $key) {
22 22
                     $this->_lock($key);
23 23
             }
24
-        } else{
24
+        } else {
25 25
                 $this->_lock($username);
26 26
         }
27 27
         return true;
28 28
     }
29 29
     public function check($username) {	 
30 30
         $ret = null;
31
-        if(is_array($username)){
32
-            foreach($username as $key){
31
+        if (is_array($username)) {
32
+            foreach ($username as $key) {
33 33
                 $get = $this->_check($key);
34
-                if(!empty($get)){
34
+                if (!empty($get)) {
35 35
                     $ret[] = $get;
36 36
                 }
37 37
             }
38
-        } else{
38
+        } else {
39 39
                 $ret = $this->_check($username);
40 40
         }
41 41
         $ret = json_encode($ret);
42 42
         return json_decode($ret);
43 43
     }
44
-    public function clearLocked(){
44
+    public function clearLocked() {
45 45
         return $this->clear_all();
46 46
     }
47 47
 
48
-    private function _unlock($username){
48
+    private function _unlock($username) {
49 49
         $this->unlock_account($username);
50 50
     }
51
-    private function _lock($username){
51
+    private function _lock($username) {
52 52
         $this->lock_account($username);
53 53
     }
54
-    private function _check($username){
55
-        return json_decode($this->check_account($username),true);
54
+    private function _check($username) {
55
+        return json_decode($this->check_account($username), true);
56 56
     }
57 57
 }
Please login to merge, or discard this patch.