<?php if (isset($_GET["verbose"])) { $GLOBALS["VERBOSE"] = true; ini_set('display_errors', 1); ini_set('error_reporting', E_ALL); ini_set('error_prepend_string', null); ini_set('error_append_string', null); } session_start(); include_once 'ressources/class.templates.inc'; include_once 'ressources/class.users.menus.inc'; include_once 'ressources/class.dhcpd.inc'; include_once 'ressources/class.system.nics.inc'; if (!GetRights()) { $tpl = new templates(); echo "alert('" . $tpl->javascript_parse_text("{ERROR_NO_PRIVS}") . "');"; die; exit; } if (isset($_GET["service-cmds"])) { service_cmds_js(); exit; } if (isset($_GET["service-cmds-peform"])) { service_cmds_perform(); exit; } if (isset($_GET["index_dhcp"])) { dhcp_index_js(); exit;
function js($nostartReturn = false) { if (!$nostartReturn) { header("content-type: application/x-javascript"); } $users = new usersMenus(); if (!GetRights()) { die("alert('no privileges')"); } $page = CurrentPageName(); $tpl = new templates(); $title = $tpl->_ENGINE_parse_body('{browse_computers}'); $networks = $tpl->_ENGINE_parse_body('{edit_networks}'); $delete_all_computers_warn = $tpl->javascript_parse_text('{delete_all_computers_warn}'); $import_artica_computers = $tpl->_ENGINE_parse_body('{import_artica_computers}'); $prefix = str_replace('.', '_', $page); $prefix = str_replace('-', '', $prefix); $start = "browse_computers_start();"; if (isset($_GET["in-front-ajax"])) { $start = "browse_computers_start_infront();"; } if (isset($_GET["no-start-js"])) { $start = null; } if ($nostartReturn) { $start = null; } $html = "\n\tvar rule_mem='';\n\tvar {$prefix}timeout=0;\n\tvar {$prefix}timerID = null;\n\tvar {$prefix}tant=0;\n\tvar {$prefix}reste=0;\t\n\t\n\tfunction browse_computers_start(){\n\t\tYahooLogWatcherHide();\n\t\tYahooLogWatcher(930,'{$page}?tabs=yes&mode={$_GET["mode"]}&value={$_GET["value"]}&callback={$_GET["callback"]}&OnlyOCS={$_GET["OnlyOCS"]}&CorrectMac={$_GET["CorrectMac"]}&fullvalues={$_GET["fullvalues"]}','{$title}');\n\t\t{$prefix}demarre();\n\t\n\t}\n\t\n\tfunction browse_computers_start_infront(){\n\t \$('#BodyContent').load('{$page}?tabs=yes&mode={$_GET["mode"]}&value={$_GET["value"]}&callback={$_GET["callback"]}&show-title=yes&OnlyOCS={$_GET["OnlyOCS"]}&CorrectMac={$_GET["CorrectMac"]}&fullvalues={$_GET["fullvalues"]}');\n\t {$prefix}demarre();\n\t\n\t}\t\n\t\n\tfunction {$prefix}demarre(){\n\t\tif(!YahooLogWatcherOpen()){return false;}\n\t\t\t{$prefix}tant = {$prefix}tant+1;\n\t\n\t\t\tif ({$prefix}tant <10 ) { \n\t\t\t\t{$prefix}timerID = setTimeout(\"{$prefix}demarre()\",1000);\n\t\t } else {\n\t\t\t\t\t\tif(!YahooSetupControlOpen()){return false;}\n\t\t\t\t\t\t{$prefix}tant = 0;\n\t\t\t\t\t\t{$prefix}ChargeLogs();\n\t\t\t\t\t\t{$prefix}demarre();\n\t\t }\n\t}\n\t\nvar x_{$prefix}ChargeLogs = function (obj) {\n\t\tdocument.getElementById('progress-computers').innerHTML=obj.responseText;\n\t}\t\n\n\t\n\tfunction {$prefix}ChargeLogs(){\n\t\tvar XHR = new XHRConnection();\n\t\tXHR.appendData('Status','yes');\n\t\tXHR.sendAndLoad('{$page}', 'GET',x_{$prefix}ChargeLogs); \n\t}\n\t\n\t\n\n\t\n\tfunction ViewNetwork(){\n\t\tYahooWin2Hide();\n\t\tYahooWin2(550,'{$page}?browse-networks=yes','{$networks}');\n\t}\n\t\n\n\t\n\tfunction ViewComputerScanLogs(){\n\t\tYahooWin3Hide();\n\t\tYahooWin3(550,'{$page}?view-scan-logs=yes','{$networks}');\n\t}\n\t\n\n\t\nvar x_ClacNetmaskcdir = function (obj) {\n\t\tdocument.getElementById('netmaskcdir').value=obj.responseText;\n\t}\t\n\t\n\tfunction ClacNetmaskcdir(){\n\t\tvar XHR = new XHRConnection();\n\t\tXHR.appendData('calc-cdir-ip',document.getElementById('ip_addr').value);\n\t\tXHR.appendData('calc-cdir-netmask',document.getElementById('netmask').value);\n\t\tXHR.sendAndLoad('{$page}', 'GET',x_ClacNetmaskcdir); \n\t}\n\t\n\tfunction BrowsComputersRefresh(){\n\t\tvar mode='';\n\t\tvar val='';\n\t\tif(document.getElementById('mode')){mode=document.getElementById('mode').value;}\n\t\tif(document.getElementById('value')){val=document.getElementById('value').value;}\n\t\tif(document.getElementById('callback')){callback=document.getElementById('callback').value;}\n\t\t\n\t\n\t}\n\t\n\tvar x_AddComputerToDansGuardian= function (obj) {\n\t\tvar mid='ip_group_rule_list_'+rule_mem;\n\t\tLoadAjax(mid,'dansguardian.index.php?ip-group_list-rule='+rule_mem);\n\t}\n\n\tvar x_DeleteAllComputers= function (obj) {\n\t\tvar results=obj.responseText;\n\t\talert(results);\n\t\tBrowsComputersRefresh();\n\t}\n\t\n\tfunction AddComputerToDansGuardian(uid,rule){\n\t\tvar XHR = new XHRConnection();\n\t\trule_mem=rule;\n\t\tXHR.appendData('AddComputerToDansGuardian',uid);\n\t\tXHR.appendData('AddComputerToDansGuardianRule',rule);\n\t\tXHR.sendAndLoad('dansguardian.index.php', 'GET',x_AddComputerToDansGuardian);\n\t}\n\t\n\tfunction BrowseComputerCheckRefresh(e){\n\t\tif(checkEnter(e)){BrowsComputersRefresh();}\n\t}\n\tfunction BrowseComputerFind(){BrowsComputersRefresh();}\n\t\n\t\n\tfunction DeleteAllComputers(){\n\t\tif(confirm('{$delete_all_computers_warn}')){\n\t\t\tvar XHR = new XHRConnection();\n\t\t\tXHR.appendData('DeleteAllcomputers','yes');\n\t\t\tAnimateDiv('computerlist');\n\t\t\tXHR.sendAndLoad('{$page}', 'GET',x_DeleteAllComputers); \n\t\t}\n\t}\n\t\nvar x_NetWorksDisable= function (obj) {\n\t\tif(document.getElementById('main_config_snort')){RefreshTab('main_config_snort');}\n\t\tViewNetwork();\n\t}\t\n\t\n\tfunction NetWorksDisable(mask){\n\t\t\tvar XHR = new XHRConnection();\n\t\t\tXHR.appendData('NetWorksDisable',mask);\n\t\t \tdocument.getElementById('networks').innerHTML='<div style=\"width:100%\"><center style=\"margin:20px;padding:20px\"><img src=\"img/wait_verybig.gif\"></center></div>';\n\t\t\tXHR.sendAndLoad('{$page}', 'GET',x_NetWorksDisable); \n\t} \n\t\n\tfunction NetWorksEnable(mask){\n\t\t\tvar XHR = new XHRConnection();\n\t\t\tXHR.appendData('NetWorksEnable',mask);\n\t\t \tdocument.getElementById('networks').innerHTML='<div style=\"width:100%\"><center style=\"margin:20px;padding:20px\"><img src=\"img/wait_verybig.gif\"></center></div>';\n\t\t\tXHR.sendAndLoad('{$page}', 'GET',x_NetWorksDisable); \n\t} \t\n\tfunction DeleteImportComputers(ip){\n\t\t\t\tvar XHR = new XHRConnection();\n\t\t\t\tXHR.appendData('artica-import-delete',ip);\n\t\t\t\tXHR.sendAndLoad('{$page}', 'GET',x_SaveImportComputers); \n\t}\n\n\t{$start}\n\t"; if ($nostartReturn) { return $html; } echo $html; }