@@ -19,25 +19,25 @@ |
||
19 | 19 | } |
20 | 20 | |
21 | 21 | public function postLoginDeveloper() { |
22 | - try{ |
|
22 | + try { |
|
23 | 23 | cb()->validation([ |
24 | 24 | 'username'=>'required', |
25 | 25 | 'password'=>'required' |
26 | 26 | ]); |
27 | 27 | |
28 | - if(request('username') == getSetting('developer_username') |
|
28 | + if (request('username') == getSetting('developer_username') |
|
29 | 29 | && request('password') == getSetting("developer_password")) { |
30 | 30 | |
31 | 31 | session(['developer'=>getSetting('developer_username')]); |
32 | 32 | |
33 | 33 | return redirect(cb()->getDeveloperUrl()); |
34 | 34 | |
35 | - }else{ |
|
36 | - return cb()->redirectBack( cbLang("password_and_username_is_wrong")); |
|
35 | + } else { |
|
36 | + return cb()->redirectBack(cbLang("password_and_username_is_wrong")); |
|
37 | 37 | } |
38 | 38 | |
39 | - }catch (CBValidationException $e) { |
|
40 | - return cb()->redirect(cb()->getLoginUrl(),$e->getMessage(),'warning'); |
|
39 | + } catch (CBValidationException $e) { |
|
40 | + return cb()->redirect(cb()->getLoginUrl(), $e->getMessage(), 'warning'); |
|
41 | 41 | } |
42 | 42 | } |
43 | 43 |
@@ -28,14 +28,14 @@ discard block |
||
28 | 28 | |
29 | 29 | public function getIndex() { |
30 | 30 | |
31 | - if(request("refresh")) { |
|
32 | - $this->fetchPluginData(false ); |
|
33 | - return cb()->redirectBack("Plugin list has been refreshed!","success"); |
|
31 | + if (request("refresh")) { |
|
32 | + $this->fetchPluginData(false); |
|
33 | + return cb()->redirectBack("Plugin list has been refreshed!", "success"); |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | $data = []; |
37 | 37 | $data['result'] = $this->fetchPluginData(); |
38 | - return view($this->view.'.index',$data); |
|
38 | + return view($this->view.'.index', $data); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | public function postLoginAccount() { |
@@ -50,13 +50,13 @@ discard block |
||
50 | 50 | ]); |
51 | 51 | $response = $curl->send(); |
52 | 52 | |
53 | - if($respArray = json_decode($response, true)) { |
|
54 | - if($respArray['status'] && isset($respArray['token'])) { |
|
53 | + if ($respArray = json_decode($response, true)) { |
|
54 | + if ($respArray['status'] && isset($respArray['token'])) { |
|
55 | 55 | session(['account_token'=>$respArray['token']]); |
56 | 56 | } |
57 | - return response()->make($response,200,["Content-Type"=>"application/json"]); |
|
57 | + return response()->make($response, 200, ["Content-Type"=>"application/json"]); |
|
58 | 58 | } else { |
59 | - return response()->json(['status'=>false,'message'=>'failed']); |
|
59 | + return response()->json(['status'=>false, 'message'=>'failed']); |
|
60 | 60 | } |
61 | 61 | } |
62 | 62 | |
@@ -73,15 +73,15 @@ discard block |
||
73 | 73 | ]); |
74 | 74 | $response = $curl->send(); |
75 | 75 | |
76 | - if($respArray = json_decode($response, true)) { |
|
77 | - if($respArray['status']) { |
|
76 | + if ($respArray = json_decode($response, true)) { |
|
77 | + if ($respArray['status']) { |
|
78 | 78 | $form = base64_decode($respArray['payment']); |
79 | - return response()->json(['status'=>true,'form'=>$form]); |
|
79 | + return response()->json(['status'=>true, 'form'=>$form]); |
|
80 | 80 | } else { |
81 | 81 | return response()->json($respArray); |
82 | 82 | } |
83 | 83 | } else { |
84 | - return response()->json(['status'=>false,'message'=>'failed','raw'=>$response]); |
|
84 | + return response()->json(['status'=>false, 'message'=>'failed', 'raw'=>$response]); |
|
85 | 85 | } |
86 | 86 | } |
87 | 87 | |
@@ -89,15 +89,15 @@ discard block |
||
89 | 89 | { |
90 | 90 | $pluginData = $this->fetchPluginData(); |
91 | 91 | |
92 | - if(isset($pluginData[$key])) { |
|
93 | - if(file_exists(app_path("CBPlugins/".$key))) { |
|
92 | + if (isset($pluginData[$key])) { |
|
93 | + if (file_exists(app_path("CBPlugins/".$key))) { |
|
94 | 94 | rrmdir(app_path("CBPlugins/".$key)); |
95 | 95 | return response()->json(['status'=>true, 'message'=>'Plugin has been uninstalled!']); |
96 | - }else{ |
|
97 | - return response()->json(['status'=>false,'message'=>'Failed to uninstall, plugin is not found']); |
|
96 | + } else { |
|
97 | + return response()->json(['status'=>false, 'message'=>'Failed to uninstall, plugin is not found']); |
|
98 | 98 | } |
99 | - }else { |
|
100 | - return response()->json(['status'=>false,'message'=>'Failed to uninstall, plugin key is not found']); |
|
99 | + } else { |
|
100 | + return response()->json(['status'=>false, 'message'=>'Failed to uninstall, plugin key is not found']); |
|
101 | 101 | } |
102 | 102 | } |
103 | 103 | |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | { |
106 | 106 | $pluginData = $this->fetchPluginData(); |
107 | 107 | |
108 | - if(isset($pluginData[$key])) { |
|
108 | + if (isset($pluginData[$key])) { |
|
109 | 109 | $plugin = $pluginData[$key]; |
110 | 110 | |
111 | 111 | // Create temp file of zip plugin |
@@ -123,22 +123,22 @@ discard block |
||
123 | 123 | fclose($temp); |
124 | 124 | |
125 | 125 | // Rename |
126 | - if(file_exists(app_path("CBPlugins/".$key))) rrmdir(app_path("CBPlugins/".$key)); |
|
126 | + if (file_exists(app_path("CBPlugins/".$key))) rrmdir(app_path("CBPlugins/".$key)); |
|
127 | 127 | rename(app_path("CBPlugins/".$dirName), app_path("CBPlugins/".$key)); |
128 | 128 | |
129 | - return response()->json(['status'=>true,'message'=>'Install / update plugin has been succesfull!']); |
|
129 | + return response()->json(['status'=>true, 'message'=>'Install / update plugin has been succesfull!']); |
|
130 | 130 | |
131 | 131 | } else { |
132 | - return response()->json(['status'=>false,'message'=>"Failed to install/update, can't open the plugin archive"]); |
|
132 | + return response()->json(['status'=>false, 'message'=>"Failed to install/update, can't open the plugin archive"]); |
|
133 | 133 | } |
134 | - }else{ |
|
135 | - return response()->json(['status'=>false,'message'=>'Failed to install/update, plugin key is not found']); |
|
134 | + } else { |
|
135 | + return response()->json(['status'=>false, 'message'=>'Failed to install/update, plugin key is not found']); |
|
136 | 136 | } |
137 | 137 | } |
138 | 138 | |
139 | 139 | private function fetchPluginData($cache = true) |
140 | 140 | { |
141 | - if($cache === true && $data = Cache::get("plugin_store_data")) { |
|
141 | + if ($cache === true && $data = Cache::get("plugin_store_data")) { |
|
142 | 142 | return $data; |
143 | 143 | } |
144 | 144 | |
@@ -155,13 +155,13 @@ discard block |
||
155 | 155 | $context = stream_context_create($opts); |
156 | 156 | $data = file_get_contents(base64_decode("aHR0cDovL2NydWRib29zdGVyLmNvbS9hcGkvcGx1Z2luP2FjY2Vzc190b2tlbj1iVmMvWm5wWU5TWnJNVlpZT0hFNVUydHFjU1U9"), false, $context); |
157 | 157 | |
158 | - if($data) { |
|
158 | + if ($data) { |
|
159 | 159 | $data = json_decode($data, true); |
160 | - if($data['status']==true) { |
|
160 | + if ($data['status'] == true) { |
|
161 | 161 | |
162 | - foreach($data['data'] as $item) { |
|
162 | + foreach ($data['data'] as $item) { |
|
163 | 163 | $key = $item['key']; |
164 | - $result[ $key ] = $item; |
|
164 | + $result[$key] = $item; |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | $result = collect($result)->sortBy("name")->all(); |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if(!function_exists("putHtaccess")) { |
|
3 | +if (!function_exists("putHtaccess")) { |
|
4 | 4 | function putHtaccess($stringToPut) |
5 | 5 | { |
6 | 6 | file_put_contents(base_path(".htaccess"), "\n".$stringToPut, FILE_APPEND); |
@@ -8,13 +8,13 @@ discard block |
||
8 | 8 | } |
9 | 9 | } |
10 | 10 | |
11 | -if(!function_exists("checkHtaccess")) { |
|
11 | +if (!function_exists("checkHtaccess")) { |
|
12 | 12 | function checkHtaccess($stringToCheck) |
13 | 13 | { |
14 | - if(file_exists(base_path(".htaccess")) && file_exists(public_path(".htaccess"))) { |
|
14 | + if (file_exists(base_path(".htaccess")) && file_exists(public_path(".htaccess"))) { |
|
15 | 15 | $htaccess = file_get_contents(base_path(".htaccess")); |
16 | - $htaccess2= file_get_contents(public_path(".htaccess")); |
|
17 | - if(\Illuminate\Support\Str::contains($htaccess, $stringToCheck) && \Illuminate\Support\Str::contains($htaccess2, $stringToCheck)) { |
|
16 | + $htaccess2 = file_get_contents(public_path(".htaccess")); |
|
17 | + if (\Illuminate\Support\Str::contains($htaccess, $stringToCheck) && \Illuminate\Support\Str::contains($htaccess2, $stringToCheck)) { |
|
18 | 18 | return true; |
19 | 19 | } |
20 | 20 | } |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | } |
24 | 24 | } |
25 | 25 | |
26 | -if(!function_exists("setEnvironmentValue")) { |
|
26 | +if (!function_exists("setEnvironmentValue")) { |
|
27 | 27 | function setEnvironmentValue(array $values) |
28 | 28 | { |
29 | 29 | $envFile = app()->environmentFilePath(); |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | } |
55 | 55 | |
56 | 56 | |
57 | -if(!function_exists("cbLang")) { |
|
57 | +if (!function_exists("cbLang")) { |
|
58 | 58 | /** |
59 | 59 | * @param string $key |
60 | 60 | * @param array $replace |
@@ -66,17 +66,17 @@ discard block |
||
66 | 66 | } |
67 | 67 | } |
68 | 68 | |
69 | -if(!function_exists('rglob')) { |
|
69 | +if (!function_exists('rglob')) { |
|
70 | 70 | function rglob($pattern, $flags = 0) { |
71 | 71 | $files = glob($pattern, $flags); |
72 | - foreach (glob(dirname($pattern).'/*', GLOB_ONLYDIR|GLOB_NOSORT) as $dir) { |
|
72 | + foreach (glob(dirname($pattern).'/*', GLOB_ONLYDIR | GLOB_NOSORT) as $dir) { |
|
73 | 73 | $files = array_merge($files, rglob($dir.'/'.basename($pattern), $flags)); |
74 | 74 | } |
75 | 75 | return $files; |
76 | 76 | } |
77 | 77 | } |
78 | 78 | |
79 | -if(!function_exists('convertPHPToMomentFormat')) { |
|
79 | +if (!function_exists('convertPHPToMomentFormat')) { |
|
80 | 80 | function convertPHPToMomentFormat($format) |
81 | 81 | { |
82 | 82 | $replacements = [ |
@@ -123,13 +123,13 @@ discard block |
||
123 | 123 | } |
124 | 124 | } |
125 | 125 | |
126 | -if(!function_exists('slug')) { |
|
126 | +if (!function_exists('slug')) { |
|
127 | 127 | function slug($string, $separator = '-') { |
128 | 128 | return \Illuminate\Support\Str::slug($string, $separator); |
129 | 129 | } |
130 | 130 | } |
131 | 131 | |
132 | -if(!function_exists('columnSingleton')) { |
|
132 | +if (!function_exists('columnSingleton')) { |
|
133 | 133 | /** |
134 | 134 | * @return \crocodicstudio\crudbooster\controllers\scaffolding\singletons\ColumnSingleton |
135 | 135 | */ |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | } |
139 | 139 | } |
140 | 140 | |
141 | -if(!function_exists('cbHook')) |
|
141 | +if (!function_exists('cbHook')) |
|
142 | 142 | { |
143 | 143 | /** |
144 | 144 | * @return crocodicstudio\crudbooster\hooks\CBHook |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | } |
151 | 151 | } |
152 | 152 | |
153 | -if(!function_exists('getTypeHook')) |
|
153 | +if (!function_exists('getTypeHook')) |
|
154 | 154 | { |
155 | 155 | /** |
156 | 156 | * @param string $type |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | } |
164 | 164 | } |
165 | 165 | |
166 | -if(!function_exists('getPrimaryKey')) |
|
166 | +if (!function_exists('getPrimaryKey')) |
|
167 | 167 | { |
168 | 168 | function getPrimaryKey($table_name) |
169 | 169 | { |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | } |
172 | 172 | } |
173 | 173 | |
174 | -if(!function_exists('cb')) |
|
174 | +if (!function_exists('cb')) |
|
175 | 175 | { |
176 | 176 | function cb() |
177 | 177 | { |
@@ -179,25 +179,25 @@ discard block |
||
179 | 179 | } |
180 | 180 | } |
181 | 181 | |
182 | -if(!function_exists('cbAsset')) { |
|
182 | +if (!function_exists('cbAsset')) { |
|
183 | 183 | function cbAsset($path, $secure = null) { |
184 | 184 | return asset("cb_asset/".$path, $secure); |
185 | 185 | } |
186 | 186 | } |
187 | 187 | |
188 | -if(!function_exists("cbConfig")) { |
|
188 | +if (!function_exists("cbConfig")) { |
|
189 | 189 | function cbConfig($name, $default = null) { |
190 | 190 | return config("crudbooster.".$name, $default); |
191 | 191 | } |
192 | 192 | } |
193 | 193 | |
194 | -if(!function_exists("strRandom")) { |
|
194 | +if (!function_exists("strRandom")) { |
|
195 | 195 | function strRandom($length = 5) { |
196 | 196 | return \Illuminate\Support\Str::random($length); |
197 | 197 | } |
198 | 198 | } |
199 | 199 | |
200 | -if(!function_exists('module')) { |
|
200 | +if (!function_exists('module')) { |
|
201 | 201 | function module() |
202 | 202 | { |
203 | 203 | $module = new \crocodicstudio\crudbooster\helpers\Module(); |
@@ -205,21 +205,21 @@ discard block |
||
205 | 205 | } |
206 | 206 | } |
207 | 207 | |
208 | -if(!function_exists('getAdminLoginURL')) { |
|
208 | +if (!function_exists('getAdminLoginURL')) { |
|
209 | 209 | function getAdminLoginURL() |
210 | 210 | { |
211 | 211 | return cb()->getAdminUrl("login"); |
212 | 212 | } |
213 | 213 | } |
214 | 214 | |
215 | -if(!function_exists('dummyPhoto')) { |
|
215 | +if (!function_exists('dummyPhoto')) { |
|
216 | 216 | function dummyPhoto() |
217 | 217 | { |
218 | 218 | return cbConfig("DUMMY_PHOTO"); |
219 | 219 | } |
220 | 220 | } |
221 | 221 | |
222 | -if(!function_exists('extract_unit')) { |
|
222 | +if (!function_exists('extract_unit')) { |
|
223 | 223 | /* |
224 | 224 | Credits: Bit Repository |
225 | 225 | URL: http://www.bitrepository.com/extract-content-between-two-delimiters-with-php.html |
@@ -244,14 +244,14 @@ discard block |
||
244 | 244 | | |
245 | 245 | */ |
246 | 246 | |
247 | -if(!function_exists('putSetting')) { |
|
247 | +if (!function_exists('putSetting')) { |
|
248 | 248 | function putSetting($key, $value) |
249 | 249 | { |
250 | - if(file_exists(storage_path('.cbconfig'))) { |
|
250 | + if (file_exists(storage_path('.cbconfig'))) { |
|
251 | 251 | $settings = file_get_contents(storage_path('.cbconfig')); |
252 | 252 | $settings = decrypt($settings); |
253 | 253 | $settings = unserialize($settings); |
254 | - }else{ |
|
254 | + } else { |
|
255 | 255 | $settings = []; |
256 | 256 | } |
257 | 257 | |
@@ -265,31 +265,31 @@ discard block |
||
265 | 265 | } |
266 | 266 | } |
267 | 267 | |
268 | -if(!function_exists('getSetting')) { |
|
268 | +if (!function_exists('getSetting')) { |
|
269 | 269 | function getSetting($key, $default = null) |
270 | 270 | { |
271 | - if($cache = \Illuminate\Support\Facades\Cache::get("setting_".$key)) { |
|
271 | + if ($cache = \Illuminate\Support\Facades\Cache::get("setting_".$key)) { |
|
272 | 272 | return $cache; |
273 | 273 | } |
274 | 274 | |
275 | - if(file_exists(storage_path('.cbconfig'))) { |
|
275 | + if (file_exists(storage_path('.cbconfig'))) { |
|
276 | 276 | $settings = file_get_contents(storage_path('.cbconfig')); |
277 | 277 | $settings = decrypt($settings); |
278 | 278 | $settings = unserialize($settings); |
279 | - }else{ |
|
279 | + } else { |
|
280 | 280 | $settings = []; |
281 | 281 | } |
282 | 282 | |
283 | - if(isset($settings[$key])) { |
|
283 | + if (isset($settings[$key])) { |
|
284 | 284 | \Illuminate\Support\Facades\Cache::forever("setting_".$key, $settings[$key]); |
285 | - return $settings[$key]?:$default; |
|
286 | - }else{ |
|
285 | + return $settings[$key] ?: $default; |
|
286 | + } else { |
|
287 | 287 | return $default; |
288 | 288 | } |
289 | 289 | } |
290 | 290 | } |
291 | 291 | |
292 | -if(!function_exists('timeAgo')) { |
|
292 | +if (!function_exists('timeAgo')) { |
|
293 | 293 | function timeAgo($datetime_to, $datetime_from = null, $full = false) |
294 | 294 | { |
295 | 295 | $datetime_from = ($datetime_from) ?: date('Y-m-d H:i:s'); |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | } |
321 | 321 | } |
322 | 322 | |
323 | - if (! $full) { |
|
323 | + if (!$full) { |
|
324 | 324 | $string = array_slice($string, 0, 1); |
325 | 325 | } |
326 | 326 | |
@@ -328,22 +328,22 @@ discard block |
||
328 | 328 | } |
329 | 329 | } |
330 | 330 | |
331 | -if(!function_exists("array_map_r")) { |
|
332 | - function array_map_r( $func, $arr ) |
|
331 | +if (!function_exists("array_map_r")) { |
|
332 | + function array_map_r($func, $arr) |
|
333 | 333 | { |
334 | 334 | $newArr = array(); |
335 | 335 | |
336 | - foreach( $arr as $key => $value ) |
|
336 | + foreach ($arr as $key => $value) |
|
337 | 337 | { |
338 | 338 | $key = $func($key); |
339 | - $newArr[ $key ] = ( is_array( $value ) ? array_map_r( $func, $value ) : ( is_array($func) ? call_user_func_array($func, $value) : $func( $value ) ) ); |
|
339 | + $newArr[$key] = (is_array($value) ? array_map_r($func, $value) : (is_array($func) ? call_user_func_array($func, $value) : $func($value))); |
|
340 | 340 | } |
341 | 341 | |
342 | 342 | return $newArr; |
343 | 343 | } |
344 | 344 | } |
345 | 345 | |
346 | -if(!function_exists("sanitizeXSS")) |
|
346 | +if (!function_exists("sanitizeXSS")) |
|
347 | 347 | { |
348 | 348 | function sanitizeXSS($value) |
349 | 349 | { |
@@ -355,7 +355,7 @@ discard block |
||
355 | 355 | } |
356 | 356 | } |
357 | 357 | |
358 | -if(!function_exists("requestAll")) { |
|
358 | +if (!function_exists("requestAll")) { |
|
359 | 359 | function requestAll() { |
360 | 360 | $all = array_map_r("sanitizeXSS", request()->all()); |
361 | 361 | return $all; |
@@ -364,22 +364,22 @@ discard block |
||
364 | 364 | |
365 | 365 | |
366 | 366 | |
367 | -if(!function_exists('getURLFormat')) { |
|
367 | +if (!function_exists('getURLFormat')) { |
|
368 | 368 | function getURLFormat($name) { |
369 | 369 | $url = request($name); |
370 | - if(filter_var($url, FILTER_VALIDATE_URL)) { |
|
370 | + if (filter_var($url, FILTER_VALIDATE_URL)) { |
|
371 | 371 | return $url; |
372 | - }else{ |
|
372 | + } else { |
|
373 | 373 | return request()->url(); |
374 | 374 | } |
375 | 375 | } |
376 | 376 | } |
377 | 377 | |
378 | -if(!function_exists('g')) { |
|
378 | +if (!function_exists('g')) { |
|
379 | 379 | function g($name, $safe = true) { |
380 | - if($safe == true) { |
|
380 | + if ($safe == true) { |
|
381 | 381 | $response = request($name); |
382 | - if(is_string($response)) { |
|
382 | + if (is_string($response)) { |
|
383 | 383 | $response = sanitizeXSS($response); |
384 | 384 | }elseif (is_array($response)) { |
385 | 385 | array_walk_recursive($response, function(&$response) { |
@@ -388,25 +388,25 @@ discard block |
||
388 | 388 | } |
389 | 389 | |
390 | 390 | return $response; |
391 | - }else{ |
|
391 | + } else { |
|
392 | 392 | return Request::get($name); |
393 | 393 | } |
394 | 394 | } |
395 | 395 | } |
396 | 396 | |
397 | -if(!function_exists('min_var_export')) { |
|
397 | +if (!function_exists('min_var_export')) { |
|
398 | 398 | function min_var_export($input) { |
399 | - if(is_array($input)) { |
|
399 | + if (is_array($input)) { |
|
400 | 400 | $buffer = []; |
401 | - foreach($input as $key => $value) |
|
401 | + foreach ($input as $key => $value) |
|
402 | 402 | $buffer[] = var_export($key, true)."=>".min_var_export($value); |
403 | - return "[".implode(",",$buffer)."]"; |
|
403 | + return "[".implode(",", $buffer)."]"; |
|
404 | 404 | } else |
405 | 405 | return var_export($input, true); |
406 | 406 | } |
407 | 407 | } |
408 | 408 | |
409 | -if(!function_exists('rrmdir')) { |
|
409 | +if (!function_exists('rrmdir')) { |
|
410 | 410 | /* |
411 | 411 | * http://stackoverflow.com/questions/3338123/how-do-i-recursively-delete-a-directory-and-its-entire-contents-files-sub-dir |
412 | 412 | */ |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | |
26 | 26 | public function headers(array $headers) { |
27 | 27 | $newHeaders = []; |
28 | - foreach($headers as $key=>$val) { |
|
28 | + foreach ($headers as $key=>$val) { |
|
29 | 29 | $newHeaders[] = $key.": ".$val; |
30 | 30 | } |
31 | 31 | $this->headers = $newHeaders; |
@@ -47,9 +47,9 @@ discard block |
||
47 | 47 | $err = curl_error($ch); |
48 | 48 | curl_close($ch); |
49 | 49 | |
50 | - if($err) { |
|
50 | + if ($err) { |
|
51 | 51 | return $err; |
52 | - }else { |
|
52 | + } else { |
|
53 | 53 | return $response; |
54 | 54 | } |
55 | 55 | } |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | |
40 | 40 | if ($this->confirm('Do you have setting the database configuration at .env ?')) { |
41 | 41 | |
42 | - if (! file_exists(public_path('vendor')) ) { |
|
42 | + if (!file_exists(public_path('vendor'))) { |
|
43 | 43 | mkdir(public_path('vendor')); |
44 | 44 | } |
45 | 45 | |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | /* |
53 | 53 | * Create CBPlugins |
54 | 54 | */ |
55 | - if(!file_exists(app_path("CBPlugins"))) { |
|
55 | + if (!file_exists(app_path("CBPlugins"))) { |
|
56 | 56 | mkdir(app_path("CBPlugins")); |
57 | 57 | } |
58 | 58 | |
@@ -61,11 +61,11 @@ discard block |
||
61 | 61 | * We need it to change default laravel local filesystem from storage to public |
62 | 62 | * We won't use symlink because of a security issue in many server |
63 | 63 | */ |
64 | - if(!file_exists(public_path("storage"))) { |
|
64 | + if (!file_exists(public_path("storage"))) { |
|
65 | 65 | $this->info("Create storage directory on /public"); |
66 | 66 | mkdir(public_path("storage")); |
67 | - file_put_contents(public_path("storage/.gitignore"),"!.gitignore"); |
|
68 | - file_put_contents(public_path("storage/index.html")," "); |
|
67 | + file_put_contents(public_path("storage/.gitignore"), "!.gitignore"); |
|
68 | + file_put_contents(public_path("storage/index.html"), " "); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | /* |
@@ -74,8 +74,8 @@ discard block |
||
74 | 74 | * Disable php execution on /vendor/* |
75 | 75 | */ |
76 | 76 | $this->info("Tweak some security for your laravel"); |
77 | - file_put_contents(base_path(".htaccess"), "\n\n# Generated by CRUDBooster\nServerSignature Off\nIndexIgnore *\nRewriteRule ^(.*)/vendor/.*\.(php|rb|py)$ - [F,L,NC]\nRewriteRule ^vendor/.*\.(php|rb|py)$ - [F,L,NC]\n<FilesMatch \"^\.\">\nOrder allow,deny\nDeny from all\n</FilesMatch>",FILE_APPEND); |
|
78 | - file_put_contents(public_path(".htaccess"), "\n\n# Generated by CRUDBooster\nServerSignature Off\nIndexIgnore *\nRewriteRule ^(.*)/vendor/.*\.(php|rb|py)$ - [F,L,NC]\nRewriteRule ^vendor/.*\.(php|rb|py)$ - [F,L,NC]\n<FilesMatch \"^\.\">\nOrder allow,deny\nDeny from all\n</FilesMatch>",FILE_APPEND); |
|
77 | + file_put_contents(base_path(".htaccess"), "\n\n# Generated by CRUDBooster\nServerSignature Off\nIndexIgnore *\nRewriteRule ^(.*)/vendor/.*\.(php|rb|py)$ - [F,L,NC]\nRewriteRule ^vendor/.*\.(php|rb|py)$ - [F,L,NC]\n<FilesMatch \"^\.\">\nOrder allow,deny\nDeny from all\n</FilesMatch>", FILE_APPEND); |
|
78 | + file_put_contents(public_path(".htaccess"), "\n\n# Generated by CRUDBooster\nServerSignature Off\nIndexIgnore *\nRewriteRule ^(.*)/vendor/.*\.(php|rb|py)$ - [F,L,NC]\nRewriteRule ^vendor/.*\.(php|rb|py)$ - [F,L,NC]\n<FilesMatch \"^\.\">\nOrder allow,deny\nDeny from all\n</FilesMatch>", FILE_APPEND); |
|
79 | 79 | |
80 | 80 | |
81 | 81 | $this->info('Dumping the autoloaded files and reloading all new files...'); |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | } |
25 | 25 | |
26 | 26 | public function getRoleByName($roleName) { |
27 | - return $this->find("cb_roles",['name'=>$roleName]); |
|
27 | + return $this->find("cb_roles", ['name'=>$roleName]); |
|
28 | 28 | } |
29 | 29 | |
30 | 30 | public function fcm() { |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | } |
41 | 41 | |
42 | 42 | public function getDeveloperUrl($path = null) { |
43 | - $path = ($path)?"/".trim($path,"/"):null; |
|
43 | + $path = ($path) ? "/".trim($path, "/") : null; |
|
44 | 44 | return url("developer/".getSetting("developer_path")).$path; |
45 | 45 | } |
46 | 46 | |
@@ -57,16 +57,16 @@ discard block |
||
57 | 57 | } |
58 | 58 | |
59 | 59 | public function getAdminPath() { |
60 | - return getSetting("ADMIN_PATH","admin"); |
|
60 | + return getSetting("ADMIN_PATH", "admin"); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | public function getAdminUrl($path = null) { |
64 | - $path = ($path)?"/".trim($path,"/"):null; |
|
64 | + $path = ($path) ? "/".trim($path, "/") : null; |
|
65 | 65 | return url($this->getAdminPath()).$path; |
66 | 66 | } |
67 | 67 | |
68 | 68 | public function getAppName() { |
69 | - return getSetting("APP_NAME", env("APP_NAME","CRUDBOOSTER")); |
|
69 | + return getSetting("APP_NAME", env("APP_NAME", "CRUDBOOSTER")); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | /** |
@@ -80,16 +80,16 @@ discard block |
||
80 | 80 | */ |
81 | 81 | private function uploadFileProcess($filename, $extension, $file, $encrypt = true, $resize_width = null, $resize_height = null) |
82 | 82 | { |
83 | - if(in_array($extension,cbConfig("UPLOAD_FILE_EXTENSION_ALLOWED"))) { |
|
83 | + if (in_array($extension, cbConfig("UPLOAD_FILE_EXTENSION_ALLOWED"))) { |
|
84 | 84 | $file_path = cbConfig("UPLOAD_PATH_FORMAT"); |
85 | - $file_path = str_replace("{Y}",date('Y'), $file_path); |
|
85 | + $file_path = str_replace("{Y}", date('Y'), $file_path); |
|
86 | 86 | $file_path = str_replace("{m}", date('m'), $file_path); |
87 | 87 | $file_path = str_replace("{d}", date("d"), $file_path); |
88 | 88 | |
89 | 89 | //Create Directory Base On Template |
90 | 90 | Storage::makeDirectory($file_path); |
91 | - Storage::put($file_path."/index.html"," ","public"); |
|
92 | - Storage::put($file_path."/.gitignore","!.gitignore","public"); |
|
91 | + Storage::put($file_path."/index.html", " ", "public"); |
|
92 | + Storage::put($file_path."/.gitignore", "!.gitignore", "public"); |
|
93 | 93 | |
94 | 94 | if ($encrypt == true) { |
95 | 95 | $filename = md5(strRandom(5)).'.'.$extension; |
@@ -97,17 +97,17 @@ discard block |
||
97 | 97 | $filename = slug($filename, '_').'.'.$extension; |
98 | 98 | } |
99 | 99 | |
100 | - if($resize_width || $resize_height) { |
|
100 | + if ($resize_width || $resize_height) { |
|
101 | 101 | $this->resizeImage($file, $file_path.'/'.$filename, $resize_width, $resize_height); |
102 | 102 | return $file_path.'/'.$filename; |
103 | - }else{ |
|
103 | + } else { |
|
104 | 104 | if (Storage::putFileAs($file_path, $file, $filename, 'public')) { |
105 | 105 | return $file_path.'/'.$filename; |
106 | 106 | } else { |
107 | 107 | throw new \Exception("Something went wrong, file can't upload!"); |
108 | 108 | } |
109 | 109 | } |
110 | - }else{ |
|
110 | + } else { |
|
111 | 111 | throw new \Exception("The file format is not allowed!"); |
112 | 112 | } |
113 | 113 | } |
@@ -123,16 +123,16 @@ discard block |
||
123 | 123 | { |
124 | 124 | $fileData = base64_decode($base64_value); |
125 | 125 | $mime_type = finfo_buffer(finfo_open(), $fileData, FILEINFO_MIME_TYPE); |
126 | - if($mime_type) { |
|
127 | - if($mime_type = explode('/', $mime_type)) { |
|
126 | + if ($mime_type) { |
|
127 | + if ($mime_type = explode('/', $mime_type)) { |
|
128 | 128 | $ext = $mime_type[1]; |
129 | - if($filename && $ext) { |
|
129 | + if ($filename && $ext) { |
|
130 | 130 | return $this->uploadFileProcess($filename, $ext, $fileData, $encrypt, $resize_width, $resize_height); |
131 | 131 | } |
132 | - }else { |
|
132 | + } else { |
|
133 | 133 | throw new \Exception("Mime type not found"); |
134 | 134 | } |
135 | - }else{ |
|
135 | + } else { |
|
136 | 136 | throw new \Exception("Mime type not found"); |
137 | 137 | } |
138 | 138 | } |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | $filename = $file->getClientOriginalName(); |
153 | 153 | $ext = strtolower($file->getClientOriginalExtension()); |
154 | 154 | |
155 | - if($filename && $ext) { |
|
155 | + if ($filename && $ext) { |
|
156 | 156 | return $this->uploadFileProcess($filename, $ext, $file, $encrypt, $resize_width, $resize_height); |
157 | 157 | } |
158 | 158 | |
@@ -187,29 +187,29 @@ discard block |
||
187 | 187 | if ($resize_width && $resize_height) { |
188 | 188 | $img->fit($resize_width, $resize_height); |
189 | 189 | |
190 | - } elseif ($resize_width && ! $resize_height) { |
|
190 | + } elseif ($resize_width && !$resize_height) { |
|
191 | 191 | |
192 | - $img->resize($resize_width, null, function ($constraint) { |
|
192 | + $img->resize($resize_width, null, function($constraint) { |
|
193 | 193 | $constraint->aspectRatio(); |
194 | 194 | }); |
195 | 195 | |
196 | - } elseif (! $resize_width && $resize_height) { |
|
196 | + } elseif (!$resize_width && $resize_height) { |
|
197 | 197 | |
198 | - $img->resize(null, $resize_height, function ($constraint) { |
|
198 | + $img->resize(null, $resize_height, function($constraint) { |
|
199 | 199 | $constraint->aspectRatio(); |
200 | 200 | }); |
201 | 201 | |
202 | 202 | } else { |
203 | 203 | |
204 | 204 | if ($img->width() > cbConfig("DEFAULT_IMAGE_MAX_WIDTH_RES")) { |
205 | - $img->resize(cbConfig("DEFAULT_IMAGE_MAX_WIDTH_RES"), null, function ($constraint) { |
|
205 | + $img->resize(cbConfig("DEFAULT_IMAGE_MAX_WIDTH_RES"), null, function($constraint) { |
|
206 | 206 | $constraint->aspectRatio(); |
207 | 207 | }); |
208 | 208 | } |
209 | 209 | } |
210 | 210 | |
211 | 211 | Storage::put($fullFilePath, $img, 'public'); |
212 | - }else{ |
|
212 | + } else { |
|
213 | 213 | throw new \Exception("The file format is not allowed!"); |
214 | 214 | } |
215 | 215 | } |
@@ -322,7 +322,7 @@ discard block |
||
322 | 322 | $validator = Validator::make($input_arr, $rules, $messages); |
323 | 323 | if ($validator->fails()) { |
324 | 324 | $message = $validator->errors()->all(); |
325 | - throw new CBValidationException(implode("; ",$message)); |
|
325 | + throw new CBValidationException(implode("; ", $message)); |
|
326 | 326 | } |
327 | 327 | } |
328 | 328 | |
@@ -334,7 +334,7 @@ discard block |
||
334 | 334 | public function findPrimaryKey($table) |
335 | 335 | { |
336 | 336 | $pk = DB::getDoctrineSchemaManager()->listTableDetails($table)->getPrimaryKey(); |
337 | - if(!$pk) { |
|
337 | + if (!$pk) { |
|
338 | 338 | return null; |
339 | 339 | } |
340 | 340 | return $pk->getColumns()[0]; |
@@ -383,7 +383,7 @@ discard block |
||
383 | 383 | $string_parameters_array = explode('&', $string_parameters); |
384 | 384 | foreach ($string_parameters_array as $s) { |
385 | 385 | $part = explode('=', $s); |
386 | - if(isset($part[0]) && isset($part[1])) { |
|
386 | + if (isset($part[0]) && isset($part[1])) { |
|
387 | 387 | $name = htmlspecialchars(urldecode($part[0])); |
388 | 388 | $name = strip_tags($name); |
389 | 389 | $value = htmlspecialchars(urldecode($part[1])); |
@@ -400,16 +400,16 @@ discard block |
||
400 | 400 | |
401 | 401 | |
402 | 402 | public function routeGet($prefix, $controller) { |
403 | - $alias = str_replace("@"," ", $controller); |
|
403 | + $alias = str_replace("@", " ", $controller); |
|
404 | 404 | $alias = ucwords($alias); |
405 | - $alias = str_replace(" ","",$alias); |
|
405 | + $alias = str_replace(" ", "", $alias); |
|
406 | 406 | Route::get($prefix, ['uses' => $controller, 'as' => $alias]); |
407 | 407 | } |
408 | 408 | |
409 | 409 | public function routePost($prefix, $controller) { |
410 | - $alias = str_replace("@"," ", $controller); |
|
410 | + $alias = str_replace("@", " ", $controller); |
|
411 | 411 | $alias = ucwords($alias); |
412 | - $alias = str_replace(" ","",$alias); |
|
412 | + $alias = str_replace(" ", "", $alias); |
|
413 | 413 | Route::post($prefix, ['uses' => $controller, 'as' => $alias]); |
414 | 414 | } |
415 | 415 | |
@@ -442,7 +442,7 @@ discard block |
||
442 | 442 | |
443 | 443 | $prefix = trim($prefix, '/').'/'; |
444 | 444 | |
445 | - if(substr($controller,0,1) != "\\") { |
|
445 | + if (substr($controller, 0, 1) != "\\") { |
|
446 | 446 | $controller = "\App\Http\Controllers\\".$controller; |
447 | 447 | } |
448 | 448 |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | $data['name'] = $name; |
26 | 26 | $data['label'] = $label; |
27 | 27 | $data['required'] = $required; |
28 | - $data['encrypt'] = isset($options['encrypt'])?$options['encrypt']:true; |
|
28 | + $data['encrypt'] = isset($options['encrypt']) ? $options['encrypt'] : true; |
|
29 | 29 | return view("crudbooster::html_helper.file_uploader.index", $data); |
30 | 30 | } |
31 | 31 | |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | $data['name'] = $name; |
43 | 43 | $data['label'] = $label; |
44 | 44 | $data['required'] = $required; |
45 | - $data['encrypt'] = isset($options['encrypt'])?$options['encrypt']:true; |
|
45 | + $data['encrypt'] = isset($options['encrypt']) ? $options['encrypt'] : true; |
|
46 | 46 | @$data['resizeWidth'] = $options['resize_width']; |
47 | 47 | @$data['resizeHeight'] = $options['resize_height']; |
48 | 48 | return view("crudbooster::html_helper.image_uploader.index", $data); |
@@ -1,9 +1,9 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -cb()->routeGroupBackend(function () { |
|
4 | - cb()->routePost("upload-file",'\crocodicstudio\crudbooster\types\file\FileController@postUploadFile'); |
|
3 | +cb()->routeGroupBackend(function() { |
|
4 | + cb()->routePost("upload-file", '\crocodicstudio\crudbooster\types\file\FileController@postUploadFile'); |
|
5 | 5 | }); |
6 | 6 | |
7 | -cb()->routeGroupDeveloper(function () { |
|
8 | - cb()->routePost("upload-file",'\crocodicstudio\crudbooster\types\file\FileController@postUploadFile'); |
|
7 | +cb()->routeGroupDeveloper(function() { |
|
8 | + cb()->routePost("upload-file", '\crocodicstudio\crudbooster\types\file\FileController@postUploadFile'); |
|
9 | 9 | }); |
10 | 10 | \ No newline at end of file |
@@ -19,15 +19,15 @@ |
||
19 | 19 | try { |
20 | 20 | |
21 | 21 | cb()->validation([ |
22 | - 'userfile' => 'required|mimes:' . implode(",",config('crudbooster.UPLOAD_FILE_EXTENSION_ALLOWED')) |
|
22 | + 'userfile' => 'required|mimes:'.implode(",", config('crudbooster.UPLOAD_FILE_EXTENSION_ALLOWED')) |
|
23 | 23 | ]); |
24 | 24 | |
25 | 25 | $file = cb()->uploadFile('userfile', request("encrypt")); |
26 | 26 | |
27 | 27 | } catch (CBValidationException $e) { |
28 | - return response()->json(['status'=>false,'message'=>$e->getMessage()]); |
|
28 | + return response()->json(['status'=>false, 'message'=>$e->getMessage()]); |
|
29 | 29 | } catch (\Exception $e) { |
30 | - return response()->json(['status'=>false,'message'=>$e->getMessage()]); |
|
30 | + return response()->json(['status'=>false, 'message'=>$e->getMessage()]); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | return response()->json([ |