當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Uri類代碼示例

本文整理匯總了PHP中Uri的典型用法代碼示例。如果您正苦於以下問題:PHP Uri類的具體用法?PHP Uri怎麽用?PHP Uri使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Uri類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: parse

 /**
  * Parses the string and returns the {@link Uri}.
  * 
  * Parses the string and returns the {@link Uri}. If parsing fails, null is returned.
  * 
  * @param String $string The url.
  * 
  * @return \Bumble\Uri\Uri The Uri object.
  */
 public function parse($string)
 {
     $data = parse_url($string);
     //helper function gets $a[$k], checks if exists
     function get($a, $k)
     {
         if (array_key_exists($k, $a)) {
             return empty($a[$k]) ? null : $a[$k];
         }
         return null;
     }
     if ($data === null) {
         return null;
     }
     $uri = new Uri();
     $uri->setProtocol(get($data, 'scheme'));
     $uri->setUsername(get($data, 'user'));
     $uri->setPassword(get($data, 'pass'));
     $uri->setHost(get($data, 'host'));
     $uri->setPort(get($data, 'port'));
     $uri->setPath(get($data, 'path'));
     $uri->setQuery(get($data, 'query'));
     $uri->setAnchor(get($data, 'anchor'));
     return $uri;
 }
開發者ID:Attibee,項目名稱:Bumble-Uri,代碼行數:34,代碼來源:Tokenizer.php

示例2: dispatch

 /**
  * @param \Components\Http_Scriptlet_Context $context_
  * @param \Components\Uri $uri_
  */
 public static function dispatch(Http_Scriptlet_Context $context_, Uri $uri_)
 {
     $key = $uri_->getFilename();
     if (!($path = Cache::get($key))) {
         throw new Http_Exception('ui/scriptlet/image', null, Http_Exception::NOT_FOUND);
     }
     // TODO Cache headers.
     readfile($path);
 }
開發者ID:evalcodenet,項目名稱:net.evalcode.components.ui,代碼行數:13,代碼來源:image.php

示例3: match

 public function match(FilterableUri $uri)
 {
     /*
      * if the URI does not contain the seed, it is not allowed
      */
     if (false === stripos($uri->toString(), $this->seed->toString())) {
         $uri->setFiltered(true, 'Doesn\'t match base URI');
         return true;
     }
     return false;
 }
開發者ID:aigouzz,項目名稱:php-spider,代碼行數:11,代碼來源:RestrictToBaseUriFilter.php

示例4: dispatch

 public static function dispatch(Http_Scriptlet_Context $context_, Uri $uri_)
 {
     $params = $uri_->getPathParams();
     $storeName = array_shift($params);
     $categoryName = array_shift($params);
     $file = Io::fileUpload();
     $store = Media::store($storeName);
     $store->add($file, $file->getName(), $categoryName);
     // TODO JSON
     echo $store->uri($file->getName(), $categoryName);
 }
開發者ID:evalcodenet,項目名稱:net.evalcode.components.media,代碼行數:11,代碼來源:upload.php

示例5: testGettersAndSetters

 public function testGettersAndSetters()
 {
     $uri1 = new Uri('');
     $uri2 = $uri1->withScheme('HTTP')->withUserInfo('foo', 'bar')->withHost('EXAMPLE.com')->withPort(81)->withPath('/FOO/bar')->withQuery('a=2&b=3')->withFragment('foobar');
     $this->assertEquals('http', $uri2->getScheme());
     $this->assertEquals('foo:bar', $uri2->getUserInfo());
     $this->assertEquals('example.com', $uri2->getHost());
     $this->assertEquals(81, $uri2->getPort());
     $this->assertEquals('/foo/bar', $uri2->getPath());
     $this->assertEquals('a=2&b=3', $uri2->getQuery());
     $this->assertEquals('foobar', $uri2->getFragment());
 }
開發者ID:jivoo,項目名稱:http,代碼行數:12,代碼來源:UriTest.php

示例6: dispatch

 /**
  * @param \Components\Http_Scriptlet_Context $context_
  * @param \Components\Uri $uri_
  */
 public static function dispatch(Http_Scriptlet_Context $context_, Uri $uri_)
 {
     $params = $uri_->getPathParams();
     $base64 = end($params);
     $info = unserialize(\str\decodeBase64Url($base64));
     $path = array_shift($info);
     $id = array_shift($info);
     $category = array_shift($info);
     $scheme = array_shift($info);
     $store = Media::store($path);
     $file = $store->findByScheme($scheme, $id, $category);
     header('Content-Length: ' . $file->getSize()->bytes());
     readfile((string) $file);
 }
開發者ID:evalcodenet,項目名稱:net.evalcode.components.media,代碼行數:18,代碼來源:image.php

示例7: getSegments

 private function getSegments()
 {
     $uri = $this->uri;
     foreach ($this->route as $key => $val) {
         if (preg_match('#^' . $key . '$#', $uri)) {
             if (strpos($val, '$') !== false && strpos($key, '(') !== false) {
                 $uri = preg_replace('#^' . $key . '$#', $val, $this->uri);
             }
         }
     }
     $uri = new Uri($uri);
     $segments = $uri->explodeSegments();
     return $segments;
 }
開發者ID:Whispersong,項目名稱:phputils,代碼行數:14,代碼來源:router.php

示例8: Anchor

 public static function Anchor($uri, $title = NULL, $attributes = NULL, $protocol = NULL, $escape_title = FALSE)
 {
     /**
      * Create HTML link anchors.
      *
      * @param   string  URL or URI string
      * @param   string  link text
      * @param   array   HTML anchor attributes
      * @param   string  non-default protocol, eg: https
      * @param   boolean option to escape the title that is output
      * @return  string
      */
     if ($protocol === NULL) {
         $protocol = getenv('HTTPS') == 'on' ? 'https' : 'http';
     }
     if (strpos($uri, '#') === 0) {
         // This is an id target link, not a URL
         $site_url = $uri;
     } elseif (strpos($uri, '://') === FALSE) {
         $site_url = Uri::baseUrl() . $uri;
     } else {
         //$attributes['target'] = '_blank';
         $site_url = $uri;
     }
     return '<a href="' . $site_url . '"' . (is_array($attributes) ? htmlAttributes($attributes) : '') . '>' . ($escape_title ? htmlspecialchars($title === NULL ? $site_url : $title, ENT_QUOTES, 'UTF-8', FALSE) : ($title === NULL ? $site_url : $title)) . '</a>';
 }
開發者ID:robotamer,項目名稱:oldstuff,代碼行數:26,代碼來源:Html.php

示例9: include_client_scripts

 protected function include_client_scripts($scripts = 'default')
 {
     if (empty($scripts)) {
         return;
     }
     if (!is_array($scripts)) {
         $scripts = array($scripts);
     }
     foreach ($scripts as $script) {
         if (empty($this->client_scripts_included[$script])) {
             switch ($script) {
                 case 'default':
                     $this->template->scripts[] = $this->create_js_link("//cdnjs.cloudflare.com/ajax/libs/jquery/1.11.2/jquery.min.js");
                     $this->template->scripts[] = $this->create_js_link("//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.4/js/bootstrap.min.js");
                     $this->template->css[] = $this->create_css_link("//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.4/css/bootstrap.min.css");
                     $this->template->css[] = $this->create_css_link(Uri::create('assets/css/style.css'));
                     break;
                 case 'jquery_forms':
                     $this->template->scripts[] = $this->create_js_link("//cdnjs.cloudflare.com/ajax/libs/qtip2/2.2.0/jquery.qtip.min.js");
                     $this->template->scripts[] = $this->create_js_link("//cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.14.0/jquery.validate.min.js");
                     $this->template->scripts[] = $this->create_js_link("//cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.14.0/additional-methods.min.js");
                     $this->template->scripts[] = $this->create_js_link("//cdnjs.cloudflare.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js");
                     $this->template->scripts[] = $this->create_js_link(Uri::create('assets/js/jquery-forms-config.js'));
                     array_unshift($this->template->css, $this->create_css_link('//cdnjs.cloudflare.com/ajax/libs/qtip2/2.2.0/jquery.qtip.min.css'));
                     array_unshift($this->template->css, $this->create_css_link("//cdnjs.cloudflare.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.css"));
                     break;
             }
             $this->client_scripts_included[$script] = true;
             //don't include the same script more than once
         }
     }
 }
開發者ID:jkapelner,項目名稱:chatroom-web-server,代碼行數:32,代碼來源:base.php

示例10: notify

 /**
  * Because Paypal Ipn is redirected to \Payment\PayPal\ipn
  * There is no need to notify customer here, we'll do that in Ipn method of Payment module
  */
 public function notify()
 {
     $config = array('mode' => $this->config['mode'], 'acct1.UserName' => $this->config['user_name'], 'acct1.Password' => $this->config['password'], 'acct1.Signature' => $this->config['signature']);
     $paypalService = new \PayPal\Service\PayPalAPIInterfaceServiceService($config);
     $getExpressCheckoutDetailsRequest = new \PayPal\PayPalAPI\GetExpressCheckoutDetailsRequestType(\Session::get('paypal.token'));
     $getExpressCheckoutDetailsRequest->Version = $this->config['version'];
     $getExpressCheckoutReq = new \PayPal\PayPalAPI\GetExpressCheckoutDetailsReq();
     $getExpressCheckoutReq->GetExpressCheckoutDetailsRequest = $getExpressCheckoutDetailsRequest;
     $getECResponse = $paypalService->GetExpressCheckoutDetails($getExpressCheckoutReq);
     // COMMIT THE PAYMENT
     $paypalService = new \PayPal\Service\PayPalAPIInterfaceServiceService($config);
     $paymentDetails = new \PayPal\EBLBaseComponents\PaymentDetailsType();
     $orderTotal = new \PayPal\CoreComponentTypes\BasicAmountType($this->config['currency'], $this->getOrderTotal());
     $paymentDetails->OrderTotal = $orderTotal;
     $paymentDetails->PaymentAction = 'Sale';
     $paymentDetails->NotifyURL = $this->config['notify_url'];
     $DoECRequestDetails = new \PayPal\EBLBaseComponents\DoExpressCheckoutPaymentRequestDetailsType();
     $DoECRequestDetails->PayerID = $getECResponse->GetExpressCheckoutDetailsResponseDetails->PayerInfo->PayerID;
     $DoECRequestDetails->Token = $getECResponse->GetExpressCheckoutDetailsResponseDetails->Token;
     $DoECRequestDetails->PaymentDetails[0] = $paymentDetails;
     $DoECRequest = new \PayPal\PayPalAPI\DoExpressCheckoutPaymentRequestType();
     $DoECRequest->DoExpressCheckoutPaymentRequestDetails = $DoECRequestDetails;
     $DoECRequest->Version = $this->config['version'];
     $DoECReq = new \PayPal\PayPalAPI\DoExpressCheckoutPaymentReq();
     $DoECReq->DoExpressCheckoutPaymentRequest = $DoECRequest;
     $DoECResponse = $paypalService->DoExpressCheckoutPayment($DoECReq);
     if ($DoECResponse->Ack == 'Success') {
         $this->savePayment('Completed', 'Completed', $DoECResponse->toXMLString());
         \Response::redirect(\Uri::create('order/checkout/finalise_order'));
     }
     $this->savePayment('Failed', 'Transaction failed', $DoECResponse->Errors[0]->LongMessage);
     return true;
     // failed
 }
開發者ID:EdgeCommerce,項目名稱:edgecommerce,代碼行數:38,代碼來源:paymentProccessTypePaypal.php

示例11: action_index

 public function action_index()
 {
     $this->template = View::forge("teachers/template");
     $this->template->auth_status = false;
     $this->template->title = "Forgotpassword";
     // login
     if (Input::post("email", null) !== null and Security::check_token()) {
         $email = Input::post('email', null);
         $user = Model_User::find("first", ["where" => [["email", $email]]]);
         if ($user != null) {
             $token = Model_Forgotpasswordtoken::forge();
             $token->user_id = $user->id;
             $token->token = sha1("asadsada23424{$user->email}" . time());
             $token->save();
             $url = Uri::base() . "teachers/forgotpassword/form/{$token->token}";
             $body = View::forge("email/forgotpassword", ["url" => $url]);
             $sendmail = Email::forge("JIS");
             $sendmail->from(Config::get("statics.info_email"), Config::get("statics.info_name"));
             $sendmail->to($email);
             $sendmail->subject("forgot password");
             $sendmail->html_body(htmlspecialchars_decode($body));
             $sendmail->send();
         }
         $view = View::forge("teachers/forgotpassword/sent");
         $this->template->content = $view;
     } else {
         $view = View::forge("teachers/forgotpassword/index");
         $this->template->content = $view;
     }
 }
開發者ID:Trd-vandolph,項目名稱:game-bootcamp,代碼行數:30,代碼來源:forgotpassword.php

示例12: testDispatch

 /**
  * @test
  * @profile
  */
 public function testDispatch()
 {
     split_time('reset');
     Rest_Test_Unit_Case_Resource_Foo::serve('resource/foo');
     split_time('Invoke Rest_Test_Unit_Case_Resource_Foo::serve(resource/foo)');
     Http_Scriptlet_Context::push(new Http_Scriptlet_Context(Environment::uriComponents()));
     split_time('Initialize Components\\Http_Scriptlet_Context');
     $uri = Uri::valueOf(Environment::uriComponents('rest', 'resource', 'foo', 'poke', '1234.json'));
     split_time("Invoke Uri::valueOf({$uri})");
     ob_start();
     split_time('reset');
     Http_Scriptlet_Context::current()->dispatch($uri, Http_Scriptlet_Request::METHOD_GET);
     split_time("Invoke Components\\Http_Scriptlet_Context\$dispatch([{$uri}], GET)");
     $result = ob_get_clean();
     assertEquals(json_encode(true), $result);
     split_time('reset');
     $uri = Uri::valueOf(Environment::uriComponents('rest', 'resource', 'foo', 'poke', '1234.json'));
     $uri->setQueryParam('log', 'false');
     split_time("Invoke Uri::valueOf({$uri})");
     ob_start();
     split_time('reset');
     Http_Scriptlet_Context::current()->dispatch($uri, Http_Scriptlet_Request::METHOD_GET);
     split_time("Invoke Components\\Http_Scriptlet_Context\$dispatch([{$uri}], GET)");
     $result = ob_get_clean();
     assertEquals(json_encode(false), $result);
 }
開發者ID:evalcodenet,項目名稱:net.evalcode.components.rest,代碼行數:30,代碼來源:resource.php

示例13: _send_instructions

 /**
  * Sends the instructions to a user's email address.
  *
  * @return bool
  */
 private static function _send_instructions($name, Model_User $user)
 {
     $config_key = null;
     switch ($name) {
         case 'confirmation':
             $config_key = 'confirmable';
             break;
         case 'reset_password':
             $config_key = 'recoverable';
             break;
         case 'unlock':
             $config_key = 'lockable';
             break;
         default:
             throw new \InvalidArgumentException("Invalid instruction: {$name}");
     }
     $mail = \Email::forge();
     $mail->from(\Config::get('email.defaults.from.email'), \Config::get('email.defaults.from.name'));
     $mail->to($user->email);
     $mail->subject(__("warden.mailer.subject.{$name}"));
     $token_name = "{$name}_token";
     $mail->html_body(\View::forge("warden/mailer/{$name}_instructions", array('username' => $user->username, 'uri' => \Uri::create(':url/:token', array('url' => rtrim(\Config::get("warden.{$config_key}.url"), '/'), 'token' => $user->{$token_name})))));
     $mail->priority(\Email::P_HIGH);
     try {
         return $mail->send();
     } catch (\EmailSendingFailedException $ex) {
         logger(\Fuel::L_ERROR, "Warden\\Mailer failed to send {$name} instructions.");
         return false;
     }
 }
開發者ID:jkapelner,項目名稱:chatroom-web-server,代碼行數:35,代碼來源:mailer.php

示例14: index

 public function index()
 {
     Cache::loadPage('', 30);
     $inputData = array();
     $postid = 0;
     Model::loadWithPath('page', System::getThemePath() . 'model/');
     if (!($match = Uri::match('page\\/(.*?)\\.html$'))) {
         Redirect::to('404page');
     }
     $friendly_url = addslashes($match[1]);
     $loadData = Pages::get(array('cacheTime' => 30, 'where' => "where friendly_url='{$friendly_url}'"));
     if (!isset($loadData[0]['pageid'])) {
         Redirect::to('404page');
     }
     $inputData = $loadData[0];
     $postid = $loadData[0]['pageid'];
     if (Uri::isNull()) {
         System::setTitle(ucfirst($loadData[0]['title']));
     }
     $keywords = isset($loadData[0]['keywords'][4]) ? $loadData[0]['keywords'] : System::getKeywords();
     System::setKeywords($keywords);
     if ($loadData[0]['page_type'] == 'fullwidth') {
         self::makeContent('pageFullWidth', $inputData);
     } else {
         self::makeContent('page', $inputData);
     }
     Cache::savePage();
 }
開發者ID:neworldwebsites,項目名稱:noblessecms,代碼行數:28,代碼來源:themePage.php

示例15: parseUrl

 /**
  * Parse url and reroute with routes.xml rules if found
  * 
  * @return Uri      Return the instance of Uri (rerouted or not) 
  */
 public function parseUrl()
 {
     // Get new instance of Uri
     $uriInst = Uri::getInstance();
     // Remove first / from uri
     $uri = trim($uriInst->getUri(false), '/');
     // Init vars
     $defaultRedirect = null;
     // Parse routes
     foreach ($this->_routes as $route) {
         // Converts shortcuts to regexp
         $rule = str_replace(':any', '.+', str_replace(':num', '[0-9]+', $route->attributes()->rule));
         // Rule match to uri
         if (preg_match('#^' . $rule . '$#', $uri)) {
             // Is there any back reference
             if (strpos($route->attributes()->redirect, '$') !== false && strpos($rule, '(') !== false) {
                 $uri = preg_replace('#^' . $rule . '$#', $route->attributes()->redirect, $uri);
             } else {
                 $uri = $route->attributes()->redirect;
             }
             // Define rerouted uri to current instance of Uri
             return $uriInst->setUri($uri);
         }
         if ($rule === 'default') {
             $defaultRedirect = (string) $route->attributes()->redirect . '/' . $uri;
         }
     }
     if (!$uriInst->isDefined() && $defaultRedirect !== null) {
         $uriInst->setUri($defaultRedirect);
     }
     return $uriInst;
 }
開發者ID:salomalo,項目名稱:php-oxygen,代碼行數:37,代碼來源:route.class.php


注:本文中的Uri類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。