Location: PHPKode > projects > PHP File Database > fdat/sources/logInOut.php
<?php
/*
###############################################################################
# logInOut.php                                                                #
###############################################################################
# FDat (File Database) Beta Version                                           #
# Open-Source Project by Jeffrey Gelens (hide@address.com)                  #
# =========================================================================== #
# Copyright (c) 2001 Jeffrey Gelens - All Rights Reserved                     #
#                                                                             #
# This program is free software; you can redistribute it and/or               #
# modify it under the terms of the GNU General Public License                 #
# as published by the Free Software Foundation; either version 2              #
# of the License, or (at your option) any later version.                      #
###############################################################################
*/
require ('../settings.php');
require ('cookieSetGet.php');

if (isset($username)) {
mysql_connect ($database['host'], $database['username'], $database['password']) or die ("Can't connect to database server");
mysql_select_db ($database['name']) or die ("Database doesn't exist, check settings.php");

$sql = "SELECT * FROM users WHERE username = '$username'";
$result = mysql_query($sql);

$password = mysql_result($result, '', "password") or die ("Username doesn't exist!<br><br>");

if ($password == md5($password_field)) {
  set_cookie("login", $cookiename, $username, $cookiepath);
  $time = time();
  $sql = "INSERT INTO logged_in VALUES ('$username', '$time')";
  $result = mysql_query($sql);

  require ('functions.php');
  $date = date("j ") . date("n ") . date("y");
  $time = date("H:i:s");
  $sql = "INSERT INTO userlog VALUES ('$username', '$date', '$time')";
  $result = mysql_query($sql);

  head();
  head2();
  echo "Logging out, please wait...";
  echo "<script language='JavaScript'>
        <!--
        setTimeout(\"window.location.href='$fdatdir/fdat.php'\", 2500);
        // -->
        </script>
  ";
  foot();
  }
else {
  echo "Username and password combination doesn't exist!";
  }
}
else {
$koekje = base64_decode($HTTP_COOKIE_VARS["FDat"]);

mysql_connect ($database['host'], $database['username'], $database['password']) or die ("Can't connect to database server");
mysql_select_db ($database['name']) or die ("Database doesn't exist, check settings.php");
$sql = "DELETE FROM logged_in WHERE username = '$koekje'";
$result = mysql_query($sql);

set_cookie("logout", $cookiename, "Guest", $cookiepath);

require ('functions.php');
head();
head2();
echo "Logging out, please wait...";
 echo "<script language='JavaScript'>
        <!--
        setTimeout(\"window.location.href='$fdatdir/fdat.php'\", 2500);
        // -->
        </script>
  ";
foot();
}
?>

Return current item: PHP File Database