11 * format = [empty=xls] , 'gnumeric' (download format)
12 * debug = true => download xml.
18 require_once 'Pman.php';
19 class Pman_Core_GnumericToExcel extends Pman
23 $au = $this->getAuthUser();
25 die("NOT authenticated");
27 $this->authUser = $au;
31 function post($fname) {
33 $ml = (int) ini_get('suhosin.post.max_value_length');
34 if (empty($_POST['xml'])) {
35 header("HTTP/1.0 400 Internal Server Error");
36 die( $ml ? "Suhosin Patch enabled - try and disable it!!!" : 'no XML sent');
39 if (empty($_POST['xml'])) {
40 header("HTTP/1.0 400 Internal Server Error");
41 die("Missing XML attribute");
45 $xml = iconv("UTF-8", "UTF-8//IGNORE", $xml);
47 //$xml = str_replace('é', 'e', $xml);
48 //$xml = str_replace("\xA0", ' ', $xml);
49 //$xml = str_replace("Ø", 'dia.',$xml);
51 //$this->addEvent("DOWNLOAD", false, isset($_REQUEST['title']) ? $_REQUEST['title'] : '???');
54 if (!empty($_POST['format']) && $_POST['format']=='gnumeric') {
55 if (empty($_POST['debug'])) {
56 header('Content-type: application/x-gnumeric');
58 header('Content-type: text/xml');
63 $srcTmp = ini_get('session.save_path') . '/' .uniqid('gnumeric_').'.gnumeric';
64 $targetTmp = ini_get('session.save_path') . '/' .uniqid('gnumeric_').'.xls';
65 // write the gnumeric file...
66 $fh = fopen($srcTmp,'w');
71 require_once 'System.php';
72 $ss = System::which('ssconvert');
74 " --import-encoding=Gnumeric_XmlIO:sax" .
75 " --export-type=Gnumeric_Excel:excel_biff8 " .
76 $srcTmp . ' ' . $targetTmp . ' 2>&1';
78 //passthru($cmd);exit;
83 if (!file_exists($targetTmp) || !filesize($targetTmp)) {
84 header("HTTP/1.0 400 Internal Server Error");
85 die("ERROR CONVERTING?:" . $cmd ."\n<BR><BR> OUTPUT:". htmlspecialchars($out));
89 $fh = fopen($targetTmp, 'r');
90 header('Content-type: application/vnd.ms-excel');
91 header('Content-Disposition: attachment; filename="' .addslashes($fname). '"');
93 // will not work on IE... - needs while/fget..