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

PHP is_readable函数代码示例

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

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



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


示例16: fileExists

 /**
  * Determine if the XML file exists
  * @return bool
  */
 public function fileExists()
 {
     if (file_exists($this->path) && is_readable($this->path)) {
         return true;
     }
     return false;
 }
开发者ID:evltuma,项目名称:moodle,代码行数:11,代码来源:xmldb_file.php


示例17: fromFile

 /**
  * Takes a filename and returnes a Stringset representing that file.
  * @param string $filename
  * @return Stringset
  */
 public static function fromFile($filename)
 {
     if (!is_readable($filename)) {
         throw new Exception("Unreadable file");
     }
     return self::fromString(file_get_contents($filename));
 }
开发者ID:rnijveld,项目名称:pgt,代码行数:12,代码来源:Po.php


示例18: probe

 /**
  * Factory fuction which produces a configuration based on a policy and based
  * on local system resources.
  *
  * @param $policy array:
  *  - enable_ssl: bool; default: TRUE
  *  - verify_peer: bool; default: TRUE
  *  - cafile: string, path to aggregated PEM; overrides any system defaults
  *  - fallback_cafile: string, path to aggregated PEM; used on systems which lack default; set FALSE to disable
  *  - fallback_ttl: int, seconds, the max age of the fallback cafile before it's regarded as stale; default: 5 years
  * @return CA_Config_Stream
  */
 public static function probe($policy = array())
 {
     if (isset($policy['enable_ssl']) && $policy['enable_ssl'] === FALSE) {
         return new CA_Config_Stream(FALSE, FALSE, NULL);
     }
     $sw = stream_get_wrappers();
     if (!extension_loaded('openssl') || !in_array('https', $sw)) {
         return new CA_Config_Stream(FALSE, FALSE, NULL);
     }
     if (isset($policy['verify_peer']) && $policy['verify_peer'] === FALSE) {
         return new CA_Config_Stream(TRUE, FALSE, NULL);
     }
     if (isset($policy['cafile'])) {
         if (file_exists($policy['cafile']) && is_readable($policy['cafile'])) {
             return new CA_Config_Stream(TRUE, TRUE, $policy['cafile']);
         } else {
             throw new Exception("Certificate Authority file is missing. Please contact the system administrator. See also: " . $policy['cafile']);
         }
     }
     if (!isset($policy['fallback_ttl'])) {
         $policy['fallback_ttl'] = 5 * 364 * 24 * 60 * 60;
     }
     if (!isset($policy['fallback_cafile'])) {
         $policy['fallback_cafile'] = dirname(__FILE__) . '/cacert.pem';
     }
     if (empty($policy['fallback_cafile']) || !file_exists($policy['fallback_cafile'])) {
         throw new Exception("Certificate Authority file is required for SSL. Please contact the system administrator.");
     } elseif (time() > filemtime($policy['fallback_cafile']) + $policy['fallback_ttl']) {
         throw new Exception("Certificate Authority file is too old. Please contact the system administrator. See also: " . $policy['fallback_cafile']);
     } else {
         return new CA_Config_Stream(TRUE, TRUE, $policy['fallback_cafile']);
     }
 }
开发者ID:kidaa30,项目名称:yes,代码行数:45,代码来源:Stream.php


示例19: getBytes

 /**
  * PRNG generator based on security principles 
  * at http://phpsecurity.readthedocs.org/en/latest/Insufficient-Entropy-For-Random-Values.html 
  * 
  * @param mixed $length 
  * @param mixed $strong 
  * @access public
  * @return void
  */
 public function getBytes($length, $strong = false)
 {
     $bytes = '';
     if (function_exists('openssl_random_pseudo_bytes')
         && (version_compare(PHP_VERSION, '5.3.4') >= 0
         || strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN')
     ) {
         $bytes = openssl_random_pseudo_bytes($length, $usable);
         if (true === $usable) {
             return $bytes;
         }
     }
     if (function_exists('mcrypt_create_iv')
         && (version_compare(PHP_VERSION, '5.3.7') >= 0
         || strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN')
     ) {
         $bytes = mcrypt_create_iv($length, MCRYPT_DEV_URANDOM);
         if ($bytes !== false && strlen($bytes) === $length) {
             return $bytes;
         }
     }
     $checkAlternatives = (file_exists('/dev/urandom') && is_readable('/dev/urandom'))
         || class_exists('\\COM', false);
     if (true === $strong && false === $checkAlternatives) {
         throw new \Exception(
             'Unable to generate sufficiently strong random bytes due to a lack ',
             'of sources with sufficient entropy'
         );
     }
     $generator = $this->getAlternativeGenerator();
     return $generator->generate($length);
 }
开发者ID:Aasit,项目名称:DISCOUNT--SRV-I,代码行数:41,代码来源:RandomUtils.php


示例20: __construct

 /**
  * Setup
  */
 function __construct()
 {
     $ns = e107::getRender();
     $pref = e107::getPref();
     $mes = e107::getMessage();
     $frm = e107::getForm();
     $this->backUrl = e_SELF;
     $core_data = file_get_contents(e_CORE . 'sql/core_sql.php');
     $this->tables['core'] = $this->getTables($core_data);
     $this->sqlLanguageTables = $this->getSqlLanguages();
     if (varset($pref['e_sql_list'])) {
         foreach ($pref['e_sql_list'] as $path => $file) {
             $filename = e_PLUGIN . $path . '/' . $file . '.php';
             if (is_readable($filename)) {
                 $id = str_replace('_sql', '', $file);
                 $data = file_get_contents($filename);
                 $this->tables[$id] = $this->getTables($data);
                 unset($data);
             } else {
                 $message = str_replace("[x]", $filename, DBVLAN_22);
                 $mes->add($message, E_MESSAGE_WARNING);
             }
         }
     }
 }
开发者ID:8moustapha8,项目名称:e107,代码行数:28,代码来源:db_verify_class.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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