function __construct($fn) { $this->fileName = $fn; // echo file_get_contents($fn);exit; return; require_once dirname(__FILE__) . '/../Convert.php'; $x = new File_Convert($fn, 'application/abiword'); $x->convert('application/abiword'); $x->serve('attachment'); exit; }
function post($fname) { $ml = (int) ini_get('suhosin.post.max_value_length'); if (empty($_POST['_json'])) { header("HTTP/1.0 400 Internal Server Error"); die($ml ? "Suhosin Patch enabled - try and disable it!!!" : 'no JSON sent'); } if (empty($_POST['_json'])) { header("HTTP/1.0 400 Internal Server Error"); die("Missing json attribute"); } $json = json_decode($_POST['_json']); require_once 'Spreadsheet/Excel/Writer.php'; // Creating a workbook $outfile2 = $this->tempName('xls'); // var_dump($outfile2); $workbook = new Spreadsheet_Excel_Writer($outfile2); //$workbook = new Spreadsheet_Excel_Writer(); $workbook->setVersion(8); // sending HTTP headers $worksheet = $workbook->addWorksheet("Sheet 1"); if (is_a($worksheet, 'PEAR_Error')) { die($worksheet->toString()); } //print_R($worksheet); $worksheet->setInputEncoding('UTF-8'); for ($r = 0; $r < count($json); $r++) { $row = $json[$r]; for ($c = 0; $c < count($row); $c++) { $worksheet->write($r, $c, $row[$c]); } } $workbook->close(); require_once 'File/Convert.php'; $fc = new File_Convert($outfile2, "application/vnd.ms-excel"); $fn = $fc->convert("application/vnd.ms-excel"); $fc->serve('attachment', 'excel-' . date('Y-m-d-H-i-s') . '.xls'); // can fix IE Mess unlink($outfile2); }
function post() { if (!$this->authUser) { $this->jerr("image conversion only allowed by registered users"); } // converts a posted string (eg.svg) // into another type.. if (empty($_REQUEST['as'])) { $this->jerr("missing target type"); } if (empty($_REQUEST['mimetype'])) { $this->jerr("missing mimetype"); } if (empty($_REQUEST['data'])) { $this->jerr("missing data"); } $this->as_mimetype = $_REQUEST['as']; $this->mimetype = $_REQUEST['mimetype']; require_once 'File/MimeType.php'; $y = new File_MimeType(); $src_ext = $y->toExt($this->mimetype); $tmp = $this->tempName($src_ext); file_put_contents($tmp, $_REQUEST['data']); require_once 'File/Convert.php'; $cv = new File_Convert($tmp, $this->mimetype); $fn = $cv->convert($this->as_mimetype, empty($_REQUEST['width']) ? 0 : $_REQUEST['width'], empty($_REQUEST['height']) ? 0 : $_REQUEST['height']); if (!empty($_REQUEST['as_data'])) { $this->jok(base64_encode(file_get_contents($fn))); } $cv->serve('attachment'); exit; }
function send($fname) { if (!empty($this->workbook)) { $this->workbook->close(); $this->workbook = false; } require_once 'File/Convert.php'; //var_Dump($this->outfile2); $fc = new File_Convert($this->outfile2, "application/vnd.ms-excel"); $fn = $fc->convert("application/vnd.ms-excel"); //print_r($fc); $fc->serve('attachment', $fname); // can fix IE Mess }