require_once REL(__FILE__, "../functions/errorFuncs.php");
require_once REL(__FILE__, "LookupHosts.php");
require_once REL(__FILE__, 'LookupHostsQuery.php');
switch ($_REQUEST[mode]) {
    #-.-.-.-.-.-.-.-.-.-.-.-.-
    case 'getHosts':
        ## prepare list of hosts using LookupHost
        getHosts('all');
        # results are in $postVars[hosts] & $postVars[numHosts]
        echo json_encode($postVars[hosts]);
        break;
        #-.-.-.-.-.-.-.-.-.-.-.-.-
    #-.-.-.-.-.-.-.-.-.-.-.-.-
    case 'addNew':
        ## add new host database entry
        echo insertHost($_POST);
        break;
        #-.-.-.-.-.-.-.-.-.-.-.-.-
    #-.-.-.-.-.-.-.-.-.-.-.-.-
    case 'update':
        ## update host database entry
        echo updateHost($_POST);
        //echo"post=";print_r($_POST);
        break;
        #-.-.-.-.-.-.-.-.-.-.-.-.-
    #-.-.-.-.-.-.-.-.-.-.-.-.-
    case 'd-3-L-3-t':
        ## delete host database entry
        echo deleteHost($_GET);
        break;
        #-.-.-.-.-.-.-.-.-.-.-.-.-
$tab = "admin";
$nav = "lookupHosts";
require_once "../functions/inputFuncs.php";
require_once "../shared/logincheck.php";
require_once "../classes/Localize.php";
require_once '../lookup2/LookupHostsQuery.php';
$loc = new Localize(OBIB_LOCALE, $tab);
$navbar = new Localize(OBIB_LOCALE, 'navbars');
if (!is_array($postVars)) {
    $postVars = array();
}
if ($_POST) {
    if (0 + $_POST['id'] > 0) {
        $update = updateHost($_POST);
    } else {
        $update = insertHost($_POST);
    }
    if ($update) {
        header("Location: ./z3950_server_list.php?done=1");
    } else {
        $updateMsg = '<sup style="color:red">*</sup>' . $loc->getText('lookup_rqdNote');
        $postVars = $_POST;
    }
} else {
    if ($_GET['id'] > 0) {
        $host = new lookupHostQuery();
        $res = $host->execSelectOne(0 + $_GET['id']);
        $row = $host->fetchRow();
        if ($row) {
            foreach ($row as $key => $val) {
                $postVars[substr($key, 1)] = $val;