| @@ 1219-1275 (lines=57) @@ | ||
| 1216 | } |
|
| 1217 | ||
| 1218 | // Are we allowing stat collection? |
|
| 1219 | if (!empty($_POST['stats']) && substr($boardurl, 0, 16) != 'http://localhost' && empty($modSettings['allow_sm_stats']) && empty($modSettings['enable_sm_stats'])) |
|
| 1220 | { |
|
| 1221 | $upcontext['allow_sm_stats'] = true; |
|
| 1222 | ||
| 1223 | // Don't register if we still have a key. |
|
| 1224 | if (empty($modSettings['sm_stats_key'])) |
|
| 1225 | { |
|
| 1226 | // Attempt to register the site etc. |
|
| 1227 | $fp = @fsockopen('www.simplemachines.org', 80, $errno, $errstr); |
|
| 1228 | if ($fp) |
|
| 1229 | { |
|
| 1230 | $out = 'GET /smf/stats/register_stats.php?site=' . base64_encode($boardurl) . ' HTTP/1.1' . "\r\n"; |
|
| 1231 | $out .= 'Host: www.simplemachines.org' . "\r\n"; |
|
| 1232 | $out .= 'Connection: Close' . "\r\n\r\n"; |
|
| 1233 | fwrite($fp, $out); |
|
| 1234 | ||
| 1235 | $return_data = ''; |
|
| 1236 | while (!feof($fp)) |
|
| 1237 | $return_data .= fgets($fp, 128); |
|
| 1238 | ||
| 1239 | fclose($fp); |
|
| 1240 | ||
| 1241 | // Get the unique site ID. |
|
| 1242 | preg_match('~SITE-ID:\s(\w{10})~', $return_data, $ID); |
|
| 1243 | ||
| 1244 | if (!empty($ID[1])) |
|
| 1245 | $smcFunc['db_insert']('replace', |
|
| 1246 | $db_prefix . 'settings', |
|
| 1247 | array('variable' => 'string', 'value' => 'string'), |
|
| 1248 | array( |
|
| 1249 | array('sm_stats_key', $ID[1]), |
|
| 1250 | array('enable_sm_stats', 1), |
|
| 1251 | ), |
|
| 1252 | array('variable') |
|
| 1253 | ); |
|
| 1254 | } |
|
| 1255 | } |
|
| 1256 | else |
|
| 1257 | { |
|
| 1258 | $smcFunc['db_insert']('replace', |
|
| 1259 | $db_prefix . 'settings', |
|
| 1260 | array('variable' => 'string', 'value' => 'string'), |
|
| 1261 | array('enable_sm_stats', 1), |
|
| 1262 | array('variable') |
|
| 1263 | ); |
|
| 1264 | } |
|
| 1265 | } |
|
| 1266 | // Don't remove stat collection unless we unchecked the box for real, not from the loop. |
|
| 1267 | elseif (empty($_POST['stats']) && empty($upcontext['allow_sm_stats'])) |
|
| 1268 | $smcFunc['db_query']('', ' |
|
| 1269 | DELETE FROM {db_prefix}settings |
|
| 1270 | WHERE variable = {string:enable_sm_stats}', |
|
| 1271 | array( |
|
| 1272 | 'enable_sm_stats' => 'enable_sm_stats', |
|
| 1273 | 'db_error_skip' => true, |
|
| 1274 | ) |
|
| 1275 | ); |
|
| 1276 | ||
| 1277 | // Are we enabling SSL? |
|
| 1278 | if (!empty($_POST['force_ssl'])) |
|
| @@ 930-986 (lines=57) @@ | ||
| 927 | return false; |
|
| 928 | ||
| 929 | // Firstly, if they're enabling SM stat collection just do it. |
|
| 930 | if (!empty($_POST['stats']) && substr($boardurl, 0, 16) != 'http://localhost' && empty($modSettings['allow_sm_stats']) && empty($modSettings['enable_sm_stats'])) |
|
| 931 | { |
|
| 932 | $upcontext['allow_sm_stats'] = true; |
|
| 933 | ||
| 934 | // Don't register if we still have a key. |
|
| 935 | if (empty($modSettings['sm_stats_key'])) |
|
| 936 | { |
|
| 937 | // Attempt to register the site etc. |
|
| 938 | $fp = @fsockopen('www.simplemachines.org', 80, $errno, $errstr); |
|
| 939 | if ($fp) |
|
| 940 | { |
|
| 941 | $out = 'GET /smf/stats/register_stats.php?site=' . base64_encode($boardurl) . ' HTTP/1.1' . "\r\n"; |
|
| 942 | $out .= 'Host: www.simplemachines.org' . "\r\n"; |
|
| 943 | $out .= 'Connection: Close' . "\r\n\r\n"; |
|
| 944 | fwrite($fp, $out); |
|
| 945 | ||
| 946 | $return_data = ''; |
|
| 947 | while (!feof($fp)) |
|
| 948 | $return_data .= fgets($fp, 128); |
|
| 949 | ||
| 950 | fclose($fp); |
|
| 951 | ||
| 952 | // Get the unique site ID. |
|
| 953 | preg_match('~SITE-ID:\s(\w{10})~', $return_data, $ID); |
|
| 954 | ||
| 955 | if (!empty($ID[1])) |
|
| 956 | $smcFunc['db_insert']('replace', |
|
| 957 | $db_prefix . 'settings', |
|
| 958 | array('variable' => 'string', 'value' => 'string'), |
|
| 959 | array( |
|
| 960 | array('sm_stats_key', $ID[1]), |
|
| 961 | array('enable_sm_stats', 1), |
|
| 962 | ), |
|
| 963 | array('variable') |
|
| 964 | ); |
|
| 965 | } |
|
| 966 | } |
|
| 967 | else |
|
| 968 | { |
|
| 969 | $smcFunc['db_insert']('replace', |
|
| 970 | $db_prefix . 'settings', |
|
| 971 | array('variable' => 'string', 'value' => 'string'), |
|
| 972 | array('enable_sm_stats', 1), |
|
| 973 | array('variable') |
|
| 974 | ); |
|
| 975 | } |
|
| 976 | } |
|
| 977 | // Don't remove stat collection unless we unchecked the box for real, not from the loop. |
|
| 978 | elseif (empty($_POST['stats']) && empty($upcontext['allow_sm_stats'])) |
|
| 979 | $smcFunc['db_query']('', ' |
|
| 980 | DELETE FROM {db_prefix}settings |
|
| 981 | WHERE variable = {string:enable_sm_stats}', |
|
| 982 | array( |
|
| 983 | 'enable_sm_stats' => 'enable_sm_stats', |
|
| 984 | 'db_error_skip' => true, |
|
| 985 | ) |
|
| 986 | ); |
|
| 987 | ||
| 988 | // Deleting old karma stuff? |
|
| 989 | if (!empty($_POST['delete_karma'])) |
|