コード例 #1
0
ファイル: exec.nginx.php プロジェクト: BillTheBest/1.6.x
function build_localhosts()
{
    if ($GLOBALS["VERBOSE"]) {
        echo "\n############################################################\n\n" . __FUNCTION__ . "." . __LINE__ . ":Start...\n";
    }
    $squidR = new squidbee();
    $rev = new squid_reverse();
    $sock = new sockets();
    $unix = new unix();
    LoadConfigs();
    $EnableArticaFrontEndToNGninx = $sock->GET_INFO("EnableArticaFrontEndToNGninx");
    $EnableFreeWeb = $sock->GET_INFO("EnableFreeWeb");
    if (!is_numeric($EnableArticaFrontEndToNGninx)) {
        $EnableArticaFrontEndToNGninx = 0;
    }
    if (!is_numeric($EnableFreeWeb)) {
        $EnableFreeWeb = 0;
    }
    $NginxAuthPort = $sock->GET_INFO("NginxAuthPort");
    if ($NginxAuthPort == null) {
        $NginxAuthPort = "unix:/var/run/nginx-authenticator.sock";
        $sock->SET_INFO("NginxAuthPort", $NginxAuthPort);
    }
    if ($EnableArticaFrontEndToNGninx == 1) {
        shell_exec("/etc/init.d/artica-webconsole stop >/dev/null 2>&1 &");
        $ArticaHttpsPort = $sock->GET_INFO("ArticaHttpsPort");
        $ArticaHttpUseSSL = $sock->GET_INFO("ArticaHttpUseSSL");
        if (!is_numeric($ArticaHttpUseSSL)) {
            $ArticaHttpUseSSL = 1;
        }
        if (!is_numeric($ArticaHttpsPort)) {
            $ArticaHttpsPort = 9000;
        }
        $LighttpdArticaListenIP = $sock->GET_INFO('LighttpdArticaListenIP');
        $host = new nginx($ArticaHttpsPort);
        $host->set_ssl();
        $host->set_listen_ip($LighttpdArticaListenIP);
        $host->set_proxy_disabled();
        $host->set_DocumentRoot("/usr/share/artica-postfix");
        $host->set_index_file("admin.index.php");
        $host->build_proxy();
    }
    $q = new mysql();
    foreach (glob("/etc/nginx/sites-enabled-backuped/*") as $filename) {
        @unlink($filename);
    }
    @mkdir("/etc/nginx/sites-enabled-backuped", 0755, true);
    $q = new mysql_squid_builder();
    if ($GLOBALS["OUTPUT"]) {
        echo "Starting......: " . date("H:i:s") . " [INIT]: Nginx, scanning /etc/nginx/sites-enabled\n";
    }
    build_progress("Backup old config", 10);
    foreach (glob("/etc/nginx/local-sites/*") as $filename) {
        @unlink($filename);
    }
    foreach (glob("/etc/nginx/sites-enabled/*") as $filename) {
        $file = basename($filename);
        if (is_numeric($file)) {
            @unlink($filename);
            continue;
        }
        $filedetect = $file;
        if (!preg_match("#freewebs-#", $file, $re)) {
            continue;
        }
        if (preg_match("#_default_#", $file)) {
            @unlink($filename);
            continue;
        }
        $filedetect = str_replace("freewebs-ssl-", "", $filedetect);
        $filedetect = str_replace("freewebs-", "", $filedetect);
        $filedetect = str_replace("freewebs-unix-", "", $filedetect);
        if (preg_match("#([0-9])-(.+?)\\.([0-9]+)\\.conf\$#", $filedetect, $re)) {
            $filedetect = "{$re[2]}.{$re[3]}.conf";
        }
        if (preg_match("#(.+?)\\.[0-9]+\\.conf\$#", $filedetect, $re)) {
            $sitename = $re[1];
            if ($GLOBALS["OUTPUT"]) {
                echo "Starting......: " . date("H:i:s") . " [INIT]: Nginx, [{$sitename}] backup/remove {$filename}\n";
            }
            if ($GLOBALS["OUTPUT"]) {
                echo "Starting......: " . date("H:i:s") . " [INIT]: Nginx, backup \"{$file}\"\n";
            }
            @copy($filename, "/etc/nginx/sites-enabled-backuped/{$file}");
            @unlink($filename);
            continue;
        }
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: Nginx, backup \"{$file}\"\n";
        }
        @copy($filename, "/etc/nginx/sites-enabled-backuped/{$file}");
        @unlink($filename);
    }
    $NOPROXY["SARG"] = true;
    $NOPROXY["ARTICA_MINIADM"] = true;
    build_progress("Building Artica in Nginx (if set)", 10);
    BuildArticaInNginx();
    build_progress("Building authenticator", 10);
    authenticator(false);
}
コード例 #2
0
ファイル: init.inc.php プロジェクト: spookdogg/v1.0
    date_default_timezone_set(date_default_timezone_get());
}
// Global functions
require './includes/functions.inc.php';
// Set up our custom error handler.
$aGlobalErrors = array();
error_reporting(E_ALL ^ E_NOTICE);
set_error_handler('HandleError');
// Disable magic quotes if need be.
if (get_magic_quotes_gpc()) {
    $_REQUEST = dmq($_REQUEST);
}
// Connect to the database.
require './includes/db.inc.php';
// Load the configuration settings.
LoadConfigs();
// Set the global time.
$CFG['globaltime'] = $sec;
// Set upload settings.
ini_set('upload_max_filesize', $CFG['uploads']['maxsize']);
// What is this page?
$CFG['currentpage'] = substr($_SERVER['PHP_SELF'], strrpos($_SERVER['PHP_SELF'], '/') + 1, strlen($_SERVER['PHP_SELF']));
// Handle data output.
if ($CFG['general']['gzip']['enabled'] && $CFG['currentpage'] != 'avatar.php' && $CFG['currentpage'] != 'attachment.php' && $CFG['currentpage'] != 'regimage.php') {
    // Compress the page if it's enabled.
    ini_set('zlib.output_compression_level', $CFG['general']['gzip']['level']);
    ob_start('ob_gzhandler');
} else {
    if ($CFG['bufferoutput']) {
        // Buffer output if it's enabled.
        ob_start();