當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。