<?php
if (!defined("_GNUBOARD_")) exit; // °³º° ÆäÀÌÁö Á¢±Ù ºÒ°¡

//±×·ì ÃÖ½ÅÀÌ¹ÌÁö gd_gallery - GD Lib »ý¼ºµÈ ½æ³×ÀÏ »ç¿ë, group_new.lib.php ¹× latest_gr_paging.php ¿Í ¿¬µ¿, 
for ($i=0; $i < count($list); $i++) {
$gr_subject = cut_str($list[$i]['gr_subject'], 20);
$gr_id = $list[$i]['gr_id'];
}

#ÇÑÁÙ´ç Ç¥½ÃÇÒ ÀÌ¹ÌÁö ¼ýÀÚ
$mod = 6;//Á÷Á¢ÀÔ·Â
$td_width = (int)(100 / $mod);

?>

<meta http-equiv="imagetoolbar" content="no">
<link rel="stylesheet" type="text/css" href="<?=$g4[path]?>/gnusr/lightbox_plus/lightbox.css" />
<script type="text/javascript" src="<?=$g4[path]?>/gnusr/lightbox_plus/lightbox_plus.js"></script> 
<!-- rel='lightbox' ÇÑÆäÀÌÁö¿¡ ¿©·¯¹ø ¸µÅ©ÇÒ°æ¿ì Ä¸¼Ç¿¡·¯ ÀÖÀ¸¹Ç·Î ÁÖÀÇ -->

<table width="100%" border="1" cellspacing="0" cellpadding="0" style="border-color:#4B4B4B; border-collapse: collapse;" >
<tr><td align='left' colspan=<?=$mod?> style='padding-left:10; padding-top:5;  padding-bottom:0; background:#EEEEEE;'><a href="<?=$g4[path]?>/?gur=<?=$gr_id?>"><b><?=$gr_subject?></b></a> ÃÖ±Ù°Ô½Ã¹° 
Latest  After <?=$config[cf_new_del];//?> Day Total:<?=$total_count //=$write_pages?></td></tr>
<tr>

<?php

if (count($list) > 0) {

for ($i=0; $i < count($list); $i++) {

$data_path = $g4['path'] . "/data/file/{$list[$i][bo_table]}";//È¯°æ¼³Á¤ ÆÄÀÏ ÂüÁ¶
$thumb_path = $data_path . '/thumb';
$thumb_size = 100;
$thumb_quality = 80;

if (!is_dir($thumb_path)) {
@mkdir($thumb_path, 0707);
@chmod($thumb_path, 0707);
}

$gr_subject = cut_str($list[$i]['gr_subject'], 10);
$bo_subject = cut_str($list[$i]['bo_subject'], 14);
$wr_subject = get_text(cut_str($list[$i]['wr_subject'], 20));
$ca_name = cut_str($list[$i]['ca_name'], 10);

  if ($i > 0 && $i % $mod == 0)
    echo "</tr><tr>";

    $img = "<img src='$latest_skin_path/img/noimage.gif' border=0 width='100' title='ÀÌ¹ÌÁö ¾øÀ½'>";

    $filename = $list[$i]['bf_file'];

    $dest_file = $data_path .'/'. $filename;
        
    if (preg_match("/\.(jp[e]?g|gif|png)$/i", $filename) && file_exists($dest_file)){
        //$thumb = "$thumb_path/".urlencode($row3['bf_file']);//°ø¹é¹®ÀÚ º¯Çü(+, %2B) ÆÄÀÏ¸íÀ¸·Î »ý¼ºµÊ
        $thumb = $thumb_path . '/' . $filename;
        if (!file_exists($thumb)) {

          $size = getimagesize($dest_file);
          if ($size[2] == 1)
            $src = imagecreatefromgif($dest_file);
          else if ($size[2] == 2)
            $src = imagecreatefromjpeg($dest_file);
          else if ($size[2] == 3)
            $src = imagecreatefrompng($dest_file);
          else
            break;
        //°¡·Î,¼¼·Î ÃÖ´ë»çÀÌÁî Á¦ÇÑ,    Daeng`2´Ô ÆÁ
           if ($size[0] >= $size[1]) {
            $rate = $thumb_size / $size[0];
            $width = $thumb_size;
            $height = (int)($size[1] * $rate);
            }
            else {
            $rate = $thumb_size / $size[1];
            $width = (int)($size[0] * $rate);
            $height = $thumb_size;
            }
            $dst = imagecreatetruecolor($width, $height);
            imagecopyresampled($dst, $src, 0, 0, 0, 0, $width, $height, $size[0], $size[1]);
            imagepng($dst, $thumb, $thumb_quality);
            chmod($thumb, 0707); 
        }

    if (file_exists($thumb))
      $img = "<img src='$thumb' border='0' title='" . $list[$i]['bf_source'] . " Hit: " . $list[$i]['wr_hit'] . "'>"; 

    }


  $style = "";
  if ($list[$i]['icon_new'])
  $style = " style='font-weight:bold;' ";
  $subject = "<span $style>" . cut_str($list[$i]['wr_subject'], 20) . "</span>";

  $comment_cnt = "";
  if ($list[$i]['comment_cnt'])
    $comment_cnt = " <a href=\"" . $list[$i]['comment_href'] . "\"><span style='font-size:7pt;'>" . $list[$i]['comment_cnt'] . "</span></a>";

//<a href='$file' rel='lightbox'>$img</a>
//<a href='" . $list[$i]['href'] . "&sca=" . $list[$i]['ca_name'] . "'>{$img}</a>
//<a href='$data_path . '/' . $file_name' rel='lightbox'>{$img}</a>
  echo "

<td width='{$td_width}%' valign=bottom style='word-break:break-all;'>
    <table width=100% cellspacing='0' cellpadding='0'>
    <tr><td height=5></td></tr>
    <tr><td align=center><a href='{$dest_file}' rel='lightbox'>{$img}</a></td></tr>
    <tr><td align=center style='line-height:110%; padding-top:2px; font-size:9pt;'><a href='" . $list[$i]['href'] . "&sca=" . $list[$i]['ca_name'] . "'>{$subject}</a>{$comment_cnt}<br>
    <a href='" . $list[$i]['ca_name_href'] . "'><font color='#cccccc'>[{$ca_name}]</a>" . $list[$i]['datetime2'] . "</font><br><a href='{$g4['bbs_path']}/board.php?bo_table={$list[$i]['bo_table']}'><font color='#cccccc'>{$bo_subject}</font></a></td></tr>
    <tr><td height=3></td></tr>
    </table>
</td>

  ";

}//for

// ³ª¸ÓÁö td
$cnt = $i % $mod;
if ($cnt > 0) {
  for ($i=$cnt; $i < $mod; $i++) {
    echo "<td width='{$td_width}%'>&nbsp;</td>";
    }
}

echo "</tr>";

}//if (count~
else{

//°Ô½Ã¹°ÀÌ ¾øÀ» ¶§
if (count($list) == 0){
    echo "<tr><td colspan='$mod' height=100 align=center>°Ô½Ã¹°ÀÌ ¾ø½À´Ï´Ù.</td></tr>";
    }

}

//ÆäÀÌÂ¡
if ($write_pages){
echo "<tr><td colspan='$mod' height='30' align='center' style='padding-right:10; padding-top:5;  padding-bottom:0; background:#EEEEEE;'>{$write_pages}</td></tr>";
}

?>

</table>
<?//=print_r2($file);?>