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


PHP realpath_exists函数代码示例

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


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

示例1: siteLibAutoloader

function siteLibAutoloader($className) {
  $paths = $GLOBALS['libDirs'];
  

  // If the className has Module in it then use the modules dir
  if (defined('MODULES_DIR') && preg_match("/(.*)WebModule/", $className, $bits)) {
    $paths[] = MODULES_DIR . '/' . strtolower($bits[1]);
  }

  // use the site lib dir if it's been defined
  if (defined('SITE_LIB_DIR')) {
    $paths[] = SITE_LIB_DIR;
  }
  
  $paths[] = LIB_DIR;
      
  foreach ($paths as $path) {
    $file = realpath_exists("$path/$className.php");
    if ($file) {
      //error_log("Autoloader found $file for $className");
      include($file);
      return;
    }
  }
  return;
}
开发者ID:nicosiseng,项目名称:Kurogo-Mobile-Web,代码行数:26,代码来源:autoloader.php

示例2: _outputTypeFile

function _outputTypeFile($matches)
{
    $file = $matches[3];
    $prefix = '';
    $bits = explode("/", $file);
    if (count($bits) > 1) {
        $file = array_pop($bits);
        $prefix = trim(implode("/", $bits), "/") . '/';
    }
    $platform = Kurogo::deviceClassifier()->getPlatform();
    $pagetype = Kurogo::deviceClassifier()->getPagetype();
    $browser = Kurogo::deviceClassifier()->getBrowser();
    $testDirs = array(THEME_DIR, SHARED_THEME_DIR, SITE_APP_DIR, SHARED_APP_DIR, APP_DIR);
    $testFiles = array("{$prefix}{$pagetype}-{$platform}-{$browser}/{$file}", "{$prefix}{$pagetype}-{$platform}/{$file}", "{$prefix}{$pagetype}/{$file}", "{$prefix}{$file}");
    foreach ($testDirs as $dir) {
        //do not assume dirs have value set
        if ($dir) {
            $dir .= '/' . $matches[1] . $matches[2];
            foreach ($testFiles as $file) {
                Kurogo::log(LOG_DEBUG, "Looking for {$dir}/{$file}", 'index');
                if ($file = realpath_exists("{$dir}/{$file}")) {
                    _outputFile($file);
                }
            }
        }
    }
    _404();
}
开发者ID:sponto,项目名称:Kurogo-Mobile-Web,代码行数:28,代码来源:index.php

示例3: _outputTypeFile

function _outputTypeFile($matches) { 
  $file = $matches[3];

  $platform = Kurogo::deviceClassifier()->getPlatform();
  $pagetype = Kurogo::deviceClassifier()->getPagetype();
  
  $testDirs = array(
    THEME_DIR.'/'.$matches[1].$matches[2],
    SITE_DIR.'/'.$matches[1].$matches[2],
    APP_DIR.'/'.$matches[1].$matches[2],
  );
  
  $testFiles = array(
    "$pagetype-$platform/$file",
    "$pagetype/$file",
    "$file",
  );
  
  foreach ($testDirs as $dir) {
    foreach ($testFiles as $file) {
      if ($file = realpath_exists("$dir/$file")) {
          _outputFile($file);
      }
    }
  }

  _404();
}
开发者ID:neoroman,项目名称:Kurogo-Mobile-Web,代码行数:28,代码来源:index.php

示例4: siteLibAutoloader

 /**
 * This function defines a autoloader that is run when a class needs to be instantiated but the corresponding
 * file has not been loaded. Files MUST be named with the same name as its class
 * currently it will search:
 * 1. If the className has Module in it, it will search the MODULES_DIR
 * 2. The SITE_LIB_DIR  (keep in mind that some files may manually include the LIB_DIR class
 * 3. The LIB_DIR 
 * 
 */
function siteLibAutoloader($className) {
  $paths = array();
  
  // If the className has Authentication at the end try the  authentication dir
  if (preg_match("/(Authentication)$/", $className, $bits)) {
    if (defined('SITE_LIB_DIR')) {
      $paths[] = SITE_LIB_DIR . "/" . $bits[1];
    }
    $paths[] = LIB_DIR . "/" . $bits[1];
  }

  // If the className has Module in it then use the modules dir
  if (defined('MODULES_DIR') && preg_match("/(.*)WebModule/", $className, $bits)) {
    $paths[] = MODULES_DIR . '/' . strtolower($bits[1]);
  }

  // use the site lib dir if it's been defined
  if (defined('SITE_LIB_DIR')) {
    $paths[] = SITE_LIB_DIR;
  }
  
  $paths[] = LIB_DIR;
      
  foreach ($paths as $path) {
    $file = realpath_exists("$path/$className.php");
    if ($file) {
      //error_log("Autoloader found $file for $className");
      include $file;
      return;
    }
  }
  return;
}
开发者ID:rezalutions,项目名称:Kurogo-Mobile-Web,代码行数:42,代码来源:autoloader.php

示例5: parseFile

 public function parseFile($filename)
 {
     if (strpos($filename, '.zip') !== false) {
         if (!class_exists('ZipArchive')) {
             throw new KurogoException("class ZipArchive (php-zip) not available");
         }
         $zip = new ZipArchive();
         $zip->open($filename);
         // locate valid shapefile components
         $shapeNames = array();
         for ($i = 0; $i < $zip->numFiles; $i++) {
             if (preg_match('/(.+)\\.(shp|dbf|prj)$/', $zip->getNameIndex($i), $matches)) {
                 $shapeName = $matches[1];
                 $extension = $matches[2];
                 if (!isset($shapeNames[$shapeName])) {
                     $shapeNames[$shapeName] = array();
                 }
                 $shapeNames[$shapeName][] = $extension;
             }
         }
         $this->dbfParser = new DBase3FileParser();
         foreach ($shapeNames as $shapeName => $extensions) {
             if (in_array('dbf', $extensions) && in_array('shp', $extensions)) {
                 $this->setContents($zip->getFromName("{$shapeName}.shp"));
                 $contents = $zip->getFromName("{$shapeName}.dbf");
                 if (!$contents) {
                     throw new KurogoDataException("could not read {$shapeName}.dbf");
                 }
                 $this->dbfParser->setContents($zip->getFromName("{$shapeName}.dbf"));
                 $this->dbfParser->setup();
                 if (in_array('prj', $extensions)) {
                     $prjData = $zip->getFromName("{$shapeName}.prj");
                     $this->mapProjection = new MapProjection($prjData);
                 }
                 $this->doParse();
             }
         }
     } elseif (realpath_exists("{$filename}.shp") && realpath_exists("{$filename}.dbf")) {
         $this->setFilename("{$filename}.shp");
         $this->dbfParser = new DBase3FileParser();
         $this->dbfParser->setFilename("{$filename}.dbf");
         $this->dbfParser->setup();
         $prjFile = $filename . '.prj';
         if (realpath_exists($prjFile)) {
             $prjData = file_get_contents($prjFile);
             $this->mapProjection = new MapProjection($prjData);
         }
         $this->doParse();
     } else {
         throw new KurogoDataException("Cannot find {$filename}");
     }
     return $this->features;
 }
开发者ID:hxfnd,项目名称:Kurogo-Mobile-Web,代码行数:53,代码来源:ShapefileDataParser.php

示例6: retrieveResponse

 protected function retrieveResponse()
 {
     $response = $this->initResponse();
     if (strpos($this->fileStem, '.zip') !== false) {
         if (!class_exists('ZipArchive')) {
             throw new KurogoException("class ZipArchive (php-zip) not available");
         }
         $response->setContext('zipped', true);
         $zip = new ZipArchive();
         if (strpos($this->fileStem, 'http') === 0 || strpos($this->fileStem, 'ftp') === 0) {
             $tmpFile = Kurogo::tempFile();
             copy($this->fileStem, $tmpFile);
             $zip->open($tmpFile);
         } else {
             $zip->open($this->fileStem);
         }
         // locate valid shapefile components
         $shapeNames = array();
         for ($i = 0; $i < $zip->numFiles; $i++) {
             if (preg_match('/(.+)\\.(shp|dbf|prj)$/', $zip->getNameIndex($i), $matches)) {
                 $shapeName = $matches[1];
                 $extension = $matches[2];
                 if (!isset($shapeNames[$shapeName])) {
                     $shapeNames[$shapeName] = array();
                 }
                 $shapeNames[$shapeName][] = $extension;
             }
         }
         $responseData = array();
         foreach ($shapeNames as $shapeName => $extensions) {
             if (in_array('dbf', $extensions) && in_array('shp', $extensions)) {
                 $fileData = array('dbf' => $zip->getFromName("{$shapeName}.dbf"), 'shp' => $zip->getFromName("{$shapeName}.shp"));
                 if (in_array('prj', $extensions)) {
                     $prjData = $zip->getFromName("{$shapeName}.prj");
                     $fileData['projection'] = new MapProjection($prjData);
                 }
                 $responseData[$shapeName] = $fileData;
             }
         }
         $response->setResponse($responseData);
     } elseif (realpath_exists("{$this->fileStem}.shp") && realpath_exists("{$this->fileStem}.dbf")) {
         $response->setContext('zipped', false);
         $response->setContext('shp', "{$this->fileStem}.shp");
         $response->setContext('dbf', "{$this->fileStem}.dbf");
         if (realpath_exists("{$this->fileStem}.prj")) {
             $prjData = file_get_contents("{$this->fileStem}.prj");
             $response->setContext('projection', new MapProjection($prjData));
         }
     } else {
         throw new KurogoDataException("Cannot find {$this->fileStem}");
     }
     return $response;
 }
开发者ID:nncsang,项目名称:Kurogo,代码行数:53,代码来源:ShapefileDataRetriever.php

示例7: loadFile

 protected function loadFile($_file, $safe = true)
 {
     if (strlen($_file) == 0) {
         return false;
     }
     if (!($file = realpath_exists($_file, $safe))) {
         return false;
     }
     $vars = parse_ini_file($file, false);
     $this->addVars($vars);
     $sectionVars = parse_ini_file($file, true);
     $this->addSectionVars($sectionVars);
     Kurogo::log(LOG_INFO, "Loaded config file {$file}", 'config');
     return $file;
 }
开发者ID:sponto,项目名称:Kurogo-Mobile-Web,代码行数:15,代码来源:ConfigFile.php

示例8: buildFileList

function buildFileList($checkFiles) {
  $foundFiles = array();

  foreach ($checkFiles['files'] as $entry) {
    if (is_array($entry)) {
      $foundFiles = array_merge($foundFiles, buildFileList($entry));
    } else if (realpath_exists($entry)) { 
      $foundFiles[] = $entry;
    }
    if ($checkFiles['include'] == 'any' && count($foundFiles)) {
      break;
    }
  }

  return $foundFiles;
}
开发者ID:neoroman,项目名称:Kurogo-Mobile-Web,代码行数:16,代码来源:minify.php

示例9: _outputTypeFile

function _outputTypeFile($matches)
{
    $file = $matches[3];
    $platform = Kurogo::deviceClassifier()->getPlatform();
    $pagetype = Kurogo::deviceClassifier()->getPagetype();
    $browser = Kurogo::deviceClassifier()->getBrowser();
    $testDirs = array(THEME_DIR . '/' . $matches[1] . $matches[2], SITE_APP_DIR . '/' . $matches[1] . $matches[2], SHARED_APP_DIR . '/' . $matches[1] . $matches[2], APP_DIR . '/' . $matches[1] . $matches[2]);
    $testFiles = array("{$pagetype}-{$platform}-{$browser}/{$file}", "{$pagetype}-{$platform}/{$file}", "{$pagetype}/{$file}", "{$file}");
    foreach ($testDirs as $dir) {
        foreach ($testFiles as $file) {
            if ($file = realpath_exists("{$dir}/{$file}")) {
                _outputFile($file);
            }
        }
    }
    _404();
}
开发者ID:nncsang,项目名称:Kurogo,代码行数:17,代码来源:index.php

示例10: generateURL

 protected static function generateURL($file, $contents, $subdirectory=null) {
     $path = AUTOLOAD_FILE_DIR;
     if (!realpath_exists($path)) {
         if (!mkdir($path, 0755, true)) {
             error_log("could not create $path");
             return;
         }
     }
     $subPath = $path."/$subdirectory";
     if (!realpath_exists($subPath)) {
         if (!mkdir($subPath, 0755, true)) {
             error_log("could not create $subPath");
             return;
         }
     }
     if (file_put_contents(self::filePath($file, $subdirectory), $contents)) {
         return self::fullURL($file, $subdirectory);
     } else {
         return false;
     }
 }
开发者ID:neoroman,项目名称:Kurogo-Mobile-Web,代码行数:21,代码来源:FileLoader.php

示例11: __construct

  function __construct() {
    // Load main configuration file
    $config = ConfigFile::factory('kurogo', 'project', ConfigFile::OPTION_IGNORE_MODE | ConfigFile::OPTION_IGNORE_LOCAL);
    $this->addConfig($config);

    define('CONFIG_MODE', $config->getVar('CONFIG_MODE'));
    define('CONFIG_IGNORE_LOCAL', $config->getVar('CONFIG_IGNORE_LOCAL'));

    //make sure active site is set    
    if (!$site = $this->getVar('ACTIVE_SITE')) {
        die("FATAL ERROR: ACTIVE_SITE not set");
    }
    
    //make sure site_dir is set and is a valid path
    if (!($siteDir = $this->getVar('SITE_DIR')) || !($siteDir = realpath_exists($siteDir))) {
        die("FATAL ERROR: Site Directory ". $this->getVar('SITE_DIR') . " not found for site " . $site);
    }
    
    // Set up defines relative to SITE_DIR
    define('SITE_DIR',             $siteDir);
    define('SITE_KEY',             md5($siteDir));
    define('SITE_LIB_DIR',         SITE_DIR.'/lib');
    define('SITE_APP_DIR',         SITE_DIR.'/app');
    define('SITE_MODULES_DIR',     SITE_DIR.'/app/modules');
    define('DATA_DIR',             SITE_DIR.'/data');
    define('CACHE_DIR',            SITE_DIR.'/cache');
    define('LOG_DIR',              SITE_DIR.'/logs');
    define('SITE_CONFIG_DIR',      SITE_DIR.'/config');

    //load in the site config file (required);
    $config = ConfigFile::factory('site', 'site');
    $this->addConfig($config);

    // Set up theme define
    if (!$theme = $this->getVar('ACTIVE_THEME')) {
        die("FATAL ERROR: ACTIVE_THEME not set");
    }
    
    define('THEME_DIR', SITE_DIR.'/themes/'.$theme);
  }
开发者ID:neoroman,项目名称:Kurogo-Mobile-Web,代码行数:40,代码来源:SiteConfig.php

示例12: generateURL

 protected static function generateURL($file, $contents, $subdirectory = null)
 {
     $path = AUTOLOAD_FILE_DIR;
     if (!realpath_exists($path)) {
         if (!mkdir($path, 0755, true)) {
             Kurogo::log(LOG_WARNING, "could not create {$path}", 'data');
             return;
         }
     }
     $subPath = $path . "/{$subdirectory}";
     if (!realpath_exists($subPath)) {
         if (!mkdir($subPath, 0755, true)) {
             Kurogo::log(LOG_WARNING, "could not create {$subPath}", 'data');
             return;
         }
     }
     if (file_put_contents(self::filePath($file, $subdirectory), $contents)) {
         return self::fullURL($file, $subdirectory);
     } else {
         return false;
     }
 }
开发者ID:hxfnd,项目名称:Kurogo-Mobile-Web,代码行数:22,代码来源:FileLoader.php

示例13: factory

  public static function factory($id, $type=null) {
  
    // when run without a type it will find either
    $classNames = array(
        'web'=>ucfirst($id).'WebModule',
        'api'=>ucfirst($id).'APIModule'
    );
    
    // if we specified a type, include only that type in the array
    if ($type) {
        if (isset($classNames[$type])) {
            $classNames = array($classNames[$type]);
        } else {
            throw new Exception("Invalid module type $type");
        }
    }

    // possible module paths
    $modulePaths = array(
      SITE_MODULES_DIR."/$id/Site%s.php"=>"Site%s",
      SITE_MODULES_DIR."/$id/%s.php"=>"%s",
      MODULES_DIR."/$id/%s.php"=>"%s",
    );
    
    //cycle module paths and class names to find a valid module
    foreach($modulePaths as $path=>$className){ 
        foreach ($classNames as $class) {
            $className = sprintf($className, $class);
            $path = sprintf($path, $class);
            $moduleFile = realpath_exists($path);
            if ($moduleFile && include_once($moduleFile)) {
                return new $className();
            }
        }
    }
   
    throw new Exception("Module $id not found");
   }
开发者ID:nicosiseng,项目名称:Kurogo-Mobile-Web,代码行数:38,代码来源:Module.php

示例14: __construct

 public function __construct($path, $timeout = NULL, $mkdir = FALSE)
 {
     if (empty($path)) {
         throw new KurogoDataException("Invalid path");
     }
     $this->path = $path;
     if ($mkdir) {
         if (!file_exists($path)) {
             if (!@mkdir($path, 0700, true)) {
                 throw new KurogoDataException("Could not create cache folder {$path}");
             }
         }
         if (!realpath_exists($path)) {
             throw new KurogoDataException("Path {$path} is not valid for cache");
         }
     }
     if (!is_writable($path)) {
         throw new KurogoDataException("Path {$path} is not writable");
     }
     if ($timeout !== NULL) {
         $this->timeout = $timeout;
     }
 }
开发者ID:sponto,项目名称:Kurogo-Mobile-Web,代码行数:23,代码来源:DiskCache.php

示例15: detectDeviceInternal

 protected function detectDeviceInternal($user_agent)
 {
     Kurogo::log(LOG_INFO, "Detecting device using internal device detection", 'deviceDetection');
     if (!$user_agent) {
         return;
     }
     /*
      * Two things here:
      * First off, we now have two files which can be used to classify devices,
      * the master file, usually at LIB_DIR/deviceData.json, and the custom file,
      * usually located at DATA_DIR/deviceData.json.
      *
      * Second, we're still allowing the use of sqlite databases (despite it
      * being slower and more difficult to update).  So, if you specify the
      * format of the custom file as sqlite, it should still work.
      */
     $master_file = LIB_DIR . "/deviceData.json";
     $site_file = Kurogo::getOptionalSiteVar('MOBI_SERVICE_SITE_FILE');
     $site_file_format = Kurogo::getOptionalSiteVar('MOBI_SERVICE_SITE_FORMAT', 'json');
     if (!($site_file && $site_file_format)) {
         // We don't have a site-specific file.  This means we can only
         // detect on the master file.
         $site_file = "";
     }
     if (!empty($site_file) && ($site_file = realpath_exists($site_file))) {
         switch ($site_file_format) {
             case 'json':
                 $site_devices = json_decode(file_get_contents($site_file), true);
                 $site_devices = $site_devices['devices'];
                 if (($error_code = json_last_error()) !== JSON_ERROR_NONE) {
                     throw new KurogoConfigurationException("Problem decoding Custom Device Detection File. Error code returned was " . $error_code);
                 }
                 if (($device = $this->checkDevices($site_devices, $user_agent)) !== false) {
                     return $this->translateDevice($device);
                 }
                 break;
             case 'sqlite':
                 Kurogo::includePackage('db');
                 try {
                     $db = new db(array('DB_TYPE' => 'sqlite', 'DB_FILE' => $site_file));
                     $result = $db->query('SELECT * FROM userAgentPatterns WHERE version<=? ORDER BY patternorder,version DESC', array($this->version));
                 } catch (Exception $e) {
                     Kurogo::log(LOG_ALERT, "Error with internal device detection: " . $e->getMessage(), 'deviceDetection');
                     if (!in_array('sqlite', PDO::getAvailableDrivers())) {
                         die("SQLite PDO drivers not available. You should switch to external device detection by changing MOBI_SERVICE_USE_EXTERNAL to 1 in " . SITE_CONFIG_DIR . "/site.ini");
                     }
                     return false;
                 }
                 while ($row = $result->fetch()) {
                     if (preg_match("#" . $row['pattern'] . "#i", $user_agent)) {
                         return $row;
                     }
                 }
                 break;
             default:
                 throw new KurogoConfigurationException('Unknown format specified for Custom Device Detection File: ' . $site_file_format);
         }
     }
     if (!empty($master_file) && ($master_file = realpath_exists($master_file))) {
         $master_devices = json_decode(file_get_contents($master_file), true);
         $master_devices = $master_devices['devices'];
         if (function_exists('json_last_error') && ($error_code = json_last_error()) !== JSON_ERROR_NONE) {
             Kurogo::log(LOG_ALERT, "Error with JSON internal device detection: " . $error_code, 'deviceDetection');
             die("Problem decoding Device Detection Master File. Error code returned was " . $error_code);
         }
         if (($device = $this->checkDevices($master_devices, $user_agent)) !== false) {
             return $this->translateDevice($device);
         }
     }
     Kurogo::log(LOG_WARNING, "Could not find a match in the internal device detection database for: {$user_agent}", 'deviceDetection');
 }
开发者ID:nncsang,项目名称:Kurogo,代码行数:71,代码来源:DeviceClassifier.php


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