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


PHP Gdn::request方法代码示例

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


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

示例1: sort

 /**
  * Set the sort order for data on an arbitrary database table.
  *
  * Expect post values TransientKey, Target (redirect URL), Table (database table name),
  * and TableID (an array of sort order => unique ID).
  *
  * @since 2.0.0
  * @access public
  */
 public function sort()
 {
     $this->permission('Garden.Settings.Manage');
     if (Gdn::request()->isAuthenticatedPostBack()) {
         $TableID = Gdn::request()->Post('TableID');
         if ($TableID) {
             $Rows = Gdn::request()->Post($TableID);
             if (is_array($Rows)) {
                 $Table = str_replace(array('Table', '`'), '', $TableID);
                 $ModelName = $Table . 'Model';
                 if (class_exists($ModelName)) {
                     $TableModel = new $ModelName();
                 } else {
                     $TableModel = new Gdn_Model($Table);
                 }
                 foreach ($Rows as $Sort => $ID) {
                     if (strpos($ID, '_') !== false) {
                         list(, $ID) = explode('_', $ID, 2);
                     }
                     if (!$ID) {
                         continue;
                     }
                     $TableModel->setField($ID, 'Sort', $Sort);
                 }
                 $this->setData('Result', true);
             }
         }
     }
     $this->render('Blank');
 }
开发者ID:sitexa,项目名称:vanilla,代码行数:39,代码来源:class.utilitycontroller.php

示例2: Gdn_Dispatcher_beforeDispatch_handler

 /**
  * Map an API request to a resource
  *
  * @since  0.1.0
  * @access public
  * @param  Gdn_Dispatcher $sender
  * @return void
  */
 public function Gdn_Dispatcher_beforeDispatch_handler($sender)
 {
     $path = APIEngine::getRequestURI();
     // Set the call and resource paths if they exist
     $call = val(0, $path);
     $resource = val(1, $path);
     // Abandon the dispatch if this isn't an API call with a valid resource
     if ($call != "api" || !$resource) {
         return;
     }
     APIEngine::setRequestHeaders();
     try {
         // Mark the dispatch with the API version
         $sender->API = c("API.Version", "Undefined");
         // Attempt dispatching the API request
         APIEngine::dispatchRequest();
     } catch (Exception $exception) {
         // As we can"t pass an object to WithControllerMethod(), we extract
         // the values we need manually before passing them on. The exception
         // message is Base64 encoded as WithControllerMethod() mangles
         // the formatting.
         $code = $exception->getCode();
         $message = base64_encode($exception->getMessage());
         $arguments = [$code, $message];
         // Call the Exception method if an exception is thrown
         Gdn::request()->withControllerMethod("API", "Exception", $arguments);
     }
 }
开发者ID:hcxiong,项目名称:vanilla-api,代码行数:36,代码来源:class.hooks.php

示例3: generateUrl

 /**
  * Generate a Gravatar image URL based on the provided email address.
  *
  * @link http://en.gravatar.com/site/implement/images/ Gravatar Image Requests
  * @param string $email Email address for the user, used to generate the avatar ID.
  * @param int $size Target image size.
  * @return string A formatted Gravatar image URL.
  */
 public static function generateUrl($email, $size = 80)
 {
     $avatarID = md5(strtolower($email));
     // Figure out our base URLs.  Gravatar doesn't support SVGs, so we're stuck with using Vanillicon v1.
     if (Gdn::request()->scheme() === 'https') {
         $baseUrl = 'https://secure.gravatar.com/avatar';
         $vanilliconBaseUrl = 'https://vanillicon.com';
     } else {
         $baseUrl = 'http://www.gravatar.com/avatar';
         $vanilliconBaseUrl = 'http://vanillicon.com';
     }
     if (c('Plugins.Gravatar.UseVanillicon', true)) {
         // Version 1 of Vanillicon only supports three sizes.  Figure out which one is best for this image.
         if ($size <= 50) {
             $vanilliconSize = 50;
         } elseif ($size <= 100) {
             $vanilliconSize = 100;
         } else {
             $vanilliconSize = 200;
         }
         $default = "{$vanilliconBaseUrl}/{$avatarID}_{$vanilliconSize}.png";
     } else {
         $configuredDefaultAvatar = c('Plugins.Gravatar.DefaultAvatar', c('Garden.DefaultAvatar'));
         if ($configuredDefaultAvatar) {
             $defaultParsed = Gdn_Upload::parse($configuredDefaultAvatar);
             $default = val('Url', $defaultParsed);
         }
     }
     if (empty($default)) {
         $default = asset($size <= 50 ? 'plugins/Gravatar/default.png' : 'plugins/Gravatar/default_250.png', true);
     }
     $query = ['default' => $default, 'rating' => c('Plugins.Gravatar.Rating', 'g'), 'size' => $size];
     return $baseUrl . "/{$avatarID}/?" . http_build_query($query);
 }
开发者ID:vanilla,项目名称:vanilla,代码行数:42,代码来源:default.php

示例4: getOpenID

 /**
  *
  *
  * @return LightOpenID
  */
 public function getOpenID()
 {
     $OpenID = new LightOpenID();
     if ($url = Gdn::request()->get('url')) {
         if (!filter_var($url, FILTER_VALIDATE_URL)) {
             throw new Gdn_UserException(sprintf(t('ValidateUrl'), 'OpenID'), 400);
         }
         // Don't allow open ID on a non-standard scheme.
         $scheme = parse_url($url, PHP_URL_SCHEME);
         if (!in_array($scheme, array('http', 'https'))) {
             throw new Gdn_UserException(sprintf(t('ValidateUrl'), 'OpenID'), 400);
         }
         // Don't allow open ID on a non-standard port.
         $port = parse_url($url, PHP_URL_PORT);
         if ($port && !in_array($port, array(80, 8080, 443))) {
             throw new Gdn_UserException(t('OpenID is not allowed on non-standard ports.'));
         }
         $OpenID->identity = $url;
     }
     $Url = url('/entry/connect/openid', true);
     $UrlParts = explode('?', $Url);
     parse_str(val(1, $UrlParts, ''), $Query);
     $Query = array_merge($Query, arrayTranslate($_GET, array('display', 'Target')));
     $OpenID->returnUrl = $UrlParts[0] . '?' . http_build_query($Query);
     $OpenID->required = array('contact/email', 'namePerson/first', 'namePerson/last', 'pref/language');
     $this->EventArguments['OpenID'] = $OpenID;
     $this->fireEvent('GetOpenID');
     return $OpenID;
 }
开发者ID:korelstar,项目名称:vanilla,代码行数:34,代码来源:class.openid.plugin.php

示例5: authenticateRequest

 /**
  * Token-based, per-request authentication
  *
  * This method takes the entire request string and turns the query into an
  * array of data. It then uses all the data to generate a signature the same
  * way it got generated on the client. If the server signature and client
  * token match, the client is considered legimate and the request is served.
  *
  * Based on initial work by Diego Zanella
  * @link http://careers.stackoverflow.com/diegozanella
  *
  * @since  0.1.0
  * @access public
  * @throws Exception
  * @return void
  * @static
  */
 public static function authenticateRequest()
 {
     $username = getIncomingValue("username");
     $email = getIncomingValue("email");
     if (!$username && !$email) {
         throw new Exception(t("API.Error.User.Missing"), 401);
     }
     if (!($userID = static::getUserID($username, $email))) {
         throw new Exception(t("API.Error.User.Invalid"), 401);
     }
     if (!($timestamp = getIncomingValue("timestamp"))) {
         throw new Exception(t("API.Error.Timestamp.Missing"), 401);
     }
     // Make sure that request is still valid
     if (abs($timestamp - time()) > c("API.Expiration")) {
         throw new Exception(t("API.Error.Timestamp.Invalid"), 401);
     }
     if (!($token = getIncomingValue("token"))) {
         throw new Exception(t("API.Error.Token.Missing"), 401);
     }
     $parsedUrl = parse_url(Gdn::request()->pathAndQuery());
     // Turn the request query data into an array to be used in the token
     // generation
     parse_str(val("query", $parsedUrl, []), $data);
     // Unset the values we don't want to include in the token generation
     unset($data["token"], $data["DeliveryType"], $data["DeliveryMethod"]);
     if ($token != ($signature = static::generateSignature($data))) {
         throw new Exception(t("API.Error.Token.Invalid"), 401);
     }
     // Now that the client has been thoroughly verified, start a session for
     // the duration of the request using the User ID specified earlier
     if ($token == $signature) {
         Gdn::session()->start(intval($userID), false);
     }
 }
开发者ID:hcxiong,项目名称:vanilla-api,代码行数:52,代码来源:class.apiauth.php

示例6: __construct

 function __construct()
 {
     $this->trustRoot = Gdn::request()->Scheme() . '://' . Gdn::request()->Host();
     $uri = rtrim(preg_replace('#((?<=\\?)|&)openid\\.[^&]+#', '', $_SERVER['REQUEST_URI']), '?');
     $this->returnUrl = $this->trustRoot . $uri;
     $this->data = $_POST + $_GET;
     # OPs may send data as POST or GET.
 }
开发者ID:karanjitsingh,项目名称:iecse-forum,代码行数:8,代码来源:class.lightopenid.php

示例7: request

 /**
  * Returns the Request part of the current url. ie. "/controller/action/" in
  * "http://localhost/garden/index.php?/controller/action/".
  *
  * @param boolean $WithWebRoot
  * @param boolean $WithDomain
  * @param boolean $RemoveSyndication
  * @return string
  */
 public static function request($WithWebRoot = false, $WithDomain = false, $RemoveSyndication = false)
 {
     $Result = Gdn::request()->path();
     if ($WithWebRoot) {
         $Result = self::webRoot($WithDomain) . '/' . $Result;
     }
     return $Result;
 }
开发者ID:sitexa,项目名称:vanilla,代码行数:17,代码来源:class.url.php

示例8: settingsController_render_before

    /**
     * Adds a "My Forums" menu option to the dashboard area.
     */
    public function settingsController_render_before($Sender)
    {
        // Have they visited their dashboard?
        if (strtolower($Sender->RequestMethod) != 'index') {
            $this->saveStep('Plugins.GettingStarted.Dashboard');
        }
        // Save the action if editing registration settings
        if (strcasecmp($Sender->RequestMethod, 'registration') == 0 && $Sender->Form->authenticatedPostBack() === true) {
            $this->saveStep('Plugins.GettingStarted.Registration');
        }
        // Save the action if they reviewed plugins
        if (strcasecmp($Sender->RequestMethod, 'plugins') == 0) {
            $this->saveStep('Plugins.GettingStarted.Plugins');
        }
        // Save the action if they reviewed plugins
        if (strcasecmp($Sender->RequestMethod, 'managecategories') == 0) {
            $this->saveStep('Plugins.GettingStarted.Categories');
        }
        // Add messages & their css on dashboard
        if (strcasecmp($Sender->RequestMethod, 'index') == 0) {
            $Sender->addCssFile('getting-started.css', 'plugins/GettingStarted');
            $Session = Gdn::session();
            $WelcomeMessage = '<div class="GettingStarted">' . anchor('×', '/dashboard/plugin/dismissgettingstarted/' . $Session->transientKey(), 'Dismiss') . "<h1>" . t("Here's how to get started:") . "</h1>" . '<ul>
      <li class="One' . (c('Plugins.GettingStarted.Dashboard', '0') == '1' ? ' Done' : '') . '">
	 <strong>' . anchor(t('Welcome to your Dashboard'), 'settings') . '</strong>
         <p>' . t('This is the administrative dashboard for your new community. Check out the configuration options to the left: from here you can configure how your community works. <b>Only users in the "Administrator" role can see this part of your community.</b>') . '</p>
      </li>
      <li class="Two' . (c('Plugins.GettingStarted.Discussions', '0') == '1' ? ' Done' : '') . '">
	 <strong>' . anchor(t("Where is your Community Forum?"), '/') . '</strong>
         <p>' . t('Access your community forum by clicking the "Visit Site" link on the top-left of this page, or by ') . anchor(t('clicking here'), '/') . t('. The community forum is what all of your users &amp; customers will see when they visit ') . anchor(Gdn::request()->Url('/', true), Gdn::request()->Url('/', true)) . '.</p>
      </li>
      <li class="Three' . (c('Plugins.GettingStarted.Categories', '0') == '1' ? ' Done' : '') . '">
         <strong>' . anchor(t('Organize your Categories'), 'vanilla/settings/managecategories') . '</strong>
         <p>' . t('Discussion categories are used to help your users organize their discussions in a way that is meaningful for your community.') . '</p>
      </li>
      <li class="Four' . (c('Plugins.GettingStarted.Profile', '0') == '1' ? ' Done' : '') . '">
         <strong>' . anchor(t('Customize your Public Profile'), 'profile') . '</strong>
         <p>' . t('Everyone who signs up for your community gets a public profile page where they can upload a picture of themselves, manage their profile settings, and track cool things going on in the community. You should ') . anchor(t('customize your profile now'), 'profile') . '.</p>
      </li>
      <li class="Five' . (c('Plugins.GettingStarted.Discussion', '0') == '1' ? ' Done' : '') . '">
         <strong>' . anchor(t('Start your First Discussion'), 'post/discussion') . '</strong>
	 <p>' . t('Get the ball rolling in your community by ') . anchor(t('starting your first discussion'), 'post/discussion') . t(' now.') . '</p>
      </li>
      <li class="Six' . (c('Plugins.GettingStarted.Plugins', '0') == '1' ? ' Done' : '') . '">
         <strong>' . anchor(t('Manage your Plugins'), 'settings/plugins') . '</strong>
         <p>' . t('Change the way your community works with plugins. We\'ve bundled popular plugins with the software, and there are more available online.') . '</p>
      </li>
   </ul>
</div>';
            $Sender->addAsset('Messages', $WelcomeMessage, 'WelcomeMessage');
        }
    }
开发者ID:karanjitsingh,项目名称:iecse-forum,代码行数:55,代码来源:default.php

示例9: profileController_afterAddSideMenu_handler

 /**
  *
  *
  * @param $Sender
  * @param $Args
  */
 public function profileController_afterAddSideMenu_handler($Sender, $Args)
 {
     if (!$Sender->User->Photo) {
         $Email = val('Email', $Sender->User);
         $Protocol = Gdn::request()->scheme() == 'https' ? 'https://secure.' : 'http://www.';
         $Url = $Protocol . 'gravatar.com/avatar.php?' . 'gravatar_id=' . md5(strtolower($Email)) . '&amp;size=' . c('Garden.Profile.MaxWidth', 200);
         if (c('Plugins.Gravatar.UseVanillicon', true)) {
             $Url .= '&default=' . urlencode(Gdn::request()->scheme() . '://vanillicon.com/' . md5($Email) . '_200.png');
         } else {
             $Url .= '&default=' . urlencode(asset(c('Plugins.Gravatar.DefaultAvatar', c('Garden.DefaultAvatar', 'plugins/Gravatar/default_250.png')), true));
         }
         $Sender->User->Photo = $Url;
     }
 }
开发者ID:caidongyun,项目名称:vanilla,代码行数:20,代码来源:default.php

示例10: isSpam

 /**
  * Check whether or not the record is spam.
  * @param string $RecordType By default, this should be one of the following:
  *  - Comment: A comment.
  *  - Discussion: A discussion.
  *  - User: A user registration.
  * @param array $Data The record data.
  * @param array $Options Options for fine-tuning this method call.
  *  - Log: Log the record if it is found to be spam.
  */
 public static function isSpam($RecordType, $Data, $Options = array())
 {
     if (self::$Disabled) {
         return false;
     }
     // Set some information about the user in the data.
     if ($RecordType == 'Registration') {
         touchValue('Username', $Data, $Data['Name']);
     } else {
         touchValue('InsertUserID', $Data, Gdn::session()->UserID);
         $User = Gdn::userModel()->getID(val('InsertUserID', $Data), DATASET_TYPE_ARRAY);
         if ($User) {
             if (val('Verified', $User)) {
                 // The user has been verified and isn't a spammer.
                 return false;
             }
             touchValue('Username', $Data, $User['Name']);
             touchValue('Email', $Data, $User['Email']);
             touchValue('IPAddress', $Data, $User['LastIPAddress']);
         }
     }
     if (!isset($Data['Body']) && isset($Data['Story'])) {
         $Data['Body'] = $Data['Story'];
     }
     touchValue('IPAddress', $Data, Gdn::request()->ipAddress());
     $Sp = self::_Instance();
     $Sp->EventArguments['RecordType'] = $RecordType;
     $Sp->EventArguments['Data'] =& $Data;
     $Sp->EventArguments['Options'] =& $Options;
     $Sp->EventArguments['IsSpam'] = false;
     $Sp->fireEvent('CheckSpam');
     $Spam = $Sp->EventArguments['IsSpam'];
     // Log the spam entry.
     if ($Spam && val('Log', $Options, true)) {
         $LogOptions = array();
         switch ($RecordType) {
             case 'Registration':
                 $LogOptions['GroupBy'] = array('RecordIPAddress');
                 break;
             case 'Comment':
             case 'Discussion':
             case 'Activity':
             case 'ActivityComment':
                 $LogOptions['GroupBy'] = array('RecordID');
                 break;
         }
         LogModel::insert('Spam', $RecordType, $Data, $LogOptions);
     }
     return $Spam;
 }
开发者ID:karanjitsingh,项目名称:iecse-forum,代码行数:60,代码来源:class.spammodel.php

示例11: execute

 /**
  *
  *
  * @return string
  */
 public function execute()
 {
     $SliceArgs = func_get_args();
     switch (count($SliceArgs)) {
         case 1:
             //die('slice request: '.$SliceArgs[0]);
             $Request = Gdn::request()->create()->fromEnvironment()->withURI($SliceArgs[0])->withDeliveryType(DELIVERY_TYPE_VIEW);
             ob_start();
             $this->Dispatcher->dispatch($Request, false);
             return ob_get_clean();
             break;
         case 2:
             break;
     }
 }
开发者ID:sitexa,项目名称:vanilla,代码行数:20,代码来源:class.slice.php

示例12: __construct

 /**
  * FlatCategoryModule constructor.
  *
  * @param string|Gdn_Controller $sender
  * @param bool|string $applicationFolder
  */
 public function __construct($sender = '', $applicationFolder = false)
 {
     parent::__construct($sender, $applicationFolder);
     $this->categoryModel = new CategoryModel();
     $this->limit = $this::DEFAULT_LIMIT;
     // If this is coming from the module controller, populate some properties by query parameters.
     if ($sender instanceof ModuleController) {
         $paramWhitelist = ['categoryID' => Gdn::request()->get('categoryID', Gdn::request()->get('CategoryID')), 'filter' => Gdn::request()->get('filter', Gdn::request()->get('Filter')), 'limit' => Gdn::request()->get('limit', Gdn::request()->get('Limit'))];
         foreach ($paramWhitelist as $property => $value) {
             if ($value) {
                 $this->{$property} = $value;
             }
         }
     }
 }
开发者ID:vanilla,项目名称:vanilla,代码行数:21,代码来源:class.flatcategorymodule.php

示例13: setToggle

 /**
  * Set the preference in the user's session.
  */
 public function setToggle()
 {
     $Session = Gdn::session();
     if (!$Session->isValid()) {
         return;
     }
     $ShowAllCategories = GetIncomingValue('ShowAllCategories', '');
     if ($ShowAllCategories != '') {
         $ShowAllCategories = $ShowAllCategories == 'true' ? true : false;
         $ShowAllCategoriesPref = $Session->GetPreference('ShowAllCategories');
         if ($ShowAllCategories != $ShowAllCategoriesPref) {
             $Session->setPreference('ShowAllCategories', $ShowAllCategories);
         }
         redirect('/' . ltrim(Gdn::request()->Path(), '/'));
     }
 }
开发者ID:karanjitsingh,项目名称:iecse-forum,代码行数:19,代码来源:class.categoryfollowtogglemodule.php

示例14: settingsController_moduleSort_create

 public function settingsController_moduleSort_create($sender, $reset = false)
 {
     $sender->permission('Garden.Settings.Manage');
     $sender->addSideMenu('settings/modulesort');
     $sender->addJsFile('html.sortable.min.js', 'plugins/modulesort');
     $sender->addJsFile('modulesort.js', 'plugins/modulesort');
     if (Gdn::request()->isAuthenticatedPostBack()) {
         if ($reset) {
             removeFromConfig('Modules');
             $sender->jsonTarget('', '', 'Refresh');
         } elseif ($sort = json_decode(Gdn::request()->post('Modules'), true)) {
             saveToConfig('Modules', $sort);
         }
     }
     $sender->title(t('Module Sort Order'));
     $sender->render('modulesort', '', 'plugins/modulesort');
 }
开发者ID:bleistivt,项目名称:modulesort,代码行数:17,代码来源:class.modulesort.plugin.php

示例15: slice

 /**
  *
  *
  * @param $SliceName
  * @param array $Arguments
  * @return Gdn_Slice
  */
 public function slice($SliceName, $Arguments = array())
 {
     $CurrentPath = Gdn::request()->path();
     $ExplodedPath = explode('/', $CurrentPath);
     switch ($this instanceof Gdn_IPlugin) {
         case true:
             $ReplacementIndex = 2;
             break;
         case false:
             $ReplacementIndex = 1;
             break;
     }
     if ($ExplodedPath[0] == strtolower(Gdn::dispatcher()->application()) && $ExplodedPath[1] == strtolower(Gdn::dispatcher()->controller())) {
         $ReplacementIndex++;
     }
     $ExplodedPath[$ReplacementIndex] = $SliceName;
     $SlicePath = implode('/', $ExplodedPath);
     return Gdn::Slice($SlicePath);
 }
开发者ID:sitexa,项目名称:vanilla,代码行数:26,代码来源:class.sliceprovider.php


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