function gen_html($input) { while (strpos($input, "<!--Remove Start-->") !== false) { $input = str_replace("<!--Remove Start-->" . get_string_between($input, "<!--Remove Start-->", "<!--Remove Stop-->") . "<!--Remove Stop-->", "", $input); } $input = str_replace("<!--Start Compile Include>", "", $input); $input = str_replace("<End Compile Include-->", "", $input); $input = str_replace("<!--COMPILIER INFO-->", "<!--" . file_get_contents("compilierinfo.txt") . "-->", $input); $input = sanitize_output($input); $input = str_replace("<!--ADS-->", file_get_contents("ads.txt"), $input); return $input; }
public function generateExcelTemplate($quotation_id) { $id = $quotation_id; //project id $this->load->model('model_tutorial'); $data['id'] = $id; //quotation header $data['quotation'] = $this->model_tutorial->getQuotationInfo($id); $getQuotationID = $this->model_tutorial->getQuotationInfo($id); //content list $content_list = $this->model_tutorial->getQuotationList($id); //agreement $agreement = $this->model_tutorial->getQuotationAgreement($id); $agreement_content = sanitize_output(html_entity_decode($agreement['agreement'])); //totals $totals = $this->model_tutorial->getQuotationTotals($getQuotationID['id']); define('EOL', PHP_SAPI == 'cli' ? PHP_EOL : '<br />'); date_default_timezone_set('Asia/Manila'); /** PHPExcel_IOFactory */ //require_once dirname(__FILE__) . '/../Classes/PHPExcel/IOFactory.php'; require_once 'application/third_party/PHPExcel-1.8/Classes/PHPExcel/IOFactory.php'; echo date('H:i:s'), " Load from Excel5 template", EOL; $objReader = PHPExcel_IOFactory::createReader('Excel5'); $objPHPExcel = $objReader->load("excel_template/quotation_format.xls"); echo date('H:i:s'), " Add new data to the template", EOL; $objPHPExcel->getActiveSheet()->setCellValue('B4', $getQuotationID['receiver_name']); $objPHPExcel->getActiveSheet()->setCellValue('B5', $getQuotationID['address']); $objPHPExcel->getActiveSheet()->setCellValue('H4', $getQuotationID['reference_no']); $objPHPExcel->getActiveSheet()->setCellValue('H6', $getQuotationID['project_date']); $objPHPExcel->getActiveSheet()->setCellValue('B8', $getQuotationID['project_name']); $baseRow = 14; $style_header = array('font' => array('bold' => true)); foreach ($content_list['items'] as $r => $dataRow) { $row = $baseRow + $r; $h_counter = $r + 1; $objPHPExcel->getActiveSheet()->insertNewRowBefore($row, 1); $objPHPExcel->getActiveSheet()->setCellValue('A' . $row, $h_counter); $objPHPExcel->getActiveSheet()->setCellValue('B' . $row, $dataRow['particular_name']); $objPHPExcel->getActiveSheet()->getStyle('B' . $row)->applyFromArray($style_header); //fp($dataRow['child_label']['items']); // $objPHPExcel->getActiveSheet()->getHighestRow() //fp($objPHPExcel->getActiveSheet()->getHighestRow()); /* foreach($dataRow['child_label']['items'] as $key => $value) { $child_row = $row + $key; $child_counter = $child_row + 1; $objPHPExcel->getActiveSheet()->insertNewRowBefore($child_row,1); $objPHPExcel->getActiveSheet()->setCellValue('A'.$child_row, $row . "." . $child_row); $objPHPExcel->getActiveSheet()->setCellValue('B'.$child_row, $value['particular']); $objPHPExcel->getActiveSheet()->setCellValue('F'.$child_row, $value['unit']); $objPHPExcel->getActiveSheet()->setCellValue('G'.$child_row, $value['unit_label']); $objPHPExcel->getActiveSheet()->setCellValue('H'.$child_row, $value['unit_price']); $objPHPExcel->getActiveSheet()->setCellValue('I'.$child_row, "=F" . $child_row . "* H" . $child_row); } $objPHPExcel->getActiveSheet()->removeRow($row-1,1); */ } $objPHPExcel->getActiveSheet()->removeRow($baseRow - 1, 1); echo date('H:i:s'), " Write to Excel5 format", EOL; $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5'); $objWriter->save(str_replace('.php', '.xls', __FILE__)); echo date('H:i:s'), " File written to ", str_replace('.php', '.xls', pathinfo(__FILE__, PATHINFO_BASENAME)), EOL; // Echo memory peak usage echo date('H:i:s'), " Peak memory usage: ", memory_get_peak_usage(true) / 1024 / 1024, " MB", EOL; // Echo done echo date('H:i:s'), " Done writing file", EOL; echo 'File has been created in ', getcwd(), EOL; /***** // Include PHPExcel require_once('application/third_party/PHPExcel-1.8/Classes/PHPExcel.php'); // Create new PHPExcel object $objPHPExcel = new PHPExcel(); // Set document properties $objPHPExcel->getProperties()->setCreator("Maarten Balliauw") ->setLastModifiedBy("Maarten Balliauw") ->setTitle("Office 2007 XLSX Test Document") ->setSubject("Office 2007 XLSX Test Document") ->setDescription("Test document for Office 2007 XLSX, generated using PHP classes.") ->setKeywords("office 2007 openxml php") ->setCategory("Test result file"); // Add some data $objPHPExcel->setActiveSheetIndex(0) ->setCellValue('A1', 'Hello') ->setCellValue('B2', 'world!') ->setCellValue('C1', 'Hello') ->setCellValue('D2', 'world!'); // Miscellaneous glyphs, UTF-8 $objPHPExcel->setActiveSheetIndex(0) ->setCellValue('A4', 'Miscellaneous glyphs') ->setCellValue('A5', 'éàèùâêîôûëïüÿäöüç'); // Rename worksheet $objPHPExcel->getActiveSheet()->setTitle('Simple'); // Set active sheet index to the first sheet, so Excel opens this as the first sheet $objPHPExcel->setActiveSheetIndex(0); // Redirect output to a client’s web browser (Excel2007) header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'); header('Content-Disposition: attachment;filename="01simple.xlsx"'); header('Cache-Control: max-age=0'); // If you're serving to IE 9, then the following may be needed header('Cache-Control: max-age=1'); // If you're serving to IE over SSL, then the following may be needed header ('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past header ('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); // always modified header ('Cache-Control: cache, must-revalidate'); // HTTP/1.1 header ('Pragma: public'); // HTTP/1.0 $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007'); $objWriter->save('php://output'); exit; ****/ }
<?php require_once VIEW_PATH . 'header.inc.php'; ?> <form method="POST" action="<?php echo sanitize_output($_SERVER['REQUEST_URI']); ?> "> <p> <label for="title">Title</label><br /> <input id="title" name="title" type="text" size="75" value="<?php echo sanitize_output($title); ?> " autofocus/></p> <p> <label for="content">Content</label><br /> <textarea id="content" name="content"><?php echo sanitize_output($content); ?> </textarea></p> <p> <input type="submit"/></p> </form> <?php require_once VIEW_PATH . 'footer.inc.php';
<p> <label for="RBI">RBI</label> <input id="RBI" name="RBI" type="Number" size="75" value="<?php echo sanitize_output($RBI); ?> " autofocus size="2"/> </p> <p> <label for="Salary">Salary</label> <input id="Salary" name="Salary" type="Number" step="any" value="<?php echo sanitize_output($Salary); ?> " autofocus size="2"/> </p> <p> <label for="Bio">Bio</label> <textarea id="Bio" name="Bio"><?php echo sanitize_output($Bio); ?> </textarea></p> <p> <input type="submit"/></p> </form> <?php require_once VIEW_PATH . 'footer.inc.php';
$res = cat(sanitize_input($_GET['file'])); } break; case 'head': if (isset($_GET['file'])) { isset($_GET['lines']) and $lines = sanitize_input($_GET['lines']) or $lines = 10; $res = catN(sanitize_input($_GET['file']), $lines); } break; case 'file': if (isset($_GET['file'])) { $res = fileinfo(sanitize_input($_GET['file'])); } break; case 'info': if (isset($_GET['dir'])) { $res = showinfo(sanitize_input($_GET['dir'])); } else { $res = showinfo('.'); } break; /*case 'grep': if (isset($_GET['dir']) and isset($_GET['expr'])) { $res = grep($_GET['dir'],$_GET['expr']); } break;*/ } $res[1] = sanitize_output($res[1]); //debug: error_log(implode(" ",$res)); echo json_encode($res); }