-
Notifications
You must be signed in to change notification settings - Fork 0
/
wp-term.php
33 lines (25 loc) · 706 Bytes
/
wp-term.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?php
require __DIR__ . '/bootstrap.php';
function json_response($array)
{
header('Content-Type: application/json');
echo json_encode($array);
exit;
}
$cmd = isset($_GET['cmd']) ? $_GET['cmd'] : '';
use Ockcyp\WpTerm\Parser\Command as CommandParser;
$commandParser = new CommandParser;
if (!$commandParser->parse($cmd)) {
json_response(array('msg' => "Please provide command in 'cmd' parameter."));
}
$command = $commandParser->get();
if (!$command) {
json_response(array('msg' => "Invalid command '$cmd'"));
}
try {
$result = $command->execute();
$result['cmd'] = $cmd;
} catch (Exception $e) {
$result = array('msg' => $e->getMessage());
}
json_response($result);