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


PHP unix::file_ext方法代码示例

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


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

示例1: HyperCacheScanBuildLocalPath

function HyperCacheScanBuildLocalPath($uri, $ID)
{
    $path = HyperCacheRetranslation_get($uri);
    if ($path != null) {
        return $path;
    }
    $unix = new unix();
    $Root = $GLOBALS["HyperCacheStoragePath"];
    if (!is_dir($Root)) {
        @mkdir($Root, 0755, true);
        @chown($Root, "squid");
        @chgrp($Root, "squid");
    }
    $RulePath = "{$Root}/{$ID}";
    if (!is_dir($RulePath)) {
        @mkdir($RulePath, 0755, true);
        @chown($RulePath, "squid");
        @chgrp($RulePath, "squid");
    }
    $H = parse_url($uri);
    $sitename = $H["host"];
    $f = new familysite();
    $Family = $f->GetFamilySites($sitename);
    $finalDir = "{$RulePath}/{$Family}";
    if (!is_dir($finalDir)) {
        @mkdir($finalDir, 0755, true);
        @chown($finalDir, "squid");
        @chgrp($finalDir, "squid");
    }
    $path = $H["path"];
    $filename = basename($path);
    $extension = $unix->file_ext($filename);
    return "{$ID}/{$Family}/" . md5($uri) . ".{$extension}";
}
开发者ID:brucewu16899,项目名称:1.6.x,代码行数:34,代码来源:exec.squidcache.php

示例2: RestoreFromBackup


//.........这里部分代码省略.........
        RestoreFromBackup_progress("zarafa-db.sock no such socket", 100);
        return;
    }
    echo "Action: /var/run/mysqld/zarafa-db.sock OK\n";
    echo "Action: create a freshed Zarafa database\n";
    $ZarafaIndexPath = $sock->GET_INFO("ZarafaIndexPath");
    if ($ZarafaIndexPath == null) {
        $ZarafaIndexPath = "/var/lib/zarafa/index";
    }
    RestoreFromBackup_progress("Cleaning/Stopping Zarafa search DBs", 50);
    if (is_dir($ZarafaIndexPath)) {
        recursive_remove_directory("{$ZarafaIndexPath}");
        shell_exec("/etc/init.d/zarafa-search stop");
    }
    RestoreFromBackup_progress("Create a freshed Zarafa database", 50);
    $results = array();
    $cmd = "{$mysql} --socket=/var/run/mysqld/zarafa-db.sock --protocol=socket --user=root --batch --debug-info --execute=\"CREATE DATABASE zarafa\" 2>&1";
    $results = array();
    exec("{$cmd}", $results);
    while (list($num, $ligne) = each($results)) {
        echo "MySQL: (Create Database) {$ligne}\n";
    }
    RestoreFromBackup_progress("Testing Database...", 51);
    if (!is_dir("{$WORKDIR}/data/zarafa")) {
        echo "Action: FAILED TO create a freshed Zarafa database: ABORT!!\n";
        echo "Action: {$WORKDIR}/data/zarafa no such directory\n";
        RestoreFromBackup_progress("FAILED to create a freshed Zarafa database", 100);
        return;
    }
    RestoreFromBackup_progress("Checks Database size", 53);
    databasesize(true);
    $gunzip = $unix->find_program("gunzip");
    $SourceFileBase = basename($backuppath);
    $file_ext = $unix->file_ext($SourceFileBase);
    $tStart = time();
    $nohup = $unix->find_program("nohup");
    $backuppath1 = $unix->shellEscapeChars($backuppath);
    $cmd = "{$nohup} {$mysql} --show-warnings --socket=/var/run/mysqld/zarafa-db.sock --protocol=socket --user=root --batch --debug-info --database=zarafa < {$backuppath1} >/root/mysqllog.txt 2>&1 &";
    echo "Action: {$SourceFileBase} extension {$file_ext}\n";
    echo "Action: Restoring From {$backuppath1}\n";
    if ($file_ext == "gz") {
        echo "Action: Restoring From {$backuppath1} with uncompress..\n";
        $cmd = "{$nohup} {$gunzip} -c {$backuppath1} |{$mysql} --show-warnings --socket=/var/run/mysqld/zarafa-db.sock --protocol=socket --user=root --batch --debug-info --database=zarafa >/root/mysqllog.txt 2>&1 &";
    }
    $size = @filesize($backuppath);
    $size = FormatBytes($size / 1024);
    echo "Action: Please wait, it should take time...\nAction: Do not shutdown the computer or restart the MySQL service!\n";
    $results = array();
    RestoreFromBackup_progress("{restoring_data} {$size} {please_wait} !", 70);
    $lastmd5 = null;
    $continue = true;
    shell_exec($cmd);
    $ALRDLO = array();
    while ($continue) {
        $fileMD5 = @md5_file("/root/mysqllog.txt");
        if ($fileMD5 != $lastmd5) {
            $LOGS = explode("\n", @file_get_contents("/root/mysqllog.txt"));
            while (list($num, $ligne) = each($LOGS)) {
                if (trim($ligne) == null) {
                    continue;
                }
                if (isset($ALRDLO[md5($ligne)])) {
                    continue;
                }
                $ALRDLO[md5($ligne)] = true;
                if (preg_match("#ERROR\\s+([0-9]+)\\s+\\(#", $ligne, $re)) {
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:67,代码来源:exec.zarafa-db.php

示例3: ScanSpool

function ScanSpool($SQLIne)
{
    $unix = new unix();
    $GLOBALS["CLASS_UNIX"] = $unix;
    $php5 = $unix->LOCATE_PHP5_BIN();
    $domainname = $SQLIne["domainname"];
    $instance = $SQLIne["hostname"];
    $nohup = $unix->find_program("nohup");
    $params = unserialize(base64_decode($SQLIne["params"]));
    $directory = "{$GLOBALS["QUEUE_DIRECTORY"]}/{$instance}/{$domainname}";
    //smtp::events("Scanning `$directory` ",__FUNCTION__,__FILE__,__LINE__);
    if (!is_dir($directory)) {
        return;
    }
    if ($GLOBALS["VERBOSE"]) {
        smtp::events("Scanning `{$directory}` ", __FUNCTION__, __FILE__, __LINE__);
    }
    if (!($handle = opendir($directory))) {
        smtp::events("glob failed {$directory} in Line: ", __FUNCTION__, __FILE__, __LINE__);
        return;
    }
    if (!isset($params["max_msg_per_connection"])) {
        ScanSpoolEvents("Warning max_msg_per_connection is not set..", __LINE__);
        $params["max_msg_per_connection"] = 5;
    }
    if (!isset($params["max_msg_rate"])) {
        $params["max_msg_rate"] = 600;
    }
    if (!isset($params["max_smtp_out"])) {
        $params["max_smtp_out"] = 5;
    }
    if (!is_numeric($params["max_msg_per_connection"])) {
        $params["max_msg_per_connection"] = 5;
    }
    if (!is_numeric($params["max_msg_rate"])) {
        $params["max_msg_rate"] = 600;
    }
    if (!is_numeric($params["max_msg_rate_timeout"])) {
        $params["max_msg_rate_timeout"] = 300;
    }
    $max_msg_per_connection = $params["max_msg_per_connection"];
    $max_msg_rate = $params["max_msg_rate"];
    $max_smtp_out = $params["max_smtp_out"];
    //smtp::events("Scanning `$directory` Max messages per instance: $max_msg_per_connection,max_msg_rate: $max_msg_rate,Max instances:$max_smtp_out",__FUNCTION__,__FILE__,__LINE__);
    if (!aiguilleur_max_msg_rate($directory, $params)) {
        return;
    }
    $c = 0;
    $dMESS = 0;
    $smtpInstances = array();
    $DetectedInstances = array();
    ScanSpoolEvents("Starting loop in {$directory}", __LINE__);
    $CountDeScannedMessageFiles = 0;
    $INSTANCESEXEC = array();
    while (false !== ($filename = readdir($handle))) {
        $CountDeScannedMessageFiles++;
        $fullpath = "{$directory}/{$filename}";
        if (is_dir($fullpath)) {
            $DirName = basename($fullpath);
            if ($GLOBALS["DEBUG"]) {
                smtp::events("{$fullpath} is a directory `{$DirName}` -> next", __FUNCTION__, __FILE__, __LINE__);
            }
            if (is_numeric($DirName)) {
                $DetectedInstances[] = $DirName;
            }
            continue;
        }
        $ext = $unix->file_ext($fullpath);
        if ($ext != "routing") {
            if ($GLOBALS["DEBUG"]) {
                smtp::events("{$fullpath} <> routing -> next", __FUNCTION__, __FILE__, __LINE__);
            }
            continue;
        }
        if ($c >= $max_smtp_out) {
            $c = 0;
        }
        $dMESS++;
        if (count($smtpInstances[$c]) >= $max_msg_per_connection) {
            //smtp::events("Instance $c =". count($smtpInstances[$c])." >= $max_msg_per_connection -> Trying the next instance " .$c+1,__FUNCTION__,__FILE__,__LINE__);
            $c++;
            continue;
        }
        $InstanceQueueMessagesNumber = InstanceQueueMessagesNumber("{$directory}/{$c}");
        if ($InstanceQueueMessagesNumber >= $max_msg_per_connection) {
            ScanSpoolExecuteProcess($domainname, $instance, $c);
            $c++;
            continue;
        }
        $smtpInstances[$c][] = $fullpath;
        if ($GLOBALS["DEBUG"]) {
            echo "Instance {$c}, add {$fullpath} " . count($smtpInstances[$c]) . " items/{$max_msg_per_connection}\n";
        }
        $c++;
        if ($c >= $max_smtp_out) {
            $c = 0;
        }
    }
    $directoriesOfInstances = $GLOBALS["CLASS_UNIX"]->dirdir($directory);
    if (is_array($directoriesOfInstances)) {
//.........这里部分代码省略.........
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:101,代码来源:exec.smtp-senderadv.php

示例4: CheckOldCachesLog

function CheckOldCachesLog()
{
    @mkdir("/home/squid/cache-logs", 0755, true);
    $unix = new unix();
    foreach (glob("/var/log/squid/cache.log.*") as $filename) {
        if ($GLOBALS["VERBOSE"]) {
            echo "Move {$filename} to /home/squid/cache-logs\n";
        }
        Events("Move {$filename} to /home/squid/cache-logs");
        @copy($filename, "/home/squid/cache-logs/" . basename($filename));
        @unlink($filename);
    }
    foreach (glob("/home/squid/cache-logs/*") as $filename) {
        $ext = $unix->file_ext($filename);
        if (is_numeric($ext)) {
            Events("Compress {$filename} to {$filename}.gz");
            if ($unix->compress($filename, "{$filename}.gz")) {
                @unlink($filename);
            }
            continue;
        }
        if ($ext == "gz") {
            $time = $unix->file_time_min($filename);
            if ($GLOBALS["VERBOSE"]) {
                echo "{$filename}  = {$time}Mn\n";
            }
            if ($time > 4320) {
                Events("Remove {$filename} (exceed 3 days on disk...)");
                @unlink($filename);
                continue;
            }
        }
    }
    if ($GLOBALS["VERBOSE"]) {
        echo "CheckOldCachesLog:: END\n";
    }
}
开发者ID:brucewu16899,项目名称:1.6.x,代码行数:37,代码来源:exec.squid.watchdog.php

示例5: analyze_single_file

function analyze_single_file($filename)
{
    $sock = new sockets();
    $unix = new unix();
    if (!isset($GLOBALS["squidtail"])) {
        $GLOBALS["squidtail"] = new squid_tail();
    }
    if ($GLOBALS["VERBOSE"]) {
        echo $filename . " -> '/' = " . strpos($filename, '/') . " pos\n";
    }
    if (!is_file($filename)) {
        if ($GLOBALS["VERBOSE"]) {
            echo $filename . " no such file\n";
        }
        if (!tests_nas()) {
            return;
        }
        $SquidOldLogsNAS = unserialize(base64_decode($sock->GET_INFO("SquidOldLogsNAS")));
        $mountPoint = "/mnt/SquidImportLogs";
        $NasFolder = $SquidOldLogsNAS["folder"];
        $NasFolder = str_replace('\\', '/', $NasFolder);
        $NasFolder = str_replace('//', '/', $NasFolder);
        if (strpos($NasFolder, "/") > 0) {
            $f = explode("/", $NasFolder);
            unset($f[0]);
            $NasFolder = @implode("/", $f);
        }
        $targetFile = "{$mountPoint}/{$NasFolder}/{$filename}";
        $targetFile = str_replace("//", "/", $targetFile);
    } else {
        $targetFile = $filename;
    }
    $REMOVE = false;
    $ext = $unix->file_ext($targetFile);
    if ($GLOBALS["SIMULATE"]) {
        echo "Simulate enabled, no MySQL events will be injected\n";
    }
    if (!$GLOBALS["SIMULATE"]) {
        $zmd5 = md5_file($targetFile);
    }
    @mkdir("/home/squid/wkdir", 0755, true);
    if ($ext == "gz") {
        $basename = $filename;
        if (count(explode('/', $basename)) > 0) {
            $basename = basename($basename);
        }
        if ($GLOBALS["VERBOSE"]) {
            echo "Uncompress {$targetFile}\n";
        }
        $unix->uncompress($targetFile, "/home/squid/wkdir/{$basename}");
        $targetFile = "/home/squid/wkdir/{$basename}";
        $REMOVE = TRUE;
    } else {
        $basename = $targetFile;
        if (count(explode('/', $basename)) > 0) {
            $basename = basename($basename);
        }
        if ($GLOBALS["VERBOSE"]) {
            echo "Copy {$targetFile} -> /home/squid/wkdir/{$basename}\n";
        }
        if (!@copy($targetFile, "/home/squid/wkdir/{$basename}")) {
            events("Unable to copy {$targetFile} to /home/squid/wkdir/{$basename}");
            return false;
        }
        $targetFile = "/home/squid/wkdir/{$basename}";
        $REMOVE = TRUE;
    }
    events("_analyze_file - {$targetFile}");
    if (_analyze_file($targetFile, $zmd5)) {
        if ($REMOVE) {
            @unlink($targetFile);
        }
    }
    killNas();
}
开发者ID:brucewu16899,项目名称:1.6.x,代码行数:75,代码来源:exec.squid.logs.import.php


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