Пример #1
0
function wizard_list_nic()
{
    $tpl = new templates();
    $page = CurrentPageName();
    $sock = new sockets();
    $datas = unserialize(base64_decode($sock->getFrameWork("cmd.php?list-nics=yes")));
    $refresh = imgtootltip("refresh-24.png", "{refresh}", "WizardRefreshNics()");
    $html = "<center>\n<table cellspacing='0' cellpadding='0' border='0' class='tableView' style='width:100%'>\n<thead class='thead'>\n\t<tr>\n\t\t<th colspan=2 align='center' style='text-align:center'>{$refresh}</th>\n\t\t<th>{tcp_address}</td>\n\t\t<th>{netmask}</th>\n\t\t<th>{gateway}</th>\n\t\t<th>{mac_addr}</th>\n\t\t<th>DHCP</th>\n\t</tr>\n</thead>\n<tbody class='tbody'>";
    $configured = true;
    while (list($num, $val) = each($datas)) {
        if (trim($val) == null) {
            continue;
        }
        writelogs("Found: {$val}", __FUNCTION__, __FILE__, __LINE__);
        $val = trim($val);
        if (preg_match('#master#', $val)) {
            continue;
        }
        if (preg_match("#^veth.+?#", $val)) {
            continue;
        }
        if (preg_match("#^tunl[0-9]+#", $val)) {
            continue;
        }
        if (preg_match("#^dummy[0-9]+#", $val)) {
            continue;
        }
        if (preg_match("#^gre[0-9]+#", $val)) {
            continue;
        }
        if (preg_match("#^ip6tnl[0-9]+#", $val)) {
            continue;
        }
        if (preg_match("#^sit[0-9]+#", $val)) {
            continue;
        }
        if (preg_match("#^vlan[0-9]+#", $val)) {
            continue;
        }
        $nicinfos = $sock->getFrameWork("cmd.php?nicstatus={$val}");
        $tbl = explode(";", $nicinfos);
        if ($classtr == "oddRow") {
            $classtr = null;
        } else {
            $classtr = "oddRow";
        }
        if ($tbl[0] == null) {
            $tbl[0] = "{not_set}";
        }
        if ($tbl[1] == null) {
            $tbl[1] = "{not_set}";
        }
        if ($tbl[2] == null) {
            $tbl[2] = "{not_set}";
        }
        if ($tbl[4] == null) {
            $tbl[4] = "&nbsp;";
        }
        $js = "javascript:Loadjs('system.nic.edit.php?nic={$val}&button=confirm&noreboot=noreboot')";
        $href = "<a href=\"javascript:blur();\" OnClick=\"{$js}\" style='font-weight:bold;font-size:14px;text-decoration:underline'>";
        $nic = new system_nic($val);
        if (!$nic->IsConfigured()) {
            $configured = false;
            $img = imgtootltip("warning-panneau-32.png", "<b>{$val}:{$tbl[0]}</b><hr>{this_nic_is_not_configured_text}");
        } else {
            $img = imgtootltip("check-32.png", "<b>{$val}:{$tbl[0]}</b><hr>{this_nic_is_configured_text}");
        }
        if ($nic->dhcp == 1) {
            $dhcp = "{yes}";
            if (!preg_match("#[0-9\\.]+#", $tbl[0])) {
                $tbl[0] = "{automatic}";
            }
            $tbl[2] = "{automatic}";
            $tbl[4] = "{automatic}";
        } else {
            $dhcp = "{no}";
        }
        $html = $html . "\n\t\t<tr class={$classtr}>\n\t\t\t<td style='font-weight:bold;font-size:14px' width=1%>{$href}{$val}</a></td>\n\t\t\t<td style='font-weight:bold;font-size:14px' width=1%>{$img}</a></td>\n\t\t\t<td style='font-weight:bold;font-size:14px'>{$href}{$tbl[0]}</a></td>\n\t\t\t<td style='font-weight:bold;font-size:14px'>{$href}{$tbl[2]}</a></td>\n\t\t\t<td style='font-weight:bold;font-size:14px'>{$href}{$tbl[4]}</a></td>\n\t\t\t<td style='font-weight:bold;font-size:14px'>{$href}{$tbl[1]}</a></td>\n\t\t\t<td style='font-weight:bold;font-size:14px'>{$href}{$dhcp}</a></td>\n\t\t</tr>\t\t\t\n\t\t";
    }
    $html = $html . "</tbody>\n\t</table>\n\t\n\t<script>\n\t\n\tvar x_ApplyNetSettingsWizard= function (obj) {\n\t\tvar results=obj.responseText;\n\t\tif(results.length>3){alert(results);}\n\t\tWizardRefreshNics();\n\t}\t\n\t\n\tfunction ApplyNetSettingsWizard(){\n\t\tvar XHR = new XHRConnection();\n\t\tAnimateDiv('wizard-nic-list');\n\t\tXHR.appendData('ApplyNetSettingsWizard','1');\n\t\tXHR.sendAndLoad('{$page}', 'POST',x_ApplyNetSettingsWizard);\t\n\t\n\t}\n\t</script>\n\t";
    if ($configured) {
        $html = $html . "<div class=explain style='font-size:14px'>{FIRST_WIZARD_NIC2}</div>\n\t\t<center>" . button("{SaveToDisk}", "ApplyNetSettingsWizard()", 18) . "</center>\n\t\t\n\t\t";
    }
    echo $tpl->_ENGINE_parse_body($html);
}