Location: PHPKode > projects > Nail Streaming Server > nailss_v12/includes/login.php
<?php
if(!isset($_COOKIE["nailsstheme"]))
{
	setcookie("nailsstheme", "default", time()+3600*24*30);
}

if(!isset($password))
{
	$_SESSION["validated"] = true;
}

if(isset($_POST["user"]))
{
	$user = $_POST["user"];
	$pass = md5($_POST["pass"]);
}
else
{
	$user = $_COOKIE["user"];
	$pass = $_COOKIE["pass"];
}

//are we using a backend?  are we already validated?
if($_SESSION["validated"] != true)
{
	if($user == "admin")
	{
		if($pass != $password)
		{
			include_once( $baseDir."/layout/header.php" );
			loginTable();
		}
		else
		{
			setcookie("pass", $pass, time()+3600*24);
			setcookie("user", $user, time()+3600*24);
			$_SESSION["validated"] = true;
		}
	}
	elseif($backend == "mysql")
	{
		connect_to($dbhost, $dbuser, $dbpass, $dbname);
		
		$sql1 = "SELECT * FROM `users` WHERE `user` = '".mysql_real_escape_string($user)."' AND `pass` = '$pass'";
		$selectResult1 = mysql_query($sql1);
		
		if(mysql_num_rows($selectResult1) == 1)
		{
			setcookie("pass", $pass, time()+3600*24);
			setcookie("user", $user, time()+3600*24);
			$_SESSION["validated"] = true;
		}
		else
		{
			include_once( $baseDir."/layout/header.php" );
			loginTable();
		}
	}
	else
	{
		include_once( $baseDir."/layout/header.php" );
		loginTable();	
	}
}

function loginTable()
{
	echo("
		<table cellpadding=\"0\" cellspacing=\"5\" width=\"100%\" class=\"tableborder\">
		<tr><td>
		<table cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">
		<tr class=\"tableheader\"><td colspan=\"7\"><center><h3>Login</h3></center></td></tr>
		<tr><td>
		<form action=\"index.php\" method=\"post\">
		<center>
		<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\">
		<tr><td>Username:</td><td><input name=\"user\"></td></tr>
		<tr><td>Password:</td><td><input name=\"pass\" type=\"password\"></td></tr>
		</table>
		<input type=\"Button\" value=\"Check\" onclick=\"javascript:this.value='Please Wait';this.disabled=1;document.forms[0].submit()\">
		</form>
		</td></tr>
		</table>
		</td></tr>
		</table>
		");
	die();
}

?>
Return current item: Nail Streaming Server