-
Notifications
You must be signed in to change notification settings - Fork 0
/
header.php
47 lines (43 loc) · 1.8 KB
/
header.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
function ce_microtime()
{
list($usec, $sec) = explode(" ",microtime());
return ((float)$usec + (float)$sec);
}
function ce_diff_microtime($ts = 0)
{
$now = ce_microtime();
if ( $ts > 0 )
{
return (float)$now - (float)$ts;
}
elseif ( defined('CE_START') )
{
return (float)$now - (float)CE_START;
}
else return (float)0;
}
define ("CE_START", ce_microtime());
define ("CE_MEM_START", memory_get_usage());
$hostName = (isset($_SERVER['HTTP_HOST'])) ? $_SERVER['HTTP_HOST'] : $_SERVER['SCRIPT_NAME'];
if (!empty($_SERVER["REQUEST_URI"])) $hostName .= $_SERVER["REQUEST_URI"];
$hostName = ''.(int)posix_getpid().' '.$hostName;
define('CE_HOSTNAME',$hostName);
openlog($hostName, LOG_ODELAY, LOG_LOCAL7);
$remoteAddr = (isset($_SERVER['REMOTE_ADDR'])) ? $_SERVER['REMOTE_ADDR'] : '0.0.0.0';
define ('IS_SMESH_IP',(bool)preg_match('/^90\.146\.194\.80$|^81\.10\.170\.10$/',$remoteAddr));
define ('CE_DEBUG', ( IS_SMESH_IP && ( defined('CE_FORCE_DEBUG') || strpos($_SERVER['REQUEST_URI'],'debug') )));
if (CE_DEBUG) error_reporting(E_ALL);
if (isset($_SERVER['REQUEST_URI']) && preg_match('/assetmanager\.php|autodiscover\.xml|FCKeditor|wp-login\.php|myluph\.php|jsp$|wget|curl|cfm$|asp$|aspx$|_vti_pvt|~guest|~log/i',$_SERVER['REQUEST_URI']))
{
syslog(LOG_INFO,'Read access forbidden ----> '.$_SERVER['REMOTE_ADDR']);
header("HTTP/1.1 403 Forbidden");
exit('403 Forbidden');
}
#
# check for robots and badly behaving IPs
#
$robots = '/^ApacheBench|^Java|WebDAV|X11|check|Qwantify|PECL|Gigablast|Jakarta|Java|Ruby|bot|spider|crawl|index|PycURL|curl|voyager|HTMLDOC|slurp|unknown|Ocelli|BorderManager|find|dig|Francis|psycheclone|larbin|search|seek|wwwtype|siteexplorer|^WebC-I/i';
define ('IS_ROBOT', isset($_SERVER['HTTP_USER_AGENT']) && preg_match($robots , $_SERVER['HTTP_USER_AGENT']));
putenv("TZ=Europe/Vienna");
?>