Merge pull request #2630 from blondak/development

Development
This commit is contained in:
Sebastian Grewe 2017-10-30 07:09:52 +00:00 committed by GitHub
commit 8d8ba4fcbf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 49 additions and 46 deletions

View File

@ -105,8 +105,9 @@ class Notification extends Mail {
**/ **/
public function getNotificationAccountIdByType($strType) { public function getNotificationAccountIdByType($strType) {
$this->debug->append("STA " . __METHOD__, 4); $this->debug->append("STA " . __METHOD__, 4);
$stmt = $this->mysqli->prepare("SELECT account_id FROM $this->tableSettings WHERE type = ? AND active = 1"); $stmt = $this->mysqli->prepare("SELECT account_id FROM $this->tableSettings WHERE type IN (?, ?) AND active = 1 GROUP BY account_id");
if ($stmt && $stmt->bind_param('s', $strType) && $stmt->execute() && $result = $stmt->get_result()) { $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 $result->fetch_all(MYSQLI_ASSOC);
} }
return $this->sqlError('E0046'); return $this->sqlError('E0046');
@ -150,7 +151,8 @@ class Notification extends Mail {
} }
// Check if this user wants strType notifications // 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 = ?"); $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)); $types = array_map(function($a){ return reset($a);}, $result->fetch_all(MYSQLI_ASSOC));
$stmt->close(); $stmt->close();
$result = true; $result = true;

View File

@ -1,41 +1,42 @@
<?php <?php
class Notifications_NotifyMyAndroid implements IPushNotification { class Notifications_NotifyMyAndroid implements IPushNotification {
private $apiKey; private $apiKey;
public function __construct($apikey){ public function __construct($apikey){
$this->apiKey = $apikey; $this->apiKey = $apikey;
} }
static $priorities = array( static $priorities = array(
0 => 'info', 0 => 'info',
2 => 'error', 2 => 'error',
); );
public static function getName(){ public static function getName(){
return "notifymyandroid.com"; return "notifymyandroid.com";
} }
public static function getParameters(){ public static function getParameters(){
return array( return array(
'apikey' => 'API key', 'apikey' => 'API key',
); );
} }
public function notify($message, $severity = 'info', $event = null){ public function notify($message, $severity = 'info', $event = null){
curl_setopt_array($ch = curl_init(), array( global $setting;
CURLOPT_URL => "https://www.notifymyandroid.com/publicapi/notify", curl_setopt_array($ch = curl_init(), array(
CURLOPT_POST => true, CURLOPT_URL => "https://www.notifymyandroid.com/publicapi/notify",
CURLOPT_RETURNTRANSFER => true, CURLOPT_POST => true,
CURLOPT_POSTFIELDS => http_build_query($data = array( CURLOPT_RETURNTRANSFER => true,
"apikey" => $this->apiKey, CURLOPT_POSTFIELDS => http_build_query($data = array(
"application" => "CryptoGlance", "apikey" => $this->apiKey,
"description" => $message, "application" => $setting->getValue('website_title')?:"PHP-MPOS",
"content-type" => "text/html", "description" => $message,
"event" => $event, "content-type" => "text/html",
"priority" => array_search($severity, self::$priorities), "event" => $event,
)), "priority" => array_search($severity, self::$priorities),
)); )),
curl_exec($ch); ));
curl_close($ch); curl_exec($ch);
} curl_close($ch);
} }
}

View File

@ -31,7 +31,8 @@
if (empty(self::$__SetSTMT)){ if (empty(self::$__SetSTMT)){
self::$__SetSTMT = $this->mysqli->prepare('REPLACE INTO '.$this->table.' (`account_id`, `name`, `value`) VALUES (?, ?, ?)'); 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)); $this->setErrorMessage($this->getErrorMsg('E0084', $this->table));
return $this->sqlError(); return $this->sqlError();
} }

View File

@ -124,8 +124,7 @@ class Worker extends Base {
) AS shares ) AS shares
FROM $this->table AS w FROM $this->table AS w
WHERE id = ?"); 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 = $result->fetch_assoc();
$row['hashrate'] = round($this->coin->calcHashrate($row['shares'], $interval), 2); $row['hashrate'] = round($this->coin->calcHashrate($row['shares'], $interval), 2);
if ($row['count_all'] > 0) { if ($row['count_all'] > 0) {
$row['difficulty'] = round($row['shares'] / $row['count_all'], 2); $row['difficulty'] = round($row['shares'] / $row['count_all'], 2);