Ok i made a fopen/fpassthru script that i use so people wont be able to figure out where i have my download coming from.. what i am trying to do now is to have it so that the php only lets 1 IP connect at a time so that you cant use download managers to mack it quicker. I was wondering if anyone had a script that when someone connects at first their ip is logged but then when they try to connect a second time the php exit;'s or dies it could be logged from a text or mysql it doesnt really matter i just wanna know how to do it.
i tried one of those useronline php script because it seemed like the closest thing to what i want but i couldnt seem to figure it out
here was my attemt (i think to problem with this one what the "== Null" is not a valid statement. How do i make it so that if it find the ip then "$alreadyconected" would be equal to 1)
$timeoutseconds = 1200; // length of session, 20 minutes is the standard
$timestamp=time();
$timeout=$timestamp-$timeoutseconds;
$ip = substr($REMOTE_ADDR, 0, strrpos($REMOTE_ADDR,"."));
// Connect to MySQL Database
@mysql_connect($dbhost,$dbuser,$dbpass);
@mysql_select_db($dbname) or die("No db");
// Add this user to database
$loopcap = 0;
$ifconected = mysql_query("SELECT * from useronline WHERE ip LIKE '%$ip%'");
if(mysql_fetch_array($ifconected) == NULL)
{ $alreadyconected = 1;}
if ($alreadyconnected = 1) {echo "Not allowed to have more than 1 connection to script<br>";
}else{
while ($loopcap<3 && @mysql_query("insert into useronline values('$timestamp','$ip','$PHP_SELF')"))
{ // in case of collision
$timestamp = $timestamp+$ip{0}; $loopcap++;
}
}
// Delete users that have been online for more then "$timeoutseconds" seconds
@mysql_query("delete from useronline where timestamp<$timeout");
// Select users online
$result = @mysql_query("select distinct ip from useronline");
$user = @mysql_num_rows($result);
mysql_free_result($result);
@mysql_close();
// Show all users online
if ($user==1) {echo $user.' user online';} else {echo $user.' users online';}