Location: PHPKode > projects > CrawlTrack > crawltrack/include/adminusersite.php
<?php
//----------------------------------------------------------------------
//  CrawlTrack 3.1.0
//----------------------------------------------------------------------
// Crawler Tracker for website
//----------------------------------------------------------------------
// Author: Jean-Denis Brun
//----------------------------------------------------------------------
// Website: www.crawltrack.net
//----------------------------------------------------------------------
// That script is distributed under GNU GPL license
//----------------------------------------------------------------------
// file: adminusersite.php
//----------------------------------------------------------------------
//  Last update: 18/09/2008
//----------------------------------------------------------------------
if (!defined('IN_CRAWLT_ADMIN'))
{
	echo"<h1>Hacking attempt !!!!</h1>";
	exit();
}
//initialize array
$listsite=array();
$listidsite=array();

//valid form

if($validlogin==1)
	{
    if($login=='' OR $password2=='' OR $password3=='' OR $password2 != $password3)
		{        
		echo"<br><br><p>".$language['login_no_ok']."</p>";


		echo"<div class=\"form\">\n";
		echo"<form action=\"index.php\" method=\"POST\" >\n";
		echo "<input type=\"hidden\" name ='validform' value='7'>\n";
		echo "<input type=\"hidden\" name ='navig' value='6'>\n";
		echo "<input type=\"hidden\" name ='validlogin' value='0'>\n";
		echo "<input type=\"hidden\" name ='logintype' value='$logintype'>\n";					
		echo "<input type=\"hidden\" name ='login' value='$login'>\n";
		echo "<input type=\"hidden\" name ='password2' value='$password2'>\n";
		echo "<input type=\"hidden\" name ='password3' value='$password3'>\n";
		echo "<input type=\"hidden\" name ='site' value='$site'>\n";		
		echo"<input name='ok' type='submit'  value=' ".$language['back_to_form']." ' size='20'>\n";
		echo"</form>\n";
		echo"</div>\n";
		}
	else
		{
		//database connection
        $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 login already exist
			
		$sqlexist = "SELECT * FROM crawlt_login
		WHERE crawlt_user='".sql_quote($login)."'";

		$requeteexist = db_query($sqlexist, $connexion);
		
		$nbrresult=mysql_num_rows($requeteexist);
		
		if($nbrresult>=1)
			{
			//login already exist		
			echo"<br><br><h1>".$language['exist_login']."</h1>";


			echo"<div class=\"form\">\n";
			echo"<form action=\"index.php\" method=\"POST\" >\n";
			echo "<input type=\"hidden\" name ='validform' value='7'>\n";
			echo "<input type=\"hidden\" name ='navig' value='6'>\n";
			echo "<input type=\"hidden\" name ='validlogin' value='0'>\n";
			echo "<input type=\"hidden\" name ='logintype' value='$logintype'>\n";					
			echo "<input type=\"hidden\" name ='login' value='$login'>\n";
			echo "<input type=\"hidden\" name ='password2' value='$password2'>\n";
			echo "<input type=\"hidden\" name ='password3' value='$password3'>\n";
			echo "<input type=\"hidden\" name ='site' value='$site'>\n";		
			echo"<input name='ok' type='submit'  value=' ".$language['back_to_form']." ' size='20'>\n";
			echo"</form>\n";
			echo"</div>\n";
			}
		else
			{		
				
			//add the login in the database
		
			//password treatment
			$pass=md5($password2);

			$admin=0;
			$website=$site;

		
			$sqllogin="INSERT INTO crawlt_login (crawlt_user,crawlt_password,admin,site) VALUES ('".sql_quote($login)."','".sql_quote($pass)."','".sql_quote($admin)."','".sql_quote($website)."')";
			$requetelogin = mysql_query($sqllogin, $connexion) or die("MySQL query error");

			//check is requete is successfull

			if($requetelogin==1)
				{
				echo"<br><br><h2>".$language['user_site_creation']."</h2>\n";

				echo"<p>".$language['login_ok']."</p>\n";	
			
				echo"<div class=\"form\">\n";
				echo"<form action=\"index.php\" method=\"POST\" >\n";
				echo "<input type=\"hidden\" name ='navig' value='6'>\n";			
				echo"<input name='ok' type='submit'  value='OK' size='20'>\n";
				echo"</form>\n";
				echo"</div>\n";								
			
				}
			else
				{
				echo"<br><br><h2>".$language['user_site_creation']."</h2>\n";			
				echo"<p>".$language['login_no_ok2']."</p>";

			
				echo"<div class=\"form\">\n";
				echo"<form action=\"index.php\" method=\"POST\" >\n";
				echo "<input type=\"hidden\" name ='validform' value='7'>\n";
				echo "<input type=\"hidden\" name ='navig' value='6'>\n";
				echo "<input type=\"hidden\" name ='validlogin' value='1'>\n";
				echo "<input type=\"hidden\" name ='site' value='$site'>\n";			
				echo "<input type=\"hidden\" name ='logintype' value='$logintype'>\n";		
				echo "<input type=\"hidden\" name ='login' value='$login'>\n";
				echo "<input type=\"hidden\" name ='password2' value='$password2'>\n";
				echo "<input type=\"hidden\" name ='password3' value='$password3'>\n";
				echo"<input name='ok' type='submit'  value=' ".$language['retry']." ' size='20'>\n";
				echo"</form>\n";
				echo"</div>\n";
				}
			}
		}
		
	}

//form

else
	{
		echo"<br><br><h2>".$language['user_site_creation']."</h2>\n";
		echo"<p>".$language['user_site_setup']."</p>\n";
		echo"<p>".$language['login_user_site_what']."</p>\n";
		
		
		//database connection
        $connexion = mysql_connect($crawlthost,$crawltuser,$crawltpassword) or die("MySQL connection to database problem");
        $selection = mysql_select_db($crawltdb) or die("MySQL database selection problem");
				
		//mysql requete
	
		$sqlsite = "SELECT * FROM crawlt_site";

	
		$requetesite = db_query($sqlsite, $connexion);
	
		$nbrresult=mysql_num_rows($requetesite);
	
		while ($ligne = mysql_fetch_object($requetesite))                                                                              
			{
			$sitename=$ligne->name; 
			$siteid=$ligne->id_site;
			$listsite[]=$sitename;
			$listidsite[]=$siteid;
			}

		//preparation of site list display
		$nbrsite=sizeof($listsite);
		$nbrsiteaf=0;
		

		
	echo"</div>\n";

	//data collect form

	echo"<div class=\"form\">\n";
	echo"<form action=\"index.php\" method=\"POST\" >\n";
	echo"<table class=\"centrer\">\n";
	echo"<tr><td>\n";
	echo"".$language['site_name']."";
	echo"<select  size=\"1\" name=\"site\"  style=\" font-size:14px; font-weight:bold; color: #003399;
	font-family: Verdana,Geneva, Arial, Helvetica, Sans-Serif;\">\n";
	do
		{
		if($listidsite[$nbrsiteaf]==$site)
			{
			echo"<option value=\"$listidsite[$nbrsiteaf]\" selected style=\" font-size:14px; font-weight:bold; color: #003399;
			font-family: Verdana,Geneva, Arial, Helvetica, Sans-Serif;\">".$listsite[$nbrsiteaf]."</option>\n";
			}
		else
			{
			echo"<option value=\"$listidsite[$nbrsiteaf]\" style=\" font-size:14px; font-weight:bold; color: #003399;
			font-family: Verdana,Geneva, Arial, Helvetica, Sans-Serif;\">".$listsite[$nbrsiteaf]."</option>\n";
			}		
			$nbrsiteaf=$nbrsiteaf+1;
		}
	
	while($nbrsiteaf<$nbrsite);

	echo"</select>\n";		
		
	echo "<input type=\"hidden\" name ='validform' value=\"7\">";
	echo "<input type=\"hidden\" name ='navig' value='6'>\n";
	echo "<input type=\"hidden\" name ='validlogin' value='1'>\n";			
	echo "<input type=\"hidden\" name ='logintype' value='$logintype'>\n";	
	echo"<td></tr>\n";
	echo"<tr>\n";
	echo"<td>".$language['login']."</td>\n";
	echo"<td><input name='login'  value='$login' type='text' maxlength='20' size='50'/></td>\n";
	echo"</tr>\n";
	echo"<tr>\n";
	echo"<td>".$language['password']."</td>\n";
	echo"<td><input name='password2' value='$password2' type='password' size='50'/></td>\n";
	echo"</tr>\n";
	echo"<tr>\n";
	echo"<td colspan=\"2\">\n";
	echo"".	$language['valid_password']."\n";
	echo"</td>\n";
	echo"</tr>\n";
	echo"<tr>\n";
	echo"<td>".$language['password']."</td>\n";
	echo"<td><input name='password3' value='$password3' type='password' size='50'/></td>\n";
	echo"</tr>\n";	
	echo"<tr>\n";
	echo"<td colspan=\"2\">\n";
	echo"<br>\n";
	echo"<input name='ok' type='submit'  value=' OK ' size='20'>\n";
	echo"</td>\n";
	echo"</tr>\n";
	echo"</table>\n";
	echo"</form>\n";
	}

?>
Return current item: CrawlTrack