public static function addNewBTCWallet() { $account = Core::validate($_POST['ACCOUNT']); $share = Core::validate($_POST['SHARE']); // percent if ($account == null || $share == null || !Core::isDouble($share)) { print 'Incorrect input data'; exit; } $result = WalletsBtc::findBy(array('account' => $account)); if (!empty($result)) { print 'This account already exists'; exit; } $bitcoin = new jsonRPCClient('http://' . BTC_RPC_USER . ':' . BTC_RPC_PASSWORD . '@' . BTC_RPC_HOST . ':' . BTC_RPC_PORT . '/'); try { $balance = $bitcoin->getbalance($account); } catch (Exception $e) { print $e; exit; } $wallet = new WalletsBtc(); $wallet->setAccount($account); $wallet->setValue($balance); $wallet->setShare($share / 100.0); $wallet->insert(); header('Location: /admin/btc'); }