View Single Post
  #1 (permalink)  
Old Jul 21st, 2005, 15:51
PHP_newb PHP_newb is offline
New Member
Join Date: Jul 2005
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Help out this newb =\

Okay, I have 2 bits of code, a friend helped me right this:

Code: Select all
<?php
// Get the ip of the person viewing.
$ip = $_SERVER['REMOTE_ADDR'];
// Get the current time in seconds
$current_time = time();

// This is the time that must have past since the last action in seconds.
// So now, its set to 60 sec = 1 minute.
$no_action_time = 60;
// Here, the cutoff is set. If you where last active after $min_time, you can't handle yet.
$min_time = $current_time - $no_action_time;


// File Handling
// Select a File.
$file = 'somefile.txt';
// Open the file
$handle = fopen($file,'r');
// Read the content from the file
$read = fread($handle,filesize($file));

// Data Handling
// Make it into an array
$ip_list = explode("%&%\n",$read);
foreach($ip_list as $tracked_ip)
{
	$no_action_info = explode('%%',$tracked_ip);
	if($ip == $no_action_info[0] && $min_time > $no_action_info[1])
	{
		$forbidden = true;
	}
	// DO NOT put an else statement here, it would just be overwriten with the next set of ip-time.
}

if($forbidden == true)
{
	echo 'Sorry, you may not take this action yet';
}
else
{
	/*
	
			YOUR SCRIPT COMES HERE
	
	*/
	// Just echoing something random here, to not have a blank screen
	echo 'Script done';
	
	$handle = fopen($file,'a');
	$input = $ip . '%%' . $current_time . "%&%\n";
	fwrite($handle,$input);
}
?>
And I want to add in a reputation script so that I have a restriction on the ammount in secondes someone can change another persons reputation, I can get the script to show you.

Here: http://jakeh.goldeye.info/reputation.txt

How could I do it? I tried adding the script where it says but it didn't work =\[/code]
Reply With Quote