示例#1
1
 public function wallet()
 {
     $wallet = Wallet::where('user_id', '=', $this->id)->get();
     if (count($wallet) != 0) {
         $wallet = $wallet->first();
     } else {
         $wallet = new Wallet();
         $wallet->user_id = $this->id;
         $wallet->account_id = $this->account_id;
         $wallet->save();
     }
     return $wallet;
 }
 public function withdraw()
 {
     //retrieve POST value
     $param = Input::only('credits', 'account_id');
     $rules = array('credits' => 'required|numeric|min:1,max:1000000', 'account_id' => 'exists:acl_users,id');
     //custom error messaging
     $messages = array();
     $validator = Validator::make($param, $rules, $messages);
     if ($validator->passes()) {
         $retrieve = Wallet::where('account_id', $param['account_id'])->first();
         if (!empty($retrieve)) {
             if ($retrieve->credits >= $param['credits']) {
                 try {
                     $update = $retrieve->decrement('credits', $param['credits']);
                     if ($update == 1) {
                         $fundin = array('wallet_id' => $retrieve->id, 'onbehalf' => Auth::user()->id, 'credits' => $param['credits'], 'description' => 'Withdraw credits', 'fundtype' => 'fundout');
                         $funds = Fundinout::create($fundin);
                     }
                 } catch (Exception $e) {
                     return false;
                 }
                 $message = 'Credit has been successfully withdraw.';
                 return Redirect::action('player.index')->with('success', $message);
             } else {
                 return Redirect::action('player.index')->with('error', 'Insufficient credits!');
             }
         } else {
             return Redirect::action('player.index')->with('error', 'Insufficient credits!');
         }
     } else {
         $messages = $validator->messages();
         return Redirect::action('player.index')->with('error', $messages->all());
     }
 }
 public function deposit()
 {
     //retrieve POST value
     $param = Input::only('credits', 'account_id');
     $rules = array('credits' => 'required|numeric|min:1,max:1000000', 'account_id' => 'exists:acl_users,id');
     $messages = array('buyer_id.exists' => 'Buyer id is not valid.', 'merchant_id.exists' => 'Merchant id is not valid');
     $validator = Validator::make($param, $rules, $messages);
     if ($validator->passes()) {
         $retrieve = Wallet::where('account_id', $param['account_id'])->first();
         $credits = array('account_id' => $param['account_id'], 'credits' => $param['credits']);
         if (!empty($retrieve)) {
             try {
                 $update = $retrieve->increment('credits', $param['credits']);
                 if ($update == 1) {
                     $fundin = array('wallet_id' => $retrieve->id, 'onbehalf' => Auth::user()->id, 'credits' => $param['credits'], 'description' => 'Deposit credits', 'fundtype' => 'fundin');
                     $funds = Fundinout::create($fundin);
                 }
             } catch (Exception $e) {
                 return false;
             }
         } else {
             $add_credits = Wallet::create($credits);
             $fundin = array('wallet_id' => $add_credits->id, 'onbehalf' => Auth::user()->id, 'credits' => $param['credits'], 'description' => 'Deposit credits', 'fundtype' => 'fundin');
             $funds = Fundinout::create($fundin);
         }
         $message = 'Credit has been successfully added.';
         return Redirect::action('roulette.index')->with('success', $message);
     } else {
         $messages = $validator->messages();
         return Redirect::action('roulette.index')->with('error', $messages->all());
     }
 }
示例#4
0
 public function getType($wallet_id)
 {
     $type = Wallet::where('id', '=', $wallet_id)->select('type')->first();
     if (isset($type->type)) {
         return $type->type;
     } else {
         return '';
     }
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     if (ACL::checkUserPermission('bet.roulette') == false) {
         return Redirect::action('dashboard');
     }
     $param = Input::only('bettype', 'betnumber', 'amount', 'game_id');
     $retrieve = Wallet::where('account_id', Auth::user()->id)->first();
     $bet_type = array('straight', 'split', 'line', 'square', 'basket', 'doublestreet');
     if ($retrieve->credits >= $param['amount']) {
         if (Input::has('betnumber')) {
             if (count($param['betnumber']) >= 0 && count($param['betnumber']) <= 6) {
                 $retrieve = Wallet::where('account_id', Auth::user()->id)->first();
                 $index = count($param['betnumber']) - 1;
                 try {
                     $update = $retrieve->decrement('credits', (double) $param['amount']);
                     $fundinout = array('wallet_id' => $retrieve->id, 'onbehalf' => Auth::user()->id, 'credits' => $param['amount'], 'description' => 'Bet on Roulette amount of $' . (double) $param['amount'], 'fundtype' => 'bet');
                     $fundout = Fundinout::create($fundinout);
                     $bet = array('player_id' => Auth::user()->id, 'channel_id' => $param['game_id'], 'bet_number' => implode(',', $param['betnumber']), 'bet_amount' => $param['amount'], 'bet_type' => $bet_type[$index]);
                     Gamebets::create($bet);
                     $message = 'Bet has been successfully place.';
                     return Redirect::action('bet.roulette')->with('success', $message);
                 } catch (Exception $e) {
                     return false;
                 }
             } else {
                 return Redirect::action('bet.roulette')->with('error', 'You can only place maximum of 6 number.');
             }
         }
         if (Input::has('bettype')) {
             $param = Input::only('bettype', 'amount', 'game_id');
             $retrieve = Wallet::where('account_id', Auth::user()->id)->first();
             try {
                 $update = $retrieve->decrement('credits', (double) $param['amount']);
                 $fundinout = array('wallet_id' => $retrieve->id, 'onbehalf' => Auth::user()->id, 'credits' => $param['amount'], 'description' => 'Bet on Roulette amount of $' . (double) $param['amount'], 'fundtype' => 'bet');
                 $fundout = Fundinout::create($fundinout);
                 $bet = array('player_id' => Auth::user()->id, 'channel_id' => $param['game_id'], 'bet_number' => $param['bettype'], 'bet_amount' => $param['amount'], 'bet_type' => $param['bettype']);
                 Gamebets::create($bet);
                 $message = 'Bet has been successfully place.';
                 return Redirect::action('bet.roulette')->with('success', $message);
             } catch (Exception $e) {
                 return false;
             }
         }
     } else {
         return Redirect::action('bet.roulette')->with('error', 'Insufficient credits!');
     }
 }
 public function blocknotifyUpdateDeposit($wallet_type = '')
 {
     $blockhash = isset($_GET['trxhash']) ? $_GET['trxhash'] : 0;
     $logFile = 'laravel_' . $wallet_type . '.log';
     Log::useDailyFiles(storage_path() . '/logs/callbackdeposits/' . $logFile);
     Log::info("*******New Blocknotify Update Deposit: " . $blockhash . " -- wallet_type: " . $wallet_type);
     Log::info("\n" . "-- wallet_type: " . $wallet_type);
     if ($wallet_type != '') {
         $wallet = Wallet::where('type', strtoupper($wallet_type))->first();
         $wallet->connectJsonRPCclient($wallet->wallet_username, $wallet->wallet_password, $wallet->wallet_ip, $wallet->port);
         $limit_confirmations = empty($wallet->limit_confirmations) || $wallet->limit_confirmations <= 0 ? 3 : $wallet->limit_confirmations;
         $listtrans = $wallet->getListTransactions();
         @Log::info("\n" . 'Result listtrans: ', $listtrans);
         $balance = new Balance();
         foreach ($listtrans as $key => $value) {
             try {
                 $transaction_id = $value['txid'];
                 $trans = $wallet->getTransaction($transaction_id);
                 if ($trans != null) {
                     $account = $trans["details"][0]["account"];
                     $category = $trans["details"][0]["category"];
                     $confirms = $trans["confirmations"];
                     //send,receive
                     $address_ = $trans["details"][0]["address"];
                     $amount = $trans["amount"];
                     Log::info("\n" . "transaction: ", $trans);
                     Log::info("\n" . "------Account: " . $account . " -- category:" . $category . " --address: " . $address_);
                     //mail("*****@*****.**", 'Deposit Cron: ', var_export($trans, true));
                     $deposit = Deposit::where('transaction_id', $transaction_id)->first();
                     $user = User::where('username', $account)->first();
                     if (isset($deposit->transaction_id)) {
                         if ($deposit->paid == 0) {
                             if ($category == "receive" && $confirms >= $limit_confirmations && isset($user->id)) {
                                 Deposit::where('id', $deposit->id)->update(array('paid' => 1, 'confirmations' => $confirms));
                                 $balance->addMoney($amount, $wallet->id, $user->id);
                                 $message .= "<br>" . $amount . " " . $wallet->type . " was credited to your account";
                                 Log::info("\n" . $amount . " " . $wallet->type . " was credited to your account");
                             }
                         } else {
                             Deposit::where('id', $deposit->id)->update(array('confirmations' => $confirms));
                             Log::info("\n" . $amount . " " . $wallet->type . " was already credited to your account. contact support if you need further assistance.");
                         }
                     } else {
                         if ($category == "receive" && isset($user->id)) {
                             if ($confirms >= $limit_confirmations) {
                                 Deposit::insert(array('user_id' => $user->id, 'wallet_id' => $wallet->id, 'transaction_id' => $transaction_id, 'amount' => $amount, 'paid' => 1, 'confirmations' => $confirms, 'address' => $address_, 'created_at' => date('Y-m-d H:i:s'), 'updated_at' => date('Y-m-d H:i:s')));
                                 $balance->addMoney($amount, $wallet->id, $user->id);
                                 Log::info("\n" . $amount . " " . $wallet->type . " was credited to your account");
                             } else {
                                 Deposit::insert(array('user_id' => $user->id, 'wallet_id' => $wallet->id, 'transaction_id' => $transaction_id, 'amount' => $amount, 'paid' => 0, 'confirmations' => $confirms, 'address' => $address_, 'created_at' => date('Y-m-d H:i:s'), 'updated_at' => date('Y-m-d H:i:s')));
                                 Log::info("\n" . "This Deposit is unconfirmed. Current confirmations:" . $confirms . ". Required : 3.");
                             }
                         } else {
                             Log::info("\n" . "transaction is not a deposit or account is invalid.");
                         }
                     }
                 } else {
                     Log::info("\n" . "We can't find any information about this deposit. contact support.");
                 }
                 //trans
             } catch (Exception $e) {
                 Log::info('Caught exception: ' . $e->getMessage() . "\n");
             }
         }
     } else {
         Log::info('------------------- Error: not param wallet_type from _GET');
     }
     Log::info("*******Stop New Blocknotify Update Deposit*************");
 }
示例#7
0
 public function routePage($page = '')
 {
     //echo "<pre>user: "******"</pre>";
     switch ($page) {
         case "fees":
             $market = new Market();
             $wallet = new Wallet();
             $fees_trade = FeeTrade::get()->toArray();
             //echo "<pre>list_buy_orders: "; print_r($list_buy_orders); echo "</pre>";
             $fees_withdraw = FeeWithdraw::leftJoin('wallets', 'fee_withdraw.wallet_id', '=', 'wallets.id')->select('fee_withdraw.*', 'wallets.type', 'wallets.name')->get();
             foreach ($fees_trade as $key => $value) {
                 $wallet_type = $market->getWalletType($value['market_id']);
                 if (!empty($wallet_type)) {
                     $fees_trade[$key]['wallet_from'] = $wallet_type['wallet_from'];
                     $fees_trade[$key]['wallet_to'] = $wallet_type['wallet_to'];
                 }
             }
             $fee['fees_trade'] = $fees_trade;
             $fee['fees_withdraw'] = $fees_withdraw;
             return View::make('fees', $fee);
             break;
         case "voting":
             $setting = new Setting();
             $coinvotes = DB::table('coin_votes')->get();
             try {
                 $wallet = Wallet::where('type', 'BTC')->first();
                 $wallet->connectJsonRPCclient($wallet->wallet_username, $wallet->wallet_password, $wallet->wallet_ip, $wallet->port);
                 foreach ($coinvotes as $key => $value) {
                     $num_vote = Vote::where('coinvote_id', '=', $value->id)->count();
                     //echo "<pre>getreceivedbyaccount"; print_r($wallet->getReceivedByAddress($value->btc_address)); echo "</pre>";//$value->label_address
                     $btc_payment = $wallet->getReceivedByAddress($value->btc_address);
                     //'12X9jVe4S8pAqJ7EoKN7B4YwMQpzfgArtX'
                     $amount_btc_per_vote = $setting->getSetting('amount_btc_per_vote', 0.0001);
                     $num_payment = floor($btc_payment / $amount_btc_per_vote);
                     //echo "btc_payment: ".$btc_payment;
                     //echo "<br>num_payment: ".$num_payment;
                     $coinvotes[$key]->num_vote = $num_vote + $num_payment;
                 }
             } catch (Exception $e) {
                 $data['error_message'] = Lang::get('texts.not_connect_wallet');
                 //'Caught exception: '.$e->getMessage()."\n";  //"Not connect to this
             }
             //echo "<pre>coinvotes"; print_r($coinvotes); echo "</pre>";
             $data['coinvotes'] = $coinvotes;
             return View::make('voting', $data);
             break;
         case "security":
             return View::make('security');
             break;
         case "api":
             if (isset($_REQUEST['method'])) {
                 $method = $_REQUEST['method'];
                 $value = $this->api($method);
             } else {
                 $setting = new Setting();
                 $data['pusher_app_key'] = $setting->getSetting('pusher_app_key', '');
                 return View::make('api', $data);
             }
             print_r($value);
             break;
         case "apiprivate":
             $value = $this->apiprivate();
             break;
         case "all-trades":
             if (Auth::guest()) {
                 return Redirect::to('/login');
             }
             $record_per_page = 15;
             if (empty($_GET['pager_page'])) {
                 $pager_page = 1;
             } else {
                 $pager_page = $_GET['pager_page'];
             }
             $data['cur_page'] = $pager_page;
             $offset_start = ($pager_page - 1) * $record_per_page;
             $trade_history = Trade::leftjoin('market', 'market.id', '=', 'trade_history.market_id')->select('trade_history.*', 'market.wallet_from as from', 'market.wallet_to as to');
             $where = '';
             if (Input::has('market')) {
                 $fil_market = Input::get('market');
                 $trade_history->where("trade_history.market_id", "=", $fil_market);
             }
             if (Input::has('type')) {
                 $fil_type = Input::get('type');
                 $trade_history->where("trade_history.type", "=", $fil_type);
             }
             $total_records = $trade_history->get();
             $data['total_pages'] = ceil(count($total_records) / $record_per_page);
             $trades = $trade_history->skip($offset_start)->take($record_per_page)->orderby("created_at", "desc")->get();
             #echo "<pre>trade_history"; print_r($trades->toArray()); echo "</pre>";
             //echo "<pre>getQueryLog: ".dd(DB::getQueryLog())."</pre>";
             $data['tradehistories'] = $trades;
             $market = new Market();
             $markets = Market::get();
             $market_wallet = array();
             foreach ($markets as $value) {
                 $market_wallet[$value->id] = $market->getWalletType($value->id);
             }
             $data['markets'] = $market_wallet;
             return View::make('alltrades', $data);
             break;
         case "all-news":
             $news = Post::where('type', 'news')->orderby('created_at', 'desc')->get();
             $data['news'] = $news;
             return View::make('allnews', $data);
             break;
         default:
             return View::make('index');
             break;
     }
 }
 public function player_winnings($payout, $player_id, $bet_amount, $channel_id)
 {
     $payout_amount = $payout * $bet_amount + $bet_amount;
     $retrieve = Wallet::where('account_id', $player_id)->first();
     try {
         $update = $retrieve->increment('credits', $payout_amount);
         if ($update == 1) {
             $fundin = array('wallet_id' => $retrieve->id, 'onbehalf' => Auth::user()->id, 'credits' => $payout_amount, 'description' => 'Player winnings on roullete ' . $channel_id, 'fundtype' => 'winnings');
             $funds = Fundinout::create($fundin);
         }
     } catch (Exception $e) {
         return false;
     }
 }
 public function doSendCoin()
 {
     $amount = Input::get('amount');
     $address = Input::get('address');
     $wallet_type = Input::get('wallet_type');
     $wallet = Wallet::where('type', $wallet_type)->first();
     //echo "<pre>wallet: "; print_r($wallet->toArray()); echo "</pre>";
     $user = Confide::user();
     if ($user->hasRole('Admin')) {
         try {
             $wallet->connectJsonRPCclient($wallet->wallet_username, $wallet->wallet_password, $wallet->wallet_ip, $wallet->port);
             $txid = $wallet->sendToAddress($address, $amount);
             $fee = $wallet->getTxFee();
             $net_total = $amount - $fee;
             if ($txid) {
                 Withdraw::insert(array('user_id' => $user->id, 'wallet_id' => $wallet->id, 'to_address' => $address, 'amount' => $amount, 'fee_amount' => $fee, 'receive_amount' => $net_total, 'created_at' => date('Y-m-d H:i:s'), 'status' => 1, 'transaction_id' => $txid));
                 return Redirect::to('admin/manage/funds')->with('success', Lang::get('admin_messages.withdraw_success', array('amount' => sprintf('%.8f', $net_total), 'coin' => $wallet->type, 'address' => $address, 'fee' => $fee)));
             } else {
                 return Redirect::to('admin/manage/funds')->with('notice', Lang::get('admin_messages.cannot_send_coin', array('name' => $wallet->name)));
             }
         } catch (Exception $e) {
             return Redirect::to('admin/manage/funds')->with('notice', Lang::get('admin_messages.cannot_connect_wallet', array('name' => $wallet->name)));
             //'Caught exception: '.$e->getMessage()
         }
     }
 }