All pastes #798398 Raw Edit

Someone

public text v1 · immutable
#798398 ·published 2007-11-26 20:02 UTC
rendered paste body
sub lognxd {

	my($host, $other)= @_ ;
	my ($time) = time();
	my ($xforwardedfor) = $ENV{HTTP_X_FORWARDED_FOR};
	$xforwardedfor =~ s/^([0-9\.]{7,15}).*$/$1/s;

	unless ($host =~ /[^A-Za-z0-9-\.]/)
	{
		if ($host =~ /\./)
		{
			use DBI;
			my ($go) = 1;
			my $db = &db_connect;
			if (!$db)
			{
				$go =0;
			}

			my $query = "INSERT INTO `data` (`time`, `ip`, `domain`) VALUES ('$time','$xforwardedfor','$host')";
			my ($execute) =0;

			if ($go)
			{
				$execute = $db->prepare($query) or $go =0;
			}

			if ($go)
			{
				$execute->execute()
			}

			&db_disconnect($db);
			&HTMLdie("Couldn't find address for $host: $other");
		}
	}
}