本文整理汇总了PHP中Gdn::Request方法的典型用法代码示例。如果您正苦于以下问题:PHP Gdn::Request方法的具体用法?PHP Gdn::Request怎么用?PHP Gdn::Request使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Gdn
的用法示例。
在下文中一共展示了Gdn::Request方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: StatsDashboard
/**
* Override the default index method of the settings controller in the
* dashboard application to render new statistics.
*/
public function StatsDashboard($Sender)
{
$StatsUrl = $this->AnalyticsServer;
if (!StringBeginsWith($StatsUrl, 'http:') && !StringBeginsWith($StatsUrl, 'https:')) {
$StatsUrl = Gdn::Request()->Scheme() . "://{$StatsUrl}";
}
// Tell the page where to find the Vanilla Analytics provider
$Sender->AddDefinition('VanillaStatsUrl', $StatsUrl);
$Sender->SetData('VanillaStatsUrl', $StatsUrl);
// Load javascript & css, check permissions, and load side menu for this page.
$Sender->AddJsFile('settings.js');
$Sender->Title(T('Dashboard'));
$Sender->RequiredAdminPermissions[] = 'Garden.Settings.Manage';
$Sender->RequiredAdminPermissions[] = 'Garden.Users.Add';
$Sender->RequiredAdminPermissions[] = 'Garden.Users.Edit';
$Sender->RequiredAdminPermissions[] = 'Garden.Users.Delete';
$Sender->RequiredAdminPermissions[] = 'Garden.Users.Approve';
$Sender->FireEvent('DefineAdminPermissions');
$Sender->Permission($Sender->RequiredAdminPermissions, '', FALSE);
$Sender->AddSideMenu('dashboard/settings');
if (!Gdn_Statistics::CheckIsEnabled() && Gdn_Statistics::CheckIsLocalhost()) {
$Sender->Render('dashboardlocalhost', '', 'plugins/VanillaStats');
} else {
$Sender->AddJsFile('plugins/VanillaStats/js/vanillastats.js');
$Sender->AddJsFile('plugins/VanillaStats/js/picker.js');
$Sender->AddCSSFile('plugins/VanillaStats/design/picker.css');
$this->ConfigureRange($Sender);
$VanillaID = Gdn::InstallationID();
$Sender->SetData('VanillaID', $VanillaID);
$Sender->SetData('VanillaVersion', APPLICATION_VERSION);
$Sender->SetData('SecurityToken', $this->SecurityToken());
// Render the custom dashboard view
$Sender->Render('dashboard', '', 'plugins/VanillaStats');
}
}
示例2: Gdn_Dispatcher_BeforeDispatch_Handler
public function Gdn_Dispatcher_BeforeDispatch_Handler($Sender)
{
$Request = Gdn::Request();
$RequestUri = $Request->RequestUri();
if (Gdn::Router()->GetRoute($RequestUri) === False) {
$RequestArgs = SplitUpString($RequestUri, '/', 'strtolower');
if (array_key_exists(0, $RequestArgs)) {
$ApplicationFolders = $Sender->EnabledApplicationFolders();
$bFoundApplication = in_array($RequestArgs[0], $ApplicationFolders);
if ($bFoundApplication === False) {
$PathParts = array('controllers', 'class.' . $RequestArgs[0] . 'controller.php');
$ControllerFileName = CombinePaths($PathParts);
$ControllerPath = Gdn_FileSystem::FindByMapping('controller', PATH_APPLICATIONS, $ApplicationFolders, $ControllerFileName);
if (!$ControllerPath || !file_exists($ControllerPath)) {
$Sender->EventArguments['RequestUri'] =& $RequestUri;
$Sender->FireEvent('BeforeGetRoute');
$NewRequest = CandyModel::GetRouteRequestUri($RequestUri);
if ($NewRequest) {
$Request->WithURI($NewRequest);
}
}
}
}
}
}
示例3: Controller_Cookie
public function Controller_Cookie($Sender)
{
$ExplodedDomain = explode('.', Gdn::Request()->RequestHost());
if (sizeof($ExplodedDomain) == 1) {
$GuessedCookieDomain = '';
} else {
$GuessedCookieDomain = '.' . implode('.', array_slice($ExplodedDomain, -2, 2));
}
$Validation = new Gdn_Validation();
$ConfigurationModel = new Gdn_ConfigurationModel($Validation);
$ConfigurationModel->SetField(array('Plugin.ProxyConnect.NewCookieDomain'));
// Set the model on the form.
$Sender->Form->SetModel($ConfigurationModel);
if ($Sender->Form->AuthenticatedPostBack()) {
$NewCookieDomain = $Sender->Form->GetValue('Plugin.ProxyConnect.NewCookieDomain', '');
SaveToConfig('Garden.Cookie.Domain', $NewCookieDomain);
} else {
$NewCookieDomain = $GuessedCookieDomain;
}
$Sender->SetData('GuessedCookieDomain', $GuessedCookieDomain);
$CurrentCookieDomain = C('Garden.Cookie.Domain');
$Sender->SetData('CurrentCookieDomain', $CurrentCookieDomain);
$Sender->Form->SetData(array('Plugin.ProxyConnect.NewCookieDomain' => $NewCookieDomain));
$Sender->Form->SetFormValue('Plugin.ProxyConnect.NewCookieDomain', $NewCookieDomain);
return $this->GetView('cookie.php');
}
示例4: DiscussionController_AfterDiscussionBody_Handler
/**
* Show buttons after OP message body.
*/
public function DiscussionController_AfterDiscussionBody_Handler($Sender)
{
$PublisherNumber = C('Plugin.ShareThis.PublisherNumber', 'Publisher Number');
$ViaHandle = C('Plugin.ShareThis.ViaHandle', '');
$CopyNShare = C('Plugin.ShareThis.CopyNShare', false);
$doNotHash = $CopyNShare ? 'false' : 'true';
$doNotCopy = $CopyNShare ? 'false' : 'true';
$Domain = Gdn::Request()->Scheme() == 'https' ? 'https://ws.sharethis.com' : 'http://w.sharethis.com';
echo <<<SHARETHIS
<script type="text/javascript">var switchTo5x=true;</script>
<script type="text/javascript" src="{$Domain}/button/buttons.js"></script>
<script type="text/javascript">stLight.options({
publisher: "{$PublisherNumber}",
doNotHash: {$doNotHash},
doNotCopy: {$doNotCopy},
hashAddressBar: false
});</script>
<div class="ShareThisButtonWrapper Right">
<span class="st_twitter_hcount ShareThisButton" st_via="{$ViaHandle}" displayText="Tweet"></span>
<span class="st_facebook_hcount ShareThisButton" displayText="Facebook"></span>
<span class="st_linkedin_hcount ShareThisButton Hidden" displayText="LinkedIn"></span>
<span class="st_googleplus_hcount ShareThisButton Hidden" displayText="Google +"></span>
<span class="st_reddit_hcount ShareThisButton Hidden" displayText="Reddit"></span>
<span class="st_pinterest_hcount ShareThisButton Hidden" displayText="Pinterest"></span>
<span class="st_email_hcount ShareThisButton" displayText="Email"></span>
<span class="st_sharethis_hcountShareThisButton" displayText="ShareThis"></span>
</div>
SHARETHIS;
}
示例5: Anchor
/**
* Builds and returns an anchor tag.
*/
function Anchor($Text, $Destination = '', $CssClass = '', $Attributes = '', $ForceAnchor = FALSE)
{
if (!is_array($CssClass) && $CssClass != '') {
$CssClass = array('class' => $CssClass);
}
if ($Destination == '' && $ForceAnchor === FALSE) {
return $Text;
}
if ($Attributes == '') {
$Attributes = array();
}
$SSL = GetValue('SSL', $Attributes, NULL);
if ($SSL) {
unset($Attributes['SSL']);
}
$WithDomain = GetValue('WithDomain', $Attributes, FALSE);
if ($WithDomain) {
unset($Attributes['WithDomain']);
}
$Prefix = substr($Destination, 0, 7);
if (!in_array($Prefix, array('https:/', 'http://', 'mailto:')) && ($Destination != '' || $ForceAnchor === FALSE)) {
$Destination = Gdn::Request()->Url($Destination, $WithDomain, $SSL);
}
return '<a href="' . htmlspecialchars($Destination, ENT_COMPAT, 'UTF-8') . '"' . Attribute($CssClass) . Attribute($Attributes) . '>' . $Text . '</a>';
}
示例6: Authenticate
public function Authenticate()
{
$ForeignIdentityUrl = C('Garden.Authenticator.AuthenticateURL');
if (!$ForeignIdentityUrl) {
return FALSE;
}
try {
$Response = $this->_GetForeignCredentials($ForeignIdentityUrl);
if (!$Response) {
throw new Exception();
}
$SQL = Gdn::Database()->SQL();
$Provider = $SQL->Select('uap.AuthenticationKey, uap.AssociationSecret')->From('UserAuthenticationProvider uap')->Get()->FirstRow(DATASET_TYPE_ARRAY);
if (!$Provider) {
throw new Exception();
}
// Got a response from the remote identity provider
$UserEmail = ArrayValue('Email', $Response);
$UserName = ArrayValue('Name', $Response);
$UserName = trim(preg_replace('/[^a-z0-9-]+/i', '', $UserName));
$AuthResponse = $this->ProcessAuthorizedRequest($Provider['AuthenticationKey'], $UserEmail, $UserName);
if ($AuthResponse == Gdn_Authenticator::AUTH_SUCCESS) {
Gdn::Request()->WithRoute('DefaultController');
} elseif ($AuthResponse == Gdn_Authenticator::AUTH_PARTIAL) {
Redirect(Url('/entry/handshake/proxy', TRUE), 302);
} else {
Gdn::Request()->WithRoute('DefaultController');
throw new Exception('authentication failed');
}
} catch (Exception $e) {
// Fallback to defer checking until the next session
$this->SetIdentity(-1, FALSE);
}
}
示例7: 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()) {
// Set some information about the user in the data.
TouchValue('IPAddress', $Data, Gdn::Request()->IpAddress());
if ($RecordType == 'User') {
TouchValue('Username', $Data, $Data['Name']);
} else {
TouchValue('Username', $Data, Gdn::Session()->User->Name);
TouchValue('Email', $Data, Gdn::Session()->User->Email);
}
$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 && GetValue('Log', $Options, TRUE)) {
LogModel::Insert('Spam', $RecordType, $Data);
}
return $Spam;
}
示例8: 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())
{
// Set some information about the user in the data.
TouchValue('IPAddress', $Data, Gdn::Request()->IpAddress());
if ($RecordType == 'Registration') {
TouchValue('Username', $Data, $Data['Name']);
} else {
TouchValue('Username', $Data, Gdn::Session()->User->Name);
TouchValue('Email', $Data, Gdn::Session()->User->Email);
}
$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 && GetValue('Log', $Options, TRUE)) {
$LogOptions = array();
switch ($RecordType) {
case 'Registration':
$LogOptions['GroupBy'] = array('RecordIPAddress');
break;
case 'Comment':
case 'Discussion':
$LogOptions['GroupBy'] = array('RecordID');
break;
}
LogModel::Insert('Spam', $RecordType, $Data, $LogOptions);
}
return $Spam;
}
示例9: Gdn_Dispatcher_BeforeBlockDetect_Handler
/**
* If the Garden.PrivateCommunity config setting is enabled,
* then bypass the sign-in redirection and let the Basic Pages
* view permission logic handle the redirection for
* pages requested by guests.
*
* @param $Sender Gdn_Dispatcher
*/
public function Gdn_Dispatcher_BeforeBlockDetect_Handler($Sender)
{
if (C('Garden.PrivateCommunity', false)) {
$BlockExceptions =& $Sender->EventArguments['BlockExceptions'];
$PathRequest = Gdn::Request()->Path();
$PageModel = new PageModel();
// Handle path requests that match "page/urlcode"
$PathMatch = 'page/';
if (substr($PathRequest, 0, strlen($PathMatch)) === $PathMatch) {
$Page = $PageModel->GetByUrlCode(substr($PathRequest, strlen($PathMatch), strlen($PathRequest)));
// Only bypass Garden.PrivateCommunity redirection if custom page view permission is enabled.
if (isset($Page->ViewPermission) && (bool) $Page->ViewPermission) {
$BlockExceptions['/^page(\\/.*)?$/'] = Gdn_Dispatcher::BLOCK_NEVER;
}
} else {
if (!strstr($PathRequest, '/')) {
// NOTE: Increases overhead every time the Dispatch method is called.
// There is room for optimization to be done here.
//
// Handle path requests which don't contain a forward slash
// because the request could possibly be for a page with
// a path of "urlcode"
$Page = $PageModel->GetByUrlCode($PathRequest);
// Only bypass Garden.PrivateCommunity redirection if custom page view permission is enabled.
if (isset($Page->ViewPermission) && (bool) $Page->ViewPermission) {
$BlockExceptions['/^' . $PathRequest . '(\\/.*)?$/'] = Gdn_Dispatcher::BLOCK_NEVER;
}
}
}
}
}
示例10: ValidateCaptcha
function ValidateCaptcha($Value = NULL)
{
require_once PATH_LIBRARY . '/vendors/recaptcha/functions.recaptchalib.php';
$CaptchaPrivateKey = C('Garden.Registration.CaptchaPrivateKey', '');
$Response = recaptcha_check_answer($CaptchaPrivateKey, Gdn::Request()->IpAddress(), Gdn::Request()->Post('recaptcha_challenge_field', ''), Gdn::Request()->Post('recaptcha_response_field', ''));
return $Response->is_valid ? TRUE : 'The reCAPTCHA value was not entered correctly. Please try again.';
}
示例11: GetWebResource
public function GetWebResource($Filepath)
{
$WebResource = $this->GetResource($Filename, FALSE, FALSE);
if (Gdn::Request()->WebRoot()) {
$WebResource = Gdn::Request()->WebRoot() . '/' . $WebResource;
}
return '/' . $WebResource;
}
示例12: 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;
}
示例13: __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.
}
示例14: _AttachBadge
protected function _AttachBadge(&$Sender)
{
$badge = ArrayValue($Sender->EventArguments['Author']->UserID, $Sender->Data('Plugin-Badge-Counts'));
if ($badge > 0) {
$icon = file_exists('plugins/TopPosters/badges/' . $badge . '.png') ? $badge . '.png' : 'medal-icon.png';
echo '<span><img src="' . str_replace("index.php?p=", "", Gdn::Request()->Domain() . Url('plugins/TopPosters/badges/' . $icon)) . '" style="width:16px;height:16px;vertical-align:middle"></span>';
}
}
示例15: Base_BeforeDispatch_Handler
public function Base_BeforeDispatch_Handler($Sender)
{
$Request = Gdn::Request();
$Folder = ltrim($Request->RequestFolder(), '/');
$Uri = ltrim($_SERVER['REQUEST_URI'], '/');
// Fix the url in the request for routing.
if (preg_match("`^{$Folder}index.php/`", $Uri)) {
$Request->PathAndQuery(substr($Uri, strlen($Folder)));
}
}