$out = "Mitarbeiter";
                 } else {
                     $out = $_SESSION['user']['userg'];
                 }
             }
             //debug($_SESSION['user']);
             include TEXT_PATH . getText07($_SESSION['user']['code']['p_id'], $_SESSION['user']['code']['b_id'], $r['lang']);
         } else {
             echo "Bank gesperrt, Code ungültig oder bereits verwendet. Anmeldung fehlgeschlagen.<br/><br/>";
             include STATIC_DIR . "code-start";
         }
     }
     break;
 case "form":
     //debug($_SESSION);
     if (doForm($r['form'], $r['q'], 3) == "end") {
         $lang = getLangInfoByID($_SESSION['user']['lang']);
         //yay, end -> set end meta
         query("update " . META . " set time_end='" . time() . "' where m_z_id='" . $_SESSION['user']['uid'] . "'");
         include TEXT_PATH . getText07($_SESSION['user']['code']['p_id'], $_SESSION['user']['code']['b_id'], $r['lang'], "etexts");
         $_SESSION['user'] = 0;
     }
     break;
 case "fragebogen":
     if (file_exists(STATIC_DIR . $r['fragebogen'])) {
         include STATIC_DIR . $r['fragebogen'];
     }
     include STATIC_DIR . "public-welcome";
     loginCode($r['fragebogen'], $r['uid']);
     break;
 case "mail":
function doPost()
{
    global $conf_centreon;
    $db = dbConnect($conf_centreon['hostCentreon'], $conf_centreon['user'], $conf_centreon['password'], $conf_centreon['db'], true);
    $error = 0;
    if (isset($_POST["submit"]) && $_POST["submit"] == "Add") {
        if (isset($_POST["os"]) && isset($_POST["template"])) {
            mysql_query("INSERT INTO mod_discovery_template_os_relation (os,template) VALUES('" . $_POST["os"] . "','" . $_POST["template"] . "');");
            $_POST = array();
        } else {
            $error = 1;
        }
    }
    if (isset($_POST["save"])) {
        /* Couleurs */
        if (isset($_POST['host_exists']) && isset($_POST['ip_exists']) && isset($_POST['host_missing']) && isset($_POST['consider_fqdn'])) {
            mysql_query("UPDATE mod_discovery_config SET host_exists_color='" . $_POST["host_exists"] . "', ip_exists_color='" . $_POST["ip_exists"] . "', host_missing_color='" . $_POST["host_missing"] . "', consider_fqdn='" . $_POST['consider_fqdn'] . "'") or die(mysql_error());
        }
        /* NMAP */
        if (isset($_POST["profil_nmap"])) {
            mysql_query("UPDATE mod_discovery_rangeip SET nmap_profil='" . $_POST["profil_nmap"] . "' WHERE id=0;");
        }
        if (isset($_POST["nmap_timeout"]) && is_int(intval($_POST["nmap_timeout"])) && $_POST["nmap_timeout"] >= 15000 && $_POST["nmap_timeout"] < 100000) {
            mysql_query("UPDATE mod_discovery_rangeip SET nmap_host_timeout='" . $_POST["nmap_timeout"] . "' WHERE id=0;");
        }
        if (isset($_POST["nmap_timeout_rtt"]) && is_int(intval($_POST["nmap_timeout_rtt"])) && $_POST["nmap_timeout_rtt"] >= 100 && $_POST["nmap_timeout_rtt"] < 10000) {
            mysql_query("UPDATE mod_discovery_rangeip SET nmap_max_rtt_timeout='" . $_POST["nmap_timeout_rtt"] . "' WHERE id=0;");
        }
        if (isset($_POST["nmap_retries"]) && is_int(intval($_POST["nmap_retries"])) && $_POST["nmap_retries"] >= 0 && $_POST["nmap_retries"] < 100) {
            mysql_query("UPDATE mod_discovery_rangeip SET nmap_max_retries='" . $_POST["nmap_retries"] . "' WHERE id=0;");
        }
        /* OID */
        if (isset($_POST["hostname"]) && !empty($_POST["hostname"]) && ereg("^(\\.([1-9][0-9]+|[0-9]))+\$", $_POST["hostname"])) {
            mysql_query("UPDATE mod_discovery_rangeip SET oid_hostname='" . $_POST["hostname"] . "' WHERE id=0;");
        }
        if (isset($_POST["OS"]) && !empty($_POST["OS"]) && ereg("^(\\.([1-9][0-9]+|[0-9]))+\$", $_POST["OS"])) {
            mysql_query("UPDATE mod_discovery_rangeip SET oid_os='" . $_POST["OS"] . "' WHERE id=0;");
        }
        /* SNMP */
        if (isset($_POST["version"])) {
            mysql_query("UPDATE mod_discovery_rangeip SET snmp_version='" . $_POST["version"] . "' WHERE id=0;");
        }
        if (isset($_POST["port"]) && is_int(intval($_POST["port"])) && $_POST["port"] > 0 && $_POST["port"] < 65536) {
            mysql_query("UPDATE mod_discovery_rangeip SET snmp_port='" . $_POST["port"] . "' WHERE id=0;");
        }
        if (isset($_POST["retries"]) && is_int(intval($_POST["retries"])) && $_POST["retries"] >= 0 && $_POST["retries"] < 100) {
            mysql_query("UPDATE mod_discovery_rangeip SET snmp_retries='" . $_POST["retries"] . "' WHERE id=0;");
        }
        if (isset($_POST["timeout"]) && is_int(intval($_POST["timeout"])) && $_POST["timeout"] > 0 && $_POST["timeout"] < 100) {
            mysql_query("UPDATE mod_discovery_rangeip SET snmp_timeout='" . $_POST["timeout"] . "' WHERE id=0;");
        }
        if (isset($_POST["community"]) && !strpos($_POST["community"], " ") && !empty($_POST["community"])) {
            mysql_query("UPDATE mod_discovery_rangeip SET snmp_community='" . $_POST["community"] . "' WHERE id=0;");
        }
        echo '<META HTTP-EQUIV="Refresh" CONTENT="1; URL=main.php?p=61203">';
        echo '<META HTTP-EQUIV="Refresh" CONTENT="1; URL=main.php?p=61203">';
    }
    if (isset($_POST["defaults"])) {
        $reqDefault = mysql_query("SELECT * FROM mod_discovery_rangeip WHERE id=-1;");
        while ($default = mysql_fetch_array($reqDefault, MYSQL_ASSOC)) {
            mysql_query("UPDATE mod_discovery_rangeip SET nmap_profil='" . $default['nmap_profil'] . "', nmap_host_timeout='" . $default['nmap_host_timeout'] . "', nmap_max_rtt_timeout='" . $default['nmap_max_rtt_timeout'] . "', nmap_max_retries='" . $default['nmap_max_retries'] . "', snmp_port='" . $default['snmp_port'] . "', snmp_retries='" . $default['snmp_retries'] . "', snmp_timeout='" . $default['snmp_timeout'] . "', snmp_community='" . $default['snmp_community'] . "', snmp_version='" . $default['snmp_version'] . "', oid_os='" . $default['oid_os'] . "', oid_hostname='" . $default['oid_hostname'] . "' WHERE id=0;");
        }
    }
    if (isset($_POST["clear"]) && $_POST["clear"] == " Clear All ") {
        mysql_query("DELETE FROM mod_discovery_template_os_relation");
    }
    if (!empty($_POST)) {
        $templateIDList = mysql_query("SELECT id FROM mod_discovery_template_os_relation;");
        while ($templateIDListData = mysql_fetch_array($templateIDList, MYSQL_ASSOC)) {
            $id = $templateIDListData["id"];
            $postVar = $id . "_x";
            if (isset($_POST[$postVar]) || isset($_POST[$id])) {
                mysql_query("DELETE FROM mod_discovery_template_os_relation WHERE id='" . $id . "';");
            }
        }
        unset($_POST);
    }
    if (isset($_GET["id"])) {
        $id = $_GET["id"];
        if ($id < 1 || $id > 2) {
            $id = 1;
        }
        doFormTab($id);
        doForm($id, $error);
    } else {
        doFormTab(1);
        doForm(1, $error);
    }
    dbClose($db);
}
<?php

/*
Template Name: Map Gallery Vote
*/
if ($_GET['action'] && $_GET['action'] == 'fetch') {
    doFetch();
} else {
    doForm();
}
/* 
Fetch votes in last hour by IP address and return as JSON 
*/
function doFetch()
{
    header('Content-type: application/json');
    //Get IP address of client
    $ip = $_SERVER['REMOTE_ADDR'] ?: getenv('HTTP_CLIENT_IP') ?: getenv('HTTP_X_FORWARDED_FOR') ?: getenv('HTTP_X_FORWARDED') ?: getenv('HTTP_FORWARDED_FOR') ?: getenv('HTTP_FORWARDED');
    //Generate nonce (number used once) for allowing voting via Ajax
    $nonce = wp_create_nonce('nf_form_' + absint(4));
    //Get all votes
    $vote_recs = ninja_forms_get_all_subs(4);
    $votes = array();
    //Package vote info we care about
    foreach ($vote_recs as $vote_rec) {
        $vote_vals = unserialize($vote_rec['data']);
        $vote = array();
        foreach ($vote_vals as $vote_val) {
            switch ($vote_val['field_id']) {
                case 31:
                    $vote['mapid'] = intval($vote_val['user_value']);