コード例 #1
0
function ParseMainDir()
{
    $unix = new unix();
    $mypid = getmypid();
    $kill = $unix->find_program("kill");
    $nohup = $unix->find_program("nohup");
    $php5 = $unix->LOCATE_PHP5_BIN();
    @mkdir("/etc/artica-postfix/pids", 0755, true);
    $pidtime = "/etc/artica-postfix/pids/" . basename(__FILE__) . ".time";
    $pidtime_hour = "/etc/artica-postfix/pids/" . basename(__FILE__) . ".hours.time";
    $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . ".pid";
    $pid = @file_get_contents($pidfile);
    if ($pid < 100) {
        $pid = null;
    }
    if ($unix->process_exists($pid, basename(__FILE__))) {
        $time = $unix->PROCCESS_TIME_MIN($pid);
        if ($time > 60) {
            unix_system_kill_force($pid);
        } else {
            events("Already executed pid {$pid} since {$time}mn-> DIE");
            if ($GLOBALS["VERBOSE"]) {
                echo "Already executed pid {$pid} since {$time}mn\n";
            }
            die;
        }
    }
    $timeP = $unix->file_time_min($pidtime);
    if ($timeP < 3) {
        events("Main::Line: " . __LINE__ . " 3Mn minimal current: {$timeP}mn-> DIE");
        die;
    }
    @unlink($pidtime);
    @file_put_contents($pidtime, time());
    @file_put_contents($pidfile, $mypid);
    $dirs = $unix->dirdir("/var/log/artica-postfix/squid/queues");
    while (list($directory, $array) = each($dirs)) {
        $dirs2 = $unix->dirdir($directory);
        if (count($dirs2) == 0) {
            events("{$dirs2} 0 elements, remove...", __LINE__);
            @rmdir($directory);
            continue;
        }
        if (is_dir("{$directory}/SearchWords")) {
            events("Scanning {$directory}/SearchWords", __LINE__);
            ParseSubDir("{$directory}/SearchWords");
        }
    }
    $timeP = $unix->file_time_min($pidtime_hour);
    if ($timeP > 30) {
        @unlink($pidtime_hour);
        @file_put_contents($pidtime_hour, time());
        shell_exec("{$nohup} {$php5} /usr/share/artica-postfix/exec.squid-searchwords.php --hour >/dev/null 2>&1");
    }
}
コード例 #2
0
function startx()
{
    $unix = new unix();
    build_progress(50, "{refresh} CPUS");
    @unlink("/etc/artica-postfix/CPU_NUMBER");
    build_progress(55, "{refresh} CPUS");
    @unlink("/usr/share/artica-postfix/ressources/interface-cache/CPU_NUMBER");
    build_progress(60, "{rescan-disk-system}");
    $dirs = $unix->dirdir("/sys/class/scsi_host");
    $echo = $unix->find_program("echo");
    $udevadm = $unix->find_program("udevadm");
    $php = $unix->LOCATE_PHP5_BIN();
    while (list($dirpath, $line) = each($dirs)) {
        $basename = basename($dirpath);
        if (!preg_match("#host[0-9]+#", $basename)) {
            continue;
        }
        $cmd = "{$echo} \"- - -\" >{$dirpath}/scan";
        build_progress(65, "{rescan-disk-system}" . dirname($dirpath));
        shell_exec($cmd);
    }
    build_progress(70, "{rescan-disk-system}");
    $cmdline = "{$php} /usr/share/artica-postfix/exec.usb.scan.write.php --verbose";
    system($cmd);
    build_progress(80, "{rescan-network-system}");
    system("{$udevadm} control --reload-rules");
    system("{$udevadm} trigger --attr-match=subsystem=net");
    sleep(3);
    system("/usr/share/artica-postfix/bin/process1 --force --verbose --" . time());
    build_progress(100, "{refresh} {done}");
}
コード例 #3
0
function download()
{
    $unix = new unix();
    build_progress("{downloading}", 10);
    $URI = "http://wordpress.org/latest.tar.gz";
    $TMP_FILE = $unix->FILE_TEMP() . ".gz";
    $TMP_DIR = $unix->TEMP_DIR();
    echo "Downloading {$URI}\n";
    $curl = new ccurl($URI);
    $curl->WriteProgress = true;
    $curl->ProgressFunction = "download_progress";
    if (!$curl->GetFile($TMP_FILE)) {
        build_progress("{downloading} {failed}", 110);
        echo $curl->error;
        return;
    }
    echo "Extracting {$TMP_FILE} in {$TMP_DIR}\n";
    $tar = $unix->find_program("tar");
    $cmd = "{$tar} xf {$TMP_FILE} -C {$TMP_DIR}/";
    build_progress("{uncompress}", 50);
    shell_exec("{$tar} xf {$TMP_FILE} -C {$TMP_DIR}/");
    @unlink($TMP_FILE);
    $dirs = $unix->dirdir($TMP_DIR);
    $WDP_DIR = null;
    while (list($num, $ligne) = each($dirs)) {
        if (!is_file("{$ligne}/wp-admin/install.php")) {
            continue;
        }
        $WDP_DIR = $ligne;
        break;
        echo "Find Directory {$ligne}\n";
    }
    if (!is_dir($WDP_DIR)) {
        build_progress("Find directory failed", 110);
        echo "Find directory failed\n";
        return;
    }
    build_progress("{installing}", 80);
    @mkdir("/usr/share/wordpress-src", 0755, true);
    $cp = $unix->find_program("cp");
    $rm = $unix->find_program("rm");
    shell_exec("cp -rfv {$WDP_DIR}/* /usr/share/wordpress-src/");
    if (is_dir($WDP_DIR)) {
        echo "Removing {$WDP_DIR}\n";
        shell_exec("{$rm} -rf {$WDP_DIR}");
    }
    $sock = new sockets();
    $sock->SET_INFO("EnableFreeWeb", 1);
    @file_put_contents("/etc/artica-postfix/settings/Daemons/WordPressInstalled", 1);
    system("/etc/init.d/artica-status restart --force");
    build_progress("{success}", 100);
    $nohup = $unix->find_program("nohup");
    $sock = new sockets();
    shell_exec("{$nohup} /usr/share/artica-postfix/bin/process1 --verbose 654646 >/dev/null 2>&1 &");
}
コード例 #4
0
function xinstall()
{
    $unix = new unix();
    $curl = new ccurl();
    $tmpfile = $unix->FILE_TEMP();
    $tmpdir = $unix->TEMP_DIR();
    build_progress("{downloading} v3.1.0-25", 15);
    $curl = new ccurl("http://articatech.net/download/UpdateUtility/updateutility-3.1.0-25.tar.gz");
    if (!$curl->GetFile($tmpfile)) {
        @unlink($tmpfile);
        build_progress("{downloading} {failed}", 110);
        return;
    }
    $tar = $unix->find_program("tar");
    $rm = $unix->find_program("rm");
    @mkdir("{$tmpdir}/updateutility", 0755);
    build_progress("{uncompress}", 20);
    shell_exec("{$tar} -xf {$tmpfile} -C {$tmpdir}/updateutility/");
    build_progress("{find_source_directory}", 25);
    $dirs = $unix->dirdir("{$tmpdir}/updateutility");
    $SOURCE_DIRECTORY = null;
    while (list($num, $ligne) = each($dirs)) {
        build_progress("{scanning} {$ligne}", 25);
        if (is_file("{$ligne}/UpdateUtility-Console")) {
            $SOURCE_DIRECTORY = $ligne;
            break;
        }
    }
    if ($SOURCE_DIRECTORY == null) {
        echo "Unable to find source directory\n";
        build_progress("{installing} {failed}", 110);
        shell_exec("{$rm} -rf {$tmpdir}/updateutility");
        return;
    }
    echo "Using directory {$SOURCE_DIRECTORY}\n";
    build_progress("{installing}...", 80);
    $cp = $unix->find_program("cp");
    @mkdir("/etc/UpdateUtility", 0755, true);
    shell_exec("{$cp} -rfv {$SOURCE_DIRECTORY}/* /etc/UpdateUtility/");
    shell_exec("{$rm} -rf {$tmpdir}/updateutility");
    if (!is_file("/etc/UpdateUtility/UpdateUtility-Console")) {
        echo "/etc/UpdateUtility/UpdateUtility-Console no such binary\n";
        build_progress("{installing} {failed}", 110);
    }
    build_progress("{installing} {success}", 100);
}
コード例 #5
0
ファイル: compile-CAS.php プロジェクト: BillTheBest/1.6.x
function install()
{
    $unix = new unix();
    $wget = $unix->find_program("wget");
    $tar = $unix->find_program("tar");
    $rm = $unix->find_program("rm");
    $cp = $unix->find_program("cp");
    $targetfile = latests();
    if (!is_file("{$GLOBALS["WORKDIR"]}/{$targetfile}")) {
        echo "Downloading source file `{$targetfile}` on base `{$GLOBALS["URISRC"]}`\n";
        shell_exec("{$wget} {$GLOBALS["URISRC"]}/{$targetfile} -O {$GLOBALS["WORKDIR"]}/{$targetfile}");
    }
    if (!is_file("{$GLOBALS["WORKDIR"]}/{$targetfile}")) {
        echo "Failed downloading {$GLOBALS["URISRC"]}/{$targetfile}\n";
        return;
    }
    echo "Extracting {$targetfile}\n";
    shell_exec("{$tar} xf {$GLOBALS["WORKDIR"]}/{$targetfile} -C {$GLOBALS["WORKDIR"]}/");
    echo "Parsing directories {$GLOBALS["WORKDIR"]}\n";
    $dirs = $unix->dirdir($GLOBALS["WORKDIR"]);
    while (list($num, $line) = each($dirs)) {
        $dirname = basename($num);
        if (preg_match("#^cas-server-#", $dirname)) {
            $sourcedir = $num;
            break;
        }
    }
    echo "Source directory `{$sourcedir}`\n";
    if (!is_dir($sourcedir)) {
        echo "Failed extracting {$targetfile}\n";
        return;
    }
    if (is_dir("/usr/share/cas-server")) {
        echo "Cleaning old installation...\n";
        shell_exec("/bin/rm -rf /usr/share/cas-server");
    }
    @mkdir("/usr/share/cas-server", 0755, true);
    echo "installing `{$sourcedir}` in /usr/share/cas-server\n";
    shell_exec("{$cp} -rf {$sourcedir}/* /usr/share/cas-server/");
    if (!is_file("/usr/share/cas-server/pom.xml")) {
        echo "Failed...\n";
        return;
    }
    echo "Cleaning temp files...\n";
    shell_exec("/bin/rm -rf {$GLOBALS["WORKDIR"]}");
}
コード例 #6
0
function CleanTempDirs()
{
    $unix = new unix();
    $dirs = $unix->dirdir("/tmp");
    if (!is_array($dirs)) {
        return null;
    }
    while (list($num, $ligne) = each($dirs)) {
        if (trim($num) == null) {
            continue;
        }
        $time = $unix->file_time_min($num);
        if ($time < 380) {
            continue;
        }
        if (is_dir($num)) {
            shell_exec("/bin/rm -rf \"{$num}\"");
        }
    }
}
コード例 #7
0
ファイル: exec.nginx.php プロジェクト: BillTheBest/1.6.x
function rotate()
{
    $unix = new unix();
    $pidTime = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".time";
    if ($unix->file_time_min($pidTime) < 55) {
        return;
    }
    @unlink($pidTime);
    @file_put_contents($pidTime, time());
    $sock = new sockets();
    $kill = $unix->find_program("kill");
    $NginxWorkLogsDir = $sock->GET_INFO("NginxWorkLogsDir");
    if ($NginxWorkLogsDir == null) {
        $NginxWorkLogsDir = "/home/nginx/logsWork";
    }
    @mkdir("{$NginxWorkLogsDir}", 0755, true);
    $directories = $unix->dirdir("/var/log/apache2");
    while (list($directory, $line) = each($directories)) {
        $sitename = basename($directory);
        $date = date("Y-m-d-H");
        $nginx_source_logs = "{$directory}/nginx.access.log";
        $nginx_dest_logs = "{$NginxWorkLogsDir}/{$sitename}-{$date}.log";
        if (is_file("{$nginx_dest_logs}")) {
            echo "{$nginx_dest_logs} no such file\n";
            continue;
        }
        if (!is_file($nginx_source_logs)) {
            continue;
        }
        if (!@copy($nginx_source_logs, $nginx_dest_logs)) {
            echo "Failed to copy {$nginx_dest_logs}\n";
            continue;
        }
        @unlink($nginx_source_logs);
    }
    $pid = PID_NUM();
    shell_exec("{$kill} -USR1 {$pid}");
    $php5 = $unix->LOCATE_PHP5_BIN();
    $nohup = $unix->find_program("nohup");
    $sock = new sockets();
    $EnableNginxStats = $sock->GET_INFO("EnableNginxStats");
    if (!is_numeric($EnableNginxStats)) {
        $EnableNginxStats = 0;
    }
    if ($EnableNginxStats == 0) {
        shell_exec("{$nohup} {$php5} " . __FILE__ . " --awstats >/dev/null 2>&1 &");
        return;
    } else {
        shell_exec("{$nohup} {$php5} /usr/share/artica-postfix/exec.nginx-stats.php --parse >/dev/null 2>&1 &");
    }
}
コード例 #8
0
ファイル: exec.freshclam.php プロジェクト: articatech/artica
function execute()
{
    $unix = new unix();
    @mkdir("/var/clamav", 0755, true);
    @mkdir("/var/run/clamav", 0755, true);
    @mkdir("/var/lib/clamav", 0755, true);
    @mkdir("/var/log/clamav", 0755, true);
    $ClamUser = $unix->ClamUser();
    $unix->chown_func("{$ClamUser}", "{$ClamUser}", "/var/clamav");
    $unix->chown_func("{$ClamUser}", "{$ClamUser}", "/var/run/clamav");
    $unix->chown_func("{$ClamUser}", "{$ClamUser}", "/var/lib/clamav");
    $unix->chown_func("{$ClamUser}", "{$ClamUser}", "/var/log/clamav");
    $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
    $pidTime = "/var/run/clamav/scheduled.time";
    $pid = $unix->get_pid_from_file($pidfile);
    if ($unix->process_exists($pid, basename(__FILE__))) {
        $time = $unix->PROCCESS_TIME_MIN($pid);
        build_progress("Already Executed since {$time}mn", 110);
        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());
    if (!$GLOBALS["FORCE"]) {
        $TimEx = $unix->file_time_min($pidTime);
        if ($TimEx < 120) {
            build_progress("Only each 120mn, current is {$TimEx}mn", 110);
            if ($GLOBALS["OUTPUT"]) {
                echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} Only each 120mn, current is {$TimEx}mn\n";
            }
            return;
        }
    }
    @unlink($pidTime);
    @file_put_contents("{$pidTime}", time());
    build_progress("{udate_clamav_databases}", 10);
    $pid = PID_NUM();
    if ($unix->process_exists($pid)) {
        $timepid = $unix->PROCCESS_TIME_MIN($pid);
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} Service already started {$pid} since {$timepid}Mn...\n";
        }
        build_progress("Service already started {$pid} since {$timepid}Mn", 110);
        return;
    }
    $Masterbin = $unix->find_program("freshclam");
    if (!is_file($Masterbin)) {
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} service freshclam not installed\n";
        }
        build_progress("Missing freshclam", 110);
        return;
    }
    if ($GLOBALS["OUTPUT"]) {
        echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} Building settings\n";
    }
    build_progress("{building_configuration}", 20);
    build();
    $verbose = null;
    $log = "/var/log/clamav/freshclam.log";
    if ($GLOBALS["PROGRESS"]) {
        $log = "/usr/share/artica-postfix/ressources/logs/web/clamav.update.progress.txt";
        $verbose = " --verbose";
    }
    $ClamUser = $unix->ClamUser();
    $nohup = $unix->find_program("nohup");
    @chmod("/usr/share/artica-postfix/ressources/logs/web", 0777);
    @chmod($log, 0777);
    if (is_file(dirname($Masterbin) . "/freshexec")) {
        @unlink(dirname($Masterbin) . "/freshexec");
    }
    @copy($Masterbin, dirname($Masterbin) . "/freshexec");
    @chmod(dirname($Masterbin) . "/freshexec", 0755);
    $Masterbin = dirname($Masterbin) . "/freshexec";
    $cmd = "{$nohup} {$Masterbin} --config-file=/etc/clamav/freshclam.conf --pid=/var/run/clamav/freshclam_manu.pid --user={$ClamUser} --log={$log}{$verbose} >/dev/null 2>&1 &";
    $Dirs = $unix->dirdir("/var/lib/clamav");
    $rm = $unix->find_program("rm");
    while (list($directory, $MAIN) = each($Dirs)) {
        echo "Checking {$directory}\n";
        if (!preg_match("#\\.tmp\$#", $directory)) {
            continue;
        }
        echo "Remove directory {$directory}";
        shell_exec("{$rm} -rf {$directory}");
    }
    build_progress("{udate_clamav_databases}", 50);
    echo $cmd;
    system($cmd);
    $PID = fresh_clam_manu_pid();
    $WAIT = true;
    while ($WAIT) {
        if (!$unix->process_exists($PID)) {
            break;
        }
        $ttl = $unix->PROCCESS_TIME_MIN($PID);
        echo "PID: Running {$PID} since {$ttl}mn\n";
        build_progress("{udate_clamav_databases} {waiting} PID {$PID} {since} {$ttl}mn", 80);
        sleep(2);
        $PID = fresh_clam_manu_pid();
    }
    build_progress("{done}", 90);
    @unlink("/usr/share/artica-postfix/ressources/interface-cache/ClamAVBases");
    sigtool();
    $php = $unix->LOCATE_PHP5_BIN();
    $nohup = $unix->find_program("nohup");
    shell_exec("{$nohup} {$php} /usr/share/artica-postfix/exec.clamav-milter.php --reload >/dev/null &");
    shell_exec("{$nohup} {$php} /usr/share/artica-postfix/exec.clamd.php --reload >/dev/null &");
    build_progress("{done}", 100);
}
コード例 #9
0
function clean_tmd()
{
    $unix = new unix();
    $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . ".MAIN.pid";
    $pidfileTime = "/etc/artica-postfix/pids/exec.mysql.clean.php.clean_tmd.time";
    $pid = $unix->get_pid_from_file($pidfile);
    if ($unix->process_exists($pid, basename(__FILE__))) {
        system_admin_events("Already process {$pid} exists", __FUNCTION__, __FILE__, __LINE__, "clean");
        die;
    }
    $timeExec = $unix->file_time_min($pidfileTime);
    if ($timeExec < 240) {
        return;
    }
    @unlink($pidfileTime);
    @file_put_contents($pidfileTime, time());
    @file_put_contents($pidfile, getmypid());
    $SIZES = 0;
    $Dirs = $unix->dirdir("/var/lib/mysql");
    while (list($directory, $none) = each($Dirs)) {
        $Files = $unix->DirFiles($directory, "\\.[0-9]+\\.TMD\$");
        while (list($filename, $none) = each($Files)) {
            $fullpath = "{$directory}/{$filename}";
            if ($unix->file_time_min($fullpath) < 240) {
                continue;
            }
            $SIZES = $SIZES + @filesize($fullpath);
            @unlink($fullpath);
        }
        $Files = $unix->DirFiles($directory, "\\.TMD-[0-9]+\$");
        while (list($filename, $none) = each($Files)) {
            $fullpath = "{$directory}/{$filename}";
            if ($unix->file_time_min($fullpath) < 240) {
                continue;
            }
            $SIZES = $SIZES + @filesize($fullpath);
            @unlink($fullpath);
        }
    }
    if (is_dir("/opt/squidsql/data")) {
        $Dirs = $unix->dirdir("/opt/squidsql/data");
        while (list($directory, $none) = each($Dirs)) {
            $Files = $unix->DirFiles($directory, "\\.[0-9]+\\.TMD\$");
            while (list($filename, $none) = each($Files)) {
                $fullpath = "{$directory}/{$filename}";
                if ($unix->file_time_min($fullpath) < 240) {
                    continue;
                }
                $SIZES = $SIZES + @filesize($fullpath);
                @unlink($fullpath);
            }
            $Files = $unix->DirFiles($directory, "\\.TMD-[0-9]+\$");
            while (list($filename, $none) = each($Files)) {
                $fullpath = "{$directory}/{$filename}";
                if ($unix->file_time_min($fullpath) < 240) {
                    continue;
                }
                $SIZES = $SIZES + @filesize($fullpath);
                @unlink($fullpath);
            }
        }
    }
}
コード例 #10
0
ファイル: exec.sarg.php プロジェクト: brucewu16899/1.6.x
function build_index_page()
{
    $sock = new sockets();
    $unix = new unix();
    $SargOutputDir = $sock->GET_INFO("SargOutputDir");
    if ($SargOutputDir == null) {
        $SargOutputDir = "/var/www/html/squid-reports";
    }
    if ($GLOBALS["OUTPUT"]) {
        echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]}, {$SargOutputDir}\n";
    }
    @copy("/usr/share/artica-postfix/bin/install/sarg.css", "{$SargOutputDir}/sarg.css");
    @copy("/usr/share/artica-postfix/img/logo-artica-160.gif", "{$SargOutputDir}/logo.gif");
    @copy("/usr/share/artica-postfix/css/images/pattern.png", "{$SargOutputDir}/pattern.png");
    @copy("/usr/share/artica-postfix/ressources/templates/default/images/ui-bg_highlight.png", "{$SargOutputDir}/ui-bg_highlight.png");
    @copy("/usr/share/artica-postfix/img/arrow-right-16.png", "{$SargOutputDir}/arrow-right-16.png");
    @chmod("{$SargOutputDir}/arrow-right-16.png", 0755);
    @chmod("{$SargOutputDir}/ui-bg_highlight.png", 0755);
    @chmod("{$SargOutputDir}/sarg.css", 0755);
    @chmod("{$SargOutputDir}/logo.gif", 0755);
    @chmod("{$SargOutputDir}/pattern.png", 0755);
    $f[] = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">";
    $f[] = "<html>";
    $f[] = "<head>";
    $f[] = "  <meta http-equiv=\"Content-Type\" content=\"text/html; charset=ISO-8859-1\">";
    $f[] = "<title>SARG reports</title>";
    $f[] = "<link rel=\"stylesheet\" href=\"/sarg.css\" type=\"text/css\">";
    $f[] = "</head>";
    $f[] = "<body>";
    $f[] = "<div class=\"logo\"><img src=\"/logo.gif\">&nbsp;</div>";
    $f[] = "<div class=\"title\"><table cellpadding=\"0\" cellspacing=\"0\">";
    $f[] = "<tr><th class=\"title_c\">Squid User Access Reports</th></tr>";
    $f[] = "</table>";
    $f[] = "</div>";
    $f[] = "<table cellpadding=\"0\" cellspacing=\"0\">\n\n";
    if (is_file("{$SargOutputDir}/hourly/index.html")) {
        $f[] = "<tr><td align='center'><a href=\"hourly/index.html\" style='font-size:22px;font-weight:bold'>&laquo;&nbsp;Hourly reports&nbsp;&raquo;</td></tr>";
    } else {
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]}, {$SargOutputDir}/hourly/index.html no such file\n";
        }
    }
    if (is_file("{$SargOutputDir}/daily/index.html")) {
        $f[] = "<tr><td align='center'><a href=\"daily/index.html\" style='font-size:22px;font-weight:bold'>&laquo;&nbsp;Daily reports&nbsp;&raquo;</td></tr>";
    } else {
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]}, {$SargOutputDir}/daily/index.html no such file\n";
        }
    }
    if (is_file("{$SargOutputDir}/weekly/index.html")) {
        $f[] = "<tr><td align='center'><a href=\"weekly/index.html\" style='font-size:22px;font-weight:bold'>&laquo;&nbsp;Weekly reports&nbsp;&raquo;</td></tr>";
    } else {
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]}, {$SargOutputDir}/weekly/index.html no such file\n";
        }
    }
    if (is_file("{$SargOutputDir}/monthly/index.html")) {
        $f[] = "<tr><td align='center'><a href=\"monthly/index.html\" style='font-size:22px;font-weight:bold'>&laquo;&nbsp;Monthly reports&nbsp;&raquo;</td></tr>";
    } else {
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]}, {$SargOutputDir}/monthly/index.html no such file\n";
        }
    }
    $dirs = $unix->dirdir($SargOutputDir);
    $monthsz = array('jan' => 1, 'ene' => 1, 'feb' => 2, 'mar' => 3, 'apr' => 4, 'abr' => 4, 'may' => 5, 'jun' => 6, 'jul' => 7, 'aug' => 8, 'ago' => 8, 'sep' => 9, 'oct' => 10, 'nov' => 11, 'dec' => 12, 'dic' => 12);
    while (list($index, $line) = each($dirs)) {
        $dir = basename($line);
        if (!preg_match("#\\/([0-9]+)([A-Za-z]+)([0-9]+)-([0-9]+)([A-Za-z]+)([0-9]+)\$#", $line, $re)) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} {$dir}, no match\n";
            continue;
        }
        $day = $re[1];
        $month = $re[2];
        $year = $re[3];
        $day1 = $re[4];
        $month1 = $re[5];
        $year1 = $re[6];
        if (strlen($year) < 4) {
            if (strlen($day) == 4) {
                $year = $re[1];
                $month = $re[2];
                $day = $re[3];
                $day1 = $re[6];
                $month1 = $re[5];
                $year1 = $re[4];
            }
        }
        if (strlen($year) < 4) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} {$dir}, no match\n";
            continue;
        }
        $monthNum = $monthsz[strtolower($month)];
        if (strlen($monthNum) == 1) {
            $monthNum = "0{$monthNum}";
        }
        $time = strtotime("{$year}-{$monthNum}-{$day} 00:00:00");
        $ARRAY[$year][$month][$day]["DIR"] = $dir;
        $too = array();
        if ($day1 != $day) {
            $too[] = $day1;
        }
        if ($month1 != $month) {
            $too[] = $month1;
        }
        if ($year1 != $year) {
            $too[] = $year1;
        }
        if ($month1 == $month) {
            $to = "{$day1}";
        }
        if (count($to) > 0) {
            $to = @implode("/", $to);
        } else {
            $to = null;
        }
        $ARRAY[$year][$month][$day]["TO"] = "{$to}";
        $ARRAY[$year][$month][$day]["TITLE"] = date("l {$day}", $time);
    }
    while (list($year, $array1) = each($ARRAY)) {
        $f[] = "<tr><td>&nbsp;</td></td>";
        $f[] = "<tr><td align='center'><span style='font-size:22px;font-weight:bold'>&laquo;&nbsp;{$year} reports&nbsp;&raquo;</td></tr>";
        $f[] = "<tr><td align='center'>";
        $TR = array();
        while (list($month, $array2) = each($array1)) {
            $ttr = array();
            $ttr[] = "<table style='width:100%;marign:5px'>";
            $c = 1;
            while (list($day, $array3) = each($array2)) {
                $c++;
                $ttr[] = "<tr>\n\t\t\t\t<td width=1% nowrap><img src='arrow-right-16.png'></td>\n\t\t\t\t<td style='font-size:14px'><a href=\"{$array3["DIR"]}/index.html\">{$array3["TITLE"]} {$array3["TO"]}</a></td>\n\t\t\t\t</tr>";
                if (strpos(" " . $array3["TITLE"], "Sunday") > 0) {
                    $ttr[] = "<tr><td colspan=2><hr></td></tr>";
                }
            }
            $ttr[] = "</table>";
            $TR[] = "<div style='font-size:22px;font-weight:bold'>&laquo;&nbsp;{$month} reports&nbsp;&raquo;</div>" . @implode("\n", $ttr);
        }
        $f[] = CompileTr4($TR);
        $f[] = "</td></tr>";
    }
    $f[] = "</table>\n</body>\n</html>";
    events("{$SargOutputDir}/index.html done");
    events("{$SargOutputDir}/index.php done");
    @file_put_contents("{$SargOutputDir}/index.html", @implode("\n", $f));
    if ($GLOBALS["OUTPUT"]) {
        echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]}, {$SargOutputDir}/index.html done\n";
    }
    @file_put_contents("{$SargOutputDir}/index.php", "<?php\nheader('location:index.html')\n?>");
}
コード例 #11
0
function PersonalCategoriesRepair()
{
    $unix = new unix();
    $user = GetSquidUser();
    $reload = false;
    $dirs = $unix->dirdir("/var/lib/squidguard/personal-categories");
    while (list($a, $dir) = each($dirs)) {
        if (!is_file("{$dir}/expressions")) {
            events_ufdb_tail("exec.squidguard.php: creating {$dir}/expressions", __LINE__);
            @file_put_contents("{$dir}/expressions", " ");
            $reload = true;
        }
    }
    shell_exec("/bin/chown -R {$user}:{$user} /var/lib/squidguard >/dev/null 2>&1 &");
    if ($reload) {
        shell_exec("{$GLOBALS["SQUIDBIN"]} -k reconfigure");
    }
}
コード例 #12
0
function SERVICE_START($nochecks = false, $nopid = false)
{
    $unix = new unix();
    $sock = new sockets();
    $kill = $unix->find_program("kill");
    if (!$nopid) {
        $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
        $pid = @file_get_contents($pidfile);
        if ($unix->process_exists($pid, basename(__FILE__))) {
            $time = $unix->PROCCESS_TIME_MIN($pid);
            echo "Starting......: " . date("H:i:s") . " MySQL this script is already executed PID: {$pid} since {$time}Mn\n";
            if ($time < 5) {
                if (!$GLOBALS["FORCE"]) {
                    return;
                }
            }
            unix_system_kill_force($pid);
        }
        @file_put_contents($pidfile, getmypid());
    }
    if (is_file("/etc/artica-postfix/mysql.stop")) {
        echo "Starting......: " . date("H:i:s") . " MySQL locked, exiting\n";
        return;
    }
    $PID_NUM = PID_NUM();
    if ($unix->process_exists($PID_NUM)) {
        $timemin = $unix->PROCCESS_TIME_MIN($PID_NUM);
        echo "Starting......: " . date("H:i:s") . " MySQL already running PID \"{$PID_NUM}\" since {$timemin}Mn\n";
        return;
    }
    $mysql_install_db = $unix->find_program('mysql_install_db');
    $mysqlbin = $unix->LOCATE_mysqld_bin();
    $php5 = $unix->LOCATE_PHP5_BIN();
    $nohup = $unix->find_program("nohup");
    if (!is_file($mysqlbin)) {
        echo "Starting......: " . date("H:i:s") . " MySQL is not installed, abort\n";
        return;
    }
    $EnableMysqlFeatures = $sock->GET_INFO('EnableMysqlFeatures');
    $MysqlBinAllAdresses = $sock->GET_INFO('MysqlBinAllAdresses');
    $MySQLTMPMEMSIZE = $sock->GET_INFO('MySQLTMPMEMSIZE');
    $MysqlTooManyConnections = $sock->GET_INFO("MysqlTooManyConnections");
    $MysqlRemoveidbLogs = $sock->GET_INFO("MysqlRemoveidbLogs");
    $innodb_force_recovery = $sock->GET_INFO("innodb_force_recovery");
    if (!is_numeric($innodb_force_recovery)) {
        $innodb_force_recovery = 0;
    }
    if (!is_numeric($MysqlRemoveidbLogs)) {
        $MysqlRemoveidbLogs = 0;
    }
    if (!is_numeric($MysqlBinAllAdresses)) {
        $MysqlBinAllAdresses = 0;
    }
    if (!is_numeric($MySQLTMPMEMSIZE)) {
        $MySQLTMPMEMSIZE = 0;
    }
    if (!is_numeric($MysqlTooManyConnections)) {
        $MysqlTooManyConnections = 0;
    }
    if (!is_numeric($EnableMysqlFeatures)) {
        $EnableMysqlFeatures = 1;
    }
    $MySqlTmpDir = $sock->GET_INFO('MySQLTMPDIR');
    $MySQLLOgErrorPath = $sock->GET_INFO('MySQLLOgErrorPath');
    $datadir = $unix->MYSQL_DATA_DIR();
    $EnableMysqlLog = $sock->GET_INFO("EnableMysqlLog");
    if (!is_numeric($EnableMysqlLog)) {
        $EnableMysqlLog = 0;
    }
    if ($datadir == null) {
        $datadir = '/var/lib/mysql';
    }
    if ($MySqlTmpDir == '/tmp') {
        $MySqlTmpDir = null;
    }
    if ($MySQLLOgErrorPath == null) {
        $MySQLLOgErrorPath = $datadir . '/mysqld.err';
    }
    if ($MysqlTooManyConnections == 1) {
        echo "Starting......: " . date("H:i:s") . " MySQL MysqlTooManyConnections=1, abort\n";
        return;
    }
    if (isset($GLOBALS["RECOVERY"])) {
        $innodb_force_recovery = $GLOBALS["RECOVERY"];
    }
    if (strlen($MySqlTmpDir) > 3) {
        echo "Starting......: " . date("H:i:s") . " MySQL tempdir : {$MySqlTmpDir}\n";
        shell_exec("{$php5} /usr/share/artica-postfix/exec.mysql.build.php --tmpfs");
        $MySqlTmpDir = str_replace("//", "/", $MySqlTmpDir);
        if (!is_dir($MySqlTmpDir)) {
            @mkdir($MySqlTmpDir, 0755, true);
            $unix->chown_func("mysql", "mysql", $MySqlTmpDir);
        }
        $MySqlTmpDirCMD = " --tmpdir={$MySqlTmpDir}";
    }
    if ($EnableMysqlFeatures == 0) {
        echo "Starting......: " . date("H:i:s") . " MySQL is disabled by \"EnableMysqlFeatures\"...\n";
        return;
    }
    $pid_file = "/var/run/mysqld/mysqld.pid";
    $socket = "/var/run/mysqld/mysqld.sock";
    $mysql_user = "******";
    @mkdir("/var/run/mysqld", 0755, true);
    @mkdir("/var/log/mysql", 0755, true);
    @mkdir($datadir, 0755, true);
    $dirs = $unix->dirdir("/var/lib/mysql");
    while (list($num, $directory) = each($dirs)) {
        echo "Starting......: " . date("H:i:s") . " MySQL, apply permissions on " . basename($directory) . "\n";
        $unix->chown_func("mysql", "mysql", "{$directory}/*");
    }
    $bind_address = ' --bind-address=127.0.0.1';
    $bind_address2 = "127.0.0.1";
    if ($MysqlBinAllAdresses == 1) {
        $bind_address2 = 'All (0.0.0.0)';
        $bind_address = ' --bind-address=0.0.0.0';
    }
    echo "Starting......: " . date("H:i:s") . " MySQL Pid path.......:{$pid_file}\n";
    echo "Starting......: " . date("H:i:s") . " datadir..............:{$datadir}\n";
    echo "Starting......: " . date("H:i:s") . " Log error............:{$MySQLLOgErrorPath}\n";
    echo "Starting......: " . date("H:i:s") . " socket...............:{$socket}\n";
    echo "Starting......: " . date("H:i:s") . " user.................:{$mysql_user}\n";
    echo "Starting......: " . date("H:i:s") . " LOGS ENABLED.........:{$EnableMysqlLog}\n";
    echo "Starting......: " . date("H:i:s") . " Daemon...............:{$mysqlbin}\n";
    echo "Starting......: " . date("H:i:s") . " Bind address.........:{$bind_address2}\n";
    echo "Starting......: " . date("H:i:s") . " Temp Dir.............:{$MySqlTmpDir}\n";
    echo "Starting......: " . date("H:i:s") . " innodb_force_recovery:{$innodb_force_recovery}\n";
    mysql_admin_mysql(1, "Starting MySQL service...", null, __FILE__, __LINE__);
    echo "Starting......: " . date("H:i:s") . " Settings permissions..\n";
    @mkdir("/var/run/mysqld", 0755, true);
    $unix->chown_func($mysql_user, $mysql_user, "/var/run/mysqld");
    $unix->chown_func($mysql_user, $mysql_user, "/var/log/mysql");
    $unix->chown_func($mysql_user, $mysql_user, $datadir);
    $unix->chown_func($mysql_user, $mysql_user, "{$datadir}/*");
    if ($unix->is_socket("/var/run/mysqld/mysqld.sock")) {
        @unlink("/var/run/mysqld/mysqld.sock");
    }
    if (is_file('/var/run/mysqld/mysqld.err')) {
        @unlink('/var/run/mysqld/mysqld.err');
    }
    if (is_file("/var/run/mysqld/mysqld.pid")) {
        $unix->chown_func($mysql_user, $mysql_user, "/var/run/mysqld/mysqld.pid");
    }
    if ($MysqlRemoveidbLogs == 1) {
        shell_exec('/bin/mv /var/lib/mysql/ib_logfile* /tmp/');
        $sock->SET_INFO('MysqlRemoveidbLogs', '0');
    }
    $logpathstring = " --log-error={$MySQLLOgErrorPath}";
    if ($EnableMysqlLog == 1) {
        $logpathstring = " --log=/var/log/mysql.log --log-slow-queries=/var/log/mysql-slow-queries.log --log-error={$MySQLLOgErrorPath} --log-warnings";
    }
    $toTouch[] = "/var/log/mysql-slow-queries.log";
    $toTouch[] = "/var/log/mysql.error";
    $toTouch[] = "/var/log/mysql.log";
    $toTouch[] = "/var/log/mysql.warn";
    while (list($num, $filename) = each($toTouch)) {
        if (!is_file($filename)) {
            @file_put_contents($filename, "#\n");
        }
        $unix->chown_func($mysql_user, $mysql_user, $filename);
    }
    echo "Starting......: " . date("H:i:s") . " MySQL Checking : {$datadir}/mysql/host.frm\n";
    if (!is_file("{$datadir}/mysql/host.frm")) {
        if (is_file($mysql_install_db)) {
            echo "Starting......: " . date("H:i:s") . " MySQL Installing default databases\n";
            shell_exec("{$mysql_install_db} --datadir=\"{$datadir}\"");
        }
    } else {
        echo "Starting......: " . date("H:i:s") . " MySQL Checking : {$datadir}/mysql/host.frm OK\n";
    }
    $cmd2 = array();
    $MEMORY = $unix->MEM_TOTAL_INSTALLEE();
    $AsCategoriesAppliance = intval(@file_get_contents("/etc/artica-postfix/settings/Daemons/AsCategoriesAppliance"));
    if ($AsCategoriesAppliance == 1) {
        $MEMORY = 620288;
    }
    if ($MEMORY < 624288) {
        $GetStartedValues = GetStartedValues();
        echo "Starting......: " . date("H:i:s") . " MySQL Warning memory did not respond to pre-requesites, tuning to lower memory\n";
        if ($GetStartedValues["--key-buffer-size"]) {
            $cmd2[] = "--key-buffer-size=8M";
        }
        if ($GetStartedValues["--max-allowed-packet"]) {
            $cmd2[] = "--max-allowed-packet=4M";
        }
        if ($GetStartedValues["--table-cache"]) {
            $cmd2[] = "--table-cache=4";
        }
        if ($GetStartedValues["--sort-buffer-size"]) {
            $cmd2[] = "--sort-buffer-size=64k";
        }
        if ($GetStartedValues["--read-buffer-size"]) {
            $cmd2[] = "--read-buffer-size=256k";
        }
        if ($GetStartedValues["--read-rnd-buffer-size"]) {
            $cmd2[] = "--read-rnd-buffer-size=128k";
        }
        if ($GetStartedValues["--net-buffer-length"]) {
            $cmd2[] = "--net-buffer-length=2k";
        }
        if ($GetStartedValues["--thread-stack"]) {
            $cmd2[] = "--thread-stack=192k";
        }
        if ($GetStartedValues["--thread-cache-size"]) {
            $cmd2[] = "--thread-cache-size=128";
        }
        if ($GetStartedValues["--thread-concurrency"]) {
            $cmd2[] = "--thread-concurrency=10";
        }
        if ($GetStartedValues["--default-storage-engine"]) {
            $cmd2[] = "--default-storage-engine=MyISAM";
        }
        if ($GetStartedValues["--default-tmp-storage-engine"]) {
            $cmd2[] = "--default-tmp-storage-engine=MyISAM";
        }
        if ($GetStartedValues["--tmp-table-size"]) {
            $cmd2[] = "--tmp-table-size=16M";
        }
        if ($GetStartedValues["--table-cache"]) {
            $cmd2[] = "--table-cache=64";
        }
        if ($GetStartedValues["--query-cache-limit"]) {
            $cmd2[] = "--query-cache-limit=4M";
        }
        if ($GetStartedValues["--query-cache-size"]) {
            $cmd2[] = "--query-cache-size=32M";
        }
        if ($GetStartedValues["--max-connections"]) {
            $cmd2[] = "--max-connections=50";
        }
        if (is_file("/etc/artica-postfix/WORDPRESS_APPLIANCE")) {
            $cmd2[] = "--innodb=OFF";
        }
        echo "Starting......: " . date("H:i:s") . " MySQL " . count($cmd2) . " forced option(s)\n";
    }
    if (is_file($MySQLLOgErrorPath)) {
        @unlink($MySQLLOgErrorPath);
    }
    $cmds[] = $mysqlbin;
    if ($MEMORY < 624288) {
        $cmds[] = "--no-defaults --user=mysql";
    }
    $cmds[] = "--pid-file=/var/run/mysqld/mysqld.pid";
    $cmds[] = trim($logpathstring);
    $cmds[] = trim($MySqlTmpDirCMD);
    $cmds[] = "--socket={$socket}";
    $cmds[] = "--datadir=\"{$datadir}\"";
    if (count($cmd2) == 0) {
        if ($innodb_force_recovery > 0) {
            $cmds[] = "--innodb-force-recovery={$innodb_force_recovery}";
        }
    }
    if (count($cmd2) > 0) {
        $cmds[] = @implode(" ", $cmd2);
    }
    $cmds[] = ">/dev/null 2>&1 &";
    if (is_file('/usr/sbin/aa-complain')) {
        echo "Starting......: " . date("H:i:s") . " Mysql Adding mysql in apparamor complain mode...\n";
        shell_exec("/usr/sbin/aa-complain {$mysqlbin} >/dev/null 2>&1");
    }
    $cmd = @implode(" ", $cmds);
    while (list($num, $ligne) = each($cmds)) {
        echo "Starting......: " . date("H:i:s") . " MySQL Option: {$ligne}\n";
    }
    echo "Starting......: " . date("H:i:s") . " MySQL Starting daemon, please wait\n";
    writelogs("Starting MySQL {$cmd}", __FUNCTION__, __FILE__, __LINE__);
    shell_exec($cmd);
    $count = 0;
    sleep(2);
    for ($i = 0; $i < 6; $i++) {
        $pid = PID_NUM();
        if ($unix->process_exists($pid, $mysqlbin)) {
            echo "Starting......: " . date("H:i:s") . " MySQL Checks daemon running...\n";
            break;
        }
        echo "Starting......: " . date("H:i:s") . " MySQL Checks daemon, please wait ({$i}/6)\n";
        sleep(1);
    }
    $pid = PID_NUM();
    if (!$unix->process_exists($pid)) {
        echo "Starting......: " . date("H:i:s") . " MySQL failed\n";
        echo "Starting......: " . date("H:i:s") . " {$cmd}\n";
        system_admin_events("Failed to start MySQL server", __FUNCTION__, __FILE__, __LINE__, "services");
        $php5 = $unix->LOCATE_PHP5_BIN();
        shell_exec("{$nohup} {$php5} /usr/share/artica-postfix/exec.mysql.build.php >/dev/null 2>&1 &");
    } else {
        for ($i = 0; $i < 4; $i++) {
            echo "Starting......: " . date("H:i:s") . " MySQL Checks mysqld.sock waiting {$i}/3\n";
            if ($unix->is_socket("/var/run/mysqld/mysqld.sock")) {
                break;
            }
            sleep(1);
        }
        if (!$unix->is_socket("/var/run/mysqld/mysqld.sock")) {
            mysql_admin_mysql(0, "Failed to start MySQL Server /var/run/mysqld/mysqld.sock no such socket after 4 seconds", null, __FILE__, __LINE__);
            echo "Starting......: " . date("H:i:s") . " MySQL Checks mysqld.sock failed...\n";
        }
        mysql_admin_mysql(1, "Success to start MySQL Server with new pid {$pid}", null, __FILE__, __LINE__);
        echo "Starting......: " . date("H:i:s") . " MySQL Success pid {$pid}\n";
        $q = new mysql_squid_builder();
        $q->MEMORY_TABLES_RESTORE();
    }
}
コード例 #13
0
function BuildPatterns()
{
    $unix = new unix();
    cpulimit();
    $dirs = $unix->dirdir("/etc/dansguardian/lists/blacklists");
    if ($GLOBALS["VERBOSE"]) {
        echo "open /etc/dansguardian/lists/blacklists array of " . count($dirs) . "\n";
    }
    if (!is_array($dirs)) {
        writelogs("Unable to dir /etc/dansguardian/lists/blacklists", __FUNCTION__, __FILE__, __LINE__);
        return;
    }
    reset($dirs);
    while (list($num, $val) = each($dirs)) {
        $category = basename($num);
        if ($GLOBALS["VERBOSE"]) {
            echo "{$category}:: {$num} -> {$val}\n";
        }
        writelogs("Checking {$category}", __FUNCTION__, __FILE__, __LINE__);
        if ($category == "blacklists") {
            if ($GLOBALS["VERBOSE"]) {
                echo "{$category} == blacklists, aborting\n";
            }
            continue;
        }
        $domains = 0;
        $urls = 0;
        $expressions = 0;
        if (is_file("{$num}/domains")) {
            $domains = $unix->COUNT_LINES_OF_FILE("{$num}/domains");
            if ($GLOBALS["VERBOSE"]) {
                echo "{$category}:: {$domains} number\n";
            }
            $filetime = date("Y-m-d H:i:s", filemtime("{$num}/domains"));
        } else {
            if ($GLOBALS["VERBOSE"]) {
                echo "{$category}:: unable to stat {$num}/domains\n";
            }
        }
        if (is_file("{$num}/urls")) {
            $urls = $unix->COUNT_LINES_OF_FILE("{$num}/urls");
        } else {
            if ($GLOBALS["VERBOSE"]) {
                echo "{$category}:: unable to stat {$num}/urls\n";
            }
        }
        if ($GLOBALS["VERBOSE"]) {
            echo "{$category}={$domains},{$urls},{$filetime}\n";
        }
        $array["{$category}"] = array($domains, $urls, $filetime);
    }
    $datas = base64_encode(serialize($array));
    writelogs("writing /usr/share/artica-postfix/ressources/logs/dansguardian.patterns", __FUNCTION__, __FILE__, __LINE__);
    @file_put_contents("/usr/share/artica-postfix/ressources/logs/dansguardian.patterns", $datas);
    @chmod("/usr/share/artica-postfix/ressources/logs/dansguardian.patterns", 0755);
    if (!is_file("/usr/share/artica-postfix/ressources/logs/dansguardian.patterns")) {
        writelogs("Error writing dansguardian.patterns", __FUNCTION__, __FILE__, __LINE__);
    }
    return;
}
コード例 #14
0
function find_sources($sourcedir)
{
    if (is_file("{$sourcedir}/domains")) {
        return $sourcedir;
    }
    $unix = new unix();
    $dirs = $unix->dirdir($sourcedir);
    while (list($dirname, $md5) = each($dirs)) {
        if (!is_file("{$dirname}/domains")) {
            echo "{$dirname}/domains no such file\n";
            continue;
        }
        return $dirname;
    }
}
コード例 #15
0
function homes()
{
    $GLOBALS["INDEXED"] = 0;
    $GLOBALS["SKIPPED"] = 0;
    $GLOBALS["DIRS"] = array();
    $FOLDERS = array();
    $RFOLDERS = array();
    $unix = new unix();
    $GLOBALS["omindex"] = $unix->find_program("omindex");
    $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
    $pid = $unix->get_pid_from_file($pidfile);
    if ($unix->process_exists($pid)) {
        system_admin_events("Already instance executed pid:{$olpid}", __FUNCTION__, __FILE__, __LINE__, "xapian");
        die;
    }
    @file_put_contents($pidfile, getmypid());
    $nice = EXEC_NICE();
    $t1 = time();
    if (!is_file($GLOBALS["omindex"])) {
        system_admin_events("omindex no such binary, aborting", __FUNCTION__, __FILE__, __LINE__, "xapian");
        return;
    }
    $ldap = new clladp();
    $attr = array("homeDirectory", "uid", "dn");
    $pattern = "(&(objectclass=sambaSamAccount)(uid=*))";
    $sock = new sockets();
    $sock = new sockets();
    $sr = @ldap_search($ldap->ldap_connection, "dc=organizations," . $ldap->suffix, $pattern, $attr);
    $hash = ldap_get_entries($ldap->ldap_connection, $sr);
    $sock = new sockets();
    for ($i = 0; $i < $hash["count"]; $i++) {
        $uid = $hash[$i]["uid"][0];
        $homeDirectory = $hash[$i][strtolower("homeDirectory")][0];
        if ($uid == null) {
            writelogs("uid is null, SKIP ", __FUNCTION__, __FILE__, __LINE__);
            continue;
        }
        if ($uid == "nobody") {
            writelogs("uid is nobody, SKIP ", __FUNCTION__, __FILE__, __LINE__);
            continue;
        }
        if ($uid == "root") {
            writelogs("uid is root, SKIP ", __FUNCTION__, __FILE__, __LINE__);
            continue;
        }
        if (substr($uid, strlen($uid) - 1, 1) == '$') {
            writelogs("{$uid}:This is a computer, SKIP ", __FUNCTION__, __FILE__, __LINE__);
            continue;
        }
        if ($homeDirectory == null) {
            $homeDirectory = "/home/{$uid}";
        }
        if (!is_dir($homeDirectory)) {
            continue;
        }
        $FOLDERS[$uid] = $homeDirectory;
        $RFOLDERS[$homeDirectory] = true;
    }
    $SambaXapianAuth = unserialize(base64_decode($sock->GET_INFO("SambaXapianAuth")));
    $username = $SambaXapianAuth["username"];
    $password = $SambaXapianAuth["password"];
    $domain = $SambaXapianAuth["domain"];
    $comp = $SambaXapianAuth["ip"];
    if (!isset($SambaXapianAuth["lang"])) {
        $SambaXapianAuth["lang"] == "none";
    }
    $lang = $SambaXapianAuth["lang"];
    if ($lang == null) {
        $lang = "none";
    }
    $t1 = time();
    $dirs = $unix->dirdir("/home");
    $samba = new samba();
    $localdatabase = "/usr/share/artica-postfix/LocalDatabases";
    while (list($dir, $ligne) = each($dirs)) {
        if ($dir == "/home/export") {
            continue;
        }
        if ($dir == "/home/netlogon") {
            continue;
        }
        if ($dir == "/home/artica") {
            continue;
        }
        if ($dir == "/home/logs-backup") {
            continue;
        }
        if (isset($RFOLDERS[$dir])) {
            continue;
        }
        if (isset($samba->main_shared_folders[$dir])) {
            continue;
        }
        $FOLDERS[basename($dir)] = $dir;
    }
    $count = 0;
    while (list($uid, $directory) = each($FOLDERS)) {
        $BaseUrl = $directory;
        $database = "{$localdatabase}/xapian-{$uid}";
        @mkdir($database, 0755, true);
        if (!is_dir($directory)) {
            system_admin_events("{$directory}, no such directory", __FUNCTION__, __FILE__, __LINE__, "xapian");
            continue;
        }
        $t = time();
        $cmd = "{$nice}{$GLOBALS["omindex"]} -l 0 -s {$lang} -E 512 -m 60M --follow -D \"{$database}\" -U \"{$BaseUrl}\" \"{$directory}\" -v 2>&1";
        if ($GLOBALS["VERBOSE"]) {
            echo "{$cmd}\n";
        }
        $results_scan = array();
        exec($cmd, $results_scan);
        $dirRes = ParseLogs($results_scan);
        $took = $unix->distanceOfTimeInWords($t, time(), true);
        $count++;
        system_admin_events("scanned {$directory} took {$took} indexed:{$dirRes[0]} skipped:{$dirRes[1]}", __FUNCTION__, __FILE__, __LINE__, "xapian");
    }
    $took = $unix->distanceOfTimeInWords($t1, time(), true);
    system_admin_events("scanned {$count} directorie(s) took {$took}", __FUNCTION__, __FILE__, __LINE__, "xapian");
}
コード例 #16
0
ファイル: exec.squidguard.php プロジェクト: BillTheBest/1.6.x
function UFDBGUARD_DOWNLOAD_ALL_CATEGORIES()
{
    include_once dirname(__FILE__) . "/ressources/class.ccurl.inc";
    $unix = new unix();
    $sock = new sockets();
    $tar = $unix->find_program("tar");
    $rm = $unix->find_program("rm");
    $RemoteStatisticsApplianceSettings = unserialize(base64_decode($sock->GET_INFO("RemoteStatisticsApplianceSettings")));
    if (!is_numeric($RemoteStatisticsApplianceSettings["SSL"])) {
        $RemoteStatisticsApplianceSettings["SSL"] = 1;
    }
    if (!is_numeric($RemoteStatisticsApplianceSettings["PORT"])) {
        $RemoteStatisticsApplianceSettings["PORT"] = 9000;
    }
    $GLOBALS["REMOTE_SSERVER"] = $RemoteStatisticsApplianceSettings["SERVER"];
    $GLOBALS["REMOTE_SPORT"] = $RemoteStatisticsApplianceSettings["PORT"];
    $GLOBALS["REMOTE_SSL"] = $RemoteStatisticsApplianceSettings["SSL"];
    if ($GLOBALS["REMOTE_SSL"] == 1) {
        $refix = "https";
    } else {
        $refix = "http";
    }
    $uri = "{$refix}://{$GLOBALS["REMOTE_SSERVER"]}:{$GLOBALS["REMOTE_SPORT"]}/ressources/databases/blacklist.tar.gz";
    $curl = new ccurl($uri, true);
    if (!$curl->GetFile("/tmp/blacklist.tar.gz")) {
        ufdbguard_admin_events("Failed to download blacklist.tar.gz aborting `{$curl->error}`", __FUNCTION__, __FILE__, __LINE__, "global-compile");
        return;
    }
    $t = time();
    shell_exec("{$rm} -rf /var/lib/squidguard/*");
    exec("{$tar} -xf /tmp/blacklist.tar.gz -C /var/lib/squidguard/ 2>&1", $results);
    $ttook = $unix->distanceOfTimeInWords($t, time(), true);
    ufdbguard_admin_events("Extracting blacklist.tar.gz took {$ttook} `" . @implode("\n", $results), __FUNCTION__, __FILE__, __LINE__, "global-compile");
    $array = $unix->dirdir("/var/lib/squidguard");
    $GLOBALS["NORESTART"] = true;
    while (list($index, $directoryPath) = each($array)) {
        if (!is_file("{$directoryPath}/domains.ufdb")) {
            UFDBGUARD_COMPILE_SINGLE_DB("{$directoryPath}/domains");
        }
    }
    build_ufdbguard_HUP();
}
コード例 #17
0
function compile_ufdbcat()
{
    $unix = new unix();
    $uri = "http://www.articatech.net/download/ufdbGuard-1.31.tar.gz";
    $curl = new ccurl("http://www.articatech.net/download/ufdbGuard-1.31.tar.gz");
    echo "Downloading {$uri}\n";
    $tempdir = $unix->TEMP_DIR() . "/ufdb";
    $tempfile = "{$tempdir}/ufdbGuard-1.31.tar.gz";
    $tar = $unix->find_program("tar");
    $rm = $unix->find_program("rm");
    $cp = $unix->find_program("cp");
    if (is_dir($tempdir)) {
        shell_exec("{$rm} -rf {$tempdir}");
    }
    @mkdir($tempdir, 0755, true);
    if (is_file($tempfile)) {
        @unlink($tempfile);
    }
    if (!$curl->GetFile($tempfile)) {
        echo "Fatal, unable to download {$uri}\n";
        meta_admin_mysql(0, "Fatal, unable to download {$uri}", @implode("\n", $curl->errors), __FILE__, __LINE__);
        return;
    }
    if (is_dir("{$tempdir}/ufdbcompile")) {
        shell_exec("{$rm} -rf {$tempdir}/ufdbcompile");
    }
    echo "Uncompressing {$tempdir}/ufdbGuard-1.31.tar.gz to {$tempdir}/\n";
    shell_exec("{$tar} -xf {$tempdir}/ufdbGuard-1.31.tar.gz -C {$tempdir}/");
    $dirs = $unix->dirdir($tempdir);
    while (list($directory, $value) = each($dirs)) {
        echo "Found directory {$directory}\n";
        if (is_file("{$directory}/src/mtserver/ufdbguardd.c")) {
            $WORKDIR = "{$directory}";
            break;
        }
    }
    if (!is_dir($WORKDIR)) {
        echo "Fatal, unable to download {$uri}\n";
        meta_admin_mysql(0, "Fatal, unable to locate working directory", __FILE__, __LINE__);
        if (is_dir($tempdir)) {
            shell_exec("{$rm} -rf {$tempdir}");
        }
        return;
    }
    echo "Patching mtserver/ufdbguardd.c\n";
    $C = explode("\n", @file_get_contents("{$directory}/src/mtserver/ufdbguardd.c"));
    while (list($index, $line) = each($C)) {
        if (strpos($line, "/tmp/ufdbguardd-") > 0) {
            echo "Patching mtserver/ufdbguardd.c line {$index}\n";
            $C[$index] = str_replace("/tmp/ufdbguardd-", "/var/run/ufdbcat-", $line);
        }
    }
    @file_put_contents("{$directory}/src/mtserver/ufdbguardd.c", @implode("\n", $C));
    chdir($WORKDIR);
    if (is_dir("/opt/ufdbcat")) {
        shell_exec("{$rm} -rf /opt/ufdbcat");
    }
    echo "Configure\n";
    $f[] = "./configure";
    $f[] = "--prefix=/opt/ufdbcat";
    $f[] = "--includedir=\"\\\${prefix}/include\"";
    $f[] = "--mandir=\"\\\${prefix}/share/man\"";
    $f[] = "--infodir=\"\\\${prefix}/share/info\"";
    $f[] = "--sysconfdir=/etc/ufdbcat";
    $f[] = "--localstatedir=/opt/ufdbcat";
    $f[] = "--with-ufdb-logdir=/var/log/ufdbcat";
    $f[] = "--with-ufdb-dbhome=/home/ufdbcat";
    $f[] = "--with-ufdb-user=root";
    $f[] = "--with-ufdb-config=/etc/ufdbcat";
    $f[] = "--with-ufdb-logdir=/var/log/ufdbcat";
    $f[] = "--with-ufdb-config=/etc/ufdbcat";
    $f[] = "--with-ufdb-piddir=/var/run/ufdbcat";
    $cmd = @implode(" ", $f);
    system($cmd);
    echo "Make\n";
    system("make");
    echo "Install\n";
    system("make install");
    if (!is_file("/opt/ufdbcat/bin/ufdbguardd")) {
        echo "Fatal, unable to compile ufdbcat\n";
        meta_admin_mysql(0, "Fatal, unable to compile ufdbcat", __FILE__, __LINE__);
        if (is_dir($tempdir)) {
            shell_exec("{$rm} -rf {$tempdir}");
        }
        return;
    }
    @copy("/opt/ufdbcat/bin/ufdbguardd", "/opt/ufdbcat/bin/ufdbcatdd");
    @unlink("/opt/ufdbcat/bin/ufdbguardd");
    @chmod("/opt/ufdbcat/bin/ufdbcatdd", 0755);
    $ufdbcatVersion = ufdbcatVersion();
    $Architecture = Architecture();
    $DebianVersion = DebianVersion();
    $base = "/root/ufdbcat-compile";
    if (is_dir($base)) {
        shell_exec("{$rm} -rf {$base}");
    }
    @mkdir("{$base}/opt/ufdbcat", 0755, true);
    shell_exec("{$cp} -rfp /opt/ufdbcat/* {$base}/opt/ufdbcat/");
    $filename = "ufdbcat-debian{$DebianVersion}-{$Architecture}-{$ufdbcatVersion}.tar.gz";
    chdir($base);
    @unlink("/root/{$filename}");
    shell_exec("/bin/tar -czf /root/{$filename} *");
    echo "/root/{$filename} done\n\n";
}
コード例 #18
0
function ScanThis($Directory = null)
{
    if ($Directory == null) {
        return;
    }
    if (!is_dir($Directory)) {
        return null;
    }
    if (isset($GLOBALS["ALREADY_SCANNED"][$Directory])) {
        return null;
    }
    if ($GLOBALS["VERBOSE"]) {
        echo "About \"{$Directory}\"\n";
    }
    $GLOBALS["ALREADY_SCANNED"][$Directory] = true;
    if (is_link($Directory)) {
        $Directory = @readlink($Directory);
    }
    $unix = new unix();
    $dirs = $unix->dirdir($Directory);
    if (count($dirs) > 0) {
        while (list($directoryPath, $value) = each($dirs)) {
            if ($GLOBALS["VERBOSE"]) {
                echo "Rescan \"{$directoryPath}\"\n";
            }
            ScanThis($directoryPath);
        }
    }
    $files = $unix->DirFiles($Directory);
    if (count($files) == 0) {
        return;
    }
    $FILES_ARRAY_SQL = array();
    while (list($filename, $value) = each($files)) {
        $filepath = "{$Directory}/{$filename}";
        $filetime = 0;
        $filesize = round(@filesize($filepath) / 1024, 2);
        if ($filetime == 0) {
            if (preg_match("#\\.([0-9]+)\\.[a-z]+\$#", $filename, $re)) {
                $filetime = $re[1];
            }
        }
        if ($filetime == 0) {
            if (preg_match("#-([0-9]+)\\.[a-z]+\$#", $filename, $re)) {
                $filetime = $re[1];
            }
        }
        if ($filetime == 0) {
            if (preg_match("#\\.log([0-9]+)\\.[a-z]+\$#", $filename, $re)) {
                $filetime = $re[1];
            }
        }
        if ($filetime == 0) {
            if (preg_match("#-([0-9]+)-([0-9]+)-([0-9]+)-([0-9]+)\\.#", $filename, $re)) {
                if (strlen($re[4]) == 1) {
                    $re[4] = "0{$re[4]}";
                }
                $strdate = "{$re[1]}-{$re[2]}-{$re[3]} {$re[4]}:00:00";
                $filetime = strtotime($strdate);
            }
        }
        if ($filetime == 0) {
            $filetime = filemtime($filepath);
        }
        $filedate = date("Y-m-d H:i:s", $filetime);
        $FILES_ARRAY_SQL[] = "('" . mysql_escape_string2($filepath) . "','{$filesize}','{$filedate}')";
        if ($GLOBALS["VERBOSE"]) {
            echo "{$filedate} - {$filepath}: {$filesize}\n";
        }
    }
    if (count($FILES_ARRAY_SQL) > 0) {
        $q = new mysql();
        $q->QUERY_SQL("INSERT IGNORE INTO sysstorestatus \n\t\t\t\t(`filepath`,`filesize`,`zDate`) VALUES " . @implode(",", $FILES_ARRAY_SQL), "artica_events");
    }
}
コード例 #19
0
function GetRulesSizes()
{
    $unix = new unix();
    $sock = new sockets();
    $fileTime = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".time";
    $TimeExec = $unix->file_time_min($fileTime);
    if ($TimeExec < 20) {
        events("GetRulesSizes:: Require 20mn, current {$TimeExec}Mn", 0, 2, __LINE__);
        return;
    }
    @unlink($fileTime);
    @file_put_contents($fileTime, time());
    if (!isset($GLOBALS["HyperCacheStoragePath"])) {
        $GLOBALS["HyperCacheStoragePath"] = $sock->GET_INFO("HyperCacheStoragePath");
        if ($GLOBALS["HyperCacheStoragePath"] == null) {
            $GLOBALS["HyperCacheStoragePath"] = "/home/artica/proxy-cache";
        }
    }
    $q = new mysql_squid_builder();
    if (!$q->FIELD_EXISTS("artica_caches", "MarkToDelete", "artica_backup")) {
        $sql = "ALTER TABLE `artica_caches` ADD `MarkToDelete` smallint(1) NOT NULL DEFAULT 0, ADD INDEX(MarkToDelete)";
        $q->QUERY_SQL($sql, "artica_backup");
    }
    $sql = "CREATE TABLE IF NOT EXISTS `artica_caches_sizes` (\n\t\t`ruleid` BIGINT UNSIGNED,\n\t\t`sizebytes` BIGINT UNSIGNED,\n\t\t`sitename` VARCHAR( 128 ) NOT NULL,\n\t\t KEY `ruleid` (`ruleid`),\n\t\t KEY `sitename` (`sitename`)\n\t\t)  ENGINE = MYISAM;\n\t\t\t";
    $q->QUERY_SQL($sql);
    $results = $q->QUERY_SQL("SELECT ID FROM artica_caches WHERE enabled=1 AND MarkToDelete=0");
    $RootPath = $GLOBALS["HyperCacheStoragePath"];
    while ($ligne = mysql_fetch_assoc($results)) {
        $ID = $ligne["ID"];
        $RULES[$ID] = 0;
        $Directory = "{$RootPath}/{$ID}";
        $Dirs = $unix->dirdir($Directory);
        while (list($SubDir, $none) = each($Dirs)) {
            $domain = basename($SubDir);
            $size = $unix->DIRSIZE_BYTES($SubDir);
            $RULES[$ID] = $RULES[$ID] + $size;
            $f[] = "('{$ID}','{$size}','{$domain}')";
        }
    }
    $q->QUERY_SQL("TRUNCATE TABLE artica_caches_sizes");
    if (count($f) > 0) {
        $q->QUERY_SQL("INSERT IGNORE INTO artica_caches_sizes (`ruleid`,`sizebytes`,`sitename`) VALUES " . @implode(",", $f));
        while (list($ID, $size) = each($RULES)) {
            $q->QUERY_SQL("UPDATE artica_caches SET `foldersize`='{$size}' WHERE ID='{$ID}'");
        }
    }
}
コード例 #20
0
ファイル: exec.ufdbcat.php プロジェクト: brucewu16899/1.6.x
function buildconfig()
{
    $q = new mysql_squid_builder();
    $unix = new unix();
    $dirs = $unix->dirdir("/home/ufdbcat");
    $AsCategoriesAppliance = intval(@file_get_contents("/etc/artica-postfix/settings/Daemons/AsCategoriesAppliance"));
    $array["category_governments"] = "governments";
    $array["category_industry"] = "industry";
    $array["category_luxury"] = "luxury";
    $array["category_shopping"] = "shopping";
    $array["category_socialnet"] = "socialnet";
    $array["category_searchengines"] = "searchengines";
    $array["category_news"] = "news";
    $array["category_blog"] = "blog";
    $array["category_remote_control"] = "remote-control";
    $array["category_audio_video"] = "audio-video";
    $array["category_webtv"] = "webtv";
    $array["category_movies"] = "movies";
    $array["category_music"] = "music";
    $array["category_animals"] = "animals";
    $array["category_children"] = "children";
    $array["category_cosmetics"] = "cosmetics";
    $array["category_clothing"] = "clothing";
    $array["category_electricalapps"] = "electricalapps";
    $array["category_electronichouse"] = "electronichouse";
    $array["category_associations"] = "associations";
    $array["category_astrology"] = "astrology";
    $array["category_bicycle"] = "bicycle";
    $array["category_automobile_bikes"] = "automobile/bikes";
    $array["category_automobile_boats"] = "automobile/boats";
    $array["category_automobile_carpool"] = "automobile/carpool";
    $array["category_automobile_planes"] = "automobile/planes";
    $array["category_automobile_cars"] = "automobile/cars";
    $array["category_cleaning"] = "cleaning";
    $array["category_converters"] = "converters";
    $array["category_finance_realestate"] = "finance/realestate";
    $array["category_finance_banking"] = "finance/banking";
    $array["category_finance_insurance"] = "finance/insurance";
    $array["category_finance_moneylending"] = "finance/moneylending";
    $array["category_stockexchange"] = "stockexchange";
    $array["category_finance_other"] = "finance/other";
    $array["category_financial"] = "financial";
    $array["category_forums"] = "forums";
    $array["category_games"] = "games";
    $array["category_gamble"] = "gamble";
    $array["category_getmarried"] = "getmarried";
    $array["category_gifts"] = "gifts";
    $array["category_green"] = "green";
    $array["category_handicap"] = "handicap";
    $array["category_humanitarian"] = "humanitarian";
    $array["category_hospitals"] = "hospitals";
    $array["category_medical"] = "medical";
    $array["category_health"] = "health";
    $array["category_hobby_cooking"] = "hobby/cooking";
    $array["category_hobby_fishing"] = "hobby/fishing";
    $array["category_hobby_other"] = "hobby/other";
    $array["category_hobby_pets"] = "hobby/pets";
    $array["category_horses"] = "horses";
    $array["category_housing_accessories"] = "housing/accessories";
    $array["category_housing_builders"] = "housing/builders";
    $array["category_housing_doityourself"] = "housing/doityourself";
    $array["category_jobsearch"] = "jobsearch";
    $array["category_jobtraining"] = "jobtraining";
    $array["category_justice"] = "justice";
    $array["category_learning"] = "learning";
    $array["category_manga"] = "manga";
    $array["category_maps"] = "maps";
    $array["category_mobile_phone"] = "mobile-phone";
    $array["category_nature"] = "nature";
    $array["category_passwords"] = "passwords";
    $array["category_police"] = "police";
    $array["category_politic"] = "politic";
    $array["category_recreation_humor"] = "recreation/humor";
    $array["category_recreation_schools"] = "recreation/schools";
    $array["category_recreation_sports"] = "recreation/sports";
    $array["category_recreation_travel"] = "recreation/travel";
    $array["category_recreation_nightout"] = "recreation/nightout";
    $array["category_recreation_wellness"] = "recreation/wellness";
    $array["category_models"] = "models";
    $array["category_celebrity"] = "celebrity";
    $array["category_womanbrand"] = "womanbrand";
    $array["category_science_astronomy"] = "science/astronomy";
    $array["category_science_chemistry"] = "science/chemistry";
    $array["category_science_computing"] = "science/computing";
    $array["category_science_weather"] = "science/weather";
    $array["category_culture"] = "culture";
    $array["category_sciences"] = "sciences";
    $array["category_literature"] = "literature";
    $array["category_smallads"] = "smallads";
    $array["category_houseads"] = "houseads";
    $array["category_tattooing"] = "tattooing";
    $array["category_teens"] = "teens";
    $array["category_terrorism"] = "terrorism";
    $array["category_translators"] = "translators";
    $array["category_transport"] = "transport";
    $array["category_tricheur"] = "tricheur";
    $array["category_updatesites"] = "updatesites";
    $array["category_webmail"] = "webmail";
    $array["category_chat"] = "chat";
    $array["category_meetings"] = "meetings";
    $array["category_webapps"] = "webapps";
    $array["category_webplugins"] = "webplugins";
    $array["category_browsersplugins"] = "browsersplugins";
    $array["category_webphone"] = "webphone";
    $array["category_wine"] = "wine";
    $array["category_tobacco"] = "tobacco";
    $array["category_alcohol"] = "alcohol";
    $array["category_drugs"] = "drugs";
    $array["category_books"] = "books";
    $array["category_dictionaries"] = "dictionaries";
    $array["category_photo"] = "photo";
    $array["category_pictureslib"] = "pictureslib";
    $array["category_imagehosting"] = "imagehosting";
    $array["category_downloads"] = "downloads";
    $array["category_filehosting"] = "filehosting";
    $array["category_society"] = "society";
    $array["category_hobby_arts"] = "hobby/arts";
    $array["category_webradio"] = "webradio";
    $array["category_genealogy"] = "genealogy";
    $array["category_paytosurf"] = "paytosurf";
    $array["category_religion"] = "religion";
    $array["category_abortion"] = "abortion";
    $array["category_sect"] = "sect";
    $array["category_suspicious"] = "suspicious";
    $array["category_warez"] = "warez";
    $array["category_hacking"] = "hacking";
    $array["category_proxy"] = "proxy";
    $array["category_porn"] = "p**n";
    $array["category_dating"] = "dating";
    $array["category_mixed_adult"] = "mixed_adult";
    $array["category_sex_lingerie"] = "sex/lingerie";
    $array["category_sexual_education"] = "sexual_education";
    $array["category_marketingware"] = "marketingware";
    $array["category_publicite"] = "publicite";
    $array["category_tracker"] = "tracker";
    $array["category_mailing"] = "mailing";
    $array["category_redirector"] = "redirector";
    $array["category_violence"] = "violence";
    $array["category_spyware"] = "spyware";
    $array["category_malware"] = "malware";
    $array["category_phishing"] = "phishing";
    $array["category_dangerous_material"] = "dangerous_material";
    $array["category_weapons"] = "weapons";
    $array["category_internal"] = "internal";
    $array["category_dynamic"] = "dynamic";
    $array["category_isp"] = "isp";
    $array["category_sslsites"] = "sslsites";
    $array["category_reaffected"] = "reaffected";
    while (list($dirname, $realcat) = each($array)) {
        if (is_file("/home/ufdbcat/{$dirname}/domains.ufdb")) {
            if (!is_file("/home/ufdbcat/{$dirname}/expressions")) {
                @touch("/home/ufdbcat/{$dirname}/expressions");
            }
            $cats[] = $dirname;
            $catz[] = "category \"{$dirname}\" {";
            $catz[] = "\tdomainlist      \"{$dirname}/domains\"";
            $catz[] = "\texpressionlist  \"{$dirname}/expressions\"";
            $catz[] = "\tredirect        \"http://none/{$realcat}\"";
            $catz[] = "}";
        }
    }
    $f[] = "dbhome \"/home/ufdbcat\"";
    $f[] = "logdir \"/var/log/ufdbcat\"";
    $f[] = "logblock off";
    $f[] = "logpass off";
    $f[] = "logall off";
    $f[] = "squid-version \"3.3\"";
    $f[] = "url-lookup-result-during-database-reload deny";
    $f[] = "url-lookup-result-when-fatal-error deny";
    $f[] = "analyse-uncategorised-urls off";
    $f[] = "enforce-https-with-hostname off";
    $f[] = "enforce-https-offical-certificate off";
    $f[] = "https-prohibit-insecure-sslv2 off";
    $EnableLocalUfdbCatService = intval(@file_get_contents("/etc/artica-postfix/settings/Daemons/EnableLocalUfdbCatService"));
    if ($AsCategoriesAppliance == 1) {
        $EnableLocalUfdbCatService = 1;
    }
    if ($EnableLocalUfdbCatService == 1) {
        $ufdbCatInterface = @file_get_contents("/etc/artica-postfix/settings/Daemons/ufdbCatInterface");
        if ($ufdbCatInterface != null) {
            if (!$unix->is_interface_available($ufdbCatInterface)) {
                if ($GLOBALS["OUTPUT"]) {
                    echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} {$ufdbCatInterface} not available\n";
                }
            } else {
                if ($GLOBALS["OUTPUT"]) {
                    echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} {$ufdbCatInterface} is available\n";
                }
            }
        }
        $ufdbCatPort = intval(@file_get_contents("/etc/artica-postfix/settings/Daemons/ufdbCatPort"));
        if ($ufdbCatPort == 0) {
            $ufdbCatPort = 3978;
        }
        if ($ufdbCatInterface == null) {
            $ufdbCatInterface = "all";
        }
        $f[] = "port {$ufdbCatPort}";
        $f[] = "interface {$ufdbCatInterface}";
    }
    $f[] = "check-proxy-tunnels off";
    $f[] = "safe-search off";
    $f[] = "youtube-edufilter    off";
    $f[] = "max-logfile-size  200000000";
    $f[] = "# refreshuserlist 15";
    $f[] = "# refreshdomainlist 15";
    $f[] = "source allSystems {";
    $f[] = "   ip  0.0.0.0/0  ";
    $f[] = "}";
    $categories = @implode(" !", $cats);
    if (!is_file("/home/ufdbcat/security/cacerts")) {
        @mkdir("/home/ufdbcat/security");
        @touch("/home/ufdbcat/security/cacerts");
    }
    $f[] = "category security {";
    $f[] = "\tcacerts \"security/cacerts\"";
    $f[] = "\toption  enforce-https-with-hostname off";
    $f[] = "\toption  enforce-https-official-certificate off";
    $f[] = "\toption  https-prohibit-insecure-sslv2 off";
    $f[] = "\toption \tallow-aim-over-https off";
    $f[] = "\toption \tallow-gtalk-over-https off";
    $f[] = "\toption \tallow-skype-over-https off";
    $f[] = "\toption \tallow-yahoomsg-over-https off";
    $f[] = "\toption \tallow-fb-chat-over-https off";
    $f[] = "\toption \tallow-citrixonline-over-https off";
    $f[] = "\toption \tallow-unknown-protocol-over-https off";
    $f[] = "}";
    $f[] = @implode("\n", $catz);
    $f[] = "";
    $f[] = "";
    $f[] = "acl {";
    $f[] = "\tallSystems  {";
    $f[] = "\t\tpass !{$categories} any";
    $f[] = "\t}";
    $f[] = "";
    $f[] = "\t\tdefault {";
    $f[] = "\tpass !{$categories} any";
    $f[] = "\tredirect        \"http://cgibin.urlfilterdb.com/cgi-bin/URLblocked.cgi?admin=%A&color=orange&size=normal&clientaddr=%a&clientname=%n&clientuser=%i&clientgroup=%s&category=%t&url=%u\"";
    $f[] = "\t}";
    $f[] = "}";
    @file_put_contents("/etc/ufdbcat/ufdbGuard.conf", @implode("\n", $f));
    if ($GLOBALS["OUTPUT"]) {
        echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} /etc/ufdbcat/ufdbGuard.conf done\n";
    }
}
コード例 #21
0
ファイル: exec.backup.php プロジェクト: articatech/artica
function backup_mysql_databases_list($ID, $instance_id = 0)
{
    $users = new usersMenus();
    $mysqldir = $users->mysqld_datadir;
    if ($instance_id > 0) {
        $mysql = new mysql_multi($instance_id);
        $prefixTXT = " ({$mysql->MyServer}) ";
        $mysqldir = $mysql->HomeDir;
    }
    if (!is_dir($mysqldir)) {
        backup_events($ID, "mysql", "ERROR,{$prefixTXT} unable to stat directory ({$mysqldir})");
        return;
    }
    $unix = new unix();
    $array = $unix->dirdir($mysqldir);
    while (list($num, $line) = each($array)) {
        writelogs("Found {$line} db", __FUNCTION__, __FILE__, __LINE__);
        $results[] = $line;
    }
    return $results;
}
コード例 #22
0
ファイル: compile-zpush.php プロジェクト: BillTheBest/1.6.x
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);
}
コード例 #23
0
ファイル: cmd.php プロジェクト: brucewu16899/artica
function dirdirBase64()
{
    $path = base64_decode($_GET["B64-dirdir"]);
    $unix = new unix();
    $array = $unix->dirdir($path);
    writelogs_framework("path={$path} (" . count($array) . " elements)", __FUNCTION__, __FILE__, __LINE__);
    echo "<articadatascgi>" . base64_encode(serialize($array)) . "</articadatascgi>";
}
コード例 #24
0
function CoherenceBase()
{
    $unix = new unix();
    $myFile = basename(__FILE__);
    $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
    $cachetime = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".time";
    $unix = new unix();
    $pid = @file_get_contents($pidfile);
    if ($unix->process_exists($pid, $myFile)) {
        WriteMyLogs("Already executed PID:{$pid}, die()", __FUNCTION__, __FILE__, __LINE__);
        die;
    }
    $q = new mysql_squid_builder();
    $unix = new unix();
    $results = $q->QUERY_SQL("SELECT * FROM ftpunivtlse1fr");
    if (!$q->ok) {
        if (strpos($q->mysql_error, "doesn't exist") > 0) {
            $q->CheckTables();
            $results = $q->QUERY_SQL("SELECT * FROM ftpunivtlse1fr");
        }
    }
    if (!$q->ok) {
        ufdbguard_admin_events("Fatal: {$q->mysql_error}", __FUNCTION__, __FILE__, __LINE__, "Toulouse DB");
        die;
    }
    while ($ligne = mysql_fetch_array($results, MYSQL_ASSOC)) {
        if ($GLOBALS["VERBOSE"]) {
            echo "ftpunivtlse1fr: {$ligne["filename"]} -> {$ligne["zmd5"]}\n";
        }
        $ARRAYSUM_LOCALE[$ligne["filename"]] = $ligne["zmd5"];
    }
    $dirs = $unix->dirdir("/var/lib/ftpunivtlse1fr");
    while (list($directory, $line) = each($dirs)) {
        if (!is_file("{$directory}/domains")) {
            echo "{$directory} has no domains\n";
            shell_exec("{$rm} -rf {$directory}");
            continue;
        }
        $virtualFilename = basename($directory) . ".tar.gz";
        if (!isset($ARRAYSUM_LOCALE[$virtualFilename])) {
            $CountDeSitesFile = CountDeSitesFile("{$directory}/domains");
            $md5 = md5($virtualFilename);
            echo "Add virtual filename {$virtualFilename} with {$CountDeSitesFile} domains";
            $q->QUERY_SQL("INSERT INTO ftpunivtlse1fr (`filename`,`zmd5`,`websitesnum`) VALUES ('{$virtualFilename}','{$md5}','{$CountDeSitesFile}')");
        } else {
            if ($GLOBALS["VERBOSE"]) {
                echo "LOCAL: {$virtualFilename} -> {$directory} OK\n";
            }
        }
    }
}
コード例 #25
0
ファイル: exec.openvpn.php プロジェクト: rsd/artica-1.5
function wakeup_client_mode(){
	$main_path="/etc/artica-postfix/openvpn/clients";
	$unix=new unix();
	$pidpath="/etc/artica-postfix/pids/".basename(__FILE__).".".__FUNCTION__.".pid";
	$oldpid=@file_get_contents($pidpath);
	if($unix->process_exists($oldpid)){
		writelogs("OpenVPN Already instance executed pid $oldpid",__FUNCTION__,__FILE__,__LINE__);
		return;
	}
	
	@file_put_contents($pidpath, posix_getpid());
	$ping=$unix->find_program("ping");
	if(!is_file($ping)){writelogs("Fatal,ping, no such binary",__FUNCTION__,__FILE__,__LINE__);return;}	
	$tbl=$unix->dirdir($main_path);
	if(count($tbl)==0){return;}
	while (list ($path, $id) = each ($tbl) ){
			if(!preg_match("#/etc/artica-postfix/openvpn/clients/([0-9]+)#",$path,$re)){if($GLOBALS["VERBOSE"]){echo "Starting......: $path NO MATCH\n";}continue;}
			$id=$re[1];
			if($GLOBALS["VERBOSE"]){echo "Starting......: OpenVPN wake up checking client ID:$id\n";}
			if(!is_file("$path/settings.ovpn")){if($GLOBALS["VERBOSE"]){echo "Starting......: $path/settings.ovpn no such file\n";}continue;}
			$ip=wakeup_client_mode_getWakeup("$path/settings.ovpn");
			if($ip==null){continue;}
			
			$resultsPing=array();
			exec("$ping -c2 -i0.2 $ip 2>&1",$resultsPing);
			writelogs("OpenVPN  \"$ip\" ".count($resultsPing)." rows",__FUNCTION__,__FILE__,__LINE__);
			$text=date("Y-m-d H:i:s")."\n".@implode("\n", $resultsPing);	
			$ping_results=@file_get_contents("$path/ping_results");
			while (list ($nimber, $l) = each ($resultsPing) ){
				if(preg_match("#,\s+([0-9]+)\%\s+#", $l,$re)){
					writelogs("OpenVPN  \"{$re[1]}%\" Packets lost",__FUNCTION__,__FILE__,__LINE__);
					if($re[1]==100){
						$note=-1;
						writelogs("OpenVPN $ip Ping failed",__FUNCTION__,__FILE__,__LINE__);
						$unix->send_email_events("[VPN]: wake up failed server link $ip" , "It seems that OpenVPN server did not respond\n$text", "vpn");
						
					}else{
						$note=1;
						if($ping_results<>1){$unix->send_email_events("[VPN]: wake up server success $ip" , "It seems that the connection to the server has been established\n$text", "vpn");}
					}
					@file_put_contents("$path/ping_results", $note);
					
					}
			}
	}

}
コード例 #26
0
function scan_artica_databases()
{
    $unix = new unix();
    $URIBASE = $unix->MAIN_URI();
    $tmpdir = $unix->TEMP_DIR();
    $curl = new ccurl("{$URIBASE}/catz/index.txt");
    if (!$curl->GetFile("{$tmpdir}/index.txt")) {
        squid_admin_mysql(0, "BLACKLISTS: Failed to retreive {$URIBASE}/catz/index.txt ", $curl->error, __FUNCTION__, __LINE__);
        artica_update_event(0, "BLACKLISTS: Failed to retreive {$URIBASE}/catz/index.txt ", $curl->error, __FUNCTION__, __LINE__);
        echo "BLACKLISTS: Failed to retreive {$URIBASE}/catz/index.txt ({$curl->error})\n";
        return;
    }
    $fIndex = unserialize(base64_decode(@file_get_contents("{$tmpdir}/index.txt")));
    //print_r($fIndex);
    $time = $fIndex["TIME"];
    $q = new mysql_squid_builder();
    //webfilters_databases_disk
    $prefix = "INSERT IGNORE INTO webfilters_databases_disk (`filename`,`size`,`category`,`filtime`) VALUES ";
    $unix = new unix();
    $dirs = $unix->dirdir($GLOBALS["WORKDIR_LOCAL"]);
    if ($GLOBALS["VERBOSE"]) {
        echo "Scanning " . count($dirs) . " files last pattern was " . date("Y-m-d H:i:s", $time) . "\n";
    }
    $sizz = 0;
    while (list($path, $path2) = each($dirs)) {
        $size = $unix->file_size("{$path2}/domains.ufdb");
        $category = basename($path);
        $sizz = $sizz + $size;
        if ($GLOBALS["VERBOSE"]) {
            echo "{$category} `{$path2}/domains.ufdb` = " . $size / 1024 . " Kb\n";
        }
        $category = $q->filaname_tocat("{$path2}/domains.ufdb");
        $filtime = filemtime("{$path2}/domains.ufdb");
        $f[] = "('{$path2}/domains.ufdb','{$size}','{$category}','{$filtime}')";
    }
    if ($GLOBALS["VERBOSE"]) {
        echo "scanned " . count($f) . " files\n";
    }
    if (count($f) > 0) {
        $sql = $prefix . @implode(",", $f);
        if (!$q->TABLE_EXISTS("webfilters_databases_disk")) {
            $q->CheckTables();
        }
        $q->QUERY_SQL("TRUNCATE TABLE webfilters_databases_disk");
        $q->CheckTables();
        $q->QUERY_SQL($sql);
        if (!$q->ok) {
            squid_admin_mysql(0, "{$q->mysql_error}", null, __FUNCTION__, __LINE__);
            artica_update_event(0, "{$q->mysql_error}", null, __FUNCTION__, __LINE__);
        }
    }
}
コード例 #27
0
function DirectoriesSize()
{
    include_once dirname(__FILE__) . '/ressources/class.mysql.inc';
    $f[] = "/var";
    $f[] = "/var/log";
    $f[] = "/var/log/artica-postfix";
    $f[] = "/var/lib";
    $f[] = "/var/www";
    $f[] = "/usr/share";
    $f[] = "/opt";
    $unix = new unix();
    $q = new mysql();
    $q->QUERY_SQL("TRUNCATE TABLE `DirectorySizes`", "artica_events");
    $prefix = "INSERT IGNORE INTO DirectorySizes (zmd5,path,size) VALUES ";
    if ($GLOBALS["OUTPUT"]) {
        echo "Checking special directories size....Please wait...\n";
    }
    $du = $unix->find_program($du);
    while (list($num, $directory) = each($f)) {
        $size = $unix->DIRSIZE_BYTES($directory);
        $tt = round($size / 1024 / 1000);
        $md = md5($directory);
        $sql[] = "('{$md}','{$directory}','{$size}')";
        echo "{$directory}... {$tt} MB\n";
        $dirs = array();
        $dirs = $unix->dirdir($directory);
        while (list($a, $b) = each($dirs)) {
            $size = $unix->DIRSIZE_BYTES($a);
            $tt = round($size / 1024 / 1000);
            if ($tt > 1) {
                echo "\t{$a} -> " . round($size / 1024 / 1000) . " MB\n";
            }
            $md = md5($a);
            $sql[] = "('{$md}','{$a}','{$size}')";
            if (count($sql) > 100) {
                $q->QUERY_SQL($prefix . @implode(",", $sql), "artica_events");
                $sql = array();
            }
        }
    }
    if (count($sql) > 0) {
        if ($GLOBALS["OUTPUT"]) {
            echo "Checking special directories done.. injecting into DirectorySizes table...\n";
        }
        $q->QUERY_SQL($prefix . @implode(",", $sql), "artica_events");
    }
}
コード例 #28
0
ファイル: cmd.php プロジェクト: articatech/artica
function USB_SCAN_WRITE()
{
    $unix = new unix();
    $dirs = $unix->dirdir("/sys/class/scsi_host");
    $echo = $unix->find_program("echo");
    while (list($dirpath, $line) = each($dirs)) {
        $basename = basename($dirpath);
        if (!preg_match("#host[0-9]+#", $basename)) {
            continue;
        }
        $cmd = "{$echo} \"- - -\" >{$dirpath}/scan";
        shell_exec($cmd);
    }
    $php = $unix->LOCATE_PHP5_BIN();
    $cmdline = "{$php} /usr/share/artica-postfix/exec.usb.scan.write.php";
    if (isset($_GET["tenir"])) {
        $cmd = "{$cmdline} --verbose 2>&1";
        writelogs_framework("{$cmd}", __FUNCTION__, __FILE__, __LINE__);
        exec($cmd, $results);
        writelogs_framework("Lines -> " . count($results), __FUNCTION__, __FILE__, __LINE__);
        krsort($results);
        echo "<articadatascgi>" . base64_encode(@implode("\n", $results)) . "</articadatascgi>";
        return;
    }
    $timeFile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".time";
    $Time = $unix->file_time_min($timeFile);
    if ($Time < 5) {
        writelogs_framework("{$Time}mn, need to wait 5mn,aborting", __FUNCTION__, __FILE__, __LINE__);
        return;
    }
    @unlink($timeFile);
    @file_put_contents($timeFile, time());
    $nohup = $unix->find_program("nohup");
    $cmd = "{$nohup} {$cmdline} >/dev/null 2>&1 &";
    writelogs_framework("{$cmd}", __FUNCTION__, __FILE__, __LINE__);
    shell_exec($cmd);
}
コード例 #29
0
ファイル: compile-squid32.php プロジェクト: BillTheBest/1.6.x
    @mkdir("/root/{$dirsrc}");
    if (!is_file("/root/{$v}")) {
        system_admin_events("Detected new version {$v}", __FUNCTION__, __FILE__, __LINE__, "software");
        echo "Downloading {$v} ...\n";
        shell_exec("{$wget} http://www.squid-cache.org/Versions/v3/3.2/{$v}");
        if (!is_file("/root/{$v}")) {
            system_admin_events("Downloading failed", __FUNCTION__, __FILE__, __LINE__, "software");
            echo "Downloading failed...\n";
            die;
        }
    }
    shell_exec("{$tar} -xf /root/{$v} -C /root/{$dirsrc}/");
    chdir("/root/{$dirsrc}");
    if (!is_file("/root/{$dirsrc}/configure")) {
        echo "/root/{$dirsrc}/configure no such file\n";
        $dirs = $unix->dirdir("/root/{$dirsrc}");
        while (list($num, $ligne) = each($dirs)) {
            if (!is_file("{$ligne}/configure")) {
                echo "{$ligne}/configure no such file\n";
            } else {
                chdir("{$ligne}");
                echo "[OK]: Change to dir {$ligne}\n";
                $SOURCE_DIRECTORY = $ligne;
                break;
            }
        }
    }
}
$cmds[] = "--prefix=/usr";
$cmds[] = "--includedir=\${prefix}/include";
$cmds[] = "--mandir=\${prefix}/share/man";
コード例 #30
0
function youtube_next()
{
    $unix = new unix();
    $mypid = getmypid();
    $dirs = $unix->dirdir("/var/log/artica-postfix/squid/queues");
    while (list($directory, $array) = each($dirs)) {
        $dirs2 = $unix->dirdir($directory);
        if (count($dirs2) == 0) {
            youtube_events("{$dirs2} 0 elements, remove...", __LINE__);
            @rmdir($directory);
            continue;
        }
        if (is_dir("{$directory}/SearchWords")) {
            $php = $unix->LOCATE_PHP5_BIN();
            $nohup = $unix->find_program("nohup");
            shell_exec("{$nohup} {$php} /usr/share/artica-postfix/exec.squid.words.parsers.php >/dev/null 2>&1 &");
        }
        if (is_dir("{$directory}/Youtube")) {
            youtube_events("Scanning {$directory}/Youtube", __LINE__);
            youtube_next_dir("{$directory}/Youtube");
        }
    }
}