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() { PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, array($this, 'onPearError')); $this->sessionState(0); // turn off the session.. $img = DB_DataObject::Factory('images'); $img->setFrom(array('onid' => 0, 'ontable' => 'ipshead')); $img->onUpload(false); require_once 'File/Convert.php'; $fc = new File_Convert($img->getStoreName(), $img->mimetype); $csv = $fc->convert('text/csv'); $this->importCsv($csv); }
function post() { if (isset($_REQUEST['_convertToPlain'])) { require_once 'System.php'; $tmpdir = System::mktemp("-d convertPlain"); $path = $tmpdir . '/' . time() . '.html'; if (isset($_REQUEST['_check_unsubscribe'])) { libxml_use_internal_errors(true); $doc = new DOMDocument('1.0', 'UTF-8'); $doc->loadHTML($_REQUEST['bodytext']); $xpath = new DOMXpath($doc); foreach ($xpath->query('//a[@href]') as $a) { $href = $a->getAttribute('href'); if (!preg_match('/^#unsubscribe/', $href)) { continue; } $a->parentNode->replaceChild($doc->createTextNode($a->nodeValue . ' {unsubscribe_link}'), $a); } $_REQUEST['bodytext'] = $doc->saveHTML(); libxml_use_internal_errors(false); } if (!file_exists($path)) { file_put_contents($path, $_REQUEST['bodytext']); } require_once 'File/Convert.php'; $fc = new File_Convert($path, 'text/html'); $plain = $fc->convert('text/plain'); $this->jok(file_get_contents($plain)); } // Import from URL if (isset($_REQUEST['importUrl'])) { $this->checkHeader($_REQUEST['importUrl']); $data = $this->convertStyle($_REQUEST['importUrl'], '', true); $this->jok($data); } // Import from file $htmlFile = DB_DataObject::factory('images'); $htmlFile->setFrom(array('onid' => 0, 'ontable' => 'crm_mailing_list_message')); $htmlFile->onUpload(false); if ($htmlFile->mimetype != 'text/html') { $this->jerr('accept html file only!'); } if (!file_exists($htmlFile->getStoreName())) { $this->jerr('update failed!'); } $data = $this->convertStyle('', $htmlFile->getStoreName(), false); $htmlFile->delete(); unlink($htmlFile->getStoreName()) or die('Unable to delete the file'); $this->jok($data); }
function post() { $this->transObj = DB_DataObject::Factory('invhist_transfer'); $this->transObj->query('BEGIN'); PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, array($this, 'onPearError')); $img = DB_DataObject::Factory('images'); $img->setFrom(array('onid' => 0, 'ontable' => 'ipshead')); $img->onUpload(false); require_once 'File/Convert.php'; $fc = new File_Convert($img->getStoreName(), $img->mimetype); $csv = $fc->convert('text/csv'); $ret = $this->importCsv($csv); $this->jdata($ret['data'], false, isset($ret['extra']) ? $ret['extra'] : array()); }
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 }