Open Journal Systems  3.3.0
PKPCurlHelper.inc.php
1 <?php
2 
23  static function getCurlObject($url = null, $useProxySettings = true) {
24  // Set up common CURL request details
25  $curl = curl_init($url);
26 
27  // Use proxy if configured
28  if ($useProxySettings && $httpProxyHost = Config::getVar('proxy', 'http_host')) {
29  curl_setopt($curl, CURLOPT_PROXY, $httpProxyHost);
30  curl_setopt($curl, CURLOPT_PROXYPORT, Config::getVar('proxy', 'http_port', '80'));
31  if ($username = Config::getVar('proxy', 'username')) {
32  curl_setopt($curl, CURLOPT_PROXYUSERPWD, $username . ':' . Config::getVar('proxy', 'password'));
33  }
34  }
35 
36  // Use cainfo if configured
37  if ($cainfo = Config::getVar('curl', 'cainfo')) {
38  curl_setopt($curl, CURLOPT_CAINFO, $cainfo);
39  }
40 
41  // Set user agent
43  if (Config::getVar('general', 'installed') && !defined('RUNNING_UPGRADE')) {
44  $currentVersion = $application->getCurrentVersion();
45  curl_setopt($curlCh, CURLOPT_USERAGENT, $application->getName() . '/' . $currentVersion->getVersionString());
46  } else {
47  curl_setopt($curlCh, CURLOPT_USERAGENT, $application->getName() . '/?');
48  }
49 
50  return $curl;
51  }
52 }
53 
54 
$application
$application
Definition: index.php:65
PKPCurlHelper\getCurlObject
static getCurlObject($url=null, $useProxySettings=true)
Definition: PKPCurlHelper.inc.php:23
PKPCurlHelper
Helper for curl usage.
Definition: PKPCurlHelper.inc.php:16
Config\getVar
static getVar($section, $key, $default=null)
Definition: Config.inc.php:35
PKPApplication\get
static get()
Definition: PKPApplication.inc.php:235