Skip to content

Commit

Permalink
Merge pull request #2517 from MPOS/development
Browse files Browse the repository at this point in the history
UPDATE : Development to Master
  • Loading branch information
TheSerapher authored Jul 18, 2017
2 parents 2549e40 + 0387451 commit f7f0437
Show file tree
Hide file tree
Showing 68 changed files with 2,034 additions and 15,008 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,7 @@

/vendor/

tests/_output/*
tests/_output/*

# NetBeans Project Directory
/nbproject/*
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ branches:

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


Expand All @@ -38,4 +38,4 @@ script:

after_script:
- wget https://scrutinizer-ci.com/ocular.phar
- php ocular.phar code-coverage:upload --format=php-clover tests/_output/coverage.xml
- php ocular.phar code-coverage:upload --format=php-clover tests/_output/coverage.xml
6 changes: 6 additions & 0 deletions cronjobs/shared.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@ function cfip() { return (@defined('SECURITY')) ? 1 : 0; }
// Load the start time for later runtime calculations for monitoring
$cron_start[$cron_name] = microtime(true);

// Skip all crons if admin enabled pool maintenance
if ($setting->getValue('maintenance')) {
$log->logInfo('Cronjobs disabled due to pool maintenance');
$monitoring->endCronjob($cron_name, 'E0083', 2, true, false);
}

// Check if our cron is activated
if ($monitoring->isDisabled($cron_name)) {
$log->logFatal('Cronjob is currently disabled due to errors, use -f option to force running cron.');
Expand Down
3 changes: 3 additions & 0 deletions include/autoloader.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,5 +78,8 @@
require_once(CLASS_DIR . '/roundstats.class.php');
require_once(CLASS_DIR . '/news.class.php');
require_once(CLASS_DIR . '/api.class.php');
require_once(CLASS_DIR . '/usersettings.class.php');
require_once(CLASS_DIR . '/ipushnotification.interface.php');
require_once(CLASS_DIR . '/pushnotification.class.php');
require_once(INCLUDE_DIR . '/lib/Michelf/Markdown.php');
require_once(INCLUDE_DIR . '/lib/scrypt.php');
12 changes: 12 additions & 0 deletions include/classes/base.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ class Base {
public function getTableName() {
return $this->table;
}

protected $debug;
public function setDebug($debug) {
$this->debug = $debug;
}
Expand All @@ -25,9 +27,13 @@ public function setCoin($coin) {
public function setCoinAddress($coin_address) {
$this->coin_address = $coin_address;
}

public $log;
public function setLog($log) {
$this->log = $log;
}

protected $mysqli;
public function setMysql($mysqli) {
$this->mysqli = $mysqli;
}
Expand All @@ -40,6 +46,10 @@ public function setSalt($salt) {
public function setSalty($salt) {
$this->salty = $salt;
}
/**
* @var Smarty
*/
var $smarty;
public function setSmarty($smarty) {
$this->smarty = $smarty;
}
Expand All @@ -52,6 +62,8 @@ public function setSessionManager($session) {
public function setConfig($config) {
$this->config = $config;
}

protected $aErrorCodes;
public function setErrorCodes(&$aErrorCodes) {
$this->aErrorCodes =& $aErrorCodes;
}
Expand Down
11 changes: 11 additions & 0 deletions include/classes/coins/coin_neoscrypt.class.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php
$defflip = (!cfip()) ? exit(header('HTTP/1.1 401 Unauthorized')) : 1;

/**
* We extend our CoinBase class
* No need to change anything, base class supports
* scrypt and sha256d
**/
class Coin extends CoinBase {
protected $target_bits = 16;
}
11 changes: 11 additions & 0 deletions include/classes/coins/coin_x13.class.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php
$defflip = (!cfip()) ? exit(header('HTTP/1.1 401 Unauthorized')) : 1;
/**
* We extend our CoinBase class
* No need to change anything, base class supports
* scrypt and sha256d
**/
class Coin extends CoinBase {
protected $target_bits = 24;
protected $share_difficulty_precision = 4;
}
11 changes: 11 additions & 0 deletions include/classes/coins/coin_x15.class.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php
$defflip = (!cfip()) ? exit(header('HTTP/1.1 401 Unauthorized')) : 1;
/**
* We extend our CoinBase class
* No need to change anything, base class supports
* scrypt and sha256d
**/
class Coin extends CoinBase {
protected $target_bits = 24;
protected $share_difficulty_precision = 4;
}
6 changes: 6 additions & 0 deletions include/classes/ipushnotification.interface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php
interface IPushNotification {
public static function getName();
public static function getParameters();
public function notify($message, $severity, $event);
}
4 changes: 2 additions & 2 deletions include/classes/monitoring.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class Monitoring extends Base {
public function storeUptimeRobotStatus() {
if ($api_keys = $this->setting->getValue('monitoring_uptimerobot_api_keys')) {
$aJSONData = array();
$url = 'http://api.uptimerobot.com';
$url = 'https://api.uptimerobot.com';
$aMonitors = explode(',', $api_keys);
foreach ($aMonitors as $aData) {
$temp = explode('|', $aData);
Expand Down Expand Up @@ -131,7 +131,7 @@ public function endCronjob($cron_name, $msgCode, $exitCode=0, $fatal=false, $mai
$this->setErrorMessage('Failed to send mail notification');
}
if ($fatal) {
if ($exitCode != 0) $this->setStatus($cron_name . "_disabled", "yesno", 1);
if ($exitCode == 1) $this->setStatus($cron_name . "_disabled", "yesno", 1);
exit($exitCode);
}
}
Expand Down
29 changes: 21 additions & 8 deletions include/classes/notification.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,14 +149,27 @@ public function sendNotification($account_id, $strType, $aMailData) {
return false;
}
// Check if this user wants strType notifications
$stmt = $this->mysqli->prepare("SELECT account_id FROM $this->tableSettings WHERE type = ? AND active = 1 AND account_id = ?");
if ($stmt && $stmt->bind_param('si', $strType, $account_id) && $stmt->execute() && $stmt->bind_result($id) && $stmt->fetch()) {
if ($stmt->close() && $this->sendMail('notifications/' . $strType, $aMailData) && $this->addNotification($account_id, $strType, $aMailData)) {
return true;
} else {
$this->setErrorMessage('SendMail call failed: ' . $this->getError());
return false;
}
$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()) {
$types = array_map(function($a){ return reset($a);}, $result->fetch_all(MYSQLI_ASSOC));
$stmt->close();
$result = true;
foreach ($types as $type){
if (strpos($type, 'push_') === 0){
if (PushNotification::Instance() instanceof PushNotification){
$result &= PushNotification::Instance()->sendNotification($account_id, $strType, $aMailData);
}
} else {
$result &= $this->sendMail('notifications/' . $strType, $aMailData);
}
}
if ($result){
$this->addNotification($account_id, $strType, $aMailData);
return true;
} else {
$this->setErrorMessage('SendMail call failed: ' . $this->getError());
return false;
}
} else {
$this->setErrorMessage('User disabled ' . $strType . ' notifications');
return true;
Expand Down
41 changes: 41 additions & 0 deletions include/classes/push_notification/notifymyandroid.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php
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){
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);
}
}
46 changes: 46 additions & 0 deletions include/classes/push_notification/pushover.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php
class Notifications_Pushover implements IPushNotification {

private $token;
private $user;
public function __construct($token, $user){
$this->token = $token;
$this->user = $user;
}

static $priorities = array(
0 => 'info',
1 => 'warning',
2 => 'error',
);

public static function getName(){
return "pushover.net";
}

public static function getParameters(){
return array(
'token' => 'API Token/Key',
'user' => 'Your User Key',
);
}

public function notify($message, $severity = 'info', $event = null){
curl_setopt_array($ch = curl_init(), array(
CURLOPT_URL => "https://api.pushover.net/1/messages.json",
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POSTFIELDS => http_build_query($data = array(
"token" => $this->token,
"user" => $this->user,
"message" => $code = strip_tags(preg_replace('/<([\/]?)span[^>]*>/i', '<\1b>', $message), "<b><i><u><a><font><p><br>"),
"title" => strip_tags($event),
"priority" => (int)array_search($severity, self::$priorities),
"timestamp" => time(),
"html" => preg_match('/<[^>]+>/', $code),
)),
));
curl_exec($ch);
curl_close($ch);
}
}
Loading

0 comments on commit f7f0437

Please sign in to comment.