Example #1
0
function stats_appliance_privs()
{
    if ($GLOBALS["VERBOSE"]) {
        echo "stats_appliance_privs():: {$_SERVER["REMOTE_ADDR"]}<br> \n";
    }
    $q = new mysql_squid_builder();
    $sock = new sockets();
    $OrginalPassword = $q->mysql_password;
    $server = $_SERVER["REMOTE_ADDR"];
    $username = str_replace(".", "", $server);
    $password = md5($server);
    if ($GLOBALS["VERBOSE"]) {
        echo "USER:{$username}@{$server} and password: {$password} Line:" . __LINE__ . "<br> \n";
    }
    writelogs("USER:{$username}@{$server} and password: {$password}", __FUNCTION__, __FILE__, __LINE__);
    // Enable Ufdbguard...
    $UFDB = unserialize(base64_decode($sock->GET_INFO("ufdbguardConfig")));
    $UFDB["tcpsockets"] = 1;
    $UFDB["listen_port"] = 3977;
    $UFDB["listen_addr"] = "all";
    $UFDB["UseRemoteUfdbguardService"] = "0";
    $sock->SET_INFO("EnableUfdbGuard", 1);
    $sock->SET_INFO("EnableUfdbGuard2", 1);
    $sock->SET_INFO("UseRemoteUfdbguardService", 0);
    $sock->SaveConfigFile(base64_encode(serialize($UFDB)), "ufdbguardConfig");
    //
    if (!$q->GRANT_PRIVS($server, $username, $password)) {
        $array["ERROR"] = $q->mysql_error;
        if ($GLOBALS["VERBOSE"]) {
            echo "stats_appliance_privs():: MySQL Error line: " . __LINE__ . " {$q->mysql_error}<br> \n";
        }
        echo "\n\n<RESULTS>" . base64_encode(serialize($array)) . "</RESULTS>\n\n";
        return;
    }
    $q = new mysql_storelogs();
    if (!$q->GRANT_PRIVS($server, $username, $password)) {
        $array["ERROR"] = $q->mysql_error;
        echo "\n\n<RESULTS>" . base64_encode(serialize($array)) . "</RESULTS>\n\n";
        return;
    }
    writelogs("Send Correctly USER:{$array["mysql"]["username"]} and password: {$array["mysql"]["password"]}", __FUNCTION__, __FILE__, __LINE__);
    $array["mysql"]["username"] = $username;
    $array["mysql"]["password"] = $password;
    if ($GLOBALS["VERBOSE"]) {
        print_r($array);
    }
    $sock->getFrameWork("cmd.php?restart-ufdb=yes");
    $sock->getFrameWork("cmd.php?squidnewbee=yes");
    echo "\n\n<RESULTS>" . base64_encode(serialize($array)) . "</RESULTS>\n\n";
}