예제 #1
0
     }
     break;
     //
     // ================= Update board mode ( submitted form ) ================================
     //
 //
 // ================= Update board mode ( submitted form ) ================================
 //
 case "update":
     if (isset($HTTP_POST_VARS['event_name']) && isset($HTTP_POST_VARS['cash']) && is_array($HTTP_POST_VARS['cash'])) {
         $event_name = $HTTP_POST_VARS['event_name'];
         $updates = array();
         $updated_data = '';
         while ($c_cur =& $cash->currency_next($cm_i)) {
             if (isset($HTTP_POST_VARS['cash'][$c_cur->id()])) {
                 $entry = cash_floatval($HTTP_POST_VARS['cash'][$c_cur->id()]);
                 if ($entry != 0) {
                     $updates[] = $c_cur->id() . CASH_EVENT_DELIM2 . $entry;
                 }
             }
         }
         if (count($updates)) {
             $updated_data = implode(CASH_EVENT_DELIM1, $updates);
         }
         $sql = "UPDATE " . CASH_EVENTS_TABLE . "\n\t\t\t\t\tSET event_data = '" . $updated_data . "'\n\t\t\t\t\tWHERE event_name = '" . str_replace("\\'", "''", $event_name) . "'";
         if (!$db->sql_query($sql)) {
             message_die(CRITICAL_ERROR, "Could not update event", "", __LINE__, __FILE__, $sql);
         }
         message_die(GENERAL_MESSAGE, $lang['Cash_events_updated'] . "<br /><br />" . sprintf($lang['Click_return_cash_events'], "<a href=\"" . append_sid("cash_events.{$phpEx}") . "\">", "</a>") . "<br /><br />" . sprintf($lang['Click_return_admin_index'], "<a href=\"" . append_sid("index.{$phpEx}?pane=right") . "\">", "</a>"));
     }
     break;
예제 #2
0
 $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));
 $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']));
예제 #3
0
         message_die(GENERAL_MESSAGE, $lang['Cash_events_updated'] . '<br /><br />' . sprintf($lang['Click_return_cash_events'], '<a href="' . append_sid('cash_events.' . PHP_EXT) . '">', '</a>') . '<br /><br />');
     }
     break;
     //
     // ================= Update board mode (submitted form) ================================
     //
 //
 // ================= Update board mode (submitted form) ================================
 //
 case 'update':
     if (!empty($event_name) && isset($_POST['cash']) && is_array($_POST['cash'])) {
         $updates = array();
         $updated_data = '';
         while ($c_cur =& $cash->currency_next($cm_i)) {
             if (isset($_POST['cash'][$c_cur->id()])) {
                 $entry = cash_floatval($_POST['cash'][$c_cur->id()]);
                 if ($entry != 0) {
                     $updates[] = $c_cur->id() . CASH_EVENT_DELIM2 . $entry;
                 }
             }
         }
         if (sizeof($updates)) {
             $updated_data = implode(CASH_EVENT_DELIM1, $updates);
         }
         $sql = "UPDATE " . CASH_EVENTS_TABLE . "\n\t\t\t\t\tSET event_data = '" . $updated_data . "'\n\t\t\t\t\tWHERE event_name = '" . $db->sql_escape($event_name) . "'";
         $db->sql_query($sql);
         message_die(GENERAL_MESSAGE, $lang['Cash_events_updated'] . '<br /><br />' . sprintf($lang['Click_return_cash_events'], '<a href="' . append_sid('cash_events.' . PHP_EXT) . '">', '</a>') . '<br /><br />' . sprintf($lang['Click_return_admin_index'], '<a href="' . append_sid('index.' . PHP_EXT . '?pane=right') . '">', '</a>'));
     }
     break;
     //
     // ================= Edit board mode (or delete) ================================
예제 #4
0
if ($board_config['cash_adminnavbar']) {
    $navbar = 1;
    include './admin_cash.' . $phpEx;
}
if ($cash->currency_count() < 2) {
    message_die(GENERAL_MESSAGE, $lang['Exchange_insufficient_currencies']);
}
$exchange_update = false;
if (isset($HTTP_POST_VARS['currency_val']) && is_array($HTTP_POST_VARS['currency_val'])) {
    $exchange_update = true;
}
$exchange = array();
while ($c_cur =& $cash->currency_next($cm_i)) {
    $exval = $c_cur->exchange();
    if ($exchange_update && isset($HTTP_POST_VARS['currency_val'][$c_cur->id()]) && is_numeric($HTTP_POST_VARS['currency_val'][$c_cur->id()]) && intval($HTTP_POST_VARS['currency_val'][$c_cur->id()]) > 0) {
        $newvalue = $c_cur->attribute_pack('cash_exchange', cash_floatval($HTTP_POST_VARS['currency_val'][$c_cur->id()]));
        $sql = "UPDATE " . CASH_TABLE . "\n\t\t\t\tSET cash_exchange = {$newvalue}\n\t\t\t\tWHERE cash_id = " . $c_cur->id();
        if (!$db->sql_query($sql)) {
            message_die(CRITICAL_ERROR, "Could not update exchange information", "", __LINE__, __FILE__, $sql);
        }
        $exval = $newvalue / $c_cur->factor();
    }
    $exchange[] = array('id' => $c_cur->id(), 'name' => $c_cur->name(), 'exchange' => $exval);
}
for ($i1 = 0; $i1 < count($exchange); $i1++) {
    $i = $exchange[$i1]['id'];
    $varname = 'exchange_' . $i;
    if (isset($HTTP_POST_VARS[$varname]) && is_array($HTTP_POST_VARS[$varname])) {
        for ($i2 = 0; $i2 < count($exchange); $i2++) {
            $j = $exchange[$i2]['id'];
            if (isset($HTTP_POST_VARS[$varname][$j]) && $i != $j) {
예제 #5
0
             }
             message_die(GENERAL_MESSAGE, "<br />" . $lang['Update_successful'] . "<br /><br />" . sprintf($lang['Click_return_cash_reset'], "<a href=\"" . append_sid("cash_reset.{$phpEx}") . "\">", "</a>") . "<br /><br />");
         }
     }
     break;
 case "submitted":
     if (isset($HTTP_POST_VARS['submit']) && isset($HTTP_POST_VARS['cash_check']) && is_array($HTTP_POST_VARS['cash_check'])) {
         switch ($HTTP_POST_VARS['submit']) {
             case $lang['Set_checked']:
                 if (isset($HTTP_POST_VARS['cash_amount']) && is_array($HTTP_POST_VARS['cash_amount'])) {
                     $s_hidden_fields = '';
                     $c_ids = array();
                     while ($c_cur =& $cash->currency_next($cm_i)) {
                         if (isset($HTTP_POST_VARS['cash_check'][$c_cur->id()]) && isset($HTTP_POST_VARS['cash_amount'][$c_cur->id()])) {
                             $c_ids[] = $c_cur->id();
                             $s_hidden_fields .= '<input type="hidden" name="cash_amount[' . $c_cur->id() . ']" value="' . cash_floatval($HTTP_POST_VARS['cash_amount'][$c_cur->id()]) . '" />';
                         }
                     }
                     if (count($c_ids)) {
                         $s_hidden_fields .= '<input type="hidden" name="cids" value="' . implode(',', $c_ids) . '" />';
                         $s_hidden_fields .= '<input type="hidden" name="mode" value="reset" />';
                         $l_confirm = $lang['Cash_confirm_reset'];
                         $template->set_filenames(array('confirm_body' => 'confirm_body.tpl'));
                         $template->assign_vars(array('MESSAGE_TITLE' => $lang['Information'], 'MESSAGE_TEXT' => $l_confirm, 'L_YES' => $lang['Yes'], 'L_NO' => $lang['No'], 'S_CONFIRM_ACTION' => append_sid("cash_reset.{$phpEx}"), 'S_HIDDEN_FIELDS' => $s_hidden_fields));
                         $template->pparse('confirm_body');
                         include $phpbb_root_path . 'includes/page_tail.' . $phpEx;
                     }
                 }
                 break;
             case $lang['Recount_checked']:
                 $c_ids = array();
예제 #6
0
function cash_event_unpack($string)
{
    $cash_amounts = array();
    if (strlen($string)) {
        $cash_entries = explode(CASH_EVENT_DELIM1, $string);
        for ($i = 0; $i < sizeof($cash_entries); $i++) {
            if (strlen($cash_entries[$i])) {
                $temp = explode(CASH_EVENT_DELIM2, $cash_entries[$i]);
                if (isset($temp[0]) && isset($temp[1])) {
                    $cash_amounts[intval($temp[0])] = cash_floatval($temp[1]);
                }
            }
        }
    }
    return $cash_amounts;
}