Her alt dizin için bir indirme fonksiyonu ile otomatik Directory Lister yapmaya çalışıyorum. Ben daha kolay indirmek için izin vermek ve sunucuda daha az bant genişliği kullanmak gibi. Zip dosyaları bu altdizinler kullanılabilir hale getirmek istiyorum.
Ben pclzip.lib eklenmiş ve bir zip dosyası oluşturmak için çalıştı kadar aşağıdaki komut cezası çalışıyordu.
<html>
<head>
<?php require_once("pclzip.lib.php");?>
<?php require_once("filesize_lib.php"); ?>
<style type="text/css">
.readme{
width:500px;
height:150px;
background: silver;
overflow-x: hidden;
overflow-y: scroll;
}
</style>
</head>
<body>
<?php
$readme = "/readme.txt";
$download = "downloads";
// Openen
$dir = new DirectoryIterator('.');
// Doorlopen
?>
<table width="960px" border="1px"><tr><td width="185px"><strong>Name</strong></td><td width="50px"><strong>Type</strong></td><td width="50px"><strong>Size</strong></td><td width="125px"><strong>Last Modified</strong></td><td><strong>Short description</strong></td><td width="50px"><strong>Download</strong></td></tr>
<?php
foreach ($dir as $file)
{
if (! $file->isDot()
&& $file != ".."
&& $file != "index.php"
&& $file != "filesize_lib.php"
&& $file != "downloads"
)
{ ?><tr><td><?php
echo '<a href="'.$file.'">'.$file.'</a>';
?></td><td><?php
echo filetype($file);
?></td><td><?php
echo fileORdirSize($file).'<br/>';
?></td><td><?php
echo date("M j, Y", filemtime($file));
?></td><?php
if (filetype($file) == "dir"){
?>
<td><div class="readme"><?php
echo file_get_contents($file.$readme);
?></div></td><?php
} else {
?><td>Files don't have descriptions, but can be tested directly from this page.</td><?php
}
?><td><?php
$zip = new PclZip("tmp/archief.zip");
if($zip->create($file) == 0)
die("Error : " . $zip->errorInfo(true));
echo '<a href="'.$zip.'">'.$zip.'</a>';
?></td></tr><?php
}
}
?>
</table>
</body>
</html>
Ben alıyorum hata şudur:
Invalid variable type p_filelist [code -3]
Ben bir dizi tek bir değişken pclzip.lib besleme değilim ve bu gerçeği nedeniyle olduğuna inanıyorum. Ne yazık ki, bu sorunu çözmek için nasıl bilmiyorum. Aşağıdaki (bana göre) sorunu için sorumlu kod parçası bakın:
<?php // ----- Init
$v_string_list = array();
$v_att_list = array();
$v_filedescr_list = array();
$p_result_list = array();
// ----- Look if the $p_filelist is really an array
if (is_array($p_filelist)) {
// ----- Look if the first element is also an array
// This will mean that this is a file description entry
if (isset($p_filelist[0]) && is_array($p_filelist[0])) {
$v_att_list = $p_filelist;
}
// ----- The list is a list of string names
else {
$v_string_list = $p_filelist;
}
}
// ----- Look if the $p_filelist is a string
else if (is_string($p_filelist)) {
// ----- Create a list from the string
$v_string_list = explode(PCLZIP_SEPARATOR, $p_filelist);
}
// ----- Invalid variable type for $p_filelist
else {
PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type p_filelist");
return 0;
}?>