/** * check the archive */ function execute() { global $lang, $errors; $archfolder = $_SESSION["archivefolder"]; if ($archfolder != "") { $d = dir($archfolder); $this->counter = 0; while (false !== ($f = $d->read())) { if (is_file($d->path . '/' . $f)) { $info = pathinfo($d->path . '/' . $f); $ext2 = strtoupper($info["extension"]); if ($ext2 == "JPG" || $ext2 == "JPEG" || $ext2 == "PNG" || $ext2 == "GIF") { createImageFromFile($d->path . '/' . $f, "", "", 1, value("folder", "NUMERIC", 1)); $this->counter++; } } } $d->close(); } nxRMDir($d->path); $_SESSION["archivefolder"] = ""; $this->add(new WZLabel($lang->get("nofi", "Number of files imported:") . $this->counter)); $this->forbidBack = true; }
/** * Delete a whole directory. * @param string path to delete * @author found at php.net */ function nxRMDir ($del_path) { if (strpos($del_path, '..') != false ) exit(); $dir = $del_path; $current_dir = opendir($dir); while($entryname = readdir($current_dir)){ if(is_dir("$dir/$entryname") and ($entryname != "." and $entryname!="..")){ nxRMDir("${dir}/${entryname}"); }elseif($entryname != "." and $entryname!=".."){ unlink("${dir}/${entryname}"); } } closedir($current_dir); rmdir(${dir}); }
/** * 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); } }