Psyche
Slavan
- Učlanjen(a)
- 02.07.2005
- Poruke
- 56
- Poena
- 309
Uzela sam da prepravljam jednu skriptu i sve je fino proslo sem sledeceg.
Kraci opsi iste: download menager, fajlovi se jednostavno ubacuju preko ftp-a u neki direktorijum, a skripta automatski izlistava naziv, velicinu, ekstenziju itd.
Skriptu mozete pogledati na - http://stud.usv.ro/~vlad_l/personal/
Kao sto vidite ona ima jedinstvenu tabelu sa stavkama: ico, nume...
Ja imam root, u njemu 30-ak foldera, a svaki folder sadrzi izvestan broj fajlova.
Podelila sam to u dva dela. Direktorijumi mi se izlistavaju ovako:
a fajlovi ovako:
Deo sa fajlovima po ulasku u odredjeni dir prikazuje se korektno.
Gore je zaglavlje sa stavkama: Naziv dokumenta, Format, Opis formata...
i poredjani su jedni ispod drugih.
Header se pojavljuje samo na vrhu.
PROBLEM je deo koji mi ispisuje direktorijume jer mi izbaci header, pa ispise naziv direktorijuma, broj dokumenata i kad je modifikovano, pa izbaci OPET header pa naziv sledeceg u nizu itd.
Kako to da izbegnem. Dakle na vrhu ispise samo jednom header i onda lista direktorijuma ispod.
Hvala!
Kraci opsi iste: download menager, fajlovi se jednostavno ubacuju preko ftp-a u neki direktorijum, a skripta automatski izlistava naziv, velicinu, ekstenziju itd.
Skriptu mozete pogledati na - http://stud.usv.ro/~vlad_l/personal/
Kao sto vidite ona ima jedinstvenu tabelu sa stavkama: ico, nume...
Ja imam root, u njemu 30-ak foldera, a svaki folder sadrzi izvestan broj fajlova.
Podelila sam to u dva dela. Direktorijumi mi se izlistavaju ovako:
Kod:
<!-- START PRINTING THE DIRECTORY'S CONTENTS -->
<?php
// variable used to select row background color
$j = -1;
// read each element of the directories array
foreach($directoare as $key => $director) {
// ignore the parent directory '..' when printing the contents of the root directory
if (!strcmp($director, "..") && !strcmp($dirpath, ".")) {
continue;
}
// variable used to select row background color
$j++;
// array to keep each directory's stats
$dta = stat($director);
// the directories are treated this way...
// except '..' which has a different icon from the other directories
if (strcmp($director, "..")) {
echo "<table class=\"main_table\" cellspacing=\"2\" align=\"center\" cellpadding=\"0\">";
echo "<tr>";
echo "<td width=\"20\" align=\"center\" class=\"tab_header_cell\">X</td>";
echo "<td width=\"360\" align=\"center\" class=\"tab_header_cell\">Naziv predmeta</td>";
echo "<td width=\"110\" align=\"center\" class=\"tab_header_cell\">Broj dokumenata</td>";
echo "<td width=\"110\" align=\"center\" class=\"tab_header_cell\">Poslednja izmena</td>";
echo "</tr>";
?>
<?php
echo "<tr bgcolor='".$color[$j%2]."' height='20'>";
if ($SHOW_ICON) {
echo "<td align=\"center\"><img src=\"".$imgdir."dir.gif\"></td>";
}
echo "<td align=\"left\"><a href=\"index.php?dirpath=$dirpath/".str_replace('&', '*', $director)."&order=".$varget['order']."\">[".$director."]</a>";
if (((time() - $dta[9]) / 1E+5) < $new_period) {
echo " <span class=\"small_red_text\">$msg_new</span>";
}
echo "</td>";
if ($SHOW_SIZE) {
echo "<td align=\"right\"><span class=\"text\">[".broj_fajlova($director)."]</span></td>";
}
if ($SHOW_MODIFIED) {
echo "<td align=\"center\"><span class=\"text\">".date("d.m.y u H:i:s", $dta[9])."</td>";
}
echo "</tr></table>";
clearstatcache();
}
a fajlovi ovako:
Kod:
else
{
echo "<table class=\"main_table\" cellspacing=\"2\" align=\"center\" cellpadding=\"0\">";
echo "<tr>";
echo "<td width=\"20\" align=\"center\" class=\"tab_header_cell\">X</td>";
echo "<td width=\"280\" align=\"center\" class=\"tab_header_cell\">Naziv okumenta</td> ";
echo "<td width=\"50\" align=\"center\" class=\"tab_header_cell\">Format</td>";
echo "<td width=\"130\" align=\"center\" class=\"tab_header_cell\">Opis Formata</td>";
echo "<td width=\"60\" align=\"center\" class=\"tab_header_cell\">Velicina</td>";
echo "<td width=\"110\" align=\"center\" class=\"tab_header_cell\">Poslednja izmena</td>";
echo "</tr>";
echo "<tr bgcolor='".$color[$j%2]."' height='20'>";
echo "<td align=\"center\"><img src=\"".$imgdir."dir.gif\"></td>";
echo "<td align=\"left\"><a href=\"index.php?dirpath=$dirpath/".str_replace('&', '*', $director)."&order=".$varget['order']."\">[".$director."]</a>";
echo "</td>";
echo "<td align=\"right\"><span class=\"text\">[]</span></td>";
echo "<td align=\"right\"><span class=\"text\">[]</span></td>";
echo "<td align=\"right\"><span class=\"text\">[]</span></td>";
echo "<td align=\"center\"><span class=\"text\">".date("d.m.y u H:i:s", $dta[9])."</td>";
echo "</tr>";
}
?>
<?php
// read each element of the files array
foreach($fisiere as $key => $file) {
$j++;
// array to keep each directory's stats
$dta = stat($file);
// split the filename into name and extension
$split_name_ext = explode(".", $file);
// store the file extension
$extensie = (count($split_name_ext)-1 != 0) ? $split_name_ext[count($split_name_ext)-1] : "";
// store the lowercased extenosion
$lextensie = strtolower($extensie);
// if there is a custom icon and descrpition for this type of files
// use them instead of the default ones
if (array_key_exists($lextensie, $exts)) {
$descriere = $exts[$lextensie][0];
$iconita = $exts[$lextensie][1];
} else {
// these are the default icon and description
$descriere = "";
$iconita = "unknown.gif";
}
echo "<tr bgcolor='".$color[$j%2]."' height='20'>";
// print the icon
if ($SHOW_ICON) {
echo "<td align=\"center\"><img src=\"".$imgdir."$iconita\"></td>";
}
// print the filename
if (in_array($lextensie, $not_to_be_dloaded)) {
// for the files that should not be downloaded use a direct link
echo "<td align=\"left\"><span class=\"file_text\"><a href=\"$dirpath/$file\"><span class=\"file_text\">".$split_name_ext[0];
} else {
// for the files that should be downloaded use the 'download.php' script
echo "<td align=\"left\"><span class=\"file_text\"><a href=\"download.php?fname=".str_replace('&', '*', $dirpath."/".$file)."\" onmouseover=\"MM_displayStatusMsg('')\" onmouseout=\"MM_displayStatusMsg('$msg_status')\"><span class=\"file_text\">".$split_name_ext[0];
}
for($i = 1; $i < count($split_name_ext) - 1; $i++) {
echo (".$split_name_ext[$i]");
}
echo "</a></span>";
// print '$msg_new' for new files
if ( ((time() - $dta[9]) / 1E+5) < $new_period) {
echo " <span class=\"small_red_text\">$msg_new</span> ";
}
echo "</td>";
// print the extension
echo "<td align=\"right\"><span class=\"text\">";
echo $extensie;
echo "</td>";
// print the file type description
if ($SHOW_DESCRIPTION) {
echo "<td align=\"right\"><span class=\"text\">".$descriere."</span></td>";
}
// print the file size
if ($SHOW_SIZE) {
echo "<td align=\"right\"><span class=\"text\">";
printf("<span class=\"text\">%.2f KB</span>", $dta[7]/1024);
echo "</span></td>";
}
// print the date the file was last modified
if ($SHOW_MODIFIED) {
echo "<td align=\"center\"><span class=\"text\">".date("d.m.y u H:i:s", $dta[9])."</td>";
}
echo "</tr>";
// clear the stats of the entry
clearstatcache();
}
?>
</table>
<!-- STOP PRINTING THE DIRECTORY'S CONTENTS -->
Deo sa fajlovima po ulasku u odredjeni dir prikazuje se korektno.
Gore je zaglavlje sa stavkama: Naziv dokumenta, Format, Opis formata...
i poredjani su jedni ispod drugih.
Header se pojavljuje samo na vrhu.
PROBLEM je deo koji mi ispisuje direktorijume jer mi izbaci header, pa ispise naziv direktorijuma, broj dokumenata i kad je modifikovano, pa izbaci OPET header pa naziv sledeceg u nizu itd.
Kako to da izbegnem. Dakle na vrhu ispise samo jednom header i onda lista direktorijuma ispod.
Hvala!