glob() статический публичный Метод

Glob with PCRE skip filter which defaults to skipping directories.
static public glob ( $pattern, $skip = '/\/$/' )
Пример #1
0
 static function find($uri_path_or_slug, $version = null, $strptime = null, $applyBodyFilters = true)
 {
     $version = self::parseVersion($version);
     $path = false;
     if (strpos($uri_path_or_slug, 'content/posts/') !== false) {
         $path = $uri_path_or_slug;
         if ($path[0] !== '/') {
             $path = gb::$site_dir . '/' . $path;
         }
     }
     if ($version === 'work') {
         # find path to raw content
         if ((!$path || !is_file($path)) && ($path = self::pathToWork($uri_path_or_slug, $strptime)) === null) {
             return false;
         }
         # parse pathspec, producing date and actual slug needed to look up cached
         try {
             self::parsePathspec(self::pathspecFromAbsPath($path), $date, $slug, $fnext);
         } catch (UnexpectedValueException $e) {
             return null;
         }
         # try to find a cached version
         $post = self::findByDateAndSlug($date, $slug);
         # load work
         return self::loadWork($path, $post, 'GBPost', $version, $slug, $applyBodyFilters);
     } elseif ($version === null) {
         if ($path) {
             self::parsePathspec(self::pathspecFromAbsPath($path), $date, $slug, $fnext);
             return self::findByDateAndSlug($date, $slug);
         }
         $path = self::pathToCached($uri_path_or_slug, $strptime);
         $data = @file_get_contents($path);
         if ($data === false && gb::$posts_fuzzy_lookup === true) {
             # exact match failed -- try fuzzy matching using glob and our knowledge of patterns
             list($prefix, $suffix) = self::cachenameFromURI($uri_path_or_slug, $strptime, true);
             $path = strtr($prefix, array('/' => '{/,*,.}', '-' => '{/,*,.}', '.' => '{/,*,.}')) . '*' . $suffix;
             $path = GBExposedContent::pathToCached('posts', $path . gb::$content_cache_fnext);
             # try any file with the cachename as prefix
             if ($path = gb::glob($path)) {
                 $data = @file_get_contents($path);
                 /*
                 Send premanent redirect if we found a valid article.
                  
                 Discussion: This is where things might go really wrong -- imagine we did find an 
                             article on fuzzy matching but it's _another_ article. Fail. But that
                             case is almost negligible since we only expand the time prefix, not
                             the slug.
                 */
                 global $gb_handle_request;
                 if ($data !== false && isset($gb_handle_request) && $gb_handle_request === true && ($post = unserialize($data)) && headers_sent() === false) {
                     header('HTTP/1.1 301 Moved Permanently');
                     header('Location: ' . $post->url());
                     exit('Moved to <a href="' . h($post->url()) . '">' . h($post->url()) . '</a>');
                 }
             }
         }
         return $data === false ? false : unserialize($data);
     }
     throw new Exception('arbitrary version retrieval not yet implemented');
 }