$part) { $description .= $part; // 문장 끝이면 멈춤 if (preg_match('/[.?!]$/', $part)) { if (mb_strlen($description, 'UTF-8') >= 80) break; // 최소 길이 보장 } if (mb_strlen($description, 'UTF-8') > $max_length) break; } // 너무 짧으면 fallback if (mb_strlen($description, 'UTF-8') < 50) { $description = mb_substr($text, 0, $max_length, 'UTF-8') . '...'; } return trim($description); } // 메인페이지 여부 $is_main = (!isset($bo_table) && !isset($wr_id)); // 메인 페이지용 if ($is_main) { $meta_title = "사회주의를향한전진 | 위기의 시대, 노동계급이 주도하는 혁명"; $meta_description = "위기의 시대, 노동계급이 주도하는 혁명으로 자본주의를 철폐해 착취·억압·차별이 없는 해방사회로 나아가고자 하는 사회주의를향한전진입니다."; $canonical_url = G5_URL . "/"; $og_image = G5_URL . "/img/social-share-default.jpg"; // 게시글 상세 페이지 } elseif (isset($bo_table) && isset($wr_id)) { $write_table = $g5['write_prefix'] . $bo_table; $sql = "SELECT wr_subject, wr_content FROM {$write_table} WHERE wr_id = '$wr_id'"; $row = sql_fetch($sql); $meta_title = get_text(mb_strimwidth($row['wr_subject'], 0, 60, "...", 'UTF-8')) . " | 사회주의를향한전진"; $meta_description = get_meta_description($row['wr_content'], 150); if (preg_match('/]+src=["\']([^"\']+)["\']/', $row['wr_content'], $matches)) { $og_image = (strpos($matches[1], 'http') === 0) ? $matches[1] : G5_URL . $matches[1]; } else { $og_image = G5_URL . "/img/social-share-default.jpg"; } $canonical_url = G5_URL . "/bbs/board.php?bo_table={$bo_table}&wr_id={$wr_id}"; // 기타 페이지 } else { $meta_title = "사회주의를향한전진 | 위기의 시대, 노동계급이 주도하는 혁명"; $meta_description = "위기의 시대, 노동계급이 주도하는 혁명으로 자본주의를 철폐해 착취·억압·차별이 없는 해방사회로 나아가고자 하는 사회주의를향한전진입니다."; $canonical_url = G5_URL . $_SERVER['REQUEST_URI']; $og_image = G5_URL . "/img/social-share-default.jpg"; } ?> <?= htmlspecialchars($meta_title) ?>