게시판 전체 게시글 원글과 조회수 재설정하기
어떤 특별한 이유에 의해서 게시글의 조회수가 엉키는 경우가 있습니다.
예를 들면 스팸게시글의 침범으로 인한 ...
이렇게 되면 글 번호가 엉키면서 - 번호가 생기기도 하죠.
게시판 관리자 화면에 가면 하나씩 재설정 하는 항목이 있지만, 게시판 수가 많다면 그것도 여간 귀찮은 일이 아닐수 없습니다.
아래 프로그램은 전체 게시판을 모두 재설정하는 방법입니다.
그누보드5 / DB_table_count_reset.php 라는 이름으로 파일을 생성후 브라우저로 실행합니다.
<?php
include_once "_common.php";
$dbconn = mysqli_connect(G5_MYSQL_HOST,G5_MYSQL_USER,G5_MYSQL_PASSWORD,G5_MYSQL_DB) ;
if (!$dbconn) {
echo "Error: Unable to connect to MySQL." . PHP_EOL;
echo "Debugging errno: " . mysqli_connect_errno() . PHP_EOL;
echo "Debugging error: " . mysqli_connect_error() . PHP_EOL;
exit;
}
//@mysqli_query("set names utf8"); // 한글문제 생기면 주석 해제
$sql = "select * from ".$g5['board_table']." order by bo_table asc ";
$result = mysqli_query($dbconn,$sql);
while($data = mysqli_fetch_array($result)) {
$bo_table = $data["bo_table"];
//echo $data["bo_table"] ."<br>";
// 게시판의 글 수
$sql = " select count(*) as cnt from ".$g5['write_prefix'].$bo_table." where wr_is_comment = 0 ";
$row = sql_fetch($sql);
$bo_count_write = $row['cnt'];
// 게시판의 코멘트 수
$sql = " select count(*) as cnt from ".$g5['write_prefix'].$bo_table." where wr_is_comment = 1 ";
$row = sql_fetch($sql);
$bo_count_comment = $row['cnt'];
if (isset($_POST['proc_count'])) {
// 원글을 얻습니다.
//$sql = " select wr_id from {$g5['write_prefix']}{$bo_table} where wr_is_comment = 0 ";
$sql = " select a.wr_id, (count(b.wr_parent) - 1) as cnt from ".$g5['write_prefix'].$bo_table." a, ".$g5['write_prefix'].$bo_table." b where a.wr_id=b.wr_parent and a.wr_is_comment=0 group by a.wr_id ";
$result = mysqli_query($dbconn,$sql);
for ($i=0; $row=mysqli_fetch_array($result); $i++) {
/*
// 코멘트수를 얻습니다.
$sql2 = " select count(*) as cnt from {$g5['write_prefix']}$bo_table where wr_parent = '{$row['wr_id']}' and wr_is_comment = 1 ";
$row2 = sql_fetch($sql2);
*/
mysqli_query($dbconn," update ".$g5['write_prefix'].$bo_table." set wr_comment = '".$row['cnt']."' where wr_id = '".$row['wr_id']."' ");
}
}
// 공지사항에는 등록되어 있지만 실제 존재하지 않는 글 아이디는 삭제합니다.
$bo_notice = "";
$lf = "";
if ($board['bo_notice']) {
$tmp_array = explode(",", $board['bo_notice']);
for ($i=0; $i<count($tmp_array); $i++) {
$tmp_wr_id = trim($tmp_array[$i]);
$row = sql_fetch(" select count(*) as cnt from ".$g5['write_prefix'].$bo_table." where wr_id = '".$tmp_wr_id."' ");
if ($row['cnt'])
{
$bo_notice .= $lf . $tmp_wr_id;
$lf = ",";
}
}
}
$sql = " update ".$g5['board_table']."
set bo_notice = '".$bo_notice."',
bo_count_write = '".$bo_count_write."',
bo_count_comment = '".$bo_count_comment."'
where bo_table = '".$bo_table."' ";
mysqli_query($dbconn,$sql);
}
echo " 게시판의 원글수와 댓글수 재설정 완료 ";
echo mysqli_error($dbconn);
// close connection
mysqli_close($dbconn);
?>
댓글 4개
게시판 목록
그누보드5 팁자료실
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 공지 | 3년 전 | 4429 | ||
| 2544 | 12개월 전 | 945 | ||
| 2543 | 12개월 전 | 843 | ||
| 2542 | 12개월 전 | 747 | ||
| 2541 | 12개월 전 | 775 | ||
| 2540 | 12개월 전 | 1187 | ||
| 2539 | 1년 전 | 1021 | ||
| 2538 | 1년 전 | 1006 | ||
| 2537 |
|
1년 전 | 842 | |
| 2536 | 1년 전 | 1227 | ||
| 2535 |
|
1년 전 | 783 | |
| 2534 |
|
1년 전 | 889 | |
| 2533 |
거북이와두루미
|
1년 전 | 1663 | |
| 2532 | 1년 전 | 798 | ||
| 2531 | 1년 전 | 675 | ||
| 2530 | 1년 전 | 720 | ||
| 2529 | 1년 전 | 1064 | ||
| 2528 |
|
1년 전 | 556 | |
| 2527 | 1년 전 | 1134 | ||
| 2526 | 1년 전 | 746 | ||
| 2525 | 1년 전 | 1110 | ||
| 2524 | 1년 전 | 912 | ||
| 2523 | 1년 전 | 1339 | ||
| 2522 | 1년 전 | 958 | ||
| 2521 | 1년 전 | 1310 | ||
| 2520 | 1년 전 | 1189 | ||
| 2519 | 1년 전 | 1060 | ||
| 2518 |
Lemios
|
1년 전 | 868 | |
| 2517 | 1년 전 | 955 | ||
| 2516 | 1년 전 | 1703 | ||
| 2515 | 1년 전 | 847 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기