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


PHP Director::is_site_url方法代码示例

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


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

示例1: register

 /**
  * Handles validation and saving new Member objects, as well as sending out validation emails.
  */
 public function register($data, Form $form)
 {
     if ($member = $this->addMember($form)) {
         $this->addRegistration($form, $member);
         if (!$this->RequireApproval && $this->EmailType != 'Validation' && !$this->AllowAdding) {
             $member->logIn();
         }
         if ($this->RegistrationRedirect) {
             if ($this->PostRegistrationTargetID) {
                 $this->redirect($this->PostRegistrationTarget()->Link());
                 return;
             }
             if ($sessionTarget = Session::get('MemberProfile.REDIRECT')) {
                 Session::clear('MemberProfile.REDIRECT');
                 if (Director::is_site_url($sessionTarget)) {
                     $this->redirect($sessionTarget);
                     return;
                 }
             }
         }
         return $this->redirect($this->Link('afterregistration'));
     } else {
         return $this->redirectBack();
     }
 }
开发者ID:helpfulrobot,项目名称:adrexia-gamesevent,代码行数:28,代码来源:RegistrationPage.php

示例2: cleanBackUrl

 public static function cleanBackUrl($back_url)
 {
     if (empty($back_url) || !empty($back_url) && !Director::is_site_url($back_url)) {
         $back_url = Director::baseURL();
     }
     return $back_url;
 }
开发者ID:Thingee,项目名称:openstack-org,代码行数:7,代码来源:OpenStackIdCommon.php

示例3: handle_shortcode

 public static function handle_shortcode($arguments, $url, $parser, $shortcode)
 {
     $result = false;
     if (Director::is_site_url($url) && VideoEmbed::GetByURL($url)) {
         $result = VideoEmbed::GetByURL($url)->forTemplate();
     } else {
         $result = parent::handle_shortcode($arguments, $url, $parser, $shortcode);
     }
     return $result;
 }
开发者ID:helpfulrobot,项目名称:gdmedia-silverstripe-video-embed,代码行数:10,代码来源:Oembed_Custom.php

示例4: doChangePassword

 /**
  * Change the password
  *
  * @param array $data The user submitted data
  */
 function doChangePassword(array $data)
 {
     if ($member = Member::currentUser()) {
         // The user was logged in, check the current password
         if (empty($data['OldPassword']) || !$member->checkPassword($data['OldPassword'])->valid()) {
             $this->clearMessage();
             $this->sessionMessage(_t('Member.ERRORPASSWORDNOTMATCH', "Your current password does not match, please try again"), "bad");
             Director::redirectBack();
             return;
         }
     }
     if (!$member) {
         if (Session::get('AutoLoginHash')) {
             $member = Member::member_from_autologinhash(Session::get('AutoLoginHash'));
         }
         // The user is not logged in and no valid auto login hash is available
         if (!$member) {
             Session::clear('AutoLoginHash');
             Director::redirect('loginpage');
             return;
         }
     }
     // Check the new password
     if (empty($data['NewPassword1'])) {
         $this->clearMessage();
         $this->sessionMessage(_t('Member.EMPTYNEWPASSWORD', "The new password can't be empty, please try again"), "bad");
         Director::redirectBack();
         return;
     } else {
         if ($data['NewPassword1'] == $data['NewPassword2']) {
             $isValid = $member->changePassword($data['NewPassword1']);
             if ($isValid->valid()) {
                 $this->clearMessage();
                 $this->sessionMessage(_t('Member.PASSWORDCHANGED', "Your password has been changed, and a copy emailed to you."), "good");
                 Session::clear('AutoLoginHash');
                 if (isset($_REQUEST['BackURL']) && $_REQUEST['BackURL'] && Director::is_site_url($_REQUEST['BackURL'])) {
                     Director::redirect($_REQUEST['BackURL']);
                 } else {
                     // Redirect to default location - the login form saying "You are logged in as..."
                     $redirectURL = HTTP::setGetVar('BackURL', Director::absoluteBaseURL(), Security::Link('login'));
                     Director::redirect($redirectURL);
                 }
             } else {
                 $this->clearMessage();
                 $this->sessionMessage(sprintf(_t('Member.INVALIDNEWPASSWORD', "We couldn't accept that password: %s"), nl2br("\n" . $isValid->starredList())), "bad");
                 Director::redirectBack();
             }
         } else {
             $this->clearMessage();
             $this->sessionMessage(_t('Member.ERRORNEWPASSWORD', "You have entered your new password differently, try again"), "bad");
             Director::redirectBack();
         }
     }
 }
开发者ID:SustainableCoastlines,项目名称:loveyourwater,代码行数:59,代码来源:ChangePasswordForm.php

示例5: checkOwnAjaxRequest

 public function checkOwnAjaxRequest($request)
 {
     $referer = @$_SERVER['HTTP_REFERER'];
     if (empty($referer)) {
         return false;
     }
     //validate
     if (!Director::is_ajax()) {
         return false;
     }
     return Director::is_site_url($referer);
 }
开发者ID:balajijegan,项目名称:openstack-org,代码行数:12,代码来源:SummitsApi.php

示例6: doSubmit

 /**
  * @param array $data
  * @param Form $form
  *
  * @return mixed
  */
 public function doSubmit($data, $form)
 {
     $controller = Controller::curr();
     $redirect = Director::baseURL() . $this->owner->URLSegment;
     if ((bool) Config::inst()->get('QuickFeedbackExtension', 'redirect_field') && isset($data['Redirect']) && Director::is_site_url($data['Redirect'])) {
         $redirect = Director::absoluteURL($data['Redirect'], true);
     }
     if (!$controller) {
         goto error;
     }
     $request = $controller->getRequest();
     if (!$request) {
         goto error;
     }
     $limit = (int) Config::inst()->get('QuickFeedbackExtension', 'rate_limit');
     $existing = Feedback::get()->filter('IP', $request->getIP())->sort('Created desc')->first();
     if ($existing) {
         $created = $existing->dbObject('Created');
         if (!$created) {
             goto error;
         }
         $seconds = abs(time() - strtotime($created->getValue()));
         $minutes = round($seconds / 60);
         if ($minutes <= $limit) {
             goto rate;
         }
     }
     $feedback = Feedback::create();
     $feedback->Rating = $data['Rating'];
     $feedback->Comment = $data['Comment'];
     $feedback->IP = $request->getIP();
     if (!empty($this->owner->ID)) {
         $feedback->PageID = $this->owner->ID;
     }
     if (!empty($this->owner->URLSegment)) {
         $feedback->URL = $this->owner->RelativeLink();
     }
     if ((bool) Config::inst()->get('QuickFeedbackExtension', 'redirect_field') && isset($data['Redirect'])) {
         $feedback->URL = $data['Redirect'];
     }
     $feedback->write();
     $form->sessionMessage(_t('QuickFeedback.ThanksMessage', 'Thanks for your comment!'), 'good');
     return $this->owner->redirect($redirect . '?success=1');
     error:
     $form->sessionMessage(_t('QuickFeedback.ErrorMessage', 'An error occurred!'), 'error');
     return $this->owner->redirect($redirect . '?error=1');
     rate:
     $form->sessionMessage(_t('QuickFeedback.RateMessage', 'Please wait a while before submitting!'), 'error');
     return $this->owner->redirect($redirect . '?rate=1');
 }
开发者ID:assertchris,项目名称:silverstripe-quickfeedback,代码行数:56,代码来源:QuickFeedbackExtension.php

示例7: viewfile

 public function viewfile($request)
 {
     $result = false;
     if ($origUrl = $request->getVar('FileURL')) {
         if (Director::is_site_url($origUrl) && VideoEmbed::GetByURL($origUrl)) {
             $video = VideoEmbed::GetByURL($origUrl);
             $result = $this->GetResultForVideo($video);
         }
     } else {
         if ($fileId = $request->getVar('ID')) {
             $video = VideoEmbed::get()->filter(array("HTML5VideoID" => $fileId))->first();
             $result = $this->GetResultForVideo($video);
         }
     }
     return $result ? $result : parent::viewfile($request);
 }
开发者ID:helpfulrobot,项目名称:gdmedia-silverstripe-video-embed,代码行数:16,代码来源:VideoHtmlEditorField.php

示例8: GetOembedData

 public function GetOembedData(SS_HTTPRequest $request)
 {
     $response = "{}";
     $this->getResponse()->addHeader("Content-Type", "application/json; charset=utf-8");
     $url = $request->postVar('url') ? $request->postVar('url') : $request->getVar("mediaurl");
     if (Director::is_site_url($url) && VideoEmbed::GetByURL($url)) {
         $video = VideoEmbed::GetByURL($url);
         $response = $video->GetOembedJson();
     } else {
         $oembed = Oembed::get_oembed_from_url($url);
         if ($oembed && $oembed->exists()) {
             $response = $oembed->toJson();
         }
     }
     echo $response;
 }
开发者ID:helpfulrobot,项目名称:gdmedia-silverstripe-video-embed,代码行数:16,代码来源:VideoEmbedController.php

示例9: logInUserAndRedirect

 protected function logInUserAndRedirect($data)
 {
     Session::clear('SessionForms.MemberLoginForm.Email');
     Session::clear('SessionForms.MemberLoginForm.Remember');
     if (Member::currentUser()->isPasswordExpired()) {
         if (isset($_REQUEST['BackURL']) && ($backURL = $_REQUEST['BackURL'])) {
             Session::set('BackURL', $backURL);
         }
         $cp = new ChangePasswordForm($this->controller, 'ChangePasswordForm');
         $cp->sessionMessage(_t('Member.PASSWORDEXPIRED', 'Your password has expired. Please choose a new one.'), 'good');
         return $this->controller->redirect('Security/changepassword');
     }
     // Absolute redirection URLs may cause spoofing
     if (!empty($_REQUEST['BackURL'])) {
         $url = $_REQUEST['BackURL'];
         if (Director::is_site_url($url)) {
             $url = Director::absoluteURL($url);
         } else {
             // Spoofing attack, redirect to homepage instead of spoofing url
             $url = Director::absoluteBaseURL();
         }
         return $this->controller->redirect($url);
     }
     // If a default login dest has been set, redirect to that.
     if ($url = Security::config()->default_login_dest) {
         $url = Controller::join_links(Director::absoluteBaseURL(), $url);
         return $this->controller->redirect($url);
     }
     // Redirect the user to the page where they came from
     $member = Member::currentUser();
     if ($member) {
         $firstname = Convert::raw2xml($member->FirstName);
         if (!empty($data['Remember'])) {
             Session::set('SessionForms.MemberLoginForm.Remember', '1');
             $member->logIn(true);
         } else {
             $member->logIn();
         }
         Session::set('Security.Message.message', _t('Member.WELCOMEBACK', "Welcome Back, {firstname}", array('firstname' => $firstname)));
         Session::set("Security.Message.type", "good");
     }
     // Do checks of pagetypes to see where we were and where to go then for the rest redirect to baseurl
     //        $url = "/resources/";
     $url = "/resources/";
     $url = Controller::join_links(Director::absoluteBaseURL(), $url);
     return $this->controller->redirect($url);
 }
开发者ID:dunatron,项目名称:onbaord-revamp,代码行数:47,代码来源:CustomLoginForm.php

示例10: callback

 public function callback()
 {
     $redirectUri = 'http' . (isset($_SERVER['HTTPS']) ? $_SERVER['HTTPS'] ? 's' : '' : '') . '://' . $_SERVER['HTTP_HOST'] . '/GoogleAuthenticatorController/callback';
     $client = new Google_Client();
     $client->setClientId(GOOGLE_AUTHENTICATOR_CLIENT_ID);
     $client->setClientSecret(GOOGLE_AUTHENTICATOR_CLIENT_SECRET);
     $client->setRedirectUri($redirectUri);
     $client->addScope("email");
     if (isset($_GET['code'])) {
         $client->authenticate($_GET['code']);
         $_SESSION['google_accesstoken'] = $client->getAccessToken();
         header('Location: ' . filter_var($redirectUri, FILTER_SANITIZE_URL));
     }
     if (isset($_SESSION['google_accesstoken']) && $_SESSION['google_accesstoken']) {
         $client->setAccessToken($_SESSION['google_accesstoken']);
     }
     $form = new GoogleAuthenticatorLoginForm($this, 'LoginForm');
     if ($client->getAccessToken() && !$client->isAccessTokenExpired()) {
         $_SESSION['google_accesstoken'] = $client->getAccessToken();
         $token_data = $client->verifyIdToken()->getAttributes();
         $email = $token_data['payload']['email'];
         $member = Member::get()->filter(array('Email' => $email))->first();
         if (isset($_SESSION['BackURL']) && $_SESSION['BackURL'] && Director::is_site_url($_SESSION['BackURL'])) {
             $backURL = $_SESSION['BackURL'];
         }
         if ($member) {
             $member->logIn();
             if ($backURL) {
                 return $this->redirect($backURL);
             }
             if (Security::config()->default_login_dest) {
                 return $this->redirect(Director::absoluteBaseURL() . Security::config()->default_login_dest);
             }
             return Controller::curr()->redirectBack();
         } else {
             $form->sessionMessage("The Google account {$email} is not authorised to access the system.", 'bad');
         }
     } else {
         $form->sessionMessage("There is an error authenticating with Google. Please try again.", 'bad');
     }
     $loginLink = Director::absoluteURL('/Security/login');
     if ($backURL) {
         $loginLink .= '?BackURL=' . urlencode($backURL);
     }
     $loginLink .= '#GoogleAuthenticatorLoginForm_LoginForm_tab';
     return $this->redirect($loginLink);
 }
开发者ID:xpointo,项目名称:silverstripe-google-authenticator,代码行数:47,代码来源:GoogleAuthenticatorController.php

示例11: logInUserAndRedirect

 /**
  * Overidden, added call to redirectByGroup().
  * 
  * Login in the user and figure out where to redirect the browser.
  *
  * The $data has this format
  * array(
  *   'AuthenticationMethod' => 'MemberAuthenticator',
  *   'Email' => 'sam@silverstripe.com',
  *   'Password' => '1nitialPassword',
  *   'BackURL' => 'test/link',
  *   [Optional: 'Remember' => 1 ]
  * )
  *
  *
  * @param array $data
  * @return void
  */
 protected function logInUserAndRedirect($data)
 {
     Session::clear('SessionForms.MemberLoginForm.Email');
     Session::clear('SessionForms.MemberLoginForm.Remember');
     if (Member::currentUser()->isPasswordExpired()) {
         if (isset($_REQUEST['BackURL']) && ($backURL = $_REQUEST['BackURL'])) {
             Session::set('BackURL', $backURL);
         }
         $cp = new ChangePasswordForm($this->controller, 'ChangePasswordForm');
         $cp->sessionMessage('Your password has expired. Please choose a new one.', 'good');
         return $this->controller->redirect('Security/changepassword');
     }
     // Absolute redirection URLs may cause spoofing
     if (isset($_REQUEST['BackURL']) && $_REQUEST['BackURL'] && Director::is_site_url($_REQUEST['BackURL'])) {
         return $this->controller->redirect($_REQUEST['BackURL']);
     }
     // Spoofing attack, redirect to homepage instead of spoofing url
     if (isset($_REQUEST['BackURL']) && $_REQUEST['BackURL'] && !Director::is_site_url($_REQUEST['BackURL'])) {
         return $this->controller->redirect(Director::absoluteBaseURL());
     }
     // If a default login dest has been set, redirect to that.
     if (Security::default_login_dest()) {
         return $this->controller->redirect(Director::absoluteBaseURL() . Security::default_login_dest());
     }
     // redirect by group
     if (singleton('Group')->hasExtension('GroupLoginDataExtension')) {
         $this->redirectByGroup();
     }
     // Redirect the user to the page where he came from
     $member = Member::currentUser();
     if ($member) {
         $firstname = Convert::raw2xml($member->FirstName);
         if (!empty($data['Remember'])) {
             Session::set('SessionForms.MemberLoginForm.Remember', '1');
             $member->logIn(true);
         } else {
             $member->logIn();
         }
         Session::set('Security.Message.message', _t('Member.WELCOMEBACK', "Welcome Back, {firstname}", array('firstname' => $firstname)));
         Session::set("Security.Message.type", "good");
     }
     Controller::curr()->redirectBack();
 }
开发者ID:arillo,项目名称:silverstripe-cleanutilities,代码行数:61,代码来源:CustomRedirectLoginForm.php

示例12: viewvidyard

 /**
  * Handles requests to view a vidyard video in the cms
  * @param {SS_HTTPRequest} $request HTTP Request object
  * @return {string} Rendered view on success null on error
  * @throws SS_HTTPResponse_Exception
  */
 public function viewvidyard(SS_HTTPRequest $request)
 {
     $file = null;
     $url = null;
     if ($fileUrl = $request->getVar('VidyardURL')) {
         // If this isn't an absolute URL, or is, but is to this site, try and get the File object
         // that is associated with it
         if (Director::is_absolute_url($fileUrl) && !Director::is_site_url($fileUrl) && Vidyard::validateVidyardURL($fileUrl)) {
             list($file, $url) = $this->getVideoByURL($fileUrl);
         } else {
             throw new SS_HTTPResponse_Exception('"VidyardURL" is not a valid Vidyard Video', 400);
         }
     } else {
         throw new SS_HTTPResponse_Exception('Need "VidyardURL" parameter to identify the file', 400);
     }
     $fileWrapper = new VidyardInsertMedia_Embed($url, $file);
     $fields = $this->getFieldsForVidyard($url, $fileWrapper);
     return $fileWrapper->customise(array('Fields' => $fields))->renderWith('HtmlEditorField_viewfile');
 }
开发者ID:webbuilders-group,项目名称:silverstripe-vidyard-embed,代码行数:25,代码来源:VidyardInsertMedia.php

示例13: getRedirect

 /**
  * @return SS_HTTPResponse
  */
 protected function getRedirect()
 {
     // Absolute redirection URLs may cause spoofing
     if (Session::get('BackURL') && Director::is_site_url(Session::get('BackURL'))) {
         return $this->redirect(Session::get('BackURL'));
     }
     // Spoofing attack, redirect to homepage instead of spoofing url
     if (Session::get('BackURL') && !Director::is_site_url(Session::get('BackURL'))) {
         return $this->redirect(Director::absoluteBaseURL());
     }
     // If a default login dest has been set, redirect to that.
     if (Security::config()->default_login_dest) {
         return $this->redirect(Director::absoluteBaseURL() . Security::config()->default_login_dest);
     }
     // fallback to redirect back to home page
     return $this->redirect(Director::absoluteBaseURL());
 }
开发者ID:eLBirador,项目名称:silverstripe-activedirectory,代码行数:20,代码来源:SAMLController.php

示例14: redirectBack

 /**
  * Redirect back. Uses either the HTTP_REFERER or a manually set request-variable called
  * _REDIRECT_BACK_URL.
  * This variable is needed in scenarios where not HTTP-Referer is sent (
  * e.g when calling a page by location.href in IE).
  * If none of the two variables is available, it will redirect to the base
  * URL (see {@link Director::baseURL()}).
  * @uses redirect()
  */
 function redirectBack()
 {
     $url = null;
     // In edge-cases, this will be called outside of a handleRequest() context; in that case,
     // redirect to the homepage - don't break into the global state at this stage because we'll
     // be calling from a test context or something else where the global state is inappropraite
     if ($this->request) {
         if ($this->request->requestVar('_REDIRECT_BACK_URL')) {
             $url = $this->request->requestVar('_REDIRECT_BACK_URL');
         } else {
             if ($this->request->getHeader('Referer')) {
                 $url = $this->request->getHeader('Referer');
             }
         }
     }
     if (!$url) {
         $url = Director::baseURL();
     }
     // absolute redirection URLs not located on this site may cause phishing
     if (Director::is_site_url($url)) {
         return $this->redirect($url);
     } else {
         return false;
     }
 }
开发者ID:hamishcampbell,项目名称:silverstripe-sapphire,代码行数:34,代码来源:Controller.php

示例15: redirectBack

 /**
  * Redirect back. Uses either the HTTP_REFERER or a manually set request-variable called
  * _REDIRECT_BACK_URL.
  * This variable is needed in scenarios where not HTTP-Referer is sent (
  * e.g when calling a page by location.href in IE).
  * If none of the two variables is available, it will redirect to the base
  * URL (see {@link Director::baseURL()}).
  * @uses redirect()
  */
 function redirectBack()
 {
     if ($this->request->requestVar('_REDIRECT_BACK_URL')) {
         $url = $this->request->requestVar('_REDIRECT_BACK_URL');
     } else {
         if ($this->request->getHeader('Referer')) {
             $url = $this->request->getHeader('Referer');
         } else {
             $url = Director::baseURL();
         }
     }
     // absolute redirection URLs not located on this site may cause phishing
     if (Director::is_site_url($url)) {
         return $this->redirect($url);
     } else {
         return false;
     }
 }
开发者ID:SustainableCoastlines,项目名称:loveyourwater,代码行数:27,代码来源:Controller.php


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