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


PHP unix::LOCATE_SQUID_BIN方法代码示例

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


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

示例1: build_rules

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);
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:32,代码来源:exec.itchart.php

示例2: xstart

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

示例3: start_parse

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__));
        }
    }
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:59,代码来源:exec.squid.static.ad.groups.php

示例4: x_squid_version

function x_squid_version()
{
    $unix = new unix();
    $squidbin = $unix->LOCATE_SQUID_BIN();
    exec("{$squidbin} -v 2>&1", $results);
    while (list($num, $val) = each($results)) {
        if (preg_match("#Squid Cache: Version.*?([0-9\\.\\-a-z]+)#", $val, $re)) {
            return trim($re[1]);
        }
    }
}
开发者ID:brucewu16899,项目名称:1.6.x,代码行数:11,代码来源:exec.squid.uncompress.php

示例5: build

function build($uri)
{
    $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
    $unix = new unix();
    $pid = $unix->get_pid_from_file($pidfile);
    if ($unix->process_exists($pid, basename(__FILE__))) {
        die;
    }
    @file_put_contents($pidfile, getmypid());
    $echo = $unix->find_program("echo");
    $curl = $unix->find_program("curl");
    $squidbin = $unix->LOCATE_SQUID_BIN();
    $curl = $unix->find_program("curl");
    @unlink("/var/log/squid/request.debug");
    $DirFinal = "/usr/share/artica-postfix/ressources/support/" . time();
    @mkdir($DirFinal, 0755, true);
    $SquidMgrListenPort = trim(@file_get_contents("/etc/artica-postfix/settings/Daemons/SquidMgrListenPort"));
    shell_exec("{$echo} \"Proxy address 127.0.0.1:{$SquidMgrListenPort}\" > /var/log/squid/request.debug 2>&1");
    shell_exec("{$echo} \"Url to test: {$uri} \" >> /var/log/squid/request.debug 2>&1");
    progress("{rotate_logs_files}", 30);
    shell_exec("{$echo} \"Rotate & turn to debug... \" >> /var/log/squid/request.debug 2>&1");
    @copy("/var/log/squid/access.log", "/var/log/squid/access.log." . time());
    shell_exec("{$squidbin} -k rotate >> /var/log/squid/request.debug 2>&1");
    progress("{turn_to_debug}", 35);
    shell_exec("{$squidbin} -k debug >/dev/null 2>&1");
    sleep(4);
    progress("{send_query}", 40);
    $cmd = "{$curl} --head --verbose --trace-time --proxy http://127.0.0.1:{$SquidMgrListenPort} --url {$uri} >> /var/log/squid/request.debug 2>&1";
    shell_exec("{$echo} \"{$cmd}\" >> /var/log/squid/request.debug 2>&1");
    shell_exec($cmd);
    sleep(4);
    progress("{return_back_to_normal}", 40);
    LogsThisDebug("************************************************************");
    squid_admin_mysql(1, "Reconfiguring proxy service", null, __FILE__, __LINE__);
    shell_exec("/etc/init.d/squid reload --script=" . basename(__FILE__) . "  >> /var/log/squid/request.debug 2>&1");
    LogsThisDebug("************************************************************");
    sleep(1);
    @copy("/var/log/squid/cache.log", "{$DirFinal}/cache.log");
    progress("{compressing_package}", 90);
    $tar = $unix->find_program("tar");
    $rm = $unix->find_program("rm");
    $filename = "request.tar.gz";
    @unlink("/usr/share/artica-postfix/ressources/support/{$filename}");
    @copy("/var/log/squid/request.debug", "{$DirFinal}/request.debug");
    @unlink("/var/log/squid/request.debug");
    chdir($DirFinal);
    $cmd = "{$tar} -cvzf /usr/share/artica-postfix/ressources/support/{$filename} * 2>&1";
    exec($cmd, $results);
    @chmod("/usr/share/artica-postfix/ressources/support/{$filename}", 0755);
    shell_exec("{$rm} -rf {$DirFinal}");
    LogsThisDebug("*********************************************************");
    $c = 0;
    progress("{success}", 100);
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:54,代码来源:exec.request.package.php

示例6: build_whitelist

function build_whitelist()
{
    build_progress_wb("{compiling}", 30);
    urlrewriteaccessdeny();
    build_progress_wb("{compiling}", 35);
    urlrewriteaccessdeny_squid();
    build_progress_wb("{compiling}", 40);
    build_blacklists();
    $unix = new unix();
    $php5 = $unix->LOCATE_PHP5_BIN();
    $squidbin = $unix->LOCATE_SQUID_BIN();
    squid_admin_mysql(2, "Reloading proxy service for whitelist domains", null, __FILE__, __LINE__);
    build_progress_wb("{reloading}", 90);
    system("{$squidbin} -k reconfigure");
    build_progress_wb("{done}", 100);
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:16,代码来源:exec.ufdbgclient.whitelists.php

示例7: tests_port

function tests_port($port_id)
{
    $unix = new unix();
    $squid = new squidbee();
    $q = new mysql_squid_builder();
    $ligne = @mysql_fetch_array($q->QUERY_SQL("SELECT * FROM proxy_ports WHERE ID={$port_id}"));
    $ssl_bump_line = $squid->ssl_bump_line($ligne["sslcertificate"]);
    $randport = rand(63500, 65535);
    build_progress("{testing_ssl_certificate} ID:{$port_id} {$ligne["sslcertificate"]}", 15);
    $t = time();
    $pid_filename = "/var/run/squid/{$t}.pid";
    $cache_log = "/var/log/squid/cache.{$t}.log";
    $f[] = "coredump_dir\t/var/squid/cache";
    $f[] = "cache_log\t/var/log/squid/cache.log";
    $f[] = "pid_filename\t/var/run/squid/squid.pid";
    $f[] = "cache_effective_user squid";
    $f[] = "http_port 127.0.0.1:{$randport} {$ssl_bump_line}";
    echo " ***********************************************************************\n";
    echo "Using HTTPS port {$ssl_bump_line} Certificate {$ligne["sslcertificate"]}\n";
    echo " ***********************************************************************\n";
    $f[] = "";
    $tmpfile = $unix->FILE_TEMP();
    $squidbin = $unix->LOCATE_SQUID_BIN();
    build_progress("{testing_ssl_certificate} {$ligne["sslcertificate"]}", 20);
    echo "Conf  : {$tmpfile}\n";
    echo "Binary: {$squidbin}\n";
    @file_put_contents($tmpfile, @implode("\n", $f));
    exec("{$squidbin} -f {$tmpfile} -k check 2>&1", $results);
    @unlink($tmpfile);
    while (list($num, $line) = each($results)) {
        echo "Check  : {$line}\n";
        if (preg_match("#FATAL: No valid signing SSL#", $line)) {
            build_progress("{testing_ssl_certificate_failed} {$ligne["sslcertificate"]}", 110);
            $sql = "UPDATE proxy_ports SET sslcertificate='' WHERE ID='{$port_id}'";
            $q->QUERY_SQL($sql);
            return;
        }
    }
    build_progress("{testing_ssl_certificate} {success}", 100);
    // FATAL: No valid signing SSL certificate
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:41,代码来源:exec.squid.testssslports.php

示例8: squid_reconfigure_exe

function squid_reconfigure_exe()
{
    $unix = new unix();
    $squidbin = $unix->LOCATE_SQUID_BIN();
    build_progress("Reloading Proxy service...", 10);
    $pid = SQUID_PID();
    if ($unix->process_exists($pid)) {
        build_progress("Reloading Proxy service...", 50);
        system("/etc/init.d/squid reload --force --script=exec.squid.reconfigure.php/" . __LINE__);
        sleep(2);
        $sock = new sockets();
        $EnableTransparent27 = intval($sock->GET_INFO("EnableTransparent27"));
        if ($EnableTransparent27 == 1) {
            build_progress("Reloading Proxy NAT service...", 60);
            system("/etc/init.d/squid-nat reload --script=" . basename(__FILE__));
        }
        build_progress("Reloading Proxy service...{done}", 100);
        return;
    }
    echo "Not running !\n";
    build_progress("Reloading Proxy service {failed}...", 110);
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:22,代码来源:exec.squid.reconfigure.php

示例9: build_whitelist

function build_whitelist()
{
    $sock = new sockets();
    $EnableTransparent27 = intval($sock->GET_INFO("EnableTransparent27"));
    $PrivoxyEnabled = intval($sock->GET_INFO("PrivoxyEnabled"));
    build_progress_wb("{compiling}", 30);
    urlrewriteaccessdeny();
    build_progress_wb("{compiling}", 35);
    urlrewriteaccessdeny_squid();
    build_progress_wb("{compiling}", 40);
    @unlink("/var/log/squid/ufdbgclient.black.db");
    @file_put_contents("/etc/squid3/ip-blacklists.db", "#");
    @file_put_contents("/etc/squid3/www-blacklists.db", "#");
    build_blacklists(true);
    build_progress_wb("{compiling}", 50);
    $unix = new unix();
    if ($PrivoxyEnabled == 1) {
        build_progress_wb("{compiling} {APP_PRIVOXY}", 55);
        shell_exec("/etc/init.d/privoxy restart");
        build_progress_wb("{compiling} {APP_PRIVOXY} {done}", 60);
    }
    build_progress_wb("{reloading}", 65);
    system("/etc/init.d/squid reload --script=" . basename(__FILE__));
    $sock = new sockets();
    $EnableTransparent27 = intval($sock->GET_INFO("EnableTransparent27"));
    $PrivoxyEnabled = intval($sock->GET_INFO("PrivoxyEnabled"));
    if ($EnableTransparent27 == 1) {
        build_progress_wb("{reloading} NAT", 70);
        system("/etc/init.d/squid-nat reload --script=" . basename(__FILE__));
    }
    $php5 = $unix->LOCATE_PHP5_BIN();
    $squidbin = $unix->LOCATE_SQUID_BIN();
    squid_admin_mysql(2, "Reloading proxy service for whitelist domains", null, __FILE__, __LINE__);
    build_progress_wb("{reloading}", 90);
    system("{$squidbin} -k reconfigure");
    build_progress_wb("{done}", 100);
}
开发者ID:articatech,项目名称:artica,代码行数:37,代码来源:exec.ufdbgclient.whitelists.php

示例10: build


//.........这里部分代码省略.........
    if ($DisableTCPEn == 1) {
        $tcp_ecn = 0;
    }
    $sysctl = $unix->find_program("sysctl");
    $f[] = "#";
    $f[] = "# /etc/sysctl.conf - Configuration file for setting system variables";
    $f[] = "# See /etc/sysctl.d/ for additonal system variables";
    $f[] = "# See sysctl.conf (5) for information.";
    $f[] = "#";
    $f[] = "";
    $f[] = "#kernel.domainname = example.com";
    $f[] = "";
    $f[] = "# Uncomment the following to stop low-level messages on console";
    $f[] = "#kernel.printk = 3 4 1 3";
    $f[] = "";
    $f[] = "##############################################################";
    // /proc/sys/vm/dirty_ratio defaults to 20% of RAM
    // /proc/sys/vm/dirty_background_ratio defaults to 10%of RAM
    $memory = $unix->MEM_TOTAL_INSTALLEE() * 1024;
    $dirty_ratio = round($memory * 0.8);
    if ($EnableSystemOptimize == 0) {
        shell_exec("{$echo} 33554432 >/proc/sys/vm/dirty_background_bytes");
        shell_exec("{$echo} {$dirty_ratio} >/proc/sys/vm/dirty_bytes");
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} Memory: {$memory} bytes\n";
        }
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} dirty_ratio = {$dirty_ratio} bytes \n";
        }
    } else {
        $swappiness = 0;
        shell_exec("{$echo} 1024 > /sys/block/sda/queue/nr_requests");
    }
    $squidbin = $unix->LOCATE_SQUID_BIN();
    $t = explode(".", $hostname);
    if (count($t) > 0) {
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} `hostname` = '{$hostname}'\n";
        }
        $f[] = "kernel.hostname={$t[0]}";
        unset($t[0]);
        $f[] = "kernel.domainname=" . @implode(".", $t);
    }
    if ($GLOBALS["OUTPUT"]) {
        echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} `swappiness` = '{$swappiness}%'\n";
    }
    $f[] = "vm.swappiness = {$swappiness}";
    $f[] = "net.ipv4.icmp_ignore_bogus_error_responses = 1";
    $f[] = "net.ipv4.tcp_window_scaling = {$tcp_window_scaling}";
    $f[] = "net.ipv4.tcp_ecn = {$tcp_ecn}";
    $f[] = "net.ipv4.tcp_sack = 1";
    $f[] = "net.ipv4.tcp_fack = 1";
    $f[] = "net.ipv4.tcp_timestamps = 1";
    $f[] = "net.ipv4.icmp_echo_ignore_broadcasts = 1";
    $f[] = "";
    if ($EnableSystemOptimize == 1) {
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} set dirty pages\n";
        }
        $f[] = "vm.dirty_background_ratio = 4";
        $f[] = "vm.dirty_background_bytes = 33554432";
        $f[] = "vm.dirty_ratio = 64";
        shell_exec("{$echo} \"100663296\" > /proc/sys/vm/dirty_bytes");
        shell_exec("{$echo} \"33554432\" > /proc/sys/vm/dirty_background_bytes");
        if (is_file($squidbin)) {
            if (is_file("/proc/sys/net/local/dgram/recvspace")) {
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:67,代码来源:exec.sysctl.php

示例11: start

function start($aspid = false)
{
    $unix = new unix();
    if (!$aspid) {
        $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());
    }
    $sock = new sockets();
    $iptables = $unix->find_program("iptables");
    $sysctl = $unix->find_program("sysctl");
    $ips = $unix->ifconfig_interfaces_list();
    $KernelSendRedirects = $sock->GET_INFO("KernelSendRedirects");
    if (!is_numeric($KernelSendRedirects)) {
        $KernelSendRedirects = 1;
    }
    $modprobe = $unix->find_program("modprobe");
    $EnableArticaHotSpot = $sock->GET_INFO("EnableArticaHotSpot");
    if (!is_numeric($EnableArticaHotSpot)) {
        $EnableArticaHotSpot = 0;
    }
    if ($EnableArticaHotSpot == 0) {
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} disabled ( see EnableArticaHotSpot )\n";
        }
        remove_sessions();
        remove_temp_sessions();
        return;
    }
    $squid = $unix->LOCATE_SQUID_BIN();
    if (!is_file($squid)) {
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} Squid-cache not installed\n";
        }
        return;
    }
    if ($GLOBALS["OUTPUT"]) {
        echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} loading ip_conntrack module\n";
    }
    shell_exec("{$modprobe} ip_conntrack");
    if ($GLOBALS["OUTPUT"]) {
        echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} building firewall\n";
    }
    if (!is_file("/etc/artica-postfix/hotspot.conf")) {
        build();
    }
    $f = explode("\n", @file_get_contents("/etc/artica-postfix/hotspot.conf"));
    while (list($num, $ligne) = each($f)) {
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} `{$ligne}`\n";
        }
        shell_exec($ligne);
    }
    if ($GLOBALS["OUTPUT"]) {
        echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} Patching kernel\n";
    }
    shell_exec("{$sysctl} -w net.ipv4.ip_forward=1 2>&1");
    shell_exec("{$sysctl} -w net.ipv4.conf.default.send_redirects={$KernelSendRedirects} 2>&1");
    shell_exec("{$sysctl} -w net.ipv4.conf.all.send_redirects={$KernelSendRedirects} 2>&1");
    shell_exec("{$sysctl} -w net.ipv4.conf.eth0.send_redirects={$KernelSendRedirects} 2>&1");
    if ($GLOBALS["OUTPUT"]) {
        echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} Delete session..\n";
    }
    untrack();
    if ($GLOBALS["OUTPUT"]) {
        echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} Success started PID 0\n";
    }
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:75,代码来源:exec.artica.hotspot.php

示例12: execute

function execute()
{
    $nice = EXEC_NICE();
    if (is_file(dirname(__FILE__) . "/exec.sarg.gilou.php")) {
        events("Executing exec.sarg.gilou.php instead...");
        shell_exec($nice . LOCATE_PHP5_BIN2() . " " . dirname(__FILE__) . "/exec.sarg.gilou.php --exec");
        return;
    }
    $sock = new sockets();
    $SargOutputDir = $sock->GET_INFO("SargOutputDir");
    if ($SargOutputDir == null) {
        $SargOutputDir = "/var/www/html/squid-reports";
    }
    $nice = EXEC_NICE();
    $unix = new unix();
    $today = date("d/m/Y");
    $sarg_bin = $unix->find_program("sarg");
    if (!is_file($sarg_bin)) {
        sarg_admin_events("Fatal, unable to locate sarg binary, aborting...", __FUNCTION__, __FILE__, __LINE__, "sarg");
        return;
    }
    events("Building settings..");
    buildconf();
    $usersauth = false;
    $squid = new squidbee();
    if ($squid->LDAP_AUTH == 1) {
        $usersauth = true;
    }
    if ($squid->LDAP_EXTERNAL_AUTH == 1) {
        $usersauth = true;
    }
    if (!is_file("/etc/squid/exclude_codes")) {
        @file_put_contents("/etc/squid/exclude_codes", "\nNONE/400\n");
    }
    @mkdir("{$SargOutputDir}", 0755, true);
    $u = " -i ";
    $cmd = "{$nice}{$sarg_bin} -d {$today}-{$today} {$u}-f /etc/squid3/sarg.conf -l /var/log/squid/access.log -o \"{$SargOutputDir}\" -x -z 2>&1";
    $t1 = time();
    echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]}, {$cmd}\n";
    sargevents("execute(): {$cmd}");
    exec($cmd, $results);
    while (list($index, $line) = each($results)) {
        if (preg_match("#SARG: No records found#", $line)) {
            events("No records found");
            $subject_add = "(No records found)";
        }
        if (preg_match("#SARG:\\s+.+?mixed records format#", $line)) {
            send_email_events("SARG: Error, squid was reloaded", "It seems that there is a mixed log file format detected in squid\n\t\t\tThis reason is Artica change squid log format from orginial to http access mode.\n\t\t\tIn this case, the log will be moved and squid will be reloaded \n\t\t\tin order to build a full log file with only one log format.\n\t\t\t\n" . @implode("\n", $results), "proxy");
            shell_exec(LOCATE_PHP5_BIN2() . " " . dirname(__FILE__) . "/exec.squid.php --reconfigure");
            shell_exec($unix->LOCATE_SQUID_BIN() . " -k rotate");
            shell_exec("/etc/init.d/auth-tail restart >/dev/null 2>&1");
            shell_exec("/etc/init.d/cache-tail restart >/dev/null 2>&1");
            return;
        }
        if (preg_match("#SARG:\\s+.+?enregistrements de plusieurs formats#", $line)) {
            send_email_events("SARG: Error, squid was reloaded", "It seems that there is a mixed log file format detected in squid\n\t\t\tThis reason is Artica change squid log format from orginial to http access mode.\n\t\t\tIn this case, the log will be moved and squid will be reloaded \n\t\t\tin order to build a full log file with only one log format.\n\t\t\t\n" . @implode("\n", $results), "proxy");
            shell_exec(LOCATE_PHP5_BIN2() . " " . dirname(__FILE__) . "/exec.squid.php --reconfigure");
            shell_exec($unix->LOCATE_SQUID_BIN() . " -k rotate");
            shell_exec("/etc/init.d/auth-tail restart >/dev/null 2>&1");
            shell_exec("/etc/init.d/cache-tail restart >/dev/null 2>&1");
            return;
        }
        if (preg_match("#SARG.+?Unknown input log file format#", $line)) {
            send_email_events("SARG: \"Unknown input log file format\", squid was reloaded", "It seems that there is a input log file format log file format detected in squid\n\t\t\tThis reason is Artica change squid log format from orginial to log_fqn on, this will be disabled\n\t\t\tIn this case, the log will be moved and squid will be reloaded \n\t\t\tin order to build a full log file with only one log format.\n\t\t\t\n" . @implode("\n", $results), "proxy");
            shell_exec(LOCATE_PHP5_BIN2() . " " . dirname(__FILE__) . "/exec.squid.php --reconfigure");
            shell_exec($unix->LOCATE_SQUID_BIN() . " -k rotate");
            shell_exec("/etc/init.d/auth-tail restart >/dev/null 2>&1");
            shell_exec("/etc/init.d/cache-tail restart >/dev/null 2>&1");
            return;
        }
    }
    $NICE = EXEC_NICE();
    $unix = new unix();
    $lighttpd_user = $unix->APACHE_SRC_ACCOUNT();
    $php = $unix->LOCATE_PHP5_BIN();
    $nohup = $unix->find_program("nohup");
    echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]}, lighttpd user: {$lighttpd_user}\n";
    $chown = $unix->find_program("chown");
    echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]},{$chown} -R {$lighttpd_user}:{$lighttpd_user} {$SargOutputDir}/*\n";
    exec("{$chown} -R {$lighttpd_user}:{$lighttpd_user} {$SargOutputDir}/* >/dev/null 2>&1", $results2);
    echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]},\n" . @implode("\n" . $results2) . "\n";
    shell_exec("{$nohup} {$php} " . __FILE__ . " --backup >/dev/null 2>&1 &");
    $t2 = time();
    $distanceOfTimeInWords = distanceOfTimeInWords($t1, $t2);
    echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]}, {$distanceOfTimeInWords}\n";
    events("Statistics generated ({$distanceOfTimeInWords})");
    if ($GLOBALS["VERBOSE"]) {
        echo "SARG: Statistics generated ({$distanceOfTimeInWords})\n\n";
        echo @implode("\n", $results) . "\n";
    }
    status(true);
    sarg_admin_events("SARG: Statistics generated ({$distanceOfTimeInWords}) {$subject_add}", "Command line:\n-----------\n{$cmd}\n" . @implode("\n", $results), __FUNCTION__, __FILE__, __LINE__, "sarg");
}
开发者ID:brucewu16899,项目名称:1.6.x,代码行数:93,代码来源:exec.sarg.php

示例13: Parseline


//.........这里部分代码省略.........
            $SquidClientParams["external_acl_startup"] = $SquidClientParams["external_acl_startup"] + 1;
            $SquidClientParams["external_acl_idle"] = $SquidClientParams["external_acl_idle"] + 1;
            $GLOBALS["CLASS_SOCKETS"]->SaveConfigFile(base64_encode(serialize($SquidClientParams)), "SquidClientParams");
            shell_exec("{$GLOBALS["NOHUP"]} {$GLOBALS["PHP5"]} /usr/share/artica-postfix/exec.squid.php --build --force >/dev/null 2>&1 &");
            events("external ACL (queue overload) Increase: external_acl_children:{$SquidClientParams["external_acl_children"]},external_acl_startup:{$SquidClientParams["external_acl_startup"]}, external_acl_idle:{$SquidClientParams["external_acl_idle"]} Line:" . __LINE__);
            $text = "{$buffer}\n\t\t\tNew parameters has been set and the proxy service was reconfigurer with:\n\t\t\texternal_acl_children = {$SquidClientParams["external_acl_children"]}\n\t\t\texternal_acl_startup  = {$SquidClientParams["external_acl_startup"]}\n\t\t\texternal_acl_idle     = {$SquidClientParams["external_acl_idle"]}\n\t\t\t";
            squid_admin_notifs($text, __FUNCTION__, __FILE__, __LINE__, "watchdog");
            squid_admin_mysql(1, "external ACL queue overload", "{$text}");
            @unlink($file);
            @file_put_contents($file, time());
            return;
        }
        events("external ACL (queue overload) timeout ({$timefile}mn) line:" . __LINE__);
        return;
    }
    // *******************************************************************************************************************
    if (preg_match("#kid[0-9]+.*?ERROR opening swap log\\s+(.+?)\\/swap\\.state: \\(13\\) Permission denied#", $buffer, $re)) {
        $dirname = $re[1];
        $file = "/etc/artica-postfix/pids/opening.swap.state." . md5($dirname);
        events("{$dirname} ERROR opening swap log... Line:" . __LINE__);
        $timefile = file_time_min($file);
        if ($timefile > 3) {
            swapstate($dirname);
            if (!isset($GLOBALS["CHMOD"])) {
                $unix = new unix();
                $GLOBALS["CHMOD"] = $unix->find_program("chmod");
            }
            if (!isset($GLOBALS["CHOWN"])) {
                $unix = new unix();
                $GLOBALS["CHOWN"] = $unix->find_program("chown");
            }
            if (!isset($GLOBALS["SQUIDBIN"])) {
                $unix = new unix();
                $GLOBALS["SQUIDBIN"] = $unix->LOCATE_SQUID_BIN();
            }
            $cmd = "{$GLOBALS["NOHUP"]} {$GLOBALS["CHMOD"]} -R 0755 {$dirname} >/dev/null 2>&1 &";
            shell_exec($cmd);
            events("{$cmd}" . __LINE__);
            squid_admin_mysql(1, "Permission denied: Reconfiguring squid-cache", "Permission as been set to {$dirname}");
            squid_admin_mysql(1, "Reconfiguring proxy service", null, __FILE__, __LINE__);
            $cmd = "{$GLOBALS["NOHUP"]} {$GLOBALS["CHOWN"]} -R squid:squid {$dirname} >/dev/null 2>&1 &";
            shell_exec("/etc/init.d/squid reload {$GLOBALS["SCRIPT_SUFFIX"]}");
            events("{$cmd}" . __LINE__);
            shell_exec($cmd);
            @unlink($file);
            @file_put_contents($file, time());
        } else {
            events("{$dirname} Timeout {$timefile}Mn need to wait 3mn Line chown just swap.state :" . __LINE__);
            swapstate($dirname);
            if (!isset($GLOBALS["SQUIDBIN"])) {
                $unix = new unix();
                $GLOBALS["SQUIDBIN"] = $unix->LOCATE_SQUID_BIN();
            }
            squid_admin_mysql(1, "Permission denied: Reconfiguring squid-cache", "Permission as been set to {$dirname}");
            squid_admin_mysql(1, "Reconfiguring proxy service", null, __FILE__, __LINE__);
            $cmd = "/etc/init.d/squid reload {$GLOBALS["SCRIPT_SUFFIX"]} >/dev/null 2>&1 &";
            events("{$cmd}" . __LINE__);
            shell_exec($cmd);
        }
        return;
    }
    // *******************************************************************************************************************
    if (preg_match("#ERROR opening swap log (.+?)\\/swap\\.state: \\(13\\) Permission denied#", $buffer, $re)) {
        $dirname = $re[1];
        $file = "/etc/artica-postfix/pids/opening.swap.state." . md5($dirname);
        events("{$dirname} ERROR opening swap log... Line:" . __LINE__);
开发者ID:brucewu16899,项目名称:1.6.x,代码行数:67,代码来源:exec.cache-logs.php

示例14: RestartDedicatedServices

function RestartDedicatedServices($aspid = false)
{
    $unix = new unix();
    if ($aspid) {
        $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
        $pid = @file_get_contents($pidfile);
        if ($unix->process_exists($pid, basename(__FILE__))) {
            $time = $unix->PROCCESS_TIME_MIN($pid);
            echo "Starting......: " . date("H:i:s") . " RestartDedicatedServices already executed PID: {$pid} since {$time}Mn\n";
            if ($time < 120) {
                if (!$GLOBALS["FORCE"]) {
                    die;
                }
            }
            unix_system_kill_force($pid);
        }
        @file_put_contents($pidfile, getmypid());
    }
    $nohup = $unix->find_program("nohup");
    $php = $unix->LOCATE_PHP5_BIN();
    $squidbin = $unix->LOCATE_SQUID_BIN();
    $unix->THREAD_COMMAND_SET("{$php} /usr/share/artica-postfix/exec.web-community-filter.php --register");
    events("Starting artica");
    echo "Starting......: " . date("H:i:s") . " nightly builds starting artica...\n";
    @file_put_contents("/usr/share/artica-postfix/download_progress", 45);
    system("/etc/init.d/artica-postfix start");
    echo "Starting......: " . date("H:i:s") . " nightly builds building init scripts\n";
    @file_put_contents("/usr/share/artica-postfix/download_progress", 50);
    system("{$php} /usr/share/artica-postfix/exec.initslapd.php --force >/dev/null 2>&1");
    echo "Starting......: " . date("H:i:s") . " nightly builds updating network\n";
    @file_put_contents("/usr/share/artica-postfix/download_progress", 55);
    system("{$php} /usr/share/artica-postfix/exec.virtuals-ip.php >/dev/null 2>&1");
    system("{$php} /usr/share/artica-postfix/exec.monit.php --build >/dev/null 2>&1");
    echo "Starting......: " . date("H:i:s") . " nightly builds purge and clean....\n";
    @file_put_contents("/usr/share/artica-postfix/download_progress", 60);
    shell_exec("{$nohup} /etc/init.d/slapd start >/dev/null 2>&1 &");
    shell_exec("{$nohup} /etc/init.d/artica-webconsole start >/dev/null 2>&1 &");
    if (is_file("/etc/init.d/nginx")) {
        shell_exec("{$nohup} /etc/init.d/nginx reload >/dev/null 2>&1 &");
    }
    shell_exec("{$nohup} /etc/init.d/auth-tail restart >/dev/null 2>&1 &");
    shell_exec("{$nohup} /etc/init.d/artica-framework restart >/dev/null 2>&1 &");
    shell_exec("{$nohup} /usr/share/artica-postfix/bin/process1 -perm >/dev/null 2>&1 &");
    shell_exec("{$nohup} /usr/share/artica-postfix/bin/artica-make --empty-cache >/dev/null 2>&1 &");
    shell_exec("{$nohup} /etc/init.d/monit restart >/dev/null 2>&1 &");
    shell_exec("{$nohup} /etc/init.d/artica-status restart --force >/dev/null 2>&1 &");
    shell_exec("{$nohup} {$php} /usr/share/artica-postfix/exec.squid.php --build-schedules >/dev/null 2>&1 &");
    shell_exec("{$nohup} {$php} /usr/share/artica-postfix/exec.schedules.php --defaults >/dev/null 2>&1 &");
    if (is_file($squidbin)) {
        squid_admin_mysql(1, "Reconfiguring proxy service", null, __FILE__, __LINE__);
        $cmd = "/etc/init.d/squid reload --script=" . basename(__FILE__) . " >/dev/null 2>&1 &";
        shell_exec($cmd);
    }
    events("done");
    @file_put_contents("/usr/share/artica-postfix/download_progress", 100);
    echo "Starting......: " . date("H:i:s") . " Done you can close the screen....\n";
    _artica_update_event(2, "RestartDedicatedServices(): finish", null, __FILE__, __LINE__);
}
开发者ID:brucewu16899,项目名称:1.6.x,代码行数:58,代码来源:exec.nightly.php

示例15: start

function start($port_id)
{
    $unix = new unix();
    $squid = new squidbee();
    $q = new mysql_squid_builder();
    $INCLUDE = false;
    $f = explode("\n", @file_get_contents("/etc/squid3/squid.conf"));
    build_progress_bandwidth("{limit_rate} {analyze}", 20);
    while (list($www, $line) = each($f)) {
        if (!preg_match("#acls_bandwidth\\.conf#", $line)) {
            continue;
        }
        echo "Include OK\n";
        $INCLUDE = TRUE;
        break;
    }
    if (!$INCLUDE) {
        echo "Include False, reconfigure\n";
        build_progress_bandwidth("{limit_rate} {reconfigure}", 80);
        $php = $unix->LOCATE_PHP5_BIN();
        system("{$php} /usr/share/artica-postfix/exec.squid.php --build --force");
        build_progress_bandwidth("{limit_rate} {done}", 100);
        return;
    }
    $md51 = md5_file("/etc/squid3/acls_bandwidth.conf");
    build_progress_bandwidth("{limit_rate} {reconfigure}", 50);
    $band = new squid_bandwith_builder();
    if (!$band->compile()) {
        build_progress_bandwidth("{limit_rate} {failed}", 110);
        return;
    }
    $md52 = md5_file("/etc/squid3/acls_bandwidth.conf");
    if ($md51 == $md52) {
        build_progress_bandwidth("{limit_rate} {done} {unmodified}", 100);
        return;
    }
    $squidbin = $unix->LOCATE_SQUID_BIN();
    build_progress_bandwidth("{limit_rate} {reloading}", 97);
    system("{$squidbin} -k reconfigure");
    build_progress_bandwidth("{limit_rate} {done} OK", 100);
    // FATAL: No valid signing SSL certificate
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:42,代码来源:exec.squid.bandwidth.php


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