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


PHP is_readable函数代码示例

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


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

示例1: getRandomBytes

 private function getRandomBytes($count)
 {
     $bytes = '';
     if (function_exists('openssl_random_pseudo_bytes') && strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN') {
         // OpenSSL slow on Win
         $bytes = openssl_random_pseudo_bytes($count);
     }
     if ($bytes === '' && @is_readable('/dev/urandom') && ($hRand = @fopen('/dev/urandom', 'rb')) !== FALSE) {
         $bytes = fread($hRand, $count);
         fclose($hRand);
     }
     if (strlen($bytes) < $count) {
         $bytes = '';
         if ($this->randomState === null) {
             $this->randomState = microtime();
             if (function_exists('getmypid')) {
                 $this->randomState .= getmypid();
             }
         }
         for ($i = 0; $i < $count; $i += 16) {
             $this->randomState = md5(microtime() . $this->randomState);
             if (PHP_VERSION >= '5') {
                 $bytes .= md5($this->randomState, true);
             } else {
                 $bytes .= pack('H*', md5($this->randomState));
             }
         }
         $bytes = substr($bytes, 0, $count);
     }
     return $bytes;
 }
开发者ID:vkaran101,项目名称:sase,代码行数:31,代码来源:Bcrypt.php

示例2: __invoke

 public function __invoke($ctx)
 {
     if (isset($ctx['Directory']['path'])) {
         $path = $ctx['Directory']['path'];
     } else {
         $url = $ctx['env']['PATH_INFO'];
         if (strpos($url, '..') !== false) {
             return array(403, array('Content-Type', 'text/plain'), 'Forbidden');
         }
         $path = $this->path . $url;
     }
     // Sanity checks
     if (!file_exists($path)) {
         return array(404, array('Content-Type', 'text/plain'), 'File not found');
     }
     $path = realpath($path);
     if (false === $path) {
         // resolving failed. not enough rights for intermediate folder?
         return array(404, array('Content-Type', 'text/plain'), 'File not found');
     }
     if (strpos($path, $this->path) !== 0) {
         // gone out of "chroot"?
         return array(404, array('Content-Type', 'text/plain'), 'File not found');
     }
     if (!is_readable($path)) {
         return array(403, array('Content-Type', 'text/plain'), 'Forbidden');
     }
     // Only files are served
     if (is_dir($path)) {
         return array(403, array('Content-Type', 'text/plain'), 'Forbidden');
     }
     return $this->serve($path);
 }
开发者ID:LookForwardPersistence,项目名称:appserver-in-php,代码行数:33,代码来源:FileServe.php

示例3: parse

 /**
  * Parses YAML into a PHP array.
  *
  * The parse method, when supplied with a YAML stream (string or file),
  * will do its best to convert YAML in a file into a PHP array.
  *
  *  Usage:
  *  <code>
  *   $array = Yaml::parse('config.yml');
  *   print_r($array);
  *  </code>
  *
  * @param string $input Path to a YAML file or a string containing YAML
  *
  * @return array The YAML converted to a PHP array
  *
  * @throws \InvalidArgumentException If the YAML is not valid
  *
  * @api
  */
 public static function parse($input)
 {
     // if input is a file, process it
     $file = '';
     if (strpos($input, "\n") === false && is_file($input)) {
         if (false === is_readable($input)) {
             throw new ParseException(sprintf('Unable to parse "%s" as the file is not readable.', $input));
         }
         $file = $input;
         if (self::$enablePhpParsing) {
             ob_start();
             $retval = (include $file);
             $content = ob_get_clean();
             // if an array is returned by the config file assume it's in plain php form else in YAML
             $input = is_array($retval) ? $retval : $content;
             // if an array is returned by the config file assume it's in plain php form else in YAML
             if (is_array($input)) {
                 return $input;
             }
         } else {
             $input = file_get_contents($file);
         }
     }
     $yaml = new Parser();
     try {
         return $yaml->parse($input);
     } catch (ParseException $e) {
         if ($file) {
             $e->setParsedFile($file);
         }
         throw $e;
     }
 }
开发者ID:QianmiHub,项目名称:crypto-js,代码行数:53,代码来源:Yaml.php

示例4: tableInsertBatch

 /**
  * Performs a batch insert into a specific table using either LOAD DATA INFILE or plain INSERTs,
  * as a fallback. On MySQL, LOAD DATA INFILE is 20x faster than a series of plain INSERTs.
  *
  * @param string $tableName PREFIXED table name! you must call Common::prefixTable() before passing the table name
  * @param array $fields array of unquoted field names
  * @param array $values array of data to be inserted
  * @param bool $throwException Whether to throw an exception that was caught while trying
  *                                LOAD DATA INFILE, or not.
  * @throws Exception
  * @return bool  True if the bulk LOAD was used, false if we fallback to plain INSERTs
  */
 public static function tableInsertBatch($tableName, $fields, $values, $throwException = false)
 {
     $filePath = PIWIK_USER_PATH . '/tmp/assets/' . $tableName . '-' . Common::generateUniqId() . '.csv';
     $filePath = SettingsPiwik::rewriteTmpPathWithInstanceId($filePath);
     $loadDataInfileEnabled = Config::getInstance()->General['enable_load_data_infile'];
     if ($loadDataInfileEnabled && Db::get()->hasBulkLoader()) {
         try {
             $fileSpec = array('delim' => "\t", 'quote' => '"', 'escape' => '\\\\', 'escapespecial_cb' => function ($str) {
                 return str_replace(array(chr(92), chr(34)), array(chr(92) . chr(92), chr(92) . chr(34)), $str);
             }, 'eol' => "\r\n", 'null' => 'NULL');
             // hack for charset mismatch
             if (!DbHelper::isDatabaseConnectionUTF8() && !isset(Config::getInstance()->database['charset'])) {
                 $fileSpec['charset'] = 'latin1';
             }
             self::createCSVFile($filePath, $fileSpec, $values);
             if (!is_readable($filePath)) {
                 throw new Exception("File {$filePath} could not be read.");
             }
             $rc = self::createTableFromCSVFile($tableName, $fields, $filePath, $fileSpec);
             if ($rc) {
                 unlink($filePath);
                 return true;
             }
         } catch (Exception $e) {
             Log::info("LOAD DATA INFILE failed or not supported, falling back to normal INSERTs... Error was: %s", $e->getMessage());
             if ($throwException) {
                 throw $e;
             }
         }
     }
     // if all else fails, fallback to a series of INSERTs
     @unlink($filePath);
     self::tableInsertBatchIterate($tableName, $fields, $values);
     return false;
 }
开发者ID:brienomatty,项目名称:elmsln,代码行数:47,代码来源:BatchInsert.php

示例5: run

 public static function run(Request $request)
 {
     $controlador = $request->getControlador() . "Controller";
     $ruta = ROOT . "Controllers" . DS . $controlador . ".php";
     $metodo = $request->getMetodo();
     if ($metodo == "index.php") {
         $metodo = "index";
     }
     $argumento = $request->getArgumento();
     if (is_readable($ruta)) {
         require_once $ruta;
         $mostrar = "Controllers\\" . $controlador;
         $controlador = new $mostrar();
         if (!isset($argumento) || !isset($metodo)) {
             $datos = call_user_func(array($controlador, $metodo));
         } else {
             $datos = call_user_func_array(array($controlador, $metodo), $argumento);
         }
     }
     //Cargar vista
     $ruta = ROOT . "Views" . DS . $request->getControlador() . DS . $request->getMetodo() . ".php";
     if (is_readable($ruta)) {
         require_once $ruta;
     } else {
         print "No se encontro la ruta";
     }
 }
开发者ID:WeSolution,项目名称:frame,代码行数:27,代码来源:Enrutador.php

示例6: loadConfig

 /**
  * Load config from file
  *
  * @param string $filename
  * @throws \Exception
  *
  * @return void
  */
 public function loadConfig($filename)
 {
     if (!is_readable($filename)) {
         throw new \Exception("Profile configuration file `{$filename}` is not readable or does not exists.");
     }
     $this->_config = (new \Magento\Framework\Xml\Parser())->load($filename)->xmlToArray();
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:15,代码来源:Config.php

示例7: autoload

function autoload($className)
{
    $filename = ABSPATH . "classes/" . $className . ".php";
    if (is_readable($filename)) {
        require_once $filename;
    }
}
开发者ID:royanonuevo,项目名称:My-Web-Kit,代码行数:7,代码来源:init.php

示例8: recursive_remove_directory

/**
 * Recursively delete an entire directory.
 *
 * @since 4.6
 * @package all
 * @param string $directory The dir you want to remove.
 * @param bool $empty Should the dir remain empty?
 * @return bool
 */
function recursive_remove_directory($directory, $empty = false)
{
    if (substr($directory, -1) == '/') {
        $directory = substr($directory, 0, -1);
    }
    if (!file_exists($directory) || !is_dir($directory)) {
        return false;
    } elseif (is_readable($directory)) {
        $handle = opendir($directory);
        while (false !== ($item = readdir($handle))) {
            if ($item != '.' && $item != '..') {
                $path = $directory . '/' . $item;
                if (is_dir($path)) {
                    recursive_remove_directory($path);
                } else {
                    unlink($path);
                }
            }
        }
        closedir($handle);
        if (!$empty) {
            if (!rmdir($directory)) {
                return false;
            }
        }
    }
    return true;
}
开发者ID:billcreswell,项目名称:plucke,代码行数:37,代码来源:functions.all.php

示例9: __construct

 function __construct()
 {
     global $mysql, $config, $_FPREFIX;
     $this->Requiremants = new DomDocument();
     $config_file = $_FPREFIX . 'includes/requirements.xml';
     if (!file_exists($config_file) || !is_readable($config_file)) {
         $this->error("Cannot read <i>{$config_file}</i> file!", false);
     }
     $this->Requiremants->load($config_file);
     $this->checkSystem();
     $this->checkDB();
     $this->loadRealms();
     if (in_array($_GET['Realm'], $this->Realms)) {
         $this->Realm = array_search($_GET['Realm'], $this->Realms);
     } else {
         foreach ($mysql->Config['char'] as $key => $realm) {
             if ($realm['default']) {
                 $this->Realm = $key;
             }
         }
     }
     if (!$this->Realm) {
         foreach ($mysql->Config['char'] as $key => $realm) {
             $this->Realm = $key;
             break;
         }
     }
     $this->server = $config['server_name'];
     if ($_GET['searchplugin']) {
         header('Content-type: text/xml');
         die($this->getOpenSearchPlugin());
     }
 }
开发者ID:demonreborn,项目名称:miniarmory,代码行数:33,代码来源:class.system.php

示例10: install_notice

    public function install_notice()
    {
        $this->generate_key();
        if (!is_readable($this->key_file)) {
            echo '
			<div class="error">
				<p>
					I couldn’t find a key file in
					<strong>' . dirname(__FILE__) . '/expurgate/cache/</strong>.
					Without one, expurgate won’t work.
				</p>
				<p>
					I tried to create one, but I couldn’t!
				</p>
			</div>
			';
        }
        if (!is_writable($this->cache_dir)) {
            echo '
			<div class="error">
				<p>
					The expurgate cache directory isn’t writable. Please 
					correct this with:
				</p>
				<p>
					chmod 777 ' . dirname(__FILE__) . '/expurgate/cache/
				</p>
			</div>
			';
        }
    }
开发者ID:robmiller,项目名称:wp-expurgate,代码行数:31,代码来源:wp-expurgate.php

示例11: execute

 /**
  * @see sfTask
  */
 protected function execute($arguments = array(), $options = array())
 {
     parent::execute($arguments, $options);
     $projectWebPath = sfConfig::get('sf_web_dir');
     $filesystem = new dmFilesystem($this->dispatcher, $this->formatter);
     foreach (array('dmAdminPlugin', 'dmFrontPlugin') as $plugin) {
         $this->logSection('plugin', 'Configuring plugin - ' . $plugin);
         $this->installPluginAssets($plugin, dm::getDir() . '/' . $plugin);
     }
     // remove useless doctrine assets
     if (is_readable($doctrineAssetPath = dmOs::join($projectWebPath, 'sfDoctrinePlugin'))) {
         if (!is_link($doctrineAssetPath)) {
             $filesystem->deleteDirContent($doctrineAssetPath);
         }
         $filesystem->remove($doctrineAssetPath);
     }
     // remove web cache dir
     $webCacheDir = sfConfig::get('sf_web_dir') . '/cache';
     if (is_link($webCacheDir)) {
         $filesystem->remove($webCacheDir);
     }
     // create web cache dir
     $filesystem->mkdir($webCacheDir);
     if (!file_exists(dmOs::join($projectWebPath, 'sf'))) {
         $filesystem->relativeSymlink(realpath(sfConfig::get('sf_symfony_lib_dir') . '/../data/web/sf'), dmOs::join($projectWebPath, 'sf'), true);
     }
 }
开发者ID:theolymp,项目名称:diem,代码行数:30,代码来源:dmPublishAssetsTask.class.php

示例12: parseIniFile

 private function parseIniFile()
 {
     $settings = array();
     $settingStack = array();
     $open_basedir_restriction = ini_get('open_basedir');
     if (empty($open_basedir_restriction)) {
         $settingStack[] = '/etc/dbc.ini';
         $settingStack[] = '/usr/local/etc/dbc.ini';
         if (function_exists("posix_getpwuid") && function_exists("posix_getuid")) {
             $userData = posix_getpwuid(posix_getuid());
             $settingStack[] = $userData['dir'] . '/.dbc.ini';
         }
     }
     $settingStack[] = dirname(__FILE__) . '/../dbc.ini';
     $settingStack[] = getcwd() . '/dbc.ini';
     foreach ($settingStack as $settingsFile) {
         if (is_readable($settingsFile)) {
             $settings = array_merge(parse_ini_file($settingsFile, true), $settings);
         }
     }
     //merge with default settings
     $settings = array_merge($this->settingsData, $settings);
     if (empty($settings)) {
         throw new Exception('No settings file found. Aborting.');
     }
     if (!isset($settings['dbConn:standard'])) {
         throw new Exception('Mandatory "dbConn:standard" is missing in settings file. Aborting.');
     }
     $this->settingsData = $this->parseValues($settings);
 }
开发者ID:CoreylDagget,项目名称:dbc,代码行数:30,代码来源:DbChangesSettings.class.php

示例13: configIsReadable

 public static function configIsReadable()
 {
     if (!is_file(self::$CONFIG_FILE)) {
         return false;
     }
     return is_readable(self::$CONFIG_FILE);
 }
开发者ID:BackupTheBerlios,项目名称:smail-svn,代码行数:7,代码来源:MySQLiFactory.php

示例14: isWritable

 function isWritable($sFile, $sPrePath = '/../../')
 {
     clearstatcache();
     $aPathInfo = pathinfo(__FILE__);
     $sFile = $aPathInfo['dirname'] . '/../../' . $sFile;
     return is_readable($sFile) && is_writable($sFile);
 }
开发者ID:Gotgot59,项目名称:dolphin.pro,代码行数:7,代码来源:BxDolIO.php

示例15: choose_page

function choose_page($page)
{
    if ($page !== "" && $page[0] === "~") {
        $xpage = Navigation::path_component(0, true);
        Navigation::set_path("/" . $page . Navigation::path_suffix(1));
        $page = Navigation::set_page($xpage ?: "index");
    }
    $i = strlen($page) - 4;
    if ($i > 0 && substr($page, $i) === ".php") {
        $page = substr($page, 0, $i);
    }
    if ($page === "index") {
        return null;
    }
    if (is_readable($page . ".php") && strpos($page, "/") === false) {
        return $page . ".php";
    } else {
        if (preg_match(',\\A(?:images|scripts|stylesheets)\\z,', $page)) {
            $_REQUEST["file"] = $page . Navigation::path();
            return "cacheable.php";
        } else {
            Navigation::redirect_site("index");
        }
    }
}
开发者ID:benesch,项目名称:peteramati,代码行数:25,代码来源:index.php


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