Advertisement
Guest User

Untitled

a guest
Mar 21st, 2018
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.70 KB | None | 0 0
  1. <?php
  2. ob_start();
  3. require 'config.php';
  4.  
  5.  
  6. if(isset($_SESSION['rt1']) && empty ($_SESSION['rt1']) ==false){
  7.  
  8.  
  9. function ajustar_data($data){
  10. if(count(explode("-",$data)) > 1){
  11. return implode("-",array_reverse(explode("-",$data)));
  12. }elseif(count(explode("-",$data)) > 1){
  13. return implode("-",array_reverse(explode("-",$data)));
  14. }
  15. }
  16.  
  17.  
  18. $id=$_SESSION['rt1'];
  19. $sql = "SELECT * FROM user3 WHERE id ='$id'";
  20. $sql = $pdo->query($sql);
  21. if($sql->rowCount() > 0) {
  22. $user3 = $sql->fetch();
  23.  
  24. }
  25.  
  26.  
  27.  
  28. }else {
  29.  
  30. header("Location:login.php");
  31. }
  32.  
  33. $nome_user=$user3['nome'];
  34.  
  35. try {
  36. $dsn = "mysql:dbname=banco_sds;localhost";
  37. $dbuser = "root";
  38. $dbpass = "";
  39. $pdo->exec("set names utf8");
  40. } catch(PDOException $e) {
  41. echo "ERRO: ".$e->getMessage();
  42. exit;
  43. }
  44.  
  45. $ip = $_SERVER['REMOTE_ADDR'];
  46. $hora = date('H:i:s');
  47. $sql = $pdo->prepare("INSERT INTO acessos (ip, hora, nome_user) VALUES (:ip, :hora, :nome_user)");
  48. $sql->bindValue(":ip", $ip);
  49. $sql->bindValue(":hora", $hora);
  50. $sql->bindValue(":nome_user", $nome_user);
  51. $sql->execute();
  52.  
  53. $sql = $pdo->prepare("DELETE FROM acessos WHERE hora < :hora");
  54. $sql->bindValue(":hora", date('H:i:s', strtotime("-5 minutes")));
  55. $sql->execute();
  56.  
  57. $sql = "SELECT * FROM acessos WHERE hora > :hora GROUP BY ip";
  58. $sql = $pdo->prepare($sql);
  59. $sql->bindValue(":hora", date('H:i:s', strtotime("-5 minutes")));
  60. $sql->execute();
  61. $contagem = $sql->rowCount();
  62. ?>
  63. <br><br><br><br>
  64. <div class="container" >
  65. <TABLE class="table table-bordered table-condensed table-hover table-striped" >
  66. <tr>
  67.  
  68.  
  69. <th> <?php echo " ".$contagem .' USUÁRIO(OS) ONLINE '.$nome_user; ?></th>
  70.  
  71.  
  72. </tr>
  73.  
  74. </TABLE>
  75. </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement