public function parse($str) { $info = new BitCoin(); $ret = $this->default_json(); $ret['main_frame'] = $info->pluginUrl() . '/gui/BitCoinAmountPage.php'; return $ret; }
$mail = new Mail(); $mail->setFrom(MAIL_EMAIL_SUPPORT_ADDRESS); $mail->setReplyTo(MAIL_EMAIL_SUPPORT_ADDRESS); $mail->setSender(MAIL_EMAIL_SENDER_NAME); // Init Database try { $db = new PDO('mysql:dbname=' . DB_DATABASE . ';host=' . DB_HOSTNAME . ';charset=utf8', DB_USERNAME, DB_PASSWORD, array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8')); $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $db->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_OBJ); } catch (PDOException $e) { $error[] = $e->getMessage(); exit; } // Init BitCoin try { $bitcoin = new BitCoin(BITCOIN_RPC_USERNAME, BITCOIN_RPC_PASSWORD, BITCOIN_RPC_HOST, BITCOIN_RPC_PORT); } catch (Exception $e) { $error[] = $bitcoin->error . '/' . $e->getMessage(); exit; } // Init variables $total_count = 0; $processed_count = 0; $transaction_count = 0; // Get pending orders $statement = $db->prepare('SELECT `uvr`.`user_verification_id`, `uvr`.`user_id`, `uvr`.`amount`, `u`.`username`, `u`.`email`, `a`.`user_id` AS `affiliate_user_id`,
public function verification() { // Redirect if user is not logged if (!$this->auth->isLogged()) { $this->response->redirect($this->url->link('account/account/login', 'redirect=' . base64_encode($this->url->getCurrentLink()))); } // Redirect if user is already verified if ($this->auth->isVerified()) { $this->response->redirect($this->url->link('account/account')); } $this->document->setTitle(tt('Account verification')); $data = array(); $code = md5(PROJECT_NAME . $this->auth->getId()); // Create a new BitCoin Address try { $bitcoin = new BitCoin(BITCOIN_RPC_USERNAME, BITCOIN_RPC_PASSWORD, BITCOIN_RPC_HOST, BITCOIN_RPC_PORT); $address = $bitcoin->getaccountaddress(BITCOIN_USER_VERIFICATION_PREFIX . $this->auth->getId()); } catch (Exception $e) { $this->security_log->write('BitCoin connection error ' . $e->error); exit; } if ('POST' == $this->request->getRequestMethod() && $this->_validateVerification()) { // Save verification request into the DB if ($this->model_account_user->addVerificationRequest($this->auth->getId(), $this->currency->getId(), FEE_USER_VERIFICATION, 'pending', $code, $this->request->post['proof'])) { // Add notification $this->model_account_notification->addNotification($this->auth->getId(), DEFAULT_LANGUAGE_ID, 'common', tt('Your verification request was sent successfully'), tt('We will process the request as quickly as possible.')); // Admin alert $this->mail->setTo(MAIL_EMAIL_SUPPORT_ADDRESS); $this->mail->setSubject(sprintf(tt('Account Verification Request - %s'), PROJECT_NAME)); $this->mail->setText(tt('A new verification was requested.')); $this->mail->send(); // Success message $this->session->setUserMessage(array('success' => tt('Your verification request was sent successfully!'))); } } $data['error'] = $this->_error; $data['action'] = $this->url->link('account/account/verification'); $data['proof'] = isset($this->request->post['proof']) ? $this->request->post['proof'] : false; $data['accept_1'] = isset($this->request->post['accept_1']) ? $this->request->post['accept_1'] : false; $data['accept_2'] = isset($this->request->post['accept_2']) ? $this->request->post['accept_2'] : false; // Step 1 $data['payment_instruction'] = sprintf(tt('Send exactly %s to this address:'), $this->currency->format(FEE_USER_VERIFICATION)); $data['payment_address'] = $address; $data['payment_qr_href'] = $this->url->link('common/image/qr', 'code=' . $address); $data['payment_wallet_href'] = sprintf('bitcoin:%s?amount=%s&label=%s Verification Request for Account ID %s', $address, FEE_USER_VERIFICATION, PROJECT_NAME, $this->auth->getId()); // Step 3 $data['confirmation_code'] = $code; $data['href_cancel'] = $this->url->link('account/account'); $data['footer'] = $this->load->controller('common/footer'); $data['header'] = $this->load->controller('common/header'); $data['alert_danger'] = $this->load->controller('common/alert/danger'); $data['alert_success'] = $this->load->controller('common/alert/success'); $data['alert_warning'] = $this->load->controller('common/alert/warning'); $data['module_account'] = $this->load->controller('module/account'); $data['module_breadcrumbs'] = $this->load->controller('module/breadcrumbs', array(array('name' => tt('Home'), 'href' => $this->url->link('common/home'), 'active' => false), array('name' => tt('Account'), 'href' => $this->url->link('account/account'), 'active' => false), array('name' => tt('Verification'), 'href' => $this->url->link('account/account/verification'), 'active' => true))); // Renter the template $this->response->setOutput($this->load->view('account/account/verification.tpl', $data)); }
public function create() { // Only for logged users if (!$this->auth->isLogged()) { $this->security_log->write('Try to order product from guest request'); exit; } // Check request if (!$this->request->isAjax()) { $this->security_log->write('Try to order product without ajax request'); exit; } // Check dependencies if (!isset($this->request->post['product_id'])) { $this->security_log->write('Try to order product without product_id parameter'); exit; } // Check dependencies if (!isset($this->request->post['license']) || !in_array($this->request->post['license'], array('regular', 'exclusive'))) { $this->security_log->write('Try to order product without license parameter'); exit; } // Try to get product if (!($product_info = $this->model_catalog_product->getProduct((int) $this->request->post['product_id'], $this->auth->getId(), ORDER_APPROVED_STATUS_ID))) { $this->security_log->write('Try to order not exists product'); exit; } // Try to get denied product if (!$product_info->status) { $this->security_log->write('Try to order product ' . (int) $this->request->post['product_id'] . ' with status ' . $product_info->status); exit; } // Check if product already ordered if ($product_info->order_status_id == ORDER_APPROVED_STATUS_ID) { $this->security_log->write('Try to order ordered product'); exit; } // Check if order self product if ($product_info->user_id == $this->auth->getId()) { $this->security_log->write('Try to order self product'); exit; } // Check regular price if ($this->request->post['license'] == 'regular' && ($product_info->regular_price > 0 || $product_info->special_regular_price > 0)) { $amount = (double) $product_info->special_regular_price > 0 ? $product_info->special_regular_price : $product_info->regular_price; // Check exclusive price } else { if ($this->request->post['license'] == 'exclusive' && ($product_info->exclusive_price > 0 || $product_info->special_exclusive_price > 0)) { $amount = (double) $product_info->special_exclusive_price > 0 ? $product_info->special_exclusive_price : $product_info->exclusive_price; // License parameter error } else { $this->security_log->write('Try to purchase product by undefined license'); exit; } } // Init variables $json = array('status' => false); // Create a new order in DB if (!($order_id = $this->model_common_order->createOrder($this->auth->getId(), $product_info->product_id, $this->request->post['license'], $amount, FEE_PER_ORDER, ORDER_PENDING_STATUS_ID, DEFAULT_CURRENCY_ID))) { $this->security_log->write('Can not create the order'); exit; } // Create a new BitCoin Address try { $bitcoin = new BitCoin(BITCOIN_RPC_USERNAME, BITCOIN_RPC_PASSWORD, BITCOIN_RPC_HOST, BITCOIN_RPC_PORT); // Set response if (false !== $bitcoin->status && ($address = $bitcoin->getaccountaddress(BITCOIN_ORDER_PREFIX . $order_id))) { $json = array('status' => true, 'address' => $address, 'text' => sprintf(tt('Send exactly %s to this address:'), $this->currency->format($amount)), 'href' => 'bitcoin:' . $address . '?amount=' . $amount . '&label=' . PROJECT_NAME . ' Order #' . $order_id, 'src' => $this->url->link('common/image/qr', 'code=' . $address)); } } catch (Exception $e) { $this->security_log->write($bitcoin->error . '/' . $e->getMessage()); } $this->response->addHeader('Content-Type: application/json'); $this->response->setOutput(json_encode($json)); }
$mail = new Mail(); $mail->setFrom(MAIL_EMAIL_SUPPORT_ADDRESS); $mail->setReplyTo(MAIL_EMAIL_SUPPORT_ADDRESS); $mail->setSender(MAIL_EMAIL_SENDER_NAME); // Init Database try { $db = new PDO('mysql:dbname=' . DB_DATABASE . ';host=' . DB_HOSTNAME . ';charset=utf8', DB_USERNAME, DB_PASSWORD, array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8')); $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $db->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_OBJ); } catch (PDOException $e) { $error[] = $e->getMessage(); exit; } // Init BitCoin try { $bitcoin = new BitCoin(BITCOIN_RPC_USERNAME, BITCOIN_RPC_PASSWORD, BITCOIN_RPC_HOST, BITCOIN_RPC_PORT); } catch (Exception $e) { $error[] = $bitcoin->error . '/' . $e->getMessage(); exit; } // Get pending orders $statement = $db->prepare('SELECT `o`.`order_id`, `o`.`amount`, `o`.`user_id` AS `buyer_user_id`, `p`.`user_id` AS `seller_user_id`, `p`.`product_id`, `p`.`currency_id`, `p`.`withdraw_address`, `us`.`email` AS `seller_email`, `ub`.`email` AS `buyer_email`, `ub`.`username` AS `buyer_username`,
<?php /** * LICENSE * * This source file is subject to the GNU General Public License, Version 3 * It is also available through the world-wide-web at this URL: * http://www.gnu.org/copyleft/gpl.html * * @package BitsyBay Engine * @copyright Copyright (c) 2015 The BitsyBay Project (http://bitsybay.com) * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License, Version 3 */ // Load dependencies require '../../config.php'; require '../../system/library/bitcoin.php'; // Init BitCoin $bitcoin = new BitCoin(BITCOIN_RPC_USERNAME, BITCOIN_RPC_PASSWORD, BITCOIN_RPC_HOST, BITCOIN_RPC_PORT); // Check daemon status, sometimes it going down if (false === $bitcoin->getinfo()) { echo system(BITCOIN_DAEMON_PATH); } echo sprintf("status: %s\n", $bitcoin->status);
} // Init variables $approved_order_data = array(); $text = ''; // Init Database try { $db = new PDO('mysql:dbname=' . DB_DATABASE . ';host=' . DB_HOSTNAME . ';charset=utf8', DB_USERNAME, DB_PASSWORD, array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8')); $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $db->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_OBJ); } catch (PDOException $e) { trigger_error($e->getMessage()); exit; } // Init BitCoin try { $bitcoin = new BitCoin(BITCOIN_RPC_USERNAME, BITCOIN_RPC_PASSWORD, BITCOIN_RPC_HOST, BITCOIN_RPC_PORT); } catch (Exception $e) { trigger_error($bitcoin->error . '/' . $e->getMessage()); exit; } // Get pending orders $statement = $db->prepare('SELECT `order_id`, `user_id`, `amount` FROM `order` WHERE `order_status_id` <> ?'); $statement->execute(array(ORDER_APPROVED_STATUS_ID)); if ($statement->rowCount()) { foreach ($statement->fetchAll() as $order) { // Order has ben purchased if ($bitcoin->getreceivedbyaccount($order->order_id) > 0) { // If order amount is correct & already has minimum confirmations if ((double) $order->amount == (double) $bitcoin->getreceivedbyaccount($order->order_id)) { // Set order as PROCESSED $statement = $db->prepare('UPDATE `order` SET `order_status_id` = ? WHERE `order_status_id` <> ? AND `order_id` = ? LIMIT 1');