Autor Zpráva
Jirka_koffee
Profil *
Z nějakýho duvodu mi nefunguje výpis adresáru na serveru.. Doma na localhoste to jde ok, ale jakmile to nahraju na web (banan,profitux), tak to čte jen soubory... mohl by mi nekdo poradit, prosím?



<?php
$homedir = ".";

if(!isset($_GET['item'])) {
$path = "$homedir";
$dh = opendir("$homedir");
echo "\n<p>\n";
while (($dir = readdir($dh)) != false) {
if ($dir == "css" || $dir == "doplnky" || $dir == "Thumbs.db" || $dir == "info.txt" || $dir == "index.php" || $dir=="." || $dir=="..") continue;
$file = @fopen("$path/$dir", "r");
if (!$file){
$nicedir = ereg_replace("_"," ",$dir);
print " <img src=\"doplnky/slozka.png\"> <a href='index.php?item=$dir'>$nicedir</a><br>\n";
}

}
closedir($dh);

echo "\n</p>\n";
$path = "$homedir";
$dh = opendir($path);
echo "\n<p>\n<table>\n";
while (($dir = readdir($dh)) != false) {
if ($dir == "Thumbs.db" || $dir == "reg.php" || $dir == "info.txt" || $dir == "index.php" || $dir=="." || $dir=="..") continue;
if ( $dir != "." && $dir != ".." ){
$file = @fopen("$path/$dir", "r");
if ($file){
$kB = number_format(filesize("$path/$dir")/1000,1,',','')." kB ";
if($kB >= 1000) {$kB = number_format(filesize("$path/$dir")/1000000,1,',','')." MB ";}
$datum_vytvoreni = StrFTime("%d/%m/%Y %H:%M", filectime("$path/$dir"));
$file=explode(".", basename("$dir"));
if (isset($file[1])) {$typ = "<tr><td><img src=\"doplnky/$file[1].png\">";$hezke = ereg_replace("_"," ",$file[0]);echo "$typ <a href=\"$path/$dir\">$hezke</a></td> <td class=\"velikost\">$kB </td> <td class=\"datum\">$datum_vytvoreni</td></tr>\n";}
}
}
}
closedir($dh);
echo "\n</table>\n</p>\n";
}

else

{$path = "$homedir/$_GET[item]";
$dh = opendir($path);
echo "\n<p>\n";
while (($dir = readdir($dh)) !== false) {
if ($dir == "Thumbs.db" || $dir == "reg.php" || $dir == "info.txt" || $dir == "index.php" || $dir=="." || $dir=="..") continue;
if ( $dir != "." && $dir != ".." ){
$file = @fopen("$path/$dir", "r");
if (!$file){
$nicedir = ereg_replace("_"," ",$dir);
print " <img src=\"doplnky/slozka.png\"> <a href='index.php?item=$_GET[item]/$dir'>$nicedir</a><br>\n";
}
}
}
closedir($dh);
echo "\n</p>\n";
$path = "$homedir/$_GET[item]";
$dh = opendir($path);
echo "\n<p>\n<table>\n";
while (($dir = readdir($dh)) !== false) {
if ($dir == "Thumbs.db" || $dir == "reg.php" || $dir == "info.txt" || $dir == "index.php" || $dir=="." || $dir=="..") continue;
if ( $dir != "." && $dir != ".." ){
$file = @fopen("$path/$dir", "r");
if ($file){
$kB = number_format(filesize("$path/$dir")/1000,1,',','')." kB ";
if($kB >= 1000) {$kB = number_format(filesize("$path/$dir")/1000000,1,',','')." MB ";}
$datum_vytvoreni = StrFTime("%d/%m/%Y %H:%M", filectime("$path/$dir"));
$file=explode(".", basename("$dir"));
if (isset($file[1])) {$typ = "<tr><td><img src=\"doplnky/$file[1].png\">";$hezke = ereg_replace("_"," ",$file[0]);echo "$typ <a href=\"$path/$dir\">$hezke</a></td> <td class=\"velikost\">$kB </td> <td class=\"datum\">$datum_vytvoreni</td></tr>\n";}
}
}
}
closedir($dh);
echo "\n</table>\n</p>\n";
}

?>

joejoe
Profil *
byva dobrym zvykem snazit se vyrobit co nejmensi ukazkovy kod toho co nefunguje - clovek vetsinou najde chybu sam.

zkus tohle a napis jestli ti to funguje:
<?

$adresar = 'x';
if ($handle = opendir($adresar)) {
while (($polozka = readdir($handle)) !== false) P
echo $polozka.'<br/>';
}
closedir($handle);
}

?>

btw v tvojem kodu mas while (($polozka = readdir($handle)) != false) coz muze byt zdrojem chyby:
echo (false == 0) ? 'true' : 'false'; // vrati true
echo (false === 0) ? 'true' : 'false'; // vrati false (typove striktni porovnani)
viz manual http://cz2.php.net/manual/en/function.readdir.php

ruzne verze php se v takovemto pripade muzou chovat ruzne..
Toto téma je uzamčeno. Odpověď nelze zaslat.