[go: up one dir, main page]

File: index.php

package info (click to toggle)
sbnc 1.3.9-3
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 8,156 kB
  • ctags: 4,719
  • sloc: ansic: 20,379; cpp: 14,175; sh: 12,783; tcl: 6,025; php: 448; makefile: 430; perl: 46; awk: 25
file content (105 lines) | stat: -rw-r--r-- 2,122 bytes parent folder | download | duplicates (4)
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
<?php

include_once('sbnc.php');

$sbnc = new SBNC("192.168.5.6", 9000, "test", "******");

if (!isset($_REQUEST['invoke'])) {
	$result = $sbnc->Call("commands");

	if (IsError($result)) {
		die(GetCode($result));
	}

	$commands = GetResult($result);

	natsort($commands);

	$params_calls = array();

	foreach ($commands as $command) {
		if ($command == "") { break; }

		array_push( $params_calls, array( 'params', array( $command ) ) );
	}

	$result = $sbnc->MultiCall($params_calls);

	if (IsError($result)) {
		die(GetCode($result));
	}

	$i = 0;

	foreach ($commands as $command) {
		if (IsError($result[$i])) {
			die(GetCode($result[$i]));
		}

		echo '<a href="index.php?invoke=' . $command . '">' . $command . '</a>' . ' ' . implode(' ', $result[$i]) . '<br>' . "\n";

		$i++;
	}
} else if (isset($_REQUEST['run'])) {
	$params = array();

	$i = 0;
	while (true) {
		if (isset($_REQUEST['param' . $i])) {
			array_push($params, $_REQUEST['param' . $i]);
		} else {
			break;
		}

		$i++;
	}

	if (isset($_REQUEST['user']) && $_REQUEST['user'] != '') {
		$user = $_REQUEST['user'];
	} else {
		$user = FALSE;
	}

	$result = $sbnc->CallAs($user, $_REQUEST['invoke'], $params);

	echo 'Code: ' . GetCode($result) . '<br>';
	echo 'Return value: <pre>';
	var_dump($result);
	echo '</pre><br>';

	echo '<br><br><a href="index.php">Back</a>';	
} else {
	$result = $sbnc->Call("params", array( $_REQUEST['invoke'] ));

	if (IsError($result)) {
		die(GetCode($result));
	}

	echo '<form>';
	echo 'Command: ' . $_REQUEST['invoke'] . '<br><br>';
	echo 'User: <input name="user" /><br><br>';
	echo 'Parameters:<br>';
	echo '<input type="hidden" name="invoke" value="' . $_REQUEST['invoke'] . '" />';
	echo '<input type="hidden" name="run" value="1" />';

	$i = 0;
	foreach (GetResult($result) as $param) {
		if ($param == "") { break; }
		echo $param . ' <input name="param' . $i . '" /><br>';
		$i++;
	}

	if ($i == 0) {
		echo 'No parameters can be specified for this command.';
	}

	echo '<br><input type="submit" value="Invoke">';

	echo '</form>';

	echo '<br><br><a href="index.php">Back</a>';	
}

$sbnc->Destroy();

?>