public static function addNewPMWallet() { $account_id = Core::validate($_POST['ACCOUNT_ID']); $pass_phrase = Core::validate($_POST['PASS_PHRASE']); $alternate_pass_phrase = Core::validate($_POST['ALTERNATE_PASS_PHRASE']); $units = Core::validate($_POST['UNITS']); $account = Core::validate($_POST['ACCOUNT']); $share = Core::validate($_POST['SHARE']); // percent if ($account_id == null || $pass_phrase == null || $alternate_pass_phrase == null || $units == null || $account == null || $share == null || !Core::isDouble($share)) { print 'Incorrect input data'; exit; } $result = WalletsPm::findBy(array('account' => $account)); if (!empty($result)) { print 'This account already exists'; exit; } $perfectMoney = new PerfectMoney(); $perfectMoney->setAccountId($account_id); $perfectMoney->setPassPhrase($pass_phrase); $resp = $perfectMoney->balance(); if ($resp == null) { print $perfectMoney->getError(); exit; } if (!isset($resp[$account])) { print 'Invalid account'; exit; } $value = $resp[$account]; $pmWallet = new WalletsPm(); $pmWallet->setAccountId($account_id); $pmWallet->setPassPhrase($pass_phrase); $pmWallet->setAlternatePassPhrase($alternate_pass_phrase); $pmWallet->setUnits($units); $pmWallet->setAccount($account); $pmWallet->setValue($value); $pmWallet->setShare($share / 100.0); $pmWallet->insert(); header('Location: /admin/pm'); }