function report($message, $severity) { global $is_logged_in; $uid = ''; if ($is_logged_in) { $uid = $is_logged_in; } $time = date('r'); $message = "{$uid} {$time}: {$message}"; switch ($severity) { case SEVERITY::PROBLEM: $filename = PROBLEM_LOGFILE; break; case SEVERITY::ERROR: $filename = ERROR_LOGFILE; break; case SEVERITY::BAD_PAGE: $filename = BAD_PAGE_LOGFILE; break; default: report("Invalid report for {$message} of {$severity}!", SEVERITY::ERROR); break; } error_log("{$message}\n", 3, $filename); beginlog(); syslog(LOG_CRIT, $message); endlog(); // do this last because it's the most risky operation, and we at least want some logs first. if ($severity == SEVERITY::ERROR) { // echo exec("echo 'A fatal error has occured. Time is now $time.' | mutt -s INTERSANGO_ERROR genjix@gmail.com -a $filename"); } }
function save_details($uid, $amount, $curr_type, &$voucher, &$reqid) { beginlog(); syslog(LOG_NOTICE, "Withdrawing {$amount} {$curr_type}:"); if ($curr_type == CURRENCY) { $is_international = post('is_international') == 'true'; if (!$is_international) { uk_withdraw($uid, $amount, $curr_type, $voucher, $reqid); return true; } else { international_withdraw($uid, $amount, $curr_type, $reqid); return true; } } else { if ($curr_type == 'BTC') { bitcoin_withdraw($uid, $amount, $curr_type, $voucher, $reqid); return true; } else { throw Error('Invalid currency', 'You cannot withdraw a currency that does not exist.'); } } // should never happen! return false; }