Location: PHPKode > projects > CrawlTrack > crawltrack/include/updatecrawltrack.php
<?php
//----------------------------------------------------------------------
//  CrawlTrack 3.2.4
//----------------------------------------------------------------------
// Crawler Tracker for website
//----------------------------------------------------------------------
// Author: Jean-Denis Brun
//----------------------------------------------------------------------
// Website: www.crawltrack.net
//----------------------------------------------------------------------
// That script is distributed under GNU GPL license
//----------------------------------------------------------------------
// file: updatecrawltrack.php
//----------------------------------------------------------------------
//  Last update: 18/06/2010
//----------------------------------------------------------------------
//this file is needed to update from a previous release 

if (!defined('IN_CRAWLT'))
{
	echo"<h1>Hacking attempt !!!!</h1>";
	exit();
}
//connexion to database
$connexion = mysql_connect($crawlthost,$crawltuser,$crawltpassword) or die("MySQL connection to database problem");
$selection = mysql_select_db($crawltdb) or die("MySQL database selection problem");

//----------------------------------------------------------------------------------------------------
//check if the crawlt_config table exit and if not create it
$table_exist1 = 0;
$sql = "SHOW TABLES ";                                                
$tables = mysql_query($sql, $connexion) or die("MySQL query error"); 

while (list($tablename)=mysql_fetch_array($tables)) 
    {
    if($tablename == 'crawlt_config')
        {
        $table_exist1 = 1;
        }
    }
if($table_exist1 == 0)
    {
    //the table didn't exist, we can create it
	$result1 = mysql_query("CREATE TABLE crawlt_config (
            id_config smallint(5) unsigned NOT NULL default '0',
            timeshift smallint(6) default NULL,
            public smallint(5) unsigned default NULL,
            mail smallint(5) unsigned default NULL,
            datelastmail smallint(5) unsigned default NULL,
            addressmail varchar(255) default NULL,
            lang varchar(20) default NULL,
            version int(10) unsigned default NULL,
            firstdayweek enum('Monday','Sunday') NOT NULL default 'Monday',
            datelastseorequest smallint(5) NOT NULL default '0',
            loop1 smallint(5) NOT NULL default '0',
            loop2 smallint(5) NOT NULL default '0',
            datelastcleaning datetime NOT NULL default '0000-00-00 00:00:00',
            rowdisplay smallint(5) NOT NULL default '0',
            orderdisplay smallint(5) NOT NULL default '0',
            typemail smallint(5) NOT NULL default '1',
            typecharset smallint(5) NOT NULL default '1',
            blockattack smallint(5) unsigned NOT NULL default '0',
            sessionid smallint(5) unsigned NOT NULL default '0',
            includeparameter smallint(5) unsigned NOT NULL default '0',
            PRIMARY KEY  (id_config)
          )") or die (mysql_error());
    
    //insert the data in the table
    
        //give a value to $time for release before 1.4.0
    if(!isset($times))
        {
        $times=0;
        }
    //give a value to $mail for release before 1.5.0
    if(!isset($mail))
        {
        $mail=0;
        }
    //give a value to $dest for release before 1.5.0
    if(!isset($dest))
        {
        $dest='';
        }	           	
    //give a value to $public for release before 1.5.0
    if(!isset($public))
        {
        $public=0;
        }            
    //insert the data in the table
    if($result1==1)
        {
        $result2 =mysql_query("INSERT INTO crawlt_config (id_config, timeshift, public, mail, datelastmail,addressmail, lang, version, firstdayweek, rowdisplay, orderdisplay, typemail, typecharset, blockattack, sessionid,includeparameter) VALUES ('1','0','0','0','0','','".sql_quote($crawltlang)."','324','Monday','30','0','1','1','0','0','0')");
        }    
    }
else
    {
    $result1=1;
    $result2=1;
    }
 //----------------------------------------------------------------------------------------------------
// check if the firstdayweek column exist in the config table and if not add it
$result3=0;
$tableinfo1 = mysql_query("SHOW COLUMNS FROM crawlt_config");
while ($table1= mysql_fetch_assoc($tableinfo1))
    {
    $listcolumn1[]=$table1['Field'];
    }
if(in_array('firstdayweek',$listcolumn1))
    {
    $result3=1;
    }	
else
    {    
    //add the column  in the config table    
    $sqlupdate3="ALTER TABLE crawlt_config ADD firstdayweek ENUM('Monday','Sunday') NOT NULL default 'Monday'";
    $result3 = mysql_query($sqlupdate3, $connexion);
    }  
//----------------------------------------------------------------------------------------------------
// check if the datelastseorequest column exist in the config table and if not add it
if(in_array('datelastseorequest',$listcolumn1))
    {
    $result4=1;
    }	
else
    {    
    //add the  column  in the config table    
    $sqlupdate4="ALTER TABLE crawlt_config ADD datelastseorequest smallint(5) NOT NULL default '0'";
    $result4 = mysql_query($sqlupdate4, $connexion);
    } 
//----------------------------------------------------------------------------------------------------
// check if the loop column exist in the config table and if not add it
if(in_array('loop1',$listcolumn1))
    {
    $result5=1;
    }	
else
    {    
    //add the  column  in the config table    
    $sqlupdate5="ALTER TABLE crawlt_config ADD loop1 smallint(5) NOT NULL default '0'";
    $result5 = mysql_query($sqlupdate5, $connexion);
    } 
//----------------------------------------------------------------------------------------------------
// check if the loop2 column exist in the config table and if not add it
if(in_array('loop2',$listcolumn1))
    {
    $result6=1;
    }	
else
    {    
    //add the  column  in the config table    
    $sqlupdate6="ALTER TABLE crawlt_config ADD loop2 smallint(5) NOT NULL default '0'";
    $result6 = mysql_query($sqlupdate6, $connexion);
    } 
//----------------------------------------------------------------------------------------------------
// check if the datelastcleaning column exist in the config table and if not add it
if(in_array('datelastcleaning',$listcolumn1))
    {
    $result7=1;
    }	
else
    {    
    //add the  column  in the config table    
    $sqlupdate7="ALTER TABLE crawlt_config ADD datelastcleaning datetime NOT NULL default '0000-00-00 00:00:00'";
    $result7 = mysql_query($sqlupdate7, $connexion);
    } 
//----------------------------------------------------------------------------------------------------
// check if the rowdisplay column exist in the config table and if not add it
if(in_array('rowdisplay',$listcolumn1))
    {
    $result71=1;
    }	
else
    {    
    //add the  column  in the config table    
    $sqlupdate71="ALTER TABLE crawlt_config ADD rowdisplay smallint(5) NOT NULL default '0'";
    $result71 = mysql_query($sqlupdate71, $connexion);
    } 
//----------------------------------------------------------------------------------------------------
// check if the orderdisplay column exist in the config table and if not add it
if(in_array('orderdisplay',$listcolumn1))
    {
    $result72=1;
    }	
else
    {    
    //add the  column  in the config table    
    $sqlupdate72="ALTER TABLE crawlt_config ADD orderdisplay smallint(5) NOT NULL default '0'";
    $result72 = mysql_query($sqlupdate72, $connexion);
    } 
//----------------------------------------------------------------------------------------------------
// check if the typemail column exist in the config table and if not add it
if(in_array('typemail',$listcolumn1))
    {
    $result73=1;
    }	
else
    {    
    //add the  column  in the config table    
    $sqlupdate73="ALTER TABLE crawlt_config ADD typemail smallint(5) NOT NULL default '0'";
    $result73 = mysql_query($sqlupdate73, $connexion);
    } 
//----------------------------------------------------------------------------------------------------
// check if the typecharset column exist in the config table and if not add it
if(in_array('typecharset',$listcolumn1))
    {
    $result74=1;
    }	
else
    {    
    //add the  column  in the config table    
    $sqlupdate74="ALTER TABLE crawlt_config ADD typecharset smallint(5) NOT NULL default '1'";
    $result74 = mysql_query($sqlupdate74, $connexion);
    } 
//----------------------------------------------------------------------------------------------------
// check if the blockattack column exist in the config table and if not add it
if(in_array('blockattack',$listcolumn1))
    {
    $result75=1;
    }	
else
    {    
    //add the  column  in the config table    
    $sqlupdate75="ALTER TABLE crawlt_config ADD blockattack smallint(5) NOT NULL default '0'";
    $result75 = mysql_query($sqlupdate75, $connexion);
    } 
//----------------------------------------------------------------------------------------------------
// check if the sessionid column exist in the config table and if not add it
if(in_array('sessionid',$listcolumn1))
    {
    $result76=1;
    }	
else
    {    
    //add the  column  in the config table    
    $sqlupdate76="ALTER TABLE crawlt_config ADD sessionid smallint(5) NOT NULL default '0'";
    $result76 = mysql_query($sqlupdate76, $connexion);
    } 
//----------------------------------------------------------------------------------------------------
// check if the includeparameter column exist in the config table and if not add it
if(in_array('includeparameter',$listcolumn1))
    {
    $result77=1;
    }	
else
    {    
    //add the  column  in the config table    
    $sqlupdate77="ALTER TABLE crawlt_config ADD includeparameter smallint(5) NOT NULL default '0'";
    $result77 = mysql_query($sqlupdate77, $connexion);
    } 

//----------------------------------------------------------------------------------------------------
//check if the crawlt_cache table exit and if not create it
$table_exist2 = 0;
$sql = "SHOW TABLES ";                                                
$tables = mysql_query($sql, $connexion) or die("MySQL query error"); 
while (list($tablename)=mysql_fetch_array($tables)) 
    {
    if($tablename == 'crawlt_cache')
        {
        $table_exist2 = 1;
        }
    }
if($table_exist2 == 0)
    {
    //the table didn't exist, we can create it
    $result8 = mysql_query("CREATE TABLE crawlt_cache (
      cachename VARCHAR(255) NOT NULL,
      time INT NULL,
      PRIMARY KEY(cachename),
 KEY `time` (`time`)
    )");
    }
else
    {
    $result8=1;
    }  
//----------------------------------------------------------------------------------------------------
// check if the time column is an index and if not index it
$result80=0;
$tableinfo80 = mysql_query("SHOW INDEX FROM crawlt_cache");
$listcolumn80=array();
while ($table80= mysql_fetch_assoc($tableinfo80))
    {
    $listcolumn80[]=$table80['Column_name'];
    }
if(in_array('time',$listcolumn80))
    {
    $result80=1;
    }	
else
    {    
    //add the index    
    $sqlupdate80="CREATE INDEX `time` ON `crawlt_cache` (`time`)";
    $result80 = mysql_query($sqlupdate80, $connexion);
    } 

//----------------------------------------------------------------------------------------------------
// check if the crawlt_ip_used column exist in the visits table and if not add it
$tableinfo2 = mysql_query("SHOW COLUMNS FROM crawlt_visits");
while ($table2= mysql_fetch_assoc($tableinfo2))
    {
    $listcolumn2[]=$table2['Field'];
    }
if(in_array('crawlt_ip_used',$listcolumn2))
    {
    $result9=1;
    $result12=1;    
    }	
else
    {
    //add the  column in the visits table
    $sqlupdate9="ALTER TABLE crawlt_visits ADD crawlt_ip_used VARCHAR(16)";
    $result9 = mysql_query($sqlupdate9, $connexion);

    $sqlupdate12="UPDATE crawlt_visits SET crawlt_ip_used=''";
    $result12 = mysql_query($sqlupdate12, $connexion);
    } 

//----------------------------------------------------------------------------------------------------
// check if the crawlt_error column exist in the visits table and if not add it
if(in_array('crawlt_error',$listcolumn2))
    {
    $result90=1;
    }	
else
    {
    //add the  column in the visits table
    $sqlupdate90="ALTER TABLE crawlt_visits ADD crawlt_error tinyint(4) NOT NULL default '0'";
    $result90 = mysql_query($sqlupdate90, $connexion);
    } 
//----------------------------------------------------------------------------------------------------
// check if the crawlt_crawler_id_crawler column is an index and if not index it
$result91=0;
$tableinfo91 = mysql_query("SHOW INDEX FROM crawlt_visits");
$listcolumn91=array();
while ($table91= mysql_fetch_assoc($tableinfo91))
    {
    $listcolumn91[]=$table91['Column_name'];
    }
if(in_array('crawlt_crawler_id_crawler',$listcolumn91))
    {
    $result91=1;
    }	
else
    {    
    //add the index    
    $sqlupdate91="CREATE INDEX `crawlt_crawler_id_crawler` ON `crawlt_visits` (`crawlt_crawler_id_crawler`)";
    $result91 = mysql_query($sqlupdate91, $connexion);
    } 
//----------------------------------------------------------------------------------------------------
// check if the crawlt_ip_used column is an index and if not index it
if(in_array('crawlt_ip_used',$listcolumn91))
    {
    $result92=1;
    }	
else
    {    
    //add the index    
    $sqlupdate92="CREATE INDEX `crawlt_ip_used` ON `crawlt_visits` (`crawlt_ip_used`)";
    $result92 = mysql_query($sqlupdate92, $connexion);
    } 
//----------------------------------------------------------------------------------------------------
// check if the crawlt_pages_id_page column is an index and if not index it
if(in_array('crawlt_pages_id_page',$listcolumn91))
    {
    $result93=1;
    }	
else
    {    
    //add the index    
    $sqlupdate93="CREATE INDEX `crawlt_pages_id_page` ON `crawlt_visits` (`crawlt_pages_id_page`)";
    $result93 = mysql_query($sqlupdate93, $connexion);
    } 
//----------------------------------------------------------------------------------------------------
// check if the crawlt_site_id_site column is an index and if not index it
if(in_array('crawlt_site_id_site',$listcolumn91))
    {
    $result94=1;
    }	
else
    {    
    //add the index    
    $sqlupdate94="CREATE INDEX `crawlt_site_id_site` ON `crawlt_visits` (`crawlt_site_id_site`)";
    $result94 = mysql_query($sqlupdate94, $connexion);
    } 
//----------------------------------------------------------------------------------------------------
// check if the date column is an index and if not index it
if(in_array('date',$listcolumn91))
    {
    $result95=1;
    }	
else
    {    
    //add the index    
    $sqlupdate95="CREATE INDEX `date` ON `crawlt_visits` (`date`)";
    $result95 = mysql_query($sqlupdate95, $connexion);
    } 
//----------------------------------------------------------------------------------------------------
// check if the crawlt_error column is an index and if not index it
if(in_array('crawlt_error',$listcolumn91))
    {
    $result96=1;
    }	
else
    {    
    //add the index    
    $sqlupdate96="CREATE INDEX `crawlt_error` ON `crawlt_visits` (`crawlt_error`)";
    $result96 = mysql_query($sqlupdate96, $connexion);
    } 


//----------------------------------------------------------------------------------------------------
// check if the url column exist in the crawlt_site table and if not add it
$tableinfo3 = mysql_query("SHOW COLUMNS FROM crawlt_site");
while ($table3= mysql_fetch_assoc($tableinfo3))
    {
    $listcolumn3[]=$table3['Field'];
    }
if(in_array('url',$listcolumn3))
    {
    $urlok=1;
    $result14=1;
    }	
else
    {
    $urlok=0;
    //add the url column  in the crawlt_site table
    $sqlupdate14="ALTER TABLE crawlt_site ADD url VARCHAR(255)";
    $result14 = mysql_query($sqlupdate14, $connexion);
    }  

//----------------------------------------------------------------------------------------------------
//check if the crawlt_graph table exit and if not create it
$table_exist13 = 0;
$sql = "SHOW TABLES ";                                                
$tables = mysql_query($sql, $connexion) or die("MySQL query error"); 
while (list($tablename)=mysql_fetch_array($tables)) 
    {

    if($tablename == 'crawlt_graph')
        {
        $table_exist13 = 1;
        }
    }
if($table_exist13 == 0)
    {
    //the table didn't exist, we can create it
    $result15 = mysql_query("CREATE TABLE crawlt_graph (
      name varchar(255) NOT NULL default '',
      graph_values blob NOT NULL,
      KEY name (name)
    )");
    }
else
    {
    $result15=1;
    }	
			
//----------------------------------------------------------------------------------------------------
//check if the crawlt_keyword table exit and if not create it				
$table_exist14 = 0;
$sql = "SHOW TABLES ";                                                
$tables = mysql_query($sql, $connexion); 
while (list($tablename)=mysql_fetch_array($tables)) 
    {

    if($tablename == 'crawlt_keyword')
        {
        $table_exist14 = 1;
        }
    }
if($table_exist14 == 0)
    {
    //the table didn't exist, we can create it
    $result16 = mysql_query("CREATE TABLE crawlt_keyword (
    id_keyword int(10) unsigned NOT NULL auto_increment,
    keyword varchar(150) default NULL,
    PRIMARY KEY  (id_keyword),
	KEY id_keyword (id_keyword)
    )");
    }
else
    {
    $result16=1;
    }
//----------------------------------------------------------------------------------------------------
// check if the keyword column is an index and if not index it
$result160=0;
$tableinfo160 = mysql_query("SHOW INDEX FROM crawlt_keyword");
$listcolumn160=array();
while ($table160= mysql_fetch_assoc($tableinfo160))
    {
    $listcolumn160[]=$table160['Column_name'];
    }
if(in_array('keyword',$listcolumn160))
    {
    $result160=1;
    }	
else
    {    
    //add the index    
    $sqlupdate160="CREATE INDEX `keyword` ON `crawlt_keyword` (`keyword`)";
    $result160 = mysql_query($sqlupdate160, $connexion);
    } 


//----------------------------------------------------------------------------------------------------
//check if the crawlt_seo_position table exit and if not create it	
$table_exist15 = 0;
$sql = "SHOW TABLES ";                                                
$tables = mysql_query($sql, $connexion); 
while (list($tablename)=mysql_fetch_array($tables)) 
    {
    if($tablename == 'crawlt_seo_position')
        {
        $table_exist15 = 1;
        }
    }
if($table_exist15 == 0)
    {
    //the table didn't exist, we can create it
    $result17 = mysql_query("CREATE TABLE crawlt_seo_position (
            `date` date default NULL,
            id_site smallint(5) NOT NULL default '0',
            linkyahoo int(10) unsigned default NULL,
            pageyahoo int(10) unsigned default NULL,
            linkmsn int(10) unsigned default NULL,
            pagemsn int(10) unsigned default NULL,
            nbrdelicious int(10) unsigned default '0',
            tagdelicious varchar(255) NOT NULL default '',
            linkexalead int(10) NOT NULL default '0',
            pageexalead int(10) NOT NULL default '0',
            linkgoogle int(10) NOT NULL default '0',
            pagegoogle int(10) NOT NULL default '0',
            KEY `date` (`date`),
            KEY id_site (id_site),
            KEY linkmsn (linkmsn),
            KEY linkyahoo (linkyahoo),
            KEY nbrdelicious (nbrdelicious),
            KEY pagemsn (pagemsn),
            KEY pageyahoo (pageyahoo),
            KEY tagdelicious (tagdelicious),
            KEY linkexalead (linkexalead),
            KEY pageexalead (pageexalead),
            KEY linkgoogle (linkgoogle),
            KEY pagegoogle (pagegoogle)
          )");
    }
else
    {
    $result17=1;
    }
//----------------------------------------------------------------------------------------------------
// check if the linkexalead exist in the crawlt_seo_position table and if not add it
$tableinfo17 = mysql_query("SHOW COLUMNS FROM crawlt_seo_position");
while ($table17= mysql_fetch_assoc($tableinfo17))
    {
    $listcolumn17[]=$table17['Field'];
    }
if(in_array('linkexalead',$listcolumn17))
    {
    $result170=1;
    }	
else
    {
    //add the linkexalead column  in the crawlt_seo_position table
    $sqlupdate170="ALTER TABLE crawlt_seo_position ADD linkexalead int(10) NOT NULL default '0'";
    $result170 = mysql_query($sqlupdate170, $connexion);
    } 
//----------------------------------------------------------------------------------------------------
// check if the pageexalead exist in the crawlt_seo_position table and if not add it
if(in_array('pageexalead',$listcolumn17))
    {
    $result171=1;
    }	
else
    {
    //add the pageexalead column  in the crawlt_seo_position table
    $sqlupdate171="ALTER TABLE crawlt_seo_position ADD pageexalead int(10) NOT NULL default '0'";
    $result171 = mysql_query($sqlupdate171, $connexion);
    } 

//----------------------------------------------------------------------------------------------------
// check if the linkgoogle exist in the crawlt_seo_position table and if not add it

if(in_array('linkgoogle',$listcolumn17))
    {
    $result1700=1;
    }	
else
    {
    //add the linkgoogle column  in the crawlt_seo_position table
    $sqlupdate1700="ALTER TABLE crawlt_seo_position ADD linkgoogle int(10) NOT NULL default '0'";
    $result1700 = mysql_query($sqlupdate1700, $connexion);
    } 
//----------------------------------------------------------------------------------------------------
// check if the pagegoogle exist in the crawlt_seo_position table and if not add it
if(in_array('pagegoogle',$listcolumn17))
    {
    $result1710=1;
    }	
else
    {
    //add the pagegoogle column  in the crawlt_seo_position table
    $sqlupdate1710="ALTER TABLE crawlt_seo_position ADD pagegoogle int(10) NOT NULL default '0'";
    $result1710 = mysql_query($sqlupdate1710, $connexion);
    } 



//----------------------------------------------------------------------------------------------------
// check if the date column is an index and if not index it
$result172=0;
$tableinfo172 = mysql_query("SHOW INDEX FROM crawlt_seo_position");
$listcolumn172=array();
while ($table172= mysql_fetch_assoc($tableinfo172))
    {
    $listcolumn172[]=$table172['Column_name'];
    }
if(in_array('date',$listcolumn172))
    {
    $result172=1;
    }	
else
    {    
    //add the index    
    $sqlupdate172="CREATE INDEX `date` ON `crawlt_seo_position` (`date`)";
    $result172 = mysql_query($sqlupdate172, $connexion);
    } 
//----------------------------------------------------------------------------------------------------
// check if the id_site column is an index and if not index it
if(in_array('id_site',$listcolumn172))
    {
    $result173=1;
    }	
else
    {    
    //add the index    
    $sqlupdate173="CREATE INDEX `id_site` ON `crawlt_seo_position` (`id_site`)";
    $result173 = mysql_query($sqlupdate173, $connexion);
    } 
//----------------------------------------------------------------------------------------------------
// check if the linkmsn column is an index and if not index it
if(in_array('linkmsn',$listcolumn172))
    {
    $result174=1;
    }	
else
    {    
    //add the index    
    $sqlupdate174="CREATE INDEX `linkmsn` ON `crawlt_seo_position` (`linkmsn`)";
    $result174 = mysql_query($sqlupdate174, $connexion);
    } 
//----------------------------------------------------------------------------------------------------
// check if the linkyahoo column is an index and if not index it
if(in_array('linkyahoo',$listcolumn172))
    {
    $result175=1;
    }	
else
    {    
    //add the index    
    $sqlupdate175="CREATE INDEX `linkyahoo` ON `crawlt_seo_position` (`linkyahoo`)";
    $result175 = mysql_query($sqlupdate175, $connexion);
    } 
//----------------------------------------------------------------------------------------------------
// check if the nbrdelicious column is an index and if not index it
if(in_array('nbrdelicious',$listcolumn172))
    {
    $result176=1;
    }	
else
    {    
    //add the index    
    $sqlupdate176="CREATE INDEX `nbrdelicious` ON `crawlt_seo_position` (`nbrdelicious`)";
    $result176 = mysql_query($sqlupdate176, $connexion);
    } 
//----------------------------------------------------------------------------------------------------
// check if the pagemsn column is an index and if not index it
if(in_array('pagemsn',$listcolumn172))
    {
    $result177=1;
    }	
else
    {    
    //add the index    
    $sqlupdate177="CREATE INDEX `pagemsn` ON `crawlt_seo_position` (`pagemsn`)";
    $result177 = mysql_query($sqlupdate177, $connexion);
    } 
//----------------------------------------------------------------------------------------------------
// check if the pageyahoo column is an index and if not index it
if(in_array('pageyahoo',$listcolumn172))
    {
    $result178=1;
    }	
else
    {    
    //add the index    
    $sqlupdate178="CREATE INDEX `pageyahoo` ON `crawlt_seo_position` (`pageyahoo`)";
    $result178 = mysql_query($sqlupdate178, $connexion);
    } 
//----------------------------------------------------------------------------------------------------
// check if the tagdelicious column is an index and if not index it
if(in_array('tagdelicious',$listcolumn172))
    {
    $result179=1;
    }	
else
    {    
    //add the index    
    $sqlupdate179="CREATE INDEX `tagdelicious` ON `crawlt_seo_position` (`tagdelicious`)";
    $result179 = mysql_query($sqlupdate179, $connexion);
    } 
//----------------------------------------------------------------------------------------------------
// check if the linkexalead column is an index and if not index it
if(in_array('linkexalead',$listcolumn172))
    {
    $result1790=1;
    }	
else
    {    
    //add the index    
    $sqlupdate1790="CREATE INDEX `linkexalead` ON `crawlt_seo_position` (`linkexalead`)";
    $result1790 = mysql_query($sqlupdate1790, $connexion);
    } 
//----------------------------------------------------------------------------------------------------
// check if the pageexalead column is an index and if not index it
if(in_array('pageexalead',$listcolumn172))
    {
    $result1791=1;
    }	
else
    {    
    //add the index    
    $sqlupdate1791="CREATE INDEX `pageexalead` ON `crawlt_seo_position` (`pageexalead`)";
    $result1791 = mysql_query($sqlupdate1791, $connexion);
    } 
//----------------------------------------------------------------------------------------------------
// check if the linkgoogle column is an index and if not index it
if(in_array('linkgoogle',$listcolumn172))
    {
    $result1792=1;
    }	
else
    {    
    //add the index    
    $sqlupdate1792="CREATE INDEX `linkgoogle` ON `crawlt_seo_position` (`linkgoogle`)";
    $result1792 = mysql_query($sqlupdate1792, $connexion);
    } 
//----------------------------------------------------------------------------------------------------
// check if the pagegoogle column is an index and if not index it
if(in_array('pagegoogle',$listcolumn172))
    {
    $result1793=1;
    }	
else
    {    
    //add the index    
    $sqlupdate1793="CREATE INDEX `pagegoogle` ON `crawlt_seo_position` (`pagegoogle`)";
    $result1793 = mysql_query($sqlupdate1793, $connexion);
    } 



//----------------------------------------------------------------------------------------------------
//check if the crawlt_visits_human table exit and if not create it	
$table_exist16 = 0;
$sql = "SHOW TABLES ";                                                
$tables = mysql_query($sql, $connexion) or die("MySQL query error"); 
while (list($tablename)=mysql_fetch_array($tables)) 
    {
    if($tablename == 'crawlt_visits_human')
        {
        $table_exist16 = 1;
        }
    }
if($table_exist16 == 0)
    {
    //the table didn't exist, we can create it
    $result18 = mysql_query("CREATE TABLE crawlt_visits_human (
            id_visit mediumint(8) unsigned NOT NULL auto_increment,
            crawlt_site_id_site tinyint(3) unsigned NOT NULL default '0',
            crawlt_keyword_id_keyword mediumint(8) unsigned NOT NULL default '0',
            crawlt_id_crawler smallint(5) unsigned NOT NULL default '0',
            `date` datetime default NULL,
            crawlt_id_page mediumint(9) NOT NULL default '0',
            crawlt_id_referer mediumint(9) NOT NULL default '0',
            crawlt_ip varchar(15) NOT NULL default '0',
            crawlt_error tinyint(3) unsigned NOT NULL default '0',
            crawlt_browser tinyint(3) unsigned NOT NULL default '0',
            PRIMARY KEY  (id_visit),
            KEY crawlt_id_crawler (crawlt_id_crawler),
            KEY crawlt_id_page (crawlt_id_page),
            KEY crawlt_keyword_id_keyword (crawlt_keyword_id_keyword),
            KEY crawlt_site_id_site (crawlt_site_id_site),
            KEY `date` (`date`),
            KEY crawlt_id_referer (crawlt_id_referer),
            KEY crawlt_ip (crawlt_ip),
            KEY crawlt_error (crawlt_error),
            KEY crawlt_browser (crawlt_browser)
          )");
    }
else
    {
    $result18=1;
    }
//----------------------------------------------------------------------------------------------------
// check if the crawlt_id_referer exist in the crawlt_visits_human table and if not add it
$tableinfo18 = mysql_query("SHOW COLUMNS FROM crawlt_visits_human");
while ($table18= mysql_fetch_assoc($tableinfo18))
    {
    $listcolumn18[]=$table18['Field'];
    }
if(in_array('crawlt_id_referer',$listcolumn18))
    {
    $result180=1;
    }	
else
    {
    //add the crawlt_id_referer column  in the crawlt_visits_human table
    $sqlupdate180="ALTER TABLE crawlt_visits_human ADD crawlt_id_referer mediumint(9) NOT NULL default '0'";
    $result180 = mysql_query($sqlupdate180, $connexion);
    } 
//----------------------------------------------------------------------------------------------------
// check if the crawlt_ip exist in the crawlt_visits_human table and if not add it
if(in_array('crawlt_ip',$listcolumn18))
    {
    $result181=1;
    }	
else
    {
    //add the crawlt_ip column  in the crawlt_visits_human table
    $sqlupdate181="ALTER TABLE crawlt_visits_human ADD crawlt_ip varchar(15) NOT NULL default '0'";
    $result181 = mysql_query($sqlupdate181, $connexion);
    } 
//----------------------------------------------------------------------------------------------------
// check if the crawlt_error exist in the crawlt_visits_human table and if not add it
if(in_array('crawlt_error',$listcolumn18))
    {
    $result182=1;
    }	
else
    {
    //add the crawlt_error column  in the crawlt_visits_human table
    $sqlupdate182="ALTER TABLE crawlt_visits_human ADD crawlt_error tinyint(3) unsigned NOT NULL default '0'";
    $result182 = mysql_query($sqlupdate182, $connexion);
    } 
//----------------------------------------------------------------------------------------------------
// check if the crawlt_browser exist in the crawlt_visits_human table and if not add it
if(in_array('crawlt_browser',$listcolumn18))
    {
    $result1820=1;
    }	
else
    {
    //add the crawlt_error column  in the crawlt_visits_human table
    $sqlupdate1820="ALTER TABLE crawlt_visits_human ADD crawlt_browser tinyint(3) unsigned NOT NULL default '0'";
    $result1820 = mysql_query($sqlupdate1820, $connexion);
    } 
//----------------------------------------------------------------------------------------------------
// check if the date column is an index and if not index it
$result183=0;
$tableinfo183 = mysql_query("SHOW INDEX FROM crawlt_visits_human");
$listcolumn183=array();
while ($table183= mysql_fetch_assoc($tableinfo183))
    {
    $listcolumn183[]=$table183['Column_name'];
    }
if(in_array('date',$listcolumn183))
    {
    $result183=1;
    }	
else
    {    
    //add the index    
    $sqlupdate183="CREATE INDEX `date` ON `crawlt_visits_human` (`date`)";
    $result183 = mysql_query($sqlupdate183, $connexion);
    } 
//----------------------------------------------------------------------------------------------------
// check if the crawlt_id_crawler column is an index and if not index it
if(in_array('crawlt_id_crawler',$listcolumn183))
    {
    $result184=1;
    }	
else
    {    
    //add the index    
    $sqlupdate184="CREATE INDEX `crawlt_id_crawler` ON `crawlt_visits_human` (`crawlt_id_crawler`)";
    $result184 = mysql_query($sqlupdate184, $connexion);
    } 
//----------------------------------------------------------------------------------------------------
// check if the crawlt_id_page column is an index and if not index it
if(in_array('crawlt_id_page',$listcolumn183))
    {
    $result185=1;
    }	
else
    {    
    //add the index    
    $sqlupdate185="CREATE INDEX `crawlt_id_page` ON `crawlt_visits_human` (`crawlt_id_page`)";
    $result185 = mysql_query($sqlupdate185, $connexion);
    } 
//----------------------------------------------------------------------------------------------------
// check if the crawlt_keyword_id_keyword column is an index and if not index it
if(in_array('crawlt_keyword_id_keyword',$listcolumn183))
    {
    $result186=1;
    }	
else
    {    
    //add the index    
    $sqlupdate186="CREATE INDEX `crawlt_keyword_id_keyword` ON `crawlt_visits_human` (`crawlt_keyword_id_keyword`)";
    $result186 = mysql_query($sqlupdate186, $connexion);
    } 
//----------------------------------------------------------------------------------------------------
// check if the crawlt_site_id_site column is an index and if not index it
if(in_array('crawlt_site_id_site',$listcolumn183))
    {
    $result187=1;
    }	
else
    {    
    //add the index    
    $sqlupdate187="CREATE INDEX `crawlt_site_id_site` ON `crawlt_visits_human` (`crawlt_site_id_site`)";
    $result187 = mysql_query($sqlupdate187, $connexion);
    } 
//----------------------------------------------------------------------------------------------------
// check if the crawlt_id_referer column is an index and if not index it
if(in_array('crawlt_id_referer',$listcolumn183))
    {
    $result188=1;
    }	
else
    {    
    //add the index    
    $sqlupdate188="CREATE INDEX `crawlt_id_referer` ON `crawlt_visits_human` (`crawlt_id_referer`)";
    $result188 = mysql_query($sqlupdate188, $connexion);
    } 
//----------------------------------------------------------------------------------------------------
// check if the crawlt_ip column is an index and if not index it
if(in_array('crawlt_ip',$listcolumn183))
    {
    $result189=1;
    }	
else
    {    
    //add the index    
    $sqlupdate189="CREATE INDEX `crawlt_ip` ON `crawlt_visits_human` (`crawlt_ip`)";
    $result189 = mysql_query($sqlupdate189, $connexion);
    } 
//----------------------------------------------------------------------------------------------------
// check if the crawlt_error column is an index and if not index it
if(in_array('crawlt_error',$listcolumn183))
    {
    $result1890=1;
    }	
else
    {    
    //add the index    
    $sqlupdate1890="CREATE INDEX `crawlt_error` ON `crawlt_visits_human` (`crawlt_error`)";
    $result1890 = mysql_query($sqlupdate1890, $connexion);
    } 
// check if the crawlt_browser column is an index and if not index it
if(in_array('crawlt_browser',$listcolumn183))
    {
    $result1891=1;
    }	
else
    {    
    //add the index    
    $sqlupdate1891="CREATE INDEX `crawlt_browser` ON `crawlt_visits_human` (`crawlt_browser`)";
    $result1891 = mysql_query($sqlupdate1891, $connexion);
    } 
//----------------------------------------------------------------------------------------------------
//update configconnect.php file if version <150
$result19=0;
if ($version<150)
    {
    //update the configconnect file    
    //determine the path to the file
	if (isset($_SERVER['SCRIPT_FILENAME']) && !empty($_SERVER['SCRIPT_FILENAME']))
		{
		$path = dirname( $_SERVER['SCRIPT_FILENAME'] );
		}
	elseif (isset($_SERVER['DOCUMENT_ROOT']) && !empty($_SERVER['DOCUMENT_ROOT']) && isset($_SERVER['PHP_SELF']) && !empty($_SERVER['PHP_SELF']))
		{
		$path = dirname($_SERVER['DOCUMENT_ROOT'].$_SERVER['PHP_SELF']);
		}
	else
		{
		$path = '..';
		}
    $filename=$path.'/include/configconnect.php';    
    $filedir=$path.'/include';
    
    //suppress existing file
    if(function_exists('chmod'))
        {
        @chmod($filedir, 0755);
        }
    unlink($filename);
    
    //create the new configconnect file    
    @$content.="<?php\n";
    @$content.="//----------------------------------------------------------------------\n";
    @$content.="//  CrawlTrack 3.2.4\n";
    @$content.="//----------------------------------------------------------------------\n";
    @$content.="// Crawler Tracker for website\n";
    @$content.="//----------------------------------------------------------------------\n";
    @$content.="// Author: Jean-Denis Brun\n";
    @$content.="//----------------------------------------------------------------------\n";
    @$content.="// Website: www.crawltrack.fr\n";
    @$content.="//----------------------------------------------------------------------\n";
    @$content.="// That script is distributed under GNU GPL license\n";
    @$content.="//----------------------------------------------------------------------\n";
    @$content.="// file: configconnect.php\n";
    @$content.="//----------------------------------------------------------------------\n";
    @$content.="\$crawltuser=\"$crawltuser\";\n";
    @$content.="\$crawltpassword=\"$crawltpassword\";\n";
    @$content.="\$crawltdb=\"$crawltdb\";\n";
    @$content.="\$crawlthost=\"$crawlthost\";\n";
    @$content.="?>\n";    
    
    if ( $file = fopen($filename, "w") )
        {
        fwrite($file, $content);
        fclose($file);
        $result19=1;
        }	
    }
else
    {
    $result19=1;
    }    
//----------------------------------------------------------------------------------------------------
//update crawltrack.php file if version <322
if ($version<322)
    {
    //update the crawltrack file    
    //determine the path to the file
	if (isset($_SERVER['SCRIPT_FILENAME']) && !empty($_SERVER['SCRIPT_FILENAME']))
		{
		$path = dirname( $_SERVER['SCRIPT_FILENAME'] );
		}
	elseif (isset($_SERVER['DOCUMENT_ROOT']) && !empty($_SERVER['DOCUMENT_ROOT']) && isset($_SERVER['PHP_SELF']) && !empty($_SERVER['PHP_SELF']))
		{
		$path = dirname($_SERVER['DOCUMENT_ROOT'].$_SERVER['PHP_SELF']);
		}
	else
		{
		$path = '..';
		}
    $filename=$path.'/crawltrack.php';
    $filedir=$path;    
    //suppress existing file
    if(function_exists('chmod'))
        {
        @chmod($filedir, 0755);
        }
        
     if( @unlink($filename))  
        {
    
        //url calculation    
        $dom=$_SERVER["HTTP_HOST"]; 
        $file1=$_SERVER["PHP_SELF"];
        $size= strlen($file1);  
        $file1=substr($file1,-$size,-9);       
        $url_crawlt="http://".$dom.$file1; 
           
@$content2.="<?php\n";
@$content2.="//----------------------------------------------------------------------\n";
@$content2.="//  CrawlTrack 3.2.4\n";
@$content2.="//----------------------------------------------------------------------\n";
@$content2.="// Crawler Tracker for website\n";
@$content2.="//----------------------------------------------------------------------\n";
@$content2.="// Author: Jean-Denis Brun\n";
@$content2.="//----------------------------------------------------------------------\n";
@$content2.="// Website: www.crawltrack.net\n";		
@$content2.="//----------------------------------------------------------------------\n";
@$content2.="// That script is distributed under GNU GPL license\n";
@$content2.="//----------------------------------------------------------------------\n";
@$content2.="// file: crawltrack.php\n";
@$content2.="//----------------------------------------------------------------------\n";
@$content2.="error_reporting(0);\n";
@$content2.="@set_time_limit(10);\n";        
@$content2.="\$crawltattack=0;\n"; 
@$content2.="//connection to database\n";	
@$content2.="require_once(\"$path/include/configconnect.php\");\n";   	
@$content2.="\$crawltconnexion = mysql_connect(\$crawlthost,\$crawltuser,\$crawltpassword);\n";
@$content2.="\$selection = mysql_select_db(\$crawltdb);\n";	        
@$content2.="//query to get the good site list\n";
@$content2.="\$sql = \"SELECT host_site FROM crawlt_good_sites\";\n";
@$content2.="\$requete = mysql_query(\$sql, \$crawltconnexion);\n";
@$content2.="\$nbrresult=mysql_num_rows(\$requete);\n";
@$content2.="if(\$nbrresult>=1)\n";
@$content2.="{\n";	
@$content2.="while (\$ligne = mysql_fetch_row(\$requete))\n";
@$content2.="{\n";
@$content2.="\$crawltlistgoodsite[]=\$ligne[0];\n";               
@$content2.="}\n";
@$content2.="}\n";
@$content2.="else\n";
@$content2.="{\n";
@$content2.="\$crawltlistgoodsite=array();\n";
@$content2.="}\n";
@$content2.="//include searchenginelist.php file\n";        
@$content2.="require_once(\"$path/include/searchenginelist.php\");\n";   
@$content2.=" //query to get the session id list\n";
@$content2.="\$sql = \"SELECT sessionid FROM crawlt_sessionid\";\n";
@$content2.="\$requete = mysql_query(\$sql, \$crawltconnexion);\n";
@$content2.="\$nbrresult=mysql_num_rows(\$requete);\n";
@$content2.="if(\$nbrresult>=1)\n";
@$content2.="{\n";	
@$content2.="while (\$ligne = mysql_fetch_row(\$requete))\n";
@$content2.="{\n";
@$content2.="\$crawltlistsessionid[]=\$ligne[0];\n";               
@$content2.="}\n";
@$content2.="}\n";
@$content2.="else\n";
@$content2.="{\n";
@$content2.="\$crawltlistsessionid=array();\n";
@$content2.="}\n";            				
@$content2.="//mysql escape function\n";
@$content2.="if( function_exists( \"crawlt_sql_quote\" ) == false )\n";
@$content2.="{\n";      		
@$content2.="function crawlt_sql_quote( \$value )\n";
@$content2.="{\n";
@$content2.="if( get_magic_quotes_gpc() )\n";
@$content2.="{\n";
@$content2.="\$value = stripslashes( \$value );\n";
@$content2.="}\n";
@$content2.="//check if this function exists\n";
@$content2.="if( function_exists( \"mysql_real_escape_string\" ) )\n";
@$content2.="{\n";
@$content2.="\$value = mysql_real_escape_string( \$value );\n";
@$content2.="}\n";
@$content2.="//for PHP version < 4.3.0 use addslashes\n";
@$content2.="else\n";
@$content2.="{\n";
@$content2.="\$value = addslashes( \$value );\n";
@$content2.="}\n";
@$content2.="return \$value;\n";
@$content2.="}\n";  
@$content2.="}\n";   

@$content2.="//function url treatment (base on phpMyVisites processParams function)\n";
@$content2.="if( function_exists( \"crawlturltreatment\" ) == false )\n";
@$content2.="{\n";         
@$content2.="function crawlturltreatment(\$url)\n";
@$content2.="{\n";
@$content2.="global \$crawltlistsessionid, \$crawltsessionid, \$crawltincludeparameter;\n";
@$content2.="if(\$crawltsessionid==0 && \$crawltincludeparameter==1)\n";
@$content2.="{\n";
@$content2.="\$toReturn=\$url;\n";
@$content2.="}\n";
@$content2.="elseif(\$crawltincludeparameter==0)\n";
@$content2.="{\n";
@$content2.="\$explodeurl=explode(\"?\",\$url);\n";
@$content2.="\$toReturn=\$explodeurl[0];\n";
@$content2.="}\n";
@$content2.="else\n";
@$content2.="{\n";                
@$content2.="\$url2=ltrim(\$url,\"/\");\n";
@$content2.="\$urltreated =0;\n"; 
@$content2.="\$parseurl = parse_url('http://site.com/'.\$url2);\n";    
@$content2.="if(isset(\$parseurl['query']))\n";
@$content2.="{\n";
@$content2.="\$chaine=\$parseurl['query'];\n";
@$content2.="if(strpos(\$chaine, '&amp;'))\n";        
@$content2.="{\n";
@$content2.="\$queryEx = explode('&amp;', \$chaine);\n";
@$content2.="\$separator='&amp;';\n";
@$content2.="}\n";
@$content2.="else\n";
@$content2.="{\n";
@$content2.="\$queryEx = explode('&', \$chaine);\n";
@$content2.="\$separator='&';\n";
@$content2.="}\n"; 
@$content2.="\$return = \$parseurl['path'] . '?';\n";		
@$content2.="foreach(\$queryEx as \$value)\n";
@$content2.="{\n";
@$content2.="\$varAndValue = explode('=', \$value);\n";        
@$content2.="// include only parameters\n";
@$content2.="if( sizeof(\$varAndValue) >= 2  && in_array(\$varAndValue[0], \$crawltlistsessionid))\n";
@$content2.="{\n";
@$content2.="\$urltreated=1;\n";	
@$content2.="}\n";
@$content2.="elseif( sizeof(\$varAndValue) >= 2)\n";
@$content2.="{\n";
@$content2.="\$return .= \$varAndValue[0].\"=\";\n";
@$content2.="for(\$i=1; \$i< sizeof(\$varAndValue);\$i++)\n";
@$content2.="{\n";
@$content2.="\$return .= \$varAndValue[\$i].\"=\";\n";
@$content2.="}\n";
@$content2.="\$return = rtrim(\$return,\"=\").\$separator;\n";			
@$content2.="}\n";
@$content2.="}\n";		
@$content2.="if(substr(\$return, strlen(\$return)-strlen(\$separator)) == \$separator && \$urltreated==1)\n";
@$content2.="{\n";
@$content2.="\$toReturn = substr(\$return, 0, strlen(\$return)-strlen(\$separator));\n";
@$content2.="}\n";
@$content2.="else if(substr(\$return, strlen(\$return)-1) == '?'  && \$urltreated==1)\n";
@$content2.="{\n";
@$content2.="\$toReturn = substr(\$return, 0, strlen(\$return)-1);\n";
@$content2.="}\n";
@$content2.="elseif(\$urltreated==0)\n";
@$content2.="{\n";
@$content2.="\$toReturn=\$url;\n";
@$content2.="}\n";
@$content2.="}\n";
@$content2.="else\n";
@$content2.="{\n";
@$content2.="\$toReturn = \$url;\n";
@$content2.="}\n"; 
@$content2.="}\n";               
@$content2.="return \$toReturn;\n";
@$content2.="}\n"; 
@$content2.="}\n"; 
@$content2.="//function browser identification \n";
@$content2.="if( function_exists( \"crawltbrowserid\" ) == false )\n";
@$content2.="{\n";
@$content2.="function crawltbrowserid(\$ua)\n";
@$content2.="{\n";
@$content2.="if(preg_match(\"/MSIE 7/i\", \$ua))\n";
@$content2.="{\n";
@$content2.="\$browser=5;\n";
@$content2.="}\n";
@$content2.="elseif(preg_match(\"/Firefox/i\", \$ua))\n"; 
@$content2.="{\n"; 
@$content2.="\$browser=2;\n"; 
@$content2.="}\n"; 
@$content2.="elseif(preg_match(\"/MSIE 6/i\", \$ua))\n"; 
@$content2.="{\n"; 
@$content2.="\$browser=4;\n"; 
@$content2.="}\n"; 
@$content2.="elseif(preg_match(\"/MSIE 8/i\", \$ua))\n"; 
@$content2.="{\n"; 
@$content2.="\$browser=6;\n"; 
@$content2.="}\n"; 
@$content2.="elseif(preg_match(\"/MSIE 5/i\", \$ua))\n"; 
@$content2.="{\n"; 
@$content2.="\$browser=3;\n"; 
@$content2.="}\n"; 
@$content2.="elseif(preg_match(\"/Opera Mini/i\", \$ua))\n"; 
@$content2.="{\n"; 
@$content2.="\$browser=22;\n"; 
@$content2.="}\n"; 
@$content2.="elseif(preg_match(\"/Opera/i\", \$ua))\n"; 
@$content2.="{\n"; 
@$content2.="\$browser=9;\n"; 
@$content2.="}\n"; 
@$content2.="elseif(preg_match(\"/Chrome/i\", \$ua))\n"; 
@$content2.="{\n"; 
@$content2.="\$browser=1;\n"; 
@$content2.="}\n"; 
@$content2.="elseif(preg_match(\"/Nokia/i\", \$ua))\n"; 
@$content2.="{\n"; 
@$content2.="\$browser=21;\n"; 
@$content2.="}\n"; 
@$content2.="elseif(preg_match(\"/iPod/i\", \$ua))\n";
@$content2.="{\n";
@$content2.="\$browser=19;\n";
@$content2.="}\n";
@$content2.="elseif(preg_match(\"/iPhone/i\", \$ua))\n";
@$content2.="{\n";
@$content2.="\$browser=18;\n";
@$content2.="}\n";
@$content2.="elseif(preg_match(\"/Android/i\", \$ua))\n";
@$content2.="{\n";
@$content2.="\$browser=20;\n";
@$content2.="}\n";
@$content2.="elseif(preg_match(\"/Safari/i\", \$ua))\n"; 
@$content2.="{\n"; 
@$content2.="\$browser=10;\n"; 
@$content2.="}\n"; 
@$content2.="elseif(preg_match(\"/MSIE 4/i\", \$ua))\n";
@$content2.="{\n";
@$content2.="\$browser=7;\n";
@$content2.="}\n";
@$content2.="elseif(preg_match(\"/PlayStation Portable/i\", \$ua))\n";
@$content2.="{\n";
@$content2.="\$browser=8;\n";
@$content2.="}\n";
@$content2.="elseif(preg_match(\"/OmniWeb/i\", \$ua))\n";
@$content2.="{\n";
@$content2.="\$browser=11;\n";
@$content2.="}\n";
@$content2.="elseif(preg_match(\"/BrowseX/i\", \$ua))\n";
@$content2.="{\n";
@$content2.="\$browser=12;\n";
@$content2.="}\n";
@$content2.="elseif(preg_match(\"/MultiZilla/i\", \$ua))\n";
@$content2.="{\n";
@$content2.="\$browser=13;\n";
@$content2.="}\n";
@$content2.="elseif(preg_match(\"/SeaMonkey/i\", \$ua))\n";
@$content2.="{\n";
@$content2.="\$browser=14;\n";
@$content2.="}\n";
@$content2.="elseif(preg_match(\"/K-meleon/i\", \$ua))\n";
@$content2.="{\n";
@$content2.="\$browser=15;\n";
@$content2.="}\n";
@$content2.="elseif(preg_match(\"/Camino/i\", \$ua))\n";
@$content2.="{\n";
@$content2.="\$browser=16;\n";
@$content2.="}\n";
@$content2.="elseif(preg_match(\"/Konqueror/i\", \$ua))\n";
@$content2.="{\n";
@$content2.="\$browser=17;\n";
@$content2.="}\n";
@$content2.="elseif(preg_match(\"/iPad/i\", \$ua))\n";
@$content2.="{\n";
@$content2.="\$browser=23;\n";
@$content2.="}\n";
@$content2.="else\n";
@$content2.="{\n";
@$content2.="\$browser=0;\n";
@$content2.="}\n";
@$content2.="return \$browser;\n";
@$content2.="}\n";
@$content2.="}\n";
@$content2.="//get information\n";        
@$content2.="\$crawltispostdata=0;\n";
@$content2.="if (!isset(\$_SERVER))\n";
@$content2.="	{\n";
@$content2.="	\$_SERVER = \$HTTP_SERVER_VARS;\n";	
@$content2.="	}\n";       		
@$content2.="if(isset(\$_POST['agent']) && isset(\$_POST['ip']) && isset(\$_POST['url']) && isset(\$_POST['site']) && isset(\$_POST['cookie']))\n";
@$content2.="	{\n";
@$content2.="	\$crawltagent = \$_POST['agent'];\n";
@$content2.="\$crawltispostdata=1;\n";        	
@$content2.="	}\n";       
@$content2.="else\n";
@$content2.="	{\n";
@$content2.="	\$crawltagent =\$_SERVER['HTTP_USER_AGENT'];\n";	
@$content2.="	}\n";        
@$content2.="if(\$crawltispostdata==1)\n";
@$content2.="	{\n";
@$content2.="	\$crawltip = \$_POST['ip'];\n";	
@$content2.="	}\n";
@$content2.="else\n";
@$content2.="	{\n";
@$content2.="\$crawltip = \$_SERVER['REMOTE_ADDR'];\n";
@$content2.="	}\n";        													
@$content2.="if(\$crawltispostdata==1)\n";
@$content2.="	{\n";
@$content2.="	\$crawlturl2 = \$_POST['url'];\n";        
@$content2.="\$crawltpostrequest=1;\n";
@$content2.="	}\n";
@$content2.="else\n";
@$content2.="	{\n";
@$content2.="if(isset(\$_ENV['REQUEST_URI']) && substr(\$_ENV['REQUEST_URI'], -3)!='cgi')\n";
@$content2.=" {\n";
@$content2.=" \$crawlturl2 =\$_ENV['REQUEST_URI'];\n";    
@$content2.=" }\n";
@$content2.="else\n";
@$content2.=" {\n";       
@$content2.="	\$crawlturl2 =\$_SERVER['REQUEST_URI'];\n";
@$content2.="	}\n";         
@$content2.="\$crawltpostrequest=0;\n";        	
@$content2.="	}\n";               	
@$content2.="if(\$crawltispostdata==1)\n";
@$content2.="	{\n";
@$content2.="	\$crawltsite = \$_POST['site'];\n";	
@$content2.="	}\n";
@$content2.="else\n";
@$content2.="	{\n";
@$content2.="   if(!isset(\$crawltsite))\n";
@$content2.="	    {\n";
@$content2.="       \$crawltsite=\$site;\n";
@$content2.="	    }\n";					
@$content2.="	}\n";              
@$content2.="if(\$crawltispostdata==1)\n";
@$content2.="	{\n";
@$content2.="	\$_COOKIE[\"crawltrackstats\".\$crawltsite] = \$_POST['cookie'];\n";
@$content2.="	}\n";
@$content2.="if(\$crawltispostdata==1)\n";
@$content2.="	{\n";
@$content2.="	\$crawlthttpcode = \$_POST['httpcode'];\n";
@$content2.="	}\n";
@$content2.="else\n";
@$content2.="	{\n";
@$content2.="  \$crawlthttpcode = \$_SERVER['REDIRECT_STATUS'];\n";
@$content2.="	}\n";	               
@$content2.="//get config parameters\n";
@$content2.="\$sqlcrawltconfig = \"SELECT mail, datelastmail, timeshift, lang, addressmail, datelastseorequest, loop1, loop2, typemail, typecharset, blockattack, datelastcleaning, sessionid,includeparameter FROM crawlt_config\";\n";
@$content2.="\$requetecrawltconfig = mysql_query(\$sqlcrawltconfig, \$crawltconnexion);\n";
@$content2.="\$nbrresultcrawlt=mysql_num_rows(\$requetecrawltconfig);\n";
@$content2.="if(\$nbrresultcrawlt>=1)\n";
@$content2.="    {\n";	
@$content2.="    \$lignecrawlt = mysql_fetch_row(\$requetecrawltconfig);\n";
@$content2.="    \$crawltmail=\$lignecrawlt[0];\n";
@$content2.="    \$crawltdatemail=\$lignecrawlt[1];\n";
@$content2.="    \$crawlttime=\$lignecrawlt[2];\n";
@$content2.="    \$crawltlang=\$lignecrawlt[3];\n";
@$content2.="    \$crawltdest=\$lignecrawlt[4];\n";
@$content2.="    \$crawltdatelastseorequest=\$lignecrawlt[5];\n";
@$content2.="    \$crawltloop=\$lignecrawlt[6];\n"; 
@$content2.="    \$crawltloop2=\$lignecrawlt[7];\n";
@$content2.="    \$crawltmailishtml=\$lignecrawlt[8];\n";
@$content2.="    \$crawltcharset=\$lignecrawlt[9];\n";
@$content2.="    \$crawltblockattack=\$lignecrawlt[10];\n";
@$content2.="    \$datecleaning=\$lignecrawlt[11];\n";
@$content2.="    \$crawltsessionid=\$lignecrawlt[12];\n";          
@$content2.="    \$crawltincludeparameter=\$lignecrawlt[13];\n";        
@$content2.="    if( \$crawltcharset !=1)\n";
@$content2.="       {\n"; 
@$content2.="       \$crawltlang = \$crawltlang.\"iso\";\n";
@$content2.="       }\n";                         
@$content2.="    \$crawltcheck=1;\n";                       
@$content2.="    }\n";
@$content2.="	\$crawlturl = crawlturltreatment(\$crawlturl2);\n";          
@$content2.="//count all the hits---------------------------------------------------\n"; 
@$content2.="//check if the date exist in the crawlt_hits table for that site\n"; 
@$content2.="\$crawlttodaylocal = date(\"Y-m-d\",(strtotime(\"today\")- (\$crawlttime * 3600)));\n"; 
@$content2.="\$crawltresult = mysql_query(\"SELECT id FROM crawlt_hits\n"; 
@$content2.=" WHERE  date='\".crawlt_sql_quote(\$crawlttodaylocal).\"'\n"; 
@$content2.=" AND idsite='\".crawlt_sql_quote(\$crawltsite).\"'\",\$crawltconnexion);\n"; 
@$content2.="\$crawltnum_rows = mysql_num_rows(\$crawltresult);\n"; 
@$content2.="if(\$crawltnum_rows>0)\n"; 
@$content2.="  {\n"; 
@$content2.="  //the date already exist in the table\n"; 
@$content2.="    while (\$crawltligne = mysql_fetch_row(\$crawltresult))\n";                                                                              
@$content2.="    {\n"; 
@$content2.="    \$crawltid=\$crawltligne[0];\n";                                                
@$content2.="    }\n"; 
@$content2.="   //add 1 in the date count\n"; 
@$content2.="    \$crawltsqlupdate=\"UPDATE crawlt_hits SET count=count+1\n"; 
@$content2.="     WHERE id='\".crawlt_sql_quote(\$crawltid).\"'\";\n"; 
@$content2.="    \$crawltrequeteupdate = mysql_query(\$crawltsqlupdate, \$crawltconnexion);\n"; 
@$content2.="  }\n"; 
@$content2.="else\n"; 
@$content2.="  {\n"; 
@$content2.="  //the link didn't exist in the table, create it\n"; 
@$content2.="  \$crawltsql=\"INSERT INTO crawlt_hits ( count,date, idsite) VALUES ('1','\".crawlt_sql_quote(\$crawlttodaylocal).\"','\".crawlt_sql_quote(\$crawltsite).\"')\";\n"; 
@$content2.="  \$crawltrequete = mysql_query(\$crawltsql, \$crawltconnexion);\n"; 
@$content2.="  }\n"; 
@$content2.="//---------------------------------------------------------------------\n"; 
@$content2.="//check if it's an attack\n";
@$content2.="\$crawlturl3 =	str_replace(\$crawltcssaattack,'http:',\$crawlturl2);\n";
@$content2.="\$crawlturl4 =	str_replace(\$crawltsqlaattack,'%20select%20',\$crawlturl2);\n";
@$content2.="if(preg_match(\"/http\:/i\", ltrim(\$crawlturl3,\"h\")))\n";
@$content2.="{\n";
@$content2.="\$crawlttypeattack=65500;\n";
@$content2.="\$crawltattack=1;\n";
@$content2.="\$crawlturl=\$crawlturl2;\n";
@$content2.="\$crawltnbrattack=substr_count(\$crawlturl3,'http:');\n";
@$content2.="\$crawltnbrgoodsite=0;\n";
@$content2.="foreach(\$crawltlistgoodsite as \$crawltgoodsite)\n";
@$content2.="{\n";
@$content2.="if(strpos(\$crawlturl, \$crawltgoodsite))\n";
@$content2.="{\n";
@$content2.="\$crawltnbrgoodsite++;\n";
@$content2.="}\n";
@$content2.="}\n";
@$content2.="if(\$crawltnbrgoodsite == \$crawltnbrattack && \$crawltnbrattack !=0)\n";
@$content2.="{\n";
@$content2.="\$crawltattack=0;\n";
@$content2.="}\n";
@$content2.="}\n";
@$content2.="elseif(preg_match(\"/%20select%20/i\", \$crawlturl4))\n";
@$content2.="{\n";
@$content2.="\$crawlttypeattack=65501;\n";
@$content2.="\$crawltattack=1;\n";
@$content2.="\$crawlturl=\$crawlturl2;\n";
@$content2.="\$crawltnbrattack=substr_count(\$crawlturl,'http:');\n";
@$content2.="\$crawltnbrgoodsite=0;\n";
@$content2.="foreach(\$crawltlistgoodsite as \$crawltgoodsite)\n";
@$content2.="{\n";
@$content2.="if(strpos(\$crawlturl, \$crawltgoodsite))\n";
@$content2.="{\n";
@$content2.="\$crawltnbrgoodsite++;\n";
@$content2.="}\n";
@$content2.="}\n";
@$content2.="if(\$crawltnbrgoodsite == \$crawltnbrattack && \$crawltnbrattack !=0)\n";
@$content2.="{\n";
@$content2.="\$crawltattack=0;\n";
@$content2.="}\n";
@$content2.="}\n";
@$content2.="else\n";
@$content2.="{\n";
@$content2.="\$crawlttypeattack=0;\n";
@$content2.="}\n";	
@$content2.="if(\$crawlttypeattack != 0 && \$crawltattack==1)\n";
@$content2.="  {\n";
@$content2.="  \$crawltdate  = date(\"Y-m-d H:i:s\");\n";	
@$content2.="  if(\$crawlthttpcode==404)\n";
@$content2.="    {\n";
@$content2.="    //we just count the number of 404 attack to avoid server overload and to big increase of database size\n";
@$content2.="    //check if the date exist in the crawlt_error table for that site\n";
@$content2.="    \$crawltresult = mysql_query(\"SELECT id FROM crawlt_error\n";
@$content2.="     WHERE  date='\".crawlt_sql_quote(\$crawlttodaylocal).\"'\n";
@$content2.="     AND idsite='\".crawlt_sql_quote(\$crawltsite).\"'\n";
@$content2.="     AND attacktype='\".crawlt_sql_quote(\$crawlttypeattack).\"'\",\$crawltconnexion);\n";
@$content2.="    \$crawltnum_rows = mysql_num_rows(\$crawltresult);\n";
@$content2.="    if(\$crawltnum_rows>0)\n";
@$content2.="      {\n";
@$content2.="      //the date already exist in the table\n";
@$content2.="       while (\$crawltligne = mysql_fetch_row(\$crawltresult))\n";                                                                              
@$content2.="        {\n";
@$content2.="        \$crawltid=\$crawltligne[0];\n";                                               
@$content2.="        }\n";
@$content2.="       //add 1 in the date count\n";
@$content2.="        \$crawltsqlupdate=\"UPDATE crawlt_error SET count=count+1\n";
@$content2.="         WHERE id='\".crawlt_sql_quote(\$crawltid).\"'\";\n";
@$content2.="        \$crawltrequeteupdate = mysql_query(\$crawltsqlupdate, \$crawltconnexion);\n";
@$content2.="      }\n";
@$content2.="    else\n";
@$content2.="      {\n";
@$content2.="      //the link didn't exist in the table, create it\n";
@$content2.="      \$crawltsql=\"INSERT INTO crawlt_error ( count,date, idsite, attacktype) VALUES ('1','\".crawlt_sql_quote(\$crawlttodaylocal).\"','\".crawlt_sql_quote(\$crawltsite).\"','\".crawlt_sql_quote(\$crawlttypeattack).\"')\";\n";
@$content2.="      \$crawltrequete = mysql_query(\$crawltsql, \$crawltconnexion);\n";
@$content2.="      }\n";
@$content2.="    }\n";
@$content2.="  else\n";
@$content2.="    {\n";
@$content2.="    //check if the page already exist, if not add it to the table\n";
@$content2.="    \$result2 = mysql_query(\"SELECT id_page FROM crawlt_pages_attack WHERE url_page='\".crawlt_sql_quote(\$crawlturl).\"'\",\$crawltconnexion);\n";
@$content2.="    \$num_rows2 = mysql_num_rows(\$result2);\n";
@$content2.="    if (\$num_rows2>0)\n";
@$content2.="      {\n";
@$content2.="      \$crawltdata2 = mysql_fetch_row(\$result2);\n";
@$content2.="      \$crawltpage= \$crawltdata2[0];\n";
@$content2.="      }\n";
@$content2.="    else\n";
@$content2.="      {\n";
@$content2.="      mysql_query(\"INSERT INTO crawlt_pages_attack (url_page) VALUES ('\".crawlt_sql_quote(\$crawlturl).\"')\",\$crawltconnexion);\n";
@$content2.="      \$crawltid_insert = mysql_fetch_row(mysql_query(\"SELECT LAST_INSERT_ID()\",\$crawltconnexion));\n";
@$content2.="      \$crawltpage = \$crawltid_insert[0];\n";
@$content2.="      }\n";
@$content2.="    //insertion of the visit datas in the visits database\n";
@$content2.="    mysql_query(\"INSERT INTO crawlt_visits (crawlt_site_id_site, crawlt_pages_id_page, crawlt_crawler_id_crawler, date, crawlt_ip_used, crawlt_error) VALUES ('\".crawlt_sql_quote(\$crawltsite).\"', '\".crawlt_sql_quote(\$crawltpage).\"', '\".crawlt_sql_quote(\$crawlttypeattack).\"', '\".crawlt_sql_quote(\$crawltdate).\"', '\".crawlt_sql_quote(\$crawltip).\"','0')\",\$crawltconnexion);\n";
@$content2.="    }\n";
@$content2.="  }\n";	
@$content2.="else\n";
@$content2.="{\n";        
@$content2.="//treatment of ip to prepare the mysql request\n";
@$content2.="\$crawltcptip=1;\n";
@$content2.="\$crawltlgthip=strlen(\$crawltip);\n";
@$content2.="while(\$crawltcptip <=\$crawltlgthip)\n";
@$content2.="{\n";
@$content2.="\$crawlttableip[]=substr(\$crawltip,0,\$crawltcptip);\n";
@$content2.="\$crawltcptip++;\n";
@$content2.="}\n";
@$content2.="\$crawltlistip=implode(\"','\",\$crawlttableip);\n";               	             
@$content2.="// check if the user agent or the ip exist in the crawler table\n";		
@$content2.="\$result = mysql_query(\"SELECT crawler_user_agent, crawler_ip,id_crawler FROM crawlt_crawler\n"; 
@$content2.=" WHERE INSTR('\".crawlt_sql_quote(\$crawltagent).\"',crawler_user_agent) > 0\n";
@$content2.="OR crawler_ip IN ('\$crawltlistip') \",\$crawltconnexion);\n";
@$content2.="\$num_rows = mysql_num_rows(\$result);\n";
@$content2.="if (\$num_rows>0)\n";
@$content2.="{\n";              
@$content2.="\$crawltdata = mysql_fetch_row(\$result);\n";
@$content2.="\$crawltcrawler = \$crawltdata[2];\n";
@$content2.="\$crawltdate  = date(\"Y-m-d H:i:s\");\n";
@$content2.="//check if the page already exist, if not add it to the table\n";        
@$content2.="\$result2 = mysql_query(\"SELECT id_page FROM crawlt_pages WHERE url_page='\".crawlt_sql_quote(\$crawlturl).\"'\",\$crawltconnexion);\n";
@$content2.="\$num_rows2 = mysql_num_rows(\$result2);\n";
@$content2.="if (\$num_rows2>0)\n";
@$content2.="{\n";
@$content2.="\$crawltdata2 = mysql_fetch_row(\$result2);\n";	
@$content2.="\$crawltpage= \$crawltdata2[0];\n";
@$content2.="}\n";        
@$content2.="else\n";
@$content2.="{\n";
@$content2.="mysql_query(\"INSERT INTO crawlt_pages (url_page) VALUES ('\".crawlt_sql_quote(\$crawlturl).\"')\",\$crawltconnexion);\n";
@$content2.="\$crawltid_insert = mysql_fetch_row(mysql_query(\"SELECT LAST_INSERT_ID()\",\$crawltconnexion));\n";
@$content2.="\$crawltpage = \$crawltid_insert[0];\n";
@$content2.="}\n";
@$content2.="if(\$crawlthttpcode==404)\n";
@$content2.="  {\n";
@$content2.="  \$crawlterror=1;\n";
@$content2.="  }\n";
@$content2.="else\n";
@$content2.="  {\n";
@$content2.="  \$crawlterror=0;\n";
@$content2.="  }\n";       
@$content2.="//insertion of the visit datas in the visits database\n";
@$content2.="mysql_query(\"INSERT INTO crawlt_visits (crawlt_site_id_site, crawlt_pages_id_page, crawlt_crawler_id_crawler, date, crawlt_ip_used, crawlt_error) VALUES ('\".crawlt_sql_quote(\$crawltsite).\"', '\".crawlt_sql_quote(\$crawltpage).\"', '\".crawlt_sql_quote(\$crawltcrawler).\"', '\".crawlt_sql_quote(\$crawltdate).\"', '\".crawlt_sql_quote(\$crawltip).\"', '\".crawlt_sql_quote(\$crawlterror).\"')\",\$crawltconnexion);\n";      
@$content2.="}\n";        
@$content2.="else\n";
@$content2.="{\n";
@$content2.="//check if it's really a visitor and if it's not you !!!\n";
@$content2.="\$crawltbrowserconcat=implode(\"|\",\$crawltbrowserlist);\n"; 
@$content2.="\$crawltnonebrowserconcat=implode(\"|\",\$crawltnonebrowserlist);\n"; 
@$content2.="if((!isset(\$_COOKIE[\"crawltrackstats\".\$crawltsite]) OR \$_COOKIE[\"crawltrackstats\".\$crawltsite]!='nocountinstats') && (ereg(\$crawltbrowserconcat, \$crawltagent) && !ereg(\$crawltnonebrowserconcat, \$crawltagent)))\n";
@$content2.="  {\n";
@$content2.="    //case human visit\n";
@$content2.="    \$crawltbrowser = crawltbrowserid(\$crawltagent);\n";
@$content2.="    \$crawltdate  = date(\"Y-m-d H:i:s\");\n";
@$content2.="    if(isset(\$_POST['referer']) && \$crawltispostdata==1 && \$_POST['referer']!='')\n";
@$content2.="   {\n";
@$content2.="    \$crawltreferer = \$_POST['referer'];\n";
@$content2.="    \$crawltrefereok=1;\n";
@$content2.="    }\n";
@$content2.="    elseif(isset(\$_SERVER['HTTP_REFERER']))\n";
@$content2.="    {\n";
@$content2.="    \$crawltreferer=\$_SERVER['HTTP_REFERER'];\n";
@$content2.="    \$crawltrefereok=1;\n";
@$content2.="    }\n";
@$content2.="    else\n";
@$content2.="    {\n";
@$content2.="    \$crawltrefereok=0;\n";
@$content2.="    }\n";
@$content2.="    if(\$crawltrefereok==1)\n";
@$content2.="    {\n";
@$content2.="    \$crawltreferertreatment = parse_url(\$crawltreferer);\n";
@$content2.="    \$crawltsearchengine=0;\n";      
@$content2.="    //test google\n";       
@$content2.="   if( in_array(\"\$crawltreferertreatment[host]\",\$crawltgooglelist)=='True')\n";
@$content2.="    {\n";
@$content2.="    \$crawltsearchengine=1;\n";
@$content2.="    parse_str(\$crawltreferertreatment['query'],\$crawlttabvar);\n";
@$content2.="    \$crawltkeyword = \$crawlttabvar['q'];\n";
@$content2.="    if(\$crawltkeyword=='')\n";
@$content2.="    {\n";
@$content2.="    \$crawltkeyword = \$crawlttabvar['as_q'];\n";
@$content2.="    if(\$crawltkeyword=='')\n";
@$content2.="    {\n";
@$content2.="    \$crawltkeyword = \$crawlttabvar['as_epq'];\n";
@$content2.="    if(\$crawltkeyword=='')\n";
@$content2.="    {\n";       
@$content2.="    \$crawltkeyword = \$crawlttabvar['as_oq'];\n";
@$content2.="    if(\$crawltkeyword=='')\n";
@$content2.="    {\n";        
@$content2.="    \$crawltkeyword = \$crawlttabvar['as_eq'];\n";
@$content2.="    if(\$crawltkeyword=='')\n";
@$content2.="    {\n";         
@$content2.="    \$crawltkeyword = \$crawlttabvar['as_occt'];\n";
@$content2.="    if(\$crawltkeyword=='')\n";
@$content2.="    {\n";                      
@$content2.="    \$crawltsearchengine=0;\n";
@$content2.="    }\n";
@$content2.="    }\n";
@$content2.="    }\n";
@$content2.="    }\n";
@$content2.="    }\n";
@$content2.="    }\n";        
@$content2.="    }\n";                   
@$content2.="    //test yahoo\n";
@$content2.="    elseif(in_array(\"\$crawltreferertreatment[host]\",\$crawltyahoolist)=='True')\n";
@$content2.="    {\n";
@$content2.="    \$crawltsearchengine=2;\n";
@$content2.="    parse_str(\$crawltreferertreatment['query'],\$crawlttabvar);\n";
@$content2.="    \$crawltkeyword = \$crawlttabvar['p'];\n";
@$content2.="    if(\$crawltkeyword=='')\n";
@$content2.="    {\n";
@$content2.="    \$crawltsearchengine=0;\n";
@$content2.="    }\n";
@$content2.="    }\n";
@$content2.="    //test msn\n";
@$content2.="    elseif(in_array(\"\$crawltreferertreatment[host]\",\$crawltmsnlist)=='True')\n";
@$content2.="    {\n";
@$content2.="    \$crawltsearchengine=3;\n";
@$content2.="    parse_str(\$crawltreferertreatment['query'],\$crawlttabvar);\n";
@$content2.="    \$crawltkeyword = \$crawlttabvar['q'];\n";
@$content2.="    if(\$crawltkeyword=='')\n";
@$content2.="    {\n";
@$content2.="    \$crawltkeyword = \$crawlttabvar['MT'];\n";
@$content2.="    if(\$crawltkeyword=='')\n";
@$content2.="    {\n";
@$content2.="    \$crawltsearchengine=0;\n";
@$content2.="    }\n";
@$content2.="    }\n";
@$content2.="    }\n";
@$content2.="    //test ask\n";
@$content2.="    elseif(in_array(\"\$crawltreferertreatment[host]\",\$crawltasklist)=='True')\n";
@$content2.="    {\n";
@$content2.="    \$crawltsearchengine=4;\n";
@$content2.="    parse_str(\$crawltreferertreatment['query'],\$crawlttabvar);\n";
@$content2.="    \$crawltkeyword = \$crawlttabvar['q'];\n";
@$content2.="    if(\$crawltkeyword=='')\n";
@$content2.="    {\n";
@$content2.="    \$crawltsearchengine=0;\n";
@$content2.="    }\n";
@$content2.="    }\n";
@$content2.="    //test baidu (replace exalead since crawltrack 3.2.0)\n";
@$content2.="    elseif(in_array(\"\$crawltreferertreatment[host]\",\$crawltbaidulist)=='True')\n";
@$content2.="    {\n";
@$content2.="    \$crawltsearchengine=5;\n";
@$content2.="    parse_str(\$crawltreferertreatment['query'],\$crawlttabvar);\n";
@$content2.="    \$crawltkeyword = \$crawlttabvar['wd'];\n";
@$content2.="    if(\$crawltkeyword=='')\n";
@$content2.="    {\n";         
@$content2.="    \$crawltkeyword = \$crawlttabvar['word'];\n";
@$content2.="    if(\$crawltkeyword=='')\n";
@$content2.="    {\n";                      
@$content2.="    \$crawltsearchengine=0;\n";
@$content2.="    }\n";
@$content2.="    }\n";
@$content2.="    }\n";
@$content2.="    //case visit send by one of the 5 searchengine\n";
@$content2.="    if(\$crawltsearchengine !=0)\n";
@$content2.="    {\n";
@$content2.="    //check if the referer already exist, if not add it to the table\n";
@$content2.="    \$result5 = mysql_query(\"SELECT id_referer FROM crawlt_referer WHERE referer='\".crawlt_sql_quote(\$crawltreferer).\"'\");\n";
@$content2.="    \$num_rows5 = mysql_num_rows(\$result5);\n";
@$content2.="    if (\$num_rows5>0)\n";
@$content2.="    {\n";
@$content2.="    \$crawltdata5 = mysql_fetch_row(\$result5);\n";
@$content2.="    \$crawltrefererid= \$crawltdata5[0];\n";
@$content2.="    }\n";
@$content2.="    else\n";
@$content2.="    {\n";
@$content2.="    mysql_query(\"INSERT INTO crawlt_referer (referer) VALUES ('\".crawlt_sql_quote(\$crawltreferer).\"')\");\n";
@$content2.="    \$crawltid_insert3 = mysql_fetch_row(mysql_query(\"SELECT LAST_INSERT_ID()\"));\n";
@$content2.="    \$crawltrefererid = \$crawltid_insert3[0];\n";
@$content2.="    }\n";  
@$content2.="    //check if the keyword already exist, if not add it to the table\n";
@$content2.="    \$result4 = mysql_query(\"SELECT id_keyword FROM crawlt_keyword WHERE keyword='\".crawlt_sql_quote(\$crawltkeyword).\"'\");\n";
@$content2.="    \$num_rows4 = mysql_num_rows(\$result4);\n";
@$content2.="    if (\$num_rows4>0)\n";
@$content2.="    {\n";
@$content2.="    \$crawltdata4 = mysql_fetch_row(\$result4);\n";
@$content2.="    \$crawltkeywordid= \$crawltdata4[0];\n";
@$content2.="    }\n";
@$content2.="    else\n";
@$content2.="    {\n";
@$content2.="    mysql_query(\"INSERT INTO crawlt_keyword (keyword) VALUES ('\".crawlt_sql_quote(\$crawltkeyword).\"')\");\n";
@$content2.="    \$crawltid_insert2 = mysql_fetch_row(mysql_query(\"SELECT LAST_INSERT_ID()\"));\n";
@$content2.="    \$crawltkeywordid = \$crawltid_insert2[0];\n";
@$content2.="    }\n";       
@$content2.="    //check if the page already exist, if not add it to the table\n";
@$content2.="    \$result2 = mysql_query(\"SELECT id_page FROM crawlt_pages WHERE url_page='\".crawlt_sql_quote(\$crawlturl).\"'\");\n";
@$content2.="    \$num_rows2 = mysql_num_rows(\$result2);\n";
@$content2.="    if (\$num_rows2>0)\n";
@$content2.="    {\n";
@$content2.="    \$crawltdata2 = mysql_fetch_row(\$result2);\n";
@$content2.="    \$crawltpage= \$crawltdata2[0];\n";
@$content2.="    }\n";
@$content2.="    else\n";
@$content2.="    {\n";
@$content2.="    mysql_query(\"INSERT INTO crawlt_pages (url_page) VALUES ('\".crawlt_sql_quote(\$crawlturl).\"')\");\n";
@$content2.="    \$crawltid_insert = mysql_fetch_row(mysql_query(\"SELECT LAST_INSERT_ID()\"));\n";
@$content2.="    \$crawltpage = \$crawltid_insert[0];\n";
@$content2.="    }\n";        
@$content2.="    //insertion of the visit datas in the visits_human database\n";
@$content2.="    if(\$crawlthttpcode==404)\n";
@$content2.="      {\n";
@$content2.="      \$crawlterror=1;\n";
@$content2.="      }\n";
@$content2.="    else\n";
@$content2.="      {\n";
@$content2.="      \$crawlterror=0;\n";
@$content2.="      }\n";    
@$content2.="    mysql_query(\"INSERT INTO crawlt_visits_human (crawlt_site_id_site, crawlt_keyword_id_keyword, crawlt_id_crawler, date, crawlt_id_page, crawlt_id_referer, crawlt_ip, crawlt_error, crawlt_browser) VALUES ('\".crawlt_sql_quote(\$crawltsite).\"', '\".crawlt_sql_quote(\$crawltkeywordid).\"', '\".crawlt_sql_quote(\$crawltsearchengine).\"', '\".crawlt_sql_quote(\$crawltdate).\"', '\".crawlt_sql_quote(\$crawltpage).\"','\".crawlt_sql_quote(\$crawltrefererid).\"','\".crawlt_sql_quote(\$crawltip).\"', '\".crawlt_sql_quote(\$crawlterror).\"','\".crawlt_sql_quote(\$crawltbrowser).\"')\");\n";
@$content2.="    }\n";
@$content2.="    else\n";
@$content2.="    {\n";
@$content2.="    //case other referer\n";
@$content2.="    //check if the referer already exist, if not add it to the table\n";
@$content2.="    \$result5 = mysql_query(\"SELECT id_referer FROM crawlt_referer WHERE referer='\".crawlt_sql_quote(\$crawltreferer).\"'\");\n";
@$content2.="    \$num_rows5 = mysql_num_rows(\$result5);\n";
@$content2.="    if (\$num_rows5>0)\n";
@$content2.="    {\n";
@$content2.="    \$crawltdata5 = mysql_fetch_row(\$result5);\n";
@$content2.="    \$crawltrefererid= \$crawltdata5[0];\n";
@$content2.="    }\n";
@$content2.="    else\n";
@$content2.="    {\n";
@$content2.="    mysql_query(\"INSERT INTO crawlt_referer (referer) VALUES ('\".crawlt_sql_quote(\$crawltreferer).\"')\");\n";
@$content2.="    \$crawltid_insert3 = mysql_fetch_row(mysql_query(\"SELECT LAST_INSERT_ID()\"));\n";
@$content2.="    \$crawltrefererid = \$crawltid_insert3[0];\n";
@$content2.="    }\n";
@$content2.="    //check if the page already exist, if not add it to the table\n";
@$content2.="    \$result2 = mysql_query(\"SELECT id_page FROM crawlt_pages WHERE url_page='\".crawlt_sql_quote(\$crawlturl).\"'\");\n";
@$content2.="    \$num_rows2 = mysql_num_rows(\$result2);\n";
@$content2.="    if (\$num_rows2>0)\n";
@$content2.="    {\n";
@$content2.="    \$crawltdata2 = mysql_fetch_row(\$result2);\n";
@$content2.="    \$crawltpage= \$crawltdata2[0];\n";
@$content2.="    }\n";
@$content2.="    else\n";
@$content2.="    {\n";
@$content2.="    mysql_query(\"INSERT INTO crawlt_pages (url_page) VALUES ('\".crawlt_sql_quote(\$crawlturl).\"')\");\n";
@$content2.="    \$crawltid_insert = mysql_fetch_row(mysql_query(\"SELECT LAST_INSERT_ID()\"));\n";
@$content2.="    \$crawltpage = \$crawltid_insert[0];\n";
@$content2.="    }\n";
@$content2.="    //insertion of the visit datas in the visits_human database\n";
@$content2.="    if(\$crawlthttpcode==404)\n";
@$content2.="      {\n";
@$content2.="      \$crawlterror=1;\n";
@$content2.="      }\n";
@$content2.="    else\n";
@$content2.="      {\n";
@$content2.="      \$crawlterror=0;\n";
@$content2.="      }\n";    
@$content2.="    mysql_query(\"INSERT INTO crawlt_visits_human (crawlt_site_id_site, crawlt_keyword_id_keyword, crawlt_id_crawler, date, crawlt_id_page, crawlt_id_referer, crawlt_ip, crawlt_error, crawlt_browser) VALUES ('\".crawlt_sql_quote(\$crawltsite).\"', '0', '0','\".crawlt_sql_quote(\$crawltdate).\"', '\".crawlt_sql_quote(\$crawltpage).\"','\".crawlt_sql_quote(\$crawltrefererid).\"','\".crawlt_sql_quote(\$crawltip).\"', '\".crawlt_sql_quote(\$crawlterror).\"','\".crawlt_sql_quote(\$crawltbrowser).\"')\");\n"; 
@$content2.="    }\n";
@$content2.="    }\n";
@$content2.="    else\n";
@$content2.="    {\n";
@$content2.="    //case direct arrival\n";
@$content2.="      //check if the page already exist, if not add it to the table\n";
@$content2.="      \$result2 = mysql_query(\"SELECT id_page FROM crawlt_pages WHERE url_page='\".crawlt_sql_quote(\$crawlturl).\"'\");\n";
@$content2.="      \$num_rows2 = mysql_num_rows(\$result2);\n";
@$content2.="      if (\$num_rows2>0)\n";
@$content2.="      {\n";
@$content2.="      \$crawltdata2 = mysql_fetch_row(\$result2);\n";
@$content2.="      \$crawltpage= \$crawltdata2[0];\n";
@$content2.="      }\n";
@$content2.="      else\n";
@$content2.="      {\n";
@$content2.="      mysql_query(\"INSERT INTO crawlt_pages (url_page) VALUES ('\".crawlt_sql_quote(\$crawlturl).\"')\");\n";
@$content2.="      \$crawltid_insert = mysql_fetch_row(mysql_query(\"SELECT LAST_INSERT_ID()\"));\n";
@$content2.="      \$crawltpage = \$crawltid_insert[0];\n";
@$content2.="      }\n";
@$content2.="      //insertion of the visit datas in the visits_human database\n";
@$content2.="    if(\$crawlthttpcode==404)\n";
@$content2.="      {\n";
@$content2.="      \$crawlterror=1;\n";
@$content2.="      }\n";
@$content2.="    else\n";
@$content2.="      {\n";
@$content2.="      \$crawlterror=0;\n";
@$content2.="      }\n";      
@$content2.="      mysql_query(\"INSERT INTO crawlt_visits_human (crawlt_site_id_site, crawlt_keyword_id_keyword, crawlt_id_crawler, date, crawlt_id_page, crawlt_id_referer, crawlt_ip, crawlt_error, crawlt_browser) VALUES ('\".crawlt_sql_quote(\$crawltsite).\"', '0', '0','\".crawlt_sql_quote(\$crawltdate).\"', '\".crawlt_sql_quote(\$crawltpage).\"','0','\".crawlt_sql_quote(\$crawltip).\"', '\".crawlt_sql_quote(\$crawlterror).\"','\".crawlt_sql_quote(\$crawltbrowser).\"')\");\n";
@$content2.="    }\n";    
@$content2.="  }\n";  
@$content2.="}\n";
@$content2.="}\n";        
@$content2.="//Email daily stats\n";
@$content2.="//take in account timeshift\n";
@$content2.="\$crawltts = strtotime(\"today\")-(\$crawlttime*3600);\n";
@$content2.="\$crawltdatetoday = date(\"j\",\$crawltts);\n";
@$content2.="\$crawltdatetoday2 = date(\"Y-m-d\",\$crawltts);\n";        
@$content2.="\$url_crawlt=\"$url_crawlt\";\n";        
@$content2.="if((\$crawltdatetoday != \$crawltdatelastseorequest) && \$crawltcheck==1)\n";
@$content2.="{\n";
@$content2.="require_once(\"$path/include/searchenginesposition.php\");\n"; 		
@$content2.="}\n";
@$content2.="if((\$crawltdatetoday != \$crawltdatemail) && \$crawltmail==1 && (\$crawltdatetoday == \$crawltdatelastseorequest) && \$crawltcheck==1)\n";
@$content2.="{\n";
@$content2.="\$crawltpath=\"$path\";\n"; 	      	         		      		
@$content2.="require_once(\"$path/include/mail.php\");\n"; 		
@$content2.="}\n";
@$content2.="mysql_close(\$crawltconnexion);\n";
@$content2.="if(\$crawltattack==1 && \$crawltblockattack==1 && \$crawltpostrequest==1)\n";
@$content2.="{\n";
@$content2.="echo \"crawltrack1\";\n";  
@$content2.="}\n";
@$content2.="elseif(\$crawltattack==1 && \$crawltblockattack==1)\n";
@$content2.="{\n";
@$content2.="\$GLOBALS = array();\n"; 
@$content2.="\$_COOKIES = array();\n";
@$content2.="\$_FILES = array();\n";
@$content2.="\$_ENV = array();\n";
@$content2.="\$_REQUEST = array();\n";                                       
@$content2.="\$_POST = array();\n";
@$content2.="\$_GET = array();\n";
@$content2.="\$_SERVER = array();\n";
@$content2.="\$_SESSION = array();\n";
@$content2.="@session_destroy();\n";
@$content2.="@mysql_close();\n";
@$content2.="@header(\"Location:".$url_crawlt."html/noacces.php\");\n";
@$content2.="echo\"<head>\";\n";
@$content2.="echo\"<META HTTP-EQUIV='Refresh' CONTENT='0;URL=".$url_crawlt."html/noacces.php'>\";\n";
@$content2.="echo\"</head>\";\n"; 
@$content2.="} \n";
@$content2.="?>\n";
        
        $filename2=$path.'/crawltrack.php';		
        $filedir=$path;        
        
                
        if ( $file2 = fopen($filename2, "w") )
            {
            fwrite($file2, $content2);
            fclose($file2);
            $result26=1;
            }
        }
    else
        {
        echo"<h1>".$language['chmod_no_ok']."</h1>";
        $result1=0;
        $result2=0;
        }
    }
else
    {
    $result26=1;
    }
//----------------------------------------------------------------------------------------------------   
//set the correct chmod level to all folder
//determine the path to the file
if (isset($_SERVER['SCRIPT_FILENAME']) && !empty($_SERVER['SCRIPT_FILENAME']))
    {
    $path = dirname( $_SERVER['SCRIPT_FILENAME'] );
    }
else
    {
    $path = '.';
    }
if(function_exists('chmod'))
    {
    @chmod($path, 0705);
    @chmod($path.'/cache', 0705);
    @chmod($path.'/graphs', 0705);    
    @chmod($path.'/html', 0705);    
    @chmod($path.'/images', 0705);    
    @chmod($path.'/include', 0705);    
    @chmod($path.'/language', 0705);
    @chmod($path.'/php', 0705);    
    @chmod($path.'/phpmailer', 0705);    
    @chmod($path.'/styles', 0705);            
    }    

//----------------------------------------------------------------------------------------------------    	
//check if the crawlt_good_sites table exit and if not create it
$table_exist18 = 0;
$sql = "SHOW TABLES ";                                                
$tables = mysql_query($sql, $connexion) or die("MySQL query error"); 
while (list($tablename)=mysql_fetch_array($tables)) 
  {
  if($tablename == 'crawlt_good_sites')
    {
    $table_exist18 = 1;
    }
  }
if($table_exist18 == 0)
  {
  //the table didn't exist, we can create it
  $result25 = mysql_query("CREATE TABLE crawlt_good_sites (
    id_site INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
    host_site VARCHAR(255) NULL,
  PRIMARY KEY(id_site),
  KEY host_site (host_site)
  )");
  }
else
  {
  $result25=1;
  }	
//----------------------------------------------------------------------------------------------------
// check if the host_site is an index and if not index it
$result250=0;
$tableinfo250 = mysql_query("SHOW INDEX FROM crawlt_good_sites");
$listcolumn250=array();
while ($table250= mysql_fetch_assoc($tableinfo250))
    {
    $listcolumn250[]=$table250['Column_name'];
    }
if(in_array('host_site',$listcolumn250))
    {
    $result250=1;
    }	
else
    {    
    //add the index    
    $sqlupdate250="CREATE INDEX `host_site` ON `crawlt_good_sites` (`host_site`)";
    $result250 = mysql_query($sqlupdate250, $connexion);
    } 

//----------------------------------------------------------------------------------------------------
//check if the crawlt_attack table exit and if not create it and fill it (use $result 20 and 21)
include"include/createtableattack.php";
//----------------------------------------------------------------------------------------------------
// check if the attack is an index and if not index it
$result200=0;
$tableinfo200 = mysql_query("SHOW INDEX FROM crawlt_attack");
$listcolumn200=array();
while ($table200= mysql_fetch_assoc($tableinfo200))
    {
    $listcolumn200[]=$table200['Column_name'];
    }
if(in_array('attack',$listcolumn200))
    {
    $result200=1;
    }	
else
    {    
    //add the index    
    $sqlupdate200="CREATE INDEX `attack` ON `crawlt_attack` (`attack`)";
    $result200 = mysql_query($sqlupdate200, $connexion);
    } 
//----------------------------------------------------------------------------------------------------
// check if the script is an index and if not index it
if(in_array('script',$listcolumn200))
    {
    $result201=1;
    }	
else
    {    
    //add the index    
    $sqlupdate201="CREATE INDEX `script` ON `crawlt_attack` (`script`)";
    $result201 = mysql_query($sqlupdate201, $connexion);
    } 
//----------------------------------------------------------------------------------------------------
// check if the type is an index and if not index it
if(in_array('type',$listcolumn200))
    {
    $result202=1;
    }	
else
    {    
    //add the index    
    $sqlupdate202="CREATE INDEX `type` ON `crawlt_attack` (`type`)";
    $result202 = mysql_query($sqlupdate202, $connexion);
    } 

//----------------------------------------------------------------------------------------------------   	
//check if the crawlt_sessionid table exit and if not create it
$table_exist19 = 0;
$sql = "SHOW TABLES ";                                                
$tables = mysql_query($sql, $connexion) or die("MySQL query error"); 
while (list($tablename)=mysql_fetch_array($tables)) 
  {
  if($tablename == 'crawlt_sessionid')
    {
    $table_exist19 = 1;
    }
  }
if($table_exist19 == 0)
  {
  //the table didn't exist, we can create it
  $result29 = mysql_query("CREATE TABLE crawlt_sessionid (
  id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
    sessionid VARCHAR(45) NULL,
  PRIMARY KEY(id)
  )");
  }
else
  {
  $result29=1;
  }		
//----------------------------------------------------------------------------------------------------   	
//check if the crawlt_badreferer table exit and if not create it
$table_exist31 = 0;
$sql = "SHOW TABLES ";                                                
$tables = mysql_query($sql, $connexion) or die("MySQL query error"); 
while (list($tablename)=mysql_fetch_array($tables)) 
  {
  if($tablename == 'crawlt_badreferer')
    {
    $table_exist31 = 1;
    }
  }
if($table_exist31 == 0)
  {
  //the table didn't exist, we can create it
  $result31 = mysql_query("CREATE TABLE crawlt_badreferer (
              id_referer int(10) unsigned NOT NULL auto_increment,
              referer varchar(255) default NULL,
              KEY referer (referer),
              KEY id_referer (id_referer)
            )");
  }
else
  {
  $result31=1;
  }
//----------------------------------------------------------------------------------------------------
// check if the crawler_info is an index and if not index it (crawlt_crawler table)
$result32=0;
$tableinfo32 = mysql_query("SHOW INDEX FROM crawlt_crawler");
$listcolumn32=array();
while ($table32= mysql_fetch_assoc($tableinfo32))
    {
    $listcolumn32[]=$table32['Column_name'];
    }
if(in_array('crawler_info',$listcolumn32))
    {
    $result32=1;
    }	
else
    {    
    //add the index    
    $sqlupdate32="CREATE INDEX `crawler_info` ON `crawlt_crawler` (`crawler_info`)";
    $result32 = mysql_query($sqlupdate32, $connexion);
    } 
//----------------------------------------------------------------------------------------------------
// check if the crawler_ip is an index and if not index it (crawlt_crawler table)
if(in_array('crawler_ip',$listcolumn32))
    {
    $result33=1;
    }	
else
    {    
    //add the index    
    $sqlupdate33="CREATE INDEX `crawler_ip` ON `crawlt_crawler` (`crawler_ip`)";
    $result33 = mysql_query($sqlupdate33, $connexion);
    } 
//----------------------------------------------------------------------------------------------------
// check if the crawler_name is an index and if not index it (crawlt_crawler table)
if(in_array('crawler_name',$listcolumn32))
    {
    $result34=1;
    }	
else
    {    
    //add the index    
    $sqlupdate34="CREATE INDEX `crawler_name` ON `crawlt_crawler` (`crawler_name`)";
    $result34 = mysql_query($sqlupdate34, $connexion);
    } 
//----------------------------------------------------------------------------------------------------
// check if the crawler_url is an index and if not index it (crawlt_crawler table)
if(in_array('crawler_url',$listcolumn32))
    {
    $result35=1;
    }	
else
    {    
    //add the index    
    $sqlupdate35="CREATE INDEX `crawler_url` ON `crawlt_crawler` (`crawler_url`)";
    $result35 = mysql_query($sqlupdate35, $connexion);
    } 
//----------------------------------------------------------------------------------------------------
// check if the crawler_user_agent is an index and if not index it (crawlt_crawler table)
if(in_array('crawler_user_agent',$listcolumn32))
    {
    $result36=1;
    }	
else
    {    
    //add the index    
    $sqlupdate36="CREATE INDEX `crawler_user_agent` ON `crawlt_crawler` (`crawler_user_agent`)";
    $result36 = mysql_query($sqlupdate36, $connexion);
    } 
//----------------------------------------------------------------------------------------------------   	
//check if the crawlt_download table exit and if not create it
$table_exist37 = 0;
$sql = "SHOW TABLES ";                                                
$tables = mysql_query($sql, $connexion) or die("MySQL query error"); 
while (list($tablename)=mysql_fetch_array($tables)) 
  {
  if($tablename == 'crawlt_download')
    {
    $table_exist37 = 1;
    }
  }
if($table_exist37 == 0)
  {
  //the table didn't exist, we can create it
  $result37 = mysql_query("CREATE TABLE crawlt_download (
            id smallint(6) NOT NULL auto_increment,
            link varchar(255) NOT NULL,
            count int(11) NOT NULL,
            `date` date NOT NULL,
            idsite smallint(5) NOT NULL,
            KEY id (id,link,count)
          )");
  }
else
  {
  $result37=1;
  }
//----------------------------------------------------------------------------------------------------   	
//check if the crawlt_error table exit and if not create it
$table_exist38 = 0;
$sql = "SHOW TABLES ";                                                
$tables = mysql_query($sql, $connexion) or die("MySQL query error"); 
while (list($tablename)=mysql_fetch_array($tables)) 
  {
  if($tablename == 'crawlt_error')
    {
    $table_exist38 = 1;
    }
  }
if($table_exist38 == 0)
  {
  //the table didn't exist, we can create it
  $result38 = mysql_query("CREATE TABLE crawlt_error (
            id smallint(5) NOT NULL auto_increment,
            idsite smallint(5) NOT NULL,
            count int(10) NOT NULL,
            `date` date NOT NULL,
            attacktype smallint(5) unsigned NOT NULL,
            KEY id (id),
            KEY id_site (idsite),
            KEY `date` (`date`)
          )");
  }
else
  {
  $result38=1;
  }
//----------------------------------------------------------------------------------------------------   	
//check if the crawlt_goodreferer table exit and if not create it
$table_exist39 = 0;
$sql = "SHOW TABLES ";                                                
$tables = mysql_query($sql, $connexion) or die("MySQL query error"); 
while (list($tablename)=mysql_fetch_array($tables)) 
  {
  if($tablename == 'crawlt_goodreferer')
    {
    $table_exist39 = 1;
    }
  }
if($table_exist39 == 0)
  {
  //the table didn't exist, we can create it
  $result39 = mysql_query("CREATE TABLE crawlt_goodreferer (
            referer varchar(255) default NULL,
            id_site smallint(5) NOT NULL,
            KEY referer (referer),
            KEY id_site (id_site)
          )");
  }
else
  {
  $result39=1;
  }
//----------------------------------------------------------------------------------------------------   	
//check if the crawlt_hits table exit and if not create it
$table_exist40 = 0;
$sql = "SHOW TABLES ";                                                
$tables = mysql_query($sql, $connexion) or die("MySQL query error"); 
while (list($tablename)=mysql_fetch_array($tables)) 
  {
  if($tablename == 'crawlt_hits')
    {
    $table_exist40 = 1;
    }
  }
if($table_exist40 == 0)
  {
  //the table didn't exist, we can create it
  $result40 = mysql_query("CREATE TABLE crawlt_hits (
            id smallint(5) NOT NULL auto_increment,
            idsite smallint(5) NOT NULL,
            count int(10) NOT NULL,
            `date` date NOT NULL,
            KEY id (id),
            KEY id_site (idsite),
            KEY `date` (`date`)
          )");
  }
else
  {
  $result40=1;
  }
//----------------------------------------------------------------------------------------------------
// check if the url_page is an index and if not index it (crawlt_pages table)
$result41=0;
$tableinfo41 = mysql_query("SHOW INDEX FROM crawlt_pages");
$listcolumn41=array();
while ($table41= mysql_fetch_assoc($tableinfo41))
    {
    $listcolumn41[]=$table41['Column_name'];
    }
if(in_array('url_page',$listcolumn41))
    {
    $result41=1;
    }	
else
    {    
    //add the index    
    $sqlupdate41="CREATE INDEX `url_page` ON `crawlt_pages` (`url_page`)";
    $result41 = mysql_query($sqlupdate41, $connexion);
    } 
//----------------------------------------------------------------------------------------------------
// check if the id_page is an index and if not index it (crawlt_pages table)
if(in_array('id_page',$listcolumn41))
    {
    $result42=1;
    }	
else
    {    
    //add the index    
    $sqlupdate42="CREATE INDEX `id_page` ON `crawlt_pages` (`id_page`)";
    $result42 = mysql_query($sqlupdate42, $connexion);
    } 
//----------------------------------------------------------------------------------------------------   	
//check if the crawlt_pages_attack table exit and if not create it
$table_exist43 = 0;
$sql = "SHOW TABLES ";                                                
$tables = mysql_query($sql, $connexion) or die("MySQL query error"); 
while (list($tablename)=mysql_fetch_array($tables)) 
  {
  if($tablename == 'crawlt_pages_attack')
    {
    $table_exist43 = 1;
    }
  }
if($table_exist43 == 0)
  {
  //the table didn't exist, we can create it
  $result43 = mysql_query("CREATE TABLE crawlt_pages_attack (
              id_page int(10) unsigned NOT NULL auto_increment,
              url_page varchar(255) default NULL,
              KEY url_page (url_page),
              KEY id_page (id_page)
            )");
  }
else
  {
  $result43=1;
  }
//----------------------------------------------------------------------------------------------------   	
//check if the crawlt_referer table exit and if not create it
$table_exist44 = 0;
$sql = "SHOW TABLES ";                                                
$tables = mysql_query($sql, $connexion) or die("MySQL query error"); 
while (list($tablename)=mysql_fetch_array($tables)) 
  {
  if($tablename == 'crawlt_referer')
    {
    $table_exist44 = 1;
    }
  }
if($table_exist44 == 0)
  {
  //the table didn't exist, we can create it
  $result44 = mysql_query("CREATE TABLE crawlt_referer (
              id_referer mediumint(8) unsigned NOT NULL auto_increment,
              referer varchar(255) default NULL,
              KEY referer (referer),
              KEY id_referer (id_referer)
            )");
  }
else
  {
  $result44=1;
  }
//----------------------------------------------------------------------------------------------------   
//check if the crawlt_ip_data table exist and if yes drop it
$table_exist45 = 0;
$sql = "SHOW TABLES ";                                                
$tables = mysql_query($sql, $connexion) or die("MySQL query error"); 
while (list($tablename)=mysql_fetch_array($tables)) 
  {
  if($tablename == 'crawlt_ip_data')
    {
    $table_exist45 = 1;
    }
  }
if($table_exist45 == 1)
  {
  //the table  exist, we can drop it
  $result45 = mysql_query("DROP TABLE crawlt_ip_data");
  }
else
  {
  $result45=1;
  }
//----------------------------------------------------------------------------------------------------   
//check if the crawlt_ip_used table exist and if yes drop it
$table_exist46 = 0;
$sql = "SHOW TABLES ";                                                
$tables = mysql_query($sql, $connexion) or die("MySQL query error"); 
while (list($tablename)=mysql_fetch_array($tables)) 
  {
  if($tablename == 'crawlt_ip_used')
    {
    $table_exist46 = 1;
    }
  }
if($table_exist46 == 1)
  {
  //the table  exist, we can drop it
  $result46 = mysql_query("DROP TABLE crawlt_ip_used");
  }
else
  {
  $result46=1;
  }
//----------------------------------------------------------------------------------------------------   
//check if the crawlt_archive table exist and if yes drop it
$table_exist47 = 0;
$sql = "SHOW TABLES ";                                                
$tables = mysql_query($sql, $connexion) or die("MySQL query error"); 
while (list($tablename)=mysql_fetch_array($tables)) 
  {
  if($tablename == 'crawlt_archive')
    {
    $table_exist47 = 1;
    }
  }
if($table_exist47 == 1)
  {
  //the table  exist, we can drop it
  $result47 = mysql_query("DROP TABLE crawlt_archive");
  }
else
  {
  $result47=1;
  }
//----------------------------------------------------------------------------------------------------   
//normally the update is done....

//emptied the cache table
$sqlcache = "TRUNCATE TABLE crawlt_cache";
$requetecache = mysql_query($sqlcache, $connexion) or die("MySQL query error");

if( $result1==1 && $result2==1 && $result3==1 && $result4==1 && $result5==1 && $result6==1 && $result7==1 && $result8==1 && $result9==1 && $result12==1 && $result14==1 && $result15==1 && $result16==1 && $result17==1 && $result18==1 && $result19==1 && $result20==1 && $result21==1 && $result25==1 && $result26==1 && $result29==1 && $result31==1 && $result37==1 && $result38==1 && $result39==1 && $result40==1 && $result43==1 && $result44==1 && $result71==1 && $result72==1 && $result73==1 && $result74==1 && $result75==1 && $result76==1 && $result77==1 && $result90==1 && $result170==1 && $result171==1 && $result1700==1 && $result1710==1 && $result180==1 && $result181==1 && $result182==1 && $result1820==1)
    {      
    $sqlupdateversion="UPDATE crawlt_config SET version='324'";    
    $requeteupdateversion = mysql_query($sqlupdateversion, $connexion);    
    
    echo"<div class=\"content\">\n";
    $a=substr($versionid,0,1);
    $b=substr($versionid,1,1);
    $c=substr($versionid,2,1);
    echo"<h1>".$language['update_crawltrack_ok']."&nbsp;$a.$b.$c</h1>";
    
    if($urlok==0) //we need to add the site url in the table
        {
        echo"<form action=\"index.php\" method=\"POST\" >\n";
        echo "<input type=\"hidden\" name ='navig' value='10'>\n";
        echo"<table width=\"100%\" align=\"center\">\n";	
        echo"<tr>\n";
        echo"<td width=\"100%\" align=\"center\">\n";
        echo"<input name='ok' type='submit'  value=' ".$language['url_update']." ' size='20'>\n";
        echo"</td>\n";
        echo"</tr>\n";
        echo"</table>\n";
        echo"</form><br><br><br>\n";           
        }
    else
        {
         //continue    
        echo"<div class=\"form\">\n";
        echo"<form action=\"index.php\" method=\"POST\" >\n";
        echo "<input type=\"hidden\" name ='navig' value='0'>\n";
        echo"<table width=\"100%\" align=\"center\">\n";	
        echo"<tr>\n";
        echo"<td width=\"100%\" align=\"center\">\n";
        echo"<input name='ok' type='submit'  value=' OK ' size='20'>\n";
        echo"</td>\n";
        echo"</tr>\n";
        echo"</table>\n";
        echo"</form>\n";
        echo"</div><br><br><br>";            
        }        
    }
else
    {
    echo"<h1>".$language['update_crawltrack_no_ok']."</h1>";

$listerror=array('1','2','3','4','5','6','7','8','9','12','14','15','16','17','18','19','20','21','25','26','29','31','32','33','34','35','36','37','38','39','40','41','42','43','44','45','46','47','71','72','73','74','75','76','77','80','90','91','92','93','94','95','96','160','170','171','172','173','174','175','176','177','178','179','180','181','182','183','184','185','186','187','188','189','200','201','202','250','1700','1710','1790','1791','1820','1890','1891');

    foreach ($listerror as $err)
        {
	$a=${'result'.$err};
	if($a==0)
		{
		echo "result".$err."<br>";
		}
	}

    
        //continue

    echo"<div class=\"form\">\n";
    echo"<form action=\"index.php\" method=\"POST\" >\n";
    echo "<input type=\"hidden\" name ='navig' value='1'>\n";
    if (isset($crawltlang))
        {
        echo "<input type=\"hidden\" name ='lang' value='$crawltlang'>\n";
        }
    else
        {
        echo "<input type=\"hidden\" name ='lang' value='$lang'>\n";
        } 
    echo"<table width=\"100%\" align=\"center\">\n";	
    echo"<tr>\n";
    echo"<td width=\"100%\" align=\"center\">\n";
    echo"<input name='ok' type='submit'  value=' OK ' size='20'>\n";
    echo"</td>\n";
    echo"</tr>\n";
    echo"</table>\n";
    echo"</form>\n";
    echo"<br><br><br>";          
    }


?>
Return current item: CrawlTrack