Plz Help Me
how hide Extension and Site Name in this Script ?
Collapse
X
-
Originally posted by TheNik View PostPlz Help MePHP Code:<?
$item_v=8;
$startdir = '.';
$showdirs = true;
$forcedownloads = false;
$hide = array(
'index1.php',
'quotes.txt',
'rantex.php',
'rantax.php',
'error_log',
'index.php',
'header.php',
'footer.php',
'shortcut.php',
'new.gif',
'cgi-bin',
'.htaccess',
'ads',
'dir.png',
'image.png',
'binary.png',
'binhex.png',
'comp.png',
'compr.png',
'generic.png',
'image.png',
'java.png',
'mov.png',
'sound.png',
'movie.png',
'new.png',
'tar.png',
'text.png',
'unknown.png',
'uu.png',
'web.png',
'.htpasswd'
);
$displayindex = false;
$indexfiles = array (
'index.html',
'index.htm',
'default.htm',
'default.html'
);
$filetypes = array (
'png' => 'jpg.gif',
);
error_reporting(0);
$leadon = $startdir;
if($leadon=='.') $leadon = '';
if((substr($leadon, -1, 1)!='/') && $leadon!='') $leadon = $leadon . '/';
$startdir = $leadon;
if($_GET['dir']) {
//check this is okay.
if(substr($_GET['dir'], -1, 1)!='/') {
$_GET['dir'] = $_GET['dir'] . '/';
}
$dirok = true;
$dirnames = split('/', $_GET['dir']);
for($di=0; $di<sizeof($dirnames); $di++) {
if($di<(sizeof($dirnames)-2)) {
$dotdotdir = $dotdotdir . $dirnames[$di] . '/';
}
if($dirnames[$di] == '..') {
$dirok = false;
}
}
if(substr($_GET['dir'], 0, 1)=='/') {
$dirok = false;
}
if($dirok) {
$leadon = $leadon . $_GET['dir'];
}
}
if ($_GET['p'])
$yd=($_GET['p']*$item_v)-1;
else
{
$_GET['p']=1;
$yd=$item_v-1;
}
if($_GET['download'] && $forcedownloads)
{
$file = str_replace('/', '', $_GET['download']);
$file = str_replace('..', '',$file);
if(file_exists($leadon . $file))
{
header("Content-type: application/x-download");
header("Content-Length: ".filesize($leadon . $file));
header('Content-Disposition: attachment; filename="'.$file.'"');
readfile($leadon . $file);
die();
}
}
$opendir = $leadon;
if(!$leadon) $opendir = '.';
if(!file_exists($opendir))
{
$opendir = '.';
$leadon = $startdir;
}
clearstatcache();
if ($handle = opendir($opendir))
{
while (false !== ($file = readdir($handle)))
{
//first see if this file is required in the listing
if ($file == "." || $file == "..") continue;
$discard = false;
for($hi=0;$hi<sizeof($hide);$hi++)
{
if(strpos($file, $hide[$hi])!==false)
{
$discard = true;
}
}
if($discard) continue;
if (@filetype($leadon.$file) == "dir")
{
if(!$showdirs) continue;
$n++;
$key = @filemtime($leadon.$file) . ".$n";
$dirs[$key] = $file . "";
}
else
{
$n++;
$key = @filemtime($leadon.$file) . ".$n";
$files[$key] = $file;
if($displayindex)
{
if(in_array(strtolower($file), $indexfiles))
{
header("Location: $file");
die();
}
}
}
}
closedir($handle);
}
//sort our files
@ksort($dirs, SORT_NUMERIC);
@ksort($files, SORT_NUMERIC);
//order correctly
$files = @array_reverse($files);
$dirs = @array_reverse($dirs);
$dirs = @array_values($dirs);
$files = @array_values($files);
if ($files && $dirs)
$final=array_merge($dirs,$files);
else if($files)
$final=$files;
else if($dirs)
$final=$dirs;
else
$final=array();
?>
<?php
$breadcrumbs = split('/', $leadon);
if(($bsize = sizeof($breadcrumbs))>0)
{
$sofar = '';
for($bi=0;$bi<($bsize-1);$bi++)
{
$sofar = $sofar . $breadcrumbs[$bi] . '/';
}
}
$baseurl = $_SERVER['PHP_SELF'] . '?dir='.$_GET['dir'] . '&';
$l_v=strlen($baseurl)-5;
$baseurl_v=substr($baseurl,0,$l_v);
$baseurl_v=str_replace(" ","+",$baseurl_v);
print "";
$num=1;
$arsize = sizeof($final);
if ($arsize<=$item_v)
$flag_v=1;
$max_p=($arsize/$item_v)+1;
if (($yd+1)<$arsize)
{
$start_v=$yd-($item_v-1);
$end_v=$yd;
}
else
{
$start_v=$yd-($item_v-1);
$end_v=$arsize-1;
}
echo "<table width=100% border=0>";
for($i=$start_v; $i<=$end_v; $i++)
{
if (@filetype($leadon.$final[$i]) == "dir") //if it is a directory
{
echo "<tr>";
if ($num%2!=0) //if odd
{
?>
<td class=odd width=100%>
<li><a href="<?=$_SERVER['PHP_SELF'].'?dir='.urlencode($leadon.$final[$i]);?>"><?=$final[$i];?></a><br>
</td>
<?
}
else //if even
{
?>
<td class=even width=100%>
<li><a href="<?=$_SERVER['PHP_SELF'].'?dir='.urlencode($leadon.$final[$i]);?>"><?=$final[$i];?></a><br>
</td>
<?
}
echo "</tr>";
$num++;
}
else
{
$filename = $final[$i];
$fname_v=$filename;
if(strlen($filename)>43)
$filename = substr($final[$i], 0, 40) . '...';
$fileurl = $leadon.$final[$i];
$fileurl2=$fileurl;
$fileurl=str_replace(" ","%20",$fileurl);
$ext_v=substr($fname_v,-3);
switch ($ext_name)
{
case 'mp3': $icon_v='sound.png';
break;
case 'wav': $icon_v='sound.png';
break;
case 'ogg': $icon_v='sound.png';
break;
case 'mid': $icon_v='sound.png';
break;
case 'aac': $icon_v='sound.png';
break;
case 'amr': $icon_v='sound.png';
break;
case 'avi': $icon_v='movie.png';
break;
case '3gp': $icon_v='mov.png';
break;
case 'JPG':
case 'jpg':
case 'gif':
case 'png': $icon_v='image.png';
break;
case 'sis': $icon_v='binary.png';
break;
case 'jar': $icon_v='java.png';
break;
case 'zip': $icon_v='compr.png';
break;
case 'rar': $icon_v='compr.png';
break;
case 'txt': $icon_v='text.png';
break;
default: $icon_v='unknown.png';
}
$vk=str_replace(" ","%20",$fileurl);
$vishal=str_replace(".mp3","",$filename);
if($num%2!=0)
{
if ($icon_v=='image.png')
{
echo "<tr><td><a href=$vk><img src=$vk width=49 height=40 border=0></a></td></tr>";
$num++;
}
}
else
{
if ($icon_v=='image.png')
{
echo "<tr><td><a href=$vk><img src=$vk width=40 height=40 border=0></a></td></tr>";
$num++;
}
}
$ts=filemtime($fileurl2);
$old=date("z",$ts);
$cur=date("z");
$dif=$cur-$old;
if($num%2!=0)
{
echo "<tr><td>";
if ($dif<=3)
echo "<li><a href=$fileurl>$vishal</a>-".round(filesize($leadon.$final[$i])/1024)." KB ";
else
echo "<li><a href=$fileurl>$vishal</a>-".round(filesize($leadon.$final[$i])/1024)." KB ";
echo "</td></tr>";
}
else
{
echo "<tr><td>";
if ($dif<=3)
echo "<li><a href=$fileurl>$vishal</a>-".round(filesize($leadon.$final[$i])/1024)." KB ";
else
echo "<li><a href=$fileurl>$vishal</a>-".round(filesize($leadon.$final[$i])/1024)." KB ";
echo "</td></tr>";
}
$num++;
}
}
echo "</table>";
$file_count = count ($files);
$dir_count = count ($dirs);
print "";
$am_v="&p=";
if ($flag_v);
elseif ($_GET['p']==1)
echo "<a href=".$baseurl_v.$am_v.($_GET['p']+1)."><b>Next
»</b></a><br/>";
elseif ($_GET['p']>=$max_p)
echo "<br><a href=".$baseurl_v.$am_v.($_GET['p']-1)."><b>« Prev</b></a>";
else
{
echo "<a href=".$baseurl_v.$am_v.($_GET['p']-1)."><b>« Prev</b></a>";
echo " <a href=".$baseurl_v.$am_v.($_GET['p']+1)."><b>Next »</b></a><br>";
}
print "</left>";
?>
</body>
</html>
Comment