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


PHP JUri::setUser方法代码示例

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


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

示例1: fetchUrl

 /**
  * Method to build and return a full request URL for the request.  This method will
  * add appropriate pagination details if necessary and also prepend the API url
  * to have a complete URL for the request.
  *
  * @param   string   $path   URL to inflect
  * @param   integer  $page   Page to request
  * @param   integer  $limit  Number of results to return per page
  *
  * @return  string   The request URL.
  *
  * @since   11.3
  */
 protected function fetchUrl($path, $page = 0, $limit = 0)
 {
     // Get a new JUri object fousing the api url and given path.
     $uri = new JUri($this->options->get('api.url') . $path);
     if ($this->options->get('gh.token', false)) {
         // Use oAuth authentication - @todo set in request header ?
         $uri->setVar('access_token', $this->options->get('gh.token'));
     } else {
         // Use basic authentication
         if ($this->options->get('api.username', false)) {
             $uri->setUser($this->options->get('api.username'));
         }
         if ($this->options->get('api.password', false)) {
             $uri->setPass($this->options->get('api.password'));
         }
     }
     // If we have a defined page number add it to the JUri object.
     if ($page > 0) {
         $uri->setVar('page', (int) $page);
     }
     // If we have a defined items per page add it to the JUri object.
     if ($limit > 0) {
         $uri->setVar('per_page', (int) $limit);
     }
     return (string) $uri;
 }
开发者ID:sural98,项目名称:joomla-cms,代码行数:39,代码来源:object.php

示例2: fetchUrl

 /**
  * Build and return a full request URL.
  *
  * This method will add appropriate pagination details and basic authentication credentials if necessary
  * and also prepend the API url to have a complete URL for the request.
  *
  * @param   string   $path   URL to inflect
  * @param   integer  $page   Page to request
  * @param   integer  $limit  Number of results to return per page
  *
  * @return  string   The request URL.
  *
  * @since   3.0.0
  */
 protected function fetchUrl($path, $page = 0, $limit = 0)
 {
     // Get a new JUri object fousing the api url and given path.
     $uri = new \JUri($this->options->get('api.url') . $path);
     // Only apply basic authentication if an access token is not set
     if ($this->options->get('gh.token', false) === false) {
         // Use basic authentication
         if ($this->options->get('api.username', false)) {
             $username = $this->options->get('api.username');
             $username = str_replace('@', '%40', $username);
             $uri->setUser($username);
         }
         if ($this->options->get('api.password', false)) {
             $password = $this->options->get('api.password');
             $password = str_replace('@', '%40', $password);
             $uri->setPass($password);
         }
     }
     // If we have a defined page number add it to the JUri object.
     if ($page > 0) {
         $uri->setVar('page', (int) $page);
     }
     // If we have a defined items per page add it to the JUri object.
     if ($limit > 0) {
         $uri->setVar('per_page', (int) $limit);
     }
     return (string) $uri;
 }
开发者ID:andrepereiradasilva,项目名称:patchtester,代码行数:42,代码来源:GitHub.php

示例3: fetchUrl

 /**
  * Method to build and return a full request URL for the request.
  *
  * @param   string  $path  URL to inflect
  *
  * @return  string   The request URL.
  *
  * @since   12.3
  */
 protected function fetchUrl($path)
 {
     // Append the path with output format
     $path .= '&format=xml';
     $uri = new JUri($this->options->get('api.url') . '/api.php' . $path);
     if ($this->options->get('api.username', false)) {
         $uri->setUser($this->options->get('api.username'));
     }
     if ($this->options->get('api.password', false)) {
         $uri->setPass($this->options->get('api.password'));
     }
     return (string) $uri;
 }
开发者ID:deenison,项目名称:joomla-cms,代码行数:22,代码来源:object.php

示例4: fetchUrl

 /**
  * Method to build and return a full request URL for the request.  This method will
  * add appropriate pagination details if necessary and also prepend the API url
  * to have a complete URL for the request.
  *
  * @param string  $path  URL to inflect
  * @param integer $page  Page to request
  * @param integer $limit Number of results to return per page
  *
  * @return string The request URL.
  *
  * @since   11.3
  */
 protected function fetchUrl($path, $page = 0, $limit = 0)
 {
     // Get a new JUri object fousing the api url and given path.
     $uri = new JUri($this->options->get('api.url') . $path);
     if ($this->options->get('api.username', false)) {
         $uri->setUser($this->options->get('api.username'));
     }
     if ($this->options->get('api.password', false)) {
         $uri->setPass($this->options->get('api.password'));
     }
     // If we have a defined page number add it to the JUri object.
     if ($page > 0) {
         $uri->setVar('page', (int) $page);
     }
     // If we have a defined items per page add it to the JUri object.
     if ($limit > 0) {
         $uri->setVar('per_page', (int) $limit);
     }
     return (string) $uri;
 }
开发者ID:houzhenggang,项目名称:cobalt,代码行数:33,代码来源:object.php

示例5: testSetUser

 /**
  * Test the setUser method.
  *
  * @return  void
  *
  * @since   11.1
  * @covers  JUri::setUser
  */
 public function testSetUser()
 {
     $this->object->setUser('root');
     $this->assertThat($this->object->getUser(), $this->equalTo('root'));
 }
开发者ID:shoffmann52,项目名称:install-from-web-server,代码行数:13,代码来源:JURITest.php

示例6: redirectToDownload

 /**
  * redirectToDownload
  *
  * @return  void
  *
  * @throws \Exception
  */
 public static function redirectToDownload()
 {
     $username = isset($_SERVER['PHP_AUTH_USER']) ? $_SERVER['PHP_AUTH_USER'] : null;
     $password = isset($_SERVER['PHP_AUTH_PW']) ? $_SERVER['PHP_AUTH_PW'] : null;
     $input = \JFactory::getApplication()->input;
     $uri = new \JUri(\JUri::root());
     $uri->setUser($username);
     $uri->setPass($password);
     $uri->setVar('access_token', $input->get('access_token'));
     $uri->setVar('cmd', 'backup.download');
     \JFactory::getApplication()->redirect($uri);
     exit;
 }
开发者ID:lyrasoft,项目名称:lyrasoft.github.io,代码行数:20,代码来源:Backup.php

示例7: request

 /**
  * Send a request to the server and return a JHttpResponse object with the response.
  *
  * @param   string   $method     The HTTP method for sending the request.
  * @param   JUri     $uri        The URI to the resource to request.
  * @param   mixed    $data       Either an associative array or a string to be sent with the request.
  * @param   array    $headers    An array of request headers to send with the request.
  * @param   integer  $timeout    Read timeout in seconds.
  * @param   string   $userAgent  The optional user agent string to send with the request.
  *
  * @return  JHttpResponse
  *
  * @since   11.3
  * @throws  RuntimeException
  */
 public function request($method, JUri $uri, $data = null, array $headers = null, $timeout = null, $userAgent = null)
 {
     // Create the stream context options array with the required method offset.
     $options = array('method' => strtoupper($method));
     // If data exists let's encode it and make sure our Content-Type header is set.
     if (isset($data)) {
         // If the data is a scalar value simply add it to the stream context options.
         if (is_scalar($data)) {
             $options['content'] = $data;
         } else {
             $options['content'] = http_build_query($data);
         }
         if (!isset($headers['Content-Type'])) {
             $headers['Content-Type'] = 'application/x-www-form-urlencoded; charset=utf-8';
         }
         // Add the relevant headers.
         $headers['Content-Length'] = strlen($options['content']);
     }
     // If an explicit timeout is given user it.
     if (isset($timeout)) {
         $options['timeout'] = (int) $timeout;
     }
     // If an explicit user agent is given use it.
     if (isset($userAgent)) {
         $options['user_agent'] = $userAgent;
     }
     // Ignore HTTP errors so that we can capture them.
     $options['ignore_errors'] = 1;
     // Follow redirects.
     $options['follow_location'] = (int) $this->options->get('follow_location', 1);
     // Set any custom transport options
     foreach ($this->options->get('transport.stream', array()) as $key => $value) {
         $options[$key] = $value;
     }
     // Add the proxy configuration, if any.
     $config = JFactory::getConfig();
     if ($config->get('proxy_enable')) {
         $options['proxy'] = $config->get('proxy_host') . ':' . $config->get('proxy_port');
         $options['request_fulluri'] = true;
         // Put any required authorization into the headers array to be handled later
         // TODO: do we need to support any auth type other than Basic?
         if ($user = $config->get('proxy_user')) {
             $auth = base64_encode($config->get('proxy_user') . ':' . $config->get('proxy_pass'));
             $headers['Proxy-Authorization'] = 'Basic ' . $auth;
         }
     }
     // Build the headers string for the request.
     $headerEntries = array();
     if (isset($headers)) {
         foreach ($headers as $key => $value) {
             $headerEntries[] = $key . ': ' . $value;
         }
         // Add the headers string into the stream context options array.
         $options['header'] = implode("\r\n", $headerEntries);
     }
     // Get the current context options.
     $contextOptions = stream_context_get_options(stream_context_get_default());
     // Add our options to the current ones, if any.
     $contextOptions['http'] = isset($contextOptions['http']) ? array_merge($contextOptions['http'], $options) : $options;
     // Create the stream context for the request.
     $context = stream_context_create(array('http' => $options, 'ssl' => array('verify_peer' => true, 'cafile' => $this->options->get('stream.certpath', __DIR__ . '/cacert.pem'), 'verify_depth' => 5)));
     // Authentification, if needed
     if ($this->options->get('userauth') && $this->options->get('passwordauth')) {
         $uri->setUser($this->options->get('userauth'));
         $uri->setPass($this->options->get('passwordauth'));
     }
     // Capture PHP errors
     $php_errormsg = '';
     $track_errors = ini_get('track_errors');
     ini_set('track_errors', true);
     // Open the stream for reading.
     $stream = @fopen((string) $uri, 'r', false, $context);
     if (!$stream) {
         if (!$php_errormsg) {
             // Error but nothing from php? Create our own
             $php_errormsg = sprintf('Could not connect to resource: %s', $uri, $err, $errno);
         }
         // Restore error tracking to give control to the exception handler
         ini_set('track_errors', $track_errors);
         throw new RuntimeException($php_errormsg);
     }
     // Restore error tracking to what it was before.
     ini_set('track_errors', $track_errors);
     // Get the metadata for the stream, including response headers.
     $metadata = stream_get_meta_data($stream);
//.........这里部分代码省略.........
开发者ID:joomla-projects,项目名称:media-manager-improvement,代码行数:101,代码来源:stream.php

示例8: _testSessionInit

 /**
  * Get session start time
  */
 protected function _testSessionInit()
 {
     $uri = new JUri(JUri::root());
     if (isset($_SERVER['PHP_AUTH_PW']) && $_SERVER['PHP_AUTH_PW']) {
         $uri->setPass($_SERVER['PHP_AUTH_PW']);
     }
     if (isset($_SERVER['PHP_AUTH_USER']) && $_SERVER['PHP_AUTH_USER']) {
         $uri->setUser($_SERVER['PHP_AUTH_USER']);
     }
     $requestUrl = $uri->toString() . 'media/zoo/applications/jbuniversal/tools/test-session.php';
     $values = array();
     for ($j = 0; $j < 10; $j++) {
         $values[] = (double) $this->app->jbhttp->request($requestUrl . '?nocache=' . mt_rand());
     }
     return array_sum($values) / doubleval(count($values));
 }
开发者ID:alexmixaylov,项目名称:real,代码行数:19,代码来源:jbperform.php


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