X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=gl%2Fincludes%2Fdb%2Fgl_db_rates.inc;h=88167b2c511818b9c2a60b79b42e46c31ea85634;hb=1607637226fffca2851963c3a0b54a937b487dc0;hp=7189afa894dc131ba7af5cf258bb08e952cd0972;hpb=5040e3d0e0f8f5d6d08e0121f12308320abaa6c2;p=fa-stable.git diff --git a/gl/includes/db/gl_db_rates.inc b/gl/includes/db/gl_db_rates.inc index 7189afa8..88167b2c 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,8 @@ 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) + @curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt ($ch, CURLOPT_TIMEOUT, 3); $contents = curl_exec ($ch); curl_close($ch); @@ -123,21 +123,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') { @@ -184,4 +173,14 @@ function get_extern_rate($curr_b, $provider = 'ECB', $date) return $val; } /* end function get_extern_rate */ +//----------------------------------------------------------------------------- + +function get_sql_for_exchange_rates() +{ + $sql = "SELECT date_, rate_buy, id FROM " + .TB_PREF."exchange_rates " + ."WHERE curr_code=".db_escape($_POST['curr_abrev'])." + ORDER BY date_ DESC"; + return $sql; +} ?> \ No newline at end of file