示例#1
0
 /**
  * Excecute web request
  * @method execute
  * @static
  */
 static function execute()
 {
     // Fixes for different platforms:
     if (isset($_SERVER['HTTP_X_REWRITE_URL'])) {
         // ISAPI 3.0
         $_SERVER['REQUEST_URI'] = $_SERVER['HTTP_X_REWRITE_URL'];
     }
     // Get the base URL
     $base_url = Q_Request::baseUrl();
     if (Q::$controller === 'Q_ActionController') {
         // we detected action.php in the URL, but
         // a misconfigured web server executed index.php instead
         return Q_ActionController::execute();
     }
     // Set the controller that is being used
     if (!isset(Q::$controller)) {
         Q::$controller = 'Q_WebController';
     }
     try {
         $slots = Q_Request::slotNames(false);
         $slots = $slots ? ' slots: (' . implode(',', $slots) . ') from' : '';
         $method = Q_Request::method();
         Q::log("{$method}{$slots} url: " . Q_Request::url(true), null, null, array('maxLength' => 10000));
         Q_Dispatcher::dispatch();
         $dispatchResult = Q_Dispatcher::result();
         if (!isset($dispatchResult)) {
             $dispatchResult = 'Ran dispatcher';
         }
         $uri = Q_Request::uri();
         $module = $uri->module;
         $action = $uri->action;
         if ($module and $action) {
             $slotNames = Q_Request::slotNames();
             $returned_slots = empty($slotNames) ? '' : implode(',', $slotNames);
             Q::log("~" . ceil(Q::milliseconds()) . 'ms+' . ceil(memory_get_peak_usage() / 1000) . 'kb.' . " {$dispatchResult} for {$module}/{$action}" . " ({$returned_slots})", null, null, array('maxLength' => 10000));
         } else {
             Q::log("~" . ceil(Q::milliseconds()) . 'ms+' . ceil(memory_get_peak_usage() / 1000) . 'kb.' . " {$dispatchResult} No route for " . $_SERVER['REQUEST_URI'], null, null, array('maxLength' => 10000));
         }
     } catch (Exception $exception) {
         /**
          * @event Q/exception
          * @param {Exception} exception
          */
         Q::event('Q/exception', compact('exception'));
     }
 }
示例#2
0
<?php

/**
 * Front controller for Q
 */
include dirname(__FILE__) . DIRECTORY_SEPARATOR . 'Q.inc.php';
//
// Handle the web request
//
Q_ActionController::execute();
示例#3
0
<?php

/**
 * Front controller for Q
 */
include dirname(__FILE__) . DIRECTORY_SEPARATOR . 'Q.inc.php';
//
// Handle batch request
//
$urls = Q::ifset($_REQUEST['urls'], array());
Q::log("Batch request for " . count($urls) . " urls");
header("Content-type: application/json");
Q_Response::$batch = true;
echo "[";
$original_request = $_REQUEST;
foreach ($urls as $i => $url) {
    $request = parse_url($url);
    parse_str($request['query'], $_REQUEST);
    $request = explode('?', $url);
    echo "[";
    if (!empty($request[0])) {
        Q_ActionController::execute($request[0]);
    }
    echo "]";
    if (isset($urls[$i + 1])) {
        echo ',';
    }
}
$_REQUEST = $original_request;
echo "]";
Q::log("~" . ceil(Q::milliseconds()) . 'ms+' . ceil(memory_get_peak_usage() / 1000) . 'kb.' . " batch complete.");