X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=gl%2Fincludes%2Fdb%2Fgl_db_rates.inc;h=5d98dcb7afd166084b4214e1901d771d1a1078a9;hb=5838404faacacbe4f77dd77bc1cd88fabc213a02;hp=5db9ba2443568970e8dd473c7a37321bd14d3431;hpb=49d2702ed98abe7a564a4abb4c8c5fa225f362e8;p=fa-stable.git diff --git a/gl/includes/db/gl_db_rates.inc b/gl/includes/db/gl_db_rates.inc index 5db9ba24..5d98dcb7 100644 --- a/gl/includes/db/gl_db_rates.inc +++ b/gl/includes/db/gl_db_rates.inc @@ -9,6 +9,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the License here . ***********************************************************************/ +include_once($path_to_root . "/includes/remote_url.inc"); //--------------------------------------------------------------------------------------------- function get_exchange_rate($rate_id) { @@ -75,12 +76,10 @@ function delete_exchange_rate($rate_id) // function retrieve_exrate($curr_b, $date) { - global $Hooks; - - if (method_exists($Hooks, 'retrieve_exrate')) - return $Hooks->retrieve_exrate($curr_b, $date); - else - return get_extern_rate($curr_b, 'ECB', $date); + $rate = hook_retrieve_exrate($curr_b, $date); + if (is_numeric($rate)) + return $rate; + return get_extern_rate($curr_b, 'ECB', $date); } //----------------------------------------------------------------------------- @@ -113,7 +112,9 @@ function get_extern_rate($curr_b, $provider = 'ECB', $date) curl_setopt ($ch, CURLOPT_COOKIEJAR, "cookie.txt"); curl_setopt ($ch, CURLOPT_HEADER, 0); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); - curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1); + // prevent warning while save_mode/open_basedir on (redireciton doesn't occur at least on ECB page) + if (!ini_get('save_mode') && !ini_get('open_basedir')) + curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt ($ch, CURLOPT_TIMEOUT, 3); $contents = curl_exec ($ch); curl_close($ch); @@ -123,21 +124,10 @@ function get_extern_rate($curr_b, $provider = 'ECB', $date) } while( ($contents == '') && $retry--); } else { - $handle = @fopen("http://".$site.$filename, 'rb'); - if ($handle) { - do - { - $data = @fread( $handle, 4096 ); - if ( strlen ( $data ) == 0 ) - break; - $contents .= $data; // with this syntax only text will be translated, whole text with htmlspecialchars($data) - } - while (true); - @fclose( $handle ); - } // end handle + $contents = url_get_contents("http://".$site.$filename); } if (!$contents) { - display_warning(_("Cannot retrieve currency rate from $provider page. Please set the rate manually.")); + display_warning(sprintf(_("Cannot retrieve currency rate from %s page. Please set the rate manually."), $provider)); } if ($provider == 'ECB') {