Skip to content

Commit 02581f1

Browse files
authored
Merge pull request #2632 from MPOS/development
UPDATE : Development to Master
2 parents e2a3536 + eedbaba commit 02581f1

File tree

14 files changed

+71
-61
lines changed

14 files changed

+71
-61
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ These people have supported this project with a donation:
3030
* [WKNiGHT](https://github.com/WKNiGHT-)
3131
* [ZC](https://github.com/zccopwrx)
3232
* Nutnut
33-
* Caberhagen (http://litecoin-pool.ch)
33+
* Caberhagen (https://coin-mining.ch)
3434
* Mining4All (https://www.mining4all.eu/)
3535
* [xisi](https://github.com/xisi)
3636
* [PCFiL](https://github.com/PCFiL)

cronjobs/findblock.php

+7-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,13 @@
2828
// Fetch our last block found from the DB as a starting point
2929
$aLastBlock = @$block->getLastValid();
3030
$strLastBlockHash = $aLastBlock['blockhash'];
31-
if (!$strLastBlockHash) $strLastBlockHash = '';
31+
if (!$strLastBlockHash) {
32+
try {
33+
$strLastBlockHash = $bitcoin->getblockhash(1);
34+
} catch (Exception $e) {
35+
$strLastBlockHash = "";
36+
}
37+
}
3238

3339
// Fetch all transactions since our last block
3440
if ( $bitcoin->can_connect() === true ){

include/classes/notification.class.php

+5-3
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,9 @@ public function getNotificationSettings($account_id) {
105105
**/
106106
public function getNotificationAccountIdByType($strType) {
107107
$this->debug->append("STA " . __METHOD__, 4);
108-
$stmt = $this->mysqli->prepare("SELECT account_id FROM $this->tableSettings WHERE type = ? AND active = 1");
109-
if ($stmt && $stmt->bind_param('s', $strType) && $stmt->execute() && $result = $stmt->get_result()) {
108+
$stmt = $this->mysqli->prepare("SELECT account_id FROM $this->tableSettings WHERE type IN (?, ?) AND active = 1 GROUP BY account_id");
109+
$notStrType = substr('push_'.$strType, 0, 15);
110+
if ($stmt && $stmt->bind_param('ss', $strType, $notStrType) && $stmt->execute() && $result = $stmt->get_result()) {
110111
return $result->fetch_all(MYSQLI_ASSOC);
111112
}
112113
return $this->sqlError('E0046');
@@ -150,7 +151,8 @@ public function sendNotification($account_id, $strType, $aMailData) {
150151
}
151152
// Check if this user wants strType notifications
152153
$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+
$notStrType = substr('push_'.$strType, 0, 15);
155+
if ($stmt && $stmt->bind_param('ssi', $strType, $notStrType, $account_id) && $stmt->execute() && $result = $stmt->get_result()) {
154156
$types = array_map(function($a){ return reset($a);}, $result->fetch_all(MYSQLI_ASSOC));
155157
$stmt->close();
156158
$result = true;
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,42 @@
11
<?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-
}
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+
global $setting;
26+
curl_setopt_array($ch = curl_init(), array(
27+
CURLOPT_URL => "https://www.notifymyandroid.com/publicapi/notify",
28+
CURLOPT_POST => true,
29+
CURLOPT_RETURNTRANSFER => true,
30+
CURLOPT_POSTFIELDS => http_build_query($data = array(
31+
"apikey" => $this->apiKey,
32+
"application" => $setting->getValue('website_title')?:"PHP-MPOS",
33+
"description" => $message,
34+
"content-type" => "text/html",
35+
"event" => $event,
36+
"priority" => array_search($severity, self::$priorities),
37+
)),
38+
));
39+
curl_exec($ch);
40+
curl_close($ch);
41+
}
42+
}

include/classes/user.class.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,7 @@ public function checkPin($userId, $pin='') {
292292
count($aPin) == 1 ? $pin_hash = $this->getHash($pin, 0) : $pin_hash = $this->getHash($pin, $aPin[1], $aPin[2]);
293293
$stmt = $this->mysqli->prepare("SELECT pin FROM $this->table WHERE id = ? AND pin = ? LIMIT 1");
294294
if ($stmt->bind_param('is', $userId, $pin_hash) && $stmt->execute() && $stmt->bind_result($row_pin) && $stmt->fetch()) {
295+
$stmt->close();
295296
$this->setUserPinFailed($userId, 0);
296297
return ($pin_hash === $row_pin);
297298
}
@@ -666,7 +667,7 @@ public function logoutUser() {
666667
// Enforce a page reload and point towards login with referrer included, if supplied
667668
$port = ($_SERVER["SERVER_PORT"] == "80" || $_SERVER["SERVER_PORT"] == "443") ? "" : (":".$_SERVER["SERVER_PORT"]);
668669
$pushto = $_SERVER['SCRIPT_NAME'].'?page=login';
669-
$location = (@$_SERVER['HTTPS'] == 'on') ? 'https://' . $_SERVER['SERVER_NAME'] . $port . $pushto : 'http://' . $_SERVER['SERVER_NAME'] . $port . $pushto;
670+
$location = (@$_SERVER['HTTPS'] == 'on') ? 'https://' . $_SERVER['HTTP_HOST'] . $port . $pushto : 'http://' . $_SERVER['HTTP_HOST'] . $port . $pushto;
670671
if (!headers_sent()) header('Location: ' . $location);
671672
exit('<meta http-equiv="refresh" content="0; url=' . $location . '"/>');
672673
}

include/classes/usersettings.class.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ private function _storeValue($name, $value){
3131
if (empty(self::$__SetSTMT)){
3232
self::$__SetSTMT = $this->mysqli->prepare('REPLACE INTO '.$this->table.' (`account_id`, `name`, `value`) VALUES (?, ?, ?)');
3333
}
34-
if (!(self::$__SetSTMT && self::$__SetSTMT->bind_param('iss', $this->account_id, $name, serialize($value)) && self::$__SetSTMT->execute())) {
34+
$val = serialize($value);
35+
if (!(self::$__SetSTMT && self::$__SetSTMT->bind_param('iss', $this->account_id, $name, $val) && self::$__SetSTMT->execute())) {
3536
$this->setErrorMessage($this->getErrorMsg('E0084', $this->table));
3637
return $this->sqlError();
3738
}

include/classes/worker.class.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,7 @@ public function getWorker($id, $interval=600) {
124124
) AS shares
125125
FROM $this->table AS w
126126
WHERE id = ?");
127-
if ($this->checkStmt($stmt) && $stmt->bind_param('iiiii', $interval, $interval, $interval, $interval, $id) && $stmt->execute() && $result = $stmt->get_result()) {
128-
$row = $result->fetch_assoc();
127+
if ($this->checkStmt($stmt) && $stmt->bind_param('iiiii', $interval, $interval, $interval, $interval, $id) && $stmt->execute() && ($result = $stmt->get_result()) && ($row = $result->fetch_assoc())) {
129128
$row['hashrate'] = round($this->coin->calcHashrate($row['shares'], $interval), 2);
130129
if ($row['count_all'] > 0) {
131130
$row['difficulty'] = round($row['shares'] / $row['count_all'], 2);

include/lib/swiftmailer/classes/Swift/Mime/SimpleMimeEntity.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -687,7 +687,7 @@ protected function _clearCache()
687687
protected function getRandomId()
688688
{
689689
$idLeft = md5(getmypid() . '.' . time() . '.' . uniqid(mt_rand(), true));
690-
$idRight = !empty($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : 'swift.generated';
690+
$idRight = !empty($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : 'swift.generated';
691691
$id = $idLeft . '@' . $idRight;
692692

693693
try {

include/lib/swiftmailer/classes/Swift/Transport/AbstractSmtpTransport.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -477,10 +477,10 @@ private function _sendBcc(Swift_Mime_Message $message, $reversePath, array $bcc,
477477
/** Try to determine the hostname of the server this is run on */
478478
private function _lookupHostname()
479479
{
480-
if (!empty($_SERVER['SERVER_NAME'])
481-
&& $this->_isFqdn($_SERVER['SERVER_NAME']))
480+
if (!empty($_SERVER['HTTP_HOST'])
481+
&& $this->_isFqdn($_SERVER['HTTP_HOST']))
482482
{
483-
$this->_domain = $_SERVER['SERVER_NAME'];
483+
$this->_domain = $_SERVER['HTTP_HOST'];
484484
} elseif (!empty($_SERVER['SERVER_ADDR'])) {
485485
$this->_domain = sprintf('[%s]', $_SERVER['SERVER_ADDR']);
486486
}

include/pages/account/reset_failed.inc.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
$user->setUserFailed($_SESSION['USERDATA']['id'], 0);
77
$port = ($_SERVER["SERVER_PORT"] == "80" || $_SERVER["SERVER_PORT"] == "443") ? "" : (":".$_SERVER["SERVER_PORT"]);
88
$pushto = $_SERVER['SCRIPT_NAME'].'?page=dashboard';
9-
$location = (@$_SERVER['HTTPS'] == 'on') ? 'https://' . $_SERVER['SERVER_NAME'] . $port . $pushto : 'http://' . $_SERVER['SERVER_NAME'] . $port . $pushto;
9+
$location = (@$_SERVER['HTTPS'] == 'on') ? 'https://' . $_SERVER['HTTP_HOST'] . $port . $pushto : 'http://' . $_SERVER['HTTP_HOST'] . $port . $pushto;
1010
header("Location: " . $location);
1111
}
1212
// Somehow we still need to load this empty template

include/pages/login.inc.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
if ($user->checkLogin(@$_POST['username'], @$_POST['password']) ) {
3030
$port = ($_SERVER["SERVER_PORT"] == "80" || $_SERVER["SERVER_PORT"] == "443") ? "" : (":".$_SERVER["SERVER_PORT"]);
3131
$location = (@$_SERVER['HTTPS'] == "on") ? 'https://' : 'http://';
32-
$location .= $_SERVER['SERVER_NAME'] . $port . $_SERVER['SCRIPT_NAME'];
32+
$location .= $_SERVER['HTTP_HOST'] . $port . $_SERVER['SCRIPT_NAME'];
3333
$location.= '?page=dashboard';
3434
if (!headers_sent()) header('Location: ' . $location);
3535
exit('<meta http-equiv="refresh" content="0; url=' . htmlspecialchars($location) . '"/>');

include/version.inc.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
$defflip = (!cfip()) ? exit(header('HTTP/1.1 401 Unauthorized')) : 1;
33

4-
define('MPOS_VERSION', '1.0.7');
4+
define('MPOS_VERSION', '1.0.8');
55
define('DB_VERSION', '1.0.2');
66
define('CONFIG_VERSION', '1.0.1');
77
define('HASH_VERSION', 1);

public/index.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ function cfip() { return (@defined('SECURITY')) ? 1 : 0; }
4040
include_once(BASEPATH . '../include/bootstrap.php');
4141

4242
// switch to https if config option is enabled
43-
$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'];
43+
$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'];
4444
($config['https_only'] && @!$_SERVER['HTTPS']) ? exit(header("Location: ".$hts)):0;
4545

4646
// Rate limiting, we use our initilized memcache from bootstrap/autoloader

templates/bootstrap/about/pool/default.tpl

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<div class="col-lg-12">
33
<div class="panel panel-info">
44
<div class="panel-heading">
5-
<i class="fa fa-info fa-fw"></i> Frequently Asked Questions
5+
<i class="fa fa-info fa-fw"></i>Frequently Asked Questions
66
</div>
77
<div class="panel-body">
88
<ul>
@@ -14,11 +14,11 @@
1414
{/if}
1515
{if $GLOBAL.config.payout_system == 'pplns'}
1616
<br>
17-
<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.
17+
<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.
1818
{/if}
1919
{if $GLOBAL.config.payout_system == 'pps'}
2020
<br>
21-
<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.
21+
<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.
2222
{/if}
2323
<br><br>
2424
<li><b><i>Q: What is a orphan block?</b></i></li>
@@ -48,7 +48,7 @@
4848
</ul>
4949
</div>
5050
<div class="panel-footer">
51-
<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>
51+
<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>
5252
</div>
5353
</div>
5454
</div>

0 commit comments

Comments
 (0)