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


PHP File::isReadable方法代码示例

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


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

示例1: getVersion

 /**
  * Returns the current version of pLog, determined by the value of the $version
  * variable in the version.php file.
  * If the file is not available, the result is unknown.
  * @static
  * @return The version identifier.
  */
 function getVersion()
 {
     $versionFile = PLOG_CLASS_PATH . "version.php";
     if (File::isReadable($versionFile)) {
         include_once $versionFile;
     } else {
         $version = "UNKNOWN";
     }
     return $version;
 }
开发者ID:BackupTheBerlios,项目名称:plogfr-svn,代码行数:17,代码来源:version.class.php

示例2: validate

 function validate($data)
 {
     // check the rules created in the constructor
     if (!parent::validate($data)) {
         return false;
     }
     // and if they succeeded, check if the file exists. If not, return false
     // and go to the main page...
     $filePath = "templates/summary/{$data}.template";
     return File::isReadable($filePath);
 }
开发者ID:BackupTheBerlios,项目名称:plogfr-svn,代码行数:11,代码来源:customsummarypagevalidator.class.php

示例3: LoggerConfigLoader

 function LoggerConfigLoader($defaultFilePath = LOGGER_DEFAULT_CONFIG_FILE_PATH)
 {
     // load the config file if it is readable
     if (File::isReadable($defaultFilePath)) {
         include_once $defaultFilePath;
         $this->_keys = $config;
     } else {
         throw new Exception("There was an error loading logger config file: {$defaultFilePath}");
         die;
     }
 }
开发者ID:BackupTheBerlios,项目名称:plogfr-svn,代码行数:11,代码来源:loggerconfigloader.class.php

示例4: __construct

 /**
  * Construct the iterator with a file instance
  * @param File $file Instance of a file object.
  * @throws \InvalidArgumentException
  */
 public function __construct(File $file)
 {
     if (!$file->exists()) {
         throw new \InvalidArgumentException('The file "' . $file->getPath() . '" does not exist');
     }
     if (!$file->isReadable()) {
         throw new \InvalidArgumentException('The file "' . $file->getPath() . '" is not readable.');
     }
     $this->file = $file;
     $this->file->open('r');
 }
开发者ID:paulgessinger,项目名称:common,代码行数:16,代码来源:FileIterator.php

示例5: reload

 /**
  * Reloads the contents from the configuration file.
  *
  * @return Returns true if successul or false otherwise
  */
 function reload()
 {
     if (File::isReadable($this->_configFile)) {
         include $this->_configFile;
         $this->_props = new Properties($config);
         $result = true;
     } else {
         $this->_props = new Properties();
         $result = false;
     }
     return $result;
 }
开发者ID:BackupTheBerlios,项目名称:plogfr-svn,代码行数:17,代码来源:configfilestorage.class.php

示例6: _loadLocaleFile

 /**
  * Loads a plugin locale file from disk
  *
  * @private
  */
 function _loadLocaleFile()
 {
     $fileName = PLOG_CLASS_PATH . "plugins/" . $this->_pluginId . "/locale/locale_" . $this->_code . ".php";
     if (File::isReadable($fileName)) {
         include $fileName;
     }
     // The following is just to handle the case where a plugin doesn't
     // have a valid local file.
     if (!isset($messages) || !is_array($messages)) {
         $messages = array();
     }
     $this->_messages = $messages;
 }
开发者ID:BackupTheBerlios,项目名称:plogfr-svn,代码行数:18,代码来源:pluginlocale.class.php

示例7: validate

 /**
  * Returns true if the template is a valid template set
  */
 function validate()
 {
     // first of all, check that the folder exists
     if (!File::isDir($this->_fullName)) {
         return ERROR_TEMPLATE_NOT_INSIDE_FOLDER;
     }
     // now check that all the basic files are available
     foreach ($this->_basicFiles as $basicFile) {
         if (!File::isReadable($this->_fullName . $basicFile)) {
             return ERROR_MISSING_BASE_FILES;
         }
     }
     return true;
 }
开发者ID:BackupTheBerlios,项目名称:plogfr-svn,代码行数:17,代码来源:templatevalidator.class.php

示例8: findBinary

 function findBinary($binary, $searchFolders)
 {
     if ($searchFolders == null) {
         $searchFolders = array($this->_folder);
     }
     $found = false;
     $i = 0;
     while (!$found && $i < count($searchFolders)) {
         // get the current folder
         $currentFolder = $searchFolders[$i];
         // see if the file's there
         $fullPath = $currentFolder . $binary;
         if (File::isReadable($fullPath)) {
             $found = true;
         } else {
             $i++;
         }
     }
     if ($found) {
         return $fullPath;
     } else {
         return "";
     }
 }
开发者ID:BackupTheBerlios,项目名称:plogfr-svn,代码行数:24,代码来源:filefinder.class.php

示例9: setSessionSavePath

 /**
  * Sets the folder where sessions should be saved, in case we'd like to save
  * them somewhere else. This class will check the config parameter <b>session_save_path</b>: if
  * it's not empty, it will use its value as the name of the folder where sessions should be saved, and it
  * will also take care of creating the folder if it does not exist. If the folder exists but it cannot
  * be read, it will throw an exception and quit (because this is a big issue)
  * If the value of this parameter is empty, it will not do anything and use PHP's default settings for this.
  *
  * @static
  */
 function setSessionSavePath()
 {
     $config =& Config::getConfig();
     $sessionFolder = $config->getValue("session_save_path");
     // do we need to do anything if we are using the default
     // session path?  PHP defaults to /tmp/, so there isn't
     // anything to do
     if (isset($sessionFolder)) {
         if (!File::exists($sessionFolder)) {
             // create folder with only user permissions
             // since we want to protect the session data
             if (!File::createDir($sessionFolder, 0700)) {
                 throw new Exception("Sessions should be " . "saved in {$sessionFolder} but it " . "doesn't exist and I can't create it!");
                 die;
             }
         }
         // check if the folder is accessible
         if (!File::isReadable($sessionFolder) || !File::isWritable($sessionFolder)) {
             if (!File::chMod($sessionFolder, 0700)) {
                 throw new Exception("Sessions should be " . "saved in {$sessionFolder} but it is " . "not accessible!");
                 die;
             }
         }
         // if everything ok, we can continue...
         session_save_path($sessionFolder);
     }
     return true;
 }
开发者ID:BackupTheBerlios,项目名称:plogfr-svn,代码行数:38,代码来源:sessionmanager.class.php

示例10: checkTemplateSet

 /**
  * Makes sure that the file is a valid template set. The file can be packed
  * in any of the formats supported by the Unpacker class (.tar.gz, .tar.bz2
  * and .zip as of the time of writing these lines)
  * Returns true if the template is valid or a negative value carrying an
  * error code.
  *
  * @param file The file that contains the template set
  * @return Returns true (positive value) if template set is ok or a negative
  * value otherwise.
  */
 function checkTemplateSet($file, $filePath)
 {
     // get the temporary folder
     $config =& Config::getConfig();
     $tmpFolder = $config->getValue('temp_folder');
     if ($tmpFolder[strlen($tmpFolder) - 1] != '/') {
         $tmpFolder .= '/';
     }
     // get the name of the file, which we will use in many places
     $fileNameParts = explode('.', $file);
     $fileNameNoExt = $fileNameParts[0];
     // create our working folder
     $workFolder = $tmpFolder . File::getTempName() . '/';
     if (!File::createDir($workFolder, 0777)) {
         return TEMPLATE_SANDBOX_ERROR_CREATING_WORKING_FOLDER;
     }
     // now we can unpack the file to the temporary folder
     $unpacker = new Unpacker();
     if (!$unpacker->unpack($filePath . $file, $workFolder)) {
         $this->cleanUp($workFolder . $fileNameNoExt);
         if (File::exists($workFolder)) {
             File::delete($workFolder);
         }
         return TEMPLATE_SANDBOX_ERROR_UNPACKING;
     }
     // if the file was correctly unpacked, now we will need the TemplateValidator
     // class to do some work for us
     $fileNameParts = explode('.', $file);
     $fileNameNoExt = $fileNameParts[0];
     // we can use the checkTenmplateFolder which will do all the rest of
     // the work for us...
     $res = $this->checkTemplateFolder($fileNameNoExt, $workFolder);
     if ($res < 0) {
         //$this->cleanUp( $workFolder.$fileNameNoExt );
         $this->cleanUp($workFolder);
         if (File::isReadable($workFolder) && File::isDir($workFolder)) {
             File::delete($workFolder);
         }
         return $res;
     }
     $this->cleanUp($workFolder . $fileNameNoExt);
     File::delete($workFolder);
     return true;
 }
开发者ID:BackupTheBerlios,项目名称:plogfr-svn,代码行数:55,代码来源:templatesandbox.class.php

示例11: createAppenderInstance

 /**
  * dynamically loads a layout formatter
  *
  * @param appenderName
  * @return a qLayout class
  */
 function createAppenderInstance($appender, $layout, $properties)
 {
     $appenderClassName = $appender . "appender";
     $appenderClassFile = PLOG_CLASS_PATH . "class/logger/appender/" . $appenderClassName . ".class.php";
     // load the class but first check if it exists...
     if (!File::isReadable($appenderClassFile)) {
         throw new Exception("Cannot find an appender suitable for appender type '{$appender}'");
         die;
     }
     // if so, load the class and create an object
     include_once $appenderClassFile;
     $appender = new $appenderClassName($layout, $properties);
     return $appender;
 }
开发者ID:BackupTheBerlios,项目名称:plogfr-svn,代码行数:20,代码来源:loggermanager.class.php

示例12: load

 /**
  * Loads classes from disk using the list of folders that has been provided 
  * via ResourceClassLoader::addSearchFolder() The class will go through all the folders where 
  * classes can be located and if it can be found, it will proceed to load it. 
  * If not, an exception will be thrown
  * 
  * @param actionClassName name of the class that we are going to load, <b>without the class suffix</b>
  * @return True if successful
  */
 function load($actionClassName)
 {
     //foreach( $this->_paths as $path ) {
     $i = 0;
     $loaded = false;
     while ($i < count($this->_paths) && !$loaded) {
         // get the current folder
         $path = $this->_paths[$i];
         // build up the file name
         $fileName = $path . strtolower($actionClassName) . $this->_classFileSuffix;
         // and see if it exists and can be loaded
         if (File::exists($fileName) && File::isReadable($fileName)) {
             include_once $fileName;
             $loaded = true;
         }
         // increase the counter
         $i++;
     }
     // did we load anything??
     if (!$loaded) {
         throw new Exception("Could not load {$actionClassName}!");
         die;
     }
     // otherwise return everything ok!
     return true;
 }
开发者ID:BackupTheBerlios,项目名称:plogfr-svn,代码行数:35,代码来源:resourceclassloader.class.php

示例13: isScreenshotAvailable

 /**
  * returns true if the template set has a screenshot available in disk
  *
  * @param templateName The name of the template
  * @param blogId If the template is blog specific, then the blog id and if it is global, then
  * '0' or no parameeter
  */
 function isScreenshotAvailable($templateName, $blogId = 0)
 {
     // build up the path to the screenshot file
     $templatePath = $this->getTemplateFolder($templateName, $blogId);
     // and return whether it is available or not
     $screenshotPath = $templatePath . "/screenshot.jpg";
     return File::isReadable($screenshotPath);
 }
开发者ID:BackupTheBerlios,项目名称:plogfr-svn,代码行数:15,代码来源:templatesetstorage.class.php

示例14: _getData

 /**
  * returns an stream of data with the contents of the file. This method is used by 
  * getData(), getPreviewData and getMediumSizePreviewData()
  *
  * @return The contents of the given file or nothing if empty or if it can't be read
  * @private
  */
 function _getData($file)
 {
     if (File::isReadable($file)) {
         $file = new File($file);
         $file->open("rb");
         $size = $file->getSize();
         return $file->read($size);
     } else {
         return false;
     }
 }
开发者ID:BackupTheBerlios,项目名称:plogfr-svn,代码行数:18,代码来源:galleryresource.class.php

示例15: addResourceFromDisk

 /**
  * adds a resource to the gallery when the resource is already stored on disk, instead of
  * it coming from an upload as it usually happens. This method is better than 
  * GalleryResources::addResource() when instead of dealing with uploaded files, the file
  * is already in disk and all that is left to do is to add it to the database.
  *
  * @param ownerId
  * @param albumId
  * @param description
  * @param fullFilePath The real path where the file is stored. This is expected to be
  * its final and permanent destination
  * @return It will return one of the following constants:
  * - GALLERY_ERROR_RESOURCE_TOO_BIG
  * - GALLERY_ERROR_RESOURCE_FORBIDDEN_EXTENSION
  * - GALLERY_ERROR_QUOTA_EXCEEDED
  * - GALLERY_ERROR_ADDING_RESOURCE
  * - GALLERY_ERROR_UPLOADS_NOT_ENABLED
  * or the identifier of the resource that was just added if the operation succeeded.
  */
 function addResourceFromDisk($ownerId, $albumId, $description, $fullFilePath)
 {
     // check if quotas are enabled, and if this file would make us go
     // over the quota
     if (GalleryResourceQuotas::isBlogOverResourceQuota($ownerId, File::getSize($fullFilePath))) {
         return GALLERY_ERROR_QUOTA_EXCEEDED;
     }
     $fileName = basename($fullFilePath);
     $filePath = dirname($fullFilePath);
     // get the metadata
     $getId3 = new GetID3();
     $metadata = $getId3->analyze($fullFilePath);
     // nifty helper method from the getid3 package
     getid3_lib::CopyTagsToComments($metadata);
     $resourceType = $this->_getResourceType($fullFilePath, $metadata);
     $info = $this->_filterMetadata($metadata, $resourceType);
     // set the flags
     $flags = 0;
     if ($resourceType == GALLERY_RESOURCE_IMAGE) {
         $flags = $flags | GALLERY_RESOURCE_PREVIEW_AVAILABLE;
     }
     // add the record to the database
     $resourceId = $this->addResourceToDatabase($ownerId, $albumId, $description, $flags, $resourceType, $filePath, $fileName, $metadata);
     if (!$resourceId) {
         return false;
     }
     // and finally move the file to the right place in disk
     // move the file to disk
     $storage = new GalleryResourceStorage();
     $resFile = $storage->storeFile($resourceId, $ownerId, $fullFilePath, RESOURCE_STORAGE_STORE_MOVE);
     // if the file cannot be read, we will also remove the record from the
     // database so that we don't screw up
     $fileReadable = File::isReadable($resFile);
     if (!$resFile || $resFile < 0 || !$fileReadable) {
         // if something went wrong, we should not keep the record in the db
         $query = "DELETE FROM " . $this->getPrefix() . "gallery_resources\n                          WHERE id = {$resourceId}";
         $this->Execute($query);
         return $resFile;
     }
     // and finally, we can generate the thumbnail only if the file is an image, of course :)
     if ($resourceType == GALLERY_RESOURCE_IMAGE) {
         $this->generateResourceThumbnail($resFile, $resourceId, $ownerId);
     }
     // return the id of the resource we just added
     return $resourceId;
 }
开发者ID:BackupTheBerlios,项目名称:plogfr-svn,代码行数:65,代码来源:galleryresources.class.php


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