//是否登陆 function is_login($uid=0,$uname='',$urnd=''){ global $empire,$public_r,$dbtbpre; $userid=$uid?$uid:getcvar('loginuserid',1); $username=$uname?$uname:getcvar('loginusername',1); $rnd=$urnd?$urnd:getcvar('loginrnd',1); $userid=(int)$userid; $username=RepPostVar($username); $rnd=RepPostVar($rnd); if(!$userid||!$username||!$rnd) { printerror("NotLogin","index.php"); } $groupid=(int)getcvar('loginlevel',1); $adminstyle=(int)getcvar('loginadminstyleid',1); if(!strstr($public_r['adminstyle'],','.$adminstyle.',')) { $adminstyle=$public_r['defadminstyle']?$public_r['defadminstyle']:1; } $truelogintime=(int)getcvar('truelogintime',1); $cdbdata=0; //COOKIE验证 $cdbdata=getcvar('ecmsdodbdata',1)?1:0; DoChECookieRnd($userid,$username,$rnd,'',$cdbdata,$groupid,$adminstyle,$truelogintime); //db $adminr=$empire->fetch1("select last_password_update_time,userid,groupid,classid,userprikey,uprnd from {$dbtbpre}enewsuser where userid='$userid' and username='".$username."' and rnd='".$rnd."' and checked=0 limit 1"); // jiuhecai last_password_update_time if(!$adminr['userid']) { printerror("SingleUser","index.php"); } DoECheckAndAuthRnd($userid,$username,$rnd,$adminr['userprikey'],$cdbdata,$groupid,$adminstyle,$truelogintime); //登陆超时 $logintime=getcvar('logintime',1); if($logintime) { if(time()-$logintime>$public_r['exittime']*60) { esetcookie("loginrnd","",0,1); printerror("LoginTime","index.php"); } esetcookie("logintime",time(),0,1); } if(getcvar('eloginlic',1)<>"empirecmslic") { printerror("NotLogin","index.php"); } // edit by jiuhecai // 假设你在数据库中为管理员表添加了一个字段,用来记录密码的最后更新时间 $last_password_update_time = $adminr['last_password_update_time']; $current_time = time(); $valid_period = 30 * 24 * 60 * 60; // 30天的有效期,单位是秒 if ($current_time - $last_password_update_time > $valid_period) { // 密码已过期,提示用户修改密码 echo '您的密码已过期,请立即修改密码。'; // 这里可以添加重定向到修改密码页面的代码 } else { // 密码未过期,继续登录流程 } $ur[userid]=$userid; $ur[username]=$username; $ur[rnd]=$rnd; $ur[groupid]=$adminr[groupid]; $ur[adminstyleid]=(int)$adminstyle; $ur[classid]=$adminr[classid]; return $ur; }
|