示例#1
0
 public function admin_index()
 {
     //check last balance
     if ($this->site_settings['last_balance_check'] < time() + 60 * 10) {
         $_SERVER['HTTP_HOST'] = 'faucet.is-lost.org';
         //over-ride for testing on localhost
         $fb = new FaucetBOX($this->site_settings['api_key']);
         $ret = $fb->getBalance();
         //pr($ret);
         $last_balance_check = $this->settings->load(['param = ?', 'last_balance_check']);
         $last_balance_check->val = time();
         $last_balance_check->update();
         $balance = $this->settings->load(['param = ?', 'balance']);
         $balance->val = $ret['balance_bitcoin'];
         $balance->update();
     }
     $settings = $this->settings->find();
     //load all available settings
     $this->fw->set('settings', $settings);
     $this->fw->set('scriptBottom', "/js/settings_admin.js");
 }
示例#2
0
 $content .= "<h3>Address</h3>";
 $content .= $user['address'];
 $content .= "<h3>Balance</h3>";
 $content .= toSatoshi($user['balance']) . " Satoshi<br /><br />";
 if (toSatoshi($user['balance']) >= 1) {
     if ($_GET['pt'] == 1) {
         if (!isset($_POST['token']) || $_POST['token'] !== $_SESSION['token']) {
             unset($_SESSION['token']);
             $_SESSION['token'] = md5(md5(uniqid() . uniqid() . mt_rand()));
             exit;
         }
         unset($_SESSION['token']);
         $_SESSION['token'] = md5(md5(uniqid() . uniqid() . mt_rand()));
         $api_key = $mysqli->query("SELECT * FROM faucet_settings WHERE id = '10' LIMIT 1")->fetch_assoc()['value'];
         $currency = "BTC";
         $faucetbox = new FaucetBOX($api_key, $currency);
         $result = $faucetbox->send($user['address'], toSatoshi($user['balance']));
         if ($result["success"] === true) {
             $timestamp = time();
             $mysqli->query("UPDATE faucet_user_list Set balance = '0' WHERE id = '{$user['id']}'");
             $mysqli->query("INSERT INTO faucet_transactions (userid, type, amount, timestamp) VALUES ('{$user['id']}', 'Withdraw', '{$user['balance']}', '{$timestamp}')");
             $content .= $result["html"];
         } else {
             $content .= $result["html"];
         }
     }
     $content .= "<form method='post' action='?pt=1'>\n\t\t<input type='hidden' name='token' value='" . $_SESSION['token'] . "'/><button type='submit' class='btn btn-primary'>Withdraw to Faucetbox</button></form>";
 } else {
     $content .= "<a href='#' class='btn btn-danger'>Withdraw is not avaible.</a>";
 }
 $content .= "<br /><br />";
示例#3
0
     $to = floatval($reward_range[1]);
     $reward = mt_rand($from, $to);
 } else {
     $reward = floatval($reward[1]);
 }
 if ($data["currency"] == "DOGE") {
     $reward = $reward * 100000000;
 }
 $q = $sql->prepare("SELECT balance FROM Faucetinabox_Refs WHERE address = ?");
 $q->execute(array(trim($_POST["address"])));
 if ($b = $q->fetch()) {
     $refbalance = floatval($b[0]);
 } else {
     $refbalance = 0;
 }
 $fb = new FaucetBOX($data["apikey"], $data["currency"], $connection_options);
 $address = trim($_POST["address"]);
 if (empty($address)) {
     $ret = array("success" => false, "message" => "Invalid address.", "html" => "<div class=\"alert alert-danger\">Invalid address.</div>");
 } else {
     if (in_array($address, $security_settings["address_ban_list"])) {
         $ret = array("success" => false, "message" => "Unknown error.", "html" => "<div class=\"alert alert-danger\">Unknown error.</div>");
     } else {
         $ret = $fb->send($address, $reward);
     }
 }
 if ($ret["success"] && $refbalance > 0) {
     $ret = $fb->sendReferralEarnings(trim($_POST["address"]), $refbalance);
 }
 if ($ret['success']) {
     setcookie('address', trim($_POST['address']), time() + 60 * 60 * 24 * 60);
示例#4
0
 public function admin_index()
 {
     $settings = $this->_load_model('settings');
     if ($data = $this->fw->get('POST.data')) {
         $api_key = $settings->load(['param=?', 'api_key']);
         $api_key->val = $data['api_key'];
         $api_key->save();
         $currency = $settings->load(['param=?', 'currency']);
         $currency->val = $data['currency'];
         $currency->save();
         //update captcha settings
         $updates = $settings->find(["param='default_captcha' or param like '%{$data['default_captcha']}%'"]);
         foreach ($updates as $setting) {
             if (array_key_exists($setting->param, $data)) {
                 $setting->val = $data[$setting->param];
             }
             $setting->save();
         }
         //end - save captcha settings
         $this->fw->set('SESSION.flash', ['type' => 'success', 'message' => "Faucet Settings Updated..."]);
         $this->fw->reroute("/admin/faucet");
         //reroute so new settings get loaded - hack for beforeroute
     }
     //end - update faucet data
     //currencies - only used if fb api doesnt have api_key yet
     $fb_currencies = ['BTC', 'LTC', 'DOGE', 'PPC', 'XPM', 'DASH'];
     $faucets = ['Solve Media' => 'solvemedia', 'ReCaptcha' => 'recaptcha', 'Are You Human' => 'ayah', 'Captch Me' => 'captchme', 'Fun Captcha' => 'funcaptcha', 'ReKlamper' => 'reklamper'];
     $this->fw->set('faucets', $faucets);
     //check apikey - current balance - and faucet currency
     $fb = new FaucetBOX($this->site_settings['api_key'], $this->site_settings['currency']);
     $currencies = $fb->getCurrencies() ?: $fb_currencies;
     $this->fw->set('currencies', $currencies);
     //pr($fb);
     if ($fb->last_status !== 200) {
         $this->fw->set('SESSION.flash', ['type' => 'danger', 'message' => "Please check your faucetbox api key..."]);
     } else {
         //good fb connection = check balance (every 10 mins)
         if ($this->site_settings['last_balance_check'] < time() + 60 * 10) {
             $fb_balance = $fb->getBalance();
             $last_balance_check = $this->fw->get('TIME');
             $settings_balance = $settings->load(['param=?', 'balance']);
             $settings_balance->val = $fb_balance['balance_bitcoin'];
             $settings_balance->save();
             //make sure to update site settings var
             $this->site_settings['balance'] = $settings_balance->val;
             $settings_balance_check = $settings->load(['param=?', 'last_balance_check']);
             $settings_balance_check->val = $last_balance_check;
             $settings_balance_check->save();
             //make sure to update site settings var
             $this->site_settings['last_balance_check'] = $settings_balance_check->val;
         }
     }
     //end - update balance
     $this->fw->set('scriptBottom', "/js/faucet_admin.js");
 }