[TYPO3-dev] firewall

Franz Holzinger franz at fholzinger.com
Sun Dec 24 09:14:46 CET 2006


Hello,

there is a way to get rid of unwanted visitors from your homepage. You 
will probably want this when you are absent for a while.
Collect the unwanted ip addresses with the tt_guest and tt_board extensions.

Adapt and copy the attached file into your typo3conf folder.

Then modify the file
typo3/sysext/cms/tslib/index_ts.php

...
define('PATH_typo3conf', PATH_site.'typo3conf/');
define('TYPO3_mainDir', 'typo3/');		// This is the directory of the 
backend administration for the sites of this TYPO3 installation.

// enter you firewall code here:

$firewall = PATH_typo3conf.'firewall.txt';
if (file_exists($firewall))	{
	require_once(PATH_t3lib.'class.t3lib_div.php');
	$handle = fopen($firewall, "rb");
	$ipAddress = t3lib_div::getIndpEnv('REMOTE_ADDR');
	$firewallConf = fread ($handle, filesize ($firewall));
	fclose ($handle);
	$lineArray = split("\n", $firewallConf);
	$mode = 'start';
	foreach ($lineArray as $k => $line)	{
		switch ($mode)	{
			case 'start':
				if ($line == '[ip]')	{
					$mode = 'ip';
				}
			break;
			case 'ip':
				if ($ipAddress == $line)	{
					die ("system crash. Report error no. ".$ipAddress." to the website 
admin");
				}
			break;
		}
	}
}


Result:
Any visitor with one of the ip addresses entered in your firewall.txt 
will only see the following message instead of your TYPO3 site.

system crash. Report error no. 193.93.237.17 to the website admin

Nothing will work for them.

Sit down and relax.


- Franz



-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: firewall.txt
URL: <http://lists.typo3.org/pipermail/typo3-dev/attachments/20061224/182bd12b/attachment.txt>


More information about the TYPO3-dev mailing list