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


PHP unix::hostname_g方法代码示例

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


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

示例1: build

function build()
{
    $lic[] = "ITEM\t{";
    $lic[] = "\t\"KEY\"\t\"Z5C2GDANS8189Y\"";
    $lic[] = "\t\"SERIAL\"\t\"TE91KNNFYHLDP1\"";
    $lic[] = "\t\"ORGANISATION\"\t\"Free Version Edition\"";
    $lic[] = "\t\"LICENSE\"\t\"ARK_DISKSTORAGE\"";
    $lic[] = "}\n";
    $lic[] = "ITEM\t{";
    $lic[] = "\t\"KEY\"\t\"PPKBEZCAVKH9PB\"";
    $lic[] = "\t\"SERIAL\"\t\"TL92JXVFRHMDPN\"";
    $lic[] = "\t\"ORGANISATION\"\t\"Free Version\"";
    $lic[] = "\t\"LICENSE\"\t\"ARK91\"";
    $lic[] = "}\n";
    $unix = new unix();
    $hostname = $unix->hostname_g();
    if (!is_file("/opt/arkeia/arkeiad/admin.cfg")) {
        echo "Starting......: " . date("H:i:s") . " Arkeia Network Backup writing admin.cfg for ({$hostname})\n";
        @file_put_contents("/opt/arkeia/arkeiad/admin.cfg", $unix->hostname_g());
    }
    if (!is_file("/opt/arkeia/server/dbase/f3sec/license.lst")) {
        echo "Starting......: " . date("H:i:s") . " Arkeia Network Backup adding Free version license...\n";
        @file_put_contents("/opt/arkeia/server/dbase/f3sec/license.lst", @implode("\n", $lic));
    }
    $users = ParseUsers();
    if (!isset($users["root"])) {
        if ($users["root"]["PASSWORD"] == null) {
            echo "Starting......: " . date("H:i:s") . " Arkeia Network Backup root as no password, delete it...\n";
            unset($users["root"]);
        }
    }
    $ldap = new clladp();
    $users[$ldap->ldap_admin]["PASSWORD"] = crypt($ldap->ldap_password, "n3");
    $users[$ldap->ldap_admin]["DENY"] = "*";
    $users[$ldap->ldap_admin]["NODE"] = "*";
    $users[$ldap->ldap_admin]["EMAIL"] = "";
    $users[$ldap->ldap_admin]["ROLE"] = "ADMINISTRATOR";
    $users[$ldap->ldap_admin]["NAME"] = "{$ldap->ldap_admin}";
    SetUsers($users);
    echo "Starting......: " . date("H:i:s") . " Arkeia Network Backup edit/add {$ldap->ldap_admin} done..\n";
    $arc[] = "NODE\t\"localhost\"";
    $arc[] = "LOGIN\t\"{$ldap->ldap_admin}\"";
    $arc[] = "PASSWORD\t\"{$ldap->ldap_password}\"";
    $arc[] = "ENCODING\t\"1\"";
    $arc[] = "LANG\t\"EN\"";
    @file_put_contents("/opt/arkeia/arkc/arkc.param", @implode("\n", $arc));
    echo "Starting......: " . date("H:i:s") . " Arkeia Network Backup edit arkc.param done..\n";
    $akeiad[] = "ARKEIADLOGLEVEL\t\"10\"\t";
    $akeiad[] = "PORT_NUMBER\t\"617\"";
    $akeiad[] = "NLP_TIMEOUT\t\"60\"";
    $akeiad[] = "RESTART_TIMEOUT\t\"300\"";
    $akeiad[] = "DONT_USE_PS\t\"1\"";
    $akeiad[] = "";
    @file_put_contents("/opt/arkeia/arkeiad/arkeiad.cfg", @implode("\n", $arc));
    echo "Starting......: " . date("H:i:s") . " Arkeia Network Backup edit arkeiad.cfg done..\n";
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:56,代码来源:exec.arkeia.php

示例2: iscsi_search

function iscsi_search()
{
    $unix = new unix();
    $uuid = $unix->GetUniqueID();
    $hostname = $unix->hostname_g();
    $hostnameR = explode(".", $hostname);
    krsort($hostnameR);
    $hostname = @implode(".", $hostnameR);
    @file_put_contents("/etc/iscsi/initiatorname.iscsi", "GenerateName=yes\n");
    $ip = $_GET["iscsi-search"];
    $unix = new unix();
    $iscsiadm = $unix->find_program("iscsiadm");
    $cmd = "{$iscsiadm} --mode discovery --type sendtargets --portal {$ip} 2>&1";
    writelogs_framework("{$cmd}", __FUNCTION__, __FILE__, __LINE__);
    exec($cmd, $results);
    writelogs_framework("{$cmd} = " . count($results) . " rows", __FUNCTION__, __FILE__, __LINE__);
    $array = array();
    while (list($index, $line) = each($results)) {
        if (preg_match("#Invalid Initiatorname#", $line)) {
            shell_exec("/etc/init.d/open-iscsi restart");
            return;
        }
        if (!preg_match("#([0-9\\.]+):([0-9]+),([0-9]+)\\s+(.+?):(.+)#", $line, $re)) {
            continue;
        }
        $array[$re[1]][] = array("PORT" => $re[2], "ID" => $re[3], "ISCSI" => $re[4], "FOLDER" => $re[5], "IP" => $re[1]);
    }
    @file_put_contents("/usr/share/artica-postfix/ressources/logs/web/iscsi-search.array", serialize($array));
    @chmod("/usr/share/artica-postfix/ressources/logs/web/iscsi-search.array", 0755);
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:30,代码来源:iscsi.php

示例3: scan

function scan()
{
    if (system_is_overloaded(basename(__FILE__))) {
        apache_admin_mysql(0, "Overloaded system, retry next time....", null, __FILE__, __LINE__);
        return;
    }
    $pidtime = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".time";
    $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, {$pid} Already exists...");
        return;
    }
    $GLOBALS["MYHOSTNAME_PROXY"] = $unix->hostname_g();
    @file_put_contents($pidFile, getmypid());
    $time = $unix->file_time_min($pidtime);
    if (!$GLOBALS["VERBOSE"]) {
        if ($time < 5) {
            events("{$time}mn, require minimal 5mn");
            return;
        }
    }
    $q = new mysql_squid_builder();
    $q->QUERY_SQL("CREATE TABLE IF NOT EXISTS `dashboard_apache_sizes` ( `TIME` DATETIME,\n\t\t\t`zmd5` VARCHAR(90) NOT NULL PRIMARY KEY,\n\t\t\t`SITENAME` VARCHAR(128),\n\t\t\t`SIZE` BIGINT UNSIGNED, `RQS` BIGINT UNSIGNED,\n\t\t\tKEY `TIME` (`TIME`),\n\t\t\tKEY `SIZE` (`SIZE`),\n\t\t\tKEY `RQS` (`RQS`)\n\t\t\t) ENGINE=MYISAM;");
    if (!$q->ok) {
        apache_admin_mysql(0, "Fatal MySQL error", $q->mysql_error, __FILE__, __LINE__);
        return;
    }
    if (!is_file("/home/apache/artica-stats/requests.log")) {
        echo "/home/apache/artica-stats/requests.log no such file...\n";
        return;
    }
    @mkdir("/home/apache/artica-stats/works", 0755, true);
    if (is_file("/home/apache/artica-stats/works/apache.log")) {
        echo "Parse /home/apache/artica-stats/works/apache.log\n";
        Parse("/home/apache/artica-stats/works/apache.log");
        return;
    }
    if (!@copy("/home/apache/artica-stats/requests.log", "/home/apache/artica-stats/works/apache.log")) {
        echo "Copy failed\n";
        return;
    }
    if (!is_file("/home/apache/artica-stats/works/apache.log")) {
        echo "/home/apache/artica-stats/works/apache.log no such file...\n";
        return;
    }
    @unlink("/home/apache/artica-stats/requests.log");
    echo "Parse /home/apache/artica-stats/works/apache.log\n";
    Parse("/home/apache/artica-stats/works/apache.log");
    CLEAN_MYSQL();
}
开发者ID:articatech,项目名称:artica,代码行数:52,代码来源:exec.apache.hour.php

示例4: migrate

function migrate()
{
    $q = new mysql();
    $unix = new unix();
    $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
    $pidtime = "/etc/artica-postfix/pids/exec.suricata.hourly.migrate.time";
    $pid = $unix->get_pid_from_file($pidfile);
    if ($unix->process_exists($pid, basename(__FILE__))) {
        $time = $unix->PROCCESS_TIME_MIN($pid);
        echo "Starting......: " . date("H:i:s") . " [INIT]: Already Artica task running PID {$pid} since {$time}mn\n";
        return;
    }
    @file_put_contents($pidfile, getmypid());
    $timeExec = $unix->file_time_min($pidtime);
    if ($timeExec < 60) {
        return;
    }
    @unlink($pidtime);
    @file_put_contents($pidtime, time());
    $hostname = $unix->hostname_g();
    if (!$q->TABLE_EXISTS("suricata_events", "artica_events")) {
        return;
    }
    $results = $q->QUERY_SQL("SELECT * FROM suricata_events", "artica_events");
    $postgres = new postgres_sql();
    $postgres->suricata_tables();
    while ($ligne = mysql_fetch_assoc($results)) {
        $src_ip = $ligne["src_ip"];
        $zDate = $ligne["zDate"];
        $dst_ip = $ligne["dst_ip"];
        $dst_port = $ligne["dst_port"];
        $proto = $ligne["proto"];
        $signature = $ligne["signature"];
        $xcount = $ligne["xcount"];
        $severity = $ligne["severity"];
        $f[] = "('{$zDate}','{$src_ip}','{$dst_ip}','{$proto}','{$dst_port}','{$signature}','{$severity}','{$xcount}','{$hostname}')";
    }
    if (count($f) > 0) {
        $prefix = "INSERT INTO suricata_events (zDate,src_ip,dst_ip,proto,dst_port,signature,severity,xcount,proxyname) VALUES ";
        $postgres->QUERY_SQL($prefix . @implode(",", $f));
        if (!$postgres->ok) {
            return;
        }
        $q->QUERY_SQL("DROP TABLE suricata_events", "artica_events");
    }
}
开发者ID:articatech,项目名称:artica,代码行数:46,代码来源:exec.suricata.hourly.php

示例5: scan

function scan()
{
    $pidtime = "/etc/artica-postfix/pids/exec.haproxy.events-parser.php.scan.time";
    $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, {$pid} Already exists...");
        return;
    }
    $GLOBALS["MYHOSTNAME_PROXY"] = $unix->hostname_g();
    @file_put_contents($pidFile, getmypid());
    if (!$GLOBALS["VERBOSE"]) {
        $time = $unix->file_time_min($pidtime);
        if (!$GLOBALS["VERBOSE"]) {
            if ($time < 5) {
                events("{$time}mn, require minimal 5mn");
                return;
            }
        }
    }
    $GLOBALS["LogFileDeamonLogDir"] = "/home/artica/haproxy-postgres/realtime-events";
    $Workpath = "{$GLOBALS["LogFileDeamonLogDir"]}/access-work";
    @file_put_contents($pidtime, time());
    @mkdir($GLOBALS["LogFileDeamonLogDir"], 0755, true);
    $postgres = new postgres_sql();
    $postgres->CREATE_TABLES();
    if (!$postgres->TABLE_EXISTS("haproxy_log")) {
        events("haproxy_log, not such table");
        die;
    }
    if (is_file("{$GLOBALS["LogFileDeamonLogDir"]}/HAPROXY.LOG")) {
        HAPROXY_LOG("{$GLOBALS["LogFileDeamonLogDir"]}/HAPROXY.LOG");
    }
    HAPROXY_LOG_SCAN($Workpath);
}
开发者ID:articatech,项目名称:artica,代码行数:36,代码来源:exec.haproxy.events-parser.php

示例6: start_week

function start_week()
{
    $unix = new unix();
    $hostname = $unix->hostname_g();
    $now = InfluxQueryFromUTC(strtotime("-7 day"));
    $today = date("Y-m-d", $now) . " 00:00:00";
    $sql = "SELECT SUM(TX) as TX, SUM(RX) as RX,ETH FROM ethrxtx WHERE proxyname='{$hostname}' AND time >'{$today}' group by time(4h),ETH";
    $influx = new influx();
    echo "{$sql}\n";
    $main = $influx->QUERY_SQL($sql);
    $c = 0;
    $f = array();
    foreach ($main as $row) {
        $time = date("Y-m-d H:i:s", InfluxToTime($row->time));
        $ETH = $row->ETH;
        if ($ETH == "lo") {
            continue;
        }
        $RX = $row->RX;
        $TX = $row->TX;
        $f[] = "('{$time}','{$ETH}','{$RX}','{$TX}')";
    }
    if (count($f) == 0) {
        return;
    }
    $q = new mysql();
    if ($q->TABLE_EXISTS("RXTX_WEEK", "artica_events")) {
        $q->QUERY_SQL("TRUNCATE TABLE `RXTX_WEEK`", "artica_events");
    }
    $sql = "CREATE TABLE IF NOT EXISTS `RXTX_WEEK`\n\t(`ZDATE` DATETIME,\n\t`RX` INT UNSIGNED NOT NULL DEFAULT 1,\n\t`TX` INT UNSIGNED NOT NULL DEFAULT 1,\n\t`ETH` VARCHAR(60),\n\tKEY `ZDATE`(`ZDATE`),\n\tKEY `RX`(`RX`),\n\tKEY `TX`(`TX`),\n\tKEY `ETH`(`ETH`) )  ENGINE = MYISAM;";
    $q->QUERY_SQL($sql, "artica_events");
    if (!$q->ok) {
        return;
    }
    $q->QUERY_SQL("INSERT IGNORE INTO RXTX_WEEK (ZDATE,ETH,RX,TX) VALUES " . @implode(",", $f), "artica_events");
}
开发者ID:articatech,项目名称:artica,代码行数:36,代码来源:exec.rxtx.hourly.php

示例7: start

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

示例8: GRAB_DATAS

function GRAB_DATAS($ligne, $md5)
{
    $GLOBALS["zMD5"] = $md5;
    $params = unserialize($ligne["params"]);
    $influx = new influx();
    $mintime = strtotime("2008-01-01 00:00:00");
    $params["TO"] = intval($params["TO"]);
    $params["FROM"] = abs(intval($params["FROM"]));
    if ($params["FROM"] < $mintime) {
        $params["FROM"] = strtotime(date("Y-m-d 00:00:00"));
    }
    $params["TO"] = intval($params["TO"]);
    if ($params["TO"] < $mintime) {
        $params["TO"] = time();
    }
    $influx = new influx();
    $from = $params["FROM"];
    $to = $params["TO"];
    $interval = $params["INTERVAL"];
    $USER_FIELD = $params["USER"];
    $md5_table = md5(__FUNCTION__ . "." . "{$from}{$to}");
    $searchsites = trim($params["searchsites"]);
    $searchuser = trim($params["searchuser"]);
    $searchsites_sql = null;
    $searchuser_sql = null;
    if ($searchsites == "*") {
        $searchsites = null;
    }
    if ($searchuser == "*") {
        $searchuser = null;
    }
    $SSEARCH = array();
    $distance = $influx->DistanceHour($from, $to);
    echo "Distance: {$distance} hours\n";
    $TimeGroup = "date_trunc('hour', zdate) as zdate";
    $SQLA[] = "SELECT SUM(xcount) as xcount,{$TimeGroup},src_ip,dst_ip,dst_port,proto,severity,signature FROM suricata_events";
    $SQLA[] = "WHERE";
    $SQLA[] = "(zdate >='" . date("Y-m-d H:i:s", $from) . "' and zdate <= '" . date("Y-m-d H:i:s", $to) . "')";
    $SQLA[] = "GROUP BY zdate, src_ip,dst_ip,dst_port,proto,severity,signature";
    build_progress("{step} {waiting_data}: BigData engine, (websites) {please_wait}", 6);
    $unix = new unix();
    $hostname = $unix->hostname_g();
    $sql = "CREATE TABLE IF NOT EXISTS \"{$md5}report\" (\n\t\tzDate timestamp,\n\t\tsrc_ip inet,\n\t\tdst_ip inet,\n\t\tdst_port smallint NOT NULL,\n\t\tproto varchar(10) NOT NULL,\n\t\tseverity smallint NOT NULL,\n\t\tsignature BIGINT,\n\t\txcount BIGINT )";
    $q = new postgres_sql();
    $q->QUERY_SQL($sql);
    if (!$q->ok) {
        echo "***************\n{$q->mysql_error}\n***************\n";
        return false;
    }
    $q->QUERY_SQL("create index zdate{$md5}report on \"{$md5}report\"(zdate);");
    $q->QUERY_SQL("create index src_ip{$md5}report on \"{$md5}report\"(src_ip);");
    $q->QUERY_SQL("create index dst_ip{$md5}report on \"{$md5}report\"(dst_ip);");
    $q->QUERY_SQL("TRUNCATE TABLE \"{$md5}report\"");
    $sql = @implode(" ", $SQLA);
    $sql = "INSERT INTO \"{$md5}report\" (xcount,zdate,src_ip,dst_ip,dst_port,proto,severity,signature) {$sql}";
    echo "***************\n{$sql}\n*****************\n";
    $q->QUERY_SQL($sql);
    if (!$q->ok) {
        echo "***************\nERROR {$q->mysql_error}\n***************\n";
        $q->QUERY_SQL("DROP TABLE \"{$md5}report\"");
        return false;
    }
    $ligne = pg_fetch_assoc($q->QUERY_SQL("SELECT COUNT(*) as tcount FROM \"{$md5}report\""));
    if (!$q->ok) {
        echo "***************\nERROR {$q->mysql_error}\n***************\n";
        $q->QUERY_SQL("DROP TABLE \"{$md5}report\"");
        return false;
    }
    $c = $ligne["tcount"];
    if ($c == 0) {
        echo "No data....\n";
        $q->QUERY_SQL("DROP TABLE \"{$md5}report\"");
        return false;
    }
    echo "{$c} items inserted to PostgreSQL\n";
    $MAIN_ARRAY = array();
    return true;
}
开发者ID:articatech,项目名称:artica,代码行数:78,代码来源:exec.system.statistics.IDS.build.php

示例9: restore

function restore()
{
    $sock = new sockets();
    $unix = new unix();
    $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
    if ($GLOBALS["VERBOSE"]) {
        echo "PID: {$pidfile}\n";
    }
    $pid = $unix->get_pid_from_file($pidfile);
    if ($unix->process_exists($pid)) {
        $TTL = $unix->PROCESS_TTL($pid);
        if ($TTL < 240) {
            return;
        }
        $kill = $unix->find_program("kill");
        unix_system_kill_force($pid);
    }
    @file_put_contents($pidfile, getmypid());
    $hostname = $unix->hostname_g();
    progress(10, "{mounting}");
    if (!restore_TestNas()) {
        system_admin_events("Mounting NAS filesystem report false", __FUNCTION__, __FILE__, __LINE__);
        progress(100, "{failed}");
        return;
    }
    $BackupArticaRestoreNASIpaddr = $sock->GET_INFO("BackupArticaRestoreNASIpaddr");
    $BackupArticaRestoreNASFolder = $sock->GET_INFO("BackupArticaRestoreNASFolder");
    $BackupArticaRestoreNASUser = $sock->GET_INFO("BackupArticaRestoreNASUser");
    $BackupArticaRestoreNASPassword = $sock->GET_INFO("BackupArticaRestoreNASPassword");
    $BackupArticaRestoreNASFolderSource = $sock->GET_INFO("BackupArticaRestoreNASFolderSource");
    $BackupArticaRestoreNetwork = $sock->GET_INFO("BackupArticaRestoreNetwork");
    $mountPoint = "/mnt/BackupArticaRestoreNAS";
    $BackupArticaRestoreNASFolderSource = str_replace("\\", "/", $BackupArticaRestoreNASFolderSource);
    $sourceDir = "{$mountPoint}/{$BackupArticaRestoreNASFolderSource}";
    $sourceDir = str_replace("//", "/", $sourceDir);
    if (!is_file("{$sourceDir}/BKVERSION.txt")) {
        progress(100, "{failed} BKVERSION.txt no such file");
        $mount = new mount("/var/log/artica-postfix/backup.debug");
        if ($mount->ismounted($mountPoint)) {
            $mount->umount($mountPoint);
        }
        return;
    }
    $time = trim(@file_get_contents("{$sourceDir}/BKVERSION.txt"));
    progress(15, "{backup} " . date("Y-m-d H:i:s"));
    progress(20, "{restoring_ldap_database}, {please_wait}...");
    Restore_ldap($sourceDir);
    progress(40, "{restoring_artica_settings}, {please_wait}...");
    restore_artica_settings($sourceDir);
    progress(50, "{restoring_artica_databases}, {please_wait}...");
    restore_artica_backup($sourceDir);
    progress(60, "{restoring_artica_databases}, {please_wait}...");
    restore_ocsweb($sourceDir);
    progress(80, "{restoring_artica_databases}, {please_wait}...");
    restore_squidlogs($sourceDir);
    progress(82, "{restoring} PowerDNS, {please_wait}...");
    restore_powerdns($sourceDir);
    progress(90, "{reconfigure_server}, {please_wait}...");
    $squidbin = $unix->LOCATE_SQUID_BIN();
    $php = $unix->LOCATE_PHP5_BIN();
    if (is_file($squidbin)) {
        shell_exec("{$php} /usr/share/artica-postfix/exec.squid.php --build --force");
    }
    progress(100, "{success}");
    $mount = new mount("/var/log/artica-postfix/backup.debug");
    if ($mount->ismounted($mountPoint)) {
        $mount->umount($mountPoint);
    }
    if ($BackupArticaRestoreNetwork == 1) {
        $unix->THREAD_COMMAND_SET("{$php} /usr/share/artica-postfix/exec.virtuals-ip.php --build");
    }
    return;
}
开发者ID:brucewu16899,项目名称:1.6.x,代码行数:73,代码来源:exec.backup.artica.php

示例10: interface_menu

function interface_menu($eth)
{
    $ARTICAVERSION = @file_get_contents("/usr/share/artica-postfix/VERSION");
    $unix = new unix();
    $HOSTNAME = $unix->hostname_g();
    $DIALOG = $unix->find_program("dialog");
    $php = $unix->LOCATE_PHP5_BIN();
    $NETWORK_ALL_INTERFACES = $unix->NETWORK_ALL_INTERFACES();
    $DEFAULT = $NETWORK_ALL_INTERFACES[$eth]["IPADDR"];
    $NETMASK = $NETWORK_ALL_INTERFACES[$eth]["NETMASK"];
    $GATEWAY = $NETWORK_ALL_INTERFACES[$eth]["GATEWAY"];
    $f[] = "#!/bin/bash";
    $f[] = "INPUT=/tmp/menu.sh.\$\$";
    $f[] = "OUTPUT=/tmp/output.sh.\$\$";
    $f[] = "trap \"rm \$OUTPUT; rm \$INPUT; exit\" SIGHUP SIGINT SIGTERM";
    $f[] = "DIALOG=\${DIALOG=dialog}";
    @unlink("/etc/artica-postfix/WIZARDIP_{$eth}");
    @unlink("/etc/artica-postfix/WIZARDMASK_{$eth}");
    $f[] = "{$DIALOG} --clear --title \"ENTER IP ADDRESS FOR '{$eth}'\" --inputbox \"Enter your IP address for the {$eth} Interface.\\nExample: 111.112.113.114\" 10 68 {$DEFAULT} 2> /etc/artica-postfix/WIZARDIP_{$eth}";
    $f[] = "if [ \$? = 1 -o \$? = 255 ]; then";
    $f[] = "rm -f /etc/artica-postfix/WIZARDIP_{$eth}";
    $f[] = "\treturn";
    $f[] = "fi";
    $f[] = "{$DIALOG} --clear --title \"ENTER IP ADDRESS FOR '{$eth}'\" --inputbox \"Enter your netmask for the {$eth} Interface.\\nExample: 255.255.255.0\" 10 68 {$NETMASK} 2> /etc/artica-postfix/WIZARDMASK_{$eth}";
    $f[] = "if [ \$? = 1 -o \$? = 255 ]; then";
    $f[] = "rm -f /etc/artica-postfix/WIZARDMASK_{$eth}";
    $f[] = "\treturn";
    $f[] = "fi";
    $f[] = "{$DIALOG} --clear --title \"ENTER IP ADDRESS FOR '{$eth}'\" --inputbox \"Enter your gateway for the {$eth} Interface.\\nExample: 111.112.113.114\\nIf this interface is the main gateway of your network, set 0.0.0.0 here\" 10 68 {$GATEWAY} 2> /etc/artica-postfix/WIZARDGATEWAY_{$eth}";
    $f[] = "if [ \$? = 1 -o \$? = 255 ]; then";
    $f[] = "rm -f /etc/artica-postfix/WIZARDGATEWAY_{$eth}";
    $f[] = "\treturn";
    $f[] = "fi";
    $f[] = "WIZARDIP=`cat /etc/artica-postfix/WIZARDIP_{$eth}`";
    $f[] = "WIZARDMASK=`cat /etc/artica-postfix/WIZARDMASK_{$eth}`";
    $f[] = "WIZARDGATEWAY=`cat /etc/artica-postfix/WIZARDGATEWAY_{$eth}`";
    $f[] = "{$DIALOG} --title \"NETWORK SETUP COMPLETE\" --yesno \"Your networking system is now configured to use:\\n\$WIZARDIP/\$WIZARDMASK Gateway \$WIZARDGATEWAY\\nIs this correct?  Press 'Yes' to continue, or 'No' to exit\" 0 0";
    $f[] = "case \$? in";
    $f[] = "0)";
    $f[] = "\techo \"{$php} " . __FILE__ . " --savenic {$eth}\"";
    $f[] = "\t{$php} " . __FILE__ . " --savenic {$eth} >/tmp/{$eth}.log &";
    $f[] = "\t{$DIALOG} --tailbox /tmp/{$eth}.log  25 150";
    $f[] = "\tWIZARDRESULTS=`cat /etc/artica-postfix/WIZARDRESULT_{$eth}`";
    $f[] = "\tif [ \"\$WIZARDRESULTS\" eq 0 ]; then";
    $f[] = "\t{$DIALOG} --title \"{$eth} failed\" --msgbox \"Sorry, An error has occured\" 9 70";
    $f[] = "\tfi";
    $f[] = "\treturn;;";
    $f[] = "1)";
    $f[] = "\treturn;;";
    $f[] = "255)";
    $f[] = "\treturn;;";
    $f[] = "esac";
    $f[] = "\n";
    @file_put_contents("/tmp/bash_network_menu_interface.sh", @implode("\n", $f));
    @chmod("/tmp/bash_network_menu_interface.sh", 0755);
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:56,代码来源:exec.menu.ips.php

示例11: menu

function menu()
{
    $ARTICAVERSION = @file_get_contents("/usr/share/artica-postfix/VERSION");
    $unix = new unix();
    $HOSTNAME = $unix->hostname_g();
    $DIALOG = $unix->find_program("dialog");
    $php = $unix->LOCATE_PHP5_BIN();
    $echo = $unix->find_program("echo");
    $diag[] = "{$DIALOG} --clear  --nocancel --backtitle \"Software version {$ARTICAVERSION} on {$HOSTNAME}\"";
    $diag[] = "--title \"[ S Y S T E M -  M E N U ]\"";
    $diag[] = "--menu \"You can use the UP/DOWN arrow keys\nChoose the TASK\" 20 100 10";
    $diag[] = "PASSWD \"System root password\"";
    $diag[] = "SuperAdmin \"Web interface SuperAdmin account\"";
    $diag[] = "Update \"Update tasks\"";
    $diag[] = "BackupRestore \"Backup and restore (snapshots)\"";
    $diag[] = "CleanLogs \"Clean the log partition\"";
    $diag[] = "OPTIMIZE \"System Optimization ( SSD Disks, HyperV, XenServer, VMWare )\"";
    $diag[] = "Quit \"Return to main menu\" 2>\"\${INPUT}\"";
    $f[] = "#!/bin/bash";
    $f[] = "INPUT=/tmp/menu.sh.\$\$";
    $f[] = "OUTPUT=/tmp/output.sh.\$\$";
    $f[] = "trap \"rm \$OUTPUT; rm \$INPUT; exit\" SIGHUP SIGINT SIGTERM";
    $f[] = "DIALOG=\${DIALOG=dialog}";
    $f[] = "function Updatep(){\n\tphp /usr/share/artica-postfix/exec.menu.updates.php --menu\n\t/tmp/bash_update_menu.sh\n}";
    $f[] = "function BackupRestorep(){";
    $f[] = "{$php} /usr/share/artica-postfix/exec.menu.snapshots.php --menu";
    $f[] = "/tmp/bash_snapshots_menu.sh";
    $f[] = "}";
    $f[] = "";
    $f[] = "function OPTIMIZE(){";
    $f[] = "\t{$DIALOG} --title \"Optimize your system\" --yesno \"This operation optimize only your system when using\\n\\n- SSD disks\\n- Microsoft HyperV\\n- VMWare ESXI\\n- XenServer\\n\\n\\nYou need to reboot after this operation\\n\\n\\nDo you need to perform this operation ? Press 'Yes' to continue, or 'No' to exit\" 0 0";
    $f[] = "\tcase \$? in";
    $f[] = "\t\t0)";
    $f[] = "\t\tif [ -f /tmp/dns.log ]; then";
    $f[] = "\t\t\trm /tmp/dns.log";
    $f[] = "\t\tfi";
    $f[] = "\t\t{$echo} 1 >/etc/artica-postfix/settings/Daemons/EnableSystemOptimize";
    $f[] = "\t\t{$php} /usr/share/artica-postfix/exec.vmware.php --optimize >/tmp/dns.log &";
    $f[] = "\t{$DIALOG} --tailbox /tmp/dns.log  25 150";
    $f[] = "\t\trm /etc/artica-postfix/WIZARUSERNAME";
    $f[] = "\t\trm /etc/artica-postfix/WIZARUSERNAMEPASSWORD";
    $f[] = "\t\treturn;;";
    $f[] = "\tesac";
    $f[] = "}";
    $f[] = "";
    $f[] = "function CleanLogsp(){";
    $f[] = "\t{$DIALOG} --title \"Clean the log directory\" --yesno \"Do you need to perform this operation ? Press 'Yes' to continue, or 'No' to exit\" 0 0";
    $f[] = "\tcase \$? in";
    $f[] = "\t\t0)";
    $f[] = "chmod 0755 /usr/share/artica-postfix/bin/remove-artica-logs.sh";
    $f[] = "for i in \$(seq 0 20 80) ; do sleep 1; echo \$i | {$DIALOG} --gauge \"Please wait\" 10 70 0; done";
    $f[] = "echo 90 | {$DIALOG} --gauge \"Running...\" 10 70 0";
    $f[] = "/usr/share/artica-postfix/bin/remove-artica-logs.sh >/dev/null 2>&1";
    $f[] = "sleep 1";
    $f[] = "echo 100 | {$DIALOG} --gauge \"Please wait\" 10 70 0";
    $f[] = "sleep 1";
    $f[] = "\t{$DIALOG} --title \"Clean the log directory\" --msgbox \"Your log directory as been cleaned...\"  0 0";
    $f[] = "\t\treturn;;";
    $f[] = "\t1)";
    $f[] = "\t\treturn;;";
    $f[] = "\t255)";
    $f[] = "\t\treturn;;";
    $f[] = "\tesac";
    $f[] = "}";
    $f[] = "";
    $f[] = "function PASSWDY(){";
    $f[] = "\tpasswd root";
    $f[] = "}";
    $f[] = "";
    $f[] = "function SuperAdmin(){";
    $f[] = "\tif [ -f /tmp/dns.log ]; then";
    $f[] = "\t\trm /tmp/dns.log";
    $f[] = "\tfi";
    $f[] = "\t{$DIALOG} --clear --title \"Username\" --inputbox \"Enter the SuperAdmin username\" 10 68 Manager 2> /etc/artica-postfix/WIZARUSERNAME";
    $f[] = "\tcase \$? in";
    $f[] = "\t\t1)";
    $f[] = "\t\trm /etc/artica-postfix/WIZARUSERNAME || true";
    $f[] = "\t\treturn";
    $f[] = "\tesac";
    $f[] = "WIZARUSERNAME = `cat /etc/artica-postfix/WIZARUSERNAME`";
    $f[] = "\t{$DIALOG} --clear --insecure --passwordbox \"ENTER SuperAdmin Password for authentication\"  10 68 secret 2> /etc/artica-postfix/WIZARUSERNAMEPASSWORD";
    $f[] = "\tcase \$? in";
    $f[] = "\t\t1)";
    $f[] = "\t\trm /etc/artica-postfix/WIZARUSERNAME || true";
    $f[] = "\t\trm /etc/artica-postfix/WIZARUSERNAMEPASSWORD || true";
    $f[] = "\t\treturn";
    $f[] = "\tesac";
    $f[] = "\t{$DIALOG} --title \"Change SuperAdmin Account\" --yesno \"Do you need to perform this operation ? Press 'Yes' to continue, or 'No' to exit\" 0 0";
    $f[] = "\tcase \$? in";
    $f[] = "\t\t0)";
    $f[] = "\tif [ -f /tmp/dns.log ]; then";
    $f[] = "\t\trm /tmp/dns.log";
    $f[] = "\tfi";
    $f[] = "\t{$php} " . __FILE__ . " --SuperAdmin >/tmp/dns.log &";
    $f[] = "\t{$DIALOG} --tailbox /tmp/dns.log  25 150";
    $f[] = "\t\trm /etc/artica-postfix/WIZARUSERNAME";
    $f[] = "\t\trm /etc/artica-postfix/WIZARUSERNAMEPASSWORD";
    $f[] = "\t\treturn;;";
    $f[] = "\t1)";
    $f[] = "\t\trm /etc/artica-postfix/WIZARUSERNAME";
//.........这里部分代码省略.........
开发者ID:articatech,项目名称:artica,代码行数:101,代码来源:exec.menu.system.php

示例12: ParseUserAuth

function ParseUserAuth($checkpid = false)
{
    $unix = new unix();
    $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
    if ($checkpid) {
        $pid = @file_get_contents($pidfile);
        if ($pid < 100) {
            $pid = null;
        }
        if ($unix->process_exists($pid, basename(__FILE__))) {
            $time = $unix->PROCCESS_TIME_MIN($pid);
            writelogs_squid("Already executed pid {$pid} since {$time}mn-> DIE");
            if ($GLOBALS["VERBOSE"]) {
                echo "Already executed pid {$pid} since {$time}mn\n";
            }
            die;
        }
        @file_put_contents($pidfile, getmypid());
    }
    $sock = new sockets();
    if (isset($GLOBALS["EnableMacAddressFilter"])) {
        $GLOBALS["EnableMacAddressFilter"] = $sock->GET_INFO("EnableMacAddressFilter");
        if (!is_numeric($GLOBALS["EnableMacAddressFilter"])) {
            $GLOBALS["EnableMacAddressFilter"] = 1;
        }
    }
    $hostname = $unix->hostname_g();
    $MustContinue = false;
    ParseUserAuthNew();
    if (function_exists("system_is_overloaded")) {
        $COUNT_FILES = $unix->COUNT_FILES("/var/log/artica-postfix/squid-users");
        if ($COUNT_FILES < 1000) {
            if (system_is_overloaded()) {
                return;
            }
        } else {
            $MustContinue = true;
        }
    }
    $countDeFiles = 0;
    if (!($handle = opendir("/var/log/artica-postfix/squid-users"))) {
        @mkdir("/var/log/artica-postfix/squid-users", 0755, true);
        die;
    }
    if (!$MustContinue) {
        if (systemMaxOverloaded()) {
            return;
        }
    }
    $countDeFiles = 0;
    $prefix = "INSERT IGNORE INTO UserAutDB (zmd5,MAC,ipaddr,uid,hostname,UserAgent) VALUES ";
    $f = array();
    while (false !== ($filename = readdir($handle))) {
        if ($filename == ".") {
            continue;
        }
        if ($filename == "..") {
            continue;
        }
        $targetFile = "/var/log/artica-postfix/squid-users/{$filename}";
        $countDeFiles++;
        $content = @file_get_contents($targetFile);
        $array = unserialize($content);
        $ParseUserAuthArray = ParseUserAuthArray($array);
        if ($ParseUserAuthArray != null) {
            $f[] = $ParseUserAuthArray;
        }
        @unlink($targetFile);
    }
    if (count($f) > 0) {
        $q = new mysql_squid_builder();
        $q->QUERY_SQL($prefix . @implode(",", $f));
    }
    nmap_scan();
}
开发者ID:brucewu16899,项目名称:1.6.x,代码行数:75,代码来源:exec.squid-tail-injector.php

示例13: RefreshIndex

function RefreshIndex()
{
    $unix = new unix();
    $nice = EXEC_NICE();
    $sock = new sockets();
    $users = new usersMenus();
    $nohup = $unix->find_program("nohup");
    $php = $unix->LOCATE_PHP5_BIN();
    $wget = $unix->find_program("wget");
    $SYSTEMID = $unix->GetUniqueID();
    if ($SYSTEMID == null) {
        build_progress("System ID is Null !!!", 5);
        return;
    }
    build_progress_index("Register server...", 10);
    build_progress("Register server...", 10);
    shell_exec("{$nohup} {$nice} {$php} /usr/share/artica-postfix/exec.web-community-filter.php --register-lic >/dev/null 2>&1 &");
    if ($SYSTEMID == null) {
        build_progress_index("No system ID, force...", 15);
        build_progress("No system ID, force", 15);
        shell_exec("{$nice} /usr/share/artica-postfix/bin/artica-update -refresh-index --force >/dev/null 2>&1");
        return;
    }
    $xMEM_TOTAL_INSTALLEE = $users->MEM_TOTAL_INSTALLEE;
    $CPU_NUMBER = $users->CPU_NUMBER;
    $LinuxDistributionFullName = $users->LinuxDistriFullName;
    if ($LinuxDistributionFullName == null) {
        $LinuxDistributionFullName = "Linux Default";
    }
    $ARTICA_VERSION = GetCurrentVersion();
    $hostname = $unix->hostname_g();
    $CheckUserCount = CheckUserCount();
    $RebootAfterArticaUpgrade = $sock->GET_INFO("RebootAfterArticaUpgrade");
    if (!is_numeric($RebootAfterArticaUpgrade)) {
        $RebootAfterArticaUpgrade = 0;
    }
    $EnableScheduleUpdates = $sock->GET_INFO("EnableScheduleUpdates");
    $ArticaUpdateIntervalAllways = intval($sock->GET_INFO("EnableScheduleUpdates"));
    if (!is_numeric($EnableScheduleUpdates)) {
        $EnableScheduleUpdates = 0;
    }
    $ArticaAutoUpateOfficial = $sock->GET_INFO("ArticaAutoUpateOfficial");
    $ArticaAutoUpateNightly = intval($sock->GET_INFO("ArticaAutoUpateNightly"));
    $ArticaUpdateIntervalAllways = intval($sock->GET_INFO("ArticaUpdateIntervalAllways"));
    $OfficialArticaUri = $sock->GET_INFO("OfficialArticaUri");
    if (!is_numeric($ArticaAutoUpateOfficial)) {
        $ArticaAutoUpateOfficial = 1;
    }
    if ($OfficialArticaUri == null) {
        $OfficialArticaUri = "http://articatech.net/artica.update.php";
    }
    $uri = $OfficialArticaUri;
    $dmidecode = @file_get_contents("/etc/artica-postfix/dmidecode.cache.url");
    @unlink($GLOBALS["MasterIndexFile"]);
    $tarballs_file = "/usr/share/artica-postfix/ressources/logs/web/tarballs.cache";
    echo "Starting......: " . date("H:i:s") . " CPU NUMBER: {$CPU_NUMBER}\n";
    echo "Starting......: " . date("H:i:s") . " Hostname..: {$hostname}\n";
    echo "Starting......: " . date("H:i:s") . " Artica ver: {$ARTICA_VERSION}\n";
    echo "Starting......: " . date("H:i:s") . " Users.....: {$CheckUserCount}\n";
    build_progress_index("Configuration done...", 15);
    build_progress("Configuration done", 15);
    $DATA["UUID"] = $SYSTEMID;
    $DATA["MEM"] = $xMEM_TOTAL_INSTALLEE;
    $DATA["CPU"] = $CPU_NUMBER;
    $DATA["LINUX"] = $LinuxDistributionFullName;
    $DATA["VERSION"] = $ARTICA_VERSION;
    $DATA["HOSTNAME"] = $hostname;
    $DATA["USERS"] = $CheckUserCount;
    $DATA["DMICODE"] = $dmidecode;
    build_progress_index("Check repositories...", 20);
    build_progress("Check repositories", 20);
    $MAIN_URI = $unix->MAIN_URI();
    echo "Starting......: " . date("H:i:s") . " Main URI..: {$MAIN_URI}\n";
    $md5string = @md5_file($GLOBALS["MasterIndexFile"]);
    build_progress_index("Get Index...", 25);
    build_progress("Get Index...", 25);
    echo "Starting......: " . date("H:i:s") . " Update index file..\n";
    $curl = new ccurl($OfficialArticaUri);
    $curl->parms["datas"] = base64_encode(serialize($DATA));
    if (!$curl->get()) {
        echo "Last detected error: {$curl->error}\n";
        build_progress_index("Get Index...{failed}", 110);
        build_progress("Get Index file !! FAILED !!", 110);
        _artica_update_event(0, "Unable to download index file with error {$curl->error_num}, {$curl->error}", null, __FILE__, __LINE__);
        return false;
    }
    @unlink("/etc/artica-postfix/settings/Daemons/ArticaUpdateRepos");
    build_progress_index("Parse Index from repository", 40);
    build_progress("Parse Index from repository", 40);
    if (preg_match("#<ERROR>(.+?)</ERROR>#is", $curl->data, $re)) {
        echo "{$re[1]} !! FAILED !!\n";
        build_progress_index("Corrupted index from repository !! FAILED !!", 110);
        build_progress("Corrupted index from repository !! FAILED !!", 110);
        return;
    }
    if (!preg_match("#<CONTENT>(.+?)</CONTENT>#is", $curl->data, $re)) {
        echo "Corrupted index from repository !! FAILED !!\n";
        build_progress_index("Corrupted index from repository !! FAILED !!", 110);
        build_progress("Corrupted index from repository !! FAILED !!", 110);
        return;
//.........这里部分代码省略.........
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:101,代码来源:exec.nightly.php

示例14: build


//.........这里部分代码省略.........
            $pathDir = dirname($ligne["dev"]);
            if (!is_dir($pathDir)) {
                @mkdir($pathDir, 0755, true);
            }
            if (!stat_system($pathFile)) {
                echo "{$GLOBALS["deflog_start"]} [{$ligne["ID"]}] {$pathFile} no such file, create it\n";
                build_progress("{$GLOBALS["deflog_start"]} {building} {$pathFile}", 20);
                $countsize = $ligne["file_size"] * 1000;
                $cmd = "{$dd} if=/dev/zero of={$ligne["dev"]} bs=1M count={$countsize}";
                echo "{$cmd}\n";
                system($cmd);
            }
        }
        if ($Params["ImmediateData"] == 1) {
            $Params["ImmediateData"] = "Yes";
        } else {
            $Params["ImmediateData"] = "No";
        }
        $f[] = "Target iqn.{$year}-{$month}.{$newhostname}:{$ligne["shared_folder"]}";
        if ($EnableAuth == 1) {
            if (strlen($uid) > 2) {
                echo "{$GLOBALS["deflog_start"]} Authentication enabled for {$ligne["dev"]} with member {$ligne["uid"]}\n";
                $user = new user($ligne["uid"]);
                if ($user->password != null) {
                    $f[] = "\tIncomingUser {$ligne["uid"]} {$user->password}";
                }
            }
        }
        $f[] = "\tLun {$c} Path={$ligne["dev"]},Type={$Params["IoType"]},IOMode={$Params["mode"]}";
        $f[] = "\tMaxConnections {$Params["MaxConnections"]}";
        $f[] = "\tImmediateData {$Params["MaxConnections"]}";
        $f[] = "\tWthreads {$Params["Wthreads"]}";
        /*$f[]="\tMaxRecvDataSegmentLength 65536";
        		$f[]="\tMaxXmitDataSegmentLength 65536";
        		$f[]="\tMaxBurstLength          1048576";
        		$f[]="\tFirstBurstLength        262144";
        		$f[]="\tMaxOutstandingR2T       1";
        		$f[]="\tHeaderDigest            None";
        		$f[]="\tDataDigest              None";
        		$f[]="\tNOPInterval             60";
        		$f[]="\tNOPTimeout              180";
        		$f[]="\tQueuedCommands          64";
        		*/
        $f[] = "";
        $c++;
    }
    @mkdir("/etc/iet", true, 0600);
    $hostname = $unix->hostname_g();
    $tbl = explode(".", $hostname);
    krsort($tbl);
    $newhostname = @implode(".", $tbl);
    $sql = "SELECT * FROM users_containers WHERE created=1 AND onerror=0 AND iscsid=1";
    $results = $q->QUERY_SQL($sql, "artica_backup");
    $count = mysql_num_rows($results);
    if ($count > 0) {
        $sock = new sockets();
        $sock->SET_INFO("EnableISCSI", 1);
    }
    build_progress("{checking_containers}", 30);
    while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) {
        $directory = trim($ligne["directory"]);
        $ID = $ligne["container_id"];
        $container_time = $ligne["container_time"];
        if (!is_numeric($container_time)) {
            $container_time = 0;
        }
        if ($container_time == 0) {
            $container_time = time();
            $q->QUERY_SQL("UPDATE users_containers SET container_time={$container_time} WHERE container_id={$ID}", "artica_backup");
        }
        $year = date("Y", $container_time);
        $month = date("m", $container_time);
        if ($directory == null) {
            echo "{$GLOBALS["deflog_start"]} id:{$ID} No specified main directory...";
            continue;
        }
        $ContainerFullPath = $directory . "/{$ID}.disk";
        $f[] = "Target iqn.{$year}-{$month}.{$newhostname}:disk{$ID}";
        $webdav_creds = unserialize(base64_decode($ligne["webdav_creds"]));
        echo "{$GLOBALS["deflog_start"]} iqn.{$year}-{$month}.{$newhostname} {$ID}.disk LUN {$ContainerFullPath}\n";
        build_progress("iqn.{$year}-{$month}.{$newhostname} {$ID}.disk", 35);
        $f[] = "\tIncomingUser {$webdav_creds["username"]} {$webdav_creds["password"]}";
        $f[] = "\tLun {$c} Path={$ContainerFullPath},Type=fileio,IOMode=wb";
        $f[] = "\tMaxConnections 5";
        $f[] = "\tImmediateData Yes";
        $f[] = "\tWthreads 8";
        $f[] = "";
    }
    build_progress("{saving_configuration}", 40);
    echo "{$GLOBALS["deflog_start"]} ietd.conf done\n";
    @file_put_contents("/etc/iet/ietd.conf", @implode("\n", $f));
    @file_put_contents("/etc/ietd.conf", @implode("\n", $f));
    build_progress("{checking_startup_script}", 50);
    system($unix->LOCATE_PHP5_BIN() . " /usr/share/artica-postfix/exec.initslapd.php --iscsi");
    if ($GLOBALS["PROGRESS"]) {
        build_progress("{restarting}", 80);
        system("/etc/init.d/iscsitarget restart");
    }
    build_progress("{done}", 100);
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:101,代码来源:exec.iscsi.php

示例15: BuildWarning

function BuildWarning($cpu, $time)
{
    $load = sys_getloadavg();
    $unix = new unix();
    $hostname = $unix->hostname_g();
    $ldtext[] = "**** Current system load ****";
    $ldtext[] = "Load 1mn.: " . $load[0];
    $ldtext[] = "Load 5mn.: " . $load[1];
    $ldtext[] = "Load 15mn: " . $load[2];
    $ldtext[] = "*****************************";
    $subject = "CPU overload ({$cpu}%) and overloaded ({$GLOBALS["SYSTEM_INTERNAL_LOAD"]}/{$GLOBALS["SYSTEM_MAX_LOAD"]})";
    shell_exec("/bin/ps -w axo ppid,pcpu,pmem,time,args --sort -pcpu,-pmem|/usr/bin/head --lines=20 >/tmp.top.txt 2>&1");
    $top = file_get_contents("/tmp.top.txt");
    @unlink("/tmp.top.txt");
    $top = SafeProcesses() . "\n" . $top;
    $text = "Server report that your {$hostname} server has reach {$cpu}% CPU average consumption in {$time} minute(s)\n" . @implode("\n", $ldtext) . "\nYou will find below a processes report:\n---------------------------------------------\n{$top}\nGenerated by " . basename(__FILE__) . " (" . __FUNCTION__ . " on line " . __LINE__ . ") at " . date("H:i:s") . "";
    send_email_events($subject, $text, 'system');
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:18,代码来源:exec.mpstat.php


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