/**
  * Connect to the proxy.
  *
  * @param string $url is the full URL containing the hostname and request.
  * @param string $host is the hostname of the new site used in the Host: HTTP header.
  * @param string $method is the HTTP method (GET | POST).
  * @param string $post_params are the POST arguments in key=value&key=value format.
  *
  * @return array containing HTTP response code, the body of the response, elapsed time.
  */
 static function surf($post_params)
 {
     try {
         $mych = new CurlRequest();
         $params = array('url' => 'http://localhost/proxy/easypress-console-proxy.php', 'host' => 'console.easypress.ca', 'header' => '', 'method' => 'POST', 'referer' => '', 'cookie' => '', 'post_fields' => $post_params, 'timeout' => 90, 'verbose' => 0);
         $mych->init($params);
         $result = $mych->exec();
         if ($result['curl_error']) {
             throw new Exception($result['curl_error']);
         }
         if ($result['http_code'] != '200') {
             throw new Exception("HTTP Code = " . $result['http_code'] . "\nBody: " . $result['body']);
         }
         if (NULL === $result['body']) {
             throw new Exception("Body of file is empty");
         }
         //echo $result['header'];
         //echo 'HTTP return code: ' . $result['http_code'];
     } catch (Exception $e) {
         error_log("easypress-console::surf(): " . $e->getMessage());
     }
     return array('code' => $result['http_code'], 'body' => $result['body'], 'etime' => $result['etime']);
 }
 public function test_initError()
 {
     $this->curl->init('https://smartsupp.com');
 }
 /**
  * HTTP requests
  *
  * @param array $request should minimally contain the POST arguments.
  * @return array containing HTTP response code, the body of the response, elapsed time.
  */
 public function http_req($request = array())
 {
     global $params;
     $host = 'provision.boreal321.com';
     if ($params['location'] == 'equalit.ie') {
         $host = 'eqpress.equalit.ie';
     }
     $url = 'https://' . $host . '/pwpush/pwpusher_public/pw.php';
     $response = array();
     $defaults = array('url' => $url, 'host' => $host, 'method' => 'POST', 'timeout' => 30, 'verbose' => 0);
     $request = array_merge($defaults, $request);
     try {
         $mych = new CurlRequest();
         $mych->init($request);
         $response = $mych->exec();
         if ($response['curl_error']) {
             throw new Exception($response['curl_error']);
         }
         //if ( $response['http_code'] != '200' ) throw new Exception( "HTTP Code = " . $response['http_code'] . '\nBody: ' . $response['body'] );
         if (NULL === $response['body']) {
             throw new Exception("Body of response is empty");
         }
     } catch (Exception $e) {
         $this->process_errors("http_req error: " . $e->getMessage() . "\n" . print_r($response, true));
     }
     //return array( 'code' => $response['http_code'], 'body' => $response['body'], 'etime' => $response['etime'] );
     //return $response['body'];
     return $response;
 }
/**
 * Connect to the proxy.
 *
 * @param string $url is the full URL containing the hostname and request.
 * @param string $host is the hostname of the new site used in the Host: HTTP header.
 * @param string $method is the HTTP method (GET | POST).
 * @param string $post_params are the POST arguments in key=value&key=value format.
 *
 * @return array containing HTTP response code, the body of the response, elapsed time.
 */
function surf($post_params)
{
    require_once dirname(__FILE__) . '/../plugin/easypress-console/inc/class-curl-request.php';
    try {
        $mych = new CurlRequest();
        $params = array('url' => 'https://www.getpendeo.com/pwpush/pwpusher_public/pw.php', 'host' => 'www.getpendeo.com', 'header' => '', 'method' => 'POST', 'referer' => '', 'cookie' => '', 'post_fields' => $post_params, 'timeout' => 90, 'verbose' => 0);
        $mych->init($params);
        $result = $mych->exec();
        if ($result['curl_error']) {
            throw new Exception($result['curl_error']);
        }
        if ($result['http_code'] != '200') {
            throw new Exception("HTTP Code = " . $result['http_code'] . "\nBody: " . $result['body']);
        }
        if (NULL === $result['body']) {
            throw new Exception("Body of file is empty");
        }
        //echo $result['header'];
        //echo 'HTTP return code: ' . $result['http_code'];
    } catch (Exception $e) {
        error_log("easypress-console-proxy: surf() error. " . $e->getMessage());
    }
    return array('code' => $result['http_code'], 'body' => $result['body'], 'etime' => $result['etime']);
}