dongrouyuan5685 2011-07-07 07:30
浏览 18

链接杀死连接用户PHP的连接

I have a list of 'Active Users' on my page. Is it possible to create a link to immediately disconnect that user temporarily, and then perhaps regrant them access? I found it online somewhere :D

<?php
if(isset($_POST['username']) && isset($_POST['password'])){
    $_SESSION['username']=$_POST['username'];
}

?>
             <h1>Currently Active Users</h1><br/>
             <?php 
             $d=date('c',time()-1800);
             $q=mysql_query("select username from navigation where time>'$d'");
             if(mysql_affected_rows()>0){
                 print "<ul>";
                 while($users=mysql_fetch_array($q)){
                    print "<li>{$users[0]}</li>";
                 }
                 print "</ul>";
             }
             ?>
  • 写回答

2条回答 默认 最新

  • doutao1282 2011-07-07 08:08
    关注

    create DB named kill with UID (user_id)

    <?php
    include("db.php");
    $bans = mysql_query("SELECT * FROM kill WHERE uid = ".$user_id." LIMIT 1");
    $ban = mysql_fetch_assoc($bans);
    if ($ban)
    {
        mysql_query("DELETE FROM kill WHERE id = $ban[id]");
        die("Banned");
    }
    
    评论

报告相同问题?