| Server IP : 104.21.21.239 / Your IP : 216.73.216.11 Web Server : Apache/2.4.68 (Amazon Linux) OpenSSL/3.5.5 System : Linux ip-172-31-69-123.ec2.internal 6.1.176-223.369.amzn2023.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Jul 24 13:34:27 UTC 2026 x86_64 User : ec2-user ( 1000) PHP Version : 8.4.23 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /home/connectionsdev/classes/ |
Upload File : |
<?php
class lcs_db_report_csv extends lcs_db_report_base implements report_interface {
protected $csv_text = '';
const CRLF = "\r\n";
public function __construct() {
}
public function report_start() {
}
public function report_end() {
}
public function header_start() {
}
public function header_end() {
}
public function header_row_start() {
}
public function header_row_end() {
$this->csv_text = $this->remove_last_comma($this->csv_text);
$this->csv_text .= self::CRLF;
}
public function header_cell_add($data = '', $args = []) {
$this->csv_text .= '"'.$this->escape_filter($data).'",';
}
public function footer_start() {
}
public function footer_end() {
}
public function footer_row_start() {
}
public function footer_row_end() {
}
public function footer_cell_add($data = '', $args = []) {
}
public function data_start() {
}
public function data_end() {
}
public function data_row_start() {
}
public function data_row_end() {
$this->csv_text = $this->remove_last_comma($this->csv_text);
$this->csv_text .= self::CRLF;
}
public function data_cell_add($data = '', $args = []) {
$this->csv_text .= '"'.$this->escape_filter($data).'",';
}
public function output_report($filename = '') {
$file = 'Report.csv';
$content_type = 'text/csv';
header("Content-Description: File Transfer");
header('Content-Disposition: attachment; filename="' . $file . '"');
header('Content-Type: '.$content_type);
//header('Content-Transfer-Encoding: binary');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Expires: 0');
echo $this->csv_text;
}
private function escape_filter($text) {
$text = str_replace('"', '""', $text);
return $text;
}
private function remove_last_comma($text) {
if (substr($text, -1) == ',') :
$text = substr($text, 0, -1);
endif;
return $text;
}
}