Example #1
0
function sslbridgre(){
	if(!is_file("/usr/share/artica-postfix/sslbridge/index.php")){return;}
	$unix=new unix();
	$ligghtpd=$unix->LIGHTTPD_USER();
	shell_exec("/bin/chown -R $ligghtpd:$ligghtpd /usr/share/artica-postfix/sslbridge");
	shell_exec("/bin/chmod -R 755 /usr/share/artica-postfix/sslbridge");
	$f[]="<?php";
	$f[]="define(\"LOCALHOST\", \"localhost\");";
	$f[]="define(\"SYSTEMDIR\", '/tmp');";
	$f[]="// define(\"DEBUG\", true);";
	$f[]="?>";
	@file_put_contents("/usr/share/artica-postfix/sslbridge/config.php",@implode("\n",$f));
	
	
}
Example #2
0
function CompressCategories()
{
    $sock = new sockets();
    $EnableRemoteStatisticsAppliance = $sock->GET_INFO("EnableRemoteStatisticsAppliance");
    if (!is_numeric($EnableRemoteStatisticsAppliance)) {
        $EnableRemoteStatisticsAppliance = 0;
    }
    if ($EnableRemoteStatisticsAppliance == 1) {
        return;
    }
    $unix = new unix();
    $tar = $unix->find_program("tar");
    $chmod = $unix->find_program("chmod");
    $chown = $unix->find_program("chown");
    $lighttpdUser = $unix->LIGHTTPD_USER();
    $StorageDir = "/usr/share/artica-postfix/ressources/databases";
    if (!is_dir("/var/lib/squidguard")) {
        ufdbguard_admin_events("/var/lib/squidguard no such directory", __FUNCTION__, __FILE__, __LINE__, "global-compile");
        return;
    }
    $t = time();
    if (is_dir("/var/lib/squidguard")) {
        chdir("/var/lib/squidguard");
        if (is_file("{$StorageDir}/blacklist.tar.gz")) {
            @unlink("{$StorageDir}/blacklist.tar.gz");
        }
        writelogs("Compressing /var/lib/squidguard", __FUNCTION__, __FILE__, __LINE__);
        shell_exec("{$tar} -czf {$StorageDir}/blacklist.tar.gz *");
        shell_exec("{$chmod} 770 {$StorageDir}/blacklist.tar.gz");
    }
    if (is_dir("/var/lib/ftpunivtlse1fr")) {
        chdir("/var/lib/ftpunivtlse1fr");
        writelogs("Compressing /var/lib/ftpunivtlse1fr", __FUNCTION__, __FILE__, __LINE__);
        if (is_file("{$StorageDir}/ftpunivtlse1fr.tar.gz")) {
            @unlink("{$StorageDir}/ftpunivtlse1fr.tar.gz");
        }
        shell_exec("{$tar} -czf {$StorageDir}/ftpunivtlse1fr.tar.gz *");
        shell_exec("{$chmod} 770 {$StorageDir}/ftpunivtlse1fr.tar.gz");
    }
    if (is_dir("/etc/dansguardian")) {
        chdir("/etc/dansguardian");
        writelogs("Compressing /etc/dansguardian", __FUNCTION__, __FILE__, __LINE__);
        if (is_file("{$StorageDir}/dansguardian.tar.gz")) {
            @unlink("{$StorageDir}/dansguardian.tar.gz");
        }
        exec("{$tar} -czf {$StorageDir}/dansguardian.tar.gz * 2>&1", $lines);
        while (list($linum, $line) = each($lines)) {
            writelogs($line, __FUNCTION__, __FILE__, __LINE__);
        }
        if (!is_file("{$StorageDir}/dansguardian.tar.gz")) {
            writelogs(".{$StorageDir}/dansguardian.tar.gz no such file", __FUNCTION__, __FILE__, __LINE__);
        }
        shell_exec("{$chmod} 770 /usr/share/artica-postfix/ressources/databases/dansguardian.tar.gz");
    }
    writelogs("Compressing done, apply permissions for `{$lighttpdUser}` user", __FUNCTION__, __FILE__, __LINE__);
    shell_exec("{$chown} {$lighttpdUser}:{$lighttpdUser} {$StorageDir}");
    shell_exec("{$chown} {$lighttpdUser}:{$lighttpdUser} {$StorageDir}/*");
    $ttook = $unix->distanceOfTimeInWords($t, time(), true);
    ufdbguard_admin_events("compress all categories done ({$ttook})", __FUNCTION__, __FILE__, __LINE__, "global-compile");
}
Example #3
0
function web_password()
{
    $sock = new sockets();
    $ldap = new clladp();
    $array = unserialize(base64_decode($sock->GET_INFO("ClueBringerMembers")));
    while (list($uid, $conf) = each($array)) {
        if ($uid == null) {
            continue;
        }
        $ct = new user($uid);
        if ($ct->password == null) {
            continue;
        }
        echo "Starting......: ClueBringer, access to {$uid}\n";
        $f[] = "{$uid}:{$ct->password}";
    }
    echo "Starting......: ClueBringer, access to {$ldap->ldap_admin}\n";
    $f[] = "{$ldap->ldap_admin}:{$ldap->ldap_password}";
    $f[] = "";
    @mkdir("/etc/lighttpd", 666, true);
    @file_put_contents("/etc/lighttpd/cluebringer.passwd", @implode("\n", $f));
    $unix = new unix();
    $lighttpd_user = $unix->LIGHTTPD_USER();
    @chown("/etc/lighttpd/cluebringer.passwd", $lighttpd_user);
}
function build()
{
    $unix = new unix();
    @mkdir("/var/run/lighttpd", 0755, true);
    @mkdir("/var/log/lighttpd", 0755, true);
    $username = $unix->LIGHTTPD_USER();
    $sock = new sockets();
    $phpcgi = $unix->LIGHTTPD_PHP5_CGI_BIN_PATH();
    $chown = $unix->find_program("chown");
    $perlbin = $unix->find_program("perl");
    $nohup = $unix->find_program("nohup");
    $php = $unix->LOCATE_PHP5_BIN();
    $PHP_STANDARD_MODE = true;
    $SquidGuardApachePort = intval($sock->GET_INFO("SquidGuardApachePort"));
    $SquidGuardApacheSSLPort = intval($sock->GET_INFO("SquidGuardApacheSSLPort"));
    if ($SquidGuardApachePort == 0) {
        $SquidGuardApachePort = 9020;
    }
    if ($SquidGuardApacheSSLPort == 0) {
        $SquidGuardApacheSSLPort = 9025;
    }
    $SquidGuardWebSSLCertificate = $sock->GET_INFO("SquidGuardWebSSLCertificate");
    @mkdir("/home/squid/error_page_sessions", 0755, true);
    @mkdir("/home/squid/error_page_cache", 0755, true);
    if ($username == null) {
        $username = "******";
        $unix->CreateUnixUser($username, $username, "lighttpd username");
    }
    if (preg_match("#^(.+?):(.+)#", $username, $re)) {
        $username = $re[1];
        $username = $re[1];
    }
    $SquidGuardStorageDir = $sock->GET_INFO("SquidGuardStorageDir");
    @unlink("/var/log/lighttpd/squidguard-lighttpd-error.log");
    @unlink("/var/log/lighttpd/squidguard-lighttpd.log");
    if (!is_file("/var/log/lighttpd/squidguard-lighttpd.log")) {
        @file_put_contents("/var/log/lighttpd/squidguard-lighttpd.log", "#");
    }
    if (!is_file("/var/log/lighttpd/squidguard-lighttpd-error.log")) {
        @file_put_contents("/var/log/artica-postfix/lighttpd-error.log", "#");
    }
    $unix->chown_func($username, $username, "/var/log/lighttpd/squidguard-lighttpd.log");
    $unix->chown_func($username, $username, "/var/log/lighttpd/squidguard-lighttpd-error.log");
    $unix->chown_func($username, $username, "/home/squid/error_page_sessions");
    $unix->chown_func($username, $username, "/home/squid/error_page_cache");
    $unix->chown_func($username, $username, "/usr/share/artica-postfix/bin/install/squid/adzap/zaps/*");
    @chmod("/var/log/lighttpd/squidguard-lighttpd-error.log", 0777);
    @chmod("/var/log/lighttpd/squidguard-lighttpd.log", 0777);
    if ($SquidGuardStorageDir == null) {
        $SquidGuardStorageDir = "/home/artica/cache";
    }
    @mkdir($SquidGuardStorageDir, 0755, true);
    $unix->chown_func($username, $username, $SquidGuardStorageDir);
    $LighttpdUseUnixSocket = $sock->GET_INFO('LighttpdUseUnixSocket');
    if (!is_numeric($LighttpdUseUnixSocket)) {
        $LighttpdUseUnixSocket = 0;
    }
    $lighttpdPhpPort = $sock->GET_INFO('lighttpdPhpPort');
    if (!is_numeric($lighttpdPhpPort)) {
        $lighttpdPhpPort = 1808;
    }
    $LighttpdArticaMaxProcs = $sock->GET_INFO('LighttpdArticaMaxProcs');
    if (!is_numeric($LighttpdArticaMaxProcs)) {
        $LighttpdArticaMaxProcs = 0;
    }
    $LighttpdArticaMaxChildren = $sock->GET_INFO('LighttpdArticaMaxChildren');
    if (!is_numeric($LighttpdArticaMaxChildren)) {
        $LighttpdArticaMaxChildren = 0;
    }
    $LighttpdRunAsminimal = $sock->GET_INFO('LighttpdRunAsminimal');
    if (!is_numeric($LighttpdRunAsminimal)) {
        $LighttpdRunAsminimal = 0;
    }
    $PHP_FCGI_MAX_REQUESTS = $sock->GET_INFO('PHP_FCGI_MAX_REQUESTS');
    if (!is_numeric($PHP_FCGI_MAX_REQUESTS)) {
        $PHP_FCGI_MAX_REQUESTS = 200;
    }
    $EnablePHPFPM = $sock->GET_INFO('EnablePHPFPM');
    if (!is_numeric($EnablePHPFPM)) {
        $EnablePHPFPM = 0;
    }
    $EnableArticaApachePHPFPM = $sock->GET_INFO("EnableArticaApachePHPFPM");
    if (!is_numeric($EnableArticaApachePHPFPM)) {
        $EnableArticaApachePHPFPM = 0;
    }
    if ($EnableArticaApachePHPFPM == 0) {
        $EnablePHPFPM = 0;
    }
    $PHP_STANDARD_MODE = true;
    $phpcgi_path = $unix->LIGHTTPD_PHP5_CGI_BIN_PATH();
    if ($GLOBALS["OUTPUT"]) {
        echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} Run as: {$username}\n";
    }
    $PHP_FCGI_CHILDREN = 1;
    $max_procs = 2;
    if ($LighttpdArticaMaxProcs > 0) {
        $max_procs = $LighttpdArticaMaxProcs;
    }
    if ($LighttpdArticaMaxChildren > 0) {
        $HP_FCGI_CHILDREN = $LighttpdArticaMaxChildren;
    }
    if ($LighttpdRunAsminimal == 1) {
        $max_procs = 2;
        $PHP_FCGI_CHILDREN = 2;
    }
    $f[] = "#artica-postfix saved by artica lighttpd.conf";
    $f[] = "";
    $f[] = "server.modules = (";
    $f[] = "        \"mod_alias\",";
    $f[] = "        \"mod_access\",";
    $f[] = "        \"mod_accesslog\",";
    $f[] = "        \"mod_compress\",";
    $f[] = "        \"mod_fastcgi\",";
    $f[] = "        \"mod_cgi\",";
    $f[] = "\t       \"mod_status\"";
    $f[] = ")";
    $f[] = "";
    $f[] = "server.document-root        = \"/usr/share/artica-postfix\"";
    $f[] = "server.username = \"{$username}\"";
    $f[] = "server.groupname = \"{$username}\"";
    $f[] = "server.errorlog             = \"/var/log/lighttpd/squidguard-lighttpd-error.log\"";
    $f[] = "index-file.names            = ( \"exec.squidguard.php\")";
    $f[] = "";
    $f[] = "mimetype.assign             = (";
    $f[] = "  \".pdf\"          =>      \"application/pdf\",";
    $f[] = "  \".sig\"          =>      \"application/pgp-signature\",";
    $f[] = "  \".spl\"          =>      \"application/futuresplash\",";
    $f[] = "  \".class\"        =>      \"application/octet-stream\",";
    $f[] = "  \".ps\"           =>      \"application/postscript\",";
    $f[] = "  \".torrent\"      =>      \"application/x-bittorrent\",";
    $f[] = "  \".dvi\"          =>      \"application/x-dvi\",";
    $f[] = "  \".gz\"           =>      \"application/x-gzip\",";
    $f[] = "  \".pac\"          =>      \"application/x-ns-proxy-autoconfig\",";
    $f[] = "  \".swf\"          =>      \"application/x-shockwave-flash\",";
    $f[] = "  \".tar.gz\"       =>      \"application/x-tgz\",";
    $f[] = "  \".tgz\"          =>      \"application/x-tgz\",";
    $f[] = "  \".tar\"          =>      \"application/x-tar\",";
    $f[] = "  \".zip\"          =>      \"application/zip\",";
    $f[] = "  \".mp3\"          =>      \"audio/mpeg\",";
    $f[] = "  \".m3u\"          =>      \"audio/x-mpegurl\",";
    $f[] = "  \".wma\"          =>      \"audio/x-ms-wma\",";
    $f[] = "  \".wax\"          =>      \"audio/x-ms-wax\",";
    $f[] = "  \".ogg\"          =>      \"application/ogg\",";
    $f[] = "  \".wav\"          =>      \"audio/x-wav\",";
    $f[] = "  \".gif\"          =>      \"image/gif\",";
    $f[] = "  \".jar\"          =>      \"application/x-java-archive\",";
    $f[] = "  \".jpg\"          =>      \"image/jpeg\",";
    $f[] = "  \".jpeg\"         =>      \"image/jpeg\",";
    $f[] = "  \".png\"          =>      \"image/png\",";
    $f[] = "  \".xbm\"          =>      \"image/x-xbitmap\",";
    $f[] = "  \".xpm\"          =>      \"image/x-xpixmap\",";
    $f[] = "  \".xwd\"          =>      \"image/x-xwindowdump\",";
    $f[] = "  \".css\"          =>      \"text/css\",";
    $f[] = "  \".html\"         =>      \"text/html\",";
    $f[] = "  \".htm\"          =>      \"text/html\",";
    $f[] = "  \".js\"           =>      \"text/javascript\",";
    $f[] = "  \".asc\"          =>      \"text/plain\",";
    $f[] = "  \".c\"            =>      \"text/plain\",";
    $f[] = "  \".cpp\"          =>      \"text/plain\",";
    $f[] = "  \".log\"          =>      \"text/plain\",";
    $f[] = "  \".conf\"         =>      \"text/plain\",";
    $f[] = "  \".text\"         =>      \"text/plain\",";
    $f[] = "  \".txt\"          =>      \"text/plain\",";
    $f[] = "  \".dtd\"          =>      \"text/xml\",";
    $f[] = "  \".xml\"          =>      \"text/xml\",";
    $f[] = "  \".mpeg\"         =>      \"video/mpeg\",";
    $f[] = "  \".mpg\"          =>      \"video/mpeg\",";
    $f[] = "  \".mov\"          =>      \"video/quicktime\",";
    $f[] = "  \".qt\"           =>      \"video/quicktime\",";
    $f[] = "  \".avi\"          =>      \"video/x-msvideo\",";
    $f[] = "  \".asf\"          =>      \"video/x-ms-asf\",";
    $f[] = "  \".asx\"          =>      \"video/x-ms-asf\",";
    $f[] = "  \".wmv\"          =>      \"video/x-ms-wmv\",";
    $f[] = "  \".bz2\"          =>      \"application/x-bzip\",";
    $f[] = "  \".tbz\"          =>      \"application/x-bzip-compressed-tar\",";
    $f[] = "  \".tar.bz2\"      =>      \"application/x-bzip-compressed-tar\",";
    $f[] = "  \"\"              =>      \"application/octet-stream\",";
    $f[] = " )";
    $f[] = "";
    $f[] = "";
    $f[] = "accesslog.filename          = \"/var/log/lighttpd/squidguard-lighttpd.log\"";
    $f[] = "url.access-deny             = ( \"~\", \".inc\",\".log\",\".ini\",\"ressources\",\"computers\",\"user-backup\",\"logon.php\",\"index.php\")";
    $f[] = "";
    $f[] = "static-file.exclude-extensions = ( \".php\", \".pl\", \".fcgi\" )";
    $f[] = "server.port                 = {$SquidGuardApachePort}";
    $f[] = "#server.bind                = \"127.0.0.1\"";
    $f[] = "server.error-handler-404   = \"/exec.squidguard.php\"";
    $f[] = "#server.error-handler-404   = \"/error-handler.php\"";
    $f[] = "server.pid-file             = \"/var/run/lighttpd/squidguard-lighttpd.pid\"";
    $f[] = "server.max-fds \t\t   = 2048";
    $f[] = "server.network-backend      = \"write\"";
    $f[] = "server.follow-symlink = \"enable\"";
    $f[] = "";
    $f[] = '';
    $f[] = "\$SERVER[\"socket\"]== \":{$SquidGuardApacheSSLPort}\" {";
    $f[] = "\tssl.engine                 = \"enable\"";
    $cert = new lighttpd_certificate($SquidGuardWebSSLCertificate);
    $f[] = $cert->build();
    $f[] = "ssl.cipher-list=\"ALL:!aNULL:!ADH:!eNULL:!LOW:!EXP:RC4+RSA:+HIGH:+MEDIUM:+SSLv3\"";
    $f[] = "}";
    if (!is_file("/opt/artica/ssl/certs/lighttpd.pem")) {
        @chmod("/usr/share/artica-postfix/bin/artica-install", 0755);
        shell_exec("/usr/share/artica-postfix/bin/artica-install -lighttpd-cert");
    }
    //
    if ($GLOBALS["OUTPUT"]) {
        echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} Listen on: {$SquidGuardApachePort}\n";
    }
    if ($GLOBALS["OUTPUT"]) {
        echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} Listen on: {$SquidGuardApacheSSLPort} SSL\n";
    }
    $phpfpm = $unix->find_program('php5-fpm');
    if (!is_file($phpfpm)) {
        $phpfpm = $unix->find_program('php-fpm');
    }
    if (is_file($phpfpm)) {
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} PHP-FPM is installed\n";
        }
        if ($EnablePHPFPM == 1) {
            if ($GLOBALS["OUTPUT"]) {
                echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} PHP-FPM is enabled\n";
            }
            $PHP_STANDARD_MODE = false;
            $f[] = 'fastcgi.server = ( ".php" =>((';
            $f[] = '         "socket" => "/var/run/php-fpm.sock",';
        }
    }
    if ($PHP_STANDARD_MODE) {
        $f[] = 'fastcgi.server = ( ".php" =>((';
        $f[] = '         "bin-path" => "/usr/bin/php-cgi",';
        if ($LighttpdUseUnixSocket == 1) {
            if ($GLOBALS["OUTPUT"]) {
                echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} Fast-cgi server unix socket mode\n";
            }
            $f[] = '         "socket" => "/var/run/lighttpd/php.socket" + var.PID,';
        } else {
            if ($GLOBALS["OUTPUT"]) {
                echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} Fast-cgi server socket 127.0.0.1:{$lighttpdPhpPort}\n";
            }
            $f[] = '         "host" => "127.0.0.1","port" =>' . $lighttpdPhpPort . ',';
        }
    }
    $f[] = '         "max-procs" => ' . $max_procs . ',';
    $f[] = '         "idle-timeout" => 10,';
    $f[] = '         "bin-environment" => (';
    $f[] = '             "PHP_FCGI_CHILDREN" => "' . $PHP_FCGI_CHILDREN . '",';
    $f[] = '             "PHP_FCGI_MAX_REQUESTS" => "' . $PHP_FCGI_MAX_REQUESTS . '"';
    $f[] = '          ),';
    $f[] = '          "bin-copy-environment" => (';
    $f[] = '            "PATH", "SHELL", "USER"';
    $f[] = '           ),';
    $f[] = '          "broken-scriptfilename" => "enable"';
    $f[] = '        ))';
    $f[] = ')';
    $f[] = "alias.url += ( \"/css/\" => \"/usr/share/artica-postfix/css/\" )";
    $f[] = "alias.url += ( \"/img/\" => \"/usr/share/artica-postfix/img/\" )";
    $f[] = "alias.url += ( \"/js/\" => \"/usr/share/artica-postfix/js/\" )";
    $f[] = "alias.url += ( \"/zaps/\" => \"/usr/share/artica-postfix/bin/install/squid/adzap/zaps/\" )";
    $f[] = "";
    $f[] = "cgi.assign= (";
    $f[] = "\t\".pl\"  => \"/usr/bin/perl\",";
    $f[] = "\t\".php\" => \"/usr/bin/php-cgi\",";
    $f[] = "\t\".py\"  => \"/usr/bin/python\",";
    $f[] = "\t\".cgi\"  => \"/usr/bin/perl\",";
    $f[] = ")";
    @file_put_contents("/etc/artica-postfix/squidguard-lighttpd.conf", @implode("\n", $f));
    if ($GLOBALS["OUTPUT"]) {
        echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} squidguard-lighttpd.conf done.\n";
    }
}
Example #5
0
function build(){
	CheckHttpdConf();
	RemoveAllSites();
	create_cron_task();
	$sock=new sockets();
	$unix=new unix();
	$varWwwPerms=$sock->GET_INFO("varWwwPerms");
	if($varWwwPerms==null){$varWwwPerms=755;}
	
	remove_files();
	$sql="SELECT * FROM freeweb ORDER BY servername";
	$httpdconf=$unix->LOCATE_APACHE_CONF_PATH();
	$apacheusername=$unix->APACHE_SRC_ACCOUNT();
	$GLOBALS["apacheusername"]=$apacheusername;
	$DAEMON_PATH=$unix->getmodpathfromconf($httpdconf);
	$q=new mysql();
	$results=$q->QUERY_SQL($sql,'artica_backup');
	if(!$q->ok){if($GLOBALS["VERBOSE"]){echo $q->mysql_error."\n";return;}}
	$d_path=$unix->APACHE_DIR_SITES_ENABLED();
	$mods_enabled=$DAEMON_PATH."/mods-enabled";
	
	
	echo "Starting......: Apache daemon path: $d_path\n";
	echo "Starting......: Apache mods path..: $mods_enabled\n";
	
	if(!is_dir($d_path)){@mkdir($d_path,666,true);}
	if(!is_dir($mods_enabled)){@mkdir($mods_enabled,666,true);}
	
	$count=mysql_num_rows($results);
	echo "Starting......: Apache checking virtual web sites count:$count\n";
	if($count==0){
		$users=new usersMenus();
		echo "Starting......: Apache building default $users->hostname...\n";
		buildHost($unix->LIGHTTPD_USER(),$users->hostname,0,$d_path);
	}
	
	
	while($ligne=mysql_fetch_array($results,MYSQL_ASSOC)){
		$uid=$ligne["uid"];
		$hostname=$ligne["servername"];
		$ssl=$ligne["useSSL"];	
		echo "Starting......: Apache \"$hostname\" starting
		\n";
		buildHost($uid,$hostname,$ssl,$d_path);

	}
	
	$users=$GLOBALS["CLASS_USERS_MENUS"];
	$APACHE_MOD_AUTHNZ_LDAP=$users->APACHE_MOD_AUTHNZ_LDAP;
	if(is_file($GLOBALS["a2enmod"])){
		if($APACHE_MOD_AUTHNZ_LDAP){
			if($GLOBALS["VERBOSE"]){echo "Starting......: Apache {$GLOBALS["a2enmod"]} authnz_ldap\n";} 
			shell_exec("{$GLOBALS["a2enmod"]} authnz_ldap >/dev/null 2>&1");
		}
	} 
	
	

	$sock=$GLOBALS["CLASS_SOCKETS"];
	if($sock->GET_INFO("ArticaMetaEnabled")==1){
		sys_THREAD_COMMAND_SET(LOCATE_PHP5_BIN()." ".dirname(__FILE__)."/exec.artica.meta.users.php --export-freewebs");
	}

	
}
Example #6
0
function execute()
{
    $nice = EXEC_NICE();
    if (is_file(dirname(__FILE__) . "/exec.sarg.gilou.php")) {
        shell_exec($nice . LOCATE_PHP5_BIN2() . " " . dirname(__FILE__) . "/exec.sarg.gilou.php --exec");
        return;
    }
    $nice = EXEC_NICE();
    $unix = new unix();
    $today = date("d/m/Y");
    $sarg_bin = $unix->find_program("sarg");
    if (!is_file($sarg_bin)) {
        echo "Sarg not installed";
        return;
    }
    buildconf();
    $usersauth = false;
    $squid = new squidbee();
    if ($squid->LDAP_AUTH == 1) {
        $usersauth = true;
    }
    if ($squid->LDAP_EXTERNAL_AUTH == 1) {
        $usersauth = true;
    }
    if (!is_file("/etc/squid/exclude_codes")) {
        @file_put_contents("/etc/squid/exclude_codes", "\nNONE/400\n");
    }
    @mkdir("/usr/share/artica-postfix/squid", 755, true);
    if ($usersauth) {
        echo "Starting......: Sarg, user authentification enabled\n";
        $u = " -i ";
    } else {
        echo "Starting......: Sarg, user authentification disabled\n";
    }
    $cmd = "{$nice}{$sarg_bin} -d {$today}-{$today} {$u}-f /etc/squid3/sarg.conf -l /var/log/squid/sarg.log -o /usr/share/artica-postfix/squid -x -z 2>&1";
    $t1 = time();
    echo "Starting......: Sarg, {$cmd}\n";
    exec($cmd, $results);
    while (list($index, $line) = each($results)) {
        if (preg_match("#SARG: No records found#", $line)) {
            $subject_add = "(No records found)";
        }
        if (preg_match("#SARG:\\s+.+?mixed records format#", $line)) {
            send_email_events("SARG: Error, squid was reloaded", "It seems that there is a mixed log file format detected in squid\n\t\t\tThis reason is Artica change squid log format from orginial to http access mode.\n\t\t\tIn this case, the log will be moved and squid will be reloaded \n\t\t\tin order to build a full log file with only one log format.\n\t\t\t\n" . @implode("\n", $results), "proxy");
            shell_exec(LOCATE_PHP5_BIN2() . " " . dirname(__FILE__) . "/exec.squid.php --reconfigure");
            shell_exec($unix->LOCATE_SQUID_BIN() . " -k rotate");
            shell_exec("/etc/init.d/artica-postfix restart squid-tail");
            return;
        }
        if (preg_match("#SARG:\\s+.+?enregistrements de plusieurs formats#", $line)) {
            send_email_events("SARG: Error, squid was reloaded", "It seems that there is a mixed log file format detected in squid\n\t\t\tThis reason is Artica change squid log format from orginial to http access mode.\n\t\t\tIn this case, the log will be moved and squid will be reloaded \n\t\t\tin order to build a full log file with only one log format.\n\t\t\t\n" . @implode("\n", $results), "proxy");
            shell_exec(LOCATE_PHP5_BIN2() . " " . dirname(__FILE__) . "/exec.squid.php --reconfigure");
            shell_exec($unix->LOCATE_SQUID_BIN() . " -k rotate");
            shell_exec("/etc/init.d/artica-postfix restart squid-tail");
            return;
        }
        if (preg_match("#SARG.+?Unknown input log file format#", $line)) {
            send_email_events("SARG: \"Unknown input log file format\", squid was reloaded", "It seems that there is a input log file format log file format detected in squid\n\t\t\tThis reason is Artica change squid log format from orginial to log_fqn on, this will be disabled\n\t\t\tIn this case, the log will be moved and squid will be reloaded \n\t\t\tin order to build a full log file with only one log format.\n\t\t\t\n" . @implode("\n", $results), "proxy");
            shell_exec(LOCATE_PHP5_BIN2() . " " . dirname(__FILE__) . "/exec.squid.php --reconfigure");
            shell_exec($unix->LOCATE_SQUID_BIN() . " -k rotate");
            shell_exec("/etc/init.d/artica-postfix restart squid-tail");
            return;
        }
    }
    $unix = new unix();
    $lighttpd_user = $unix->LIGHTTPD_USER();
    echo "Starting......: Sarg, lighttpd user: {$lighttpd_user}\n";
    $chown = $unix->find_program("chown");
    echo "Starting......: Sarg,{$chown} -R {$lighttpd_user}:{$lighttpd_user} /usr/share/artica-postfix/squid/*\n";
    exec("{$chown} -R {$lighttpd_user}:{$lighttpd_user} /usr/share/artica-postfix/squid/* >/dev/null 2>&1", $results2);
    echo "Starting......: Sarg,\n" . @implode("\n" . $results2) . "\n";
    $t2 = time();
    $distanceOfTimeInWords = distanceOfTimeInWords($t1, $t2);
    echo "Starting......: Sarg, {$distanceOfTimeInWords}\n";
    if ($GLOBALS["VERBOSE"]) {
        echo "SARG: Statistics generated ({$distanceOfTimeInWords})\n\n";
        echo @implode("\n", $results) . "\n";
    }
    send_email_events("SARG: Statistics generated ({$distanceOfTimeInWords}) {$subject_add}", "Command line:\n-----------\n{$cmd}\n" . @implode("\n", $results), "proxy");
}
Example #7
0
function build()
{
    $unix = new unix();
    if (is_file("/etc/artica-postfix/FROM_ISO")) {
        if ($unix->file_time_min("/etc/artica-postfix/FROM_ISO") < 1) {
            return;
        }
    }
    $mef = basename(__FILE__);
    $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
    $pid = @file_get_contents($pidfile);
    if ($unix->process_exists($pid, $mef)) {
        echo "Starting......: " . date("H:i:s") . " [INIT]: Apache building : Process Already exist pid {$pid} line:" . __LINE__ . "\n";
        return;
    }
    @file_put_contents($pidfile, getmypid());
    if ($GLOBALS["VERBOSE"]) {
        echo "Starting......: " . date("H:i:s") . " [DEBUG]: Apache -> CheckHttpdConf();\n";
    }
    CheckHttpdConf();
    if ($GLOBALS["VERBOSE"]) {
        echo "Starting......: " . date("H:i:s") . " [DEBUG]: Apache -> RemoveAllSites();\n";
    }
    RemoveAllSites();
    if ($GLOBALS["VERBOSE"]) {
        echo "Starting......: " . date("H:i:s") . " [DEBUG]: Apache -> create_cron_task();\n";
    }
    create_cron_task();
    sync_squid();
    $sock = new sockets();
    $FreeWebDisableSSL = intval(trim($sock->GET_INFO("FreeWebDisableSSL")));
    $php5 = $unix->LOCATE_PHP5_BIN();
    $varWwwPerms = $sock->GET_INFO("varWwwPerms");
    if ($varWwwPerms == null) {
        $varWwwPerms = 755;
    }
    if ($GLOBALS["VERBOSE"]) {
        echo "Starting......: " . date("H:i:s") . " [DEBUG]: Apache -> remove_files();\n";
    }
    remove_files();
    $sql = "SELECT * FROM freeweb ORDER BY servername";
    $httpdconf = $unix->LOCATE_APACHE_CONF_PATH();
    $apacheusername = $unix->APACHE_SRC_ACCOUNT();
    $GLOBALS["apacheusername"] = $apacheusername;
    $DAEMON_PATH = $unix->getmodpathfromconf($httpdconf);
    if ($GLOBALS["VERBOSE"]) {
        echo "Starting......: " . date("H:i:s") . " [DEBUG]: Apache -> sql();\n";
    }
    $q = new mysql();
    $results = $q->QUERY_SQL($sql, 'artica_backup');
    if (!$q->ok) {
        if ($GLOBALS["VERBOSE"]) {
            echo "Starting......: " . date("H:i:s") . " [DEBUG]: Apache {$q->mysql_error}\n";
            return;
        }
    }
    $d_path = $unix->APACHE_DIR_SITES_ENABLED();
    $mods_enabled = $DAEMON_PATH . "/mods-enabled";
    if ($FreeWebDisableSSL == 0) {
        SSL_DEFAULT_VIRTUAL_HOST();
    }
    echo "Starting......: " . date("H:i:s") . " [INIT]: Apache daemon path: {$d_path}\n";
    echo "Starting......: " . date("H:i:s") . " [INIT]: Apache mods path..: {$mods_enabled}\n";
    if (!is_dir($d_path)) {
        @mkdir($d_path, 666, true);
    }
    if (!is_dir($mods_enabled)) {
        @mkdir($mods_enabled, 666, true);
    }
    $count = mysql_num_rows($results);
    echo "Starting......: " . date("H:i:s") . " [INIT]: Apache checking virtual web sites count:{$count}\n";
    if ($count == 0) {
        $users = new usersMenus();
        echo "Starting......: " . date("H:i:s") . " [INIT]: Apache building default {$users->hostname}...\n";
        buildHost($unix->LIGHTTPD_USER(), $users->hostname, 0, $d_path);
    }
    if ($GLOBALS["VERBOSE"]) {
        $add_plus = " --verbose";
    }
    while ($ligne = mysql_fetch_array($results, MYSQL_ASSOC)) {
        $uid = $ligne["uid"];
        $hostname = $ligne["servername"];
        $ssl = $ligne["useSSL"];
        if ($FreeWebDisableSSL == 1) {
            $ssl = 0;
        }
        echo "Starting......: " . date("H:i:s") . " [INIT]: Apache \"{$hostname}\" starting\n";
        $cmd = "{$php5} " . __FILE__ . " --sitename \"{$hostname}\" --no-httpd-conf --noreload{$add_plus}";
        if ($GLOBALS["VERBOSE"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: Apache \"{$cmd}\"\n";
        }
        shell_exec($cmd);
    }
    $users = $GLOBALS["CLASS_USERS_MENUS"];
    $APACHE_MOD_AUTHNZ_LDAP = $users->APACHE_MOD_AUTHNZ_LDAP;
    if (is_file($GLOBALS["a2enmod"])) {
        if ($APACHE_MOD_AUTHNZ_LDAP) {
            if ($GLOBALS["VERBOSE"]) {
                echo "Starting......: " . date("H:i:s") . " [INIT]: Apache {$GLOBALS["a2enmod"]} authnz_ldap\n";
            }
            shell_exec("{$GLOBALS["a2enmod"]} authnz_ldap >/dev/null 2>&1");
        }
    }
    $sock = $GLOBALS["CLASS_SOCKETS"];
    if ($sock->GET_INFO("ArticaMetaEnabled") == 1) {
        sys_THREAD_COMMAND_SET(LOCATE_PHP5_BIN() . " " . dirname(__FILE__) . "/exec.artica.meta.users.php --export-freewebs");
    }
    sys_THREAD_COMMAND_SET(LOCATE_PHP5_BIN() . " " . __FILE__ . " --monit");
}