rtoss - Rev 51

Subversion Repositories:
Rev:
<?php echo '<?xml version="1.0" encoding="euc-jp"?>'."\n" ?>
<?php
/***
* Reconstruction by Wastepaper Basket
* ¥µ¥à¥Í¥¤¥ë¥«¥Ã¥¿¡¼¡¡¡Ê²èÁü°ìÍ÷¡Ëby ToR

* ¢¨PHP¥ª¥×¥·¥ç¥ó¤ËGD¤¬É¬ÍפǤ¹¡Ê̵ÎÁ»ª¤Ç¤Ï¥À¥á¤Ê¤È¤³¤í¤¬Â¿¤¤
* $_GETÅù»ÈÍѤ·¤Æ¤Þ¤¹¡£¸Å¤¤¥Ð¡¼¥¸¥ç¥ó¤ÎPHP¤Ç¤Ï$_GET¢ª$HTTP_GET_VARS $_SERVER¢ª$HTTP_SERVER_VERS
**/


$title     = 'Wastepaper Basket';       //¥¿¥¤¥È¥ë
$upphp     = 'upload.php';              //¥¢¥Ã¥×¥í¡¼¥À
$img_dir   = "./img/";                  //²èÁü°ìÍ÷¥Ç¥£¥ì¥¯¥È¥ê
$thumb_dir = "./imgs/";                 //¥µ¥à¥Í¥¤¥ëÊݸ¥Ç¥£¥ì¥¯¥È¥ê
$ext       = ".+\.png$|.+\.jpe?g$";     //³ÈÄ¥»Ò¡¤GIF¤ÏGD¤ÎŽÊŽÞŽ°Ž¼ŽÞŽ®ŽÝ¤Ë¤è¤Ã¤Æ¤Ï̵Íý
$W         = 120;                       //½ÐÎϲèÁüÉý
$H         = 120;                       //½ÐÎϲèÁü¹â¤µ
$cols      = 2;                         //1¹Ô¤Ëɽ¼¨¤¹¤ë²èÁü¿ô
$page_def  = 4;                 //1¥Ú¡¼¥¸¤Ëɽ¼¨¤¹¤ë²èÁü¿ô

if ($_GET["cmd"]=="min" && isset($_GET["pic"])) {
  $src = $img_dir.$_GET["pic"];

  // ²èÁü¤ÎÉý¤È¹â¤µ¤È¥¿¥¤¥×¤ò¼èÆÀ
  $size = GetImageSize($src);
  switch ($size[2]) {
    case 1 : $im_in = ImageCreateFromGIF($src);  break;
    case 2 : $im_in = ImageCreateFromJPEG($src); break;
    case 3 : $im_in = ImageCreateFromPNG($src);  break;
  }
  // Æɤ߹þ¤ß¥¨¥é¡¼»þ
  if (!$im_in) {
    $im_in = ImageCreate($W,$H);
    $bgc = ImageColorAllocate($im_in, 0xff, 0xff, 0xff);
    $tc  = ImageColorAllocate($im_in, 0,0x80,0xff);
    ImageFilledRectangle($im_in, 0, 0, $W, $H, $bgc);
    ImageString($im_in,1,5,30,"Error loading {$_GET["pic"]}",$tc);
    ImagePNG($im_in);
    exit;
   }
  // ¥ê¥µ¥¤¥º
  if ($size[0] > $W || $size[1] > $H) {
    $key_w = $W / $size[0];
    $key_h = $H / $size[1];
    ($key_w < $key_h) ? $keys = $key_w : $keys = $key_h;

    $out_w = $size[0] * $keys;
    $out_h = $size[1] * $keys;
  } else {
    $out_w = $size[0];
    $out_h = $size[1];
  }
  // ½ÐÎϲèÁü¡Ê¥µ¥à¥Í¥¤¥ë¡Ë¤Î¥¤¥á¡¼¥¸¤òºîÀ®
  $im_out = ImageCreateTrueColor($out_w, $out_h);
  // ¸µ²èÁü¤ò½Ä²£¤È¤â ¥³¥Ô¡¼¤·¤Þ¤¹¡£
  ImageCopyResampled($im_out, $im_in, 0, 0, 0, 0, $out_w, $out_h, $size[0], $size[1]);

  // ¤³¤³¤Ç¥¨¥é¡¼¤¬½Ð¤ëÊý¤Ï²¼£²¹Ô¤ÈÃÖ¤­´¹¤¨¤Æ¤¯¤À¤µ¤¤¡£(GD2.0°Ê²¼
  //$im_out = ImageCreate($out_w, $out_h);
  //ImageCopyResized($im_out, $im_in, 0, 0, 0, 0, $out_w, $out_h, $size[0], $size[1]);

  // ¥µ¥à¥Í¥¤¥ë²èÁü¤ò¥Ö¥é¥¦¥¶¤Ë½ÐÎÏ¡¢Êݸ
  switch ($size[2]) {
  case 1 : if (function_exists('ImageGIF')) { ImageGIF($im_out); ImageGIF($im_out, $thumb_dir.$_GET["pic"]); } break;
  case 2 : ImageJPEG($im_out);ImageJPEG($im_out, $thumb_dir.$_GET["pic"]); break;
  case 3 : ImagePNG($im_out); ImagePNG($im_out, $thumb_dir.$_GET["pic"]);  break;
  }
  // ºîÀ®¤·¤¿¥¤¥á¡¼¥¸¤òÇË´þ
  ImageDestroy($im_in);
  ImageDestroy($im_out);
  exit;
}
// ¥Ç¥£¥ì¥¯¥È¥ê°ìÍ÷¼èÆÀ¡¢¥½¡¼¥È
$d = dir($img_dir);
while ($ent = $d->read()) {
  if (eregi($ext, $ent)) {
    $files[] = $ent;
  }
}
$d->close();
// ¥½¡¼¥È
@natsort($files);
$files2 = @array_reverse($files);
//¥Ø¥Ã¥ÀHTML
echo <<<HEAD
<!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" />
<title>$title</title>
<link href="style.css" type="text/css" rel="stylesheet" media="all" />
</head>
<body>

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

<h2>²èÁü°ìÍ÷</h2>
<table summary="¥µ¥à¥Í¥¤¥ë°ìÍ÷">
<tr>

HEAD
;

//print_r($files);
$maxs = count($files)-1;
$start = $_GET['start'];
$ends = $start+$page_def-1;
$counter = 0;
while (list($line, $filename) = @each($files2)) {
  if (($line >= $start) && ($line <= $ends)) {
    $image = rawurlencode($filename);
    // ¥µ¥à¥Í¥¤¥ë¤¬¤¢¤ë»þ¤ÏŽ»ŽÑŽÈŽ²ŽÙ¤Ø¤ÎŽØŽÝŽ¸¡¢¤½¤ì°Ê³°¤ÏŽ»ŽÑŽÈŽ²ŽÙɽ¼¨¡¢ºîÀ®
    if (file_exists($thumb_dir.$image)) $piclink = $thumb_dir.$image;
    else $piclink = $_SERVER["PHP_SELF"]."?cmd=min&pic=".$image;
    $counter++;
    if (((($counter) % $cols) == 1)&&(($counter) != 1)) {
        echo "</tr>\n<tr>\n";
    }//¥á¥¤¥óHTML
    echo <<<EOD
<td class="img"><a href="$img_dir$image"><img src="$piclink" alt="$filename" title="$filename" /><br />$filename</a></td>

EOD
;
  }
}
echo "</tr>\n</table>\n";

//ŽÍŽßŽ°Ž¼ŽÞ¥ê¥ó¥¯
echo '<p class="tline"><a href="'.$upphp.'?">Ìá¤ë</a> Page:';
if ($_GET["start"] > 0) {
  $prevstart = $_GET["start"] - $page_def;
  echo " <a href=\"$_SERVER[PHP_SELF]?start=$prevstart\">&lt;&lt;Á°¤Ø</a>";
}
if ($ends < $maxs) {
  $nextstart = $ends+1;
  echo " <a href=\"$_SERVER[PHP_SELF]?start=$nextstart\">¼¡¤Ø&gt;&gt;</a>";
}
echo '</p>';

echo '

<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>
'
;
?>