Location: PHPKode > projects > MyNews > mynews/auth.php
<?php
// ----------------------------------------------------------------------
// MyNews
// Copyright (C) 2004 by Frank Mancuso Aka crash4o4
// https://sourceforge.net/projects/mynews/
// http://frankmancuso.ca
// ----------------------------------------------------------------------
// LICENSE
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License (GPL)
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// To read the license please visit http://www.gnu.org/copyleft/gpl.html
// ----------------------------------------------------------------------
// Original Author of file: Frank Mancuso aka crash4o4
// Purpose of file:
// ----------------------------------------------------------------------


include("mysql.php");
include("config.php");

$auth = false;

if (isset($_COOKIE["authacc"])) 
{
	$fourvar = $_COOKIE["authacc"];
	list($username,$passwd,$ip_address,$session_key,$group_id) = explode(":",$fourvar);

	$db = new db;
	$db->info['sql_host']		=	$conf['sql_host'];
	$db->info['sql_user']		=	$conf['sql_user'];
	$db->info['sql_pass']		=	$conf['sql_pass'];
	$db->info['sql_db']		=	$conf['sql_db'];
	$db->connect();
	$sql = "SELECT * FROM sessions WHERE username='$username'
		&& password='$passwd' && ip_address='$ip_address'
		&& session_key='$session_key' && group_id='$group_id' ";
	$check_query = $db->query($sql);
	$row = mysql_numrows($check_query);

	if ( $row != 0 )
	{
		$auth = true;
	}
	// Cookie cheated
	if ( ! $auth )
	{
		echo "Invalid Cookie, please <a href=\"login.php\">login</a>";
		exit();
	}
}else{

		// Stuff to do if user isn't login
		echo "<p>Please <a href=\"login.php\">login</a></p>";
		exit();

}
?>
Return current item: MyNews