Example #1
0
function AJAX_COMPUTER()
{
    if ($_GET["userid"] == "newcomputer\$") {
        $add_computer = true;
    }
    $button_title = "{apply}";
    if ($add_computer) {
        $button_title = "{add}";
    }
    $computer = new computers($_GET["userid"]);
    $group = new groups($computer->gidNumber);
    $gpslist = $computer->Groups_list();
    $users = new usersMenus();
    $sock = new sockets();
    $page = CurrentPageName();
    $tpl = new templates();
    $modify_js_text = $tpl->javascript_parse_text("{change}");
    $TF = time();
    $EnableDHCPServer = $sock->GET_INFO('EnableDHCPServer');
    if (is_array($gpslist)) {
        while (list($num, $val) = each($gpslist)) {
            $a_gpr[] = $val;
        }
    }
    $computer->uid = str_replace('$', '', $computer->uid);
    if ($users->KAV4SAMBA_INSTALLED) {
        $scan_computer = Paragraphe("64-find-virus.png", "{AV_REMOTE_SCAN}", "{AV_REMOTE_SCAN_TEXT}", "javascript:Loadjs('computer.scan.php?uid={$computer->uid}');");
    }
    if (trim($computer->uidNumber) == null) {
        $field_dhcpfixed_disabled = true;
        $scan_computer = null;
    }
    $uidenc = urlencode($_GET["userid"]);
    $delete = Paragraphe('delete-64.png', '{delete_this_computer}', "{delete_this_computer}", "javascript:Loadjs('computer.delete.php?uid={$uidenc}&t={$_GET["t"]}')");
    $bind9 = new bind9();
    $t = time();
    if ($EnableDHCPServer == 1) {
        $dhcp_fix = Field_checkbox("dhcpfixed-{$t}", 1, $computer->dhcpfixed, "Loadjs('{$page}?dhcpfixedForm=yes&t={$t}')", '{enable_disable}', $field_dhcpfixed_disabled);
    } else {
        $dhcp_fix = Field_checkbox("dhcpfixed", 1, $computer->dhcpfixed, null, '{no_feature_dhcp_server_not_enabled}', $field_dhcpfixed_disabled);
    }
    $VolatileIPAddress = Field_checkbox("VolatileIPAddress", 1, $computer->VolatileIPAddress, "Loadjs('{$page}?VolatileIPForm=yes')", '{enable_disable}', $field_dhcpfixed_disabled);
    $ini_USER = new Bs_IniHandler();
    $ini_USER->loadString($computer->ComputerCryptedInfos);
    $USERNAME_REMOTE = $ini_USER->_params["ACCOUNT"]["USERNAME"];
    if (!preg_match("#([0-9]+)\\.([0-9]+)\\.([0-9]+)#", $computer->DisplayName)) {
        if (preg_match("#(.+?)\\.#", $computer->DisplayName, $re)) {
            $Diplayname = $re[1];
        } else {
            $Diplayname = $computer->DisplayName;
        }
    } else {
        $Diplayname = $computer->DisplayName;
    }
    $password = Paragraphe("cyrus-password-64.png", "{credentials_informations}", "{credentials_informations_text}", "javascript:Loadjs('computer.passwd.php?uid={$_GET["userid"]}')");
    $cuidenc = urlencode($computer->uid);
    $computer_infos_services = Paragraphe("computer-tour-64.png", "{COMPUTER_INFOS_SERVICES}", "{COMPUTER_INFOS_SERVICES_TEXT}", "javascript:Loadjs('computer.infos.php?uid={$cuidenc}');");
    $wakeonlan = Paragraphe("restart-64.png", "{wakeup_computer}", "{wakeup_computer_text}", "javascript:Loadjs('computer.wakeonlan.php?uid={$uidenc}')");
    $group = new groups($computer->gidNumber);
    $gpslist = $computer->Groups_list();
    $users = new usersMenus();
    $sock = new sockets();
    $page = CurrentPageName();
    $computerOS = utf8_encode($computer->ComputerOS);
    $computerOS_text = $computerOS;
    $computerOS2 = $computerOS;
    if (strlen($computerOS_text) > 36) {
        $computerOS_text = texttooltip(substr($computerOS_text, 0, 33) . '...', $computerOS_text, null, null, 1);
        $computerOS2 = substr($computerOS_text, 0, 33) . '...';
    }
    $array_computerOS = $computer->OSLIST(true);
    $array_computerOS[$computerOS] = $computerOS2;
    if (is_array($a_gpr)) {
        $groups = "\n\t\n\t\t\t<tr>\n\t\t\t\t<td class=legend>{groups}:</strong></td>\n\t\t\t\t<td align=left><strong>" . implode(', ', $a_gpr) . "</strong></td>\n\t\t\t</tr>\t";
    }
    $MacField = Field_text('ComputerMacAddress', $computer->ComputerMacAddress, 'width:95%;font-size:22px;padding:3px;font-weight:bold', null, null, null, false, "ComputerFindByMac()");
    if (IsPhysicalAddress($computer->ComputerMacAddress)) {
        $MacField = "<input type='hidden' name='ComputerMacAddress' id='ComputerMacAddress' value='{$computer->ComputerMacAddress}'>\n\t\t<code style='font-size:22px'>{$computer->ComputerMacAddress}</code>";
    } else {
        $mac_warn = imgtootltip("status_warning.png", "{WARNING_MAC_ADDRESS_CORRUPT}");
        $wakeonlan = Paragraphe("restart-64-grey.png", "{wakeup_computer}", "{wakeup_computer_text}", "");
    }
    $dns = AJAX_COMPUTER_DNS_FORM($_GET["userid"]);
    if ($add_computer) {
        $scan_computer = null;
        $delete = null;
        $backup_icon = null;
        $computer_icon = null;
        $password = null;
        $computer_infos_services = null;
        $add_computer = 1;
    }
    $html = "\n\t<input type='hidden' name='Yahoowin' id='Yahoowin' value='{$_GET["Yahoowin"]}'>\n\t<form name='FFM34567-{$_GET["userid"]}'>\n\t<input type='hidden' name='userid' id='userid' value='{$_GET["userid"]}'>\n\t<input type='hidden' name='gpid' value='{$_GET["gpid"]}'>\n\t<input type='hidden' name='SaveComputerInfo' value='yes'>\n\t<input type='hidden' name='add_computer_form' value='{$add_computer}'>\n\t\n\t\n\t<table style='width:100%'>\n\t<td width=1% valign='top' style='vertical-align:top' style='vertical-align:top'>\n\t\t<div id='computer_refresh_div'>{$computer_icon}</div>\n\t\t{$password}\n\t\t{$computer_infos_services}\n\t\t{$scan_computer}\n\t\t{$wakeonlan}\n\t\t{$delete}\n\t\t</td>\n\t<td valign='top' style='vertical-align:top' style='vertical-align:top' width=99% style='vertical-align:top !important'>\n\t\t   <div style='width:98%' class=form>\n\t\t\t<table style='width:100%'>\n\t\t\t\t<tr>\n\t\t\t\t\t<td colspan=3 ><div style='font-size:26px;margin-bottom:20px'>{network_information}</div></td>\n\t\t\t\t\t\n\t\t\t\t</tr>\n\t\t\t\t<tr>\n\t\t\t\t\t<td class=legend nowrap style='font-size:22px;vertical-align:middle'>{groupName}:</strong></td>\n\t\t\t\t\t<td align=left colspan=2><strong style='font-size:22px;'>{$group->groupName}</strong></td>\n\t\t\t\t</tr>\t\t\t\t\t\t\t\t\t\n\t\t\t\t<tr>\n\t\t\t\t\t\n\t\t\t\t\t<td class=legend nowrap style='font-size:22px;vertical-align:top'>{computer_name}:</strong></td>\n\t\t\t\t\t<td width=1%>&nbsp;</td>\n\t\t\t\t\t<td align=left>" . Field_text('uid', $computer->uid, 'width:100%;font-size:22px;padding:3px;
							font-weight:bold;width:400px') . "\n\t\t\t\t\t<div style='margin-top:2px;text-align:right;padding-left:250px' id='modifyNameComp'></div></td>\n\t\t\t\t</tr>\t\t\t\t\t\t\t\t\n\t\t\t\t<tr>\n\t\t\t\t\t\n\t\t\t\t\t<td class=legend nowrap style='font-size:22px;vertical-align:middle'>{ipaddr}:</strong></td>\n\t\t\t\t\t<td width=1%>&nbsp;</td>\n\t\t\t\t\t<td align=left>" . field_ipv4('ComputerIP', $computer->ComputerIP, 'font-size:22px;padding:3px;font-weight:bold') . "</strong></td>\n\t\t\t\t</tr>\t\t\t\n\t\t\t\t<tr>\n\t\t\t\t\t\n\t\t\t\t\t<td class=legend nowrap style='font-size:22px;vertical-align:middle'>{ComputerMacAddress}:</strong></td>\n\t\t\t\t\t<td width=1%><span id='mac-warn'>{$mac_warn}</span></td>\n\t\t\t\t\t<td align=left>{$MacField}</strong></td>\n\t\t\t\t</tr>\n\t\t\t\t<tr>\n\t\t\t\t\t\n\t\t\t\t\t<td class=legend nowrap style='font-size:22px'>{uid_number}:</strong></td>\n\t\t\t\t\t\n\t\t\t\t\t<td align=left colspan=2><strong style='font-size:22px'>{$computer->uidNumber}</strong></td>\n\t\t\t\t</tr>\t\n\t\t\t\t<tr>\n\t\t\t\t\t<td colspan=3><div style='padding-top:10px;font-size:26px;margin-bottom:20px;;margin-top:20px;border-top:1px solid #CCCCCC''>{materialos}</div></td>\n\t\t\t\t\t\n\t\t\t\t</tr>\t\n\t\t\t\t<tr>\n\t\t\t\t\t<td class=legend nowrap style='font-size:22px;vertical-align:middle'>{ComputerCPU}:</strong></td>\n\t\t\t\t\t<td align=left colspan=2>" . Field_text('ComputerCPU', $computer->ComputerCPU, 'width:100%;font-size:22px') . "</strong></td>\n\t\t\t\t</tr>\t\n\t\t\t\t\t\t\n\t\t\t\t<tr>\n\t\t\t\t\t<td class=legend nowrap style='font-size:22px;vertical-align:middle'>{ComputerMachineType}:</strong></td>\n\t\t\t\t\t<td align=left colspan=2>\n\t\t\t\t\t" . Field_text('ComputerMachineType', $computer->ComputerMachineType, 'width:100%;font-size:22px') . "\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\t\n\t\t\t\t<tr>\n\t\t\t\t\t<td class=legend nowrap style='font-size:22px;vertical-align:middle'>{ComputerOS}:</strong></td>\n\t\t\t\t\t<td align=left colspan=2>\n\t\t\t\t\t" . Field_array_Hash($array_computerOS, 'ComputerOS', $computerOS, 'style:width:100%;font-size:22px') . "\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n\t\t\t\t<tr>\n\t\t\t\t\t<td class=legend nowrap style='font-size:22px;vertical-align:middle'>{ComputerRunning}:</strong></td>\n\t\t\t\t\t<td align=left colspan=2><strong style='font-size:22px;'>{$computer->ComputerRunning}</strong></td>\n\t\t\t\t</tr>\t\t\t\n\t\t\t\t<tr>\n\t\t\t\t\t<td class=legend nowrap style='font-size:22px;vertical-align:middle'>{ComputerUpTime}:</strong></td>\n\t\t\t\t\t<td align=left colspan=2><strong style='font-size:22px;'>{$computer->ComputerUpTime}</strong></td>\n\t\t\t\t</tr>\t\t\t\n\t\t\t\t<tr>\n\t\t\t\t\t<td colspan=3><div style='padding-top:10px;font-size:26px;margin-bottom:20px;\n\t\t\t\t\tmargin-top:20px;border-top:1px solid #CCCCCC''>{dns_information}</div></td>\n\t\t\t\t\t\n\t\t\t\t</tr>\t\n\t\t\t\t{$dns}\n\t\t\t\t\n\t\t\t</table>\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t<table style='width:100%'>\n\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\n\t\t\t\t<tr>\n\t\t\t\t\t<td colspan=3 align='right' style='padding:10px'>\n\t\t\t\t\t\t<hr>" . button($button_title, "SaveComputerForm{$TF}();", 32) . "\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t</table>\n\t\t\t\t</div>\n\t\t</td>\n\t\t</tr>\t\t\n\t\t</table>\n\t</form>\n\t<script>\n\tvar m_userid;\nvar x_SaveComputerForm= function (obj) {\n\t\n\tvar tempvalue=obj.responseText;\n\tif(tempvalue.length>3){\n\t\talert(tempvalue);\n\t\tvar re = new RegExp(/^ERROR/);\n\t\tm=re.exec(tempvalue);\n        if(m){return false;}\n\t}\n\t\n\tif(document.getElementById('main_config_browse_computers')){RefreshTab('main_config_browse_computers');}\n\tif(document.getElementById('ZoneListComp')){Loadjs('index.bind9.php?script=yes');BindComputers(document.getElementById('ZoneListComp').value);}\n\tif(document.getElementById('browser-computers-list')){Loadjs('smb.browse.php?set-field='+document.getElementById('browser-computers-list').value);}\n\tif(document.getElementById('main-content')){Loadjs('start.php');}\n\tif(document.getElementById('crossroads-backend-list-table')){SearchBackendList();}\n\t\n\tif(document.getElementById('flexRT{$_GET["t"]}')){\n\t\t\$('#flexRT{$_GET["t"]}').flexReload();\n\t}\n\tsetTimeout('ComputerRefresh()',1000);\n}\t\n\nfunction ComputerRefresh(){\n\tif(document.getElementById('uid').value=='newcomputer'){return false;}\n\tvar computer=document.getElementById('uid').value;\n\tvar DnsZone=document.getElementById('DnsZoneName').value;\n\t\$('#COMPUTER_BROWSE_TABLE').flexReload();\n\tif(document.getElementById('computerlist')){BrowsComputersRefresh();}\n\tif(document.getElementById('main_config_browse_computers')){RefreshTab('main_config_browse_computers');}\n\tif(document.getElementById('container-computer-tabs')){RefreshTab('container-computer-tabs');}\n\tif(document.getElementById('main_dansguardiangroups_tabs')){RefreshTab('main_dansguardiangroups_tabs');}\t\n}\n\nfunction SaveComputerForm{$TF}(){\n\tvar XHR = new XHRConnection();\n\tif(document.getElementById('ComputerMacAddress')){\n\t\t XHR.appendData('ComputerMacAddress',document.getElementById('ComputerMacAddress').value);\t\n\t}\n    XHR.appendData('userid','{$_GET["userid"]}');\n\tXHR.appendData('SaveComputerInfo','yes');\n\tXHR.appendData('add_computer_form','{$add_computer}');\n\tXHR.appendData('gpid','{$_GET["gpid"]}');\n\tXHR.appendData('Yahoowin','{$_GET["Yahoowin"]}');\n\t\n\t\n\t\n\tif(document.getElementById('ComputerCPU')){\n\t\tXHR.appendData('ComputerCPU',document.getElementById('ComputerCPU').value);\n\t}\n\t\t\n\tif(document.getElementById('ComputerOS')){\n\t\tXHR.appendData('ComputerOS',document.getElementById('ComputerOS').value);\n\t}\t\n\tif(document.getElementById('ComputerMachineType')){\n\t\tXHR.appendData('ComputerMachineType',document.getElementById('ComputerMachineType').value);\n\t}\t\n\t\n\tif(document.getElementById('uid')){\n\t\t XHR.appendData('uid',document.getElementById('uid').value);\t\n\t}\n\tif(document.getElementById('ComputerIP')){\n\t\t XHR.appendData('ComputerIP',document.getElementById('ComputerIP').value);\t\n\t}\t\n\tif(document.getElementById('DnsZoneName')){\n\t\t XHR.appendData('DnsZoneName',document.getElementById('DnsZoneName').value);\t\n\t}\t\n\tif(document.getElementById('DnsType')){\n\t\t XHR.appendData('DnsType',document.getElementById('DnsType').value);\t\n\t}\t\n\tif(document.getElementById('DnsMXLength')){\n\t\t XHR.appendData('DnsMXLength',document.getElementById('DnsMXLength').value);\t\n\t}\t  \n\t\n\t\n\t\n\tXHR.sendAndLoad('{$page}', 'GET',x_SaveComputerForm);\n\n}\n\n\t\nvar x_ComputerFindByMac= function (obj) {\n\tvar results=obj.responseText;\n\tif(results.length>0){document.getElementById('mac-warn').innerHTML=results;}\n\t}\t\t\n\t\n\t\n\t\n\tfunction ComputerFindByMac(){\n\t\tvar ComputerMacAddress=document.getElementById('ComputerMacAddress').value;\n\t\tif(ComputerMacAddress.length==0){return;}\n\t\tvar XHR = new XHRConnection();\n\t\tXHR.appendData('ComputerMacAddressFindUid',ComputerMacAddress);\n\t\tXHR.appendData('userid','{$_GET["userid"]}');\n\t\tXHR.sendAndLoad('{$page}', 'GET',x_ComputerFindByMac);\t\n\t\t\n\t}\n\t\n\t\n\tfunction CheckUidComp(){\n\t\tvar uid='{$computer->uid}';\n\t\tif(uid.length==0){return;}\n\t\tif(uid=='newcomputer'){return;}\n\t\tdocument.getElementById('uid').disabled=true;\n\t\tLoadAjaxTiny('modifyNameComp','{$page}?AJAX_COMPUTER_NETBIOS_LINK=yes&userid={$_GET["userid"]}');\n\t\t\n\t\t\n\t\t\n\t}\nCheckUidComp();\n</script>\t\n\t\n\t";
    return $tpl->_ENGINE_parse_body($html);
}
function AJAX_COMPUTER_MATERIAL_OS()
{
    $computer = new computers($_GET["userid"]);
    $group = new groups($computer->gidNumber);
    $gpslist = $computer->Groups_list();
    $users = new usersMenus();
    $sock = new sockets();
    $page = CurrentPageName();
    $computerOS = $computer->ComputerOS;
    $computerOS_text = $computerOS;
    $computerOS2 = $computerOS;
    if (strlen($computerOS_text) > 36) {
        $computerOS_text = texttooltip(substr($computerOS_text, 0, 33) . '...', $computerOS_text, null, null, 1);
        $computerOS2 = substr($computerOS_text, 0, 33) . '...';
    }
    $array = $computer->OSLIST(true);
    $array[$computerOS] = $computerOS2;
    $computer_infos = "\n<div style='font-size:13px;text-align:right;border-bottom:1px solid #005447;padding:5px;margin-bottom:5px'>\n{ComputerOS}:{$computerOS}&nbsp;|&nbsp;{$computer->ComputerMachineType}&nbsp;|&nbsp;{$computer->ComputerCPU}</div>\n<table style='width:100%'>\n\t<tr>\n\t<td colspan=2 valign='top'><img src='img/linux_cluster_install-128.png'></td>\n\t<td valign='top'>\n\t\t\t<table>\n\t\t\t\n\t\t\t\t<tr>\n\t\t\t\t\t<td class=legend>{ComputerCPU}:</strong></td>\n\t\t\t\t\t<td align=left>" . Field_text('ComputerCPU', $computer->ComputerCPU, 'width:100%;font-size:13px') . "</strong></td>\n\t\t\t\t</tr>\t\n\t\t\t\t\t\t\n\t\t\t\t<tr>\n\t\t\t\t\t<td class=legend>{ComputerMachineType}:</strong></td>\n\t\t\t\t\t<td align=left>\n\t\t\t\t\t" . Field_text('ComputerMachineType', $computer->ComputerMachineType, 'width:100%;font-size:13px') . "\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\t\n\t\t\t\t<tr>\n\t\t\t\t\t<td class=legend>{ComputerOS}:</strong></td>\n\t\t\t\t\t<td align=left>\n\t\t\t\t\t" . Field_array_Hash($array, 'ComputerOS', $computerOS, 'width:100%;font-size:13px') . "\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n\t\t\t\t<tr>\n\t\t\t\t\t<td class=legend>{ComputerRunning}:</strong></td>\n\t\t\t\t\t<td align=left><strong>{$computer->ComputerRunning}</strong></td>\n\t\t\t\t</tr>\t\t\t\n\t\t\t\t<tr>\n\t\t\t\t\t<td class=legend>{ComputerUpTime}:</strong></td>\n\t\t\t\t\t<td align=left><strong>{$computer->ComputerUpTime}</strong></td>\n\t\t\t\t</tr>\t\t\t\n\t\t\t\t<tr>\n\t\t\t\t\t<td class=legend>{groupName}:</strong></td>\n\t\t\t\t\t<td align=left><strong>{$group->groupName}</strong></td>\n\t\t\t\t</tr>\n\t\t\t\t<tr>\n\t\t\t\t<td colspan=2 align='right'><hr>\n\t\t\t\t\t" . button('{edit}', 'ComputerSaveComputerInfosHard()') . "</td>\n\t\t\t\t</tr>\n\t\t\t</table>\n\t\t</td>\n\t</tr>\n</table>\n<script>\n\tvar x_ComputerSaveComputerInfosHard= function (obj) {\n\t\tvar results=obj.responseText;\n\t\tif(results.length>0){alert(results);return;}\n\t\tRefreshtab('container-computer-tabs');\n\t}\t\n\tfunction ComputerSaveComputerInfosHard(){\n\t\tvar XHR = new XHRConnection();\n\t\tXHR.appendData('AJAX_COMPUTER_MATERIAL_OS_SAVE','yes');\n\t\tXHR.appendData('userid','{$_GET["userid"]}');\n\t\tXHR.appendData('ComputerCPU',document.getElementById('ComputerCPU').value);\n\t\tXHR.appendData('ComputerOS',document.getElementById('ComputerOS').value);\n\t\tXHR.appendData('ComputerMachineType',document.getElementById('ComputerMachineType').value);\n\t\tXHR.sendAndLoad('{$page}', 'GET',x_ComputerSaveComputerInfosHard);  \n\t}\n</script>\n";
    $tpl = new templates();
    return $tpl->_ENGINE_parse_body($computer_infos);
}