Merge pull request #2540 from blondak/development

#2539 - Feature request: Pushover.net notifications
This commit is contained in:
Sebastian Grewe 2017-02-28 15:41:31 +01:00 committed by GitHub
commit 6640f1f889
22 changed files with 634 additions and 80 deletions

View File

@ -78,5 +78,8 @@ require_once(CLASS_DIR . '/transaction.class.php');
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');

View File

@ -16,6 +16,8 @@ class Base {
public function getTableName() {
return $this->table;
}
protected $debug;
public function setDebug($debug) {
$this->debug = $debug;
}
@ -25,9 +27,13 @@ class Base {
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;
}
@ -40,6 +46,10 @@ class Base {
public function setSalty($salt) {
$this->salty = $salt;
}
/**
* @var Smarty
*/
var $smarty;
public function setSmarty($smarty) {
$this->smarty = $smarty;
}
@ -52,6 +62,8 @@ class Base {
public function setConfig($config) {
$this->config = $config;
}
protected $aErrorCodes;
public function setErrorCodes(&$aErrorCodes) {
$this->aErrorCodes =& $aErrorCodes;
}

View File

@ -0,0 +1,6 @@
<?php
interface IPushNotification {
public static function getName();
public static function getParameters();
public function notify($message, $severity, $event);
}

View File

@ -149,14 +149,27 @@ class Notification extends Mail {
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;

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -0,0 +1,171 @@
<?php
$defflip = (!cfip()) ? exit(header('HTTP/1.1 401 Unauthorized')) : 1;
class PushNotification extends Base {
var $tableSettings = 'push_notification_settings';
private static function getClassesInFile($file){
$classes = array();
$tokens = token_get_all(file_get_contents($file));
$count = count($tokens);
for ($i = 2; $i < $count; $i++) {
if ($tokens[$i - 2][0] == T_CLASS && $tokens[$i - 1][0] == T_WHITESPACE && $tokens[$i][0] == T_STRING) {
$class_name = $tokens[$i][1];
$classes[] = $class_name;
}
}
return $classes;
}
private static $classes = null;
public function getClasses(){
if (self::$classes === null){
$directory = new DirectoryIterator(__DIR__.'/push_notification');
foreach ($directory as $fileInfo) {
if (($fileInfo->getExtension() != 'php') || $fileInfo->isDot()) {
continue;
}
foreach (self::getClassesInFile($fileInfo->getRealPath()) as $class){
if (!class_exists($class)){
include $fileInfo->getRealPath();
}
$cr = new ReflectionClass($class);
if ($cr->isSubclassOf('IPushNotification')){
self::$classes[$class] = array($fileInfo->getFilename(), $cr->getMethod('getName')->invoke(null), $cr->getMethod('getParameters')->invoke(null));
}
}
}
}
return self::$classes;
}
public function getClassesForSmarty(){
$c = $this->getClasses();
return array_map(function($a, $b){
return array(
'class' => $b,
'file' => $a[0],
'name' => $a[1],
'parameters' => $a[2],
);
}, $c, array_keys($c));
}
/**
* @param string|array $notificator
* @param array $data
* @return IPushNotification|bool
*/
public function getNotificatorInstance($notificator, $data){
$class = null;
$file = null;
if (is_array($notificator)){
if (count($notificator) == 2){
list($class, $file) = $notificator;
} else {
$class = reset($notificator);
}
} else {
$class = $notificator;
}
if (!class_exists($class)){
if ($file === null){
foreach (self::getClasses() as $_class => $_info){
if ($_class == $class){
$file = $_info[0];
break;
}
}
} else {
include __DIR__.'/push_notification/'.$file;
}
if (!class_exists($class)){
return false;
}
}
$cr = new ReflectionClass($class);
$constructor = $cr->getConstructor();
$constructorParameters = array();
foreach (array_map(function($a){ return $a->getName();}, $constructor->getParameters()) as $param){
$constructorParameters[] = array_key_exists($param, $data)?$data[$param]:null;
}
$instance = $cr->newInstanceArgs($constructorParameters);
return $instance;
}
/**
* Update accounts push notification settings
* @param account_id int Account ID
* @param data array Data array
* @return bool
**/
public function updateSettings($account_id, $data) {
UserSettings::construct($account_id)->PushNotifications = $data;
return true;
}
/**
* Fetch notification settings for user account
* @param id int Account ID
* @return array Notification settings
**/
public function getNotificationSettings($account_id) {
if ($settings = UserSettings::construct($account_id)->PushNotifications){
return $settings;
}
return array(
'class' => false,
'params' => null,
'file' => null,
);
}
private static $instance = null;
/**
* @param PushNotification $instance
*/
public static function Instance($instance = null){
if (func_num_args() == 0){
return self::$instance;
}
return self::$instance = $instance;
}
public function sendNotification($account_id, $template, $aData){
$settings = $this->getNotificationSettings($account_id);
if ($settings['class']){
$instance = $this->getNotificatorInstance(array($settings['class'], $settings['file']), $settings['params']);
if ($instance){
$this->smarty->assign('WEBSITENAME', $this->setting->getValue('website_name'));
$this->smarty->assign('SUBJECT', $aData['subject']);
$this->smarty->assign('DATA', $aData);
$message = false;
foreach (array('/mail/push_notifications/', '/mail/notifications/') as $dir){
$this->smarty->clearCache($templateFile = TEMPLATE_DIR.$dir.$template.'.tpl');
try {
$message = $this->smarty->fetch($templateFile);
break;
} catch (SmartyException $e){
}
}
if ($message){
$instance->notify($message, 'info', $aData['subject']);
}
}
}
return true;
}
}
$pushnotification = PushNotification::Instance(new PushNotification());
$pushnotification->setDebug($debug);
$pushnotification->setLog($log);
$pushnotification->setMysql($mysqli);
$pushnotification->setSmarty($smarty);
$pushnotification->setConfig($config);
$pushnotification->setSetting($setting);
$pushnotification->setErrorCodes($aErrorCodes);

View File

@ -430,6 +430,7 @@ class Transaction extends Base {
$aMailData['email'] = $this->user->getUserEmailById($account_id);
$aMailData['subject'] = $type . ' Completed';
$aMailData['amount'] = $amount;
$aMailData['currency'] = $this->config['currency'];
if (!$this->notification->sendNotification($account_id, 'payout', $aMailData)) {
$this->setErrorMessage('Failed to send notification email to users address: ' . $aMailData['email'] . 'ERROR: ' . $this->notification->getCronError());
}

View File

@ -244,7 +244,7 @@ class User extends Base {
$notifs->setSetting($this->setting);
$notifs->setErrorCodes($this->aErrorCodes);
$ndata = $notifs->getNotificationSettings($uid);
if (@$ndata['success_login'] == 1) {
if ((array_key_exists('push_success_lo', $ndata) && $ndata['push_success_lo']) || (array_key_exists('success_login', $ndata) && $ndata['success_login'])){
// seems to be active, let's send it
$aDataN['username'] = $username;
$aDataN['email'] = $this->getUserEmail($username);

View File

@ -0,0 +1,100 @@
<?php
$defflip = (!cfip()) ? exit(header('HTTP/1.1 401 Unauthorized')) : 1;
class UserSettings extends Base {
protected $table = 'user_settings';
private $__cache = array();
protected $account_id = null;
private $__lazyWrite;
public function __construct($account_id, $lazy_write = true){
$this->account_id = $account_id;
$this->__lazyWrite = $lazy_write;
if (is_callable(self::$__setup_callbacks)){
call_user_func(self::$__setup_callbacks, $this);
}
}
private static $__GetSTMT = null;
private static $__SetSTMT = null;
public function __destruct(){
if ($this->__lazyWrite){
foreach ($this->__cache as $name=>$value){
$this->_storeValue($name, $value);
}
}
}
private function _storeValue($name, $value){
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())) {
$this->setErrorMessage($this->getErrorMsg('E0084', $this->table));
return $this->sqlError();
}
return true;
}
private function _getValue($name, $default = null){
if (empty(self::$__GetSTMT)){
self::$__GetSTMT = $this->mysqli->prepare('SELECT `value` FROM '.$this->table.' WHERE `account_id` = ? AND `name` = ? LIMIT 1');
}
if (self::$__GetSTMT && self::$__GetSTMT->bind_param('is', $this->account_id, $name) && self::$__GetSTMT->execute() && $result = self::$__GetSTMT->get_result()) {
if ($result->num_rows > 0) {
return unserialize($result->fetch_object()->value);
} else {
return $default;
}
}
$this->sqlError();
return $default;
}
public function __get($name){
if (!$this->__lazyWrite){
return $this->_getValue($name);
}
if (!array_key_exists($name, $this->__cache)){
$this->__cache[$name] = $this->_getValue($name);
}
return $this->__cache[$name];
}
public function __set($name, $value){
if (!$this->__lazyWrite){
$this->_storeValue($name, $value);
} else {
$this->__cache[$name] = $value;
}
}
private static $__setup_callbacks = null;
public static function setup($callback = null){
self::$__setup_callbacks = $callback;
}
private static $__lastInstanceId;
private static $__lastInstance;
/**
* @param int $account_id
* @param string $lazy_write
* @return UserSettings
*/
public static function construct($account_id, $lazy_write = true){
if ((self::$__lastInstanceId == $account_id) && (self::$__lastInstance instanceof UserSettings)){
return self::$__lastInstance;
}
self::$__lastInstanceId = $account_id;
return self::$__lastInstance = new self($account_id, $lazy_write);
}
}
UserSettings::setup(function($instance)use($debug, $log, $mysqli, $aErrorCodes){
$instance->setDebug($debug);
$instance->setLog($log);
$instance->setMysql($mysqli);
$instance->setErrorCodes($aErrorCodes);
});

View File

@ -79,3 +79,4 @@ $aErrorCodes['E0080'] = 'No new unaccounted shares since last run';
$aErrorCodes['E0081'] = 'Failed to insert new block into database';
$aErrorCodes['E0082'] = 'Block does not supply any usable confirmation information';
$aErrorCodes['E0083'] = 'Maintenance mode enabled, skipped';
$aErrorCodes['E0084'] = 'Error updating %s table';

View File

@ -8,7 +8,25 @@ if ($user->isAuthenticated()) {
} else {
if (@$_REQUEST['do'] == 'save') {
if (!$config['csrf']['enabled'] || $config['csrf']['enabled'] && $csrftoken->valid) {
if ($notification->updateSettings($_SESSION['USERDATA']['id'], $_REQUEST['data'])) {
$pushSettings = array(
'class' => $_REQUEST['pushnotification-class'],
'params' => null,
'file' => null,
);
if ($pushSettings['class'] && array_key_exists($pushSettings['class'], $_REQUEST['pushnotification'])){
$pushSettings['params'] = $_REQUEST['pushnotification'][$pushSettings['class']];
}
if ($pushSettings['class']){
$c = $pushnotification->getClasses();
if (array_key_exists($pushSettings['class'], $c)){
$pushSettings['file'] = $c[$pushSettings['class']][0];
}
}
if (!$pushnotification->updateSettings($_SESSION['USERDATA']['id'], $pushSettings)){
$_SESSION['POPUP'][] = array('CONTENT' => $pushnotification->getError(), 'TYPE' => 'alert alert-danger');
}elseif ($notification->updateSettings($_SESSION['USERDATA']['id'], $_REQUEST['data'])) {
$_SESSION['POPUP'][] = array('CONTENT' => 'Updated notification settings', 'TYPE' => 'alert alert-success');
} else {
$_SESSION['POPUP'][] = array('CONTENT' => $notification->getError(), 'TYPE' => 'alert alert-danger');
@ -29,8 +47,12 @@ if ($user->isAuthenticated()) {
// Fetch user notification settings
$aSettings = $notification->getNotificationSettings($_SESSION['USERDATA']['id']);
$aPushSettings = $pushnotification->getNotificationSettings($_SESSION['USERDATA']['id']);
$aSmartyClasses = $pushnotification->getClassesForSmarty();
$smarty->assign('NOTIFICATIONS', $aNotifications);
$smarty->assign('PUSHNOTIFICATIONS', $aSmartyClasses);
$smarty->assign('PUSHSETTINGS', $aPushSettings);
$smarty->assign('SETTINGS', $aSettings);
$smarty->assign('CONTENT', 'default.tpl');
}

View File

@ -2,7 +2,7 @@
$defflip = (!cfip()) ? exit(header('HTTP/1.1 401 Unauthorized')) : 1;
define('MPOS_VERSION', '1.0.6');
define('DB_VERSION', '1.0.1');
define('DB_VERSION', '1.0.2');
define('CONFIG_VERSION', '1.0.1');
define('HASH_VERSION', 1);

View File

@ -659,4 +659,9 @@ div.fade {
padding: 0px;
}
.push-notifications-params,
.push-notifications-disabled .push-notifications {
display : none;
}
/* END EDIT */

View File

@ -88,3 +88,14 @@ $(function() {
});
});
$(document).on('change', '#push-notifications', function(e){
var notificationClass = $(this).val();
$('#push-notifications-pannel').toggleClass('push-notifications-disabled', notificationClass == 0);
$('.push-notifications-params').each(function(){
var $this = $(this);
$this.toggle($this.attr('data-class-name') == notificationClass);
});
}).ready(function(){
$('#push-notifications').trigger('change');
});

View File

@ -142,7 +142,7 @@ CREATE TABLE IF NOT EXISTS `settings` (
UNIQUE KEY `setting` (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
INSERT INTO `settings` (`name`, `value`) VALUES ('DB_VERSION', '1.0.1');
INSERT INTO `settings` (`name`, `value`) VALUES ('DB_VERSION', '1.0.2');
CREATE TABLE IF NOT EXISTS `shares` (
`id` bigint(30) NOT NULL AUTO_INCREMENT,
@ -248,6 +248,13 @@ CREATE TABLE `statistics_users` (
KEY `account_id_timestamp` (`account_id`,`timestamp`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS `user_settings` (
`account_id` int(11) NOT NULL,
`name` varchar(50) NOT NULL,
`value` text DEFAULT NULL,
PRIMARY KEY (`account_id`,`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;

View File

@ -1,72 +1,138 @@
<div class="row">
<form class="col-lg-4" method="POST" role="form">
<input type="hidden" name="page" value="{$smarty.request.page|escape}">
<input type="hidden" name="action" value="{$smarty.request.action|escape}">
<input type="hidden" name="do" value="save">
<input type="hidden" name="ctoken" value="{$CTOKEN|escape|default:""}">
<div class="panel panel-info">
<div class="panel-heading">
<i class="fa fa-gear fa-fw"></i> Notification Settings
</div>
<div class="panel-body no-padding">
<table class="table table-striped table-bordered table-hover">
{if $DISABLE_IDLEWORKERNOTIFICATIONS|default:"" != 1}
<tr>
<td>
<label>Idle Worker</label>
</td>
<td>
<input type="hidden" name="data[idle_worker]" value="0" />
<input type="checkbox" class="switch" data-size="mini" name="data[idle_worker]" id="idle_worker" value="1"{nocache}{if $SETTINGS['idle_worker']|default:"0" == 1}checked{/if}{/nocache} />
</td>
</tr>
{/if}
{if $DISABLE_BLOCKNOTIFICATIONS|default:"" != 1}
<tr>
<td>
<label>New Blocks</label>
</td>
<td>
<input type="hidden" name="data[new_block]" value="0" />
<input type="checkbox"class="switch" data-size="mini" name="data[new_block]" id="new_block" value="1"{nocache}{if $SETTINGS['new_block']|default:"0" == 1}checked{/if}{/nocache} />
</td>
</tr>
{/if}
<tr>
<td>
<label>Payout</label>
</td>
<td>
<input type="hidden" name="data[payout]" value="0" />
<input type="checkbox" class="switch" data-size="mini" name="data[payout]" id="payout" value="1"{nocache}{if $SETTINGS['payout']|default:"0" == 1}checked{/if}{/nocache} />
</td>
</tr>
<tr>
<td>
<label>Successful Login</label>
</td>
<td>
<input type="hidden" name="data[success_login]" value="0" />
<input type="checkbox" class="switch" data-size="mini" name="data[success_login]" id="success_login" value="1"{nocache}{if $SETTINGS['success_login']|default:"0" == 1}checked{/if}{/nocache} />
</td>
</tr>
{if $DISABLE_POOLNEWSLETTER|default:"" != 1}
<tr>
<td>
<label>Pool Newsletter</label>
</td>
<td>
<input type="hidden" name="data[newsletter]" value="0" />
<input type="checkbox"class="switch" data-size="mini" name="data[newsletter]" id="new_block" value="1"{nocache}{if $SETTINGS['newsletter']|default:"1" == 1}checked{/if}{/nocache} />
</td>
</tr>
{/if}
</table>
</div>
<div class="panel-footer">
<input type="submit" value="Update" class="btn btn-success btn-sm">
</div>
</form>
<div class="col-lg-4">
<form method="POST" role="form">
<input type="hidden" name="page" value="{$smarty.request.page|escape}">
<input type="hidden" name="action" value="{$smarty.request.action|escape}">
<input type="hidden" name="do" value="save">
<input type="hidden" name="ctoken" value="{$CTOKEN|escape|default:""}">
<div class="panel panel-info">
<div class="panel-heading">
<i class="fa fa-gear fa-fw"></i> Push Notification Settings
</div>
<div class="panel-body no-padding">
<table class="table table-striped table-bordered table-hover">
<tbody>
<tr>
<td>
<label>Push Notifications</label>
</td>
<td>
<select name="pushnotification-class" class="form-control select-mini" id="push-notifications">
<option value="0">Disabled</option>
{section pushnotification $PUSHNOTIFICATIONS}
<option value="{$PUSHNOTIFICATIONS[pushnotification].class}"{nocache}{if $PUSHNOTIFICATIONS[pushnotification].class == $PUSHSETTINGS.class} selected="selected"{/if}{/nocache}>{$PUSHNOTIFICATIONS[pushnotification].name}</option>
{/section}
</select>
</td>
</tbody>
{section pushnotification $PUSHNOTIFICATIONS}
<tbody class="push-notifications-params" data-class-name="{$PUSHNOTIFICATIONS[pushnotification].class}">
{foreach $PUSHNOTIFICATIONS[pushnotification].parameters key=name item=text}
<tr>
<td><label>{$text}</label></td>
<td><input class="form-control" type="text" name="pushnotification[{$PUSHNOTIFICATIONS[pushnotification].class}][{$name}]" {nocache}value="{$PUSHSETTINGS.params[$name]|default:""}"{/nocache}/></td>
</tr>
{/foreach}
</tbody>
{/section}
</table>
</div>
</div>
<div class="panel panel-info">
<div class="panel-heading">
<i class="fa fa-gear fa-fw"></i> Notification Settings
</div>
<div class="panel-body no-padding push-notifications-disabled" id="push-notifications-pannel">
<table class="table table-striped table-bordered table-hover">
<thread>
<tr>
<th>Event</th>
<th>Email</th>
<th class="push-notifications">Push</th>
</tr>
</thread>
<tbody>
{if $DISABLE_IDLEWORKERNOTIFICATIONS|default:"" != 1}
<tr>
<td>
<label>Idle Worker</label>
</td>
<td>
<input type="hidden" name="data[idle_worker]" value="0" />
<input type="checkbox" class="switch" data-size="mini" name="data[idle_worker]" id="idle_worker" value="1"{nocache}{if $SETTINGS['idle_worker']|default:"0" == 1}checked{/if}{/nocache} />
</td>
<td class="push-notifications">
<input type="hidden" name="data[push_idle_worke]" value="0" />
<input type="checkbox" class="switch" data-size="mini" name="data[push_idle_worke]" id="push_idle_worke" value="1"{nocache}{if $SETTINGS['push_idle_worke']|default:"0" == 1}checked{/if}{/nocache} />
</td>
</tr>
{/if}
{if $DISABLE_BLOCKNOTIFICATIONS|default:"" != 1}
<tr>
<td>
<label>New Blocks</label>
</td>
<td>
<input type="hidden" name="data[new_block]" value="0" />
<input type="checkbox"class="switch" data-size="mini" name="data[new_block]" id="new_block" value="1"{nocache}{if $SETTINGS['new_block']|default:"0" == 1}checked{/if}{/nocache} />
</td>
<td class="push-notifications">
<input type="hidden" name="data[push_new_block]" value="0" />
<input type="checkbox"class="switch" data-size="mini" name="data[push_new_block]" id="new_block" value="1"{nocache}{if $SETTINGS['push_new_block']|default:"0" == 1}checked{/if}{/nocache} />
</td>
</tr>
{/if}
<tr>
<td>
<label>Payout</label>
</td>
<td>
<input type="hidden" name="data[payout]" value="0" />
<input type="checkbox" class="switch" data-size="mini" name="data[payout]" id="payout" value="1"{nocache}{if $SETTINGS['payout']|default:"0" == 1}checked{/if}{/nocache} />
</td>
<td class="push-notifications">
<input type="hidden" name="data[push_payout]" value="0" />
<input type="checkbox" class="switch" data-size="mini" name="data[push_payout]" id="push_payout" value="1"{nocache}{if $SETTINGS['push_payout']|default:"0" == 1}checked{/if}{/nocache} />
</td>
</tr>
<tr>
<td>
<label>Successful Login</label>
</td>
<td>
<input type="hidden" name="data[success_login]" value="0" />
<input type="checkbox" class="switch" data-size="mini" name="data[success_login]" id="success_login" value="1"{nocache}{if $SETTINGS['success_login']|default:"0" == 1}checked{/if}{/nocache} />
</td>
<td class="push-notifications">
<input type="hidden" name="data[push_success_lo]" value="0" />
<input type="checkbox" class="switch" data-size="mini" name="data[push_success_lo]" id="push_success_lo" value="1"{nocache}{if $SETTINGS['push_success_lo']|default:"0" == 1}checked{/if}{/nocache} />
</td>
</tr>
{if $DISABLE_POOLNEWSLETTER|default:"" != 1}
<tr>
<td>
<label>Pool Newsletter</label>
</td>
<td>
<input type="hidden" name="data[newsletter]" value="0" />
<input type="checkbox"class="switch" data-size="mini" name="data[newsletter]" id="newsletter" value="1"{nocache}{if $SETTINGS['newsletter']|default:"1" == 1}checked{/if}{/nocache} />
</td>
<td class="push-notifications">
<input type="hidden" name="data[push_newsletter]" value="0" />
<input type="checkbox"class="switch" data-size="mini" name="data[push_newsletter]" id="push_newsletter" value="1"{nocache}{if $SETTINGS['push_newsletter']|default:"0" == 1}checked{/if}{/nocache} />
</td>
</tr>
{/if}
</tbody>
</table>
</div>
<div class="panel-footer">
<input type="submit" value="Update" class="btn btn-success btn-sm">
</div>
</form>
</div>
</div>
<div class="col-lg-8">

View File

@ -0,0 +1,5 @@
One of your workers is currently IDLE: <b>{nocache}{$DATA.worker}{/nocache}</b><br/>
We have not received any shares for this worker in the past 10 minutes.<br/>
Since monitoring is enabled for this worker, this notification was sent.<br/>
<br />
Please check your workers!

View File

@ -0,0 +1 @@
{nocache}Block Number <b>{$DATA.height}</b> has been discovered by <b>{$DATA.finder}</b> with a total value of <b>{$DATA.amount} {$DATA.currency}</b>! The current difficulty is {$DATA.difficulty}.{/nocache}

View File

@ -0,0 +1 @@
You account has been debited and the coins have been sent to your wallet.Amount: {nocache}<b>{$DATA.amount} {$DATA.currency}</b>{/nocache}

View File

@ -0,0 +1,5 @@
Your account has successfully logged in<br/>
User: <b>{$DATA.LOGINUSER}</b><br/>
IP: <b>{$DATA.LOGINIP}</b><br/>
Time: <b>{$DATA.LOGINTIME}</b><br/>
If you initiated this login, you can ignore this message. If you did NOT, please notify an administrator.

View File

@ -0,0 +1,37 @@
<?php
function run_102() {
// Ugly but haven't found a better way
global $setting, $config, $coin_address, $user, $mysqli;
// Version information
$db_version_old = '1.0.1'; // What version do we expect
$db_version_new = '1.0.2'; // What is the new version we wish to upgrade to
$db_version_now = $setting->getValue('DB_VERSION'); // Our actual version installed
// Upgrade specific variables
$aSql[] = "
CREATE TABLE IF NOT EXISTS `user_settings` (
`account_id` int(11) NOT NULL,
`name` varchar(50) NOT NULL,
`value` text DEFAULT NULL,
PRIMARY KEY (`account_id`,`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;
";
$aSql[] = "UPDATE " . $setting->getTableName() . " SET value = '".$db_version_new."' WHERE name = 'DB_VERSION'";
if ($db_version_now == $db_version_old && version_compare($db_version_now, DB_VERSION, '<')) {
// Run the upgrade
echo '- Starting database migration to version ' . $db_version_new . PHP_EOL;
foreach ($aSql as $sql) {
echo '- Preparing: ' . $sql . PHP_EOL;
$stmt = $mysqli->prepare($sql);
if ($stmt && $stmt->execute()) {
echo '- success' . PHP_EOL;
} else {
echo '- failed: ' . $mysqli->error . PHP_EOL;
exit(1);
}
}
}
}
?>