• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP sys_get_temp_dir函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: dir_name

 public function dir_name()
 {
     $path = ini_get("xhprof.output_dir");
     $path = empty($path) ? sys_get_temp_dir() : $path;
     return $path;
     // return DATA_DIR."/xhprof/";
 }
开发者ID:sss201413,项目名称:ecstore,代码行数:7,代码来源:xhprof.php


示例2: __construct

 public function __construct($namespace = '', $defaultLifetime = 0, $directory = null)
 {
     parent::__construct('', $defaultLifetime);
     if (!isset($directory[0])) {
         $directory = sys_get_temp_dir() . '/symfony-cache';
     }
     if (isset($namespace[0])) {
         if (preg_match('#[^-+_.A-Za-z0-9]#', $namespace, $match)) {
             throw new InvalidArgumentException(sprintf('FilesystemAdapter namespace contains "%s" but only characters in [-+_.A-Za-z0-9] are allowed.', $match[0]));
         }
         $directory .= '/' . $namespace;
     }
     if (!file_exists($dir = $directory . '/.')) {
         @mkdir($directory, 0777, true);
     }
     if (false === ($dir = realpath($dir))) {
         throw new InvalidArgumentException(sprintf('Cache directory does not exist (%s)', $directory));
     }
     if (!is_writable($dir .= DIRECTORY_SEPARATOR)) {
         throw new InvalidArgumentException(sprintf('Cache directory is not writable (%s)', $directory));
     }
     // On Windows the whole path is limited to 258 chars
     if ('\\' === DIRECTORY_SEPARATOR && strlen($dir) > 234) {
         throw new InvalidArgumentException(sprintf('Cache directory too long (%s)', $directory));
     }
     $this->directory = $dir;
 }
开发者ID:zanderbaldwin,项目名称:symfony,代码行数:27,代码来源:FilesystemAdapter.php


示例3: testFromNonDirectoryWithNonExistingPath

 public function testFromNonDirectoryWithNonExistingPath()
 {
     $directory = uniqid(sys_get_temp_dir() . 'non-existing', true);
     $exception = InvalidDirectory::fromNonDirectory($directory);
     self::assertInstanceOf(InvalidDirectory::class, $exception);
     self::assertSame(sprintf('"%s" does not exists', $directory), $exception->getMessage());
 }
开发者ID:roave,项目名称:better-reflection,代码行数:7,代码来源:InvalidDirectoryTest.php


示例4: testExecution

 /**
  * @dataProvider getFormat
  * @runInSeparateProcess
  */
 public function testExecution($format)
 {
     $tmpDir = sys_get_temp_dir() . '/sf_hello';
     $filesystem = new Filesystem();
     $filesystem->remove($tmpDir);
     $filesystem->mkdirs($tmpDir);
     chdir($tmpDir);
     $tester = new CommandTester(new InitCommand());
     $tester->execute(array('--name' => 'Hello' . $format, '--app-path' => 'hello' . $format, '--web-path' => 'web', '--src-path' => 'src', '--format' => $format));
     // autoload
     $content = file_get_contents($file = $tmpDir . '/src/autoload.php');
     $content = str_replace("__DIR__.'/vendor", "'" . __DIR__ . "/../../../../src/vendor", $content);
     file_put_contents($file, $content);
     // Kernel
     $class = 'Hello' . $format . 'Kernel';
     $file = $tmpDir . '/hello' . $format . '/' . $class . '.php';
     $this->assertTrue(file_exists($file));
     $content = file_get_contents($file);
     $content = str_replace("__DIR__.'/../src/vendor/Symfony/src/Symfony/Bundle'", "'" . __DIR__ . "/../../../../src/vendor/Symfony/src/Symfony/Bundle'", $content);
     file_put_contents($file, $content);
     require_once $file;
     $kernel = new $class('dev', true);
     $response = $kernel->handle(Request::create('/'));
     $this->assertRegExp('/successfully/', $response->getContent());
     $filesystem->remove($tmpDir);
 }
开发者ID:kawahara,项目名称:symfony-bootstrapper,代码行数:30,代码来源:InitCommandTest.php


示例5: processemail

 public static function processemail($emailsrc, $pdfout, $coverfile = '')
 {
     $combfilelist = array();
     # Process the email
     $emailparts = Mail_mimeDecode::decode(array('include_bodies' => true, 'decode_bodies' => true, 'decode_headers' => true, 'input' => file_get_contents($emailsrc), 'crlf' => "\r\n"));
     # Process the cover if it exists
     if ($coverfile !== '') {
         $combfilelist[] = self::processpart(file_get_contents($coverfile), mime_content_type($coverfile));
     }
     # Process the parts
     $combfilelist = array_merge($combfilelist, self::processparts($emailparts));
     # Create an intermediate file to build the pdf
     $tmppdffilename = sys_get_temp_dir() . '/e2p-' . (string) abs((int) (microtime(true) * 100000)) . '.pdf';
     # Build the command to combine all of the intermediate files into one
     $conbcom = str_replace(array_merge(array('INTFILE', 'COMBLIST'), array_keys(self::$driver_paths)), array_merge(array($tmppdffilename, implode(' ', $combfilelist)), array_values(self::$driver_paths)), self::$mime_drivers['gs']);
     exec($conbcom);
     # Remove the intermediate files
     foreach ($combfilelist as $combfilename) {
         unlink($combfilename);
     }
     # Write the intermediate file to the final destination
     $intfileres = fopen($tmppdffilename, 'rb');
     $outfileres = fopen($pdfout, 'ab');
     while (!feof($intfileres)) {
         fwrite($outfileres, fread($intfileres, 8192));
     }
     fclose($intfileres);
     fclose($outfileres);
     # Remove the intermediate file
     unlink($tmppdffilename);
 }
开发者ID:swk,项目名称:bluebox,代码行数:31,代码来源:emailtopdf.php


示例6: testSetPath

 public function testSetPath()
 {
     $exporter = $this->getMockForAbstractClass(AbstractExporter::class);
     $path = sys_get_temp_dir() . DIRECTORY_SEPARATOR . sha1(time()) . DIRECTORY_SEPARATOR;
     $exporter->setPath($path);
     $this->assertEquals($path, $exporter->getPath());
 }
开发者ID:fireguard,项目名称:report,代码行数:7,代码来源:AbstractExporterTest.php


示例7: setUp

 public function setUp()
 {
     $this->numberOfPayloads = 5;
     $this->tempDirectory = sys_get_temp_dir() . '/orphanage';
     $this->realDirectory = sys_get_temp_dir() . '/storage';
     $this->payloads = array();
     $filesystem = new Filesystem();
     $filesystem->mkdir($this->tempDirectory);
     $filesystem->mkdir($this->realDirectory);
     for ($i = 0; $i < $this->numberOfPayloads; $i++) {
         // create temporary file
         $file = tempnam(sys_get_temp_dir(), 'uploader');
         $pointer = fopen($file, 'w+');
         fwrite($pointer, str_repeat('A', 1024), 1024);
         fclose($pointer);
         $this->payloads[] = new FilesystemFile(new UploadedFile($file, $i . 'grumpycat.jpeg', null, null, null, true));
     }
     // create underlying storage
     $this->storage = new FilesystemStorage($this->realDirectory);
     // is ignored anyways
     $chunkStorage = new FilesystemChunkStorage('/tmp/');
     // create orphanage
     $session = new Session(new MockArraySessionStorage());
     $session->start();
     $config = array('directory' => $this->tempDirectory);
     $this->orphanage = new FilesystemOrphanageStorage($this->storage, $session, $chunkStorage, $config, 'cat');
 }
开发者ID:lsv,项目名称:OneupUploaderBundle,代码行数:27,代码来源:FilesystemOrphanageStorageTest.php


示例8: setUp

 public function setUp()
 {
     $this->tmpdir = sys_get_temp_dir() . '/' . uniqid('conveyor');
     $this->projectdir = $this->tmpdir . '/project';
     $this->reposdir = $this->tmpdir . '/repos';
     $this->reposurl = 'file:///' . $this->reposdir;
     $this->filesystem = new Filesystem();
     $this->filesystem->mkdir($this->tmpdir);
     $this->filesystem->mkdir($this->projectdir);
     $svnadminbin = getenv('SVNADMIN_BIN') ? getenv('SVNADMIN_BIN') : '/usr/local/bin/svnadmin';
     $svnbin = getenv('SVN_BIN') ? getenv('SVN_BIN') : '/usr/local/bin/svn';
     if (!file_exists($svnadminbin)) {
         $this->markTestSkipped(sprintf('%s not found', $svnadminbin));
     }
     if (!file_exists($svnbin)) {
         $this->markTestSkipped(sprintf('%s not found', $svnbin));
     }
     $svnadmin = new Svnadmin($this->tmpdir, $svnadminbin);
     $svnadmin->create(basename($this->reposdir));
     $svn = new Svn($this->reposurl, new CliAdapter($svnbin, new Cli(), new CliParser()));
     $svn->import(__DIR__ . '/../Test/Fixtures/skeleton/svn/trunk', '/', 'imported skeleton');
     $svn->setHead(new Reference('2.1', Reference::TAG));
     $svn->import(__DIR__ . '/../Test/Fixtures/skeleton/svn/tags/2.1', '/', 'imported skeleton');
     $svn->setHead(new Reference('feature1', Reference::BRANCH));
     $svn->import(__DIR__ . '/../Test/Fixtures/skeleton/svn/branches/feature1', '/', 'imported skeleton');
     $content = file_get_contents(__DIR__ . '/../Test/Fixtures/conveyor.yml.twig');
     $content = str_replace('{{ repository.url }}', $this->reposurl, $content);
     file_put_contents($this->projectdir . '/conveyor.yml', $content);
     chdir($this->projectdir);
 }
开发者ID:webcreate,项目名称:conveyor,代码行数:30,代码来源:VersionsCommandTest.php


示例9: assembleBook

 public function assembleBook()
 {
     // implode all the contents to create the whole book
     $book = $this->app->render('book.twig', array('items' => $this->app['publishing.items']));
     $temp = tempnam(sys_get_temp_dir(), 'easybook_');
     fputs(fopen($temp, 'w+'), $book);
     // use PrinceXML to transform the HTML book into a PDF book
     $prince = $this->app->get('prince');
     $prince->setBaseURL($this->app['publishing.dir.contents'] . '/images');
     // Prepare and add stylesheets before PDF conversion
     if ($this->app->edition('include_styles')) {
         $defaultStyles = tempnam(sys_get_temp_dir(), 'easybook_style_');
         $this->app->renderThemeTemplate('style.css.twig', array('resources_dir' => $this->app['app.dir.resources'] . '/'), $defaultStyles);
         $prince->addStyleSheet($defaultStyles);
     }
     // TODO: custom book styles could also be defined with Twig
     $customCss = $this->app->getCustomTemplate('style.css');
     if (file_exists($customCss)) {
         $prince->addStyleSheet($customCss);
     }
     // TODO: the name of the book file (book.pdf) must be configurable
     $errorMessages = array();
     $prince->convert_file_to_file($temp, $this->app['publishing.dir.output'] . '/book.pdf', $errorMessages);
     // show PDF conversion errors
     if (count($errorMessages) > 0) {
         foreach ($errorMessages as $message) {
             echo $message[0] . ': ' . $message[2] . ' (' . $message[1] . ')' . "\n";
         }
     }
 }
开发者ID:raulfraile,项目名称:easybook,代码行数:30,代码来源:PdfPublisher.php


示例10: setUp

 public function setUp()
 {
     parent::setUp();
     $this->originalFile = __DIR__ . '/files/testimage.gif';
     $this->compressedFile = $temp_file = sys_get_temp_dir() . '/php_image_optimizer.gif';
     copy($this->originalFile, $this->compressedFile);
 }
开发者ID:approached,项目名称:laravel-image-optimizer,代码行数:7,代码来源:ConvertGIFTest.php


示例11: getZippedFile

	private static function getZippedFile($filename) {
		
		if(!self::zipModuleLoaded()) {
			throw new WURFL_WURFLException("The Zip extension is not loaded. Load the extension or use the flat wurfl.xml file");
		}
		
		
		$tmpDir = sys_get_temp_dir();
		
		$zip = new ZipArchive();

		if ($zip->open($filename)!==TRUE) {
			exit("cannot open <$filename>\n");
		}
		$zippedFile = $zip->statIndex(0);
		$wurflFile = $zippedFile['name'];
		
		//$wurflFile = md5(uniqid(rand(), true)); 
		
		//$zip->extractTo($tmpDir, $wurflFile);
		$zip->extractTo($tmpDir);

		$zip->close();
		
		return $tmpDir . '/' .$wurflFile;
	}
开发者ID:richard-cai,项目名称:Zend-Framework-Extended,代码行数:26,代码来源:Utils.php


示例12: testDetectTypeFromFileCannotOpen

 /**
  * @expectedException XML_XRD_Loader_Exception
  * @expectedExceptionMessage Cannot open file to determine type
  */
 public function testDetectTypeFromFileCannotOpen()
 {
     $file = tempnam(sys_get_temp_dir(), 'xml_xrd-unittests');
     $this->cleanupList[] = $file;
     chmod($file, '0000');
     @$this->loader->detectTypeFromFile($file);
 }
开发者ID:pear,项目名称:xml_xrd,代码行数:11,代码来源:LoaderTest.php


示例13: tempFilename

 protected function tempFilename()
 {
     $temp_dir = is_null($this->temp_dir) ? sys_get_temp_dir() : $this->temp_dir;
     $filename = tempnam($temp_dir, "xlsx_writer_");
     $this->temp_files[] = $filename;
     return $filename;
 }
开发者ID:mk-j,项目名称:php_xlsxwriter,代码行数:7,代码来源:xlsxwriter.class.php


示例14: php_sys_get_temp_dir

/**
 * NOTE: This function is incomplete, the fallback is to '/tmp' which targets Unix-like.
 *
 * @return string
 */
function php_sys_get_temp_dir()
{
    // (PHP 5 >= 5.2.1)
    if (function_exists('sys_get_temp_dir')) {
        return sys_get_temp_dir();
    }
    // (PHP 4 >= 4.3.0, PHP 5)
    if (function_exists('stream_get_meta_data')) {
        $handle = tmpfile();
        // (PHP 4, PHP 5)
        $meta = stream_get_meta_data($handle);
        // (PHP 5 >= 5.1.0)
        if (isset($meta['uri'])) {
            return dirname($meta['uri']);
        }
    }
    // emulate  PHP 4 <= 4.0.6 tempnam() behavior, fragile
    foreach (array('TMPDIR', 'TMP') as $key) {
        if (isset($_ENV[$key])) {
            return $_ENV[$key];
        }
    }
    // fallback for Unix-like (php_shell specifically)
    return '/tmp';
}
开发者ID:melzaiady,项目名称:DropboxUploader,代码行数:30,代码来源:test-filemtime.php


示例15: generate

 public function generate()
 {
     $tempPath = sys_get_temp_dir() . '/';
     // FastCGI fix for Windows machines, where temp path is not available to
     // PHP, and defaults to the unwritable system directory.  If the temp
     // path is pointing to the system directory, shift to the 'TEMP'
     // sub-folder, which should also exist, but actually be writable.
     if (IS_WIN && $tempPath == getenv("SystemRoot") . '/') {
         $tempPath = getenv("SystemRoot") . '/TEMP/';
     }
     $keyFile = $tempPath . md5(microtime(true));
     if (!is_dir($tempPath)) {
         mkdir($tempPath);
     }
     $return = array();
     if ($this->canGenerateKeys()) {
         shell_exec('ssh-keygen -q -t rsa -b 2048 -f ' . $keyFile . ' -N "" -C "deploy@phpci"');
         $pub = file_get_contents($keyFile . '.pub');
         $prv = file_get_contents($keyFile);
         if (empty($pub)) {
             $pub = '';
         }
         if (empty($prv)) {
             $prv = '';
         }
         $return = array('private_key' => $prv, 'public_key' => $pub);
     }
     return $return;
 }
开发者ID:bztrn,项目名称:PHPCI,代码行数:29,代码来源:SshKey.php


示例16: process

 /**
  *
  * @param resource $pipe        	
  * @param string $job        	
  *
  * @throws PHPUnit_Framework_Exception
  *
  * @since Method available since Release 3.5.12
  */
 protected function process($pipe, $job)
 {
     if (!($this->tempFile = tempnam(sys_get_temp_dir(), 'PHPUnit')) || file_put_contents($this->tempFile, $job) === false) {
         throw new PHPUnit_Framework_Exception('Unable to write temporary file');
     }
     fwrite($pipe, '<?php require_once ' . var_export($this->tempFile, true) . '; ?>');
 }
开发者ID:sapwoo,项目名称:portfolio,代码行数:16,代码来源:Windows.php


示例17: filterDump

 public function filterDump(AssetInterface $asset)
 {
     $pb = $this->createProcessBuilder(array($this->jpegtranBin));
     if ($this->optimize) {
         $pb->add('-optimize');
     }
     if ($this->copy) {
         $pb->add('-copy')->add($this->copy);
     }
     if ($this->progressive) {
         $pb->add('-progressive');
     }
     if (null !== $this->restart) {
         $pb->add('-restart')->add($this->restart);
     }
     $pb->add($input = tempnam(sys_get_temp_dir(), 'assetic_jpegtran'));
     file_put_contents($input, $asset->getContent());
     $proc = $pb->getProcess();
     $code = $proc->run();
     unlink($input);
     if (0 < $code) {
         throw FilterException::fromProcess($proc)->setInput($asset->getContent());
     }
     $asset->setContent($proc->getOutput());
 }
开发者ID:Wilsoncreative,项目名称:bloggkit,代码行数:25,代码来源:JpegtranFilter.php


示例18: createBundleMock

 /**
  * @return BundleInterface|\PHPUnit_Framework_MockObject_MockObject
  */
 private function createBundleMock()
 {
     $bundleMock = $this->getMock('Symfony\\Component\\HttpKernel\\Bundle\\BundleInterface');
     $bundleMock->expects($this->any())->method('getNamespace')->will($this->returnValue('Sonata\\AdminBundle\\Tests\\Fixtures'));
     $bundleMock->expects($this->any())->method('getPath')->will($this->returnValue(sprintf('%s/%s', sys_get_temp_dir(), lcg_value())));
     return $bundleMock;
 }
开发者ID:saberyounis,项目名称:Sonata-Project,代码行数:10,代码来源:AdminGeneratorTest.php


示例19: start

	public static function start(){
		//PHP
		self::$params["safe_mode"] = (int) ini_get("safe_mode");
		self::$params["safe_mode_gid"] = (int) ini_get("safe_mode_gid");
		self::$params["upload_max_size"] = ini_get("upload_max_filesize");
    	self::$params["post_max_size"] = ini_get("post_max_size");
		self::$params["memory_limit"] = ((ini_get("memory_limit")!="")?ini_get("memory_limit"):get_cfg_var("memory_limit"));
		self::$params["max_execution_time"] = ini_get("max_execution_time");
		
		$uploadTmpDir = ini_get("upload_tmp_dir");
		$uploadTmpDir = $uploadTmpDir ? $uploadTmpDir : realpath(sys_get_temp_dir()); 
		self::$params["upload_tmp_dir"] = $uploadTmpDir;		
		self::$params["upload_tmp_dir_writable"] =  @is_writable($uploadTmpDir);
		self::$params["output_buffering"] = (int)  !! ini_get('output_buffering');
		
		//ZLIB
		self::$params["zlib"] = (int) function_exists('gzopen');
		
		
		//For future or commercial versions
		self::$params["xml_parser_create"] = (int) function_exists("xml_parser_create");
		//GD
		self::$params['gd'] = (int) (function_exists("gd_info") && function_exists("imagecopyresized") && function_exists("imagecopyresampled")) ;
			
		
		self::liveTests();
	}
开发者ID:utopszkij,项目名称:lmp,代码行数:27,代码来源:diaghelper.php


示例20: testRouteSetupInstallerInstall

 public function testRouteSetupInstallerInstall()
 {
     $emMock = $this->createEntityManagerMock();
     $this->app['repo.sessions'] = $this->createEntityRepositoryMock();
     $this->app['EM'] = $emMock;
     $this->app['phraseanet.configuration-tester']->expects($this->once())->method('isBlank')->will($this->returnValue(true));
     $this->app['phraseanet.installer'] = $this->getMockBuilder('Alchemy\\Phrasea\\Setup\\Installer')->disableOriginalConstructor()->getMock();
     $user = $this->createUserMock();
     $this->app['phraseanet.installer']->expects($this->once())->method('install')->will($this->returnValue($user));
     $authenticator = $this->getMockBuilder('Alchemy\\Phrasea\\Authentication\\Authenticator')->disableOriginalConstructor()->getMock();
     $session = $this->getMock('Entities\\Session');
     $authenticator->expects($this->once())->method('openAccount')->with($this->equalTo($user))->will($this->returnValue($session));
     $this->app['authentication'] = $authenticator;
     $client = $this->createClient();
     $settings = Yaml::parse(file_get_contents(__DIR__ . '/../../../../../resources/hudson/InstallDBs.yml'));
     $settings = $settings['database'];
     $host = isset($settings['host']) ? $settings['host'] : 'localhost';
     $port = isset($settings['port']) ? $settings['port'] : '3306';
     $user = isset($settings['user']) ? $settings['user'] : 'root';
     $password = isset($settings['password']) ? $settings['password'] : '';
     $abName = isset($settings['ab_name']) ? $settings['ab_name'] : null;
     $dbName = isset($settings['db_name']) ? $settings['db_name'] : null;
     $params = array('email' => '[email protected]', 'password' => 'prètty%%password', 'binary_xpdf' => '/path/to/xpdf', 'binary_mplayer' => '/path/to/mplayer', 'binary_MP4Box' => '/path/to/MP4Box', 'binary_ffmpeg' => '/path/to/ffmpeg', 'binary_unoconv' => '/path/to/unoconv', 'binary_swfrender' => '/path/to/swfrender', 'binary_pdf2swf' => '/path/to/pdf2swf', 'binary_swfextract' => '/path/to/swfextract', 'binary_exiftool' => '/path/to/exiftool', 'binary_composite' => '/path/to/composite', 'binary_convert' => '/path/to/convert', 'binary_php' => '/path/to/php', 'datapath_noweb' => sys_get_temp_dir() . '/datainstall/noweb', 'hostname' => $host, 'port' => $port, 'user' => $user, 'db_password' => $password, 'ab_name' => $abName, 'db_name' => $dbName, 'db_template' => 'en', 'create_task' => array(), 'binary_phraseanet_indexer' => '/path/to/phraseanet_indexer');
     $client->request('POST', '/setup/installer/install/', $params);
     $response = $client->getResponse();
     $this->assertEquals(302, $response->getStatusCode());
     $this->assertTrue(false === strpos($response->headers->get('location'), '/setup/installer/'), $response);
 }
开发者ID:nlegoff,项目名称:Phraseanet,代码行数:28,代码来源:SetupTest.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP sys_getloadavg函数代码示例发布时间:2022-05-23
下一篇:
PHP sys_get_param_str函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap