From 0307e1e62ddab00a934be797a11668b2b6028c89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Blon=C4=8F=C3=A1k?= Date: Mon, 4 Sep 2017 15:26:27 +0200 Subject: [PATCH 1/7] fixed - Only variables should be passed by reference --- include/classes/notification.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/classes/notification.class.php b/include/classes/notification.class.php index 15764c88..ffafcc78 100644 --- a/include/classes/notification.class.php +++ b/include/classes/notification.class.php @@ -150,7 +150,8 @@ class Notification extends Mail { } // Check if this user wants strType notifications $stmt = $this->mysqli->prepare("SELECT type FROM $this->tableSettings WHERE type IN (?, ?) AND active = 1 AND account_id = ?"); - if ($stmt && $stmt->bind_param('ssi', $strType, substr('push_'.$strType, 0, 15), $account_id) && $stmt->execute() && $result = $stmt->get_result()) { + $notStrType = substr('push_'.$strType, 0, 15); + if ($stmt && $stmt->bind_param('ssi', $strType, $notStrType, $account_id) && $stmt->execute() && $result = $stmt->get_result()) { $types = array_map(function($a){ return reset($a);}, $result->fetch_all(MYSQLI_ASSOC)); $stmt->close(); $result = true; From 70ea8f1609467e79e33d8f3cba45356555898b1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Blon=C4=8F=C3=A1k?= Date: Mon, 4 Sep 2017 20:05:13 +0200 Subject: [PATCH 2/7] fixed - Undefined index: count_all --- include/classes/worker.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/classes/worker.class.php b/include/classes/worker.class.php index cb13387f..d87b0480 100644 --- a/include/classes/worker.class.php +++ b/include/classes/worker.class.php @@ -124,7 +124,7 @@ class Worker extends Base { ) AS shares FROM $this->table AS w WHERE id = ?"); - if ($this->checkStmt($stmt) && $stmt->bind_param('iiiii', $interval, $interval, $interval, $interval, $id) && $stmt->execute() && $result = $stmt->get_result()) { + if ($this->checkStmt($stmt) && $stmt->bind_param('iiiii', $interval, $interval, $interval, $interval, $id) && $stmt->execute() && ($result = $stmt->get_result())) { $row = $result->fetch_assoc(); $row['hashrate'] = round($this->coin->calcHashrate($row['shares'], $interval), 2); if ($row['count_all'] > 0) { From f6bfc10b900c9f12b115be53408eea1eebf7998c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Blon=C4=8F=C3=A1k?= Date: Mon, 4 Sep 2017 20:19:03 +0200 Subject: [PATCH 3/7] update - notifymyandroid.com - title from configuration --- .../push_notification/notifymyandroid.php | 81 ++++++++++--------- 1 file changed, 41 insertions(+), 40 deletions(-) diff --git a/include/classes/push_notification/notifymyandroid.php b/include/classes/push_notification/notifymyandroid.php index 87f0b80e..923caad4 100644 --- a/include/classes/push_notification/notifymyandroid.php +++ b/include/classes/push_notification/notifymyandroid.php @@ -1,41 +1,42 @@ apiKey = $apikey; - } - - static $priorities = array( - 0 => 'info', - 2 => 'error', - ); - - public static function getName(){ - return "notifymyandroid.com"; - } - - public static function getParameters(){ - return array( - 'apikey' => 'API key', - ); - } - - public function notify($message, $severity = 'info', $event = null){ - curl_setopt_array($ch = curl_init(), array( - CURLOPT_URL => "https://www.notifymyandroid.com/publicapi/notify", - CURLOPT_POST => true, - CURLOPT_RETURNTRANSFER => true, - CURLOPT_POSTFIELDS => http_build_query($data = array( - "apikey" => $this->apiKey, - "application" => "CryptoGlance", - "description" => $message, - "content-type" => "text/html", - "event" => $event, - "priority" => array_search($severity, self::$priorities), - )), - )); - curl_exec($ch); - curl_close($ch); - } - } \ No newline at end of file +class Notifications_NotifyMyAndroid implements IPushNotification { + + private $apiKey; + public function __construct($apikey){ + $this->apiKey = $apikey; + } + + static $priorities = array( + 0 => 'info', + 2 => 'error', + ); + + public static function getName(){ + return "notifymyandroid.com"; + } + + public static function getParameters(){ + return array( + 'apikey' => 'API key', + ); + } + + public function notify($message, $severity = 'info', $event = null){ + global $setting; + curl_setopt_array($ch = curl_init(), array( + CURLOPT_URL => "https://www.notifymyandroid.com/publicapi/notify", + CURLOPT_POST => true, + CURLOPT_RETURNTRANSFER => true, + CURLOPT_POSTFIELDS => http_build_query($data = array( + "apikey" => $this->apiKey, + "application" => $setting->getValue('website_title')?:"PHP-MPOS", + "description" => $message, + "content-type" => "text/html", + "event" => $event, + "priority" => array_search($severity, self::$priorities), + )), + )); + curl_exec($ch); + curl_close($ch); + } +} \ No newline at end of file From d687cab6c1ef60d089ccdeedcf26542871505be0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Blon=C4=8F=C3=A1k?= Date: Tue, 5 Sep 2017 20:08:35 +0200 Subject: [PATCH 4/7] FIXED - notifications without email notifications --- include/classes/notification.class.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/include/classes/notification.class.php b/include/classes/notification.class.php index ffafcc78..c1807dd9 100644 --- a/include/classes/notification.class.php +++ b/include/classes/notification.class.php @@ -105,8 +105,9 @@ class Notification extends Mail { **/ public function getNotificationAccountIdByType($strType) { $this->debug->append("STA " . __METHOD__, 4); - $stmt = $this->mysqli->prepare("SELECT account_id FROM $this->tableSettings WHERE type = ? AND active = 1"); - if ($stmt && $stmt->bind_param('s', $strType) && $stmt->execute() && $result = $stmt->get_result()) { + $stmt = $this->mysqli->prepare("SELECT account_id FROM $this->tableSettings WHERE type IN (?, ?) AND active = 1 GROUP BY account_id"); + $notStrType = substr('push_'.$strType, 0, 15); + if ($stmt && $stmt->bind_param('ss', $strType, $notStrType) && $stmt->execute() && $result = $stmt->get_result()) { return $result->fetch_all(MYSQLI_ASSOC); } return $this->sqlError('E0046'); From b144d21cb385fc621c402e509c20514ad4878246 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Blon=C4=8F=C3=A1k?= Date: Wed, 6 Sep 2017 21:03:37 +0200 Subject: [PATCH 5/7] FIX - Only variables should be passed by reference in usersettings.class.php on line 34 --- include/classes/usersettings.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/classes/usersettings.class.php b/include/classes/usersettings.class.php index f65d2355..06967b35 100644 --- a/include/classes/usersettings.class.php +++ b/include/classes/usersettings.class.php @@ -31,7 +31,8 @@ if (empty(self::$__SetSTMT)){ self::$__SetSTMT = $this->mysqli->prepare('REPLACE INTO '.$this->table.' (`account_id`, `name`, `value`) VALUES (?, ?, ?)'); } - if (!(self::$__SetSTMT && self::$__SetSTMT->bind_param('iss', $this->account_id, $name, serialize($value)) && self::$__SetSTMT->execute())) { + $val = serialize($value); + if (!(self::$__SetSTMT && self::$__SetSTMT->bind_param('iss', $this->account_id, $name, $val) && self::$__SetSTMT->execute())) { $this->setErrorMessage($this->getErrorMsg('E0084', $this->table)); return $this->sqlError(); } From 4670e553b21d9679305d0af239faea80cc8bb4c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Blon=C4=8F=C3=A1k?= Date: Wed, 13 Sep 2017 18:27:48 +0200 Subject: [PATCH 6/7] FIX - check for data in SQL result --- include/classes/worker.class.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/include/classes/worker.class.php b/include/classes/worker.class.php index d87b0480..1d486d4f 100644 --- a/include/classes/worker.class.php +++ b/include/classes/worker.class.php @@ -98,7 +98,7 @@ class Worker extends Base { **/ public function getWorker($id, $interval=600) { $this->debug->append("STA " . __METHOD__, 4); - $stmt = $this->mysqli->prepare(" + $stmt = $this->mysqli->prepare($q =" SELECT id, username, password, monitor, ( SELECT COUNT(id) FROM " . $this->share->getTableName() . " WHERE our_result = 'Y' AND username = w.username AND time > DATE_SUB(now(), INTERVAL ? SECOND) @@ -124,8 +124,7 @@ class Worker extends Base { ) AS shares FROM $this->table AS w WHERE id = ?"); - if ($this->checkStmt($stmt) && $stmt->bind_param('iiiii', $interval, $interval, $interval, $interval, $id) && $stmt->execute() && ($result = $stmt->get_result())) { - $row = $result->fetch_assoc(); + if ($this->checkStmt($stmt) && $stmt->bind_param('iiiii', $interval, $interval, $interval, $interval, $id) && $stmt->execute() && ($result = $stmt->get_result()) && ($row = $result->fetch_assoc())) { $row['hashrate'] = round($this->coin->calcHashrate($row['shares'], $interval), 2); if ($row['count_all'] > 0) { $row['difficulty'] = round($row['shares'] / $row['count_all'], 2); From 6875749f15650784ba3b6816e5a08af7480ef96d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Blon=C4=8F=C3=A1k?= Date: Wed, 13 Sep 2017 18:28:48 +0200 Subject: [PATCH 7/7] TYPO - remove unused variable --- include/classes/worker.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/classes/worker.class.php b/include/classes/worker.class.php index 1d486d4f..f2236b04 100644 --- a/include/classes/worker.class.php +++ b/include/classes/worker.class.php @@ -98,7 +98,7 @@ class Worker extends Base { **/ public function getWorker($id, $interval=600) { $this->debug->append("STA " . __METHOD__, 4); - $stmt = $this->mysqli->prepare($q =" + $stmt = $this->mysqli->prepare(" SELECT id, username, password, monitor, ( SELECT COUNT(id) FROM " . $this->share->getTableName() . " WHERE our_result = 'Y' AND username = w.username AND time > DATE_SUB(now(), INTERVAL ? SECOND)