Compare commits

...
18 Commits
Author SHA1 Message Date
Keith Solomon 6e63c37071 - Update README 2022-12-31 13:24:10 -06:00
Keith Solomon b13d9294da - Update vault.csv with default values
- Update README with vault info
2022-12-31 13:22:37 -06:00
Keith Solomon 28eecb304a - Update functions.php 2022-12-31 12:57:25 -06:00
Keith Solomon 31435f5520 - Update functions.php 2022-12-31 12:51:07 -06:00
Keith Solomon 85e5724c23 - Update functions.php for generic user names/keys
- Update README
2022-12-31 12:16:38 -06:00
Keith Solomon 66f1da90e4 - Add Torn profile link to README 2022-12-31 11:55:15 -06:00
Keith Solomon ce8cea41b9 - Add Torn profile link to README 2022-12-31 11:54:08 -06:00
Keith Solomon 6c24b59894 Add Torn profile link to README 2022-12-31 11:51:19 -06:00
Keith Solomon d7dfcdf3f9 Remove old project files 2022-12-31 11:48:07 -06:00
Keith Solomon e9a92be0c6 Git fix 2022-12-31 11:44:09 -06:00
Keith Solomon 8ef4e53b49 Merge pull request #2 from ksolomon/API-Connection
API connection
2022-09-27 09:53:05 -05:00
Keith Solomon 9864688aae Feat(api): Correct Log URL
Switch to correct API URL for the Log call

Issue/Task ID: 1
2022-09-27 09:50:21 -05:00
Keith Solomon 6e63f963b1 Feat(api): Change variable names
Changed $json in each API call to $jsonMoney and $jsonLog

Issue/Task ID: 1
2022-09-27 09:16:52 -05:00
Keith Solomon 3e8b919471 Feat(api): Connect to API
Set up and connect to both potential API sources.

Issue/Task ID: 1
2022-09-27 09:07:59 -05:00
Keith Solomon 6b6ca19b1c Docs(notes): Switch to plain text 2022-09-27 09:00:25 -05:00
Keith Solomon 2a3edacc63 Chore(*): Site notes 2022-09-27 08:39:54 -05:00
Keith Solomon c5876d6080 Chore(*): Initial commit 2022-09-27 08:06:45 -05:00
Keith Solomon 38973bbfc5 Initial commit 2022-09-27 08:03:34 -05:00
3 changed files with 32 additions and 16 deletions
+13 -7
View File
@@ -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
View File
@@ -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;
+2
View File
@@ -0,0 +1,2 @@
User1,1663917355,Initial balance,1000000
User2,1663917355,Initial balance,1000000
1 User1 1663917355 Initial balance 1000000
1 User1 1663917355 Initial balance 1000000
2 User2 1663917355 Initial balance 1000000