Răsfoiți Sursa

editing of networks is placed on a separate page

Roman Dmitriev 2 ani în urmă
părinte
comite
384a7bf38a

+ 0 - 270
html/admin/customers/control-subnets.php

@@ -1,270 +0,0 @@
-<?php
-
-require_once($_SERVER['DOCUMENT_ROOT'] . "/inc/auth.php");
-require_once($_SERVER['DOCUMENT_ROOT'] . "/inc/languages/" . HTML_LANG . ".php");
-
-if (isset($_POST["s_remove"])) {
-    if (!empty($_POST["s_id"])) {
-        $s_id = $_POST["s_id"];
-        foreach ($s_id as $key => $net_id) {
-            if (isset($net_id)) {
-                LOG_INFO($db_link, "Remove subnet id: $net_id");
-                delete_record($db_link, "subnets", "id=" . $net_id);
-            }
-        }
-    }
-    header("Location: " . $_SERVER["REQUEST_URI"]);
-    exit;
-}
-
-if (isset($_POST['s_save'])) {
-    if (!empty($_POST["s_id"])) {
-        $s_id = $_POST["s_id"];
-        foreach ($s_id as $key => $net_id) {
-            if (isset($net_id)) {
-                $new['subnet'] = trim($_POST['s_subnet'][$net_id]);
-                $new['office'] = $_POST['s_office'][$net_id] * 1;
-                $new['hotspot'] = $_POST['s_hotspot'][$net_id] * 1;
-                $new['vpn'] = $_POST['s_vpn'][$net_id] * 1;
-                $new['free'] = $_POST['s_free'][$net_id] * 1;
-                $new['dhcp'] = $_POST['s_dhcp'][$net_id] * 1;
-                $new['dhcp_lease_time'] = $_POST['s_lease_time'][$net_id] * 1;
-                $new['static'] = $_POST['s_static'][$net_id] * 1;
-                $new['discovery'] = $_POST['s_discovery'][$net_id] * 1;
-                $new['dhcp_update_hostname'] = $_POST['s_dhcp_update'][$net_id] * 1;
-                $new['comment'] = trim($_POST['s_comment'][$net_id]);
-                $range = cidrToRange($new['subnet']);
-                $first_user_ip = $range[0];
-                $last_user_ip = $range[1];
-                $cidr = $range[2][1];
-                if (isset($cidr) and $cidr <= 32) {
-                    $new['subnet'] = $first_user_ip . '/' . $cidr;
-                } else {
-                    $new['subnet'] = '';
-                }
-                $new['ip_int_start'] = ip2long($first_user_ip);
-                $new['ip_int_stop'] = ip2long($last_user_ip);
-                $new['dhcp_start'] = ip2long(trim($_POST['s_dhcp_start'][$net_id]));
-                $new['dhcp_stop'] = ip2long(trim($_POST['s_dhcp_stop'][$net_id]));
-                $dhcp_fail = 0;
-                if (!isset($new['dhcp_start']) or $new['dhcp_start'] == 0) {
-                    $dhcp_fail = 1;
-                }
-                if (!isset($new['dhcp_stop']) or $new['dhcp_stop'] == 0) {
-                    $dhcp_fail = 1;
-                }
-                if (!$dhcp_fail and ($new['dhcp_start'] - $new['ip_int_stop'] >= 0)) {
-                    $dhcp_fail = 1;
-                }
-                if (!$dhcp_fail and ($new['dhcp_start'] - $new['ip_int_start'] <= 0)) {
-                    $dhcp_fail = 1;
-                }
-                if (!$dhcp_fail and ($new['dhcp_stop'] - $new['ip_int_stop'] >= 0)) {
-                    $dhcp_fail = 1;
-                }
-                if (!$dhcp_fail and ($new['dhcp_stop'] - $new['ip_int_start'] <= 0)) {
-                    $dhcp_fail = 1;
-                }
-                if (!$dhcp_fail and ($new['dhcp_start'] - $new['dhcp_stop'] >= 0)) {
-                    $dhcp_fail = 1;
-                }
-                if ($dhcp_fail) {
-                    $new['dhcp_start'] = ip2long($range[3]);
-                    $new['dhcp_stop'] = ip2long($range[4]);
-                }
-                $gateway = ip2long(trim($_POST['s_gateway'][$net_id]));
-                if (!isset($gateway)) {
-                    $gateway = $range[5];
-                }
-                $new['gateway'] = $gateway;
-                if ($new['hotspot']) {
-                    $new['dhcp_update_hostname'] = 0;
-                    $new['discovery'] = 0;
-                    $new['vpn'] = 0;
-                }
-                if ($new['vpn']) {
-                    $new['discovery'] = 0;
-                    $new['dhcp'] = 0;
-                }
-                if ($new['office']) {
-                    $new['free'] = 0;
-                }
-                if (!$new['office']) {
-                    $new['discovery'] = 0;
-                    $new['dhcp'] = 0;
-                    $new['static'] = 0;
-                    $new['dhcp_update_hostname'] = 0;
-                    $new['gateway'] = 0;
-                    $new['dhcp_start'] = 0;
-                    $new['dhcp_stop'] = 0;
-                }
-                update_record($db_link, "subnets", "id='$net_id'", $new);
-            }
-        }
-    }
-    header("Location: " . $_SERVER["REQUEST_URI"]);
-    exit;
-}
-
-if (isset($_POST["s_create"])) {
-    $new_subnet = $_POST["s_create_subnet"];
-    if (isset($new_subnet)) {
-        $new['subnet'] = trim($new_subnet);
-        $range = cidrToRange($new['subnet']);
-        $first_user_ip = $range[0];
-        $last_user_ip = $range[1];
-        $cidr = $range[2][1];
-        if (isset($cidr) and $cidr < 32) {
-            $ip = $first_user_ip . '/' . $cidr;
-        } else {
-            $ip = $first_user_ip;
-        }
-        $new['ip_int_start'] = ip2long($first_user_ip);
-        $new['ip_int_stop'] = ip2long($last_user_ip);
-        $new['dhcp_start'] = ip2long($range[3]);
-        $new['dhcp_stop'] = ip2long($range[4]);
-        $new['gateway'] = ip2long($range[5]);
-        LOG_INFO($db_link, "Create new subnet $new_subnet");
-        insert_record($db_link, "subnets", $new);
-    }
-    header("Location: " . $_SERVER["REQUEST_URI"]);
-    exit;
-}
-
-unset($_POST);
-
-fix_auth_rules($db_link);
-
-require_once($_SERVER['DOCUMENT_ROOT'] . "/inc/header.php");
-
-print_control_submenu($page_url);
-
-?>
-<div id="cont">
-    <br>
-    <form name="def" action="control-subnets.php" method="post">
-    <div>
-        <?php print WEB_network_create . "&nbsp:<input type=\"text\" name='s_create_subnet' value=''>"; ?>
-        <input type="submit" name="s_create" value="<?php echo WEB_btn_add; ?>">
-        <button class="button_right" name='s_save' value='save'><?php print WEB_btn_save; ?></button>
-        <input type="submit" onclick="return confirm('<?php print WEB_btn_delete; ?>?')" name="s_remove" value="<?php print WEB_btn_remove; ?>">
-    </div>
-        <b><?php echo WEB_network_org_title; ?></b> <br>
-        <table class="data">
-            <tr align="center">
-                <td></td>
-                <td><b><?php echo WEB_network_subnet; ?></b></td>
-                <td><b><?php echo WEB_network_gateway; ?></b></td>
-                <td><b><?php echo WEB_network_use_dhcp; ?></b></td>
-                <td><b><?php echo WEB_network_static; ?></b></td>
-                <td><b><?php echo WEB_network_dhcp_first; ?></b></td>
-                <td><b><?php echo WEB_network_dhcp_last; ?></b></td>
-                <td><b><?php echo WEB_network_dhcp_leasetime; ?></b></td>
-                <td><b><?php echo WEB_network_office_subnet; ?></b></td>
-                <td><b><?php echo WEB_network_hotspot; ?></b></td>
-                <td><b><?php echo WEB_network_vpn; ?></b></td>
-                <td><b><?php echo WEB_network_free; ?></b></td>
-                <td><b><?php echo WEB_network_dyndns; ?></b></td>
-                <td><b><?php echo WEB_network_discovery; ?></b></td>
-                <td><b><?php echo WEB_cell_comment; ?></b></td>
-            </tr>
-            <?php
-            $t_subnets = get_records($db_link, 'subnets', 'True ORDER BY ip_int_start');
-            foreach ($t_subnets as $row) {
-                print "<tr align=center>\n";
-                $cl = "data";
-                print "<td class=\"$cl\" style='padding:0'><input type=checkbox name=s_id[] value='" . $row['id'] . "'></td>\n";
-                print "<td class=\"$cl\"><input type=\"text\" name='s_subnet[" . $row['id'] . "]' value='".$row['subnet']."' size='18'></td>\n";
-                $cell_disabled = '';
-                if ($row['office'] and !$row['vpn']) {
-                    $default_range = cidrToRange($row['subnet']);
-                    if (!isset($row['dhcp_start']) or !($row['dhcp_start'] > 0)) {
-                        $row['dhcp_start'] = ip2long($default_range[3]);
-                    }
-                    if (!isset($row['dhcp_stop']) or !($row['dhcp_stop'] > 0)) {
-                        $row['dhcp_stop'] = ip2long($default_range[4]);
-                    }
-                } else {
-                    $cell_disabled = 'readonly=true';
-                    $cl = 'down';
-                }
-                print "<td class=\"$cl\"><input type=\"text\" name='s_gateway[" . $row['id'] . "]' value='" . long2ip($row['gateway']) . "'  size='15' $cell_disabled></td>\n";
-                if ($row['dhcp']) {
-                    $cl = 'up';
-                } else {
-                    $cl = 'data';
-                }
-                print "<td class=\"$cl\">";
-                print_qa_select("s_dhcp[" . $row['id'] . "]", $row['dhcp']);
-                print "</td>\n";
-                if ($row['static']) {
-                    $cl = 'up';
-                } else {
-                    $cl = 'data';
-                }
-                print "<td class=\"$cl\">";
-                print_qa_select("s_static[" . $row['id'] . "]", $row['static']);
-                print "</td>\n";
-                $cl = 'data';
-                print "<td class=\"$cl\"><input type=\"text\" name='s_dhcp_start[" . $row['id'] . "]' value='" . long2ip($row['dhcp_start']) . "' size='15' $cell_disabled></td>\n";
-                print "<td class=\"$cl\"><input type=\"text\" name='s_dhcp_stop[" . $row['id'] . "]' value='" . long2ip($row['dhcp_stop']) . "' size='15' $cell_disabled></td>\n";
-                print "<td class=\"$cl\"><input type=\"text\" name='s_lease_time[" . $row['id'] . "]' value='" . $row['dhcp_lease_time'] . "'size='3' $cell_disabled></td>\n";
-                $row_cl = 'data';
-                if (!$row['office']) {
-                    $row_cl = 'down';
-                }
-                if ($row['office']) {
-                    $cl = 'up';
-                } else {
-                    $cl = 'data';
-                }
-                print "<td class=\"$cl\">";
-                print_qa_select("s_office[" . $row['id'] . "]", $row['office']);
-                print "</td>\n";
-                if ($row_cl === 'data' and $row['hotspot']) {
-                    $cl = 'up';
-                } else {
-                    $cl = $row_cl;
-                }
-                print "<td class=\"$cl\">";
-                print_qa_select_ext("s_hotspot[" . $row['id'] . "]", $row['hotspot'], !$row['office']);
-                print "</td>\n";
-                if ($row_cl === 'data' and $row['vpn']) {
-                    $cl = 'up';
-                } else {
-                    $cl = $row_cl;
-                }
-                print "<td class=\"$cl\">";
-                print_qa_select_ext("s_vpn[" . $row['id'] . "]", $row['vpn'], !$row['office']);
-                print "</td>\n";
-                if ($row['free']) {
-                    $cl = 'up';
-                } else {
-                    $cl = $row_cl;
-                }
-                print "<td class=\"$cl\">";
-                print_qa_select("s_free[" . $row['id'] . "]", $row['free']);
-                print "</td>\n";
-                if ($row_cl === 'data' and $row['dhcp_update_hostname']) {
-                    $cl = 'up';
-                } else {
-                    $cl = $row_cl;
-                }
-                print "<td class=\"$cl\">";
-                print_qa_select_ext("s_dhcp_update[" . $row['id'] . "]", $row['dhcp_update_hostname'], !$row['office']);
-                print "</td>\n";
-                if ($row_cl === 'data' and $row['discovery']) {
-                    $cl = 'up';
-                } else {
-                    $cl = $row_cl;
-                }
-                print "<td class=\"$cl\">";
-                print_qa_select_ext("s_discovery[" . $row['id'] . "]", $row['discovery'], !$row['office']);
-                print "</td>\n";
-                print "<td class=\"data\"><input type=\"text\" name='s_comment[" . $row['id'] . "]' value='".$row['comment']."'></td>\n";
-                print "</tr>\n";
-                }
-            ?>
-        </table>
-    </form>
-    <?php require_once($_SERVER['DOCUMENT_ROOT'] . "/inc/footer.php"); ?>

+ 205 - 0
html/admin/customers/editsubnet.php

@@ -0,0 +1,205 @@
+<?php
+
+require_once($_SERVER['DOCUMENT_ROOT'] . "/inc/auth.php");
+require_once($_SERVER['DOCUMENT_ROOT'] . "/inc/languages/" . HTML_LANG . ".php");
+require_once($_SERVER['DOCUMENT_ROOT'] . "/inc/idfilter.php");
+
+if (isset($_POST['s_save'])) {
+
+        $new['subnet'] = trim($_POST['s_subnet']);
+        $new['office'] = $_POST['s_office'] * 1;
+        $new['hotspot'] = $_POST['s_hotspot'] * 1;
+        $new['vpn'] = $_POST['s_vpn'] * 1;
+        $new['free'] = $_POST['s_free'] * 1;
+        $new['dhcp'] = $_POST['s_dhcp'] * 1;
+        $new['dhcp_lease_time'] = $_POST['s_lease_time'] * 1;
+        $new['static'] = $_POST['s_static'] * 1;
+        $new['discovery'] = $_POST['s_discovery'] * 1;
+        $new['dhcp_update_hostname'] = $_POST['s_dhcp_update'] * 1;
+        $new['comment'] = trim($_POST['s_comment']);
+
+        $range = cidrToRange($new['subnet']);
+        $first_user_ip = $range[0];
+        $last_user_ip = $range[1];
+        $cidr = $range[2][1];
+        if (isset($cidr) and $cidr <= 32) { $new['subnet'] = $first_user_ip . '/' . $cidr; } else { $new['subnet'] = ''; }
+        $new['ip_int_start'] = ip2long($first_user_ip);
+        $new['ip_int_stop'] = ip2long($last_user_ip);
+        $new['dhcp_start'] = ip2long(trim($_POST['s_dhcp_start']));
+        $new['dhcp_stop'] = ip2long(trim($_POST['s_dhcp_stop']));
+
+        $dhcp_fail = 0;
+        if (!isset($new['dhcp_start']) or $new['dhcp_start'] == 0) { $dhcp_fail = 1; }
+        if (!isset($new['dhcp_stop']) or $new['dhcp_stop'] == 0) { $dhcp_fail = 1; }
+        if (!$dhcp_fail and ($new['dhcp_start'] - $new['ip_int_stop'] >= 0)) { $dhcp_fail = 1; }
+        if (!$dhcp_fail and ($new['dhcp_start'] - $new['ip_int_start'] <= 0)) { $dhcp_fail = 1; }
+        if (!$dhcp_fail and ($new['dhcp_stop'] - $new['ip_int_stop'] >= 0)) { $dhcp_fail = 1; }
+        if (!$dhcp_fail and ($new['dhcp_stop'] - $new['ip_int_start'] <= 0)) { $dhcp_fail = 1; }
+        if (!$dhcp_fail and ($new['dhcp_start'] - $new['dhcp_stop'] >= 0)) { $dhcp_fail = 1; }
+
+        if ($dhcp_fail) {
+            $new['dhcp_start'] = ip2long($range[3]);
+            $new['dhcp_stop'] = ip2long($range[4]);
+        }
+
+        $gateway = ip2long(trim($_POST['s_gateway']));
+        if (!isset($gateway)) { $gateway = $range[5]; }
+
+        $new['gateway'] = $gateway;
+
+        if ($new['hotspot']) {
+            $new['dhcp_update_hostname'] = 0;
+            $new['discovery'] = 0;
+            $new['vpn'] = 0;
+        }
+
+        if ($new['vpn']) { 
+            $new['discovery'] = 0;
+            $new['dhcp'] = 0;
+        }
+
+        if ($new['office']) { $new['free'] = 0; }
+        
+        if (!$new['office']) {
+            $new['discovery'] = 0;
+            $new['dhcp'] = 0;
+            $new['static'] = 0;
+            $new['dhcp_update_hostname'] = 0;
+            $new['gateway'] = 0;
+            $new['dhcp_start'] = 0;
+            $new['dhcp_stop'] = 0;
+        }
+        update_record($db_link, "subnets", "id='$id'", $new);
+        header("Location: " . $_SERVER["REQUEST_URI"]);
+        exit;
+    }
+
+unset($_POST);
+
+require_once($_SERVER['DOCUMENT_ROOT'] . "/inc/header.php");
+
+print_control_submenu($page_url);
+
+$sSQL = "SELECT * FROM subnets WHERE id=$id";
+$subnet_info = get_record_sql($db_link, $sSQL);
+
+?>
+<div id="cont">
+    <?php
+    if (!empty($_SESSION[$page_url]['msg'])) {
+        print '<div id="msg">' . $_SESSION[$page_url]['msg'] . '</div>';
+        unset($_SESSION[$page_url]['msg']);
+    }
+    ?>
+<form name="def" action="editsubnet.php?id=<?php echo $id; ?>" method="post">
+<input type="hidden" name="id" value=<?php echo $id; ?>>
+<table class="data">
+<td><td><b><?php echo WEB_network_subnet; ?></b></td>
+<?php 
+$cl = "data";
+print "<td class=\"$cl\"><input type=\"text\" name='s_subnet' value='".$row['subnet']."' size='18'></td>\n";
+?>
+<td><button class="button_right" name='s_save' value='save'><?php print WEB_btn_save; ?></button></td></tr>
+
+<td><td><b><?php echo WEB_cell_comment; ?></b></td>
+<?php print "<td colspan=2 class=\"data\"><input type=\"text\" name='s_comment[" . $subnet_info['id'] . "]' value='".$subnet_info['comment']."'></td>\n"; ?></tr>
+
+<td><td><b><?php echo WEB_network_gateway; ?></b></td>
+<?php 
+$cell_disabled = '';
+if ($subnet_info['office'] and !$subnet_info['vpn']) {
+        $default_range = cidrToRange($subnet_info['subnet']);
+        if (!isset($subnet_info['dhcp_start']) or !($subnet_info['dhcp_start'] > 0)) {
+            $subnet_info['dhcp_start'] = ip2long($default_range[3]);
+            }
+        if (!isset($subnet_info['dhcp_stop']) or !($subnet_info['dhcp_stop'] > 0)) {
+            $subnet_info['dhcp_stop'] = ip2long($default_range[4]);
+            }
+    } else {
+        $cell_disabled = 'readonly=true';
+        $cl = 'down';
+    }
+print "<td colspan=2 class=\"$cl\"><input type=\"text\" name='s_gateway' value='" . long2ip($subnet_info['gateway']) . "'  size='15' $cell_disabled></td>\n";
+?>
+</tr>
+<td><td><b><?php echo WEB_network_use_dhcp; ?></b></td>
+<?php
+if ($subnet_info['dhcp']) { $cl = 'up'; } else { $cl = 'data'; }
+print "<td colspan=2 class=\"$cl\">";
+print_qa_select("s_dhcp", $subnet_info['dhcp']);
+print "</td>\n";
+?>
+</tr>
+<td><td><b><?php echo WEB_network_static; ?></b></td>
+<?php
+if ($subnet_info['static']) { $cl = 'up'; } else { $cl = 'data'; }
+print "<td colspan=2 class=\"$cl\">";
+print_qa_select("s_static", $subnet_info['static']);
+print "</td>\n";
+$cl = 'data';
+?>
+</tr>
+<td><td><b><?php echo WEB_network_dhcp_first; ?></b></td>
+<?php print "<td colspan=2 class=\"$cl\"><input type=\"text\" name='s_dhcp_start' value='" . long2ip($subnet_info['dhcp_start']) . "' size='15' $cell_disabled></td>\n"; ?></tr>
+<td><td><b><?php echo WEB_network_dhcp_last; ?></b></td>
+<?php print "<td colspan=2 class=\"$cl\"><input type=\"text\" name='s_dhcp_stop' value='" . long2ip($subnet_info['dhcp_stop']) . "' size='15' $cell_disabled></td>\n"; ?></tr>
+<td><td><b><?php echo WEB_network_dhcp_leasetime; ?></b></td>
+<?php print "<td colspan=2 class=\"$cl\"><input type=\"text\" name='s_lease_time' value='" . $subnet_info['dhcp_lease_time'] . "'size='3' $cell_disabled></td>\n"; ?></tr>
+<td><td><b><?php echo WEB_network_office_subnet; ?></b></td>
+<?php
+$row_cl = 'data';
+if (!$subnet_info['office']) { $row_cl = 'down'; }
+if ($subnet_info['office']) { $cl = 'up'; } else { $cl = 'data'; }
+print "<td colspan=2 class=\"$cl\">";
+print_qa_select("s_office", $subnet_info['office']);
+print "</td>\n";
+?>
+</tr>
+<td><td><b><?php echo WEB_network_hotspot; ?></b></td>
+<?php
+if ($row_cl === 'data' and $subnet_info['hotspot']) { $cl = 'up'; } else { $cl = $row_cl; }
+print "<td colspan=2 class=\"$cl\">";
+print_qa_select_ext("s_hotspot", $subnet_info['hotspot'], !$subnet_info['office']);
+print "</td>\n";
+?>
+</tr>
+<td><td><b><?php echo WEB_network_vpn; ?></b></td>
+<?php
+if ($row_cl === 'data' and $subnet_info['vpn']) { $cl = 'up'; } else { $cl = $row_cl; }
+print "<td colspan=2 class=\"$cl\">";
+print_qa_select_ext("s_vpn", $subnet_info['vpn'], !$subnet_info['office']);
+print "</td>\n";
+?>
+</tr>
+<td><td><b><?php echo WEB_network_free; ?></b></td>
+<?php
+if ($subnet_info['free']) { $cl = 'up'; } else { $cl = $row_cl; }
+print "<td colspan=2 class=\"$cl\">";
+print_qa_select("s_free", $subnet_info['free']);
+print "</td>\n";
+?>
+</tr>
+<td><td><b><?php echo WEB_network_dyndns; ?></b></td>
+<?php
+if ($row_cl === 'data' and $subnet_info['dhcp_update_hostname']) { $cl = 'up'; } else { $cl = $row_cl; }
+print "<td colspan=2 class=\"$cl\">";
+print_qa_select_ext("s_dhcp_update", $subnet_info['dhcp_update_hostname'], !$subnet_info['office']);
+print "</td>\n";
+?>
+</tr>
+<td><td><b><?php echo WEB_network_discovery; ?></b></td>
+<?php
+if ($row_cl === 'data' and $subnet_info['discovery']) { $cl = 'up'; } else { $cl = $row_cl; }
+print "<td colspan=2 class=\"$cl\">";
+print_qa_select_ext("s_discovery", $subnet_info['discovery'], !$subnet_info['office']);
+print "</td>\n";
+?>
+</tr>
+</table>
+<?php
+    if ($msg_error) {
+        print "<div id='msg'><b>$msg_error</b></div><br>\n";
+    }
+?>
+</form>
+<?php require_once($_SERVER['DOCUMENT_ROOT'] . "/inc/footer.php"); ?>

+ 98 - 0
html/admin/customers/index-subnets.php

@@ -0,0 +1,98 @@
+<?php
+
+require_once($_SERVER['DOCUMENT_ROOT'] . "/inc/auth.php");
+require_once($_SERVER['DOCUMENT_ROOT'] . "/inc/languages/" . HTML_LANG . ".php");
+
+if (isset($_POST["s_remove"])) {
+    if (!empty($_POST["s_id"])) {
+        $s_id = $_POST["s_id"];
+        foreach ($s_id as $key => $net_id) {
+            if (isset($net_id)) {
+                LOG_INFO($db_link, "Remove subnet id: $net_id");
+                delete_record($db_link, "subnets", "id=" . $net_id);
+            }
+        }
+    }
+    header("Location: " . $_SERVER["REQUEST_URI"]);
+    exit;
+}
+
+if (isset($_POST["s_create"])) {
+    $new_subnet = $_POST["s_create_subnet"];
+    if (isset($new_subnet)) {
+        $new['subnet'] = trim($new_subnet);
+        $range = cidrToRange($new['subnet']);
+        $first_user_ip = $range[0];
+        $last_user_ip = $range[1];
+        $cidr = $range[2][1];
+        if (isset($cidr) and $cidr < 32) {
+            $ip = $first_user_ip . '/' . $cidr;
+        } else {
+            $ip = $first_user_ip;
+        }
+        $new['ip_int_start'] = ip2long($first_user_ip);
+        $new['ip_int_stop'] = ip2long($last_user_ip);
+        $new['dhcp_start'] = ip2long($range[3]);
+        $new['dhcp_stop'] = ip2long($range[4]);
+        $new['gateway'] = ip2long($range[5]);
+        LOG_INFO($db_link, "Create new subnet $new_subnet");
+        insert_record($db_link, "subnets", $new);
+    }
+    header("Location: " . $_SERVER["REQUEST_URI"]);
+    exit;
+}
+
+unset($_POST);
+
+fix_auth_rules($db_link);
+
+require_once($_SERVER['DOCUMENT_ROOT'] . "/inc/header.php");
+
+print_control_submenu($page_url);
+
+?>
+<div id="cont">
+    <br>
+    <form name="def" action="control-subnets.php" method="post">
+    <div>
+        <?php print WEB_network_create . "&nbsp:<input type=\"text\" name='s_create_subnet' value=''>"; ?>
+        <input type="submit" name="s_create" value="<?php echo WEB_btn_add; ?>">
+        <button class="button_right" name='s_save' value='save'><?php print WEB_btn_save; ?></button>
+        <input type="submit" onclick="return confirm('<?php print WEB_btn_delete; ?>?')" name="s_remove" value="<?php print WEB_btn_remove; ?>">
+    </div>
+        <b><?php echo WEB_network_org_title; ?></b> <br>
+        <table class="data">
+            <tr align="center">
+                <td></td>
+                <td><b><?php echo WEB_network_subnet; ?></b></td>
+                <td><b><?php echo WEB_network_use_dhcp; ?></b></td>
+                <td><b><?php echo WEB_network_static; ?></b></td>
+                <td><b><?php echo WEB_network_office_subnet; ?></b></td>
+                <td><b><?php echo WEB_network_hotspot; ?></b></td>
+                <td><b><?php echo WEB_network_vpn; ?></b></td>
+                <td><b><?php echo WEB_network_free; ?></b></td>
+                <td><b><?php echo WEB_network_dyndns; ?></b></td>
+                <td><b><?php echo WEB_network_discovery; ?></b></td>
+                <td><b><?php echo WEB_cell_comment; ?></b></td>
+            </tr>
+            <?php
+            $t_subnets = get_records($db_link, 'subnets', 'True ORDER BY ip_int_start');
+            foreach ($t_subnets as $row) {
+                print "<tr align=center>\n";
+                print "<td class=\"data\" style='padding:0'><input type=checkbox name=s_id[] value='" . $row['id'] . "'></td>\n";
+                print "<td class=\"data\" align=left><a href=editsubnet.php?id=".$row["id"].">" . $row["subnet"] . "</a></td>\n";
+                print_td_yes_no($row['dhcp']);
+                print_td_yes_no($row['static']);
+                print_td_yes_no($row['office']);
+                print_td_yes_no($row['hotspot']);
+                print_td_yes_no($row['vpn']);
+                print_td_yes_no($row['free']);
+                print_td_yes_no($row['dhcp_update_hostname']);
+                print_td_yes_no($row['discovery']);
+                print "<td class=\"data\">" . $row['comment'] . " </td>\n";
+                print "</tr>\n";
+                }
+            ?>
+        </table>
+    </form>
+    <?php require_once($_SERVER['DOCUMENT_ROOT'] . "/inc/footer.php"); ?>

+ 10 - 1
html/inc/common.php

@@ -572,7 +572,7 @@ function print_control_submenu($current_page)
 {
     print "<div id='submenu'>\n";
     print_submenu_url(WEB_submenu_control, '/admin/customers/control.php', $current_page, 0);
-    print_submenu_url(WEB_submenu_network, '/admin/customers/control-subnets.php', $current_page, 0);
+    print_submenu_url(WEB_submenu_network, '/admin/customers/index-subnets.php', $current_page, 0);
     print_submenu_url(WEB_submenu_network_stats, '/admin/customers/control-subnets-usage.php', $current_page, 0);
     print_submenu_url(WEB_submenu_options, '/admin/customers/control-options.php', $current_page, 0);
     print_submenu_url(WEB_submenu_customers, '/admin/customers/index.php', $current_page, 1);
@@ -885,6 +885,15 @@ function print_qa_select_ext($qa_name, $qa_value, $readonly)
     print "</select>\n";
 }
 
+function print_td_yes_no($qa_value)
+{
+    $cl = 'down';
+    if ($qa_value==1) { $cl='up'; }
+    print "<td class=\"$cl\">";
+    if ($qa_value==1) { print WEB_select_item_yes; } else { print WEB_select_item_no; }
+    print "</td>\n";
+}
+
 function print_control_proto_select($qa_name, $qa_value)
 {
     print "<select name=\"$qa_name\">\n";