View file statistics.php

File size: 7.49Kb
<?php
include "connection/connection.php";
if (!isset($_SESSION['id'])) {
    // Redirigir al usuario a la página de inicio de sesión
    header("Location: login.php");
    exit(); // Detener la ejecución del script
}
$correo = $_SESSION['correo_electronico'];

if (!empty($correo)) {
    // Consulta para obtener los enlaces del usuario
    $sql = "SELECT short_id, original_url, created_at FROM urls WHERE user_email = '$correo'";
    $result = $conn->query($sql);
} else {
    echo "El correo no está definido.";
    exit();
}
?>
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="utf-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  <link rel="apple-touch-icon" sizes="76x76" href="../assets/img/apple-icon.png">
  <link rel="icon" type="image/png" href="../assets/img/favicon.png">
  <title>
    Statistics - Link Shortener
  </title>
    <link href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" rel="stylesheet">
  <!--     Fonts and icons     -->
  <link href="https://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700" rel="stylesheet" />
  <!-- Nucleo Icons -->
  <link href="https://demos.creative-tim.com/argon-dashboard-pro/assets/css/nucleo-icons.css" rel="stylesheet" />
  <link href="https://demos.creative-tim.com/argon-dashboard-pro/assets/css/nucleo-svg.css" rel="stylesheet" />
  <!-- Font Awesome Icons -->
  <script src="https://kit.fontawesome.com/42d5adcbca.js" crossorigin="anonymous"></script>
  <!-- CSS Files -->
  <link id="pagestyle" href="css/assets/css/argon-dashboard.css?v=2.1.0" rel="stylesheet" />
</head>

<body class="g-sidenav-show   bg-gray-100">
<?php include "inc/menu.php" ?>
  <main class="main-content position-relative border-radius-lg ">
    <!-- Navbar -->
    <nav class="navbar navbar-main navbar-expand-lg px-0 mx-4 shadow-none border-radius-xl " id="navbarBlur" data-scroll="false">
      <div class="container-fluid py-1 px-3">
        <nav aria-label="breadcrumb">
          <ol class="breadcrumb bg-transparent mb-0 pb-0 pt-1 px-0 me-sm-6 me-5">
            <li class="breadcrumb-item text-sm"><a class="opacity-5 text-white" href="javascript:;">Pages</a></li>
            <li class="breadcrumb-item text-sm text-white active" aria-current="page">statistics</li>
          </ol>
          <h6 class="font-weight-bolder text-white mb-0">statistics</h6>
                      </nav>
   
                      </div>
                    </div>
                  </a>
                </li>
              </ul>
            </li>
          </ul>
        </div>
      </div>
    </nav>
    <!-- End Navbar -->
   <div class="container-fluid py-4">
    <div class="row">
        <div class="col-12">
            <div class="card mb-4">
                <div class="card-header pb-0">
                    <h6>Url Links</h6>
                </div>
                <div class="card-body px-0 pt-0 pb-2">
                    <div class="table-responsive p-0">
                        <table class="table align-items-center mb-0">
                            <thead>
                                <tr>
                                    <th class="text-uppercase text-secondary text-xxs font-weight-bolder opacity-7">Url</th>
                                    <th class="text-uppercase text-secondary text-xxs font-weight-bolder opacity-7 ps-2">Url Short</th>
                                    <th class="text-center text-uppercase text-secondary text-xxs font-weight-bolder opacity-7">Status</th>
                                    <th class="text-center text-uppercase text-secondary text-xxs font-weight-bolder opacity-7">Create</th>
                                    <th class="text-secondary opacity-7"></th>
                                </tr>
                            </thead>
                            <tbody>
                                <?php if ($result && $result->num_rows > 0): ?>
                                    <?php while ($row = $result->fetch_assoc()): ?>
                                        <tr>
                                          <td>
    <div class="d-flex px-2 py-1">
        <div class="d-flex flex-column justify-content-center">
            <h6 class="mb-0 text-sm">
                <a href="<?= $row['original_url'] ?>" target="_blank" title="<?= $row['original_url'] ?>">
                    <?= strlen($row['original_url']) > 20 ? substr($row['original_url'], 0, 20) . '...' : $row['original_url'] ?>
                </a>
            </h6>
        </div>
    </div>
</td>

                                            <td>
                                                <p class="text-xs font-weight-bold mb-0">
                                                    <a href="redirect.php?id=<?= $row['short_id'] ?>" target="_blank"><?= $row['short_id'] ?></a>
                                                </p>
                                            </td>
                                            <td class="align-middle text-center text-sm">
                                                <span class="badge badge-sm bg-gradient-success">Active</span>
                                            </td>
                                            <td class="align-middle text-center">
                                                <span class="text-secondary text-xs font-weight-bold"><?= date("d/m/Y", strtotime($row['created_at'])) ?></span>
                                            </td>
                                            <td class="align-middle">
                                                <a href="statisticsurl.php?id=<?= $row['short_id'] ?>" 
                                                   class="text-secondary font-weight-bold text-xs" 
                                                   data-toggle="tooltip" 
                                                   data-original-title="View statistics">
                                                    Statistics
                                                </a>
                                            </td>
                                        </tr>
                                    <?php endwhile; ?>
                                <?php else: ?>
                                    <tr>
                                        <td colspan="5" class="text-center">No se encontraron enlaces.</td>
                                    </tr>
                                <?php endif; ?>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
    
     -->
  <script src="css/assets/js/core/popper.min.js"></script>
  <script src="css/assets/js/core/bootstrap.min.js"></script>
  <script src="css/assets/js/plugins/perfect-scrollbar.min.js"></script>
  <script src="css/assets/js/plugins/smooth-scrollbar.min.js"></script>
  <script>
    var win = navigator.platform.indexOf('Win') > -1;
    if (win && document.querySelector('#sidenav-scrollbar')) {
      var options = {
        damping: '0.5'
      }
      Scrollbar.init(document.querySelector('#sidenav-scrollbar'), options);
    }
  </script>
  <!-- Github buttons -->
  <script async defer src="https://buttons.github.io/buttons.js"></script>
  <!-- Control Center for Soft Dashboard: parallax effects, scripts for the example pages etc -->
  <script src="../assets/js/argon-dashboard.min.js?v=2.1.0"></script>
</body>

</html>