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


PHP wfTempDir函数代码示例

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


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

示例1: __construct

	protected function __construct() {
		$idFile = wfTempDir() . '/mw-' . __CLASS__ . '-UID-nodeid';
		$nodeId = is_file( $idFile ) ? file_get_contents( $idFile ) : '';
		// Try to get some ID that uniquely identifies this machine (RFC 4122)...
		if ( !preg_match( '/^[0-9a-f]{12}$/i', $nodeId ) ) {
			wfSuppressWarnings();
			if ( wfIsWindows() ) {
				// http://technet.microsoft.com/en-us/library/bb490913.aspx
				$csv = trim( wfShellExec( 'getmac /NH /FO CSV' ) );
				$line = substr( $csv, 0, strcspn( $csv, "\n" ) );
				$info = str_getcsv( $line );
				$nodeId = isset( $info[0] ) ? str_replace( '-', '', $info[0] ) : '';
			} elseif ( is_executable( '/sbin/ifconfig' ) ) { // Linux/BSD/Solaris/OS X
				// See http://linux.die.net/man/8/ifconfig
				$m = array();
				preg_match( '/\s([0-9a-f]{2}(:[0-9a-f]{2}){5})\s/',
					wfShellExec( '/sbin/ifconfig -a' ), $m );
				$nodeId = isset( $m[1] ) ? str_replace( ':', '', $m[1] ) : '';
			}
			wfRestoreWarnings();
			if ( !preg_match( '/^[0-9a-f]{12}$/i', $nodeId ) ) {
				$nodeId = MWCryptRand::generateHex( 12, true );
				$nodeId[1] = dechex( hexdec( $nodeId[1] ) | 0x1 ); // set multicast bit
			}
			file_put_contents( $idFile, $nodeId ); // cache
		}
		$this->nodeId32 = wfBaseConvert( substr( sha1( $nodeId ), 0, 8 ), 16, 2, 32 );
		$this->nodeId48 = wfBaseConvert( $nodeId, 16, 2, 48 );
		// If different processes run as different users, they may have different temp dirs.
		// This is dealt with by initializing the clock sequence number and counters randomly.
		$this->lockFile88 = wfTempDir() . '/mw-' . __CLASS__ . '-UID-88';
		$this->lockFile128 = wfTempDir() . '/mw-' . __CLASS__ . '-UID-128';
	}
开发者ID:nahoj,项目名称:mediawiki_ynh,代码行数:33,代码来源:UIDGenerator.php

示例2: factory

 /**
  * Make a new temporary file on the file system.
  * Temporary files may be purged when the file object falls out of scope.
  *
  * @param $prefix string
  * @param $extension string
  * @return TempFSFile|null
  */
 public static function factory($prefix, $extension = '')
 {
     wfProfileIn(__METHOD__);
     $base = wfTempDir() . '/' . $prefix . wfRandomString(12);
     $ext = $extension != '' ? ".{$extension}" : "";
     for ($attempt = 1; true; $attempt++) {
         $path = "{$base}-{$attempt}{$ext}";
         wfSuppressWarnings();
         $newFileHandle = fopen($path, 'x');
         wfRestoreWarnings();
         if ($newFileHandle) {
             fclose($newFileHandle);
             break;
             // got it
         }
         if ($attempt >= 5) {
             wfProfileOut(__METHOD__);
             return null;
             // give up
         }
     }
     $tmpFile = new self($path);
     $tmpFile->canDelete = true;
     // safely instantiated
     wfProfileOut(__METHOD__);
     return $tmpFile;
 }
开发者ID:Grprashanthkumar,项目名称:ColfusionWeb,代码行数:35,代码来源:TempFSFile.php

示例3: setUp

 protected function setUp()
 {
     global $wgFileBackends;
     parent::setUp();
     # Forge a FSRepo object to not have to rely on local wiki settings
     $tmpPrefix = wfTempDir() . '/storebatch-test-' . time() . '-' . mt_rand();
     if ($this->getCliArg('use-filebackend=')) {
         $name = $this->getCliArg('use-filebackend=');
         $useConfig = array();
         foreach ($wgFileBackends as $conf) {
             if ($conf['name'] == $name) {
                 $useConfig = $conf;
             }
         }
         $useConfig['name'] = 'local-testing';
         // swap name
         $class = $useConfig['class'];
         $backend = new $class($useConfig);
     } else {
         $backend = new FSFileBackend(array('name' => 'local-testing', 'lockManager' => 'nullLockManager', 'containerPaths' => array('unittests-public' => "{$tmpPrefix}-public", 'unittests-thumb' => "{$tmpPrefix}-thumb", 'unittests-temp' => "{$tmpPrefix}-temp", 'unittests-deleted' => "{$tmpPrefix}-deleted")));
     }
     $this->repo = new FileRepo(array('name' => 'unittests', 'backend' => $backend));
     $this->date = gmdate("YmdHis");
     $this->createdFiles = array();
 }
开发者ID:nischayn22,项目名称:mediawiki-core,代码行数:25,代码来源:StoreBatchTest.php

示例4: setUp

 function setUp()
 {
     global $wgReadOnlyFile;
     $this->originals['wgReadOnlyFile'] = $wgReadOnlyFile;
     $wgReadOnlyFile = tempnam(wfTempDir(), "mwtest_readonly");
     unlink($wgReadOnlyFile);
 }
开发者ID:amjadtbssm,项目名称:website,代码行数:7,代码来源:GlobalTest.php

示例5: createFileOfSize

 private function createFileOfSize($size)
 {
     $filename = tempnam(wfTempDir(), "mwuploadtest");
     $fh = fopen($filename, 'w');
     ftruncate($fh, $size);
     fclose($fh);
     return $filename;
 }
开发者ID:laiello,项目名称:media-wiki-law,代码行数:8,代码来源:UploadTest.php

示例6: setUp

 protected function setUp()
 {
     parent::setUp();
     // Setup a file for bug 29408
     $this->bug29408File = wfTempDir() . '/bug29408';
     file_put_contents($this->bug29408File, "");
     self::$users = ['sysop' => new TestUser('Uploadstashtestsysop', 'Upload Stash Test Sysop', 'upload_stash_test_sysop@example.com', ['sysop']), 'uploader' => new TestUser('Uploadstashtestuser', 'Upload Stash Test User', 'upload_stash_test_user@example.com', [])];
 }
开发者ID:paladox,项目名称:mediawiki,代码行数:8,代码来源:UploadStashTest.php

示例7: execute

 public function execute()
 {
     global $wgCaptchaSecret, $wgCaptchaDirectoryLevels;
     $instance = ConfirmEditHooks::getInstance();
     if (!$instance instanceof FancyCaptcha) {
         $this->error("\$wgCaptchaClass is not FancyCaptcha.\n", 1);
     }
     $backend = $instance->getBackend();
     $countAct = $instance->estimateCaptchaCount();
     $this->output("Estimated number of captchas is {$countAct}.\n");
     $countGen = (int) $this->getOption('fill') - $countAct;
     if ($countGen <= 0) {
         $this->output("No need to generate anymore captchas.\n");
         return;
     }
     $tmpDir = wfTempDir() . '/mw-fancycaptcha-' . time() . '-' . wfRandomString(6);
     if (!wfMkdirParents($tmpDir)) {
         $this->error("Could not create temp directory.\n", 1);
     }
     $e = null;
     // exception
     try {
         $cmd = sprintf("python %s --key %s --output %s --count %s --dirs %s", wfEscapeShellArg(__DIR__ . '/../captcha.py'), wfEscapeShellArg($wgCaptchaSecret), wfEscapeShellArg($tmpDir), wfEscapeShellArg($countGen), wfEscapeShellArg($wgCaptchaDirectoryLevels));
         foreach (array('wordlist', 'font', 'font-size', 'blacklist', 'verbose') as $par) {
             if ($this->hasOption($par)) {
                 $cmd .= " --{$par} " . wfEscapeShellArg($this->getOption($par));
             }
         }
         $this->output("Generating {$countGen} new captchas...\n");
         $retVal = 1;
         wfShellExec($cmd, $retVal, array(), array('time' => 0));
         if ($retVal != 0) {
             wfRecursiveRemoveDir($tmpDir);
             $this->error("Could not run generation script.\n", 1);
         }
         $flags = FilesystemIterator::SKIP_DOTS;
         $iter = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($tmpDir, $flags), RecursiveIteratorIterator::CHILD_FIRST);
         $this->output("Copying the new captchas to storage...\n");
         foreach ($iter as $fileInfo) {
             if (!$fileInfo->isFile()) {
                 continue;
             }
             list($salt, $hash) = $instance->hashFromImageName($fileInfo->getBasename());
             $dest = $instance->imagePath($salt, $hash);
             $backend->prepare(array('dir' => dirname($dest)));
             $status = $backend->quickStore(array('src' => $fileInfo->getPathname(), 'dst' => $dest));
             if (!$status->isOK()) {
                 $this->error("Could not save file '{$fileInfo->getPathname()}'.\n");
             }
         }
     } catch (Exception $e) {
         wfRecursiveRemoveDir($tmpDir);
         throw $e;
     }
     $this->output("Removing temporary files...\n");
     wfRecursiveRemoveDir($tmpDir);
     $this->output("Done.\n");
 }
开发者ID:Tarendai,项目名称:spring-website,代码行数:58,代码来源:GenerateFancyCaptchas.php

示例8: doGetLocalCopyMulti

 protected function doGetLocalCopyMulti(array $params)
 {
     $tmpFiles = array();
     // (path => MockFSFile)
     foreach ($params['srcs'] as $src) {
         $tmpFiles[$src] = new MockFSFile(wfTempDir() . '/' . wfRandomString(32));
     }
     return $tmpFiles;
 }
开发者ID:MediaWiki-stable,项目名称:1.26.1,代码行数:9,代码来源:MockFileBackend.php

示例9: __construct

 /**
  * @param $params array
  */
 public function __construct($params)
 {
     global $wgDBAhandler;
     if (!isset($params['dir'])) {
         $params['dir'] = wfTempDir();
     }
     $this->mFile = $params['dir'] . '/mw-cache-' . wfWikiID() . '.db';
     wfDebug(__CLASS__ . ": using cache file {$this->mFile}\n");
     $this->mHandler = $wgDBAhandler;
 }
开发者ID:seedbank,项目名称:old-repo,代码行数:13,代码来源:DBABagOStuff.php

示例10: populateCDB

 private function populateCDB($thisSite, $local, $global)
 {
     $cdbFile = tempnam(wfTempDir(), 'MW-ClassicInterwikiLookupTest-') . '.cdb';
     $cdb = \Cdb\Writer::open($cdbFile);
     $hash = $this->populateHash($thisSite, $local, $global);
     foreach ($hash as $key => $value) {
         $cdb->set($key, $value);
     }
     $cdb->close();
     return $cdbFile;
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:11,代码来源:ClassicInterwikiLookupTest.php

示例11: setUp

 function setUp()
 {
     $this->save = array();
     $saveVars = array('wgReadOnlyFile');
     foreach ($saveVars as $var) {
         if (isset($GLOBALS[$var])) {
             $this->save[$var] = $GLOBALS[$var];
         }
     }
     $GLOBALS['wgReadOnlyFile'] = wfTempDir() . '/testReadOnly-' . mt_rand();
 }
开发者ID:BackupTheBerlios,项目名称:openzaurus-svn,代码行数:11,代码来源:GlobalTest.php

示例12: inspectDirectory

 /**
  * Run PHP Storm's Code Inspect for a given directory
  *
  * Actually, PHP storm will be run for a given directory.
  * XML reports will then be parsed to get issues for given file.
  *
  * @param string $dirName file to run Code Inspect for
  * @return string output from Code Inspect
  * @throws Exception
  */
 protected function inspectDirectory($dirName)
 {
     global $wgPHPStormPath, $IP;
     $start = microtime(true);
     $dirName = realpath($dirName);
     $isCached = $this->cache['directory'] !== '' && strpos($dirName, $this->cache['directory']) === 0;
     if (!$isCached) {
         $lintProfile = dirname(__FILE__) . '/php/profiles/phplint.xml';
         $projectMetaData = dirname(__FILE__) . '/php/project';
         // copy project meta data to trunk root
         $copyCmd = "cp -rf {$projectMetaData}/.idea {$IP}";
         echo "Copying project meta data <{$copyCmd}>...";
         exec($copyCmd);
         echo " [done]\n";
         // create a temporary directory for Code Inspect results
         $resultsDir = wfTempDir() . '/phpstorm/' . uniqid('lint');
         echo "Creating temporary directory for results <{$resultsDir}>...";
         if (wfMkdirParents($resultsDir)) {
             echo " [done]\n";
         } else {
             echo " [err!]\n";
         }
         $cmd = sprintf('/bin/sh %s/inspect.sh %s %s %s -d %s -v2', $wgPHPStormPath, realpath($IP . '/includes/..'), $lintProfile, $resultsDir, $dirName);
         echo "Running PHP storm <{$cmd}>...";
         #echo "Running PhpStorm for <{$dirName}>...";
         $retVal = 0;
         $output = array();
         exec($cmd, $output, $retVal);
         if ($retVal !== 0) {
             throw new Exception("{$cmd} ended with code #{$retVal}");
         }
         // get the version of PhpStorm
         $tool = '';
         foreach ($output as $line) {
             if (strpos($line, 'Starting up JetBrains PhpStorm') !== false) {
                 preg_match('#JetBrains PhpStorm [\\d\\.]+#', $line, $matches);
                 $tool = $matches[0];
             }
         }
         echo implode("\n", $output);
         // debug
         echo " [done]\n";
         // format results
         $output = array('problems' => $this->parseResults($resultsDir), 'tool' => $tool);
         // update the cache
         $this->cache = array('directory' => $dirName, 'output' => $output);
     } else {
         //echo "Got results from cache for <{$this->cache['directory']}>\n";
         $output = $this->cache['output'];
     }
     $output['time'] = round(microtime(true) - $start, 4);
     return $output;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:63,代码来源:CodeLintPhp.class.php

示例13: uploadFromUrl

 /**
  * @param LocalFile $file
  * @param string $url
  * @param string $comment
  * @return FileRepoStatus
  */
 private function uploadFromUrl($file, $url, $comment)
 {
     $tmpFile = tempnam(wfTempDir(), 'upload');
     // fetch an asset
     $res = Http::get($url, 'default', ['noProxy' => true]);
     $this->assertTrue($res !== false, 'File from <' . $url . '> should be uploaded');
     file_put_contents($tmpFile, $res);
     $this->assertTrue(is_readable($tmpFile), 'Temp file for HTTP upload should be created and readable');
     Wikia::log(__METHOD__, false, sprintf('uploading %s (%.2f kB) as %s', $tmpFile, filesize($tmpFile) / 1024, $file->getName()), true);
     $res = $file->upload($tmpFile, $comment, '');
     #unlink( $tmpFile );
     return $res;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:19,代码来源:ImagesServiceUploadTest.php

示例14: makeChunk

	function makeChunk( $content ) {
		$file = tempnam( wfTempDir(), "" );
		$fh = fopen( $file, "wb" );
		if ( $fh == false ) {
			$this->markTestIncomplete( "Couldn't open $file!\n" );
			return;
		}
		fwrite( $fh, $content );
		fclose( $fh );

		$_FILES['chunk']['tmp_name'] = $file;
		$_FILES['chunk']['size'] = 3;
		$_FILES['chunk']['error'] = null;
		$_FILES['chunk']['name'] = "test.txt";
	}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:15,代码来源:ResumableUploadTest.php

示例15: setUp

 function setUp()
 {
     parent::setUp();
     $this->filePath = dirname(__FILE__) . '/../../data/media/';
     $this->handler = new BitmapHandler();
     $this->repo = new FSRepo(array('name' => 'temp', 'directory' => wfTempDir() . '/exif-test-' . time() . '-' . mt_rand(), 'url' => 'http://localhost/thumbtest'));
     if (!wfDl('exif')) {
         $this->markTestSkipped("This test needs the exif extension.");
     }
     global $wgShowEXIF;
     $this->show = $wgShowEXIF;
     $wgShowEXIF = true;
     global $wgEnableAutoRotation;
     $this->oldAuto = $wgEnableAutoRotation;
     $wgEnableAutoRotation = true;
 }
开发者ID:eFFemeer,项目名称:seizamcore,代码行数:16,代码来源:ExifRotationTest.php


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