Example #1
0
define("IN_WALLET", true);
include 'common.php';
$con = mysqli_connect("{$db_host}", "{$db_user}", "{$db_pass}", "{$db_name}");
$key = $_GET['key'];
if (mysqli_connect_errno()) {
    echo "Failed to connect to MySQL. Make sure to edit the common.php file: " . mysqli_connect_error();
}
$result = mysqli_query($con, "SELECT * FROM users where secret = '{$key}' and authused=1");
while ($row = mysqli_fetch_array($result)) {
    $id = $row['id'];
    $username = $row['username'];
    $pin = $row['supportpin'];
    $twofactoren = $row['authused'];
    $isadmin = $row['admin'];
    $client = new Client($rpc_host, $rpc_port, $rpc_user, $rpc_pass);
    $apibal = $client->getBalance($username);
    $addr = $client->getAddress($username);
}
if ($isadmin == 1) {
    $ifadmin = "true";
} else {
    $ifadmin = "false";
}
if ($twofactoren == 1) {
    $iftwofactor = "true";
} else {
    $iftwofactor = "false";
}
echo json_encode(array("id" => "{$id}", "username" => "{$username}", "balance" => "{$apibal}", "addresses" => "{$addr}", "Support Pin" => "{$pin}", "Two Factor Enabled" => "{$iftwofactor}", "admin" => "{$ifadmin}"));
?>
Example #2
0
 if (empty($_SESSION['token'])) {
     $_SESSION['token'] = sha1('@s%a$l£t#' . rand(0, 10000));
 }
 $user_session = $_SESSION['user_session'];
 $admin = false;
 if (!empty($_SESSION['user_admin']) && $_SESSION['user_admin'] == 1) {
     $admin = true;
 }
 $error = array('type' => "none", 'message' => "");
 $client = new Client($rpc_host, $rpc_port, $rpc_user, $rpc_pass);
 $admin_action = false;
 if ($admin && !empty($_GET['a'])) {
     $admin_action = $_GET['a'];
 }
 if (!$admin_action) {
     $balance = $client->getBalance($user_session);
     if (!empty($_POST['jsaction'])) {
         $json = array();
         switch ($_POST['jsaction']) {
             case "new_address":
                 $client->getnewaddress($user_session);
                 $json['success'] = true;
                 $json['message'] = "Um novo endereço foi gerado!";
                 $json['balance'] = $client->getBalance($user_session);
                 $json['addressList'] = $client->getAddressList($user_session);
                 $json['transactionList'] = $client->getTransactionList($user_session);
                 echo json_encode($json);
                 exit;
                 break;
             case "withdraw":
                 $json['success'] = false;
require_once 'config.php';
// print_r($_REQUEST);
$id = $_REQUEST["id"];
?>
<a href="explorer.php">Return to explorer</a>
<form action="search.php" method="post">
	<input name="id" type="text" placeholder="enter block, txid or address" style="width:450px;"/>
	<input type="submit" value="Submit">	
</form>
<?php 
$data = array();
$cnt = 0;
if (strlen($id) == 34) {
    $addressData = Client::getAddress($id);
    $balance = Client::getBalance($id);
    $in = 0;
    $out = 0;
    $total = 0;
    $tx_cnt = 0;
    foreach ($addressData as $data) {
        if ($data["amount"] < 0) {
            $out += $data["amount"];
        }
        if ($data["amount"] > 0) {
            $in += $data["amount"];
        }
        $total += $data["amount"];
        $tx_cnt++;
    }
    echo "<p><span style='font-size:16px;font-weight:bold;'>Address</span><span style='font-size:14px;'> {$total}</span></p>";