Skip to content

Commit 4e7eb89

Browse files
committed
Merge pull request #2441 from xisi/dev-adminchecks-move
Move admin_checks to admin panel/system/setup
2 parents d4a161a + 8dba76c commit 4e7eb89

14 files changed

+343
-156
lines changed

CHANGELOG.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
1.0.3 (XXX XXth 2015)
1+
1.0.4 (Jun 19th 2015)
22
---------------------
3-
43
* Honor anonymous attribute when sending block finder mails
54
* Display admin warning if no transfer fees are set
5+
* Moved admin_checks.php into the admin panel/system/setup
6+
* Checks are now loaded individually from pages/admin/checks
67

78
1.0.3 (Apr 29th 2015)
89
---------------------

cronjobs/findblock.php

+6-2
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,12 @@
157157
// Notify users
158158
$aAccounts = $notification->getNotificationAccountIdByType('new_block');
159159
if (is_array($aAccounts)) {
160-
161-
$finder = $user->getUserName($iAccountId);
160+
if ($user->getUserNameAnon($iAccountId) == 1) {
161+
$finder = "Anonymous";
162+
} else {
163+
$finder = $user->getUserName($iAccountId);
164+
}
165+
162166
foreach ($aAccounts as $aData) {
163167
$aMailData['height'] = $aBlock['height'];
164168
$aMailData['subject'] = 'New Block';

include/admin_checks.php

-150
This file was deleted.

include/classes/user.class.php

+3
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ private function getHash($string, $version=0, $pepper='') {
3131
public function getUserName($id) {
3232
return $this->getSingle($id, 'username', 'id');
3333
}
34+
public function getUserNameAnon($id) {
35+
return $this->getSingle($id, 'is_anonymous', 'id');
36+
}
3437
public function getUserNameByEmail($email) {
3538
return $this->getSingle($email, 'username', 'email', 's');
3639
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?php
2+
$defflip = (!cfip()) ? exit(header('HTTP/1.1 401 Unauthorized')) : 1;
3+
4+
// check if daemon can connect -> error
5+
try {
6+
if ($bitcoin->can_connect() !== true) {
7+
$newerror = array();
8+
$newerror['name'] = "Coin daemon";
9+
$newerror['level'] = 3;
10+
$newerror['description'] = "Unable to connect to coin daemon using provided credentials.";
11+
$newerror['configvalue'] = "wallet.*";
12+
$newerror['extdesc'] = "We weren't able to connect to your coin daemon using the host/username/password/port given in the config. Check that your coin daemon is running and mpos is configured with the data from your coin daemon config. Your coin daemon may also not yet be fully synced.";
13+
$newerror['helplink'] = "https://github.com/MPOS/php-mpos/wiki/Config-Setup#wiki-local-wallet-rpc";
14+
$error[] = $newerror;
15+
$newerror = null;
16+
}
17+
else {
18+
// validate that the wallet service is not in test mode
19+
if ($bitcoin->is_testnet() == true) {
20+
$newerror = array();
21+
$newerror['name'] = "Coin daemon";
22+
$newerror['level'] = 3;
23+
$newerror['extdesc'] = "You may have accidentally mistyped the port, or are running the coin daemon in testnet mode. Check your coin daemon config and MPOS config.";
24+
$newerror['description'] = "The coin daemon service is running as a testnet. Check the TESTNET setting in your coin daemon config and make sure the correct port is set in the MPOS config.";
25+
$newerror['configvalue'] = "wallet.host";
26+
$newerror['helplink'] = "https://github.com/MPOS/php-mpos/wiki/Config-Setup#wiki-local-wallet-rpc";
27+
$error[] = $newerror;
28+
$newerror = null;
29+
}
30+
// check if there is more than one account set on wallet
31+
$accounts = $bitcoin->listaccounts();
32+
if (count($accounts) > 1 && $accounts[''] <= 0) {
33+
$newerror = array();
34+
$newerror['name'] = "Coin daemon";
35+
$newerror['level'] = 3;
36+
$newerror['extdesc'] = "You need at least one account to be able to pay miners! Your coin daemon may not yet be fully synced, see the above link for more details.";
37+
$newerror['description'] = "There are " . count($accounts) . " Accounts set in local Wallet and Default Account has no liquid funds to pay your miners!";
38+
$newerror['configvalue'] = "wallet.host";
39+
$newerror['helplink'] = "https://github.com/MPOS/php-mpos/wiki/Config-Setup#wiki-local-wallet-rpc";
40+
$error[] = $newerror;
41+
$newerror = null;
42+
}
43+
}
44+
} catch (Exception $e) {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
$defflip = (!cfip()) ? exit(header('HTTP/1.1 401 Unauthorized')) : 1;
3+
4+
// check if fees are 0 and ap/mp tx fees are also set to 0 -> issue #2424
5+
if ($config['fees'] == 0 && ($config['txfee_auto'] == 0 || $config['txfee_manual'] == 0)) {
6+
$newerror = array();
7+
$newerror['name'] = "Fees and TX Fees 0";
8+
$newerror['level'] = 2;
9+
$newerror['extdesc'] = "This is an issue that can only occur with both your fees set to 0 and auto or manual tx fees set to 0 as well. It's best to avoid it if possible though, as it can prevent payouts; set the txfee to a small amount to avoid this.";
10+
$newerror['description'] = "Having your pool fees set to 0 and tx fees also set to 0 can cause a problem where the wallet cannot payout, consider setting the txfee to a very low amount, ie. 0.0001 to avoid this.";
11+
$newerror['configvalue'] = "fees";
12+
$newerror['helplink'] = "https://github.com/MPOS/php-mpos/issues/2424";
13+
$error[] = $newerror;
14+
$newerror = null;
15+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
<?php
2+
$defflip = (!cfip()) ? exit(header('HTTP/1.1 401 Unauthorized')) : 1;
3+
4+
// check if memcache isn't available but enabled in config -> error
5+
if (!class_exists('Memcached') && $config['memcache']['enabled']) {
6+
$newerror = array();
7+
$newerror['name'] = "Memcache Config";
8+
$newerror['level'] = 3;
9+
$newerror['extdesc'] = "Memcache is a service that you run that lets us cache commonly used data and access it quickly. It's highly recommended you <a href='https://github.com/MPOS/php-mpos/wiki/Quick-Start-Guide#requirements-1'>install the service and php packages</a> for your distro.";
10+
$newerror['description'] = "You have memcached enabled in your config and it's not available as a PHP module. Install the package on your system.";
11+
$newerror['configvalue'] = "memcache.enabled";
12+
$newerror['helplink'] = "https://github.com/MPOS/php-mpos/wiki/Config-Setup#wiki-memcache";
13+
$error[] = $newerror;
14+
$newerror = null;
15+
}
16+
17+
// if it's not enabled, test it if it exists, if it works -> error tell them to enable, -> otherwise notice it's disabled
18+
if (!$config['memcache']['enabled']) {
19+
if (PHP_OS == 'WINNT') {
20+
require_once(CLASS_DIR . 'memcached.class.php');
21+
}
22+
if (class_exists('Memcached')) {
23+
$memcache_test = @new Memcached();
24+
if ($config['memcache']['sasl'] === true) {
25+
$memcache_test->setOption(Memcached::OPT_BINARY_PROTOCOL, true);
26+
$memcache_test->setSaslAuthData($config['memcache']['sasl']['username'], $config['memcache']['sasl']['password']);
27+
}
28+
$memcache_test_add = @$memcache_test->addServer($config['memcache']['host'], $config['memcache']['port']);
29+
$randmctv = rand(5,10);
30+
$memcache_test_set = @$memcache_test->set('test_mpos_setval', $randmctv);
31+
$memcache_test_get = @$memcache_test->get('test_mpos_setval');
32+
}
33+
if (class_exists('Memcached') && $memcache_test_get == $randmctv) {
34+
$newerror = array();
35+
$newerror['name'] = "Memcache Config";
36+
$newerror['level'] = 2;
37+
$newerror['extdesc'] = "Memcache is a service that you run that lets us cache commonly used data and access it quickly. It's highly recommended you <a href='https://github.com/MPOS/php-mpos/wiki/Quick-Start-Guide#requirements-1'>install the service and php packages</a> for your distro.";
38+
$newerror['description'] = "You have memcache disabled in the config but it's available and works! Enable it for best performance.";
39+
$newerror['configvalue'] = "memcache.enabled";
40+
$newerror['helplink'] = "https://github.com/MPOS/php-mpos/wiki/Config-Setup#wiki-memcache";
41+
$error[] = $newerror;
42+
$newerror = null;
43+
} else {
44+
$newerror = array();
45+
$newerror['name'] = "Memcache Config";
46+
$newerror['level'] = 2;
47+
$newerror['extdesc'] = "Memcache is a service that you run that lets us cache commonly used data and access it quickly. It's highly recommended you <a href='https://github.com/MPOS/php-mpos/wiki/Quick-Start-Guide#requirements-1'>install the service and php packages</a> for your distro.";
48+
$newerror['description'] = "Memcache is disabled; Almost every linux distro has packages for it, you should be using it if you can.";
49+
$newerror['configvalue'] = "memcache.enabled";
50+
$newerror['helplink'] = "https://github.com/MPOS/php-mpos/wiki/Config-Setup#wiki-memcache";
51+
$error[] = $newerror;
52+
$newerror = null;
53+
}
54+
}
55+
56+
// check anti DOS protection, we need memcache for that
57+
if ($config['mc_antidos'] && !$config['memcache']['enabled']) {
58+
$newerror = array();
59+
$newerror['name'] = "Memcache Config";
60+
$newerror['level'] = 3;
61+
$newerror['extdesc'] = "Memcache is a service that you run that lets us cache commonly used data and access it quickly. It's highly recommended you <a href='https://github.com/MPOS/php-mpos/wiki/Quick-Start-Guide#requirements-1'>install the service and php packages</a> for your distro.";
62+
$newerror['description'] = "mc_antidos is enabled and memcache is not, <u>memcache is required</u> to use this.";
63+
$newerror['configvalue'] = "memcache.enabled";
64+
$newerror['helplink'] = "https://github.com/MPOS/php-mpos/wiki/Config-Setup#memcache-rate-limiting";
65+
$error[] = $newerror;
66+
$newerror = null;
67+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<?php
2+
$defflip = (!cfip()) ? exit(header('HTTP/1.1 401 Unauthorized')) : 1;
3+
4+
if ($config['logging']['enabled']) {
5+
// checks to see that the logging path is writable
6+
if (!is_writable($config['logging']['path'])) {
7+
$newerror = array();
8+
$newerror['name'] = "Log path permissions";
9+
$newerror['level'] = 3;
10+
$newerror['extdesc'] = "In order to log data, we need to be able to write in the logs folder. See the link above for more details.";
11+
$newerror['description'] = "Logging is enabled but we can't write in the logfile path.";
12+
$newerror['configvalue'] = "logging.path";
13+
$newerror['helplink'] = "https://github.com/MPOS/php-mpos/wiki/Quick-Start-Guide#configuration-1";
14+
$error[] = $newerror;
15+
$newerror = null;
16+
}
17+
}
18+
19+
// check if we can write templates/cache and templates/compile -> error
20+
if (!is_writable(TEMPLATE_DIR . '/cache')) {
21+
$newerror = array();
22+
$newerror['name'] = "templates/cache permissions";
23+
$newerror['level'] = 3;
24+
$newerror['extdesc'] = "In order to cache template data, we need to be able to write in the templates/cache folder. See the link above for more details.";
25+
$newerror['description'] = "templates/cache folder is not writable for uid {$apache_user['name']}";
26+
$newerror['configvalue'] = "templates/cache folder";
27+
$newerror['helplink'] = "https://github.com/MPOS/php-mpos/wiki/Quick-Start-Guide#folder-permissions";
28+
$error[] = $newerror;
29+
$newerror = null;
30+
}
31+
if (!is_writable(TEMPLATE_DIR . '/compile')) {
32+
$newerror = array();
33+
$newerror['name'] = "templates/compile permissions";
34+
$newerror['level'] = 3;
35+
$newerror['extdesc'] = "In order to cache compiled template data, we need to be able to write in the templates/compile folder. See the link above for more details.";
36+
$newerror['description'] = "templates/compile folder is not writable for uid {$apache_user['name']}";
37+
$newerror['configvalue'] = "templates/compile folder";
38+
$newerror['helplink'] = "https://github.com/MPOS/php-mpos/wiki/Quick-Start-Guide#folder-permissions";
39+
$error[] = $newerror;
40+
$newerror = null;
41+
}
42+
43+
// check if we can write the config files, we should NOT be able to -> error
44+
if (is_writable(INCLUDE_DIR.'/config/global.inc.php') || is_writable(INCLUDE_DIR.'/config/global.inc.dist.php') ||
45+
is_writable(INCLUDE_DIR.'/config/security.inc.php') || is_writable(INCLUDE_DIR.'/config/security.inc.dist.php')) {
46+
$newerror = array();
47+
$newerror['name'] = "Config permissions";
48+
$newerror['level'] = 2;
49+
$newerror['extdesc'] = "For security purposes, the user your webserver runs as should not be able to write to the config files, only read from them. To fix this, check the ownership and permissions of the include/config files.";
50+
$newerror['description'] = "Your config files <b>SHOULD NOT be writable by this user</b>!";
51+
$newerror['configvalue'] = "global.inc.php and security.inc.php";
52+
$newerror['helplink'] = "https://github.com/MPOS/php-mpos/wiki/Quick-Start-Guide#configuration-1";
53+
$error[] = $newerror;
54+
$newerror = null;
55+
}

0 commit comments

Comments
 (0)