summaryrefslogtreecommitdiffstats
path: root/usr/local/sbin/pfSsh.php
blob: 885e38e1f416c23c01f74dc98b6a0bdd745b7bba (plain)
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
#!/usr/local/bin/php -f
 
<?php

echo "Starting the pfSense shell system";

echo ".";
require("globals.inc");
$g['booting'] = true;
require("functions.inc");
echo ".";
require("config.inc");
echo ".";
$g['booting'] = false;

$fp = fopen('php://stdin', 'r');

echo ".\n\n";

$shell_active = true;

echo "Example commands:\n\n";
echo "    print_r(\$config);\n";
echo "    \$config['interfaces']['lan']['ipaddr'] = \"192.168.1.1\";\n";
echo "    write_config();\n";
echo "    multiline\n";
echo "    exit";

while($shell_active == true) {
        echo "\n\npfSense shell> ";
        $command = chop(fgets($fp));
        if($command == "exit") {
                $shell_active = false;
                echo "\n";
                break;
		}
		if($command == "multiline" or $command == "ml") {
			echo "\nmultiline mode enabled.  enter EOF on a blank line to execute.\n\n";
			$command = "";
			$mlcommand = "";
			$xxxyzyz = 0;
			while($command <> "EOF") {
				echo "pfSense multiline shell[$xxxyzyz]> ";
		        $command = chop(fgets($fp));
		        if($command == "exit") 
		        	die;
		        if($command <> "EOF") 
		        	$mlcommand .= $command;
		        $xxxyzyz++;
			}
			$command = $mlcommand;
		}
		if($command) {
			echo "\n";
	        eval($command); 
	    }
}
OpenPOWER on IntegriCloud