当前位置: 首页>>代码示例>>PHP>>正文


PHP unix::TEMP_DIR方法代码示例

本文整理汇总了PHP中unix::TEMP_DIR方法的典型用法代码示例。如果您正苦于以下问题:PHP unix::TEMP_DIR方法的具体用法?PHP unix::TEMP_DIR怎么用?PHP unix::TEMP_DIR使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在unix的用法示例。


在下文中一共展示了unix::TEMP_DIR方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: install

function install($filename)
{
    $GLOBALS["PROGRESS_FILE"] = "/usr/share/artica-postfix/ressources/logs/squid.install.progress";
    $GLOBALS["LOG_FILE"] = "/usr/share/artica-postfix/ressources/logs/web/squid.install.progress.txt";
    $unix = new unix();
    $LINUX_CODE_NAME = $unix->LINUX_CODE_NAME();
    $LINUX_DISTRIBUTION = $unix->LINUX_DISTRIBUTION();
    $LINUX_VERS = $unix->LINUX_VERS();
    $LINUX_ARCHITECTURE = $unix->LINUX_ARCHITECTURE();
    $APACHEUSER = $unix->APACHE_SRC_ACCOUNT();
    $DebianVer = "debian{$LINUX_VERS[0]}";
    $TMP_DIR = $unix->TEMP_DIR();
    $ORGV = @file_get_contents("/usr/share/artica-postfix/VERSION");
    $PATCH_VER = null;
    $tarballs_file = "/usr/share/artica-postfix/ressources/conf/upload/{$filename}";
    echo "Package {$tarballs_file}\n";
    $size = filesize($tarballs_file);
    echo "Size....................: " . FormatBytes($size / 1024) . "\n";
    build_progress("Analyze...", 10);
    echo "Current system..........: {$LINUX_CODE_NAME} {$LINUX_DISTRIBUTION} {$LINUX_VERS[0]}/{$LINUX_VERS[1]} {$LINUX_ARCHITECTURE}\n";
    echo "Package.................: {$filename}\n";
    echo "Temp dir................: {$TMP_DIR}\n";
    if (!is_file($tarballs_file)) {
        echo "{$tarballs_file} no such file...\n";
        build_progress("No such file...", 110);
        return;
    }
    echo "Uncompressing {$tarballs_file}...\n";
    build_progress("{extracting} {$filename}...", 20);
    $chown = $unix->find_program("chown");
    $chmod = $unix->find_program("chmod");
    $tar = $unix->find_program("tar");
    $rm = $unix->find_program("rm");
    $nohup = $unix->find_program("nohup");
    $php = $unix->LOCATE_PHP5_BIN();
    $squid = $unix->LOCATE_SQUID_BIN();
    build_progress("{extracting} {$filename}...", 50);
    system("{$tar} xf {$tarballs_file} -C /");
    echo "Removing {$tarballs_file}...\n";
    @unlink($tarballs_file);
    shell_exec("{$rm} -rf /usr/share/artica-postfix/ressources/conf/upload/*");
    @unlink(dirname(__FILE__) . "/ressources/logs/squid.compilation.params");
    build_progress("{restarting} Squid-cache...", 60);
    system("/etc/init.d/squid restart --force");
    build_progress("{reconfiguring} Squid-cache...", 65);
    system("{$php} /usr/share/artica-postfix/exec.squid.php --build --force");
    build_progress("{reconfiguring} {APP_UFDBGUARD}...", 70);
    system("{$php} /usr/share/artica-postfix/exec.squidguard.php --build --force");
    build_progress("{restarting} {APP_C_ICAP}...", 80);
    system("/etc/init.d/c-icap restart");
    build_progress("Refresh local versions...", 90);
    system('/usr/share/artica-postfix/bin/process1 --force --verbose --' . time());
    $squid_version = x_squid_version();
    build_progress("{success} v.{$squid_version}...", 100);
    echo "Starting......: " . date("H:i:s") . " Done you can close the screen....\n";
}
开发者ID:brucewu16899,项目名称:1.6.x,代码行数:56,代码来源:exec.squid.uncompress.php

示例2: download

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 &");
}
开发者ID:articatech,项目名称:artica,代码行数:55,代码来源:exec.wordpress.download.php

示例3: install

function install()
{
    $unix = new unix();
    $DISTRICODE = $unix->LINUX_CODE_NAME();
    $arch = $unix->LINUX_ARCHITECTURE();
    $VERS = $unix->LINUX_VERS();
    $dpkg = $unix->find_program("dpkg");
    echo "DISTRICODE:{$DISTRICODE} \n";
    if (!python_verify_modules("MySQLdb")) {
        $unix->DEBIAN_INSTALL_PACKAGE("python-mysqldb");
    }
    if (!python_verify_modules("ldap")) {
        echo "Installing python-ldap\n";
        if ($DISTRICODE == "DEBIAN") {
            if ($arch == 64) {
                if ($VERS[0] == 6) {
                    if (is_file("/usr/share/artica-postfix/bin/install/postfix/python-6-ldap-amd64.deb")) {
                        shell_exec("{$dpkg} -i --force-all /usr/share/artica-postfix/bin/install/postfix/python-6-ldap-amd64.deb");
                    }
                }
                if ($VERS[0] == 7) {
                    if (is_file("/usr/share/artica-postfix/bin/install/postfix/python-7-ldap-amd64.deb")) {
                        shell_exec("{$dpkg} -i --force-all /usr/share/artica-postfix/bin/install/postfix/python-7-ldap-amd64.deb");
                    }
                }
            }
        }
    }
    if (!python_verify_modules("ldap")) {
        $unix->DEBIAN_INSTALL_PACKAGE("python-ldap");
    }
    if (!python_verify_modules("ldap")) {
        echo "Warning, ldap/python-ldap not installed...\n";
        return;
    }
    if (!python_verify_modules("MySQLdb")) {
        echo "Warning, MySQLdb/python-mysqldb not installed...\n";
        return;
    }
    echo "MySQLdb / python-mysqldb OK\n";
    echo "LDAP / python-ldap OK\n";
    $tmpdir = $unix->TEMP_DIR() . "/iredmail";
    $tar = $unix->find_program("tar");
    $rm = $unix->find_program("rm");
    if (!is_file("/usr/share/artica-postfix/bin/install/postfix/iredapd.tar.gz")) {
        return;
    }
    @mkdir($tmpdir, 0755, true);
    shell_exec("{$tar} xf /usr/share/artica-postfix/bin/install/postfix/iredapd.tar.gz -C /");
    if (!is_file("/opt/iRedAPD/iredapd.py")) {
        return;
    }
    @chmod("/opt/iRedAPD/iredapd.py", 0755);
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:54,代码来源:exec.iredmail.install.php

示例4: update

function update()
{
    if (system_is_overloaded()) {
        return;
    }
    $unix = new unix();
    $sock = new sockets();
    $pidfile = "/etc/artica-postfix/pids/exec.ipblock.php.update.pid";
    $pidtime = "/etc/artica-postfix/pids/exec.ipblock.php.update.time";
    $pid = @file_get_contents($pidfile);
    if (!$GLOBALS["FORCE"]) {
        if ($unix->process_exists($pid)) {
            echo "Already running pid {$pid}\n";
            return;
        }
    }
    include_once dirname(__FILE__) . '/ressources/class.ccurl.inc';
    if (!is_file($pidtime)) {
        @file_put_contents($pidtime, time());
    }
    if (!$GLOBALS["FORCE"]) {
        if ($unix->file_time_min($pidtime) > 720) {
            @unlink($pidtime);
            @file_put_contents($pidtime, time());
            return;
        }
    }
    @file_put_contents($pidfile, getmypid());
    $EnableIpBlocks = intval($sock->GET_INFO("EnableIpBlocks"));
    if ($EnableIpBlocks == 0) {
        return;
    }
    $DIR_TEMP = $unix->TEMP_DIR();
    $curl = new ccurl("http://www.ipdeny.com/ipblocks/data/countries/all-zones.tar.gz");
    if (!$curl->GetFile("{$DIR_TEMP}/all-zones.tar.gz")) {
        system_admin_events(0, "Fatal, Unable to download all-zones.tar.gz from ipdeny.com", __FILE__, __LINE__);
        return;
    }
    $OldMd5 = $sock->GET_INFO("IpBlocksMD5");
    $md5File = md5_file("{$DIR_TEMP}/all-zones.tar.gz");
    if ($md5File == $OldMd5) {
        ipblocks();
        return;
    }
    $tar = $unix->find_program("tar");
    @mkdir("/home/artica/ipblocks", 0755, true);
    shell_exec("{$tar} xf {$DIR_TEMP}/all-zones.tar.gz -C  /home/artica/ipblocks/");
    if (ipblocks()) {
        $sock->SET_INFO("IpBlocksMD5", "{$md5File}");
        system_admin_events(0, "Restarting Firewall in order to refresh countries blocking");
    }
}
开发者ID:articatech,项目名称:artica,代码行数:52,代码来源:exec.ipblock.php

示例5: xinstall

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);
}
开发者ID:articatech,项目名称:artica,代码行数:46,代码来源:exec.updateutility.install.php

示例6: xstart

function xstart()
{
    $curl = new ccurl();
    $unix = new unix();
    $Pidfile = "/etc/artica-postfix/pids/exec.abuse-ch.pid";
    $PidTime = "/etc/artica-postfix/pids/exec.abuse-ch.time";
    $pid = $unix->get_pid_from_file($Pidfile);
    if ($unix->process_exists($pid, basename(__FILE__))) {
        if ($GLOBALS["VERBOSE"]) {
            echo "Aborting Task already running pid {$pid} " . __FUNCTION__ . "()\n";
        }
        return;
    }
    @file_put_contents($Pidfile, getmypid());
    if (!$GLOBALS["VERBOSE"]) {
        $time = $unix->file_time_min($PidTime);
        if ($time < 10) {
            echo "Only each 10mn\n";
            die;
        }
        @unlink($PidTime);
        @file_put_contents($PidTime, time());
    }
    $curl = new ccurl("http://articatech.net/WebfilterDBS/ransomwaretracker.txt");
    $tmpfile = $unix->TEMP_DIR();
    if (!$curl->GetFile("{$tmpfile}/ransomwaretracker.txt")) {
        squid_admin_mysql(0, "ransomwaretracker.txt unable to get index file", $curl->error, __FILE__, __LINE__);
        return;
    }
    $array = unserialize(@file_get_contents("{$tmpfile}/ransomwaretracker.txt"));
    $TIME = $array["TIME"];
    if (!isset($array["MD5"])) {
        squid_admin_mysql(0, "ransomwaretracker.txt corrupted file", $curl->error, __FILE__, __LINE__);
        return;
    }
    @unlink("{$tmpfile}/ransomwaretracker.txt");
    $CurrentMD5 = @file_get_contents("/etc/artica-postfix/settings/Daemons/ransomwaretrackerMD5");
    if ($CurrentMD5 == $array["MD5"]) {
        return;
    }
    $curl = new ccurl("http://articatech.net/WebfilterDBS/ransomwaretracker.gz");
    if (!$curl->GetFile("{$tmpfile}/ransomwaretracker.gz")) {
        squid_admin_mysql(0, "ransomwaretracker.gz unable to get pattern file", $curl->error, __FILE__, __LINE__);
        return;
    }
    if (!$unix->uncompress("{$tmpfile}/ransomwaretracker.gz", "{$tmpfile}/ransomwaretracker.db")) {
        squid_admin_mysql(0, "ransomwaretracker.gz unable to extract file", $curl->error, __FILE__, __LINE__);
        return;
    }
    $ARRAY = unserialize(@file_get_contents("{$tmpfile}/ransomwaretracker.db"));
    if (!isset($ARRAY["URIS"])) {
        squid_admin_mysql(0, "ransomwaretracker.db corrupted database", $curl->error, __FILE__, __LINE__);
        return;
    }
    if (is_file("/etc/squid3/ransomwaretracker.db")) {
        @unlink("/etc/squid3/ransomwaretracker.db");
    }
    @copy("{$tmpfile}/ransomwaretracker.db", "/etc/squid3/ransomwaretracker.db");
    if (!is_file("/etc/artica-postfix/settings/Daemons/RansomwareReloaded")) {
        squid_admin_mysql(1, "Reloading Proxy service for updating Ranswomware function", null, __FILE__, __LINE__);
        $squid = $unix->LOCATE_SQUID_BIN();
        shell_exec("{$squid} -f /etc/squid3/squid.conf -k reconfigure");
        @touch("/etc/artica-postfix/settings/Daemons/RansomwareReloaded");
    }
    squid_admin_mysql(2, "Success updating ranswomware database v{$TIME}", null, __FILE__, __LINE__);
}
开发者ID:articatech,项目名称:artica,代码行数:66,代码来源:exec.abuse-ch.php

示例7: ping

function ping()
{
    $ip = $_GET["ip"];
    $unix = new unix();
    $tmp = $unix->TEMP_DIR();
    if (trim($ip) == null) {
        return false;
    }
    $ftmp = "{$tmp}/" . md5(__FILE__);
    exec("/bin/ping -q -c 1 -s 16 -W1 -Q 0x02 {$ip} >{$ftmp} 2>&1");
    $results = explode("\n", @file_get_contents($ftmp));
    @unlink($ftmp);
    if (!is_array($results)) {
        return false;
    }
    while (list($index, $line) = each($results)) {
        if (preg_match("#[0-9]+\\s+[a-zA-Z]+\\s+[a-zA-Z]+,\\s+([0-9]+)\\s+received#", $line, $re)) {
            if ($re[1] > 0) {
                $ping_check = true;
            } else {
                $ping_check = false;
            }
        }
    }
    if ($ping_check) {
        echo "<articadatascgi>TRUE</articadatascgi>";
        return;
    }
    echo "<articadatascgi>FALSE</articadatascgi>";
}
开发者ID:articatech,项目名称:artica,代码行数:30,代码来源:cmd.php

示例8: GetIndex

function GetIndex()
{
    $WORKING_DIR = "/home/working_toulouse_databases";
    $WORKING_DOWNLOAD = "{$WORKING_DIR}/dowloads";
    $WORKING_UPLOAD = "{$WORKING_DIR}/uploads";
    @mkdir($WORKING_DOWNLOAD, 0755, true);
    @mkdir($WORKING_UPLOAD, 0755, true);
    $unix = new unix();
    $tar = $unix->find_program("tar");
    $catz = new mysql_catz();
    $tmpfile = $unix->FILE_TEMP();
    $tmpdir = $unix->TEMP_DIR();
    $rm = $unix->find_program("rm");
    $mainuri = "ftp://ftp.univ-tlse1.fr/pub/reseau/cache/squidguard_contrib";
    $EXEC_NICE = $unix->EXEC_NICE();
    $ufdbGenTable = $unix->find_program("ufdbGenTable");
    $curl = new ccurl("{$mainuri}/MD5SUM.LST");
    if (!$curl->GetFile($tmpfile)) {
        echo "Failed to download MD5SUM.LST\n";
        return;
    }
    $tr = explode("\n", @file_get_contents($tmpfile));
    while (list($index, $line) = each($tr)) {
        if (preg_match("#(.+?)\\s+(.+)#", $line, $re)) {
            $filename = trim($re[1]);
            $md5 = trim($re[2]);
            $array[$md5] = $filename;
        }
    }
    @unlink($tmpfile);
    $q = new mysql_squid_builder();
    $TLSE_CONVERTION = TLSE_CONVERTION();
    $FINAL_ARRAY = array();
    while (list($filename, $md5) = each($array)) {
        $category = str_replace(".tar.gz", "", $filename);
        if (isset($TLSE_CONVERTION[$category])) {
            $FINAL_ARRAY[$filename] = $md5;
        }
    }
    $UPDATED = 0;
    $MAIN_ARRAY = unserialize(base64_decode(@file_get_contents("{$WORKING_UPLOAD}/index.txt")));
    while (list($filename, $md5) = each($FINAL_ARRAY)) {
        $TargetFile = "{$WORKING_DOWNLOAD}/{$filename}";
        $categoryname = str_replace(".tar.gz", "", $filename);
        if ($categoryname == "adult") {
            continue;
        }
        if ($categoryname == "aggressive") {
            continue;
        }
        if ($categoryname == "agressif") {
            continue;
        }
        if ($categoryname == "redirector") {
            continue;
        }
        if ($categoryname == "ads") {
            continue;
        }
        if ($categoryname == "drogue") {
            continue;
        }
        $MyStoreMd5 = md5_file($TargetFile);
        if ($MyStoreMd5 == $md5) {
            echo "Skipping {$filename}\n";
            continue;
        }
        echo "Downloading {$filename}\n";
        $curl = new ccurl("{$mainuri}/{$filename}");
        $tmpfile = $unix->FILE_TEMP();
        if (!$curl->GetFile($tmpfile)) {
            echo "Failed {$curl->error}\n";
            @unlink($tmpfile);
            continue;
        }
        $md5_tmp = md5_file($tmpfile);
        if ($md5_tmp != $md5) {
            echo "Failed Corrupted file\n";
            @unlink($tmpfile);
            continue;
        }
        if (is_file($TargetFile)) {
            @unlink($TargetFile);
        }
        if (!@copy($tmpfile, $TargetFile)) {
            echo "Failed Copy file\n";
            @unlink($tmpfile);
            @unlink($TargetFile);
            continue;
        }
        @unlink($tmpfile);
        $MyStoreMd5 = md5_file($TargetFile);
        if ($MyStoreMd5 != $md5) {
            echo "Failed MD5 file\n";
            @unlink($TargetFile);
            continue;
        }
        @mkdir("{$WORKING_DIR}/{$categoryname}", 0755, true);
        echo "Extracting {$TargetFile}\n";
        $cmd = "{$tar} xvf {$TargetFile} -C {$WORKING_DIR}/{$categoryname}/";
//.........这里部分代码省略.........
开发者ID:articatech,项目名称:artica,代码行数:101,代码来源:exec.compile-free-ufdb.php

示例9: install

function install($filekey = 0, $OS)
{
    include_once dirname(__FILE__) . "/ressources/class.ccurl.inc";
    $unix = new unix();
    $filename = null;
    $MD5 = null;
    $DebianVersion = DebianVersion();
    if ($OS != $DebianVersion) {
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]}, influxdb Debian version incompatible!\n";
        }
        build_progress_idb("Incompatible system {$OS}<>{$DebianVersion}!", 110);
        die;
    }
    if ($filekey != 0) {
        $sock = new sockets();
        $ArticaTechNetHaProxyRepo = unserialize(base64_decode($sock->GET_INFO("ArticaTechNetHaProxyRepo")));
        $version = $ArticaTechNetHaProxyRepo[$filekey][$OS]["VERSION"];
        $filename = $ArticaTechNetHaProxyRepo[$filekey][$OS]["FILENAME"];
        $MD5 = $ArticaTechNetHaProxyRepo[$filekey][$OS]["MD5"];
        $URL = $ArticaTechNetHaProxyRepo[$filekey][$OS]["URL"];
    }
    $rmmod = $unix->find_program("rmmod");
    $depmod = $unix->find_program("depmod");
    $modprobe = $unix->find_program("modprobe");
    $ldconfig = $unix->find_program("ldconfig");
    echo "Downloading {$URL}\n";
    $curl = new ccurl($URL);
    $tmpdir = $unix->TEMP_DIR();
    $php = $unix->LOCATE_PHP5_BIN();
    build_progress_idb("{downloading}", 1);
    $curl->WriteProgress = true;
    $curl->ProgressFunction = "download_progress";
    if ($GLOBALS["OUTPUT"]) {
        echo "Starting......: " . date("H:i:s") . " [INIT]: Downloading {$filename}\n";
    }
    if (!$curl->GetFile("{$tmpdir}/{$filename}")) {
        build_progress_idb("{$curl->error}", 110);
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: {$curl->error}\n";
        }
        while (list($key, $value) = each($curl->errors)) {
            if ($GLOBALS["OUTPUT"]) {
                echo "Starting......: " . date("H:i:s") . " [INIT]: {$value}\n";
            }
        }
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]}, HaProxy unable to install....\n";
        }
        @unlink("{$tmpdir}/{$filename}");
        return;
    }
    if ($MD5 != null) {
        $DESTMD5 = md5_file("{$tmpdir}/{$filename}");
        if ($DESTMD5 != $MD5) {
            echo "{$DESTMD5}<>{$MD5}\n";
            @unlink("{$tmpdir}/{$filename}");
            build_progress_idb("{install_failed} {corrupted_package}", 110);
            return;
        }
    }
    build_progress_idb("{stopping_service}", 95);
    if (!is_file("/etc/init.d/haproxy")) {
        system("{$php} /usr/share/artica-postfix/exec.initslapd.php --haproxy");
    }
    system("/etc/init.d/firehol stop");
    system("/etc/init.d/haproxy stop");
    build_progress_idb("{extracting}", 96);
    if ($GLOBALS["OUTPUT"]) {
        echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]}, extracting....\n";
    }
    $tar = $unix->find_program("tar");
    shell_exec("{$tar} xvf {$tmpdir}/{$filename} -C /");
    build_progress_idb("{installing} 1/1", 96);
    system("{$ldconfig}");
    if ($GLOBALS["PROGRESS"]) {
        build_progress_idb("{restarting_service}", 97);
        system("{$php} /usr/share/artica-postfix/exec.status.php --haproxy >/dev/null");
        system("/etc/init.d/artica-status restart --force");
        build_progress_idb("{restarting_service} 1/2", 98);
        system("/etc/init.d/haproxy restart");
        build_progress_idb("{restarting_service} 2/2", 98);
        system("/etc/init.d/firehol restart");
    }
    build_progress_idb("{refresh_status}", 98);
    build_progress_idb("{done}", 100);
}
开发者ID:articatech,项目名称:artica,代码行数:87,代码来源:exec.haproxy.install.php

示例10: nightly

function nightly()
{
    @mkdir("/var/log/artica-postfix", 0755, true);
    $GLOBALS["MasterIndexFile"] = "/usr/share/artica-postfix/ressources/index.ini";
    $unix = new unix();
    $sock = new sockets();
    $autoinstall = true;
    $timefile = "/etc/artica-postfix/croned.1/nightly";
    $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . ".pid";
    $pid = @file_get_contents($pidfile);
    $kill = $unix->find_program("kill");
    $tmpdir = $unix->TEMP_DIR();
    $php5 = $unix->LOCATE_PHP5_BIN();
    $nohup = $unix->find_program("nohup");
    if ($unix->process_exists($pid, basename(__FILE__))) {
        $time = $unix->PROCCESS_TIME_MIN($pid);
        echo "Starting......: " . date("H:i:s") . " nightly build already executed PID: {$pid} since {$time}Mn\n";
        system_admin_events("nightly build already executed PID: {$pid} since {$time}Mn", __FUNCTION__, __FILE__, __LINE__, "artica-update");
        if ($time < 120) {
            if (!$GLOBALS["FORCE"]) {
                die;
            }
        }
        unix_system_kill_force($pid);
    }
    $mypid = getmypid();
    @file_put_contents($pidfile, $mypid);
    $EnableScheduleUpdates = $sock->GET_INFO("EnableScheduleUpdates");
    if (!is_numeric($EnableScheduleUpdates)) {
        $EnableScheduleUpdates = 0;
    }
    if ($GLOBALS["FORCE"]) {
        _artica_update_event(1, "Update task pid {$mypid} is forced by an human.", null, __FILE__, __LINE__);
    }
    if ($EnableScheduleUpdates == 1) {
        if (!$GLOBALS["FORCE"]) {
            if (!$GLOBALS["BYCRON"]) {
                _artica_update_event(2, "Operation must be only executed by scheduler ( use --force to by pass)", null, __FILE__, __LINE__);
                @file_put_contents("/usr/share/artica-postfix/download_progress", 100);
                return;
            }
        }
    }
    $ini = new iniFrameWork();
    $ini->loadFile('/etc/artica-postfix/artica-update.conf');
    if (!isset($ini->_params["AUTOUPDATE"]["enabled"])) {
        $ini->_params["AUTOUPDATE"]["enabled"] = "yes";
    }
    if (trim($ini->_params["AUTOUPDATE"]["enabled"]) == null) {
        $ini->_params["AUTOUPDATE"]["enabled"] = "yes";
    }
    if ($ini->_params["AUTOUPDATE"]["enabled"] == null) {
        $ini->_params["AUTOUPDATE"]["enabled"] = "yes";
    }
    if (trim($ini->_params["AUTOUPDATE"]["uri"]) == null) {
        $ini->_params["AUTOUPDATE"]["uri"] = "http://www.articatech.net/auto.update.php";
    }
    if ($ini->_params["AUTOUPDATE"]["enabled"] == 1) {
        $ini->_params["AUTOUPDATE"]["enabled"] = 'yes';
    }
    if (!is_numeric(trim($ini->_params["AUTOUPDATE"]["CheckEveryMinutes"]))) {
        $ini->_params["AUTOUPDATE"]["CheckEveryMinutes"] = 60;
    }
    if ($ini->_params["AUTOUPDATE"]["enabled"] != 'yes') {
        echo "Starting......: " . date("H:i:s") . " Artica Update feature is disabled (enabled = {$ini->_params["AUTOUPDATE"]["enabled"]} )\n";
        return;
    }
    $CheckEveryMinutes = $ini->_params["AUTOUPDATE"]["CheckEveryMinutes"];
    $uri = $ini->_params["AUTOUPDATE"]["uri"];
    $arrayURI = parse_url($uri);
    $MAIN_URI = "{$arrayURI["scheme"]}://{$arrayURI["host"]}";
    $MAIN_URI = str_replace("www.artica.fr", "www.articatech.net", $MAIN_URI);
    if (!$GLOBALS["FORCE"]) {
        if ($EnableScheduleUpdates == 0) {
            if ($unix->file_time_min($timefile) < $CheckEveryMinutes) {
                echo "Starting......: " . date("H:i:s") . " update feature (too short time, require {$CheckEveryMinutes}mn)\n";
                @file_put_contents("/usr/share/artica-postfix/download_progress", 100);
                return;
            }
        }
    }
    @unlink($timefile);
    @file_put_contents($timefile, time());
    if ($GLOBALS["FORCE"]) {
        if (is_file("/root/artica-latest.tgz")) {
            echo "Starting......: " . date("H:i:s") . " Installing old downloaded package\n";
            if (install_package("/root/artica-latest.tgz")) {
                return;
            }
        }
    }
    // ----------------------- LANCEMENT ------------------------------------------------------------------------------
    $EnableArticaMetaClient = intval($sock->GET_INFO("EnableArticaMetaClient"));
    if ($EnableArticaMetaClient == 1) {
        echo "Starting......: " . date("H:i:s") . " Nightly builds using Artica Meta console\n";
        system("{$nohup} {$php5} /usr/share/artica-postfix/exec.artica-meta-client.php --artica-updates >/dev/null 2>&1 &");
        die;
    }
    echo "Starting......: " . date("H:i:s") . " Nightly builds checking an official release first\n";
    if (update_release()) {
//.........这里部分代码省略.........
开发者ID:brucewu16899,项目名称:1.6.x,代码行数:101,代码来源:exec.nightly.php

示例11: compile_ufdbcat

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);
//.........这里部分代码省略.........
开发者ID:brucewu16899,项目名称:1.6.x,代码行数:101,代码来源:compile-squid34.php

示例12: start

function start($id)
{
    $GLOBALS["CACHEFILE"] = "/usr/share/artica-postfix/ressources/logs/web/mimedefang.resend.progress.{$id}";
    $id = intval($id);
    $sock = new sockets();
    $unix = new unix();
    if ($id == 0) {
        echo "ID: {$id} not supported\n";
        build_progress(110, "{failed}");
        die;
    }
    $postgres = new postgres_sql();
    $tempfile = $unix->FILE_TEMP();
    $Dirtemp = $unix->TEMP_DIR();
    $q = new postgres_sql();
    $ligne = pg_fetch_array($q->QUERY_SQL("SELECT * FROM quarmsg WHERE id='{$id}'"));
    if (!$q->ok) {
        echo "PostgreSQL Error:" . $q->mysql_error . "\n";
        build_progress(110, "PostgreSQL {failed}");
        die;
    }
    $instance = $unix->hostname_g();
    $mailfrom = $ligne["mailfrom"];
    $mailto = $ligne["mailto"];
    $msgmd5 = $ligne["msgmd5"];
    if ($mailfrom == null) {
        $mailfrom = "root@{$instance}";
    }
    echo "From: {$mailfrom}\n";
    echo "To..: {$mailto}\n";
    echo "ID..: {$msgmd5}\n";
    build_progress(20, "{$mailfrom} {to} {$mailto} ({$msgmd5})");
    $sql = "SELECT contentid FROM quardata WHERE msgmd5='{$msgmd5}'";
    $ligne = pg_fetch_array($q->QUERY_SQL($sql));
    if (!$q->ok) {
        echo "PostgreSQL Error:" . $q->mysql_error . "\n";
        build_progress(110, "PostgreSQL {failed}");
        die;
    }
    $contentid = $ligne["contentid"];
    build_progress(30, "msg id: {$contentid}");
    @mkdir($Dirtemp, 0777, true);
    @chmod($Dirtemp, 0777);
    $sql = "select lo_export({$contentid}, '{$Dirtemp}/{$msgmd5}.gz')";
    if ($GLOBALS["VERBOSE"]) {
        echo "<hr>{$sql}<br>\n";
    }
    $q->QUERY_SQL($sql);
    if (!$q->ok) {
        echo "PostgreSQL Error:" . $q->mysql_error . "\n";
        build_progress(110, "PostgreSQL {failed}");
        die;
    }
    build_progress(40, "{uncompress}");
    if (!$unix->uncompress("{$Dirtemp}/{$msgmd5}.gz", "{$Dirtemp}/{$msgmd5}.msg")) {
        @unlink("{$Dirtemp}/{$msgmd5}.gz");
        @unlink("{$Dirtemp}/{$msgmd5}.msg");
        build_progress(110, "{uncompress} {failed}");
        die;
    }
    $smtp = new smtp();
    $TargetHostname = inet_interfaces();
    if (preg_match("#all#is", $TargetHostname)) {
        $TargetHostname = "127.0.0.1";
    }
    $params["helo"] = $instance;
    $params["debug"] = true;
    $params["host"] = $TargetHostname;
    $params["bindto"] = "127.0.0.1";
    build_progress(50, "{connecting}");
    if (!$smtp->connect($params)) {
        build_progress(110, "{connect} {failed}");
        @unlink("{$Dirtemp}/{$msgmd5}.msg");
        echo "{$smtp->error_number}: Could not connect to `{$TargetHostname}` {$smtp->error_text}\n";
        return;
    }
    $finalbody = @file_get_contents("{$Dirtemp}/{$msgmd5}.msg");
    build_progress(90, "{sending}");
    if (!$smtp->send(array("from" => $mailfrom, "recipients" => $mailto, "body" => $finalbody, "headers" => null))) {
        build_progress(110, "{sending} {failed}");
        @unlink("{$Dirtemp}/{$msgmd5}.msg");
        echo "{$smtp->error_number}: Could not connect to `{$TargetHostname}` {$smtp->error_text}\n";
        $smtp->quit();
        return;
    }
    @unlink("{$Dirtemp}/{$msgmd5}.msg");
    $smtp->quit();
    build_progress(100, "{success}");
}
开发者ID:articatech,项目名称:artica,代码行数:89,代码来源:exec.mimedefang.quarantine.resend.php

示例13: snapshot


//.........这里部分代码省略.........
                    continue;
                }
                if (preg_match("#^allsizes#", $table_name)) {
                    continue;
                }
                if (preg_match("#^alluid#", $table_name)) {
                    continue;
                }
                if (preg_match("#^categorize#", $table_name)) {
                    continue;
                }
                if (preg_match("#^blocked_#", $table_name)) {
                    continue;
                }
                if (preg_match("#^sites\$#", $table_name)) {
                    continue;
                }
                if (preg_match("#^users\$#", $table_name)) {
                    continue;
                }
                if (preg_match("#^ufdbunlock\$#", $table_name)) {
                    continue;
                }
                if (preg_match("#^updateblks_events\$#", $table_name)) {
                    continue;
                }
                if (preg_match("#^main_websites#", $table_name)) {
                    continue;
                }
                if (preg_match("#^notcategorized#", $table_name)) {
                    continue;
                }
                if ($q->COUNT_ROWS($table_name, "squidlogs") == 0) {
                    $GLOBALS["TRUNCATES"]["squidlogs"][$table_name] = true;
                    continue;
                }
                progress(30, "{backup} {$table_name}");
                echo "{$BaseWorkDir}/squidlogs/{$table_name}.gz\n";
                $cmd = "{$prefix} {$table_name} | {$gzip} > {$BaseWorkDir}/squidlogs/{$table_name}.gz 2>&1";
                if ($GLOBALS["VERBOSE"]) {
                    echo "{$cmd}\n";
                }
                exec($cmd, $results);
                if ($unix->MYSQL_BIN_PARSE_ERROR($results)) {
                    echo "Failed to create snapshot\n " . @implode("\n", $results);
                    shell_exec("{$rm} -rf {$BaseWorkDir}");
                    system_admin_events("Failed to create snapshot " . @implode("\n", $results), __FUNCTION__, __FILE__, __LINE__);
                    return;
                }
                $GLOBALS["ARRAY_CONTENT"]["squidlogs/{$table_name}.gz"] = @filesize("{$BaseWorkDir}/squidlogs/{$table_name}.gz");
                $c++;
            }
        }
    }
    progress(35, "{backup} OpenDLAP server");
    backup_ldap($BaseWorkDir);
    progress(40, "{backup} Reverse Proxy");
    backup_nginx($BaseWorkDir);
    progress(45, "{backup} PowerDNS");
    backup_mysql_powerdns($BaseWorkDir);
    progress(50, "{backup} Artica settings");
    backup_artica_settings($BaseWorkDir);
    @file_put_contents("{$BaseWorkDir}/TRUNCATE_TABLES", serialize($GLOBALS["TRUNCATES"]));
    $temp = $unix->FILE_TEMP() . ".tar.gz";
    $tempdir = $unix->TEMP_DIR();
    chdir($BaseWorkDir);
    progress(60, "{compressing}");
    system("{$tar} -czf {$temp} *");
    shell_exec("{$rm} -rf {$BaseWorkDir}");
    echo "{$temp}\n";
    $q = new mysql();
    $q->CREATE_DATABASE("artica_snapshots");
    $sql = "CREATE TABLE IF NOT EXISTS `snapshots` (\n\t`ID` int(11) NOT NULL AUTO_INCREMENT,\n\t`zmd5` VARCHAR(90) NOT NULL,\n\t`size` INT UNSIGNED NOT NULL,\n\t`zDate` DATETIME NOT NULL,\n\t`snap` LONGBLOB NOT NULL,\n\t `content` TEXT NOT NULL,\n\t PRIMARY KEY (`ID`),\n\t UNIQUE KEY `zmd5` (`zmd5`),\n\t KEY `zDate` (`zDate`)\n\t) ENGINE=MyISAM";
    $q->QUERY_SQL($sql, 'artica_snapshots');
    progress(70, "{saving}");
    if ($GLOBALS["SEND_META"]) {
        $articameta = new artica_meta();
        $filemeta = $tempdir . "/snapshot.tar.gz";
        if (@copy($temp, $filemeta)) {
            if (!$articameta->SendFile($filemeta, "SNAPSHOT")) {
                $articameta->events("{$temp} unable to upload", __FUNCTION__, __FILE__, __LINE__);
            }
        } else {
            $articameta->events("{$temp} unable to copy {$temp} to {$filemeta}", __FUNCTION__, __FILE__, __LINE__);
        }
        @unlink($filemeta);
    }
    $zmd5 = md5_file($temp);
    $data = mysql_escape_string2(@file_get_contents($temp));
    $size = @filesize($temp);
    $final_array = mysql_escape_string2(serialize($GLOBALS["ARRAY_CONTENT"]));
    $q->QUERY_SQL("INSERT IGNORE INTO `snapshots` (zDate,snap,size,content,zmd5) \n\t\t\tVALUES (NOW(),'{$data}','{$size}','{$final_array}','{$zmd5}')", "artica_snapshots");
    if (!$q->ok) {
        echo "{$q->mysql_error}\n";
        progress(70, "{failed}");
    }
    @unlink($temp);
    shell_exec("{$rm} -rf /usr/share/artica-postfix/snapshots");
    progress(100, "{success}");
}
开发者ID:brucewu16899,项目名称:1.6.x,代码行数:101,代码来源:exec.backup.artica.php

示例14: WriteGnuPlot

function WriteGnuPlot($processname, $array)
{
    $unix = new unix();
    $tempdir = $unix->TEMP_DIR();
    $processname_path = str_replace(".", "-", $processname);
    $processname_path = str_replace(" ", "-", $processname_path);
    $processname_path = strtolower($processname_path);
    $countlines = count($array);
    $shellpath = "{$tempdir}/gnuplot." . md5($processname) . ".plot";
    $imagepath = "/usr/share/artica-postfix/ressources/logs/dstat.topmem.{$countlines}.{$processname_path}.png";
    $datafile = "{$tempdir}/gnuplot." . md5($processname) . ".datas";
    while (list($num, $datas) = each($array)) {
        usleep(1000);
        $line = $line . "{$datas[0]} {$datas[1]}\n";
    }
    file_put_contents($datafile, $line);
    $conf = $conf . '#!/usr/bin/gnuplot -persist' . "\n";
    $conf = $conf . 'reset' . "\n";
    $conf = $conf . "set xlabel \"time\" #font \"Helvetica,12\"\n";
    $conf = $conf . "set ylabel \"Mo\" #font \"Helvetica,12\"\n";
    $conf = $conf . 'set autoscale' . "\n";
    $conf = $conf . 'set grid' . "\n";
    $conf = $conf . 'set xdata time' . "\n";
    $conf = $conf . 'set format x "%H:%M"' . "\n";
    $conf = $conf . 'set timefmt "%d-%m %H:%M:%S"' . "\n";
    $conf = $conf . 'set term png transparent size 500,250' . "\n";
    $conf = $conf . 'set datafile commentschars "-"' . "\n";
    $conf = $conf . "set title \"{$processname}\"\n";
    $conf = $conf . "set output \"{$imagepath}\"\n";
    $conf = $conf . "plot \"{$datafile}\" using 1:3 title \"{$processname} Memory\" with lines\n";
    file_put_contents($shellpath, $conf);
    system("/bin/chmod 777 {$shellpath}");
    echo "Processing \"{$imagepath}\"\n";
    echo "Processing {$datafile}\n";
    echo "Processing {$shellpath}\n";
    sleep(1);
    system("{$shellpath}");
    if (!is_file($imagepath)) {
        echo "Fatal ERROR on {$imagepath}\n";
    }
    if (is_file($imagepath)) {
        system("/bin/chmod 755 {$imagepath}");
    }
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:44,代码来源:exec.dstat.top.php

示例15: install

function install()
{
    $unix = new unix();
    $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
    $pidTime = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".time";
    $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());
    $pidTimeEx = $unix->file_time_min($pidTime);
    if ($pidTimeEx < 60) {
        return;
    }
    @unlink($pidTime);
    @file_put_contents($pidTime, time());
    include_once dirname(__FILE__) . "/ressources/class.ccurl.inc";
    $Masterbin = "/opt/ufdbcat/bin/ufdbcatdd";
    $DebianVersion = _DebianVersion();
    $Arch = _Architecture();
    if ($Arch == 32) {
        return;
    }
    $filename = "ufdbcat-debian{$DebianVersion}-{$Arch}-1.31.tar.gz";
    $url = "http://articatech.net/download/Debian7-squid/{$filename}";
    $curl = new ccurl($url);
    $tmpfile = $unix->TEMP_DIR() . "/{$filename}";
    if (!$curl->GetFile($tmpfile)) {
        squid_admin_mysql(0, "Unable to download {$filename}", @implode("\n", $curl->errors), __FILE__, __LINE__);
        return;
    }
    $tar = $unix->find_program("tar");
    shell_exec("{$tar} xf {$tmpfile} -C /");
    if (is_file($Masterbin)) {
        squid_admin_mysql(0, "Success installing Artica Categorize Daemon", null, __FILE__, __LINE__);
        return;
    }
    $php = $unix->LOCATE_PHP5_BIN();
    shell_exec("{$php} /usr/share/artica-postfix/exec.initslapd.php --ufdbcat");
    if (!$GLOBALS["NOUPDATE"]) {
        shell_exec("{$php} /usr/share/artica-postfix/exec.squid.blacklists.php --ufdb --force --" . __FUNCTION__ . "-" . __LINE__ . " >/dev/null 2>&1 &");
    }
}
开发者ID:brucewu16899,项目名称:1.6.x,代码行数:47,代码来源:exec.ufdbcat.php


注:本文中的unix::TEMP_DIR方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。