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


PHP SEFTools::PostRequest方法代码示例

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


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

示例1: _parseLinks

 function _parseLinks($url, &$found)
 {
     // Get response, follow 5 redirections
     $redirs = 0;
     do {
         $redirect = false;
         $response = SEFTools::PostRequest($url, null, null, 'get', null);
         if ($response === false) {
             // Error
             return;
         }
         if ($redirs < 5 && $response->code >= 300 && $response->code < 400) {
             // Parse redirect URL
             $pos = stripos($response->header, 'location:');
             if ($pos !== false) {
                 $pos += 9;
                 // Skip header name
                 $pos2 = strpos($response->header, "\r", $pos);
                 $url = substr($response->header, $pos, $pos2 - $pos);
                 $url = trim($url);
                 $redirect = true;
                 $redirs++;
             }
         }
     } while ($redirect);
     // Check code
     if ($response->code == 200) {
         // Parse URLs
         $matches = array();
         if (preg_match_all('#<a\\s[^>]*href=["\']([^"\']+)#i', $response->content, $matches) > 0) {
             // Loop through found URLs
             foreach ($matches[1] as $link) {
                 $link = str_replace(JURI::root(), '', $link);
                 if (strpos($link, '://') !== false) {
                     // Absolute external link, skip
                     continue;
                 }
                 // Internal link
                 $link = JURI::root() . ltrim(html_entity_decode(urldecode($link)), '/');
                 if (!in_array($link, $found)) {
                     $found[] = $link;
                 }
             }
         }
     }
 }
开发者ID:01J,项目名称:bealtine,代码行数:46,代码来源:crawler.php

示例2: _getPackageFromServer

 function _getPackageFromServer($extension)
 {
     // Make sure that zlib is loaded so that the package can be unpacked
     if (!extension_loaded('zlib')) {
         JError::raiseWarning(100, JText::_('WARNINSTALLZLIB'));
         return false;
     }
     // build the appropriate paths
     $sefConfig =& SEFConfig::getConfig();
     $config =& JFactory::getConfig();
     if (empty($extension)) {
         $tmp_dest = $config->getValue('config.tmp_path') . DS . 'joomsef.zip';
     } else {
         $tmp_dest = $config->getValue('config.tmp_path') . DS . $extension . '.zip';
     }
     // Validate the upgrade on server
     $data = array();
     $data['username'] = $sefConfig->artioUserName;
     $data['password'] = $sefConfig->artioPassword;
     if (empty($extension)) {
         $data['download_id'] = $sefConfig->artioDownloadId;
         $data['file'] = 'com_joomsef';
     } else {
         $params =& SEFTools::getExtParams($extension);
         $data['download_id'] = $params->get('downloadId', '');
         $data['file'] = 'ext_joomsef3_' . substr($extension, 4);
     }
     $uri = parse_url(JURI::root());
     $url = $uri['host'] . $uri['path'];
     $url = trim($url, '/');
     $data['site'] = $url;
     $data['ip'] = $_SERVER['SERVER_ADDR'];
     $lang =& JFactory::getLanguage();
     $data['lang'] = $lang->getTag();
     $data['cat'] = 'joomsef3';
     // Get the server response
     $response = SEFTools::PostRequest($sefConfig->serverAutoUpgrade, JURI::root(), $data);
     // Check the response
     if ($response === false || $response->code != 200) {
         JError::raiseWarning(100, JText::_('Connection to server could not be established.'));
         return false;
     }
     // Response OK, check what we got
     if (strpos($response->header, 'Content-Type: application/zip') === false) {
         JError::raiseWarning(100, $response->content);
         return false;
     }
     // Seems we got the ZIP installation package, let's save it to disk
     if (!JFile::write($tmp_dest, $response->content)) {
         JError::raiseWarning(100, JText::_('Unable to save installation file in temp directory.'));
         return false;
     }
     // Unpack the downloaded package file
     $package = JInstallerHelper::unpack($tmp_dest);
     // Delete the package file
     JFile::delete($tmp_dest);
     return $package;
 }
开发者ID:andreassetiawanhartanto,项目名称:PDKKI,代码行数:58,代码来源:upgrade.php

示例3: getPageSpeed

 function getPageSpeed($url)
 {
     require_once JPATH_COMPONENT_ADMINISTRATOR . DS . 'classes' . DS . 'config.php';
     $url = str_replace("/administrator", "", JFactory::getURI()->base()) . $url;
     $config = SEFConfig::getConfig();
     $ndata = new stdClass();
     if (strlen($config->google_apikey) == 0) {
         return false;
     }
     $google_url = 'https://www.googleapis.com/pagespeedonline/v1/runPagespeed?url=' . urlencode($url) . '&key=' . $config->google_apikey;
     if (function_exists('curl_init')) {
         $c = curl_init($google_url);
         curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
         curl_setopt($c, CURLOPT_ENCODING, "utf-8");
         $data = curl_exec($c);
         curl_close($c);
     } else {
         // Try to use our own method
         $data = SEFTools::PostRequest($google_url, null, null, 'get');
         if ($data !== false) {
             $data = $data->content;
         }
     }
     if ($data === false) {
         // Could not connect
         return false;
     }
     $data = json_decode($data);
     $ndata = new stdClass();
     if (isset($data->error)) {
         $ndata->message = $data->error->errors[0]->message;
         return $ndata;
     }
     @($ndata->pageStats = $data->pageStats);
     @($ndata->score = $data->score);
     $reg = new JRegistry();
     $reg->loadObject($ndata);
     return $reg->toString("ini");
 }
开发者ID:andreassetiawanhartanto,项目名称:PDKKI,代码行数:39,代码来源:google.php

示例4: getPageSpeed

 function getPageSpeed($url)
 {
     require_once JPATH_COMPONENT_ADMINISTRATOR . '/classes/config.php';
     $url = rtrim(JURI::root(), '/') . '/' . ltrim($url, '/');
     $config = SEFConfig::getConfig();
     $ndata = new stdClass();
     if (strlen($config->google_apikey) == 0) {
         return false;
     }
     $google_url = 'https://www.googleapis.com/pagespeedonline/v1/runPagespeed?url=' . urlencode($url) . '&key=' . $config->google_apikey;
     // Use CURL if available
     if (function_exists('curl_init')) {
         $certFile = realpath(dirname(__FILE__) . '/../cacert.pem');
         $c = curl_init($google_url);
         curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
         curl_setopt($c, CURLOPT_ENCODING, "utf-8");
         curl_setopt($c, CURLOPT_CAINFO, $certFile);
         $data = curl_exec($c);
         curl_close($c);
     } else {
         // Try to use our own method
         $data = SEFTools::PostRequest($google_url, null, null, 'get');
         if ($data !== false) {
             $data = $data->content;
         }
     }
     if ($data === false) {
         // Could not connect
         return false;
     }
     $data = json_decode($data);
     $ndata = new stdClass();
     if (isset($data->error)) {
         $ndata->message = $data->error->errors[0]->message;
         return $ndata;
     }
     @($ndata->pageStats = $data->pageStats);
     @($ndata->score = $data->score);
     $reg = new JRegistry();
     $reg->loadObject($ndata);
     return $reg->toString("ini");
 }
开发者ID:jmangarret,项目名称:webtuagencia24,代码行数:42,代码来源:google.php

示例5: _getPackageFromServer

 function _getPackageFromServer()
 {
     $extension = trim(JRequest::getString('extension'));
     // Make sure we have an extension selected
     if (empty($extension)) {
         JError::raiseWarning(100, JText::_('COM_SEF_NO_EXTENSION_SELECTED'));
         return false;
     }
     // Make sure that zlib is loaded so that the package can be unpacked
     if (!extension_loaded('zlib')) {
         JError::raiseWarning(100, JText::_('COM_SEF_WARNINSTALLZLIB'));
         return false;
     }
     // build the appropriate paths
     $sefConfig =& SEFConfig::getConfig();
     $config =& JFactory::getConfig();
     $tmp_dest = $config->get('tmp_path') . '/' . $extension . '.zip';
     // Validate the upgrade on server
     $data = array();
     $data['username'] = $sefConfig->artioUserName;
     $data['password'] = $sefConfig->artioPassword;
     $params =& SEFTools::getExtParams($extension);
     $data['download_id'] = $params->get('downloadId', '');
     $data['file'] = 'ext_joomsef4_' . substr($extension, 4);
     $uri = parse_url(JURI::root());
     $url = $uri['host'] . $uri['path'];
     $url = trim($url, '/');
     $data['site'] = $url;
     $data['ip'] = $_SERVER['SERVER_ADDR'];
     $lang =& JFactory::getLanguage();
     $data['lang'] = $lang->getTag();
     $data['cat'] = 'joomsef4';
     // Get the server response
     $response = SEFTools::PostRequest($sefConfig->serverAutoUpgrade, JURI::root(), $data);
     // Check the response
     if ($response === false || $response->code != 200) {
         JError::raiseWarning(100, JText::_('COM_SEF_ERROR_SERVER_CONNECTION'));
         return false;
     }
     // Response OK, check what we got
     if (strpos($response->header, 'Content-Type: application/zip') === false) {
         JError::raiseWarning(100, $response->content);
         return false;
     }
     // Seems we got the ZIP installation package, let's save it to disk
     if (!JFile::write($tmp_dest, $response->content)) {
         JError::raiseWarning(100, JText::_('COM_SEF_ERROR_TEMP_DIRECTORY'));
         return false;
     }
     // Unpack the downloaded package file
     $package = JInstallerHelper::unpack($tmp_dest);
     // Delete the package file
     JFile::delete($tmp_dest);
     return $package;
 }
开发者ID:jmangarret,项目名称:webtuagencia24,代码行数:55,代码来源:extension.php

示例6: getData

 function getData($metrics, $dimensions = "", $sort = "", $max_results = "50")
 {
     $google_url = $this->_feed . "data";
     $headers = array();
     $headers[] = "GData-Version: 2";
     $headers[] = "Authorization: GoogleLogin auth=\"" . $this->_info["Auth"] . "\"";
     $url_params = array();
     $url_params["ids"] = "ga:" . JRequest::getInt('account_id', $this->_default_id);
     $url_params["start-date"] = JRequest::getString('start_date', JFactory::getDate(JFactory::getDate()->toUnix() - 60 * 60 * 24 * 7)->toFormat("%Y-%m-%d"));
     $url_params["end-date"] = JRequest::getString('end_date', JFactory::getDate()->toFormat("%Y-%m-%d"));
     $url_params["prettyprint"] = "true";
     $url_params["metrics"] = $metrics;
     $url_params["dimensions"] = $dimensions;
     $url_params["sort"] = $sort;
     $url_params["max-results"] = $max_results;
     $google_url .= "?" . http_build_query($url_params);
     if (function_exists('curl_init')) {
         // Use CURL
         $c = curl_init($google_url);
         curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
         curl_setopt($c, CURLOPT_HTTPHEADER, $headers);
         $data = curl_exec($c);
         curl_close($c);
     } else {
         // Try to use OpenSSL
         $response = SEFTools::PostRequest($google_url, null, null, 'get', null, $headers);
         if ($response === false) {
             return array();
         }
         $data = $response->content;
     }
     if (!$data) {
         return array();
     }
     $xml = new DomDocument("1.0");
     if ($xml->loadXML($data) === false) {
         return array();
     }
     return $this->_processData($xml->getElementsByTagName('entry'));
 }
开发者ID:andreassetiawanhartanto,项目名称:PDKKI,代码行数:40,代码来源:google_analytics.php


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