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


PHP OS类代码示例

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


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

示例1: getRevisionAuthor

function getRevisionAuthor($rev)
{
    $xmlLines = OS::executeAndReturnOutput("svn log -c {$rev} --xml");
    $xmlString = implode('', $xmlLines);
    $xml = simplexml_load_string($xmlString);
    return (string) $xml->logentry->author;
}
开发者ID:florinp,项目名称:dexonline,代码行数:7,代码来源:svnAnnotate.php

示例2: update

 public function update()
 {
     if (isset($this->config['build'])) {
         OS::run('cd ' . OS::bashize($this->directory) . ';git pull');
         $this->readConfig();
     }
 }
开发者ID:RemiFabre,项目名称:deps,代码行数:7,代码来源:Package.php

示例3: db_executeSqlFile

function db_executeSqlFile($filename)
{
    $dsn = Config::get('global.database');
    $parts = db_splitDsn($dsn);
    $command = sprintf("cat {$filename} | mysql -u %s %s %s", $parts['user'], $parts['database'], $parts['password'] ? "-p" . $parts['password'] : '');
    OS::executeAndAssert($command);
}
开发者ID:florinp,项目名称:dexonline,代码行数:7,代码来源:db.php

示例4: parseArguments

function parseArguments()
{
    global $argv;
    $verbose = false;
    $fileName = FILE_NAME;
    for ($i = 1; $i < count($argv); $i++) {
        $arg = $argv[$i];
        if ($arg == "-v") {
            $verbose = true;
        } else {
            if ($arg == '-f') {
                $i++;
                $fileName = $argv[$i];
            } else {
                if ($arg == '-t') {
                    runTestSuite();
                    exit;
                } else {
                    OS::errorAndExit("Unknown flag: {$arg}");
                }
            }
        }
    }
    return array($verbose, $fileName);
}
开发者ID:florinp,项目名称:dexonline,代码行数:25,代码来源:common.php

示例5: run

 public function run(array $arguments)
 {
     foreach ($arguments as $dep) {
         echo "* Removing {$dep}...\n";
         $dir = $this->deps->getPackageDirectory($dep);
         OS::run("rm -rf {$dir}");
     }
     return true;
 }
开发者ID:Rhoban,项目名称:deps,代码行数:9,代码来源:RemoveCommand.php

示例6: closeCurrentFile

function closeCurrentFile()
{
    global $g_numFiles;
    global $g_curFileName;
    global $g_curFile;
    fprintf($g_curFile, "</urlset>\n");
    fclose($g_curFile);
    OS::executeAndAssert("gzip - < {$g_curFileName} > wwwbase/sitemap{$g_numFiles}.xml.gz");
    util_deleteFile($g_curFileName);
}
开发者ID:Jobava,项目名称:mirror-dexonline,代码行数:10,代码来源:generateSitemap.php

示例7: bold

 public static function bold($message)
 {
     if (!OS::isWindows()) {
         echo "[1m";
     }
     echo $message;
     if (!OS::isWindows()) {
         echo "[m";
     }
 }
开发者ID:Rhoban,项目名称:deps,代码行数:10,代码来源:Terminal.php

示例8: GetWotdFromSubject

function GetWotdFromSubject($subject)
{
    $parts = preg_split("/\\s+/", trim($subject));
    if (count($parts) != 2) {
        OS::errorAndExit("Ignoring message '{$subject}' due to invalid subject", 0);
    }
    if ($parts[0] != Config::get('WotD.password')) {
        OS::errorAndExit("Ignoring message '{$subject}' due to invalid password in the subject", 0);
    }
    return $parts[1];
}
开发者ID:Jobava,项目名称:mirror-dexonline,代码行数:11,代码来源:getWotdImageByEmail.php

示例9: get_grid_cell

 /** @return lat_lng_bound */
 public function get_grid_cell()
 {
     /** @var lat_lng_bound $cell */
     foreach (OS::cells() as $cell) {
         if ($cell->contains($this)) {
             return $cell;
         }
     }
     $bound = new \stdClass();
     $bound->code = 'N/A';
     return $bound;
 }
开发者ID:robchett,项目名称:uknxcl,代码行数:13,代码来源:lat_lng.php

示例10: ensureThumbnail

 public function ensureThumbnail()
 {
     if (!$this->image) {
         return;
     }
     $fullImage = self::$IMAGE_DIR . "/{$this->image}";
     $fullThumb = self::$THUMB_DIR . "/{$this->image}";
     if (!file_exists($fullThumb) && file_exists($fullImage)) {
         $oldumask = umask(0);
         @mkdir(dirname($fullThumb), 0777, true);
         umask($oldumask);
         OS::executeAndAssert(sprintf("convert -strip -geometry %dx%d -sharpen 1x1 '%s' '%s'", self::$THUMB_SIZE, self::$THUMB_SIZE, $fullImage, $fullThumb));
     }
 }
开发者ID:nastasie-octavian,项目名称:DEXonline,代码行数:14,代码来源:WordOfTheDay.php

示例11: recursiveScan

function recursiveScan($path, $logFile)
{
    global $IGNORED_DIRS, $EXTENSIONS, $beforeBytes, $afterBytes;
    $files = scandir($path);
    foreach ($files as $file) {
        if (in_array($file, $IGNORED_DIRS)) {
            continue;
        }
        $full = "{$path}/{$file}";
        if (is_dir($full)) {
            recursiveScan($full, $logFile);
        } else {
            $extension = pathinfo(strtolower($full), PATHINFO_EXTENSION);
            $fullNoExt = substr($full, 0, strlen($full) - strlen($extension) - 1);
            // Strip the dot as well
            if (in_array($extension, $EXTENSIONS)) {
                OS::executeAndAssert("convert -strip '{$full}' '" . Config::get('global.tempDir') . "/fileNoExif.{$extension}'");
                OS::executeAndAssert("convert '" . Config::get('global.tempDir') . "/fileNoExif.{$extension}' '/fileNoExifPng.png'");
                OS::executeAndAssert("optipng '" . Config::get('global.tempDir') . "/fileNoExifPng.png'");
                $fs1 = filesize($full);
                $fs2 = filesize(Config::get('global.tempDir') . "/fileNoExif.{$extension}");
                $fs3 = filesize(Config::get('global.tempDir') . '/fileNoExifPng.png');
                $beforeBytes += $fs1;
                if ($fs3 < $fs1 && $fs3 < $fs2) {
                    $compression = 100.0 * (1 - $fs3 / $fs1);
                    $afterBytes += $fs3;
                    fprintf($logFile, "%s -- Strip EXIF, convert to PNG and optimize: %d/%d bytes, %.2f%% saved\n", $full, $fs3, $fs1, $compression);
                    unlink($full);
                    unlink(Config::get('global.tempDir') . "/fileNoExif.{$extension}");
                    rename(Config::get('global.tempDir') . '/fileNoExifPng.png', "{$fullNoExt}.png");
                } else {
                    if ($fs2 < $fs1) {
                        $compression = 100.0 * (1 - $fs2 / $fs1);
                        $afterBytes += $fs2;
                        fprintf($logFile, "%s -- Strip EXIF: %d/%d bytes, %.2f%% saved\n", $full, $fs2, $fs1, $compression);
                        unlink($full);
                        rename(Config::get('global.tempDir') . "/fileNoExif.{$extension}", $full);
                        unlink(Config::get('global.tempDir') . '/fileNoExifPng.png');
                    } else {
                        $afterBytes += $fs1;
                        fprintf($logFile, "{$full} -- leave unchanged\n");
                        unlink(Config::get('global.tempDir') . "/fileNoExif.{$extension}");
                        unlink(Config::get('global.tempDir') . '/fileNoExifPng.png');
                    }
                }
            }
        }
    }
}
开发者ID:florinp,项目名称:dexonline,代码行数:49,代码来源:wotdCompressImages.php

示例12: createThumb

 function createThumb()
 {
     $url = Config::get('static.url') . self::STATIC_DIR . $this->path;
     $ext = pathinfo($url, PATHINFO_EXTENSION);
     $localFile = "/tmp/a.{$ext}";
     $localThumbFile = "/tmp/thumb.{$ext}";
     $contents = file_get_contents($url);
     file_put_contents($localFile, $contents);
     $command = sprintf("convert -strip -geometry %sx%s -sharpen 1x1 '%s' '%s'", self::THUMB_SIZE, self::THUMB_SIZE, $localFile, $localThumbFile);
     OS::executeAndAssert($command);
     $f = new FtpUtil();
     $f->staticServerPut($localThumbFile, self::STATIC_THUMB_DIR . $this->path);
     unlink($localFile);
     unlink($localThumbFile);
 }
开发者ID:Jobava,项目名称:mirror-dexonline,代码行数:15,代码来源:Visual.php

示例13: run

 public function run(array $arguments)
 {
     $json = $this->deps->nearestJson();
     $linkDir = dirname($json);
     $package = new Package(dirname($json));
     $name = $package->getName();
     if (!$name) {
         echo "Error: no name for package\n";
     } else {
         echo "* Linking package {$name} to {$linkDir}...\n";
         $dir = $this->deps->getPackageDirectory($package->getName());
         if (is_dir($dir)) {
             OS::run("rm -rf {$dir}");
         }
         OS::run("ln -s {$linkDir} {$dir}");
     }
 }
开发者ID:RemiFabre,项目名称:deps,代码行数:17,代码来源:LinkCommand.php

示例14: run

 public function run(array $arguments)
 {
     $json = $this->deps->nearestJson();
     $linkDir = dirname($json);
     $package = new Package(dirname($json));
     $name = $package->getName();
     if (!$name) {
         echo "Error: no name for package\n";
     } else {
         echo "Do you want to create symlink from {$name} to {$linkDir}? (yes/no)\n";
         $l = readline();
         if (trim($l) == 'yes') {
             echo "* Linking package {$name} to {$linkDir}...\n";
             $dir = $this->deps->getPackageDirectory($package->getName());
             if (is_dir($dir)) {
                 OS::run("rm -rf {$dir}");
             }
             OS::run("ln -s {$linkDir} {$dir}");
         } else {
             echo "Aborting.\n";
         }
     }
 }
开发者ID:Rhoban,项目名称:deps,代码行数:23,代码来源:LinkCommand.php

示例15: deleteContents

 /**
  * deleteContents of a folder recursively, but not the folder itself.
  *
  * On Windows systems this will try to remove the read-only attribute if needed.
  *
  * @param string $path Path of folder whose contents will be deleted
  *
  * @throws \RuntimeException Thrown when something could not be deleted.
  */
 public static function deleteContents($path)
 {
     if (!is_dir($path)) {
         return;
     }
     /** @var \SplFileInfo[] $files */
     $files = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($path, \RecursiveDirectoryIterator::SKIP_DOTS), \RecursiveIteratorIterator::CHILD_FIRST);
     foreach ($files as $fileInfo) {
         if ($fileInfo->isDir()) {
             if (@rmdir($fileInfo->getRealPath()) === false) {
                 throw new \RuntimeException(sprintf("Unable to delete child folder '%s' in '%s': %s", $fileInfo->getFilename(), $fileInfo->getPathname(), error_get_last()['message']));
             }
         } elseif (@unlink($fileInfo->getRealPath()) === false) {
             if (OS::isWindows()) {
                 Exec::create('attrib', '-R', $fileInfo->getRealPath())->run();
                 if (@unlink($fileInfo->getPathname())) {
                     continue;
                 }
             }
             throw new \RuntimeException(sprintf("Unable to delete file '%s' in folder '%s': %s", $fileInfo->getFilename(), $fileInfo->getPathname(), error_get_last()['message']));
         }
     }
 }
开发者ID:nochso,项目名称:omni,代码行数:32,代码来源:Folder.php


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