-Misc fixes
-Add all entries CSV
This commit is contained in:
+111
@@ -0,0 +1,111 @@
|
|||||||
|
26/09/2022,symoss,1,Deposit
|
||||||
|
26/09/2022,symoss,185354305,Deposit
|
||||||
|
27/09/2022,zarathos75,-2000000,Withdrawal
|
||||||
|
27/09/2022,symoss,-3000,Withdrawal
|
||||||
|
28/09/2022,symoss,-1000000,Withdrawal
|
||||||
|
28/09/2022,zarathos75,-2000000,Withdrawal
|
||||||
|
28/09/2022,symoss,-300000,Withdrawal
|
||||||
|
30/09/2022,symoss,-400000,Withdrawal
|
||||||
|
30/09/2022,symoss,-150000,Withdrawal
|
||||||
|
30/09/2022,symoss,-50000,Withdrawal
|
||||||
|
02/10/2022,symoss,-2000000,Withdrawal
|
||||||
|
02/10/2022,zarathos75,-2000000,Withdrawal
|
||||||
|
02/10/2022,symoss,1000000,Deposit
|
||||||
|
04/10/2022,symoss,-300000,Withdrawal
|
||||||
|
05/10/2022,symoss,-300000,Withdrawal
|
||||||
|
06/10/2022,zarathos75,-2000000,Withdrawal
|
||||||
|
06/10/2022,symoss,-2000000,Withdrawal
|
||||||
|
06/10/2022,symoss,-10000000,Withdrawal
|
||||||
|
07/10/2022,symoss,-350000,Withdrawal
|
||||||
|
07/10/2022,symoss,-2000000,Withdrawal
|
||||||
|
13/10/2022,zarathos75,-2000000,Withdrawal
|
||||||
|
14/10/2022,symoss,-350000,Withdrawal
|
||||||
|
15/10/2022,symoss,-350000,Withdrawal
|
||||||
|
16/10/2022,zarathos75,-2000000,Withdrawal
|
||||||
|
16/10/2022,symoss,-1200000,Withdrawal
|
||||||
|
18/10/2022,symoss,-10000000,Withdrawal
|
||||||
|
19/10/2022,zarathos75,-2000000,Withdrawal
|
||||||
|
21/10/2022,symoss,-350000,Withdrawal
|
||||||
|
21/10/2022,symoss,-1000000,Withdrawal
|
||||||
|
22/10/2022,symoss,-350000,Withdrawal
|
||||||
|
23/10/2022,symoss,-230000,Withdrawal
|
||||||
|
24/10/2022,zarathos75,-80000000,Withdrawal
|
||||||
|
24/10/2022,zarathos75,12392725,Deposit
|
||||||
|
24/10/2022,symoss,-1000000,Withdrawal
|
||||||
|
24/10/2022,zarathos75,2988600,Deposit
|
||||||
|
25/10/2022,zarathos75,89862,Deposit
|
||||||
|
25/10/2022,zarathos75,-352500,Withdrawal
|
||||||
|
25/10/2022,symoss,-600000,Withdrawal
|
||||||
|
25/10/2022,symoss,690914,Deposit
|
||||||
|
25/10/2022,symoss,-1000000,Withdrawal
|
||||||
|
26/10/2022,zarathos75,-3000000,Withdrawal
|
||||||
|
26/10/2022,zarathos75,-2000000,Withdrawal
|
||||||
|
26/10/2022,symoss,-1500000,Withdrawal
|
||||||
|
26/10/2022,symoss,-5000000,Withdrawal
|
||||||
|
26/10/2022,symoss,-750000,Withdrawal
|
||||||
|
28/10/2022,symoss,-700000,Withdrawal
|
||||||
|
28/10/2022,symoss,96429637,Deposit
|
||||||
|
28/10/2022,symoss,-800000,Withdrawal
|
||||||
|
28/10/2022,zarathos75,52642857,Deposit
|
||||||
|
29/10/2022,symoss,-352500,Withdrawal
|
||||||
|
29/10/2022,symoss,-750000,Withdrawal
|
||||||
|
30/10/2022,symoss,760975,Deposit
|
||||||
|
30/10/2022,symoss,-352500,Withdrawal
|
||||||
|
31/10/2022,zarathos75,-1000000,Withdrawal
|
||||||
|
31/10/2022,symoss,-20000000,Withdrawal
|
||||||
|
31/10/2022,symoss,450000,Deposit
|
||||||
|
01/11/2022,symoss,-400000,Withdrawal
|
||||||
|
01/11/2022,symoss,-750000,Withdrawal
|
||||||
|
03/11/2022,zarathos75,-100000000,Withdrawal
|
||||||
|
03/11/2022,symoss,99442460,Deposit
|
||||||
|
03/11/2022,symoss,-500000,Withdrawal
|
||||||
|
03/11/2022,symoss,-750000,Withdrawal
|
||||||
|
05/11/2022,zarathos75,-2000000,Withdrawal
|
||||||
|
05/11/2022,symoss,-500000,Withdrawal
|
||||||
|
07/11/2022,symoss,-200000,Withdrawal
|
||||||
|
08/11/2022,zarathos75,-2000000,Withdrawal
|
||||||
|
09/11/2022,symoss,-350000,Withdrawal
|
||||||
|
09/11/2022,symoss,-750000,Withdrawal
|
||||||
|
10/11/2022,symoss,-50000,Withdrawal
|
||||||
|
11/11/2022,symoss,-330000,Withdrawal
|
||||||
|
12/11/2022,symoss,-1050000,Withdrawal
|
||||||
|
12/11/2022,symoss,-75000,Withdrawal
|
||||||
|
12/11/2022,symoss,526550,Deposit
|
||||||
|
13/11/2022,symoss,-350000,Withdrawal
|
||||||
|
14/11/2022,symoss,-1000000,Withdrawal
|
||||||
|
14/11/2022,symoss,-100000,Withdrawal
|
||||||
|
14/11/2022,symoss,-10000000,Withdrawal
|
||||||
|
14/11/2022,symoss,5775234,Deposit
|
||||||
|
14/11/2022,symoss,-16000000,Withdrawal
|
||||||
|
14/11/2022,symoss,-1200000,Withdrawal
|
||||||
|
16/11/2022,symoss,-350000,Withdrawal
|
||||||
|
16/11/2022,symoss,-700000,Withdrawal
|
||||||
|
20/11/2022,symoss,-1100000,Withdrawal
|
||||||
|
21/11/2022,symoss,-200000,Withdrawal
|
||||||
|
22/11/2022,symoss,-1050000,Withdrawal
|
||||||
|
25/11/2022,symoss,-1000000,Withdrawal
|
||||||
|
29/11/2022,zarathos75,-3000000,Withdrawal
|
||||||
|
29/11/2022,symoss,-1000000,Withdrawal
|
||||||
|
02/12/2022,symoss,-500000,Withdrawal
|
||||||
|
04/12/2022,symoss,-10000000,Withdrawal
|
||||||
|
05/12/2022,symoss,-500000,Withdrawal
|
||||||
|
06/12/2022,symoss,-20000000,Withdrawal
|
||||||
|
07/12/2022,zarathos75,40000000,Deposit
|
||||||
|
09/12/2022,symoss,86455,Deposit
|
||||||
|
09/12/2022,symoss,-1000000,Withdrawal
|
||||||
|
10/12/2022,zarathos75,2608832,Deposit
|
||||||
|
10/12/2022,zarathos75,-1000000,Withdrawal
|
||||||
|
11/12/2022,symoss,-200000,Withdrawal
|
||||||
|
11/12/2022,symoss,-1000000,Withdrawal
|
||||||
|
12/12/2022,zarathos75,-4000000,Withdrawal
|
||||||
|
14/12/2022,symoss,-750000,Withdrawal
|
||||||
|
14/12/2022,symoss,-15000000,Withdrawal
|
||||||
|
15/12/2022,zarathos75,3203752,Deposit
|
||||||
|
15/12/2022,zarathos75,-5000000,Withdrawal
|
||||||
|
15/12/2022,symoss,-750000,Withdrawal
|
||||||
|
17/12/2022,zarathos75,3915202,Deposit
|
||||||
|
17/12/2022,zarathos75,-6000000,Withdrawal
|
||||||
|
17/12/2022,zarathos75,3000000,Deposit
|
||||||
|
17/12/2022,zarathos75,3000000,Deposit
|
||||||
|
17/12/2022,zarathos75,-8000000,Withdrawal
|
||||||
|
17/12/2022,zarathos75,4000000,Deposit
|
||||||
|
+23
-18
@@ -4,6 +4,7 @@ setlocale(LC_MONETARY, "en_US");
|
|||||||
// Open CSV file in read & append mode ('a+')
|
// Open CSV file in read & append mode ('a+')
|
||||||
$fp = fopen('vault.csv', 'a+');
|
$fp = fopen('vault.csv', 'a+');
|
||||||
|
|
||||||
|
// Read transactions from CSV
|
||||||
$csvVault = [];
|
$csvVault = [];
|
||||||
$csv = [];
|
$csv = [];
|
||||||
|
|
||||||
@@ -13,11 +14,14 @@ foreach ($lines as $key => $value) {
|
|||||||
$csv[$key] = str_getcsv($value);
|
$csv[$key] = str_getcsv($value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get user log entries
|
||||||
$zarTxn = getLog('zarathos', $csv);
|
$zarTxn = getLog('zarathos', $csv);
|
||||||
$symTxn = getLog('symos', $csv);
|
$symTxn = getLog('symos', $csv);
|
||||||
|
|
||||||
|
// Merge user arrays into transaction array
|
||||||
$txnVault = array_merge($zarTxn, $symTxn);
|
$txnVault = array_merge($zarTxn, $symTxn);
|
||||||
|
|
||||||
|
// Build array of entries not already in the CSV
|
||||||
foreach ($txnVault as $key => $value) {
|
foreach ($txnVault as $key => $value) {
|
||||||
$csvComp = searchForId($value['timestamp'], $csv);
|
$csvComp = searchForId($value['timestamp'], $csv);
|
||||||
|
|
||||||
@@ -26,13 +30,21 @@ foreach ($txnVault as $key => $value) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Loop through file pointer and add a line
|
// Store new trasnactions in CSV
|
||||||
foreach ($csvVault as $fields) {
|
foreach ($csvVault as $fields) {
|
||||||
fputcsv($fp, $fields);
|
fputcsv($fp, $fields);
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose($fp);
|
fclose($fp);
|
||||||
|
|
||||||
|
// Sort the CSV array
|
||||||
|
usort($csv, "custom_sort");
|
||||||
|
|
||||||
|
// Define the custom sort function
|
||||||
|
function custom_sort($a, $b) {
|
||||||
|
return $a[1] > $b[1];
|
||||||
|
}
|
||||||
|
|
||||||
// searchForID(): Serach CSV array for timestamp ID
|
// searchForID(): Serach CSV array for timestamp ID
|
||||||
function searchForId($id, $array) {
|
function searchForId($id, $array) {
|
||||||
foreach ($array as $key => $val) {
|
foreach ($array as $key => $val) {
|
||||||
@@ -58,11 +70,18 @@ function formatMoney($number, $cents = 1) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return '$' . $money;
|
if (substr($number,0,1) == '-') {
|
||||||
|
$money = ltrim($money, '-');
|
||||||
|
$sign = '-$';
|
||||||
|
} else {
|
||||||
|
$sign = '$';
|
||||||
|
}
|
||||||
|
|
||||||
|
return $sign.$money;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// getLog(): Get log entries for user. Uses CSV array for dupe checking. Returns array.
|
// getLog(): Get log entries for user. Returns array.
|
||||||
function getLog($user, $csv) {
|
function getLog($user, $csv) {
|
||||||
$tornURL = 'https://api.torn.com/user/?selections=log&key=';
|
$tornURL = 'https://api.torn.com/user/?selections=log&key=';
|
||||||
$i = 0;
|
$i = 0;
|
||||||
@@ -85,26 +104,12 @@ function getLog($user, $csv) {
|
|||||||
$usrVault[$i]['user'] = $user;
|
$usrVault[$i]['user'] = $user;
|
||||||
$usrVault[$i]['timestamp'] = $entry->timestamp;
|
$usrVault[$i]['timestamp'] = $entry->timestamp;
|
||||||
$usrVault[$i]['operation'] = $entry->title;
|
$usrVault[$i]['operation'] = $entry->title;
|
||||||
$usrVault[$i]['amount'] = $entry->data->withdrawn;
|
$usrVault[$i]['amount'] = '-'.$entry->data->withdrawn;
|
||||||
|
|
||||||
$csvComp = searchForId($entry->timestamp, $csv);
|
|
||||||
|
|
||||||
if ($csvComp) {
|
|
||||||
//echo 'Withdrawal (ID: ' . $entry->timestamp . ') already in vault';
|
|
||||||
}
|
|
||||||
|
|
||||||
// fputcsv($fp, $usrVault[i]);
|
|
||||||
} elseif ($entry->log == 5850) {
|
} elseif ($entry->log == 5850) {
|
||||||
$usrVault[$i]['user'] = $user;
|
$usrVault[$i]['user'] = $user;
|
||||||
$usrVault[$i]['timestamp'] = $entry->timestamp;
|
$usrVault[$i]['timestamp'] = $entry->timestamp;
|
||||||
$usrVault[$i]['operation'] = $entry->title;
|
$usrVault[$i]['operation'] = $entry->title;
|
||||||
$usrVault[$i]['amount'] = $entry->data->deposited;
|
$usrVault[$i]['amount'] = $entry->data->deposited;
|
||||||
|
|
||||||
$csvComp = searchForId($entry->timestamp, $csv);
|
|
||||||
|
|
||||||
if ($csvComp) {
|
|
||||||
//echo 'Deposit (ID: ' . $entry->timestamp . ') already in vault';
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,12 +11,16 @@ include('functions.php');
|
|||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>Torn Vault Tracker</title>
|
<title>Torn Vault Tracker</title>
|
||||||
|
|
||||||
<link rel="stylesheet" href="style.css">
|
<link rel="stylesheet" href="style.css?v=<?php echo filemtime('style.css'); ?>">
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<h1>Torn Vault Tracker</h1>
|
<h1>Torn Vault Tracker</h1>
|
||||||
|
|
||||||
|
<div class="grid">
|
||||||
|
<div class="gridLeft">
|
||||||
|
<h2>Transactions</h2>
|
||||||
|
|
||||||
<table>
|
<table>
|
||||||
<thead>
|
<thead>
|
||||||
<td>User</td>
|
<td>User</td>
|
||||||
@@ -26,16 +30,14 @@ include('functions.php');
|
|||||||
</thead>
|
</thead>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
// Sort the multidimensional array
|
foreach ($csv as $entry) {
|
||||||
usort($csv, "custom_sort");
|
if ($entry[2] == 'Vault withdraw') {
|
||||||
|
$class = 'debit';
|
||||||
// Define the custom sort function
|
} else {
|
||||||
function custom_sort($a, $b) {
|
$class = 'credit';
|
||||||
return $a[1] > $b[1];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($csv as $entry) {
|
echo '<tr class="' . $class . '">';
|
||||||
echo '<tr>';
|
|
||||||
echo '<td>';
|
echo '<td>';
|
||||||
echo $entry[0];
|
echo $entry[0];
|
||||||
echo '</td>';
|
echo '</td>';
|
||||||
@@ -52,6 +54,12 @@ include('functions.php');
|
|||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
</table>
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="gridRght">
|
||||||
|
<h2>Balances</h2>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
@@ -1,3 +1,11 @@
|
|||||||
|
.grid {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(2, 1fr);
|
||||||
|
grid-template-rows: 1fr;
|
||||||
|
grid-column-gap: 0px;
|
||||||
|
grid-row-gap: 0px;
|
||||||
|
}
|
||||||
|
|
||||||
table, tr, td {
|
table, tr, td {
|
||||||
border: 1px solid #333;
|
border: 1px solid #333;
|
||||||
border-collapse: collapse;
|
border-collapse: collapse;
|
||||||
@@ -10,4 +18,8 @@ thead td {
|
|||||||
text-transform: uppercase;
|
text-transform: uppercase;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tr.debit { background-color: #f77e82; }
|
||||||
|
|
||||||
|
tr.credit { background-color: #08817d; color: #fff; }
|
||||||
|
|
||||||
td { padding: .15em 1em; }
|
td { padding: .15em 1em; }
|
||||||
@@ -1,10 +1,11 @@
|
|||||||
Zarathos,1671111614,"Vault withdraw",5000000
|
Zarathos,1671111614,"Vault withdraw",-5000000
|
||||||
Zarathos,1670871611,"Vault withdraw",4000000
|
Zarathos,1670871611,"Vault withdraw",-4000000
|
||||||
Zarathos,1670698196,"Vault withdraw",1000000
|
Zarathos,1670698196,"Vault withdraw",-1000000
|
||||||
Zarathos,1671108304,"Vault deposit",3203752
|
Zarathos,1671108304,"Vault deposit",3203752
|
||||||
Zarathos,1671306102,"Vault withdraw",6000000
|
Zarathos,1671306102,"Vault withdraw",-6000000
|
||||||
Zarathos,1671306091,"Vault deposit",3915202
|
Zarathos,1671306091,"Vault deposit",3915202
|
||||||
Symos,1671136332,"Vault withdraw",750000
|
Symos,1671136332,"Vault withdraw",-750000
|
||||||
Zarathos,1671313291,"Vault withdraw",8000000
|
Zarathos,1671313291,"Vault withdraw",-8000000
|
||||||
Zarathos,1671313285,"Vault deposit",3000000
|
Zarathos,1671313285,"Vault deposit",3000000
|
||||||
Zarathos,1671313280,"Vault deposit",3000000
|
Zarathos,1671313280,"Vault deposit",3000000
|
||||||
|
Zarathos,1671313336,"Vault deposit",4000000
|
||||||
|
|||||||
|
Reference in New Issue
Block a user