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


PHP JHttpFactory::getAvailableDriver方法代码示例

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


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

示例1: getDonationCodeStatus

 /**
  * Gets the status of the entered donation code from the donation code script
  *
  * @param string $host
  * @param string $donation_code
  *
  * @return int
  */
 private static function getDonationCodeStatus($host, $donation_code)
 {
     $donation_code_check = 0;
     if (JHttpFactory::getAvailableDriver(new Registry()) == false) {
         return -2;
     }
     if (!empty($host) and !empty($donation_code)) {
         // First try it with the main validation server and with HTTPS
         $url_check = 'https://check.kubik-rubik.de/donationcode/validation.php?key=' . rawurlencode($donation_code) . '&host=' . rawurlencode($host);
         try {
             $donation_code_request = JHttpFactory::getHttp()->get($url_check);
         } catch (Exception $e) {
             // Try it with the fall back server and without HTTPS
             $url_check_fallback = 'http://check.kubik-rubik.eu/donationcode/validation.php?key=' . rawurlencode($donation_code) . '&host=' . rawurlencode($host);
             try {
                 $donation_code_request = JHttpFactory::getHttp()->get($url_check_fallback);
             } catch (Exception $e) {
                 return -1;
             }
         }
         if (!empty($donation_code_request->body)) {
             if (preg_match('@(error|access denied)@i', $donation_code_request->body)) {
                 return -1;
             }
             $donation_code_check = (int) $donation_code_request->body;
         }
     }
     return $donation_code_check;
 }
开发者ID:davetheapple,项目名称:oakencraft,代码行数:37,代码来源:easyjoomlabackup.php

示例2: __construct

 /**
  * 
  */
 public function __construct()
 {
     jimport('joomla.http.factory');
     if (!class_exists('JHttpFactory')) {
         throw new BadFunctionCallException(JchPlatformUtility::translate('JHttpFactory not present. Please upgrade your version of Joomla. Exiting plugin...'));
     }
     $aOptions = array('follow_location' => true);
     $oOptions = new JRegistry($aOptions);
     $this->oHttpAdapter = JHttpFactory::getAvailableDriver($oOptions);
 }
开发者ID:naka211,项目名称:myloyal,代码行数:13,代码来源:http.php

示例3: getDonationCodeStatus

 private function getDonationCodeStatus($host, $donation_code)
 {
     $donation_code_check = 0;
     if (JHttpFactory::getAvailableDriver(new JRegistry()) == false) {
         $donation_code_check = -2;
     } else {
         if (!empty($host) and !empty($donation_code)) {
             $url_check = 'https://joomla-extensions.kubik-rubik.de/scripts/je_kr_donation_code_check/je_kr_check_code.php?key=' . rawurlencode($donation_code) . '&host=' . rawurlencode($host);
             $donation_code_request = JHttpFactory::getHttp()->get($url_check);
             if (!empty($donation_code_request->body)) {
                 $donation_code_check = $donation_code_request->body;
             }
         }
         if (preg_match('@(error|access denied)@i', $donation_code_check)) {
             $donation_code_check = -1;
         }
     }
     return $donation_code_check;
 }
开发者ID:vstorm83,项目名称:propertease,代码行数:19,代码来源:krdonationcodecheck.php

示例4: __construct

 /**
  * Constructor.
  *
  * @param   JRegistry       $options    Client options object. If the registry contains any headers.* elements,
  *                                      these will be added to the request headers.
  * @param   JHttpTransport  $transport  The HTTP transport object.
  *
  * @since   11.3
  */
 public function __construct(JRegistry $options = null, JHttpTransport $transport = null)
 {
     $this->options = isset($options) ? $options : new JRegistry();
     $this->transport = isset($transport) ? $transport : JHttpFactory::getAvailableDriver($this->options);
 }
开发者ID:RuDers,项目名称:JoomlaSQL,代码行数:14,代码来源:http.php

示例5: testGetAvailableDriver

 /**
  * Tests the getAvailableDriver method.
  *
  * @return  void
  *
  * @since   3.4
  */
 public function testGetAvailableDriver()
 {
     $this->assertFalse(JHttpFactory::getAvailableDriver(new \Joomla\Registry\Registry(), array()), 'Passing an empty array should return false due to there being no adapters to test');
     $this->assertFalse(JHttpFactory::getAvailableDriver(new \Joomla\Registry\Registry(), array('fopen')), 'A false should be returned if a class is not present or supported');
 }
开发者ID:SysBind,项目名称:joomla-cms,代码行数:12,代码来源:JHttpFactoryTest.php

示例6: getPageContent

 /**
  * This function loads the content of the provided URL. It uses the JHttp class of the Joomla! API and the factory
  * class of Joomla! 3 which was backported for Joomla! 2.5
  *
  * The socket transport driver is used to determine whether a called URL exists at all. The timeout of 5 seconds
  * helps to reduce the loading time of the request process.
  *
  * @param string $url
  * @param bool   $socket
  *
  * @return bool|int|JHttpResponse
  */
 private function getPageContent($url, $socket = false)
 {
     $content = new stdClass();
     // We need the factory class which helps us to determine all supported adapters by the used server
     if (!class_exists('JHttpFactory')) {
         include JPATH_COMPONENT_ADMINISTRATOR . '/helpers/jhttpfactory.php';
     }
     if (!empty($socket) and $http_socket = JHttpFactory::getAvailableDriver(new JRegistry(), 'socket')) {
         $content = $http_socket->request('HEAD', new JUri($url), null, null, 5, $this->_user_agent);
         // We don't need the content, only the response code if the socket transport driver is used
         return $content->code;
     } else {
         // Normal query check with available handlers - cURL has always priority - use allow_url_fopen only as fallback
         // Normally you should get the content like this:
         // $jhttp_factory = JHttpFactory::getHttp();
         // $content = $jhttp_factory->get($url);
         // But so we can not set the user agent which is required on many websites (servers) to make the request valid
         if ($http_curl = JHttpFactory::getAvailableDriver(new JRegistry(), 'curl')) {
             $content = $http_curl->request('GET', new JUri($url), null, null, 5, $this->_user_agent);
         } elseif ($http_fopen = JHttpFactory::getAvailableDriver(new JRegistry(), 'stream')) {
             $content = $http_fopen->request('GET', new JUri($url), null, null, 5, $this->_user_agent);
         }
     }
     // Code 200? Everything okay, go on!
     if (!empty($content) and $content->code == 200) {
         return $content;
     } else {
         return false;
     }
 }
开发者ID:gokuale,项目名称:JBC-Joomla-Backlink-Checker,代码行数:42,代码来源:checkbacklinks.php

示例7: getAvailableDriver

 /**
  * Helper wrapper method for getAvailableDriver
  *
  * @param   Registry  $options  Option for creating http transport object.
  * @param   mixed     $default  Adapter (string) or queue of adapters (array) to use.
  *
  * @return JHttpTransport Interface sub-class
  *
  * @see     JHttpFactory::getAvailableDriver()
  * @since   3.4
  */
 public function getAvailableDriver(Registry $options, $default = null)
 {
     return JHttpFactory::getAvailableDriver($options, $default);
 }
开发者ID:deenison,项目名称:joomla-cms,代码行数:15,代码来源:factory.php


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