do { $exchange_data[$row['ex_cash_id1']][$row['ex_cash_id2']] = 1; } while ($row = $db->sql_fetchrow($result)); $exchanger = new cash_user($userdata['user_id'], $userdata); if (isset($HTTP_POST_VARS['exchange']) && isset($HTTP_POST_VARS['from_id']) && is_numeric($HTTP_POST_VARS['from_id']) && isset($HTTP_POST_VARS['to_id']) && is_numeric($HTTP_POST_VARS['to_id']) && isset($HTTP_POST_VARS['convert_amount']) && is_numeric($HTTP_POST_VARS['convert_amount'])) { $from_id = intval($HTTP_POST_VARS['from_id']); $to_id = intval($HTTP_POST_VARS['to_id']); $convert_amount = cash_floatval($HTTP_POST_VARS['convert_amount']); if ($convert_amount < 0) { qs($from_id, $to_id); $convert_amount = -$convert_amount; } if ($to_id != $from_id && $cash->currency_exists($to_id) && $cash->currency_exists($from_id) && isset($exchange_data[$from_id]) && is_array($exchange_data[$from_id]) && isset($exchange_data[$from_id][$to_id]) && $cash->currencies[$from_id]->mask(CURRENCY_ENABLED | CURRENCY_EXCHANGEABLE) && $cash->currencies[$to_id]->mask(CURRENCY_ENABLED | CURRENCY_EXCHANGEABLE)) { $c_cur_from = $cash->currency($from_id); $c_cur_to = $cash->currency($to_id); if ($exchanger->has($c_cur_from->id(), $convert_amount)) { $converted_amount = $convert_amount / $c_cur_from->data('cash_exchange') * $c_cur_to->data('cash_exchange'); $exchanger->remove_by_id_array(array($c_cur_from->id() => $convert_amount)); $exchanger->give_by_id_array(array($c_cur_to->id() => $converted_amount)); } } } $template->assign_vars(array('S_EXCHANGE_ACTION' => append_sid("cash.{$phpEx}?mode=exchange"), 'S_HIDDEN_FIELDS' => '<input type="hidden" name="exchange" value="1" />', 'L_EXCHANGE' => $lang['Exchange'], 'L_FROM' => $lang['From'], 'L_TO' => $lang['To'], 'L_CONVERT' => $lang['Convert'], 'L_SELECT_ONE' => $lang['Select_one'], 'L_SUBMIT' => $lang['Submit'], 'L_RESET' => $lang['Reset'])); $max_columns_per_row = 3; $columnwidth = intval(floor(100 / $max_columns_per_row)); $bresenham = 0; $numrows = intval(ceil(count($indices) / $max_columns_per_row)); $i = 0; while ($c_cur =& $cash->currency_next($cm_i, CURRENCY_ENABLED | CURRENCY_EXCHANGEABLE)) { $template->assign_block_vars("cashrow", array('CASH_ID' => $c_cur->id(), 'CASH_NAME' => $c_cur->name(true))); if ($i * $numrows / $cash->currency_count(CURRENCY_ENABLED | CURRENCY_EXCHANGEABLE) >= $bresenham) {