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;
 }
Example #2
0
 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);
     }
 }
Example #3
0
 public static function handler(Exception $e)
 {
     try {
         $type = get_class($e);
         $code = $e->getCode();
         $message = $e->getMessage();
         $file = $e->getFile();
         $line = $e->getLine();
         $trace = $e->getTrace();
         if ($e instanceof ErrorException) {
             if (isset(keke_exception::$php_errors[$code])) {
                 $code = keke_exception::$php_errors[$code];
             }
             if (version_compare(PHP_VERSION, '5.3', '<')) {
                 for ($i = count($trace) - 1; $i > 0; --$i) {
                     if (isset($trace[$i - 1]['args'])) {
                         $trace[$i]['args'] = $trace[$i - 1]['args'];
                         unset($trace[$i - 1]['args']);
                     }
                 }
             }
         }
         $error = keke_exception::text($e);
         $data['type'] = $type;
         $data['code'] = $code;
         $data['message'] = $message;
         $data['file'] = $file;
         $data['line'] = $line;
         $vars = array('_SESSION', '_GET', '_POST', '_FILES', '_COOKIE', '_SERVER');
         $data['trace'] = array_reverse(keke_debug::trace($trace));
         require S_ROOT . '/control/exception.php';
         die;
     } catch (Exception $e) {
         ob_get_level() and ob_clean();
         echo keke_exception::text($e), "\n";
         exit(1);
     }
 }