<?php
$hidden_hash_var='your_password_here';
$logged_in=false;
//clear it out in case someone sets it in the url or something
unset($logged_in);
/*
create table user (
user_id int not null auto_increment primary key,
user_name text,
real_name text,
email text,
password text,
remote_addr text,
confirm_hash text,
is_confirmed int not null default 0
);
*/
function user_isloggedin() {
global $user_name,$id_hash,$hidden_hash_var,$logged_in;
//have we already run the hash checks?
//if so, return the pre-set var
if (isset($logged_in)) {
return $logged_in;
}
if ($user_name && $id_hash) {
$hash=md5($user_name.$hidden_hash_var);
if ($hash == $id_hash) {
$logged_in=true;
return true;
} else {
$logged_in=false;
return false;
}
} else {
$logged_in=false;
return false;
}
}
function user_login($user_name,$password) {
global $feedback;
if (!$user_name || !$password) {
$feedback .= ' error - missing user name or password ';
return false;
} else {
$user_name=strtolower($user_name);
$password=strtolower($password);
$sql="select * from user where user_name='$user_name' and password='". md5($password) ."'";
$result=db_query($sql);
if (!$
| 对此文章发表了评论 |
