"") {
if(substr($path,strlen($substr)-1)=="/") {
$path=substr($path,0,strlen($path)-1);
} else {
$path=substr($path,0,strrpos($path,"/"));
}
}
if(substr($path,strlen($path)-1)!="/" && is_dir($loc.$path) && $path<>"") $path.="/";
$fpath=$loc.$path;
$vpath="";
$dpath="";
$fname="";
$view=false;
if(is_file($fpath)) { // Preparing file preview
if(strpos($path,"/")) {
$path=substr($path,0,strrpos($path,"/")+1);
} else {
$path="";
}
$vpath=$fpath;
$fname=substr($vpath,strrpos($vpath,"/")+1);
$fpath=substr($fpath,0,strrpos($fpath,"/")+1);
$dpath=$dl.$path.$fname;
$view=true;
if(strpos($path.$fname,"secrets")==false) {
appendf($analytics,time()."\v".$path.$fname."\n");
}
}
$farr=array();
$darr=array();
if($handle=opendir($fpath)) { // List current directory
while(false!==($entry=readdir($handle))) {
if($entry!="." && $entry!="..") {
if(is_dir($fpath.$entry)) {
array_push($darr,$entry);
} else {
array_push($farr,$entry);
}
}
}
}
closedir($handle);
$items=count($darr)+count($farr);
$items.=($items>1)?" items":" item";
sort($darr);
sort($farr);
session_set_cookie_params(["SameSite" => "Strict"]); //none, lax, strict
session_set_cookie_params(["Secure" => "true"]); //false, true
session_set_cookie_params(["HttpOnly" => "true"]); //false, true
session_start(); // Visit counter
$visits=intval(readf($visitpath));
if(!$_SESSION['visited']) {
$_SESSION['visited']=true;
$visits++;
if($visits>1) writef($visitpath,$visits);
}
?>
>
" href="/" target="_self">~ ".$lpath[$i]."";
}
?>
"") $up.="/";
else $up="/";
echo "
.. \n";
$bad=array("%","!","?","&","#"," ","+");
$good=array("%25","%21","%3F","%26","%23","%20","%2B");
for($i=0;$i
$fnamelen) $cutn="...";
if($path.$darr[$i]=="stuff") $dimg="desktop.png";
if($darr[$i]!="secrets") {
echo " ".substr($darr[$i],0,$fnamelen).$cutn." \n";
}
}
for($i=0;$ifgets();
$fh=fopen($fpath.$farr[$i],'r');
$line=fread($fh,64);
fclose($fh);
switch($line) {
case (preg_match('/#!.*sh.*/',$line)?true:false): // script match
$img="script.png"; break;
case (preg_match('/[^\x00-\x7F]/',$line)?true:false): // binary match
$img="application.png"; break;
case (preg_match('/[ -~]/',$line)?true:false): // ascii match
$img="text.png"; break;
default:
$img="unknown.png";
}
}
$selected="";
$hidden="";
$cutn="";
$new="";
if(time()-filemtime($fpath.$farr[$i])<$oldafter) { $new=" new"; }
if($view) if($fname==$farr[$i]) $selected=" selected";
if(substr($farr[$i],0,1)==".") $hidden=" hid";
if(strlen($farr[$i])>$fnamelen) $cutn="...";
$target="_self";
$href="".str_replace($bad,$good,$path.$farr[$i])."#view"; // Standard local file link
/* Make *.url files open the links directly */
/*if($info['extension']=="url") { // .url file - link contained url instead
$target="_blank";
$href=str_replace("\n","",readf($fpath.$farr[$i])); // just in case the .url file contains newline
}*/
$limg="img/";
if($tmb) {
$limg="";
}
echo " ".substr($farr[$i],0,$fnamelen).$cutn." \n";
} // skip
}
?>
"") echo "
".$lpath[$i]." ";
}
$fs_get=filesize($vpath);
if($fs_get>(1024*1024*1024)) {//gb
$fs_get=round($fs_get/1024/1024/1024,1)." GB";
} else if($fs_get>(1024*1024)) {//mb
$fs_get=round($fs_get/1024/1024,1)." MB";
} else if($fs_get>(1024)) {// kb
$fs_get=round($fs_get/1024)." KB";
} else {
$fs_get=$fs_get." B";
}
echo "
".$fname." \n"
."
\n"
."
"
."".$fs_get." • "
."".number_format($fviews,0,","," ")." • "
."".$mtime." • "
." \n"
."
Download "
."
Raw "
."
Close \n"
."
\n"
."
\n"
."
\n"
."".$mtime." • "
."".number_format($fviews,0,","," ")." \n"
."
\n";
$info=pathinfo($vpath);
$bprev="";
$prev="";
switch(strtolower($info['extension'])) { // Detect best way to preview by file extension
case "png": case "jpg": case "jpeg": case "bmp": case "gif": case "ico": case "webp": case "svg":
$prev="
\n";
break;
case "wav": case "mp3": case "ogg":
$prev="
\n";
break;
case "fbx":
$prev="
";
break;
case "mp4": case "webm":
$prev="
\n";
break;
case "url":
$fc=readf($vpath);
$fctarget="_blank";
$fclnk="";
$fchref=$fc;
if(substr($fc,0,1)=="/") { // inside link
$fctarget="_self";
$fclnk="~";
$fchref="/".$root.substr($fc,1);
}
$prev="
".$fclnk.$fc." \n";
break;
case "$":
echo "
\n";
if(is_file($vpath)) include($vpath);
echo "
\n";
break;
default:
$bad=array("&","<",">");
$good=array("&","<",">");
$prev=true;
$prev=true;
if(filesize($vpath)>(1024*1024*75)) {
$prev=false;
} else {
$fc=readf($vpath);
$tmp=explode("\n",$fc);
if(preg_match('/[^\x00-\x7F]/',$tmp[0])) { // Detect binary file
$prev=false;
}
if($info['extension']=='apk' ||
$info['extension']=='dex' ||
$info['extension']=='res' ||
$info['extension']=='jar' ||
$info['extension']=='idsig') {
$prev=false;
}
}
if($prev) {
$fc=str_replace($bad,$good,$fc);
$bprev="
{} ";
$prev="
".$fc."
\n";
//$prev.="
".$fc."
\n";
} else {
$prev="
<no preview>
\n";
}
?>
\n".$prev."\n
Top \n
\n\n";
}
}
?>
";
}
?>
visits