3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php/* */require_once 'config.php';require_once 'header.php';$dir=htmlspecialchars($_GET['dir']);if(!$dir) { $dir = $f_dir_om; }if ($dir{0} == '/' || $dir{0} == '.' || $dir{1} == '.' || $dir{1} == '/'){ echo 'Invalid url request recieved!!!'; $_errro_OMi = true;}else{function r($f,$t=0) { return strtolower(substr(strrchr($f,'.'),1)); }function translit($dir) { $dir=basename($dir); $omi_exx=explode('.', $dir); $r=$omi_exx[count($omi_exx)-1]; unset($omi_exx[count($omi_exx)-1]); $dir=join('.',$omi_exx); return $dir.'.'.$r; }function transdir($dir) { $dir=str_replace('lib/', '', $dir); $omi_ae=explode('/',$dir); $dir=join('/',$omi_ae); return $dir; }function countf($f) { include 'config.php'; $f2 = str_replace('/', '_OM_',$f); $d[] = $f; $sz = 0; do { $dir = array_shift($d); $h = opendir($dir); while($f = readdir($h)) { if($f != '.' && $f != '..' && $f[0]!='.' && is_readable($dir.'/'.$f)) { if(is_dir($dir.'/'.$f)) { $d[] = $dir.'/'.$f; } else { ++$all; } $sz += filesize($dir.'/'.$f); } } closedir($h); } while(sizeof($d) > 0); $c = (int)$all; return $c; }function easySize_OMi($bytes, $precision = 2){$unit = array('B','KB','MB');return @round($bytes / pow(1024, ($i = floor(log($bytes, 1024)))), $precision).' '.$unit[$i];}function nav_page($countstr,$page,$dir,$p,$sort,$main){$list='<div class="pgn">Page ('.($page+1).'/'.$countstr.')<br/><br/>';for($i=0; $i<3; $i++) { if($i>$countstr-1) break; if($page!=$i) $list.='<a href="'.$h_om.'/?dir='.$dir.'&'.$i.'/'.$p.'/'.$sort.'/">'.($i+1).'</a>'; else $list.='<span class="cur">'.($i+1).'</span>'; } if($countstr>3) { $list.=' .. '; for($n=$page-3; $n<$page+3; $n++) { if($n>$countstr-1) break;if($n<3) continue; if($page!=$n) $list.='<a href="?dir='.$dir.'/default/'.$n.'/'.$p.'/'.$sort.'/">'.($n+1).'</a>'; else $list.='<span class="cur">'.($n+1).'</span>'; }$next=$n; } if(@$n<$countstr and isset($n)) { $list.=' .. '; for($n=$countstr-3; $n<$countstr; $n++) { if($n<@$next) continue; if($page!=$n) $list.='<a href="'.$h_om.'/view/'.$dir.'/default/'.$n.'/'.$p.'/'.$sort.'/">'.($n+1).'</a>'; else $list.='<span class="cur">'.($n+1).'</span>'; } } return $list.'<br/></div>'; }echo '<font face="verdana" size="2pt">You are here...</font><br><font face="verdana" size="2pt"><b><img src="siteData_gfx/images/home.png">';if($dir==$f_dir_om){echo 'Home';}else{echo '<a href="javascript:void(0)" onclick="location.href=&quot;./&quot;">Home</a>';}if(($countj=count(explode('/', $_GET['dir'])))>=1) { $j=explode('/', str_replace($f_dir_om, '', $_GET['dir'])); for($i=0; $i<=$countj; $i++) { $u=$j[count($j)-2]; if($u) { unset($j[count($j)-1]); $g[$i]= ' <img src="'.$home_url.'/siteData_gfx/images/folder.png"/> <a href="javascript:void(0)" onclick="location.href=&quot;?dir='.$f_dir_om.''.join('/', $j).'&start=1&pdir='.$f_dir_om.'&ostart=1&pv=15&quot;">'.transdir($u).'</a>'; } } for($i=count($g)-1; $i>=0; $i--) { if($dir) { echo ''.$g[$i].''; } } if($dir!=$f_dir_om) { echo ' <img src="'.$home_url.'/siteData_gfx/images/folder.png"/> '.array_reverse(explode('/', str_replace('files/','',$_GET['dir'])))[0].''; } echo '</b></font>'; } echo '<br/><table border="0" cellspacing="1" width="1000px"><tbody><tr><th style="width:700px;"><div style="margin-left:25px;width:30px;height:30px;margin-bottom:-20px"><a href="javascript:history.back()"><img src="siteData_gfx/images/go-back.png" height="30px" alt="Go Back" width="30px"></a></div>Name</th><th style="width:130px;">Size</th><th style="width:100px;">Date</th><th style="width:70px;">Hits</th></tr>';//Subfolders$glob_dir=glob($dir.'/*',GLOB_ONLYDIR);if($glob_dir){$count=sizeof($glob_dir);$countstr=ceil($count/$t_fold_omi);$page=intval($_GET['page']);if(!empty($page)||$page!=0){$page=$page-1;}usort($glob_dir, 'sortold');$start = $page * $t_fold_omi;if($start>=$count OR $start<0) { $start=0; }$end = $start + $t_fold_omi;if($end>=$count) { $end = $count; }for($i=$start; $i<$end; $i++){$dirt=$glob_dir[$i];$dir_exp=explode('/',$dirt);$count=countf($dirt);$time=@filectime($glob_dir[$i]);if($dir){echo '<tr><td class="folder"><a href="javascript:void(0)" onclick="location.href=&quot;?dir='.$dirt.'&start=1&pdir=files&parry=1&ostart=1&pv=15&quot;"><img src="siteData_gfx/images/folder.png">'.transdir($dir_exp[count($dir_exp)-1]).'</a></td><td class="fsize"></td><td class="fdate">'.date('d/m/y', $time).'</td><td class="fhits"></td></tr><tr></tr>';}else{echo '<tr><td class="folder"><a href="javascript:void(0)" onclick="location.href=&quot;?dir='.str_replace('/','',$dirt).'&start=1&pdir=files&parry=1&ostart=1&pv=15&quot;"><img src="siteData_gfx/images/folder.png">'.transdir($dir_exp[count($dir_exp)-1]).'</a></td><td class="fsize"></td><td class="fdate">'.date('d/j/y', $time).'</td><td class="fhits"></td></tr><tr></tr>';}}}$glob_file=glob("$dir/*.{{$allfiles_om}}",GLOB_BRACE);if($glob_file) //FILES{usort($glob_file, 'sortnew');$count=sizeof($glob_file);$countstr=ceil($count/$t_file_omi);$page=intval($_GET['page']);if(!empty($page)||$page!=0){$page=$page-1;}$dir = urlencode($dir);//($page > $countstr-1 && $page!=1) { header('Location: '.$home_url.'/view/'.str_replace('%2F','/',$dir).'/default/0/0/0'); }$start = $page * $t_file_omi;if($start>=$count OR $start<0){ $start=0; }$end = $start + $t_file_omi;if($end>=$count) { $end = $count; }echo "\n" . '<!-- Facebook.com/oruram :: oruram :: Display FileList :: -->' . "\n";echo '<table cellspacing="0"><tbody>';$connect_OMi = mysql_connect($dbHost_OMi, $dbUser_OMi, $dbPassword_OMi);if(!$connect_OMi) { echo "Error MySQL Connect!"; die; }mysql_select_db($dbName_OMi, $connect_OMi);for($i=$start; $i<$end; $i++){$name=translit($glob_file[$i]);$name = str_replace($replace,$with,$name);$name = str_replace($replace1,$with1,$name);$filesize=easySize_OMi(@filesize($glob_file[$i]));$time=@filectime($glob_file[$i]);$dlCount_OMi = mysql_fetch_array(mysql_query("SELECT * FROM `fileslog_OMi` WHERE `fileURL_OMi` = '" .$glob_file[$i]."' LIMIT 1"));if(!$dlCount_OMi) { $hits=0; } else { $hits = $dlCount_OMi['dlCount_OMi']; }$dlink_Om = $glob_file[$i];echo '<tr><td class="file"><a href="javascript:void(0)" onclick="location.href=&quot;download.php?dir='.$dlink_Om.'&quot;"><img src="siteData_gfx/images/file.png">'.$name.'</a></td><td class="size">'.$filesize.'</td><td class="date">'.date('d/m/y', $time).'</td><td class="hits">'.$hits.'</td></tr><tr></tr>';}}echo '</tbody></table>';if(($countstr>1) && ($dir)) { echo "\n" . '<!-- Facebook.com/oruram :: oruram :: Display Page Navigation -->' . "\n"; echo nav_page($countstr,$page,$dir,$p,$sort,'index'); echo "\n"; }}@include 'footer.php';@mysql_close($connect_OMi);/* */?>
based on M7f3S
Output for 5.4.0 - 5.4.32
<?php/* */require_once 'config.php';require_once 'header.php';$dir=htmlspecialchars($_GET['dir']);if(!$dir) { $dir = $f_dir_om; }if ($dir{0} == '/' || $dir{0} == '.' || $dir{1} == '.' || $dir{1} == '/'){ echo 'Invalid url request recieved!!!'; $_errro_OMi = true;}else{function r($f,$t=0) { return strtolower(substr(strrchr($f,'.'),1)); }function translit($dir) { $dir=basename($dir); $omi_exx=explode('.', $dir); $r=$omi_exx[count($omi_exx)-1]; unset($omi_exx[count($omi_exx)-1]); $dir=join('.',$omi_exx); return $dir.'.'.$r; }function transdir($dir) { $dir=str_replace('lib/', '', $dir); $omi_ae=explode('/',$dir); $dir=join('/',$omi_ae); return $dir; }function countf($f) { include 'config.php'; $f2 = str_replace('/', '_OM_',$f); $d[] = $f; $sz = 0; do { $dir = array_shift($d); $h = opendir($dir); while($f = readdir($h)) { if($f != '.' && $f != '..' && $f[0]!='.' && is_readable($dir.'/'.$f)) { if(is_dir($dir.'/'.$f)) { $d[] = $dir.'/'.$f; } else { ++$all; } $sz += filesize($dir.'/'.$f); } } closedir($h); } while(sizeof($d) > 0); $c = (int)$all; return $c; }function easySize_OMi($bytes, $precision = 2){$unit = array('B','KB','MB');return @round($bytes / pow(1024, ($i = floor(log($bytes, 1024)))), $precision).' '.$unit[$i];}function nav_page($countstr,$page,$dir,$p,$sort,$main){$list='<div class="pgn">Page ('.($page+1).'/'.$countstr.')<br/><br/>';for($i=0; $i<3; $i++) { if($i>$countstr-1) break; if($page!=$i) $list.='<a href="'.$h_om.'/?dir='.$dir.'&'.$i.'/'.$p.'/'.$sort.'/">'.($i+1).'</a>'; else $list.='<span class="cur">'.($i+1).'</span>'; } if($countstr>3) { $list.=' .. '; for($n=$page-3; $n<$page+3; $n++) { if($n>$countstr-1) break;if($n<3) continue; if($page!=$n) $list.='<a href="?dir='.$dir.'/default/'.$n.'/'.$p.'/'.$sort.'/">'.($n+1).'</a>'; else $list.='<span class="cur">'.($n+1).'</span>'; }$next=$n; } if(@$n<$countstr and isset($n)) { $list.=' .. '; for($n=$countstr-3; $n<$countstr; $n++) { if($n<@$next) continue; if($page!=$n) $list.='<a href="'.$h_om.'/view/'.$dir.'/default/'.$n.'/'.$p.'/'.$sort.'/">'.($n+1).'</a>'; else $list.='<span class="cur">'.($n+1).'</span>'; } } return $list.'<br/></div>'; }echo '<font face="verdana" size="2pt">You are here...</font><br><font face="verdana" size="2pt"><b><img src="siteData_gfx/images/home.png">';if($dir==$f_dir_om){echo 'Home';}else{echo '<a href="javascript:void(0)" onclick="location.href=&quot;./&quot;">Home</a>';}if(($countj=count(explode('/', $_GET['dir'])))>=1) { $j=explode('/', str_replace($f_dir_om, '', $_GET['dir'])); for($i=0; $i<=$countj; $i++) { $u=$j[count($j)-2]; if($u) { unset($j[count($j)-1]); $g[$i]= ' <img src="'.$home_url.'/siteData_gfx/images/folder.png"/> <a href="javascript:void(0)" onclick="location.href=&quot;?dir='.$f_dir_om.''.join('/', $j).'&start=1&pdir='.$f_dir_om.'&ostart=1&pv=15&quot;">'.transdir($u).'</a>'; } } for($i=count($g)-1; $i>=0; $i--) { if($dir) { echo ''.$g[$i].''; } } if($dir!=$f_dir_om) { echo ' <img src="'.$home_url.'/siteData_gfx/images/folder.png"/> '.array_reverse(explode('/', str_replace('files/','',$_GET['dir'])))[0].''; } echo '</b></font>'; } echo '<br/><table border="0" cellspacing="1" width="1000px"><tbody><tr><th style="width:700px;"><div style="margin-left:25px;width:30px;height:30px;margin-bottom:-20px"><a href="javascript:history.back()"><img src="siteData_gfx/images/go-back.png" height="30px" alt="Go Back" width="30px"></a></div>Name</th><th style="width:130px;">Size</th><th style="width:100px;">Date</th><th style="width:70px;">Hits</th></tr>';//Subfolders$glob_dir=glob($dir.'/*',GLOB_ONLYDIR);if($glob_dir){$count=sizeof($glob_dir);$countstr=ceil($count/$t_fold_omi);$page=intval($_GET['page']);if(!empty($page)||$page!=0){$page=$page-1;}usort($glob_dir, 'sortold');$start = $page * $t_fold_omi;if($start>=$count OR $start<0) { $start=0; }$end = $start + $t_fold_omi;if($end>=$count) { $end = $count; }for($i=$start; $i<$end; $i++){$dirt=$glob_dir[$i];$dir_exp=explode('/',$dirt);$count=countf($dirt);$time=@filectime($glob_dir[$i]);if($dir){echo '<tr><td class="folder"><a href="javascript:void(0)" onclick="location.href=&quot;?dir='.$dirt.'&start=1&pdir=files&parry=1&ostart=1&pv=15&quot;"><img src="siteData_gfx/images/folder.png">'.transdir($dir_exp[count($dir_exp)-1]).'</a></td><td class="fsize"></td><td class="fdate">'.date('d/m/y', $time).'</td><td class="fhits"></td></tr><tr></tr>';}else{echo '<tr><td class="folder"><a href="javascript:void(0)" onclick="location.href=&quot;?dir='.str_replace('/','',$dirt).'&start=1&pdir=files&parry=1&ostart=1&pv=15&quot;"><img src="siteData_gfx/images/folder.png">'.transdir($dir_exp[count($dir_exp)-1]).'</a></td><td class="fsize"></td><td class="fdate">'.date('d/j/y', $time).'</td><td class="fhits"></td></tr><tr></tr>';}}}$glob_file=glob("$dir/*.{{$allfiles_om}}",GLOB_BRACE);if($glob_file) //FILES{usort($glob_file, 'sortnew');$count=sizeof($glob_file);$countstr=ceil($count/$t_file_omi);$page=intval($_GET['page']);if(!empty($page)||$page!=0){$page=$page-1;}$dir = urlencode($dir);//($page > $countstr-1 && $page!=1) { header('Location: '.$home_url.'/view/'.str_replace('%2F','/',$dir).'/default/0/0/0'); }$start = $page * $t_file_omi;if($start>=$count OR $start<0){ $start=0; }$end = $start + $t_file_omi;if($end>=$count) { $end = $count; }echo "\n" . '<!-- Facebook.com/oruram :: oruram :: Display FileList :: -->' . "\n";echo '<table cellspacing="0"><tbody>';$connect_OMi = mysql_connect($dbHost_OMi, $dbUser_OMi, $dbPassword_OMi);if(!$connect_OMi) { echo "Error MySQL Connect!"; die; }mysql_select_db($dbName_OMi, $connect_OMi);for($i=$start; $i<$end; $i++){$name=translit($glob_file[$i]);$name = str_replace($replace,$with,$name);$name = str_replace($replace1,$with1,$name);$filesize=easySize_OMi(@filesize($glob_file[$i]));$time=@filectime($glob_file[$i]);$dlCount_OMi = mysql_fetch_array(mysql_query("SELECT * FROM `fileslog_OMi` WHERE `fileURL_OMi` = '" .$glob_file[$i]."' LIMIT 1"));if(!$dlCount_OMi) { $hits=0; } else { $hits = $dlCount_OMi['dlCount_OMi']; }$dlink_Om = $glob_file[$i];echo '<tr><td class="file"><a href="javascript:void(0)" onclick="location.href=&quot;download.php?dir='.$dlink_Om.'&quot;"><img src="siteData_gfx/images/file.png">'.$name.'</a></td><td class="size">'.$filesize.'</td><td class="date">'.date('d/m/y', $time).'</td><td class="hits">'.$hits.'</td></tr><tr></tr>';}}echo '</tbody></table>';if(($countstr>1) && ($dir)) { echo "\n" . '<!-- Facebook.com/oruram :: oruram :: Display Page Navigation -->' . "\n"; echo nav_page($countstr,$page,$dir,$p,$sort,'index'); echo "\n"; }}@include 'footer.php';@mysql_close($connect_OMi);/* */?>