integration to flo blockchain
This commit is contained in:
parent
7b93c44e40
commit
6d7771367b
@ -11,7 +11,7 @@ if (!checkLoginStatus()) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$last_trade_date = $_SESSION['last_trade_date'];
|
$last_trade_date = isset($_SESSION['last_trade_date'])?$_SESSION['last_trade_date']:'';
|
||||||
|
|
||||||
$lod = $OrderClass->get_last_order_date($last_trade_date);
|
$lod = $OrderClass->get_last_order_date($last_trade_date);
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
require_once '../includes/imp_files.php';
|
require_once '../includes/imp_files.php';
|
||||||
|
|
||||||
if (!checkLoginStatus()) {
|
if (!checkLoginStatus() || !isset($OrderClass, $UserClass)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -10,17 +10,15 @@ if (isset($_POST['job']) && trim($_POST['job']) == "update-user-bc-balance") {
|
|||||||
|
|
||||||
if (isset($_POST['bc_bal_updt'], $_POST['cus_id'], $_POST['_bc2'])) {
|
if (isset($_POST['bc_bal_updt'], $_POST['cus_id'], $_POST['_bc2'])) {
|
||||||
$cus_id = (int)$_POST['cus_id'];
|
$cus_id = (int)$_POST['cus_id'];
|
||||||
$bc2 = trim($_POST['_bc2']);
|
$bc2 = $_POST['_bc2'];
|
||||||
$balance = number_format((float)$_POST['bc_bal_updt'], 10);
|
$balance = number_format((float)$_POST['bc_bal_updt'], 10);
|
||||||
|
|
||||||
$std = new stdClass();
|
$std = new stdClass();
|
||||||
$std->mesg = array();
|
$std->mesg = array();
|
||||||
$std->error = true;
|
$std->error = true;
|
||||||
|
|
||||||
$is_sel2_valid= $OrderClass->is_bc_valid($bc2, null, 1);
|
if ($bc2==""||$bc2==null || !is_array($bc2) || empty($bc2)) {
|
||||||
|
$mess = "Please choose a Blockchain contract from the dropdown menu.";
|
||||||
if ($bc2==""||$bc2==null || !$is_sel2_valid) {
|
|
||||||
$mess = "Please choose a Blockchain contract from second dropdown.";
|
|
||||||
$std->error = true;
|
$std->error = true;
|
||||||
$std->mesg[] = $mess;
|
$std->mesg[] = $mess;
|
||||||
echo json_encode($std);
|
echo json_encode($std);
|
||||||
@ -44,14 +42,6 @@ if (isset($_POST['job']) && trim($_POST['job']) == "update-user-bc-balance") {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isset($OrderClass, $UserClass)) {
|
|
||||||
$mess = "System Error!";
|
|
||||||
$std->error = true;
|
|
||||||
$std->mesg[] = $mess;
|
|
||||||
echo json_encode($std);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
$update_bal = null;
|
$update_bal = null;
|
||||||
|
|
||||||
/*Restrict decimal places while updating balance*/
|
/*Restrict decimal places while updating balance*/
|
||||||
@ -63,31 +53,44 @@ if (isset($_POST['job']) && trim($_POST['job']) == "update-user-bc-balance") {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Prev balance of user
|
foreach ($bc2 as $b2) {
|
||||||
$bal_prev = (float) $OrderClass->check_customer_balance($bc2, $cus_id)->balance;
|
$is_sel2_valid= $OrderClass->is_bc_valid($b2, null, 1);
|
||||||
|
if (!$is_sel2_valid) {
|
||||||
|
$mess = "Unknown Blockchain contract.";
|
||||||
|
$std->error = true;
|
||||||
|
$std->mesg[] = $mess;
|
||||||
|
echo json_encode($std);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
$update_bal = $OrderClass->update_user_balance($bc2, $balance, $cus_id);
|
//Prev balance of user
|
||||||
|
$bal_prev = (float) $OrderClass->check_customer_balance($b2, $cus_id)->balance;
|
||||||
|
|
||||||
if (!$update_bal) {
|
$update_bal = $OrderClass->update_user_balance($b2, $balance, $cus_id);
|
||||||
$mess = "Failed to update balance.";
|
|
||||||
$std->error = true;
|
if (!$update_bal) {
|
||||||
$std->mesg[] = $mess;
|
$mess = "Failed to update $b2 balance.";
|
||||||
echo json_encode($std);
|
$std->error = true;
|
||||||
return false;
|
$std->mesg[] = $mess;
|
||||||
} else if($update_bal) {
|
echo json_encode($std);
|
||||||
// Record this change
|
//return false;
|
||||||
$OrderClass->record_root_bal_update($cus_id, $bal_prev, $balance, $bc2);
|
} else if($update_bal) {
|
||||||
$mess = "Successfully updated balance!";
|
// Record this change
|
||||||
$std->error = false;
|
$OrderClass->record_root_bal_update($cus_id, $bal_prev, $balance, $b2);
|
||||||
$std->mesg[] = $mess;
|
$mess = "Successfully updated balance!";
|
||||||
echo json_encode($std);
|
$std->error = false;
|
||||||
return false;
|
$std->mesg[] = $mess;
|
||||||
} else {
|
echo json_encode($std);
|
||||||
$mess = "Something went wrong. Failed to update balance!";
|
//return false;
|
||||||
$std->error = true;
|
} else {
|
||||||
$std->mesg[] = $mess;
|
$mess = "Something went wrong. Failed to update $b2 balance!";
|
||||||
echo json_encode($std);
|
$std->error = true;
|
||||||
return false;
|
$std->mesg[] = $mess;
|
||||||
|
echo json_encode($std);
|
||||||
|
//return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
4
api/.htaccess
Normal file
4
api/.htaccess
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
RewriteEngine on
|
||||||
|
RewriteCond %{REQUEST_FILENAME} !-d
|
||||||
|
RewriteCond %{REQUEST_FILENAME} !-f
|
||||||
|
RewriteRule . api.php [L]
|
||||||
70
api/api.php
Normal file
70
api/api.php
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
<?php
|
||||||
|
use \Psr\Http\Message\ServerRequestInterface as Request;
|
||||||
|
use \Psr\Http\Message\ResponseInterface as Response;
|
||||||
|
use Carbon\Carbon;
|
||||||
|
use Carbon\CarbonInterval;
|
||||||
|
|
||||||
|
require '../includes/imp_files.php';
|
||||||
|
require '../vendor/autoload.php';
|
||||||
|
|
||||||
|
$app = new \Slim\App;
|
||||||
|
|
||||||
|
if (isset($OrderClass, $UserClass)) {
|
||||||
|
|
||||||
|
// Get User data by email
|
||||||
|
$app->get('/user_by_email/{em}', function (Request $request, Response $response) {
|
||||||
|
try {
|
||||||
|
$UserClass = new Users();
|
||||||
|
$email = (string) trim($request->getAttribute('em'));
|
||||||
|
$is_email = is_email($email);
|
||||||
|
if ($is_email) {
|
||||||
|
$stmt = $UserClass->get_user_by_email($email);
|
||||||
|
$user_details = $stmt;
|
||||||
|
|
||||||
|
echo json_encode($user_details);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
echo '{"error": {"text": "Invalid email"}}';
|
||||||
|
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
echo '{"error": {"text": ' . $e->getMessage() . '}}';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
// Update RMT balance in BCX
|
||||||
|
$app->put('/up_val/rmt/{uid}', function (Request $request, Response $response) {
|
||||||
|
try {
|
||||||
|
$OrderClass = new Orders();
|
||||||
|
$data = $request->getParsedBody(); // Array([new_bal] => 115)
|
||||||
|
//$data = $request->getParam('new_bal'); // 115
|
||||||
|
$uid = $request->getAttribute('uid');
|
||||||
|
|
||||||
|
$add_bal = (float) $data['new_bal'];
|
||||||
|
|
||||||
|
$prev_bal = (float) $OrderClass->check_customer_balance($assetType = RMT, $uid)->balance;
|
||||||
|
|
||||||
|
$new_bal = $prev_bal + $add_bal;
|
||||||
|
|
||||||
|
if ($new_bal < 0) {
|
||||||
|
echo '{"process": {"text": "Invalid amount"}}';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($data['pass']) && trim($data['pass'])=="secret") {
|
||||||
|
$update_successful = $OrderClass->update_user_balance(RMT, $new_bal, $uid);
|
||||||
|
|
||||||
|
if ($update_successful) {
|
||||||
|
echo '{"process": {"text": "success"}}';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
echo '{"process": {"text": "failed"}}';
|
||||||
|
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
echo '{"process": {"text": ' . $e->getMessage() . '}}';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
$app->run();
|
||||||
|
}
|
||||||
60
api/viv.php
Normal file
60
api/viv.php
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Created by PhpStorm.
|
||||||
|
* User: Abhishek Kumar Sinha
|
||||||
|
* Date: 7/17/2018
|
||||||
|
* Time: 6:48 AM
|
||||||
|
*/
|
||||||
|
error_reporting(E_ALL);
|
||||||
|
//require '../includes/imp_files.php';
|
||||||
|
require_once '../includes/defines.php';
|
||||||
|
require_once '../includes/config.php';
|
||||||
|
include_once '../includes/autoload.php';
|
||||||
|
include_once '../includes/functions.php';
|
||||||
|
|
||||||
|
//take in root address
|
||||||
|
$root_address = "oLu7TJH6EkR79LE8smqQjG1yXgg4hvdtE6";
|
||||||
|
$root_init_value = 21000;
|
||||||
|
|
||||||
|
if(!class_exists('Viv')) {
|
||||||
|
echo "Class Viv not exists";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*$VivClass = new Viv();
|
||||||
|
$VivClass->truncate_tbl(VIV_TX_TBL);
|
||||||
|
$VivClass->truncate_tbl(VIV_LOGS);
|
||||||
|
$VivClass->truncate_tbl(VIV_WEB);
|
||||||
|
$VivClass->truncate_tbl(VIV_EXTRA);
|
||||||
|
|
||||||
|
$root_inserted = $VivClass->insertTx($root_address, 0, $root_init_value);
|
||||||
|
if (!$root_inserted) {
|
||||||
|
echo "Failed to initialize root address.";
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
$transferDescription = "Root address = (string) $root_address has been initialized with (string) $root_init_value tokens";
|
||||||
|
$blockchainReference = 'https://testnet.florincoin.info/tx/';
|
||||||
|
|
||||||
|
$log_inserted = $VivClass->insertLogs(1, $transferDescription, 0, $blockchainReference);
|
||||||
|
if (!$log_inserted) {
|
||||||
|
echo "Failed to log transfer description.";
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
//find root address's block
|
||||||
|
$string = "https://testnet.florincoin.info/ext/getaddress/$root_address";
|
||||||
|
$root_trans_hash = get_tx_hash($root_address);
|
||||||
|
$root_block_hash = get_block_hash($root_trans_hash);
|
||||||
|
$root_block_index = get_block_index($root_block_hash);
|
||||||
|
echo "Root block index: ".$root_block_index."<br>";
|
||||||
|
|
||||||
|
//get current block count
|
||||||
|
$current_block_index = get_current_block_count()["height"];
|
||||||
|
echo "Current Block index: ". $current_block_index."<br>";*/
|
||||||
|
|
||||||
|
$rr = dothemagic(26679);
|
||||||
|
print_r($rr);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -1368,7 +1368,7 @@ class Orders extends Users {
|
|||||||
$extraQuerry1 = "AND ".CREDITS_TABLE.".bc = :bc1";
|
$extraQuerry1 = "AND ".CREDITS_TABLE.".bc = :bc1";
|
||||||
$extraQuerry2 = "ORDER BY ".CREDITS_TABLE.".balance DESC";
|
$extraQuerry2 = "ORDER BY ".CREDITS_TABLE.".balance DESC";
|
||||||
} else {
|
} else {
|
||||||
$extraQuerry2 = "ORDER BY ".USERS_TABLE.".name ASC";
|
$extraQuerry2 = "ORDER BY ".USERS_TABLE.".id ASC";
|
||||||
}
|
}
|
||||||
|
|
||||||
$query = $this->db_connection->prepare("
|
$query = $this->db_connection->prepare("
|
||||||
|
|||||||
@ -297,6 +297,27 @@ class Users {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function get_user_by_email($em) {
|
||||||
|
|
||||||
|
if ($this->databaseConnection()) {
|
||||||
|
|
||||||
|
$query = $this->db_connection->prepare("SELECT * FROM ".USERS_TABLE." WHERE email = :email AND is_active = 1 LIMIT 1");
|
||||||
|
$query->bindParam('email', $em);
|
||||||
|
|
||||||
|
if ($query->execute()) {
|
||||||
|
$row_count = $query->rowCount();
|
||||||
|
if ($row_count == 1) {
|
||||||
|
return $user_details = $query->fetchObject();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
50
classes/Viv.php
Normal file
50
classes/Viv.php
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Created by PhpStorm.
|
||||||
|
* User: Abhishek Kumar Sinha
|
||||||
|
* Date: 7/17/2018
|
||||||
|
* Time: 3:34 PM
|
||||||
|
*/
|
||||||
|
|
||||||
|
class Viv extends Users{
|
||||||
|
|
||||||
|
public function insertTx($address=null, $parentId=null, $transferBalance=null) {
|
||||||
|
if ($this->databaseConnection()) {
|
||||||
|
$query = $this->db_connection->prepare("INSERT INTO ".VIV_TX_TBL."(`id`, `address`, `parentid`, `transferBalance`)
|
||||||
|
VALUES ('', :addr, :pid, :tb)");
|
||||||
|
$query->bindParam("addr", $address);
|
||||||
|
$query->bindParam("pid", $parentId);
|
||||||
|
$query->bindParam("tb", $transferBalance);
|
||||||
|
$query->execute();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function insertLogs($primaryIDReference=null, $transferDescription=null, $transferIDConsumed=null, $blockchainReference=null) {
|
||||||
|
if ($this->databaseConnection()) {
|
||||||
|
$query = $this->db_connection->prepare("
|
||||||
|
INSERT INTO ".VIV_LOGS." (primaryIDReference, transferDescription, transferIDConsumed, blockchainReference)
|
||||||
|
VALUES (:pr, :td, :tc, :br)
|
||||||
|
");
|
||||||
|
$query->bindParam("pr", $primaryIDReference);
|
||||||
|
$query->bindParam("td",$transferDescription );
|
||||||
|
$query->bindParam("tc", $transferIDConsumed);
|
||||||
|
$query->bindParam("br", $blockchainReference);
|
||||||
|
|
||||||
|
$query->execute();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function truncate_tbl($tbl='') {
|
||||||
|
if ($this->databaseConnection()) {
|
||||||
|
$query = $this->db_connection->query("TRUNCATE TABLE ".$tbl);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -51,4 +51,5 @@
|
|||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
<?php if ($user_logged_in) {include_once VIEWS_DIR.'/req_user_info.php';} ?>
|
||||||
@ -125,4 +125,195 @@ function rmt_price_today() {
|
|||||||
|
|
||||||
function bc_to_usd($bc_rmt_price, $current_rmt_price_in_usd) {
|
function bc_to_usd($bc_rmt_price, $current_rmt_price_in_usd) {
|
||||||
return round(($bc_rmt_price * $current_rmt_price_in_usd), 2);
|
return round(($bc_rmt_price * $current_rmt_price_in_usd), 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
function user_rmt_bal($uid=0) {
|
||||||
|
$bit_price = null;
|
||||||
|
if (!is_int($uid)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
$url = "https://www.ranchimall.net/exchange/api/token_ratio/$uid/rmt";
|
||||||
|
|
||||||
|
$json = file_get_contents($url);
|
||||||
|
$data = json_decode($json, TRUE);
|
||||||
|
|
||||||
|
$user_rmt_bal= $data["user"];
|
||||||
|
} catch(Exception $e) {
|
||||||
|
$user_rmt_bal = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (float) $user_rmt_bal;
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_tx_hash($addr=null) {
|
||||||
|
$root_trans_hash = null;
|
||||||
|
try {
|
||||||
|
$string = "https://testnet.florincoin.info/ext/getaddress/$addr";
|
||||||
|
$json = file_get_contents($string);
|
||||||
|
$data = json_decode($json, TRUE);
|
||||||
|
foreach ($data["last_txs"] as $cur) {
|
||||||
|
if ($cur["type"] == "vout") {
|
||||||
|
$root_trans_hash = $cur["addresses"];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception $e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return $root_trans_hash;
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_block_hash($root_trans_hash) {
|
||||||
|
$root_block_hash = null;
|
||||||
|
try {
|
||||||
|
$string = "https://testnet.florincoin.info/api/getrawtransaction?txid=".$root_trans_hash."&decrypt=1";
|
||||||
|
$json = file_get_contents($string);
|
||||||
|
$data = json_decode($json, TRUE);
|
||||||
|
$root_block_hash = $data["blockhash"];
|
||||||
|
} catch (Exception $e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return $root_block_hash;
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_block_index($root_block_hash) {
|
||||||
|
$root_block_index = null;
|
||||||
|
try {
|
||||||
|
$string = "https://testnet.florincoin.info/api/getblock?hash=".$root_block_hash;
|
||||||
|
$json = file_get_contents($string);
|
||||||
|
$root_block_index = json_decode($json, TRUE);
|
||||||
|
//$root_block_index = $data["height"];
|
||||||
|
} catch (Exception $e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return $root_block_index;
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_current_block_count() {
|
||||||
|
$current_block_index = null;
|
||||||
|
try {
|
||||||
|
$string = "https://testnet.florincoin.info/api/getblockcount";
|
||||||
|
$json = file_get_contents($string);
|
||||||
|
$data = json_decode($json, TRUE);
|
||||||
|
$current_block_index = $data;
|
||||||
|
} catch (Exception $e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return $current_block_index;
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_current_blockhash($block_index=null) {
|
||||||
|
$blockhash = null;
|
||||||
|
try {
|
||||||
|
$string = "https://testnet.florincoin.info/api/getblockhash?index=".$block_index;
|
||||||
|
$blockhash = file_get_contents($string);
|
||||||
|
} catch (Exception $e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return $blockhash;
|
||||||
|
}
|
||||||
|
|
||||||
|
function listcheck($element=null) {
|
||||||
|
try {
|
||||||
|
$element = (float) $element;
|
||||||
|
if (!is_float($element)) {
|
||||||
|
throw new Exception("Invalid float value");
|
||||||
|
}
|
||||||
|
} catch(Exception $e) {
|
||||||
|
echo 'Message: ' .$e->getMessage();
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
function dothemagic($blockindex=null) {
|
||||||
|
if ($blockindex==null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$blockindex = (int) $blockindex;
|
||||||
|
$blockhash = get_current_blockhash($blockindex);
|
||||||
|
$blockinfo = get_block_index($blockhash);
|
||||||
|
|
||||||
|
foreach ($blockinfo["tx"] as $transaction) {
|
||||||
|
$string = "https://testnet.florincoin.info/api/getrawtransaction?txid=".$transaction."&decrypt=1";
|
||||||
|
$json = file_get_contents($string);
|
||||||
|
$data = json_decode($json, TRUE);
|
||||||
|
$text = substr($data["floData"], 5);
|
||||||
|
$comment_list = explode("#", $text);
|
||||||
|
|
||||||
|
if ($comment_list[0]=='ranchimalltest') {
|
||||||
|
echo "<p>I just saw ranchimalltest</p>";
|
||||||
|
$commentTransferAmount = $comment_list[1];
|
||||||
|
|
||||||
|
if (strlen($commentTransferAmount)==0) {
|
||||||
|
echo "Value for token transfer has not been specified";
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$returnval = listcheck($commentTransferAmount);
|
||||||
|
if ($returnval == 1) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$commentTransferAmount_arr = [];
|
||||||
|
array_push($commentTransferAmount_arr, $commentTransferAmount);
|
||||||
|
$commentTransferAmount =$commentTransferAmount_arr;
|
||||||
|
|
||||||
|
$inputlist = [];
|
||||||
|
$querylist = [];
|
||||||
|
|
||||||
|
foreach ($data["vin"] as $obj) {
|
||||||
|
array_push($querylist, [$obj["txid"], $obj["vout"]]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$inputval = 0;
|
||||||
|
$inputadd = '';
|
||||||
|
|
||||||
|
foreach ($querylist as $query) {
|
||||||
|
$string = "https://testnet.florincoin.info/api/getrawtransaction?txid=".$query[0]."&decrypt=1";
|
||||||
|
$json = file_get_contents($string);
|
||||||
|
$content = json_decode($json, TRUE);
|
||||||
|
|
||||||
|
foreach ($content["vout"] as $objec) {
|
||||||
|
if ($objec["n"] == $query[1]) {
|
||||||
|
$inputadd = $objec["scriptPubKey"]["addresses"][0];
|
||||||
|
$inputval = $inputval + $objec["value"];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
array_push($inputlist, [$inputadd, $inputval]);
|
||||||
|
|
||||||
|
if (count($inputlist) > 1) {
|
||||||
|
print("Program has detected more than one input address ");
|
||||||
|
print("This transaction will be discarded");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$outputlist = [];
|
||||||
|
foreach ($data["vout"] as $obj) {
|
||||||
|
if ($obj["scriptPubKey"]["type"] == "pubkeyhash") {
|
||||||
|
if ($inputlist[0][0] == $obj["scriptPubKey"]["addresses"][0]) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$temp = [];
|
||||||
|
array_push($temp, $obj["scriptPubKey"]["addresses"][0]);
|
||||||
|
array_push($temp, $obj["value"]);
|
||||||
|
array_push($outputlist, $temp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
print("Input List");
|
||||||
|
echo "<br>";
|
||||||
|
print_r($inputlist);
|
||||||
|
echo "<br>";
|
||||||
|
print("Output List");
|
||||||
|
print_r($outputlist);
|
||||||
|
echo "<br>";
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -18,7 +18,7 @@ if (isset($UserClass)) {
|
|||||||
$validate_user = $UserClass->is_fb_registered($fb_id);
|
$validate_user = $UserClass->is_fb_registered($fb_id);
|
||||||
|
|
||||||
if($validate_user == "" || $validate_user == false) {
|
if($validate_user == "" || $validate_user == false) {
|
||||||
redirect_to('index.php');
|
redirect_to('index.php?msg=Unknown User');
|
||||||
}
|
}
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
@ -50,7 +50,7 @@ if(checkLoginStatus()) {
|
|||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<nav class="navbar navbar-expand-md fixed-top navbar-dark bg-dark">
|
<nav class="navbar navbar-dark bg-dark">
|
||||||
<a class="navbar-brand" href="#">Ranchi Mall Blockchain Contract</a>
|
<a class="navbar-brand" href="#">Ranchi Mall Blockchain Contract</a>
|
||||||
|
|
||||||
<div class="sel-div float-right">
|
<div class="sel-div float-right">
|
||||||
@ -73,32 +73,38 @@ if(checkLoginStatus()) {
|
|||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<button class="navbar-toggler p-0 border-0" type="button" data-toggle="offcanvas">
|
|
||||||
<span class="navbar-toggler-icon"></span>
|
|
||||||
</button>
|
|
||||||
</nav>
|
</nav>
|
||||||
|
|
||||||
<div class="nav-scroller bg-white box-shadow">
|
<nav class="navbar navbar-expand-md navbar-light bg-white box-shadow">
|
||||||
<nav class="nav nav-underline">
|
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarsExample04" aria-controls="navbarsExample04" aria-expanded="false" aria-label="Toggle navigation">
|
||||||
<?php if($user_logged_in) { ?>
|
<span class="navbar-toggler-icon"></span>
|
||||||
<a class="nav-link active" href="#"><?php echo "Welcome ". (isset($_SESSION['full_name']) ? $_SESSION['full_name']:"")?></a>
|
</button>
|
||||||
<?php } ?>
|
|
||||||
<!--<a class="nav-link" href="#">
|
|
||||||
Investors
|
|
||||||
<span class="badge badge-pill bg-light align-text-bottom">127</span>
|
|
||||||
</a>-->
|
|
||||||
<a class="nav-link" href="https://www.ranchimall.net/exchange">Buy RMT</a>
|
|
||||||
|
|
||||||
<?php if($user_logged_in) { ?>
|
<div class="collapse navbar-collapse" id="navbarsExample04">
|
||||||
<a class="nav-link" href="logout.php">Log Out</a>
|
<ul class="navbar-nav mr-auto">
|
||||||
<?php } elseif(isset($loginUrl)) {?>
|
<?php if($user_logged_in) { ?>
|
||||||
<a href="<?=$loginUrl?>" role="button" class="nav-link" name="fb_login">
|
<li class="nav-item">
|
||||||
<div class="btn--facebook ">
|
<a class="nav-link active" href="#"><?php echo "Welcome ". (isset($_SESSION['full_name']) ? $_SESSION['full_name']:"")?></a>
|
||||||
Login with Facebook
|
</li>
|
||||||
</div>
|
|
||||||
</a>
|
|
||||||
<?php } ?>
|
|
||||||
</nav>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
<?php } ?>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" href="https://www.ranchimall.net/exchange">Buy RMT</a>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<?php if($user_logged_in) { ?>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" href="logout.php">Log Out</a>
|
||||||
|
</li>
|
||||||
|
<?php } elseif(isset($loginUrl)) {?>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a href="<?=$loginUrl?>" role="button" class="nav-link" name="fb_login">
|
||||||
|
<div class="btn--facebook ">
|
||||||
|
Login with Facebook
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
<?php } ?>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
|||||||
23
rm_root.php
23
rm_root.php
@ -26,7 +26,7 @@
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
<!--Transfer tokens-->
|
<!--Transfer tokens-->
|
||||||
<div class="col-xs-12 col-md-12 col-lg-12 mb-50">
|
<div class="col-xs-12 col-md-12 col-lg-12 mb-50">
|
||||||
<h2>Transfer tokens</h2>
|
<h2>Transfer tokens (Please select a BC from second select box above)</h2>
|
||||||
<div class="mt--2 mb--2 p--1">
|
<div class="mt--2 mb--2 p--1">
|
||||||
<div class="form-inline">
|
<div class="form-inline">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
@ -134,6 +134,14 @@
|
|||||||
<label class="sr-only" for="bal">Input Balance</label>
|
<label class="sr-only" for="bal">Input Balance</label>
|
||||||
<input type="text" class="form-control" name="bal" id="bc-bal-updt" placeholder="Input Balance">
|
<input type="text" class="form-control" name="bal" id="bc-bal-updt" placeholder="Input Balance">
|
||||||
</div>
|
</div>
|
||||||
|
<select class="custom-select" id="bc_menue_sel" multiple>
|
||||||
|
<option value="" selected>Open this multiple select menu</option>
|
||||||
|
<option value="RMT">RMT</option>
|
||||||
|
<?php if(is_array($BClist) && !empty($BClist)):
|
||||||
|
foreach ($BClist as $bcl): ?>
|
||||||
|
<option value="<?=$bcl->bc_code; ?>"><?=$bcl->contracts?></option>
|
||||||
|
<?php endforeach; endif; ?>
|
||||||
|
</select>
|
||||||
<input type="submit" class="btn-sm mt--1" id="bc_tr_btn" value="Update balance">
|
<input type="submit" class="btn-sm mt--1" id="bc_tr_btn" value="Update balance">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -145,8 +153,8 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<th>Id</th>
|
<th>Id</th>
|
||||||
<th>User</th>
|
<th>User</th>
|
||||||
<th>RMT</th>
|
<th>BC</th>
|
||||||
<th>Cash</th>
|
<th>Balance</th>
|
||||||
<th>Action</th>
|
<th>Action</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
@ -281,20 +289,20 @@
|
|||||||
$(document).on('click', '#bc_tr_btn', function() {
|
$(document).on('click', '#bc_tr_btn', function() {
|
||||||
var bc_bal_updt = $('#bc-bal-updt').val();
|
var bc_bal_updt = $('#bc-bal-updt').val();
|
||||||
var cus_id = $('#cus_id').val();
|
var cus_id = $('#cus_id').val();
|
||||||
var sel_bc2 = $('#sel-bc-2').val();
|
var sel_bc2 = $('#bc_menue_sel').val();
|
||||||
var job = 'update-user-bc-balance';
|
var job = 'update-user-bc-balance';
|
||||||
var btn = this;
|
var btn = this;
|
||||||
|
|
||||||
if (sel_bc2=="") {
|
if (sel_bc2=="") {
|
||||||
$.notify({
|
$.notify({
|
||||||
title: "<strong>Alert!: </strong> ",
|
title: "<strong>Alert!: </strong> ",
|
||||||
message: "Please choose a contract from second dropdown at top."
|
message: "Please choose a contract from the dropdown menu."
|
||||||
},{
|
},{
|
||||||
type: 'warning'
|
type: 'warning'
|
||||||
});
|
});
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$(btn).val('Please wait....').prop( "disabled", true );
|
$(btn).prop( "disabled", true );
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
method: 'post',
|
method: 'post',
|
||||||
@ -304,7 +312,8 @@
|
|||||||
console.log(xhr, status, error);
|
console.log(xhr, status, error);
|
||||||
},
|
},
|
||||||
success: function(data) {
|
success: function(data) {
|
||||||
$(btn).val('Transfer '+sel_bc2).prop( "disabled", false );
|
console.log(data);
|
||||||
|
$(btn).prop( "disabled", false );
|
||||||
if ($.trim(data) != '' && $.trim(data) != undefined && $.trim(data) != null) {
|
if ($.trim(data) != '' && $.trim(data) != undefined && $.trim(data) != null) {
|
||||||
var IS_JSON = true;
|
var IS_JSON = true;
|
||||||
try {
|
try {
|
||||||
|
|||||||
@ -25,7 +25,7 @@ input[type=text] {
|
|||||||
}
|
}
|
||||||
.sel-div {
|
.sel-div {
|
||||||
display: flex;
|
display: flex;
|
||||||
width: 100%;
|
//width: 100%;
|
||||||
}
|
}
|
||||||
.selbc {
|
.selbc {
|
||||||
margin-right: 5px;
|
margin-right: 5px;
|
||||||
@ -61,44 +61,23 @@ h5 > span {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.nav-scroller {
|
a.nav-link {
|
||||||
position: relative;
|
font-weight: 500;
|
||||||
z-index: 2;
|
color: var(--secondary);
|
||||||
height: 2.75rem;
|
|
||||||
overflow-y: hidden;
|
|
||||||
}
|
|
||||||
|
|
||||||
.nav-scroller .nav {
|
|
||||||
display: -webkit-box;
|
|
||||||
display: -ms-flexbox;
|
|
||||||
display: flex;
|
|
||||||
-ms-flex-wrap: nowrap;
|
|
||||||
flex-wrap: nowrap;
|
|
||||||
padding-bottom: 1rem;
|
|
||||||
margin-top: -1px;
|
|
||||||
overflow-x: auto;
|
|
||||||
color: rgba(255, 255, 255, .75);
|
|
||||||
text-align: center;
|
|
||||||
white-space: nowrap;
|
|
||||||
-webkit-overflow-scrolling: touch;
|
|
||||||
}
|
|
||||||
|
|
||||||
.nav-underline .nav-link {
|
|
||||||
padding-top: .75rem;
|
padding-top: .75rem;
|
||||||
padding-bottom: .75rem;
|
padding-bottom: .75rem;
|
||||||
font-size: .875rem;
|
font-size: .875rem;
|
||||||
color: var(--secondary);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.nav-underline .nav-link:hover {
|
a.active {
|
||||||
color: var(--blue);
|
|
||||||
}
|
|
||||||
|
|
||||||
.nav-underline .active {
|
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
color: var(--gray-dark);
|
color: var(--gray-dark);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
a.nav-link:hover {
|
||||||
|
color: var(--blue);
|
||||||
|
}
|
||||||
|
|
||||||
.text-white-50 { color: rgba(255, 255, 255, .5); }
|
.text-white-50 { color: rgba(255, 255, 255, .5); }
|
||||||
|
|
||||||
.bg-purple { background-color: var(--purple); }
|
.bg-purple { background-color: var(--purple); }
|
||||||
@ -114,8 +93,8 @@ h5 > span {
|
|||||||
/*Extra small devices (portrait phones, less than 576px)*/
|
/*Extra small devices (portrait phones, less than 576px)*/
|
||||||
@media (max-width: 576px) {
|
@media (max-width: 576px) {
|
||||||
body {
|
body {
|
||||||
//display: block;
|
display: block;
|
||||||
padding-top: 56px;
|
// padding-top: 56px;
|
||||||
//font-size: 24px;
|
//font-size: 24px;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
@ -131,7 +110,7 @@ h5 > span {
|
|||||||
/*Small devices (landscape phones, 576px and up)*/
|
/*Small devices (landscape phones, 576px and up)*/
|
||||||
@media (min-width: 576px) {
|
@media (min-width: 576px) {
|
||||||
body {
|
body {
|
||||||
padding-top: 56px;
|
//padding-top: 56px;
|
||||||
//font-size: 18px; !important;
|
//font-size: 18px; !important;
|
||||||
}
|
}
|
||||||
.lays {
|
.lays {
|
||||||
@ -146,7 +125,7 @@ h5 > span {
|
|||||||
/*Medium devices (tablets, 768px and up)*/
|
/*Medium devices (tablets, 768px and up)*/
|
||||||
@media (min-width: 768px) {
|
@media (min-width: 768px) {
|
||||||
body {
|
body {
|
||||||
padding-top: 56px;
|
//padding-top: 56px;
|
||||||
//font-size: 16px;
|
//font-size: 16px;
|
||||||
}
|
}
|
||||||
.lays {
|
.lays {
|
||||||
|
|||||||
52
views/req_user_info.php
Normal file
52
views/req_user_info.php
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
<?php
|
||||||
|
if (!isset($user_id)) {
|
||||||
|
$user_id = $_SESSION['user_id'];
|
||||||
|
}
|
||||||
|
if (!isset($user_email)) {
|
||||||
|
$user_email = $_SESSION['email'];
|
||||||
|
}
|
||||||
|
if (!isset($log_fullName)) {
|
||||||
|
$log_fullName = $_SESSION['full_name'];
|
||||||
|
}
|
||||||
|
if (($user_email == null) && ($user_logged_in == true)) {
|
||||||
|
|
||||||
|
if (isset($_POST['user_em_id'], $UserClass) && is_email($_POST['user_em_id'])) {
|
||||||
|
$email = trim($_POST['user_em_id']);
|
||||||
|
$updateEmail = $UserClass->input_user_email($email, $user_id);
|
||||||
|
if ($updateEmail) {
|
||||||
|
$_SESSION['email'] = $email;
|
||||||
|
redirect_to("index.php?msg=Email updated as $email successfully.&type=success");
|
||||||
|
}
|
||||||
|
redirect_to("index.php?msg=Email could not be updated.&type=warning");
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
<script>
|
||||||
|
$(document).ready(function() {
|
||||||
|
$('#getUserInfo').modal('show');
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<div id="getUserInfo" class="modal fade" tabindex="-1" role="dialog">
|
||||||
|
<div class="modal-dialog" role="document">
|
||||||
|
<div class="modal-content" style="background-color: #dfdfe9">
|
||||||
|
<div class="modal-header">
|
||||||
|
<h5 class="modal-title text-danger">Your Email Id Required!</h5>
|
||||||
|
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||||
|
<span aria-hidden="true">×</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<form action="<?=$_SERVER["PHP_SELF"]?>" method="post">
|
||||||
|
<div class="modal-body">
|
||||||
|
<h5 class="text-dark">Hi <?=$log_fullName?></h5>
|
||||||
|
<p id="req_em_msg" class="text-secondary">We need your email address to verify your account.</p>
|
||||||
|
<input type="text" name="user_em_id" class="form-control" placeholder="Enter Your Email Id here...">
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
|
||||||
|
<input type="submit" class="btn btn-dark" id="req_em_btn" value="Submit">
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<?php }
|
||||||
Loading…
Reference in New Issue
Block a user