diff --git a/include/classes/notification.class.php b/include/classes/notification.class.php index 15764c88..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'); @@ -150,7 +151,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; 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 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(); } diff --git a/include/classes/worker.class.php b/include/classes/worker.class.php index cb13387f..f2236b04 100644 --- a/include/classes/worker.class.php +++ b/include/classes/worker.class.php @@ -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);