All pastes #500402 Raw Edit

Anonymous

public text v1 · immutable
·published 2007-05-21 16:05 UTC
rendered paste body
<?php
function human_size($bytes, $decimal='1')
{
  $position = 0;
  $units=array("", "K", "M", "G", "T");
  while($bytes>=1024 && ($bytes/1024)>=1)
  {
    $bytes/=1024;
    $position++;
  }
  return round($bytes,$decimal).$units[$position];
}
function iconurl($x)
{
  $baseurl='/img/repos/';
  $ext=substr(($t=strrchr($x,'.'))!==false?$t:'',1);
  if($ext=='pdf')$f='pdf.gif';
  else if(in_array($ext,array('bin','rpm','deb')))$f='binary.gif';
  else if(in_array($ext,array('txt','rtf','doc','pdf')))$f='text.gif';
  else if(in_array($ext,array('ogg')))$f='sound.gif';
  else if(in_array($ext,array('c','C','h','cpp')))$f='c.gif';
  else if(in_array($ext,array('py','pyc')))$f='python.gif';
  else if(in_array($ext,array('sh')))$f='shell.gif';
  else if(in_array($ext,array('zip','tgz','gz','bz2','rar','ace','7z','tbz','tar.bz2','tar.gz')))$f='compressed.gif';
  else if(in_array($ext,array('php','html','html','asp','shtml')))$f='html.gif';
  else if(in_array($ext,array('gif','jpg','jpeg','png','bmp')))$f='img.gif';
  else $f='unknown.gif';
  return $baseurl.$f;
}
echo "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr"
lang="fr">
<head>
  <title>~gapz</title>
  <meta http-equiv="Content-Type" content="text/HTML; charset=UTF-8"/>
  <link rel="SHORTCUT ICON" href="/favicon.ico"/>  
  <style type="text/css">
  body
  {
    background: black;
    color: #d5d5d5;
  }
  a { color: #d5d5d5; text-decoration: none; }
  a:hover { text-decoration: none; color: #00e100; }
  tt
  {
    font-size: 13px;
    white-space: pre;
    display: block;
  }
  .title
  { 
    font-size: 40px; 
    font-weight: bold;
    color: #505050;
  }
  </style>
</head>
<body>
<center><img src="/img/cer-ship.png" width="120px"></center>
<tt>
<?php

$dirs=array();
$files=array();
$rep=opendir('.');

while($x=readdir($rep))
{
  if($x[0]=='.' || $x=='index.php' || $x=='favicon.ico' || $x=='index-depot.html' || $x=='dists');
  else if(strpos($x,'hidden')===0);
  else if(is_dir($x))$dirs[]=$x;
  else $files[]=$x;
}

closedir($rep);
sort($dirs);
sort($files);

?>
<img src="/img/repos/blank.gif" alt="Icon" /> Name                                      Last modified       Size</tt>
<hr /><tt><img src="/img/repos/back.gif" alt="Up" /> <a href="..">Parent Directory</a>
<?php

$x=reset($dirs);
if($x!=false)
do
{

?>
<img src="/img/repos/folder.gif" alt="[DIR]" /> <a href="<?php echo $x; ?>/"><?php printf("%-25s",$x); ?></a>                 <?php echo date("d-M-Y H:i",filemtime($x)); ?>     -  
<?php

}while($x=next($dirs));

$x=reset($files);
if($x!=false)
do
{

?>
<img src="<?php echo iconurl($x); ?>" alt="[IMG]" /> <a href="<?php echo $x; ?>"><?php printf("%-25s",$x); ?></a>                 <?php  echo date("d-M-Y H:i",filemtime($x)); ?>  <?php printf("%6s",human_size(filesize($x))); ?>  
<?php
}while($x=next($files));
?>
</tt><hr />
</body>
</html>