作者發出的修正
我在phpbb的論壇中找到的
尋找\r
代碼: 選擇全部
//========================================[ Exchange Code ]===========================
//
代碼: 選擇全部
//
//========================================[ Exchange Code ]===========================
//
case "exchange":
default:
//
// Load templates
//
$template->set_filenames(array(
'body' => 'cash_exchange.tpl')
);
//
// Output page header
//
$page_title = $lang['Exchange'];
include($phpbb_root_path . 'includes/page_header.'.$phpEx);
$sql = "SELECT * FROM " . CASH_EXCHANGE_TABLE;
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, "Could not obtain exchange information", '', __LINE__, __FILE__, $sql);
}
if ( !($row = $db->sql_fetchrow($result)) )
{
message_die(GENERAL_MESSAGE, $lang['Exchange_lack_of_currencies']);
}
$exchange_data = array();
do
{
$exchange_data[$row['ex_cash_id1']][$row['ex_cash_id2']] = 1;
}
while ( $row = $db->sql_fetchrow($result) );
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 ( ($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) )
{
if ( $convert_amount < 0 )
{
qs($from_id,$to_id);
$convert_amount = -$convert_amount;
}
$c_cur_from = $cash->currency($from_id);
$c_cur_to = $cash->currency($to_id);
$exchanger = new cash_user($userdata['user_id'],$userdata);
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 )
{
$bresenham++;
$template->assign_block_vars("rowrow",array());
}
$headercash = $c_cur->display($userdata[$c_cur->db()]);
$template->assign_block_vars("rowrow.cashtable",array( 'CASH_ID' => $c_cur->id(),
'CASH_NAME' => $c_cur->name(),
'HEADER' => $lang['You_have'] . " " . $headercash,
'ONE_WORTH' => sprintf($lang['One_worth'],$c_cur->name()),
'NO_EXCHANGE' => sprintf($lang['Cannot_exchange'],$c_cur->name()))
);
$exchangecount = 0;
if ( isset($exchange_data[$c_cur->id()]) && count($exchange_data[$c_cur->id()]) )
{
$template->assign_block_vars("rowrow.cashtable.switch_exon",array());
while ( $c_cur_j = &$cash->currency_next($cm_j,CURRENCY_ENABLED | CURRENCY_EXCHANGEABLE) )
{
if ( ($c_cur->id() != $c_cur_j->id()) && isset($exchange_data[$c_cur->id()]) && isset($exchange_data[$c_cur->id()][$c_cur_j->id()]) )
{
$ratio = floor(($c_cur_j->data('cash_exchange')/$c_cur->data('cash_exchange'))*1000)/1000;
$template->assign_block_vars("rowrow.cashtable.switch_exon.exchangeitem",array( 'EXCHANGE' => $c_cur_j->display($ratio)));
}
}
}
else
{
$template->assign_block_vars("rowrow.cashtable.switch_exoff",array());
}
$i++;
}
$template->pparse('body');
include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
break;
}
?>