예제 #1
0
function config($servername)
{
    $GLOBALS["SERVICE_NAME"] = "Wordpress {$servername}";
    $unix = new unix();
    $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".{$servername}.pid";
    $pid = $unix->get_pid_from_file($pidfile);
    if ($unix->process_exists($pid, basename(__FILE__))) {
        build_progress("{$servername} Already executed", 110);
        die;
    }
    @file_put_contents($pidfile, getmypid());
    $q = new mysql();
    $cp = $unix->find_program("cp");
    $sock = new sockets();
    $Salts = null;
    $DB_HOST = $q->mysql_server;
    if ($GLOBALS["OUTPUT"]) {
        echo "Starting......: " . date("H:i:s") . " [INIT]: {$servername}: MySQL host: {$DB_HOST}\n";
    }
    if ($q->mysql_server == "127.0.0.1" or $q->mysql_server == "localhost" or $q->mysql_server == "localhost:") {
        if ($q->SocketPath == null) {
            $q->SocketPath = "/var/run/mysqld/mysqld.sock";
        }
        $DB_HOST = "localhost:{$q->SocketPath}";
    }
    if (!is_file("/usr/share/artica-postfix/bin/wp-cli.phar")) {
        build_progress("wp-cli.phar: no such binary", 110);
        return;
    }
    @chmod("/usr/share/artica-postfix/bin/wp-cli.phar", 0755);
    build_progress("{$servername}: {testing_configuration}", 40);
    $free = new freeweb($servername);
    $WORKING_DIRECTORY = $free->www_dir;
    if ($GLOBALS["OUTPUT"]) {
        echo "Starting......: " . date("H:i:s") . " [INIT]: {$servername}: Directory: {$WORKING_DIRECTORY}\n";
    }
    @unlink("{$WORKING_DIRECTORY}/wp-config.php");
    if ($GLOBALS["OUTPUT"]) {
        echo "Starting......: " . date("H:i:s") . " [INIT]: {$servername}: Duplicate: {$free->groupware_duplicate}\n";
    }
    if ($free->groupware_duplicate != null) {
        build_progress("{$servername}: {duplicate} {from} {$free->groupware_duplicate}", 40);
        if (!duplicate_wordpress($servername)) {
            build_progress("{$servername}: {installing} {failed}...", 110);
            apache_admin_mysql(0, "Failed to duplicate {$servername} from {$free->groupware_duplicate}", null, __FILE__, __LINE__);
            return;
        }
        apache_admin_mysql(2, "Success duplicate {$servername} from {$free->groupware_duplicate}", null, __FILE__, __LINE__);
        $free = new freeweb($servername);
    } else {
        if (!scan($WORKING_DIRECTORY)) {
            build_progress("{$servername}: {installing}...", 42);
            @mkdir($WORKING_DIRECTORY);
            shell_exec("{$cp} -rf /usr/share/wordpress-src/* {$WORKING_DIRECTORY}/");
            if (!scan($WORKING_DIRECTORY)) {
                apache_admin_mysql(0, "Failed to install {$servername} from /usr/share/wordpress-src", null, __FILE__, __LINE__);
                build_progress("{$servername}: {installing} {failed}...", 110);
                return;
            }
            apache_admin_mysql(2, "Success to install {$servername} from /usr/share/wordpress-src", null, __FILE__, __LINE__);
        }
    }
    $wordpressDB = $free->mysql_database;
    if ($wordpressDB == null) {
        $wordpressDB = $free->CreateDatabaseName();
        $free->mysql_database = $wordpressDB;
        $free->CreateSite(true);
    }
    $WordPressDBPass = $free->mysql_password;
    $DB_USER = $free->mysql_username;
    if ($DB_USER == "wordpress") {
        $DB_USER = null;
    }
    if ($DB_USER == null) {
        $DB_USER = "******" . time();
        $free->mysql_username = $DB_USER;
        $free->CreateSite(true);
    }
    if ($WordPressDBPass == null) {
        $WordPressDBPass = md5(time());
        $free->mysql_password = $WordPressDBPass;
        $free->CreateSite(true);
    }
    $DB_PASSWORD = $WordPressDBPass;
    if (is_file("{$WORKING_DIRECTORY}/salts.php")) {
        $Salts = @file_get_contents("{$WORKING_DIRECTORY}/salts.php");
    }
    if ($Salts == null) {
        $TMP = $unix->FILE_TEMP();
        build_progress("{$servername}: Acquiring Salts...", 44);
        $curl = new ccurl("https://api.wordpress.org/secret-key/1.1/salt/");
        if (!$curl->GetFile("{$TMP}")) {
            if ($GLOBALS["OUTPUT"]) {
                echo "Starting......: " . date("H:i:s") . " [INIT]: {$servername}: Unable to download salts !!\n";
            }
            build_progress("{$servername}: Acquiring Salts {failed}...", 110);
            return;
        }
        $ASASLT = false;
        $fa = explode("\n", @file_get_contents($TMP));
        @unlink($TMP);
        while (list($num, $ligne) = each($fa)) {
            if (preg_match("#define\\(#", $ligne)) {
                $ASASLT = true;
                break;
            }
        }
        if (!$ASASLT) {
            if ($GLOBALS["OUTPUT"]) {
                echo "Starting......: " . date("H:i:s") . " [INIT]: {$servername}: Unable to download salts !!\n";
            }
            build_progress("{$servername}: Acquiring Salts {failed}...", 110);
            return;
        }
        @file_put_contents("{$WORKING_DIRECTORY}/salts.php", @implode("\n", $fa));
    }
    build_progress("{$servername}: checking...", 48);
    if ($GLOBALS["OUTPUT"]) {
        echo "Starting......: " . date("H:i:s") . " [INIT]: {$servername}: MySQL host...........: \"{$DB_HOST}\"\n";
    }
    if (!$q->DATABASE_EXISTS($wordpressDB)) {
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: {$servername}: Create MySQL database: \"{$wordpressDB}\"\n";
        }
        $q->CREATE_DATABASE($wordpressDB);
    }
    if ($GLOBALS["OUTPUT"]) {
        echo "Starting......: " . date("H:i:s") . " [INIT]: {$servername}: MySQL database.......: \"{$wordpressDB}\"\n";
    }
    if ($GLOBALS["OUTPUT"]) {
        echo "Starting......: " . date("H:i:s") . " [INIT]: {$servername}: MySQL user...........: \"{$DB_USER}\"\n";
    }
    if ($GLOBALS["OUTPUT"]) {
        echo "Starting......: " . date("H:i:s") . " [INIT]: {$servername}: MySQL Password.......: \"{$DB_PASSWORD}\"\n";
    }
    $q->PRIVILEGES($DB_USER, $WordPressDBPass, $wordpressDB);
    $f[] = "<?php";
    $f[] = $Salts;
    $f[] = "/**";
    $f[] = " * The base configurations of the WordPress.";
    $f[] = " *";
    $f[] = " * This file has the following configurations: MySQL settings, Table Prefix,";
    $f[] = " * Secret Keys, WordPress Language, and ABSPATH. You can find more information";
    $f[] = " * by visiting {@link http://codex.wordpress.org/Editing_wp-config.php Editing";
    $f[] = " * wp-config.php} Codex page. You can get the MySQL settings from your web host.";
    $f[] = " *";
    $f[] = " * This file is used by the wp-config.php creation script during the";
    $f[] = " * installation. You don't have to use the web site, you can just copy this file";
    $f[] = " * to \"wp-config.php\" and fill in the values.";
    $f[] = " *";
    $f[] = " * @package WordPress";
    $f[] = " */";
    $f[] = "";
    $f[] = "// ** MySQL settings - You can get this info from your web host ** //";
    $f[] = "/** The name of the database for WordPress */";
    $f[] = "define('DB_NAME', '{$wordpressDB}');";
    $f[] = "";
    $f[] = "/** MySQL database username */";
    $f[] = "define('DB_USER', '{$DB_USER}');";
    $f[] = "";
    $f[] = "/** MySQL database password */";
    $f[] = "define('DB_PASSWORD', '{$DB_PASSWORD}');";
    $f[] = "";
    $f[] = "/** MySQL hostname */";
    $f[] = "define('DB_HOST', '{$DB_HOST}');";
    $f[] = "";
    $f[] = "/** Database Charset to use in creating database tables. */";
    $f[] = "define('DB_CHARSET', 'utf8');";
    $f[] = "";
    $f[] = "/** The Database Collate type. Don't change this if in doubt. */";
    $f[] = "define('DB_COLLATE', '');";
    $f[] = "";
    $f[] = "/**#@+";
    $f[] = " * Authentication Unique Keys and Salts.";
    $f[] = " *";
    $f[] = " * Change these to different unique phrases!";
    $f[] = " * You can generate these using the {@link https://api.wordpress.org/secret-key/1.1/salt/ WordPress.org secret-key service}";
    $f[] = " * You can change these at any point in time to invalidate all existing cookies. This will force all users to have to log in again.";
    $f[] = " *";
    $f[] = " * @since 2.6.0";
    $f[] = " */";
    $f[] = "";
    $f[] = "/**#@-*/";
    $f[] = "";
    $f[] = "/**";
    $f[] = " * WordPress Database Table prefix.";
    $f[] = " *";
    $f[] = " * You can have multiple installations in one database if you give each a unique";
    $f[] = " * prefix. Only numbers, letters, and underscores please!";
    $f[] = " */";
    $f[] = "\$table_prefix  = 'wp_';";
    $f[] = "";
    $f[] = "/**";
    $f[] = " * WordPress Localized Language, defaults to English.";
    $f[] = " *";
    $f[] = " * Change this to localize WordPress. A corresponding MO file for the chosen";
    $f[] = " * language must be installed to wp-content/languages. For example, install";
    $f[] = " * de_DE.mo to wp-content/languages and set WPLANG to 'de_DE' to enable German";
    $f[] = " * language support.";
    $f[] = " */";
    $f[] = "define('WPLANG', '');";
    $f[] = "";
    $f[] = "/**";
    $f[] = " * For developers: WordPress debugging mode.";
    $f[] = " *";
    $f[] = " * Change this to true to enable the display of notices during development.";
    $f[] = " * It is strongly recommended that plugin and theme developers use WP_DEBUG";
    $f[] = " * in their development environments.";
    $f[] = " */";
    $f[] = "define('WP_DEBUG', false);";
    $f[] = "";
    $f[] = "/* That's all, stop editing! Happy blogging. */";
    $f[] = "";
    $f[] = "/** Absolute path to the WordPress directory. */";
    $f[] = "if ( !defined('ABSPATH') )";
    $f[] = "\tdefine('ABSPATH', dirname(__FILE__) . '/');";
    $f[] = "";
    $f[] = "/** Sets up WordPress vars and included files. */";
    $f[] = "require_once(ABSPATH . 'wp-settings.php');";
    $f[] = "?>";
    @file_put_contents("{$WORKING_DIRECTORY}/wp-config.php", @implode("\n", $f));
    build_progress("{$servername}: wp-config.php {done}...", 50);
    if ($GLOBALS["OUTPUT"]) {
        echo "Starting......: " . date("H:i:s") . " [INIT]: {$servername}: {$WORKING_DIRECTORY}/wp-config.php done...\n";
    }
    $f = array();
    $f[] = "<?php";
    $f[] = "/*";
    $f[] = "WP-Cache Config Sample File";
    $f[] = "";
    $f[] = "See wp-cache.php for author details.";
    $f[] = "*/";
    $f[] = "";
    $f[] = "if ( ! defined('WPCACHEHOME') )";
    $f[] = "\tdefine( 'WPCACHEHOME', WP_PLUGIN_DIR . '/wp-super-cache/' );";
    $f[] = "";
    $f[] = "\$cache_compression = 0; // Super cache compression";
    $f[] = "\$cache_enabled = false;";
    $f[] = "\$super_cache_enabled = false;";
    $f[] = "\$cache_max_time = 3600; //in seconds";
    $f[] = "//\$use_flock = true; // Set it true or false if you know what to use";
    $f[] = "\$cache_path = WP_CONTENT_DIR . '/cache/';";
    $f[] = "\$file_prefix = 'wp-cache-';";
    $f[] = "\$ossdlcdn = 0;";
    $f[] = "";
    $f[] = "// Array of files that have 'wp-' but should still be cached";
    $f[] = "\$cache_acceptable_files = array( 'wp-comments-popup.php', 'wp-links-opml.php', 'wp-locations.php' );";
    $f[] = "";
    $f[] = "\$cache_rejected_uri = array('wp-.*\\.php', 'index\\.php');";
    $f[] = "\$cache_rejected_user_agent = array ( 0 => 'bot', 1 => 'ia_archive', 2 => 'slurp', 3 => 'crawl', 4 => 'spider', 5 => 'Yandex' );";
    $f[] = "";
    $f[] = "\$cache_rebuild_files = 1;";
    $f[] = "";
    $f[] = "// Disable the file locking system.";
    $f[] = "// If you are experiencing problems with clearing or creating cache files";
    $f[] = "// uncommenting this may help.";
    $f[] = "\$wp_cache_mutex_disabled = 1;";
    $f[] = "";
    $f[] = "// Just modify it if you have conflicts with semaphores";
    $f[] = "\$sem_id = 5419;";
    $f[] = "";
    $f[] = "if ( '/' != substr(\$cache_path, -1)) {";
    $f[] = "\t\$cache_path .= '/';";
    $f[] = "}";
    $f[] = "";
    $f[] = "\$wp_cache_mobile = 0;";
    $f[] = "\$wp_cache_mobile_whitelist = 'Stand Alone/QNws';";
    $f[] = "\$wp_cache_mobile_browsers = 'Android, 2.0 MMP, 240x320, AvantGo, BlackBerry, Blazer, Cellphone, Danger, DoCoMo, Elaine/3.0, EudoraWeb, hiptop, IEMobile, iPhone, iPod, KYOCERA/WX310K, LG/U990, MIDP-2.0, MMEF20, MOT-V, NetFront, Newt, Nintendo Wii, Nitro, Nokia, Opera Mini, Palm, Playstation Portable, portalmmm, Proxinet, ProxiNet, SHARP-TQ-GX10, Small, SonyEricsson, Symbian OS, SymbianOS, TS21i-10, UP.Browser, UP.Link, Windows CE, WinWAP';";
    $f[] = "";
    $f[] = "// change to relocate the supercache plugins directory";
    $f[] = "\$wp_cache_plugins_dir = WPCACHEHOME . 'plugins';";
    $f[] = "// set to 1 to do garbage collection during normal process shutdown instead of wp-cron";
    $f[] = "\$wp_cache_shutdown_gc = 0;";
    $f[] = "\$wp_super_cache_late_init = 0;";
    $f[] = "";
    $f[] = "// uncomment the next line to enable advanced debugging features";
    $f[] = "\$wp_super_cache_advanced_debug = 0;";
    $f[] = "\$wp_super_cache_front_page_text = '';";
    $f[] = "\$wp_super_cache_front_page_clear = 0;";
    $f[] = "\$wp_super_cache_front_page_check = 0;";
    $f[] = "\$wp_super_cache_front_page_notification = '0';";
    $f[] = "";
    $f[] = "\$wp_cache_object_cache = 0;";
    $f[] = "\$wp_cache_anon_only = 0;";
    $f[] = "\$wp_supercache_cache_list = 0;";
    $f[] = "\$wp_cache_debug_to_file = 0;";
    $f[] = "\$wp_super_cache_debug = 0;";
    $f[] = "\$wp_cache_debug_level = 5;";
    $f[] = "\$wp_cache_debug_ip = '';";
    $f[] = "\$wp_cache_debug_log = '';";
    $f[] = "\$wp_cache_debug_email = '';";
    $f[] = "\$wp_cache_pages[ \"search\" ] = 0;";
    $f[] = "\$wp_cache_pages[ \"feed\" ] = 0;";
    $f[] = "\$wp_cache_pages[ \"category\" ] = 0;";
    $f[] = "\$wp_cache_pages[ \"home\" ] = 0;";
    $f[] = "\$wp_cache_pages[ \"frontpage\" ] = 0;";
    $f[] = "\$wp_cache_pages[ \"tag\" ] = 0;";
    $f[] = "\$wp_cache_pages[ \"archives\" ] = 0;";
    $f[] = "\$wp_cache_pages[ \"pages\" ] = 0;";
    $f[] = "\$wp_cache_pages[ \"single\" ] = 0;";
    $f[] = "\$wp_cache_pages[ \"author\" ] = 0;";
    $f[] = "\$wp_cache_hide_donation = 0;";
    $f[] = "\$wp_cache_not_logged_in = 0;";
    $f[] = "\$wp_cache_clear_on_post_edit = 0;";
    $f[] = "\$wp_cache_hello_world = 0;";
    $f[] = "\$wp_cache_mobile_enabled = 0;";
    $f[] = "\$wp_cache_cron_check = 0;";
    $f[] = "?>";
    if (is_file("{$WORKING_DIRECTORY}/wp-content/plugins/wp-super-cache/wp-cache-config-sample.php")) {
        @file_put_contents("{$WORKING_DIRECTORY}/wp-content/plugins/wp-super-cache/wp-cache-config.php", @implode("\n", $f));
    }
    @file_put_contents("{$WORKING_DIRECTORY}/wp-config.php", @implode("\n", $f));
    build_progress("{$servername}: wp-config.php {done}...", 50);
    if ($GLOBALS["OUTPUT"]) {
        echo "Starting......: " . date("H:i:s") . " [INIT]: {$servername}: {$WORKING_DIRECTORY}/wp-config.php done...\n";
    }
    if ($GLOBALS["OUTPUT"]) {
        echo "Starting......: " . date("H:i:s") . " [INIT]: {$servername}: Testing configuration...\n";
    }
    if ($free->groupware_admin == null) {
        $ldap = new clladp();
        $free->groupware_admin = $ldap->ldap_admin;
        $free->groupware_password = $ldap->ldap_password;
    }
    $admin = $unix->shellEscapeChars($free->groupware_admin);
    $password = $unix->shellEscapeChars($free->groupware_password);
    $WORKING_DIRECTORY_CMDLINE = $unix->shellEscapeChars($WORKING_DIRECTORY);
    $cmd = array();
    $cmd[] = "/usr/share/artica-postfix/bin/wp-cli.phar core install";
    $cmd[] = "--url=\"{$servername}\"";
    $cmd[] = "--title=\"{$servername}\"";
    $cmd[] = "--admin_user={$admin}";
    $cmd[] = "--admin_password={$password}";
    $cmd[] = "--admin_email={$admin}@{$servername}";
    $cmd[] = "--path={$WORKING_DIRECTORY_CMDLINE}";
    $cmd[] = "--allow-root --debug --no-color 2>&1";
    $cmdline = @implode(" ", $cmd);
    if ($GLOBALS["OUTPUT"]) {
        echo "Starting......: " . date("H:i:s") . " [INIT]: {$servername}: {$cmdline}\n";
    }
    build_progress("{$servername}: {install_wordpress} {please_wait} !...", 51);
    exec($cmdline, $results1);
    while (list($num, $ligne) = each($results1)) {
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: {$servername}: {$ligne}\n";
        }
    }
    build_progress("{$servername}: {enforce_security}", 52);
    secure_wp($WORKING_DIRECTORY);
    build_progress("{$servername}: {directory_size}", 53);
    $size = $unix->DIRSIZE_BYTES($free->WORKING_DIRECTORY);
    if ($GLOBALS["OUTPUT"]) {
        echo "Starting......: " . date("H:i:s") . " [INIT]: {$servername}: {$free->WORKING_DIRECTORY} {$size}Bytes\n";
    }
    $q->QUERY_SQL("UPDATE freeweb SET DirectorySize={$size} WHERE servername='{$servername}'", "artica_backup");
    if (!$q->ok) {
        system_admin_events("{$q->mysql_error}", __FUNCTION__, __FILE__, __LINE__, "freewebs");
    }
}
예제 #2
0
function DUMP_FULL($MAIN)
{
    $backupdir = "/home/apache/artica-stats/works/backup";
    $failedPath = "/home/apache/artica-stats/works/failed";
    @mkdir($backupdir, 0755, true);
    @mkdir($failedPath, 0755, true);
    $PROXYNAME = $GLOBALS["MYHOSTNAME_PROXY"];
    $AS_POSTGRES = false;
    $suffix = "influx";
    if (is_file("/usr/local/ArticaStats/bin/postgres")) {
        $AS_POSTGRES = true;
        $suffix = "postgres";
    }
    $prefix = "(zDate,IPADDR,SITENAME,HTTP_CODE,RQS,SIZE,PROXYNAME)";
    $q = new influx();
    $FINAL = array();
    while (list($MD5, $ARRAY) = each($MAIN)) {
        $SIZE = $ARRAY["SIZE"];
        $RQS = $ARRAY["RQS"];
        $SITENAME = $ARRAY["SITENAME"];
        $DATE = $ARRAY["DATE"];
        $INFLUX_TIME = $ARRAY["INFLUX_TIME"];
        $IPADDR = $ARRAY["IPADDR"];
        $HTTP_CODE = $ARRAY["HTTP_CODE"];
        $zDate = $ARRAY["DATE"];
        if ($AS_POSTGRES) {
            $FINAL[] = "('{$zDate}','{$IPADDR}','{$SITENAME}','{$HTTP_CODE}','{$RQS}','{$SIZE}','{$PROXYNAME}')";
            continue;
        }
        $zArray["precision"] = "s";
        $zArray["time"] = $INFLUX_TIME;
        $zArray["fields"]["RQS"] = $RQS;
        $zArray["fields"]["SIZE"] = $SIZE;
        $zArray["fields"]["HTTP_CODE"] = $HTTP_CODE;
        $zArray["tags"]["SITENAME"] = $SITENAME;
        $zArray["tags"]["IPADDR"] = $IPADDR;
        $line = $q->prepare("apache_size", $zArray);
        $FINAL[] = $line;
    }
    if (count($FINAL) > 0) {
        $backupfile = "{$backupdir}/apache." . time() . ".{$suffix}.log";
        $failedPath = "{$failedPath}/apache." . time() . ".{$suffix}.log";
        if ($AS_POSTGRES) {
            $sql = "INSERT INTO apache_size {$prefix} VALUES " . @implode(",", $FINAL);
            $q = new postgres_sql();
            $q->QUERY_SQL($sql);
            if (!$q->ok) {
                events("INJECTION Failed: backup to {$failedPath} ({$q->curl_error})");
                @file_put_contents($failedPath, @implode("\n", $sql));
                return false;
            }
        }
        if (!$AS_POSTGRES) {
            if (!$q->bulk_inject($FINAL)) {
                apache_admin_mysql(0, "INJECTION Failed ({$q->curl_error})", ": backup to {$failedPath}", __FILE__, __LINE__);
                @file_put_contents($failedPath, @implode("\n", $FINAL));
                sleep(1);
                return true;
            }
        }
        events("INJECTION Success: backup to {$backupfile}");
        @file_put_contents($backupfile, @implode("\n", $FINAL));
        $FINAL = array();
    }
    sleep(1);
    return true;
}
예제 #3
0
function ftp_backup($WordpressBackupParams)
{
    $sock = new sockets();
    $mount = new mount();
    $unix = new unix();
    $rm = $unix->find_program("rm");
    $FTP_ENABLE = intval($WordpressBackupParams["FTP_ENABLE"]);
    if ($FTP_ENABLE == 0) {
        echo "FTP disbabled\n";
        return;
    }
    $FTP_SERVER = $WordpressBackupParams["FTP_ENABLE"];
    $FTP_USER = $WordpressBackupParams["FTP_USER"];
    $FTP_PASS = $WordpressBackupParams["FTP_PASS"];
    $FTP_SERVER = $WordpressBackupParams["FTP_SERVER"];
    $mntDir = "/home/artica/mnt-wordpress-" . time();
    @mkdir($mntDir, 0755, true);
    if (!$mount->ftp_mount($mntDir, $FTP_SERVER, $FTP_USER, $FTP_PASS)) {
        apache_admin_mysql(0, "Unable to mount FTP {$FTP_USER}@{$FTP_SERVER}", null, __FILE__, __LINE__);
        return;
    }
    $FTPDir = "{$mntDir}/" . $unix->hostname_g() . "/wordpress-backup";
    echo "Starting copy... in {$FTPDir}\n";
    if ($GLOBALS["VERBOSE"]) {
        echo "Checks {$FTPDir}\n";
    }
    if (!is_dir($FTPDir)) {
        if ($GLOBALS["VERBOSE"]) {
            echo "{$FTPDir} no such directory\n";
        }
        @mkdir($FTPDir, 0755, true);
    }
    if (!is_dir($FTPDir)) {
        apache_admin_mysql(0, "Fatal FTP {$FTP_USER}@{$FTP_SERVER} {$FTPDir} permission denied", null, __FILE__, __LINE__);
        $mount->umount($mntDir);
        @rmdir($mntDir);
        return;
    }
    $directories_servernames = $unix->dirdir($WordpressBackupParams["DEST"]);
    $cp = $unix->find_program("cp");
    while (list($directory, $ext) = each($directories_servernames)) {
        $dirRoot = basename($directory);
        $TargetDirectory = "{$FTPDir}/{$dirRoot}";
        if (!is_dir($TargetDirectory)) {
            if ($GLOBALS["VERBOSE"]) {
                echo "Create directory {$TargetDirectory}\n";
            }
            @mkdir($TargetDirectory, 0755, true);
        }
        if (!is_dir($TargetDirectory)) {
            apache_admin_mysql(0, "Fatal FTP {$FTP_USER}@{$FTP_SERVER} {$TargetDirectory} permission denied", __FILE__, __LINE__);
            continue;
        }
        if ($GLOBALS["VERBOSE"]) {
            echo "Scaning {$directory}\n";
        }
        $directories_conteners = $unix->dirdir($directory);
        while (list($directoryTime, $ext) = each($directories_conteners)) {
            $dirRootTime = basename($directoryTime);
            $TargetDirectory = "{$FTPDir}/{$dirRoot}/{$dirRootTime}";
            @mkdir($TargetDirectory, 0755, true);
            if (!is_dir($TargetDirectory)) {
                apache_admin_mysql(0, "Fatal FTP {$FTP_USER}@{$FTP_SERVER} {$TargetDirectory} permission denied", __FILE__, __LINE__);
                continue;
            }
            if (!is_file("{$directoryTime}/database.gz")) {
                apache_admin_mysql(0, "Fatal {$directoryTime}/database.gz no such file, skip", null, __FILE__, __LINE__);
                continue;
            }
            $t = time();
            $results = array();
            if ($GLOBALS["VERBOSE"]) {
                echo "Copy {$directoryTime}/* -> {$TargetDirectory}\n";
            }
            exec("{$cp} -rf {$directoryTime}/* {$TargetDirectory}/ 2>&1", $results);
            while (list($a, $b) = each($results)) {
                if (preg_match("#cannot#i", $b)) {
                    apache_admin_mysql(0, "Fatal Copy error {$b}, skip", $b, __FILE__, __LINE__);
                }
            }
            $took = $unix->distanceOfTimeInWords($t, time());
            if (!is_file("{$TargetDirectory}/database.gz")) {
                apache_admin_mysql(0, "Fatal {$TargetDirectory}/database.gz permission denied, skip", null, __FILE__, __LINE__);
                continue;
            }
            shell_exec("{$rm} -rf {$directoryTime}");
        }
    }
    $mount->umount($mntDir);
    @rmdir($mntDir);
    return;
}
예제 #4
0
function startApache($withoutkill = false, $aspid = false)
{
    $unix = new unix();
    if (is_file("/etc/artica-postfix/FROM_ISO")) {
        if ($unix->file_time_min("/etc/artica-postfix/FROM_ISO") < 1) {
            return;
        }
    }
    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]: Apache Already Artica task running PID {$pid} since {$time}mn\n";
            }
            return;
        }
        @file_put_contents($pidfile, getmypid());
    }
    if (!isset($GLOBALS["startApacheCount"])) {
        $GLOBALS["startApacheCount"] = 0;
    }
    $GLOBALS["startApacheCount"] = $GLOBALS["startApacheCount"] + 1;
    $EnableFreeWeb = intval($GLOBALS["CLASS_SOCKETS"]->GET_INFO("EnableFreeWeb"));
    $SquidPerformance = intval($GLOBALS["CLASS_SOCKETS"]->GET_INFO("SquidPerformance"));
    $EnableIntelCeleron = intval($GLOBALS["CLASS_SOCKETS"]->GET_INFO("EnableIntelCeleron"));
    $SquidAllow80Port = intval($GLOBALS["CLASS_SOCKETS"]->GET_INFO("SquidAllow80Port"));
    if ($SquidPerformance > 2) {
        $EnableFreeWeb = 0;
    }
    if ($EnableIntelCeleron == 1) {
        $EnableFreeWeb = 0;
    }
    if ($SquidAllow80Port == 1) {
        $EnableFreeWeb = 0;
    }
    if (is_file("/etc/httpd/conf.d/ssl.conf")) {
        @unlink("/etc/httpd/conf.d/ssl.conf");
    }
    if ($GLOBALS["startApacheCount"] > 3) {
        echo "Starting......: " . date("H:i:s") . " [INIT]: Apache failed, too many start:{$GLOBALS["startApacheCount"]}...\n";
        return;
    }
    if (!is_file("/usr/lib/apache2/mpm-prefork/apache2")) {
        $ln = $unix->find_program("ln");
        echo "Starting......: " . date("H:i:s") . " [INIT]: Apache failed, linking /usr/lib/apache2/mpm-prefork/apache2\n";
        shell_exec("{$ln} -sf /usr/lib/apache2/mpm-prefork/apache2 /usr/sbin/apache2 >/dev/null 2>&1");
    }
    $APACHE_PID_PATH = $GLOBALS["CLASS_UNIX"]->APACHE_PID_PATH();
    $APACHE_BIN_PATH = $GLOBALS["CLASS_UNIX"]->LOCATE_APACHE_BIN_PATH();
    if (!is_file($APACHE_BIN_PATH)) {
        echo "Starting......: " . date("H:i:s") . " [INIT]: Apache failed no binary found, re-install it ( if debian )\n";
        APACHE_INSTALL_DEBIAN();
        return;
    }
    $apache2ctl = $GLOBALS["CLASS_UNIX"]->find_program("apache2ctl");
    if (!is_file($apache2ctl)) {
        $apache2ctl = $GLOBALS["CLASS_UNIX"]->find_program("apachectl");
    }
    $pid = $GLOBALS["CLASS_UNIX"]->get_pid_from_file($APACHE_PID_PATH);
    if ($GLOBALS["CLASS_UNIX"]->process_exists($pid)) {
        $timep = $unix->PROCESS_UPTIME($pid);
        echo "Starting......: " . date("H:i:s") . " [INIT]: Apache already started pid {$pid} {$timep} [{$APACHE_PID_PATH}]\n";
        if ($EnableFreeWeb == 0) {
            StopApache();
            return;
        }
        return;
    }
    $sysctl = $unix->find_program("sysctl");
    shell_exec("{$sysctl} -w kernel.msgmni=1024 >/dev/null 2>&1");
    shell_exec("{$sysctl} -w \"kernel.sem=250 256000 32 1024\" >/dev/null 2>&1");
    shell_exec("{$sysctl} -p >/dev/null 2>&1");
    if ($EnableFreeWeb == 0) {
        echo "Starting......: " . date("H:i:s") . " [INIT]: Apache Disabled ( see EnableFreeWeb({$EnableFreeWeb})/SquidAllow80Port({$SquidAllow80Port})/EnableIntelCeleron({$EnableIntelCeleron})/SquidPerformance({$SquidPerformance}) tokens )\n";
        return;
    }
    echo "Starting......: " . date("H:i:s") . " [INIT]: Apache {$GLOBALS["startApacheCount"]} time(s)\n";
    $files = $unix->DirFiles("/usr/share/artica-postfix/bin");
    while (list($filename, $line) = each($files)) {
        @chmod("/usr/share/artica-postfix/bin/{$filename}", 0755);
        @chown("/usr/share/artica-postfix/bin/{$filename}", "root");
    }
    @chmod("/usr/share/artica-postfix/ressources/mem.pl", 0755);
    if (!is_file($apache2ctl)) {
        return;
    }
    apache_permissions();
    $LOCATE_APACHE_CONF_PATH = $GLOBALS["CLASS_UNIX"]->LOCATE_APACHE_CONF_PATH();
    $kill = $GLOBALS["CLASS_UNIX"]->find_program("kill");
    $cmd = "{$apache2ctl} -f {$LOCATE_APACHE_CONF_PATH} -k start 2>&1";
    echo "Starting......: " . date("H:i:s") . " [INIT]: apache2 bin \"{$APACHE_BIN_PATH}\"\n";
    echo "Starting......: " . date("H:i:s") . " [INIT]: apache2ctl: \"{$apache2ctl}\"\n";
    echo "Starting......: " . date("H:i:s") . " [INIT]: PID Path..: \"{$APACHE_PID_PATH}\"\n";
    exec($cmd, $results);
    $hostname = $unix->hostname_g();
    $hostname_ip = $unix->get_EtcHostsByName("{$hostname}");
    echo "Starting......: " . date("H:i:s") . " [INIT]: Apache {$hostname} = {$hostname_ip}\n";
    if ($hostname_ip == null) {
        $echo = $unix->find_program("echo");
        echo "Starting......: " . date("H:i:s") . " [INIT]: Apache Add {$hostname} in /etc/hosts\n";
        shell_exec("{$echo} \"127.0.0.1\t{$hostname}\" >>/etc/hosts");
    }
    $hostname_ip = $unix->get_EtcHostsByName("localhost");
    echo "Starting......: " . date("H:i:s") . " [INIT]: Apache localhost = {$hostname_ip}\n";
    if ($hostname_ip == null) {
        $echo = $unix->find_program("echo");
        echo "Starting......: " . date("H:i:s") . " [INIT]: Apache Add localhost in /etc/hosts\n";
        shell_exec("{$echo} \"127.0.0.1\tlocalhost\" >>/etc/hosts");
    }
    while (list($num, $ligne) = each($results)) {
        if (apachectl_line_skip($ligne)) {
            continue;
        }
        if (preg_match("#Cannot load .+?mod_dav_fs.+?into server#", $ligne)) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: Apache {$ligne}\n";
            echo "Starting......: " . date("H:i:s") . " [INIT]: Apache mod_dav_fs failed, disable it\n";
            $sock = new sockets();
            $sock->SET_INFO("ApacheDisableModDavFS", 1);
            CheckHttpdConf();
            continue;
        }
        if (preg_match("#Cannot load.*?mod_status\\.so.*?undefined symbol#", $ligne)) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: Apache {$ligne}\n";
            echo "Starting......: " . date("H:i:s") . " [INIT]: Apache mod_status failed, disable it\n";
            $sock = new sockets();
            $sock->SET_INFO("ApacheDisableModStatus", 1);
            CheckHttpdConf();
            continue;
        }
        if (preg_match("#Error retrieving pid file\\s+(.+)#", $ligne, $re)) {
            $re[1] = trim($re[1]);
            echo "Starting......: " . date("H:i:s") . " [INIT]: Apache, removing {$re[1]}\n";
            @unlink(trim($re[1]));
            startApache(true, true);
            return;
        }
        if (preg_match("#httpd.+?pid\\s+([0-9]+)\\) already running#", $ligne, $re)) {
            if (!$withoutkill) {
                echo "Starting......: " . date("H:i:s") . " [INIT]: Apache killing PID {$re[1]}\n";
                unix_system_kill_force($re[1]);
                KillApacheProcesses();
                startApache(true, true);
                return;
            } else {
                echo "Starting......: " . date("H:i:s") . " [INIT]: Apache restart\n";
                shell_exec("{$apache2ctl} restart");
                continue;
            }
        }
        if (preg_match("#Address already in use: make_sock:\\s+could not bind to address\\s+(.+)\$#", $ligne, $re)) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: Apache ERROR {$ligne}\n";
            sleep(1);
            if (!$withoutkill) {
                KillApacheProcesses($re[1]);
                startApache(true, true);
                return;
            }
        }
        echo "Starting......: " . date("H:i:s") . " [INIT]: Apache {$ligne} [INFO]\n";
    }
    $APACHE_PID_PATH = $GLOBALS["CLASS_UNIX"]->APACHE_PID_PATH();
    $unix = new unix();
    sleep(2);
    $pid = $unix->get_pid_from_file($APACHE_PID_PATH);
    if (!$unix->process_exists($pid)) {
        apache_admin_mysql(0, "Apache Web failed to be started [action=info]", @implode("\n", $results), __FILE__, __LINE__);
        echo "Starting......: " . date("H:i:s") . " [INIT]: Apache Failed [{$APACHE_PID_PATH}]\n";
        return;
    }
    apache_admin_mysql(1, "Apache Web success to be started [action=info]", @implode("\n", $results), __FILE__, __LINE__);
    echo "Starting......: " . date("H:i:s") . " [INIT]: Apache Success pid {$pid}\n";
    $nginx = $GLOBALS["CLASS_UNIX"]->find_program("nginx");
    if (is_file($nginx)) {
        shell_exec("/etc/init.d/nginx start");
    }
}
예제 #5
0
function execute_mysql($OnlyID = 0)
{
    $GLOBALS["INDEXED"] = 0;
    $GLOBALS["SKIPPED"] = 0;
    $GLOBALS["DIRS"] = array();
    $unix = new unix();
    $httrack = $unix->find_program("httrack");
    if (!is_file($httrack)) {
        apache_admin_mysql(0, "httrack no such binary", null, __FILE__, __LINE__, "webcopy");
        return;
    }
    $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
    $pid = $unix->get_pid_from_file($pidfile);
    if ($unix->process_exists($pid, basename(__FILE__))) {
        apache_admin_mysql(1, "Already instance executed", null, __FILE__, __LINE__, "webcopy");
        return;
    }
    $ini = new Bs_IniHandler();
    $sock = new sockets();
    $datas = $sock->GET_INFO("ArticaProxySettings");
    if (trim($datas) != null) {
        $ini->loadString($datas);
        if (!isset($ini->_params["PROXY"]["ArticaProxyServerEnabled"])) {
            $ini->_params["PROXY"]["ArticaProxyServerEnabled"] = "no";
        }
        $ArticaProxyServerEnabled = $ini->_params["PROXY"]["ArticaProxyServerEnabled"];
        $ArticaProxyServerName = $ini->_params["PROXY"]["ArticaProxyServerName"];
        $ArticaProxyServerPort = $ini->_params["PROXY"]["ArticaProxyServerPort"];
        $ArticaProxyServerUsername = trim($ini->_params["PROXY"]["ArticaProxyServerUsername"]);
        $ArticaProxyServerUserPassword = $ini->_params["PROXY"]["ArticaProxyServerUserPassword"];
        if ($ArticaProxyServerEnabled == 1) {
            $ArticaProxyServerEnabled = "yes";
        }
    }
    $PPRoxy = null;
    $userPP = null;
    if ($ArticaProxyServerEnabled == "yes") {
        if ($ArticaProxyServerUsername != null) {
            $userPP = "{$ArticaProxyServerUsername}:{$ArticaProxyServerUserPassword}@";
        }
        $PPRoxy = " --proxy {$userPP}@{$ArticaProxyServerName}:{$ArticaProxyServerPort}";
    } else {
        $squidbin = $unix->LOCATE_SQUID_BIN();
        if (is_file($squidbin)) {
            $SQUIDEnable = $sock->GET_INFO("SQUIDEnable");
            if (!is_numeric($SQUIDEnable)) {
                $SQUIDEnable = 1;
            }
            $SquidMgrListenPort = intval($sock->GET_INFO("SquidMgrListenPort"));
            $PPRoxy = " --proxy 127.0.0.1:{$SquidMgrListenPort}";
        }
    }
    $getmypid = getmypid();
    @file_put_contents($pidfile, $getmypid);
    $php = $unix->LOCATE_PHP5_BIN();
    $APACHE_USERNAME = $unix->APACHE_SRC_ACCOUNT();
    $APACHE_SRC_GROUP = $unix->APACHE_SRC_GROUP();
    $q = new mysql();
    $nice = EXEC_NICE();
    $sql = "SELECT * FROM httrack_sites WHERE enabled=1";
    $results = $q->QUERY_SQL($sql, "artica_backup");
    if (!$q->ok) {
        apache_admin_mysql(0, "Fatal: {$q->mysql_error}", null, __FILE__, __LINE__, "webcopy");
        return;
    }
    $t1 = time();
    $count = 0;
    if ($OnlyID > 0) {
        $ligne2 = mysql_fetch_array($q->QUERY_SQL("SELECT sitename FROM httrack_sites WHERE ID={$OnlyID}", "artica_backup"));
        $log_exp = " only for [{$ligne2["sitename"]}] ";
    }
    apache_admin_mysql(2, "Starting executing WebCopy task {$log_exp} pid:{$getmypid}", null, __FILE__, __LINE__, "webcopy");
    $dirsizeG = 0;
    while ($ligne = mysql_fetch_assoc($results)) {
        if ($OnlyID > 0) {
            if ($ligne["ID"] != $OnlyID) {
                continue;
            }
        }
        $t = time();
        $count++;
        $workingdir = $ligne["workingdir"];
        $sitename = $ligne["sitename"];
        $minrate = $ligne["minrate"];
        $maxfilesize = $ligne["maxfilesize"];
        $maxsitesize = $ligne["maxsitesize"];
        $size = $ligne["size"];
        $sizeKB = $size / 1024;
        $sizeMB = round($sizeKB / 1024, 2);
        $maxworkingdir = intval($ligne["maxworkingdir"]);
        if ($maxworkingdir == 0) {
            $maxworkingdir = 20;
        }
        $maxsitesizeMB = $maxsitesize / 1000;
        if ($maxsitesizeMB > $maxworkingdir) {
            $maxsitesize = $maxworkingdir * 1000;
        }
        if ($sizeMB > $maxworkingdir) {
            apache_admin_mysql(1, "Skip downloading content of {$sitename} Directory: {$sizeMB}MB reach limit of {$maxworkingdir}MB", null, __FILE__, __LINE__, "webcopy");
            continue;
        }
        if ($GLOBALS["VERBOSE"]) {
            echo "Dir: Current size:{$sizeMB}\n";
            echo "Dir: Max size:{$maxworkingdir}\n";
        }
        $ResteMB = $maxworkingdir - $sizeMB;
        $ResteKB = $ResteMB * 1000;
        if ($maxsitesize > $ResteKB) {
            $maxsitesize = $ResteKB;
        }
        echo "Dir: Max Downloads:{$maxsitesize} KB\n";
        $maxfilesize = $maxfilesize * 1000;
        $maxsitesize = $maxsitesize * 1000;
        $minrate = $minrate * 1000;
        $update = null;
        $resultsCMD = array();
        echo "Dir: Max Downloads:{$maxsitesize} Bytes\n";
        if (!is_dir($workingdir)) {
            @mkdir($workingdir, 0755, true);
        }
        if (is_file("{$workingdir}/hts-cache")) {
            $update = " --update";
        }
        apache_admin_mysql(2, "Starting downloading content of {$sitename}/{$minrate}/" . FormatBytes($maxsitesize / 1000), null, __FILE__, __LINE__, "webcopy");
        $cmdline = "{$httrack} \"{$sitename}\" --quiet{$update}{$PPRoxy} --max-files={$maxfilesize} --max-size={$maxsitesize} --max-rate={$minrate} -O \"{$workingdir}\" 2>&1";
        if ($GLOBALS["VERBOSE"]) {
            echo "{$cmdline}\n";
        }
        exec($cmdline, $resultsCMD);
        if ($GLOBALS["VERBOSE"]) {
            echo @implode("\n", $resultsCMD);
        }
        $dirsize = $unix->DIRSIZE_BYTES($workingdir);
        $dirsizeG = $dirsizeG + $dirsize;
        $took = $unix->distanceOfTimeInWords($t, time(), true);
        $dirsizeText = round($dirsize / 1024 / 1000, 2);
        if ($GLOBALS["VERBOSE"]) {
            echo "Dir: Current size:{$sizeMB}\n";
            echo "Dir: New size....:{$dirsizeText}MB\n";
        }
        apache_admin_mysql(2, "{$sitename} scrapped took {$took} size={$dirsizeText} MB", @implode("\n", $resultsCMD), __FILE__, __LINE__, "webcopy");
        $q->QUERY_SQL("UPDATE httrack_sites SET size='{$dirsize}' WHERE ID={$ligne["ID"]}", "artica_backup");
    }
    $took = $unix->distanceOfTimeInWords($t1, time(), true);
    @chmod($workingdir, 0755);
    @chmod(dirname($workingdir), 0755);
    $chown = $unix->find_program("chown");
    shell_exec("{$chown} -R {$APACHE_USERNAME}:{$APACHE_SRC_GROUP} {$workingdir}");
    @file_put_contents("/etc/artica-postfix/settings/Daemons/HTTRackSize", $dirsizeG);
    if ($count > 0) {
        apache_admin_mysql(2, "{$count} web sites scrapped took {$took}", null, __FILE__, __LINE__, "webcopy");
    }
    system("{$php} /usr/share/artica-postfix/exec.syslog-engine.php --apache");
}
예제 #6
0
function nginx()
{
    $bin = $GLOBALS["CLASS_UNIX"]->find_program("nginx");
    if (!is_file($bin)) {
        $GLOBALS["CLASS_USERS"]->NGINX_INSTALLED = false;
    }
    $MEMORY = $GLOBALS["CLASS_UNIX"]->MEM_TOTAL_INSTALLEE();
    if ($MEMORY < 624288) {
        return;
    }
    if (!$GLOBALS["CLASS_USERS"]->NGINX_INSTALLED) {
        $cmd = trim("{$GLOBALS["NICE"]}{$GLOBALS["PHP5"]} " . dirname(__FILE__) . "/exec.nginx.php --install-nginx >/dev/null 2>&1 &");
        shell_exec2($cmd);
        if ($GLOBALS["VERBOSE"]) {
            echo __FUNCTION__ . " not installed\n";
        }
        return null;
    }
    $enabled = intval(@file_get_contents("/etc/artica-postfix/settings/Daemons/EnableNginx"));
    $SquidAllow80Port = intval($GLOBALS["CLASS_SOCKETS"]->GET_INFO("SquidAllow80Port"));
    if ($SquidAllow80Port == 1) {
        $enabled = 0;
    }
    $pid_path = "/var/run/nginx.pid";
    $master_pid = trim(@file_get_contents($pid_path));
    $l[] = "[APP_NGINX]";
    $l[] = "service_name=APP_NGINX";
    $l[] = "master_version=" . nginx_version();
    $l[] = "service_cmd=/etc/init.d/nginx";
    $l[] = "service_disabled={$enabled}";
    $l[] = "family=proxy";
    $l[] = "pid_path={$pid_path}";
    $l[] = "watchdog_features=1";
    if ($enabled == 0) {
        return implode("\n", $l);
        return;
    }
    if (!$GLOBALS["CLASS_UNIX"]->process_exists($master_pid)) {
        $master_pid = $GLOBALS["CLASS_UNIX"]->PIDOF($bin);
    }
    if (!$GLOBALS["CLASS_UNIX"]->process_exists($master_pid)) {
        if (!$GLOBALS["DISABLE_WATCHDOG"]) {
            apache_admin_mysql(0, "Nginx Web service was stopped [action=start]", "Enabled:{$enabled}", __FILE__, __LINE__);
            $cmd = trim("{$GLOBALS["NICE"]} {$GLOBALS["nohup"]} {$GLOBALS["NICE"]} {$GLOBALS["PHP5"]} " . dirname(__FILE__) . "/exec.nginx.php --start >/dev/null 2>&1 &");
            shell_exec2($cmd);
        }
        $l[] = "running=0\ninstalled=1";
        $l[] = "";
        return implode("\n", $l);
        return;
    }
    $l[] = "running=1";
    $l[] = GetMemoriesOf($master_pid);
    $l[] = "";
    $prefixcmd = "{$GLOBALS["NICE"]} {$GLOBALS["nohup"]} {$GLOBALS["NICE"]} {$GLOBALS["PHP5"]} ";
    $timeFile = $GLOBALS["CLASS_UNIX"]->file_time_min("/etc/artica-postfix/pids/exec.nginx.stats.hours.php.tables_hours.time");
    if ($timeFile > 60) {
        $cmd = trim($prefixcmd . dirname(__FILE__) . "/exec.nginx.stats.hours.php >/dev/null 2>&1 &");
        shell_exec2($cmd);
    }
    if (!$GLOBALS["CLASS_UNIX"]->is_socket("/var/run/nginx-authenticator.sock")) {
        $cmd = trim($prefixcmd . dirname(__FILE__) . "/exec.nginx.php --authenticator >/dev/null 2>&1 &");
    }
    $timeFile = $GLOBALS["CLASS_UNIX"]->file_time_min("/usr/share/artica-postfix/ressources/logs/web/nginx.status.acl");
    if ($timeFile > 5) {
        $cmd = trim($prefixcmd . dirname(__FILE__) . "/exec.nginx.php --status >/dev/null 2>&1 &");
        shell_exec2($cmd);
    }
    $timeFile = $GLOBALS["CLASS_UNIX"]->file_time_min("/etc/artica-postfix/pids/exec.nginx.php.test_sources.time");
    if ($timeFile > 15) {
        $cmd = trim($prefixcmd . dirname(__FILE__) . "/exec.nginx.php --tests-sources >/dev/null 2>&1 &");
        shell_exec2($cmd);
    }
    $timeFile = $GLOBALS["CLASS_UNIX"]->file_time_min("/etc/artica-postfix/pids/exec.nginx.php.parse_memory.time");
    if ($timeFile > 4) {
        $cmd = trim($prefixcmd . dirname(__FILE__) . "/exec.nginx.php --mem >/dev/null 2>&1 &");
        shell_exec2($cmd);
    }
    $timeFile = $GLOBALS["CLASS_UNIX"]->file_time_min("/etc/artica-postfix/pids/exec.nginx.wizard.php.check_all_websites_status_available.time");
    if ($timeFile > 15) {
        $cmd = trim($prefixcmd . dirname(__FILE__) . "/exec.nginx.wizard.php --avail-status >/dev/null 2>&1 &");
        shell_exec2($cmd);
    }
    return implode("\n", $l);
    return;
}