Server IP : 162.214.80.37 / Your IP : 216.73.216.83 Web Server : Apache System : Linux sh013.webhostingservices.com 4.19.286-203.ELK.el7.x86_64 #1 SMP Wed Jun 14 04:33:55 CDT 2023 x86_64 User : imyrqtmy ( 2189) PHP Version : 8.2.18 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON Directory (0755) : /home2/imyrqtmy/public_html/destinytrafficsolutions/vendor/ |
[ Home ] | [ C0mmand ] | [ Upload File ] |
---|
<?php require 'vendor/autoload.php'; // Load PhpSpreadsheet Library include("inc/config.php"); use PhpOffice\PhpSpreadsheet\Spreadsheet; use PhpOffice\PhpSpreadsheet\Writer\Xlsx; if (!isset($_GET['time_range'])) { die("Invalid request!"); } $time_range = intval($_GET['time_range']); // 15 or 60 minutes date_default_timezone_set("Asia/Kolkata"); $current_time = date("H:i"); $current_date = date("Y-m-d"); $start_time = date("H:i", strtotime("-$time_range minutes")); // Create Spreadsheet $spreadsheet = new Spreadsheet(); $sheet = $spreadsheet->getActiveSheet(); // Add Title $sheet->setCellValue("A1", "Time Range Report"); $sheet->setCellValue("A2", "Start Time:"); $sheet->setCellValue("B2", $start_time); $sheet->setCellValue("A3", "End Time:"); $sheet->setCellValue("B3", $current_time); // Example Data (Replace this with your actual database query) $sheet->setCellValue("A5", "Example Data"); $sheet->setCellValue("A6", "Category"); $sheet->setCellValue("B6", "Clicks"); // Set Auto Column Width foreach (range('A', 'B') as $column) { $sheet->getColumnDimension($column)->setAutoSize(true); } // Save the Excel file in the "uploads" folder $folder = "exelfile/"; if (!is_dir($folder)) { mkdir($folder, 0777, true); // Create folder if it does not exist } $filename = "click_data_" . $time_range . "min_" . date("Ymd_His") . ".xlsx"; $filepath = $folder . $filename; $writer = new Xlsx($spreadsheet); $writer->save($filepath); // Return JSON response header('Content-Type: application/json'); echo json_encode([ "status" => "success", "message" => "File Generated Successfully", "file" => $filepath // Ensure this has the correct path ]); exit; // echo json_encode([ // "status" => "success", "message" => "File Generated Successfully", "file" => $filepath]); // exit; ?>