function Connect($server, $port, $user, $pass)
{
    writelogs("synchronize {$server}:{$port}", __FUNCTION__, __FILE__, __LINE__);
    $sync = new articaSMTPSync();
    $ldap = new clladp();
    $http = new httpd();
    $array = $sync->GetUsers();
    $field = base64_encode(serialize($array));
    $cred["user"] = $user;
    $cred["pass"] = $pass;
    $curl = new ccurl("https://{$server}:{$port}/exec.smtp.export.users.php");
    $curl->parms["credentials"] = base64_encode(serialize($cred));
    $curl->parms["users"] = $field;
    $curl->parms["local_port"] = $http->https_port;
    $curl->parms["mycred"] = base64_encode(serialize(array($ldap->ldap_admin, $ldap->ldap_password)));
    if (!$curl->get()) {
        writelogs("synchronize {$server}:{$port} failed", __FUNCTION__, __FILE__, __LINE__);
    }
    if (preg_match("#<datas>(.+?)</datas>#is", $curl->data, $re)) {
        $array = unserialize(base64_decode($re[1]));
        $sync->import($array, "{$server}:{$port}");
        $sock = new sockets();
        $sock->getFrameWork("cmd.php?postfix-transport-maps=yes");
    }
}
Esempio n. 2
0
function GetCategory($source, $dest)
{
    for ($i = 1; $i < 13; $i++) {
        echo "Checking page number {$i}\n";
        $curl = new ccurl("http://cacaweb.com/category/{$source}/page/{$i}");
        $curl->NoHTTP_POST = true;
        $curl->UserAgent = "Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:10.0) Gecko/20100101 Firefox/10.0";
        $curl->FollowLocation = true;
        if (!$curl->get()) {
            echo $curl->error . "\n";
            return;
        }
        CheckWebsites($curl->data, $dest);
    }
}
Esempio n. 3
0
function ping($hostid)
{
    $mefile = basename(__FILE__);
    $GLOBALS["CLASS_UNIX"] = new unix();
    $GLOBALS["CLASS_UNIX"]->events("{$mefile}:: blackboxes({$hostid})", "/var/log/stats-appliance.log");
    $black = new blackboxes($hostid);
    $ssluri = $black->ssluri . "/nodes.listener.php";
    $nossluri = $black->sslnouri . "/nodes.listener.php";
    if ($GLOBALS["VERBOSE"]) {
        echo "Try {$ssluri}\n";
    }
    $GLOBALS["CLASS_UNIX"]->events("{$mefile}:: {$ssluri}", "/var/log/stats-appliance.log");
    $curl = new ccurl($ssluri);
    $curl->parms["PING-ORDERS"] = true;
    if ($GLOBALS["VERBOSE"]) {
        $curl->parms["VERBOSE"] = true;
    }
    $curl->noproxyload = true;
    if ($GLOBALS["VERBOSE"]) {
        echo "Sending PING-ORDERS\n";
    }
    if (!$curl->get()) {
        $ssluri = $nossluri;
        $GLOBALS["CLASS_UNIX"]->events("{$mefile}:: {$ssluri}", "/var/log/stats-appliance.log");
        if ($GLOBALS["VERBOSE"]) {
            echo "error `{$ssluri}` {$curl->error}, trying http\n";
        }
        $curl = new ccurl($nossluri);
        $curl->noproxyload = true;
        $curl->parms["PING-ORDERS"] = true;
        if (!$curl->get()) {
            ufdbguard_admin_events("{$mefile}:: Failed to send ping to {$black->hostname} with Error:`{$curl->error}`", __FUNCTION__, __FILE__, __LINE__, "communicate");
            return;
        }
    }
    if ($GLOBALS["VERBOSE"]) {
        echo $curl->data;
    }
    if (preg_match("#SUCCESS<#s", $curl->data)) {
        $GLOBALS["CLASS_UNIX"]->events("Success to send ping to {$black->hostname}", "/var/log/stats-appliance.log");
        ufdbguard_admin_events("{$mefile}:: Success to send ping to {$black->hostname}", __FUNCTION__, __FILE__, __LINE__, "communicate");
    }
}
Esempio n. 4
0
function ImportNets()
{
    $sock = new sockets();
    $ini = new Bs_IniHandler();
    $ini->loadString($sock->GET_INFO("ComputersImportArtica"));
    if (!is_array($ini->_params)) {
        writelogs("No artica masters defined", __FUNCTION__, __FILE__, __LINE__);
        die;
    }
    if (count($ini->_params) == 0) {
        writelogs("No artica masters defined", __FUNCTION__, __FILE__, __LINE__);
        die;
    }
    while (list($ip, $array) = each($ini->_params)) {
        if (trim($ip) == null) {
            continue;
        }
        $curl = new ccurl("https://{$ip}:{$array["port"]}/exec.import-networks.php");
        while (list($key, $value) = each($array)) {
            $curl->parms[$key] = $value;
        }
        $curl->get();
        $datas = $curl->data;
        if (trim($datas) == null) {
            continue;
        }
        $md5 = md5($datas);
        import_vpn_remotes_sites($datas);
        if (!$GLOBALS["FORCE"]) {
            if ($array["md5"] != $md5) {
                ImportDatas($datas);
            }
        } else {
            ImportDatas($datas);
        }
        $ini->_params[$ip]["md5"] = $md5;
    }
    reset($ini->_params);
    $ini->saveFile("/etc/artica-postfix/settings/Daemons/ComputersImportArtica");
}
Esempio n. 5
0
function Save()
{
    include_once dirname(__FILE__) . "/ressources/class.ccurl.inc";
    $sock = new sockets();
    $tpl = new templates();
    $curl = new ccurl();
    $proto = "http";
    $StatsServervame = $_POST["StatsServervame"];
    $StatsServerPort = $_POST["StatsServerPort"];
    $StatsServerSSL = $_POST["StatsServerSSL"];
    if ($StatsServerSSL == 1) {
        $proto = "https";
    }
    $EnableRemoteSyslogStatsAppliance = $_POST["EnableRemoteSyslogStatsAppliance"];
    $uri = "{$proto}://{$StatsServervame}:{$StatsServerPort}/nodes.listener.php";
    if ($EnableRemoteSyslogStatsAppliance == 1) {
        writelogs("{$uri}", __FUNCTION__, __FILE__, __LINE__);
        $curl = new ccurl($uri);
        $curl->parms["OPENSYSLOG"] = 1;
        if (!$curl->get()) {
            echo "Error " . $tpl->_ENGINE_parse_body($curl->error);
            return;
        }
        if (strpos($curl->data, "<RESULTS>OK</RESULTS>") == 0) {
            echo "Error Protocol error or bad version on remote server\n";
            return;
        }
    }
    $sock->SET_INFO("EnableRemoteSyslogStatsAppliance", $EnableRemoteSyslogStatsAppliance);
    $RemoteSyslogAppliance["SSL"] = $_POST["StatsServerSSL"];
    $RemoteSyslogAppliance["PORT"] = $_POST["StatsServerPort"];
    $RemoteSyslogAppliance["SERVER"] = $_POST["StatsServervame"];
    $sock->SaveConfigFile(base64_encode(serialize($RemoteSyslogAppliance)), "RemoteSyslogAppliance");
    $sock->getFrameWork("cmd.php?syslog-client-mode=yes");
    $sock->getFrameWork("squid.php?compile-schedules-reste=yes");
    $sock->getFrameWork("squid.php?squid-reconfigure=yes");
}
Esempio n. 6
0
function RefreshIndex()
{
    $unix = new unix();
    $nice = EXEC_NICE();
    $sock = new sockets();
    $users = new usersMenus();
    $nohup = $unix->find_program("nohup");
    $php = $unix->LOCATE_PHP5_BIN();
    $wget = $unix->find_program("wget");
    $SYSTEMID = $unix->GetUniqueID();
    if ($SYSTEMID == null) {
        build_progress("System ID is Null !!!", 5);
        return;
    }
    build_progress_index("Register server...", 10);
    build_progress("Register server...", 10);
    shell_exec("{$nohup} {$nice} {$php} /usr/share/artica-postfix/exec.web-community-filter.php --register-lic >/dev/null 2>&1 &");
    if ($SYSTEMID == null) {
        build_progress_index("No system ID, force...", 15);
        build_progress("No system ID, force", 15);
        shell_exec("{$nice} /usr/share/artica-postfix/bin/artica-update -refresh-index --force >/dev/null 2>&1");
        return;
    }
    $xMEM_TOTAL_INSTALLEE = $users->MEM_TOTAL_INSTALLEE;
    $CPU_NUMBER = $users->CPU_NUMBER;
    $LinuxDistributionFullName = $users->LinuxDistriFullName;
    if ($LinuxDistributionFullName == null) {
        $LinuxDistributionFullName = "Linux Default";
    }
    $ARTICA_VERSION = GetCurrentVersion();
    $hostname = $unix->hostname_g();
    $CheckUserCount = CheckUserCount();
    $RebootAfterArticaUpgrade = $sock->GET_INFO("RebootAfterArticaUpgrade");
    if (!is_numeric($RebootAfterArticaUpgrade)) {
        $RebootAfterArticaUpgrade = 0;
    }
    $EnableScheduleUpdates = $sock->GET_INFO("EnableScheduleUpdates");
    $ArticaUpdateIntervalAllways = intval($sock->GET_INFO("EnableScheduleUpdates"));
    if (!is_numeric($EnableScheduleUpdates)) {
        $EnableScheduleUpdates = 0;
    }
    $ArticaAutoUpateOfficial = $sock->GET_INFO("ArticaAutoUpateOfficial");
    $ArticaAutoUpateNightly = intval($sock->GET_INFO("ArticaAutoUpateNightly"));
    $ArticaUpdateIntervalAllways = intval($sock->GET_INFO("ArticaUpdateIntervalAllways"));
    $OfficialArticaUri = $sock->GET_INFO("OfficialArticaUri");
    if (!is_numeric($ArticaAutoUpateOfficial)) {
        $ArticaAutoUpateOfficial = 1;
    }
    if ($OfficialArticaUri == null) {
        $OfficialArticaUri = "http://articatech.net/artica.update.php";
    }
    $uri = $OfficialArticaUri;
    $dmidecode = @file_get_contents("/etc/artica-postfix/dmidecode.cache.url");
    @unlink($GLOBALS["MasterIndexFile"]);
    $tarballs_file = "/usr/share/artica-postfix/ressources/logs/web/tarballs.cache";
    echo "Starting......: " . date("H:i:s") . " CPU NUMBER: {$CPU_NUMBER}\n";
    echo "Starting......: " . date("H:i:s") . " Hostname..: {$hostname}\n";
    echo "Starting......: " . date("H:i:s") . " Artica ver: {$ARTICA_VERSION}\n";
    echo "Starting......: " . date("H:i:s") . " Users.....: {$CheckUserCount}\n";
    build_progress_index("Configuration done...", 15);
    build_progress("Configuration done", 15);
    $DATA["UUID"] = $SYSTEMID;
    $DATA["MEM"] = $xMEM_TOTAL_INSTALLEE;
    $DATA["CPU"] = $CPU_NUMBER;
    $DATA["LINUX"] = $LinuxDistributionFullName;
    $DATA["VERSION"] = $ARTICA_VERSION;
    $DATA["HOSTNAME"] = $hostname;
    $DATA["USERS"] = $CheckUserCount;
    $DATA["DMICODE"] = $dmidecode;
    build_progress_index("Check repositories...", 20);
    build_progress("Check repositories", 20);
    $MAIN_URI = $unix->MAIN_URI();
    echo "Starting......: " . date("H:i:s") . " Main URI..: {$MAIN_URI}\n";
    $md5string = @md5_file($GLOBALS["MasterIndexFile"]);
    build_progress_index("Get Index...", 25);
    build_progress("Get Index...", 25);
    echo "Starting......: " . date("H:i:s") . " Update index file..\n";
    $curl = new ccurl($OfficialArticaUri);
    $curl->parms["datas"] = base64_encode(serialize($DATA));
    if (!$curl->get()) {
        echo "Last detected error: {$curl->error}\n";
        build_progress_index("Get Index...{failed}", 110);
        build_progress("Get Index file !! FAILED !!", 110);
        _artica_update_event(0, "Unable to download index file with error {$curl->error_num}, {$curl->error}", null, __FILE__, __LINE__);
        return false;
    }
    @unlink("/etc/artica-postfix/settings/Daemons/ArticaUpdateRepos");
    build_progress_index("Parse Index from repository", 40);
    build_progress("Parse Index from repository", 40);
    if (preg_match("#<ERROR>(.+?)</ERROR>#is", $curl->data, $re)) {
        echo "{$re[1]} !! FAILED !!\n";
        build_progress_index("Corrupted index from repository !! FAILED !!", 110);
        build_progress("Corrupted index from repository !! FAILED !!", 110);
        return;
    }
    if (!preg_match("#<CONTENT>(.+?)</CONTENT>#is", $curl->data, $re)) {
        echo "Corrupted index from repository !! FAILED !!\n";
        build_progress_index("Corrupted index from repository !! FAILED !!", 110);
        build_progress("Corrupted index from repository !! FAILED !!", 110);
        return;
    }
    $MAIN = unserialize(base64_decode($re[1]));
    if (!is_array($MAIN)) {
        echo "It is not an array...\n";
        build_progress_index("Corrupted index from repository !! FAILED !!", 110);
        build_progress("Corrupted index from repository !! FAILED !!", 110);
    }
    build_progress_index("Retreive index from repository success", 100);
    @file_put_contents("/etc/artica-postfix/settings/Daemons/ArticaUpdateRepos", serialize($MAIN));
    return true;
}
Esempio n. 7
0
function save_ssl()
{
    $sock = new sockets();
    if (isset($_POST["UfdbUseArticaClient"])) {
        $sock->SET_INFO("UfdbUseArticaClient", $_POST["UfdbUseArticaClient"]);
    }
    if (isset($_POST["UfdbgclientSockTimeOut"])) {
        $sock->SET_INFO("UfdbgclientSockTimeOut", $_POST["UfdbgclientSockTimeOut"]);
    }
    if (isset($_POST["UfdbgclientMaxSockTimeOut"])) {
        $sock->SET_INFO("UfdbgclientMaxSockTimeOut", $_POST["UfdbgclientMaxSockTimeOut"]);
    }
    if (isset($_POST["SquidGuardRedirectBehavior"])) {
        $sock->SET_INFO("SquidGuardRedirectBehavior", $_POST["SquidGuardRedirectBehavior"]);
    }
    if (isset($_POST["SquidGuardRedirectHTTPCode"])) {
        $sock->SET_INFO("SquidGuardRedirectHTTPCode", $_POST["SquidGuardRedirectHTTPCode"]);
    }
    if (isset($_POST["SquidGuardUseRefreshDomainList"])) {
        $sock->SET_INFO("SquidGuardUseRefreshDomainList", $_POST["SquidGuardUseRefreshDomainList"]);
    }
    if (isset($_POST["UseRemoteUfdbguardService"])) {
        $sock->SET_INFO('UseRemoteUfdbguardService', $_POST["UseRemoteUfdbguardService"]);
        if ($_POST["UseRemoteUfdbguardService"] == 1) {
            $remote_server = $_POST["remote_server"];
            $remote_port = $_POST["remote_port"];
            if (!is_numeric($remote_port)) {
                $remote_port = 3977;
                $_POST["remote_port"] = 3977;
            }
            if (@fsockopen($remote_server, 9000, $errno, $errstr, 1)) {
                $uri = "https://{$remote_server}:9000/nodes.listener.php?ufdbguardport={$remote_port}";
                $curl = new ccurl($uri);
                $curl->NoHTTP_POST = true;
                if (!$curl->get()) {
                }
            }
            if (!@fsockopen($remote_server, $remote_port, $errno, $errstr, 1)) {
                echo "{$remote_server}:{$remote_port}\nError: {$errno} {$errstr}\n";
            }
        }
    }
    if (isset($_POST["UfdbGuardThreads"])) {
        writelogs("SET_INFO UfdbGuardThreads= {$_POST["UfdbGuardThreads"]}", __FUNCTION__, __FILE__, __LINE__);
        $sock->SET_INFO('UfdbGuardThreads', $_POST["UfdbGuardThreads"]);
    }
    if (isset($_POST["ufdbguardReloadTTL"])) {
        writelogs("SET_INFO ufdbguardReloadTTL= {$_POST["ufdbguardReloadTTL"]}", __FUNCTION__, __FILE__, __LINE__);
        $sock->SET_INFO('ufdbguardReloadTTL', $_POST["ufdbguardReloadTTL"]);
    }
    if (isset($_POST["EnableGoogleSafeSearch"])) {
        writelogs("SET_INFO EnableGoogleSafeSearch= {$_POST["EnableGoogleSafeSearch"]}", __FUNCTION__, __FILE__, __LINE__);
        $sock->SET_INFO('EnableGoogleSafeSearch', $_POST["EnableGoogleSafeSearch"]);
    }
    if (isset($_POST["UfdbDatabasesInMemory"])) {
        writelogs("SET_INFO UfdbDatabasesInMemory= {$_POST["UfdbDatabasesInMemory"]}", __FUNCTION__, __FILE__, __LINE__);
        $sock->SET_INFO('UfdbDatabasesInMemory', $_POST["UfdbDatabasesInMemory"]);
    }
    $datas = unserialize(base64_decode($sock->GET_INFO("ufdbguardConfig")));
    while (list($key, $line) = each($_POST)) {
        writelogs("SAVE {$key} = {$line}", __FUNCTION__, __FILE__, __LINE__);
        $datas[$key] = $line;
    }
    $sock->SaveConfigFile(base64_encode(serialize($datas)), "ufdbguardConfig");
    $sock->getFrameWork("cmd.php?reload-squidguard=yes");
}
Esempio n. 8
0
function RefreshIndex()
{
    $unix = new unix();
    $nice = EXEC_NICE();
    $sock = new sockets();
    $users = new usersMenus();
    $nohup = $unix->find_program("nohup");
    $php = $unix->LOCATE_PHP5_BIN();
    $wget = $unix->find_program("wget");
    $SYSTEMID = $unix->GetUniqueID();
    if ($SYSTEMID == null) {
        build_progress("System ID is Null !!!", 5);
        return;
    }
    build_progress("Register server...", 10);
    shell_exec("{$nohup} {$nice} {$php} /usr/share/artica-postfix/exec.web-community-filter.php --register-lic >/dev/null 2>&1 &");
    if ($SYSTEMID == null) {
        build_progress("No system ID, force", 15);
        shell_exec("{$nice} /usr/share/artica-postfix/bin/artica-update -refresh-index --force >/dev/null 2>&1");
        return;
    }
    $xMEM_TOTAL_INSTALLEE = $users->MEM_TOTAL_INSTALLEE;
    $CPU_NUMBER = $users->CPU_NUMBER;
    $LinuxDistributionFullName = $users->LinuxDistriFullName;
    if ($LinuxDistributionFullName == null) {
        $LinuxDistributionFullName = "Linux Default";
    }
    $ARTICA_VERSION = GetCurrentVersion();
    $hostname = $unix->hostname_g();
    $CheckUserCount = CheckUserCount();
    $dmidecode = @file_get_contents("/etc/artica-postfix/dmidecode.cache.url");
    $uriplus = "{$SYSTEMID};{$xMEM_TOTAL_INSTALLEE};{$CPU_NUMBER};{$LinuxDistributionFullName};{$ARTICA_VERSION};{$hostname};{$CheckUserCount};{$dmidecode}";
    $uriplus = urlencode($uriplus);
    @unlink($GLOBALS["MasterIndexFile"]);
    $tarballs_file = "/usr/share/artica-postfix/ressources/logs/web/tarballs.cache";
    echo "Starting......: " . date("H:i:s") . " CPU NUMBER: {$CPU_NUMBER}\n";
    echo "Starting......: " . date("H:i:s") . " Hostname..: {$hostname}\n";
    echo "Starting......: " . date("H:i:s") . " Artica ver: {$ARTICA_VERSION}\n";
    echo "Starting......: " . date("H:i:s") . " Users.....: {$CheckUserCount}\n";
    build_progress("Configuration done", 15);
    $ini = new iniFrameWork();
    $ini->loadFile('/etc/artica-postfix/artica-update.conf');
    if (trim($ini->_params["AUTOUPDATE"]["uri"]) == null) {
        $ini->_params["AUTOUPDATE"]["uri"] = "http://www.articatech.net/auto.update.php";
    }
    if (!isset($ini->_params["AUTOUPDATE"]["enabled"])) {
        $ini->_params["AUTOUPDATE"]["enabled"] = "yes";
    }
    if ($ini->_params["AUTOUPDATE"]["enabled"] == null) {
        $ini->_params["AUTOUPDATE"]["enabled"] = "yes";
    }
    if (!is_numeric(trim($ini->_params["AUTOUPDATE"]["CheckEveryMinutes"]))) {
        $ini->_params["AUTOUPDATE"]["CheckEveryMinutes"] = 60;
    }
    $uri = $ini->_params["AUTOUPDATE"]["uri"];
    $arrayURI = parse_url($uri);
    build_progress("Check repositories", 20);
    $MAIN_URI = $unix->MAIN_URI();
    echo "Starting......: " . date("H:i:s") . " Main URI..: {$MAIN_URI}\n";
    $md5string = @md5_file($GLOBALS["MasterIndexFile"]);
    build_progress("Get TarBalls...", 25);
    echo "Starting......: " . date("H:i:s") . " Update tarballs..\n";
    $curl = new ccurl("{$MAIN_URI}/tarballs.php?time=" . time());
    @unlink($tarballs_file);
    $curl->NoHTTP_POST = true;
    if (!$curl->GetFile($tarballs_file)) {
        build_progress("Get TarBalls !! FAILED !!", 30);
        _artica_update_event(0, "Unable to download tarballs file with error {$curl->error_num}, {$curl->error}", null, __FILE__, __LINE__);
        @unlink($tarballs_file);
    }
    build_progress("Ping repositories...", 35);
    @chmod($tarballs_file, 0755);
    echo "Starting......: " . date("H:i:s") . " dmidecode = " . strlen($dmidecode) . " bytes\n";
    echo "Starting......: " . date("H:i:s") . " Updating repository information..\n";
    $curl = new ccurl("{$MAIN_URI}/routers.inject.php?time=" . time());
    $curl->NoHTTP_POST = true;
    $curl->get();
    build_progress("Retreive index from repository", 40);
    $curl = new ccurl("{$uri}?time=" . time() . "&datas={$uriplus}");
    $curl->NoHTTP_POST = true;
    $curl->forceCache = true;
    echo "Starting......: " . date("H:i:s") . " Downloading collection using Interface: `{$curl->interface}`\n";
    echo "Starting......: " . date("H:i:s") . " Using \"{$GLOBALS["MasterIndexFile"]}\"\n";
    echo "Starting......: " . date("H:i:s") . " Timeout set to \"{$curl->Timeout}s\"\n";
    if (!$curl->GetFile($GLOBALS["MasterIndexFile"])) {
        build_progress("Retreive index from repository !! FAILED !!", 100);
        if (!$GLOBALS["NOT_FORCE_PROXY"]) {
            echo "Starting......: " . date("H:i:s") . " FATAL: Unable to download index file, try in direct mode\n";
            $GLOBALS["NOT_FORCE_PROXY"] = true;
            return RefreshIndex();
        }
        echo "Starting......: " . date("H:i:s") . " FATAL: {$GLOBALS["MasterIndexFile"]} " . @filesize($GLOBALS["MasterIndexFile"]) . " bytes\n";
        echo "Starting......: " . date("H:i:s") . " FATAL: Unable to download index file with error {$curl->error_num}, {$curl->error}\n";
        _artica_update_event(0, "Unable to download index file with error {$curl->error_num}, {$curl->error}", null, __FILE__, __LINE__);
        exec("{$nice} /usr/share/artica-postfix/bin/artica-update -refresh-index 2>&1", $results);
        while (list($num, $ligne) = each($dirs)) {
            echo "Starting......: " . date("H:i:s") . " {$ligne}\n";
        }
        return;
    }
    build_progress("Retreive index from repository !! Success !!", 100);
    $md5string2 = md5_file($GLOBALS["MasterIndexFile"]);
    echo "Starting......: " . date("H:i:s") . " source: `{$md5string}` new: `{$md5string2}`\n";
    echo "Starting......: " . date("H:i:s") . " Success...\n";
    return true;
}
function peer_infos(){
	include_once("ressources/class.ccurl.inc");
	$squid=new squidbee();
	$sock=new sockets();
	$SquidMgrListenPort=trim($sock->GET_INFO("SquidMgrListenPort"));
	
	if( !is_numeric($SquidMgrListenPort) OR ($SquidMgrListenPort==0) ){
		$listenport=$squid->listen_port;
	
	}else{
		$listenport=$SquidMgrListenPort;
	}


	$uri="http://127.0.0.1:$listenport/squid-internal-mgr/peer_select";
	if($GLOBALS["VERBOSE"]){echo "<li> curl -> $uri</li>";}
	$curl=new ccurl("http://127.0.0.1:$squid->listen_port/squid-internal-mgr/peer_select");
	$curl->NoHTTP_POST=true;
	$curl->ArticaProxyServerEnabled="no";
	$curl->CURLOPT_NOPROXY="127.0.0.1";
	$curl->ArticaProxyServerEnabled=="no";
	$curl->interface="127.0.0.1";
	$curl->Timeout=5;
	$curl->UseDirect=true;		
	$curl->get();
	if($GLOBALS["VERBOSE"]){echo "<li> ". strlen( $curl->data)."</li>";}
	$datas=explode("\n", $curl->data);
	while (list ($index, $line) = each ($datas)){
		
		if(preg_match("#peer digest from\s+(.+)#", $line,$re)){$serv=$re[1];}
		if(preg_match("#needed:\s+(.+?),\s+usable:\s+(.+?),\s+requested:\s+(.+)#", $line,$re)){
			$ARR[$serv]["needed"]=$re[1];
			$ARR[$serv]["usable"]=$re[2];
			$ARR[$serv]["requested"]=$re[3];
		}
	
		if(preg_match("#requests sent: ([0-9]+), volume: (.+)#",$line,$re)){
			$ARR[$serv]["RQSENT"]=$re[1];
			$ARR[$serv]["VOL"]=$re[2];
		}
	
	
		
	}
	
	return $ARR;
	
}
Esempio n. 10
0
function exunlink()
{
    $unix = new unix();
    $sock = new sockets();
    $net = new networking();
    $WgetBindIpAddress = $sock->GET_INFO("WgetBindIpAddress");
    $MAIN = unserialize(base64_decode($sock->GET_INFO("HASettings")));
    $eth = $MAIN["eth"];
    $t = time();
    if (!is_numeric($MAIN["SLAVE_SSL"])) {
        $MAIN["SLAVE_SSL"] = 1;
    }
    $proto = "http";
    if ($MAIN["SLAVE_SSL"] == 1) {
        $proto = "https";
    }
    $MAIN = unserialize(base64_decode($sock->GET_INFO("HASettings")));
    $eth = $MAIN["eth"];
    $nic = new system_nic($eth);
    $MAIN["BALANCE_IP"] = $MAIN["first_ipaddr"];
    $SEND_SETTING = base64_encode(serialize($MAIN));
    $uri = "{$proto}://{$MAIN["SLAVE"]}:{$MAIN["SLAVE_PORT"]}/nodes.listener.php?ucarp2-remove={$SEND_SETTING}&continue=true";
    build_progress("Notify {$MAIN["SLAVE"]}", 20);
    $curl = new ccurl($uri, true, $WgetBindIpAddress, true);
    $curl->NoHTTP_POST = true;
    if (!$curl->get()) {
        echo "{$curl->error}\n";
        debug_curl($curl->CURL_ALL_INFOS);
        build_progress("{reboot_networks} {$MAIN["SLAVE"]}:{$MAIN["SLAVE_PORT"]} {failed}", 110);
        return;
    }
    if (!preg_match("#<RESULTS>(.+?)</RESULTS>#is", $curl->data, $re)) {
        echo "Please verify that both servers must have the same Artica version\n";
        build_progress("{reboot_networks} {$MAIN["SLAVE"]}:{$MAIN["SLAVE_PORT"]} {protocol_error}", 110);
        return;
    }
    $array = unserialize(base64_decode($re[1]));
    if ($array["ERROR"]) {
        echo "{$array["ERROR_SHOW"]}\n";
        build_progress("{reboot_networks} {$MAIN["SLAVE"]}:{$MAIN["SLAVE_PORT"]} {failed}", 110);
        return;
    }
    build_progress("{please_wait_reconfigure_network}", 80);
    $nic = new system_nic($eth);
    $nic->ucarp_enabled = 0;
    $nic->ucarp_vip = null;
    $nic->ucarp_vid = 0;
    $nic->ucarp_master = 0;
    $nic->NoReboot = true;
    if (isset($MAIN["first_ipaddr"])) {
        if ($MAIN["first_ipaddr"] != null) {
            $nic->IPADDR = $MAIN["first_ipaddr"];
        }
    }
    if (!$nic->SaveNic()) {
        echo "Unable to save local settings\n";
        build_progress("{saving_local_parameters} {failed}", 110);
        return;
    }
    //please_wait_reconfigure_network
    $sock->SET_INFO("HASettings", base64_encode(serialize(array())));
    build_progress("{reboot_networks}", 75);
    $php = $unix->LOCATE_PHP5_BIN();
    system("{$php} /usr/share/artica-postfix/exec.virtuals-ip.php --build --force");
    build_progress("{reboot_networks}", 80);
    squid_admin_mysql(0, "Rebooting Network", null, __FILE__, __LINE__);
    system("/etc/init.d/artica-ifup --script=exec.failover.php/" . __FUNCTION__);
    build_progress("{starting_service}", 90);
    system("/etc/init.d/artica-failover stop");
    sleep(3);
    build_progress("{done}", 100);
}
Esempio n. 11
0
function notify_remote_proxys()
{
    include_once dirname(__FILE__) . "/ressources/class.ccurl.inc";
    $q = new mysql_squid_builder();
    $sql = "SELECT * FROM squidservers";
    $results = $q->QUERY_SQL($sql);
    while ($ligne = mysql_fetch_array($results, MYSQL_ASSOC)) {
        $server = $ligne["ipaddr"];
        $port = $ligne["port"];
        if (!is_numeric($port)) {
            continue;
        }
        $refix = "https";
        $uri = "{$refix}://{$server}:{$port}/squid.stats.listener.php";
        writelogs($uri, __FUNCTION__, __FILE__, __LINE__);
        $curl = new ccurl($uri, true);
        $curl->parms["CHANGE_CONFIG"] = "FILTERS";
        if (!$curl->get()) {
            squidstatsApplianceEvents("{$server}:{$port}", "FAILED Notify change it`s configuration {$curl->error}");
            continue;
        }
        if (preg_match("#<ANSWER>OK</ANSWER>#is", $curl->data)) {
            squidstatsApplianceEvents("{$server}:{$port}", "SUCCESS to notify change it`s configuration");
            continue;
        }
        squidstatsApplianceEvents("{$server}:{$port}", "FAILED Notify change it`s configuration {$curl->data}");
    }
}
function AddArticaAgent(){
	$tpl=new templates();
	$sock=new sockets();
	$pattern=$_POST["AddArticaAgent"];
	$ip=$pattern;
	if(preg_match("#(.+?):([0-9]+)#", $pattern,$re)){$ip=$re[1];$port=$re[2];}
	if(!is_numeric($port)){$port=9001;}
	include_once(dirname(__FILE__)."/ressources/class.ccurl.inc");
	
	
	$ArticaHttpsPort=$sock->GET_INFO("ArticaHttpsPort");
	$ArticaHttpUseSSL=$sock->GET_INFO("ArticaHttpUseSSL");
	if(!is_numeric($ArticaHttpUseSSL)){$ArticaHttpUseSSL=1;}
	if(!is_numeric($ArticaHttpsPort)){$ArticaHttpsPort="9000";}	
	
	
	$time=date('Y-m-d H:i:s');
	if(preg_match("#^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+#", $ip)){
		$hostname=gethostbyaddr($ip);
	}else{
		$hostname=$ip;
		$ip=gethostbyname($hostname);
	}

	$q=new mysql_blackbox();
	$q->CheckTables();
	$sql="INSERT IGNORE INTO `nodes` (ipaddress,hostname,port,laststatus) VALUES ('$ip','$hostname','$port','$time')";
	$q->QUERY_SQL($sql);
	if(!$q->ok){echo $q->mysql_error;return;}
	if($q->last_id==0){
		echo "Unable to get Last ID\n";return;
	}
	$curl=new ccurl("http://$ip:$port/listener.php");
	$curl->parms["REGISTER"]="yes";
	$curl->parms["SSL"]=$ArticaHttpUseSSL;
	$curl->parms["PORT"]=$ArticaHttpsPort;
	$curl->parms["NODE_ID"]=$q->last_id;
	if(!$curl->get()){echo $tpl->javascript_parse_text("{$curl->error}")."\nhttp://$ip:$port";return;}
	if(!preg_match("#<SUCCESS>#is", $curl->data)){echo $tpl->javascript_parse_text("{failed} `http://$ip:$port`");return;}	
	
}	
Esempio n. 13
0
function TESTCONNECTION($force = false)
{
    $sock = new sockets();
    $unix = new unix();
    if ($GLOBALS["FORCE"]) {
        $force = true;
    }
    $TimeFile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".time";
    $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
    if ($GLOBALS["VERBOSE"]) {
        echo "{$TimeFile}\n";
    }
    if (!$force) {
        $pid = $unix->get_pid_from_file($pidfile);
        if ($unix->process_exists($pid, basename(__FILE__))) {
            $time = $unix->PROCCESS_TIME_MIN($pid);
            if ($GLOBALS["OUTPUT"]) {
                echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]}: Already Artica task running PID {$pid} since {$time}mn\n";
            }
            return;
        }
    }
    @file_put_contents($pidfile, getmypid());
    $TimeEx = $unix->file_time_min($TimeFile);
    if (!$force) {
        if ($TimeEx < 5) {
            die;
        }
        @unlink($TimeFile);
        @file_put_contents($TimeFile, time());
    }
    $ArticaHotSpotInterface = $sock->GET_INFO("ArticaHotSpotInterface");
    if ($ArticaHotSpotInterface == null) {
        $ArticaHotSpotInterface = "eth0";
    }
    $NETWORK_ALL_INTERFACES = $unix->NETWORK_ALL_INTERFACES();
    $IPADDR = $NETWORK_ALL_INTERFACES[$ArticaHotSpotInterface]["IPADDR"];
    $ArticaHotSpotPort = intval($sock->GET_INFO("ArticaHotSpotPort"));
    $uri = "http://{$IPADDR}:{$ArticaHotSpotPort}/wifidog/status";
    $curl = new ccurl($uri, true, $IPADDR, true);
    $curl->NoHTTP_POST = true;
    $curl->Timeout = 5;
    $curl->interface = $IPADDR;
    if (!$curl->get()) {
        if (!$GLOBALS["NO_RESTART"]) {
            hotspot_admin_mysql(0, "Checking HotSpot service failed [action=restart]", $curl->errors, __FILE__, __LINE__);
            $GLOBALS["RECOVER"] = true;
            stop(true);
            start(true);
        }
    }
    $f = explode("\n", $curl->data);
    while (list($num, $line) = each($f)) {
        $line = trim($line);
        if (preg_match("#IP:\\s+([0-9\\.]+)\\s+MAC:\\s+(.+)#", $line, $re)) {
            $MAC = trim(strtolower($re[2]));
            $IP = trim($re[1]);
            continue;
        }
        if (preg_match("#Token:\\s+(.+)#", $line, $re)) {
            $ARRAY["SESSIONS"][$MAC] = trim($re[1]);
        }
        if ($line == null) {
            continue;
        }
        if (preg_match("#Uptime:\\s+(.+)#", $line, $re)) {
            $ARRAY["UPTIME"] = trim($re[1]);
            continue;
        }
        if (preg_match("#Internet Connectivity:\\s+(.+)#", $line, $re)) {
            $ARRAY["INTERNET"] = trim($re[1]);
            continue;
        }
        if (preg_match("#Clients served this session:\\s+([0-9]+)#", $line, $re)) {
            $ARRAY["CLIENTS"] = trim($re[1]);
            continue;
        }
        if (preg_match("#([0-9]+)\\s+clients connected#", $line, $re)) {
            $ARRAY["CLIENTS"] = trim($re[1]);
            continue;
        }
        if ($GLOBALS["VERBOSE"]) {
            echo "No Match {$line}\n";
        }
    }
    $ARRAY["TIME"] = time();
    if ($GLOBALS["VERBOSE"]) {
        print_r($ARRAY);
    }
    @mkdir("/usr/share/artica/postfix/ressources/logs/web", 0755, true);
    file_put_contents("/usr/share/artica/postfix/ressources/logs/web/wifidog.status", serialize($ARRAY));
    chmod("/usr/share/artica/postfix/ressources/logs/web/wifidog.status", 0755);
    return $ARRAY;
}
function replic_host($servername)
{
    $t = time();
    $unix = new unix();
    $free = new freeweb($servername);
    $instanceid = $free->mysql_instance_id;
    $localdatabase = $free->mysql_database;
    if (!isset($free->Params["ROUNDCUBE"]["ENABLE_REPLIC"])) {
        if ($GLOBALS["VERBOSE"]) {
            echo "{$servername}: ROUNDCUBE/ENABLE_REPLIC no set\n";
        }
        return null;
    }
    if ($free->Params["ROUNDCUBE"]["ENABLE_REPLIC"] == 0) {
        if ($GLOBALS["VERBOSE"]) {
            echo "{$servername}: ROUNDCUBE/ENABLE_REPLIC set to disabled\n";
        }
        return null;
    }
    $ARTICA_PORT = $free->Params["ROUNDCUBE"]["ARTICA_PORT"];
    $ARTICA_ADMIN = $free->Params["ROUNDCUBE"]["ARTICA_ADMIN"];
    $ARTICA_PASSWORD = $free->Params["ROUNDCUBE"]["ARTICA_PASSWORD"];
    $ARTICA_HOST = $free->Params["ROUNDCUBE"]["ARTICA_HOST"];
    $ARTICA_RMWEB = $free->Params["ROUNDCUBE"]["ARTICA_RMWEB"];
    if ($GLOBALS["VERBOSE"]) {
        echo "Send order to get database dump {$ARTICA_HOST}:{$ARTICA_PORT}\n";
    }
    $auth = array("username" => $ARTICA_ADMIN, "password" => md5($ARTICA_PASSWORD));
    $auth = base64_encode(serialize($auth));
    $curl = new ccurl("https://{$ARTICA_HOST}:{$ARTICA_PORT}/exec.gluster.php");
    $curl->noproxyload = true;
    $curl->parms["AUTH"] = $auth;
    $curl->parms["RDCUBE-REPLIC"] = $ARTICA_RMWEB;
    if (!$curl->get()) {
        if ($GLOBALS["VERBOSE"]) {
            echo "Error replicate roundcube to {$ARTICA_HOST}:{$ARTICA_PORT} with error {$curl->error}\n";
        }
        system_admin_events("Error replicate roundcube to {$ARTICA_HOST}:{$ARTICA_PORT} with error {$curl->error}", __FUNCTION__, __FILE__, __LINE__, "roundcube");
        return;
    }
    preg_match("#<INFOS>(.*?)</INFOS>#is", $curl->data, $re);
    if ($GLOBALS["VERBOSE"]) {
        echo "{$curl->data}\n";
    }
    if (!preg_match("#<FILENAME>(.*?)</FILENAME>#is", $curl->data, $re)) {
        preg_match("#<ERROR>(.*?)</ERROR>#is", $curl->data, $re);
        if ($GLOBALS["VERBOSE"]) {
            echo "Error replicate roundcube to {$ARTICA_HOST}:{$ARTICA_PORT} with error {$re[1]}\n";
        }
        system_admin_events("Error replicate roundcube to {$ARTICA_HOST}:{$ARTICA_PORT} with error {$re[1]}", __FUNCTION__, __FILE__, __LINE__, "roundcube");
        return;
    }
    $filepath = $re[1];
    $filename = basename($filepath);
    $curl = new ccurl("https://{$ARTICA_HOST}:{$ARTICA_PORT}/{$filepath}");
    if (!$curl->GetFile("/tmp/{$filename}")) {
        if ($GLOBALS["VERBOSE"]) {
            echo "Error get  roundcube database from {$filepath} with error {$curl->error}\n";
        }
        system_admin_events("Error get  roundcube database from {$filepath} with error {$curl->error}", __FUNCTION__, __FILE__, __LINE__, "roundcube");
        return;
    }
    $filesize = $unix->file_size("/tmp/{$filename}");
    if ($GLOBALS["VERBOSE"]) {
        echo "Downloading {$filename} done with {$filesize} bytes\n";
    }
    if (!$unix->uncompress("/tmp/{$filename}", "/tmp/{$filename}.sql")) {
        @unlink("/tmp/{$filename}");
        if ($GLOBALS["VERBOSE"]) {
            echo "Error uncompress {$filepath}\n";
        }
        system_admin_events("Error uncompress {$filepath}", __FUNCTION__, __FILE__, __LINE__, "roundcube");
        return;
    }
    @unlink("/tmp/{$filename}");
    $mysqlbin = $unix->find_program("mysql");
    if ($instanceid > 0) {
        $q = new mysql_multi($instance_id);
        if ($q->mysql_password != null) {
            $password = "******";
        }
        $cmdline = "{$mysqlbin} --batch --force --user={$q->mysql_admin}{$password} --socket={$q->SocketPath} --database={$localdatabase} </tmp/{$filename}.sql 2>&1";
    } else {
        $q = new mysql();
        if ($q->mysql_server == "127.0.0.1") {
            $servcmd = " --socket=/var/run/mysqld/mysqld.sock ";
        } else {
            $servcmd = " --host={$q->mysql_server} --port={$q->mysql_port} ";
        }
        if ($q->mysql_password != null) {
            $password = "******";
        }
        $cmdline = "{$mysqlbin} --batch --force --user={$q->mysql_admin}{$password} {$servcmd} --database={$localdatabase} </tmp/{$filename}.sql 2>&1";
    }
    if ($GLOBALS["VERBOSE"]) {
        echo $cmdline . "\n";
    }
    shell_exec($cmdline);
    $took = $unix->distanceOfTimeInWords($t, time(), true);
    system_admin_events("Success import from {$filename} to {$localdatabase} took {$took}", __FUNCTION__, __FILE__, __LINE__, "roundcube");
    @unlink("/tmp/{$filename}.sql");
}
function add_node()
{
    $sock = new sockets();
    $ArticaMetaAddNewServ = unserialize($sock->GET_INFO("ArticaMetaAddNewServ"));
    $ArticaMetaHost = $ArticaMetaAddNewServ["ArticaMetaHost"];
    $ArticaMetaPort = $ArticaMetaAddNewServ["ArticaMetaPort"];
    $ArticaMetaUsername = $ArticaMetaAddNewServ["ArticaMetaUsername"];
    $ArticaMetaPassword = $ArticaMetaAddNewServ["ArticaMetaPassword"];
    $change_uuid = $ArticaMetaAddNewServ["change_uuid"];
    echo "ArticaMetaHost.........: {$ArticaMetaHost}\n";
    echo "ArticaMetaPort.........: {$ArticaMetaPort}\n";
    echo "ArticaMetaUsername.....: {$ArticaMetaUsername}\n";
    echo "Testing authentication...\n";
    add_node_progress("Authenticate to {$ArticaMetaHost}:{$ArticaMetaPort}", 10);
    $array["username"] = $ArticaMetaUsername;
    $array["password"] = $ArticaMetaPassword;
    $ident = urlencode(base64_encode(serialize($array)));
    $curl = new ccurl("https://{$ArticaMetaHost}:{$ArticaMetaPort}/artica.meta.listener.php?test-local-ident={$ident}");
    $curl->NoHTTP_POST = true;
    $curl->NoLocalProxy();
    $curl->Timeout = 120;
    if (!$curl->get()) {
        echo @implode("\n", $curl->errors);
        add_node_progress("{$curl->error}", 110);
        die;
    }
    if (!preg_match("#<ARTICA_META>(.+?)</ARTICA_META>#is", $curl->data, $re)) {
        echo "Expected <ARTICA_META>Someting...</ARTICA_META>";
        add_node_progress("Communication: {failed}", 110);
        die;
    }
    if ($re[1] != "SUCCESS") {
        add_node_progress("Authenticate: {failed}", 110);
        die;
    }
    echo "Testing authentication - success -...\n";
    if ($change_uuid == 1) {
        echo "Ask to remote server to change UUID...\n";
        add_node_progress("{change_uuid}", 20);
        $curl = new ccurl("https://{$ArticaMetaHost}:{$ArticaMetaPort}/artica.meta.listener.php?local-ident={$ident}&chuuid=yes");
        $curl->NoHTTP_POST = true;
        $curl->NoLocalProxy();
        $curl->Timeout = 120;
        if (!$curl->get()) {
            echo @implode("\n", $curl->errors);
            add_node_progress("{$curl->error}", 110);
            die;
        }
        if (!preg_match("#<ARTICA_META>(.+?):(.+?)</ARTICA_META>#is", $curl->data, $re)) {
            add_node_progress("{change_uuid}: Communication: {failed}", 110);
            die;
        }
        add_node_progress("{change_uuid}:{$re[2]} {success}", 25);
        echo "Ask to remote server to change UUID - success -...\n";
    }
    echo "Ask UUID to remote server...\n";
    add_node_progress("{uuid}:", 30);
    $curl = new ccurl("https://{$ArticaMetaHost}:{$ArticaMetaPort}/artica.meta.listener.php?local-ident={$ident}&GetYourUUID=yes");
    $curl->NoHTTP_POST = true;
    $curl->NoLocalProxy();
    $curl->Timeout = 120;
    if (!$curl->get()) {
        echo @implode("\n", $curl->errors);
        add_node_progress("{$curl->error}", 110);
        die;
    }
    if (!preg_match("#<ARTICA_META>(.+?):(.+?)</ARTICA_META>#is", $curl->data, $re)) {
        add_node_progress("{uuid}: Communication: {failed}", 110);
        die;
    }
    $RESULT = $re[1];
    $uuid = $re[2];
    echo "UUID results:\n---------------------------------------------\n{$uuid}\n{$RESULT}\n---------------------------------------------\n";
    if ($RESULT == "SUCCESS") {
        add_node_progress("{uuid}: {$uuid} {success}", 35);
    } else {
        add_node_progress("{uuid}: {failed}", 110);
        return;
    }
    echo "Ask to remote server to register to Artica Meta server ...\n";
    add_node_progress("{order}: -> {register}", 50);
    $ArticaMetaServerUsername = $sock->GET_INFO("ArticaMetaServerUsername");
    $ArticaMetaServerPassword = $sock->GET_INFO("ArticaMetaServerPassword");
    $ArticaMetaAddNewServ["ArticaMetaUsername"] = $ArticaMetaServerUsername;
    $ArticaMetaAddNewServ["ArticaMetaPassword"] = $ArticaMetaServerPassword;
    if ($GLOBALS["VERBOSE"]) {
        $verbosed = "&verbose=yes";
    }
    $ArticaMetaAddNewServ_enc = urlencode(base64_encode(serialize($ArticaMetaAddNewServ)));
    $curl = new ccurl("https://{$ArticaMetaHost}:{$ArticaMetaPort}/artica.meta.listener.php?local-ident={$ident}&registerby={$ArticaMetaAddNewServ_enc}{$verbosed}");
    $curl->NoHTTP_POST = true;
    $curl->NoLocalProxy();
    $curl->Timeout = 120;
    if (!$curl->get()) {
        echo @implode("\n", $curl->errors);
        add_node_progress("{$curl->error}", 110);
        die;
    }
    if ($GLOBALS["VERBOSE"]) {
        echo "***********************************\n{$curl->data}\n***********************************\n";
    }
    if (!preg_match("#<ARTICA_META>(.+?):(.+?)</ARTICA_META>#is", $curl->data, $re)) {
        add_node_progress("{register}: Communication: {failed}", 110);
        die;
    }
    $RESULT = $re[1];
    $DATA = $re[2];
    echo $DATA;
    echo "Register results:\n---------------------------------------------\n{$DATA}\n{$RESULT}\n---------------------------------------------\n";
    if ($RESULT == "SUCCESS") {
        add_node_progress("{register}: {success}", 99);
    } else {
        add_node_progress("{register}: {failed}", 110);
        return;
    }
    $artica_meta = new mysql_meta();
    add_node_progress("{waiting}: {$ArticaMetaHost} {to_return_back}", 79);
    for ($i = 0; $i < 20; $i++) {
        if ($artica_meta->isExists($uuid)) {
            break;
        }
        echo "Waiting {$ArticaMetaHost} {$uuid} to register to Artica Meta...{$i}/20 second\n";
        $prc = 79 + $i;
        add_node_progress("{waiting}: {$ArticaMetaHost} {to_return_back}", $prc);
        sleep(1);
    }
    if ($artica_meta->isExists($uuid)) {
        $hostname = $artica_meta->uuid_to_host($uuid);
        add_node_progress("{register}: {success} `{$hostname}`", 100);
        return;
    }
    add_node_progress("{register}: {failed}", 110);
}
if (!is_numeric($NoDryReboot)) {
    $NoDryReboot = 0;
}
$proto = "http";
if ($ArticaHttpUseSSL == 1) {
    $proto = "https";
}
$uri = $curl = new ccurl("{$proto}://{$LighttpdArticaListenIP}:{$ArticaHttpsPort}/logon.php");
$curl->NoHTTP_POST = true;
$curl->noproxyload = true;
if (!$curl->get()) {
    if ($GLOBALS["VERBOSE"]) {
        echo "Error Data returned error {$curl->error}\n";
    }
    if ($curl->error == 500) {
        exec("/etc/init.d/artica-postfix restart apache 2>&1", $results);
        system_admin_events("Error 500 detected on the Artica Web interface, reboot web server" . @implode("\n", $results), __FUNCTION__, __FILE__, __LINE__, "watchdog");
        $curl = new ccurl("{$proto}://{$LighttpdArticaListenIP}:{$ArticaHttpsPort}/logon.php");
        $curl->NoHTTP_POST = true;
        $curl->noproxyload = true;
        if (!$curl->get()) {
            system_admin_events("Error 500 detected on the Artica Web interface, after reboot web server" . @implode("\n", $results), __FUNCTION__, __FILE__, __LINE__, "watchdog");
            if ($NoDryReboot == 0) {
                system_admin_events("Error 500 detected: reboot the server..." . @implode("\n", $results), __FUNCTION__, __FILE__, __LINE__, "watchdog");
                $unix->send_email_events("Web Error 500 as been detected, reboot the server", "Web service still stay in 500 status after rebooting the web service, artica will reboot the server", "system");
                $reboot = $unix->find_program("reboot");
                shell_exec($reboot);
            }
        }
    }
}
Esempio n. 17
0
function request_order()
{
    $curl = new ccurl("http://www.artica.fr/shalla-orders.php");
    $sock = new sockets();
    $uuid = base64_decode($sock->getFrameWork("cmd.php?system-unique-id=yes"));
    $sock = new sockets();
    $shallalistLicense = $sock->GET_INFO("shallalistLicense");
    $ini = new Bs_IniHandler();
    $ini->loadString($shallalistLicense);
    $license = $ini->_params["SHALLA"]["LICENSE"];
    $conf[] = "[INFO]";
    $conf[] = "email={$_GET["email"]}";
    $conf[] = "company={$_GET["company"]}";
    $conf[] = "[SHALLA]";
    $conf[] = "LICENSE={$license}";
    $sock->SaveConfigFile(implode("\n", $conf), "shallalistLicense");
    $_GET["UUID"] = $uuid;
    $datas = base64_encode(serialize($_GET));
    $curl->parms["DATAS"] = $datas;
    if (!$curl->get()) {
        $tpl = new templates();
        echo $tpl->javascript_parse_text($curl->error);
        return;
    }
    if (preg_match("#<ANSWER>OK</ANSWER>#is", $curl->data)) {
        $tpl = new templates();
        echo $tpl->javascript_parse_text("{shalla_success_order}");
    }
}
Esempio n. 18
0
function CurlGet($cmd)
{
    if (is31()) {
        if ($GLOBALS["VERBOSE"]) {
            echo "squidclient({$cmd})\n";
        }
        $data = squidclient($cmd);
        if ($GLOBALS["VERBOSE"]) {
            echo "squidclient({$cmd}) -> " . strlen($data) . " bytes\n";
        }
        return $data;
    }
    if ($GLOBALS["VERBOSE"]) {
        echo "builduri({$cmd})\n";
    }
    $curl = new ccurl(builduri($cmd));
    $curl->ArticaProxyServerEnabled == "no";
    $curl->interface = "127.0.0.1";
    $curl->Timeout = 5;
    $curl->UseDirect = true;
    if (!$curl->get()) {
        return;
    }
    return $curl->data;
}
Esempio n. 19
0
function NoIp()
{
    $sock = new sockets();
    $EnableNoIpService = $sock->GET_INFO("EnableNoIpService");
    if (!is_numeric($EnableNoIpService)) {
        $EnableNoIpService = 0;
    }
    if ($EnableNoIpService == 0) {
        return;
    }
    $Config = unserialize(base64_decode($sock->GET_INFO("NoipConf")));
    $curl = new ccurl("http://dynupdate.no-ip.com/nic/update?hostname={$Config["NoIPHostname"]}");
    $curl->authname = $Config["NoIPUsername"];
    $curl->authpass = $Config["NoIPPassword"];
    $curl->NoHTTP_POST = true;
    if (!$curl->get()) {
        system_admin_events("Fatal {$curl->error} !!", __FUNCTION__, __FILE__, __LINE__, "system");
        return;
    }
    $results = explode("\n", $curl->data);
    while (list($num, $line) = each($results)) {
        $line = trim($line);
        if ($line == null) {
            continue;
        }
        if (preg_match("#good\\s+([0-9\\.]+)#", $line, $re)) {
            system_admin_events("OK For {$re[1]}", __FUNCTION__, __FILE__, __LINE__, "system");
            writelogs("OK for {$re[1]}", __FUNCTION__, __FILE__);
            $myip = $re[1];
            break;
        }
        if (preg_match("#nochg\\s+([0-9\\.]+)#", $line, $re)) {
            writelogs("OK no changes {$re[1]}", __FUNCTION__, __FILE__);
            $myip = $re[1];
            break;
        }
        if (preg_match("#nochg\\s+([0-9\\.]+)#", $line, $re)) {
            writelogs("OK no changes {$re[1]}", __FUNCTION__, __FILE__);
            $myip = $re[1];
            break;
        }
        if (preg_match("#abuse\\s+(.+)#", $line, $re)) {
            writelogs("Fatal: Abuse!!!! {$re[1]}", __FUNCTION__, __FILE__);
            break;
        }
    }
    if ($myip != null) {
        @file_put_contents("/usr/share/artica-postfix/ressources/logs/web/myIP.conf", $myip);
        @chmod("/usr/share/artica-postfix/ressources/logs/web/myIP.conf", 775);
        $sock->SET_INFO("PublicIPAddress", $myip);
    }
}
Esempio n. 20
0
function pushit(){
	$curl=new ccurl("http://www.artica.fr/shalla-orders.php");
	$curl->parms["ORDER_EXPORT"]="yes";
	$curl->get();
	if(preg_match("#<ANSWER>OK</ANSWER>#is",$curl->data)){
		WriteMyLogs("success",__FUNCTION__,__FILE__,__LINE__);
	}else{
		WriteMyLogs("failed\n$curl->data" ,__FUNCTION__,__FILE__,__LINE__);	
	}
}
Esempio n. 21
0
function start()
{
    $unix = new unix();
    $tmp_path = $unix->TEMP_DIR();
    _progress("Check repository", 10);
    echo "Downloading index file...\n";
    $curl = new ccurl("http://www.artica.fr/auto.update.php");
    $curl->NoHTTP_POST = true;
    if (!$curl->get()) {
        _progress("Check repository - FAILED", 100);
        echo "{$curl->error}\n";
        return;
    }
    $ini = new Bs_IniHandler();
    $ini->loadString($curl->data);
    $couldversion = $ini->_params["NEXT"]["z-push"];
    echo "Available version = {$couldversion}\n";
    if ($couldversion == null) {
        _progress("Check repository - FAILED", 100);
        echo "Corrupted index file\n";
        return;
    }
    $rm = $unix->find_program("rm");
    $SourceFile = "z-push-{$couldversion}.tar.gz";
    $SourcePath = "{$tmp_path}/{$SourceFile}";
    $SourceTemp = "{$tmp_path}/" . time();
    $InstallDir = $SourceTemp;
    echo "Downloading http://www.artica.fr/download/z-push-{$couldversion}.tar.gz\n";
    _progress("Downloading v.{$couldversion}", 15);
    $curl = new ccurl("http://www.artica.fr/download/z-push-{$couldversion}.tar.gz");
    @unlink($SourcePath);
    if (!$curl->GetFile($SourcePath)) {
        @unlink($SourcePath);
        _progress("Download {$SourceFile} - FAILED", 100);
        echo $curl->error . "\n";
        return;
    }
    _progress("Uncompress {$SourceFile}", 20);
    echo "Create temp dir: {$SourceTemp}\n";
    echo "Uncompress {$SourcePath}\n";
    @mkdir("/usr/share/z-push", 0755, true);
    @mkdir($SourceTemp, 0755, true);
    $tar = $unix->find_program("tar");
    $cp = $unix->find_program("cp");
    $php = $unix->LOCATE_PHP5_BIN();
    shell_exec("{$tar} xf {$SourcePath} -C {$SourceTemp}/");
    @unlink($SourcePath);
    if (!is_file("{$InstallDir}/version.php")) {
        echo "Finding directory\n";
        $DIRS = $unix->dirdir($SourceTemp);
        while (list($num, $ligne) = each($DIRS)) {
            if (is_file("{$num}/version.php")) {
                echo "Found Directory {$num}\n";
                $InstallDir = $num;
                break;
            }
        }
    }
    if (!is_file("{$InstallDir}/version.php")) {
        _progress("Failed Corrupted compressed file", 100);
        shell_exec("{$rm} -rf {$SourceTemp}");
        return;
    }
    _progress("Installing z-Push {$couldversion}", 50);
    shell_exec("{$cp} -rfd {$InstallDir}/* /usr/share/z-push/");
    shell_exec("{$rm} -rf {$SourceTemp}");
    _progress("Reconfiguring FreeWebs ", 80);
    system("{$php} /usr/share/artica-postfix/exec.freeweb.php --reconfigure-zpush");
    _progress("Success", 100);
}
Esempio n. 22
0
function upload()
{
    echo "Starting uploading organization\n";
    $users = new usersMenus();
    if ($users->CURL_PATH == null) {
        echo "Unable to stat Curl program\n";
        exit;
    }
    $ldap = new clladp();
    $session = $_GET["SESSION"];
    $ou = $_GET["OU"];
    echo "Using session {$session} for ou {$ou}\n";
    $sock = new sockets();
    $ini = new Bs_IniHandler();
    echo "Reading session {$session}\n";
    $ini->loadString($sock->GET_INFO($session));
    $uri = "https://{$ini->_params["CONF"]["servername"]}:{$ini->_params["CONF"]["port"]}/cyrus.murder.listener.php";
    $command = "?export-ou=yes&admin={$ini->_params["CONF"]["username"]}&pass={$ini->_params["CONF"]["password"]}&original-suffix={$ldap->suffix}";
    echo "Exporting DN....\n";
    ExportOuDN($ou);
    echo "Exporting DN done\n";
    $tmpfile = "/usr/share/artica-postfix/ressources/ldap-back/{$ou}/backup.ldif";
    echo "Sending ldif {$tmpfile} to the target server:  \"{$uri}\"\n";
    $filedatas = base64_encode(@file_get_contents("{$tmpfile}"));
    $curl = new ccurl("{$uri}{$command}");
    echo "post ldif {$tmpfile} to the target server:  \"{$uri}\"\n";
    $curl->parms["exported-datas"] = $filedatas;
    $curl->parms["exported-org"] = $ou;
    if (!$curl->get()) {
        echo "Failed\n";
    }
    echo $curl->data . "\n";
    //system($cmd);
}
Esempio n. 23
0
function GetVersions($uri)
{
    $curl = new ccurl($uri);
    $curl->NoHTTP_POST = true;
    $array = array();
    if (!$curl->get()) {
        if ($GLOBALS["VERBOSE"]) {
            echo "Failed to retreive directly listing from {$uri} with error {$curl->error}\n";
        }
        system_admin_events("Geoip Failed to retreive directly listing from {$uri} with error {$curl->error}", __FUNCTION__, __FILE__, __LINE__, "geoip");
        return array("FAILED" => true);
    }
    http:
    //download.maxmind.com/download/geoip/database/asnum/GeoIPASNumv6.dat.gz
    $f = explode("\n", $curl->data);
    while (list($num, $line) = each($f)) {
        if (preg_match('#http:\\/\\/(.+?)\\.dat\\.gz#', $line, $re)) {
            $re[1] = trim($re[1]);
            $file = basename("{$re[1]}.dat");
            $uri = "http://{$re[1]}.dat.gz";
            //echo "GetVersions() $file = $uri\n";
            $curl = new ccurl($uri);
            $headers = $curl->getHeaders();
            $filetime = $headers["filetime"];
            $array[$file] = array("VERSION" => date("Ymdh", $filetime), "URI" => $uri);
        } else {
            //if($GLOBALS["VERBOSE"]){echo "`$line` -> no such preg\n";}
        }
    }
    return $array;
}
Esempio n. 24
0
function HyperCache_create_license()
{
    $sock = new sockets();
    $unix = new unix();
    $uuid = $unix->GetUniqueID();
    if ($uuid == null) {
        if ($GLOBALS["VERBOSE"]) {
            echo "No system ID !\n";
        }
        return;
    }
    $HyperCacheStoreID = intval($sock->GET_INFO("HyperCacheStoreID"));
    if ($HyperCacheStoreID == 0) {
        return;
    }
    $HyperCacheStoreIDLicense = $sock->GET_INFO("HyperCacheStoreIDLicense");
    if ($HyperCacheStoreIDLicense == null) {
        echo "No license set..., continue in evalution mode\n";
        return;
    }
    $uri = "https://svb.unveiltech.com/svblicenseaction.php?ma=86&license={$HyperCacheStoreIDLicense}";
    $curl = new ccurl($uri);
    $curl->parms["ma"] = 86;
    $curl->parms["license"] = $HyperCacheStoreIDLicense;
    $curl->parms["artid"] = $uuid;
    if (!$curl->get()) {
        echo "HyperCache:: Check license failed\n";
        return false;
    }
    echo $curl->data . "\n";
    if (intval(trim($curl->data)) == 1) {
        return true;
    }
    if (stripos($curl->data, "The Activation Code is not valid") > 0) {
        return false;
    }
    if (stripos($curl->data, "The Activation Code is already activated") > 0) {
        return true;
    }
    if (stripos($curl->data, "The Activation Code is already activated with another server") > 0) {
        return false;
    }
}
function inject_array_remote($array)
{
    $sock = new sockets();
    $ArticaHttpsPort = $sock->GET_INFO("ArticaHttpsPort");
    if (!is_numeric($ArticaHttpsPort)) {
        $ArticaHttpsPort = 9000;
    }
    include_once dirname(__FILE__) . "/ressources/class.ccurl.inc";
    if ($GLOBALS["REMOTE_SSL"] == 1) {
        $refix = "https";
    } else {
        $refix = "http";
    }
    $uri = "{$refix}://{$GLOBALS["REMOTE_SSERVER"]}:{$GLOBALS["REMOTE_SPORT"]}/squid.stats.listener.php";
    events("Injecting -> {$uri} on line:" . __LINE__);
    $curl = new ccurl($uri, true);
    $f = base64_encode(serialize($array));
    $curl->parms["STATS_LINE"] = $f;
    $curl->parms["MYSSLPORT"] = $ArticaHttpsPort;
    if (!$curl->get()) {
        inject_failed($array);
        events("Injecting -> FAILED " . $curl->error . " on line:" . __LINE__);
        echo "FAILED " . $curl->error . "\n";
        return;
    }
    if (preg_match("#<ANSWER>OK</ANSWER>#is", $curl->data)) {
        return true;
    }
    events("Injecting -> FAILED " . $curl->data . " on line:" . __LINE__);
    echo "FAILED " . $curl->data . "\n";
    inject_failed($array);
}
function streamget_send_remote($sql, $hostname)
{
    _LoadStatisticsSettings();
    include_once dirname(__FILE__) . "/ressources/class.ccurl.inc";
    if ($GLOBALS["REMOTE_SSL"] == 1) {
        $refix = "https";
    } else {
        $refix = "http";
    }
    $uri = "{$refix}://{$GLOBALS["REMOTE_SSERVER"]}:{$GLOBALS["REMOTE_SPORT"]}/squid.blocks.listener.php";
    $curl = new ccurl($uri, true);
    $f = base64_encode($sql);
    $curl->parms["STREAM_LINE"] = $f;
    $curl->parms["HOSTNAME"] = $hostname;
    events_tail("streamget_send_remote:: send " . strlen($sql) . " bytes to `{$uri}`");
    if (!$curl->get()) {
        events_tail("FAILED " . $curl->error);
        return;
    }
    if (preg_match("#<ANSWER>OK</ANSWER>#is", $curl->data)) {
        events_tail("streamget_send_remote():: SUCCESS...");
        return true;
    }
    events_tail("streamget_send_remote():: FAILED " . $curl->data . "...");
}
Esempio n. 27
0
function update()
{
    $unix = new unix();
    $sock = new sockets();
    $filetime = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".time";
    $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
    if ($GLOBALS["VERBOSE"]) {
        echo "filetime = {$filetime}\n";
        echo "pidfile = {$pidfile}\n";
    }
    $EnableSpamhausDROPList = $sock->GET_INFO("EnableSpamhausDROPList");
    if (!is_numeric($EnableSpamhausDROPList)) {
        $EnableSpamhausDROPList = 0;
    }
    if (!$GLOBALS["FORCE"]) {
        if (!$GLOBALS["VERBOSE"]) {
            $pid = $unix->get_pid_from_file($pidfile);
            if ($unix->process_exists($pid)) {
                if ($GLOBALS["VERBOSE"]) {
                    echo "{$pid} already running !!!\n";
                }
                return;
            }
        }
    }
    @file_put_contents($pidfile, getmypid());
    if (!$GLOBALS["FORCE"]) {
        $time = $unix->file_time_min($filetime);
        if ($time < 1440) {
            if ($GLOBALS["VERBOSE"]) {
                echo "{$time}Mn !!!\n";
            }
            return;
        }
        @unlink($filetime);
        @file_put_contents($filetime, time());
    }
    $iptables = new iptables_chains();
    $curl = new ccurl("http://www.spamhaus.org/drop/drop.lasso");
    $curl->NoHTTP_POST = true;
    $tmpdir = $unix->TEMP_DIR();
    $destination = "{$tmpdir}/drop.lasso";
    if (!$curl->get()) {
        system_admin_events("Spamhaus DROP List failed {$curl->error}");
        return;
    }
    $drop = explode("\n", $curl->data);
    foreach ($drop as $line) {
        $line = trim($line);
        if (!empty($line) && substr($line, 0, 1) !== ';') {
            list($cidr, $sbl) = explode(" ; ", $line);
            $cidr = trim($cidr);
            $sbl = trim($sbl);
            //echo "iptables -A input -s $cidr -d 0/0 -j REJECT\n";
            //echo "iptables -A output -s 0/0 -d $cidr -j REJECT\n";
            $array[$cidr] = $sbl;
        }
    }
    $q = new mysql();
    $prefix = "INSERT IGNORE INTO iptables(\n\tservice,\n\tservername,\n\tserverip,\n\tlocal_port,\n\tdisable,\n\tevents_number,\n\trule_string,\n\trulemd5,\n\tflux,\n\tevents_block,\n\tdate_created,\n\tmultiples_ports,allow ) VALUES ";
    $date = date("Y-m-d H:i:s");
    while (list($cidr, $sbl) = each($array)) {
        $rulemd5 = md5("{$cidr}{$sbl}");
        $f[] = "('SpamHaus',\n\t\t'{$cidr}',\n\t\t'{$cidr}',\n\t\t'0',\n\t\t'0',\n\t\t'0',\n\t\t'iptables -A input -s {$cidr} -d 0/0 -j REJECT',\n\t\t'{$rulemd5}','INPUT',\n\t\t'Spamhaus DROP List',\n\t\t'{$date}',\n\t\t'0',0)";
    }
    if (count($f) > 0) {
        echo count($f) . " rules added";
        $q->QUERY_SQL("DELETE FROM iptables WHERE `service`='SpamHaus' AND `allow`=0", "artica_backup");
        $q->QUERY_SQL($prefix . @implode($f, ","), "artica_backup");
    }
    $php = $unix->LOCATE_PHP5_BIN();
    $nohup = $unix->find_program("nohup");
    $cmd = "{$nohup} {$php} /usr/share/artica-postfix/exec.postfix.iptables.php --spamhaus >/dev/null 2>&1 &";
    echo $cmd . "\n";
    shell_exec($cmd);
}
Esempio n. 28
0
 public function test_remote_server($ip, $port, $username, $password)
 {
     writelogs("Testing remote server {$ip}:{$port}", __CLASS__ . '/' . __FUNCTION__, __FILE__, __LINE__);
     $uri = "https://{$ip}:{$port}/cyrus.murder.listener.php";
     $array["admin"] = $username;
     $array["pass"] = $password;
     $array["cmd"] = "tests";
     $datas = base64_encode(serialize($array));
     $curl = new ccurl($uri);
     $curl->parms["cyrus-cluster"] = $datas;
     if (!$curl->get()) {
         $this->error = true;
         $this->error_text = $curl->error;
         return false;
     }
     return $this->Is_error($curl->data);
 }
Esempio n. 29
0
function backup_webget($ID, $array)
{
    if ($GLOBALS["VERBOSE"]) {
        print_r($array);
    }
    $RemoteArticaServer = $array["RemoteArticaServer"];
    $RemoteArticaPort = $array["RemoteArticaPort"];
    $RemoteArticaUser = $array["RemoteArticaUser"];
    $RemoteArticaPassword = $array["RemoteArticaPassword"];
    $RemoteArticaSite = $array["RemoteArticaSite"];
    $AutoRestore = $array["AutoRestore"];
    $AutoRestoreSqlInstance = $array["AutoRestoreSqlInstance"];
    $AutoRestoreSiteName = $array["AutoRestoreSiteName"];
    if (!is_numeric($AutoRestore)) {
        $AutoRestore = 0;
    }
    if (!is_numeric($AutoRestoreSqlInstance)) {
        $AutoRestoreSqlInstance = 0;
    }
    $array["RemoteArticaPassword"] = md5($array["RemoteArticaPassword"]);
    $unix = new unix();
    $rm = $unix->find_program("rm");
    $php5 = $unix->LOCATE_PHP5_BIN();
    $RESULTS = null;
    if (trim($RemoteArticaServer) == null) {
        backup_events($ID, $RemoteArticaSite, "ERROR, No remote Artica server defined...", __LINE__);
        return;
    }
    if (!is_numeric($RemoteArticaPort)) {
        $RemoteArticaPort = 9000;
    }
    $uri = "https://{$RemoteArticaServer}:{$RemoteArticaPort}";
    backup_events($ID, $RemoteArticaSite, "INFO, Connecting to {$uri} in order to send backup order.", __LINE__);
    include_once dirname(__FILE__) . "/ressources/class.ccurl.inc";
    $params = base64_encode(serialize($array));
    $curl = new ccurl("{$uri}/exec.articaget.php?params={$params}");
    $curl->Timeout = 5600;
    $curl->NoHTTP_POST = true;
    if (!$curl->get()) {
        backup_events($ID, $RemoteArticaSite, "ERROR, Connecting to {$uri} {$curl->error}", __LINE__);
        return;
    }
    $datas = $curl->data;
    if (preg_match("#<LOGS>(.*?)</LOGS>#is", $datas, $re)) {
        $events = $re[1];
    }
    if (preg_match("#<RESULTS>(.*?)</RESULTS>#is", $datas, $re)) {
        $RESULTS = $re[1];
    }
    if ($RESULTS == null) {
        backup_events($ID, $RemoteArticaSite, "ERROR, No answer from {$RemoteArticaServer} ??? {$datas}", __LINE__);
        return;
    }
    if ($RESULTS != "SUCCESS") {
        if ($GLOBALS["VERBOSE"]) {
            echo "\nFAILED\n\n";
        }
        backup_events($ID, $RemoteArticaSite, "ERROR, Failed -> `{$RESULTS}`", __LINE__);
        backup_events($ID, $RemoteArticaSite, "INFO, {$events}", __LINE__);
        return;
    }
    backup_events($ID, $RemoteArticaSite, "INFO,downloading {$RemoteArticaSite}.tar.gz package", __LINE__);
    $curl = new ccurl("{$uri}/ressources/logs/web/{$RemoteArticaSite}.tar.gz");
    $curl->Timeout = 5600;
    $curl->NoHTTP_POST = true;
    @mkdir("/var/tmp/{$RemoteArticaSite}", 0755, true);
    if ($GLOBALS["VERBOSE"]) {
        echo "\nDownloading {$uri}/ressources/logs/web/{$RemoteArticaSite}.tar.gz\n\n";
    }
    $curdate = date("YmdH");
    if (!$curl->GetFile("/var/tmp/{$RemoteArticaSite}/{$RemoteArticaSite}-{$curdate}.tar.gz")) {
        backup_events($ID, $RemoteArticaSite, "ERROR, Failed downloading {$RemoteArticaSite}.tar.gz {$curl->error}", __LINE__);
        return;
    }
    if ($GLOBALS["VERBOSE"]) {
        echo "\n\n";
    }
    backup_events($ID, $RemoteArticaSite, "INFO, Connecting to {$uri} in order to cleaning the backup container.", __LINE__);
    $curl = new ccurl("{$uri}/exec.articaget.php?params={$params}&remove=yes");
    $curl->NoHTTP_POST = true;
    if (!$curl->get()) {
        backup_events($ID, $RemoteArticaSite, "ERROR, ordering to cleaning container...{$uri} {$curl->error}", __LINE__);
    }
    //Auto-restore
    if ($AutoRestore == 0) {
        backup_events($ID, $RemoteArticaSite, "INFO the Autorestore feature is disabled...", __LINE__);
    }
    if ($AutoRestore == 1) {
        backup_events($ID, $RemoteArticaSite, "INFO the Autorestore feature is enabled on `{$AutoRestoreSiteName}` local website...", __LINE__);
        if ($AutoRestoreSiteName != null) {
            $tt1 = time();
            backup_events($ID, $RemoteArticaSite, "INFO, auto-restore {$RemoteArticaSite}.tar.gz to {$AutoRestoreSiteName}", __LINE__);
            $cmd = "{$php5} " . dirname(__FILE__) . "/exec.freeweb.php --restore \"{$AutoRestoreSiteName}\" \"/var/tmp/{$RemoteArticaSite}/{$RemoteArticaSite}-{$curdate}.tar.gz\" {$AutoRestoreSqlInstance} --verbose 2>&1";
            exec($cmd, $AutorestoreResults);
            $tt2 = time();
            $took = $unix->distanceOfTimeInWords($tt1, $tt2, true);
            backup_events($ID, $RemoteArticaSite, "INFO, Auto-restore finish took {$took}, see details:\n" . @implode("\n", $AutorestoreResults), __LINE__);
        } else {
            backup_events($ID, $RemoteArticaSite, "ERROR, Autorestore disabled `AutoRestoreSiteName` is null ", __LINE__);
        }
    }
    $DestinationPath = "{$GLOBALS["MOUNTED_PATH_FINAL"]}/freewebs/webget.{$RemoteArticaSite}";
    backup_mkdir($DestinationPath);
    if (!backup_isdir($DestinationPath)) {
        backup_events($ID, $RemoteArticaSite, "ERROR, {$DestinationPath} permission denied or no such file or directory", __LINE__);
        @unlink("/var/tmp/{$RemoteArticaSite}/{$RemoteArticaSite}.tar.gz");
        return false;
    }
    $info = backup_copy("/var/tmp/{$RemoteArticaSite}/", "{$DestinationPath}", $ID);
    backup_events($ID, $RemoteArticaSite, "INFO,/var/tmp/{$RemoteArticaSite}\n{$info}", __LINE__);
    backup_events($ID, $RemoteArticaSite, "INFO,cleaning /var/tmp/{$RemoteArticaSite}", __LINE__);
    if (is_dir("/var/tmp/{$RemoteArticaSite}")) {
        shell_exec("{$rm} -rf /var/tmp/{$RemoteArticaSite}");
    }
}
Esempio n. 30
0
function MASTER_SEND_LOGS($host, $text)
{
    $curl = new ccurl("https://{$host}/exec.gluster.php");
    $curl->parms["events"] = base64_encode($text);
    if (!$curl->get()) {
        return null;
    }
}