本文整理汇总了PHP中unzip函数的典型用法代码示例。如果您正苦于以下问题:PHP unzip函数的具体用法?PHP unzip怎么用?PHP unzip使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了unzip函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: unzipFile
function unzipFile($filename, $filenameRail, $feedDirectory)
{
$results = unzip($filename, $dest_dir = false, $create_zip_name_dir = true, $overwrite = true);
$results2 = unzip($filenameRail, $dest_dir = false, $create_zip_name_dir = true, $overwrite = true);
$filenameRailFolder = $feedDirectory . "/gtfs/" . basename($filenameRail, ".zip");
$test = copy_directory($filenameRailFolder, $feedDirectory . "/" . basename($filenameRail, ".zip"));
}
示例2: install
function install()
{
if (!isset($_GET['step'])) {
hello_screen();
} else {
$step = $_GET['step'];
switch ($step) {
case 'test':
testserver();
break;
case 'unzip':
unzip();
break;
case 'database':
dbconfig();
break;
case 'admin':
adminconf();
break;
case 'final':
finalstep();
break;
default:
hello_screen();
}
}
}
示例3: getOSZ
function getOSZ($id)
{
$osz = downloadOSZ($id);
if ($osz === true) {
unzip(ROOT . '/ddl/' . $id . '.osz', ROOT . '/ddl/' . $id . '/');
} else {
echo $osz . 'sec';
}
}
示例4: uploadSkin
function uploadSkin()
{
// Check for upload error
if ($_FILES["uploadSkin"]["error"]) {
$this->esoTalk->message("invalidSkin");
return false;
}
// Move the uploaded file
move_uploaded_file($_FILES["uploadSkin"]["tmp_name"], "skins/{$_FILES["uploadSkin"]["name"]}");
// Upzip it
if (!($files = unzip("skins/{$_FILES["uploadSkin"]["name"]}", "skins/"))) {
$this->esoTalk->message("invalidSkin");
} else {
$directories = 0;
$infoFound = false;
$skinFound = false;
foreach ($files as $k => $file) {
if (substr($file["name"], 0, 9) == "__MACOSX/" or substr($file["name"], -9) == ".DS_Store") {
unset($files[$k]);
continue;
}
if ($file["directory"]) {
$directories++;
}
if (substr($file["name"], -8) == "skin.php") {
$skinFound = true;
}
}
// If we found a skin.php, info.php, and a base directory, write the files
if ($skinFound and $directories == 1) {
$error = false;
foreach ($files as $k => $file) {
if ($file["directory"] and !is_dir("skins/{$file["name"]}")) {
mkdir("skins/{$file["name"]}");
} elseif (!$file["directory"]) {
if (file_exists("skins/{$file["name"]}") and !is_writeable("skins/{$file["name"]}")) {
$this->esoTalk->message("notWritable", false, "skins/{$file["name"]}");
$error = true;
break;
}
$handle = fopen("skins/{$file["name"]}", "w");
chmod("skins/{$file["name"]}", 0777);
fwrite($handle, $file["content"]);
fclose($handle);
}
}
if (!$error) {
$this->esoTalk->message("skinAdded");
}
} else {
$this->esoTalk->message("invalidSkin");
}
}
unlink("skins/{$_FILES["uploadSkin"]["name"]}");
}
示例5: setOpenZipFile
function setOpenZipFile($vars_file, $vars_code)
{
$i = 0;
$vars_array = array();
$zip = @zip_open($vars_file);
if ($zip) {
echo 'id;filename;filesize;md5' . "\n\r";
while ($zip_entry = zip_read($zip)) {
if (zip_entry_filesize($zip_entry) > 0) {
$i++;
$vars_array = unzip($vars_file, $i);
echo $i . ';' . zip_entry_name($zip_entry) . ';' . zip_entry_filesize($zip_entry) . ';' . md5($vars_array[1]) . "\n\r";
}
}
zip_close($zip);
}
}
示例6: testunzip
public function testunzip()
{
//execute the method and test if it returns true and verify the if unzipped files exist
$cache_dir = rtrim($GLOBALS['sugar_config']['cache_dir'], '/\\');
$files_list = array('config.php', 'config_override.php');
$file = $cache_dir . '/zipTest.zip';
//creata a zip file first, to unzip
if (!file_exists($file)) {
zip_files_list($file, $files_list);
}
$result = unzip($file, $cache_dir);
$this->assertTrue($result);
$this->assertFileExists($cache_dir . '/config.php');
$this->assertFileExists($cache_dir . '/config_override.php');
unlink($cache_dir . '/config.php');
unlink($cache_dir . '/config_override.php');
}
示例7: md5_change
require CLASS_DIR . 'options/md5change.php';
md5_change();
break;
case 'md5_change_go':
if (!empty($options['disable_md5_change'])) {
break;
}
require CLASS_DIR . 'options/md5change.php';
md5_change_go();
break;
case 'unzip':
if (!empty($options['disable_unzip'])) {
break;
}
require CLASS_DIR . 'options/unzip.php';
unzip();
break;
case 'unzip_go':
if (!empty($options['disable_unzip'])) {
break;
}
require CLASS_DIR . 'options/unzip.php';
unzip_go();
break;
case 'split':
if (!empty($options['disable_split'])) {
break;
}
require CLASS_DIR . 'options/split.php';
rl_split();
break;
示例8: testExtractFailsWhenExtractDirectoryDoesNotExist
public function testExtractFailsWhenExtractDirectoryDoesNotExist()
{
$this->assertFalse(unzip($this->testdir . '/testarchive.zip', $this->testdir . '/testarchiveoutputnothere'));
}
示例9: restore_backup
public function restore_backup()
{
//Upload File
$file_upload = $this->do_upload();
$filename = $file_upload['file_name'];
$filname_without_ext = pathinfo($filename, PATHINFO_FILENAME);
if (isset($file_upload['error'])) {
$data['error'] = $file_upload['error'];
$this->load->view('templates/header');
$this->load->view('templates/menu');
$this->load->view('settings/backup', $data);
$this->load->view('templates/footer');
} elseif ($file_upload['file_ext'] != '.zip') {
$data['error'] = "The file you are trying to upload is not a .zip file. Please try again.";
$this->load->view('templates/header');
$this->load->view('templates/menu');
$this->load->view('settings/backup', $data);
$this->load->view('templates/footer');
} else {
$data['file_upload'] = $file_upload;
//Unzip
$full_path = $file_upload['full_path'];
$file_path = $file_upload['file_path'];
$raw_name = $file_upload['raw_name'];
$return_code = unzip($full_path, $file_path);
if ($return_code === TRUE) {
//execute sql file
$sql_file_name = $file_path . $raw_name . '.sql';
$file_content = file_get_contents($sql_file_name);
$query_list = explode(";", $file_content);
foreach ($query_list as $query) {
//Remove Comments like # # Commment #
$pos1 = strpos($query, "#\n# ");
if ($pos1 !== FALSE) {
$pos2 = strpos($query, "\n#", $pos1 + 3);
$comment = substr($query, $pos1, $pos2 - $pos1) . "<br/>";
$query = substr($query, $pos2 + 2);
}
$this->db->query($query);
}
} else {
$data['error'] = $return_code;
}
$this->load->view('templates/header');
$this->load->view('templates/menu');
$this->load->view('settings/backup', $data);
$this->load->view('templates/footer');
}
}
示例10: internalToFilesystem
}
// soe stripped out all the name.
$targetFile = $targetPath . '/' . internalToFilesystem($seoname);
if (file_exists($targetFile)) {
$append = '_' . time();
$seoname = stripSuffix($seoname) . $append . '.' . getSuffix($seoname);
$targetFile = $targetPath . '/' . internalToFilesystem($seoname);
}
if (move_uploaded_file($tempFile, $targetFile)) {
@chmod($targetFile, 0666 & CHMOD_VALUE);
$album = new Album($gallery, $folder);
$image = newImage($album, $seoname);
$image->setOwner($_zp_current_admin_obj->getUser());
if ($name != $seoname && $image->getTitle() == substr($seoname, 0, strrpos($seoname, '.'))) {
$image->setTitle(substr($name, 0, strrpos($name, '.')));
}
$image->save();
} else {
$error = UPLOAD_ERR_NO_FILE;
}
} else {
if (is_zip($name)) {
unzip($tempFile, $targetPath);
}
}
}
}
}
}
$file = $_FILES['file'];
echo '{"name":"' . $file['name'] . '","type":"' . $file['type'] . '","size":"' . $file['size'] . '","error":' . $error . '}';
示例11: time
$append = '_' . time();
$soename = stripSuffix($soename) . $append . '.' . getSuffix($soename);
$uploadfile = $targetPath . '/' . internalToFilesystem($soename);
}
move_uploaded_file($tmp_name, $uploadfile);
@chmod($uploadfile, FILE_MOD);
$image = newImage($album, $soename);
$image->setOwner($_zp_current_admin_obj->getUser());
if ($name != $soename) {
$image->setTitle(stripSuffix($name));
}
$image->save();
}
} else {
if (is_zip($name)) {
unzip($tmp_name, $targetPath);
} else {
$error = UPLOAD_ERR_EXTENSION;
// invalid file uploaded
break;
}
}
}
} else {
break;
}
}
if ($error == UPLOAD_ERR_OK && ($filecount || isset($_POST['newalbum']))) {
if ($album->albumSubRights() & MANAGED_OBJECT_RIGHTS_EDIT) {
// he has edit rights, allow new album creation
header('Location: ' . FULLWEBPATH . '/' . ZENFOLDER . '/admin-edit.php?page=edit&album=' . pathurlencode($folder) . '&uploaded&subpage=1&tab=imageinfo&albumimagesort=id_desc');
示例12: rmdir_recursive
$_SESSION['unzip_dir'] = $unzip_dir;
$_SESSION['install_file'] = $install_file;
$_SESSION['zip_from_dir'] = $zip_from_dir;
if (is_dir($unzip_dir . '/scripts')) {
rmdir_recursive($unzip_dir . '/scripts');
}
if (is_file($unzip_dir . '/manifest.php')) {
rmdir_recursive($unzip_dir . '/manifest.php');
}
mkdir_recursive($unzip_dir);
if (!is_dir($unzip_dir)) {
echo "\n{$unzip_dir} is not an available directory\nFAILURE\n";
fwrite(STDERR, "\n{$unzip_dir} is not an available directory\nFAILURE\n");
exit(1);
}
unzip($argv[1], $unzip_dir);
// mimic standard UW by copy patch zip to appropriate dir
copy($argv[1], $install_file);
//// END UPGRADE PREP
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
//// UPGRADE UPGRADEWIZARD
$zipBasePath = "{$unzip_dir}/{$zip_from_dir}";
$uwFiles = findAllFiles("{$zipBasePath}/modules/UpgradeWizard", array());
$destFiles = array();
foreach ($uwFiles as $uwFile) {
$destFile = str_replace($zipBasePath . "/", '', $uwFile);
copy($uwFile, $destFile);
}
require_once 'modules/UpgradeWizard/uw_utils.php';
// must upgrade UW first
示例13: mk_temp_dir
$show_files = true;
if (empty($unzip_dir)) {
$unzip_dir = mk_temp_dir($base_tmp_upgrade_dir);
}
$zip_from_dir = ".";
$zip_to_dir = ".";
$zip_force_copy = array();
if (!$unzip_dir) {
logThis('Could not create a temporary directory using mk_temp_dir( $base_tmp_upgrade_dir )');
die($mod_strings['ERR_UW_NO_CREATE_TMP_DIR']);
}
//double check whether unzipped .
if (file_exists($unzip_dir . "/scripts") && file_exists($unzip_dir . "/manifest.php")) {
//already unzipped
} else {
unzip($install_file, $unzip_dir);
}
// assumption -- already validated manifest.php at time of upload
require_once "{$unzip_dir}/manifest.php";
if (isset($manifest['copy_files']['from_dir']) && $manifest['copy_files']['from_dir'] != "") {
$zip_from_dir = $manifest['copy_files']['from_dir'];
}
if (isset($manifest['copy_files']['to_dir']) && $manifest['copy_files']['to_dir'] != "") {
$zip_to_dir = $manifest['copy_files']['to_dir'];
}
if (isset($manifest['copy_files']['force_copy']) && $manifest['copy_files']['force_copy'] != "") {
$zip_force_copy = $manifest['copy_files']['force_copy'];
}
if (isset($manifest['version'])) {
$version = $manifest['version'];
}
示例14: performUninstall
function performUninstall($name)
{
$uh = new UpgradeHistory();
$uh->name = $name;
$uh->id_name = $name;
$found = $uh->checkForExisting($uh);
if ($found != null) {
global $sugar_config;
global $mod_strings;
global $current_language;
$base_upgrade_dir = sugar_cached("/upgrades");
$base_tmp_upgrade_dir = "{$base_upgrade_dir}/temp";
if (!isset($GLOBALS['mi_remove_tables'])) {
$GLOBALS['mi_remove_tables'] = true;
}
$unzip_dir = mk_temp_dir($base_tmp_upgrade_dir);
unzip($found->filename, $unzip_dir);
$mi = new ModuleInstaller();
$mi->silent = true;
$mi->uninstall("{$unzip_dir}");
$found->delete();
unlink(remove_file_extension($found->filename) . '-manifest.php');
unlink($found->filename);
}
}
示例15: upgradeSugarCache
/**
* change from using the older SugarCache in 6.1 and below to the new one in 6.2
*/
function upgradeSugarCache($file)
{
global $sugar_config;
$cacheUploadUpgradesTemp = mk_temp_dir(sugar_cached('upgrades/temp'));
unzip($file, $cacheUploadUpgradesTemp);
if (!file_exists(clean_path("{$cacheUploadUpgradesTemp}/manifest.php"))) {
logThis("*** ERROR: no manifest file detected while bootstraping upgrade wizard files!");
return;
} else {
include clean_path("{$cacheUploadUpgradesTemp}/manifest.php");
}
$from_dir = "{$cacheUploadUpgradesTemp}/{$manifest['copy_files']['from_dir']}";
$allFiles = array();
if (file_exists("{$from_dir}/include/SugarCache")) {
$allFiles = findAllFiles("{$from_dir}/include/SugarCache", $allFiles);
}
if (file_exists("{$from_dir}/include/database")) {
$allFiles = findAllFiles("{$from_dir}/include/database", $allFiles);
}
if (file_exists("{$from_dir}/include/utils/external_cache.php")) {
$allFiles[] = "{$from_dir}/include/utils/external_cache.php";
}
if (file_exists("{$from_dir}/include/utils/sugar_file_utils.php")) {
$allFiles[] = "{$from_dir}/include/utils/sugar_file_utils.php";
}
if (file_exists("{$from_dir}/include/utils/sugar_file_utils.php")) {
$allFiles[] = "{$from_dir}/include/utils/sugar_file_utils.php";
}
foreach ($allFiles as $k => $file) {
$destFile = str_replace($from_dir . "/", "", $file);
if (!is_dir(dirname($destFile))) {
mkdir_recursive(dirname($destFile));
// make sure the directory exists
}
if (stristr($file, 'uw_main.tpl')) {
logThis('Skipping "' . $file . '" - file copy will during commit step.');
} else {
logThis('updating UpgradeWizard code: ' . $destFile);
copy_recursive($file, $destFile);
}
}
}