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


PHP Q_Request::filename方法代码示例

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


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

示例1: Q_dir

/**
 * Default Q/dir handler.
 * Just displays a simple directory listing,
 * and prevents further processing by returning true.
 */
function Q_dir()
{
    $filename = Q_Request::filename();
    // TODO: show directory listing
    echo Q::view('Q/dir.php', compact('filename'));
    return true;
}
开发者ID:dmitriz,项目名称:Platform,代码行数:12,代码来源:dir.php

示例2: Q_file

function Q_file($params)
{
    $filename = Q::ifset($params, 'filename', Q_Request::filename());
    $parts = explode('.', $filename);
    $ext = end($parts);
    $intercept = true;
    switch ($ext) {
        case 'png':
        case 'jpeg':
        case 'gif':
            header("Content-type: image/{$ext}");
            break;
        case 'jpg':
            header("Content-type: image/jpeg");
            break;
        case 'pdf':
            header("Content-type: application/{$ext}");
            break;
        case 'js':
            header("Content-type: application/javascript");
            break;
        case 'ogg':
        case 'mp3':
            header("Content-type: audio/{$ext}");
            break;
        case 'css':
            header("Content-type: text/css");
            break;
        case 'cur':
            header("Content-type: image/vnd.microsoft.icon .cur .ico");
            break;
        default:
            break;
    }
    header("HTTP/1.0 404 Not Found");
    readfile($filename);
    return true;
}
开发者ID:dmitriz,项目名称:Platform,代码行数:38,代码来源:file.php

示例3: dispatch

 /**
  * Dispatches a URI for internal processing.
  * Usually called by a front controller.
  * @method dispatch
  * @static
  * @param {mixed} [$uri=null] You can pass a custom URI to dispatch. Otherwise, Qbix will attempt
  *  to route the requested URL, if any.
  * @param {array} [$check=array('accessible')] Pass array() to skip checking whether the URI can be obtained
  *  as a result of routing some URL.
  * @return {boolean}
  * @throws {Q_Exception_MethodNotSupported}
  * @throws {Q_Exception_Recursion}
  * @throws {Q_Exception_DispatcherErrors}
  * @throws {Q_Exception_DispatcherForward}
  */
 static function dispatch($uri = null, $check = array('accessible'))
 {
     if (!is_array($check)) {
         $check = array('accessible');
     }
     if (isset($uri)) {
         if (in_array('accessible', $check)) {
             if (!Q_Uri::url($uri)) {
                 // We shouldn't dispatch to this URI
                 $uri = Q_Uri::from(array());
             }
         }
         self::$uri = Q_Uri::from($uri);
     } else {
         $request_uri = Q_Request::uri();
         self::$uri = clone $request_uri;
     }
     // if file or dir is requested, try to serve it
     $served = false;
     $skip = Q_Config::get('Q', 'dispatcherSkipFilename', false);
     $filename = $skip ? false : Q_Request::filename();
     if ($filename) {
         if (is_dir($filename)) {
             /**
              * @event Q/dir
              * @param {string} filename
              * @param {string} routed_uri
              * @return {boolean}
              */
             $served = Q::event("Q/dir", compact('filename', 'routed_uri'));
             $dir_was_served = true;
         } else {
             /**
              * @event Q/file
              * @param {string} filename
              * @param {string} routed_uri
              * @return {boolean}
              */
             $served = Q::event("Q/file", compact('filename', 'routed_uri'));
             $dir_was_served = false;
         }
     }
     // if response was served, then return
     if ($served) {
         self::result($dir_was_served ? "Dir served" : "File served");
         return true;
     }
     // This loop is for forwarding
     $max_forwards = Q_Config::get('Q', 'maxForwards', 10);
     for ($try = 0; $try < $max_forwards; ++$try) {
         // Make an array from the routed URI
         $routed_uri_array = array();
         if (self::$uri instanceof Q_Uri) {
             $routed_uri_array = self::$uri->toArray();
         }
         // If no module was found, then respond with noModule and return
         if (!isset(self::$uri->module)) {
             /**
              * @event Q/noModule
              * @param {array} $routed_uri_array
              */
             Q::event("Q/noModule", $routed_uri_array);
             // should echo things
             self::result("No module");
             return false;
         }
         $module = self::$uri->module;
         try {
             // Implement restricting of modules we are allowed to access
             $routed_modules = Q_Config::get('Q', 'routedModules', null);
             if (isset($routed_modules)) {
                 if (!in_array($module, $routed_modules)) {
                     /**
                      * @event Q/notFound
                      * @param {array} $routed_uri_array
                      */
                     Q::event('Q/notFound', $routed_uri_array);
                     // should echo things
                     self::result("Unknown module");
                     return false;
                 }
             } else {
                 if (!Q::realPath("handlers/{$module}")) {
                     Q::event('Q/notFound', $routed_uri_array);
                     // should echo things
//.........这里部分代码省略.........
开发者ID:dmitriz,项目名称:Platform,代码行数:101,代码来源:Dispatcher.php


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