| 1 |
<? |
|---|
| 2 |
/* |
|---|
| 3 |
--------------------------------------------------------------------------- |
|---|
| 4 |
VoicePulse Global Provisioning System (VGPS) |
|---|
| 5 |
by Ketan Patel |
|---|
| 6 |
Copyright (C) 2006 VoicePulse Inc. |
|---|
| 7 |
|
|---|
| 8 |
This program is free software, distributed under the terms of the GNU General |
|---|
| 9 |
Public License Version 2. See the LICENSE file at the top of the source tree. |
|---|
| 10 |
--------------------------------------------------------------------------- |
|---|
| 11 |
*/ |
|---|
| 12 |
|
|---|
| 13 |
require('client_lib.php'); |
|---|
| 14 |
$models = list_models(); |
|---|
| 15 |
$generic_settings = list_generic_settings(); |
|---|
| 16 |
|
|---|
| 17 |
switch($op) { |
|---|
| 18 |
case "set_device": |
|---|
| 19 |
$result = set_device($model, $mac, $location, $note); |
|---|
| 20 |
break; |
|---|
| 21 |
case "list_devices": |
|---|
| 22 |
$devices_result = list_devices(); |
|---|
| 23 |
$devices_filtered = array(); |
|---|
| 24 |
foreach($devices_result as $device) { |
|---|
| 25 |
if(filter_device($device, $model, $mac, $location, $note)) { |
|---|
| 26 |
array_push($devices_filtered, $device); |
|---|
| 27 |
} |
|---|
| 28 |
} |
|---|
| 29 |
break; |
|---|
| 30 |
case "list_device_settings": |
|---|
| 31 |
$settings_result = list_device_settings($mac); |
|---|
| 32 |
break; |
|---|
| 33 |
case "set_setting": |
|---|
| 34 |
foreach($settings_array as $key=>$val) { |
|---|
| 35 |
if(!is_null($val) and strlen($val) > 0) { |
|---|
| 36 |
$result .= set_setting($mac, $key, $val); |
|---|
| 37 |
} |
|---|
| 38 |
} |
|---|
| 39 |
break; |
|---|
| 40 |
} |
|---|
| 41 |
|
|---|
| 42 |
function filter_device($device, $model, $mac, $location, $note) { |
|---|
| 43 |
$match = true; |
|---|
| 44 |
if(!is_null($model) && strlen($model) > 0) { |
|---|
| 45 |
if(!is_substr($device[tag], $model)) { |
|---|
| 46 |
$match = false; |
|---|
| 47 |
} |
|---|
| 48 |
} |
|---|
| 49 |
if(!is_null($mac) && strlen($mac) > 0) { |
|---|
| 50 |
if(!is_substr($device[mac_address], $mac)) { |
|---|
| 51 |
$match = false; |
|---|
| 52 |
} |
|---|
| 53 |
} |
|---|
| 54 |
if(!is_null($location) && strlen($location) > 0) { |
|---|
| 55 |
if(!is_substr($device[location], $location)) { |
|---|
| 56 |
$match = false; |
|---|
| 57 |
} |
|---|
| 58 |
} |
|---|
| 59 |
if(!is_null($note) && strlen($note) > 0) { |
|---|
| 60 |
if(!is_substr($device[note], $note)) { |
|---|
| 61 |
$match = false; |
|---|
| 62 |
} |
|---|
| 63 |
} |
|---|
| 64 |
return $match; |
|---|
| 65 |
} |
|---|
| 66 |
?> |
|---|
| 67 |
<head> |
|---|
| 68 |
<title>VoicePulse Global Provisioning System</title> |
|---|
| 69 |
</head> |
|---|
| 70 |
<? |
|---|
| 71 |
if(!is_null($result) && strlen($result) > 0) { |
|---|
| 72 |
$color = "black"; |
|---|
| 73 |
if(strpos($result, "ERROR") === 0) { |
|---|
| 74 |
$color = "red"; |
|---|
| 75 |
} |
|---|
| 76 |
if(strpos($result, "SUCCESS") === 0) { |
|---|
| 77 |
$color = "green"; |
|---|
| 78 |
} |
|---|
| 79 |
echo "<font color=\"$color\">$result</font>"; |
|---|
| 80 |
} |
|---|
| 81 |
?> |
|---|
| 82 |
<form> |
|---|
| 83 |
<table> |
|---|
| 84 |
<tr colspan="2"> |
|---|
| 85 |
<td>Add Device</td> |
|---|
| 86 |
</tr> |
|---|
| 87 |
<tr> |
|---|
| 88 |
<td>Model:</td> |
|---|
| 89 |
<td> |
|---|
| 90 |
<select name="model"> |
|---|
| 91 |
<option value="">Select one...</option> |
|---|
| 92 |
<? |
|---|
| 93 |
foreach($models as $model) { |
|---|
| 94 |
echo "<option value=\"$model[tag]\">$model[name]</option>"; |
|---|
| 95 |
} |
|---|
| 96 |
?> |
|---|
| 97 |
</select> |
|---|
| 98 |
</td> |
|---|
| 99 |
</tr> |
|---|
| 100 |
<tr> |
|---|
| 101 |
<td>MAC:</td> |
|---|
| 102 |
<td><input type="text" name="mac"></td> |
|---|
| 103 |
</tr> |
|---|
| 104 |
<tr> |
|---|
| 105 |
<td>Location:</td> |
|---|
| 106 |
<td><input type="text" name="location"></td> |
|---|
| 107 |
</tr> |
|---|
| 108 |
<tr> |
|---|
| 109 |
<td>Note:</td> |
|---|
| 110 |
<td><input type="text" name="note"></td> |
|---|
| 111 |
</tr> |
|---|
| 112 |
<tr> |
|---|
| 113 |
<td></td> |
|---|
| 114 |
<td><input type="submit"></td> |
|---|
| 115 |
</tr> |
|---|
| 116 |
</table> |
|---|
| 117 |
<input type="hidden" name="op" value="set_device"> |
|---|
| 118 |
</form> |
|---|
| 119 |
<form> |
|---|
| 120 |
<table> |
|---|
| 121 |
<tr colspan="2"> |
|---|
| 122 |
<td>List Devices</td> |
|---|
| 123 |
</tr> |
|---|
| 124 |
<tr> |
|---|
| 125 |
<td>Model:</td> |
|---|
| 126 |
<td> |
|---|
| 127 |
<select name="model"> |
|---|
| 128 |
<option value="">All</option> |
|---|
| 129 |
<? |
|---|
| 130 |
foreach($models as $model) { |
|---|
| 131 |
echo "<option value=\"$model[tag]\">$model[name]</option>"; |
|---|
| 132 |
} |
|---|
| 133 |
?> |
|---|
| 134 |
</select> |
|---|
| 135 |
</td> |
|---|
| 136 |
</tr> |
|---|
| 137 |
<tr> |
|---|
| 138 |
<td>MAC:</td> |
|---|
| 139 |
<td><input type="text" name="mac"></td> |
|---|
| 140 |
</tr> |
|---|
| 141 |
<tr> |
|---|
| 142 |
<td>Location:</td> |
|---|
| 143 |
<td><input type="text" name="location"></td> |
|---|
| 144 |
</tr> |
|---|
| 145 |
<tr> |
|---|
| 146 |
<td>Note:</td> |
|---|
| 147 |
<td><input type="text" name="note"></td> |
|---|
| 148 |
</tr> |
|---|
| 149 |
<tr> |
|---|
| 150 |
<td></td> |
|---|
| 151 |
<td><input type="submit"></td> |
|---|
| 152 |
</tr> |
|---|
| 153 |
</table> |
|---|
| 154 |
<input type="hidden" name="op" value="list_devices"> |
|---|
| 155 |
</form> |
|---|
| 156 |
<form action="index.php"> |
|---|
| 157 |
<? |
|---|
| 158 |
if($devices_filtered) { |
|---|
| 159 |
?> |
|---|
| 160 |
Matching Devices<br> |
|---|
| 161 |
<table> |
|---|
| 162 |
<tr><td>MAC</td><td>Model</td><td>Location</td><td>Note</td><td></td></tr> |
|---|
| 163 |
<? |
|---|
| 164 |
foreach($devices_filtered as $device) { |
|---|
| 165 |
echo "<tr><td>$device[mac_address]</td><td>$device[name]</td><td>$device[location]</td><td>$device[note]</td><td><form><input type=\"hidden\" name=\"mac\" value=\"$device[mac_address]\"><input type=\"hidden\" name=\"op\" value=\"list_device_settings\"><input type=\"submit\" value=\"Settings\"></form>"; |
|---|
| 166 |
} |
|---|
| 167 |
?> |
|---|
| 168 |
</table> |
|---|
| 169 |
<? |
|---|
| 170 |
} |
|---|
| 171 |
?> |
|---|
| 172 |
<br> |
|---|
| 173 |
<? |
|---|
| 174 |
if($settings_result) { |
|---|
| 175 |
?> |
|---|
| 176 |
Device Settings<br> |
|---|
| 177 |
<form> |
|---|
| 178 |
<table> |
|---|
| 179 |
<? |
|---|
| 180 |
foreach($generic_settings as $generic_setting) { |
|---|
| 181 |
$profile_name = $generic_setting[name]; |
|---|
| 182 |
$profile_key = $generic_setting[tag]; |
|---|
| 183 |
$profile_value = ""; |
|---|
| 184 |
foreach($settings_result as $key=>$val) { |
|---|
| 185 |
if($profile_key == $key) { |
|---|
| 186 |
$profile_value = $val; |
|---|
| 187 |
break; |
|---|
| 188 |
} |
|---|
| 189 |
} |
|---|
| 190 |
echo "<tr><td>$profile_name</td><td><input type=\"text\" name=\"settings_array[$profile_key]\" value=\"$profile_value\"></td></tr>"; |
|---|
| 191 |
} |
|---|
| 192 |
?> |
|---|
| 193 |
</table> |
|---|
| 194 |
<br> |
|---|
| 195 |
<input type="submit" name="button" value="Save Device Settings"> |
|---|
| 196 |
<input type="hidden" name="mac" value="<? echo $mac ?>"> |
|---|
| 197 |
<input type="hidden" name="op" value="set_setting"> |
|---|
| 198 |
</form> |
|---|
| 199 |
<? |
|---|
| 200 |
} |
|---|
| 201 |
?> |
|---|