ZenCart_Documentation  1.5.0
http://www.collinsharper.com
C:/xampp/htdocs/zen-cart/extras/curltester.php
Go to the documentation of this file.
00001 <?php
00002 /*
00003  * @package utilities
00004  * @copyright Copyright 2003-2011 Zen Cart Development Team
00005  * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
00006  * @version $Id: curltester.php 18695 2011-05-04 05:24:19Z drbyte $
00007  *
00008  * This utility is simply intended to test whether the host server has the ability to use CURL to connect to external servers in order to send communications, such as for PayPal transactions
00009  */
00010   error_reporting(E_ALL);
00011 
00012   $defaultURL = "http://www.zen-cart.com/testcurl.php";
00013   $useSSL = (isset($_GET['ssl']) && (strtolower($_GET['ssl']) == 'yes' || $_GET['ssl'] == 1)) ? true : false;
00014   if ($useSSL) $defaultURL = "https://www.zen-cart.com/testcurl.php";
00015   $url = $defaultURL;
00016   $proxy = (isset($_GET['proxy'])) ? true : false;
00017   $proxyAddress = (isset($_GET['proxyaddress'])) ? $_GET['proxyaddress'] : '';
00018 
00019   $testFirstData = ((isset($_GET['firstdata']) && (strtolower($_GET['firstdata']) == 'yes' || $_GET['firstdata'] == 1)) || (isset($_GET['linkpoint']) && (strtolower($_GET['linkpoint']) == 'yes' || $_GET['linkpoint'] == 1))) ? true : false;
00020   if ($testFirstData) $url = "https://secure.linkpt.net:1129/LSGSXML";
00021 
00022   $testAuthnet = (isset($_GET['authnet']) && (strtolower($_GET['authnet']) == 'yes' || $_GET['authnet'] == 1)) ? true : false;
00023   if ($testAuthnet) $url = "https://secure.authorize.net/gateway/transact.dll";
00024 
00025   $testPayPal = (isset($_GET['paypal']) && (strtolower($_GET['paypal']) == 'yes' || $_GET['paypal'] == 1)) ? true : false;
00026   if ($testPayPal) $url = "https://api-3t.paypal.com/nvp";
00027 
00028   $_POST = array();
00029   if (isset($GLOBALS)) unset($GLOBALS);
00030   if (isset($_GET)) unset($_GET);
00031   if (isset($_REQUEST)) unset($_REQUEST);
00032   $data = "field1=This is a test&statuskey=ready";
00033 
00034   // Send CURL communication
00035   $ch = curl_init();
00036   curl_setopt($ch, CURLOPT_URL, $url);
00037   curl_setopt($ch, CURLOPT_VERBOSE, 0);
00038   if ($data != '') {
00039     curl_setopt($ch, CURLOPT_POST, 1);
00040     curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
00041   }
00042   curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
00043   curl_setopt($ch, CURLOPT_FORBID_REUSE, 1);
00044   curl_setopt($ch, CURLOPT_FRESH_CONNECT, 1);
00045   curl_setopt($ch, CURLOPT_TIMEOUT, 25);
00046   curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 20);
00047   curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); /* compatibility for SSL communications on some Windows servers (IIS 5.0+) */
00048   curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
00049   curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
00050   curl_setopt ($ch, CURLOPT_SSLVERSION, 3);
00051   curl_setopt($ch, CURLOPT_USERAGENT, 'Zen Cart(tm) - CURL TEST');
00052 
00060   $result = curl_exec($ch);
00061   $errtext = curl_error($ch);
00062   $errnum = curl_errno($ch);
00063   $commInfo = @curl_getinfo($ch);
00064   curl_close ($ch);
00065 
00066 // enclose URL in quotes so it doesn't get converted to a clickable link if posted on the forum
00067   if (isset($commInfo['url'])) $commInfo['url'] = '"' . $commInfo['url'] . '"';
00068 
00069 // Handle results
00070   echo ($errnum != 0 ? '<br />' . $errnum . ' ' . $errtext . '<br />' : '');
00071   if ($url == $defaultURL) {
00072     echo $result;
00073   } else {
00074     if ($commInfo['http_code'] == 200) echo 'COMMUNICATIONS TEST OKAY.<br />You may see error information below, but that information simply confirms that the server actually responded, which means communications is open.';
00075   }
00076   echo '<pre>' . print_r($commInfo, true) . '</pre><br /><br />';
00077   if ($url != $defaultURL) echo $result . '<br>EOF';
00078 
 All Data Structures Namespaces Files Functions Variables Enumerations