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


PHP PMA_Util::configureCurl方法代码示例

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


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

示例1: getLatestVersion

 /**
  * Returns information with latest version from phpmyadmin.net
  *
  * @return object JSON decoded object with the data
  */
 public function getLatestVersion()
 {
     if (!$GLOBALS['cfg']['VersionCheck']) {
         return null;
     }
     // wait 3s at most for server response, it's enough to get information
     // from a working server
     $connection_timeout = 3;
     $response = '{}';
     // Get response text from phpmyadmin.net or from the session
     // Update cache every 6 hours
     if (isset($_SESSION['cache']['version_check']) && time() < $_SESSION['cache']['version_check']['timestamp'] + 3600 * 6) {
         $save = false;
         $response = $_SESSION['cache']['version_check']['response'];
     } else {
         $save = true;
         $file = 'https://www.phpmyadmin.net/home_page/version.json';
         if (ini_get('allow_url_fopen')) {
             $context = array('http' => array('request_fulluri' => true, 'timeout' => $connection_timeout));
             $context = PMA_Util::handleContext($context);
             if (!defined('TESTSUITE')) {
                 session_write_close();
             }
             $response = file_get_contents($file, false, stream_context_create($context));
         } else {
             if (function_exists('curl_init')) {
                 $curl_handle = curl_init($file);
                 if ($curl_handle === false) {
                     return null;
                 }
                 $curl_handle = PMA_Util::configureCurl($curl_handle);
                 curl_setopt($curl_handle, CURLOPT_HEADER, false);
                 curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, true);
                 curl_setopt($curl_handle, CURLOPT_TIMEOUT, $connection_timeout);
                 if (!defined('TESTSUITE')) {
                     session_write_close();
                 }
                 $response = curl_exec($curl_handle);
             }
         }
     }
     $data = json_decode($response);
     if (!is_object($data) || empty($data->version) || empty($data->date) || empty($data->releases)) {
         return null;
     }
     if ($save) {
         if (!isset($_SESSION) && !defined('TESTSUITE')) {
             ini_set('session.use_only_cookies', 'false');
             ini_set('session.use_cookies', 'false');
             ini_set('session.use_trans_sid', 'false');
             ini_set('session.cache_limiter', 'nocache');
             session_start();
         }
         $_SESSION['cache']['version_check'] = array('response' => $response, 'timestamp' => time());
     }
     return $data;
 }
开发者ID:AnitaGarcia819,项目名称:WinaryCode,代码行数:62,代码来源:VersionInformation.php

示例2: PMA_sendErrorReport

/**
 * Sends report data to the error reporting server
 *
 * @param Array $report the report info to be sent
 *
 * @return String the reply of the server
 */
function PMA_sendErrorReport($report)
{
    $data_string = json_encode($report);
    if (ini_get('allow_url_fopen')) {
        $context = array("http" => array('method' => 'POST', 'content' => $data_string, 'header' => "Content-Type: multipart/form-data\r\n"));
        $context = PMA_Util::handleContext($context);
        $response = file_get_contents(SUBMISSION_URL, false, stream_context_create($context));
        return $response;
    }
    if (!function_exists('curl_init')) {
        return null;
    }
    $curl_handle = curl_init(SUBMISSION_URL);
    $curl_handle = PMA_Util::configureCurl($curl_handle);
    curl_setopt($curl_handle, CURLOPT_CUSTOMREQUEST, "POST");
    curl_setopt($curl_handle, CURLOPT_HTTPHEADER, array('Expect:'));
    curl_setopt($curl_handle, CURLOPT_POSTFIELDS, $data_string);
    curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1);
    $response = curl_exec($curl_handle);
    curl_close($curl_handle);
    return $response;
}
开发者ID:Sorekk,项目名称:cvillecouncilus,代码行数:29,代码来源:error_report.lib.php

示例3: checkHTTP

 /**
  * Checks if given URL is 200 or 404, optionally returns data
  *
  * @param string  $link     the URL to check
  * @param boolean $get_body whether to retrieve body of document
  *
  * @return string|boolean test result or data
  */
 public function checkHTTP($link, $get_body = false)
 {
     if (!function_exists('curl_init')) {
         return null;
     }
     $handle = curl_init($link);
     if ($handle === false) {
         return null;
     }
     PMA_Util::configureCurl($handle);
     curl_setopt($handle, CURLOPT_FOLLOWLOCATION, 0);
     curl_setopt($handle, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($handle, CURLOPT_SSL_VERIFYHOST, 0);
     curl_setopt($handle, CURLOPT_SSL_VERIFYPEER, 0);
     curl_setopt($handle, CURLOPT_CONNECTTIMEOUT, 5);
     curl_setopt($handle, CURLOPT_TIMEOUT, 5);
     if (!defined('TESTSUITE')) {
         session_write_close();
     }
     $data = @curl_exec($handle);
     if (!defined('TESTSUITE')) {
         ini_set('session.use_only_cookies', '0');
         ini_set('session.use_cookies', '0');
         ini_set('session.use_trans_sid', '0');
         ini_set('session.cache_limiter', 'nocache');
         session_start();
     }
     if ($data === false) {
         return null;
     }
     $http_status = curl_getinfo($handle, CURLINFO_HTTP_CODE);
     if ($http_status == 200) {
         return $get_body ? $data : true;
     }
     if ($http_status == 404) {
         return false;
     }
     return null;
 }
开发者ID:Timandes,项目名称:phpmyadmin,代码行数:47,代码来源:Config.class.php

示例4: checkHTTP

 /**
  * Checks if given URL is 200 or 404, optionally returns data
  *
  * @param string  $link     the URL to check
  * @param boolean $get_body whether to retrieve body of document
  *
  * @return string|boolean test result or data
  */
 function checkHTTP($link, $get_body = false)
 {
     if (!function_exists('curl_init')) {
         return null;
     }
     $ch = curl_init($link);
     PMA_Util::configureCurl($ch);
     curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
     curl_setopt($ch, CURLOPT_HEADER, 1);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
     curl_setopt($ch, CURLOPT_TIMEOUT, 5);
     if (!defined('TESTSUITE')) {
         session_write_close();
     }
     $data = @curl_exec($ch);
     if (!defined('TESTSUITE')) {
         ini_set('session.use_only_cookies', '0');
         ini_set('session.use_cookies', '0');
         ini_set('session.use_trans_sid', '0');
         ini_set('session.cache_limiter', 'nocache');
         session_start();
     }
     if ($data === false) {
         return null;
     }
     $httpOk = 'HTTP/1.1 200 OK';
     $httpNotFound = 'HTTP/1.1 404 Not Found';
     if (substr($data, 0, strlen($httpOk)) === $httpOk) {
         return $get_body ? mb_substr($data, mb_strpos($data, "\r\n\r\n") + 4) : true;
     }
     $httpNOK = substr($data, 0, strlen($httpNotFound));
     if ($httpNOK === $httpNotFound) {
         return false;
     }
     return null;
 }
开发者ID:elenacaseyroby,项目名称:MetaphoricalFruit,代码行数:45,代码来源:Config.class.php


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