@@ -30,14 +30,14 @@ discard block |
||
30 | 30 | |
31 | 31 | public function getIndex() { |
32 | 32 | |
33 | - if(request("refresh")) { |
|
34 | - $this->fetchPluginData(false ); |
|
35 | - return cb()->redirectBack("Plugin list has been refreshed!","success"); |
|
33 | + if (request("refresh")) { |
|
34 | + $this->fetchPluginData(false); |
|
35 | + return cb()->redirectBack("Plugin list has been refreshed!", "success"); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | $data = []; |
39 | 39 | $data['result'] = $this->fetchPluginData(); |
40 | - return view($this->view.'.index',$data); |
|
40 | + return view($this->view.'.index', $data); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | public function postLoginAccount() { |
@@ -52,13 +52,13 @@ discard block |
||
52 | 52 | ]); |
53 | 53 | $response = $curl->send(); |
54 | 54 | |
55 | - if($respArray = json_decode($response, true)) { |
|
56 | - if($respArray['status'] && isset($respArray['token'])) { |
|
55 | + if ($respArray = json_decode($response, true)) { |
|
56 | + if ($respArray['status'] && isset($respArray['token'])) { |
|
57 | 57 | session(['account_token'=>$respArray['token']]); |
58 | 58 | } |
59 | - return response()->make($response,200,["Content-Type"=>"application/json"]); |
|
59 | + return response()->make($response, 200, ["Content-Type"=>"application/json"]); |
|
60 | 60 | } else { |
61 | - return response()->json(['status'=>false,'message'=>'failed']); |
|
61 | + return response()->json(['status'=>false, 'message'=>'failed']); |
|
62 | 62 | } |
63 | 63 | } |
64 | 64 | |
@@ -75,15 +75,15 @@ discard block |
||
75 | 75 | ]); |
76 | 76 | $response = $curl->send(); |
77 | 77 | |
78 | - if($respArray = json_decode($response, true)) { |
|
79 | - if($respArray['status']) { |
|
78 | + if ($respArray = json_decode($response, true)) { |
|
79 | + if ($respArray['status']) { |
|
80 | 80 | $form = base64_decode($respArray['payment']); |
81 | - return response()->json(['status'=>true,'form'=>$form]); |
|
81 | + return response()->json(['status'=>true, 'form'=>$form]); |
|
82 | 82 | } else { |
83 | 83 | return response()->json($respArray); |
84 | 84 | } |
85 | 85 | } else { |
86 | - return response()->json(['status'=>false,'message'=>'failed','raw'=>$response]); |
|
86 | + return response()->json(['status'=>false, 'message'=>'failed', 'raw'=>$response]); |
|
87 | 87 | } |
88 | 88 | } |
89 | 89 | |
@@ -91,11 +91,11 @@ discard block |
||
91 | 91 | { |
92 | 92 | $pluginData = $this->fetchPluginData(); |
93 | 93 | |
94 | - if(isset($pluginData[$key])) { |
|
95 | - if(file_exists(app_path("CBPlugins/".$key))) { |
|
94 | + if (isset($pluginData[$key])) { |
|
95 | + if (file_exists(app_path("CBPlugins/".$key))) { |
|
96 | 96 | |
97 | - if(isset($pluginData['source']) && $pluginData['source'] == 'composer') { |
|
98 | - if(isset($pluginData['package'])) { |
|
97 | + if (isset($pluginData['source']) && $pluginData['source'] == 'composer') { |
|
98 | + if (isset($pluginData['package'])) { |
|
99 | 99 | ComposerHelper::composerRemove($pluginData['package']); |
100 | 100 | } |
101 | 101 | } |
@@ -103,24 +103,24 @@ discard block |
||
103 | 103 | rrmdir(app_path("CBPlugins/".$key)); |
104 | 104 | |
105 | 105 | return response()->json(['status'=>true, 'message'=>'Plugin has been uninstalled!']); |
106 | - }else{ |
|
107 | - return response()->json(['status'=>false,'message'=>'Failed to uninstall, plugin is not found']); |
|
106 | + } else { |
|
107 | + return response()->json(['status'=>false, 'message'=>'Failed to uninstall, plugin is not found']); |
|
108 | 108 | } |
109 | - }else { |
|
110 | - return response()->json(['status'=>false,'message'=>'Failed to uninstall, plugin key is not found']); |
|
109 | + } else { |
|
110 | + return response()->json(['status'=>false, 'message'=>'Failed to uninstall, plugin key is not found']); |
|
111 | 111 | } |
112 | 112 | } |
113 | 113 | |
114 | - private function recursiveCopy($src,$dst) { |
|
114 | + private function recursiveCopy($src, $dst) { |
|
115 | 115 | $dir = opendir($src); |
116 | 116 | @mkdir($dst); |
117 | - while(false !== ( $file = readdir($dir)) ) { |
|
118 | - if (( $file != '.' ) && ( $file != '..' )) { |
|
119 | - if ( is_dir($src . '/' . $file) ) { |
|
120 | - $this->recursiveCopy($src . '/' . $file,$dst . '/' . $file); |
|
117 | + while (false !== ($file = readdir($dir))) { |
|
118 | + if (($file != '.') && ($file != '..')) { |
|
119 | + if (is_dir($src.'/'.$file)) { |
|
120 | + $this->recursiveCopy($src.'/'.$file, $dst.'/'.$file); |
|
121 | 121 | } |
122 | 122 | else { |
123 | - copy($src . '/' . $file,$dst . '/' . $file); |
|
123 | + copy($src.'/'.$file, $dst.'/'.$file); |
|
124 | 124 | } |
125 | 125 | } |
126 | 126 | } |
@@ -129,24 +129,24 @@ discard block |
||
129 | 129 | |
130 | 130 | public function getInstall($key) |
131 | 131 | { |
132 | - ini_set("memory_limit","192M"); |
|
132 | + ini_set("memory_limit", "192M"); |
|
133 | 133 | set_time_limit(500); |
134 | 134 | |
135 | 135 | $pluginData = $this->fetchPluginData(); |
136 | 136 | |
137 | 137 | try { |
138 | - if(isset($pluginData[$key])) { |
|
138 | + if (isset($pluginData[$key])) { |
|
139 | 139 | $plugin = $pluginData[$key]; |
140 | 140 | |
141 | - if(isset($plugin['source']) && $plugin['source'] == "composer") { |
|
141 | + if (isset($plugin['source']) && $plugin['source'] == "composer") { |
|
142 | 142 | |
143 | - if(isset($plugin['package']) && isset($plugin['service_provider'])) { |
|
143 | + if (isset($plugin['package']) && isset($plugin['service_provider'])) { |
|
144 | 144 | // Make a composer |
145 | 145 | $output = ComposerHelper::composerRequire($plugin['package'], $plugin['service_provider']); |
146 | 146 | |
147 | - return response()->json(['status'=>true,'message'=>$output]); |
|
147 | + return response()->json(['status'=>true, 'message'=>$output]); |
|
148 | 148 | } else { |
149 | - return response()->json(['status'=>true,'message'=>'Installation is failed, there is no package and or service provider']); |
|
149 | + return response()->json(['status'=>true, 'message'=>'Installation is failed, there is no package and or service provider']); |
|
150 | 150 | } |
151 | 151 | |
152 | 152 | } else { |
@@ -165,16 +165,16 @@ discard block |
||
165 | 165 | fclose($temp); |
166 | 166 | |
167 | 167 | // Rename |
168 | - if(file_exists(app_path("CBPlugins/".$key))) rrmdir(app_path("CBPlugins/".$key)); |
|
168 | + if (file_exists(app_path("CBPlugins/".$key))) rrmdir(app_path("CBPlugins/".$key)); |
|
169 | 169 | rename(app_path("CBPlugins/".$dirName), app_path("CBPlugins/".$key)); |
170 | 170 | |
171 | 171 | // Read Plugin JSON |
172 | 172 | $pluginJson = json_decode(file_get_contents(app_path("CBPlugins/".$key."/plugin.json")), true); |
173 | 173 | |
174 | 174 | // Check if has asset |
175 | - if($pluginJson && $pluginJson['asset']) { |
|
175 | + if ($pluginJson && $pluginJson['asset']) { |
|
176 | 176 | // Check destination folder is ready |
177 | - if(file_exists(public_path("cb_asset/".$key))) { |
|
177 | + if (file_exists(public_path("cb_asset/".$key))) { |
|
178 | 178 | rrmdir(public_path("cb_asset/".$key)); |
179 | 179 | } |
180 | 180 | |
@@ -185,31 +185,31 @@ discard block |
||
185 | 185 | $this->recursiveCopy(app_path("CBPlugins/".$key."/".$pluginJson['asset']), public_path("cb_asset/".$key)); |
186 | 186 | } |
187 | 187 | |
188 | - return response()->json(['status'=>true,'message'=>'Install / update plugin has been succesfull!']); |
|
188 | + return response()->json(['status'=>true, 'message'=>'Install / update plugin has been succesfull!']); |
|
189 | 189 | |
190 | 190 | } else { |
191 | - return response()->json(['status'=>false,'message'=>"Failed to install/update, can't open the plugin archive"]); |
|
191 | + return response()->json(['status'=>false, 'message'=>"Failed to install/update, can't open the plugin archive"]); |
|
192 | 192 | } |
193 | 193 | } |
194 | 194 | |
195 | - }else{ |
|
196 | - return response()->json(['status'=>false,'message'=>'Failed to install/update, plugin key is not found']); |
|
195 | + } else { |
|
196 | + return response()->json(['status'=>false, 'message'=>'Failed to install/update, plugin key is not found']); |
|
197 | 197 | } |
198 | 198 | } catch (\Exception $e) { |
199 | - return response()->json(['status'=>false,'message'=>'Something went wrong!']); |
|
199 | + return response()->json(['status'=>false, 'message'=>'Something went wrong!']); |
|
200 | 200 | } |
201 | 201 | } |
202 | 202 | |
203 | 203 | private function fetchPluginData($cache = true) |
204 | 204 | { |
205 | - if($cache === true && $data = Cache::get("plugin_store_data")) { |
|
205 | + if ($cache === true && $data = Cache::get("plugin_store_data")) { |
|
206 | 206 | return $data; |
207 | 207 | } |
208 | 208 | |
209 | 209 | $result = []; |
210 | 210 | |
211 | 211 | try { |
212 | - $no_cache = ($cache)?0:1; |
|
212 | + $no_cache = ($cache) ? 0 : 1; |
|
213 | 213 | $opts = [ |
214 | 214 | "http" => [ |
215 | 215 | "method" => "GET", |
@@ -218,17 +218,17 @@ discard block |
||
218 | 218 | "No-Cache: ".$no_cache |
219 | 219 | ] |
220 | 220 | ]; |
221 | - Log::debug("Headers: ".print_r($opts,true)); |
|
221 | + Log::debug("Headers: ".print_r($opts, true)); |
|
222 | 222 | $context = stream_context_create($opts); |
223 | 223 | $data = file_get_contents(base64_decode("aHR0cDovL2NydWRib29zdGVyLmNvbS9hcGkvcGx1Z2luP2FjY2Vzc190b2tlbj1iVmMvWm5wWU5TWnJNVlpZT0hFNVUydHFjU1U9"), false, $context); |
224 | 224 | Log::debug("Plugin API : ".$data); |
225 | - if($data) { |
|
225 | + if ($data) { |
|
226 | 226 | $data = json_decode($data, true); |
227 | - if($data['status']==true) { |
|
227 | + if ($data['status'] == true) { |
|
228 | 228 | |
229 | - foreach($data['data'] as $item) { |
|
229 | + foreach ($data['data'] as $item) { |
|
230 | 230 | $key = $item['key']; |
231 | - $result[ $key ] = $item; |
|
231 | + $result[$key] = $item; |
|
232 | 232 | } |
233 | 233 | |
234 | 234 | $result = collect($result)->sortBy("name")->all(); |
@@ -103,10 +103,10 @@ discard block |
||
103 | 103 | rrmdir(app_path("CBPlugins/".$key)); |
104 | 104 | |
105 | 105 | return response()->json(['status'=>true, 'message'=>'Plugin has been uninstalled!']); |
106 | - }else{ |
|
106 | + } else{ |
|
107 | 107 | return response()->json(['status'=>false,'message'=>'Failed to uninstall, plugin is not found']); |
108 | 108 | } |
109 | - }else { |
|
109 | + } else { |
|
110 | 110 | return response()->json(['status'=>false,'message'=>'Failed to uninstall, plugin key is not found']); |
111 | 111 | } |
112 | 112 | } |
@@ -118,8 +118,7 @@ discard block |
||
118 | 118 | if (( $file != '.' ) && ( $file != '..' )) { |
119 | 119 | if ( is_dir($src . '/' . $file) ) { |
120 | 120 | $this->recursiveCopy($src . '/' . $file,$dst . '/' . $file); |
121 | - } |
|
122 | - else { |
|
121 | + } else { |
|
123 | 122 | copy($src . '/' . $file,$dst . '/' . $file); |
124 | 123 | } |
125 | 124 | } |
@@ -165,7 +164,9 @@ discard block |
||
165 | 164 | fclose($temp); |
166 | 165 | |
167 | 166 | // Rename |
168 | - if(file_exists(app_path("CBPlugins/".$key))) rrmdir(app_path("CBPlugins/".$key)); |
|
167 | + if(file_exists(app_path("CBPlugins/".$key))) { |
|
168 | + rrmdir(app_path("CBPlugins/".$key)); |
|
169 | + } |
|
169 | 170 | rename(app_path("CBPlugins/".$dirName), app_path("CBPlugins/".$key)); |
170 | 171 | |
171 | 172 | // Read Plugin JSON |
@@ -192,7 +193,7 @@ discard block |
||
192 | 193 | } |
193 | 194 | } |
194 | 195 | |
195 | - }else{ |
|
196 | + } else{ |
|
196 | 197 | return response()->json(['status'=>false,'message'=>'Failed to install/update, plugin key is not found']); |
197 | 198 | } |
198 | 199 | } catch (\Exception $e) { |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | */ |
13 | 13 | public function up() |
14 | 14 | { |
15 | - Schema::table('users', function (Blueprint $table) { |
|
15 | + Schema::table('users', function(Blueprint $table) { |
|
16 | 16 | $table->string('photo')->nullable(); |
17 | 17 | $table->integer('cb_roles_id'); |
18 | 18 | $table->ipAddress("ip_address")->nullable(); |
@@ -28,8 +28,8 @@ discard block |
||
28 | 28 | */ |
29 | 29 | public function down() |
30 | 30 | { |
31 | - Schema::table('users', function (Blueprint $table) { |
|
32 | - $table->dropColumn(["photo","cb_roles_id","ip_address","user_agent","login_at"]); |
|
31 | + Schema::table('users', function(Blueprint $table) { |
|
32 | + $table->dropColumn(["photo", "cb_roles_id", "ip_address", "user_agent", "login_at"]); |
|
33 | 33 | }); |
34 | 34 | } |
35 | 35 | } |
@@ -55,7 +55,7 @@ |
||
55 | 55 | $process->setInput("Y"); |
56 | 56 | $process->setWorkingDirectory(base_path())->run(); |
57 | 57 | |
58 | - Artisan::call("vendor:publish",["--provider"=>$serviceProvider]); |
|
58 | + Artisan::call("vendor:publish", ["--provider"=>$serviceProvider]); |
|
59 | 59 | |
60 | 60 | return $process->getOutput(); |
61 | 61 | } |
@@ -25,22 +25,22 @@ discard block |
||
25 | 25 | |
26 | 26 | public function getIndex() { |
27 | 27 | $data = []; |
28 | - return view($this->view.".index",$data); |
|
28 | + return view($this->view.".index", $data); |
|
29 | 29 | } |
30 | 30 | |
31 | 31 | public function getAdd() { |
32 | 32 | $data = []; |
33 | 33 | $data['form_title'] = "Add Menu"; |
34 | 34 | $data['form_url'] = route('DeveloperMenusControllerPostAddSave'); |
35 | - $data['modules'] = DB::table("cb_modules")->orderBy("name","asc")->get(); |
|
35 | + $data['modules'] = DB::table("cb_modules")->orderBy("name", "asc")->get(); |
|
36 | 36 | return view($this->view.".form", $data); |
37 | 37 | } |
38 | 38 | |
39 | 39 | public function getEdit($id) { |
40 | 40 | $data = []; |
41 | 41 | $data['form_title'] = "Edit Menu"; |
42 | - $data['form_url'] = route('DeveloperMenusControllerPostEditSave',['id'=>$id]); |
|
43 | - $data['modules'] = DB::table("cb_modules")->orderBy("name","asc")->get(); |
|
42 | + $data['form_url'] = route('DeveloperMenusControllerPostEditSave', ['id'=>$id]); |
|
43 | + $data['modules'] = DB::table("cb_modules")->orderBy("name", "asc")->get(); |
|
44 | 44 | $data['row'] = cb()->find("cb_menus", $id); |
45 | 45 | return view($this->view.".form", $data); |
46 | 46 | } |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | $menu['name'] = request('name'); |
54 | 54 | $menu['icon'] = request('icon'); |
55 | 55 | $menu['type'] = request('type'); |
56 | - if(request('type') == 'module') { |
|
56 | + if (request('type') == 'module') { |
|
57 | 57 | $menu['cb_modules_id'] = request('cb_modules_id'); |
58 | 58 | }elseif (request('type') == 'url') { |
59 | 59 | $menu['path'] = request('url_value'); |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | |
68 | 68 | CacheHelper::forgetGroup("sidebar_menu"); |
69 | 69 | |
70 | - return cb()->redirect(route("DeveloperMenusControllerGetIndex"),"The menu has been added!","success"); |
|
70 | + return cb()->redirect(route("DeveloperMenusControllerGetIndex"), "The menu has been added!", "success"); |
|
71 | 71 | |
72 | 72 | } catch (CBValidationException $e) { |
73 | 73 | return cb()->redirectBack($e->getMessage()); |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | $menu['name'] = request('name'); |
83 | 83 | $menu['icon'] = request('icon'); |
84 | 84 | $menu['type'] = request('type'); |
85 | - if(request('type') == 'module') { |
|
85 | + if (request('type') == 'module') { |
|
86 | 86 | $menu['cb_modules_id'] = request('cb_modules_id'); |
87 | 87 | }elseif (request('type') == 'url') { |
88 | 88 | $menu['path'] = request('url_value'); |
@@ -91,11 +91,11 @@ discard block |
||
91 | 91 | } elseif (request("type") == "empty") { |
92 | 92 | $menu['path'] = "javascript:void(0);"; |
93 | 93 | } |
94 | - DB::table("cb_menus")->where("id",$id)->update($menu); |
|
94 | + DB::table("cb_menus")->where("id", $id)->update($menu); |
|
95 | 95 | |
96 | 96 | CacheHelper::forgetGroup("sidebar_menu"); |
97 | 97 | |
98 | - return cb()->redirect(route("DeveloperMenusControllerGetIndex"),"The menu has been saved!","success"); |
|
98 | + return cb()->redirect(route("DeveloperMenusControllerGetIndex"), "The menu has been saved!", "success"); |
|
99 | 99 | |
100 | 100 | } catch (CBValidationException $e) { |
101 | 101 | return cb()->redirectBack($e->getMessage()); |
@@ -108,20 +108,20 @@ discard block |
||
108 | 108 | |
109 | 109 | $menus = request('menus'); |
110 | 110 | $menus = json_decode($menus, true); |
111 | - if($menus) { |
|
111 | + if ($menus) { |
|
112 | 112 | $menus = $menus[0]; |
113 | - if($menus) { |
|
114 | - foreach($menus as $i=>$menu) { |
|
113 | + if ($menus) { |
|
114 | + foreach ($menus as $i=>$menu) { |
|
115 | 115 | $id = $menu['id']; |
116 | - cb()->update("cb_menus",$id,["sort_number"=>$i,'parent_cb_menus_id'=>null]); |
|
117 | - if($menu['children'][0]) { |
|
118 | - foreach($menu['children'][0] as $ii=>$sub) { |
|
116 | + cb()->update("cb_menus", $id, ["sort_number"=>$i, 'parent_cb_menus_id'=>null]); |
|
117 | + if ($menu['children'][0]) { |
|
118 | + foreach ($menu['children'][0] as $ii=>$sub) { |
|
119 | 119 | $id = $sub['id']; |
120 | - cb()->update("cb_menus",$id,["sort_number"=>$ii,"parent_cb_menus_id"=>$menu['id']]); |
|
121 | - if($sub['children'][0]) { |
|
122 | - foreach($sub['children'][0] as $iii=>$subsub) { |
|
120 | + cb()->update("cb_menus", $id, ["sort_number"=>$ii, "parent_cb_menus_id"=>$menu['id']]); |
|
121 | + if ($sub['children'][0]) { |
|
122 | + foreach ($sub['children'][0] as $iii=>$subsub) { |
|
123 | 123 | $id = $subsub['id']; |
124 | - cb()->update("cb_menus",$id,["sort_number"=>$iii,"parent_cb_menus_id"=>$sub['id']]); |
|
124 | + cb()->update("cb_menus", $id, ["sort_number"=>$iii, "parent_cb_menus_id"=>$sub['id']]); |
|
125 | 125 | } |
126 | 126 | } |
127 | 127 | } |
@@ -132,20 +132,20 @@ discard block |
||
132 | 132 | |
133 | 133 | CacheHelper::forgetGroup("sidebar_menu"); |
134 | 134 | |
135 | - return response()->json(['api_status'=>1,'api_message'=>'success']); |
|
135 | + return response()->json(['api_status'=>1, 'api_message'=>'success']); |
|
136 | 136 | |
137 | 137 | } catch (CBValidationException $e) { |
138 | - return response()->json(['api_status'=>0,'api_message'=>$e->getMessage()]); |
|
138 | + return response()->json(['api_status'=>0, 'api_message'=>$e->getMessage()]); |
|
139 | 139 | } |
140 | 140 | } |
141 | 141 | |
142 | 142 | public function getDelete($id) { |
143 | - DB::table("cb_menus")->where("id",$id)->delete(); |
|
143 | + DB::table("cb_menus")->where("id", $id)->delete(); |
|
144 | 144 | DB::table("cb_role_privileges")->where("cb_menus_id", $id)->delete(); |
145 | 145 | |
146 | 146 | CacheHelper::forgetGroup("sidebar_menu"); |
147 | 147 | |
148 | - return cb()->redirectBack("The menu has been deleted!","success"); |
|
148 | + return cb()->redirectBack("The menu has been deleted!", "success"); |
|
149 | 149 | } |
150 | 150 | |
151 | 151 | } |
152 | 152 | \ No newline at end of file |
@@ -55,9 +55,9 @@ discard block |
||
55 | 55 | $menu['type'] = request('type'); |
56 | 56 | if(request('type') == 'module') { |
57 | 57 | $menu['cb_modules_id'] = request('cb_modules_id'); |
58 | - }elseif (request('type') == 'url') { |
|
58 | + } elseif (request('type') == 'url') { |
|
59 | 59 | $menu['path'] = request('url_value'); |
60 | - }elseif (request('type') == 'path') { |
|
60 | + } elseif (request('type') == 'path') { |
|
61 | 61 | $menu['path'] = request('path_value'); |
62 | 62 | } elseif (request("type") == "empty") { |
63 | 63 | $menu['path'] = "javascript:void(0);"; |
@@ -84,9 +84,9 @@ discard block |
||
84 | 84 | $menu['type'] = request('type'); |
85 | 85 | if(request('type') == 'module') { |
86 | 86 | $menu['cb_modules_id'] = request('cb_modules_id'); |
87 | - }elseif (request('type') == 'url') { |
|
87 | + } elseif (request('type') == 'url') { |
|
88 | 88 | $menu['path'] = request('url_value'); |
89 | - }elseif (request('type') == 'path') { |
|
89 | + } elseif (request('type') == 'path') { |
|
90 | 90 | $menu['path'] = request('path_value'); |
91 | 91 | } elseif (request("type") == "empty") { |
92 | 92 | $menu['path'] = "javascript:void(0);"; |