rtoss - Rev 51

Subversion Repositories:
Rev:
<?php
/*********************************************
  Wastepaper Uploader v1.5
  http://utu.under.jp/
  PHP¤¢¤×¤í¤À¤ò¸µ¤ËW3C¤Ë½àµò¤·¤¿XHTML¤òÌܻؤ¹¤Ù¤¯
  ¥¹¥¯¥ê¥×¥ÈµÚ¤ÓHTMLʸ½ñ¤ò²þ¤¤¤¤¿¤·¤Þ¤·¤¿¡£
  ·ë¹½Å¬Åö¤ÊXHTML¤«¤â¤·¤ì¤Þ¤»¤ó¤¬W3C¿®¼ÔÍͤªµö¤·¤ò¡Ä¡£
  ------------------ÀßÃÖË¡-------------------
  ÀßÃ֥ǥ£¥ì¥¯¥È¥ê¤Ï755
  img¡¢imgs¥Ç¥£¥ì¥¯¥È¥ê¤Ï777
  upload.php¡¢sum.php¤Ï755
  up.log¡¢last.cgi¡¢count.txt¤Ï666  
  ------------------Based--------------------
  source by PHP¤¢¤×¤í¤À v2.2
  http://php.s3.to
 
  source by ¤º¤ë¤Ý¤ó
  http://zurubon.virtualave.net/

  ¤â¤·¤â¤Î°Ù¤Î.htaccess ¡ÊCGI¶Ø»ßSSI¶Ø»ßIndexɽ¼¨¶Ø»ß¡Ë
  Options -ExecCGI -Includes -Indexes
  .txt¤Ç¤â¡¢Ãæ¿È¤¬HTML¤À¤Èɽ¼¨¤µ¤ì¤Á¤ã¤¦¤Î¤ÇÃí°Õ
  -------------------------------------------
 *********************************************/

if(phpversion()>="4.1.0"){//PHP4.1.0°Ê¹ßÂбþ
  $_GET = array_map("_clean", $_GET);
  $_POST = array_map("_clean", $_POST);
  //$_POST = array_map("_clean", $_GET);
  extract($_GET);
  extract($_POST);
  extract($_COOKIE);
  extract($_SERVER);
  $upfile_type=_clean($_FILES['up']['type']);
  $upfile_size=$_FILES["upfile"]["size"];//Ë¿½ê¤Çµ¤¤Å¤¯¡¦¡¦¡¦
  $upfile_name=_clean($_FILES["upfile"]["name"]);
  $upfile=$_FILES["upfile"]["tmp_name"];
}

  $title        = 'Wastepaper Uploader';        //¥¿¥¤¥È¥ë
  $home         = 'http://utu.under.jp/';       //¥Û¡¼¥à
  $logfile      = "up.log";     //¥í¥°¥Õ¥¡¥¤¥ë̾¡ÊÊѹ¹¤¹¤ë»ö¡Ë
  $updir        = "./img/";     //¥¢¥Ã¥×Íѥǥ£¥ì¥¯¥È¥ê
  $upsdir       = "./imgs/";    //¥µ¥à¥Í¥¤¥ëÊݸ¥Ç¥£¥ì¥¯¥È¥ê
  $prefix       = '';           //ÀÜƬ¸ì¡Êup001.txt,up002.jpg¤Ê¤éup¡Ë
  $logmax       = 50;           //logÊݸ¹Ô¡Ê¤³¤ì°Ê¾å¤Ï¸Å¤¤¤Î¤«¤éºï½ü¡Ë
  $commax       = 250;          //¥³¥á¥ó¥ÈÅê¹ÆÎÌÀ©¸Â¡Ê¥Ð¥¤¥È¡£Á´³Ñ¤Ï¤³¤ÎȾʬ¡Ë
  $limitk       = 100;  //¥¢¥Ã¥×¥í¡¼¥ÉÀ©¸Â¡ÊKB ¥­¥í¥Ð¥¤¥È¡Ë
  $page_def     = 10;           //°ì¥Ú¡¼¥¸¤Îɽ¼¨¹Ô¿ô
  $admin        = "12345";      //ºï½ü´ÉÍý¥Ñ¥¹
  $auto_link    = 1;            //¥³¥á¥ó¥È¤Î¼«Æ°¥ê¥ó¥¯¡ÊYes=1;No=0);
  $denylist     = array('192.168.0.1','sex.com','annony');      //¥¢¥¯¥»¥¹µñÈÝ¥Û¥¹¥È
  $arrowext     = array('zip','lzh','rar','avi','mpg','wmv','mp3','wma','swf','txt','bmp','jpg','png','gif');   //µö²Ä³ÈÄ¥»Ò ¾®Ê¸»ú¡Ê¤½¤ì°Ê³°¤Ï¥¨¥é¡¼

  $count_start  = "2004/10/24"; //¥«¥¦¥ó¥¿³«»ÏÆü
  $count_file   = "count.txt";  //¥«¥¦¥ó¥¿¥Õ¥¡¥¤¥ë¡Ê¶õ¥Õ¥¡¥¤¥ë¤Ç666¡Ë

  $last_file    = "last.cgi";   //Ϣ³Åê¹ÆÀ©¸ÂÍÑ¥Õ¥¡¥¤¥ë¡Ê¶õ¥Õ¥¡¥¤¥ë¤Ç666¡Ë
  $last_time    = 0;            //Ʊ°ìIP¤«¤é¤ÎϢ³Åê¹Æµö²Ä¤¹¤ë´Ö³Ö¡Êʬ¡Ë¡Ê0¤Ç̵À©¸Â¡Ë

  /* ¹àÌÜɽ¼¨¡Ê´Ä¶­ÀßÄê¡Ë¤Î½é´ü¾õÂÖ (ɽ¼¨¤Ê¤éChecked ɽ¼¨¤·¤Ê¤¤¤Ê¤é¶õ) */
  $f_act  = 'checked="checked"';        //ACT¡Êºï½ü¥ê¥ó¥¯¡Ë
  $f_com  = 'checked="checked"';        //¥³¥á¥ó¥È
  $f_size = 'checked="checked"';        //¥Õ¥¡¥¤¥ë¥µ¥¤¥º
  $f_mime = '';                         //MIME¥¿¥¤¥×
  $f_date = 'checked="checked"';        //ÆüÉÕ¤±
  $f_orig = 'checked="checked"';        //¸µ¥Õ¥¡¥¤¥ë̾

if($act=="envset"){
  $cookval = @implode(",", array($acte,$come,$sizee,$mimee,$datee,$orige));
  setcookie ("upcook", $cookval,time()+365*24*3600);
}
function _clean($str) {
  $str = htmlspecialchars($str);
  if (get_magic_quotes_gpc()) $str = stripslashes($str);
  return $str;
}
/* ¤³¤³¤«¤é¥Ø¥Ã¥À¡¼ */
?>
<?php echo '<?xml version="1.0" encoding="euc-jp"?>'."\n" ?>
<!DOCTYPE html
   PUBLIC "-//W3C//DTD XHTML 1.1//EN"
   "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ja">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=euc-jp" media="all" />
<title><?php echo "$title" ?></title>
<link href="style.css" type="text/css" rel="stylesheet" />
</head>
<body>

<h1><?php echo "$title" ?></h1>
<p>µ¤¤Ë¤Ê¤ë¥Í¥¿¤Ê¤É¡³(¡­¡¼¡®)¥Î</p>

<?php
/* ¥Ø¥Ã¥À¡¼¤³¤³¤Þ¤Ç */
$foot = <<<FOOT

<h2>Ãøºî¸¢É½¼¨</h2>
<p id="link"><a href="http://php.s3.to/">¥ì¥Ã¥ÄPHP!</a> + <a href="http://utu.under.jp">Wastepaper Basket</a></p>

</body>
</html>
FOOT
;

function FormatByte($size){//¥Ð¥¤¥È¤Î¥Õ¥©¡¼¥Þ¥Ã¥È¡ÊB¢ªkB¡Ë
  if($size == 0)                        $format = "";
  else if($size <= 1024)                $format = $size."B";
  else if($size <= (1024*1024))         $format = sprintf ("%dkB",($size/1024));
  else if($size <= (10*1024*1024))      $format = sprintf ("%.2fMB",($size/(1024*1024)));
  else                                  $format = $size."B";

  return $format;
}
function paging($page, $total){//¥Ú¡¼¥¸¥ê¥ó¥¯ºîÀ®
  global $PHP_SELF,$page_def;

    for ($j = 1; $j * $page_def < $total+$page_def; $j++) {
      if($page == $j){//º£É½¼¨¤·¤Æ¤¤¤ë¤Î¤ÏŽØŽÝŽ¸¤·¤Ê¤¤
        $next .= "[<strong>$j</strong>]";
      }else{
        $next .= sprintf("[<a href=\"%s?page=%d\">%d</a>]", $PHP_SELF,$j,$j);//¾¤ÏŽØŽÝŽ¸
      }
    }
    if($page=="all") return sprintf ("Page: %s [ALL]",$next,$PHP_SELF);
    else return sprintf ("Page: %s [<a href=\"%s?page=all\">ALL</a>]",$next,$PHP_SELF);
}
function error($mes1=""){//¤¨¤Ã¤é¡¼ŽÒŽ¯Ž¾Ž°Ž¼ŽÞ
  global $foot;

  echo $mes1;
  echo $foot;
  exit;
}
/* start */
$limitb = $limitk * 1024;
$host = @gethostbyaddr($REMOTE_ADDR);
if(!$upcook) $upcook=@implode(",",array($f_act,$f_com,$f_size,$f_mime,$f_date,$f_orig));
list($c_act,$c_com,$c_size,$c_mime,$c_date,$c_orig)=explode(",",$upcook);

/* ¥¢¥¯¥»¥¹À©¸Â */
if(is_array($denylist)){
  while(list(,$line)=each($denylist)){
    if(strstr($host, $line)) error('<h2>¥¨¥é¡¼¥á¥Ã¥»¡¼¥¸</h2>
<p class="error">¥¢¥¯¥»¥¹À©¸Â:¥¢¥¯¥»¥¹¸¢¸Â¤¬¤¢¤ê¤Þ¤»¤ó</p>'
);
  }
}
/* ºï½ü¼Â¹Ô */
if($delid && $delpass!=""){
  $old = file($logfile);
  $find = false;
  for($i=0; $i<count($old); $i++){
    list($did,$dext,,,,,,$dpwd,)=explode("\t",$old[$i]);
    if($delid==$did){
      $find = true;
      $del_ext = $dext;
      $del_pwd = rtrim($dpwd);
    }else{
      $new[] = $old[$i];
    }
  }
  if(!$find) error('<h2>¥¨¥é¡¼¥á¥Ã¥»¡¼¥¸</h2>
<p class="error">ºï½ü¥¨¥é¡¼:³ºÅö¥Õ¥¡¥¤¥ë¤¬¸«¤Ä¤«¤ê¤Þ¤»¤ó</p>'
);
  if($delpass == $admin || substr(md5($delpass), 2, 7) == $del_pwd){
    if(file_exists($updir.$prefix.$delid.".$del_ext")) unlink($updir.$prefix.$delid.".$del_ext");
    if(file_exists($upsdir.$prefix.$delid.".$del_ext")) unlink($upsdir.$prefix.$delid.".$del_ext");
    $fp = fopen($logfile, "w");
    flock($fp, 2);
    fputs($fp, @implode("",$new));  
    fclose($fp);
  }else{
    error('<h2>¥¨¥é¡¼¥á¥Ã¥»¡¼¥¸</h2>
<p class="error">ºï½ü¥¨¥é¡¼:¥Ñ¥¹¥ï¡¼¥É¤¬°ã¤¤¤Þ¤¹</p>'
);
  }
}
/* ºï½ü¥Õ¥©¡¼¥à */
if($del){
  error("<h2>ºï½ü¥Õ¥©¡¼¥à</h2>
<form method=\"post\" enctype=\"multipart/form-data\" action=\"$PHP_SELF\">
<p>ºï½ü¥Ñ¥¹ÆþÎÏ<br />
<input type=\"hidden\" name=\"delid\" value=\""
.htmlspecialchars($del)."\" />
<input type=\"password\" size=\"12\" name=\"delpass\" class=\"box\" tabindex=\"1\" accesskey=\"1\" />
<input type=\"submit\" value=\"ºï½ü\" tabindex=\"2\" accesskey=\"2\" /></p>
</form>
<p class=\"tline\"><a href=\"$PHP_SELF?\">Ìá¤ë</a></p>
"
);
}
/* ´Ä¶­ÀßÄê¥Õ¥©¡¼¥à */
if($act=="env"){
  echo "<h2>´Ä¶­ÀßÄê</h2>
<form method=\"get\" action=\"$PHP_SELF\">
<p><input type=\"hidden\" name=\"act\" value=\"envset\" /></p>
<h3>ɽ¼¨ÀßÄê</h3>
<ul>
<li><input type=\"checkbox\" name=\"acte\" value=\"checked\" tabindex=\"1\" accesskey=\"1\" $c_act />ACT</li>
<li><input type=\"checkbox\" name=\"come\" value=\"checked\" tabindex=\"2\" accesskey=\"2\" $c_com />COMMENT</li>
<li><input type=\"checkbox\" name=\"sizee\" value=\"checked\" tabindex=\"3\" accesskey=\"3\" $c_size />SIZE</li>
<li><input type=\"checkbox\" name=\"mimee\" value=\"checked\" tabindex=\"4\" accesskey=\"4\" $c_mime />MIME</li>
<li><input type=\"checkbox\" name=\"datee\" value=\"checked\" tabindex=\"5\" accesskey=\"5\" $c_date />DATE</li>
<li><input type=\"checkbox\" name=\"orige\" value=\"checked\" tabindex=\"6\" accesskey=\"6\" $c_orig />ORIG</li>
</ul>
<p>¾åµ­¤ÎÀßÄê¤Ë¤ÆˬÌ䤹¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡Ê¢¨cookie¡Ë</p>
<p><input type=\"submit\" value=\"ÅÐÏ¿\" tabindex=\"7\" accesskey=\"7\" /><input type=\"reset\" value=\"¸µ¤ËÌ᤹\" tabindex=\"8\" accesskey=\"8\" /></p>
</form>
<p class=\"tline\"><a href=\"$PHP_SELF?\">Ìá¤ë</a></p>

"
;
echo $foot;
exit;
}
$lines = file($logfile);
/* ¥¢¥×¥í¡¼¥É½ñ¤­¹þ¤ß½èÍý */
if(file_exists($upfile) && $com && $upfile_size > 0){
  if(strlen($com) > $commax) error('<h2>¥¨¥é¡¼¥á¥Ã¥»¡¼¥¸</h2>
<p class="error">Åê¹Æ¥¨¥é¡¼:¥³¥á¥ó¥È¤¬Ä¹¤¹¤®¤Þ¤¹</p>
'
);
  if($upfile_size > $limitb)        error('<h2>¥¨¥é¡¼¥á¥Ã¥»¡¼¥¸</h2>
<p class="error">Åê¹Æ¥¨¥é¡¼:¥Õ¥¡¥¤¥ë¤¬¥Ç¥«¤¹¤®¤Þ¤¹</p>'
);
  /* Ϣ³Åê¹ÆÀ©¸Â */
  if($last_time > 0){
    $now = time();
    $last = @fopen($last_file, "r+") or die('<h2>¥¨¥é¡¼¥á¥Ã¥»¡¼¥¸</h2>
<p class="error">Ϣ³Åê¹ÆÍÑ¥Õ¥¡¥¤¥ë $last_file ¤òºîÀ®¤·¤Æ¤¯¤À¤µ¤¤</p>'
);
    $lsize = fgets($last, 1024);
    list($ltime, $lip) = explode("\t", $lsize);
    if($host == $lip && $last_time*60 > ($now-$ltime)){
      error('<h2>¥¨¥é¡¼¥á¥Ã¥»¡¼¥¸</h2>
<p class="error">Ϣ³Åê¹ÆÀ©¸ÂÃæ:»þ´Ö¤òÃÖ¤¤¤Æ¤ä¤êľ¤·¤Æ¤¯¤À¤µ¤¤</p>'
);
    }
    rewind($last);
    fputs($last, "$now\t$host\t");
    fclose($last);
  }
  /* ³ÈÄ¥»Ò¤È¿·¥Õ¥¡¥¤¥ë̾ */
  $pos = strrpos($upfile_name,".");     //³ÈÄ¥»Ò¼èÆÀ
  $ext = substr($upfile_name,$pos+1,strlen($upfile_name)-$pos);
  $ext = strtolower($ext);//¾®Ê¸»ú²½
  if(!in_array($ext, $arrowext))
    error('<h2>¥¨¥é¡¼¥á¥Ã¥»¡¼¥¸</h2>
<p class="error">³ÈÄ¥»Ò¥¨¥é¡¼:¤½¤Î³ÈÄ¥»Ò¥Õ¥¡¥¤¥ë¤Ï¥¢¥Ã¥×¥í¡¼¥É¤Ç¤­¤Þ¤»¤ó</p>'
);
  /* µñÈݳÈÄ¥»Ò¤Ïtxt¤ËÊÑ´¹
  for($i=0; $i<count($denyext); $i++){
    if(strstr($ext,$denyext[$i])) $ext = 'txt';
  }
  */

  list($id,) = explode("\t", $lines[0]);//No¼èÆÀ
  $id = sprintf("%03d", ++$id);         //¥¤¥ó¥¯¥ê
  $newname = $prefix.$id.".".$ext;

  /* ¼«»ªÅ¾Á÷ */
  move_uploaded_file($upfile, $updir.$newname);//3.0.16¤è¤ê¸å¤Î¥Ð¡¼¥¸¥ç¥ó¤ÎPHP 3¤Þ¤¿¤Ï 4.0.2 ¸å
  //copy($upfile, $updir.$newname);
  chmod($updir.$newname, 0604);

  /* MIME¥¿¥¤¥× */
  if(!$upfile_type) $upfile_type = "text/plain";//¥Ç¥Õ¥©MIME¤Ïtext/plain

  /* ¥³¥á¥ó¥È¾ */
  $com = htmlspecialchars($com);        //¥¿¥°ÊÑ´¹
  if(get_magic_quotes_gpc()) $com = stripslashes($com); //¡ï½üµî

  $now = gmdate("Y/m/d(D)H:i", time()+9*60*60); //ÆüÉդΥե©¡¼¥Þ¥Ã¥È
  $pwd = ($pass) ? substr(md5($pass), 2, 7) : "*";      //¥Ñ¥¹¤ÃºîÀ®¡Ê̵¤¤¤Ê¤é*¡Ë

  $dat = @implode("\t", array($id,$ext,$com,$host,$now,$upfile_size,$upfile_type,$pwd,$upfile_name,));

  if(count($lines) >= $logmax){         //¥í¥°¥ª¡¼¥Ð¡¼¤Ê¤é¥Ç¡¼¥¿ºï½ü
    for($d = count($lines)-1; $d >= $logmax-1; $d--){
      list($did,$dext,)=explode("\t", $lines[$d]);
      if(file_exists($updir.$prefix.$did.".".$dext)) {
        unlink($updir.$prefix.$did.".".$dext);
      }
    }
  }

  $fp = fopen ($logfile , "w");         //½ñ¤­¹þ¤ß¥â¡¼¥É¤Ç¥ª¡¼¥×¥ó
  flock($fp ,2);
  fputs ($fp, "$dat\n");                //ÀèƬ¤Ë½ñ¤­¹þ¤à
  for($i = 0; $i < $logmax-1; $i++)     //¤¤¤Þ¤Þ¤Ç¤Îʬ¤òÄɵ­
    fputs($fp, $lines[$i]);
  fclose ($fp);
  reset($lines);
  $lines = file($logfile);              //Æþ¤ì¤Ê¤ª¤·
}
foreach($arrowext as $list) $arrow .= $list." ";
/* Åê¹Æ¥Õ¥©¡¼¥à */
echo '<h2>¥¢¥Ã¥×¥í¡¼¥É¥Õ¥©¡¼¥à</h2>
<form method="post" enctype="multipart/form-data" action="'
.$PHP_SELF.'" >
<p>Up File<strong>¡Ê'
.$limitk.' KB¤Þ¤Ç¡Ë</strong><br />
<input type="hidden" name="MAX_FILE_SIZE" value="'
.$limitb.'" />
<input type="file" size="40" name="upfile" class="box" tabindex="1" accesskey="1" />
 Del Pass : <input type="password" size="10" name="pass" maxlength="10" class="box" tabindex="2" accesskey="2" /></p>
<p>Comment¡Ê¢¨¥³¥á¥ó¥È̵µ­Æþ¤Ï¥ê¥í¡¼¥É/URI¤Ï¥ª¡¼¥È¥ê¥ó¥¯¡Ë<br />
<input type="text" size="45" name="com" value="" class="box" tabindex="3" accesskey="3" />
<input type="submit" value="Up/Reload" tabindex="4" accesskey="4" />
<input type="reset" value="Cancel" tabindex="5" accesskey="5" /></p>
<p>UP²Äǽ³ÈÄ¥»Ò¡§'
.$arrow.'</p>
</form>
'
;
/* ¥«¥¦¥ó¥¿ */
echo "<p class=\"uline\">$count_start ¤«¤é ";
if(file_exists($count_file)){
  $fp = fopen($count_file,"r+");//Æɤ߽ñ¤­¥â¡¼¥É¤Ç¥ª¡¼¥×¥ó
  $count = fgets($fp, 64);      //64¥Ð¥¤¥ÈorEOF¤Þ¤Ç¼èÆÀ¡¢¥«¥¦¥ó¥È¥¢¥Ã¥×
  $count++;
  fseek($fp, 0);                        //¥Ý¥¤¥ó¥¿¤òÀèƬ¤Ë¡¢¥í¥Ã¥¯¤·¤Æ½ñ¤­¹þ¤ß
  flock($fp,2);
  fputs($fp, $count);
  fclose($fp);                  //¥Õ¥¡¥¤¥ë¤òÊĤ¸¤ë
  echo $count;                  //¥«¥¦¥ó¥¿É½¼¨
}
/* ¥â¡¼¥É¥ê¥ó¥¯ */
echo '
¡Ê¤³¤ï¤ì¤Ë¤¯¤µ¥ì¥Ù¥ë1¡ËD¡§Åê¹Æµ­»öºï½ü</p>
<p class="uline"><a href="'
.$home.'">HOME</a> | <a href="'.$PHP_SELF.'?act=env">´Ä¶­ÀßÄê</a> | <a href="'.$PHP_SELF.'?">¥ê¥í¡¼¥É</a> | <a href="sam.php">²èÁü°ìÍ÷</a></p>

<h2>¥Õ¥¡¥¤¥ë°ìÍ÷</h2>
<p class="uline">'
;
/* ¥í¥°³«»Ï°ÌÃÖ */
$st = ($page) ? ($page - 1) * $page_def : 0;
if(!$page) $page = 1;
if($page == "all"){
  $st = 0;
  $page_def = count($lines);
}
echo paging($page, count($lines));//¥Ú¡¼¥¸¥ê¥ó¥¯
//¥á¥¤¥ó¥Ø¥Ã¥À
echo "</p>\n";
echo "<table summary=\"files\">\n<tr>";
if($c_act) echo "<th abbr=\"delete\" scope=\"col\">DEL</th>";
echo "<th abbr=\"name\" scope=\"col\">NAME</th>";
if($c_com) echo "<th abbr=\"comment\" scope=\"col\">COMMENT</th>";
if($c_size) echo "<th abbr=\"size\" scope=\"col\">SIZE</th>";
if($c_mime) echo "<th abbr=\"mime\" scope=\"col\">MIME</th>";
if($c_date) echo "<th abbr=\"date\" scope=\"col\">DATE</th>";
if($c_orig) echo "<th abbr=\"original name\" scope=\"col\">ORIG</th>";
echo "</tr>\n";
//¥á¥¤¥óɽ¼¨
for($i = $st; $i < $st+$page_def; $i++){
  if($lines[$i]=="") continue;
  list($id,$ext,$com,$host,$now,$size,$mtype,$pas,$orig,)=explode("\t",$lines[$i]);
  $fsize = FormatByte($size);
  if($auto_link) $com = ereg_replace("(https?|ftp|news)(://[[:alnum:]\+\$\;\?\.%,!#~*/:@&=_-]+)","<a href=\"\\1\\2\">\\1\\2</a>",$com);

  $filename = $prefix.$id.".$ext";
  $target = $updir.$filename;

 
  echo "<tr><!--$host-->\n";//¥Û¥¹¥Èɽ¼¨
  if($c_act) echo "<td class=\"del\"><a href=\"$PHP_SELF?del=$id\">D</a></td>";
  echo "<td>[<a href=\"$target\">$filename</a>]</td>";
  if($c_com) echo "<td>$com</td>";
  if($c_size) echo "<td class=\"size\">$fsize</td>";
  if($c_mime) echo "<td>$mtype</td>";
  if($c_date) echo "<td>$now</td>\n";
  if($c_orig) echo "<td class=\"orig\">\n$orig</td>\n";
  echo "</tr>\n";
  }

echo "</table>\n<p class=\"tline\">";
echo paging($page,count($lines));
echo "</p>\n";
echo $foot;
?>