Merge pull request #2632 from MPOS/development

UPDATE : Development to Master
This commit is contained in:
Sebastian Grewe 2017-11-02 09:49:15 +00:00 committed by GitHub
commit 02581f1ea3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 71 additions and 61 deletions

View File

@ -30,7 +30,7 @@ These people have supported this project with a donation:
* [WKNiGHT](https://github.com/WKNiGHT-) * [WKNiGHT](https://github.com/WKNiGHT-)
* [ZC](https://github.com/zccopwrx) * [ZC](https://github.com/zccopwrx)
* Nutnut * Nutnut
* Caberhagen (http://litecoin-pool.ch) * Caberhagen (https://coin-mining.ch)
* Mining4All (https://www.mining4all.eu/) * Mining4All (https://www.mining4all.eu/)
* [xisi](https://github.com/xisi) * [xisi](https://github.com/xisi)
* [PCFiL](https://github.com/PCFiL) * [PCFiL](https://github.com/PCFiL)

View File

@ -28,7 +28,13 @@ require_once('shared.inc.php');
// Fetch our last block found from the DB as a starting point // Fetch our last block found from the DB as a starting point
$aLastBlock = @$block->getLastValid(); $aLastBlock = @$block->getLastValid();
$strLastBlockHash = $aLastBlock['blockhash']; $strLastBlockHash = $aLastBlock['blockhash'];
if (!$strLastBlockHash) $strLastBlockHash = ''; if (!$strLastBlockHash) {
try {
$strLastBlockHash = $bitcoin->getblockhash(1);
} catch (Exception $e) {
$strLastBlockHash = "";
}
}
// Fetch all transactions since our last block // Fetch all transactions since our last block
if ( $bitcoin->can_connect() === true ){ if ( $bitcoin->can_connect() === true ){

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

@ -292,6 +292,7 @@ class User extends Base {
count($aPin) == 1 ? $pin_hash = $this->getHash($pin, 0) : $pin_hash = $this->getHash($pin, $aPin[1], $aPin[2]); count($aPin) == 1 ? $pin_hash = $this->getHash($pin, 0) : $pin_hash = $this->getHash($pin, $aPin[1], $aPin[2]);
$stmt = $this->mysqli->prepare("SELECT pin FROM $this->table WHERE id = ? AND pin = ? LIMIT 1"); $stmt = $this->mysqli->prepare("SELECT pin FROM $this->table WHERE id = ? AND pin = ? LIMIT 1");
if ($stmt->bind_param('is', $userId, $pin_hash) && $stmt->execute() && $stmt->bind_result($row_pin) && $stmt->fetch()) { if ($stmt->bind_param('is', $userId, $pin_hash) && $stmt->execute() && $stmt->bind_result($row_pin) && $stmt->fetch()) {
$stmt->close();
$this->setUserPinFailed($userId, 0); $this->setUserPinFailed($userId, 0);
return ($pin_hash === $row_pin); return ($pin_hash === $row_pin);
} }
@ -666,7 +667,7 @@ class User extends Base {
// Enforce a page reload and point towards login with referrer included, if supplied // Enforce a page reload and point towards login with referrer included, if supplied
$port = ($_SERVER["SERVER_PORT"] == "80" || $_SERVER["SERVER_PORT"] == "443") ? "" : (":".$_SERVER["SERVER_PORT"]); $port = ($_SERVER["SERVER_PORT"] == "80" || $_SERVER["SERVER_PORT"] == "443") ? "" : (":".$_SERVER["SERVER_PORT"]);
$pushto = $_SERVER['SCRIPT_NAME'].'?page=login'; $pushto = $_SERVER['SCRIPT_NAME'].'?page=login';
$location = (@$_SERVER['HTTPS'] == 'on') ? 'https://' . $_SERVER['SERVER_NAME'] . $port . $pushto : 'http://' . $_SERVER['SERVER_NAME'] . $port . $pushto; $location = (@$_SERVER['HTTPS'] == 'on') ? 'https://' . $_SERVER['HTTP_HOST'] . $port . $pushto : 'http://' . $_SERVER['HTTP_HOST'] . $port . $pushto;
if (!headers_sent()) header('Location: ' . $location); if (!headers_sent()) header('Location: ' . $location);
exit('<meta http-equiv="refresh" content="0; url=' . $location . '"/>'); exit('<meta http-equiv="refresh" content="0; url=' . $location . '"/>');
} }

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

View File

@ -687,7 +687,7 @@ class Swift_Mime_SimpleMimeEntity implements Swift_Mime_MimeEntity
protected function getRandomId() protected function getRandomId()
{ {
$idLeft = md5(getmypid() . '.' . time() . '.' . uniqid(mt_rand(), true)); $idLeft = md5(getmypid() . '.' . time() . '.' . uniqid(mt_rand(), true));
$idRight = !empty($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : 'swift.generated'; $idRight = !empty($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : 'swift.generated';
$id = $idLeft . '@' . $idRight; $id = $idLeft . '@' . $idRight;
try { try {

View File

@ -477,10 +477,10 @@ abstract class Swift_Transport_AbstractSmtpTransport implements Swift_Transport
/** Try to determine the hostname of the server this is run on */ /** Try to determine the hostname of the server this is run on */
private function _lookupHostname() private function _lookupHostname()
{ {
if (!empty($_SERVER['SERVER_NAME']) if (!empty($_SERVER['HTTP_HOST'])
&& $this->_isFqdn($_SERVER['SERVER_NAME'])) && $this->_isFqdn($_SERVER['HTTP_HOST']))
{ {
$this->_domain = $_SERVER['SERVER_NAME']; $this->_domain = $_SERVER['HTTP_HOST'];
} elseif (!empty($_SERVER['SERVER_ADDR'])) { } elseif (!empty($_SERVER['SERVER_ADDR'])) {
$this->_domain = sprintf('[%s]', $_SERVER['SERVER_ADDR']); $this->_domain = sprintf('[%s]', $_SERVER['SERVER_ADDR']);
} }

View File

@ -6,7 +6,7 @@ if ($user->isAuthenticated()) {
$user->setUserFailed($_SESSION['USERDATA']['id'], 0); $user->setUserFailed($_SESSION['USERDATA']['id'], 0);
$port = ($_SERVER["SERVER_PORT"] == "80" || $_SERVER["SERVER_PORT"] == "443") ? "" : (":".$_SERVER["SERVER_PORT"]); $port = ($_SERVER["SERVER_PORT"] == "80" || $_SERVER["SERVER_PORT"] == "443") ? "" : (":".$_SERVER["SERVER_PORT"]);
$pushto = $_SERVER['SCRIPT_NAME'].'?page=dashboard'; $pushto = $_SERVER['SCRIPT_NAME'].'?page=dashboard';
$location = (@$_SERVER['HTTPS'] == 'on') ? 'https://' . $_SERVER['SERVER_NAME'] . $port . $pushto : 'http://' . $_SERVER['SERVER_NAME'] . $port . $pushto; $location = (@$_SERVER['HTTPS'] == 'on') ? 'https://' . $_SERVER['HTTP_HOST'] . $port . $pushto : 'http://' . $_SERVER['HTTP_HOST'] . $port . $pushto;
header("Location: " . $location); header("Location: " . $location);
} }
// Somehow we still need to load this empty template // Somehow we still need to load this empty template

View File

@ -29,7 +29,7 @@ if (!empty($_POST['username']) && !empty($_POST['password'])) {
if ($user->checkLogin(@$_POST['username'], @$_POST['password']) ) { if ($user->checkLogin(@$_POST['username'], @$_POST['password']) ) {
$port = ($_SERVER["SERVER_PORT"] == "80" || $_SERVER["SERVER_PORT"] == "443") ? "" : (":".$_SERVER["SERVER_PORT"]); $port = ($_SERVER["SERVER_PORT"] == "80" || $_SERVER["SERVER_PORT"] == "443") ? "" : (":".$_SERVER["SERVER_PORT"]);
$location = (@$_SERVER['HTTPS'] == "on") ? 'https://' : 'http://'; $location = (@$_SERVER['HTTPS'] == "on") ? 'https://' : 'http://';
$location .= $_SERVER['SERVER_NAME'] . $port . $_SERVER['SCRIPT_NAME']; $location .= $_SERVER['HTTP_HOST'] . $port . $_SERVER['SCRIPT_NAME'];
$location.= '?page=dashboard'; $location.= '?page=dashboard';
if (!headers_sent()) header('Location: ' . $location); if (!headers_sent()) header('Location: ' . $location);
exit('<meta http-equiv="refresh" content="0; url=' . htmlspecialchars($location) . '"/>'); exit('<meta http-equiv="refresh" content="0; url=' . htmlspecialchars($location) . '"/>');

View File

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

View File

@ -40,7 +40,7 @@ define("BASEPATH", dirname(__FILE__) . "/");
include_once(BASEPATH . '../include/bootstrap.php'); include_once(BASEPATH . '../include/bootstrap.php');
// switch to https if config option is enabled // switch to https if config option is enabled
$hts = ($config['https_only'] && (!empty($_SERVER['QUERY_STRING']))) ? "https://".$_SERVER['SERVER_NAME'].$_SERVER['SCRIPT_NAME']."?".$_SERVER['QUERY_STRING'] : "https://".$_SERVER['SERVER_NAME'].$_SERVER['SCRIPT_NAME']; $hts = ($config['https_only'] && (!empty($_SERVER['QUERY_STRING']))) ? "https://".$_SERVER['HTTP_HOST'].$_SERVER['SCRIPT_NAME']."?".$_SERVER['QUERY_STRING'] : "https://".$_SERVER['HTTP_HOST'].$_SERVER['SCRIPT_NAME'];
($config['https_only'] && @!$_SERVER['HTTPS']) ? exit(header("Location: ".$hts)):0; ($config['https_only'] && @!$_SERVER['HTTPS']) ? exit(header("Location: ".$hts)):0;
// Rate limiting, we use our initilized memcache from bootstrap/autoloader // Rate limiting, we use our initilized memcache from bootstrap/autoloader

View File

@ -2,7 +2,7 @@
<div class="col-lg-12"> <div class="col-lg-12">
<div class="panel panel-info"> <div class="panel panel-info">
<div class="panel-heading"> <div class="panel-heading">
<i class="fa fa-info fa-fw"></i> Frequently Asked Questions <i class="fa fa-info fa-fw"></i>Frequently Asked Questions
</div> </div>
<div class="panel-body"> <div class="panel-body">
<ul> <ul>
@ -14,11 +14,11 @@
{/if} {/if}
{if $GLOBAL.config.payout_system == 'pplns'} {if $GLOBAL.config.payout_system == 'pplns'}
<br> <br>
<b>Pay Per Last N Shares (PPLNS)</b> - Block rewards are distributed among the last shares, disregarding round boundaries. In the accurate implementation, the number of shares is deter- mined so that their total will be a specified quantity of score (where the score of a share is the inverse of the difficulty). Most pools use a naive implementation based on a fixed number of shares or a fixed multiple of the difficulty. The share-variance can be reduced at the cost of increased maturity time, but there is no way to decrease the long-term pool-variance. <b>Pay Per Last N Shares (PPLNS)</b> - Block rewards are distributed among the last shares, disregarding round boundaries. In the accurate implementation, the number of shares is determined so that their total will be a specified quantity of score (where the score of a share is the inverse of the difficulty). Most pools use a naive implementation based on a fixed number of shares or a fixed multiple of the difficulty. The share-variance can be reduced at the cost of increased maturity time, but there is no way to decrease the long-term pool-variance.
{/if} {/if}
{if $GLOBAL.config.payout_system == 'pps'} {if $GLOBAL.config.payout_system == 'pps'}
<br> <br>
<b>Pay Per Share (PPS)</b> - Each share receives a fixed reward known in advance. This is the ultimate low- variance, low-maturity simple method, but has the highest risk for the operator, and hence lower expected returns than other methods and risk of collapse if not managed properly. <b>Pay Per Share (PPS)</b> - Each share receives a fixed reward known in advance. This is the ultimate low-variance, low-maturity simple method, but has the highest risk for the operator, and hence lower expected returns than other methods and risk of collapse if not managed properly.
{/if} {/if}
<br><br> <br><br>
<li><b><i>Q: What is a orphan block?</b></i></li> <li><b><i>Q: What is a orphan block?</b></i></li>
@ -48,7 +48,7 @@
</ul> </ul>
</div> </div>
<div class="panel-footer"> <div class="panel-footer">
<h6>This Pool is running <a href="https://github.com/TheSerapher/php-mpos">MPOS</a> project code. This frontend was created by TheSerapher aka Sebastian Grewe. The operation of the pool is soley at the hand of your trusted pool operator.</h6> <h6>This Pool is running <a href="https://github.com/TheSerapher/php-mpos">MPOS</a> project code. This frontend was created by <a href="https://github.com/MPOS/php-mpos"TheSerapher aka Sebastian Grewe</a>. The operation of the pool is soley at the hand of your trusted pool operator.</h6>
</div> </div>
</div> </div>
</div> </div>