| 以下为引用的内容:
源代码网整理以下 <?php
源代码网整理以下 $hidden_hash_var="your_secret_password_here";
源代码网整理以下 $LOGGED_IN=false; unset($LOGGED_IN);
源代码网整理以下 function user_isloggedin() { global $user_name,$id_hash,$hidden_hash_var,$LOGGED_IN; file://已经进行无序码的检测了吗
源代码网整理以下 file://如果是的话,返回该变量
源代码网整理以下 if ( isset($LOGGED_IN) ) {
源代码网整理以下 return $LOGGED_IN;
源代码网整理以下 }
源代码网整理以下 file://are both cookies present?
源代码网整理以下 if ($user_name && $id_hash) {
源代码网整理以下 /* 由cookies中得来的用户名和系统超级密码产生一个认证用的无序码如果该无序码与cookie中的无序码一样,则cookies中的变量是可信的,用户已经登录
源代码网整理以下 */
源代码网整理以下 $hash=md5($user_name.$hidden_hash_var);
源代码网整理以下 if ($hash == $id_hash) {
源代码网整理以下 file://无序码符合,设置一个全局变量,这样我们在再次调用该函数的时候,
源代码网整理以下 file://就无需再次进行md5()运算
源代码网整理以下 $LOGGED_IN=true;
源代码网整理以下 return true;
源代码网整理以下 } else {
源代码网整理以下 file://两个无序码不符合,没有登录
源代码网整理以下 $LOGGED_IN=false;
源代码网整理以下 return false;
源代码网整理以下 }
源代码网整理以下 } else {
源代码网整理以下 $LOGGED_IN=false;
源代码网整理以下 return false;
源代码网整理以下 }
源代码网整理以下 }
源代码网整理以下 function user_set_tokens($user_name_in) {
源代码网整理以下 /*
源代码网整理以下 一旦用户名和密码通过验证,就调用这个函数
源代码网整理以下 */
源代码网整理以下 global $hidden_hash_var,$user_name,$id_hash;
源代码网整理以下 if (!$user_name_in) {
源代码网整理以下 $feedback .= " ERROR - User Name Missing When Setting Tokens ";
源代码网整理以下 return false;
源代码网整理以下 }
源代码网整理以下 $user_name=strtolower($user_name_in);
源代码网整理以下 file://使用用户名和超级密码创建一个无序码,作判断是否已经登录用
源代码网整理以下 $id_hash= md5($user_name.$hidden_hash_var);
源代码网整理以下 file://设置cookies的有效期为一个月,可设置为任何的值
源代码网整理以下 setcookie("user_name",$user_name,(time()+2592000),"/","",0);
源代码网整理以下 setcookie("id_hash",$id_hash,(time()+2592000),"/","",0);
源代码网整理以下 }
源代码网整理以下 ?>
|