Skip to content

Commit 8d8ba4f

Browse files
authored
Merge pull request #2630 from blondak/development
Development
2 parents 043bde2 + 7dd8c69 commit 8d8ba4f

File tree

4 files changed

+49
-46
lines changed

4 files changed

+49
-46
lines changed

include/classes/notification.class.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,9 @@ public function getNotificationSettings($account_id) {
105105
**/
106106
public function getNotificationAccountIdByType($strType) {
107107
$this->debug->append("STA " . __METHOD__, 4);
108-
$stmt = $this->mysqli->prepare("SELECT account_id FROM $this->tableSettings WHERE type = ? AND active = 1");
109-
if ($stmt && $stmt->bind_param('s', $strType) && $stmt->execute() && $result = $stmt->get_result()) {
108+
$stmt = $this->mysqli->prepare("SELECT account_id FROM $this->tableSettings WHERE type IN (?, ?) AND active = 1 GROUP BY account_id");
109+
$notStrType = substr('push_'.$strType, 0, 15);
110+
if ($stmt && $stmt->bind_param('ss', $strType, $notStrType) && $stmt->execute() && $result = $stmt->get_result()) {
110111
return $result->fetch_all(MYSQLI_ASSOC);
111112
}
112113
return $this->sqlError('E0046');
@@ -150,7 +151,8 @@ public function sendNotification($account_id, $strType, $aMailData) {
150151
}
151152
// Check if this user wants strType notifications
152153
$stmt = $this->mysqli->prepare("SELECT type FROM $this->tableSettings WHERE type IN (?, ?) AND active = 1 AND account_id = ?");
153-
if ($stmt && $stmt->bind_param('ssi', $strType, substr('push_'.$strType, 0, 15), $account_id) && $stmt->execute() && $result = $stmt->get_result()) {
154+
$notStrType = substr('push_'.$strType, 0, 15);
155+
if ($stmt && $stmt->bind_param('ssi', $strType, $notStrType, $account_id) && $stmt->execute() && $result = $stmt->get_result()) {
154156
$types = array_map(function($a){ return reset($a);}, $result->fetch_all(MYSQLI_ASSOC));
155157
$stmt->close();
156158
$result = true;
Lines changed: 41 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,42 @@
11
<?php
2-
class Notifications_NotifyMyAndroid implements IPushNotification {
3-
4-
private $apiKey;
5-
public function __construct($apikey){
6-
$this->apiKey = $apikey;
7-
}
8-
9-
static $priorities = array(
10-
0 => 'info',
11-
2 => 'error',
12-
);
13-
14-
public static function getName(){
15-
return "notifymyandroid.com";
16-
}
17-
18-
public static function getParameters(){
19-
return array(
20-
'apikey' => 'API key',
21-
);
22-
}
23-
24-
public function notify($message, $severity = 'info', $event = null){
25-
curl_setopt_array($ch = curl_init(), array(
26-
CURLOPT_URL => "https://www.notifymyandroid.com/publicapi/notify",
27-
CURLOPT_POST => true,
28-
CURLOPT_RETURNTRANSFER => true,
29-
CURLOPT_POSTFIELDS => http_build_query($data = array(
30-
"apikey" => $this->apiKey,
31-
"application" => "CryptoGlance",
32-
"description" => $message,
33-
"content-type" => "text/html",
34-
"event" => $event,
35-
"priority" => array_search($severity, self::$priorities),
36-
)),
37-
));
38-
curl_exec($ch);
39-
curl_close($ch);
40-
}
41-
}
2+
class Notifications_NotifyMyAndroid implements IPushNotification {
3+
4+
private $apiKey;
5+
public function __construct($apikey){
6+
$this->apiKey = $apikey;
7+
}
8+
9+
static $priorities = array(
10+
0 => 'info',
11+
2 => 'error',
12+
);
13+
14+
public static function getName(){
15+
return "notifymyandroid.com";
16+
}
17+
18+
public static function getParameters(){
19+
return array(
20+
'apikey' => 'API key',
21+
);
22+
}
23+
24+
public function notify($message, $severity = 'info', $event = null){
25+
global $setting;
26+
curl_setopt_array($ch = curl_init(), array(
27+
CURLOPT_URL => "https://www.notifymyandroid.com/publicapi/notify",
28+
CURLOPT_POST => true,
29+
CURLOPT_RETURNTRANSFER => true,
30+
CURLOPT_POSTFIELDS => http_build_query($data = array(
31+
"apikey" => $this->apiKey,
32+
"application" => $setting->getValue('website_title')?:"PHP-MPOS",
33+
"description" => $message,
34+
"content-type" => "text/html",
35+
"event" => $event,
36+
"priority" => array_search($severity, self::$priorities),
37+
)),
38+
));
39+
curl_exec($ch);
40+
curl_close($ch);
41+
}
42+
}

include/classes/usersettings.class.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ private function _storeValue($name, $value){
3131
if (empty(self::$__SetSTMT)){
3232
self::$__SetSTMT = $this->mysqli->prepare('REPLACE INTO '.$this->table.' (`account_id`, `name`, `value`) VALUES (?, ?, ?)');
3333
}
34-
if (!(self::$__SetSTMT && self::$__SetSTMT->bind_param('iss', $this->account_id, $name, serialize($value)) && self::$__SetSTMT->execute())) {
34+
$val = serialize($value);
35+
if (!(self::$__SetSTMT && self::$__SetSTMT->bind_param('iss', $this->account_id, $name, $val) && self::$__SetSTMT->execute())) {
3536
$this->setErrorMessage($this->getErrorMsg('E0084', $this->table));
3637
return $this->sqlError();
3738
}

include/classes/worker.class.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,7 @@ public function getWorker($id, $interval=600) {
124124
) AS shares
125125
FROM $this->table AS w
126126
WHERE id = ?");
127-
if ($this->checkStmt($stmt) && $stmt->bind_param('iiiii', $interval, $interval, $interval, $interval, $id) && $stmt->execute() && $result = $stmt->get_result()) {
128-
$row = $result->fetch_assoc();
127+
if ($this->checkStmt($stmt) && $stmt->bind_param('iiiii', $interval, $interval, $interval, $interval, $id) && $stmt->execute() && ($result = $stmt->get_result()) && ($row = $result->fetch_assoc())) {
129128
$row['hashrate'] = round($this->coin->calcHashrate($row['shares'], $interval), 2);
130129
if ($row['count_all'] > 0) {
131130
$row['difficulty'] = round($row['shares'] / $row['count_all'], 2);

0 commit comments

Comments
 (0)