-
Notifications
You must be signed in to change notification settings - Fork 0
/
outletcontrol.php
39 lines (23 loc) · 875 Bytes
/
outletcontrol.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
<?php
// copyright license/LICENSE
//SEND MODIFYING STATE COMMAND
include("outlet_values.php");
//DYNAMIC VALUES
//$num = 1; //outlet port # (1-8)
$num = $_REQUEST['outletnum'];
//echo $num; //echo vs return seem to change whether it returns once or twice, also return fails to pass anything but ""
//if ($num) { echo 1; } else { echo 0;}
//$num = 8;
$op = ".".$num; //outlet port # (1-8)
//$cmd = 3; //state change: 1 immediateon, 2 immediateoff, 3 reboot
$cmd = $_REQUEST['commandnum'];
$oid = $pre.$det.$op;
//FUNCTIONS
//READ STATUS
$status = snmp3_real_walk($ip, $sec_name, $sec_level, $auth_protocol, $auth_passphrase, $priv_protocol, $priv_passphrase, $oid);
//CHANGE STATE
$result = snmpset($ip, $comm, $oid, 'i', $cmd); //true/false or 1/0?
//RETURN VALUES
//echo "Outlet: ".$num." was ".$result." turned ".$cmd;
//return $result;
echo $result;