-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy patharuba_ap_prov.php
67 lines (52 loc) · 1.98 KB
/
aruba_ap_prov.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
<?php
if (!isset($_GET["post"])) {
echo "<h1>Aruba AP provisioning via CSV file</h1>";
echo "<form action='?post=1' method='post' enctype='multipart/form-data'>";
echo "<input type='file' name='csv' />";
echo "<br />(column field names should be on the first row)";
echo "<br />Field AP name: <input type='text' name='ap_name' value='CINR' />";
echo "<br />Field MAC adres: <input type='text' name='mac_addr' value='Macadres' />";
echo "<br />Field AP group: <input type='text' name='ap_group' value='AP group' />";
echo "<br />Comma separator: <input type='text' name='separator' value=';' />";
echo "<br /><br /><input type='submit' value='OK' />";
echo "</form>";
}
else {
$in = file_get_contents($_FILES['csv']['tmp_name']);
$in = explode("\n",$in);
$tmp = explode($_POST["separator"], $in[0]);
$col_names = array("ap_name","ap_group","mac_addr");
$col_pos = array();
$i = 0;
foreach ($tmp as $col) {
foreach ($col_names as $cname) {
if ($_POST[$cname] == trim($col)) {
$col_pos[$cname] = $i;
}
}
$i++;
}
$i = 0;
foreach ($in as $line) {
if ($i == 0) {
$i++;
continue;
}
$tmp = explode($_POST["separator"],$line);
$mac = str_replace(":", "", str_replace("-", "", str_replace(".", "", strtolower($tmp[$col_pos["mac_addr"]]))));
if ($mac == "") continue;
$mac = "{$mac[0]}{$mac[1]}:{$mac[2]}{$mac[3]}:{$mac[4]}{$mac[5]}:{$mac[6]}{$mac[7]}:{$mac[8]}{$mac[9]}:{$mac[10]}{$mac[11]}";
$name = trim($tmp[$col_pos["ap_name"]]);
$group = trim($tmp[$col_pos["ap_group"]]);
if ($group == "") continue;
echo nl2br('clear provisioning-ap-list
provision-ap
read-bootinfo ap-name ' . $mac . '
copy-provisioning-params ap-name ' . $mac . '
ap-name ' . $name . '
ap-group ' . $group . '
reprovision ap-name ' . $mac . '
');
$i++;
}
}