コード例 #1
0
function cron()
{
    $unix = new unix();
    $files = $unix->DirFiles("/etc/cron.d");
    $sql = "SELECT CronSchedule,ID FROM imapsync";
    $q = new mysql();
    $results = $q->QUERY_SQL($sql, "artica_backup");
    if (!$q->ok) {
        return null;
    }
    while (list($index, $line) = each($files)) {
        if ($index == null) {
            continue;
        }
        if (preg_match("#^imapsync-#", $index)) {
            @unlink("/etc/cron.d/{$index}");
        }
    }
    $sql = "SELECT CronSchedule,ID FROM imapsync";
    $q = new mysql();
    $results = $q->QUERY_SQL($sql, "artica_backup");
    while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) {
        if (trim($ligne["CronSchedule"] == null)) {
            continue;
        }
        $f[] = "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/X11R6/bin:/usr/share/artica-postfix/bin";
        $f[] = "MAILTO=\"\"";
        $f[] = "{$ligne["CronSchedule"]}  root " . __FILE__ . " --sync {$ligne["ID"]}";
        $f[] = "";
        @file_put_contents("/etc/cron.d/imapsync-{$ligne["ID"]}", implode("\n", $f));
        @chmod("/etc/cron.d/imapsync-{$ligne["ID"]}", 600);
        unset($f);
    }
}
コード例 #2
0
function startx()
{
    $unix = new unix();
    $php = $unix->LOCATE_PHP5_BIN();
    $tar = $unix->find_program("tar");
    build_progress("{backup_parameters}....", 5);
    chdir("/etc/squid3");
    system("cd /etc/squid3");
    system("{$tar} -czf /root/backup.squid.tar.gz *");
    build_progress("{reconfiguring}....", 10);
    system("{$php} /usr/share/artica-postfix/exec.squid.php --build --force");
    build_progress("{stopping_service}....", 50);
    system("/etc/init.d/squid stop");
    build_progress("{starting_service}....", 80);
    system("/etc/init.d/squid start");
    $cachefile = "/usr/share/artica-postfix/ressources/logs/web/squid.start.progress";
    if (is_file($cachefile)) {
        $textAR = unserialize(@file_get_contents($cachefile));
        if ($textAR["POURC"] > 100) {
            build_progress("{restore_parameters}....", 90);
            shell_exec("{$tar} -xf /root/backup.squid.tar.gz -C /etc/squid3/");
            build_progress("{starting_service}....", 90);
            system("/etc/init.d/squid start");
        }
    }
    @unlink("/root/backup.squid.tar.gz");
    build_progress("{starting_service} {success}", 100);
    chdir("/root");
}
コード例 #3
0
function startx()
{
    build_progress("{rebuild_ssl_cache}: Removing SSL cache", 10);
    $unix = new unix();
    $rm = $unix->find_program("rm");
    $chown = $unix->find_program("chown");
    if ($GLOBALS["RESTART"]) {
        build_progress("{rebuild_ssl_cache}: {stopping_proxy_service}", 30);
        system("/etc/init.d/squid stop --script=" . basename(__FILE__));
    }
    echo "Remove /var/lib/squid/session/ssl/ssl_db\n";
    shell_exec("{$rm} -rf /var/lib/squid/session/ssl/ssl_db");
    build_progress("{rebuild_ssl_cache}: Reconstruct SSL cache", 50);
    $sslcrtd_program = $unix->squid_locate_generic_bin("ssl_crtd");
    system("{$sslcrtd_program} -c -s /var/lib/squid/session/ssl/ssl_db");
    system("{$chown} -R squid:squid /var/lib/squid/session");
    build_progress("{rebuild_ssl_cache}: Reload Proxy service", 60);
    system("/etc/init.d/cache-tail restart --force");
    if ($GLOBALS["RESTART"]) {
        build_progress("{rebuild_ssl_cache}: {starting_proxy_service}", 30);
        system("/etc/init.d/squid start --script=" . basename(__FILE__));
        build_progress("{rebuild_ssl_cache}: {done}", 100);
        return;
    }
    build_progress("{rebuild_ssl_cache}: Reload Proxy service", 70);
    system("/etc/init.d/squid reload --force --script=" . basename(__FILE__));
    build_progress("{rebuild_ssl_cache}: {done}", 100);
}
コード例 #4
0
ファイル: btrfs.php プロジェクト: BillTheBest/1.6.x
function disks_scan()
{
    $unix = new unix();
    $btrfs = $unix->find_program("btrfs");
    $blkid = $unix->find_program("blkid");
    $cmd = "{$btrfs} filesystem show 2>&1";
    writelogs_framework("{$cmd}", __FUNCTION__, __FILE__, __LINE__);
    exec($cmd, $results);
    while (list($num, $ligne) = each($results)) {
        if (preg_match("#Label:\\s+'(.*?)'\\s+uuid:\\s+(.+)#i", $ligne, $re)) {
            $UUID = $re[2];
            $array[$UUID]["LABEL"] = $re[1];
            $array[$UUID]["DEV"] = exec("{$blkid} -U {$UUID}");
            $array[$UUID]["MOUNTED"] = $unix->MOUNTED_PATH($array[$UUID]["DEV"]);
            $array[$UUID]["DF"] = $unix->BLKID_INFOS($array[$UUID]["DEV"]);
            continue;
        }
        if (preg_match("#Total devices.+?FS bytes used (.+)#", $ligne, $re)) {
            $array[$UUID]["USED"] = $re[1];
            continue;
        }
        if (preg_match("#devid\\s+([0-9]+)\\s+size\\s+(.+?)\\s+used\\s+(.+?)\\s+path\\s+(.+)#", $ligne, $re)) {
            writelogs_framework("{$UUID}: {$ligne}", __FUNCTION__, __FILE__, __LINE__);
            writelogs_framework("{$UUID}: {$re[4]}: SIZE: {$re[2]}", __FUNCTION__, __FILE__, __LINE__);
            $array[$UUID]["DEVICES"][$re[1]]["SIZE"] = $re[2];
            $array[$UUID]["DEVICES"][$re[1]]["USED"] = $re[3];
            $array[$UUID]["DEVICES"][$re[1]]["DEV"] = $re[4];
        }
    }
    echo "<articadatascgi>" . base64_encode(serialize($array)) . "</articadatascgi>";
}
コード例 #5
0
ファイル: exec.dropbox.php プロジェクト: BillTheBest/1.6.x
function DropBoxUri()
{
    $sock = new sockets();
    $DropBoxUri = $sock->GET_INFO("DropBoxUri");
    if (strlen($DropBoxUri) > 10) {
        echo $DropBoxUri . "\n";
        return;
    }
    $unix = new unix();
    $grep = $unix->find_program("grep");
    $tail = $unix->find_program("tail");
    exec("{$grep} \"Please visit\" /var/log/dropbox.log|{$tail} -n 2000 2>&1", $results);
    while (list($dir, $line) = each($results)) {
        if (preg_match("#Please visit\\s+(.+?)\\s+to link#", $line, $re)) {
            $uri = trim($re[1]);
            break;
        }
    }
    if ($uri != null) {
        $sock = new sockets();
        $sock->SET_INFO("DropBoxUri", $uri);
        echo $uri . "\n";
        return;
    }
}
コード例 #6
0
function ScanQueue()
{
    $users = new usersMenus();
    $GLOBALS["SAMBA_INSTALLED"] = $users->SAMBA_INSTALLED;
    $unix = new unix();
    $path = "/var/log/artica-postfix/xapian";
    $SartOn = time();
    $files = $unix->DirFiles($path);
    if (count($files) == 0) {
        return;
    }
    cpulimitProcessName("omindex");
    while (list($num, $file) = each($files)) {
        $toScan = "{$path}/{$file}";
        if (ScanFile($toScan)) {
            @unlink($toScan);
        }
    }
    $SartOff = time();
    $time = distanceOfTimeInWords($SartOn, $SartOff);
    $countdir = count($GLOBALS["DIRS"]);
    cpulimitProcessNameKill("omindex");
    $echo = "InstantSearch {items}: {skipped}: {$GLOBALS["SKIPPED"]} {files}<br>{indexed}: {$GLOBALS["INDEXED"]} {files}<br>{duration}:{$time}";
    if ($GLOBALS["INDEXED"] > 0) {
        @file_put_contents("/usr/share/artica-postfix/ressources/logs/xapian.results", $echo);
        @chmod("/usr/share/artica-postfix/ressources/logs/xapian.results", 0777);
    }
    echo $echo . "\n";
}
コード例 #7
0
ファイル: exec.itchart.php プロジェクト: BillTheBest/1.6.x
function build_rules()
{
    $q = new mysql_squid_builder();
    $unix = new unix();
    $SQUID_BIN = $unix->LOCATE_SQUID_BIN();
    build_progress("{IT_charter}", 25);
    $sql = "SELECT ID,title FROM itcharters WHERE enabled=1";
    $results = $q->QUERY_SQL($sql);
    if (!$q->ok) {
        build_progress("{IT_charter} {mysql_error}", 110);
        echo $q->mysql_error;
        return;
    }
    if (mysql_num_rows($results) == 0) {
        @unlink("/etc/squid3/itCharts.enabled.db");
        squid_admin_mysql(1, "Reloading Proxy service (itCharts)", null, __FILE__, __LINE__);
        build_progress("{IT_charter} {reload_proxy_service}", 90);
        system("{$SQUID_BIN} -f /etc/squid3/squid.conf -k reconfigure");
        build_progress("{IT_charter} {done} 0 {item}", 100);
        return;
    }
    while ($ligne = mysql_fetch_assoc($results)) {
        build_progress("{$ligne["title"]}", 50);
        echo "{$ligne["ID"]}: {$ligne["title"]}\n";
        $MAIN[$ligne["ID"]] = $ligne["title"];
    }
    @file_put_contents("/etc/squid3/itCharts.enabled.db", serialize($MAIN));
    squid_admin_mysql(1, "Reloading Proxy service (itCharts)", null, __FILE__, __LINE__);
    build_progress("{IT_charter} {reload_proxy_service}", 90);
    system("{$SQUID_BIN} -f /etc/squid3/squid.conf -k reconfigure");
    build_progress("{IT_charter} {done} " . count($MAIN) . " {items}", 100);
}
コード例 #8
0
ファイル: exec.squid80443.php プロジェクト: BillTheBest/1.6.x
function xstart()
{
    $sock = new sockets();
    $unix = new unix();
    $php = $unix->LOCATE_PHP5_BIN();
    $SquidAllow80Port = intval($sock->GET_INFO("SquidAllow80Port"));
    build_progress("{starting} {allow_80443_port}", 15);
    if ($SquidAllow80Port == 1) {
        build_progress("{stopping} {web_service}", 20);
        system("/etc/init.d/apache2 stop");
        build_progress("{stopping} Reverse Proxy", 30);
        system("/etc/init.d/nginx stop");
    } else {
        build_progress("{remove} 80/443 ports", 20);
        $q = new mysql_squid_builder();
        $q->QUERY_SQL("DELETE FROM proxy_ports WHERE `port`='80'");
        build_progress("{remove} 80/443 ports", 25);
        $q->QUERY_SQL("DELETE FROM proxy_ports WHERE `port`='443'");
        build_progress("{reconfigure_proxy_service}", 30);
        $php = $unix->LOCATE_PHP5_BIN();
        shell_exec("{$php} /usr/share/artica-postfix/exec.squid.php --build --force");
    }
    build_progress("{restarting_artica_status}", 80);
    system("/etc/init.d/artica-status restart --force");
    build_progress("{done}", 100);
}
コード例 #9
0
function xstart()
{
    $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . ".pid";
    $pidtime = "/etc/artica-postfix/pids/" . basename(__FILE__) . ".time";
    $pid = @file_get_contents($pidfile);
    if ($GLOBALS["VERBOSE"]) {
        echo "{$pidtime}\n";
    }
    $unix = new unix();
    $squid = $unix->LOCATE_SQUID_BIN();
    if (!$GLOBALS["FORCE"]) {
        if ($unix->process_exists($pid, basename(__FILE__))) {
            $time = $unix->PROCCESS_TIME_MIN($pid);
            if ($GLOBALS["VERBOSE"]) {
                echo "Already executed pid {$pid} since {$time}mn\n";
            }
            die;
        }
    }
    $mypid = getmypid();
    @file_put_contents($pidfile, $mypid);
    $timefile = $unix->file_time_min($pidtime);
    if ($GLOBALS["VERBOSE"]) {
        echo "Timelock:{$pidtime} {$timefile} Mn\n";
    }
    if (!$GLOBALS["FORCE"]) {
        if ($timefile < 5) {
            if ($GLOBALS["VERBOSE"]) {
                echo "{$timefile}mn require 5mn\n";
            }
            return;
        }
    }
    @unlink($pidtime);
    @file_put_contents($pidtime, time());
    if (!is_file("/home/ufdb/smtp-events/ACCESS_LOG")) {
        if ($GLOBALS["VERBOSE"]) {
            echo "/home/ufdb/smtp-events/ACCESS_LOG no such file\n";
        }
    }
    $array = explode("\n", @file_get_contents("/home/ufdb/smtp-events/ACCESS_LOG"));
    @unlink("/home/ufdb/smtp-events/ACCESS_LOG");
    $body = array();
    $mmstp = new ufdb_msmtp();
    $Subject = count($array) . " Web filtering blocked event(s)";
    $body[] = "Return-Path: <{$mmstp->smtp_sender}>";
    $body[] = "Date: " . date("D, d M Y H:i:s") . " +0100 (CET)";
    $body[] = "From: {$mmstp->smtp_sender}";
    $body[] = "Subject: {$Subject}";
    $body[] = "To: {$mmstp->recipient}";
    $body[] = "";
    $body[] = "";
    $body[] = @implode("\r\n", $array);
    $body[] = "";
    $body[] = "";
    $finalbody = @implode("\r\n", $body);
    if (!$mmstp->Send($finalbody)) {
        squid_admin_mysql(0, "Unable to send notification {$Subject} to {$mmstp->recipient}", "{$Subject} to {$mmstp->recipient}\n------------------\n" . @implode("\n", $array) . "\n\t\tThe following error encountered\n" . $mmstp->logs . "\n", __FILE__, __LINE__);
    }
}
コード例 #10
0
ファイル: exec.HugePages.php プロジェクト: BillTheBest/1.6.x
function build()
{
    $sock = new sockets();
    $unix = new unix();
    $sysctl = $unix->find_program("sysctl");
    $echo = $unix->find_program("echo");
    $HugePages = $sock->GET_INFO("HugePages");
    $KernelShmmax = $sock->GET_INFO("KernelShmmax");
    $meminfo = MemInfo();
    $HUGEPAGESIZE = intval($meminfo["HUGEPAGESIZE"]);
    $HUGEPAGESIZEBytes = $HUGEPAGESIZE;
    if (!is_numeric($HugePages)) {
        $HugePages = 0;
    }
    if (!is_numeric($KernelShmmax)) {
        $KernelShmmax = 0;
    }
    if ($HugePages > 0) {
        $HugePagesB = $HugePages * 1024;
        $HugePagesB = $HugePagesB * 1024;
        $HugePagesF = $HugePagesB / $HUGEPAGESIZEBytes;
        echo "HUGEPAGESIZE = {$HUGEPAGESIZE} ({$HUGEPAGESIZEBytes} bytes) " . FormatBytes($HUGEPAGESIZEBytes / 1024) . "\n";
        echo "HugePages = {$HugePages} Mb ({$HugePagesB} bytes)\n";
        echo "HugePages Final = {$HugePagesF} " . FormatBytes($HugePagesF / 1024) . " \n";
        $unix->sysctl("vm.nr_hugepages", $HugePagesF);
        shell_exec("{$sysctl} -w vm.nr_hugepages={$HugePagesF}");
        for ($i = 0; $i < 10; $i++) {
            shell_exec("{$echo} {$HugePagesF} > /proc/sys/vm/nr_hugepages");
            sleep(1);
        }
    }
    // sysctl
}
コード例 #11
0
function ParseAllcontacts()
{
    $unix = new unix();
    $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
    $pidtime = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".time";
    $pid = @file_get_contents($pidfile);
    if ($unix->process_exists($pid)) {
        return;
    }
    @file_put_contents($pidfile, getmypid());
    if ($unix->file_time_min($pidtime) < 120) {
        return;
    }
    @file_put_contents($pidtime, time());
    $ldap = new clladp();
    $suffix = $ldap->suffix;
    $arr = array("uid");
    $sr = @ldap_search($ldap->ldap_connection, "dc=organizations,{$suffix}", '(objectclass=userAccount)', $arr);
    if ($sr) {
        $hash = ldap_get_entries($ldap->ldap_connection, $sr);
        for ($i = 0; $i < $hash["count"]; $i++) {
            ParseContacts($hash[$i]["uid"][0]);
            if (system_is_overloaded(dirname(__FILE__))) {
                $unix->send_email_events(basename(__FILE__) . " Overloaded aborting task", "Zarafa contacts importation has been canceled due to overloaded system", "mailbox");
                return;
            }
            sleep(1);
        }
    }
}
コード例 #12
0
function export_to_zarafa($uid)
{
    $f[] = "First Name,Middle Name,Last Name,Title,Suffix,Initials,Web Page,Gender,Birthday,Anniversary,Location,Language,Internet Free Busy,Notes,E-mail Address,E-mail 2 Address,E-mail 3 Address,Primary Phone,Home Phone,Home Phone 2,Mobile Phone,Pager,Home Fax,Home Address,Home Street,Home Street 2,Home Street 3,Home Address PO Box,Home City,Home State,Home Postal Code,Home Country,Spouse,Children,Manager's Name,Assistant's Name,Referred By,Company Main Phone,Business Phone,Business Phone 2,Business Fax,Assistant's Phone,Company,Job Title,Department,Office Location,Organizational ID Number,Profession,Account,Business Address,Business Street,Business Street 2,Business Street 3,Business Address PO Box,Business City,Business State,Business Postal Code,Business Country,Other Phone,Other Fax,Other Address,Other Street,Other Street 2,Other Street 3,Other Address PO Box,Other City,Other State,Other Postal Code,Other Country,Callback,Car Phone,ISDN,Radio Phone,TTY/TDD Phone,Telex,User 1,User 2,User 3,User 4,Keywords,Mileage,Hobby,Billing Information,Directory Server,Sensitivity,Priority,Private,Categories";
    $ldap = new clladp();
    $ct = new user($uid);
    $dn = "ou={$uid},ou=People,dc={$ct->ou},dc=NAB,{$ldap->suffix}";
    $filter = "(objectClass=inetOrgPerson)";
    $attrs = array();
    $hash = $ldap->Ldap_search($dn, $filter, array("employeeNumber"));
    if ($GLOBALS["VERBOSE"]) {
        echo "[{$uid}]: Exporting {$hash["count"]} user(s)\n";
    }
    for ($i = 0; $i < $hash["count"]; $i++) {
        $emp = new contacts(null, $hash[$i]["employeenumber"][0]);
        $f[] = @implode(",", $emp->ContactTocsvArray());
    }
    $tmpfile = "/tmp/{$uid}." . time() . ".csv";
    @file_put_contents("{$tmpfile}", @implode("\n", $f));
    $unix = new unix();
    $php = $unix->LOCATE_PHP5_BIN();
    $basename = basename($tmpfile);
    $cmd = $php . " " . dirname(__FILE__) . "/exec.zarafa.csv2contacts.php {$uid} \"{$ct->password}\" {$basename} 2>&1";
    if ($GLOBALS["VERBOSE"]) {
        echo "[{$uid}]: {$cmd}\n";
    }
    exec($cmd, $results);
    if ($GLOBALS["VERBOSE"]) {
        while (list($num, $line) = each($results)) {
            echo "[{$uid}]: {$line}\n";
        }
    }
}
コード例 #13
0
ファイル: milter-greylist.php プロジェクト: BillTheBest/1.6.x
function database_empty()
{
    $hostname = $_GET["hostname"];
    if ($hostname == null) {
        $hostname = "master";
    }
    if ($hostname == "master") {
        $d[] = "/var/milter-greylist/greylist.db";
        $d[] = "/usr/share/artica-postfix/ressources/logs/mgrelist-db.inc";
    }
    if ($hostname != "master") {
        $d[] = "/var/milter-greylist/{$hostname}/greylist.db";
        $d[] = "/usr/share/artica-postfix/ressources/logs/mgrelist-{$_GET["hostname"]}.inc";
    }
    $d[] = "/usr/share/artica-postfix/ressources/logs/greylist-count-{$hostname}.tot";
    $d[] = "/usr/share/artica-postfix/ressources/logs/mgrelist-{$hostname}.inc";
    while (list($num, $line) = each($d)) {
        if (is_file($line)) {
            @unlink($line);
        }
    }
    $unix = new unix();
    $nohup = $unix->find_program("nohup");
    shell_exec("{$nohup} /etc/init.d/milter-greylist restart >/dev/null 2>&1 &");
}
コード例 #14
0
function patchbin()
{
    $unix = new unix();
    $sabnzbdplus = $unix->find_program("sabnzbdplus");
    if (strlen($sabnzbdplus) < 5) {
        echo "Starting......: sabnzbdplus sabnzbdplus no such file\n";
        return;
    }
    echo "Starting......: sabnzbdplus {$sabnzbdplus}\n";
    $f = explode("\n", @file_get_contents($sabnzbdplus));
    while (list($index, $line) = each($f)) {
        if (preg_match("#^import sys#", $line)) {
            $nextline = $f[$index + 1];
            echo "Starting......: sabnzbdplus line {$index}\n";
            if (preg_match("#sys\\.path.insert\\(0#", $nextline)) {
                echo "Starting......: sabnzbdplus Patched OK\n";
                return;
            } else {
                echo "Starting......: sabnzbdplus patching line {$index}\n";
                $f[$index] = "import sys\nsys.path.insert(0,'/usr/share/sabnzbdplus')";
                @file_put_contents($sabnzbdplus, @implode("\n", $f));
                return;
            }
        }
    }
}
コード例 #15
0
ファイル: fstab-cmd.php プロジェクト: brucewu16899/artica
function fstabmount()
{
    $unix = new unix();
    $fstabmount = $_GET["fstabmount"];
    $dev = $unix->FSTAB_GETDEV($fstabmount);
    if ($dev != null) {
        $ext = $unix->DISK_GET_TYPE($dev);
    }
    if ($ext == null) {
        $ext = "auto";
    }
    if (!is_dir($fstabmount)) {
        @mkdir($fstabmount);
    }
    $tmp = $unix->FILE_TEMP();
    if ($ext == "ext4") {
        $kernel = $unix->KERNEL_VERSION_BIN();
        error_log("framework::" . __FUNCTION__ . " kernel: {$kernel}");
        if ($kernel < 20629) {
            $ext = "ext4dev";
        }
    }
    $cmd = "/bin/mount -t {$ext} {$dev} {$fstabmount} >{$tmp} 2>&1";
    error_log("framework::" . __FUNCTION__ . " {$cmd}");
    shell_exec("/bin/mount -t {$ext} {$dev} {$fstabmount} >{$tmp} 2>&1");
    $results = @file_get_contents($tmp);
    @unlink($tmp);
    error_log("framework::" . __FUNCTION__ . " mount point is \"{$dev}\" ({$ext})={$results} line " . __LINE__);
    if (strlen($results) > 0) {
        echo "<articadatascgi>{$results}</articadatascgi>";
    }
}
コード例 #16
0
function ReloadMacHelpers($output = false)
{
    @mkdir("/var/log/squid/reload", 0755, true);
    $unix = new unix();
    $pgrep = $unix->find_program("pgrep");
    $rm = $unix->find_program("rm");
    shell_exec("{$rm} /var/log/squid/reload/*.ufdbgclient.php");
    if (is_file("/var/log/squid/UfdbguardCache.db")) {
        @unlink("/var/log/squid/UfdbguardCache.db");
    }
    exec("{$pgrep} -l -f \"ufdbgclient.php\" 2>&1", $results);
    while (list($index, $ligne) = each($results)) {
        if (preg_match("#pgrep#", $ligne)) {
            continue;
        }
        if (!preg_match("#^([0-9]+)\\s+#", $ligne, $re)) {
            continue;
        }
        $PIDS[] = $re[1];
        echo "Starting......: " . date("H:i:s") . " [INIT]: Webfilter client reloading PID {$re[1]}\n";
        @touch("/var/log/squid/reload/{$re[1]}.ufdbgclient.php");
        @chown("/var/log/squid/reload/{$re[1]}.ufdbgclient.php", "squid");
        @chgrp("/var/log/squid/reload/{$re[1]}.ufdbgclient.php", "squid");
    }
    squid_admin_mysql(2, count($PIDS) . " Artica helper(s) was reloaded", null, __FILE__, __LINE__);
}
コード例 #17
0
function xstart()
{
    $unix = new unix();
    $php = $unix->LOCATE_PHP5_BIN();
    $tar = $unix->find_program("tar");
    build_progress("{downloading} roundcubeemail-1.1.2.tar.gz", 20);
    $tmpfile = $unix->FILE_TEMP();
    $curl = new ccurl("http://articatech.net/download/postfix-debian7/roundcubeemail-1.1.2.tar.gz");
    if (!$curl->GetFile($tmpfile)) {
        echo "Failed: " . $curl->error . "\n";
        @unlink($tmpfile);
        build_progress("{failed} roundcubeemail-1.1.2.tar.gz", 110);
        return;
    }
    build_progress("{uncompressing} roundcubeemail-1.1.2.tar.gz", 50);
    system("{$tar} xf {$tmpfile} -C /");
    @unlink($tmpfile);
    if (!is_file("/usr/share/roundcube/index.php")) {
        build_progress("{uncompressing} roundcubeemail-1.1.2.tar.gz {failed}", 110);
        return;
    }
    build_progress("{verify_database}", 60);
    system("{$php} /usr/share/artica-postfix/exec.roundcube.php --database");
    build_progress("{restarting_service}", 70);
    system("{$php} /usr/share/artica-postfix/exec.roundcube.php --restart");
    system("/etc/init.d/artica-status restart");
    build_progress("{installing} roundcubeemail-1.1.2.tar.gz {success}", 100);
}
コード例 #18
0
function start()
{
    $unix = new unix();
    $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
    $pid = $unix->get_pid_from_file($pidfile);
    if ($unix->process_exists($pid, basename(__FILE__))) {
        $time = $unix->PROCCESS_TIME_MIN($pid);
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} Already Artica task running PID {$pid} since {$time}mn\n";
        }
        return;
    }
    @file_put_contents($pidfile, getmypid());
    $PID = GET_PID();
    if ($unix->process_exists($PID)) {
        squid_admin_mysql(1, "Watchdog says that rsyslog is off, but exists [action=stamp-pid]", null, __FILE__, __LINE__);
        $SrcPid = intval(@file_get_contents("/var/run/rsyslogd.pid"));
        if ($SrcPid != $PID) {
            squid_admin_mysql(2, "Watchdog says that rsyslog is off (PID:{$SrcPid}), but exists (PID:{$PID}) [action=stamp-pid]", null, __FILE__, __LINE__);
            @file_put_contents("/var/run/rsyslogd.pid", $PID);
        } else {
            squid_admin_mysql(2, "Watchdog says that rsyslog is off (PID:{$SrcPid}), but exists [action=nothing]", null, __FILE__, __LINE__);
        }
        @unlink($pidfile);
        die(1);
    }
    squid_admin_mysql(0, "Syslog daemon is down [action=start]", null, __FILE__, __LINE__);
    system("/etc/init.d/rsyslog start");
    $squid = $unix->LOCATE_SQUID_BIN();
    if (is_file($squid)) {
        sleep(3);
        squid_admin_mysql(1, "Reloading proxy service after starting syslog daemon", null, __FILE__, __LINE__);
        system("{$squid} -f /etc/squid3/squid.conf -k reconfigure");
    }
}
コード例 #19
0
ファイル: exec.raccon.php プロジェクト: BillTheBest/1.6.x
function getlongkey()
{
    $sock = new sockets();
    $RacconKey = $sock->GET_INFO("RacconKey");
    if ($sock->GET_INFO("RacconKey") != null) {
        return $RacconKey;
    }
    $unix = new unix();
    $xxd_bin = $unix->find_program("xxd");
    $dd_bin = $unix->find_program("dd");
    $cmd = "{$dd_bin} if=/dev/random count=24 bs=1|{$xxd_bin} -ps 2>&1";
    if ($GLOBALS["VERBOSE"]) {
        echo "{$cmd}\n";
    }
    exec($cmd, $results);
    while (list($num, $ligne) = each($results)) {
        if (preg_match("#\\s+[a-z]+#", trim($ligne))) {
            if ($GLOBALS["VERBOSE"]) {
                echo "skipped \"{$ligne}\" -> \\s+[a-z]+\n";
            }
            continue;
        }
        if (strlen(trim($ligne)) < 48) {
            if ($GLOBALS["VERBOSE"]) {
                echo "skipped \"" . strlen(trim($ligne)) . "\" length+\n";
            }
            continue;
        }
        $key = trim($ligne);
    }
    $sock->SET_INFO("RacconKey", $key);
    return $key;
}
コード例 #20
0
function BuildDHCP()
{
    $ldap = new clladp();
    if ($ldap->ldapFailed) {
        echo "Starting......: DHCP SERVER ldap connection failed,aborting\n";
        return;
    }
    if (!$ldap->ExistsDN("dc=organizations,{$ldap->suffix}")) {
        echo "Starting......: DHCP SERVER dc=organizations,{$ldap->suffix} no such branch, aborting\n";
        return;
    }
    echo "Starting......: DHCP SERVER ldap connection success\n";
    $dhcpd = new dhcpd();
    $conf = $dhcpd->BuildConf();
    $confpath = dhcp3Config();
    $unix = new unix();
    @mkdir(dirname($confpath), null, true);
    @file_put_contents($confpath, $conf);
    echo "Starting......: DHCP SERVER saving \"{$confpath}\" (" . strlen($conf) . " bytes) done\n";
    if (is_dir("/var/lib/dhcp3")) {
        shell_exec("/bin/chown -R dhcpd:dhcpd /var/lib/dhcp3");
        shell_exec("/bin/chmod 755 /var/lib/dhcp3");
    }
    $complain = $unix->find_program("aa-complain");
    if (is_file($complain)) {
        $dhcpd3 = $unix->find_program("dhcpd3");
        if (is_file($dhcpd3)) {
            shell_exec("{$complain} {$dhcpd3} >/dev/null 2>&1");
        }
    }
}
コード例 #21
0
function schedules()
{
    $unix = new unix();
    $files = $unix->DirFiles("/etc/cron.d");
    $cron = new cron_macros();
    $php5 = $unix->LOCATE_PHP5_BIN();
    while (list($index, $line) = each($files)) {
        if ($index == null) {
            continue;
        }
        if (preg_match("#^LdapImport-#", $index)) {
            @unlink("/etc/cron.d/{$index}");
        }
    }
    $sql = "SELECT * FROM ldap_ou_import WHERE enabled=1";
    $q = new mysql();
    $results = $q->QUERY_SQL($sql, "artica_backup");
    while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) {
        if (trim($ligne["ScheduleMin"] == null)) {
            continue;
        }
        $schedule = $cron->cron_defined_macros[$ligne["ScheduleMin"]];
        $f[] = "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/X11R6/bin:/usr/share/artica-postfix/bin";
        $f[] = "MAILTO=\"\"";
        $f[] = "{$schedule}  root {$php5} " . __FILE__ . " --import {$ligne["ID"]} >/dev/null 2>&1";
        $f[] = "";
        @file_put_contents("/etc/cron.d/LdapImport-{$ligne["ID"]}", implode("\n", $f));
        @chmod("/etc/cron.d/LdapImport-{$ligne["ID"]}", 600);
        unset($f);
    }
}
コード例 #22
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}");
}
コード例 #23
0
function reset2()
{
    system("clear");
    echo "Remove databases\n";
    $q = new mysql();
    echo "Remove database settings\n";
    $q->DELETE_DATABASE("artica_backup");
    echo "Remove database events\n";
    $q->DELETE_DATABASE("artica_events");
    echo "Remove database Proxy\n";
    $q = new mysql_squid_builder();
    $q->QUERY_SQL("DROP DATABASE `squidlogs`");
    echo "Remove Artica settings Proxy\n";
    $unix = new unix();
    $files = $unix->DirFiles("/etc/artica-postfix/settings/Daemons");
    while (list($filename, $value) = each($files)) {
        $fulename = "/etc/artica-postfix/settings/Daemons/{$filename}";
        echo "Removing {$filename}\n";
        @unlink($fulename);
    }
    @file_put_contents("/root/build/etc/artica-postfix/settings/Daemons/ProxyUseArticaDB", 1);
    @file_put_contents("/root/build/etc/artica-postfix/settings/Daemons/StatsPerfsSquidAnswered", 1);
    @file_put_contents("/root/build/etc/artica-postfix/settings/Daemons/CacheManagement2", 1);
    @file_put_contents("/root/build/etc/artica-postfix/settings/Daemons/EnablePHPFPM", 0);
    @file_put_contents("/root/build/etc/artica-postfix/settings/Daemons/EnableArticaFrontEndToNGninx", 0);
    @file_put_contents("/root/build/etc/artica-postfix/settings/Daemons/EnableArticaFrontEndToApache", 1);
    @file_put_contents("/root/build/etc/artica-postfix/settings/Daemons/EnableNginx", 0);
    echo "Restarting Web Console...\n";
    system('/etc/init.d/artica-webconsole restart');
    system("clear");
    echo "All data has been erased..\n";
    echo "Type Enter key to exit\n";
    $answer = trim(strtolower(fgets(STDIN)));
    die;
}
コード例 #24
0
function purge()
{
    $unix = new unix();
    $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
    $pidtime = "/etc/artica-postfix/pids/exec.suricata.hourly.purge.time";
    $pid = $unix->get_pid_from_file($pidfile);
    if ($unix->process_exists($pid, basename(__FILE__))) {
        $time = $unix->PROCCESS_TIME_MIN($pid);
        echo "Starting......: " . date("H:i:s") . " [INIT]: Already Artica task running PID {$pid} since {$time}mn\n";
        return;
    }
    @file_put_contents($pidfile, getmypid());
    if (system_is_overloaded()) {
        return;
    }
    $timeExec = $unix->file_time_min($pidtime);
    if ($timeExec < 1440) {
        return;
    }
    @unlink($pidtime);
    @file_put_contents($pidtime, time());
    $q = new postgres_sql();
    $sock = new sockets();
    $SuricataPurge = intval($sock->GET_INFO("SuricataPurge"));
    if ($SuricataPurge == 0) {
        $SuricataPurge = 15;
    }
    $q->QUERY_SQL("DELETE FROM suricata_events WHERE zdate < NOW() - INTERVAL '{$SuricataPurge} days'");
}
コード例 #25
0
ファイル: exec.cas-server.php プロジェクト: BillTheBest/1.6.x
function build()
{
    $webappFile = null;
    $tomcatDir = "/var/lib/tomcat6/webapps";
    if (!is_dir($tomcatDir)) {
        echo "Starting......: " . date("H:i:s") . " C.A.S server failed `{$tomcatDir}` no such directory...\n";
        return;
    }
    $unix = new unix();
    $dirfiles = $unix->DirFiles("/usr/share/cas-server/modules", "cas-server-webapp-.*?\\.war");
    echo "Starting......: " . date("H:i:s") . " C.A.S server checking libraries...\n";
    echo "Starting......: " . date("H:i:s") . " C.A.S server TomCat webapps `{$tomcatDir}`\n";
    while (list($num, $line) = each($dirfiles)) {
        $webappFile = "/usr/share/cas-server/modules/{$num}";
    }
    if ($webappFile == null) {
        echo "Starting......: " . date("H:i:s") . " C.A.S server failed to retrive cas-server-webapp war file\n";
        return;
    }
    if (is_file("{$tomcatDir}/cas.war")) {
        @unlink("{$tomcatDir}/cas.war");
    }
    echo "Starting......: " . date("H:i:s") . " C.A.S server installing {$webappFile} into {$tomcatDir}..\n";
    @link($webappFile, "{$tomcatDir}/cas.war");
    writesettings();
    maven2();
    tomcat_config();
    log4jxml();
    if (is_file("/etc/init.d/tomcat6")) {
        echo "Starting......: " . date("H:i:s") . " C.A.S server restarting tomcat server...\n";
        shell_exec("/etc/init.d/tomcat6 restart >/dev/null 2>&1");
    }
    WEB_INF_deployerConfigContext();
    log4jxml();
}
コード例 #26
0
ファイル: exec.AutoFS.php プロジェクト: BillTheBest/1.6.x
function Checks()
{
    $GLOBALS["NORELOAD"] = true;
    $unix = new unix();
    if (!is_file("/usr/lib/x86_64-linux-gnu/autofs/lookup_ldap.so")) {
        build_progress_rs("{install} autofs-ldap", 15);
        $unix->DEBIAN_INSTALL_PACKAGE("autofs-ldap");
    }
    if (!is_file("/usr/lib/x86_64-linux-gnu/autofs/lookup_ldap.so")) {
        build_progress_rs("{install} autofs-ldap {failed}", 110);
        return;
    }
    if (!$unix->is_socket("/var/run/slapd/slapd.sock")) {
        build_progress_rs("{restarting_service} OpenLDAP", 15);
        system("/etc/init.d/slapd restart");
    } else {
        if ($GLOBALS["PROGRESS"]) {
            build_progress_rs("{restarting_service} OpenLDAP", 15);
            system("/etc/init.d/slapd restart");
        }
    }
    $curlftpfs = $unix->find_program("curlftpfs");
    $fusermount = $unix->find_program("fusermount");
    if (is_file($curlftpfs)) {
        if (!is_file("/sbin/mount.curl")) {
            build_progress_rs("/sbin/mount.curl", 15);
            $curlftpfsZ[] = "#! /bin/sh";
            $curlftpfsZ[] = "{$curlftpfs} \$1 \$2 -o \$5,disable_eprt";
            $curlftpfsZ[] = "";
            @file_put_contents("/sbin/mount.curl", @implode("\n", $curlftpfsZ));
            @chmod("/sbin/mount.curl", 0755);
        }
        if (!is_file("/sbin/umount.curl")) {
            build_progress_rs("/sbin/umount.curl", 15);
            $curlftpfsZ = array();
            $curlftpfsZ[] = "#! /bin/sh";
            $curlftpfsZ[] = "{$fusermount} -u \$1";
            $curlftpfsZ[] = "";
            @file_put_contents("/sbin/umount.curl", @implode("\n", $curlftpfsZ));
            @chmod("/sbin/umount.curl", 0755);
        }
    }
    $ldap = new clladp();
    $data = "<?xml version=\"1.0\" ?>\n         <autofs_ldap_sasl_conf\n                 usetls=\"no\"\n                 tlsrequired=\"no\"\n                 authrequired=\"yes\"\n                 authtype=\"PLAIN\"\n                 user=\"{$ldap->ldap_admin}\"\n                 secret=\"{$ldap->ldap_password}\"\n         />";
    @file_put_contents("/etc/autofs_ldap_auth.conf", $data);
    if (is_file("/etc/autofs_ldap_auth.conf")) {
        @chmod("/etc/autofs_ldap_auth.conf", 0600);
        @chown("/etc/autofs_ldap_auth.conf", "root");
        @chgrp("/etc/autofs_ldap_auth.conf", "root");
    }
    build_progress_rs("{checking_configuration}", 15);
    $auto = new autofs();
    build_progress_rs("{checking_configuration}", 20);
    autofs_default();
    build_progress_rs("{checking_configuration}", 25);
    Autocount();
    build_progress_rs("{checking_configuration}", 30);
    davfs();
}
コード例 #27
0
ファイル: exec.iptables.php プロジェクト: BillTheBest/1.6.x
function iprulesDNS()
{
    $unix = new unix();
    $IPCHAIN = "dnsfilter";
    $pidfile = "/etc/artica-postfix/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
    if ($unix->process_exists(@file_get_contents($pidfile), basename(__FILE__))) {
        echo "Starting......: " . date("H:i:s") . " iptables configurator already executed PID " . @file_get_contents($pidfile) . "\n";
        die;
    }
    $pid = getmypid();
    file_put_contents($pidfile, $pid);
    $sock = new sockets();
    $EnableIptablesDNS = $sock->GET_INFO("EnableIptablesDNS");
    if (!is_numeric($EnableIptablesDNS)) {
        $EnableIptablesDNS = 1;
    }
    if ($EnableIptablesDNS == 0) {
        $ip = new iptables_exec();
        if ($ip->is_chain_exists($IPCHAIN)) {
            shell_exec("{$GLOBALS["iptables"]} -F {$IPCHAIN}");
            shell_exec("{$GLOBALS["iptables"]} -X {$IPCHAIN}");
        }
        return;
    }
    $tmpfile = $unix->FILE_TEMP();
    $curl = new ccurl("https://raw.github.com/smurfmonitor/dns-iptables-rules/master/domain-blacklist.txt");
    $curl->NoHTTP_POST = true;
    if ($curl->GetFile($tmpfile)) {
        $size = @filesize($tmpfile);
        if ($size < 100) {
            $tmpfile = "/usr/share/artica-postfix/bin/install/iptables_defaults.txt";
        }
    }
    $ip = new iptables_exec();
    if (!$ip->is_chain_exists($IPCHAIN)) {
        echo "Adding chain {$IPCHAIN}\n";
        shell_exec("{$GLOBALS["iptables"]} -N {$IPCHAIN}");
        shell_exec("{$GLOBALS["iptables"]} -I INPUT -p udp --dport 53 -j {$IPCHAIN}");
    } else {
        echo "chain {$IPCHAIN} exists...\n";
    }
    shell_exec("{$GLOBALS["iptables"]} -F {$IPCHAIN}");
    shell_exec("{$GLOBALS["iptables"]} -A {$IPCHAIN} -j RETURN");
    $f = explode("\n", @file_get_contents($tmpfile));
    while (list($num, $ligne) = each($f)) {
        $ligne = trim($ligne);
        if ($ligne == null) {
            continue;
        }
        $ligne = str_replace("INPUT", $IPCHAIN, $ligne);
        $ligne = str_replace("iptables", $GLOBALS["iptables"], $ligne);
        $results = array();
        exec($ligne, $results);
        echo "{$ligne}\n";
        while (list($a, $b) = each($results)) {
            echo "{$b}\n";
        }
    }
}
コード例 #28
0
function start_parse()
{
    if ($GLOBALS["VERBOSE"]) {
        "echo Loading...\n";
    }
    $unix = new unix();
    if ($GLOBALS["VERBOSE"]) {
        "echo Loading done...\n";
    }
    $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
    $timefile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".time";
    $pid = @file_get_contents($pidfile);
    if (!$GLOBALS["FORCE"]) {
        if ($pid < 100) {
            $pid = null;
        }
        $unix = new unix();
        if ($unix->process_exists($pid, basename(__FILE__))) {
            if ($GLOBALS["VERBOSE"]) {
                echo "Already executed pid {$pid}\n";
            }
            return;
        }
        $timeexec = $unix->file_time_min($timefile);
        if ($timeexec < 10) {
            return;
        }
        $mypid = getmypid();
        @file_put_contents($pidfile, $mypid);
    }
    @unlink($timefile);
    @file_put_contents($timefile, time());
    $ldap = new clladp();
    if (!$ldap->IsKerbAuth()) {
        return;
    }
    $q = new mysql_squid_builder();
    $sql = "SELECT ID,GroupName FROM webfilters_sqgroups WHERE `enabled`=1 AND `GroupType`='proxy_auth_statad'";
    $results = $q->QUERY_SQL($sql);
    $REFRESH = false;
    $Count = mysql_num_rows($results);
    $UPDATED = array();
    while ($ligne = mysql_fetch_assoc($results)) {
        if (parse_object($ligne["ID"], $ligne["GroupName"])) {
            $UPDATED[] = $ligne["GroupName"];
            $REFRESH = true;
        }
    }
    if ($REFRESH) {
        squid_admin_mysql(1, "Reloading proxy service after updating " . count($UPDATED) . " Active Directory group(s)", @implode("\n", $UPDATED), __FILE__, __LINE__);
        $squid = $unix->LOCATE_SQUID_BIN();
        system("/etc/init.d/squid reload --force --script=exec.squid.static.ad.groups.php/" . __LINE__);
        $sock = new sockets();
        $EnableTransparent27 = intval($sock->GET_INFO("EnableTransparent27"));
        if ($EnableTransparent27 == 1) {
            system("/etc/init.d/squid-nat reload --script=" . basename(__FILE__));
        }
    }
}
コード例 #29
0
ファイル: rdpproxy.php プロジェクト: BillTheBest/1.6.x
function restart_auth()
{
    $unix = new unix();
    $nohup = null;
    $php5 = $unix->LOCATE_PHP5_BIN();
    shell_exec("{$php5} /usr/share/artica-postfix/exec.initslapd.php --rdpproxy >/dev/null");
    shell_exec("{$nohup} /etc/init.d/rdpproxy-authhook restart >/dev/null 2>&1 &");
}
コード例 #30
0
ファイル: dnsmasq.php プロジェクト: brucewu16899/1.6.x
function remove_dhcp_role()
{
    $eth = $_GET["eth"];
    $unix = new unix();
    $nohup = $unix->find_program("nohup");
    $php = $unix->LOCATE_PHP5_BIN();
    shell_exec("{$php} /usr/share/artica-postfix/exec.dnsmasq.php --remove-service {$eth}");
}