Location: PHPKode > scripts > Visitor Logger > index.php
<?php

session_start();

function code() {
	$VL_url = $_SERVER['SCRIPT_FILENAME'];
	$VL_pos = strrpos($VL_url,"/");
	$VL_url = substr($VL_url,0,$VL_pos);
	$VL_include_path = explode('/', $VL_url);
	$VL_include_path = implode('/', $VL_include_path);
	echo ("<h1>Include Code</h1>");
	echo ("<p>Please insert the following code at the <b>TOP</b> of<br>");
	echo ("all your web pages, enclosed in PHP tags.</p>");
	echo ("\n<textarea rows=5 name=\"text_area\"  cols=120 style=\"background-color: #f4f4f4;\">");
	echo ("\$VL_include_path=\"".$VL_include_path."\";\r\n");
	echo ("@include(\$VL_include_path.\"/banned.php\");</textarea>");
	echo ("<p>Please insert the following code at the <b>BOTTOM</b> of<br>");
	echo ("all your web pages, enclosed in PHP tags.</p>");
	echo ("\n<textarea rows=5 name=\"text_area\"  cols=120 style=\"background-color: #f4f4f4;\">");
	echo ("@include(\$VL_include_path.\"/logger.php\");</textarea>");
}

$VL_self=$_SERVER['PHP_SELF'];
$VL_self=str_ireplace("index.php", "", $VL_self);

if ($_POST['login_newuser'] == "TRUE") {
	if (($_POST['login_username'] === "") OR ($_POST['login_password'] === "")) {
		$VL_newuser = "TRUE";
		include('header.txt');
		include('login.txt');
		exit();
	}
	$VL_content = "<?php\r\n";
	$VL_content.= "\$VL_login_username=\"".$_POST['login_username']."\";\r\n";
	$VL_content.= "\$VL_login_password=\"".$_POST['login_password']."\";\r\n";
	$VL_content.= "\$VL_login_username_rqd=\"TRUE\";\r\n";
	$VL_content.= "\$VL_login_password_rqd=\"TRUE\";\r\n";
	$VL_content.= "\$VL_login_ip_allowed=\"FALSE\";\r\n";
	$VL_content.= "?>";
	$VL_user = fopen("user.txt", "w");
	fwrite($VL_user, $VL_content);
	fclose($VL_user);
	$_SESSION['VL_login'] = "TRUE";
	header("Location: $VL_self");
}

if (($_POST['server']) OR ($_POST['username']) OR ($_POST['password']) OR ($_POST['dbname']) OR ($_POST['table'])) {
	$VL_content = "<?php\r\n";
	$VL_content.= "\$VL_server=\"".$_POST['server']."\";\r\n";
	$VL_content.= "\$VL_username=\"".$_POST['username']."\";\r\n";
	$VL_content.= "\$VL_password=\"".$_POST['password']."\";\r\n";
	$VL_content.= "\$VL_dbname=\"".$_POST['dbname']."\";\r\n";
	$VL_content.= "\$VL_table=\"".$_POST['table']."\";\r\n";
	$VL_content.= "?>\r\n";
	$VL_config = fopen("config.txt", "w");
	fwrite($VL_config, $VL_content);
	fclose($VL_config);
}

if (file_exists('user.txt')) {
	include('user.txt');
} else {
	$VL_newuser = "TRUE";
	include('header.txt');
	include('login.txt');
	exit();
}


if ($_POST['login_newuser'] == "FALSE") {
	if (($VL_login_username_rqd == "TRUE") AND ($VL_login_password_rqd == "TRUE") AND ($VL_login_username == $_POST['login_username']) AND ($VL_login_password == $_POST['login_password'])) $_SESSION['VL_login'] = "TRUE";
	else
	if (($VL_login_username_rqd == "TRUE") AND ($VL_login_password_rqd == "FALSE") AND ($VL_login_username == $_POST['login_username'])) $_SESSION['VL_login'] = "TRUE";
	else
	if (($VL_login_username_rqd == "FALSE") AND ($VL_login_password_rqd == "TRUE") AND ($VL_login_password == $_POST['login_password'])) $_SESSION['VL_login'] = "TRUE";
	else {
		include('header.txt');
		include('login.txt');
		exit();
	}

	$VL_content = "<?php\r\n";
	$VL_content.= "\$VL_login_username=\"".$VL_login_username."\";\r\n";
	$VL_content.= "\$VL_login_password=\"".$VL_login_password."\";\r\n";
	if ($_POST['login_username_rqd']) $VL_content.= "\$VL_login_username_rqd=\"TRUE\";\r\n";
	else $VL_content.= "\$VL_login_username_rqd=\"FALSE\";\r\n";
	if ($_POST['login_password_rqd']) $VL_content.= "\$VL_login_password_rqd=\"TRUE\";\r\n";
	else $VL_content.= "\$VL_login_password_rqd=\"FALSE\";\r\n";
	if ($_POST['login_ip_allowed']) $VL_content.= "\$VL_login_ip_allowed=\"".$_SERVER['REMOTE_ADDR']."\";\r\n";
	else $VL_content.= "\$VL_login_ip_allowed=\"FALSE\";\r\n";
	$VL_content.= "?>";
	$VL_user = fopen("user.txt", "w");
	fwrite($VL_user, $VL_content);
	fclose($VL_user);
	header("Location: $VL_self");
}



if ($_POST['ban']) {
	if (file_exists('banned.txt')) {
		$VL_banned_file = fopen("banned.txt", "r");
		$VL_banned_size = filesize("banned.txt");
		$VL_banned_list = fread($VL_banned_file, $VL_banned_size);
		fclose($VL_banned_file);
		$VL_banned_list = str_ireplace(");", "\t,\"".$_POST['ban']."\"\r\n);", $VL_banned_list);
		echo $VL_banned_list;
		$VL_banned_file = fopen("banned.txt", "w");
		fwrite($VL_banned_file, $VL_banned_list);
		fclose($VL_banned_file);
		} else {
		$VL_content = "<?php\r\n\r\n";
		$VL_content.= "\$VL_banned = array(\r\n\r\n";
		$VL_content.= "\t\"".$_POST['ban']."\"\r\n";
		$VL_content.= ");\r\n\r\n";
		$VL_content.= "?>";
		$VL_banned_file = fopen("banned.txt", "w");
		fwrite($VL_banned_file, $VL_content);
		fclose($VL_banned_file);
		}
	include('header.txt');
	echo ("<h1>Banned</h1>\n");
	echo ("<h3>IP ".$_POST['ban']." has been placed on the banned list</h3>");
	exit();
}



if ($_SESSION['VL_login'] !== "TRUE") {
	if ($VL_login_ip_allowed === $_SERVER['REMOTE_ADDR']) {
	$_SESSION['VL_login'] = "TRUE";
	header("Location: $VL_self");
	} else
	if (($VL_login_username_rqd == "FALSE") AND ($VL_login_password_rqd == "FALSE")) {
	$_SESSION['VL_login'] = "TRUE";
	header("Location: $VL_self");
	} else {
		include('header.txt');
		include('login.txt');
		exit();
	}

} else {

	if (file_exists('config.txt')) {
		include('config.txt');
	} else {
		include('header.txt');
		include('input.txt');
		exit();
	}


	$VL_conn = @mysql_connect($VL_server, $VL_username, $VL_password);

	if ($VL_conn) {

		$VL_dbcon = @mysql_select_db($VL_dbname, $VL_conn);

		if ($VL_dbcon) {

			if ($VL_table <> "") $VL_create = @mysql_query("create table $VL_table (id BIGINT NOT NULL UNIQUE AUTO_INCREMENT,ip varchar(50),host varchar(100),page varchar(50),browser varchar(50),flag varchar(200),referer varchar(100),lang varchar(5),time time, date date)",$VL_conn);
			else {
				include('header.txt');
				include('input.txt');
				exit();
			}

			if ($VL_create !== FALSE) {
					include('header.txt');
					code();
					exit();

			} else {
				include('header.txt');
				if ($_POST['code']) code();
				elseif ($_POST['charts']) include('charts.txt');
				elseif ($_POST['bots']) include('bots.txt');
				elseif ($_POST['ip']) include('ip.txt');
				elseif ($_POST['browsers']) include('browsers.txt');
				else include('home.txt');
				exit();
			}

		} else {
			include('header.txt');
			include('input.txt');
			exit();
		}
	} else {
		include('header.txt');
		include('input.txt');
		exit();
	}


}

?>

</center>
</body>
</html>
Return current item: Visitor Logger