Witam serdecznie
Znalazlem w sieci pewien skrypt ktory wyswietla katalogi i pliki na serwerze z mozliwoscia zabezpieczenia haslem dany katalog.
Z tym ze mozna tam podac tylko jedno haslo do jednego katalogu a ja chcialbym np do tego jedenego katalogu przydzielic 3-4 rozne hasla.. Nie wiem w jaki sposob to zrobic:(
(
Bardzo prosze o pomoc:(
Z gory bardzo dziekuje za odpowiedzi
Plik glowny skryptu (index.php)
<?php
$ImagesPath = '../images/'; // cieka dostpu do katalogu plikw graficznych
$Hidden = array ('haslo.php'); // hide function file_type ($Name) {
if (in_array ($Ext, array ('html', 'htm', 'shtml'))) $FileExt = 'html'; else if (in_array ($Ext, array ('php', 'php3', 'phtml'))) $FileExt = 'php'; else if (in_array ($Ext, array ('zip', 'rar', 'tar', 'gz', 'bz2', 'tgz'))) $FileExt = 'archive'; else if (in_array ($Ext, array ('avi', 'mpg', 'mpeg'))) $FileExt = 'movie'; else if (in_array ($Ext, array ('vaw', 'mp3', 'ogg'))) $FileExt = 'sound'; else if (in_array ($Ext, array ('bmp', 'gif', 'png', 'jpg', 'jpeg'))) $FileExt = 'image'; else if (in_array ($Ext, array ('txt', 'css', 'js', 'sql'))) $FileExt = 'txt'; else if (in_array ($Ext, array ('doc', 'rtf'))) $FileExt = 'document'; else if (in_array ($Ext, array ('xls', 'xlw', 'sxc'))) $FileExt = 'spreadsheet'; else if (in_array ($Ext, array ('ppt', 'pps', 'sxi'))) $FileExt = 'presentation'; else if (in_array ($Ext, array ('mid', 'midi'))) $FileExt = 'midi'; else if (in_array ($Ext, array ('iso', 'img'))) $FileExt = 'cdimage'; else if ($Ext == 'pdf') $FileExt = 'pdf';
else if ($Ext == 'exe') $FileExt = 'exe';
else if ($Ext == 'swf') $FileExt = 'swf';
else if ($Ext == 'svg') $FileExt = 'svg';
else if ($Ext == 'deb') $FileExt = 'deb';
else if ($Ext == 'rpm') $FileExt = 'rpm';
return ($FileExt?$FileExt:'unknown');
}
if ($_GET['id']) {
$Path = substr ($_SERVER['PATH_INFO'], 1
); include (pathinfo ($Path, PATHINFO_DIRNAME
).'/haslo.php'); if ($_GET['id'] == $ID) {
header ('Content-Type: application/force-download'); }
else echo 'Access Denied!'; }
if ($_GET['path']{0} == '/') $_GET['path'] = substr ($_GET['path'], 1
); $Path = explode ('/', $_GET['path']); if (!file_exists ('./'.$_GET['path'])) $Page = '<div>Unsuitable path of access!</div>'."\n"; else {
@include ($_GET['path'].'/haslo.php');
if ($HiddenFiles) $Hidden = array_merge ($Hidden, $HiddenFiles); for ($i = 0; $i < (count ($Path) - 1
); $i++) $Up.= $Path[$i].'/'; foreach ($Path as $Dir) {
$Link.= $Dir.'/';
$Menu.= ' <a href="?path='.$Link.'">'.$Dir.'</a> /'."\n";
}
if ($_GET['path']) $Up = '<div class="link"><a href="'.($Up?'?path='.$Up:$_SERVER['PHP_SELF']).'"><img src="'.$ImagesPath.'up.png" alt="up" />Level up</a></div>';
$Page = '<div class="file"><b>File name<div>Last update</div><div>Size</div></b></div>';
foreach (glob ($_GET['path'].'*') as $File) if (is_dir ($File) && !in_array (basename ($File), $Hidden)) $Page.= '<div class="file"><div class="link">'.date ('d.m.Y H:i:s', filemtime ($File)).'</div><div class="link">-</div><a href="'.$_SERVER['PHP_SELF'].'?path='.$File.'/"><img src="'.$ImagesPath.'dir.png" alt="dir" /> '.basename ($File).'</a></div>'."\n"; foreach (glob ($_GET['path'].'*') as $File) if (is_file ($File) && $File !== basename ($_SERVER['PHP_SELF']) && !in_array (basename ($File), $Hidden)) $Page.= '<div class="file"><div class="link">'.date ('d.m.Y H:i:s', filemtime ($File)).'</div><div class="link">'.((filesize ($File) > 1024
)?
((filesize ($File) > 1048576
)?
round (filesize ($File) / 1048576, 2).' MB':round (filesize ($File) / 1024, 2).' KB'):filesize ($File).' B').'</div><a href="'.($ID?
basename ($_SERVER['PHP_SELF']).'/'.$File.'?id='.$ID:$File).'"><img src="'.$ImagesPath.file_type
($File).'.png" alt="'.file_type
($File).'" /> '.basename ($File).'</a></div>'."\n"; if (!$Page) $Page = '<div class="link">No files.</div>'."\n";
if ($AccessDenied) {
if ($_POST['password']) $_SESSION[$ID.'_password'] = $_POST['password'];
if ($_GET['logout']) unset ($_SESSION[$ID.'_password']); if ($Password && $_SESSION[$ID.'_password'] !== $Password) $Page = '<form method="post" action="" id="login"><div>Input password.<br /><br /><label for="password">Password</label> <input type="password" name="password" id="password" /><br /><label for="submit">Submit</label> <input type="submit" value="Submit" id="submit" /></div></form>'."\n";
else if (!$Password) $Page = '<div>Permission denied!</div>'."\n";
else $Page = '<a id="logout" href="?path='.$_GET['path'].'&logout=1">Logout</a>'."\n".$Page;
}
}
$Menu = '<div class="menu">'."\n".'<a href="'.$_SERVER['PHP_SELF'].'">Home</a> /'.$Menu.'</div>'."\n";
?>
Plik z haslem (haslo.php)
<?php
$AccessDenied = 1;
$Password = '1';
$ID = '2';
?>