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


PHP unix::squid_version方法代码示例

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


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

示例1: reload

function reload()
{
    $unix = new unix();
    $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
    $sock = new sockets();
    $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;
    }
    $timeFile = "/etc/artica-postfix/pids/UfdbGuardReload.time";
    $ufdbguardReloadTTL = intval(@file_get_contents("/etc/artica-postfix/settings/Daemons/ufdbguardReloadTTL"));
    $UfdbReloadBySchedule = trim(@file_get_contents("/etc/artica-postfix/settings/Daemons/UfdbReloadBySchedule"));
    if (!is_numeric($UfdbReloadBySchedule)) {
        $UfdbReloadBySchedule = 1;
    }
    $TimeReload = $unix->file_time_min($timeFile);
    if (!$GLOBALS["FORCE"]) {
        if ($ufdbguardReloadTTL < 1) {
            $ufdbguardReloadTTL = 10;
        }
        if ($TimeReload < $ufdbguardReloadTTL) {
            $unix->_syslog("{$GLOBALS["TITLENAME"]} Aborting reload, last reload since {$TimeReload}Mn, need at least {$ufdbguardReloadTTL}Mn", basename(__FILE__));
            if ($GLOBALS["OUTPUT"]) {
                echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} Aborting reload, last reload since {$TimeReload}Mn, need at least {$ufdbguardReloadTTL}Mn\n";
            }
            return;
        }
        if ($UfdbReloadBySchedule == 1) {
            if (!$GLOBALS["BYSCHEDULE"]) {
                $unix->_syslog("{$GLOBALS["TITLENAME"]} Aborting reload, only allowed trough a schedule", basename(__FILE__));
                if ($GLOBALS["OUTPUT"]) {
                    echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} Aborting reload, only allowed trough a schedule\n";
                }
                return;
            }
        }
    }
    if ($GLOBALS["FORCE"]) {
        $pid = PID_NUM();
        $TimeService = $unix->PROCCESS_TIME_MIN($pid);
        squid_admin_mysql(1, "Force Webfiltering service Running since {$TimeService}Mn to be reloaded", "last reload since {$TimeReload}Mn", __FILE__, __LINE__);
    }
    @unlink($timeFile);
    @file_put_contents($timeFile, time());
    $squid_version = $unix->squid_version();
    if (preg_match("#^([0-9]+)\\.([0-9]+)#", $squid_version, $re)) {
        if (intval($re[2]) > 4) {
            $re[2] = 4;
        }
        $squid_version = "{$re[1]}.{$re[2]}";
    }
    $kill = $unix->find_program("kill");
    $php5 = $unix->LOCATE_PHP5_BIN();
    $verif_Squid_Version = verif_Squid_Version();
    if ($verif_Squid_Version != $squid_version) {
        squid_admin_mysql(1, "{$verif_Squid_Version}/{$squid_version} reconfiguring for squid compatibility", __FILE__, __LINE__, "global-compile");
        $unix->_syslog("{$GLOBALS["TITLENAME"]} {$verif_Squid_Version}/{$squid_version} reconfiguring for squid compatibility", basename(__FILE__));
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} {$verif_Squid_Version}/{$squid_version} reconfiguring for squid compatibility...\n";
        }
        shell_exec("{$php5} /usr/share/artica-postfix/exec.squidguard.php --build --force");
    }
    if ($GLOBALS["OUTPUT"]) {
        echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} Squid-Cache version {$squid_version}\n";
    }
    $pid = PID_NUM();
    if ($unix->process_exists($pid)) {
        $unix->_syslog("{$GLOBALS["TITLENAME"]} Reloading PID {$pid}\n", basename(__FILE__));
        $chmod = $unix->find_program("chmod");
        $chown = $unix->find_program("chown");
        shell_exec("{$chmod} 0755 /etc/squid3/ufdbGuard.conf");
        shell_exec("{$chown} squid:squid /etc/squid3");
        shell_exec("{$chown} squid:squid /etc/squid3/ufdbGuard.conf");
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} Reloading PID {$pid}\n";
        }
        shell_exec("{$php5} /usr/share/artica-postfix/exec.squidguard.php --dbmem");
        shell_exec("{$php5} /usr/share/artica-postfix/exec.squidguard.php --reload");
        shell_exec("{$php5} /usr/share/artica-postfix/exec.ufdbclient.reload.php");
    } else {
        start(true);
    }
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:87,代码来源:exec.ufdb.php

示例2: hypercache

function hypercache()
{
    $timefile = "/etc/artica-postfix/pids/exec.nightly.php.hypercache.time";
    $unix = new unix();
    if ($unix->file_time_min($timefile) < 1440) {
        updater_events("Current {$timefile}Mn !== 1440", __FUNCTION__, __LINE__);
        return;
    }
    @unlink($timefile);
    @file_put_contents($timefile, time());
    $squiver = $unix->squid_version();
    if (!preg_match("#^3\\.(5|6|7|8)\\.#", $squiver)) {
        return;
    }
    $uri = "https://svb.unveiltech.com/box/articatech/getlatest.php";
    $curl = new ccurl($uri);
    $tmpfile = $unix->FILE_TEMP();
    if (!$curl->GetFile($tmpfile)) {
        _artica_update_event(0, "Unable to download hypercache-plugin infos {$curl->error_num}, {$curl->error}", __FILE__, __LINE__);
        @unlink($tmpfile);
        return;
    }
    $array = json_decode(@file_get_contents($tmpfile));
    @unlink($tmpfile);
    $local_version = hypercachestoreid_version();
    $remote_version = $array->ver;
    $remote_uri = $array->url;
    $remote_date = $array->date;
    if ($GLOBALS["VERBOSE"]) {
        echo "{$local_version} / {$remote_version} - " . intval($remote_version) . " {$remote_date}\n";
    }
    if (intval($remote_version) == 0) {
        return;
    }
    if ($remote_version == $local_version) {
        return;
    }
    $curl = new ccurl($remote_uri);
    $tmpfile = $unix->FILE_TEMP();
    if (!$curl->GetFile($tmpfile)) {
        _artica_update_event(0, "Unable to download hypercache-plugin infos {$curl->error_num}, {$curl->error}", __FILE__, __LINE__);
        @unlink($tmpfile);
        return;
    }
    $tempdir = $unix->TEMP_DIR() . "/" . time();
    @mkdir($tempdir, 0755, true);
    $tar = $unix->find_program("tar");
    $rm = $unix->find_program("rm");
    shell_exec("{$tar} xf {$tmpfile} -C {$tempdir}/");
    @unlink($tmpfile);
    if (!is_file("{$tempdir}/64bits/hypercache-plugin")) {
        _artica_update_event(0, "Unable to extract hypercache-plugin version {$remote_version}", null, __FILE__, __LINE__);
        shell_exec("{$rm} -rf xf {$tempdir}");
    }
    @copy("/lib/squid3/hypercache-plugin", "/lib/squid3/hypercache-plugin-{$local_version}");
    @unlink("/lib/squid3/hypercache-plugin");
    @copy("{$tempdir}/64bits/hypercache-plugin", "/lib/squid3/hypercache-plugin");
    shell_exec("{$rm} -rf xf {$tempdir}");
    @chmod("/lib/squid3/hypercache-plugin", 0755);
    @chown("/lib/squid3/hypercache-plugin", "squid");
    squid_admin_mysql(1, "Reloading proxy service in order to update Hypercache software version from {$local_version} to {$remote_version}", null, __FILE__, __LINE__);
    _artica_update_event(2, "Success update Hypercache software version from {$local_version} to {$remote_version}", null, __FILE__, __LINE__);
    shell_exec("/etc/init.d/squid reload --force --script=" . basename(__FILE__) . "/" . __LINE__);
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:64,代码来源:exec.nightly.php

示例3: downgrade

function downgrade($file)
{
    $unix = new unix();
    $pidFile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
    $unix = new unix();
    $pid = $unix->get_pid_from_file($pidFile);
    if ($unix->process_exists($pid)) {
        Events("??%: A process already exists PID {$pid}");
        return;
    }
    @file_put_contents($pidFile, getmypid());
    $workdir = "/home/squid/downgrade";
    $gzf = "/home/squid/downgrade/{$file}";
    @mkdir("/home/squid/downgrade", 0755, true);
    Events("0%: Ask to update package name {$file}");
    Events("1%: downloading {$file}");
    if (!is_dir($workdir)) {
        Events("100%: Failed,  {$workdir} Permission denied");
        die;
    }
    if (is_file($gzf)) {
        @unlink($gzf);
    }
    $unix = new unix();
    $URIBASE = $unix->MAIN_URI();
    Events("5%: PLEASE WAIT,PLEASE WAIT,PLEASE WAIT.....downloading {$file}");
    $curl = new ccurl("{$URIBASE}/download/old-squid/{$file}");
    $curl->NoHTTP_POST = true;
    $curl->ProgressFunction = "downgrade_prg";
    $curl->WriteProgress = true;
    if (!$curl->GetFile($gzf)) {
        Events("100%: Failed to download {$curl->error}");
        die;
    }
    if (!is_file($gzf)) {
        Events("100%: Failed to download permission denied on disk");
        die;
    }
    $size = @filesize($gzf);
    $size = $size / 1024;
    $size = $size / 1024;
    Events("10%: " . basename($gzf) . " " . round($size, 2) . " MB");
    Events("10%: Testing {$gzf}");
    if ($GLOBALS["VERBOSE"]) {
        echo "Open TAR...\n";
    }
    $tar = new tar();
    if (!$tar->openTar($gzf)) {
        Events("100%: Failed archive seems corrupted..");
        die;
    }
    Events("10%: Testing {$gzf} success");
    Events("15%: Start upgrade procedure...");
    Events("16%: Stopping Squid-Cache...");
    shell_exec("/etc/init.d/squid stop");
    $squidbin = $unix->LOCATE_SQUID_BIN();
    $rm = $unix->find_program("rm");
    $tar = $unix->find_program("tar");
    $php5 = $unix->LOCATE_PHP5_BIN();
    $nohup = $unix->find_program("nohup");
    Events("17%: Removing {$squidbin}...");
    @unlink($squidbin);
    $f[] = "/lib/squid3";
    $f[] = "/usr/share/squid-langpack";
    $f[] = "/usr/share/squid3";
    while (list($num, $dir) = each($f)) {
        Events("20%: Removing {$dir} directory...");
        shell_exec("{$rm} -rf {$dir} >/dev/null 2>&1");
    }
    Events("50%: Installing...");
    shell_exec("{$tar} xf {$gzf} -C / >/dev/null");
    $squidbin = $unix->LOCATE_SQUID_BIN();
    if (!is_file($squidbin)) {
        Events("100%: Failed archive seems corrupted, please restart again or contact or support team...");
        die;
    }
    $ver = $unix->squid_version();
    Events("60%: New Squid-cache version {$ver}");
    Events("65%: Reconfiguring parameters");
    shell_exec("{$php5} /usr/share/artica-postfix/exec.squid.php --build --force >/dev/null");
    Events("70%: Starting Squid-Cache");
    shell_exec("/etc/init.d/squid start");
    Events("80%: Refresh Artica with the new version...");
    shell_exec("/etc/init.d/artica-process1 start");
    Events("90%: Restarting watchdogs...");
    system("/etc/init.d/cache-tail restart");
    system("{$nohup} /etc/init.d/artica-status reload >/dev/null 2>&1 &");
    shell_exec("{$nohup} /etc/init.d/monit restart  >/dev/null 2>&1 &");
    Events("100%: Done...");
    Events("-------------------------------------------------------------");
    Events("----------------     Squid Cache V.{$ver}    ------------------");
    Events("-------------------------------------------------------------");
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:93,代码来源:exec.squid.downgrade.php

示例4: events

$GLOBALS["EnableRemoteStatisticsAppliance"] = $EnableRemoteStatisticsAppliance;
events("SQUID ENGINE: EnableRemoteStatisticsAppliance = {$EnableRemoteSyslogStatsAppliance}");
if (is_file("/etc/artica-postfix/auth-tail-debug")) {
    $GLOBALS["VERBOSE"] = true;
}
if ($GLOBALS["VERBOSE"]) {
    events("waiting event in VERBOSE MODE....");
}
@mkdir("/var/log/artica-postfix/squid-users", 0755, true);
@mkdir("/var/log/artica-postfix/squid-brut", 0777, true);
@mkdir("/var/log/artica-postfix/squid-reverse", 0777, true);
@mkdir("/var/log/artica-postfix/youtube", 0755, true);
@mkdir('/var/log/artica-postfix/squid-userAgent');
@chmod("/var/log/artica-postfix/squid-brut", 0777);
@chmod("/var/log/artica-postfix/squid-reverse", 0777);
$squidver = $unix->squid_version();
if (preg_match("#^([0-9]+)\\.([0-9]+)\\.([0-9]+)#", $squidver, $re)) {
    $SQUID_MAJOR = $re[1];
    $SQUID_MINOR = $re[2];
}
if ($SQUID_MAJOR > 2) {
    if ($SQUID_MINOR > 1) {
        $GLOBALS["SQUID32"] = true;
    }
}
$unix = new unix();
$pid = $unix->get_pid_from_file("/var/run/artica-auth-tail.pid");
if ($unix->process_exists($pid, basename(__FILE__))) {
    echo "Already process exists PID {$pid}\n";
    die;
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:31,代码来源:exec.auth-tail.php

示例5: current_version

function current_version()
{
    $unix = new unix();
    echo "<articadatascgi>" . base64_encode($unix->squid_version()) . "</articadatascgi>";
}
开发者ID:articatech,项目名称:artica,代码行数:5,代码来源:squid.php

示例6: squid_updates_table

function squid_updates_table()
{
    $unix = new unix();
    $sock = new sockets();
    $squidbin = $unix->LOCATE_SQUID_BIN();
    $users = new usersMenus();
    if (!is_file($squidbin)) {
        return;
    }
    $tmpfile = $unix->TEMP_DIR() . "/squid.update.db";
    $VERSION = @file_get_contents(dirname(__FILE__) . "/VERSION");
    $UUID = $unix->GetUniqueID();
    $SQUID_VERSION = $unix->squid_version();
    $WizardSavedSettings = unserialize(base64_decode($sock->GET_INFO("WizardSavedSettings")));
    $LICENSE = 0;
    if ($users->CORP_LICENSE == 1) {
        $LICENSE = 1;
    }
    $WizardSavedSettings["LICENSE"] = $LICENSE;
    $WizardSavedSettings["UUID"] = trim($UUID);
    $WizardSavedSettings["SQUID_VERSION"] = trim($SQUID_VERSION);
    $WizardSavedSettings["ARTICA_VERSION"] = trim($VERSION);
    $content = urlencode(base64_encode(serialize($WizardSavedSettings)));
    $TimeFile = $unix->file_time_min("/etc/artica-postfix/settings/Daemons/ArticaTechNetSquidRepo");
    if ($TimeFile > 380) {
        $curl = new ccurl("http://articatech.net/squid.update.php?content={$content}");
        if (!$curl->GetFile($tmpfile)) {
            @unlink($tmpfile);
            squid_admin_mysql(1, "Unable to retreive Proxy available versions", $curl->error, __FILE__, __LINE__);
            return;
        }
        $DATA = @file_get_contents($tmpfile);
        $ARRAY = unserialize(base64_decode($DATA));
        if (count($ARRAY) > 1) {
            @unlink("/etc/artica-postfix/settings/Daemons/ArticaTechNetSquidRepo");
            @copy("{$tmpfile}", "/etc/artica-postfix/settings/Daemons/ArticaTechNetSquidRepo");
        }
        @unlink($tmpfile);
    }
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:40,代码来源:exec.web-community-filter.php


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