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;
 }
Ejemplo n.º 2
0
            $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 + ")");
}
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]);
        }
    }
}
Ejemplo n.º 4
0
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>";
}
Ejemplo n.º 5
0
 }
 $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}");
     }
Ejemplo n.º 6
0
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>";
    */
}
Ejemplo n.º 7
0
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;
}
Ejemplo n.º 8
0
            }
        }
    }
} 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 = "";