commit
2ced75b752
@ -78,6 +78,9 @@ if (! empty($users)) {
|
||||
|
||||
// Create transaction record
|
||||
if ($transaction->addTransaction($aUserData['id'], $dBalance - $config['txfee'], 'Debit_AP', NULL, $aUserData['coin_address']) && $transaction->addTransaction($aUserData['id'], $config['txfee'], 'TXFee', NULL, $aUserData['coin_address'])) {
|
||||
// Mark all older transactions as archived
|
||||
if (!$transaction->setArchived($aUserData['id'], $transaction->insert_id))
|
||||
$log->logError('Failed to mark transactions for user #' . $aUserData['id'] . ' prior to #' . $transaction->insert_id . ' as archived');
|
||||
// Notify user via mail
|
||||
$aMailData['email'] = $user->getUserEmail($user->getUserName($aUserData['id']));
|
||||
$aMailData['subject'] = 'Auto Payout Completed';
|
||||
|
||||
@ -39,7 +39,7 @@ if ($bitcoin->can_connect() !== true) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// var_dump($oPayout->createPayout(1.12, 1));
|
||||
// Fetch outstanding payout requests
|
||||
$aPayouts = $oPayout->getUnprocessedPayouts();
|
||||
|
||||
if (count($aPayouts) > 0) {
|
||||
@ -75,7 +75,11 @@ if (count($aPayouts) > 0) {
|
||||
$monitoring->setStatus($cron_name . "_status", "okerror", 1);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if ($transaction->addTransaction($aData['account_id'], $dBalance - $config['txfee'], 'Debit_MP', NULL, $aData['coin_address']) && $transaction->addTransaction($aData['account_id'], $config['txfee'], 'TXFee', NULL, $aData['coin_address'])) {
|
||||
// Mark all older transactions as archived
|
||||
if (!$transaction->setArchived($aData['account_id'], $transaction->insert_id))
|
||||
$log->logError('Failed to mark transactions for #' . $aData['account_id'] . ' prior to #' . $transaction->insert_id . ' as archived');
|
||||
// Notify user via mail
|
||||
$aMailData['email'] = $user->getUserEmail($user->getUserName($aData['account_id']));
|
||||
$aMailData['subject'] = 'Manual Payout Completed';
|
||||
|
||||
@ -8,6 +8,7 @@ if (!defined('SECURITY'))
|
||||
// some cross-class functions.
|
||||
class Base {
|
||||
private $sError = '';
|
||||
private $values = array(), $types = '';
|
||||
|
||||
public function setDebug($debug) {
|
||||
$this->debug = $debug;
|
||||
@ -30,6 +31,9 @@ class Base {
|
||||
public function setToken($token) {
|
||||
$this->token = $token;
|
||||
}
|
||||
public function setBlock($block) {
|
||||
$this->block= $block;
|
||||
}
|
||||
public function setBitcoin($bitcoin) {
|
||||
$this->bitcoin = $bitcoin;
|
||||
}
|
||||
@ -89,5 +93,24 @@ class Base {
|
||||
$this->debug->append("Unable to update " . $field['name'] . " with " . $field['value'] . " for ID $id");
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* We may need to generate our bind_param list
|
||||
**/
|
||||
public function addParam($type, &$value) {
|
||||
$this->values[] = $value;
|
||||
$this->types .= $type;
|
||||
}
|
||||
public function getParam() {
|
||||
$array = array_merge(array($this->types), $this->values);
|
||||
// See here why we need this: http://stackoverflow.com/questions/16120822/mysqli-bind-param-expected-to-be-a-reference-value-given
|
||||
if (strnatcmp(phpversion(),'5.3') >= 0) {
|
||||
$refs = array();
|
||||
foreach($array as $key => $value)
|
||||
$refs[$key] = &$array[$key];
|
||||
return $refs;
|
||||
}
|
||||
return $array;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
@ -36,12 +36,10 @@ class Payout Extends Base {
|
||||
* @return data mixed Inserted ID or false
|
||||
**/
|
||||
public function createPayout($account_id=NULL) {
|
||||
$stmt = $this->mysqli->prepare("
|
||||
INSERT INTO $this->table (account_id)
|
||||
VALUES (?)
|
||||
");
|
||||
if ($stmt && $stmt->bind_param('i', $account_id) && $stmt->execute())
|
||||
$stmt = $this->mysqli->prepare("INSERT INTO $this->table (account_id) VALUES (?)");
|
||||
if ($stmt && $stmt->bind_param('i', $account_id) && $stmt->execute()) {
|
||||
return $stmt->insert_id;
|
||||
}
|
||||
$this->setErrorMessage('Unable to create new payout request');
|
||||
$this->debug->append('Failed to create new payout request in database: ' . $this->mysqli->error);
|
||||
return false;
|
||||
|
||||
@ -4,31 +4,13 @@
|
||||
if (!defined('SECURITY'))
|
||||
die('Hacking attempt');
|
||||
|
||||
class Transaction {
|
||||
private $sError = '';
|
||||
private $table = 'transactions';
|
||||
private $tableBlocks = 'blocks';
|
||||
public $num_rows = 0;
|
||||
|
||||
public function __construct($debug, $mysqli, $config, $block, $user) {
|
||||
$this->debug = $debug;
|
||||
$this->mysqli = $mysqli;
|
||||
$this->config = $config;
|
||||
$this->block = $block;
|
||||
$this->user = $user;
|
||||
$this->debug->append("Instantiated Transaction class", 2);
|
||||
}
|
||||
|
||||
// get and set methods
|
||||
private function setErrorMessage($msg) {
|
||||
$this->sError = $msg;
|
||||
}
|
||||
public function getError() {
|
||||
return $this->sError;
|
||||
}
|
||||
class Transaction extends Base {
|
||||
private $sError = '', $table = 'transactions';
|
||||
public $num_rows = 0, $insert_id = 0;
|
||||
|
||||
/**
|
||||
* Add a new transaction to our class table
|
||||
* We also store the inserted ID in case the user needs it
|
||||
* @param account_id int Account ID to book transaction for
|
||||
* @param amount float Coin amount
|
||||
* @param type string Transaction type [Credit, Debit_AP, Debit_MP, Fee, Donation, Orphan_Credit, Orphan_Fee, Orphan_Donation]
|
||||
@ -38,55 +20,36 @@ class Transaction {
|
||||
**/
|
||||
public function addTransaction($account_id, $amount, $type='Credit', $block_id=NULL, $coin_address=NULL) {
|
||||
$stmt = $this->mysqli->prepare("INSERT INTO $this->table (account_id, amount, block_id, type, coin_address) VALUES (?, ?, ?, ?, ?)");
|
||||
if ($this->checkStmt($stmt)) {
|
||||
$stmt->bind_param("idiss", $account_id, $amount, $block_id, $type, $coin_address);
|
||||
if ($stmt->execute()) {
|
||||
$this->setErrorMessage("Failed to store transaction");
|
||||
$stmt->close();
|
||||
return true;
|
||||
}
|
||||
if ($this->checkStmt($stmt) && $stmt->bind_param("idiss", $account_id, $amount, $block_id, $type, $coin_address) && $stmt->execute()) {
|
||||
$this->insert_id = $stmt->insert_id;
|
||||
return true;
|
||||
}
|
||||
$this->setErrorMessage("Failed to store transaction");
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* Mark transactions of a user as archived
|
||||
* @param account_id int Account ID
|
||||
* @param txid int Transaction ID to start from
|
||||
* @param bool boolean True or False
|
||||
**/
|
||||
public function setArchived($account_id, $txid) {
|
||||
$stmt = $this->mysqli->prepare("UPDATE $this->table SET archived = 1 WHERE account_id = ? AND id <= ?");
|
||||
if ($this->checkStmt($stmt) && $stmt->bind_param('ii', $account_id, $txid) && $stmt->execute())
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all transactions from start for account_id
|
||||
* @param account_id int Account ID
|
||||
* @param start int Starting point, id of transaction
|
||||
* @param filter array Filter to limit transactions
|
||||
* @param limit int Only display this many transactions
|
||||
* @param account_id int Account ID
|
||||
* @return data array Database fields as defined in SELECT
|
||||
**/
|
||||
public function getTransactions($account_id, $start=0) {
|
||||
$this->debug->append("STA " . __METHOD__, 4);
|
||||
$stmt = $this->mysqli->prepare("
|
||||
SELECT
|
||||
t.id AS id,
|
||||
t.type AS type,
|
||||
t.amount AS amount,
|
||||
t.coin_address AS coin_address,
|
||||
t.timestamp AS timestamp,
|
||||
b.height AS height,
|
||||
b.confirmations AS confirmations
|
||||
FROM transactions AS t
|
||||
LEFT JOIN " . $this->block->getTableName() . " AS b ON t.block_id = b.id
|
||||
WHERE t.account_id = ?
|
||||
ORDER BY id DESC");
|
||||
if ($this->checkStmt($stmt)) {
|
||||
if(!$stmt->bind_param('i', $account_id)) return false;
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
return $result->fetch_all(MYSQLI_ASSOC);
|
||||
}
|
||||
$this->debug->append('Unable to fetch transactions');
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch all transactions for all users
|
||||
* Optionally apply a filter
|
||||
* @param none
|
||||
* @return mixed array or false
|
||||
**/
|
||||
public function getAllTransactions($start=0,$filter=NULL,$limit=30) {
|
||||
public function getTransactions($start=0, $filter=NULL, $limit=30, $account_id=NULL) {
|
||||
$this->debug->append("STA " . __METHOD__, 4);
|
||||
$sql = "
|
||||
SELECT
|
||||
@ -109,13 +72,14 @@ class Transaction {
|
||||
if (!empty($value)) {
|
||||
switch ($key) {
|
||||
case 'type':
|
||||
$aFilter[] = "t.type = '$value'";
|
||||
$aFilter[] = "t.type = ?";
|
||||
$this->addParam('s', $value);
|
||||
break;
|
||||
case 'status':
|
||||
switch ($value) {
|
||||
case 'Confirmed':
|
||||
if (empty($filter['type']) || ($filter['type'] != 'Debit_AP' && $filter['type'] != 'Debit_MP' && $filter['type'] != 'TXFee' && $filter['type'] != 'Credit_PPS' && $filter['type'] != 'Fee_PPS' && $filter['type'] != 'Donation_PPS')) {
|
||||
$aFilter[] = "b.confirmations >= " . $this->config['confirmations'];
|
||||
$aFilter[] = "b.confirmations >= " . $this->config['confirmations'] . " OR ISNULL(b.confirmations)";
|
||||
}
|
||||
break;
|
||||
case 'Unconfirmed':
|
||||
@ -127,10 +91,12 @@ class Transaction {
|
||||
}
|
||||
break;
|
||||
case 'account':
|
||||
$aFilter[] = "LOWER(a.username) = LOWER('$value')";
|
||||
$aFilter[] = "LOWER(a.username) = LOWER(?)";
|
||||
$this->addParam('s', $value);
|
||||
break;
|
||||
case 'address':
|
||||
$aFilter[] = "t.coin_address = '$value'";
|
||||
$aFilter[] = "t.coin_address = ?";
|
||||
$this->addParam('s', $value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -139,32 +105,36 @@ class Transaction {
|
||||
$sql .= " WHERE " . implode(' AND ', $aFilter);
|
||||
}
|
||||
}
|
||||
if (is_int($account_id) && empty($aFilter)) {
|
||||
$sql .= " WHERE a.id = ?";
|
||||
$this->addParam('i', $account_id);
|
||||
} else if (is_int($account_id)) {
|
||||
$sql .= " AND a.id = ?";
|
||||
$this->addParam('i', $account_id);
|
||||
}
|
||||
$sql .= "
|
||||
ORDER BY id DESC
|
||||
LIMIT ?,?
|
||||
";
|
||||
// Add some other params to query
|
||||
$this->addParam('i', $start);
|
||||
$this->addParam('i', $limit);
|
||||
$stmt = $this->mysqli->prepare($sql);
|
||||
if ($this->checkStmt($stmt) && $stmt->bind_param('ii', $start, $limit) && $stmt->execute() && $result = $stmt->get_result()) {
|
||||
if ($this->checkStmt($stmt) && call_user_func_array( array($stmt, 'bind_param'), $this->getParam()) && $stmt->execute() && $result = $stmt->get_result()) {
|
||||
// Fetch matching row count
|
||||
$num_rows = $this->mysqli->prepare("SELECT FOUND_ROWS() AS num_rows");
|
||||
if ($num_rows->execute() && $row_count = $num_rows->get_result()->fetch_object()->num_rows)
|
||||
$this->num_rows = $row_count;
|
||||
return $result->fetch_all(MYSQLI_ASSOC);
|
||||
}
|
||||
$this->debug->append('Unable to fetch transactions');
|
||||
$this->debug->append('Failed to fetch transactions: ' . $this->mysqli->error);
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Count the amount of transactions in the table
|
||||
* Get all different transaction types
|
||||
* @return mixed array/bool Return types on succes, false on failure
|
||||
**/
|
||||
public function getCountAllTransactions($filter=NULL) {
|
||||
$stmt = $this->mysqli->prepare("SELECT COUNT(id) AS total FROM $this->table");
|
||||
if ($this->checkStmt($stmt) && $stmt->execute() && $result = $stmt->get_result())
|
||||
return $result->fetch_object()->total;
|
||||
$this->debug->append('Failed to fetch transaction count: ' . $this->mysqli->error);
|
||||
return false;
|
||||
}
|
||||
public function getTypes() {
|
||||
$stmt = $this->mysqli->prepare("SELECT DISTINCT type FROM $this->table");
|
||||
if ($this->checkStmt($stmt) && $stmt->execute() && $result = $stmt->get_result()) {
|
||||
@ -178,15 +148,6 @@ class Transaction {
|
||||
return false;
|
||||
}
|
||||
|
||||
private function checkStmt($bState) {
|
||||
if ($bState ===! true) {
|
||||
$this->debug->append("Failed to prepare statement: " . $this->mysqli->error);
|
||||
$this->setErrorMessage('Internal application Error');
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all donation transactions
|
||||
* Used on donors page
|
||||
@ -227,31 +188,16 @@ class Transaction {
|
||||
public function getLockedBalance() {
|
||||
$this->debug->append("STA " . __METHOD__, 4);
|
||||
$stmt = $this->mysqli->prepare("
|
||||
SELECT ROUND(IFNULL(t1.credit, 0) - IFNULL(t2.debit, 0) - IFNULL(t3.other, 0), 8) AS balance
|
||||
FROM
|
||||
(
|
||||
SELECT sum(t.amount) AS credit
|
||||
FROM $this->table AS t
|
||||
LEFT JOIN " . $this->block->getTableName() . " AS b ON t.block_id = b.id
|
||||
WHERE (
|
||||
( t.type IN ('Credit','Bonus') AND b.confirmations >= ? ) OR
|
||||
( t.type = 'Credit_PPS' )
|
||||
)
|
||||
) AS t1,
|
||||
(
|
||||
SELECT sum(t.amount) AS debit
|
||||
FROM $this->table AS t
|
||||
WHERE t.type IN ('Debit_MP', 'Debit_AP')
|
||||
) AS t2,
|
||||
(
|
||||
SELECT sum(t.amount) AS other
|
||||
FROM " . $this->table . " AS t
|
||||
LEFT JOIN " . $this->block->getTableName() . " AS b ON t.block_id = b.id
|
||||
WHERE (
|
||||
( t.type IN ('Donation','Fee') AND b.confirmations >= ? ) OR
|
||||
t.type IN ('Donation_PPS','Fee_PPS','TXFee')
|
||||
)
|
||||
) AS t3");
|
||||
SELECT
|
||||
ROUND((
|
||||
SUM( IF( ( t.type IN ('Credit','Bonus') OR t.type = 'Credit_PPS') AND b.confirmations >= ?, t.amount, 0 ) ) -
|
||||
SUM( IF( t.type IN ('Debit_MP', 'Debit_AP'), t.amount, 0 ) ) -
|
||||
SUM( IF( ( t.type IN ('Donation','Fee') AND b.confirmations >= ? ) OR ( t.type IN ('Donation_PPS', 'Fee_PPS', 'TXFee') ), t.amount, 0 ) )
|
||||
), 8) AS balance
|
||||
FROM $this->table AS t
|
||||
LEFT JOIN " . $this->block->getTableName() . " AS b
|
||||
ON t.block_id = b.id
|
||||
WHERE archived = 0");
|
||||
if ($this->checkStmt($stmt) && $stmt->bind_param('ii', $this->config['confirmations'], $this->config['confirmations']) && $stmt->execute() && $stmt->bind_result($dBalance) && $stmt->fetch())
|
||||
return $dBalance;
|
||||
// Catchall
|
||||
@ -261,7 +207,7 @@ class Transaction {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an accounts total balance
|
||||
* Get an accounts total balance, ignore archived entries
|
||||
* @param account_id int Account ID
|
||||
* @return data float Credit - Debit - Fees - Donation
|
||||
**/
|
||||
@ -269,87 +215,35 @@ class Transaction {
|
||||
$this->debug->append("STA " . __METHOD__, 4);
|
||||
$stmt = $this->mysqli->prepare("
|
||||
SELECT
|
||||
ROUND(IFNULL(t1.credit, 0) - IFNULL(t2.debit, 0) - IFNULL(t3.other, 0), 8) AS confirmed,
|
||||
ROUND(IFNULL(t4.credit, 0) - IFNULL(t5.other, 0), 8) AS unconfirmed,
|
||||
ROUND(IFNULL(t6.credit, 0) - IFNULL(t7.other, 0), 8) AS orphaned
|
||||
FROM
|
||||
(
|
||||
SELECT sum(t.amount) AS credit
|
||||
FROM $this->table AS t
|
||||
LEFT JOIN " . $this->block->getTableName() . " AS b ON t.block_id = b.id
|
||||
WHERE
|
||||
(
|
||||
( t.type IN ('Credit','Bonus') AND b.confirmations >= ? ) OR
|
||||
( t.type = 'Credit_PPS' )
|
||||
)
|
||||
AND t.account_id = ?
|
||||
) AS t1,
|
||||
(
|
||||
SELECT sum(t.amount) AS debit
|
||||
FROM $this->table AS t
|
||||
WHERE t.type IN ('Debit_MP', 'Debit_AP')
|
||||
AND t.account_id = ?
|
||||
) AS t2,
|
||||
(
|
||||
SELECT sum(t.amount) AS other
|
||||
FROM $this->table AS t
|
||||
LEFT JOIN " . $this->block->getTableName() . " AS b ON t.block_id = b.id
|
||||
WHERE
|
||||
(
|
||||
( t.type IN ('Donation','Fee') AND b.confirmations >= ? ) OR
|
||||
( t.type IN ('Donation_PPS', 'Fee_PPS', 'TXFee') )
|
||||
)
|
||||
AND t.account_id = ?
|
||||
) AS t3,
|
||||
(
|
||||
SELECT sum(t.amount) AS credit
|
||||
FROM $this->table AS t
|
||||
LEFT JOIN " . $this->block->getTableName() . " AS b ON t.block_id = b.id
|
||||
WHERE
|
||||
t.type IN ('Credit','Bonus') AND b.confirmations < ? AND b.confirmations >= 0
|
||||
AND t.account_id = ?
|
||||
) AS t4,
|
||||
(
|
||||
SELECT sum(t.amount) AS other
|
||||
FROM $this->table AS t
|
||||
LEFT JOIN " . $this->block->getTableName() . " AS b ON t.block_id = b.id
|
||||
WHERE
|
||||
(
|
||||
t.type IN ('Donation','Fee') AND b.confirmations < ? AND b.confirmations >= 0
|
||||
)
|
||||
AND t.account_id = ?
|
||||
) AS t5,
|
||||
(
|
||||
SELECT sum(t.amount) AS credit
|
||||
FROM $this->table AS t
|
||||
LEFT JOIN " . $this->block->getTableName() . " AS b ON t.block_id = b.id
|
||||
WHERE
|
||||
t.type IN ('Credit','Bonus') AND b.confirmations = -1
|
||||
AND t.account_id = ?
|
||||
) AS t6,
|
||||
(
|
||||
SELECT sum(t.amount) AS other
|
||||
FROM $this->table AS t
|
||||
LEFT JOIN " . $this->block->getTableName() . " AS b ON t.block_id = b.id
|
||||
WHERE
|
||||
(
|
||||
t.type IN ('Donation','Fee') AND b.confirmations = -1
|
||||
)
|
||||
AND t.account_id = ?
|
||||
) AS t7
|
||||
ROUND((
|
||||
SUM( IF( ( t.type IN ('Credit','Bonus') OR t.type = 'Credit_PPS') AND b.confirmations >= ?, t.amount, 0 ) ) -
|
||||
SUM( IF( t.type IN ('Debit_MP', 'Debit_AP'), t.amount, 0 ) ) -
|
||||
SUM( IF( ( t.type IN ('Donation','Fee') AND b.confirmations >= ? ) OR ( t.type IN ('Donation_PPS', 'Fee_PPS', 'TXFee') ), t.amount, 0 ) )
|
||||
), 8) AS confirmed,
|
||||
ROUND((
|
||||
SUM( IF( t.type IN ('Credit','Bonus') AND b.confirmations < ? AND b.confirmations >= 0, t.amount, 0 ) ) -
|
||||
SUM( IF( t.type IN ('Donation','Fee') AND b.confirmations < ? AND b.confirmations >= 0, t.amount, 0 ) )
|
||||
), 8) AS unconfirmed,
|
||||
ROUND((
|
||||
SUM( IF( t.type IN ('Credit','Bonus') AND b.confirmations = -1, t.amount, 0) ) -
|
||||
SUM( IF( t.type IN ('Donation','Fee') AND b.confirmations = -1, t.amount, 0) )
|
||||
), 8) AS orphaned
|
||||
FROM $this->table AS t
|
||||
LEFT JOIN " . $this->block->getTableName() . " AS b
|
||||
ON t.block_id = b.id
|
||||
WHERE t.account_id = ?
|
||||
AND archived = 0
|
||||
");
|
||||
if ($this->checkStmt($stmt)) {
|
||||
$stmt->bind_param("iiiiiiiiiii", $this->config['confirmations'], $account_id, $account_id, $this->config['confirmations'], $account_id, $this->config['confirmations'], $account_id, $this->config['confirmations'], $account_id, $account_id, $account_id);
|
||||
if (!$stmt->execute()) {
|
||||
$this->debug->append("Unable to execute statement: " . $stmt->error);
|
||||
$this->setErrorMessage("Fetching balance failed");
|
||||
}
|
||||
$result = $stmt->get_result();
|
||||
$stmt->close();
|
||||
if ($this->checkStmt($stmt) && $stmt->bind_param("iiiii", $this->config['confirmations'], $this->config['confirmations'], $this->config['confirmations'], $this->config['confirmations'], $account_id) && $stmt->execute() && $result = $stmt->get_result())
|
||||
return $result->fetch_assoc();
|
||||
}
|
||||
$this->debug->append('Failed to fetch users balance: ' . $this->mysqli->error);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
$transaction = new Transaction($debug, $mysqli, $config, $block, $user);
|
||||
$transaction = new Transaction();
|
||||
$transaction->setDebug($debug);
|
||||
$transaction->setMysql($mysqli);
|
||||
$transaction->setConfig($config);
|
||||
$transaction->setBlock($block);
|
||||
$transaction->setUser($user);
|
||||
|
||||
@ -320,7 +320,7 @@ class User {
|
||||
$this->setErrorMessage('Invalid email address');
|
||||
return false;
|
||||
}
|
||||
if ($this->bitcoin->can_connect() === true && !empty($address)) {
|
||||
/* if ($this->bitcoin->can_connect() === true && !empty($address)) {
|
||||
try {
|
||||
$aStatus = $this->bitcoin->validateaddress($address);
|
||||
if (!$aStatus['isvalid']) {
|
||||
@ -335,6 +335,7 @@ class User {
|
||||
$this->setErrorMessage('Unable to connect to RPC server for coin address validation');
|
||||
return false;
|
||||
}
|
||||
*/
|
||||
// Number sanitizer, just in case we fall through above
|
||||
$threshold = min($this->config['ap_threshold']['max'], max(0, floatval($threshold)));
|
||||
$donate = min(100, max(0, floatval($donate)));
|
||||
|
||||
@ -3,9 +3,17 @@
|
||||
// Make sure we are called from index.php
|
||||
if (!defined('SECURITY')) die('Hacking attempt');
|
||||
if ($user->isAuthenticated()) {
|
||||
$aTransactions = $transaction->getTransactions($_SESSION['USERDATA']['id']);
|
||||
$iLimit = 30;
|
||||
empty($_REQUEST['start']) ? $start = 0 : $start = $_REQUEST['start'];
|
||||
$aTransactions = $transaction->getTransactions($start, @$_REQUEST['filter'], $iLimit, $_SESSION['USERDATA']['id']);
|
||||
$iCountTransactions = $transaction->num_rows;
|
||||
$aTransactionTypes = $transaction->getTypes();
|
||||
if (!$aTransactions) $_SESSION['POPUP'][] = array('CONTENT' => 'Could not find any transaction', 'TYPE' => 'errormsg');
|
||||
$smarty->assign('LIMIT', $iLimit);
|
||||
$smarty->assign('TRANSACTIONS', $aTransactions);
|
||||
$smarty->assign('TRANSACTIONTYPES', $aTransactionTypes);
|
||||
$smarty->assign('TXSTATUS', array('' => '', 'Confirmed' => 'Confirmed', 'Unconfirmed' => 'Unconfirmed', 'Orphan' => 'Orphan'));
|
||||
$smarty->assign('COUNTTRANSACTIONS', $iCountTransactions);
|
||||
}
|
||||
$smarty->assign('CONTENT', 'default.tpl');
|
||||
?>
|
||||
|
||||
@ -12,7 +12,8 @@ if (!$user->isAuthenticated() || !$user->isAdmin($_SESSION['USERDATA']['id'])) {
|
||||
if (!$smarty->isCached('master.tpl', $smarty_cache_key)) {
|
||||
$iLimit = 30;
|
||||
$debug->append('No cached version available, fetching from backend', 3);
|
||||
$aTransactions = $transaction->getAllTransactions(@$_REQUEST['start'], @$_REQUEST['filter'], $iLimit);
|
||||
empty($_REQUEST['start']) ? $start = 0 : $start = $_REQUEST['start'];
|
||||
$aTransactions = $transaction->getTransactions($start, @$_REQUEST['filter'], $iLimit);
|
||||
$iCountTransactions = $transaction->num_rows;
|
||||
$aTransactionTypes = $transaction->getTypes();
|
||||
if (!$aTransactions) $_SESSION['POPUP'][] = array('CONTENT' => 'Could not find any transaction', 'TYPE' => 'errormsg');
|
||||
|
||||
@ -1,40 +1,86 @@
|
||||
{include file="global/block_header.tpl" BLOCK_HEADER="Transaction Log" BUTTONS=array(Confirmed,Unconfirmed,Orphan)}
|
||||
<div class="block_content tab_content" id="Confirmed" style="clear:;">
|
||||
{include file="global/block_header.tpl" ALIGN="left" BLOCK_STYLE="width: 23%" BLOCK_HEADER="Transaction Filter"}
|
||||
<form action="{$smarty.server.PHP_SELF}">
|
||||
<input type="hidden" name="page" value="{$smarty.request.page}" />
|
||||
<input type="hidden" name="action" value="{$smarty.request.action}" />
|
||||
<table cellpadding="1" cellspacing="1" width="100%">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="left">
|
||||
{if $COUNTTRANSACTIONS / $LIMIT > 1}
|
||||
{if $smarty.request.start|default:"0" > 0}
|
||||
<a href="{$smarty.server.PHP_SELF}?page={$smarty.request.page}&action={$smarty.request.action}&start={$smarty.request.start|default:"0" - $LIMIT}{if $FILTERS|default:""}{$FILTERS}{/if}"><img src="{$PATH}/images/prev.png" /></a>
|
||||
{else}
|
||||
<img src="{$PATH}/images/prev.png" />
|
||||
{/if}
|
||||
{/if}
|
||||
</td>
|
||||
<td class="right">
|
||||
{if $COUNTTRANSACTIONS / $LIMIT > 1}
|
||||
{if $COUNTTRANSACTIONS - $smarty.request.start|default:"0" - $LIMIT > 0}
|
||||
<a href="{$smarty.server.PHP_SELF}?page={$smarty.request.page}&action={$smarty.request.action}&start={$smarty.request.start|default:"0" + $LIMIT}{if $FILTERS|default:""}{$FILTERS}{/if}"><img src="{$PATH}/images/next.png" /></a>
|
||||
{else}
|
||||
<img src="{$PATH}/images/next.png" />
|
||||
{/if}
|
||||
{/if}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="left">TX Type</td>
|
||||
<td class="right">{html_options name="filter[type]" options=$TRANSACTIONTYPES selected=$smarty.request.filter.type|default:""}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="left">TX Status</td>
|
||||
<td class="right">{html_options name="filter[status]" options=$TXSTATUS selected=$smarty.request.filter.status|default:""}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="center" colspan="2"><input type="submit" class="submit small" value="Filter"></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</form>
|
||||
{include file="global/block_footer.tpl"}
|
||||
|
||||
{include file="global/block_header.tpl" ALIGN="right" BLOCK_STYLE="width: 75%" BLOCK_HEADER="Transaction History"}
|
||||
<div class="block_content" style="clear:;">
|
||||
<center>
|
||||
{include file="global/pagination.tpl"}
|
||||
<table cellpadding="1" cellspacing="1" width="98%" class="pagesort">
|
||||
<table cellpadding="1" cellspacing="1" width="100%">
|
||||
<thead style="font-size:13px;">
|
||||
<tr>
|
||||
<th class="header" style="cursor: pointer;">TX #</th>
|
||||
<th class="header" style="cursor: pointer;">Account</th>
|
||||
<th class="header" style="cursor: pointer;">Date</th>
|
||||
<th class="header" style="cursor: pointer;">TX Type</th>
|
||||
<th class="header" style="cursor: pointer;">Status</th>
|
||||
<th class="header" style="cursor: pointer;">Payment Address</th>
|
||||
<th class="header" style="cursor: pointer;">Block #</th>
|
||||
<th class="header" style="cursor: pointer;">Amount</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody style="font-size:12px;">
|
||||
{assign var=has_confirmed value=false}
|
||||
{section transaction $TRANSACTIONS}
|
||||
{if (
|
||||
( ( $TRANSACTIONS[transaction].type == 'Credit' or $TRANSACTIONS[transaction].type == 'Bonus' or $TRANSACTIONS[transaction].type == 'Donation' or $TRANSACTIONS[transaction].type == 'Fee' ) and $TRANSACTIONS[transaction].confirmations >= $GLOBAL.confirmations )
|
||||
or $TRANSACTIONS[transaction].type == 'Credit_PPS' or $TRANSACTIONS[transaction].type == 'Fee_PPS' or $TRANSACTIONS[transaction].type == 'Donation_PPS'
|
||||
or $TRANSACTIONS[transaction].type == 'Debit_AP' or $TRANSACTIONS[transaction].type == 'Debit_MP' or $TRANSACTIONS[transaction].type == 'TXFee'
|
||||
)}
|
||||
{assign var=has_credits value=true}
|
||||
<tr class="{cycle values="odd,even"}">
|
||||
<td>{$TRANSACTIONS[transaction].id}</td>
|
||||
<td>{$TRANSACTIONS[transaction].username}</td>
|
||||
<td>{$TRANSACTIONS[transaction].timestamp}</td>
|
||||
<td>{$TRANSACTIONS[transaction].type}</td>
|
||||
<td>
|
||||
{if $TRANSACTIONS[transaction].type == 'Credit_PPS' OR
|
||||
$TRANSACTIONS[transaction].type == 'Fee_PPS' OR
|
||||
$TRANSACTIONS[transaction].type == 'Donation_PPS' OR
|
||||
$TRANSACTIONS[transaction].type == 'Debit_MP' OR
|
||||
$TRANSACTIONS[transaction].type == 'Debit_AP' OR
|
||||
$TRANSACTIONS[transaction].type == 'TXFee' OR
|
||||
$TRANSACTIONS[transaction].confirmations >= $GLOBAL.confirmations
|
||||
}<font color="green">Confirmed</font>
|
||||
{else if $TRANSACTIONS[transaction].confirmations == -1}<font color="red">Orphaned</font>
|
||||
{else}<font color="orange">Unconfirmed</font>{/if}
|
||||
<font size="1px">({$TRANSACTIONS[transaction].confirmations|default:"n/a"})</font>
|
||||
</td>
|
||||
<td>{$TRANSACTIONS[transaction].coin_address}</td>
|
||||
<td>{if $TRANSACTIONS[transaction].height == 0}n/a{else}{$TRANSACTIONS[transaction].height}{/if}</td>
|
||||
<td>{if $TRANSACTIONS[transaction].height == 0}n/a{else}{if $GLOBAL.blockexplorer}<a href="{$GLOBAL.blockexplorer}{$TRANSACTIONS[transaction].blockhash}">{$TRANSACTIONS[transaction].height}</a>{else}{$TRANSACTIONS[transaction].height}{/if}{/if}</td>
|
||||
<td><font color="{if $TRANSACTIONS[transaction].type == 'Credit' or $TRANSACTIONS[transaction].type == 'Credit_PPS' or $TRANSACTIONS[transaction].type == 'Bonus'}green{else}red{/if}">{$TRANSACTIONS[transaction].amount|number_format:"8"}</td>
|
||||
</tr>
|
||||
{/if}
|
||||
{/section}
|
||||
{if !$has_confirmed}
|
||||
<tr><td class="center" colspan="6"><b><i>No data</i></b></td></tr>
|
||||
{/if}
|
||||
</tbody>
|
||||
</table>
|
||||
<p>
|
||||
@ -44,97 +90,4 @@
|
||||
</p>
|
||||
</center>
|
||||
</div>
|
||||
<div class="block_content tab_content" id="Unconfirmed" style="">
|
||||
<center>
|
||||
{include file="global/pagination.tpl" ID=2}
|
||||
<table cellpadding="1" cellspacing="1" width="98%" class="pagesort2">
|
||||
<thead style="font-size:13px;">
|
||||
<tr>
|
||||
<th class="header" style="cursor: pointer;">TX #</th>
|
||||
<th class="header" style="cursor: pointer;">Date</th>
|
||||
<th class="header" style="cursor: pointer;">TX Type</th>
|
||||
<th class="header" style="cursor: pointer;">Payment Address</th>
|
||||
<th class="header" style="cursor: pointer;">Block #</th>
|
||||
<th class="header" style="cursor: pointer;">Amount</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody style="font-size:12px;">
|
||||
{assign var=has_unconfirmed value=false}
|
||||
{section transaction $TRANSACTIONS}
|
||||
{if
|
||||
(($TRANSACTIONS[transaction].type == 'Credit' or $TRANSACTIONS[transaction].type == 'Bonus' or $TRANSACTIONS[transaction].type == 'Donation' or $TRANSACTIONS[transaction].type == 'Fee') and $TRANSACTIONS[transaction].confirmations < $GLOBAL.confirmations and $TRANSACTIONS[transaction].confirmations >= 0)
|
||||
}
|
||||
{assign var=has_unconfirmed value=true}
|
||||
<tr class="{cycle values="odd,even"}">
|
||||
<td>{$TRANSACTIONS[transaction].id}</td>
|
||||
<td>{$TRANSACTIONS[transaction].timestamp}</td>
|
||||
<td>{$TRANSACTIONS[transaction].type}</td>
|
||||
<td>{$TRANSACTIONS[transaction].coin_address}</td>
|
||||
<td>{if $TRANSACTIONS[transaction].height == 0}n/a{else}{$TRANSACTIONS[transaction].height}{/if}</td>
|
||||
<td><font color="{if $TRANSACTIONS[transaction].type == 'Credit' or $TRANSACTIONS[transaction].type == 'Bonus'}green{else}red{/if}">{$TRANSACTIONS[transaction].amount|number_format:"8"}</td>
|
||||
</tr>
|
||||
{if $TRANSACTIONS[transaction].type == 'Credit' or $TRANSACTIONS[transaction].type == 'Bonus'}
|
||||
{assign var="credits" value="`$credits|default:"0"+$TRANSACTIONS[transaction].amount`"}
|
||||
{else}
|
||||
{assign var="debits" value="`$debits|default:"0"+$TRANSACTIONS[transaction].amount`"}
|
||||
{/if}
|
||||
{/if}
|
||||
{/section}
|
||||
{if !$has_unconfirmed}
|
||||
<tr><td class="center" colspan="6"><b><i>No data</i></b></td></tr>
|
||||
{/if}
|
||||
<tr>
|
||||
<td colspan="5"><b>Unconfirmed Totals:</b></td>
|
||||
<td><b>{($credits|default - $debits|default)|number_format:"8"}</b></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<p><font color="" sizeze="1">Listed are your estimated rewards and donations/fees for all blocks awaiting {$GLOBAL.confirmations} confirmations.</font></p>
|
||||
</center>
|
||||
</div>
|
||||
<div class="block_content tab_content" id="Orphan" style="">
|
||||
<center>
|
||||
{include file="global/pagination.tpl"}
|
||||
<table cellpadding="1" cellspacing="1" width="98%" class="pagesort3">
|
||||
<thead style="font-size:13px;">
|
||||
<tr>
|
||||
<th class="header" style="cursor: pointer;">TX #</th>
|
||||
<th class="header" style="cursor: pointer;">Date</th>
|
||||
<th class="header" style="cursor: pointer;">TX Type</th>
|
||||
<th class="header" style="cursor: pointer;">Payment Address</th>
|
||||
<th class="header" style="cursor: pointer;">Block #</th>
|
||||
<th class="header" style="cursor: pointer;">Amount</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody style="font-size:12px;">
|
||||
{assign var=has_orphaned value=false}
|
||||
{section transaction $TRANSACTIONS}
|
||||
{if ($TRANSACTIONS[transaction].type == 'Credit' or $TRANSACTIONS[transaction].type == 'Fee' or $TRANSACTIONS[transaction].type == 'Donation' or $TRANSACTIONS[transaction].type == 'Bonus') and $TRANSACTIONS[transaction].confirmations == -1}
|
||||
<tr class="{cycle values="odd,even"}">
|
||||
<td>{$TRANSACTIONS[transaction].id}</td>
|
||||
<td>{$TRANSACTIONS[transaction].timestamp}</td>
|
||||
<td>{$TRANSACTIONS[transaction].type}</td>
|
||||
<td>{$TRANSACTIONS[transaction].coin_address}</td>
|
||||
<td>{if $TRANSACTIONS[transaction].height == 0}n/a{else}{$TRANSACTIONS[transaction].height}{/if}</td>
|
||||
<td><font color="{if $TRANSACTIONS[transaction].type == 'Credit' or $TRANSACTIONS[transaction].type == 'Bonus'}green{else}red{/if}">{$TRANSACTIONS[transaction].amount|number_format:"8"}</td>
|
||||
</tr>
|
||||
{if $TRANSACTIONS[transaction].type == 'Credit' or $TRANSACTIONS[transaction].type == 'Bonus'}
|
||||
{assign var="orphan_credits" value="`$orphan_credits|default:"0"+$TRANSACTIONS[transaction].amount`"}
|
||||
{else}
|
||||
{assign var="orphan_debits" value="`$orphan_debits|default:"0"+$TRANSACTIONS[transaction].amount`"}
|
||||
{/if}
|
||||
{/if}
|
||||
{/section}
|
||||
{if !$has_orphaned}
|
||||
<tr><td class="center" colspan="6"><b><i>No data</i></b></td></tr>
|
||||
{/if}
|
||||
<tr>
|
||||
<td colspan="5"><b>Orphaned Totals:</b></td>
|
||||
<td><b>{($orphan_credits|default - $orphan_debits|default)|number_format:"8"}</b></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<p><font color="" sizeze="1">Listed are your orphaned transactions for blocks not part of the main blockchain.</font></p>
|
||||
</center>
|
||||
</div>
|
||||
{include file="global/block_footer.tpl"}
|
||||
|
||||
@ -1,4 +1,7 @@
|
||||
{include file="global/block_header.tpl" ALIGN="left" BLOCK_STYLE="width: 23%" BLOCK_HEADER="Transaction Filter"}
|
||||
<form action="{$smarty.server.PHP_SELF}">
|
||||
<input type="hidden" name="page" value="{$smarty.request.page}" />
|
||||
<input type="hidden" name="action" value="{$smarty.request.action}" />
|
||||
<table cellpadding="1" cellspacing="1" width="100%">
|
||||
<tbody>
|
||||
<tr>
|
||||
@ -21,9 +24,6 @@
|
||||
{/if}
|
||||
</td>
|
||||
</tr>
|
||||
<form action="{$smarty.server.PHP_SELF}">
|
||||
<input type="hidden" name="page" value="{$smarty.request.page}" />
|
||||
<input type="hidden" name="action" value="{$smarty.request.action}" />
|
||||
<tr>
|
||||
<td class="left">TX Type</td>
|
||||
<td class="right">{html_options name="filter[type]" options=$TRANSACTIONTYPES selected=$smarty.request.filter.type|default:""}</td>
|
||||
@ -43,9 +43,9 @@
|
||||
<tr>
|
||||
<td class="center" colspan="2"><input type="submit" class="submit small" value="Filter"></td>
|
||||
</tr>
|
||||
</form>
|
||||
</tbody>
|
||||
</table>
|
||||
</form>
|
||||
{include file="global/block_footer.tpl"}
|
||||
|
||||
{include file="global/block_header.tpl" ALIGN="right" BLOCK_STYLE="width: 75%" BLOCK_HEADER="Transaction History"}
|
||||
|
||||
2
sql/007_transactions.sql
Normal file
2
sql/007_transactions.sql
Normal file
@ -0,0 +1,2 @@
|
||||
ALTER TABLE `transactions` ADD `archived` BOOLEAN NOT NULL DEFAULT FALSE AFTER `timestamp` ;
|
||||
ALTER TABLE `transactions` ADD INDEX ( `archived` ) ;
|
||||
Loading…
Reference in New Issue
Block a user