[ Index ] |
|
Code source de Zen Cart E-Commerce Shopping Cart 1.3.7.1 |
1 <?php 2 // 3 // +----------------------------------------------------------------------+ 4 // |zen-cart Open Source E-commerce | 5 // +----------------------------------------------------------------------+ 6 // | Copyright (c) 2006 The zen-cart developers | 7 // | | 8 // | http://www.zen-cart.com/index.php | 9 // | | 10 // | Portions Copyright (c) 2003 osCommerce | 11 // +----------------------------------------------------------------------+ 12 // | This source file is subject to version 2.0 of the GPL license, | 13 // | that is bundled with this package in the file LICENSE, and is | 14 // | available through the world-wide-web at the following url: | 15 // | http://www.zen-cart.com/license/2_0.txt. | 16 // | If you did not receive a copy of the zen-cart license and are unable | 17 // | to obtain it through the world-wide-web, please send a note to | 18 // | license@zen-cart.com so we can mail you a copy immediately. | 19 // +----------------------------------------------------------------------+ 20 // $Id: localization.php 5369 2006-12-23 10:55:52Z drbyte $ 21 // 22 23 function quote_oanda_currency($code, $base = DEFAULT_CURRENCY) { 24 $url = 'http://www.oanda.com/convert/fxdaily'; 25 $data = 'value=1&redirected=1&exch=' . $code . '&format=CSV&dest=Get+Table&sel_list=' . $base; 26 // check via file() ... may fail if php file Wrapper disabled. 27 $page = @file($url . '?' . $data); 28 if (!is_object($page) && function_exists('curl_init')) { 29 // check via cURL instead. May fail if proxy not set, esp with GoDaddy. 30 $page = doCurlCurrencyRequest('POST', $url, $data) ; 31 $page = explode("\n", $page); 32 } 33 if (is_object($page) || $page !='') { 34 $match = array(); 35 36 preg_match('/(.+),(\w{3}),([0-9.]+),([0-9.]+)/i', implode('', $page), $match); 37 38 if (sizeof($match) > 0) { 39 return $match[3]; 40 } else { 41 return false; 42 } 43 } 44 } 45 46 function quote_xe_currency($to, $from = DEFAULT_CURRENCY) { 47 $url = 'http://www.xe.net/ucc/convert.cgi'; 48 $data = 'Amount=1&From=' . $from . '&To=' . $to; 49 // check via file() ... may fail if php file Wrapper disabled. 50 $page = @file($url . '?' . $data); 51 if (!is_object($page) && function_exists('curl_init')) { 52 // check via cURL instead. May fail if proxy not set, esp with GoDaddy. 53 $page = doCurlCurrencyRequest('POST', $url, $data) ; 54 $page = explode("\n", $page); 55 } 56 if (is_object($page) || $page !='') { 57 $match = array(); 58 59 preg_match('/[0-9.]+\s*' . $from . '\s*=\s*([0-9.]+)\s*' . $to . '/', implode('', $page), $match); 60 if (sizeof($match) > 0) { 61 return $match[1]; 62 } else { 63 return false; 64 } 65 } 66 } 67 68 function doCurlCurrencyRequest($method, $url, $vars) { 69 //echo '-----------------<br />'; 70 //echo 'URL: ' . $url . ' VARS: ' . $vars . '<br />'; 71 $ch = curl_init(); 72 curl_setopt($ch, CURLOPT_URL,$url); 73 curl_setopt($ch, CURLOPT_VERBOSE, 0); 74 curl_setopt($ch, CURLOPT_HEADER, false); 75 curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); 76 curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false); 77 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 78 // curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt'); 79 // curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookie.txt'); 80 if (strtoupper($method) == 'POST') { 81 curl_setopt($ch, CURLOPT_POST, true); 82 curl_setopt($ch, CURLOPT_POSTFIELDS, $vars); 83 } 84 if (CURL_PROXY_REQUIRED == 'True') { 85 $proxy_tunnel_flag = (defined('CURL_PROXY_TUNNEL_FLAG') && strtoupper(CURL_PROXY_TUNNEL_FLAG) == 'FALSE') ? false : true; 86 curl_setopt ($ch, CURLOPT_HTTPPROXYTUNNEL, $proxy_tunnel_flag); 87 curl_setopt ($ch, CURLOPT_PROXYTYPE, CURLPROXY_HTTP); 88 curl_setopt ($ch, CURLOPT_PROXY, CURL_PROXY_SERVER_DETAILS); 89 } 90 $data = curl_exec($ch); 91 $error = curl_error($ch); 92 //$info=curl_getinfo($ch); 93 curl_close($ch); 94 95 if ($error != '') { 96 global $messageStack; 97 $messageStack->add_session('cURL communication ERROR: ' . $error, 'error'); 98 } 99 //echo 'INFO: <pre>'; print_r($info); echo '</pre><br />'; 100 //echo 'ERROR: ' . $error . '<br />'; 101 //print_r($data) ; 102 103 if ($data != '') { 104 return $data; 105 } else { 106 return $error; 107 } 108 } 109 110 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Mon Nov 26 16:45:43 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |