Compare commits
18
Commits
887d758196
...
6e63c37071
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6e63c37071 | ||
|
|
b13d9294da | ||
|
|
28eecb304a | ||
|
|
31435f5520 | ||
|
|
85e5724c23 | ||
|
|
66f1da90e4 | ||
|
|
ce8cea41b9 | ||
|
|
6c24b59894 | ||
|
|
d7dfcdf3f9 | ||
|
|
e9a92be0c6 | ||
|
|
8ef4e53b49 | ||
|
|
9864688aae | ||
|
|
6e63f963b1 | ||
|
|
3e8b919471 | ||
|
|
6b6ca19b1c | ||
|
|
2a3edacc63 | ||
|
|
c5876d6080 | ||
|
|
38973bbfc5 |
@@ -14,17 +14,23 @@ Uses the [Torn API](https://www.torn.com/api.html) to pul the most recent vault
|
|||||||
|
|
||||||
### Installing
|
### Installing
|
||||||
|
|
||||||
* Create folder in your server's web root, for example, 'tvt'
|
* Create folder in your server's web root, for example, 'tvt'.
|
||||||
* Upload/clone this repo into your folder
|
* Upload/clone this repo into your folder.
|
||||||
* Edit `functions.php` to add API keys for you and your spouse
|
* Edit `functions.php` to add API keys and Torn user names for you and your spouse.
|
||||||
* Open the tracker in any web browser
|
* Edit `vault.csv` to set initial balances for each user (see notes below).
|
||||||
|
* Open the tracker in any web browser.
|
||||||
|
* Style as you see fit in `style.css` (Optional, but if you make something cool, let me know!).
|
||||||
|
|
||||||
### Automating the API requests (TK)
|
### Initial vault balance(s)
|
||||||
|
Currently, there's no way to get past vault transactions via the API. If you're starting new, you can use the vault balance before your spouse adds their first deposit. For existing vaults, you'll need to figure out the balances the hard way. Once you have the balances, put them into the `vault.csv` with the proper user names. The timestamp field doesn't matter, and can be left at the current value.
|
||||||
|
|
||||||
|
### Automating transaction updates
|
||||||
|
|
||||||
|
I recommend using an external site monitoring service such as [cronitor.io](https://cronitor.io) set to check the URL of your server. A check rate of 15 minutes should be more than enough, since you can always force a refresh by simply opening the site in your browser.
|
||||||
|
|
||||||
## Authors
|
## Authors
|
||||||
|
|
||||||
Keith Solomon
|
Keith Solomon / [ZarathosX75](https://www.torn.com/profiles.php?XID=2606457) on [Torn](https://torn.com/)
|
||||||
[KeithSolomon.net](https://keithsolomon.net/)
|
|
||||||
|
|
||||||
## Version History
|
## Version History
|
||||||
|
|
||||||
|
|||||||
+17
-9
@@ -1,4 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
// Set usernames and keys here
|
||||||
|
const USER1_KEY = 'user1Key';
|
||||||
|
const USER2_KEY = 'user2Key';
|
||||||
|
|
||||||
|
const USER1_NAME = 'user1';
|
||||||
|
const USER2_NAME = 'user2';
|
||||||
|
|
||||||
|
// Set locale for monetary functions.
|
||||||
setlocale(LC_MONETARY, "en_US");
|
setlocale(LC_MONETARY, "en_US");
|
||||||
|
|
||||||
// Open CSV file in read & append mode ('a+')
|
// Open CSV file in read & append mode ('a+')
|
||||||
@@ -14,12 +22,12 @@ foreach ($lines as $key => $value) {
|
|||||||
$csv[$key] = str_getcsv($value);
|
$csv[$key] = str_getcsv($value);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get user log entries
|
// Get user log entries.
|
||||||
$zarTxn = getLog('zarathos', $csv);
|
$user1Txn = getLog(USER1_NAME, $csv);
|
||||||
$symTxn = getLog('symos', $csv);
|
$user2Txn = getLog(USER2_NAME, $csv);
|
||||||
|
|
||||||
// Merge user arrays into transaction array
|
// Merge user arrays into transaction array
|
||||||
$txnVault = array_merge($zarTxn, $symTxn);
|
$txnVault = array_merge($user1Txn, $user2Txn);
|
||||||
|
|
||||||
// Build array of entries not already in the CSV
|
// Build array of entries not already in the CSV
|
||||||
foreach ($txnVault as $key => $value) {
|
foreach ($txnVault as $key => $value) {
|
||||||
@@ -78,12 +86,12 @@ 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;
|
||||||
|
|
||||||
if ($user == 'zarathos') {
|
if ($user == USER1_NAME) {
|
||||||
$usrKey = 'LDtibInYMdgVnM9n';
|
$usrKey = USER1_KEY;
|
||||||
$user = 'Zarathos';
|
$user = USER1_NAME;
|
||||||
} else {
|
} else {
|
||||||
$usrKey = 'lne9TZLuqvFXtK3V';
|
$usrKey = USER2_KEY;
|
||||||
$user = 'Symos';
|
$user = USER2_NAME;
|
||||||
}
|
}
|
||||||
|
|
||||||
$usrURL = $tornURL . $usrKey;
|
$usrURL = $tornURL . $usrKey;
|
||||||
|
|||||||
Reference in New Issue
Block a user