Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- ob_start();
- require 'config.php';
- if(isset($_SESSION['rt1']) && empty ($_SESSION['rt1']) ==false){
- function ajustar_data($data){
- if(count(explode("-",$data)) > 1){
- return implode("-",array_reverse(explode("-",$data)));
- }elseif(count(explode("-",$data)) > 1){
- return implode("-",array_reverse(explode("-",$data)));
- }
- }
- $id=$_SESSION['rt1'];
- $sql = "SELECT * FROM user3 WHERE id ='$id'";
- $sql = $pdo->query($sql);
- if($sql->rowCount() > 0) {
- $user3 = $sql->fetch();
- }
- }else {
- header("Location:login.php");
- }
- $nome_user=$user3['nome'];
- try {
- $dsn = "mysql:dbname=banco_sds;localhost";
- $dbuser = "root";
- $dbpass = "";
- $pdo->exec("set names utf8");
- } catch(PDOException $e) {
- echo "ERRO: ".$e->getMessage();
- exit;
- }
- $ip = $_SERVER['REMOTE_ADDR'];
- $hora = date('H:i:s');
- $sql = $pdo->prepare("INSERT INTO acessos (ip, hora, nome_user) VALUES (:ip, :hora, :nome_user)");
- $sql->bindValue(":ip", $ip);
- $sql->bindValue(":hora", $hora);
- $sql->bindValue(":nome_user", $nome_user);
- $sql->execute();
- $sql = $pdo->prepare("DELETE FROM acessos WHERE hora < :hora");
- $sql->bindValue(":hora", date('H:i:s', strtotime("-5 minutes")));
- $sql->execute();
- $sql = "SELECT * FROM acessos WHERE hora > :hora GROUP BY ip";
- $sql = $pdo->prepare($sql);
- $sql->bindValue(":hora", date('H:i:s', strtotime("-5 minutes")));
- $sql->execute();
- $contagem = $sql->rowCount();
- ?>
- <br><br><br><br>
- <div class="container" >
- <TABLE class="table table-bordered table-condensed table-hover table-striped" >
- <tr>
- <th> <?php echo " ".$contagem .' USUÁRIO(OS) ONLINE '.$nome_user; ?></th>
- </tr>
- </TABLE>
- </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement