Who can make this code? IP Blocker

Started on the old forum in September 2012 · view the original in the archive · old links redirect here

9 replies · 853 views · started 14 years ago · 1 min read

7 participants
Newfine Newbie · 6 posts #1

How to store visitors ip in database and recall it >> if they visit again with same ip they redirect to home page>> and this ip should delete from database in 24hrs.. can anyone try to make this code..?

L

Hammad Developer · 89 posts #2

Newfine wrote: How to store visitors ip in database and recall it >> if they visit again with same ip they redirect to home page>> and this ip should delete from database in 24hrs.. can anyone try to make this code..?

You simply Want to Make Anti Cheat script, If not Use cookie instead saving ip in database

WapdeviL.iN Most Updated Services Portal.. Want To increase Site Users ???

Ghost Senior · 366 posts #3

why does he need to inbox you. if you can really make it. then why not just make it and post here in the thread where he asked for it. this way other people have the chance to either use yours or add another code attempt of it so he has more than one option to choose from.

<?php include ('Ghost'); if ($Post == true) { echo ' ![](http://destrukt.dk/ico/phpdeveloper.jpg) alt='coding-talk.com!!' />'; echo 'Sharing Is Caring!'; } else { echo ' ![](http://img98.imageshack.us/img98/6476/av3ro4.jpg) alt='the username GHOST has been comprimised!' />'; echo 'OMG SOMEBODY HELP ME!!'; } ?>
softwarefreak Senior · 349 posts #4

Tracking/blocking with IP is not a good option, most of us have dynamic external IP's , it changes whenever you disconnect & then reconnect, cookie is a better option.

I need some facebook likes, can you please help me 🤝 http://facebook.com/softwarefreakin I noticed social media is really powerful 🧙 Well DONE is better than well SAID

arnage Lead · 811 posts #5

Set tables for ip and time, do mysql_num_rows() with query $var = time() - (24 * 60 * 60), if there is send header Location, if not do wath you want with that, and at the end set query to delete stored ip older than 24h.

<!DOCTYPE html PUBLIC "-//***WAPFORUM**.**RS***
softwarefreak Senior · 349 posts #7

Lue_chin wrote: Hello mr i made it you can try here and want to buy pm me One ip one click

It's cool, But the problem is, a person can make 1000 clicks in 24 hours 😛 by using the intelligent part of his brain 🤝

I need some facebook likes, can you please help me 🤝 http://facebook.com/softwarefreakin I noticed social media is really powerful 🧙 Well DONE is better than well SAID

arnage Lead · 811 posts #9

Lue_chin wrote: Hello mr i made it you can try here and want to buy pm me One ip one click

This is just dumb. I'll not delete it because its the reason why this person should never get any help here anymore, even he got it alot.

<!DOCTYPE html PUBLIC "-//***WAPFORUM**.**RS***
arnage Lead · 811 posts #10

Try this.

CREATE TABLE `logs` (
	`id` bigint(1000000) NOT NULL auto_increment,
	`ip` varchar(15) NOT NULL,
	`time` int(10) NOT NULL,
PRIMARY KEY  (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8;
$where = ''; // Where to redirect
$ip = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '';

if (!empty($ip)) {

	$time24 = (time() - (24 * 60 * 60));

	$check = mysql_query('SELECT COUNT(*) FROM `logs` WHERE `ip` = "'.$ip.'" AND `time` < '.$time24.'');
	if (!mysql_num_rows($check)) {

		@mysql_query('INSERT INTO `logs` VALUES (\'\', "'.$ip.'", "'.time().'")');

		// The rest of page goes here...

	} else {

		$select = mysql_query('SELECT `id` FROM `logs` WHERE `time` > '.$time24.'');
		if (mysql_num_rows($select)) {
			while ($sel = mysql_fetch_array($select)) {

				@mysql_query('DELETE FROM `logs` WHERE `id` = '.$sel[0].'');
	
			}
		}

		header('Location: '.$where.'');
		exit;

	}
} else {

	exit('No IP...');

}

... or:

function logs() {

$ip = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '';

if (!empty($ip)) {

	$time24 = (time() - (24 * 60 * 60));

	$check = mysql_query('SELECT COUNT(*) FROM `logs` WHERE `ip` = "'.$ip.'" AND `time` < '.$time24.'');
	if (!mysql_num_rows($check)) {

		@mysql_query('INSERT INTO `logs` VALUES (\'\', "'.$ip.'", "'.time().'")');

		return false;

	} else {

		$select = mysql_query('SELECT `id` FROM `logs` WHERE `time` > '.$time24.'');
		if (mysql_num_rows($select)) {
			while ($sel = mysql_fetch_array($select)) {

				@mysql_query('DELETE FROM `logs` WHERE `id` = '.$sel[0].'');
	
			}
		}

		return true;

	}
} else {

	return true;

}
}

//

if (logs())
	header('Location: http://google.com/');
	exit;

If someone have a better idea please post.

<!DOCTYPE html PUBLIC "-//***WAPFORUM**.**RS***

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close