-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgroup_update.php
156 lines (127 loc) · 4.97 KB
/
group_update.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
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
<?php
/*
+-------------------------------------------------------------------------+
| Copyright (C) 2006 Michael Earls |
| |
| This program is free software; you can redistribute it and/or |
| modify it under the terms of the GNU General Public License |
| as published by the Free Software Foundation; either version 2 |
| of the License, or (at your option) any later version. |
| |
| This program is distributed in the hope that it will be useful, |
| but WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| GNU General Public License for more details. |
+-------------------------------------------------------------------------+
| - phpIP - http://www.phpip.net/ |
+-------------------------------------------------------------------------+
*/
ob_start();
// include the layout file
include 'layout.php';
login_check();
admin_check();
switch ($_REQUEST["mode"]) {
case "edit":
{
if (isset ($_GET['di'])) { $di = strip_tags($_GET['di']); }
// Use the myheader function from layout.php
myheader("Selecting Group");
echo "<FORM action='group_update.php?mode=update' method='post' name='edit'>";
echo "<table class=\"listTable\" style=\"width:100%\" cellpadding=\"0\" cellspacing=\"0\">";
echo "<tr class=\"tableheader\">";
echo "<td colspan=6 class=\"listCell\">GROUP UPDATE</td>";
echo "<tr class=\"listHeadRow\">";
echo "<td class=\"listCell\">IP</td>";
echo "<td class=\"listCell\">GROUP</td>";
echo "</tr>";
$pdesc = mysql_query("SELECT * FROM `NetMenu` WHERE `NetMenuId` = '$di'");
while ($row = mysql_fetch_array($pdesc))
{
if ($RowClass == "listRow2") { $RowClass = "listRow1";
} else { $RowClass = "listRow2"; }
$cur_gid = $row[groupid];
echo "<tr class=\"$RowClass\" class=\"listCell\">";
echo "<td class=\"listCell\"> $row[NetMenuCidr]<input type=\"hidden\" value=\"$di\" name=\"di\"></td>";
?>
<td class="listCell">
<select name="gid">
<?php
$val = @mysql_query("SELECT * FROM groups");
if (mysql_num_rows($val) > 0)
{
while($row = mysql_fetch_array($val))
{
$gid = $row[id];
$group = $row[group];
if ($cur_gid == $gid)
{
echo "<option value=$gid selected>$group</option>";
} else {
echo "<option value=$gid>$group</option>";
}
}
}
?>
</select>
</td>
<?php
echo "</tr>";
}
echo "</table>";
echo "<table>";
echo "<td><a href=\"javascript:document.edit.submit()\">[UPDATE]</td>";
echo "</table>";
} //end case
break;
case "update":
{
if (isset ($_POST['di'])) { $di = strip_tags($_POST['di']); }
if (isset ($_POST['gid'])) { $gid = strip_tags($_POST['gid']); }
// Use the myheader function from layout.php
myheader("Updating");
// Update NetMenu groupid
$updesc = mysql_query("UPDATE `NetMenu` SET `groupid` = '$gid' WHERE `NetMenuId` = '$di'");
// Update net_ips groupid
$UpNetIps = mysql_query("UPDATE `net_ips` SET `groupid` = '$gid' WHERE `NetCidr` = '$di'");
$SelectNetIps = mysql_query("SELECT `netaddress` FROM `net_ips` WHERE `NetCidr` = $di");
while ($row = mysql_fetch_array($SelectNetIps)) {
$UpdateAddress = mysql_query("UPDATE `addresses` SET `groupid` = '$gid' WHERE `ip` LIKE '%$row[netaddress].%'");
}
// Redirect after sql insert
?>
<h2><font color="FF0000">Updating Database, Please wait</font></h4>
<meta http-equiv=Refresh content=1;url="group_update.php">
<?php
}
break;
default:
// Use the myheader function from layout.php
myheader("Group Update");
echo "<table class=\"listTable\" style=\"width:100%\" cellpadding=\"0\" cellspacing=\"0\">";
echo "<tr class=\"tableheader\">";
echo "<td colspan=6 class=\"listCell\">GROUP</td>";
echo "<tr class=\"listHeadRow\">";
echo "<td class=\"listCell\"> </td>";
echo "<td class=\"listCell\">IP</td>";
echo "<td class=\"listCell\">GROUP</td>";
echo "</tr>";
$pdesc = mysql_query("SELECT * FROM `NetMenu` a INNER JOIN groups b ON a.groupid = b.id ORDER BY a.NetMenuId + 0");
while ($row = mysql_fetch_array($pdesc))
{
if ($RowClass == "listRow2") { $RowClass = "listRow1"; }
else { $RowClass = "listRow2"; }
$cur_gid = $row[groupid];
$cur_group = $row[group];
echo "<tr class=\"$RowClass\" class=\"listCell\">";
echo "<td class=\"listCell\" width=\"20\"> <a href=\"group_update.php?mode=edit&di=$row[NetMenuId]\">[Edit]</a></td>";
echo "<td class=\"listCell\"> $row[NetMenuCidr]</td>";
echo "<td class=\"listCell\"> $row[group]</td>";
echo "</tr>";
}
echo "</table>";
// Use the footer function from layout.php
footer();
} // end switch
//------------------------------------------------------------------------------------------
?>