39 lines
		
	
	
		
			No EOL
		
	
	
		
			1.2 KiB
		
	
	
	
		
			PHP
		
	
	
		
			Executable file
		
	
	
	
	
			
		
		
	
	
			39 lines
		
	
	
		
			No EOL
		
	
	
		
			1.2 KiB
		
	
	
	
		
			PHP
		
	
	
		
			Executable file
		
	
	
	
	
<?php
 | 
						|
session_start();
 | 
						|
 | 
						|
// Make sure the session contains data to export
 | 
						|
if (empty($_SESSION)) {
 | 
						|
    http_response_code(400);
 | 
						|
    header("Content-Type: application/json");
 | 
						|
    echo json_encode(["error" => "No session data available to export"]);
 | 
						|
    exit();
 | 
						|
}
 | 
						|
 | 
						|
// Clean up the session data before export
 | 
						|
if (isset($_SESSION["characters"])) {
 | 
						|
    // Remove any entries with empty character IDs
 | 
						|
    if (isset($_SESSION["characters"][""])) {
 | 
						|
        unset($_SESSION["characters"][""]);
 | 
						|
    }
 | 
						|
    
 | 
						|
    // Create a clean copy for export (don't modify the actual session)
 | 
						|
    $export_data = $_SESSION;
 | 
						|
} else {
 | 
						|
    $export_data = $_SESSION;
 | 
						|
}
 | 
						|
 | 
						|
// Generate descriptive filename with timestamp for user download
 | 
						|
$date_time = date("Y-m-d");
 | 
						|
$download_filename = "eve_indy_job_tracker_backup_{$date_time}.json";
 | 
						|
 | 
						|
// Set headers for download
 | 
						|
header("Content-Type: application/json");
 | 
						|
header('Content-Disposition: attachment; filename="' . $download_filename . '"');
 | 
						|
header("Cache-Control: no-store, no-cache, must-revalidate");
 | 
						|
header("Pragma: no-cache");
 | 
						|
 | 
						|
// Output session data as pretty-printed JSON
 | 
						|
echo json_encode($export_data, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
 | 
						|
error_log("Export completed successfully for session download.");
 | 
						|
exit();
 | 
						|
?>
 |