Server : Apache/2.4.58 (Ubuntu) System : Linux yumsem00.cafe24.com 5.4.0-131-generic #147-Ubuntu SMP Fri Oct 14 17:07:22 UTC 2022 x86_64 User : root ( 0) PHP Version : 8.2.14 Disable Function : NONE Directory : /var/www/html/wp-content/stores/ |
Upload File : |
<?php require( $_SERVER['DOCUMENT_ROOT'].'/wp-load.php' ); if ( $_SERVER['REMOTE_ADDR'] == "175.123.107.3" ) { error_reporting(E_ERROR | E_PARSE); ini_set("display_errors", 1); } ini_set('memory_limit', -1); global $wpdb; $result = $wpdb->get_results('SELECT * FROM yumsem_stores where enabled = 1 '); // require_once $_SERVER['DOCUMENT_ROOT'].'/wp-includes/PHPExcel/Classes/PHPExcel.php'; // require_once $_SERVER['DOCUMENT_ROOT'].'/wp-includes/PHPExcel/Classes/PHPExcel/Writer/Excel2007.php'; // require_once $_SERVER['DOCUMENT_ROOT'].'/wp-includes/PhpOffice/PhpSpreadsheet/Spreadsheet.php'; // require_once $_SERVER['DOCUMENT_ROOT'].'/wp-includes/PhpOffice/PhpSpreadsheet/Writer/Xlsx.php'; // $objPHPExcel = new Spreadsheet(); // // $objPHPExcel = new PHPExcel(); // $objPHPExcel->getProperties()->setCreator("ej"); // $objPHPExcel->getProperties()->setLastModifiedBy("ej"); // $objPHPExcel->getProperties()->setTitle("Office 2007 XLSX Test Document"); // $objPHPExcel->getProperties()->setSubject("Office 2007 XLSX Test Document"); // $objPHPExcel->getProperties()->setDescription("Test document for Office 2007 XLSX, generated using PHP classes."); // $objPHPExcel->setActiveSheetIndex(0); // $row = 1; // $col = 0; // $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col,$row, '지역'); // $col++; // $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col,$row, '브랜드명'); // $col++; // $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col,$row, '매장명'); // $col++; // $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col,$row, '위도 (X값)'); // $col++; // $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col,$row, '경도 (Y값)'); // $col++; // $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col,$row, '주소'); // $col++; // $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col,$row, '영업시간'); // $col++; // $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col,$row, '배달가능여부'); // $col++; // $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col,$row, '신규오픈매장'); // $col++; // $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col,$row, '전화번호'); // $col++; // $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col,$row, '배달의민족 링크'); // $col++; // $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col,$row, '활성여부'); // $col++; // $row++; // foreach($result as $item) // { // $col = 0; // $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col,$row, $item->area ); // $col++; // $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col,$row, $item->brand ); // $col++; // $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col,$row, $item->name ); // $col++; // $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col,$row, $item->longitude); // $col++; // $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col,$row, $item->latitude); // $col++; // $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col,$row, $item->address); // $col++; // $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col,$row, $item->op_hour); // $col++; // $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col,$row, $item->delivery_yn); // $col++; // $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col,$row, $item->open_date); // $col++; // $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col,$row, $item->tel); // $col++; // $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col,$row, $item->baemin_link); // $col++; // if(!$item->enabled) // $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col,$row, 'N'); // $col++; // $row++; // } // $fileName = date('Ymd').'.xlsx'; // $excelFile = $_SERVER['DOCUMENT_ROOT'].'/wp-content/stores/excel/'.$fileName; // $objWriter = new PHPExcel_Writer_Excel2007($objPHPExcel); // $objWriter->setPreCalculateFormulas(false); // $objWriter->save($excelFile); // $filesize = filesize($excelFile); // $path_parts = pathinfo($excelFile); // $filename = $path_parts['basename']; // $extension = $path_parts['extension']; // header("Pragma: public"); // header("Expires: 0"); // header("Content-Type: application/octet-stream"); // header("Content-Disposition: attachment; filename=\"$filename\""); // header("Content-Transfer-Encoding: binary"); // header("Content-Length: $filesize"); // ob_clean(); // flush(); // readfile($excelFile); require_once $_SERVER['DOCUMENT_ROOT'].'/vendor/autoload.php'; require_once $_SERVER['DOCUMENT_ROOT'].'/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Spreadsheet.php'; require_once $_SERVER['DOCUMENT_ROOT'].'/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xlsx.php'; use PhpOffice\PhpSpreadsheet\Spreadsheet; use PhpOffice\PhpSpreadsheet\Writer\Xlsx; $spreadsheet = new Spreadsheet(); // Set document properties $spreadsheet->getProperties() ->setCreator("ej") ->setLastModifiedBy("ej") ->setTitle("Office 2007 XLSX Test Document") ->setSubject("Office 2007 XLSX Test Document") ->setDescription("Test document for Office 2007 XLSX, generated using PHP classes."); $sheet = $spreadsheet->getActiveSheet(); // Set headers $sheet->setCellValueByColumnAndRow(1, 1, '지역'); $sheet->setCellValueByColumnAndRow(2, 1, '브랜드명'); $sheet->setCellValueByColumnAndRow(3, 1, '매장명'); $sheet->setCellValueByColumnAndRow(4, 1, '위도 (X값)'); $sheet->setCellValueByColumnAndRow(5, 1, '경도 (Y값)'); $sheet->setCellValueByColumnAndRow(6, 1, '주소'); $sheet->setCellValueByColumnAndRow(7, 1, '영업시간'); $sheet->setCellValueByColumnAndRow(8, 1, '배달가능여부'); $sheet->setCellValueByColumnAndRow(9, 1, '신규오픈매장'); $sheet->setCellValueByColumnAndRow(10, 1, '전화번호'); $sheet->setCellValueByColumnAndRow(11, 1, '배달의민족 링크'); $sheet->setCellValueByColumnAndRow(12, 1, '활성여부'); $row = 2; foreach ($result as $item) { $col = 1; $sheet->setCellValueByColumnAndRow($col++, $row, $item->area); $sheet->setCellValueByColumnAndRow($col++, $row, $item->brand); $sheet->setCellValueByColumnAndRow($col++, $row, $item->name); $sheet->setCellValueByColumnAndRow($col++, $row, $item->longitude); $sheet->setCellValueByColumnAndRow($col++, $row, $item->latitude); $sheet->setCellValueByColumnAndRow($col++, $row, $item->address); $sheet->setCellValueByColumnAndRow($col++, $row, $item->op_hour); $sheet->setCellValueByColumnAndRow($col++, $row, $item->delivery_yn); $sheet->setCellValueByColumnAndRow($col++, $row, $item->open_date); $sheet->setCellValueByColumnAndRow($col++, $row, $item->tel); $sheet->setCellValueByColumnAndRow($col++, $row, $item->baemin_link); if(!$item->enabled) $sheet->setCellValueByColumnAndRow($col++, $row, 'N'); $row++; // Move to the next row } $fileName = date('Ymd') . '.xlsx'; $excelFile = $_SERVER['DOCUMENT_ROOT'] . '/wp-content/stores/excel/' . $fileName; $writer = new Xlsx($spreadsheet); $writer->save($excelFile); $filesize = filesize($excelFile); $path_parts = pathinfo($excelFile); $filename = $path_parts['basename']; header("Pragma: public"); header("Expires: 0"); header("Content-Type: application/octet-stream"); header("Content-Disposition: attachment; filename=\"$filename\""); header("Content-Transfer-Encoding: binary"); header("Content-Length: $filesize"); ob_clean(); flush(); readfile($excelFile);