Location: PHPKode > scripts > CrawlProtect > crawlprotect/index.php
<?php
//----------------------------------------------------------------------
//  CrawlProtect 2.0.0
//----------------------------------------------------------------------
// Protect your website from hackers
//----------------------------------------------------------------------
// Author: Jean-Denis Brun
//----------------------------------------------------------------------
// Website: www.crawlprotect.com
//----------------------------------------------------------------------
// That script is distributed under GNU GPL license
//----------------------------------------------------------------------
// file: index.php
//----------------------------------------------------------------------
//  Last update: 03/07/2010
//----------------------------------------------------------------------
//---release info----------------------------------------------------------------------------
$crawlprotect=200;
$release='CrawlProtect 2-0-0';
//---error hide for security reason (change to E_ALL for debuging)----------------------------
error_reporting(0);
//---do not modify---------------------------------------------------------------------------
define('IN_CRAWLPROTECT', TRUE);
//---get navig variable value----------------------------------------------------------------
if(isset($_POST['navig']))
	{
	$navig = $_POST['navig'];
	}
else
	{
	$navig = 0;
	}
//--- start session---------------------------------------------------------------------------
if(!isset($_SESSION['flag']))
	{
	session_name('crawlp');
	session_start();
	$_SESSION['flag'] = true;
	}
if (isset($_SERVER['SCRIPT_FILENAME']) && !empty($_SERVER['SCRIPT_FILENAME']))
	{
	$_SESSION['path'] = dirname( $_SERVER['SCRIPT_FILENAME'] );
	}
elseif (isset($_SERVER['DOCUMENT_ROOT']) && !empty($_SERVER['DOCUMENT_ROOT']) && isset($_SERVER['PHP_SELF']) && !empty($_SERVER['PHP_SELF']))
	{
	$_SESSION['path'] = dirname($_SERVER['DOCUMENT_ROOT'].$_SERVER['PHP_SELF']);
	}
else
	{
	$_SESSION['path'] = '..';
	}
//include
include "include/functions.php";
include "include/functionsdata.php";
include "include/configconnect.php";
//variables init------------------------------------------------------------------------------
$logindb='';
//---file or MySQL?---------------------------------------------------------------------------
if(file_exists('include/config.php'))
	{
	$type='file';
	}
elseif($crawltuser!="login" OR $crawltpassword!="password" OR $crawltdb!="database-name" OR $crawlthost!="server-name")
	{
	$type='mysql';
//connection check and create table if needed
$mysqlinfo='ok';
$connexion = @mysql_connect($crawlthost,$crawltuser,$crawltpassword);
if(!$connexion) 
	{
	$mysqlinfo='nook';
	}
else
	{
	//check is base selection is ok
	$selection = @mysql_select_db($crawltdb);
	if(!$selection)
		{
		$mysqlinfo='nook';
		}
	}
	if($mysqlinfo=='nook')
		{
		$languageuse='language/english.php';
		include"language/english.php";
		echo"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\n";
		echo"<html>\n";
		echo"<head>\n";
		echo"<title>".$release."</title>\n";
		echo"<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\n";
		echo"<link rel=\"stylesheet\" type=\"text/css\" href=\"style-200.css\" >\n";
		echo"</head>\n";
		echo"<body>\n";
		echo"<div class=\"main\">\n";
		echo"<div class=\"header\">\n";
		echo"&nbsp;&nbsp;CrawlProtect";
		echo"</div>\n";
		echo"<div align=\"center\"><br><br>\n";
		echo"<table width='100%'><tr><td align=\"center\">";
		echo"<h2>English</h2>";
		echo"<p class=\"red\">CrawlProtect is unable to connect to your database, please check configconnect.php file content.</p><br><br><br>";
		echo"</td></tr><tr><td align=\"center\">";
		echo"<h2>Français</h2>";
		echo"<p class=\"red\">CrawlProtect n'arrive pas à se connecter à votre base de données, merci de vérifier le contenu du fichier configconnect.php</p>";
		echo"</td></tr></table><br><br>";
		echo"<br><br><br>\n";
		echo"</div>\n";
		include("include/sponsors.php");
		echo"<div class=\"footer\">\n";
		echo"<a href=\"http://www.crawlprotect.com\" onclick=\"window.open(this.href);return(false);\">\n";
		echo"CrawlProtect</a>\n";
		echo"</div>\n";
		echo"</div>\n";
		echo"</body>\n";
		echo"</html>\n";
		exit();
		}
	//create table if they didn't exist yet
	if(!isset($_SESSION['tableok']))
		{
		//check if table already exist
		$table_exist1 = 0;
		$table_exist2 = 0;
		$table_exist3 = 0;
		$table_exist4 = 0;
		$table_exist5 = 0;
		$sql = "SHOW TABLES ";
		$tables = mysql_query($sql, $connexion) or die (mysql_error());
		while (list($tablename)=mysql_fetch_array($tables))
			{
			if($tablename == 'crawlp_login')
				{
				$table_exist1 = 1;
				}
			if($tablename == 'crawlp_stats')
				{
				$table_exist2 = 1;
				}
			if($tablename == 'crawlp_setting')
				{
				$table_exist3 = 1;
				}
			if($tablename == 'crawlp_bad')
				{
				$table_exist4 = 1;
				}
			if($tablename == 'crawlp_script')
				{
				$table_exist5 = 1;
				}
			}
		//crawlp_config table creation--------------------------------------------------------------------------
		if($table_exist1 == 0)
			{
			//the table didn't exist, we can create it
			$result1 = mysql_query("CREATE TABLE crawlp_login (
			crawlp_user VARCHAR(20) NULL,
			crawlp_password VARCHAR(45) NULL
			)") ;
			}
		else
			{
			$result1=1;
			}
		//crawlp_stats table creation--------------------------------------------------------------------------
		if($table_exist2 == 0)
			{
			//the table didn't exist, we can create it
			$result2 = mysql_query("CREATE TABLE crawlp_stats (
			date varchar(25),
			attack tinyint(2),
			url text ,
			ip varchar(15)
			)") ;
			}
		else
			{
			$result2=1;
			}
		//crawlp_setting table creation--------------------------------------------------------------------------
		if($table_exist3 == 0)
			{
			//the table didn't exist, we can create it
			$result3 = mysql_query("CREATE TABLE crawlp_setting (
			logrecording varchar(5) NOT NULL default 'ok',
			whichfile varchar(5) NOT NULL default 'all',
			folderlevel varchar(5) NOT NULL default 'all',
			justbad varchar(5) NOT NULL default 'no',
			nocache varchar(5) NOT NULL default 'no',
			nostats varchar(5) NOT NULL default 'no',
			nologs varchar(5) NOT NULL default 'no',
			graph varchar(5) NOT NULL default '1',
			language varchar(45) NOT NULL,
			listfiledontchangeserialize LONGTEXT,
			listfolderdontchangeserialize LONGTEXT 
			)") ;
			}
		else
			{
			$result3=1;
			}
		//crawlp_bad table creation--------------------------------------------------------------------------
		if($table_exist4 == 0)
			{
			//the table didn't exist, we can create it
			$result4 = mysql_query("CREATE TABLE crawlp_bad (
			listip LONGTEXT,
			listreferer LONGTEXT
			)") ;
			}
		else
			{
			$result4=1;
			}
		//crawlp_script table creation--------------------------------------------------------------------------
		if($table_exist5 == 0)
			{
			//the table didn't exist, we can create it
			$result5 = mysql_query("CREATE TABLE crawlp_script (
			crawltrack tinyint(3) NOT NULL,
			phpmyvisites tinyint(3) NOT NULL,
			piwik tinyint(3) NOT NULL,
			socialengine tinyint(3) NOT NULL,
			vbulletin tinyint(3) NOT NULL,
			wordpress tinyint(3) NOT NULL,
			pageear tinyint(3) NOT NULL,
			josdewplayer tinyint(3) NOT NULL,
			imperial tinyint(3) NOT NULL,
			cornerpubli tinyint(3) NOT NULL,
			vbseo tinyint(3) NOT NULL,
			drupal tinyint(3) NOT NULL,
			punbb tinyint(3) NOT NULL,
			openx tinyint(3) NOT NULL
			)") ;
			}
		else
			{
			$result5=1;
			}
		if(($result1 + $result2 + $result3 + $result4 + $result5 ) == 5)
			{
			$_SESSION['tableok']=1;
			}
		}
	//get info from database
	$sqlconfig = "SELECT * FROM crawlp_login";
	$requeteconfig = mysql_query($sqlconfig, $connexion);
	$nbrresult=mysql_num_rows($requeteconfig);
	if($nbrresult>=1)
		{
		$ligne = mysql_fetch_array($requeteconfig,MYSQL_ASSOC);
		$logindb = $ligne['crawlp_user'];
		}
	else
		{
		$logindb ='0';
		}
	$sqlsetting = "SELECT * FROM crawlp_setting";
	$requetesetting = mysql_query($sqlsetting, $connexion);
	$nbrresult=mysql_num_rows($requetesetting);
	if($nbrresult>=1)
		{
		$ligne = mysql_fetch_assoc($requetesetting);
		$langdb = $ligne['language'];
		}
	else
		{
		$langdb = '';
		}
	}
else
	{
	if(preg_match("/Suhosin/i", $_SERVER['SERVER_SIGNATURE']))
		{
		$type='mysql-no-configconnect';
		}
	else
		{
		if(function_exists('chmod'))
			{
			chmod('COPYING.txt',0644);
			}
		$fp = fopen("COPYING.txt", "w");
		if($fp)
			{
			$type='file';
			fclose($fp);
			}
		else
			{
			$type='mysql-no-configconnect';
			}
		}
	}
//---header------------------------------------------------------------------------------------
echo"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\n";
echo"<html>\n";
echo"<head>\n";
echo"<title>".$release."</title>\n";
echo"<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\n";
echo"<link rel=\"stylesheet\" type=\"text/css\" href=\"style-200.css\" >\n";
echo"</head>\n";
echo"<body>\n";
echo"<div class=\"main\">\n";
echo"<div class=\"header\">\n";
echo"&nbsp;&nbsp;CrawlProtect";
echo"</div>\n";
//---include the right file for the content-----------------------------------------------------
if($navig==0)
	{
	include "content/index.php";
	}
elseif($navig==1)
	{
	include "content/admin.php";
	}
elseif($navig==2)
	{
	include "content/chmod.php";
	}
elseif($navig==3)
	{
	include "content/createhtaccess.php";
	}
//---footer------------------------------------------------------------------------------------
include("include/sponsors.php");
echo"<div class=\"footer\">\n";
echo"<a href=\"http://www.crawlprotect.com\" onclick=\"window.open(this.href);return(false);\">\n";
echo"CrawlProtect</a>\n";
echo"</div>\n";
echo"</div>\n";
echo"</body>\n";
echo"</html>\n";
?>
Return current item: CrawlProtect