<?php
class USER
{
function checklogin()
{
session_start();
If ( $_SESSION['user'] == null )
{
If ( $_COOKIE['user'] == null )
{
return 0;
}
Else
{
return $_COOKIE['user'];
}
}
Else
{
return $_SESSION['user'];
}
}
function makeuser($rawusername)
{
return ucfirst(strtolower($rawusername));
}
function makepass($rawpassword)
{
//Might add something here later...
return md5($rawpassword);
}
function dologin($udat)
{
session_start();
mysql_query("UPDATE `fg_users` SET `loggedin` = 1, `activity` = '".time()."' WHERE `uid` = '".$udat['uid']."'");
//We need to improve the security here...
$_SESSION['user'] = $udat['uid'];
setCookie('user', $udat['uid']);
}
function dologout($uid)
{
mysql_query("UPDATE `fg_users` SET `loggedin` = 0 WHERE `uid` = '".$uid."'");
$_SESSION['user'] = '';
session_destroy();
SetCookie('user', '', time()-3600);
}
function docreate($cr_u, $cr_p, $cr_e)
{
mysql_query("INSERT INTO `fg_users` ( `username`, `password`, `email` ) VALUES ('".$cr_u."', '".$cr_p."', '".$cr_e."')");
}
}
$user = new USER();
?>