<?php
require_once('./global.php');
if(session_is_registered(username)) {
	header("Location: ".$path); 
	exit; 
}

$sql = mysql_query("SELECT null FROM users WHERE ip_last='".$_SERVER['REMOTE_ADDR']."'");
$sql1 = mysql_query("SELECT null FROM users_referidos WHERE ip_referida='".$_SERVER['REMOTE_ADDR']."'");

if(mysql_num_rows($sql) > 0) {
	header("Location: " . $path . "/signup");
	exit;
} elseif(mysql_num_rows($sql1) > 0) {
	 header("Location: " . $path . "/signup");
	 exit;
    } else {
	$r = mysql_real_escape_string($_GET['r']);
	$ip = $_SERVER['REMOTE_ADDR'];
	mysql_query("INSERT INTO users_referidos (usuario, ip_referida, fecha) VALUES ('".$r."','".$remote_ip."','".time()."')");
	header("Location: " . $path . "/signup");
}

?>