|
Answer» just a couple questions?
a)i want to log i.p addresses that visit the password gate on my new site and after three password trys, i want to be able to add them to a banlist , i already figured out as much as logging the i.p and found a ban script online i can use , but i need to know how to send the information to the banscript? without using a database.
b)how can i call php pages from a html page? , i DONT want to open them .. just use them when a page is opened , say my index.html page , when they surf to the address how can i load the ban.php script i have without it beeing noticed when it opens?
(a) You could just keep a flat file of banned IP addresses in a TEXT file elsewhere on the web server. Search through it with (e.g.) strpos() and append (if the IP is not present) using fopen() etc.
That said, this is a bad idea. Many people could access the web site and be banned simultaneously, causing multiple read-writes to the banned list. The results are undefined. This is why you should really use a multi-user database (e.g. MySQL) for this kind of problem.
A word of warning: IP-banning is a little pointless. Many people may share the same IP address as far as your web server is concerned. (E.g. corporate LAN, several users on a home LAN or behind a proxy server such as AOL.) Your banning algorithm would need to be reasonably tight to avoid indiscriminate banning of innocent users. (E.g. taking account of username as well as IP address, or by means of a unique stored cookie.) Again this pretty much presupposes the use of a database.
(b) Configure your web server to pass html pages through the PHP parser as well (instructions vary depending on the web server in use). Then you can use <?php include(...); ?> as normal.thanks man , but im new to php still and cant figure out how to use strpos() and fopen() to do what i need
<html> <HEAD> <title></title> <LINK rel="stylesheet" href="http://***REMOVED***/main_style_sheet.css" type="text/css"> </head> <body> <?php $getip = $_SERVER["REMOTE_ADDR"]; $getdate = date( "l dS of F Y" ); $gettime = date( "h:i:sa (@B" );
$banned_ip = array(); $banned_ip[] = '111.111.111.110'; $banned_ip[] = '111.111.111.111'; $banned_ip[] = '111.111.111.112'; $banned_ip[] = '111.111.111.113'; $banned_ip[] = '111.111.111.114';
foreach($banned_ip as $banned) { $ip = $_SERVER['REMOTE_ADDR']; if($ip == $banned){ echo "It seems you have been banned from viewing this website."; echo " "; echo "If you think you have been banned in error please contact me."; $fp = fopen("SCR/ip_data.dat", "a"); fputs($fp, "**BANNED** Visit logged on $getdate at $gettime internet time) for IP: $getip "); fputs($fp, ""); fclose($fp); exit(); } } echo "<font size=3 color=#000000>Update in progress.</font>"; echo " "; echo "'<font color=#007700>Authorized Visit</font>' detected and logged on $getdate at $gettime internet time) for IP: $getip";
$fp = fopen("code/data/ip_data.dat", "a"); fputs($fp, "Authorized Visit logged on $getdate at $gettime internet time) for IP: $getip "); fputs($fp, ""); fclose($fp); ?> <!--End -->
</body> </html> >
how can i get these i.ps from a text file in replace of what i have now? $banned_ip = array(); $banned_ip[] = '111.111.111.110'; $banned_ip[] = '111.111.111.111'; $banned_ip[] = '111.111.111.112'; $banned_ip[] = '111.111.111.113'; $banned_ip[] = '111.111.111.114';
also i tryed but it dident work for me, i found success with another methodQuote from: m3rcllessd3ath on January 25, 2008, 10:23:13 AM ... also i tryed <?php include(...); ?> but it dident work for me, i found success with another method
If include doesn't work, try
|