Skip to content

Commit f7f0437

Browse files
authored
Merge pull request #2517 from MPOS/development
UPDATE : Development to Master
2 parents 2549e40 + 0387451 commit f7f0437

File tree

68 files changed

+2034
-15008
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+2034
-15008
lines changed

.gitignore

+4-1
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,7 @@
3737

3838
/vendor/
3939

40-
tests/_output/*
40+
tests/_output/*
41+
42+
# NetBeans Project Directory
43+
/nbproject/*

.travis.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ branches:
1818

1919
install:
2020
- wget http://selenium-release.storage.googleapis.com/2.42/selenium-server-standalone-2.42.2.jar
21-
- composer global require "fxp/composer-asset-plugin:1.0.0-beta2"
21+
- composer global require "fxp/composer-asset-plugin:~1.1.1"
2222
- composer install
2323

2424

@@ -38,4 +38,4 @@ script:
3838

3939
after_script:
4040
- wget https://scrutinizer-ci.com/ocular.phar
41-
- php ocular.phar code-coverage:upload --format=php-clover tests/_output/coverage.xml
41+
- php ocular.phar code-coverage:upload --format=php-clover tests/_output/coverage.xml

cronjobs/shared.inc.php

+6
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,12 @@ function cfip() { return (@defined('SECURITY')) ? 1 : 0; }
6969
// Load the start time for later runtime calculations for monitoring
7070
$cron_start[$cron_name] = microtime(true);
7171

72+
// Skip all crons if admin enabled pool maintenance
73+
if ($setting->getValue('maintenance')) {
74+
$log->logInfo('Cronjobs disabled due to pool maintenance');
75+
$monitoring->endCronjob($cron_name, 'E0083', 2, true, false);
76+
}
77+
7278
// Check if our cron is activated
7379
if ($monitoring->isDisabled($cron_name)) {
7480
$log->logFatal('Cronjob is currently disabled due to errors, use -f option to force running cron.');

include/autoloader.inc.php

+3
Original file line numberDiff line numberDiff line change
@@ -78,5 +78,8 @@
7878
require_once(CLASS_DIR . '/roundstats.class.php');
7979
require_once(CLASS_DIR . '/news.class.php');
8080
require_once(CLASS_DIR . '/api.class.php');
81+
require_once(CLASS_DIR . '/usersettings.class.php');
82+
require_once(CLASS_DIR . '/ipushnotification.interface.php');
83+
require_once(CLASS_DIR . '/pushnotification.class.php');
8184
require_once(INCLUDE_DIR . '/lib/Michelf/Markdown.php');
8285
require_once(INCLUDE_DIR . '/lib/scrypt.php');

include/classes/base.class.php

+12
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ class Base {
1616
public function getTableName() {
1717
return $this->table;
1818
}
19+
20+
protected $debug;
1921
public function setDebug($debug) {
2022
$this->debug = $debug;
2123
}
@@ -25,9 +27,13 @@ public function setCoin($coin) {
2527
public function setCoinAddress($coin_address) {
2628
$this->coin_address = $coin_address;
2729
}
30+
31+
public $log;
2832
public function setLog($log) {
2933
$this->log = $log;
3034
}
35+
36+
protected $mysqli;
3137
public function setMysql($mysqli) {
3238
$this->mysqli = $mysqli;
3339
}
@@ -40,6 +46,10 @@ public function setSalt($salt) {
4046
public function setSalty($salt) {
4147
$this->salty = $salt;
4248
}
49+
/**
50+
* @var Smarty
51+
*/
52+
var $smarty;
4353
public function setSmarty($smarty) {
4454
$this->smarty = $smarty;
4555
}
@@ -52,6 +62,8 @@ public function setSessionManager($session) {
5262
public function setConfig($config) {
5363
$this->config = $config;
5464
}
65+
66+
protected $aErrorCodes;
5567
public function setErrorCodes(&$aErrorCodes) {
5668
$this->aErrorCodes =& $aErrorCodes;
5769
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
$defflip = (!cfip()) ? exit(header('HTTP/1.1 401 Unauthorized')) : 1;
3+
4+
/**
5+
* We extend our CoinBase class
6+
* No need to change anything, base class supports
7+
* scrypt and sha256d
8+
**/
9+
class Coin extends CoinBase {
10+
protected $target_bits = 16;
11+
}
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
$defflip = (!cfip()) ? exit(header('HTTP/1.1 401 Unauthorized')) : 1;
3+
/**
4+
* We extend our CoinBase class
5+
* No need to change anything, base class supports
6+
* scrypt and sha256d
7+
**/
8+
class Coin extends CoinBase {
9+
protected $target_bits = 24;
10+
protected $share_difficulty_precision = 4;
11+
}
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
$defflip = (!cfip()) ? exit(header('HTTP/1.1 401 Unauthorized')) : 1;
3+
/**
4+
* We extend our CoinBase class
5+
* No need to change anything, base class supports
6+
* scrypt and sha256d
7+
**/
8+
class Coin extends CoinBase {
9+
protected $target_bits = 24;
10+
protected $share_difficulty_precision = 4;
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?php
2+
interface IPushNotification {
3+
public static function getName();
4+
public static function getParameters();
5+
public function notify($message, $severity, $event);
6+
}

include/classes/monitoring.class.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class Monitoring extends Base {
1212
public function storeUptimeRobotStatus() {
1313
if ($api_keys = $this->setting->getValue('monitoring_uptimerobot_api_keys')) {
1414
$aJSONData = array();
15-
$url = 'http://api.uptimerobot.com';
15+
$url = 'https://api.uptimerobot.com';
1616
$aMonitors = explode(',', $api_keys);
1717
foreach ($aMonitors as $aData) {
1818
$temp = explode('|', $aData);
@@ -131,7 +131,7 @@ public function endCronjob($cron_name, $msgCode, $exitCode=0, $fatal=false, $mai
131131
$this->setErrorMessage('Failed to send mail notification');
132132
}
133133
if ($fatal) {
134-
if ($exitCode != 0) $this->setStatus($cron_name . "_disabled", "yesno", 1);
134+
if ($exitCode == 1) $this->setStatus($cron_name . "_disabled", "yesno", 1);
135135
exit($exitCode);
136136
}
137137
}

include/classes/notification.class.php

+21-8
Original file line numberDiff line numberDiff line change
@@ -149,14 +149,27 @@ public function sendNotification($account_id, $strType, $aMailData) {
149149
return false;
150150
}
151151
// Check if this user wants strType notifications
152-
$stmt = $this->mysqli->prepare("SELECT account_id FROM $this->tableSettings WHERE type = ? AND active = 1 AND account_id = ?");
153-
if ($stmt && $stmt->bind_param('si', $strType, $account_id) && $stmt->execute() && $stmt->bind_result($id) && $stmt->fetch()) {
154-
if ($stmt->close() && $this->sendMail('notifications/' . $strType, $aMailData) && $this->addNotification($account_id, $strType, $aMailData)) {
155-
return true;
156-
} else {
157-
$this->setErrorMessage('SendMail call failed: ' . $this->getError());
158-
return false;
159-
}
152+
$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+
$types = array_map(function($a){ return reset($a);}, $result->fetch_all(MYSQLI_ASSOC));
155+
$stmt->close();
156+
$result = true;
157+
foreach ($types as $type){
158+
if (strpos($type, 'push_') === 0){
159+
if (PushNotification::Instance() instanceof PushNotification){
160+
$result &= PushNotification::Instance()->sendNotification($account_id, $strType, $aMailData);
161+
}
162+
} else {
163+
$result &= $this->sendMail('notifications/' . $strType, $aMailData);
164+
}
165+
}
166+
if ($result){
167+
$this->addNotification($account_id, $strType, $aMailData);
168+
return true;
169+
} else {
170+
$this->setErrorMessage('SendMail call failed: ' . $this->getError());
171+
return false;
172+
}
160173
} else {
161174
$this->setErrorMessage('User disabled ' . $strType . ' notifications');
162175
return true;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?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+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?php
2+
class Notifications_Pushover implements IPushNotification {
3+
4+
private $token;
5+
private $user;
6+
public function __construct($token, $user){
7+
$this->token = $token;
8+
$this->user = $user;
9+
}
10+
11+
static $priorities = array(
12+
0 => 'info',
13+
1 => 'warning',
14+
2 => 'error',
15+
);
16+
17+
public static function getName(){
18+
return "pushover.net";
19+
}
20+
21+
public static function getParameters(){
22+
return array(
23+
'token' => 'API Token/Key',
24+
'user' => 'Your User Key',
25+
);
26+
}
27+
28+
public function notify($message, $severity = 'info', $event = null){
29+
curl_setopt_array($ch = curl_init(), array(
30+
CURLOPT_URL => "https://api.pushover.net/1/messages.json",
31+
CURLOPT_POST => true,
32+
CURLOPT_RETURNTRANSFER => true,
33+
CURLOPT_POSTFIELDS => http_build_query($data = array(
34+
"token" => $this->token,
35+
"user" => $this->user,
36+
"message" => $code = strip_tags(preg_replace('/<([\/]?)span[^>]*>/i', '<\1b>', $message), "<b><i><u><a><font><p><br>"),
37+
"title" => strip_tags($event),
38+
"priority" => (int)array_search($severity, self::$priorities),
39+
"timestamp" => time(),
40+
"html" => preg_match('/<[^>]+>/', $code),
41+
)),
42+
));
43+
curl_exec($ch);
44+
curl_close($ch);
45+
}
46+
}

0 commit comments

Comments
 (0)