• <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>
  • 簡化的實現方法(限制為同一會話頁面)

    發表于:2007-07-14來源:作者:點擊數: 標簽:
    ?php session_start(); $login=false; $lifetime=60;//會話時間 $loginFILE=loginmsg.txt; if(file_exists($loginFILE) (time()-filemtime($loginFILE))$lifetime){//在會話時間范圍內 $info=file($loginFILE); $username=trim($info[0]);//已在線的登陸用戶
    <?php
    session_start();
    $login=false;

    $lifetime=60;//會話時間
    $loginFILE="loginmsg.txt";

    if(file_exists($loginFILE)&& (time()-filemtime($loginFILE))<$lifetime){//在會話時間范圍內
            $info=file($loginFILE);
                $username=trim($info[0]);    //已在線的登陸用戶名
                $password=trim($info[1]);    //已在線密碼(可以不保存)
                $ip     =trim($info[2]);    //已在線IP
                $sid     =trim($info[3]);    //已在線PORT
                if(strcmp($_SESSION[LoginUser],$username)==0){
                    if(strcmp($_SESSION['LoginPw'],$password)==0){
                        $login=true;
                        echo "<h3>可以確定你是獨苗苗~:)</h3>";
                        $cf=fopen($loginFILE,"a+");
                        fputs($cf,"\r\na");
                        fclose($cf);//這里增加文件記錄僅僅是為了修改文件的最后修改時間
                        echo "<meta http-equiv=refresh content=\"10;url=t.php\">";//消除刷新頁面瀏覽器提示
                    }else{
                        echo "密碼錯誤";
                    }
                }else{
                    echo "已經有用戶($username)登陸系統,但那人不是你:),你還是等會再登陸吧...暫時不允許登陸";
                    print_r($_SESSION);
                }
    }else{//用戶超時,或根本沒登陸系統、或為登陸系統進行必要的變量轉換
                if(isset($_POST[LoginUser])){
                    $_SESSION[LoginUser]=$_POST[LoginUser];    //轉變形式
                    $_SESSION[LoginPw]=$_POST[LoginPw];
                    $fp=fopen($loginFILE,"w");    //清除所有舊的登陸信息
                    $msg=$_POST['LoginUser']."\r\n".$_POST['LoginPw']."\r\n";
                    fwrite($fp,$msg);
                    fclose($fp);
                    $login=flase;    //禁止登陸頁面顯示
                    echo "<meta http-equiv=refresh content=\"0;url=index.php\">";//刷新頁面使用轉變后變量進行驗證
                }else{
                    $outtime=time()-filemtime($loginFILE)-60;
                    echo "登陸不存在或您已經超時(".$outtime."秒)...";
                }
    }
    if(!$login){
    ?>
        <Form action="<?=$_SERVER[PHP_SELF]?>" method="post" name="Loginform">
            <table cellpadding=0 border=0>
            <tr><td>
            用戶名:<td><input type="text" name="LoginUser"></span><br>
            <tr><td>密碼:<td><input type="password" name="LoginPw"></span><br>
            <tr><td> <td><input type="button" value=" Login " onclick="if(this.form.LoginUser.length*this.form.LoginPw.length!=0){this.form.submit();}else{return false;}">
            </table>
        </form>
    <?
    }
    ?>


    t.php
    =====
    <meta http-equiv=refresh content="0;url=<?=$_SERVER[HTTP_REFERER]?>">

    原文轉自:http://www.kjueaiud.com

    老湿亚洲永久精品ww47香蕉图片_日韩欧美中文字幕北美法律_国产AV永久无码天堂影院_久久婷婷综合色丁香五月

  • <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>