/** * Standard constructor * @param string Name of the widget * @param string Label of the widget * @param string type of the input TEXT|TEXTAREA * @param boolean can this field not be left empty? */ function WZUploadArchive($name) { global $c, $errors, $lang, $_FILES; WZO::WZO($name); if ($_FILES[$this->name]['name'] != "") { if (stristr(strtoupper($_FILES[$this->name]['type']), "ZIP") === false) { $this->errortext = "<br/>" . $lang->get("no_archive", "The file you uploaded is not an zip-archive or your browser does not send the file correct!"); $errors .= "-NOZIP"; $this->css = "error"; } else { $this->value = ""; mt_srand((double) microtime() * 1000000); $tmpfilename = md5(uniqid(mt_rand())) . ".zip"; move_uploaded_file($_FILES[$this->name]['tmp_name'], $c["path"] . "cache/" . $tmpfilename); $tmpFolder = $c['path'] . "cache/" . md5(uniqid(mt_rand())); mkdir($tmpFolder); nxunzip($c["path"] . "cache/" . $tmpfilename, $tmpFolder . "/"); $_SESSION["archivefolder"] = $tmpFolder; @unlink($c['path'] . "cache/" . $tmpfilename); } } }
/** * parse document as OpenOffice Writer */ function parseOOWriter() { // unzip the file. global $c; mt_srand((double) microtime() * 1000000); $this->tmpFolder = $c['path'] . "cache/" . md5(uniqid(mt_rand())); mkdir($this->tmpFolder); nxunzip($this->filename, $this->tmpFolder . "/"); $this->filename = $this->tmpFolder . "/content.xml"; $this->loadFile(); if ($this->filecontent) { $vals = array(); $index = array(); $p = xml_parser_create(); xml_parse_into_struct($p, $this->filecontent, $vals, $index); xml_parser_free($p); $this->officeStyles = $this->indentSubTagsRec(array_slice($vals, $index['OFFICE:AUTOMATIC-STYLES'][0] + 1, $index['OFFICE:AUTOMATIC-STYLES'][1] - $index['OFFICE:AUTOMATIC-STYLES'][0] - 1), 2); $this->prepareStyles(); $this->officeBody = array_slice($vals, $index['OFFICE:BODY'][0] + 1, $index['OFFICE:BODY'][1] - $index['OFFICE:BODY'][0] - 1); $this->officeBody = $this->indentSubTagsRec($this->officeBody, 1); $res = $this->renderOOBody($this->officeBody); nxRMDir($this->tmpFolder); return implode(chr(10), $res); } }