diff --git a/htdocs/.DS_Store b/htdocs/.DS_Store index aca56015..4a8fcf18 100644 Binary files a/htdocs/.DS_Store and b/htdocs/.DS_Store differ diff --git a/htdocs/.htaccess b/htdocs/.htaccess index 57ae4f51..bb6c821a 100755 --- a/htdocs/.htaccess +++ b/htdocs/.htaccess @@ -1,9 +1,6 @@ -Options -Indexes RewriteEngine On -# Check if the request is not for an existing directory or file -RewriteCond %{REQUEST_FILENAME} !-d +RewriteCond $1 !^(index\.php) RewriteCond %{REQUEST_FILENAME} !-f - -# Rewrite all other URLs to index.php with the 'url' parameter -RewriteRule ^(.+)$ index.php?url=$1 [QSA,L] +RewriteCond %{REQUEST_FILENAME} !-d +RewriteRule ^(.*)$ index.php?/$1 [L] \ No newline at end of file diff --git a/htdocs/account.php b/htdocs/account.php index 65b5ee54..cf4d1010 100644 --- a/htdocs/account.php +++ b/htdocs/account.php @@ -1,5 +1,7 @@ - Dashboard + Account @@ -23,8 +25,7 @@ if (!isset($_SESSION['user_id'])) { - - + diff --git a/htdocs/assets/.DS_Store b/htdocs/assets/.DS_Store index 9a0ef78a..8dd6ad5f 100755 Binary files a/htdocs/assets/.DS_Store and b/htdocs/assets/.DS_Store differ diff --git a/htdocs/assets/_cookies.php b/htdocs/assets/_cookies.php new file mode 100644 index 00000000..a9991570 --- /dev/null +++ b/htdocs/assets/_cookies.php @@ -0,0 +1,39 @@ + + +
+

By clicking "Accept All Cookies", you agree to the storing of cookies on your device to enhance site navigation, analyze site usage, and assist in our marketing efforts.

+ + + + × +
+ + diff --git a/htdocs/assets/_header.php b/htdocs/assets/_header.php index 8084a40f..39e58053 100755 --- a/htdocs/assets/_header.php +++ b/htdocs/assets/_header.php @@ -6,33 +6,50 @@ if (session_status() === PHP_SESSION_NONE) {
-
-
+ diff --git a/htdocs/assets/css/_account.css b/htdocs/assets/css/_account.css index 7f6461e7..349571c1 100644 --- a/htdocs/assets/css/_account.css +++ b/htdocs/assets/css/_account.css @@ -1,12 +1,120 @@ +/* General Styles */ body { font-family: "Montserrat", sans-serif; margin: 0; padding: 0; + display: flex; + height: 100vh; background-color: #ffffff; - color: #333333; + color: #111313; } -main { - padding: 60px 20px; - text-align: center; -} \ No newline at end of file +/* User Image */ +.user-image { + width: 40px; + height: 40px; + margin-top: -5px; + border-radius: 50%; + margin-left: 25px; + border: 1px solid #ffffff; +} + +/* Sidebar Styles */ +.sidebar { + width: 20%; + background-color: #ffffff; + color: #98E5DD; + display: flex; + flex-direction: column; + border: solid 1px rgb(58, 66, 65); + padding: 20px; +} + +/* Sidebar Header (Flexbox) */ +.sidebar .sidebar-header { + display: flex; + flex-wrap: wrap; /* Allows wrapping when screen is small */ + align-items: center; /* Ensures vertical alignment */ + margin-left: -25px; + margin-right: -20px; + + margin-top: 45px; +} + +/* Image & Text Flexbox */ +.sidebar .sidebar-header .user-image { + width: 40px; + height: 40px; + border-radius: 50%; + margin-right: 10px; +} + +.user-info { + font-size: 14px; + margin-bottom: 20px; + line-height: 1.4; + color: #171c24; + +} + +.user-email { + color: #677583; +} + +/* Sidebar Links */ +.sidebar a { + text-decoration: none; + color: #171c24; + padding: 15px; + display: block; + font-size: 16px; + transition: background-color 0.3s ease; /* Keep only background-color for transition */ +} + +/* Main Content */ +.content { + width: 80%; + padding: 20px; +} + +.content h2, .content h3 { + color: #EEB58F; +} + +/* Responsive Design */ +@media screen and (max-width: 768px) { + body { + flex-direction: column; + } + + .sidebar { + width: 100%; + height: auto; + display: flex; + flex-direction: row; + justify-content: space-around; + padding: 10px; + } + + .sidebar .sidebar-header { + justify-content: flex-start; + text-align: center; + margin-left: 0; + margin-right: 0; + } + + .sidebar .sidebar-header .user-image { + margin-left: 0; + margin-right: 10px; + } + + .user-info { + font-size: 12px; + text-align: left; + } + + .content { + width: 100%; + padding: 20px; + } +} diff --git a/htdocs/assets/css/_cookies.css b/htdocs/assets/css/_cookies.css new file mode 100644 index 00000000..a9f441c1 --- /dev/null +++ b/htdocs/assets/css/_cookies.css @@ -0,0 +1,47 @@ +#cookieBanner { + position: fixed; + bottom: 0; + left: 0; + width: 100%; + background: white; + box-shadow: 0 -2px 10px rgba(0,0,0,0.1); + padding: 15px; + display: flex; + align-items: center; + justify-content: space-between; + font-family: Arial, sans-serif; + z-index: 10; +} + +#cookieBanner p { + font-size: 14px; + color: #333; + margin: 0; + flex: 1; +} + +button { + padding: 10px 15px; + border: 1px solid #002147; + cursor: pointer; + font-size: 14px; + border-radius: 4px; + margin: 0 5px; +} + +.cookie-settings { + background: white; + color: #002147; +} + +.reject, .accept { + background: #002147; + color: white; +} + +.close { + font-size: 18px; + font-weight: bold; + cursor: pointer; + margin-left: 10px; +} diff --git a/htdocs/assets/css/_header.css b/htdocs/assets/css/_header.css index 1e1b8706..46482504 100755 --- a/htdocs/assets/css/_header.css +++ b/htdocs/assets/css/_header.css @@ -120,11 +120,12 @@ nav ul li a.disabled { .burger span { display: block; position: absolute; - height: 2.3px; + height: 2px; width: 100%; - background: black; + background: #000; border-radius: 9px; opacity: 1; + z-index: 2; left: 0; transform: rotate(0deg); transition: .25s ease-in-out; @@ -164,18 +165,60 @@ nav ul li a.disabled { left: 5px; } + .sidebar { + position: absolute; + top: 0; + width: 100%; + height: 100vh; + background-color: #ffffff; + text-align: center; + align-items: center; + justify-content: center; + display: flex; + z-index: 1; + transition: right 0.3s ease-in-out; + padding: 20px; +} + +/* Show sidebar when active */ +.sidebar.active { + right: 0; +} + + +.sidebar ul { + list-style: none; + padding: 0; + margin: 0; + display: flex; + flex-direction: column; + gap: 14px; +} + +.sidebar ul li a { + text-decoration: none; + color: #5e6775; + font-size: 18px; + font-weight: 500; + transition: color 0.3s; +} + +.sidebar ul li a:hover { + color: #272B2F; +} + + /* Adjust position of the hamburger menu */ @media (max-width: 768px) { .burger { display: block; margin-left: auto; - margin-right: 15px; + margin-right: 15px; } nav ul { display: none; } - .burger input:checked ~ nav ul { display: flex; flex-direction: column; @@ -187,6 +230,13 @@ nav ul li a.disabled { border-top: 1px solid #F2F2F2; padding: 10px 0; } + .burger input:checked ~ .sidebar { + display: block; + left: 0; + } + .sidebar { + width: 100%; + } } /* Adjust the logo alignment */ @@ -203,11 +253,14 @@ nav ul li a.disabled { } } -@media (max-width: 450px) { +@media (max-width: 485px) { .burger { display: block; margin-left: auto; margin-right: 25px; } + .sidebar { + width: 100%; + } } \ No newline at end of file diff --git a/htdocs/assets/css/_home.css b/htdocs/assets/css/_home.css index 713556e3..f6997643 100755 --- a/htdocs/assets/css/_home.css +++ b/htdocs/assets/css/_home.css @@ -232,13 +232,12 @@ main { .stat-icon { width: 35px; height: 35px; - margin-bottom: 15px; } .stat-item h3 { font-size: 16px; color: #677583; - margin-bottom: 10px; + margin-bottom: 15px; font-weight: 600; } diff --git a/htdocs/assets/css/_unzipper.css b/htdocs/assets/css/_unzipper.css new file mode 100644 index 00000000..0c5ce844 --- /dev/null +++ b/htdocs/assets/css/_unzipper.css @@ -0,0 +1,141 @@ +body { + font-family: "Montserrat", sans-serif; + background: #ffffff; + margin: 0; + padding: 0; +} + +.max-container { + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + height: 100vh; + width: 100%; +} + +.container { + background: white; + padding: 100px; + margin-top: 50px; + border-radius: 12px; + box-shadow: 0px 4px 15px rgba(0, 0, 0, 0.2); + text-align: center; + width: 750px; + border-top: 5px solid #652bf6; + min-height: 350px; + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; +} + +h2 { + font-size: 32px; + color: rgb(43, 35, 76); + font-weight: 400; + margin-bottom: 15px; +} + +.countdown-wrapper { + width: 100px; + height: 100px; + border: 2px solid rgb(70, 41, 204); + border-radius: 50%; + display: flex; + justify-content: center; + align-items: center; + margin: 20px auto; + position: relative; +} + +.countdown { + font-size: 16px; + font-weight: 400; + margin-top: -px; + color: rgb(70, 41, 204); + text-align: center; +} + +.countdown span { + font-size: 25px; + font-weight: 400; + color: rgb(70, 41, 204); + text-align: center; +} + +button { + padding: 17px 40px; + border-radius: 50px; + cursor: pointer; + border: 0; + background-color: rgb(103, 204, 129); + box-shadow: rgba(68, 68, 68, 0.572) 3px 2px 10px 0px; + color: #ffffff; + font-weight: 600; + text-transform: uppercase; + cursor: not-allowed; + font-size: 15px; + transition: all 0.5s ease; +} + +button:active { + box-shadow: rgba(68, 68, 68, 0.572) 3px 2px 10px 0px; + cursor: pointer; +} +@media (max-width: 1170px){ + + .container{ + width: 650px; + } +} +@media (max-width: 1024px){ + .container{ + width: 500px; + } +} +@media (max-width: 768px) { + .container { + padding: 40px 20px; + width: 85%; + } + + h2 { + font-size: 26px; + } + + .countdown-wrapper { + width: 90px; + height: 90px; + } + + .countdown span { + font-size: 20px; + } + + button { + padding: 15px 35px; + font-size: 15px; + } +} + +@media (max-width: 480px) { + .container { + padding: 30px 15px; + width: 90%; + } + + h2 { + font-size: 22px; + } + + + .countdown span { + font-size: 18px; + } + + button { + padding: 12px 25px; + font-size: 14px; + } +} diff --git a/htdocs/assets/images/default_user.png b/htdocs/assets/images/default_user.png new file mode 100644 index 00000000..30abea3c Binary files /dev/null and b/htdocs/assets/images/default_user.png differ diff --git a/htdocs/assets/js/_header.js b/htdocs/assets/js/_header.js new file mode 100644 index 00000000..5f2fecb6 --- /dev/null +++ b/htdocs/assets/js/_header.js @@ -0,0 +1,28 @@ +document.addEventListener("DOMContentLoaded", function () { + const burgerToggle = document.getElementById("burger-toggle"); + const sidebar = document.querySelector(".sidebar"); + + // Ensure sidebar is hidden initially + sidebar.style.display = "none"; + + burgerToggle.addEventListener("click", function () { + if (sidebar.style.display === "none" || sidebar.style.display === "") { + sidebar.style.display = "flex"; + sidebar.classList.add("active"); + } else { + sidebar.style.display = "none"; + sidebar.classList.remove("active"); + } + }); +}); + +window.addEventListener('scroll', function () { + const header = document.querySelector('.header'); // Get the header element + + // Check if the page has been scrolled + if (window.scrollY > 0) { + header.classList.add('scrolled'); // Add the "scrolled" class + } else { + header.classList.remove('scrolled'); // Remove the "scrolled" class + } +}); diff --git a/htdocs/assets/js/_home.js b/htdocs/assets/js/_home.js index f479ac0e..b67fc7e4 100755 --- a/htdocs/assets/js/_home.js +++ b/htdocs/assets/js/_home.js @@ -1,14 +1,3 @@ -window.addEventListener('scroll', function () { - const header = document.querySelector('.header'); // Get the header element - - // Check if the page has been scrolled - if (window.scrollY > 0) { - header.classList.add('scrolled'); // Add the "scrolled" class - } else { - header.classList.remove('scrolled'); // Remove the "scrolled" class - } -}); - const form = document.querySelector(".shorten-form"), urlInput = document.querySelector("#url-input"), shortenBtn = document.querySelector("#shorten-btn"), @@ -47,7 +36,7 @@ shortenBtn.onclick = () => { let data = xhr.response; if (data.length <= 5) { //This is your domain name - const domain = "xeorl.buzz/"; + const domain = "http://localhost/Php-Projects/xeorl/htdocs/"; let shortenURL = domain + data; // Remove the default message if it exists diff --git a/htdocs/assets/js/_unzipper.js b/htdocs/assets/js/_unzipper.js new file mode 100644 index 00000000..cde65ce2 --- /dev/null +++ b/htdocs/assets/js/_unzipper.js @@ -0,0 +1,62 @@ +// Countdown logic +let countdown = 10; +let countdownInterval; +const timerElement = document.getElementById("timer"); +const button = document.getElementById("getLinkBtn"); + +function updateCountdown() { + if (countdown > 0) { + countdown--; + timerElement.textContent = countdown; + } + if (countdown <= 0) { + button.disabled = false; // Enable the button when countdown ends + button.classList.add("active"); // Optional, if you use active class for style + button.style.cursor = "pointer"; // Enable cursor + setTimeout(function () { + button.textContent = "Getting links..."; // Change text before enabling + }, 300); // 0.3 seconds delay + setTimeout(function () { + button.textContent = "Get link"; // Final button text + }, 600); // After another 0.3 seconds + clearInterval(countdownInterval); + } +} + +function startCountdown() { + countdownInterval = setInterval(updateCountdown, 1000); +} + +function stopCountdown() { + clearInterval(countdownInterval); +} + +function init() { + // Initialize countdown value and button state + countdown = 10; + timerElement.textContent = countdown; + button.disabled = true; + button.classList.remove("active"); + button.style.cursor = "not-allowed"; + button.textContent = "PLEASE WAIT..."; + + startCountdown(); +} + +document.addEventListener("visibilitychange", () => { + if (document.hidden) { + stopCountdown(); + } else { + startCountdown(); + } +}); + +window.addEventListener("beforeunload", () => { + init(); // Reset state when the page is about to be unloaded +}); + +init(); // Call init to initialize the countdown when the page loads + +function redirect() { + window.location.href = redirectUrl; // Redirect to the full URL +} diff --git a/htdocs/core/delete.php b/htdocs/core/delete.php index bcd64238..98fe5c7d 100755 --- a/htdocs/core/delete.php +++ b/htdocs/core/delete.php @@ -1,9 +1,17 @@ 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); } -*/ + ?> diff --git a/htdocs/core/process.php b/htdocs/core/process.php index 7fa586fd..ee97d1b9 100644 --- a/htdocs/core/process.php +++ b/htdocs/core/process.php @@ -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 } } diff --git a/htdocs/core/resend.php b/htdocs/core/resend.php index 46ff8ad0..cef22d0f 100644 --- a/htdocs/core/resend.php +++ b/htdocs/core/resend.php @@ -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; diff --git a/htdocs/core/url-controll.php b/htdocs/core/url-controll.php index 8ee19d58..25f3faff 100755 --- a/htdocs/core/url-controll.php +++ b/htdocs/core/url-controll.php @@ -1,6 +1,8 @@ diff --git a/htdocs/home.php b/htdocs/home.php index ad1710ca..d0875e46 100644 --- a/htdocs/home.php +++ b/htdocs/home.php @@ -1,6 +1,8 @@ @@ -56,17 +58,20 @@ require 'core/get_statistics.php'; // Include the statistics file
Total Clicks

Total Clicks

-

+ +

Total Links

Total URLs

-

+ +

Active Users

Register Users

- + +
@@ -86,7 +91,7 @@ require 'core/get_statistics.php'; // Include the statistics file - + diff --git a/htdocs/index.php b/htdocs/index.php index e5e05467..ba0778f1 100755 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -1,5 +1,7 @@ load(); diff --git a/htdocs/login.php b/htdocs/login.php index fb250e2a..740322fb 100644 --- a/htdocs/login.php +++ b/htdocs/login.php @@ -1,5 +1,7 @@ diff --git a/htdocs/logout.php b/htdocs/logout.php index 2048c58a..170749da 100644 --- a/htdocs/logout.php +++ b/htdocs/logout.php @@ -1,6 +1,8 @@ diff --git a/htdocs/monetization.php b/htdocs/monetization.php index 32237e43..56d2a160 100644 --- a/htdocs/monetization.php +++ b/htdocs/monetization.php @@ -1,5 +1,7 @@ - Dashboard + Monetization @@ -23,7 +25,6 @@ if (!isset($_SESSION['user_id'])) { - diff --git a/htdocs/register.php b/htdocs/register.php index 9ba08a82..50734015 100644 --- a/htdocs/register.php +++ b/htdocs/register.php @@ -1,5 +1,7 @@ diff --git a/htdocs/unzipper.php b/htdocs/unzipper.php old mode 100755 new mode 100644 index b7b1bbc1..fbdeb272 --- a/htdocs/unzipper.php +++ b/htdocs/unzipper.php @@ -1,422 +1,56 @@ prepareExtraction($archive, $destination); +// Check if redirect_url is set in session +if (!isset($_SESSION['redirect_url'])) { + http_response_code(400); + die("Invalid request! The page you are looking for may have been deleted or removed from our server."); } -if (isset($_POST['dozip'])) { - $zippath = !empty($_POST['zippath']) ? strip_tags($_POST['zippath']) : '.'; - // Resulting zipfile e.g. zipper--2016-07-23--11-55.zip. - $zipfile = 'zipper-' . date("Y-m-d--H-i") . '.zip'; - Zipper::zipDir($zippath, $zipfile); -} - -$timeend = microtime(TRUE); -$time = round($timeend - $timestart, 4); - -/** - * Class Unzipper - */ -class Unzipper { - public $localdir = '.'; - public $zipfiles = array(); - - public function __construct() { - // Read directory and pick .zip, .rar and .gz files. - if ($dh = opendir($this->localdir)) { - while (($file = readdir($dh)) !== FALSE) { - if (pathinfo($file, PATHINFO_EXTENSION) === 'zip' - || pathinfo($file, PATHINFO_EXTENSION) === 'gz' - || pathinfo($file, PATHINFO_EXTENSION) === 'rar' - ) { - $this->zipfiles[] = $file; - } - } - closedir($dh); - - if (!empty($this->zipfiles)) { - $GLOBALS['status'] = array('info' => '.zip or .gz or .rar files found, ready for extraction'); - } - else { - $GLOBALS['status'] = array('info' => 'No .zip or .gz or rar files found. So only zipping functionality available.'); - } - } - } - - /** - * Prepare and check zipfile for extraction. - * - * @param string $archive - * The archive name including file extension. E.g. my_archive.zip. - * @param string $destination - * The relative destination path where to extract files. - */ - public function prepareExtraction($archive, $destination = '') { - // Determine paths. - if (empty($destination)) { - $extpath = $this->localdir; - } - else { - $extpath = $this->localdir . '/' . $destination; - // Todo: move this to extraction function. - if (!is_dir($extpath)) { - mkdir($extpath); - } - } - // Only local existing archives are allowed to be extracted. - if (in_array($archive, $this->zipfiles)) { - self::extract($archive, $extpath); - } - } - - /** - * Checks file extension and calls suitable extractor functions. - * - * @param string $archive - * The archive name including file extension. E.g. my_archive.zip. - * @param string $destination - * The relative destination path where to extract files. - */ - public static function extract($archive, $destination) { - $ext = pathinfo($archive, PATHINFO_EXTENSION); - switch ($ext) { - case 'zip': - self::extractZipArchive($archive, $destination); - break; - case 'gz': - self::extractGzipFile($archive, $destination); - break; - case 'rar': - self::extractRarArchive($archive, $destination); - break; - } - - } - - /** - * Decompress/extract a zip archive using ZipArchive. - * - * @param $archive - * @param $destination - */ - public static function extractZipArchive($archive, $destination) { - // Check if webserver supports unzipping. - if (!class_exists('ZipArchive')) { - $GLOBALS['status'] = array('error' => 'Error: Your PHP version does not support unzip functionality.'); - return; - } - - $zip = new ZipArchive; - - // Check if archive is readable. - if ($zip->open($archive) === TRUE) { - // Check if destination is writable - if (is_writeable($destination . '/')) { - $zip->extractTo($destination); - $zip->close(); - $GLOBALS['status'] = array('success' => 'Files unzipped successfully'); - } - else { - $GLOBALS['status'] = array('error' => 'Error: Directory not writeable by webserver.'); - } - } - else { - $GLOBALS['status'] = array('error' => 'Error: Cannot read .zip archive.'); - } - } - - /** - * Decompress a .gz File. - * - * @param string $archive - * The archive name including file extension. E.g. my_archive.zip. - * @param string $destination - * The relative destination path where to extract files. - */ - public static function extractGzipFile($archive, $destination) { - // Check if zlib is enabled - if (!function_exists('gzopen')) { - $GLOBALS['status'] = array('error' => 'Error: Your PHP has no zlib support enabled.'); - return; - } - - $filename = pathinfo($archive, PATHINFO_FILENAME); - $gzipped = gzopen($archive, "rb"); - $file = fopen($destination . '/' . $filename, "w"); - - while ($string = gzread($gzipped, 4096)) { - fwrite($file, $string, strlen($string)); - } - gzclose($gzipped); - fclose($file); - - // Check if file was extracted. - if (file_exists($destination . '/' . $filename)) { - $GLOBALS['status'] = array('success' => 'File unzipped successfully.'); - - // If we had a tar.gz file, let's extract that tar file. - if (pathinfo($destination . '/' . $filename, PATHINFO_EXTENSION) == 'tar') { - $phar = new PharData($destination . '/' . $filename); - if ($phar->extractTo($destination)) { - $GLOBALS['status'] = array('success' => 'Extracted tar.gz archive successfully.'); - // Delete .tar. - unlink($destination . '/' . $filename); - } - } - } - else { - $GLOBALS['status'] = array('error' => 'Error unzipping file.'); - } - - } - - /** - * Decompress/extract a Rar archive using RarArchive. - * - * @param string $archive - * The archive name including file extension. E.g. my_archive.zip. - * @param string $destination - * The relative destination path where to extract files. - */ - public static function extractRarArchive($archive, $destination) { - // Check if webserver supports unzipping. - if (!class_exists('RarArchive')) { - $GLOBALS['status'] = array('error' => 'Error: Your PHP version does not support .rar archive functionality. How to install RarArchive'); - return; - } - // Check if archive is readable. - if ($rar = RarArchive::open($archive)) { - // Check if destination is writable - if (is_writeable($destination . '/')) { - $entries = $rar->getEntries(); - foreach ($entries as $entry) { - $entry->extract($destination); - } - $rar->close(); - $GLOBALS['status'] = array('success' => 'Files extracted successfully.'); - } - else { - $GLOBALS['status'] = array('error' => 'Error: Directory not writeable by webserver.'); - } - } - else { - $GLOBALS['status'] = array('error' => 'Error: Cannot read .rar archive.'); - } - } - -} - -/** - * Class Zipper - * - * Copied and slightly modified from http://at2.php.net/manual/en/class.ziparchive.php#110719 - * @author umbalaconmeogia - */ -class Zipper { - /** - * Add files and sub-directories in a folder to zip file. - * - * @param string $folder - * Path to folder that should be zipped. - * - * @param ZipArchive $zipFile - * Zipfile where files end up. - * - * @param int $exclusiveLength - * Number of text to be exclusived from the file path. - */ - private static function folderToZip($folder, &$zipFile, $exclusiveLength) { - $handle = opendir($folder); - - while (FALSE !== $f = readdir($handle)) { - // Check for local/parent path or zipping file itself and skip. - if ($f != '.' && $f != '..' && $f != basename(__FILE__)) { - $filePath = "$folder/$f"; - // Remove prefix from file path before add to zip. - $localPath = substr($filePath, $exclusiveLength); - - if (is_file($filePath)) { - $zipFile->addFile($filePath, $localPath); - } - elseif (is_dir($filePath)) { - // Add sub-directory. - $zipFile->addEmptyDir($localPath); - self::folderToZip($filePath, $zipFile, $exclusiveLength); - } - } - } - closedir($handle); - } - - /** - * Zip a folder (including itself). - * - * Usage: - * Zipper::zipDir('path/to/sourceDir', 'path/to/out.zip'); - * - * @param string $sourcePath - * Relative path of directory to be zipped. - * - * @param string $outZipPath - * Relative path of the resulting output zip file. - */ - public static function zipDir($sourcePath, $outZipPath) { - $pathInfo = pathinfo($sourcePath); - $parentPath = $pathInfo['dirname']; - $dirName = $pathInfo['basename']; - - $z = new ZipArchive(); - $z->open($outZipPath, ZipArchive::CREATE); - $z->addEmptyDir($dirName); - if ($sourcePath == $dirName) { - self::folderToZip($sourcePath, $z, 0); - } - else { - self::folderToZip($sourcePath, $z, strlen("$parentPath/")); - } - $z->close(); - - $GLOBALS['status'] = array('success' => 'Successfully created archive ' . $outZipPath); - } -} +// Retrieve the redirect URL from session +$redirect_url = $_SESSION['redirect_url']; ?> - - + - File Unzipper + Zipper - - + + Xeorl - Unzipper + + + + + + + + + + + + -

- Status:
- Processing Time: seconds -

-
-
-

Archive Unzipper

- - - - -

Enter extraction path without leading or trailing slashes (e.g. "mypath"). If left empty current directory will be used.

- -
+ +
+
+

Your link is almost ready.

+
+
+ 10
Seconds +
+
+ +
+
+ + + + + + + + -
-

Archive Zipper

- - -

Enter path to be zipped without leading or trailing slashes (e.g. "zippath"). If left empty current directory will be used.

- -
-
-

Unzipper version: