/** * Force downloads for * -- Cart66 reports (admin) * -- Downloading the debuggin log file (admin) * -- Downloading digital product files */ public function forceDownload() { ob_end_clean(); if ($_SERVER['REQUEST_METHOD'] == 'POST' && Cart66Common::postVal('cart66-action') == 'export_csv') { require_once CART66_PATH . "/models/Cart66Exporter.php"; $start = str_replace(';', '', $_POST['start_date']); $end = str_replace(';', '', $_POST['end_date']); Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Date parameters for report: START {$start} and END {$end}"); $report = Cart66Exporter::exportOrders($start, $end); header('Content-Type: application/csv'); header('Content-Disposition: inline; filename="Cart66Report.csv"'); echo $report; die; } elseif ($_SERVER['REQUEST_METHOD'] == 'POST' && Cart66Common::postVal('cart66-action') == 'download log file') { $logFilePath = Cart66Log::getLogFilePath(); if (file_exists($logFilePath)) { $logData = file_get_contents($logFilePath); $cartSettings = Cart66Log::getCartSettings(); header('Content-Description: File Transfer'); header('Content-Type: text/plain'); header('Content-Disposition: attachment; filename=Cart66LogFile.txt'); header('Expires: 0'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Pragma: public'); echo $cartSettings . "\n\n"; echo $logData; die; } } elseif ($_SERVER['REQUEST_METHOD'] == 'POST' && Cart66Common::postVal('cart66-action') == 'clear log file') { Cart66Common::clearLog(); } }