<?php
if (!defined('BASEPATH')) exit('No direct script access allowed');

if( route(2) == "download" ){
    // Tumhare purane credentials (ye working hain)
    $db_host = 'localhost';
    $db_user = 'alixdeal_ads1';
    $db_pass = 'alixdeal_ads1';
    $db_name = 'alixdeal_ads1';

    // Dynamic filename: Ab ye DB name aur date ke sath ayega
    $filename = $db_name . "_Backup_" . date("d-M-Y_H-i") . ".sql";
    
    header('Content-Type: application/sql');
    header('Content-Disposition: attachment; filename="' . $filename . '"');

    // FIX: --password= ke baad space mat dena, ye command ka standard hai
    $command = "mysqldump --opt -h " . escapeshellarg($db_host) . " -u " . escapeshellarg($db_user) . " --password=" . escapeshellarg($db_pass) . " " . escapeshellarg($db_name);
    
    // Command chalao
    passthru($command);
    exit;
}

require 'admin/views/backup-sql.php'; 
?> 
