当前位置: 首页>>代码示例>>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;未经允许,请勿转载。