当前位置: 首页>>代码示例>>PHP>>正文


PHP Zip::Extract方法代码示例

本文整理汇总了PHP中Zip::Extract方法的典型用法代码示例。如果您正苦于以下问题:PHP Zip::Extract方法的具体用法?PHP Zip::Extract怎么用?PHP Zip::Extract使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zip的用法示例。


在下文中一共展示了Zip::Extract方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: extract

 public function extract($zip_file)
 {
     $posts = array();
     if (!$zip_file) {
         return $posts;
     }
     $z = new Zip();
     $result = $z->Extract($zip_file, ".");
     if (!$result) {
         $posts;
     }
     foreach ($result as $key => $value) {
         if (!self::is_file_with_extension($key, 'xliff')) {
             continue;
         }
         $xliff = self::get_xliff($value);
         $translation_item = self::get_translation_item($xliff->children());
         if (!self::is_valid($translation_item)) {
             continue;
         }
         $post = get_post($translation_item['id']);
         if (!$post) {
             continue;
         }
         if ($post->post_title != $translation_item['title']) {
             $post->post_title = $translation_item['title'];
         }
         if ($post->post_content != $translation_item['content']) {
             $post->post_content = $translation_item['content'];
         }
         array_push($posts, $post);
     }
     return $posts;
 }
开发者ID:JonZiemlich,项目名称:wpml2mlp,代码行数:34,代码来源:Wpml2mlp_Xliff_Extractor.php

示例2: confirmUninstall

            $file = $superCage->files->getRaw('plugin');
            $info = pathinfo($file['name']);
            if (strtolower($info['extension'] != 'zip')) {
                cpg_die(CRITICAL_ERROR, $lang_pluginmgr_php['not_plugin_package'], __FILE__, __LINE__);
            }
            if (!is_dir('./plugins/receive')) {
                $mask = umask(0);
                mkdir('./plugins/receive', 0777);
                umask($mask);
            }
            if (!move_uploaded_file($superCage->files->getRaw('plugin/tmp_name'), './plugins/receive/' . $file['name'])) {
                cpg_die(CRITICAL_ERROR, $lang_pluginmgr_php['copy_error'], __FILE__, __LINE__);
            }
            require_once './include/zip.lib.php';
            $zip = new Zip();
            $zip->Extract('./plugins/receive/' . $file['name'], './plugins', array(-1));
            unlink('./plugins/receive/' . $file['name']);
        }
        break;
}
pageheader($lang_pluginmgr_php['pmgr']);
if (isset($lang_pluginmgr_php['confirm_version']) != TRUE) {
    $lang_pluginmgr_php['confirm_version'] = 'Could not determine the version requirements for this plugin. This is usually an indicator that the plugin was not designed for your version of coppermine and might therefore crash your gallery. Continue anway (not recommended)?';
}
echo <<<EOT

<script language="javascript" type="text/javascript">
function confirmUninstall(text)
{
    return confirm("{$lang_pluginmgr_php['confirm_uninstall']} (" + text + ")");
}
开发者ID:JoseCOCA,项目名称:baudprint,代码行数:31,代码来源:pluginmgr.php

示例3: start_unzip

function start_unzip($tmp_name, $new_name, $todir = 'zipfile')
{
    $z = new Zip();
    $have_zip_file = 0;
    $upfile = array("tmp_name" => $tmp_name, "name" => $new_name);
    if (is_file($upfile[tmp_name])) {
        $have_zip_file = 1;
        echo "<br>正在解压: {$upfile['name']}<br><br>";
        if (preg_match('/\\.zip$/mis', $upfile[name])) {
            $result = $z->Extract($upfile[tmp_name], $todir);
            if ($result == -1) {
                echo "<br>文件 {$upfile['name']} 错误.<br>";
            }
            echo "<br>完成,共建立 {$z->total_folders} 个目录,{$z->total_files} 个文件.<br><br><br>";
        } else {
            echo "<br>{$upfile['name']} 不是 zip 文件.<br><br>";
        }
        if (realpath($upfile[name]) != realpath($upfile[tmp_name])) {
            @unlink($upfile[name]);
            rename($upfile[tmp_name], $upfile[name]);
        }
    }
}
开发者ID:yulb2020,项目名称:webshellSample,代码行数:23,代码来源:29c607c65dee7ee1e35497b59757a091.php

示例4: ExactFile

function ExactFile($fileName)
{
    global $dir, $key;
    echo "<font color=green size=1>ÒÔÏÂΪÎļþµÄ¸´Öƽø¶È£¬±àºÅ´ú±íÎļþ¸´ÖƵĸöÊý(µÚÒ»²½/×ÜÈý²½)£º</font><BR>";
    $zip = new Zip();
    $zipfile = $dir . "/" . $fileName;
    $array = $zip->get_list($zipfile);
    $count = count($array);
    $f = 0;
    $d = 0;
    for ($i = 0; $i < $count; $i++) {
        if ($array[$i][folder] == 0) {
            if ($zip->Extract($zipfile, $key, $i) > 0) {
                $f++;
            }
        } else {
            $d++;
        }
        if ($i % 15 == 0 && $i > 1) {
            $br = "<BR>";
        } else {
            $br = '¡¡¡¡';
        }
        print "<font color=green size=1>" . $i . $br . "</font>";
    }
    if ($i == $f + $d) {
        echo "<BR><font color=green size=1>{$fileName} ½âѹ³É¹¦<br>({$f} ¸öÎļþ {$d} ¸öĿ¼)</font><BR>";
    } elseif ($f == 0) {
        echo "<BR><font color=red size=1>{$fileName} ½âѹʧ°Ü</font><BR>";
    } else {
        echo "<BR><font color=orange size=1>{$fileName} δ½âѹÍêÕû<br>(Òѽâѹ {$f} ¸öÎļþ {$d} ¸öĿ¼)</font><BR>";
    }
    //echo "<META HTTP-EQUIV=REFRESH CONTENT='0;URL=?action=setting&RemoteHostName=".$_GET['RemoteHostName']."'>\n";
    //È·¶¨¸üмǼ######################################################
    $goalfile = $fileName . ".txt";
    if (is_file($goalfile)) {
        unlink($goalfile);
    }
    $string = "±¾¸üаüÒѾ­¸üÐÂ";
    @(!($handle = fopen($goalfile, 'w')));
    if (!fwrite($handle, $string)) {
        exit;
    }
    fclose($handle);
    print "<BR><font color=orange size=1>{$string}</font>";
}
开发者ID:shesai0519,项目名称:sunshineCRM,代码行数:46,代码来源:updatezip.php

示例5: upfile

 }
 $array[path] = $webdb[updir] . "/";
 $array[size] = is_array($postfile) ? $_FILES[postfile][size] : $postfile_size;
 /*
 if(($array[size]+$lfjdb[usespace])>($webdb[totalSpace]*1048576+$groupdb[totalspace]*1048576+$lfjdb[totalspace]))
 {
 	showerr("你的空间不足,上传失败,<A HREF='?uid=$lfjuid'>点击查看你的空间容量信息</A>");
 }
 
 $array[updateTable]=1;	//统计用户上传的文件占用空间大小
 */
 $filename = upfile(is_array($postfile) ? $_FILES[postfile][tmp_name] : $postfile, $array);
 rename(ROOT_PATH . "{$webdb['updir']}/{$filename}", dirname(ROOT_PATH . $postdb[filepath]) . "/{$filename}");
 require_once ROOT_PATH . "inc/class.z.php";
 $z = new Zip();
 $z->Extract(dirname(ROOT_PATH . $postdb[filepath]) . "/{$filename}", dirname(ROOT_PATH . $postdb[filepath]) . "/tmp");
 @unlink(dirname(ROOT_PATH . $postdb[filepath]) . "/{$filename}");
 @unlink(ROOT_PATH . $postdb[filepath]);
 //查找模板在哪个目录,有的可能是二级目录
 $ck = 0;
 $dir = opendir(dirname(ROOT_PATH . $postdb[filepath]) . "/tmp");
 while ($file = readdir($dir)) {
     if ($file == '.' || $file == '..') {
         continue;
     } elseif (eregi("(\\.htm|\\.html)\$", $file)) {
         $ck = 1;
         rename(dirname(ROOT_PATH . $postdb[filepath]) . "/tmp/{$file}", ROOT_PATH . $postdb[filepath]);
         $truedir = dirname(ROOT_PATH . $postdb[filepath]) . "/tmp/";
     } elseif (eregi("(\\.php|\\.php3|\\.asp|\\.aspx)\$", $file)) {
         unlink(dirname(ROOT_PATH . $postdb[filepath]) . "/tmp/{$file}");
     }
开发者ID:xubo245,项目名称:liuyangzhang,代码行数:31,代码来源:admin.php

示例6: ExactFile

function ExactFile($fileName, $dir)
{
    $zip = new Zip();
    $zipfile = $dir . "/" . $fileName;
    $key = $dir . "/";
    $array = $zip->get_list($zipfile);
    //print_R($array);
    $count = count($array);
    $f = 0;
    $d = 0;
    for ($i = 0; $i < $count; $i++) {
        if ($array[$i][folder] == 0) {
            if ($zip->Extract($zipfile, $key, $i) > 0) {
                $f++;
            }
            print $zipfile;
        } else {
            $d++;
        }
        if ($i % 15 == 0 && $i > 1) {
            $br = $stored_filename . "<BR>";
        } else {
            $br = $stored_filename;
        }
        //print "<font color=green size=1>".$i.$br."</font>";
    }
    if ($i == $f + $d) {
        //echo "<BR><font color=green size=1>$fileName ½âѹ³É¹¦<br>($f ¸öÎļþ $d ¸öĿ¼)</font><BR>";
    } elseif ($f == 0) {
        //echo "<BR><font color=red size=1>$fileName ½âѹʧ°Ü</font><BR>";
    }
    //else echo "<BR><font color=orange size=1>$fileName δ½âѹÍêÕû<br>(Òѽâѹ $f ¸öÎļþ $d ¸öĿ¼)</font><BR>";
    //echo "<META HTTP-EQUIV=REFRESH CONTENT='0;URL=?action=setting&RemoteHostName=".$_GET['RemoteHostName']."'>\n";
    //È·¶¨¸üмǼ######################################################
    /*
    $goalfile = $dir."/".$fileName.".txt";
    if(is_file($goalfile))	{
    unlink($goalfile);
    }
    $string ="±¾¸üаüÒѾ­¸üÐÂ";
    @!$handle = fopen($goalfile, 'w');
    if (!fwrite($handle, $string)) {
    exit;
    }
    fclose($handle);
    print "<BR><font color=orange size=1>$string</font>";
    */
}
开发者ID:shesai0519,项目名称:sunshineCRM,代码行数:48,代码来源:lib.zip.inc.php

示例7: unpackzip

function unpackzip($filename, $key, $indexes = -1, $cover = 0, &$info)
{
    global $user;
    if (!file_exists($filename)) {
        return false;
    }
    $all = true;
    if ($indexes != -1) {
        $indexes = "|||" . $indexes . "|||";
    }
    if ($info != -1) {
        $info = array("cover" => array(), "dir" => 0, "folders" => array(), "file" => 0, "size" => 0, "orig_size" => 0, "error" => array());
    }
    include_once "class/zip.class.php";
    $zip = new Zip();
    $all = $l = $zip->get_list($filename);
    foreach ($l as $file) {
        if ($indexes != -1 && !strpos($indexes, "|" . $file["index"] . "|")) {
            continue;
        }
        $ftype = getext($file["filename"]);
        if ($user["limit"]["{$ftype}"] && !$user["only"]) {
            continue;
        } else {
            if (!$user["limit"]["{$ftype}"] && $user["only"]) {
                continue;
            }
        }
        $path = $key . "/" . $file["filename"];
        if ($file["folder"]) {
            if (!is_dir($path)) {
                @mkdir($path, 0777);
            } else {
                if ($info != -1) {
                    $info["folders"][] = $path;
                }
            }
            if ($info != -1) {
                $info["dir"]++;
            }
        } else {
            if (file_exists($path)) {
                if ($info != -1) {
                    $info["cover"][] = array("filename" => $path, "index" => $file["index"]);
                }
                if (!$cover) {
                    continue;
                }
            }
            if ($zip->Extract($filename, $key, $file["index"])) {
                if ($info != -1) {
                    $info["orig_size"] += $file["compressed_size"];
                    $info["size"] += $file["size"];
                    $info["file"]++;
                }
            } else {
                if ($info != -1) {
                    $info["error"][] = $path;
                }
                if ($all) {
                    $all = false;
                }
            }
        }
    }
    return $all;
}
开发者ID:TopGrd,项目名称:newxb,代码行数:67,代码来源:func.php

示例8: elseif

            }
        }
    }
} elseif ($downrar) {
    if (!empty($dl)) {
        if (eregi("unzipto:", $localfile)) {
            $path = "" . $dir . "/" . str_replace("unzipto:", "", $localfile) . "";
            $zip = new Zip();
            $zipfile = $dir . "/" . $dl[0];
            $array = $zip->get_list($zipfile);
            $count = count($array);
            $f = 0;
            $d = 0;
            for ($i = 0; $i < $count; $i++) {
                if ($array[$i][folder] == 0) {
                    if ($zip->Extract($zipfile, $path, $i) > 0) {
                        $f++;
                    }
                } else {
                    $d++;
                }
            }
            if ($i == $f + $d) {
                echo "{$dl['0']} 解压到" . $path . "成功<br>({$f} 个文件 {$d} 个目录)";
            } elseif ($f == 0) {
                echo "{$dl['0']} 解压到" . $path . "失败";
            } else {
                echo "{$dl['0']} 未解压完整<br>(已解压 {$f} 个文件 {$d} 个目录)";
            }
        } else {
            $zipfile = "";
开发者ID:akin520,项目名称:autosetup1,代码行数:31,代码来源:mm.php


注:本文中的Zip::Extract方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。