]> git.openstreetmap.org Git - nominatim.git/blob - lib/init-website.php
Merge remote-tracking branch 'upstream/master'
[nominatim.git] / lib / init-website.php
1 <?php
2     require_once('init.php');
3
4     header('Content-type: text/html; charset=utf-8');
5
6     // check blocks in place for external servers
7     if (strpos($_SERVER["REMOTE_ADDR"],'193.63.75.') !== 0 &&
8         strpos(CONST_WhitelistedIPs, ','.$_SERVER["REMOTE_ADDR"].',') === false)
9     {
10
11         if (strpos(CONST_BlockedIPs, ','.$_SERVER["REMOTE_ADDR"].',') !== false)
12         {
13             header('HTTP/1.0 403 Forbidden');
14             header('Content-type: text/html; charset=utf-8');
15             echo "<html><body><h1>Access blocked</h1>";
16             echo "Your IP has been blocked for overusing OpenStreetMap's volunteer-run servers.<br> \n";
17             echo 'Please consult the <a href="http://wiki.openstreetmap.org/wiki/Nominatim_usage_policy">Nominatim usage policy</a> for more information.';
18             echo "\n</body></html>\n";
19             exit;
20         }
21
22         $sTempBlockedIP = file_get_contents(CONST_IPBanFile);
23         if (preg_match('/\b'.$_SERVER["REMOTE_ADDR"].'\b/', $sTempBlockedIP))
24         {
25             header('HTTP/1.0 503 Service Temporarily Unavailable');
26             header('Content-type: text/html; charset=utf-8');
27             echo "<html><body><h1>Access blocked</h1>";
28             echo "Your IP has been blocked temporarily for overusing OpenStreetMap's volunteer-run servers. This ban will be lifted automatically in a while. To avoid further blocks, please read the<br> \n";
29             echo '<a href="http://wiki.openstreetmap.org/wiki/Nominatim_usage_policy">Nominatim usage policy</a> carefully before you continue to use this service.';
30             echo "\n</body></html>\n";
31             exit;
32         }
33
34     }