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


PHP Filesystem::mkdir方法代码示例

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


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

示例1: createFolderWithinPluginIfNotExists

 private function createFolderWithinPluginIfNotExists($pluginName, $folder)
 {
     $pluginPath = $this->getPluginPath($pluginName);
     if (!file_exists($pluginName . $folder)) {
         Filesystem::mkdir($pluginPath . $folder, true);
     }
 }
开发者ID:KiwiJuicer,项目名称:handball-dachau,代码行数:7,代码来源:GeneratePluginBase.php

示例2: __construct

 public function __construct($outputId)
 {
     if (!Filesystem::isValidFilename($outputId)) {
         throw new \Exception('The given output id has an invalid format');
     }
     $dir = CliMulti::getTmpPath();
     Filesystem::mkdir($dir);
     $this->tmpFile = $dir . '/' . $outputId . '.output';
 }
开发者ID:carriercomm,项目名称:piwik,代码行数:9,代码来源:Output.php

示例3: createFolderWithinPluginIfNotExists

 private function createFolderWithinPluginIfNotExists($pluginNameOrCore, $folder)
 {
     if ($pluginNameOrCore === 'core') {
         $pluginPath = $this->getPathToCore();
     } else {
         $pluginPath = $this->getPluginPath($pluginNameOrCore);
     }
     if (!file_exists($pluginPath . $folder)) {
         Filesystem::mkdir($pluginPath . $folder);
     }
 }
开发者ID:dorelljames,项目名称:piwik,代码行数:11,代码来源:GeneratePluginBase.php

示例4: __construct

 public function __construct($pid)
 {
     if (!Filesystem::isValidFilename($pid)) {
         throw new \Exception('The given pid has an invalid format');
     }
     $pidDir = CliMulti::getTmpPath();
     Filesystem::mkdir($pidDir);
     $this->isSupported = self::isSupported();
     $this->pidFile = $pidDir . '/' . $pid . '.pid';
     $this->timeCreation = time();
     $this->markAsNotStarted();
 }
开发者ID:brienomatty,项目名称:elmsln,代码行数:12,代码来源:Process.php

示例5: isCustomLogoWritable

 /**
  * @return bool
  */
 public function isCustomLogoWritable()
 {
     $pathUserLogo = $this->getPathUserLogo();
     $directoryWritingTo = PIWIK_DOCUMENT_ROOT . '/' . dirname($pathUserLogo);
     // Create directory if not already created
     Filesystem::mkdir($directoryWritingTo, $denyAccess = false);
     $directoryWritable = is_writable($directoryWritingTo);
     $logoFilesWriteable = is_writeable(PIWIK_DOCUMENT_ROOT . '/' . $pathUserLogo) && is_writeable(PIWIK_DOCUMENT_ROOT . '/' . $this->getPathUserSvgLogo()) && is_writeable(PIWIK_DOCUMENT_ROOT . '/' . $this->getPathUserLogoSmall());
     $serverUploadEnabled = ini_get('file_uploads') == 1;
     $isCustomLogoWritable = ($logoFilesWriteable || $directoryWritable) && $serverUploadEnabled;
     return $isCustomLogoWritable;
 }
开发者ID:KiwiJuicer,项目名称:handball-dachau,代码行数:15,代码来源:CustomLogo.php

示例6: sendHttpRequest

 /**
  * Sends an HTTP request using best available transport method.
  *
  * @param string $aUrl The target URL.
  * @param int $timeout The number of seconds to wait before aborting the HTTP request.
  * @param string|null $userAgent The user agent to use.
  * @param string|null $destinationPath If supplied, the HTTP response will be saved to the file specified by
  *                                     this path.
  * @param int|null $followDepth Internal redirect count. Should always pass `null` for this parameter.
  * @param bool $acceptLanguage The value to use for the `'Accept-Language'` HTTP request header.
  * @param array|bool $byteRange For `Range:` header. Should be two element array of bytes, eg, `array(0, 1024)`
  *                              Doesn't work w/ `fopen` transport method.
  * @param bool $getExtendedInfo If true returns the status code, headers & response, if false just the response.
  * @param string $httpMethod The HTTP method to use. Defaults to `'GET'`.
  * @throws Exception if the response cannot be saved to `$destinationPath`, if the HTTP response cannot be sent,
  *                   if there are more than 5 redirects or if the request times out.
  * @return bool|string If `$destinationPath` is not specified the HTTP response is returned on success. `false`
  *                     is returned on failure.
  *                     If `$getExtendedInfo` is `true` and `$destinationPath` is not specified an array with
  *                     the following information is returned on success:
  *
  *                     - **status**: the HTTP status code
  *                     - **headers**: the HTTP headers
  *                     - **data**: the HTTP response data
  *
  *                     `false` is still returned on failure.
  * @api
  */
 public static function sendHttpRequest($aUrl, $timeout, $userAgent = null, $destinationPath = null, $followDepth = 0, $acceptLanguage = false, $byteRange = false, $getExtendedInfo = false, $httpMethod = 'GET')
 {
     // create output file
     $file = null;
     if ($destinationPath) {
         // Ensure destination directory exists
         Filesystem::mkdir(dirname($destinationPath));
         if (($file = @fopen($destinationPath, 'wb')) === false || !is_resource($file)) {
             throw new Exception('Error while creating the file: ' . $destinationPath);
         }
     }
     $acceptLanguage = $acceptLanguage ? 'Accept-Language: ' . $acceptLanguage : '';
     return self::sendHttpRequestBy(self::getTransportMethod(), $aUrl, $timeout, $userAgent, $destinationPath, $file, $followDepth, $acceptLanguage, $acceptInvalidSslCertificate = false, $byteRange, $getExtendedInfo, $httpMethod);
 }
开发者ID:josl,项目名称:CGE-File-Sharing,代码行数:42,代码来源:Http.php

示例7: isCustomLogoWritable

 /**
  * @return bool
  */
 public function isCustomLogoWritable()
 {
     if (Config::getInstance()->General['enable_custom_logo_check'] == 0) {
         return true;
     }
     $pathUserLogo = $this->getPathUserLogo();
     $directoryWritingTo = PIWIK_DOCUMENT_ROOT . '/' . dirname($pathUserLogo);
     // Create directory if not already created
     Filesystem::mkdir($directoryWritingTo);
     $directoryWritable = is_writable($directoryWritingTo);
     $logoFilesWriteable = is_writeable(PIWIK_DOCUMENT_ROOT . '/' . $pathUserLogo) && is_writeable(PIWIK_DOCUMENT_ROOT . '/' . $this->getPathUserSvgLogo()) && is_writeable(PIWIK_DOCUMENT_ROOT . '/' . $this->getPathUserLogoSmall());
     $isCustomLogoWritable = ($logoFilesWriteable || $directoryWritable) && $this->isFileUploadEnabled();
     return $isCustomLogoWritable;
 }
开发者ID:P3PO,项目名称:piwik,代码行数:17,代码来源:CustomLogo.php

示例8: checkDirectoriesWritable

 /**
  * Checks if directories are writable and create them if they do not exist.
  *
  * @param array $directoriesToCheck array of directories to check - if not given default Piwik directories that needs write permission are checked
  * @return array  directory name => true|false (is writable)
  */
 public static function checkDirectoriesWritable($directoriesToCheck)
 {
     $resultCheck = array();
     foreach ($directoriesToCheck as $directoryToCheck) {
         if (!preg_match('/^' . preg_quote(PIWIK_USER_PATH, '/') . '/', $directoryToCheck)) {
             $directoryToCheck = PIWIK_USER_PATH . $directoryToCheck;
         }
         Filesystem::mkdir($directoryToCheck);
         $directory = Filesystem::realpath($directoryToCheck);
         if ($directory !== false) {
             $resultCheck[$directory] = is_writable($directoryToCheck);
         }
     }
     return $resultCheck;
 }
开发者ID:piwikjapan,项目名称:piwik,代码行数:21,代码来源:Filechecks.php

示例9: getAssetDirectory

 /**
  * Check if the merged file directory exists and is writable.
  *
  * @return string The directory location
  * @throws Exception if directory is not writable.
  */
 public function getAssetDirectory()
 {
     $mergedFileDirectory = StaticContainer::get('path.tmp') . '/assets';
     if (!is_dir($mergedFileDirectory)) {
         Filesystem::mkdir($mergedFileDirectory);
     }
     if (!is_writable($mergedFileDirectory)) {
         throw new Exception("Directory " . $mergedFileDirectory . " has to be writable.");
     }
     return $mergedFileDirectory;
 }
开发者ID:diosmosis,项目名称:piwik,代码行数:17,代码来源:AssetManager.php

示例10: set

 /**
  * A function to store content a cache entry.
  *
  * @param string $id The cache entry ID
  * @param array $content The cache content
  * @throws \Exception
  * @return bool  True if the entry was succesfully stored
  */
 public function set($id, $content)
 {
     if (empty($id)) {
         return false;
     }
     if (!is_dir($this->cachePath)) {
         Filesystem::mkdir($this->cachePath);
     }
     if (!is_writable($this->cachePath)) {
         return false;
     }
     $id = $this->cleanupId($id);
     $id = $this->cachePath . $id . '.php';
     if (is_object($content)) {
         throw new \Exception('You cannot use the CacheFile to cache an object, only arrays, strings and numbers.');
     }
     $cache_literal = "<" . "?php\n";
     $cache_literal .= "\$" . "content   = " . var_export($content, true) . ";\n";
     $cache_literal .= "\$" . "expires_on   = " . $this->getExpiresTime() . ";\n";
     $cache_literal .= "\$" . "cache_complete   = true;\n";
     $cache_literal .= "?" . ">";
     // Write cache to a temp file, then rename it, overwriting the old cache
     // On *nix systems this should guarantee atomicity
     $tmp_filename = tempnam($this->cachePath, 'tmp_');
     @chmod($tmp_filename, 0640);
     if ($fp = @fopen($tmp_filename, 'wb')) {
         @fwrite($fp, $cache_literal, strlen($cache_literal));
         @fclose($fp);
         if (!@rename($tmp_filename, $id)) {
             // On some systems rename() doesn't overwrite destination
             @unlink($id);
             if (!@rename($tmp_filename, $id)) {
                 // Make sure that no temporary file is left over
                 // if the destination is not writable
                 @unlink($tmp_filename);
             }
         }
         $this->opCacheInvalidate($id);
         return true;
     }
     return false;
 }
开发者ID:KiwiJuicer,项目名称:handball-dachau,代码行数:50,代码来源:CacheFile.php

示例11: generatePluginFolder

 protected function generatePluginFolder($pluginName)
 {
     $pluginPath = $this->getPluginPath($pluginName);
     Filesystem::mkdir($pluginPath);
 }
开发者ID:piwik,项目名称:piwik,代码行数:5,代码来源:GeneratePlugin.php

示例12: saveTemporary

 /**
  * Save translations to  temporary file; translations should already be cleansed.
  *
  * @throws \Exception
  * @return bool|int False if failure, or number of bytes written
  */
 public function saveTemporary()
 {
     $this->applyFilters();
     if (!$this->hasTranslations() || !$this->isValid()) {
         throw new Exception('unable to save empty or invalid translations');
     }
     $path = $this->getTemporaryTranslationPath();
     Filesystem::mkdir(dirname($path));
     return file_put_contents($path, $this->__toString());
 }
开发者ID:josl,项目名称:CGE-File-Sharing,代码行数:16,代码来源:Writer.php

示例13: createEmptyTarget

 private function createEmptyTarget()
 {
     Filesystem::mkdir($this->testPath . '/target');
     return $this->testPath . '/target';
 }
开发者ID:dorelljames,项目名称:piwik,代码行数:5,代码来源:FilesystemTest.php

示例14: start

 /**
  * Start the session
  *
  * @param array|bool $options An array of configuration options; the auto-start (bool) setting is ignored
  * @return void
  * @throws Exception if starting a session fails
  */
 public static function start($options = false)
 {
     if (headers_sent() || self::$sessionStarted || defined('PIWIK_ENABLE_SESSION_START') && !PIWIK_ENABLE_SESSION_START) {
         return;
     }
     self::$sessionStarted = true;
     // use cookies to store session id on the client side
     @ini_set('session.use_cookies', '1');
     // prevent attacks involving session ids passed in URLs
     @ini_set('session.use_only_cookies', '1');
     // advise browser that session cookie should only be sent over secure connection
     if (ProxyHttp::isHttps()) {
         @ini_set('session.cookie_secure', '1');
     }
     // advise browser that session cookie should only be accessible through the HTTP protocol (i.e., not JavaScript)
     @ini_set('session.cookie_httponly', '1');
     // don't use the default: PHPSESSID
     @ini_set('session.name', self::SESSION_NAME);
     // proxies may cause the referer check to fail and
     // incorrectly invalidate the session
     @ini_set('session.referer_check', '');
     $currentSaveHandler = ini_get('session.save_handler');
     $config = Config::getInstance();
     if (self::isFileBasedSessions()) {
         // Note: this handler doesn't work well in load-balanced environments and may have a concurrency issue with locked session files
         // for "files", use our own folder to prevent local session file hijacking
         $sessionPath = self::getSessionsDirectory();
         // We always call mkdir since it also chmods the directory which might help when permissions were reverted for some reasons
         Filesystem::mkdir($sessionPath);
         @ini_set('session.save_handler', 'files');
         @ini_set('session.save_path', $sessionPath);
     } elseif ($config->General['session_save_handler'] === 'dbtable' || in_array($currentSaveHandler, array('user', 'mm'))) {
         // We consider these to be misconfigurations, in that:
         // - user  - we can't verify that user-defined session handler functions have already been set via session_set_save_handler()
         // - mm    - this handler is not recommended, unsupported, not available for Windows, and has a potential concurrency issue
         $config = array('name' => Common::prefixTable('session'), 'primary' => 'id', 'modifiedColumn' => 'modified', 'dataColumn' => 'data', 'lifetimeColumn' => 'lifetime');
         $saveHandler = new DbTable($config);
         if ($saveHandler) {
             self::setSaveHandler($saveHandler);
         }
     }
     // garbage collection may disabled by default (e.g., Debian)
     if (ini_get('session.gc_probability') == 0) {
         @ini_set('session.gc_probability', 1);
     }
     try {
         parent::start();
         register_shutdown_function(array('Zend_Session', 'writeClose'), true);
     } catch (Exception $e) {
         Log::error('Unable to start session: ' . $e->getMessage());
         $enableDbSessions = '';
         if (DbHelper::isInstalled()) {
             $enableDbSessions = "<br/>If you still experience issues after trying these changes,\n\t\t\t            \t\t\twe recommend that you <a href='http://piwik.org/faq/how-to-install/#faq_133' rel='noreferrer' target='_blank'>enable database session storage</a>.";
         }
         $pathToSessions = Filechecks::getErrorMessageMissingPermissions(self::getSessionsDirectory());
         $message = sprintf("Error: %s %s %s\n<pre>Debug: the original error was \n%s</pre>", Piwik::translate('General_ExceptionUnableToStartSession'), $pathToSessions, $enableDbSessions, $e->getMessage());
         $ex = new MissingFilePermissionException($message, $e->getCode(), $e);
         $ex->setIsHtmlMessage();
         throw $ex;
     }
 }
开发者ID:FluentDevelopment,项目名称:piwik,代码行数:68,代码来源:Session.php

示例15: getAssetDirectory

 /**
  * Check if the merged file directory exists and is writable.
  *
  * @return string The directory location
  * @throws Exception if directory is not writable.
  */
 public function getAssetDirectory()
 {
     $mergedFileDirectory = PIWIK_USER_PATH . "/tmp/assets";
     $mergedFileDirectory = SettingsPiwik::rewriteTmpPathWithInstanceId($mergedFileDirectory);
     if (!is_dir($mergedFileDirectory)) {
         Filesystem::mkdir($mergedFileDirectory);
     }
     if (!is_writable($mergedFileDirectory)) {
         throw new Exception("Directory " . $mergedFileDirectory . " has to be writable.");
     }
     return $mergedFileDirectory;
 }
开发者ID:carriercomm,项目名称:piwik,代码行数:18,代码来源:AssetManager.php


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