/
sh.php
70 lines (45 loc) · 1.46 KB
/
sh.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php
/**
* @Author: Griffen Fargo
* @Date: 2016-01-26 00:20:13
* @Last Modified by: Griffen Fargo
* @Last Modified time: 2016-04-11 19:30:09
*/
// Load Composer Plugins
require 'vendor/autoload.php';
use AdamBrett\ShellWrapper\Command;
use AdamBrett\ShellWrapper\Command\Param;
use AdamBrett\ShellWrapper\Runners\Exec;
use AdamBrett\ShellWrapper\Runners\ShellExec;
use AdamBrett\ShellWrapper\Runners\System;
use AdamBrett\ShellWrapper\Runners\ReturnValue;
use AdamBrett\ShellWrapper\Command\Builder as CommandBuilder;
$shell = new ShellExec();
$system = new System();
$cmd = $_POST['command'];
// XDebug Stuff
if ($cmd == 'xdebug') {
$xdebugCommand = new Command($cmd);
// $debugCheck = new CommandBuilder('php');
// $debugCheck->addFlag('m')
// ->addFlag('c |')
// // ->addArgument('|')
// ->addArgument('grep xdebug');
// // ->addArgument('xdebug');
$debugCheck = new Command('php -m -c | grep xdebug');
$check = $system->run($debugCheck);
echo "current check: " . $check;
$inipath = php_ini_loaded_file();
if ($inipath) {
echo 'Loaded php.ini: ' . $inipath;
} else {
echo 'A php.ini file is not loaded';
}
if ( empty($check) || $check == null ) {
// echo "CHECK IS NULL - Run DEBUG ON";
$shell->run(new Command('xdebug_on'));
} else {
// echo "RUN XDEBUG OFF";
$shell->run(new Command('xdebug_off'));
}
}