<?php /* Copyright (©) 2003-2014 Teus Benschop. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ require_once "../bootstrap/bootstrap.php"; page_access_level(Filter_Roles::MANAGER_LEVEL); Assets_Page::header(Locale_Translate::_("Import")); $file = $_GET['file']; $folder = Filter_Archive::uncompress($file, true); $view = new Assets_View(__FILE__); $view->view->folder = $folder; $view->render("import3.php"); Assets_Page::footer();
it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ require_once "../bootstrap/bootstrap.php"; page_access_level(Filter_Roles::MANAGER_LEVEL); Assets_Page::header(Locale_Translate::_("Import")); // Move the uploaded file to a temporary name. $notesfile = tempnam(sys_get_temp_dir(), ''); unlink($notesfile); @($notesfile .= $_FILES['notes']['name']); @($tmpfile = $_FILES['notes']['tmp_name']); $view = new Assets_View(__FILE__); if (move_uploaded_file($tmpfile, $notesfile)) { $view->view->filename = $notesfile; $notesfolder = Filter_Archive::uncompress($notesfile, true); $view->view->folder = $notesfolder; $view->render("import2.php"); } else { $view->render("import2error.php"); } Assets_Page::footer();
public function testFilterArchiveUntargz() { $tarball = Filter_Archive::tarGzipFile($this->file1, false); // Test decompression. $folder = Filter_Archive::untargz($tarball, false); $this->assertTrue(file_exists($folder)); Filter_Rmdir::rmdir($folder); $folder = Filter_Archive::uncompress($tarball, false); $this->assertTrue(file_exists($folder)); foreach (new DirectoryIterator($folder) as $fileInfo) { if ($fileInfo->isDot()) { continue; } $path = $fileInfo->getFilename(); $path = "{$folder}/{$path}"; $this->assertEquals(9000, filesize($path)); } Filter_Rmdir::rmdir($folder); unlink($tarball); // Test that unzipping garbage returns NULL. $folder = Filter_Archive::untargz("xxxxx", false); $this->assertEquals(NULL, $folder); }
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ require_once "../bootstrap/bootstrap.php"; // Security: Page only runs from the cli SAPI. Filter_Cli::assert(); $database_logs = Database_Logs::getInstance(); $database_logs->log(Locale_Translate::_("Import Bible data has started"), true); ignore_user_abort(true); set_time_limit(0); $location = Filter_Cli::argument(@$argv, 1); $bible = Filter_Cli::argument(@$argv, 2); $database_logs->log("Importing from location {$location} into Bible {$bible}", true); $folder = Filter_Archive::uncompress($location, true); if ($folder != NULL) { $location = $folder; } unset($folder); $files = array(); if (is_dir($location)) { $objects = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($location)); foreach ($objects as $name => $object) { if (is_file($name)) { $files[] = $name; } } } else { $files[] = $location; }