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


PHP getTempFolder函数代码示例

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


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

示例1: getStore

 /**
  * @return HybridSessionStore_Cookie
  */
 protected function getStore()
 {
     $store = Injector::inst()->get('HybridSessionStore');
     $store->setKey(uniqid());
     $store->open(getTempFolder() . '/' . __CLASS__, 'SESSIONCOOKIE');
     return $store;
 }
开发者ID:owindsor,项目名称:silverstripe-hybridsessions,代码行数:10,代码来源:HybridSessionStoreTest.php

示例2: getJobDir

 /**
  * Gets the path to the queuedjob cache directory
  */
 protected function getJobDir()
 {
     // make sure our temp dir is in place. This is what will be inotify watched
     $jobDir = Config::inst()->get('QueuedJobService', 'cache_dir');
     if ($jobDir[0] != '/') {
         $jobDir = getTempFolder() . '/' . $jobDir;
     }
     if (!is_dir($jobDir)) {
         Filesystem::makeFolder($jobDir);
     }
     return $jobDir;
 }
开发者ID:nyeholt,项目名称:silverstripe-queuedjobs,代码行数:15,代码来源:QueuedJobDescriptor.php

示例3: prepareForRestart

 /**
  * On any restart, make sure to check that our temporary file is being created still.
  */
 public function prepareForRestart()
 {
     parent::prepareForRestart();
     // if the file we've been building is missing, lets fix it up
     if (!$this->tempFile || !file_exists($this->tempFile)) {
         $tmpfile = tempnam(getTempFolder(), 'sitemap');
         if (file_exists($tmpfile)) {
             $this->tempFile = $tmpfile;
         }
         $this->currentStep = 0;
         $this->pagesToProcess = DB::query('SELECT ID FROM SiteTree_Live WHERE ShowInSearch=1')->column();
     }
 }
开发者ID:tim-lar,项目名称:silverstripe-queuedjobs,代码行数:16,代码来源:GenerateGoogleSitemapJob.php

示例4: prepareForRestart

 /**
  * On any restart, make sure to check that our temporary file is being created still. 
  */
 public function prepareForRestart()
 {
     parent::prepareForRestart();
     // if the file we've been building is missing, lets fix it up
     if (!$this->tempFile || !file_exists($this->tempFile)) {
         $tmpfile = tempnam(getTempFolder(), 'postsitemap');
         if (file_exists($tmpfile)) {
             $this->tempFile = $tmpfile;
         }
         $this->currentStep = 0;
         $this->toProcess = $this->getProcessIds();
     }
 }
开发者ID:helpfulrobot,项目名称:silverstripe-microblog,代码行数:16,代码来源:GeneratePostSitemapJob.php

示例5: testGetTempPathInProject

 public function testGetTempPathInProject()
 {
     if (file_exists($this->tempPath)) {
         $this->assertEquals(getTempFolder(BASE_PATH), $this->tempPath);
     } else {
         // A typical Windows location for where sites are stored on IIS
         $this->assertEquals(getTempFolder('C:\\inetpub\\wwwroot\\silverstripe-test-project'), sys_get_temp_dir() . '/silverstripe-cacheC--inetpub-wwwroot-silverstripe-test-project');
         // A typical Mac OS X location for where sites are stored
         $this->assertEquals(getTempFolder('/Users/joebloggs/Sites/silverstripe-test-project'), sys_get_temp_dir() . '/silverstripe-cache-Users-joebloggs-Sites-silverstripe-test-project');
         // A typical Linux location for where sites are stored
         $this->assertEquals(getTempFolder('/var/www/silverstripe-test-project'), sys_get_temp_dir() . '/silverstripe-cache-var-www-silverstripe-test-project');
     }
 }
开发者ID:normann,项目名称:sapphire,代码行数:13,代码来源:CoreTest.php

示例6: testGetTempPathInProject

 public function testGetTempPathInProject()
 {
     $user = getTempFolderUsername();
     if (file_exists($this->tempPath)) {
         $this->assertEquals(getTempFolder(BASE_PATH), $this->tempPath . DIRECTORY_SEPARATOR . $user);
     } else {
         $user = getTempFolderUsername();
         $base = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'silverstripe-cache-php' . preg_replace('/[^\\w-\\.+]+/', '-', PHP_VERSION);
         // A typical Windows location for where sites are stored on IIS
         $this->assertEquals($base . 'C--inetpub-wwwroot-silverstripe-test-project' . DIRECTORY_SEPARATOR . $user, getTempFolder('C:\\inetpub\\wwwroot\\silverstripe-test-project'));
         // A typical Mac OS X location for where sites are stored
         $this->assertEquals($base . '-Users-joebloggs-Sites-silverstripe-test-project' . DIRECTORY_SEPARATOR . $user, getTempFolder('/Users/joebloggs/Sites/silverstripe-test-project'));
         // A typical Linux location for where sites are stored
         $this->assertEquals($base . '-var-www-silverstripe-test-project' . DIRECTORY_SEPARATOR . $user, getTempFolder('/var/www/silverstripe-test-project'));
     }
 }
开发者ID:SpiritLevel,项目名称:silverstripe-framework,代码行数:16,代码来源:CoreTest.php

示例7: requireTempFolder

 public function requireTempFolder($testDetails)
 {
     $this->testing($testDetails);
     try {
         $tempFolder = getTempFolder();
     } catch (Exception $e) {
         $tempFolder = false;
     }
     if (!$tempFolder) {
         $testDetails[2] = "Permission problem gaining access to a temp directory. " . "Please create a folder named silverstripe-cache in the base directory " . "of the installation and ensure it has the adequate permissions.";
         $this->error($testDetails);
     }
 }
开发者ID:miamollie,项目名称:echoAerial,代码行数:13,代码来源:install.php5

示例8: importAttachmentsAsFiles

 /**
  *
  */
 public function importAttachmentsAsFiles($directory = null)
 {
     // todo(Jake): make $directory use relative to the SS/basedir rather than full filepath
     $this->logFunctionStart(__FUNCTION__);
     if ($directory === null) {
         throw new Exception('Must provide a $directory parameter');
     }
     $directorIsCLI = Director::is_cli();
     $folderMap = array();
     $existingWpIDs = singleton('File')->WordpressIDsMap();
     $fileResolver = new WordpressAttachmentFileResolver($directory, getTempFolder());
     if (!$fileResolver->getFilesRecursive()) {
         $this->log('No files found recursively in ' . $fileResolver->directory);
         $this->logFunctionEnd(__FUNCTION__);
         return;
     }
     $basePath = Director::baseFolder() . DIRECTORY_SEPARATOR;
     $baseAssetPath = $basePath . ASSETS_DIR . DIRECTORY_SEPARATOR;
     $this->setupDefaultDatabaseIfNull();
     $attachments = $this->_db->getAttachments();
     foreach ($attachments as $wpData) {
         $wpID = $wpData['ID'];
         if (isset($existingWpIDs[$wpID])) {
             //$this->log('File (Wordpress ID: '.$wpID.') already imported.');
             continue;
         }
         $wpMeta = $this->_db->attachAndGetAttachmentMeta($wpData);
         if (isset($wpMeta['_wp_attached_file'])) {
             $filepaths = $fileResolver->getFilepathsFromRecord($wpData);
             if (!$filepaths) {
                 $this->log('Unable to find matching file for "' . $wpMeta['_wp_attached_file'] . '"" database entry (Wordpress ID: ' . $wpData['ID'] . ')', 'error');
                 continue;
             }
             // Check each filepath and see what year/month pattern matches the current Wordpress attachment
             $yearMonthFile = $fileResolver->extractYearAndMonth($wpMeta['_wp_attached_file']);
             if (!$yearMonthFile) {
                 throw new Exception('Doubled up basename and unable to determine year/month from _wp_attached_file postmeta.');
             }
             $chosenFilepath = null;
             foreach ($filepaths as $filepath) {
                 $checkYearMonthAgainst = $fileResolver->extractYearAndMonth($filepath);
                 if ($yearMonthFile === $checkYearMonthAgainst) {
                     $chosenFilepath = $filepath;
                 }
             }
             if ($chosenFilepath === null) {
                 $errorString = "\n    - " . implode("\n    - ", $filepaths);
                 $errorString = 'Unable to find EXACT matching file for "' . $wpMeta['_wp_attached_file'] . '"" database entry (Wordpress ID: ' . $wpData['ID'] . ') -- Possible paths were: ' . $errorString;
                 if (!$directorIsCLI) {
                     $errorString = nl2br($errorString);
                 }
                 $this->log($errorString, 'notice');
                 continue;
             }
             // $chosenFilepath = Full filename (ie. C:/wamp/www/MySSSite)
             $relativeFilepath = str_replace($basePath, '', $chosenFilepath);
             if ($relativeFilepath === $chosenFilepath) {
                 throw new Exception('Wordpress assets must be moved underneath your Silverstripe assets folder.');
             }
             // Convert from Windows backslash to *nix forwardslash
             $relativeFilepath = str_replace("\\", '/', $relativeFilepath);
             // Add S3 CDN path to the record
             $cdnFile = '';
             if (isset($wpMeta['amazonS3_info']) && isset($wpMeta['amazonS3_info']['key'])) {
                 $cdnFile = 'Cdn:||' . $wpMeta['amazonS3_info']['key'];
             }
             // Feed record data into the object directly
             $recordData = array('Title' => $wpData['post_title'], 'Created' => $wpData['post_date'], 'LastEdited' => $wpData['post_modified'], 'Content' => $wpData['post_content'], 'Description' => $wpData['post_content'], 'CDNFile' => $cdnFile);
             if ($fileResolver->isFileExtensionImage($relativeFilepath)) {
                 $record = Image::create($recordData);
             } else {
                 $record = File::create($recordData);
             }
             $record->Filename = $relativeFilepath;
             // Determine folder to save to
             $relativeDirectoryInsideAssets = str_replace(array($baseAssetPath, '\\'), array('', '/'), $chosenFilepath);
             $relativeDirectoryInsideAssets = dirname($relativeDirectoryInsideAssets);
             if (!isset($folderMap[$relativeDirectoryInsideAssets])) {
                 // Using this to speed-up the lookup on already found or made directories
                 $folderMap[$relativeDirectoryInsideAssets] = Folder::find_or_make($relativeDirectoryInsideAssets);
             }
             $folder = $folderMap[$relativeDirectoryInsideAssets];
             if (!$folder || !$folder->ID) {
                 throw new Exception('Unable to determine or create Folder at: ' . $relativeDirectoryInsideAssets);
             }
             $record->ParentID = $folder->ID;
             try {
                 $record->WordpressData = $wpData;
                 $record->write();
                 $this->log('Added "' . $record->Title . '" (' . $record->class . ') to #' . $record->ID, 'created');
             } catch (Exception $e) {
                 //Debug::dump($relativeFilepath);
                 //Debug::dump($e->getMessage()); exit;
                 $this->log('Failed to write #' . $record->ID . ' (' . $record->class . ', Wordpress ID: ' . $wpData['ID'] . ') -- ' . $e->getMessage(), 'error');
             }
         }
     }
//.........这里部分代码省略.........
开发者ID:silbinarywolf,项目名称:silverstripe-wordpressmigrationtools,代码行数:101,代码来源:WordpressImportService.php

示例9: Exception

    $frameworkDirSlashSuffix = FRAMEWORK_DIR ? FRAMEWORK_DIR . '/' : '';
} else {
    throw new Exception("Path error: FRAMEWORK_PATH " . FRAMEWORK_PATH . " not within BASE_PATH " . BASE_PATH);
}
define('FRAMEWORK_ADMIN_DIR', $frameworkDirSlashSuffix . 'admin');
define('FRAMEWORK_ADMIN_PATH', FRAMEWORK_PATH . '/admin');
define('THIRDPARTY_DIR', $frameworkDirSlashSuffix . 'thirdparty');
define('THIRDPARTY_PATH', FRAMEWORK_PATH . '/thirdparty');
define('ADMIN_THIRDPARTY_DIR', FRAMEWORK_ADMIN_DIR . '/thirdparty');
define('ADMIN_THIRDPARTY_PATH', BASE_PATH . '/' . ADMIN_THIRDPARTY_DIR);
if (!defined('ASSETS_DIR')) {
    define('ASSETS_DIR', 'assets');
}
if (!defined('ASSETS_PATH')) {
    define('ASSETS_PATH', BASE_PATH . '/' . ASSETS_DIR);
}
///////////////////////////////////////////////////////////////////////////////
// INCLUDES
if (defined('CUSTOM_INCLUDE_PATH')) {
    $includePath = '.' . PATH_SEPARATOR . CUSTOM_INCLUDE_PATH . PATH_SEPARATOR . FRAMEWORK_PATH . PATH_SEPARATOR . FRAMEWORK_PATH . '/parsers' . PATH_SEPARATOR . THIRDPARTY_PATH . PATH_SEPARATOR . get_include_path();
} else {
    $includePath = '.' . PATH_SEPARATOR . FRAMEWORK_PATH . PATH_SEPARATOR . FRAMEWORK_PATH . '/parsers' . PATH_SEPARATOR . THIRDPARTY_PATH . PATH_SEPARATOR . get_include_path();
}
set_include_path($includePath);
/**
 * Define the temporary folder if it wasn't defined yet
 */
require_once 'Core/TempPath.php';
if (!defined('TEMP_FOLDER')) {
    define('TEMP_FOLDER', getTempFolder(BASE_PATH));
}
开发者ID:Cheddam,项目名称:silverstripe-framework,代码行数:31,代码来源:Constants.php

示例10: getTempFolder

 * CustomHtmlForms is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with CustomHtmlForms.  If not, see <http://www.gnu.org/licenses/>.
 *
 * @package CustomHtmlForm
 * @subpackage Config
 * @ignore
 */
ContentController::add_extension('CustomHtmlFormPage_Controller');
Security::add_extension('CustomHtmlFormPage_Controller');
SiteConfig::add_extension('CustomHtmlFormConfiguration');
$cacheBaseDir = getTempFolder() . DIRECTORY_SEPARATOR . 'cache';
$cacheDir = $cacheBaseDir . DIRECTORY_SEPARATOR . 'CustomHtmlForm';
if (Director::isDev()) {
    $cachelifetime = 1;
} else {
    $cachelifetime = 86400;
}
if (!is_dir($cacheDir)) {
    if (!is_dir($cacheBaseDir)) {
        mkdir($cacheBaseDir);
    }
    mkdir($cacheDir);
}
if (class_exists('SilvercartCleanCacheTask')) {
    SilvercartCleanCacheTask::register_cache_directory($cacheDir);
}
开发者ID:silvercart,项目名称:customhtmlform,代码行数:31,代码来源:_config.php

示例11: render

 /**
  * Renders passed in content to a PDF.
  *
  * If $outputTo == '', then the temporary filename is returned, with the expectation
  * that the caller will correctly handle the streaming of the content.
  *
  * @param String $content
  * 			Raw content to render into a pdf
  * @param String $outputTo
  * 				'file' or 'browser'
  * @param String $outname
  * 				A filename if the pdf is sent direct to the browser
  * @return String
  * 				The filename of the output file
  */
 protected function render($content, $outputTo = null, $outname = '')
 {
     // Setup a temp folder for the pdfs
     $tempFolder = getTempFolder();
     if (!is_dir($tempFolder)) {
         throw new Exception("Temp directory could not be found " . var_export(getTempFolder(), true));
     }
     $pdfFolder = $tempFolder . '/' . self::$temp_folder_name;
     if (!file_exists($pdfFolder)) {
         @mkdir($pdfFolder, 0750);
     }
     if (!is_dir($pdfFolder)) {
         throw new Exception("PDF temp directory could not be found " . $pdfFolder);
     }
     // Change all the links and urls in the content to use absolute paths
     $content = $this->fixLinks($content);
     // Translate all the breaking spaces that tinymce litters everywhere
     $content = $this->fixEntities($content);
     // Create a temp pdf file ready for the pdf convertor output
     $pdfFile = tempnam($pdfFolder, "pdf_");
     // Start up the pdf generator and tell it where to write its output
     $pdfGenerator = new PDFGenerator($pdfFile);
     // Convert the content into pdf
     if (!$pdfGenerator->generatePDF($content)) {
         throw new Exception("PDF could not be created");
     }
     if (!file_exists($pdfFile)) {
         throw new Exception("Could not generate pdf " . $pdfFile);
     }
     // Return the pdf contents if the output type is anything but 'browser'
     if ($outputTo != 'browser') {
         return $pdfFile;
     }
     // Return the pdf to the browser as a file download
     if (file_exists($pdfFile)) {
         $filedata = array('path' => $pdfFile, 'name' => urlencode(htmlentities($outname)), 'mime' => "application/pdf");
         // TODO: use this instead
         //$this->send_file($filedata);
         $size = filesize($pdfFile);
         $type = "application/pdf";
         $name = urlencode(htmlentities($outname));
         if (!headers_sent()) {
             // set cache-control headers explicitly for https traffic, otherwise no-cache will be used,
             // which will break file attachments in IE
             // Thanks to Niklas Forsdahl <niklas@creamarketing.com>
             if (isset($_SERVER['HTTPS'])) {
                 header('Cache-Control: private');
                 header('Pragma: ');
             }
             header('Content-disposition: attachment; filename=' . $name);
             header('Content-type: application/pdf');
             //octet-stream');
             header('Content-Length: ' . $size);
             readfile($pdfFile);
         } else {
             echo "Invalid file";
         }
         // Delete the pdf temp file
         unlink($pdfFile);
     }
     return true;
 }
开发者ID:helpfulrobot,项目名称:mparkhill-silverstripe-tcpdf,代码行数:77,代码来源:PDFService.php

示例12: getCSVContent

 /**
  * Creates and returns the CSV content to download.
  * $exportContext can be:
  * 0 = all customers with a valid email address
  * 1 = all newsletter recipients
  * 2 = all newsletter recipients with customer account
  * 3 = all newsletter recipients without customer account
  * 4 = all non-newletter recipients with customer account
  * 
  * @param string $exportContext 0|1|2|3|4; Identifies the context to get recipients for
  * 
  * @return string
  */
 protected function getCSVContent($exportContext)
 {
     $membersSql = 'SELECT "M"."Email", "M"."Salutation", "M"."FirstName", "M"."Surname" FROM "Member" AS "M" WHERE "M"."Email" IS NOT NULL';
     $anonymousSql = 'SELECT "ANR"."Email", "ANR"."Salutation", "ANR"."FirstName", "ANR"."Surname" FROM "SilvercartAnonymousNewsletterRecipient" AS "ANR" WHERE "ANR"."Email" IS NOT NULL AND "ANR"."NewsletterOptInStatus" = 1';
     $membersSqlAddition = '';
     switch ($exportContext) {
         case '1':
             // All newletter recipients
             $useMembersSql = true;
             $useAnonymousSql = true;
             $membersSqlAddition = ' AND "M"."NewsletterOptInStatus" = 1';
             break;
         case '2':
             // All newletter recipients with customer account
             $useMembersSql = true;
             $useAnonymousSql = false;
             $membersSqlAddition = ' AND "M"."NewsletterOptInStatus" = 1';
             break;
         case '3':
             // All newletter recipients without customer account
             $useMembersSql = false;
             $useAnonymousSql = true;
             break;
         case '4':
             // All non-newletter recipients
             $useMembersSql = true;
             $useAnonymousSql = false;
             $membersSqlAddition = ' AND "M"."NewsletterOptInStatus" = 0';
             break;
         case '0':
         default:
             // All customers with a valid email address
             $useMembersSql = true;
             $useAnonymousSql = true;
             break;
     }
     $tempFolder = getTempFolder();
     $tempCsvFile = $tempFolder . '/do_newsletter_recipients_export.csv';
     $csvFile = fopen($tempCsvFile, 'w');
     fputcsv($csvFile, array('email', 'salutation', 'firstname', 'surname'));
     if ($useMembersSql) {
         $records = DB::query($membersSql . $membersSqlAddition);
         if ($records->numRecords() > 0) {
             foreach ($records as $record) {
                 $record['Salutation'] = SilvercartTools::getSalutationText($record['Salutation']);
                 fputcsv($csvFile, $record);
             }
         }
     }
     if ($useAnonymousSql) {
         $records = DB::query($anonymousSql);
         if ($records->numRecords() > 0) {
             foreach ($records as $record) {
                 $record['Salutation'] = SilvercartTools::getSalutationText($record['Salutation']);
                 fputcsv($csvFile, $record);
             }
         }
     }
     fclose($csvFile);
     $csvFileContent = file_get_contents($tempCsvFile);
     unlink($tempCsvFile);
     return $csvFileContent;
 }
开发者ID:silvercart,项目名称:silvercart,代码行数:76,代码来源:SilvercartNewsletterRecipientsAdmin.php

示例13: define

     $_SERVER['REQUEST_METHOD'] = "";
 }
 define('BASE_PATH', getcwd());
 global $databaseConfig;
 $_SESSION = null;
 state("Including SilverStripe core...");
 if (file_exists("sapphire/core/Core.php")) {
     $framework_dir = "sapphire";
 } elseif (file_exists("framework/core/Core.php")) {
     $framework_dir = "framework";
 } else {
     fail("Could not find framework directory!");
 }
 require_once $framework_dir . "/core/TempPath.php";
 if (isset($PARAMS['flush'])) {
     exec("rm -rf " . getTempFolder(BASE_PATH));
 }
 require_once $framework_dir . "/core/Core.php";
 require_once $framework_dir . "/model/DB.php";
 say("done.");
 state("Connecting to database...");
 if ($databaseConfig['type'] == "MySQLDatabase") {
     $conn = @new MySQLi($databaseConfig['server'], $databaseConfig['username'], $databaseConfig['password']);
     if ($conn->connect_error) {
         $err = $conn->connect_error;
         say("\nCould not connect to MySQL Database.", "on_red", "white");
         say("This is often due to an issue with MAMP.");
         say("You can run 'silversmith fix-mamp' resolve this issue.");
         $answer = ask("Press any key to show the error output...");
         say("Connection error: {$conn->connect_error}");
     }
开发者ID:Tangdongle,项目名称:SilverSmith,代码行数:31,代码来源:silversmith.php

示例14: getPidFilePath

 /**
  * Get the absolute path to the pidfile
  *
  * @return string
  */
 protected function getPidFilePath()
 {
     return getTempFolder() . DIRECTORY_SEPARATOR . 'pid.' . strtolower(__CLASS__) . '.txt';
 }
开发者ID:spark-green,项目名称:silverstripe-staticpublishqueue,代码行数:9,代码来源:BuildStaticCacheFromQueue.php

示例15: getHtmlPurifierService

 /**
  * @return HTMLPurifier (or anything with a "purify()" method)
  */
 public function getHtmlPurifierService()
 {
     $config = HTMLPurifier_Config::createDefault();
     $allowedElements = $this->getOption('html_allowed_elements');
     $config->set('HTML.AllowedElements', $allowedElements);
     // This injector cannot be set unless the 'p' element is allowed
     if (in_array('p', $allowedElements)) {
         $config->set('AutoFormat.AutoParagraph', true);
     }
     $config->set('AutoFormat.Linkify', true);
     $config->set('URI.DisableExternalResources', true);
     $config->set('Cache.SerializerPath', getTempFolder());
     return new HTMLPurifier($config);
 }
开发者ID:krissihall,项目名称:sm_ss,代码行数:17,代码来源:Comment.php


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