게시판 전체 게시글 원글과 조회수 재설정하기
어떤 특별한 이유에 의해서 게시글의 조회수가 엉키는 경우가 있습니다.
예를 들면 스팸게시글의 침범으로 인한 ...
이렇게 되면 글 번호가 엉키면서 - 번호가 생기기도 하죠.
게시판 관리자 화면에 가면 하나씩 재설정 하는 항목이 있지만, 게시판 수가 많다면 그것도 여간 귀찮은 일이 아닐수 없습니다.
아래 프로그램은 전체 게시판을 모두 재설정하는 방법입니다.
그누보드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년 전 | 4436 | ||
| 2424 | 1년 전 | 1145 | ||
| 2423 | 1년 전 | 1164 | ||
| 2422 |
|
1년 전 | 1841 | |
| 2421 | 1년 전 | 1067 | ||
| 2420 |
|
1년 전 | 1846 | |
| 2419 | 1년 전 | 1156 | ||
| 2418 | 1년 전 | 1144 | ||
| 2417 | 1년 전 | 932 | ||
| 2416 | 1년 전 | 1226 | ||
| 2415 | 1년 전 | 1111 | ||
| 2414 | 1년 전 | 998 | ||
| 2413 | 1년 전 | 1400 | ||
| 2412 |
|
1년 전 | 2004 | |
| 2411 | 1년 전 | 995 | ||
| 2410 | 1년 전 | 1864 | ||
| 2409 | 1년 전 | 1695 | ||
| 2408 | 1년 전 | 1192 | ||
| 2407 | 1년 전 | 1163 | ||
| 2406 | 1년 전 | 837 | ||
| 2405 | 1년 전 | 2046 | ||
| 2404 |
와칸다포에버
|
1년 전 | 1052 | |
| 2403 | 1년 전 | 1126 | ||
| 2402 |
뽕엄능브라
|
1년 전 | 2058 | |
| 2401 | 1년 전 | 1163 | ||
| 2400 | 1년 전 | 1266 | ||
| 2399 | 1년 전 | 1851 | ||
| 2398 | 1년 전 | 1586 | ||
| 2397 | 1년 전 | 1896 | ||
| 2396 | 1년 전 | 1262 | ||
| 2395 | 1년 전 | 1081 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기