diff --git a/cronjobs/auto_payout.php b/cronjobs/auto_payout.php index 7e5609fc..aaf715e0 100755 --- a/cronjobs/auto_payout.php +++ b/cronjobs/auto_payout.php @@ -22,8 +22,10 @@ limitations under the License. // Include all settings and classes require_once('shared.inc.php'); +verbose("Running auto-payouts ..."); + if ($bitcoin->can_connect() !== true) { - verbose("Unable to connect to RPC server, exiting"); + verbose(" unable to connect to RPC server, exiting\n"); exit(1); } @@ -33,14 +35,17 @@ $setting->setValue('auto_payout_active', 1); // Fetch all users with setup AP $users = $user->getAllAutoPayout(); +// Quick summary +verbose(" found " . count($users) . " queued payout(s)\n"); + // Go through users and run transactions if (! empty($users)) { - verbose("UserID\tUsername\tBalance\tThreshold\tAddress\t\t\t\t\tStatus\n\n"); + verbose("\tUserID\tUsername\tBalance\tThreshold\tAddress\t\t\t\t\tStatus\n\n"); foreach ($users as $aUserData) { $aBalance = $transaction->getBalance($aUserData['id']); $dBalance = $aBalance['confirmed']; - verbose($aUserData['id'] . "\t" . $aUserData['username'] . "\t" . $dBalance . "\t" . $aUserData['ap_threshold'] . "\t\t" . $aUserData['coin_address'] . "\t"); + verbose("\t" . $aUserData['id'] . "\t" . $aUserData['username'] . "\t" . $dBalance . "\t" . $aUserData['ap_threshold'] . "\t\t" . $aUserData['coin_address'] . "\t"); // Only run if balance meets threshold and can pay the potential transaction fee if ($dBalance > $aUserData['ap_threshold'] && $dBalance > $config['txfee']) { @@ -80,7 +85,7 @@ if (! empty($users)) { } } } else { - verbose("No user has configured their AP > 0\n"); + verbose(" no user has configured their AP > 0\n"); } // Mark this job as inactive diff --git a/cronjobs/notifications.php b/cronjobs/notifications.php index ec61002a..61a608ab 100755 --- a/cronjobs/notifications.php +++ b/cronjobs/notifications.php @@ -22,35 +22,51 @@ limitations under the License. // Include all settings and classes require_once('shared.inc.php'); +verbose("Running system notifications\n"); + +verbose(" IDLE Worker Notifications ..."); // Find all IDLE workers $aWorkers = $worker->getAllIdleWorkers(); if (empty($aWorkers)) { - verbose("No idle workers found\n"); + verbose(" no idle workers found\n"); } else { + verbose(" found " . count($aWorkers) . " IDLE workers\n"); foreach ($aWorkers as $aWorker) { $aData = $aWorker; $aData['username'] = $user->getUserName($aWorker['account_id']); $aData['subject'] = 'IDLE Worker : ' . $aWorker['username']; $aData['worker'] = $aWorker['username']; $aData['email'] = $user->getUserEmail($aData['username']); - if (!$notification->sendNotification($aWorker['account_id'], 'idle_worker', $aData)) - verbose($notification->getError() . "\n"); - } -} - -// We notified, lets check which recovered -$aNotifications = $notification->getAllActive('idle_worker'); -if (!empty($aNotifications)) { - foreach ($aNotifications as $aNotification) { - $aData = json_decode($aNotification['data'], true); - $aWorker = $worker->getWorker($aData['id']); - if ($aWorker['active'] == 1) { - if ($notification->setInactive($aNotification['id'])) { - verbose("Marked notification " . $aNotification['id'] . " as inactive\n"); - } else { - verbose("Failed to set notification inactive for " . $aWorker['username'] . "\n"); - } + verbose(" " . $aWorker['username'] . "..."); + if (!$notification->sendNotification($aWorker['account_id'], 'idle_worker', $aData)) { + verbose(" " . $notification->getError() . "\n"); + } else { + verbose(" sent\n"); } } } + + +verbose(" Reset IDLE Worker Notifications ..."); +// We notified, lets check which recovered +$aNotifications = $notification->getAllActive('idle_worker'); +if (!empty($aNotifications)) { + verbose(" found " . count($aNotifications) . " active notification(s)\n"); + foreach ($aNotifications as $aNotification) { + $aData = json_decode($aNotification['data'], true); + $aWorker = $worker->getWorker($aData['id']); + verbose(" " . $aWorker['username'] . " ..."); + if ($aWorker['active'] == 1) { + if ($notification->setInactive($aNotification['id'])) { + verbose(" updated #" . $aNotification['id'] . " for " . $aWorker['username'] . " as inactive\n"); + } else { + verbose(" failed to update #" . $aNotification['id'] . " for " . $aWorker['username'] . "\n"); + } + } else { + verbose(" still inactive\n"); + } + } +} else { + verbose(" no active IDLE worker notifications\n"); +} ?> diff --git a/cronjobs/statistics.php b/cronjobs/statistics.php index d4fe65e0..eefa9d70 100755 --- a/cronjobs/statistics.php +++ b/cronjobs/statistics.php @@ -25,25 +25,37 @@ require_once('shared.inc.php'); // Fetch all cachable values but disable fetching from cache $statistics->setGetCache(false); +// Verbose output +verbose("Running statistical cache updates\n"); + // Since fetching from cache is disabled, overwrite our stats +verbose(" getRoundShares ..."); if (!$statistics->getRoundShares()) - verbose("Unable to fetch and store current round shares\n"); + verbose(" update failed"); +verbose("\n getTopContributors shares ..."); if (!$statistics->getTopContributors('shares')) - verbose("Unable to fetch and store top share contributors\n"); + verbose(" update failed"); +verbose("\n getTopContributors hashes ..."); if (!$statistics->getTopContributors('hashes')) - verbose("Unable to fetch and store top hashrate contributors\n"); + verbose(" update failed"); +verbose("\n getCurrentHashrate ..."); if (!$statistics->getCurrentHashrate()) - verbose("Unable to fetch and store pool hashrate\n"); + verbose(" update failed"); // Admin specific statistics, we cache the global query due to slowness +verbose("\n getAllUserStats ..."); if (!$statistics->getAllUserStats('%')) - verbose("Unable to fetch and store admin panel full user list\n"); + verbose(" update failed"); +verbose("\n"); // Per user share statistics based on all shares submitted +verbose(" getUserShares ...\n"); $stmt = $mysqli->prepare("SELECT DISTINCT SUBSTRING_INDEX( `username` , '.', 1 ) AS username FROM " . $share->getTableName()); if ($stmt && $stmt->execute() && $result = $stmt->get_result()) { while ($row = $result->fetch_assoc()) { + verbose(" " . $row['username'] . " ..."); if (!$statistics->getUserShares($user->getUserId($row['username']))) - verbose("Failed to fetch and store user stats for " . $row['username'] . "\n"); + verbose(" update failed"); + verbose("\n"); } } ?> diff --git a/cronjobs/tickerupdate.php b/cronjobs/tickerupdate.php index 48e3678d..26323738 100755 --- a/cronjobs/tickerupdate.php +++ b/cronjobs/tickerupdate.php @@ -25,7 +25,7 @@ require_once('shared.inc.php'); // Include additional file not set in autoloader require_once(CLASS_DIR . '/tools.class.php'); -verbose("Running updates\n"); +verbose("Running scheduled updates\n"); verbose(" Price API Call ... "); if ($price = $tools->getPrice()) { verbose("found $price as price\n"); diff --git a/public/include/classes/notification.class.php b/public/include/classes/notification.class.php index b38bac2e..e07b3c32 100644 --- a/public/include/classes/notification.class.php +++ b/public/include/classes/notification.class.php @@ -173,8 +173,10 @@ class Notification extends Mail { // Check if this user wants strType notifications $stmt = $this->mysqli->prepare("SELECT account_id FROM $this->tableSettings WHERE type = ? AND active = 1 AND account_id = ?"); if ($stmt && $stmt->bind_param('si', $strType, $account_id) && $stmt->execute() && $stmt->bind_result($id) && $stmt->fetch()) { - if ($stmt->close() && $this->sendMail('notifications/' . $strType, $aMailData) && $this->addNotification($account_id, $strType, $aMailData)) + if ($stmt->close() && $this->sendMail('notifications/' . $strType, $aMailData) && $this->addNotification($account_id, $strType, $aMailData)) { + $this->setErrorMessage('Error sending mail notification'); return true; + } } else { $this->setErrorMessage('User disabled ' . $strType . ' notifications'); }