Heray-Was-Here
Server : LiteSpeed
System : Linux uk-fast-web1372.main-hosting.eu 4.18.0-553.121.1.lve.el8.x86_64 #1 SMP Thu Apr 30 16:40:41 UTC 2026 x86_64
User : u390967363 ( 390967363)
PHP Version : 8.2.30
Disable Function : system, exec, shell_exec, passthru, mysql_list_dbs, ini_alter, dl, symlink, link, chgrp, leak, popen, apache_child_terminate, virtual, mb_send_mail
Directory :  /home/u390967363/domains/aibenproperties.com/public_html/app/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/u390967363/domains/aibenproperties.com/public_html/app/backup.php
<?php
require 'includes/db.php';

session_start();

// Access Control: Super Admin & Admin Only
if (!isset($_SESSION['user_role']) || !in_array($_SESSION['user_role'], ['super_admin', 'admin'])) {
    header("Location: dashboard.php");
    exit;
}

$dbName = 'aiben_properties_db'; // Assuming DB name, but PDO handles connection
// Better to get DB name from PDO connection if possible, or just ignore USE statement

$filename = 'backup_' . date('Y-m-d_H-i-s') . '.sql';

header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="' . $filename . '"');
header('Pragma: no-cache');

// 1. Header
echo "-- Aiben Properties Database Backup\n";
echo "-- Generated: " . date('Y-m-d H:i:s') . "\n";
echo "-- Host: " . $_SERVER['SERVER_NAME'] . "\n\n";
echo "SET SQL_MODE = \"NO_AUTO_VALUE_ON_ZERO\";\n";
echo "SET time_zone = \"+00:00\";\n\n";

try {
    // 2. Get Tables
    $tables = [];
    $stmt = $pdo->query("SHOW TABLES");
    while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
        $tables[] = $row[0];
    }

    foreach ($tables as $table) {
        echo "-- --------------------------------------------------------\n\n";
        echo "-- Table structure for table `$table`\n\n";
        
        $row = $pdo->query("SHOW CREATE TABLE `$table`")->fetch(PDO::FETCH_NUM);
        echo $row[1] . ";\n\n";
        
        echo "-- Dumping data for table `$table`\n\n";
        
        $stmt = $pdo->query("SELECT * FROM `$table`");
        while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
            $keys = array_keys($row);
            $values = array_map(function ($value) use ($pdo) {
                if ($value === null) return "NULL";
                return $pdo->quote($value);
            }, array_values($row));
            
            echo "INSERT INTO `$table` (`" . implode('`, `', $keys) . "`) VALUES (" . implode(', ', $values) . ");\n";
        }
        echo "\n";
    }

    // Log the backup action
    if (function_exists('logActivity')) {
        logActivity($_SESSION['user_id'], 'DB_BACKUP', "Downloaded database backup");
    }

} catch (Exception $e) {
    echo "\n-- Error: " . $e->getMessage();
}
exit;
?>

Hry