//reset default if second parameter is skipped
$nullify = ($nullify === null) ? (false) : ($nullify);
- //undo slashes for poorly configured servers
- $value = (get_magic_quotes_gpc()) ? (stripslashes($value)) : ($value);
//check for null/unset/empty strings
if ((!isset($value)) || (is_null($value)) || ($value === "")) {
}
}
+ //-----------------------------------------------------------------------------
+ // Removing magic quotes from nested arrays/variables
+ //
+ function strip_quotes($data)
+ {
+ if(get_magic_quotes_gpc()) {
+ if(is_array($data)) {
+ foreach($data as $k => $v) {
+ $data[$k] = strip_quotes($data[$k]);
+ }
+ } else
+ return stripslashes($data);
+ }
+ return $data;
+ }
+
+
//----------------------------------------------------------------------------------------
if (!isset($_SESSION["wa_current_user"]) ||
(isset($_SESSION["wa_current_user"]) && !$_SESSION["wa_current_user"]->logged_in()))
check_page_security($page_security);
-
+// POST vars cleanup needed for direct reuse.
+// We quote all values later with db_escape() before db update.
+ $_POST = strip_quotes($_POST);
?>
\ No newline at end of file
else
$currency = $from_currency;
$rate = get_ecb_rate($currency);
- if (get_date_exchange_rate($currency, $date_))
- update_exchange_rate($currency, $date_, $rate, $rate);
- else
- add_exchange_rate($currency, $date_, $rate, $rate);
+ if ($rate==0)
+ {
+ display_error(_("Cannot get exchange rate for this currency. Please add exchange rate manually on Exchange Rates page.") );
+ $rate = get_exchange_rate_from_to($to_currency, $from_currency, $date_);
+ } else
+ {
+ if (get_date_exchange_rate($currency, $date_))
+ update_exchange_rate($currency, $date_, $rate, $rate);
+ else
+ add_exchange_rate($currency, $date_, $rate, $rate);
+ }
if ($from_currency == $comp_currency)
$rate = 1 / $rate;
$Ajax->activate('get_rate');