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


PHP JUri::getPort方法代码示例

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


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

示例1: connect

 /**
  * Method to connect to a server and get the resource.
  *
  * @param   JUri     $uri      The URI to connect with.
  * @param   integer  $timeout  Read timeout in seconds.
  *
  * @return  resource  Socket connection resource.
  *
  * @since   11.3
  * @throws  RuntimeException
  */
 protected function connect(JUri $uri, $timeout = null)
 {
     $errno = null;
     $err = null;
     // Get the host from the uri.
     $host = $uri->isSsl() ? 'ssl://' . $uri->getHost() : $uri->getHost();
     // If the port is not explicitly set in the URI detect it.
     if (!$uri->getPort()) {
         $port = $uri->getScheme() == 'https' ? 443 : 80;
     } else {
         $port = $uri->getPort();
     }
     // Build the connection key for resource memory caching.
     $key = md5($host . $port);
     // If the connection already exists, use it.
     if (!empty($this->connections[$key]) && is_resource($this->connections[$key])) {
         // Connection reached EOF, cannot be used anymore
         $meta = stream_get_meta_data($this->connections[$key]);
         if ($meta['eof']) {
             if (!fclose($this->connections[$key])) {
                 throw new RuntimeException('Cannot close connection');
             }
         } elseif (!$meta['timed_out']) {
             return $this->connections[$key];
         }
     }
     if (!is_numeric($timeout)) {
         $timeout = ini_get('default_socket_timeout');
     }
     // Capture PHP errors
     $php_errormsg = '';
     $track_errors = ini_get('track_errors');
     ini_set('track_errors', true);
     // PHP sends a warning if the uri does not exists; we silence it and throw an exception instead.
     // Attempt to connect to the server
     $connection = @fsockopen($host, $port, $errno, $err, $timeout);
     if (!$connection) {
         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);
     // Since the connection was successful let's store it in case we need to use it later.
     $this->connections[$key] = $connection;
     // If an explicit timeout is set, set it.
     if (isset($timeout)) {
         stream_set_timeout($this->connections[$key], (int) $timeout);
     }
     return $this->connections[$key];
 }
开发者ID:grlf,项目名称:eyedock,代码行数:66,代码来源:socket.php

示例2: _connect

 /**
  * Method to connect to a server and get the resource.
  *
  * @param   JUri   $uri  The URI to connect with.
  *
  * @return  mixed  Connection resource on success or boolean false on failure.
  *
  * @since   11.1
  */
 protected function _connect(JUri $uri)
 {
     // Initialize variables.
     $errno = null;
     $err = null;
     // Get the host from the uri.
     $host = $uri->isSSL() ? 'ssl://' . $uri->getHost() : $uri->getHost();
     // If the port is not explicitly set in the URI detect it.
     if (!$uri->getPort()) {
         $port = $uri->getScheme() == 'https' ? 443 : 80;
     } else {
         $port = $uri->getPort();
     }
     // Build the connection key for resource memory caching.
     $key = md5($host . $port);
     // If the connection already exists, use it.
     if (!empty($this->_connections[$key]) && is_resource($this->_connections[$key])) {
         // Make sure the connection has not timed out.
         $meta = stream_get_meta_data($this->_connections[$key]);
         if (!$meta['timed_out']) {
             return $this->_connections[$key];
         }
     }
     // Attempt to connect to the server.
     if ($this->_connections[$key] = fsockopen($host, $port, $errno, $err, $this->_timeout)) {
         stream_set_timeout($this->_connections[$key], $this->_timeout);
     }
     return $this->_connections[$key];
 }
开发者ID:carmerin,项目名称:cesae-web,代码行数:38,代码来源:http.php

示例3: connect

 /**
  * Method to connect to a server and get the resource.
  *
  * @param   JUri     $uri      The URI to connect with.
  * @param   integer  $timeout  Read timeout in seconds.
  *
  * @return  resource  Socket connection resource.
  *
  * @since   11.3
  * @throws  RuntimeException
  */
 protected function connect(JUri $uri, $timeout = null)
 {
     // Initialize variables.
     $errno = null;
     $err = null;
     // Get the host from the uri.
     $host = $uri->isSSL() ? 'ssl://' . $uri->getHost() : $uri->getHost();
     // If the port is not explicitly set in the URI detect it.
     if (!$uri->getPort()) {
         $port = $uri->getScheme() == 'https' ? 443 : 80;
     } else {
         $port = $uri->getPort();
     }
     // Build the connection key for resource memory caching.
     $key = md5($host . $port);
     // If the connection already exists, use it.
     if (!empty($this->connections[$key]) && is_resource($this->connections[$key])) {
         // Connection reached EOF, cannot be used anymore
         $meta = stream_get_meta_data($this->connections[$key]);
         if ($meta['eof']) {
             if (!fclose($this->connections[$key])) {
                 throw new RuntimeException('Cannot close connection');
             }
         } elseif (!$meta['timed_out']) {
             return $this->connections[$key];
         }
     }
     if (!is_numeric($timeout)) {
         $timeout = ini_get("default_socket_timeout");
     }
     // Attempt to connect to the server.
     $connection = fsockopen($host, $port, $errno, $err, $timeout);
     if (!$connection) {
         throw new RuntimeException($err, $errno);
     }
     // Since the connection was successful let's store it in case we need to use it later.
     $this->connections[$key] = $connection;
     // If an explicit timeout is set, set it.
     if (isset($timeout)) {
         stream_set_timeout($this->connections[$key], (int) $timeout);
     }
     return $this->connections[$key];
 }
开发者ID:exntu,项目名称:joomla-cms,代码行数:54,代码来源:socket.php

示例4: testSetPort

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

示例5: onAfterInitialise

 function onAfterInitialise()
 {
     /** @var JSite $app */
     $app = JFactory::getApplication();
     if ($app->isAdmin()) {
         // don't use MobileJoomla in backend
         return;
     }
     $is_joomla15 = $this->isJoomla15();
     //load MobileJoomla class
     require_once JPATH_ADMINISTRATOR . '/components/com_mobilejoomla/classes/mobilejoomla.php';
     //load config
     $MobileJoomla_Settings =& MobileJoomla::getConfig();
     $MobileJoomla_Device =& MobileJoomla::getDevice();
     // check for legacy redirect
     if (@$_GET['option'] == 'com_mobilejoomla' && @$_GET['task'] == 'setmarkup' && isset($_GET['markup']) && isset($_GET['return'])) {
         $desktop_uri = new JUri($MobileJoomla_Settings['desktop_url']);
         $uri = new JUri(base64_decode($_GET['return']));
         if (!$uri->getScheme()) {
             $uri->setScheme('http');
         }
         $uri->setHost($desktop_uri->getHost());
         $uri->setPort($desktop_uri->getPort());
         $app->redirect($uri->toString());
     }
     JPluginHelper::importPlugin('mobile');
     $cached_data = $app->getUserState('mobilejoomla.cache');
     if ($cached_data !== null) {
         $cached_data = @gzinflate(@base64_decode($cached_data));
         if ($cached_data !== false) {
             $cached_data = @unserialize($cached_data);
         }
     }
     if (is_array($cached_data)) {
         $MobileJoomla_Device = $cached_data['device'];
     } else {
         $app->triggerEvent('onDeviceDetection', array(&$MobileJoomla_Settings, &$MobileJoomla_Device));
         $gzlevel = 5;
         $cached_data = array('device' => $MobileJoomla_Device);
         $cached_data = base64_encode(gzdeflate(serialize($cached_data), $gzlevel));
         $app->setUserState('mobilejoomla.cache', $cached_data);
     }
     $MobileJoomla_Device['markup'] = self::CheckMarkup($MobileJoomla_Device['markup']);
     $MobileJoomla_Device['real_markup'] = $MobileJoomla_Device['markup'];
     $app->triggerEvent('onAfterDeviceDetection', array(&$MobileJoomla_Settings, &$MobileJoomla_Device));
     $MobileJoomla_Device['markup'] = self::CheckMarkup($MobileJoomla_Device['markup']);
     $markup = $MobileJoomla_Device['markup'];
     $MobileJoomla_Device['default_markup'] = $markup;
     //get user choice
     $user_markup = $this->getUserMarkup();
     if ($user_markup !== false) {
         $markup = $user_markup;
     }
     // template preview
     $getTemplate = isset($_GET['template']) ? $_GET['template'] : null;
     if (version_compare(JVERSION, '1.7', '>=')) {
         if ($getTemplate === null && isset($_GET['templateStyle']) && is_int($_GET['templateStyle'])) {
             $db = JFactory::getDBO();
             $query = 'SELECT template FROM #__template_styles WHERE id = ' . intval($_GET['templateStyle']) . ' AND client_id = 0';
             $db->setQuery($query);
             $getTemplate = $db->loadResult();
         }
     } elseif (version_compare(JVERSION, '1.6', '>=')) {
         if (is_int($getTemplate)) {
             $db = JFactory::getDBO();
             $query = 'SELECT template FROM #__template_styles WHERE id = ' . intval($getTemplate) . ' AND client_id = 0';
             $db->setQuery($query);
             $getTemplate = $db->loadResult();
         }
     }
     if ($getTemplate) {
         switch ($getTemplate) {
             case $MobileJoomla_Settings['xhtml.template']:
                 $markup = 'xhtml';
                 break;
             case $MobileJoomla_Settings['iphone.template']:
                 $markup = 'iphone';
                 break;
             case $MobileJoomla_Settings['wml.template']:
                 $markup = 'wml';
                 break;
             case $MobileJoomla_Settings['chtml.template']:
                 $markup = 'chtml';
                 break;
         }
     }
     $MobileJoomla_Device['markup'] = $markup;
     if ($MobileJoomla_Device['screenwidth'] == 0 || $MobileJoomla_Device['screenheight'] == 0) {
         switch ($markup) {
             case 'wml':
                 $MobileJoomla_Device['screenwidth'] = 64;
                 $MobileJoomla_Device['screenheight'] = 96;
                 break;
             case 'chtml':
                 $MobileJoomla_Device['screenwidth'] = 120;
                 $MobileJoomla_Device['screenheight'] = 128;
                 break;
             case 'xhtml':
                 $MobileJoomla_Device['screenwidth'] = 320;
                 $MobileJoomla_Device['screenheight'] = 480;
//.........这里部分代码省略.........
开发者ID:bright-spark,项目名称:mobilejoomla,代码行数:101,代码来源:mobilebot.php

示例6: connect

 /**
  * Method to connect to a server and get the resource.
  *
  * @param   JUri     $uri      The URI to connect with.
  * @param   integer  $timeout  Read timeout in seconds.
  *
  * @return  resource  Socket connection resource.
  *
  * @since   11.3
  * @throws  JMapExceptionRuntime
  */
 protected function connect(JUri $uri, $timeout = null)
 {
     // Initialize variables.
     $errno = null;
     $err = null;
     // Get the host from the uri.
     $host = $uri->isSSL() ? 'ssl://' . $uri->getHost() : $uri->getHost();
     // If the port is not explicitly set in the URI detect it.
     if (!$uri->getPort()) {
         $port = $uri->getScheme() == 'https' ? 443 : 80;
     } else {
         $port = $uri->getPort();
     }
     // Build the connection key for resource memory caching.
     $key = md5($host . $port);
     // If the connection already exists, use it.
     if (!empty($this->connections[$key]) && is_resource($this->connections[$key])) {
         // Make sure the connection has not timed out.
         $meta = stream_get_meta_data($this->connections[$key]);
         if (!$meta['timed_out']) {
             return $this->connections[$key];
         }
     }
     // Attempt to connect to the server.
     $connection = @fsockopen($host, $port, $errno, $err, $timeout);
     if (!$connection) {
         throw new JMapExceptionRuntime($err, 'error', $errno);
     }
     // Since the connection was successful let's store it in case we need to use it later.
     $this->connections[$key] = $connection;
     // If an explicit timeout is set, set it.
     if (isset($timeout)) {
         stream_set_timeout($this->connections[$key], (int) $timeout);
     }
     return $this->connections[$key];
 }
开发者ID:neoandrew1000,项目名称:crao_journal,代码行数:47,代码来源:socket.php


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