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


PHP Q_Request::method方法代码示例

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


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

示例1: Streams_related_validate

function Streams_related_validate()
{
    switch (Q_Request::method()) {
        case 'POST':
            $required = array('toPublisherId', 'toStreamName', 'type', 'fromPublisherId', 'fromStreamName');
            break;
        case 'DELETE':
            $required = array('toPublisherId', 'toStreamName', 'type', 'fromPublisherId', 'fromStreamName');
            break;
        case 'PUT':
            $required = array('toPublisherId', 'toStreamName', 'type', 'fromPublisherId', 'fromStreamName', 'weight');
            if (isset($_REQUEST['adjustWeights'])) {
                if (!is_numeric($_REQUEST['adjustWeights'])) {
                    Q_Response::addError(new Q_Exception_WrongValue(array('field' => 'adjustWeights', 'range' => 'a numeric value'), 'adjustWeights'));
                }
            }
            break;
        case 'GET':
            $required = array();
            break;
    }
    foreach ($required as $r) {
        if (!isset($_REQUEST[$r])) {
            Q_Response::addError(new Q_Exception_RequiredField(array('field' => $r)));
        }
    }
}
开发者ID:dmitriz,项目名称:Platform,代码行数:27,代码来源:validate.php

示例2: Streams_interest_validate

function Streams_interest_validate($params)
{
    // Protect against CSRF attacks:
    if (Q_Request::method() !== 'GET') {
        Q_Valid::nonce(true);
    }
}
开发者ID:dmitriz,项目名称:Platform,代码行数:7,代码来源:validate.php

示例3: Streams_invite_validate

function Streams_invite_validate()
{
    if (Q_Request::method() === 'PUT') {
        return;
    }
    if (Q_Request::method() !== 'GET') {
        Q_Valid::nonce(true);
    }
    $fields = array('publisherId', 'streamName');
    if (Q_Request::method() === 'POST') {
        if (Q_Valid::requireFields($fields)) {
            return;
        }
        foreach ($fields as $f) {
            if (strlen(trim($_REQUEST[$f])) === 0) {
                Q_Response::addError(new Q_Exception("{$f} can't be empty", $f));
            }
        }
    }
    if (isset($_REQUEST['fullName'])) {
        $length_min = Q_Config::get('Streams', 'inputs', 'fullName', 'lengthMin', 5);
        $length_max = Q_Config::get('Streams', 'inputs', 'fullName', 'lengthMax', 30);
        if (strlen($_REQUEST['fullName']) < $length_min) {
            throw new Q_Exception("A user's full name can't be that short.", 'fullName');
        }
        if (strlen($_REQUEST['fullName']) > $length_max) {
            throw new Q_Exception("A user's full name can't be that long.", 'fullName');
        }
    }
}
开发者ID:dmitriz,项目名称:Platform,代码行数:30,代码来源:validate.php

示例4: Q_notice_response_data

function Q_notice_response_data()
{
    $method = Q_Request::method();
    if ($method !== 'DELETE') {
        throw new Q_Exception_MethodNotSupported($method);
    }
    return Q::$cache['notice_deleted'];
}
开发者ID:dmitriz,项目名称:Platform,代码行数:8,代码来源:data.php

示例5: Streams_stream_validate

function Streams_stream_validate($params)
{
    // Protect against CSRF attacks:
    if (Q_Request::method() !== 'GET') {
        Q_Valid::nonce(true);
    }
    $type = Streams::requestedType();
    if ($type && Q::canHandle("Streams/validate/{$type}")) {
        return Q::event("Streams/validate/{$type}", $params);
    }
}
开发者ID:dmitriz,项目名称:Platform,代码行数:11,代码来源:validate.php

示例6: Users_login_validate

function Users_login_validate()
{
    if (Q_Request::method() === 'GET') {
        return;
    }
    Q_Valid::nonce(true);
    foreach (array('identifier', 'passphrase') as $field) {
        if (!isset($_REQUEST[$field])) {
            throw new Q_Exception("{$field} is missing", array($field));
        }
    }
}
开发者ID:dmitriz,项目名称:Platform,代码行数:12,代码来源:validate.php

示例7: Q_nonce_response_data

function Q_nonce_response_data()
{
    $method = Q_Request::method();
    if ($method !== 'POST') {
        throw new Q_Exception_MethodNotSupported($method);
    }
    // we could technically return the nonce in the response,
    // because other sites can't read the response from a cross-domain post
    // but we aren't going to do that because we already set the cookie
    // so just return true
    return true;
}
开发者ID:AndreyTepaykin,项目名称:Platform,代码行数:12,代码来源:data.php

示例8: Users_activate_response_content

function Users_activate_response_content()
{
    $email = $mobile = $type = $user = $emailAddress = $mobileNumber = null;
    extract(Users::$cache, EXTR_IF_EXISTS);
    $complete = false;
    if ($user and !empty($user->passphraseHash)) {
        if ($emailAddress and $user->emailAddress == $emailAddress) {
            $complete = true;
        } else {
            if ($mobileNumber and $user->mobileNumber = $mobileNumber) {
                $complete = true;
            }
        }
    }
    if (!empty(Users::$cache['success'])) {
        $app = Q_Config::expect('Q', 'app');
        $successUrl = Q_Config::get('Users', 'uris', "{$app}/successUrl", "{$app}/home");
        if (Q_Request::method() === 'POST') {
            if ($qs = $_SERVER['QUERY_STRING']) {
                $qs = "&{$qs}";
            }
            Q_Response::redirect(Q_Config::get('Users', 'uris', "{$app}/afterActivate", $successUrl) . '?Q.fromSuccess=Users/activate' . $qs);
            return true;
        }
    }
    $view = Q_Config::get('Users', 'activateView', 'Users/content/activate.php');
    $t = $email ? 'e' : 'm';
    $identifier = $email ? $emailAddress : $mobileNumber;
    // Generate 10 passphrase suggestions
    $suggestions = array();
    $arr = (include USERS_PLUGIN_FILES_DIR . DS . 'Users' . DS . 'passphrases.php');
    for ($i = 0; $i < 10; ++$i) {
        $pre1 = $arr['pre'][mt_rand(0, count($arr['pre']) - 1)];
        $noun1 = $arr['nouns'][mt_rand(0, count($arr['nouns']) - 1)];
        $verb = $arr['verbs'][mt_rand(0, count($arr['verbs']) - 1)];
        $pre2 = $arr['pre'][mt_rand(0, count($arr['pre']) - 1)];
        $adj = $arr['adjectives'][mt_rand(0, count($arr['adjectives']) - 1)];
        $noun2 = $arr['nouns'][mt_rand(0, count($arr['nouns']) - 1)];
        //$suggestions[] = strtolower("$pre1 $noun1 $verb $pre2 $adj $noun2");
        $suggestions[] = strtolower("{$pre1} {$noun1} {$verb} {$pre2} {$noun2}");
    }
    $verb_ue = urlencode($arr['verbs'][mt_rand() % count($arr['verbs'])]);
    $noun_ue = urlencode($arr['nouns'][mt_rand() % count($arr['nouns'])]);
    $code = Q::ifset($_REQUEST['code']);
    Q_Response::addScriptLine("Q.onReady.set(function () {\n\t\tif (Q.Notice) {\n\t\t\tQ.Notice.hide('Users/email');\n\t\t\tQ.Notice.hide('Users/mobile');\n\t\t}\n\t});");
    // shh! not while I'm activating! lol
    return Q::view($view, compact('identifier', 'type', 'user', 'code', 'suggestions', 'verb_ue', 'noun_ue', 't', 'app', 'home', 'complete'));
}
开发者ID:AndreyTepaykin,项目名称:Platform,代码行数:48,代码来源:content.php

示例9: execute

 /**
  * 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'));
     }
 }
开发者ID:dmitriz,项目名称:Platform,代码行数:51,代码来源:WebController.php

示例10: Streams_basic_validate

function Streams_basic_validate()
{
    Q_Valid::nonce(true);
    if (Q_Request::method() !== 'POST') {
        return;
    }
    $fields = array('firstName' => 'First name', 'lastName' => 'Last name', 'gender' => 'Gender', 'birthday_month' => 'Month', 'birthday_day' => 'Day', 'birthday_year' => 'Year');
    if (isset($_REQUEST['fullName'])) {
        $length_min = Q_Config::get('Streams', 'inputs', 'fullName', 'lengthMin', 5);
        $length_max = Q_Config::get('Streams', 'inputs', 'fullName', 'lengthMax', 30);
        if (strlen($_REQUEST['fullName']) < $length_min) {
            Q_Response::addError(new Q_Exception("Your full name can't be that short.", 'fullName'));
        }
        if (strlen($_REQUEST['fullName']) > $length_max) {
            Q_Response::addError(new Q_Exception("Your full name can't be that long.", 'fullName'));
        }
    }
    if (Q_Response::getErrors()) {
        return;
    }
    if (!empty($_REQUEST['birthday_month']) or !empty($_REQUEST['birthday_day']) or !empty($_REQUEST['birthday_year'])) {
        foreach (array('birthday_month', 'birthday_day', 'birthday_year') as $field) {
            if (empty($_REQUEST[$field]) or !trim($_REQUEST[$field])) {
                throw new Q_Exception_RequiredField(compact('field'), $field);
            }
        }
        if (!checkdate($_REQUEST['birthday_month'], $_REQUEST['birthday_day'], $_REQUEST['birthday_year'])) {
            Q_Response::addError(new Q_Exception("Not a valid date", "birthday_day"));
        }
        if ($_REQUEST['birthday_year'] > date('Y') - 13) {
            // compliance with COPPA
            Q_Response::addError(new Q_Exception("You're still a kid.", "birthday_year"));
        }
        if ($_REQUEST['birthday_year'] < date('Y') - 100) {
            Q_Response::addError(new Q_Exception("A world record? Really?", "birthday_year"));
        }
    }
    if (!empty($_REQUEST['gender'])) {
        if (!in_array($_REQUEST['gender'], array('male', 'female'))) {
            Q_Response::addError(new Q_Exception("Please enter male or female", "gender"));
        }
    }
}
开发者ID:dmitriz,项目名称:Platform,代码行数:43,代码来源:validate.php

示例11: Places_zipcode_response

function Places_zipcode_response()
{
    if (Q_Request::method() !== 'GET') {
        return null;
    }
    $zip = array();
    if (isset($_REQUEST['zipcodes'])) {
        $zip = $_REQUEST['zipcodes'];
    } else {
        if (isset($_REQUEST['zipcode'])) {
            $zip = $_REQUEST['zipcode'];
        }
    }
    if (is_string($zip)) {
        $zip = explode(',', $zip);
    }
    $zipcodes = Places_Zipcode::select('*')->where(array('zipcode' => $zip))->fetchDbRows();
    Q_Response::setSlot('zipcodes', $zipcodes);
}
开发者ID:dmitriz,项目名称:Platform,代码行数:19,代码来源:response.php

示例12: execute

 /**
  * The standard action front controller
  * @method execute
  * @static
  * @throws {Q_Exception_BadUrl}
  * @throws {Q_Exception}
  * @throws {Q_Exception_MissingConfig}
  */
 static function execute($url = null)
 {
     // Fixes for different platforms:
     if (isset($_SERVER['HTTP_X_REWRITE_URL'])) {
         // ISAPI 3.0
         $_SERVER['REQUEST_URI'] = $_SERVER['HTTP_X_REWRITE_URL'];
     }
     // Set the controller that is being used
     if (!isset(Q::$controller)) {
         Q::$controller = 'Q_ActionController';
     }
     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));
         $tail = Q_Request::tail($url);
         if (!isset($tail)) {
             // Bad url was requested somehow
             $url = Q_Request::url(true);
             $base_url = Q_Request::baseUrl(true);
             throw new Q_Exception_BadUrl(compact('base_url', 'url'));
         }
         $parts = explode('/', $tail);
         $parts_len = count($parts);
         if ($parts_len >= 1) {
             $module = $parts[0];
         }
         if ($parts_len >= 2) {
             $action = $parts[1];
         }
         if (empty($module) or empty($action)) {
             throw new Q_Exception("Not implemented");
         }
         // Make sure the 'Q'/'web' config fields are set,
         // otherwise URLs will be formed pointing to the wrong
         // controller script.
         $ar = Q_Config::get('Q', 'web', 'appRootUrl', null);
         if (!isset($ar)) {
             throw new Q_Exception_MissingConfig(array('fieldpath' => 'Q/web/appRootUrl'));
         }
         // Dispatch the request
         $uri = Q_Uri::from(compact('module', 'action'));
         Q_Dispatcher::dispatch($uri);
         $dispatchResult = Q_Dispatcher::result();
         if (!isset($dispatchResult)) {
             $dispatchResult = 'Ran dispatcher';
         }
         if ($module and $action) {
             $slotNames = Q_Request::slotNames();
             $requestedSlots = empty($slotNames) ? '' : implode(',', $slotNames);
             Q::log("~" . ceil(Q::milliseconds()) . 'ms+' . ceil(memory_get_peak_usage() / 1000) . 'kb.' . " {$dispatchResult} for {$module}/{$action}" . " ({$requestedSlots})");
         } else {
             Q::log("~" . ceil(Q::milliseconds()) . 'ms+' . ceil(memory_get_peak_usage() / 1000) . 'kb.' . " No route for " . $_SERVER['REQUEST_URI']);
         }
     } catch (Exception $exception) {
         /**
          * @event Q/exception
          * @param {Exception} exception
          */
         Q::event('Q/exception', compact('exception'));
     }
 }
开发者ID:dmitriz,项目名称:Platform,代码行数:71,代码来源:ActionController.php

示例13: Users_activate_objects_mobile

function Users_activate_objects_mobile($mobileNumber, &$mobile)
{
    Q_Response::removeNotice('Users/activate/objects');
    $mobile = new Users_Mobile();
    if (!Q_Valid::phone($mobileNumber, $normalized)) {
        return;
    }
    $mobile->number = $normalized;
    if (!$mobile->retrieve()) {
        throw new Q_Exception_MissingRow(array('table' => 'mobile phone', 'criteria' => "number {$normalized}"));
    }
    $user = Users::loggedInUser();
    if ($user) {
        if ($user->id != $mobile->userId) {
            throw new Q_Exception("You are logged in as a different user. Please log out and click the link again.");
        }
    } else {
        $user = new Users_User();
        $user->id = $mobile->userId;
        if (!$user->retrieve()) {
            throw new Q_Exception_MissingRow(array('table' => 'user', 'criteria' => 'id = ' . $user->id));
        }
    }
    if ($mobile->activationCode != $_REQUEST['code']) {
        throw new Q_Exception("The activation code does not match. Did you get a newer message?", 'code');
    }
    $timestamp = Users_Mobile::db()->getCurrentTimestamp();
    if ($timestamp > Users_Mobile::db()->fromDateTime($mobile->activationCodeExpires)) {
        throw new Q_Exception("Activation code expired");
    }
    if (Q_Request::method() !== 'POST' and empty($_REQUEST['p']) and isset($user->mobileNumber) and $user->mobileNumber == $mobile->number) {
        Q_Response::setNotice('Users/activate/objects', "{$normalized} has already been activated for {$user->username}", true);
        return $user;
    }
    return $user;
}
开发者ID:dmitriz,项目名称:Platform,代码行数:36,代码来源:objects.php

示例14: dispatch


//.........这里部分代码省略.........
                 Q::event('Q/validate', $routed_uri_array);
                 if (!isset(self::$skip['Q/errors'])) {
                     // Check if any errors accumulated
                     if (Q_Response::getErrors()) {
                         // There were validation errors -- render a response
                         self::result('Validation errors');
                         self::errors(null, $module, null);
                         return false;
                     }
                 }
             }
             // Time to instantiate some app objects from the request
             if (!isset(self::$skip['Q/objects'])) {
                 /**
                  * @event Q/objects
                  * @param {array} $routed_uri_array
                  */
                 Q::event('Q/objects', $routed_uri_array, true);
             }
             // We might want to reroute the request
             if (!isset(self::$skip['Q/reroute'])) {
                 /**
                  * @event Q/reroute
                  * @param {array} $routed_uri_array
                  * @return {boolean} whether to stop the dispatch
                  */
                 $stop_dispatch = Q::event('Q/reroute', $routed_uri_array, true);
                 if ($stop_dispatch) {
                     self::result("Stopped dispatch");
                     return false;
                 }
             }
             // Make some changes to server state, possibly
             $method = Q_Request::method();
             if ($method != 'GET') {
                 $methods = Q_Config::get('Q', 'methods', array('POST', 'PUT', 'DELETE', 'OPTIONS', 'HEAD'));
                 if (!in_array($method, $methods)) {
                     throw new Q_Exception_MethodNotSupported(compact('method'));
                 }
                 $method_event = 'Q/' . strtolower($method);
                 if (!isset(self::$skip['Q/method']) and !isset(self::$skip[$method_event])) {
                     if (!Q::canHandle($method_event)) {
                         throw new Q_Exception_MethodNotSupported(compact('method'));
                     }
                     Q::event($method_event);
                 }
             }
             // You can calculate some analytics here, and store them somewhere
             if (!isset(self::$skip['Q/analytics'])) {
                 /**
                  * @event Q/analytics
                  * @param {array} $routed_uri_array
                  */
                 Q::event('Q/analytics', $routed_uri_array, true);
             }
             if (!isset(self::$skip['Q/errors'])) {
                 // Check if any errors accumulated
                 if (Q_Response::getErrors()) {
                     // There were processing errors -- render a response
                     self::result('Processing errors');
                     self::errors(null, $module, null);
                     return false;
                 }
             }
             // When handling all further events, you should probably
             // refrain from changing server state, and only do reading.
开发者ID:dmitriz,项目名称:Platform,代码行数:67,代码来源:Dispatcher.php

示例15: Streams_stream_response

/**
 * Used to get a stream
 *
 * @param {array} $_REQUEST 
 * @param {string} $_REQUEST.publisherId Required
 * @param {string} $_REQUEST.streamName Required streamName or name
 * @param {integer} [$_REQUEST.messages] optionally pass a number here to fetch latest messages
 * @param {integer} [$_REQUEST.participants] optionally pass a number here to fetch participants
 * @return {void}
 */
function Streams_stream_response()
{
    // this handler is only for GET requests
    if (Q_Request::method() !== 'GET') {
        return null;
    }
    $publisherId = Streams::requestedPublisherId(true);
    $name = Streams::requestedName(true);
    $fields = Streams::requestedFields();
    $user = Users::loggedInUser();
    $userId = $user ? $user->id : "";
    if (isset(Streams::$cache['stream'])) {
        $stream = Streams::$cache['stream'];
    } else {
        $streams = Streams::fetch($userId, $publisherId, $name, $fields ? $fields : '*', array('withParticipant' => true));
        if (Q_Request::slotName('streams')) {
            Q_Response::setSlot('streams', Db::exportArray($streams));
        }
        if (empty($streams)) {
            if (Q_Request::slotName('stream')) {
                Q_Response::setSlot('stream', null);
                Q_Response::setSlot('messages', null);
                Q_Response::setSlot('participants', null);
                Q_Response::setSlot('related', null);
                Q_Response::setSlot('relatedTo', null);
            } else {
                if (!Q_Request::slotName('streams')) {
                    $app = Q_Config::expect('Q', 'app');
                    Q_Dispatcher::forward("{$app}/notFound");
                }
            }
            return null;
        }
        // The rest of the data is joined only on the first stream
        Streams::$cache['stream'] = $stream = reset($streams);
    }
    if (empty($stream)) {
        if (Q_Request::slotName('stream')) {
            Q_Response::setSlot('stream', null);
        }
        return null;
    }
    if ($userId && !empty($_REQUEST['join'])) {
        $stream->join();
        // NOTE: one of the rare times we may change state in a response handler
    }
    if (Q_Request::slotName('stream')) {
        Q_Response::setSlot('stream', $stream->exportArray());
    }
    if (!empty($_REQUEST['messages'])) {
        $max = -1;
        $limit = $_REQUEST['messages'];
        $messages = false;
        $type = isset($_REQUEST['messageType']) ? $_REQUEST['messageType'] : null;
        if ($stream->testReadLevel('messages')) {
            $messages = Db::exportArray($stream->getMessages(compact('type', 'max', 'limit')));
        }
        Q_Response::setSlot('messages', $messages);
    }
    if (!empty($_REQUEST['participants'])) {
        $limit = $_REQUEST['participants'];
        $participants = false;
        if ($stream->testReadLevel('participants')) {
            $participants = Db::exportArray($stream->getParticipants(compact('limit', 'offset')));
        }
        Q_Response::setSlot('participants', $participants);
    }
}
开发者ID:AndreyTepaykin,项目名称:Platform,代码行数:78,代码来源:response.php


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