/** * Try to upload file */ private function tryToUploadFile() { $extension = Filesystem::extensionOfFile($_FILES['qqfile']['name']); if (!ImporterFactory::canImportExtension($extension)) { $this->throwUnknownExtension($extension); } elseif ($this->uploadErrorIsPresent()) { $this->throwUploadError(); } elseif ($this->uploadedFileWasTooBig()) { $this->throwTooBigFile(); } elseif ($this->tryToMoveFile()) { $this->setSucceeded(); } else { $this->throwUploadFailed(); } }
/** * Parse file * @param string $Filename relative path (from FRONTEND_PATH) to file */ public function parseFile($Filename) { $Archive = new ZipArchive(); if ($Archive->open(FRONTEND_PATH . $Filename) === true) { $Files = array(); for ($i = 0; $i < $Archive->numFiles; ++$i) { $file = $Archive->getNameIndex($i); $pathinfo = pathinfo($file); if (is_array($pathinfo) && isset($pathinfo['dirname']) && isset($pathinfo['extension']) && $pathinfo['dirname'] == '.' && substr($file, 0, 1) != '.' && ImporterFactory::canImportExtension($pathinfo['extension'])) { $Files[] = $file; } } $Archive->extractTo(FRONTEND_PATH . ImporterUpload::relativePath(''), $Files); $Archive->close(); $this->readFiles($Files); } }