public static function cash_out($id, $cash, $action, $profit = 0, $obj_type = null, $obj_id = null) { $user_info = db_factory::get_one("select * from " . TABLEPRE . "witkey_space where uid = " . intval($id)); $res = false; $fo = new Keke_witkey_finance_class(); $fo->setFina_action($action); $fo->setFina_type("out"); $fo->setObj_type($obj_type); $fo->setObj_id($obj_id); $fo->setSite_profit($profit); $fo->setUid($user_info['uid']); $fo->setUsername($user_info['username']); if (empty(self::$_mem)) { $action_arr = keke_glob_class::get_finance_action($action); self::$_mem = $action_arr[$action]; } $fo->setFina_mem(self::$_mem); $user_balance = $user_info['balance']; if ($cash && $action) { try { if ($user_balance < $cash) { return false; } db_factory::execute("update " . TABLEPRE . "witkey_space set balance = balance-" . abs(floatval($cash)) . " where uid ='{$user_info['uid']}'"); $fo->setFina_cash($cash); $fo->setUser_balance($user_balance - abs($cash)); $fo->setFina_time(time()); $res = $fo->create_keke_witkey_finance(); } catch (Exception $e) { keke_exception::handler($e); } } return $res; }
static function shutdown_handler() { if (KEKE_DEBUG and $error = error_get_last() and in_array($error['type'], array(E_PARSE, E_ERROR, E_USER_ERROR))) { ob_get_level() and ob_clean(); keke_exception::handler(new ErrorException($error['message'], $error['type'], 0, $error['file'], $error['line'])); exit(1); } }