Sfoglia il codice sorgente

create network devices from user list

Roman Dmitriev 2 anni fa
parent
commit
b3b4d5141c

+ 1 - 0
html/admin/users/index.php

@@ -76,6 +76,7 @@ if ($msg_error) {
         <tr><td><input type=checkbox class="putField" name="e_new_ou" value='1'></td><td><?php print WEB_cell_ou."&nbsp";print_ou_select($db_link, 'a_new_ou', $rou); ?></td></tr>
         <tr><td><input type=checkbox class="putField" name="e_bind_mac" value='1'></td><td><?php print WEB_user_bind_mac."&nbsp";print_qa_select('a_bind_mac', 1);?></td></tr>
         <tr><td><input type=checkbox class="putField" name="e_bind_ip" value='1'></td><td><?php print WEB_user_bind_ip."&nbsp";print_qa_select('a_bind_ip', 1);?></td></tr>
+        <tr><td><input type=checkbox class="putField" name="e_create_netdev" value='1'></td><td><?php print WEB_user_create_netdev."&nbsp";print_qa_select('a_create_netdev', 1);?></td></tr>
         </table>
         <input type="submit" name="submit" class="btn" value="<?php echo WEB_btn_apply; ?>">
     </form>

+ 1 - 0
html/inc/languages/english.php

@@ -461,6 +461,7 @@ define("WEB_user_bind_mac","Bind mac for login");
 define("WEB_user_unbind_mac","Unbind mac for login");
 define("WEB_user_bind_ip","Bind ip-address for login");
 define("WEB_user_unbind_ip","Unbind ip-address for login");
+define("WEB_user_create_netdev","Create network device");
 
 /* public */
 define("WEB_msg_access_login","Internet for login");

+ 1 - 0
html/inc/languages/russian.php

@@ -461,6 +461,7 @@ define("WEB_user_bind_mac","Привязать мак к юзеру");
 define("WEB_user_unbind_mac","Отвязать мак от юзера");
 define("WEB_user_bind_ip","Привязать IP-адрес к юзеру");
 define("WEB_user_unbind_ip","Отвязать IP-адрес от юзера");
+define("WEB_user_create_netdev","Создать устройтсво");
 
 /* public */
 define("WEB_msg_access_login","Интернет (логин)");

+ 29 - 0
html/utils/user_apply.php

@@ -42,6 +42,10 @@ if (isset($_POST["ApplyForAll"])) {
         $_POST["a_bind_ip"] = 0;
     }
 
+    if (empty($_POST["a_create_netdev"])) {
+        $_POST["a_create_netdev"] = 0;
+    }
+
     $a_enabled  = $_POST["a_enabled"] * 1;
     $a_dhcp     = $_POST["a_dhcp"] * 1;
     $a_dhcp_acl = $_POST["a_dhcp_acl"];
@@ -165,6 +169,31 @@ if (isset($_POST["ApplyForAll"])) {
                         LOG_INFO($db_link, "Remove auto rule for user_id: " . $val . " and ip " . $b_ip);
                 }
             }
+
+            //create network devices
+            if (isset($_POST["e_create_netdev"])) {
+                if ($a_create_netdev) {
+                    if (!empty($b_ip)) {
+                        $device = get_record_sql($db_link,"SELECT * FROM devices WHERE user_id=".$val);
+                        $auth = get_record_sql($db_link,"SELECT * FROM User_auth WHERE user_id=".$val);
+                        if (empty($device) and !empty($auth)) {
+                            $new['user_id']=$val;
+                            $new['device_name'] = $login['login'];
+                            $new['device_type'] = 5;
+                            $new['ip']=$auth['ip'];
+                            $new['community'] = get_const('snmp_default_community');
+                            $new['snmp_version'] = get_const('snmp_default_version');
+                            $new['login'] = get_option($db_link,28);
+                            $new['password'] = get_option($db_link,29);
+                            //default ssh
+                            $new['protocol'] = 0;
+                            $new['control_port'] = get_option($db_link,30);
+                            $new_id=insert_record($db_link, "devices", $new);
+                        }
+                    }
+                }
+            }
+
         }
     }
     if ($all_ok) {