// 댓글
function latest_comment($skin_dir='', $bo_table, $rows=10, $subject_len=40, $cache_time=1)
{
    global $g5;

    if (!$skin_dir) $skin_dir = 'basic';

    $time_unit = 3600;

    if (G5_IS_MOBILE) {
        $latest_skin_path = G5_MOBILE_PATH.'/'.G5_SKIN_DIR.'/latest/'.$skin_dir;
        $latest_skin_url  = G5_MOBILE_URL.'/'.G5_SKIN_DIR.'/latest/'.$skin_dir;
    } else {
        if(preg_match('#^theme/(.+)$#', $skin_dir, $match)) {
            $latest_skin_path = G5_THEME_PATH.'/'.G5_SKIN_DIR.'/latest/'.$match[1];
            $latest_skin_url  = G5_THEME_URL.'/'.G5_SKIN_DIR.'/latest/'.$match[1];
        } else {
            $latest_skin_path = G5_SKIN_PATH.'/latest/'.$skin_dir;
            $latest_skin_url  = G5_SKIN_URL.'/latest/'.$skin_dir;
        }
    }

    $list = array();
    $board = get_board_db($bo_table, true);

    if (!$board) return '';

    $bo_subject = get_text($board['bo_subject']);
    $tmp_write_table = $g5['write_prefix'] . $bo_table;

    $sql = "SELECT * FROM {$tmp_write_table}
            WHERE wr_is_comment = 1
            ORDER BY wr_id DESC
            LIMIT {$rows}";

    $result = sql_query($sql);
    for ($i=0; $row = sql_fetch_array($result); $i++) {
        $list[$i] = get_list($row, $board, $latest_skin_url, $subject_len);
    }

    ob_start();
    include $latest_skin_path.'/latest.skin.php';
    $content = ob_get_contents();
    ob_end_clean();

    return $content;
}
