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


PHP File::exists方法代码示例

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


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

示例1: model

 public function model($data = [])
 {
     $view = false;
     $db = $this->db;
     $table = $this->table;
     $modelFile = APPLICATION_PATH . DS . 'models' . DS . 'Mysql' . DS . 'models' . DS . Inflector::lower($db) . DS . ucfirst(Inflector::lower($table)) . '.php';
     if (!is_dir(APPLICATION_PATH . DS . 'models' . DS . 'Mysql')) {
         File::mkdir(APPLICATION_PATH . DS . 'models' . DS . 'Mysql');
     }
     if (!is_dir(APPLICATION_PATH . DS . 'models' . DS . 'Mysql' . DS . 'models')) {
         File::mkdir(APPLICATION_PATH . DS . 'models' . DS . 'Mysql' . DS . 'models');
     }
     if (!is_dir(APPLICATION_PATH . DS . 'models' . DS . 'Mysql' . DS . 'models' . DS . Inflector::lower($db))) {
         File::mkdir(APPLICATION_PATH . DS . 'models' . DS . 'Mysql' . DS . 'models' . DS . Inflector::lower($db));
     }
     if (!File::exists($modelFile)) {
         File::put($modelFile, str_replace('##class##', ucfirst(Inflector::lower($db)) . ucfirst(Inflector::lower($table)) . 'SQLModel', File::read(__DIR__ . DS . 'dbModel.tpl')));
     }
     $class = '\\Thin\\' . ucfirst(Inflector::lower($db)) . ucfirst(Inflector::lower($table)) . 'SQLModel';
     if (!class_exists($class)) {
         require_once $modelFile;
     }
     $model = $this;
     if (true === $view) {
         $model = self::instance($db, $table);
     }
     return new $class($model, $data);
 }
开发者ID:schpill,项目名称:standalone,代码行数:28,代码来源:Db.php

示例2: background

 public function background()
 {
     $file = realpath(APPLICATION_PATH . DS . '..' . DS . 'public' . DS . 'scripts' . DS . 'schedule.php');
     if (File::exists($file)) {
         $cmd = 'php ' . $file;
         lib('utils')->backgroundTask($cmd);
     }
 }
开发者ID:schpill,项目名称:standalone,代码行数:8,代码来源:schedule.php

示例3: __construct

 public function __construct($namespace, $entity)
 {
     $this->db = STORAGE_PATH . DS . 'dbNode_' . $namespace . '::' . $entity . '.data';
     $this->lock = STORAGE_PATH . DS . 'dbNode_' . $namespace . '::' . $entity . '.lock';
     if (!File::exists($this->db)) {
         File::put($this->db, json_encode(array()));
     }
     $this->buffer = json_decode(fgc($this->db), true);
     $this->clean();
 }
开发者ID:schpill,项目名称:thin,代码行数:10,代码来源:Driver.php

示例4: read

 public function read($file)
 {
     $key = $this->redisKey($file);
     $cache = $this->model->cache()->get($key);
     if (!strlen($cache)) {
         if (File::exists($file)) {
             $cache = File::read($file);
             $this->model->cache()->set($key, $cache);
         }
     }
     return $cache;
 }
开发者ID:schpill,项目名称:standalone,代码行数:12,代码来源:Redis.php

示例5: getOptionsFromMarket

 public function getOptionsFromMarket($market_id)
 {
     if (!is_integer($market_id)) {
         throw new Exception("market_id must be an integer id.");
     }
     $file = APPLICATION_PATH . DS . 'models' . DS . 'options' . DS . $market_id . '.php';
     if (File::exists($file)) {
         $options = (include $file);
         return $options;
     }
     return [];
 }
开发者ID:schpill,项目名称:standalone,代码行数:12,代码来源:forms.php

示例6: __construct

 public function __construct(Database $model)
 {
     $this->model = $model->inCache(false);
     $fileConfig = APPLICATION_PATH . DS . 'models' . DS . 'CrudNosql' . DS . ucfirst(Inflector::camelize($model->db)) . DS . ucfirst(Inflector::camelize($model->table)) . '.php';
     if (File::exists($fileConfig)) {
         $this->config = (include $fileConfig);
     } else {
         $this->config = [];
     }
     if (!empty($this->config)) {
         $this->prepareFields();
     }
     if (get_magic_quotes_gpc()) {
         $_REQUEST = $this->stripslashes($_REQUEST);
     }
 }
开发者ID:schpill,项目名称:standalone,代码行数:16,代码来源:Crud.php

示例7: dispatch

 public static function dispatch()
 {
     static::$method = Request::method();
     $uri = substr(str_replace('/ws/', '/', $_SERVER['REQUEST_URI']), 1);
     $tab = explode('/', $uri);
     if (count($tab) < 3) {
         Api::forbidden();
     }
     $namespace = current($tab);
     $controller = $tab[1];
     $action = $tab[2];
     $tab = array_slice($tab, 3);
     $count = count($tab);
     if (0 < $count && $count % 2 == 0) {
         for ($i = 0; $i < $count; $i += 2) {
             $_REQUEST[$tab[$i]] = $tab[$i + 1];
         }
     }
     $file = APPLICATION_PATH . DS . 'webservices' . DS . $namespace . DS . $controller . '.php';
     if (!File::exists($file)) {
         Api::NotFound();
     }
     require_once $file;
     $class = 'Thin\\' . ucfirst($controller) . 'Ws';
     $i = new $class();
     $methods = get_class_methods($i);
     $call = strtolower(static::$method) . ucfirst($action);
     if (!Arrays::in($call, $methods)) {
         Api::NotFound();
     }
     if (Arrays::in('init', $methods)) {
         $i->init($call);
     }
     $i->{$call}();
     if (Arrays::in('after', $methods)) {
         $i->after();
     }
 }
开发者ID:schpill,项目名称:standalone,代码行数:38,代码来源:Rest.php

示例8: hage

 public function hage($hash, $key)
 {
     $file = $this->getHashFile($hash, $key);
     if (File::exists($file)) {
         return filemtime($file);
     }
     return 0;
 }
开发者ID:schpill,项目名称:thin,代码行数:8,代码来源:Store.php

示例9: read

 public function read($file, $default = null, $mode = 'rb', $try = 1)
 {
     $file = $this->dir . DS . $file . '.php';
     if (File::exists($file)) {
         $fp = fopen($file, 'rb');
         if (!flock($fp, LOCK_EX)) {
             if ($try < 100) {
                 usleep(50000);
                 return $this->read($file, $default, $mode, $try++);
             } else {
                 throw new Exception("The file '{$file}' can not be locked.");
             }
         }
         $data = unserialize(File::read($file));
         flock($fp, LOCK_UN);
         fclose($fp);
         return $data;
     }
     return $default;
 }
开发者ID:schpill,项目名称:standalone,代码行数:20,代码来源:Store.php

示例10: go

 private static function go($module, $controller, $action)
 {
     $cdir = APPLICATION_PATH . DS . 'modules' . DS . SITE_NAME . DS . Inflector::lower($module) . DS . 'controllers';
     if (!is_dir($cdir)) {
         static::is404();
     } else {
         $dirApps = realpath(APPLICATION_PATH);
         $tplDir = realpath($dirApps . DS . 'modules' . DS . SITE_NAME . DS . Inflector::lower($module) . DS . 'views');
         $controllerDir = realpath($dirApps . DS . 'modules' . DS . SITE_NAME . DS . Inflector::lower($module) . DS . 'controllers');
         $tpl = $tplDir . DS . Inflector::lower($controller) . DS . Inflector::lower($action) . '.phtml';
         $controllerFile = $controllerDir . DS . Inflector::lower($controller) . 'Controller.php';
         if (!file::exists($controllerFile)) {
             return static::is404();
         } else {
             if (File::exists($tpl)) {
                 $view = new View($tpl);
             }
             require_once $controllerFile;
             $controllerClass = 'Thin\\' . Inflector::lower($controller) . 'Controller';
             $instance = new $controllerClass();
             if (File::exists($tpl)) {
                 $instance->view = $view;
             }
             if (strstr($action, '-')) {
                 $words = explode('-', $action);
                 $newAction = '';
                 for ($i = 0; $i < count($words); $i++) {
                     $word = trim($words[$i]);
                     if ($i > 0) {
                         $word = ucfirst($word);
                     }
                     $newAction .= $word;
                 }
                 $action = $newAction;
             }
             $actionName = $action . 'Action';
             $actions = get_class_methods($controllerClass);
             if (!Arrays::in($actionName, $actions)) {
                 $continue = false;
                 foreach ($actions as $act) {
                     if (Inflector::lower($act) == Inflector::lower($actionName)) {
                         $actionName = $act;
                         $continue = true;
                         break;
                     }
                 }
                 if (false === $continue) {
                     return static::is404();
                 }
             }
             if (Arrays::in('init', $actions)) {
                 $instance->init();
             }
             if (Arrays::in('preDispatch', $actions)) {
                 $instance->preDispatch();
             }
             $instance->{$actionName}();
             if (File::exists($tpl)) {
                 $instance->view->render();
             }
             /* stats */
             if (File::exists($tpl) && null === container()->getNoShowStats()) {
                 echo View::showStats();
             }
             if (Arrays::in('postDispatch', $actions)) {
                 $instance->postDispatch();
             }
             if (Arrays::in('exit', $actions)) {
                 $instance->exit();
             }
         }
     }
     exit;
 }
开发者ID:schpill,项目名称:standalone,代码行数:74,代码来源:Router.php

示例11: evaluate

 public static function evaluate($template, array $parameters)
 {
     extract($parameters, EXTR_SKIP);
     if (File::exists($template)) {
         if (empty($view)) {
             throw new Exception("A view is needed to evaluate.");
         }
         ob_start();
         require $template;
         return ob_get_clean();
     } elseif (is_string($template)) {
         if (empty($view)) {
             throw new Exception("A view is needed to evaluate.");
         }
         ob_start();
         eval('; ?>' . $template . '<?php ;');
         return ob_get_clean();
     } else {
         throw new Exception("A view is needed to evaluate.");
     }
 }
开发者ID:schpill,项目名称:thin,代码行数:21,代码来源:View.php

示例12: search

 private function search($condition = null, $results = array(), $populate = true)
 {
     $searchFile = $this->dir . DS . sha1(serialize(func_get_args()));
     $changeFile = $this->dir . DS . 'change';
     if (File::exists($changeFile) && File::exists($searchFile)) {
         $ageSearch = filemtime($searchFile);
         $ageChange = filemtime($changeFile);
         if ($ageSearch > $ageChange) {
             $collection = json_decode(file_get_contents($searchFile), true);
             if (true === $populate) {
                 $this->results = $collection;
             }
             return $collection;
         } else {
             File::delete($searchFile);
         }
     }
     $datas = !count($results) ? $this->all() : $results;
     if (empty($condition)) {
         return $datas;
     }
     $collection = array();
     $condition = repl('LIKE START', 'LIKESTART', $condition);
     $condition = repl('LIKE END', 'LIKEEND', $condition);
     $condition = repl('NOT LIKE', 'NOTLIKE', $condition);
     $condition = repl('NOT IN', 'NOTIN', $condition);
     list($field, $op, $value) = explode(' ', $condition, 3);
     if ($value instanceof Container) {
         $value = $value->id();
         $field = $field . '_id';
     }
     if (count($datas)) {
         foreach ($datas as $tab) {
             if (!empty($tab)) {
                 $val = isAke($tab, $field, null);
                 if (strlen($val)) {
                     $val = repl('|', ' ', $val);
                     $check = $this->compare($val, $op, $value);
                 } else {
                     $check = 'null' == $value ? true : false;
                 }
                 if (true === $check) {
                     array_push($collection, $tab);
                 }
             }
         }
     }
     if (true === $populate) {
         $this->results = $collection;
     }
     File::put($searchFile, json_encode($collection));
     return $collection;
 }
开发者ID:noikiy,项目名称:inovi,代码行数:53,代码来源:Dbjson.php

示例13: limit

 public function limit($limit, $offset = 0)
 {
     $hash = sha1($this->db->getHash() . 'limit' . serialize(func_get_args()));
     $cursor = $this->db->motor()->getPath() . DS . 'cursors' . DS . $hash;
     if (is_dir($cursor)) {
         $ageCursor = filemtime($cursor . DS . '.');
         $ageDb = $this->db->getAge();
         if ($ageDb < $ageCursor) {
             $this->cursor = $cursor;
             return $this;
         } else {
             File::rmdir($cursor);
         }
     }
     File::mkdir($this->db->motor()->getPath() . DS . 'cursors');
     File::mkdir($this->db->motor()->getPath() . DS . 'cursors' . DS . $hash);
     $index = 0;
     for ($i = $offset; $i < $limit; $i++) {
         $file = $this->cursor . DS . $i . '.php';
         if (File::exists($file)) {
             $newFile = $cursor . DS . $index . '.php';
             $data = (include $file);
             File::put($newFile, "<?php\nreturn " . var_export($data, 1) . ';');
             $index++;
         }
     }
     $this->cursor = $cursor;
     return $this;
 }
开发者ID:schpill,项目名称:standalone,代码行数:29,代码来源:Iterator.php

示例14: cached

 private function cached($key, $value = null)
 {
     if (false === $this->cache) {
         return null;
     }
     $settings = isAke(self::$configs, $this->entity);
     $event = isAke($settings, 'cache');
     if (!empty($event)) {
         return $this->{$event}($key, $value);
     }
     $file = STORAGE_PATH . DS . 'cache' . DS . $key . '.eav';
     if (empty($value)) {
         if (File::exists($file)) {
             $age = filemtime($file);
             $maxAge = time() - $this->ttl;
             if ($maxAge < $age) {
                 return json_decode(File::get($file), true);
             } else {
                 File::delete($file);
                 return null;
             }
         }
     } else {
         if (File::exists($file)) {
             File::delete($file);
         }
         File::put($file, json_encode($value));
         return true;
     }
 }
开发者ID:noikiy,项目名称:inovi,代码行数:30,代码来源:Dbeav.php

示例15: cached

 public function cached($key, $data = null)
 {
     $file = CACHE_PATH . DS . $key . '_sql';
     if (!empty($data)) {
         File::put($file, serialize($data));
         return $data;
     }
     if (File::exists($file)) {
         $age = time() - filemtime($file);
         if ($age > $this->_tts) {
             File::delete($file);
         } else {
             return unserialize(fgc($file));
         }
     }
 }
开发者ID:noikiy,项目名称:inovi,代码行数:16,代码来源:Activerecord.php


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