This commit is contained in:
2024-09-03 02:42:27 +05:30
parent bde2d88ddf
commit a021bfa479
16 changed files with 518 additions and 155 deletions

View File

@@ -1,77 +1,6 @@
<?php
// Enable error reporting
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
// Include the configuration file
include "core/config.php";
// Start session management
session_start();
// Initialize dotenv and load environment variables
$dotenv = Dotenv\Dotenv::createImmutable(__DIR__);
$dotenv->load();
// Retrieve environment variables
$domain = $_ENV['DOMAIN'];
$host = $_ENV['DB_HOST'];
$user = $_ENV['DB_USER'];
$pass = $_ENV['DB_PASS'];
$db = $_ENV['DB_NAME'];
// Establish database connection
$conn = mysqli_connect($host, $user, $pass, $db);
if (!$conn) {
die("Database connection error: " . mysqli_connect_error());
}
// Set a cookie to track user visits or preferences
$cookie_name = "user_visited";
$cookie_value = "true";
$cookie_expire_time = time() + (86400 * 30); // Cookie expires in 30 days
setcookie($cookie_name, $cookie_value, $cookie_expire_time, "/"); // The "/" makes the cookie available across the entire website
// Check if the cookie exists
if (isset($_COOKIE[$cookie_name])) {
// Cookie exists, you can execute specific logic like tracking the visit
} else {
// Cookie does not exist, handle the first-time visit
}
// Set session data for the user
$_SESSION['user'] = "unique_user_id"; // Store unique user ID in session
// Retrieve and use session data
if (isset($_SESSION['user'])) {
$user_id = $_SESSION['user'];
// Do something with $user_id, like loading user-specific data
}
// Initialize the shortened URL variable
$new_url = "";
// Check if there's a GET request and process the shortened URL
if (isset($_GET)) {
foreach ($_GET as $key => $val) {
$u = mysqli_real_escape_string($conn, $key);
$new_url = str_replace('/', '', $u);
}
// Query the database for the full URL associated with the shortened URL
$sql = mysqli_query($conn, "SELECT full_url FROM url WHERE shorten_url = '{$new_url}'");
if (mysqli_num_rows($sql) > 0) {
// Increment the click count for the shortened URL
$sql2 = mysqli_query($conn, "UPDATE url SET clicks = clicks + 1 WHERE shorten_url = '{$new_url}'");
if ($sql2) {
// Fetch the full URL and redirect to it
$full_url = mysqli_fetch_assoc($sql);
header("Location:" . $full_url['full_url']);
exit(); // Stop further script execution after redirection
}
}
}
require 'core/process.php';
require 'core/get_statistics.php'; // Include the statistics file
?>
<!DOCTYPE html>
@@ -80,7 +9,7 @@ if (isset($_GET)) {
<meta charset="UTF-8">
<title>Xeorl - Link Shortener and Management Tool</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Xeorl is an All-in-One, Fully Free to Use advanced Link Shortener and Management Tool | Equipped with multi-layered URL encryption, URL metadata remover, Mass shrinker, Quick link and many more! | Powered by xeorgs...">
<meta name="description" content="Xeorl - The All-In-One, Fully Free to Use Advanced Link Shortener and Management Tool - Equipped with Multi-layered URL encryption, URL metadata remover, Mass shrinker, Quick link and Many more! - Powered by @xodivorce...">
<link rel="icon" href="assets/images/favicon.ico" type="image/x-icon">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
@@ -91,7 +20,9 @@ if (isset($_GET)) {
include "assets/_header.php";
?>
<body>
<main>
<!-- Shorten Section -->
<section class="shorten-section">
<h1>Open source inits.</h1>
<h2>Lovingly hand-crafted.</h2>
@@ -118,12 +49,57 @@ include "assets/_header.php";
echo '<button class="delete-btn"><img src="assets/images/delete.png"></button>';
echo '</li>';
}
} else {
// No shortened links found
echo '<li>';
echo '<div class="link-icon"><img src="assets/images/url.png" class="url-img"></div>';
echo '<div class="link-info">';
echo '<span class="short-link"">xeorl.buzz/*****</span>';
echo '<span class="long-link">You don\'t have any shortened links</span>';
echo '</div>';
echo '<button class="copy-btn"><img src="assets/images/copy.png"></button>';
echo '<button class="delete-btn"><img src="assets/images/delete.png"></button>';
echo '</li>';
}
?>
</ul>
</div>
</section>
<!-- Dashboard Statistics Section -->
<section class="dashboard-stats-section">
<h1 class="section-heading">Numbers Speak For Themselves.</h1>
<h2 class="section-subheading">Challenged By URLs, Defeted By None.</h2>
<p class="section-paragraph">
Even though were a growing community with a close-knit user base,<br>
our commitment to you is always personal. Were here 24/7<br>
to support and resolve any issues you have because your satisfaction<br>
means everything to us. For any issues, email us at <a href="mailto:hey@xodivorce.in" class="contact-link">hey@xodivorce.in</a>.
</p>
<section class="dashboard-stats">
<div class="stat-item">
<img src="assets/images/links.png" alt="Total Links" class="stat-icon links-icon">
<h3>Total URLs</h3>
<p><?php echo $total_links; ?></p>
</div>
<div class="stat-item">
<img src="assets/images/total.png" alt="Total Clicks" class="stat-icon total-icon">
<h3>Total Clicks</h3>
<p><?php echo $total_clicks; ?></p>
</div>
<div class="stat-item">
<img src="assets/images/users.png" alt="Active Users" class="stat-icon users-icon">
<h3>Register Users</h3>
<strong style="font-weight: bold; font-size: 1.5em;"><?php echo "2,407"; ?></strong>
</div>
</section>
</section>
</main>
<?php include 'assets/_footer.php'; ?>
<script src="assets/js/_home.js"></script>
<script src="assets/js/developer_tools.js"></script>