本文整理汇总了PHP中Archive_Tar::ListContent方法的典型用法代码示例。如果您正苦于以下问题:PHP Archive_Tar::ListContent方法的具体用法?PHP Archive_Tar::ListContent怎么用?PHP Archive_Tar::ListContent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Archive_Tar
的用法示例。
在下文中一共展示了Archive_Tar::ListContent方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: install
static function install($source, $filename)
{
$target = SIMPLE_EXT . substr($filename, 0, -3);
setup::out("{t}Download{/t}: " . $source . " ...");
if ($fz = gzopen($source, "r") and $fp = fopen($target, "w")) {
$i = 0;
while (!gzeof($fz)) {
$i++;
setup::out(".", false);
if ($i % 160 == 0) {
setup::out();
}
fwrite($fp, gzread($fz, 16384));
}
gzclose($fz);
fclose($fp);
} else {
sys_die("{t}Error{/t}: gzopen [2] " . $source);
}
setup::out();
if (!file_exists($target) or filesize($target) == 0 or filesize($target) % 10240 != 0) {
sys_die("{t}Error{/t}: file-check [3] Filesize: " . filesize($target) . " " . $target);
}
setup::out(sprintf("{t}Processing %s ...{/t}", basename($target)));
$tar_object = new Archive_Tar($target);
$tar_object->setErrorHandling(PEAR_ERROR_PRINT);
$tar_object->extract(SIMPLE_EXT);
$file_list = $tar_object->ListContent();
if (!is_array($file_list) or !isset($file_list[0]["filename"]) or !is_dir(SIMPLE_EXT . $file_list[0]["filename"])) {
sys_die("{t}Error{/t}: tar [4] " . $target);
}
self::update_modules_list();
$ext_folder = db_select_value("simple_sys_tree", "id", "anchor=@anchor@", array("anchor" => "extensions"));
foreach ($file_list as $file) {
sys_chmod(SIMPLE_EXT . $file["filename"]);
setup::out(sprintf("{t}Processing %s ...{/t}", SIMPLE_EXT . $file["filename"]));
if (basename($file["filename"]) == "install.php") {
setup::out("");
require SIMPLE_EXT . $file["filename"];
setup::out("");
}
if (basename($file["filename"]) == "readme.txt") {
$data = file_get_contents(SIMPLE_EXT . $file["filename"]);
setup::out(nl2br("\n" . q($data) . "\n"));
}
if (!empty($ext_folder) and basename($file["filename"]) == "folders.xml") {
setup::out(sprintf("{t}Processing %s ...{/t}", "folder structure"));
folders::create_default_folders(SIMPLE_EXT . $file["filename"], $ext_folder, false);
}
}
}
示例2: extract
static function extract($target, $folder)
{
setup::out(sprintf("{t}Processing %s ...{/t}", basename($target)));
$tar_object = new Archive_Tar($target);
$tar_object->setErrorHandling(PEAR_ERROR_PRINT);
$tar_object->extract($folder);
$file_list = $tar_object->ListContent();
if (!is_array($file_list) or !isset($file_list[0]["filename"]) or !is_dir($folder . $file_list[0]["filename"])) {
sys_die("{t}Error{/t}: tar [3] " . $target);
}
foreach ($file_list as $file) {
sys_chmod($folder . $file["filename"]);
}
@unlink($target);
return $folder . $file_list[0]["filename"];
}
示例3: ExtractPackage
public static function ExtractPackage($p_uploaded_package, &$p_log = null)
{
$plugin_name = false;
require_once 'Archive/Tar.php';
$tar = new Archive_Tar($p_uploaded_package);
if (($file_list = $tar->ListContent()) == 0) {
$p_log = getGS('The uploaded file format is unsupported.');
return false;
} else {
foreach ($file_list as $v) {
if (preg_match('/[^\\/]+\\/([^.]+)\\.info\\.php/', $v['filename'], $matches)) {
$plugin_name = $matches[1];
}
#$p_log .= sprintf("Name: %s Size: %d modtime: %s mode: %s<br>", $v['filename'], $v['size'], $v['mtime'], $v['mode']);
}
}
if ($plugin_name === false) {
$p_log = getGS('The uploaded archive does not contain an valid newscoop plugin.');
return false;
}
$tar->extract(CS_PATH_PLUGINS);
self::ClearPluginsInfo();
CampPlugin::GetPluginsInfo(false, true);
}