This commit is contained in:
2025-02-05 03:51:15 +05:30
parent c4c8ba334e
commit 7977ddc04e
31 changed files with 643 additions and 513 deletions

View File

@@ -1,9 +1,17 @@
<?php
include "config.php";
session_start();
if (!isset($_SESSION['user_id'])) {
echo "This feature is for members only";
exit;
}
if(isset($_GET['id'])){
$delete_id = mysqli_real_escape_string($conn, $_GET['id']);
$sql = mysqli_query($conn, "DELETE FROM url WHERE shorten_url = '{$delete_id}'");
if($sql){
echo "success";
} else {

View File

@@ -1,6 +1,8 @@
<?php
session_start(); // Start the session to access session variables
require_once 'config.php'; // Ensure this is your mysqli connection file
error_reporting(E_ALL);
ini_set('display_errors', 1);
// Check if the email is stored in the session
if (!isset($_SESSION['email'])) {

View File

@@ -1,6 +1,8 @@
<?php
session_start();
include "config.php";
error_reporting(E_ALL);
ini_set('display_errors', 1);
// Check if the session variable for storing shortened links exists
if (!isset($_SESSION['shortened_links'])) {

View File

@@ -2,6 +2,8 @@
// core/get_statistics.php
require 'config.php'; // Assuming config.php contains your database connection setup
error_reporting(E_ALL);
ini_set('display_errors', 1);
// Initialize variables in case the queries fail
$total_links = 0;
@@ -28,17 +30,15 @@ if ($result_total_clicks) {
echo "Error fetching total clicks: " . mysqli_error($conn);
}
// Calculate active users (assuming there's a 'user_sessions' table or similar)
/*
$sql_active_users = "SELECT COUNT(DISTINCT user_id) as active_users FROM user_sessions WHERE last_active > DATE_SUB(NOW(), INTERVAL 30 DAY)";
$result_active_users = mysqli_query($conn, $sql_active_users);
if ($result_active_users) {
$active_users_row = mysqli_fetch_assoc($result_active_users);
$active_users = $active_users_row['active_users'];
// Calculate active users
$sql_total_users = "SELECT COUNT(*) as total_users FROM user";
$result_total_users = mysqli_query($conn, $sql_total_users);
if ($result_total_users) {
$total_users_row = mysqli_fetch_assoc($result_total_users);
$total_users = $total_users_row['total_users'];
} else {
//echo "Error fetching active users: " . mysqli_error($conn);
echo "Error fetching total users: " . mysqli_error($conn);
}
*/
?>

View File

@@ -27,28 +27,6 @@ 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 = "";
@@ -65,9 +43,12 @@ if (isset($_GET)) {
// 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
// Fetch the full URL and store it in the session
$full_url = mysqli_fetch_assoc($sql);
header("Location:" . $full_url['full_url']);
$_SESSION['redirect_url'] = $full_url['full_url'];
// Redirect to unzipper.php
header("Location: unzipper.php");
exit(); // Stop further script execution after redirection
}
}

View File

@@ -5,6 +5,8 @@ session_start();
// Include necessary files
require_once 'config.php'; // Ensure this is your mysqli connection file
require 'vendor/autoload.php';
error_reporting(E_ALL);
ini_set('display_errors', 1);
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
use Dotenv\Dotenv;

View File

@@ -1,6 +1,8 @@
<?php
session_start();
include "config.php";
error_reporting(E_ALL);
ini_set('display_errors', 1);
$full_url = mysqli_real_escape_string($conn, $_POST['full_url']);
if (!empty($full_url) && filter_var($full_url, FILTER_VALIDATE_URL)) {