Explorar o código

draft: migrate from global variables to define
some bugixes in snmp walk mac table

root %!s(int64=3) %!d(string=hai) anos
pai
achega
9aef19c7ea
Modificáronse 63 ficheiros con 322 adicións e 467 borrados
  1. 1 1
      html/admin/customers/control-options.php
  2. 1 1
      html/admin/customers/control-subnets-usage.php
  3. 1 1
      html/admin/customers/control-subnets.php
  4. 1 1
      html/admin/customers/control.php
  5. 1 1
      html/admin/customers/editcustom.php
  6. 1 1
      html/admin/customers/index.php
  7. 2 2
      html/admin/customers/ipcam.php
  8. 1 1
      html/admin/devices/building.php
  9. 1 1
      html/admin/devices/devmodels.php
  10. 1 1
      html/admin/devices/devvendors.php
  11. 1 1
      html/admin/devices/edit_l3int.php
  12. 1 1
      html/admin/devices/editdevice.php
  13. 1 1
      html/admin/devices/editport.php
  14. 1 1
      html/admin/devices/index-passive.php
  15. 1 1
      html/admin/devices/index-tree-simple.php
  16. 1 1
      html/admin/devices/index-tree.php
  17. 1 1
      html/admin/devices/index.php
  18. 2 2
      html/admin/devices/mactable.php
  19. 2 2
      html/admin/devices/portmactable.php
  20. 1 1
      html/admin/devices/portsbyvlan.php
  21. 3 4
      html/admin/devices/snmpwalk.php
  22. 1 1
      html/admin/devices/switchport-conn.php
  23. 4 5
      html/admin/devices/switchport.php
  24. 6 8
      html/admin/devices/switchstatus.php
  25. 1 1
      html/admin/filters/editfilter.php
  26. 1 1
      html/admin/filters/editgroup.php
  27. 1 1
      html/admin/filters/groups.php
  28. 1 1
      html/admin/filters/index.php
  29. 1 3
      html/admin/groups/edit_group.php
  30. 1 1
      html/admin/groups/index.php
  31. 1 1
      html/admin/iplist/auto_rules.php
  32. 1 1
      html/admin/iplist/deleted.php
  33. 1 1
      html/admin/iplist/doubles.php
  34. 1 1
      html/admin/iplist/index.php
  35. 4 4
      html/admin/iplist/nagios.php
  36. 9 13
      html/admin/logs/authlog.php
  37. 1 1
      html/admin/logs/detaillog.php
  38. 1 1
      html/admin/logs/dhcp.php
  39. 11 16
      html/admin/logs/index.php
  40. 1 1
      html/admin/logs/ip.php
  41. 1 1
      html/admin/logs/mac.php
  42. 1 1
      html/admin/logs/syslog.php
  43. 1 1
      html/admin/logs/unknown.php
  44. 1 1
      html/admin/queues/index.php
  45. 1 1
      html/admin/reports/authday.php
  46. 1 1
      html/admin/reports/index-full.php
  47. 1 1
      html/admin/reports/index.php
  48. 1 1
      html/admin/reports/userday.php
  49. 1 1
      html/admin/reports/userdaydetail.php
  50. 1 1
      html/admin/reports/userdaydetaillog.php
  51. 1 3
      html/admin/users/add_dhcp.php
  52. 1 1
      html/admin/users/edit_alias.php
  53. 1 1
      html/admin/users/edit_rules.php
  54. 3 5
      html/admin/users/editauth.php
  55. 4 8
      html/admin/users/edituser.php
  56. 2 3
      html/admin/users/index.php
  57. 138 324
      html/inc/common.php
  58. 75 10
      html/inc/config.php.sample
  59. 2 2
      html/inc/header.php
  60. 2 2
      html/inc/header_public.php
  61. 4 4
      html/inc/loglevelfilter.php
  62. 1 1
      html/inc/sql.php
  63. 4 4
      html/public/blocked.php

+ 1 - 1
html/admin/customers/control-options.php

@@ -1,7 +1,7 @@
 <?php
 
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/auth.php");
-require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . $language . ".php");
+require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . HTML_LANG . ".php");
 
 if (isset($_POST["remove"])) {
     $fid = $_POST["f_id"];

+ 1 - 1
html/admin/customers/control-subnets-usage.php

@@ -1,7 +1,7 @@
 <?php
 
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/auth.php");
-require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . $language . ".php");
+require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . HTML_LANG . ".php");
 unset($_POST);
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/header.php");
 print_control_submenu($page_url);

+ 1 - 1
html/admin/customers/control-subnets.php

@@ -1,7 +1,7 @@
 <?php
 
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/auth.php");
-require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . $language . ".php");
+require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . HTML_LANG . ".php");
 
 if (isset($_POST["s_remove"])) {
     $s_id = $_POST["s_id"];

+ 1 - 1
html/admin/customers/control.php

@@ -1,7 +1,7 @@
 <?php
 
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/auth.php");
-require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . $language . ".php");
+require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . HTML_LANG . ".php");
 
 if (isset($_POST["recheck_ip"]) and is_option($db_link, 37)) {
     $run_cmd = get_option($db_link, 37);

+ 1 - 1
html/admin/customers/editcustom.php

@@ -1,6 +1,6 @@
 <?php
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/auth.php");
-require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . $language . ".php");
+require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . HTML_LANG . ".php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/idfilter.php");
 
 $msg_error = "";

+ 1 - 1
html/admin/customers/index.php

@@ -1,6 +1,6 @@
 <?php
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/auth.php");
-require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . $language . ".php");
+require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . HTML_LANG . ".php");
 
 $msg_error = "";
 

+ 2 - 2
html/admin/customers/ipcam.php

@@ -1,10 +1,10 @@
 <?php
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/auth.php");
-require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . $language . ".php");
+require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . HTML_LANG . ".php");
 
 // if(isset($_POST['f_ou_id'])){ $f_ou_id=$_POST['f_ou_id']*1; } else { $f_ou_id=1; }
 
-$f_ou_id = $ipcam_group_id;
+$f_ou_id = IPCAM_GROUP_ID;
 
 if (isset($_POST['port_on'])) {
     $len = is_array($_POST['port_on']) ? count($_POST['port_on']) : 0;

+ 1 - 1
html/admin/devices/building.php

@@ -1,6 +1,6 @@
 <?php
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/auth.php");
-require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . $language . ".php");
+require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . HTML_LANG . ".php");
 
 if (isset($_POST["remove"])) {
     $fid = $_POST["f_id"];

+ 1 - 1
html/admin/devices/devmodels.php

@@ -2,7 +2,7 @@
 
 $default_displayed=25;
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/auth.php");
-require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . $language . ".php");
+require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . HTML_LANG . ".php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/vendorfilter.php");
 
 if (isset($_POST['save'])) {

+ 1 - 1
html/admin/devices/devvendors.php

@@ -2,7 +2,7 @@
 
 $default_displayed=25;
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/auth.php");
-require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . $language . ".php");
+require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . HTML_LANG . ".php");
 
 if (isset($_POST['save'])) {
     $saved = array();

+ 1 - 1
html/admin/devices/edit_l3int.php

@@ -1,7 +1,7 @@
 <?php
 
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/auth.php");
-require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . $language . ".php");
+require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . HTML_LANG . ".php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/idfilter.php");
 
 $sSQL = "SELECT * FROM devices WHERE id=$id";

+ 1 - 1
html/admin/devices/editdevice.php

@@ -1,6 +1,6 @@
 <?php
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/auth.php");
-require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . $language . ".php");
+require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . HTML_LANG . ".php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/idfilter.php");
 
 if (isset($_POST["editdevice"]) and isset($id)) {

+ 1 - 1
html/admin/devices/editport.php

@@ -1,6 +1,6 @@
 <?php
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/auth.php");
-require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . $language . ".php");
+require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . HTML_LANG . ".php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/idfilter.php");
 
 if (isset($_POST["editport"])) {

+ 1 - 1
html/admin/devices/index-passive.php

@@ -1,7 +1,7 @@
 <?php
 $default_displayed=500;
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/auth.php");
-require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . $language . ".php");
+require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . HTML_LANG . ".php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/header.php");
 $default_sort='ip_int';
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/oufilter.php");

+ 1 - 1
html/admin/devices/index-tree-simple.php

@@ -1,6 +1,6 @@
 <?php
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/auth.php");
-require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . $language . ".php");
+require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . HTML_LANG . ".php");
 unset($_POST);
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/header.php");
 print_device_submenu($page_url);

+ 1 - 1
html/admin/devices/index-tree.php

@@ -1,6 +1,6 @@
 <?php
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/auth.php");
-require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . $language . ".php");
+require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . HTML_LANG . ".php");
 unset($_POST);
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/header.php");
 print_device_submenu($page_url);

+ 1 - 1
html/admin/devices/index.php

@@ -1,6 +1,6 @@
 <?php
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/auth.php");
-require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . $language . ".php");
+require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . HTML_LANG . ".php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/devtypesfilter.php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/buildingfilter.php");
 $default_sort='device_name';

+ 2 - 2
html/admin/devices/mactable.php

@@ -1,12 +1,12 @@
 <?php
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/auth.php");
-require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . $language . ".php");
+require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . HTML_LANG . ".php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/idfilter.php");
 ?>
 <html>
 <head>
 <title>Панель администратора</title>
-<link rel="stylesheet" type="text/css"	href=<?php echo "\"/$style.css\""; ?>>
+<link rel="stylesheet" type="text/css"	href=<?php echo "\"/HTML_STYLE.css\""; ?>>
 <meta http-equiv="content-type" content="application/xhtml+xml">
 <meta charset="UTF-8">
 </head>

+ 2 - 2
html/admin/devices/portmactable.php

@@ -1,12 +1,12 @@
 <?php
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/auth.php");
-require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . $language . ".php");
+require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . HTML_LANG . ".php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/idfilter.php");
 ?>
 <html>
 <head>
 <title>Панель администратора</title>
-<link rel="stylesheet" type="text/css"	href=<?php echo "\"/$style.css\""; ?>>
+<link rel="stylesheet" type="text/css"	href=<?php echo "\"/HTML_STYLE.css\""; ?>>
 <meta http-equiv="content-type" content="application/xhtml+xml">
 <meta charset="UTF-8">
 </head>

+ 1 - 1
html/admin/devices/portsbyvlan.php

@@ -1,7 +1,7 @@
 <?php
 $default_displayed=100;
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/auth.php");
-require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . $language . ".php");
+require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . HTML_LANG . ".php");
 $default_id=1;
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/idfilter.php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/header.php");

+ 3 - 4
html/admin/devices/snmpwalk.php

@@ -1,12 +1,12 @@
 <?php
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/auth.php");
-require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . $language . ".php");
+require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . HTML_LANG . ".php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/idfilter.php");
 ?>
 <html>
 <head>
 <title>Панель администратора</title>
-<link rel="stylesheet" type="text/css" href=<?php echo "\"/$style.css\""; ?>>
+<link rel="stylesheet" type="text/css" href=<?php echo "\"/HTML_STYLE.css\""; ?>>
 <meta http-equiv="content-type" content="application/xhtml+xml">
 <meta charset="UTF-8">
 </head>
@@ -15,8 +15,7 @@ require_once ($_SERVER['DOCUMENT_ROOT']."/inc/idfilter.php");
 <?php
 $dev_info = get_record($db_link,'devices','id='.$id);
 $interfaces = get_snmp_interfaces($dev_info['ip'], $dev_info['community'], $dev_info['snmp_version']);
-global $sysinfo_mib;
-$dev_info = walk_snmp($dev_info['ip'], $dev_info['community'], $dev_info['snmp_version'],$sysinfo_mib);
+$dev_info = walk_snmp($dev_info['ip'], $dev_info['community'], $dev_info['snmp_version'],SYSINFO_MIB);
 foreach ($dev_info as $key => $value) {
 list ($v_type,$v_data)=explode(':',$value);
 $v_clean = preg_replace('/\s/', '', $v_data);

+ 1 - 1
html/admin/devices/switchport-conn.php

@@ -1,6 +1,6 @@
 <?php
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/auth.php");
-require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . $language . ".php");
+require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . HTML_LANG . ".php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/idfilter.php");
 
 $switch=get_record($db_link,'devices',"id=".$id);

+ 4 - 5
html/admin/devices/switchport.php

@@ -1,6 +1,6 @@
 <?php
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/auth.php");
-require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . $language . ".php");
+require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . HTML_LANG . ".php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/idfilter.php");
 
 if (isset($_POST["regensnmp"])) {
@@ -106,16 +106,15 @@ foreach ($ports as $row) {
         print "<td class=\"$cl\" >" . get_qa($row['skip']) . "</td>\n";
         $vlan = $row['vlan'];
         $ifname= compact_port_name($row['ifName']);
-        global $torrus_url;
         $f_cacti_url = get_cacti_graph($switch['ip'], $row['snmp_index']);
-        if (! isset($torrus_url) and (! isset($f_cacti_url))) {  $snmp_url=$ifname; }
+        if (! isset(get_const('torrus_url')) and (! isset($f_cacti_url))) {  $snmp_url=$ifname; }
                 else {
                 if (isset($f_cacti_url)) { $snmp_url = "<a href=\"$f_cacti_url\">" . $ifname . "</a>"; }
-                if (isset($torrus_url)) {
+                if (isset(get_const('torrus_url'))) {
                     $normed_ifname = str_replace("/", "_", $ifname);
                     $normed_ifname = str_replace(".", "_", $normed_ifname);
                     $normed_ifname = trim(str_replace(" ", "_", $normed_ifname));
-                    $t_url = str_replace("HOST_IP", $switch['ip'], $torrus_url);
+                    $t_url = str_replace("HOST_IP", $switch['ip'], get_const('torrus_url'));
                     $t_url = str_replace("IF_NAME", $normed_ifname, $t_url);
                     $snmp_url = "<a href=\"$t_url\">" . $ifname . "</a>";
                     }

+ 6 - 8
html/admin/devices/switchstatus.php

@@ -1,6 +1,6 @@
 <?php
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/auth.php");
-require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . $language . ".php");
+require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . HTML_LANG . ".php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/idfilter.php");
 
 $switch=get_record($db_link,'devices',"id=".$id);
@@ -80,12 +80,11 @@ if ($switch['snmp_version']>0) {
     $snmp_ok = check_snmp_access($switch['ip'], $switch['community'], $switch['snmp_version']);
     $modules_oids = NULL;
     if ($snmp_ok) {
-	    global $cisco_modules;
             if ($switch['snmp_version'] == 2) {
-	        $modules_oids = snmp2_real_walk($switch['ip'], $switch['community'], $cisco_modules);
+	        $modules_oids = snmp2_real_walk($switch['ip'], $switch['community'], CISCO_MODULES);
 	        }
             if ($switch['snmp_version'] == 1) {
-	        $modules_oids = snmprealwalk($switch['ip'], $switch['community'], $cisco_modules);
+	        $modules_oids = snmprealwalk($switch['ip'], $switch['community'], CISCO_MODULES);
 	        }
 	    }
     } else { $snmp_ok = 0; }
@@ -169,16 +168,15 @@ if ($switch['snmp_version']>0) {
         if (!empty($new_info)) { update_record($db_link, "device_ports", "id=".$row['id'], $new_info); }
 
         $ifname=compact_port_name($ifname);
-        global $torrus_url;
         $f_cacti_url = get_cacti_graph($switch['ip'], $row['snmp_index']);
-        if (! isset($torrus_url) and (! isset($f_cacti_url))) {  $snmp_url=$ifname; } 
+        if (empty(get_const('torrus_url')) and (empty($f_cacti_url))) {  $snmp_url=$ifname; } 
                 else {
                 if (isset($f_cacti_url)) { $snmp_url = "<a href=\"$f_cacti_url\">" . $ifname . "</a>"; }
-                if (isset($torrus_url)) {
+                if (!empty(get_const('torrus_url'))) {
                     $normed_ifname = str_replace("/", "_", $ifname);
                     $normed_ifname = str_replace(".", "_", $normed_ifname);
                     $normed_ifname = trim(str_replace(" ", "_", $normed_ifname));
-                    $t_url = str_replace("HOST_IP", $switch['ip'], $torrus_url);
+                    $t_url = str_replace("HOST_IP", $switch['ip'], get_const('torrus_url'));
                     $t_url = str_replace("IF_NAME", $normed_ifname, $t_url);
                     $snmp_url = "<a href=\"$t_url\">" . $ifname . "</a>";
                     }

+ 1 - 1
html/admin/filters/editfilter.php

@@ -1,6 +1,6 @@
 <?php
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/auth.php");
-require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . $language . ".php");
+require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . HTML_LANG . ".php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/idfilter.php");
 
 if (isset($_POST["editfilter"])) {

+ 1 - 1
html/admin/filters/editgroup.php

@@ -1,6 +1,6 @@
 <?php
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/auth.php");
-require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . $language . ".php");
+require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . HTML_LANG . ".php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/idfilter.php");
 
 if (isset($_POST["editgroup"])) {

+ 1 - 1
html/admin/filters/groups.php

@@ -1,6 +1,6 @@
 <?php
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/auth.php");
-require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . $language . ".php");
+require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . HTML_LANG . ".php");
 
 if (isset($_POST["create"])) {
     $fname = $_POST["newgroup"];

+ 1 - 1
html/admin/filters/index.php

@@ -1,6 +1,6 @@
 <?php
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/auth.php");
-require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . $language . ".php");
+require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . HTML_LANG . ".php");
 
 if (isset($_POST["create"])) {
     $fname = $_POST["newfilter"];

+ 1 - 3
html/admin/groups/edit_group.php

@@ -1,9 +1,7 @@
 <?php
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/auth.php");
-require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . $language . ".php");
+require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . HTML_LANG . ".php");
 require_once ($_SERVER["DOCUMENT_ROOT"]."/inc/idfilter.php");
-global $default_user_ou_id;
-global $default_hotspot_ou_id;
 
 if (isset($_POST['save'])) {
         $new['ou_name'] = $_POST['f_group_name'];

+ 1 - 1
html/admin/groups/index.php

@@ -1,6 +1,6 @@
 <?php
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/auth.php");
-require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . $language . ".php");
+require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . HTML_LANG . ".php");
 
 if (isset($_POST["remove"])) {
     $fid = $_POST["f_id"];

+ 1 - 1
html/admin/iplist/auto_rules.php

@@ -1,7 +1,7 @@
 <?php
 $default_displayed=50;
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/auth.php");
-require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . $language . ".php");
+require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . HTML_LANG . ".php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/header.php");
 
 if (isset($_POST["removeRule"])) {

+ 1 - 1
html/admin/iplist/deleted.php

@@ -1,7 +1,7 @@
 <?php
 $default_displayed = 500;
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/auth.php");
-require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . $language . ".php");
+require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . HTML_LANG . ".php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/header.php");
 $default_sort='ip_int';
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/oufilter.php");

+ 1 - 1
html/admin/iplist/doubles.php

@@ -1,6 +1,6 @@
 <?php
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/auth.php");
-require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . $language . ".php");
+require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . HTML_LANG . ".php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/header.php");
 
 if (isset($_POST["removeauth"])) {

+ 1 - 1
html/admin/iplist/index.php

@@ -1,7 +1,7 @@
 <?php
 $default_displayed=500;
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/auth.php");
-require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . $language . ".php");
+require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . HTML_LANG . ".php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/header.php");
 $default_sort='ip_int';
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/oufilter.php");

+ 4 - 4
html/admin/iplist/nagios.php

@@ -1,7 +1,7 @@
 <?php
 $default_displayed=500;
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/auth.php");
-require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . $language . ".php");
+require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . HTML_LANG . ".php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/header.php");
 $default_sort='ip_int';
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/oufilter.php");
@@ -145,9 +145,9 @@ foreach ($users as $user) {
         }
 
     if (!empty($user['nagios']) and $user['nagios']) {
-        $nagios_url = rtrim(get_option($db_link, 57),'/');
-        if (preg_match('/127.0.0.1/', $nagios_url)) { print "<td class=\"$cl\" >". get_qa($user['nagios']) ."</td>\n"; } else {
-            $nagios_link = $nagios_url.'/cgi-bin/status.cgi?host='.get_nagios_name($user);
+        get_const('nagios_url') = rtrim(get_option($db_link, 57),'/');
+        if (preg_match('/127.0.0.1/', get_const('nagios_url'))) { print "<td class=\"$cl\" >". get_qa($user['nagios']) ."</td>\n"; } else {
+            $nagios_link = get_const('nagios_url').'/cgi-bin/status.cgi?host='.get_nagios_name($user);
             print "<td class=\"$cl\" >"; print_url(get_qa($user['nagios']),$nagios_link); print "</td>\n";
             }
         } else {

+ 9 - 13
html/admin/logs/authlog.php

@@ -1,6 +1,6 @@
 <?php
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/auth.php");
-require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . $language . ".php");
+require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . HTML_LANG . ".php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/header.php");
 $default_date_shift='m';
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/datefilter.php");
@@ -16,7 +16,7 @@ if (!isset($auth_id)) { header('Location: /admin/logs/index.php', true, 301); ex
 Начало:<input type="date" name="date_start" value="<?php echo $date1; ?>" />
 Конец:<input type="date" name="date_stop" value="<?php echo $date2; ?>" />
 Отображать:<?php print_row_at_pages('rows',$displayed); ?>
-Уровень логов:<?php print_loglevel_select('log_level',$log_level); ?>
+Уровень логов:<?php print_loglevel_select('log_level',get_const('log_level')); ?>
 <input type="submit" value="OK"><br><br>
 Фильтр Источник:<input name="customer" value="<?php echo $fcustomer; ?>" />
 Сообщение:<input name="message" value="<?php echo $fmessage; ?>" />
@@ -25,15 +25,11 @@ if (!isset($auth_id)) { header('Location: /admin/logs/index.php', true, 301); ex
 <?php
 $log_filter ='';
 
-global $L_INFO;
-global $L_ERROR;
-global $L_VERBOSE;
-global $L_DEBUG;
 
-if ($log_level == $L_INFO) { $log_filter = " and `level`=$L_INFO "; }
-if ($log_level == $L_ERROR) { $log_filter = " and (`level`=$L_INFO or `level`=$L_ERROR) "; }
-if ($log_level == $L_VERBOSE) { $log_filter = " and (`level`=$L_INFO or `level`=$L_ERROR or `level`=$L_VERBOSE) "; }
-if ($log_level == $L_DEBUG) { $log_filter = ""; }
+if (get_const('log_level') == L_INFO) { $log_filter = " and `level`=L_INFO "; }
+if (get_const('log_level') == L_ERROR) { $log_filter = " and (`level`=L_INFO or `level`=L_ERROR) "; }
+if (get_const('log_level') == L_VERBOSE) { $log_filter = " and (`level`=L_INFO or `level`=L_ERROR or `level`=L_VERBOSE) "; }
+if (get_const('log_level') == L_DEBUG) { $log_filter = ""; }
 
 if (!empty($log_filter)) { $log_filter = $log_filter." and auth_id=".$auth_id; } else { $log_filter = " and auth_id=".$auth_id; }
 if (!empty($fcustomer)) { $log_filter = $log_filter." and customer LIKE '%".$fcustomer."%'"; }
@@ -66,9 +62,9 @@ foreach ($userlog as $row) {
     print "<td class=\"data\">" . $row['timestamp'] . "</td>\n";
     print "<td class=\"data\">" . $row['customer'] . "</td>\n";
     $msg_level = 'INFO';
-    if ($row['level'] == $L_ERROR) { $msg_level='ERROR'; }
-    if ($row['level'] == $L_DEBUG) { $msg_level='DEBUG'; }
-    if ($row['level'] == $L_VERBOSE) { $msg_level='VERBOSE'; }
+    if ($row['level'] == L_ERROR) { $msg_level='ERROR'; }
+    if ($row['level'] == L_DEBUG) { $msg_level='DEBUG'; }
+    if ($row['level'] == L_VERBOSE) { $msg_level='VERBOSE'; }
     print "<td class=\"data\">" . $msg_level . "</td>\n";
     $print_msg = expand_log_str($db_link, $row['message']);
     print "<td class=\"data\" align=left>" . $print_msg . "</td>\n";

+ 1 - 1
html/admin/logs/detaillog.php

@@ -1,6 +1,6 @@
 <?php
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/auth.php");
-require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . $language . ".php");
+require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . HTML_LANG . ".php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/header.php");
 $default_date_shift='h';
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/datetimefilter.php");

+ 1 - 1
html/admin/logs/dhcp.php

@@ -1,6 +1,6 @@
 <?php
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/auth.php");
-require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . $language . ".php");
+require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . HTML_LANG . ".php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/header.php");
 $default_date_shift='d';
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/datefilter.php");

+ 11 - 16
html/admin/logs/index.php

@@ -1,6 +1,6 @@
 <?php
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/auth.php");
-require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . $language . ".php");
+require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . HTML_LANG . ".php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/header.php");
 $default_date_shift='d';
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/datefilter.php");
@@ -14,7 +14,7 @@ print_log_submenu($page_url);
 Начало:<input type="date" name="date_start" value="<?php echo $date1; ?>" />
 Конец:<input type="date" name="date_stop" value="<?php echo $date2; ?>" />
 Отображать:<?php print_row_at_pages('rows',$displayed); ?>
-Уровень логов:<?php print_loglevel_select('log_level',$log_level); ?>
+Уровень логов:<?php print_loglevel_select('log_level',get_const('log_level')); ?>
 <input type="submit" value="OK"><br><br>
 Фильтр Источник:<input name="customer" value="<?php echo $fcustomer; ?>" />
 Сообщение:<input name="message" value="<?php echo $fmessage; ?>" />
@@ -23,17 +23,12 @@ print_log_submenu($page_url);
 <?php
 $log_filter ='';
 
-global $L_ERROR;
-global $L_WARNING;
-global $L_INFO;
-global $L_VERBOSE;
-global $L_DEBUG;
 
-if ($log_level === $L_ERROR) { $log_filter = " and `level`=$L_ERROR "; }
-if ($log_level === $L_WARNING) { $log_filter = " and `level`<=$L_WARNING "; }
-if ($log_level === $L_INFO) { $log_filter = " and `level`<=$L_INFO "; }
-if ($log_level === $L_VERBOSE) { $log_filter = " and `level`<=$L_VERBOSE "; }
-if ($log_level === $L_DEBUG) { $log_filter = ""; }
+if (get_const('log_level') === L_ERROR) { $log_filter = " and `level`=L_ERROR "; }
+if (get_const('log_level') === L_WARNING) { $log_filter = " and `level`<=L_WARNING "; }
+if (get_const('log_level') === L_INFO) { $log_filter = " and `level`<=L_INFO "; }
+if (get_const('log_level') === L_VERBOSE) { $log_filter = " and `level`<=L_VERBOSE "; }
+if (get_const('log_level') === L_DEBUG) { $log_filter = ""; }
 
 if (!empty($fcustomer)) { $log_filter = $log_filter." and customer LIKE '%".$fcustomer."%'"; }
 if (!empty($fmessage)) { $log_filter = $log_filter." and message LIKE '%".$fmessage."%'"; }
@@ -68,10 +63,10 @@ foreach ($userlog as $row) {
     print "<td class=\"data\">" . $row['timestamp'] . "</td>\n";
     print "<td class=\"data\">" . $row['customer'] . "</td>\n";
     $msg_level = 'INFO';
-    if ($row['level'] == $L_ERROR) { $msg_level='ERROR'; }
-    if ($row['level'] == $L_WARNING) { $msg_level='WARNING'; }
-    if ($row['level'] == $L_DEBUG) { $msg_level='DEBUG'; }
-    if ($row['level'] == $L_VERBOSE) { $msg_level='VERBOSE'; }
+    if ($row['level'] == L_ERROR) { $msg_level='ERROR'; }
+    if ($row['level'] == L_WARNING) { $msg_level='WARNING'; }
+    if ($row['level'] == L_DEBUG) { $msg_level='DEBUG'; }
+    if ($row['level'] == L_VERBOSE) { $msg_level='VERBOSE'; }
     print "<td class=\"data\">" . $msg_level . "</td>\n";
     $print_msg = expand_log_str($db_link, $row['message']);
     print "<td class=\"data\" align=left>" . $print_msg . "</td>\n";

+ 1 - 1
html/admin/logs/ip.php

@@ -1,6 +1,6 @@
 <?php
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/auth.php");
-require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . $language . ".php");
+require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . HTML_LANG . ".php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/header.php");
 $default_date_shift='m';
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/datefilter.php");

+ 1 - 1
html/admin/logs/mac.php

@@ -1,6 +1,6 @@
 <?php
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/auth.php");
-require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . $language . ".php");
+require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . HTML_LANG . ".php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/header.php");
 $default_date_shift='m';
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/datefilter.php");

+ 1 - 1
html/admin/logs/syslog.php

@@ -1,6 +1,6 @@
 <?php
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/auth.php");
-require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . $language . ".php");
+require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . HTML_LANG . ".php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/header.php");
 $default_date_shift='d';
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/datefilter.php");

+ 1 - 1
html/admin/logs/unknown.php

@@ -1,6 +1,6 @@
 <?php
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/auth.php");
-require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . $language . ".php");
+require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . HTML_LANG . ".php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/header.php");
 $default_date_shift='m';
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/datefilter.php");

+ 1 - 1
html/admin/queues/index.php

@@ -1,6 +1,6 @@
 <?php
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/auth.php");
-require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . $language . ".php");
+require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . HTML_LANG . ".php");
 
 if (isset($_POST['save'])) {
     $len = is_array($_POST['id']) ? count($_POST['id']) : 0;

+ 1 - 1
html/admin/reports/authday.php

@@ -1,6 +1,6 @@
 <?php
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/auth.php");
-require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . $language . ".php");
+require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . HTML_LANG . ".php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/header.php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/idfilter.php");
 $default_date_shift='d';

+ 1 - 1
html/admin/reports/index-full.php

@@ -1,7 +1,7 @@
 <?php
 $default_displayed=100;
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/auth.php");
-require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . $language . ".php");
+require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . HTML_LANG . ".php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/header.php");
 $default_date_shift='d';
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/datefilter.php");

+ 1 - 1
html/admin/reports/index.php

@@ -1,6 +1,6 @@
 <?php
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/auth.php");
-require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . $language . ".php");
+require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . HTML_LANG . ".php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/header.php");
 $default_date_shift='d';
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/datefilter.php");

+ 1 - 1
html/admin/reports/userday.php

@@ -1,6 +1,6 @@
 <?php
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/auth.php");
-require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . $language . ".php");
+require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . HTML_LANG . ".php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/header.php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/idfilter.php");
 $default_date_shift='d';

+ 1 - 1
html/admin/reports/userdaydetail.php

@@ -1,6 +1,6 @@
 <?php
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/auth.php");
-require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . $language . ".php");
+require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . HTML_LANG . ".php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/header.php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/idfilter.php");
 $default_date_shift='d';

+ 1 - 1
html/admin/reports/userdaydetaillog.php

@@ -1,6 +1,6 @@
 <?php
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/auth.php");
-require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . $language . ".php");
+require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . HTML_LANG . ".php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/header.php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/idfilter.php");
 $default_date_shift='h';

+ 1 - 3
html/admin/users/add_dhcp.php

@@ -1,8 +1,6 @@
 <?php
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/qauth.php");
 
-global $default_user_ou_id;
-global $default_hotspot_user_id;
 
 if (!empty($_GET["ip"]) and !empty($_GET["mac"])) {
     $ip = $_GET["ip"];
@@ -45,7 +43,7 @@ if (!empty($_GET["ip"]) and !empty($_GET["mac"])) {
 	if ($action ==='del' and !empty($auth)) {
             $last_time = strtotime($auth['dhcp_time']);
             LOG_VERBOSE($db_link,"Delete action found for ip $ip (id: $aid, userid: ".$auth['user_id']."). Last timestamp = ".strftime('%Y-%m-%d %H-%M-%S',$last_time)." Now = ".strftime('%Y-%m-%d %H-%M-%S',time()),$aid);
-	    if ((time() - $last_time>60) and ($auth['ou_id'] == $default_user_ou_id or $auth['ou_id'] == $default_hotspot_ou_id)) {
+	    if ((time() - $last_time>60) and ($auth['ou_id'] == get_const('default_user_ou_id') or $auth['ou_id'] == get_const('default_hotspot_ou_id'))) {
                 LOG_VERBOSE($db_link,"Remove dynamic user ip (id: $aid) by dhcp request for ip: $ip mac: $mac",$aid);
 	        delete_record($db_link,"User_auth","id=".$aid);
 	        $u_count=get_count_records($db_link,'User_auth','deleted=0 and user_id='.$auth['user_id']);

+ 1 - 1
html/admin/users/edit_alias.php

@@ -1,7 +1,7 @@
 <?php
 
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/auth.php");
-require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . $language . ".php");
+require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . HTML_LANG . ".php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/idfilter.php");
 
 $msg_error = "";

+ 1 - 1
html/admin/users/edit_rules.php

@@ -1,7 +1,7 @@
 <?php
 
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/auth.php");
-require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . $language . ".php");
+require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . HTML_LANG . ".php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/idfilter.php");
 
 $msg_error = "";

+ 3 - 5
html/admin/users/editauth.php

@@ -1,10 +1,8 @@
 <?php
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/auth.php");
-require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . $language . ".php");
+require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . HTML_LANG . ".php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/idfilter.php");
 
-global $default_user_ou_id;
-global $default_hotspot_ou_id;
 
 $msg_error = "";
 
@@ -58,7 +56,7 @@ if (isset($_POST["editauth"]) and !$old_auth_info['deleted']) {
         if (empty($f_dnsname)) { $new['dns_name'] = ''; }
         $new['save_traf'] = $_POST["f_save_traf"] * 1;
         $new['dhcp_acl'] = trim($_POST["f_acl"]);
-        if ($default_user_ou_id == $parent_ou_id or $default_hotspot_ou_id == $parent_ou_id) {
+        if (get_const('default_user_ou_id') == $parent_ou_id or get_const('default_hotspot_ou_id') == $parent_ou_id) {
                 $new['nagios_handler'] = '';
                 $new['enabled'] = 0;
                 $new['link_check'] = 0;
@@ -153,7 +151,7 @@ if (isset($_POST["recovery"]) and $old_auth_info['deleted']) {
 	        $new['user_id'] = $new_user_id;
 		}
 
-        if ($default_user_ou_id == $parent_ou_id or $default_hotspot_ou_id == $parent_ou_id) {
+        if (get_const('default_user_ou_id') == $parent_ou_id or get_const('default_hotspot_ou_id') == $parent_ou_id) {
                 $new['nagios_handler'] = '';
                 $new['enabled'] = 0;
                 $new['link_check'] = 0;

+ 4 - 8
html/admin/users/edituser.php

@@ -1,10 +1,8 @@
 <?php
 require_once ($_SERVER["DOCUMENT_ROOT"]."/inc/auth.php");
-require_once ($_SERVER["DOCUMENT_ROOT"]."/inc/languages/" . $language . ".php");
+require_once ($_SERVER["DOCUMENT_ROOT"]."/inc/languages/" . HTML_LANG . ".php");
 require_once ($_SERVER["DOCUMENT_ROOT"]."/inc/idfilter.php");
 
-global $default_user_ou_id;
-global $default_hotspot_ou_id;
 
 $default_sort='ip_int';
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/sortfilter.php");
@@ -21,7 +19,7 @@ if (isset($_POST["edituser"])) {
     $new["queue_id"] = $_POST["f_queue"]*1;
     $new["login"] = trim($_POST["f_login"]);
     $new["fio"] = trim($_POST["f_fio"]);
-    if ($default_user_ou_id == $new["ou_id"] or $default_hotspot_ou_id == $new["ou_id"]) {
+    if (get_const('default_user_ou_id') == $new["ou_id"] or get_const('default_hotspot_ou_id') == $new["ou_id"]) {
         $new["enabled"] = 0;
         $new["blocked"] = 0;
         $new["day_quota"] = 0;
@@ -89,14 +87,12 @@ if (isset($_POST["showDevice"])) {
     $device = get_record_sql($db_link,"SELECT * FROM devices WHERE user_id=".$id);
     $auth = get_record_sql($db_link,"SELECT * FROM User_auth WHERE user_id=".$id);
     if (empty($device) and !empty($auth)) {
-        global $snmp_default_version;
-        global $snmp_default_community;
 	$new['user_id']=$id;
         $new['device_name'] = $user_info['login'];
         $new['device_type'] = 5;
         $new['ip']=$auth['ip'];
-        $new['community'] = $snmp_default_community;
-        $new['snmp_version'] = $snmp_default_version;
+        $new['community'] = get_const('snmp_default_community');
+        $new['snmp_version'] = get_const('snmp_default_version');
         $new_id=insert_record($db_link, "devices", $new);
         unset($_POST);
         if (!empty($new_id)) {

+ 2 - 3
html/admin/users/index.php

@@ -1,10 +1,9 @@
 <?php
 $default_displayed = 500;
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/auth.php");
-require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . $language . ".php");
+require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . HTML_LANG . ".php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/header.php");
-global $default_user_ou_id;
-$default_ou=$default_user_ou_id;
+$default_ou=get_const('default_user_ou_id');
 
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/oufilter.php");
 $default_sort='login';

+ 138 - 324
html/inc/common.php

@@ -3,75 +3,12 @@ if (! defined("CONFIG")) { die("Not defined"); }
 
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/class.simple.mail.php");
 
-$config["init"]=0;
-
 #ValidIpAddressRegex = "^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$";
 #ValidHostnameRegex = "^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])$";
 #$ValidMacAddressRegex="^([0-9A-Fa-f]{2}[:-]){5}[0-9A-Fa-f]{2}|([0-9a-fA-F]{4}[\\.-][0-9a-fA-F]{4}[\\.-][0-9a-fA-F]{4})|[0-9A-Fa-f]{12}$";
 
-$port_status_oid        = '.1.3.6.1.2.1.2.2.1.8.';
-$port_admin_status_oid  = '.1.3.6.1.2.1.2.2.1.7.';
-$port_speed_oid         = '.1.3.6.1.2.1.2.2.1.5.';
-$port_errors_oid        = '.1.3.6.1.2.1.2.2.1.14.';
-$port_vlan_oid          = '.1.3.6.1.2.1.17.7.1.4.5.1.1.';
-
-
-$mac_table_oid          = '.1.3.6.1.2.1.17.7.1.2.2.1.2';
-$mac_table_oid2         = '.1.3.6.1.2.1.17.4.3.1.2';
-
-$eltex_sfp_status       = '.1.3.6.1.4.1.89.90.1.2.1.3';
-$eltex_sfp_vendor       = '.1.3.6.1.4.1.35265.1.23.53.1.1.1.5';
-$eltex_sfp_sn           = '.1.3.6.1.4.1.35265.1.23.53.1.1.1.6';
-$eltex_sfp_freq         = '.1.3.6.1.4.1.35265.1.23.53.1.1.1.4';
-$eltex_sfp_length       = '.1.3.6.1.4.1.35265.1.23.53.1.1.1.8';
-
-$cisco_descr            = '.1.3.6.1.2.1.1.1.0';
-$cisco_modules          = '.1.3.6.1.2.1.47.1.1.1.1.7';
-$cisco_sfp_sensors      = '.1.3.6.1.4.1.9.9.91.1.1.1.1.4';
-$cisco_sfp_precision    = '.1.3.6.1.4.1.9.9.91.1.1.1.1.3';
-$cisco_vlan_oid         = '.1.3.6.1.4.1.9.9.9.46.1.3.1.1.2';
-
-$ifmib_ifindex          = '.1.3.6.1.2.1.2.2.1.1';
-$ifmib_ifindex_map      = '.1.3.6.1.2.1.17.1.4.1.2';
-$ifmib_ifdescr          = '.1.3.6.1.2.1.2.2.1.2';
-$ifmib_ifname           = '.1.3.6.1.2.1.31.1.1.1.1';
-
-$huawei_sfp_vendor      = '.1.3.6.1.4.1.2011.5.25.31.1.1.2.1.11';
-$huawei_sfp_speed       = '.1.3.6.1.4.1.2011.5.25.31.1.1.2.1.2';
-$huawei_sfp_volt        = '.1.3.6.1.4.1.2011.5.25.31.1.1.3.1.6';
-$huawei_sfp_optrx       = '.1.3.6.1.4.1.2011.5.25.31.1.1.3.1.32';
-$huawei_sfp_opttx       = '.1.3.6.1.4.1.2011.5.25.31.1.1.3.1.33';
-$huawei_sfp_biascurrent = '.1.3.6.1.4.1.2011.5.25.31.1.1.3.1.31';
-$huawei_sfp_rx          = '.1.3.6.1.4.1.2011.5.25.31.1.1.3.1.8';
-$huawei_sfp_tx          = '.1.3.6.1.4.1.2011.5.25.31.1.1.3.1.9';
-
-$pethPsePortAdminEnable = '.1.3.6.1.2.1.105.1.1.1.3.1';
-$huawei_poe_oid         = '.1.3.6.1.4.1.2011.5.25.195.3.1.3';
-$allied_poe_oid         = '.1.3.6.1.2.1.105.1.1.1.3.1';
-$hp_poe_oid             = '.1.3.6.1.2.1.105.1.1.1.3.1';
-$netgear_poe_oid        = '.1.3.6.1.4.1.4526.11.15.1.1.1.6.1';
-$mikrotik_poe_oid       = '.1.3.6.1.4.1.14988.1.1.15.1.1.3';
-
-// interface id
-$mikrotik_poe_int       = '.1.3.6.1.4.1.14988.1.1.15.1.1.1';
-// interface names
-$mikrotik_poe_int_names = '.1.3.6.1.4.1.14988.1.1.15.1.1.2';
-// voltage in dV (decivolt)
-$mikrotik_poe_volt      = '.1.3.6.1.4.1.14988.1.1.15.1.1.4';
-// current in mA
-$mikrotik_poe_current   = '.1.3.6.1.4.1.14988.1.1.15.1.1.5';
-// power usage in dW (deviwatt)
-$mikrotik_poe_usage     = '.1.3.6.1.4.1.14988.1.1.15.1.1.6';
-
-$sysinfo_mib            = '.1.3.6.1.2.1.1';
-
-$L_ERROR = 0;
-$L_WARNING = 1;
-$L_INFO = 2;
-$L_VERBOSE = 3;
-$L_DEBUG = 255;
-
-$log_level = 2;
+
+$config["init"]=0;
 
 // #### vendor id
 // 1, Unknown
@@ -90,15 +27,6 @@ $log_level = 2;
 // 17, 'Maipu'
 // 18, 'Asus'
 
-$admin_email = "admin";
-$sender_email = "root";
-$send_email = 0;
-
-
-
-$mac_table_str_oid = '.1.3.6.1.2.1.17.4.3.1.2';
-$mac_table_str_oid2 = '1.3.6.1.2.1.17.7.1.2.2.1.2';
-
 function get_user_ip()
 {
     $auth_ip = getenv("HTTP_CLIENT_IP");
@@ -123,10 +51,9 @@ function fbytes($traff)
         "G",
         "T"
     );
-    $KB = 1024;
     if (!empty($traff) and $traff > 0) {
-        $index = min(((int) log($traff, $KB)), count($units) - 1);
-        $result = round($traff / pow($KB, $index), 3) . ' ' . $units[$index] . 'b';
+        $index = min(((int) log($traff, get_const('KB'))), count($units) - 1);
+        $result = round($traff / pow(get_const('KB'), $index), 3) . ' ' . $units[$index] . 'b';
     } else {
         $result = '0 b';
     }
@@ -142,10 +69,9 @@ function fpkts($packets)
         "G",
         "T"
     );
-    $KB = 1000;
     if (!empty($packets) and $packets > 0) {
-        $index = min(((int) log($packets, $KB)), count($units) - 1);
-        $result = round($packets / pow($KB, $index), 3) . ' ' . $units[$index] . 'pkt/s';
+        $index = min(((int) log($packets, get_const('KB'))), count($units) - 1);
+        $result = round($packets / pow(get_const('KB'), $index), 3) . ' ' . $units[$index] . 'pkt/s';
     } else {
         $result = '0 pkt/s';
     }
@@ -480,16 +406,11 @@ function print_subnet_select_office($db, $subnet_name, $subnet_value)
 function print_loglevel_select($item_name, $value)
 {
     print "<select name=\"$item_name\">\n";
-    global $L_INFO;
-    global $L_WARNING;
-    global $L_ERROR;
-    global $L_VERBOSE;
-    global $L_DEBUG;
-    print_select_item('Error',$L_ERROR,$value);
-    print_select_item('Warning',$L_WARNING,$value);
-    print_select_item('Info',$L_INFO,$value);
-    print_select_item('Verbose',$L_VERBOSE,$value);
-    print_select_item('Debug',$L_DEBUG,$value);
+    print_select_item('Error',L_ERROR,$value);
+    print_select_item('Warning',L_WARNING,$value);
+    print_select_item('Info',L_INFO,$value);
+    print_select_item('Verbose',L_VERBOSE,$value);
+    print_select_item('Debug',L_DEBUG,$value);
     print "</select>\n";
 }
 
@@ -1365,11 +1286,9 @@ return $set_auth;
 }
 
 function fix_auth_rules($db) {
-global $default_user_ou_id;
-global $default_hotspot_ou_id;
 //cleanup hotspot subnet rules
-delete_record($db,"auth_rules","ou_id=".$default_user_ou_id);
-delete_record($db,"auth_rules","ou_id=".$default_hotspot_ou_id);
+delete_record($db,"auth_rules","ou_id=".get_const('default_user_ou_id'));
+delete_record($db,"auth_rules","ou_id=".get_const('default_hotspot_ou_id'));
 $t_hotspot = get_records_sql($db,"SELECT * FROM subnets WHERE hotspot=1");
 if (!empty($t_hotspot)) {
     foreach ($t_hotspot as $row) { delete_record($db,"auth_rules","rule='".$row['subnet']."'"); }
@@ -1379,7 +1298,6 @@ if (!empty($t_hotspot)) {
 #---------------------------------------------------------------------------------------------------------------
 
 function new_user($db,$user_info) {
-global $auto_mac_rule;
 if (!empty($user_info['mac'])) {
     $user['login']=mac_dotted($user_info['mac']);
     } else {
@@ -1612,39 +1530,29 @@ function isRO($db,$table)
 }
 
 function LOG_INFO($db,$msg,$auth_id = 0) {
-global $L_INFO;
-global $log_level;
-if ($log_level < $L_INFO) { return; }
-write_log($db,$msg,$L_INFO,$auth_id);
+if (get_const('log_level') < L_INFO) { return; }
+write_log($db,$msg,L_INFO,$auth_id);
 }
 
 function LOG_ERROR($db,$msg,$auth_id = 0) {
-global $L_ERROR;
-global $log_level;
-if ($log_level < $L_ERROR) { return; }
-email($L_ERROR,$msg);
-write_log($db,$msg,$L_ERROR,$auth_id);
+if (get_const('log_level') < L_ERROR) { return; }
+email(L_ERROR,$msg);
+write_log($db,$msg,L_ERROR,$auth_id);
 }
 
 function LOG_VERBOSE($db,$msg,$auth_id=0) {
-global $L_VERBOSE;
-global $log_level;
-if ($log_level < $L_VERBOSE) { return; }
-write_log($db,$msg,$L_VERBOSE,$auth_id);
+if (get_const('log_level') < L_VERBOSE) { return; }
+write_log($db,$msg,L_VERBOSE,$auth_id);
 }
 
 function LOG_WARNING($db,$msg,$auth_id=0) {
-global $L_WARNING;
-global $log_level;
-if ($log_level < $L_WARNING) { return; }
-email($L_WARNING,$msg);
-write_log($db,$msg,$L_WARNING,$auth_id);
+if (get_const('log_level') < L_WARNING) { return; }
+email(L_WARNING,$msg);
+write_log($db,$msg,L_WARNING,$auth_id);
 }
 
 function LOG_DEBUG($db,$msg,$auth_id=0) {
-global $debug;
-global $L_DEBUG;
-if (isset($debug) and $debug) { write_log($db,$msg,$L_DEBUG,$auth_id); }
+if (!empty(get_const('debug')) and get_const('debug')) { write_log($db,$msg,L_DEBUG,$auth_id); }
 }
 
 function get_first_line($msg) {
@@ -1655,26 +1563,21 @@ return;
 }
 
 function email ($level,$msg) {
-global $send_email;
-global $admin_email;
-global $sender_email;
-global $L_WARNING;
-global $L_ERROR;
 
-if (!$send_email) { return; }
-if (!($level === $L_WARNING or $level === $L_ERROR)) { return; }
+if (!get_const('send_email')) { return; }
+if (!($level === L_WARNING or $level === L_ERROR)) { return; }
 
 $subject = get_first_line($msg);
 
-if ($level === $L_WARNING) { $subject = "WARN: ".$subject."..."; $message = 'WARNING! Manager: '.$_SESSION['login'].' </br>'; }
-if ($level === $L_ERROR) { $subject = "ERROR: ".$subject."..."; $message = 'ERROR! Manager: '.$_SESSION['login'].' </br>'; }
+if ($level === L_WARNING) { $subject = "WARN: ".$subject."..."; $message = 'WARNING! Manager: '.$_SESSION['login'].' </br>'; }
+if ($level === L_ERROR) { $subject = "ERROR: ".$subject."..."; $message = 'ERROR! Manager: '.$_SESSION['login'].' </br>'; }
 
 $msg_lines = preg_replace("/\r\n/","</br>",$msg);
 $message .= $msg_lines;
 
 $send = SimpleMail::make()
-    ->setTo($admin_email, 'Administrator')
-    ->setFrom($sender_email, 'Stat')
+    ->setTo(get_const('admin_email'), 'Administrator')
+    ->setFrom(get_const('sender_email'), 'Stat')
     ->setSubject($subject)
     ->setMessage($message)
     ->setHtml()
@@ -1691,8 +1594,7 @@ function write_log($db, $msg, $level, $auth_id = 0)
     if (! isset($msg)) {
         $msg = 'ERROR! Empty log string!';
     }
-    global $L_INFO;
-    if (!isset($level)) { $level = $L_INFO; }
+    if (!isset($level)) { $level = L_INFO; }
     $msg = str_replace("'", '', $msg);
     $sSQL = "insert into syslog(customer,message,level,auth_id) values('$work_user','$msg',$level,$auth_id)";
     mysqli_query($db, $sSQL);
@@ -1784,6 +1686,7 @@ function get_mac_port_table($ip, $port_index, $community, $version, $oid, $index
         $version = '2';
     }
     $mac_table = walk_snmp($ip, $community, $version, $oid);
+var_dump($mac_table);
     if (isset($mac_table) and count($mac_table) > 0) {
         foreach ($mac_table as $key => $value) {
             $key = trim($key);
@@ -1804,11 +1707,9 @@ function get_mac_port_table($ip, $port_index, $community, $version, $oid, $index
 
 function get_ifmib_index_table ($ip, $community, $version)
 {
-global $ifmib_ifindex_map;
-global $ifmib_ifindex;
 $ifmib_map = NULL;
-$index_table =  walk_snmp($ip, $community, $version, $ifmib_ifindex_map);
-$is_mikrotik = walk_snmp($ip, $community, '.1.3.6.1.2.1.9999.1.1.1.1.0', $version);
+$index_table =  walk_snmp($ip, $community, $version, IFMIB_IFINDEX_MAP);
+$is_mikrotik = walk_snmp($ip, $community, $version, '.1.3.6.1.2.1.9999.1.1.1.1.0');
 if (isset($index_table) and count($index_table) > 0 and isset($is_mikrotik)) {
         foreach ($index_table as $key => $value) {
             $key = trim($key);
@@ -1820,7 +1721,7 @@ if (isset($index_table) and count($index_table) > 0 and isset($is_mikrotik)) {
                 }
             }
         } else {
-#        $index_table =  walk_snmp($ip, $community, $version, $ifmib_ifindex);
+#        $index_table =  walk_snmp($ip, $community, $version, IFMIB_IFINDEX);
         if (isset($index_table) and count($index_table) > 0) {
             foreach ($index_table as $key => $value) {
                 $key = trim($key);
@@ -1838,10 +1739,6 @@ return $ifmib_map;
 
 function get_fdb_port_table($ip, $port_index, $community, $version)
 {
-    global $mac_table_str_oid;
-    global $mac_table_str_oid2;
-    global $mac_table_oid;
-    global $mac_table_oid2;
 
     if (! isset($ip)) {
         return;
@@ -1857,9 +1754,8 @@ function get_fdb_port_table($ip, $port_index, $community, $version)
     }
 
     $ifindex_map = get_ifmib_index_table($ip,$community, $version);
-
-    $fdb1_port_table = get_mac_port_table($ip, $port_index, $community, $version, $mac_table_oid2, $ifindex_map);
-    $fdb2_port_table = get_mac_port_table($ip, $port_index, $community, $version, $mac_table_oid, $ifindex_map);
+    $fdb1_port_table = get_mac_port_table($ip, $port_index, $community, $version, MAC_TABLE_OID2, $ifindex_map);
+    $fdb2_port_table = get_mac_port_table($ip, $port_index, $community, $version, MAC_TABLE_OID, $ifindex_map);
 
     if (!empty($fdb1_port_table)) { $fdb_port_table = $fdb1_port_table; }
     if (!empty($fdb2_port_table)) {
@@ -1874,8 +1770,7 @@ function get_fdb_port_table($ip, $port_index, $community, $version)
 
     // maybe cisco?!
     if (! isset($fdb_port_table) or ! $fdb_port_table or count($fdb_port_table) == 0) {
-        global $cisco_vlan_oid;
-        $vlan_table = walk_snmp($ip, $community, $version, $cisco_vlan_oid);
+        $vlan_table = walk_snmp($ip, $community, $version, CISCO_VLAN_OID);
         if (! $vlan_table) {
             return;
         }
@@ -1887,9 +1782,9 @@ function get_fdb_port_table($ip, $port_index, $community, $version)
             if (!empty($result)) {
                 $vlan_id = preg_replace('/^\./', '', $matches[0]);
                 if ($vlan_id > 1000 and $vlan_id < 1009) { continue; }
-                $fdb_vlan_table = get_mac_port_table($ip, $port_index, $community . '@' . $vlan_id, $version, $mac_table_oid2,$ifindex_map);
+                $fdb_vlan_table = get_mac_port_table($ip, $port_index, $community . '@' . $vlan_id, $version, MAC_TABLE_OID2,$ifindex_map);
                 if (! isset($fdb_vlan_table) or ! $fdb_vlan_table or count($fdb_vlan_table) == 0) {
-                    $fdb_vlan_table = get_mac_port_table($ip, $port_index, $community, $version, $mac_table_oid,$ifindex_map);
+                    $fdb_vlan_table = get_mac_port_table($ip, $port_index, $community, $version, MAC_TABLE_OID,$ifindex_map);
                 }
                 foreach ($fdb_vlan_table as $mac => $port) {
                     if (! isset($mac)) { continue; }
@@ -1926,19 +1821,15 @@ function get_mac_table($ip, $community, $version, $oid, $index_map)
             $result = preg_match($pattern, $key, $matches);
             if (!empty($result)) {
                     $mac_key = preg_replace('/^\./', '', $matches[0]);
-                    $fdb_port_table[$mac_key] = $value;
+                    $fdb_table[$mac_key] = $value;
                 }
         }
     }
-    return $fdb_port_table;
+    return $fdb_table;
 }
 
 function get_fdb_table($ip, $community, $version)
 {
-    global $mac_table_str_oid;
-    global $mac_table_str_oid2;
-    global $mac_table_oid;
-    global $mac_table_oid2;
 
     if (! isset($ip)) {
         return;
@@ -1951,24 +1842,23 @@ function get_fdb_table($ip, $community, $version)
     }
 
     $ifindex_map = get_ifmib_index_table($ip,$community, $version);
+    $fdb1_table = get_mac_table($ip, $community, $version, MAC_TABLE_OID2, $ifindex_map);
+    $fdb2_table = get_mac_table($ip, $community, $version, MAC_TABLE_OID, $ifindex_map);
 
-    $fdb1_port_table = get_mac_table($ip, $community, $version, $mac_table_oid2, $ifindex_map);
-    $fdb2_port_table = get_mac_table($ip, $community, $version, $mac_table_oid, $ifindex_map);
-    if (!empty($fdb1_port_table)) { $fdb_port_table = $fdb1_port_table; }
-    if (!empty($fdb2_port_table)) {
-        if (empty($fdb_port_table)) {
-            $fdb_port_table = $fdb2_port_table;
+    if (!empty($fdb1_table)) { $fdb_table = $fdb1_table; }
+    if (!empty($fdb2_table)) {
+        if (empty($fdb_table)) {
+            $fdb_table = $fdb2_table;
             } else {
-            foreach ($fdb2_port_table as $mac => $port) {
-                if (empty($fdb_port_table[$mac])) { $fdb_port_table[$mac]=$port; }
+            foreach ($fdb2_table as $mac => $port) {
+                if (empty($fdb_table[$mac])) { $fdb_table[$mac]=$port; }
                 }
             }
         }
 
     // maybe cisco?!
-    if (! isset($fdb_port_table) or ! $fdb_port_table or count($fdb_port_table) == 0) {
-        global $cisco_vlan_oid;
-        $vlan_table = walk_snmp($ip, $community, $version, $cisco_vlan_oid);
+    if (! isset($fdb_table) or ! $fdb_table or count($fdb_table) == 0) {
+        $vlan_table = walk_snmp($ip, $community, $version, CISCO_VLAN_OID);
         if (! $vlan_table) {
             return;
         }
@@ -1979,18 +1869,18 @@ function get_fdb_table($ip, $community, $version)
             if (!empty($result)) {
                 $vlan_id = preg_replace('/^\./', '', $matches[0]);
                 if ($vlan_id > 1000 and $vlan_id < 1009) { continue; }
-                $fdb_vlan_table = get_mac_table($ip, $community . '@' . $vlan_id, $version, $mac_table_oid2);
+                $fdb_vlan_table = get_mac_table($ip, $community . '@' . $vlan_id, $version, MAC_TABLE_OID2);
                 if (! isset($fdb_vlan_table) or ! $fdb_vlan_table or count($fdb_vlan_table) == 0) {
-                    $fdb_vlan_table = get_mac_table($ip, $community, $version, $mac_table_oid);
+                    $fdb_vlan_table = get_mac_table($ip, $community, $version, MAC_TABLE_OID);
                 }
                 foreach ($fdb_vlan_table as $mac => $port) {
                     if (! isset($mac)) { continue; }
-                    $fdb_port_table[$mac] = $port;
+                    $fdb_table[$mac] = $port;
                 }
             }
         }
     }
-    return $fdb_port_table;
+    return $fdb_table;
 }
 
 function check_snmp_access($ip, $community, $version)
@@ -2023,8 +1913,7 @@ function get_port_state($port, $ip, $community, $version)
     if (! isset($version)) {
         $version = '2';
     }
-    global $port_status_oid;
-    $port_oid = $port_status_oid . $port;
+    $port_oid = PORT_STATUS_OID . $port;
     $port_state = get_snmp($ip, $community, $version, $port_oid);
     return $port_state;
 }
@@ -2042,10 +1931,8 @@ function get_last_digit($oid)
 function get_cisco_sensors($ip, $community, $version, $mkey)
 {
     $index = get_last_digit($mkey);
-    global $cisco_sfp_sensors;
-    global $cisco_sfp_precision;
-    $result = parse_snmp_value(get_snmp($ip, $community, $version, $cisco_sfp_sensors . "." . $index));
-    $prec = parse_snmp_value(get_snmp($ip, $community, $version, $cisco_sfp_precision . "." . $index));
+    $result = parse_snmp_value(get_snmp($ip, $community, $version, CISCO_SFP_SENSORS . "." . $index));
+    $prec = parse_snmp_value(get_snmp($ip, $community, $version, CISCO_SFP_PRECISION . "." . $index));
     if (! isset($prec)) { $prec = 1; }
     $result = round(trim($result) / (10 * $prec), 2);
     return $result;
@@ -2053,24 +1940,20 @@ function get_cisco_sensors($ip, $community, $version, $mkey)
 
 function get_snmp_ifname1($ip, $community, $version, $port)
 {
-    global $ifmib_ifname;
-    $port_name = parse_snmp_value(get_snmp($ip, $community, $version, $ifmib_ifname . "." . $port));
+    $port_name = parse_snmp_value(get_snmp($ip, $community, $version, IFMIB_IFNAME . "." . $port));
     return $port_name;
 }
 
 function get_snmp_ifname2($ip, $community, $version, $port)
 {
-    global $ifmib_ifdescr;
-    $port_name = parse_snmp_value(get_snmp($ip, $community, $version, $ifmib_ifdescr . "." . $port));
+    $port_name = parse_snmp_value(get_snmp($ip, $community, $version, IFMIB_IFDESCR . "." . $port));
     return $port_name;
 }
 
 function get_snmp_interfaces($ip, $community, $version)
 {
-    global $ifmib_ifname;
-    global $ifmib_ifdescr;
-    $result = walk_snmp($ip, $community, $version, $ifmib_ifname);
-    if (empty($result)) { $result = walk_snmp($ip, $community, $version, $ifmib_ifdescr); }
+    $result = walk_snmp($ip, $community, $version, IFMIB_IFNAME);
+    if (empty($result)) { $result = walk_snmp($ip, $community, $version, IFMIB_IFDESCR); }
     return $result;
 }
 
@@ -2118,33 +2001,26 @@ function get_sfp_status($vendor_id, $port, $ip, $community, $version, $modules_o
     }
     // if (!is_up($ip)) { return; }
 
-    global $ifmib_ifname;
-    global $ifmib_ifdescr;
 
     $status = '';
     // eltex
     if ($vendor_id == 2) {
-        global $eltex_sfp_status;
-        global $eltex_sfp_vendor;
-        global $eltex_sfp_sn;
-        global $eltex_sfp_freq;
-        global $eltex_sfp_length;
-        $sfp_vendor = parse_snmp_value(get_snmp($ip, $community, $version, $eltex_sfp_vendor . "." . $port));
+        $sfp_vendor = parse_snmp_value(get_snmp($ip, $community, $version, ELTEX_SFP_VENDOR . "." . $port));
         if (isset($sfp_vendor)) {
-            $sfp_status_temp = $eltex_sfp_status . "." . $port . ".5";
-            $sfp_status_volt = $eltex_sfp_status . "." . $port . ".6";
-            $sfp_status_circut = $eltex_sfp_status . "." . $port . ".7";
-            $sfp_status_tx = $eltex_sfp_status . "." . $port . ".8";
-            $sfp_status_rx = $eltex_sfp_status . "." . $port . ".9";
+            $sfp_status_temp = ELTEX_SFP_STATUS . "." . $port . ".5";
+            $sfp_status_volt = ELTEX_SFP_STATUS . "." . $port . ".6";
+            $sfp_status_circut = ELTEX_SFP_STATUS . "." . $port . ".7";
+            $sfp_status_tx = ELTEX_SFP_STATUS . "." . $port . ".8";
+            $sfp_status_rx = ELTEX_SFP_STATUS . "." . $port . ".9";
             $temp = parse_snmp_value(get_snmp($ip, $community, $version, $sfp_status_temp));
             $volt = parse_snmp_value(get_snmp($ip, $community, $version, $sfp_status_volt));
             $circut = parse_snmp_value(get_snmp($ip, $community, $version, $sfp_status_circut));
             $tx = parse_snmp_value(get_snmp($ip, $community, $version, $sfp_status_tx));
             $rx = parse_snmp_value(get_snmp($ip, $community, $version, $sfp_status_rx));
-            $sfp_sn = parse_snmp_value(get_snmp($ip, $community, $version, $eltex_sfp_sn . "." . $port));
-            $sfp_freq = parse_snmp_value(get_snmp($ip, $community, $version, $eltex_sfp_freq . "." . $port));
+            $sfp_sn = parse_snmp_value(get_snmp($ip, $community, $version, ELTEX_SFP_SN . "." . $port));
+            $sfp_freq = parse_snmp_value(get_snmp($ip, $community, $version, ELTEX_SFP_FREQ . "." . $port));
             if (! isset($sfp_freq) or $sfp_freq == 65535) {  $sfp_freq = 'unspecified';  }
-            $sfp_length = parse_snmp_value(get_snmp($ip, $community, $version, $eltex_sfp_length . "." . $port));
+            $sfp_length = parse_snmp_value(get_snmp($ip, $community, $version, ELTEX_SFP_LENGTH . "." . $port));
             $status = 'Vendor: ' . $sfp_vendor . ' Serial: ' . $sfp_sn . ' Laser: ' . $sfp_freq . ' Distance: ' . $sfp_length . '<br>';
             if (isset($sfp_status_temp) and $temp > 0.1) { $status .= 'Temp: ' . $temp . " C"; }
             if (isset($sfp_status_volt) and $volt > 0.1) { $status .= ' Volt: ' . round($volt / 1000000, 2) . ' V'; }
@@ -2158,12 +2034,10 @@ function get_sfp_status($vendor_id, $port, $ip, $community, $version, $modules_o
     }
     // cisco
     if ($vendor_id == 16) {
-        global $cisco_descr;
-        global $cisco_modules;
         // get interface names
-        $port_name = parse_snmp_value(get_snmp($ip, $community, $version, $ifmib_ifname . "." . $port));
+        $port_name = parse_snmp_value(get_snmp($ip, $community, $version, IFMIB_IFNAME . "." . $port));
         if (empty($port_name)) {
-            $port_name = parse_snmp_value(get_snmp($ip, $community, $version, $ifmib_ifdescr . "." . $port));
+            $port_name = parse_snmp_value(get_snmp($ip, $community, $version, IFMIB_IFDESCR . "." . $port));
             }
         // search module indexes
         $port_name = preg_quote(trim($port_name), '/');
@@ -2223,21 +2097,12 @@ function get_sfp_status($vendor_id, $port, $ip, $community, $version, $modules_o
 
     // huawei
     if ($vendor_id == 3) {
-        global $huawei_sfp_vendor;
-        global $huawei_sfp_speed;
-        global $huawei_sfp_db;
         
-        global $huawei_sfp_volt;
-        global $huawei_sfp_optrx;
-        global $huawei_sfp_opttx;
-        global $huawei_sfp_rx;
-        global $huawei_sfp_tx;
-        global $huawei_sfp_biascurrent;
         
         // get interface names
-        $port_name = parse_snmp_value(get_snmp($ip, $community, $version, $ifmib_ifname . "." . $port));
+        $port_name = parse_snmp_value(get_snmp($ip, $community, $version, IFMIB_IFNAME . "." . $port));
         if (empty($port_name)) {
-            $port_name = parse_snmp_value(get_snmp($ip, $community, $version, $ifmib_ifdescr . "." . $port));
+            $port_name = parse_snmp_value(get_snmp($ip, $community, $version, IFMIB_IFDESCR . "." . $port));
     	    }
         // search module indexes
         $port_name = preg_quote(trim($port_name), '/');
@@ -2247,22 +2112,22 @@ function get_sfp_status($vendor_id, $port, $ip, $community, $version, $modules_o
             if (isset($matches[0])) {
                 $module_id = get_last_digit($key);
                 unset($result);
-                $result = parse_snmp_value(get_snmp($ip, $community, $version, $huawei_sfp_vendor . "." . $module_id));
+                $result = parse_snmp_value(get_snmp($ip, $community, $version, HUAWEI_SFP_VENDOR . "." . $module_id));
                 if (isset($result)) { $sfp_vendor = $result; }
                 unset($result);
-                $result = parse_snmp_value(get_snmp($ip, $community, $version, $huawei_sfp_speed . "." . $module_id));
+                $result = parse_snmp_value(get_snmp($ip, $community, $version, HUAWEI_SFP_SPEED . "." . $module_id));
                 if (isset($result)) {
                     list ($sfp_speed, $spf_lenght, $sfp_type) = explode('-', $result);
                     if ($sfp_type == 0) { $sfp_type = 'MultiMode'; }
                     if ($sfp_type == 1) { $sfp_type = 'SingleMode'; }
                 }
 
-                $volt = parse_snmp_value(get_snmp($ip, $community, $version, $huawei_sfp_volt . "." . $module_id));
-                $circut = parse_snmp_value(get_snmp($ip, $community, $version, $huawei_sfp_biascurrent . "." . $module_id));
-                $tx = parse_snmp_value(get_snmp($ip, $community, $version, $huawei_sfp_opttx . "." . $module_id));
-                $rx = parse_snmp_value(get_snmp($ip, $community, $version, $huawei_sfp_optrx . "." . $module_id));
-		if (!isset($tx)) { $tx = parse_snmp_value(get_snmp($ip, $community, $version, $huawei_sfp_tx . "." . $module_id)); }
-            	if (!isset($rx)) { $rx = parse_snmp_value(get_snmp($ip, $community, $version, $huawei_sfp_rx . "." . $module_id)); }
+                $volt = parse_snmp_value(get_snmp($ip, $community, $version, HUAWEI_SFP_VOLT . "." . $module_id));
+                $circut = parse_snmp_value(get_snmp($ip, $community, $version, HUAWEI_SFP_BIASCURRENT . "." . $module_id));
+                $tx = parse_snmp_value(get_snmp($ip, $community, $version, HUAWEI_SFP_OPTTX . "." . $module_id));
+                $rx = parse_snmp_value(get_snmp($ip, $community, $version, HUAWEI_SFP_OPTRX . "." . $module_id));
+		if (!isset($tx)) { $tx = parse_snmp_value(get_snmp($ip, $community, $version, HUAWEI_SFP_TX . "." . $module_id)); }
+            	if (!isset($rx)) { $rx = parse_snmp_value(get_snmp($ip, $community, $version, HUAWEI_SFP_RX . "." . $module_id)); }
                 if (isset($sfp_vendor)) {  $status .= ' Name:' . $sfp_vendor.'<br>';  }
 //                if (isset($sfp_speed)) { $status .= ' ' . $sfp_speed; }
 //                if (isset($spf_lenght)) { $status .= ' ' . $spf_lenght; }
@@ -2311,8 +2176,7 @@ function get_port_vlan($port, $port_index, $ip, $community, $version, $fdb_by_sn
 
     if ($fdb_by_snmp == 1) { $port = $port_index; }
 
-    global $port_vlan_oid;
-    $port_oid = $port_vlan_oid . $port;
+    $port_oid = PORT_VLAN_OID . $port;
     $port_vlan = get_snmp($ip, $community, $version, $port_oid);
     $port_vlan = preg_replace('/.*\:/','',$port_vlan);
     $port_vlan = intval(trim($port_vlan));
@@ -2337,32 +2201,26 @@ function get_port_poe_state($vendor_id, $port, $ip, $community, $version)
     // if (!is_up($ip)) { return; }
 
     // default poe oid
-    global $pethPsePortAdminEnable;
-    $poe_status = $pethPsePortAdminEnable . "." . $port;
+    $poe_status = PETH_PSE_PORT_ADMIN_ENABLE . "." . $port;
 
     if ($vendor_id == 3) {
-        global $huawei_poe_oid;
-        $poe_status = $huawei_poe_oid . "." . $port;
+        $poe_status = HUAWEI_POE_OID . "." . $port;
     }
 
     if ($vendor_id == 8) {
-        global $allied_poe_oid;
-        $poe_status = $allied_poe_oid . "." . $port;
+        $poe_status = ALLIED_POE_OID . "." . $port;
     }
 
     if ($vendor_id == 15) {
-        global $hp_poe_oid;
-        $poe_status = $hp_poe_oid . "." . $port;
+        $poe_status = HP_POE_OID . "." . $port;
     }
 
     if ($vendor_id == 9) {
-        global $mikrotik_poe_oid;
-        $poe_status = $mikrotik_poe_oid . "." . $port;
+        $poe_status = MIKROTIK_POE_OID . "." . $port;
     }
 
     if ($vendor_id == 10) {
-        global $netgear_poe_oid;
-        $poe_status = $netgear_poe_oid . "." . $port;
+        $poe_status = NETGEAR_POE_OID . "." . $port;
     }
 
     $result = '';
@@ -2395,23 +2253,18 @@ function set_port_poe_state($vendor_id, $port, $ip, $community, $version, $state
     }
     // if (!is_up($ip)) { return; }
     // default poe oid
-    global $pethPsePortAdminEnable;
-    $poe_status = $pethPsePortAdminEnable . "." . $port;
+    $poe_status = PETH_PSE_PORT_ADMIN_ENABLE . "." . $port;
     if ($vendor_id == 3) {
-        global $huawei_poe_oid;
-        $poe_status = $huawei_poe_oid . "." . $port;
+        $poe_status = HUAWEI_POE_OID . "." . $port;
     }
     if ($vendor_id == 8) {
-        global $allied_poe_oid;
-        $poe_status = $allied_poe_oid . "." . $port;
+        $poe_status = ALLIED_POE_OID . "." . $port;
     }
     if ($vendor_id == 15) {
-        global $hp_poe_oid;
-        $poe_status = $hp_poe_oid . "." . $port;
+        $poe_status = HP_POE_OID . "." . $port;
     }
     if ($vendor_id == 10) {
-        global $netgear_poe_oid;
-        $poe_status = $netgear_poe_oid . "." . $port;
+        $poe_status = NETGEAR_POE_OID . "." . $port;
     }
 
     if ($state) {
@@ -2469,12 +2322,9 @@ function get_port_poe_detail($vendor_id, $port, $ip, $community, $version)
 
     // mikrotik
     if ($vendor_id == 9) {
-        global $mikrotik_poe_volt;
-        global $mikrotik_poe_current;
-        global $mikrotik_poe_usage;
-        $poe_power = $mikrotik_poe_usage . '.' . $port;
-        $poe_current = $mikrotik_poe_current . '.' . $port;
-        $poe_volt = $mikrotik_poe_volt . '.' . $port;
+        $poe_power = MIKROTIK_POE_USAGE . '.' . $port;
+        $poe_current = MIKROTIK_POE_CURRENT . '.' . $port;
+        $poe_volt = MIKROTIK_POE_VOLT . '.' . $port;
     }
 
     // netgear
@@ -2582,8 +2432,7 @@ function set_port_state($vendor_id, $port, $ip, $community, $version, $state)
     if (! isset($version)) {
         $version = '2';
     }
-    global $port_admin_status_oid;
-    $port_status = $port_admin_status_oid . $port;
+    $port_status = PORT_ADMIN_STATUS_OID . $port;
     if ($state == 1) {
         // enable port
         $c_state = set_snmp($ip, $community, $version, $port_status, 'i', 1);
@@ -2656,15 +2505,11 @@ function get_port_state_detail($port, $ip, $community, $version)
     }
     // if (!is_up($ip)) { return; }
 
-    global $port_status_oid;
-    global $port_admin_status_oid;
-    global $port_speed_oid;
-    global $port_errors_oid;
 
-    $oper = $port_status_oid . $port;
-    $admin = $port_admin_status_oid . $port;
-    $speed = $port_speed_oid . $port;
-    $errors = $port_errors_oid . $port;
+    $oper = PORT_STATUS_OID . $port;
+    $admin = PORT_ADMIN_STATUS_OID . $port;
+    $speed = PORT_SPEED_OID . $port;
+    $errors = PORT_ERRORS_OID . $port;
     $result = '';
     $c_state = get_snmp($ip, $community, $version, $oper);
     $p_state = parse_snmp_value($c_state);
@@ -3172,17 +3017,12 @@ function get_diff_rec($db, $table, $filter, $newvalue, $only_changed)
 
 function get_cacti_graph($host_ip, $port_index)
 {
-    global $cacti_dbname;
-    global $cacti_dbhost;
-    global $cacti_url;
-    global $dbuser;
-    global $dbpass;
 
-    if (! isset($cacti_url)) { return; }
+    if (empty(get_const('cacti_url'))) { return; }
 
-    $cacti_db_link = mysqli_connect($cacti_dbhost, $dbuser, $dbpass, $cacti_dbname);
+    $cacti_db_link = mysqli_connect(CACTI_DB_HOST, DB_USER, DB_PASS, CACTI_DB_NAME);
     if (! $cacti_db_link) {
-        echo "Ошибка: Невозможно установить соединение с MySQL with $cacti_dbhost [$cacti_dbname] for $dbuser." . PHP_EOL;
+        echo "Ошибка: Невозможно установить соединение с MySQL with CACTI_DB_HOST [CACTI_DB_NAME] for DB_USER." . PHP_EOL;
         echo "Код ошибки errno: " . mysqli_connect_errno() . PHP_EOL;
         echo "Текст ошибки error: " . mysqli_connect_error() . PHP_EOL;
         return FALSE;
@@ -3198,7 +3038,7 @@ function get_cacti_graph($host_ip, $port_index)
     $graph_id = $cacti_graph["id"];
 
     if (empty($graph_id)) { return; }
-    $result = $cacti_url . "/graph_image.php?local_graph_id=" . $graph_id;
+    $result = get_const('cacti_url') . "/graph_image.php?local_graph_id=" . $graph_id;
     return $result;
 }
 
@@ -3317,8 +3157,6 @@ return 0;
 
 function get_new_user_id($db, $ip, $mac, $hostname)
 {
-    global $default_hotspot_ou_id;
-    global $default_user_ou_id;
     
     $result['ip']=$ip;
     $result['mac']=mac_dotted($mac);
@@ -3355,7 +3193,7 @@ function get_new_user_id($db, $ip, $mac, $hostname)
     //ou rules
     //ip
     if (!empty($ip)) {
-        if (is_hotspot($db, $ip)) { $result['ou_id']=$default_hotspot_ou_id; }
+        if (is_hotspot($db, $ip)) { $result['ou_id']=get_const('default_hotspot_ou_id'); }
         $t_rules = get_records_sql($db, "SELECT * FROM auth_rules WHERE type=1 and LENGTH(rule)>0 AND ou_id IS NOT NULL");
         foreach ($t_rules as $row) {
             if (!empty($row['rule']) and is_subnet_aton($row['rule'],$ip_aton)) { $result['ou_id']=$row['ou_id']; }
@@ -3376,7 +3214,7 @@ function get_new_user_id($db, $ip, $mac, $hostname)
             }
         }
 
-    if (empty($result['ou_id'])) { $result['ou_id']=$default_user_ou_id; }
+    if (empty($result['ou_id'])) { $result['ou_id']=get_const('default_user_ou_id'); }
 
     return $result;
 }
@@ -3431,66 +3269,42 @@ function is_our_network($db, $ip)
     return 0;
 }
 
-function init_option($db)
-{
-    global $org_name;
-    $org_name = get_option($db, 32);
-
-    global $KB;
-    $KB = get_option($db, 1);
-
-    global $debug;
-    $debug = get_option($db, 34);
-
-    global $log_level;
-    $log_level = get_option($db, 53);
-
-    if ($debug) { $log_level = 255; }
-
-    global $send_email;
-    $send_email = get_option($db, 51);
-
-    global $admin_email;
-    $admin_email = get_option($db, 21);
-
-    global $sender_email;
-    $sender_email = get_option($db, 52);
-
-    global $mac_discovery;
-    $mac_discovery = get_option($db, 17);
-
-    global $snmp_default_version;
-    $snmp_default_version = get_option($db, 9);
-
-    global $snmp_default_community;
-    $snmp_default_community = get_option($db, 11);
+function get_const($const_name) {
+global $config;
+if (isset($config[$const_name])) { return $config[$const_name]; }
+return NULL;
+}
 
-    global $cacti_url;
-    $cacti_url = rtrim(get_option($db, 58),'/');
-    if (preg_match('/127.0.0.1/', $cacti_url)) { $cacti_url=NULL; }
+$config["org_name"]= get_option($db_link, 32);
+$config["KB"]= get_option($db_link, 1);
+$config["debug"]= get_option($db_link, 34);
+$config["log_level"]= get_option($db_link, 53);
+if ($config["debug"]) { $config["log_level"]= 255; }
+$config["send_email"]= get_option($db_link, 51);
+$config["admin_email"]= get_option($db_link, 21);
+$config["sender_email"]= get_option($db_link, 52);
+$config["mac_discovery"]= get_option($db_link, 17);
+$config["snmp_default_version"]= get_option($db_link, 9);
+$config["snmp_default_community"]= get_option($db_link, 11);
+$config["auto_mac_rule"]= get_option($db_link, 64);
 
-    global $nagios_url;
-    $nagios_url = rtrim(get_option($db, 57),'/').'/cgi-bin/';
-    if (preg_match('/127.0.0.1/', $nagios_url)) { $nagios_url=NULL; }
+$config["cacti_url"]= rtrim(get_option($db_link, 58),'/');
+if (preg_match('/127.0.0.1/', $config["cacti_url"])) { $config["cacti_url"]=NULL; }
 
-    global $torrus_url;
-    $torrus_url = rtrim(get_option($db, 59),'/').'?nodeid=if//HOST_IP//IF_NAME////inoutbps';
-    if (preg_match('/127.0.0.1/', $torrus_url)) { $torrus_url=NULL; }
+$config["nagios_url"]= rtrim(get_option($db_link, 57),'/').'/cgi-bin/';
+if (preg_match('/127.0.0.1/', $config["nagios_url"])) { $config["nagios_url"]=NULL; }
 
-    global $auto_mac_rule;
-    $auto_mac_rule = get_option($db, 64);
+$config["torrus_url"]= rtrim(get_option($db_link, 59),'/').'?nodeid=if//HOST_IP//IF_NAME////inoutbps';
+if (preg_match('/127.0.0.1/', $config["torrus_url"])) { $config["torrus_url"]=NULL; }
 
-    global $default_user_ou_id;
-    $ou = get_record_sql($db,"SELECT id FROM OU WHERE default_users = 1");
-    if (empty($ou)) { $default_user_ou_id = 0; } else { $default_user_ou_id = $ou['id']; }
+$ou=get_record_sql($db_link,"SELECT id FROM OU WHERE default_users = 1");
+if (empty($ou)) { $config["default_user_ou_id"]=0; } else { $config["default_user_ou_id"]= $ou['id']; }
 
-    global $default_hotspot_ou_id;
-    $ou = get_record_sql($db,"SELECT id FROM OU WHERE default_hotspot = 1");
-    if (empty($ou)) { $default_hotspot_ou_id = $default_user_ou_id; } else { $default_hotspot_ou_id = $ou['id']; }
+$ou=get_record_sql($db_link,"SELECT id FROM OU WHERE default_hotspot=1");
+if (empty($ou)) { $config["default_hotspot_ou_id"]= $config["default_user_ou_id"]; } else { $config["default_hotspot_ou_id"]=$ou['id']; }
 
-}
+$config["init"]=1;
 
-init_option($db_link);
 clean_dns_cache($db_link);
 
 snmp_set_valueretrieval(SNMP_VALUE_LIBRARY);

+ 75 - 10
html/inc/config.php.sample

@@ -2,20 +2,85 @@
 
 if (!defined("CONFIG"))die("Not defined");
 
-$language="russian";
 setlocale(LC_ALL, 'ru_RU.UTF8');
 
-$style="white"; #css ctyle
+define("HTML_LANG","russian");
+define("HTML_STYLE","white");
 
-/* MySQL settings */
-$dbhost="localhost";
-$dbname="database";
-$dbuser="username";
-$dbpass="password";
+#changeme!!!
 
-#$cacti_dbhost="cacti_host";
-#$cacti_dbname="cacti";
+define("DB_HOST","localhost");
+define("DB_NAME","stat");
+define("CACTI_DB_HOST","localhost");
+define("CACTI_DB_NAME","cacti");
+define("DB_USER","user");
+define("DB_PASS","password");
 
-$ipcam_group_id=5;
+define("IPCAM_GROUP_ID","5");
+
+############################ CONSTANTES ############################
+
+define("PORT_STATUS_OID",".1.3.6.1.2.1.2.2.1.8.");
+define("PORT_ADMIN_STATUS_OID",".1.3.6.1.2.1.2.2.1.7.");
+define("PORT_SPEED_OID",".1.3.6.1.2.1.2.2.1.5.");
+define("PORT_ERRORS_OID",".1.3.6.1.2.1.2.2.1.14.");
+define("PORT_VLAN_OID",".1.3.6.1.2.1.17.7.1.4.5.1.1.");
+
+define("MAC_TABLE_OID",".1.3.6.1.2.1.17.7.1.2.2.1.2");
+define("MAC_TABLE_OID2",".1.3.6.1.2.1.17.4.3.1.2");
+define("MAC_TABLE_STR_OID",".1.3.6.1.2.1.17.4.3.1.2");
+define("MAC_TABLE_STR_OID2","1.3.6.1.2.1.17.7.1.2.2.1.2");
+
+define("ELTEX_SFP_STATUS",".1.3.6.1.4.1.89.90.1.2.1.3");
+define("ELTEX_SFP_VENDOR",".1.3.6.1.4.1.35265.1.23.53.1.1.1.5");
+define("ELTEX_SFP_SN",".1.3.6.1.4.1.35265.1.23.53.1.1.1.6");
+define("ELTEX_SFP_FREQ",".1.3.6.1.4.1.35265.1.23.53.1.1.1.4");
+define("ELTEX_SFP_LENGTH",".1.3.6.1.4.1.35265.1.23.53.1.1.1.8");
+
+define("CISCO_DESCR",".1.3.6.1.2.1.1.1.0");
+define("CISCO_MODULES",".1.3.6.1.2.1.47.1.1.1.1.7");
+define("CISCO_SFP_SENSORS",".1.3.6.1.4.1.9.9.91.1.1.1.1.4");
+define("CISCO_SFP_PRECISION",".1.3.6.1.4.1.9.9.91.1.1.1.1.3");
+define("CISCO_VLAN_OID",".1.3.6.1.4.1.9.9.9.46.1.3.1.1.2");
+
+define("IFMIB_IFINDEX",".1.3.6.1.2.1.2.2.1.1");
+define("IFMIB_IFINDEX_MAP",".1.3.6.1.2.1.17.1.4.1.2");
+define("IFMIB_IFDESCR",".1.3.6.1.2.1.2.2.1.2");
+define("IFMIB_IFNAME",".1.3.6.1.2.1.31.1.1.1.1");
+
+define("HUAWEI_SFP_VENDOR",".1.3.6.1.4.1.2011.5.25.31.1.1.2.1.11");
+define("HUAWEI_SFP_SPEED",".1.3.6.1.4.1.2011.5.25.31.1.1.2.1.2");
+define("HUAWEI_SFP_VOLT",".1.3.6.1.4.1.2011.5.25.31.1.1.3.1.6");
+define("HUAWEI_SFP_OPTRX",".1.3.6.1.4.1.2011.5.25.31.1.1.3.1.32");
+define("HUAWEI_SFP_OPTTX",".1.3.6.1.4.1.2011.5.25.31.1.1.3.1.33");
+define("HUAWEI_SFP_BIASCURRENT",".1.3.6.1.4.1.2011.5.25.31.1.1.3.1.31");
+define("HUAWEI_SFP_RX",".1.3.6.1.4.1.2011.5.25.31.1.1.3.1.8");
+define("HUAWEI_SFP_TX",".1.3.6.1.4.1.2011.5.25.31.1.1.3.1.9");
+
+define("PETH_PSE_PORT_ADMIN_ENABLE",".1.3.6.1.2.1.105.1.1.1.3.1");
+define("HUAWEI_POE_OID",".1.3.6.1.4.1.2011.5.25.195.3.1.3");
+define("ALLIED_POE_OID",".1.3.6.1.2.1.105.1.1.1.3.1");
+define("HP_POE_OID",".1.3.6.1.2.1.105.1.1.1.3.1");
+define("NETGEAR_POE_OID",".1.3.6.1.4.1.4526.11.15.1.1.1.6.1");
+define("MIKROTIK_POE_OID",".1.3.6.1.4.1.14988.1.1.15.1.1.3");
+
+//INTERFACE ID
+define("MIKROTIK_POE_INT",".1.3.6.1.4.1.14988.1.1.15.1.1.1");
+// INTERFACE NAMES
+define("MIKROTIK_POE_INT_NAMES",".1.3.6.1.4.1.14988.1.1.15.1.1.2");
+// VOLTAGE IN DV (DECIVOLT)
+define("MIKROTIK_POE_VOLT",".1.3.6.1.4.1.14988.1.1.15.1.1.4");
+// CURRENT IN MA
+define("MIKROTIK_POE_CURRENT",".1.3.6.1.4.1.14988.1.1.15.1.1.5");
+// POWER USAGE IN DW (DEVIWATT)
+define("MIKROTIK_POE_USAGE",".1.3.6.1.4.1.14988.1.1.15.1.1.6");
+
+define("SYSINFO_MIB",".1.3.6.1.2.1.1");
+
+define("L_ERROR",0);
+define("L_WARNING",1);
+define("L_INFO",2);
+define("L_VERBOSE",3);
+define("L_DEBUG",255);
 
 ?>

+ 2 - 2
html/inc/header.php

@@ -2,7 +2,7 @@
 <html>
 <head>
 <title>Панель администратора</title>
-<link rel="stylesheet" type="text/css" href=<? echo "\"/$style.css\""; ?>>
+<link rel="stylesheet" type="text/css" href="/<?php echo HTML_STYLE.'.css'; ?>">
 <script src="/js/jq/jquery.min.js"></script>
 <link href="/js/select2/css/select2.min.css" rel="stylesheet"/>
 <script src="/js/select2/js/select2.min.js"></script>
@@ -34,7 +34,7 @@ $('.js-select-single').select2();
 </head>
 <body>
 
-<div id="title"><?php print $org_name?></div>
+<div id="title"><?php print get_const('org_name')?></div>
 <div id="navi">
 <a href="/admin/reports/index-full.php">
 <?php print $title_reports?>

+ 2 - 2
html/inc/header_public.php

@@ -19,9 +19,9 @@ $page_url = $page_url_array[0];
 <html>
 <head>
 <title>Панель статистики</title>
-<link rel="stylesheet" type="text/css" href=<? echo "\"../$style.css\""; ?>>
+<link rel="stylesheet" type="text/css" href=<? echo "\"../HTML_STYLE.css\""; ?>>
 <meta http-equiv="content-type" content="text/html; charset=utf-8">
 </head>
 <body>
-<div id="title"><?php print $org_name; ?></div>
+<div id="title"><?php print get_const('org_name'); ?></div>
 

+ 4 - 4
html/inc/loglevelfilter.php

@@ -1,10 +1,10 @@
 <?php
 if (! defined("CONFIG")) die("Not defined");
 if (isset($_POST['log_level']) or isset($_GET['log_level'])) {
-    if (isset($_GET['log_level'])) { $log_level = $_GET['log_level']*1; }
-    if (isset($_POST['log_level'])) { $log_level = $_POST['log_level']*1; }
+    if (isset($_GET['log_level'])) { get_const('log_level') = $_GET['log_level']*1; }
+    if (isset($_POST['log_level'])) { get_const('log_level') = $_POST['log_level']*1; }
     } else {
-    if (isset($_SESSION[$page_url]['log_level'])) { $log_level=$_SESSION[$page_url]['log_level']; } else { $log_level = 1; }
+    if (isset($_SESSION[$page_url]['log_level'])) { get_const('log_level')=$_SESSION[$page_url]['log_level']; } else { get_const('log_level') = 1; }
     }
-$_SESSION[$page_url]['log_level']=$log_level;
+$_SESSION[$page_url]['log_level']=get_const('log_level');
 ?>

+ 1 - 1
html/inc/sql.php

@@ -1,7 +1,7 @@
 <?php
 if (! defined("SQL")) { die("Not defined"); }
 
-$db_link = mysqli_connect($dbhost, $dbuser, $dbpass, $dbname);
+$db_link = mysqli_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME);
 
 if (! $db_link) {
     echo "Ошибка: Невозможно установить соединение с MySQL." . PHP_EOL;

+ 4 - 4
html/public/blocked.php

@@ -45,10 +45,10 @@ if (empty($user['day_quota'])) { $user['day_quota']=0; }
 if (empty($auth['month_quota'])) { $auth['month_quota']=0; }
 if (empty($auth['day_quota'])) { $auth['day_quota']=0; }
 
-$user['month_quota'] = $user['month_quota'] * $KB * $KB;
-$user['day_quota'] = $user['day_quota'] * $KB * $KB;
-$auth['month_quota'] = $auth['month_quota'] * $KB * $KB;
-$auth['day_quota'] = $auth['day_quota'] * $KB * $KB;
+$user['month_quota'] = $user['month_quota'] * get_const('KB') * get_const('KB');
+$user['day_quota'] = $user['day_quota'] * get_const('KB') * get_const('KB');
+$auth['month_quota'] = $auth['month_quota'] * get_const('KB') * get_const('KB');
+$auth['day_quota'] = $auth['day_quota'] * get_const('KB') * get_const('KB');
 
 $day =  GetNowDayString();
 $month = strftime('%m',time());