From 146799d163eb7ffbc85ebb6b8be9d92ea90700e6 Mon Sep 17 00:00:00 2001 From: iAmShorty Date: Thu, 13 Feb 2014 12:28:26 +0100 Subject: [PATCH 01/12] [FEATURE] show addresses from account --- public/include/pages/admin/wallet.inc.php | 2 + .../templates/mpos/admin/wallet/default.tpl | 27 ++++++++ ...t.tpl-d66ba982-20e0-419c-910c-1d20a0ff2f3a | 68 +++++++++++++++++++ 3 files changed, 97 insertions(+) create mode 100644 public/templates/mpos/admin/wallet/default.tpl-d66ba982-20e0-419c-910c-1d20a0ff2f3a diff --git a/public/include/pages/admin/wallet.inc.php b/public/include/pages/admin/wallet.inc.php index 909d05ef..daf8d050 100644 --- a/public/include/pages/admin/wallet.inc.php +++ b/public/include/pages/admin/wallet.inc.php @@ -11,6 +11,7 @@ if (!$smarty->isCached('master.tpl', $smarty_cache_key)) { $debug->append('No cached version available, fetching from backend', 3); if ($bitcoin->can_connect() === true){ $dBalance = $bitcoin->getbalance(); + $dAddresses = $bitcoin->getaddressesbyaccount(''); $aGetInfo = $bitcoin->getinfo(); if (is_array($aGetInfo) && array_key_exists('newmint', $aGetInfo)) { $dNewmint = $aGetInfo['newmint']; @@ -37,6 +38,7 @@ if (!$smarty->isCached('master.tpl', $smarty_cache_key)) { if (! $dColdCoins = $setting->getValue('wallet_cold_coins')) $dColdCoins = 0; $smarty->assign("UNCONFIRMED", $dBlocksUnconfirmedBalance); $smarty->assign("BALANCE", $dBalance); + $smarty->assign("ADDRESSES", $dAddresses); $smarty->assign("COLDCOINS", $dColdCoins); $smarty->assign("LOCKED", $dLockedBalance); $smarty->assign("NEWMINT", $dNewmint); diff --git a/public/templates/mpos/admin/wallet/default.tpl b/public/templates/mpos/admin/wallet/default.tpl index d3485a60..f5a4d94c 100644 --- a/public/templates/mpos/admin/wallet/default.tpl +++ b/public/templates/mpos/admin/wallet/default.tpl @@ -46,4 +46,31 @@ + + +
+ +





+
+ +
+

Addresses assigned to Default Wallet

+ + + + + + +{assign var=rank value=1} +{section address $ADDRESSES} + + + + +{/section} + +
#Address
{$rank++}{$ADDRESSES[address]}
+
\ No newline at end of file diff --git a/public/templates/mpos/admin/wallet/default.tpl-d66ba982-20e0-419c-910c-1d20a0ff2f3a b/public/templates/mpos/admin/wallet/default.tpl-d66ba982-20e0-419c-910c-1d20a0ff2f3a new file mode 100644 index 00000000..7b8b12d7 --- /dev/null +++ b/public/templates/mpos/admin/wallet/default.tpl-d66ba982-20e0-419c-910c-1d20a0ff2f3a @@ -0,0 +1,68 @@ +
+

Balance Summary

+ + + + + + + + + + + + + + + + + +{if $NEWMINT >= 0} + + + + +{/if} +
Wallet Balance{$BALANCE|number_format:"8"}
Locked for users{$LOCKED|number_format:"8"}
Unconfirmed{$UNCONFIRMED|number_format:"8"}
Liquid Assets{($BALANCE - $LOCKED)|number_format:"8"}
PoS New Mint{$NEWMINT|number_format:"8"}
+
+ +
+

Wallet Information

+ + + + + + + + + + + + + + + + + +
VersionProtocol VersionWallet VersionConnectionsErrors
{$COININFO.version|default:""}{$COININFO.protocolversion|default:""}{$COININFO.walletversion|default:""}{$COININFO.connections|default:""}{$COININFO.errors|default:"OK"}
+
+ +
+

Wallet Address Information

+ + + + + + +{assign var=rank value=1} +{section address $ADDRESSES + + + + +{/section} + +
#Address
#{$ADDRESSES[address]}
+
\ No newline at end of file From 81b8b976d10c51e51031ea11f2d0c9d2c18decb8 Mon Sep 17 00:00:00 2001 From: iAmShorty Date: Thu, 13 Feb 2014 12:29:04 +0100 Subject: [PATCH 02/12] [FEATURE] show addresses from account --- ...t.tpl-d66ba982-20e0-419c-910c-1d20a0ff2f3a | 68 ------------------- 1 file changed, 68 deletions(-) delete mode 100644 public/templates/mpos/admin/wallet/default.tpl-d66ba982-20e0-419c-910c-1d20a0ff2f3a diff --git a/public/templates/mpos/admin/wallet/default.tpl-d66ba982-20e0-419c-910c-1d20a0ff2f3a b/public/templates/mpos/admin/wallet/default.tpl-d66ba982-20e0-419c-910c-1d20a0ff2f3a deleted file mode 100644 index 7b8b12d7..00000000 --- a/public/templates/mpos/admin/wallet/default.tpl-d66ba982-20e0-419c-910c-1d20a0ff2f3a +++ /dev/null @@ -1,68 +0,0 @@ -
-

Balance Summary

- - - - - - - - - - - - - - - - - -{if $NEWMINT >= 0} - - - - -{/if} -
Wallet Balance{$BALANCE|number_format:"8"}
Locked for users{$LOCKED|number_format:"8"}
Unconfirmed{$UNCONFIRMED|number_format:"8"}
Liquid Assets{($BALANCE - $LOCKED)|number_format:"8"}
PoS New Mint{$NEWMINT|number_format:"8"}
-
- -
-

Wallet Information

- - - - - - - - - - - - - - - - - -
VersionProtocol VersionWallet VersionConnectionsErrors
{$COININFO.version|default:""}{$COININFO.protocolversion|default:""}{$COININFO.walletversion|default:""}{$COININFO.connections|default:""}{$COININFO.errors|default:"OK"}
-
- -
-

Wallet Address Information

- - - - - - -{assign var=rank value=1} -{section address $ADDRESSES - - - - -{/section} - -
#Address
#{$ADDRESSES[address]}
-
\ No newline at end of file From 224af2c9d32629c2de0cdcd79dbad8269da55dce Mon Sep 17 00:00:00 2001 From: iAmShorty Date: Thu, 13 Feb 2014 16:29:33 +0100 Subject: [PATCH 03/12] [UPDATE] showing accounts with balance and address --- public/include/pages/admin/wallet.inc.php | 15 +- .../templates/mpos/admin/wallet/default.tpl | 145 ++++++++++-------- 2 files changed, 92 insertions(+), 68 deletions(-) diff --git a/public/include/pages/admin/wallet.inc.php b/public/include/pages/admin/wallet.inc.php index daf8d050..2e150bc9 100644 --- a/public/include/pages/admin/wallet.inc.php +++ b/public/include/pages/admin/wallet.inc.php @@ -11,7 +11,16 @@ if (!$smarty->isCached('master.tpl', $smarty_cache_key)) { $debug->append('No cached version available, fetching from backend', 3); if ($bitcoin->can_connect() === true){ $dBalance = $bitcoin->getbalance(); - $dAddresses = $bitcoin->getaddressesbyaccount(''); + + $dWalletAccounts = $bitcoin->listaccounts(); + $dAddressCount = count($dWalletAccounts); + + $dAccountAddresses = array(); + foreach($dWalletAccounts as $key => $value) + { + $dAccountAddresses[$key] = $bitcoin->getaddressesbyaccount($key); + } + $aGetInfo = $bitcoin->getinfo(); if (is_array($aGetInfo) && array_key_exists('newmint', $aGetInfo)) { $dNewmint = $aGetInfo['newmint']; @@ -38,7 +47,9 @@ if (!$smarty->isCached('master.tpl', $smarty_cache_key)) { if (! $dColdCoins = $setting->getValue('wallet_cold_coins')) $dColdCoins = 0; $smarty->assign("UNCONFIRMED", $dBlocksUnconfirmedBalance); $smarty->assign("BALANCE", $dBalance); - $smarty->assign("ADDRESSES", $dAddresses); + $smarty->assign("ADDRESSCOUNT", $dAddressCount); + $smarty->assign("ACCOUNTADDRESSES", $dAccountAddresses); + $smarty->assign("ACCOUNTS", $dWalletAccounts); $smarty->assign("COLDCOINS", $dColdCoins); $smarty->assign("LOCKED", $dLockedBalance); $smarty->assign("NEWMINT", $dNewmint); diff --git a/public/templates/mpos/admin/wallet/default.tpl b/public/templates/mpos/admin/wallet/default.tpl index f5a4d94c..f16a6dba 100644 --- a/public/templates/mpos/admin/wallet/default.tpl +++ b/public/templates/mpos/admin/wallet/default.tpl @@ -1,76 +1,89 @@ -
-

Balance Summary

- - - - - - - - - - - - - - - - - +
+

Wallet Information - Number of Accounts in Wallet: {$ADDRESSCOUNT|default:"0"}

+ +
+

Balance Summary

+
Wallet Balance{$BALANCE|number_format:"8"}
Locked for users{$LOCKED|number_format:"8"}
Unconfirmed{$UNCONFIRMED|number_format:"8"}
Liquid Assets{($BALANCE - $LOCKED)|number_format:"8"}
+ + + + + + + + + + + + + + + + {if $NEWMINT >= 0} - - - - + + + + {/if} -
Wallet Balance{$BALANCE|number_format:"8"}
Locked for users{$LOCKED|number_format:"8"}
Unconfirmed{$UNCONFIRMED|number_format:"8"}
Liquid Assets{($BALANCE - $LOCKED)|number_format:"8"}
PoS New Mint{$NEWMINT|number_format:"8"}
PoS New Mint{$NEWMINT|number_format:"8"}
+ +
+ +
+

Network Information

+ + + + + + + + + + + + + + + + + +
VersionProtocol VersionWallet VersionConnectionsErrors
{$COININFO.version|default:""}{$COININFO.protocolversion|default:""}{$COININFO.walletversion|default:""}{$COININFO.connections|default:""}{$COININFO.errors|default:"OK"}
+
-
-

Wallet Information

- - - - - - - - - +{foreach key=NAME item=VALUE from=$ACCOUNTS} +
+

Account: {$NAME|default:"Default"}

+
+

Balance Info

+
VersionProtocol VersionWallet VersionConnectionsErrors
- - - - - + + - -
{$COININFO.version|default:""}{$COININFO.protocolversion|default:""}{$COININFO.walletversion|default:""}{$COININFO.connections|default:""}{$COININFO.errors|default:"OK"}Balance{$VALUE|number_format:"8"}
+ +
+ +{foreach key=ACCOUNT item=ADDRESS from=$ACCOUNTADDRESSES} +{if $ACCOUNT == $NAME} +
+

Addresses assigned to Account {$ACCOUNT|default:"Default"}

+ + +{foreach from=$ACCOUNTADDRESSES[$ACCOUNT] key=ACCOUNT1 item=ADDRESS1} + + + +{/foreach} + +
{$ADDRESS1}
+
+{/if} +{/foreach} +{/foreach} + -
- -





-
-
-

Addresses assigned to Default Wallet

- - - - - - -{assign var=rank value=1} -{section address $ADDRESSES} - - - - -{/section} - -
#Address
{$rank++}{$ADDRESSES[address]}
-
\ No newline at end of file From 1fd749985689c35d6345641e0ca7cefdf0c461a1 Mon Sep 17 00:00:00 2001 From: iAmShorty Date: Thu, 13 Feb 2014 17:28:47 +0100 Subject: [PATCH 04/12] [UPDATE] style changes --- .../templates/mpos/admin/wallet/default.tpl | 53 ++++++++++--------- 1 file changed, 27 insertions(+), 26 deletions(-) diff --git a/public/templates/mpos/admin/wallet/default.tpl b/public/templates/mpos/admin/wallet/default.tpl index f16a6dba..505877f5 100644 --- a/public/templates/mpos/admin/wallet/default.tpl +++ b/public/templates/mpos/admin/wallet/default.tpl @@ -1,5 +1,5 @@
-

Wallet Information - Number of Accounts in Wallet: {$ADDRESSCOUNT|default:"0"}

+

Wallet Information

Balance Summary

@@ -52,38 +52,39 @@
+{if $ADDRESSCOUNT > 1} +
+

Number of Accounts in Wallet: {$ADDRESSCOUNT|default:"0"}

{foreach key=NAME item=VALUE from=$ACCOUNTS} -
-

Account: {$NAME|default:"Default"}

-

Balance Info

- - - - - -
Balance{$VALUE|number_format:"8"}
-
- +

Account: {$NAME|default:"Default"}

+
+

Balance Info

+ + + + + +
Balance{$VALUE|number_format:"8"}
+
{foreach key=ACCOUNT item=ADDRESS from=$ACCOUNTADDRESSES} {if $ACCOUNT == $NAME} -
-

Addresses assigned to Account {$ACCOUNT|default:"Default"}

- - +
+

Addresses assigned to Account {$ACCOUNT|default:"Default"}

+
+ {foreach from=$ACCOUNTADDRESSES[$ACCOUNT] key=ACCOUNT1 item=ADDRESS1} - - - + + + {/foreach} - -
{$ADDRESS1}
{$ADDRESS1}
-
+ + +
{/if} {/foreach} - -
+ {/foreach} - - + +{/if} From 0ef5fdedefe347be8d88e4ba1783dbab1c87915f Mon Sep 17 00:00:00 2001 From: iAmShorty Date: Fri, 14 Feb 2014 17:08:22 +0100 Subject: [PATCH 05/12] [UPDATE] small changes --- public/templates/mpos/admin/wallet/default.tpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/templates/mpos/admin/wallet/default.tpl b/public/templates/mpos/admin/wallet/default.tpl index 505877f5..41af9626 100644 --- a/public/templates/mpos/admin/wallet/default.tpl +++ b/public/templates/mpos/admin/wallet/default.tpl @@ -30,7 +30,7 @@
-

Network Information

+

Wallet Status

From 6f1f56abb6ed9a81dee4fe930ae97b0fbc877372 Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Fri, 14 Feb 2014 17:21:52 +0100 Subject: [PATCH 06/12] [ADDED] getrealbalance wrapper for payouts During payouts, we must ensure our wallets main accounts has the funds to payout users. Hence we implement a wrapper method: * If account count == 1 we only have main account, return getbalance * Else return our main accounts balance - calculated unconfirmed This should keep getbalance untouched when used on other places but gives our payout processing a proper main account balance. It's mostly a wrapper for those wallets running multiple accounts in one wallet. They are warned on the front-end already but this ensure payouts process properly. Fixes #1755 once merged. --- cronjobs/payouts.php | 4 ++-- .../include/classes/bitcoinwrapper.class.php | 21 +++++++++++++------ 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/cronjobs/payouts.php b/cronjobs/payouts.php index c96af16c..24b2629a 100755 --- a/cronjobs/payouts.php +++ b/cronjobs/payouts.php @@ -41,7 +41,7 @@ $sendmanyAvailable = ((strpos($bitcoin->help('sendmany'), 'unknown') === FALSE) if ($sendmanyAvailable) $log->logDebug(' sendmany available in coind help command'); -if (!$dWalletBalance = $bitcoin->getbalance()) +if (!$dWalletBalance = $bitcoin->getrealbalance()) $dWalletBalance = 0; // Fetch outstanding manual-payouts @@ -113,7 +113,7 @@ if ($setting->getValue('disable_manual_payouts') != 1 && $aManualPayouts) { } } -if (!$dWalletBalance = $bitcoin->getbalance()) +if (!$dWalletBalance = $bitcoin->getrealbalance()) $dWalletBalance = 0; // Fetch outstanding auto-payouts diff --git a/public/include/classes/bitcoinwrapper.class.php b/public/include/classes/bitcoinwrapper.class.php index ebe1c470..010b455f 100644 --- a/public/include/classes/bitcoinwrapper.class.php +++ b/public/include/classes/bitcoinwrapper.class.php @@ -31,17 +31,26 @@ class BitcoinWrapper extends BitcoinClient { if ($data = $this->memcache->get(__FUNCTION__)) return $data; return $this->memcache->setCache(__FUNCTION__, parent::getmininginfo(), 30); } - // Wrapper to check our wallet balance from the DEFAULT account only - public function getbalance() { - $this->oDebug->append("STA " . __METHOD__, 4); - $aAccounts = parent::listaccounts(); - return $aAccounts['']; - } public function getblockcount() { $this->oDebug->append("STA " . __METHOD__, 4); if ($data = $this->memcache->get(__FUNCTION__)) return $data; return $this->memcache->setCache(__FUNCTION__, parent::getblockcount(), 30); } + // Wrapper method to get the real main account balance + public function getrealbalance() { + $this->oDebug->append("STA " . __METHOD__, 4); + $aAccounts = parent::listaccounts(); + $dBalance = parent::getbalance(); + // Account checks + if (count($aAccounts) == 1) { + // We only have a single account so getbalance will be fine + return $dBalance; + } else { + $dMainBalance = $aAccounts['']; + $dUnconfirmed = $dMainBalance - $dBalance; + return $dMainBalance - $dUnconfirmed; + } + } public function getdifficulty() { $this->oDebug->append("STA " . __METHOD__, 4); if ($data = $this->memcache->get(__FUNCTION__)) return $data; From 691e1e60cb65d00e9ecb663510eb177c14fd3109 Mon Sep 17 00:00:00 2001 From: iAmShorty Date: Fri, 14 Feb 2014 20:49:42 +0100 Subject: [PATCH 07/12] Update bitcoinwrapper.class.php --- public/include/classes/bitcoinwrapper.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/public/include/classes/bitcoinwrapper.class.php b/public/include/classes/bitcoinwrapper.class.php index 010b455f..126cbb2b 100644 --- a/public/include/classes/bitcoinwrapper.class.php +++ b/public/include/classes/bitcoinwrapper.class.php @@ -48,7 +48,8 @@ class BitcoinWrapper extends BitcoinClient { } else { $dMainBalance = $aAccounts['']; $dUnconfirmed = $dMainBalance - $dBalance; - return $dMainBalance - $dUnconfirmed; + //return $dMainBalance - $dUnconfirmed; + return $dMainBalance - abs($dUnconfirmed) } } public function getdifficulty() { From b0baa29a1fdd184c72859337e211b2468963c66a Mon Sep 17 00:00:00 2001 From: iAmShorty Date: Fri, 14 Feb 2014 21:03:30 +0100 Subject: [PATCH 08/12] [FIX] fix for negative balance using php abs() should do the trick with negative balance --- public/include/classes/bitcoinwrapper.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/public/include/classes/bitcoinwrapper.class.php b/public/include/classes/bitcoinwrapper.class.php index 126cbb2b..a09c30e4 100644 --- a/public/include/classes/bitcoinwrapper.class.php +++ b/public/include/classes/bitcoinwrapper.class.php @@ -47,7 +47,8 @@ class BitcoinWrapper extends BitcoinClient { return $dBalance; } else { $dMainBalance = $aAccounts['']; - $dUnconfirmed = $dMainBalance - $dBalance; + //$dUnconfirmed = $dMainBalance - $dBalance; + $dUnconfirmed = $dMainBalance - abs($dBalance); //return $dMainBalance - $dUnconfirmed; return $dMainBalance - abs($dUnconfirmed) } From 2acf83894d7de42ca2a60fb73f71a8834aff7319 Mon Sep 17 00:00:00 2001 From: iAmShorty Date: Sat, 15 Feb 2014 13:55:28 +0100 Subject: [PATCH 09/12] only show new table if accounts > 1 --- public/templates/mpos/admin/wallet/default.tpl | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/public/templates/mpos/admin/wallet/default.tpl b/public/templates/mpos/admin/wallet/default.tpl index 41af9626..7884cd9f 100644 --- a/public/templates/mpos/admin/wallet/default.tpl +++ b/public/templates/mpos/admin/wallet/default.tpl @@ -1,6 +1,7 @@ +{if $ADDRESSCOUNT > 1}

Wallet Information

- +{/if}

Balance Summary

Version
@@ -50,9 +51,9 @@
+{if $ADDRESSCOUNT > 1} -{if $ADDRESSCOUNT > 1}

Number of Accounts in Wallet: {$ADDRESSCOUNT|default:"0"}

{foreach key=NAME item=VALUE from=$ACCOUNTS} From 146b56259b46301cd645f9a2b3d32785e50d2b70 Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Sat, 15 Feb 2014 19:01:25 +0100 Subject: [PATCH 10/12] [IMPROVED] Combined cleanup tasks into single PHP * [IMPROVED] Logging format for all cleanup tasks * [UPDATED] Cron shellescripts * [UPDATE] Cron Monitoring Page * [DELETED] Old `*_cleanup.php` scripts --- cronjobs/archive_cleanup.php | 39 ---------- cronjobs/notification_cleanup.php | 38 ---------- cronjobs/run-crons.sh | 2 +- cronjobs/run-maintenance.sh | 2 +- cronjobs/tables_cleanup.php | 79 +++++++++++++++++++++ cronjobs/token_cleanup.php | 39 ---------- public/include/config/monitor_crons.inc.php | 2 +- 7 files changed, 82 insertions(+), 119 deletions(-) delete mode 100755 cronjobs/archive_cleanup.php delete mode 100755 cronjobs/notification_cleanup.php create mode 100755 cronjobs/tables_cleanup.php delete mode 100755 cronjobs/token_cleanup.php diff --git a/cronjobs/archive_cleanup.php b/cronjobs/archive_cleanup.php deleted file mode 100755 index 350d7c3d..00000000 --- a/cronjobs/archive_cleanup.php +++ /dev/null @@ -1,39 +0,0 @@ -#!/usr/bin/php -purgeArchive(); -if ($affected_rows === false) { - $log->logError("Failed to delete archived shares, not critical but should be checked: " . $share->getCronError()); - $monitoring->endCronjob($cron_name, 'E0008', 0, false, false); -} else { - $log->logDebug("Deleted $affected_rows archived shares this run"); -} - -// Cron cleanup and monitoring -require_once('cron_end.inc.php'); -?> diff --git a/cronjobs/notification_cleanup.php b/cronjobs/notification_cleanup.php deleted file mode 100755 index 566b226f..00000000 --- a/cronjobs/notification_cleanup.php +++ /dev/null @@ -1,38 +0,0 @@ -#!/usr/bin/php -cleanupNotifications($setting->getValue('notifications_cleanup_time', 7))) { - $notification->deleted == 0 ? $log->logDebug('Did not delete any old notifications') : $log->logInfo('Deleted ' . $notification->deleted . ' notifications'); -} else { - $log->logError('Failed to delete notifications: ' . $notification->getCronError()); - $monitoring->endCronjob($cron_name, 'E0074', 0, false, false); -} - -// Cron cleanup and monitoring -require_once('cron_end.inc.php'); -?> diff --git a/cronjobs/run-crons.sh b/cronjobs/run-crons.sh index 66c59c1f..d1cca24b 100755 --- a/cronjobs/run-crons.sh +++ b/cronjobs/run-crons.sh @@ -10,7 +10,7 @@ PHP_BIN=$( which php ) # List of cruns to execute -CRONS="findblock.php proportional_payout.php pplns_payout.php pps_payout.php blockupdate.php payouts.php tickerupdate.php notifications.php statistics.php token_cleanup.php archive_cleanup.php notification_cleanup.php" +CRONS="findblock.php proportional_payout.php pplns_payout.php pps_payout.php blockupdate.php payouts.php tickerupdate.php notifications.php statistics.php tables_cleanup.php" # Output additional runtime information VERBOSE="0" diff --git a/cronjobs/run-maintenance.sh b/cronjobs/run-maintenance.sh index 1161f4cd..54799323 100755 --- a/cronjobs/run-maintenance.sh +++ b/cronjobs/run-maintenance.sh @@ -10,7 +10,7 @@ PHP_BIN=$( which php ) # List of cruns to execute -CRONS="tickerupdate.php notifications.php token_cleanup.php archive_cleanup.php notification_cleanup.php" +CRONS="tickerupdate.php notifications.php tables_cleanup.php" # Output additional runtime information VERBOSE="0" diff --git a/cronjobs/tables_cleanup.php b/cronjobs/tables_cleanup.php new file mode 100755 index 00000000..04386133 --- /dev/null +++ b/cronjobs/tables_cleanup.php @@ -0,0 +1,79 @@ +#!/usr/bin/php +logInfo(sprintf($strLogMask, 'Process', 'Affected', 'Runtime', 'Status', 'Message')); + +// Cleanup old notifications +$start = microtime(true); +$status = 'OK'; +$message = ''; +$affected = 0; +if ($notification->cleanupNotifications($setting->getValue('notifications_cleanup_time', 7))) { + $affected = $notification->deleted; + $affected == 0 ? $message = 'No notifications deleted' : $message = 'Deleted notifications older than ' . $setting->getValue('notifications_cleanup_time', 7) . ' days'; +} else { + $message = 'Failed to delete notifications: ' . $notification->getCronError(); + $status = 'ERROR'; + $monitoring->endCronjob($cron_name, 'E0074', 0, false, false); +} +$log->logInfo(sprintf($strLogMask, 'cleanupNotifications', $affected, number_format(microtime(true) - $start, 3), $status, $message)); + +// Cleanup old expired tokens +$start = microtime(true); +$status = 'OK'; +$message = ''; +$affected = 0; +if ($oToken->cleanupTokens()) { + $affected = $oToken->deleted; + $affected == 0 ? $message = 'No tokens deleted' : $message = 'Deleted expired tokens'; +} else { + $message = 'Failed to delete notifications: ' . $oToken->getCronError(); + $status = 'ERROR'; + $monitoring->endCronjob($cron_name, 'E0074', 0, false, false); +} +$log->logInfo(sprintf($strLogMask, 'cleanupTokens', $affected, number_format(microtime(true) - $start, 3), $status, $message)); + +// Clenaup shares archive +$start = microtime(true); +$status = 'OK'; +$message = ''; +$affected = $share->purgeArchive(); +if ($affected === false) { + $message = 'Failed to delete notifications: ' . $oToken->getCronError(); + $status = 'ERROR'; + $monitoring->endCronjob($cron_name, 'E0008', 0, false, false); +} else { + $affected == 0 ? $message = 'No shares deleted' : $message = 'Deleted old shares'; +} +$log->logInfo(sprintf($strLogMask, 'purgeArchive', $affected, number_format(microtime(true) - $start, 3), $status, $message)); + + +// Cron cleanup and monitoring +require_once('cron_end.inc.php'); +?> diff --git a/cronjobs/token_cleanup.php b/cronjobs/token_cleanup.php deleted file mode 100755 index dec00bd9..00000000 --- a/cronjobs/token_cleanup.php +++ /dev/null @@ -1,39 +0,0 @@ -#!/usr/bin/php -cleanupTokens()) { - $oToken->deleted == 0 ? $log->logDebug('Did not find any expired tokens') : $log->logInfo('Deleted ' . $oToken->deleted . ' expired tokens'); -} else { - $log->logError('Failed to delete expired tokens: ' . $oToken->getCronError()); - // Treat as critical since tokens like password resets will never expire - $monitoring->endCronjob($cron_name, 'E0074', 1, true, true); -} - -// Cron cleanup and monitoring -require_once('cron_end.inc.php'); -?> diff --git a/public/include/config/monitor_crons.inc.php b/public/include/config/monitor_crons.inc.php index 5b69d6f1..98b8eb0f 100644 --- a/public/include/config/monitor_crons.inc.php +++ b/public/include/config/monitor_crons.inc.php @@ -2,7 +2,7 @@ // Small helper array that may be used on some page controllers to // fetch the crons we wish to monitor -$aMonitorCrons = array('statistics','payouts','token_cleanup','archive_cleanup','notification_cleanup','blockupdate','findblock','notifications','tickerupdate'); +$aMonitorCrons = array('statistics','payouts','tables_cleanup','blockupdate','findblock','notifications','tickerupdate'); switch ($config['payout_system']) { case 'pplns': From d1f3f5d01d781de1bb554516b82eb365b3cdf476 Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Sat, 15 Feb 2014 19:17:12 +0100 Subject: [PATCH 11/12] [UPDATE] Return negative balance if main is negative --- public/include/classes/bitcoinwrapper.class.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/public/include/classes/bitcoinwrapper.class.php b/public/include/classes/bitcoinwrapper.class.php index a09c30e4..f72f3933 100644 --- a/public/include/classes/bitcoinwrapper.class.php +++ b/public/include/classes/bitcoinwrapper.class.php @@ -47,10 +47,9 @@ class BitcoinWrapper extends BitcoinClient { return $dBalance; } else { $dMainBalance = $aAccounts['']; - //$dUnconfirmed = $dMainBalance - $dBalance; + if ($dMainBalance < 0) return $dMainBalance; $dUnconfirmed = $dMainBalance - abs($dBalance); - //return $dMainBalance - $dUnconfirmed; - return $dMainBalance - abs($dUnconfirmed) + return $dMainBalance - abs($dUnconfirmed); } } public function getdifficulty() { From 45d79d0eab86f0be8e81d8aa2d6fe14ad88730b7 Mon Sep 17 00:00:00 2001 From: iAmShorty Date: Sat, 15 Feb 2014 23:17:37 +0100 Subject: [PATCH 12/12] [UPDATE] style change for addresses --- public/templates/mpos/admin/wallet/default.tpl | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/public/templates/mpos/admin/wallet/default.tpl b/public/templates/mpos/admin/wallet/default.tpl index 7884cd9f..37cf18d2 100644 --- a/public/templates/mpos/admin/wallet/default.tpl +++ b/public/templates/mpos/admin/wallet/default.tpl @@ -57,9 +57,9 @@

Number of Accounts in Wallet: {$ADDRESSCOUNT|default:"0"}

{foreach key=NAME item=VALUE from=$ACCOUNTS} -
+

Account: {$NAME|default:"Default"}

-
+

Balance Info

@@ -75,9 +75,13 @@
{foreach from=$ACCOUNTADDRESSES[$ACCOUNT] key=ACCOUNT1 item=ADDRESS1} - +{if $ADDRESS1@iteration is even by 1} +{else} + + +{/if} {/foreach}
{$ADDRESS1}
{$ADDRESS1}