|
6 | 6 | $notice = array(); |
7 | 7 | $enotice = array(); |
8 | 8 | $error = array(); |
9 | | - |
| 9 | + |
10 | 10 | // setup some basic stuff for checking - getuid/getpwuid not available on mac/windows |
11 | 11 | $apache_user = 'unknown'; |
12 | 12 | if (substr_count(strtolower(PHP_OS), 'nix') > 0 || substr_count(strtolower(PHP_OS), 'linux') > 0) { |
13 | 13 | $apache_user = (function_exists('posix_getuid')) ? posix_getuid() : 'unknown'; |
14 | 14 | $apache_user = (function_exists('posix_getpwuid')) ? posix_getpwuid($apache_user) : $apache_user; |
15 | 15 | } |
16 | | - |
| 16 | + |
17 | 17 | // setup checks |
18 | 18 | // logging |
19 | 19 | if ($config['logging']['enabled']) { |
20 | 20 | if (!is_writable($config['logging']['path'])) { |
21 | | - $error[] = "Logging is enabled but we can't write in the logging path"; |
| 21 | + $error[] = "Logging is enabled but we can't write in the logfile path"; |
22 | 22 | } |
23 | 23 | } |
| 24 | + |
24 | 25 | // check if memcache isn't available but enabled in config -> error |
25 | 26 | if (!class_exists('Memcached') && $config['memcache']['enabled']) { |
26 | | - $error[] = "You have memcache enabled in your config and it's not available. Install the package on your system."; |
| 27 | + $error[] = "You have memcached enabled in your config and it's not available as a PHP module. Install the package on your system."; |
27 | 28 | } |
| 29 | + |
28 | 30 | // if it's not enabled, test it if it exists, if it works -> error tell them to enable, -> otherwise notice it's disabled |
29 | 31 | if (!$config['memcache']['enabled']) { |
30 | 32 | if (PHP_OS == 'WINNT') { |
|
38 | 40 | $memcache_test_get = @$memcache_test->get('test_mpos_setval'); |
39 | 41 | } |
40 | 42 | if (class_exists('Memcached') && $memcache_test_get == $randmctv) { |
41 | | - $error[] = "You have memcache disabled in the config and it's available & works! Enable it."; |
| 43 | + $error[] = "You have memcache disabled in the config but it's available and works! Enable it for best performance."; |
42 | 44 | } else { |
43 | 45 | $notice[] = "Memcache is disabled; Almost every linux distro has packages for it, you should be using it if you can."; |
44 | 46 | } |
45 | 47 | } |
| 48 | + |
46 | 49 | // check if htaccess exists |
47 | 50 | if (!file_exists(BASEPATH.".htaccess")) { |
48 | 51 | $htaccess_link = "<a href='https://github.com/MPOS/php-mpos/blob/next/public/.htaccess'>.htaccess</a>"; |
49 | | - $notice[] = "You don't seem to have a .htaccess in your public folder, if you're using apache set it up $htaccess_link"; |
| 52 | + $notice[] = "You don't seem to have a .htaccess in your public folder, if you're using Apache set it up: $htaccess_link"; |
50 | 53 | } |
| 54 | + |
51 | 55 | // check if we can write templates/cache and templates/compile -> error |
52 | 56 | if (!is_writable(THEME_DIR.'/cache')) { |
53 | 57 | $error[] = "templates/cache folder is not writable for uid {$apache_user['name']}"; |
54 | 58 | } |
55 | 59 | if (!is_writable(THEME_DIR.'/compile')) { |
56 | 60 | $error[] = "templates/compile folder is not writable for uid {$apache_user['name']}"; |
57 | 61 | } |
| 62 | + |
58 | 63 | // check if we can write the config files, we should NOT be able to -> error |
59 | 64 | if (is_writable(INCLUDE_DIR.'/config/global.inc.php') || is_writable(INCLUDE_DIR.'/config/global.inc.dist.php') || |
60 | 65 | is_writable(INCLUDE_DIR.'/config/security.inc.php') || is_writable(INCLUDE_DIR.'/config/security.inc.dist.php')) { |
61 | 66 | $error[] = "Your config files <b>SHOULD NOT be writable to this user</b>!"; |
62 | 67 | } |
| 68 | + |
63 | 69 | // check if daemon can connect -> error |
64 | 70 | try { |
65 | 71 | if ($bitcoin->can_connect() !== true) { |
|
76 | 82 | if (!$bitcoin->validateaddress($config['coldwallet']['address'])) |
77 | 83 | $error[] = "Your cold wallet address is <u>SET and INVALID</u>"; |
78 | 84 | } |
79 | | - |
| 85 | + |
80 | 86 | // check if there is more than one account set on wallet |
81 | 87 | $accounts = $bitcoin->listaccounts(); |
82 | 88 | if (count($accounts) > 1 && $accounts[''] <= 0) { |
|
85 | 91 | } |
86 | 92 | } catch (Exception $e) { |
87 | 93 | } |
88 | | - // if database connection fails -> error |
89 | | - $db_connect = new mysqli($config['db']['host'], $config['db']['user'], $config['db']['pass'], $config['db']['name'], $config['db']['port']); |
90 | | - if (mysqli_connect_errno() || !array_key_exists('client_info', $db_connect)) { |
91 | | - $error[] = "Unable to connect to mysql using provided credentials"; |
92 | | - } |
| 94 | + // check anti DOS protection, we need memcache for that |
93 | 95 | if ($config['mc_antidos'] && !$config['memcache']['enabled']) { |
94 | 96 | $error[] = "mc_antidos is enabled and memcache is not, <u>memcache is required</u> to use this"; |
95 | 97 | } |
| 98 | + |
96 | 99 | // poke stratum using gettingstarted details -> enotice |
97 | | - if (substr_count(strtolower(PHP_OS), 'nix') > 0) { |
98 | | - // unix *poke* |
99 | | - $socket = @socket_create(AF_INET, SOCK_STREAM, SOL_TCP); |
| 100 | + if (function_exists('socket_create')) { |
| 101 | + $socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); |
100 | 102 | if ($socket !== false) { |
101 | 103 | $address = @gethostbyname($config['gettingstarted']['stratumurl']); |
102 | 104 | $result = @socket_connect($socket, $address, $config['gettingstarted']['stratumport']); |
103 | 105 | if ($result !== true) { |
104 | | - $enotice[] = "We tried to poke your Stratum server using config->gettingstarted details but it didn't respond"; |
| 106 | + $enotice[] = 'We tried to poke your Stratum server using your $config[\'gettingstarted\'] settings but it didn\'t respond'; |
105 | 107 | } |
106 | 108 | $close = @socket_close($socket); |
107 | 109 | } |
108 | 110 | } else { |
109 | | - // mac/windows *poke* |
110 | | - if (! $fp = @fsockopen($config['gettingstarted']['stratumurl'],$config['gettingstarted']['stratumport'],$errCode,$errStr,1)) { |
111 | | - $enotice[] = "We tried to poke your Stratum server using config->gettingstarted details but it didn't respond"; |
| 111 | + // Connect via fsockopen as fallback |
| 112 | + if (! $fp = @fsockopen($config['gettingstarted']['stratumurl'], $config['gettingstarted']['stratumport'], $errCode, $errStr, 1)) { |
| 113 | + $enotice[] = 'We tried to poke your Stratum server using your $config[\'gettingstarted\'] settings but it didn\'t respond'; |
112 | 114 | } |
113 | 115 | @fclose($fp); |
114 | 116 | } |
115 | | - |
| 117 | + |
116 | 118 | // security checks |
117 | 119 | // salts too short -> notice, salts default -> error |
118 | 120 | if ((strlen($config['SALT']) < 24) || (strlen($config['SALTY']) < 24) || $config['SALT'] == 'PLEASEMAKEMESOMETHINGRANDOM' || $config['SALTY'] == 'THISSHOULDALSOBERRAANNDDOOM') { |
|
122 | 124 | $notice[] = "SALT or SALTY is too short, they should be more than 24 characters and changing them will require registering again"; |
123 | 125 | } |
124 | 126 | } |
125 | | - |
| 127 | + |
126 | 128 | // display the errors |
127 | 129 | foreach ($enotice as $en) { |
128 | 130 | $_SESSION['POPUP'][] = array('CONTENT' => $en, 'TYPE' => 'info'); |
|
0 commit comments