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


PHP SS_HTTPRequest::getURL方法代码示例

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


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

示例1: testGetURL

 public function testGetURL()
 {
     $req = new SS_HTTPRequest('GET', '/');
     $this->assertEquals('', $req->getURL());
     $req = new SS_HTTPRequest('GET', '/assets/somefile.gif');
     $this->assertEquals('assets/somefile.gif', $req->getURL());
     $req = new SS_HTTPRequest('GET', '/home?test=1');
     $this->assertEquals('home?test=1', $req->getURL(true));
     $this->assertEquals('home', $req->getURL());
 }
开发者ID:jacobbuck,项目名称:silverstripe-framework,代码行数:10,代码来源:HTTPRequestTest.php

示例2: handleRequest

 /**
  * Process all incoming requests passed to this controller, checking
  * that the file exists and passing the file through if possible.
  */
 public function handleRequest(SS_HTTPRequest $request, DataModel $model)
 {
     $response = new SS_HTTPResponse();
     $filename = $request->getURL();
     if (strpos($filename, 'cdnassets') === 0) {
         $filename = 'assets/' . substr($filename, strlen('cdnassets/'));
     }
     $file = null;
     if (strpos($filename, '_resampled') !== false) {
         $file = ContentServiceAsset::get()->filter('Filename', $filename)->first();
     } else {
         if (strpos($filename, '/_versions/') !== false) {
             $file = FileVersion::get()->filter('Filename', "/" . $filename)->first();
         } else {
             $file = File::get()->filter('filename', $filename)->first();
         }
     }
     if ($file && $file->canView()) {
         if (!$file->CDNFile && !$file->FilePointer) {
             return $this->httpError(404);
         }
         // Permission passed redirect to file
         $redirectLink = '';
         if ($file->getViewType() != CDNFile::ANYONE_PERM) {
             if ($file->hasMethod('getSecureURL')) {
                 $redirectLink = $file->getSecureURL(180);
             }
             if (!strlen($redirectLink)) {
                 // can we stream it?
                 return $this->sendFile($file);
             }
         } else {
             $redirectLink = $file->getURL();
         }
         if ($redirectLink && trim($redirectLink, '/') != $request->getURL()) {
             $response->redirect($redirectLink);
         } else {
             return $this->httpError(404);
         }
     } else {
         if (class_exists('SecureFileController')) {
             $handoff = SecureFileController::create();
             return $handoff->handleRequest($request, $model);
         } elseif ($file instanceof File) {
             // Permission failure
             Security::permissionFailure($this, 'You are not authorised to access this resource. Please log in.');
         } else {
             // File doesn't exist
             $response = new SS_HTTPResponse('File Not Found', 404);
         }
     }
     return $response;
 }
开发者ID:stephenmcm,项目名称:silverstripe-cdncontent,代码行数:57,代码来源:CDNSecureFileController.php

示例3: handleRequest

 /**
  * @uses ModelAsController::getNestedController()
  * @param SS_HTTPRequest $request
  * @param DataModel $model
  * @return SS_HTTPResponse
  */
 public function handleRequest(SS_HTTPRequest $request, DataModel $model)
 {
     // Check Translatable dependency
     if (!class_exists('Translatable') || !SiteTree::has_extension('Translatable') && !SiteTree::has_extension('LanguagePrefixTranslatable')) {
         throw new Exception('Dependency error: the LanguagePrefix module expects the Translatable module.');
     }
     $disablePrefixForDefaultLang = Config::inst()->get('prefixconfig', 'disable_prefix_for_default_lang');
     $firstSegment = $request->param('URLSegment');
     if ($firstSegment) {
         $prefixUsed = $this->setLocale($firstSegment);
         $defaultLocale = Translatable::default_locale();
         $isDefaultLocale = $this->locale == $defaultLocale;
         if ($prefixUsed) {
             if ($isDefaultLocale && $disablePrefixForDefaultLang) {
                 $url = substr($request->getURL(true), strlen($firstSegment));
                 return $this->redirect($url, 301);
             } else {
                 $request->shiftAllParams();
                 $request->shift(1);
             }
         } else {
             /*
              *  if no prefix is used but $disablePrefixForDefaultLang
              *  is set, we go on like nothing happened. Otherwise a
              *  404 is generated. @todo: maybe we should redirect
              *  pages that do actually exist, because this is a bit
              *  harsh?
              */
             //if (!$isDefaultLocale || !$disablePrefixForDefaultLang) {
             //	return $this->showPageNotFound();
             //}
         }
     }
     return parent::handleRequest($request, $model);
 }
开发者ID:martimiz,项目名称:silverstripe-languageprefix,代码行数:41,代码来源:PrefixModelAsController.php

示例4: placeOrder

 public function placeOrder(SS_HTTPRequest $request)
 {
     $eventbrite_event_header = $request->getHeader('X-Eventbrite-Event');
     if (!$eventbrite_event_header) {
         return $this->httpError(403);
     }
     if ($eventbrite_event_header !== 'order.placed') {
         return $this->httpError(403);
     }
     if (!$this->isJson()) {
         return $this->httpError(403);
     }
     $json_request = $this->getJsonRequest();
     if (!isset($json_request['config']) || !isset($json_request['api_url'])) {
         return $this->httpError(403);
     }
     $config = $json_request['config'];
     if (!isset($config['action']) || $config['action'] !== 'order.placed') {
         return $this->httpError(403);
     }
     $current_local_url = Controller::join_links(Director::absoluteBaseURL(), $request->getURL());
     if (!isset($config['endpoint_url']) || $config['endpoint_url'] !== $current_local_url) {
         return $this->httpError(403);
     }
     try {
         $this->manager->registerEvent('ORDER_PLACED', $json_request['api_url']);
     } catch (Exception $ex) {
         SS_Log::log($ex->getMessage(), SS_Log::ERR);
         return $this->httpError(500);
     }
     return true;
 }
开发者ID:OpenStackweb,项目名称:openstack-org,代码行数:32,代码来源:EventbriteOrderPlacedEndpoint.php

示例5: postRequest

 public function postRequest(\SS_HTTPRequest $request, \SS_HTTPResponse $response, \DataModel $model)
 {
     if (defined('PROXY_CACHE_GENERATING') || isset($GLOBALS['__cache_publish']) || strpos($request->getURL(), 'admin/') !== false) {
         return;
     }
     $this->database = Db::getConn();
     $queries = $this->database->queryRecord;
     $dupes = $this->database->getDuplicateQueries();
     $str = "\n<!-- Total queries: " . count($queries) . "-->\n";
     $str .= "\n<!-- Duplicate queries: " . count($dupes) . "-->\n";
     $b = $response->getBody();
     if (strpos($b, '</html>')) {
         if (count($queries) > $this->queryThreshold) {
             // add a floating div with info about the stuff
             $buildQueryList = function ($source, $class) {
                 $html = '';
                 foreach ($source as $sql => $info) {
                     $html .= "\n<p class='{$class}' style='display: none; border-top: 1px dashed #000;'>{$info->count} : {$info->query}</p>\n";
                     if ($info->source) {
                         $html .= "\n<p class='{$class}' style='color: #a00; display: none; '>Last called from {$info->source}</p>\n";
                     }
                 }
                 return $html;
             };
             $html = $buildQueryList($queries, 'debug-query');
             $html .= $buildQueryList($dupes, 'debug-dupe-query');
             $div = '<div id="query-stat-debugger" ' . 'style="position: fixed; bottom: 0; right: 0; border: 2px solid red; background: #fff; ' . 'font-size: 8px; font-family: sans-serif; width: 100px; z-index: 2000; padding: 1em;' . 'overflow: auto; max-height: 500px;">' . '<p id="debug-all-queries-list">Total of ' . count($queries) . ' queries</p>' . '<p id="debug-dupe-queries-list">Total of ' . count($dupes) . ' duplicates</p>' . $html . '<script>' . 'jQuery("#debug-all-queries-list").click(function () {' . 'var elems = jQuery(this).parent().find(".debug-query");' . 'jQuery(this).parent().css("width", "40%");' . 'elems.toggle();' . '}); ' . 'jQuery("#debug-dupe-queries-list").click(function () {' . 'var elems = jQuery(this).parent().find(".debug-dupe-query");' . 'jQuery(this).parent().css("width", "40%");' . 'elems.toggle();' . '}); ' . '' . '' . '</script>' . '</div>';
             $b = str_replace('</body>', "{$div}</body>", $b);
         }
         $b = str_replace('</html>', "{$str}</html>", $b);
         $response->setBody($b);
     }
 }
开发者ID:silverstripe-australia,项目名称:ssautesting,代码行数:33,代码来源:QueryDisplayFilter.php

示例6: onBeforeHTTPError404

 /**
  * On every URL that generates a 404, we'll capture it here and see if we can
  * find an old URL that it should be redirecting to.
  *
  * @param SS_HTTPRequest $request The request object
  * @throws SS_HTTPResponse_Exception
  */
 public function onBeforeHTTPError404($request)
 {
     // We need to get the URL ourselves because $request->allParams() only has a max of 4 params
     $params = preg_split('|/+|', $request->getURL());
     $cleanURL = trim(Director::makeRelative($request->getURL(false), '/'));
     $getvars = $request->getVars();
     unset($getvars['url']);
     $page = self::find_old_page($params);
     $cleanPage = trim(Director::makeRelative($page), '/');
     if (!$cleanPage) {
         $cleanPage = Director::makeRelative(RootURLController::get_homepage_link());
     }
     if ($page && $cleanPage != $cleanURL) {
         $res = new SS_HTTPResponse();
         $res->redirect(Controller::join_links($page, $getvars ? '?' . http_build_query($getvars) : null), 301);
         throw new SS_HTTPResponse_Exception($res);
     }
 }
开发者ID:aaronleslie,项目名称:aaronunix,代码行数:25,代码来源:OldPageRedirector.php

示例7: getUrl

 /**
  * Extract url, checks $_SERVER first to try and get raw url
  *
  * @param SS_HTTPRequest $request
  * @return string
  */
 public function getUrl($request)
 {
     if (!empty($_SERVER['REQUEST_URI'])) {
         return $_SERVER['REQUEST_URI'];
     } elseif (!empty($_GET['url'])) {
         return $_GET['url'];
     } else {
         return $request->getURL();
     }
 }
开发者ID:webtorque7,项目名称:old-urls,代码行数:16,代码来源:RedirectHandler.php

示例8: getRedirectForRequest

 /**
  * @param \SS_HTTPRequest $request
  * @return \Heyday\Redirects\Redirect
  */
 public function getRedirectForRequest(\SS_HTTPRequest $request)
 {
     $url = $request->getURL();
     foreach ($this->dataSource->get() as $redirect) {
         if ($redirect->match($url)) {
             return $redirect;
         }
     }
     return false;
 }
开发者ID:helpfulrobot,项目名称:heyday-silverstripe-redirects,代码行数:14,代码来源:Redirector.php

示例9: UpdateContinentBasedOnURL

 /**
  * @param SS_HTTPRequest $request
  */
 public static function UpdateContinentBasedOnURL(SS_HTTPRequest $request)
 {
     if ($strURL = $request->getURL(false)) {
         $arrParts = explode('/', $strURL);
         foreach (ContinentalContent::GetContinents() as $strContinent => $strCode) {
             if ($strCode === $arrParts[0]) {
                 ContinentalContent::ForceUpdateContinent($strCode);
             }
         }
     }
 }
开发者ID:helpfulrobot,项目名称:silverstripers-continental-content,代码行数:14,代码来源:ContinentsRequestFilter.php

示例10: onBeforeHTTPError404

 /**
  * On every URL that generates a 404, we'll capture it here and see if we can
  * find an old URL that it should be redirecting to.
  *
  * @param SS_HTTPRequest $request The request object
  * @throws SS_HTTPResponse_Exception
  */
 public function onBeforeHTTPError404($request)
 {
     // We need to get the URL ourselves because $request->allParams() only has a max of 4 params
     $params = preg_split('|/+|', $request->getURL());
     $getvars = $request->getVars();
     unset($getvars['url']);
     $page = self::find_old_page($params);
     if ($page) {
         $res = new SS_HTTPResponse();
         $res->redirect(Controller::join_links($page, $getvars ? '?' . http_build_query($getvars) : null), 301);
         throw new SS_HTTPResponse_Exception($res);
     }
 }
开发者ID:helpfulrobot,项目名称:comperio-silverstripe-cms,代码行数:20,代码来源:OldPageRedirector.php

示例11: getRedirectForRequest

 /**
  * @param \SS_HTTPRequest $request
  * @return \Heyday\Redirects\Redirect
  */
 public function getRedirectForRequest(\SS_HTTPRequest $request)
 {
     // Format the URL as the key will have been formatted
     $url = Redirect::formatUrl($request->getURL());
     $dataSource = $this->dataSource->get();
     // Check if there's a key for the URL
     if (isset($dataSource[$url])) {
         $redirect = $dataSource[$url];
         if ($redirect->match($url)) {
             return $redirect;
         }
     }
     return false;
 }
开发者ID:heyday,项目名称:silverstripe-redirects,代码行数:18,代码来源:Redirector.php

示例12: preRequest

 /**
  * Check if we're in a login request. If so, we're going to explicitly disable
  * restrictedobjects permission checks. This is poor, but dictated by the core
  * member login code performing writes prior to having a user context.
  * 
  * @param \SS_HTTPRequest $request
  * @param \Session $session
  * @param \DataModel $model
  */
 public function preRequest(\SS_HTTPRequest $request, \Session $session, \DataModel $model)
 {
     if (strtolower($request->httpMethod()) === 'post' && ($request->getURL() === 'Security/LoginForm' || $request->getURL() === 'Security/LostPasswordForm' || $request->getURL() === 'Security/ChangePasswordForm')) {
         Restrictable::set_enabled(false);
     }
 }
开发者ID:nyeholt,项目名称:silverstripe-restrictedobjects,代码行数:15,代码来源:MemberLoginFilter.php

示例13: createSpamAttempt

 /**
  * Creates a failed spam attempt object witht the user's info
  *
  * @param SS_HTTPRequest
  * @return ContactFormSpamAttempt
  */
 public function createSpamAttempt(SS_HTTPRequest $r)
 {
     $spam = ContactFormSpamAttempt::create(array('IPAddress' => $r->getIP(), 'URL' => $r->getURL(), 'Notes' => $this->class));
     return $spam;
 }
开发者ID:helpfulrobot,项目名称:silverstripe-contact-form,代码行数:11,代码来源:ContactFormSpamProtector.php

示例14: detail

 /**
  * Action to show a product detail page.
  * Returns the rendered detail page.
  * 
  * @param SS_HTTPRequest $request Request
  * 
  * @return string
  * 
  * @author Sebastian Diel <sdiel@pixeltricks.de>
  * @since 03.07.2013
  */
 public function detail(SS_HTTPRequest $request)
 {
     $params = $request->allParams();
     $productID = $params['ID'];
     $product = SilvercartProduct::get()->byID($productID);
     $productLink = $product->Link();
     $calledLink = $request->getURL();
     if (strpos($calledLink, '/') != strpos($productLink, '/')) {
         if (strpos($productLink, '/') == 0) {
             $calledLink = '/' . $calledLink;
         } elseif (strpos($calledLink, '/') == 0) {
             $productLink = '/' . $productLink;
         }
     }
     if ($calledLink != $productLink) {
         SilvercartTools::redirectPermanentlyTo($productLink);
     }
     $this->setProduct($product);
     return $this->render();
 }
开发者ID:silvercart,项目名称:silvercart,代码行数:31,代码来源:SilvercartProductGroupPage.php

示例15: postRequest

 /**
  *	Attempt to redirect towards the highest priority link mapping that may have been defined.
  *
  *	@URLparameter direct <{BYPASS_LINK_MAPPINGS}> boolean
  */
 public function postRequest(SS_HTTPRequest $request, SS_HTTPResponse $response, DataModel $model)
 {
     // Bypass the request filter when requesting specific director rules such as "/admin" or "/dev".
     $requestURL = $request->getURL();
     $configuration = Config::inst();
     foreach ($configuration->get('Director', 'rules') as $segment => $controller) {
         // Retrieve the specific director rules.
         if (($position = strpos($segment, '$')) !== false) {
             $segment = rtrim(substr($segment, 0, $position), '/');
         }
         // Determine if the current request matches a specific director rule.
         if ($segment && strpos($requestURL, $segment) === 0) {
             // Continue processing the response.
             return true;
         }
     }
     // Bypass the request filter when using the direct GET parameter.
     if ($request->getVar('direct')) {
         // Continue processing the response.
         return true;
     }
     // Determine the default automated URL handling response status.
     $status = $response->getStatusCode();
     $success = $status >= 200 && $status < 300;
     $error = $status === 404;
     // Either hook into a page not found, or when enforced, replace the default automated URL handling.
     $enforce = $configuration->get('MisdirectionRequestFilter', 'enforce_misdirection');
     $replace = $configuration->get('MisdirectionRequestFilter', 'replace_default');
     if (($error || $enforce || $replace) && ($map = $this->service->getMappingByRequest($request))) {
         // Update the response code where appropriate.
         $responseCode = $map->ResponseCode;
         if ($responseCode == 0) {
             $responseCode = 303;
         } else {
             if ($responseCode == 301 && $map->ForwardPOSTRequest) {
                 $responseCode = 308;
             } else {
                 if ($responseCode == 303 && $map->ForwardPOSTRequest) {
                     $responseCode = 307;
                 }
             }
         }
         // Update the response using the link mapping redirection.
         $response->redirect($map->getLink(), $responseCode);
     } else {
         if ($error && ($fallback = $this->service->determineFallback($requestURL))) {
             // Update the response code where appropriate.
             $responseCode = $fallback['code'];
             if ($responseCode === 0) {
                 $responseCode = 303;
             }
             // Update the response using the fallback, enforcing no further redirection.
             $response->redirect(HTTP::setGetVar('direct', true, Controller::join_links(Director::absoluteBaseURL(), $fallback['link'])), $responseCode);
         } else {
             if (!$error && !$success && $replace) {
                 $response->setStatusCode(404);
                 // Retrieve the appropriate page not found response.
                 ClassInfo::exists('SiteTree') && ($page = ErrorPage::response_for(404)) ? $response->setBody($page->getBody()) : $response->setBody('No URL was matched!');
             }
         }
     }
     // Continue processing the response.
     return true;
 }
开发者ID:helpfulrobot,项目名称:nglasl-silverstripe-misdirection,代码行数:69,代码来源:MisdirectionRequestFilter.php


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