// 게시물 읽기 관련 작업들
// 작업 개요
/*
1. 해당 게시물의 접근권한이 있는지 확인하고,
2. 페이지 우측 상단에 있는 해당 게시판의 서브 섹션들 표시하고,
3. 읽은 횟수 증가 시키고,
4. 해당 게시물 가져오고,
5. 다운로드와 댓글이 있다면, 각각 처리해서
6. html/read.php 파일 호출함.
*/
/*
저작권: 이 파일에서 다루고 있는 모든 코드는 다음 조건 아래서,
제작자의 동의 없이, 상업적이든 그렇지않든 마음대로 사용할 수 있습니다.
조건1: 코드가 수정되지 않고 부분적으로 사용될 경우는 반드시
이 저작권을 명시해야합니다.
조건2: 코드가 수정되었을 경우는 변경된 부분을 반드시 명시하고,
그 변경된 부분에 대한 저작권은 변경자의 제량에 맡깁니다.
조건3: 이 코드를 사용함으로 인해 발생하는 불이익에 대한 책임은 제작자에게 없습니다.
제1차 제작자: 김상기 접근 권한 없음 \n";
return $str;
}
}
// 다운로드 파일 크기를 쉽게 표현하기 위해서
function commonfilesize($fsize){
if($fsize > 1048576){
$fsize = number_format($fsize / 1048576, 2);
$fsize = "$fsize MB";
}
elseif($fsize > 1024){
$fsize = number_format($fsize / 1024, 2);
$fsize = "$fsize KB";
}
else {
$fsize = "$fsize byte";
}
return $fsize;
}
// 간략 목록을 위한 내부 함수
// 루틴은 pg_result->printtr() 하고 같음
function mktr($row, $bgcolor, $depthstr = ""){
global $criteria, $id, $limit, $ukeyword, $page;
$str = "파일이름 크기 Info comments) $str .= " [$row->comments]";
$str .= " \n";
return $str;
}
// 페이지 하단 간략 목록
function mkbrieflist($pgdb, $row){
global $worktable, $subcrit, $keyword;
// 현재글의 최상위 글부터 상위 3개 하위 3개 보이기
// 검색어가 있을 때는 관련글하고,
$s = "\n";
$s .= "
\n";
return $s;
}
// 접근 권한 처리
$allowgroups = split(",", ereg_replace("[{}]", "",$menuinfo->vgroups));
$ispermit = false;
// 관리자면 무조건 OK
if($userinfo->groups[1]){
$ispermit = true;
}
// 아무나면 무조건 OK
if($allowgroups[0] == ""){
$ispermit = true;
}
foreach($allowgroups as $allowgroup){
if($ispermit) break;
if($userinfo->groups[$allowgroup]) {
$ispermit = true;
}
}
if(! $ispermit){
$errormsg = "
\n";
$res = $pgdb->exec("select id from $worktable where id > $row->gid and topic = '$row->topic' and pid = 0 order by id limit 3");
if(pg_num_rows($res)) {
list($startid) = pg_fetch_row($res, pg_num_rows($res) - 1);
$limit = 4 + pg_num_rows($res);
}
else {
$startid = $row->gid;
$limit = 4;
}
$res = $pgdb->exec("select id,gid,subject,name,reads,to_char(abstime(cdate), 'YYYY-MM-DD') as cdate, crows, comments from $worktable where id <= $startid and topic = '$row->topic' and pid = 0 order by id desc limit $limit");
$i = 0;
while($brow = @pg_fetch_object($res, $i++)){
if(($brow->id != $row->id) && ($brow->gid == $row->gid)){
$s .= mktr($brow, "#dddffe");
}
else {
if($brow->id == $row->id) $s .= mktr($brow, '#aaaccb');
else $s .= mktr($brow,"");
}
if($brow->crows){
$res2 = $pgdb->exec("select * from getthread('$worktable',$brow->id,1) as t(depth int,id int,subject text, name text, cdate int, reads int, comments int, commdate int, deleted int, crows int)");
$j = 0;
while($bbrow = @pg_fetch_object($res2, $j++)){
$bbrow->cdate = date("Y-m-d",$bbrow->cdate);
$depthstr = "";
for($k = 1; $k < $bbrow->depth; $k++){
$depthstr .= " ";
}
if($bbrow->depth) $depthstr .= "";
if(($bbrow->id != $row->id) && ($bbrow->gid == $row->gid)) $s .= mktr($bbrow, '#dddffe', $depthstr);
else {
if($bbrow->id == $row->id) $s .= mktr($bbrow, '#aaaccb', $depthstr);
else $s .= mktr($bbrow,"", $depthstr);
}
}
}
}
$s .= "
페이지 주소를 다시 한번 확인해 보시고 바르게 호출해 주십시오."; include("html/error.php"); exit; } $aid || $aid = '0'; // 게시물 읽은 횟수 증가 if($userinfo->num) $pgdb->exec("update $worktable set reads = reads + 1 where id = '$aid' and usernum <> $userinfo->num"); else $pgdb->exec("update $worktable set reads = reads + 1 where id = '$aid'"); $row = @pg_fetch_object($pgdb->exec("select * from $worktable where id = '$aid'"),0); if($menuinfo->subcrit != $row->topic){ $subcritinfo = pg_fetch_object($pgdb->exec("select * from menus where criteria = '$criteria' and subcrit = '$row->topic'"),0); } if(! $row->id){ $errormsg .= "
해당 게시물 없음
삭제된 게시물
"; $row->name = ""; $row->uid = 0; $row->reads = 0; $row->cdate = 0; } // 파일 다운로드 처리 // if($menuinfo->allowupload == 't'){ if($userinfo->groups[1] || $userinfo->groups[3] || ($userinfo->num == $row->usernum)){ $deleteattach = "'X' as dowork"; } else{ $deleteattach = "' ' as dowork"; } $uploadres = new upres($pgdb->conn, $pgdb->exec("select '' || fname || '' as 파일이름, case when fsize > 1048576 then to_char(fsize::float / 1048576, 'FM999,999,999,999.99') || ' MB' when fsize > 1024 then to_char(fsize::float / 1024, 'FM999,999,999,999.99') || ' KB' else to_char(fsize, 'FM999,999,999,999') || ' bytes' end as 크기, case when fwidth > 0 then to_char(fwidth, 'FM999,999,999,999') || 'px * ' || to_char(fheight, 'FM999,999,999,999') || 'px' else '' end || case when ftype = 4 then ', ' else '' end || case when ftime > 0 then text(ftime)::interval::text else '' end as \"Info\", $deleteattach from uploadfiles where menuid = $subcritinfo->menuid and pid = $aid order by num")); $uptableinfo->class = "uploadtable"; $uptableinfo->cellspacing = "0"; $uptableinfo->cellpadding = "3"; $uptableinfo->border = "0"; $tUpload = $uploadres->printtable($uptableinfo); //} // 댓글 처리 // 코드가 지저분한 이유가 로그인했을때와 안했을때, 관리자일때와 아닐때, 등 온갖 경우 때문임 $comment_list = ""; if($row->comments){ $res = $pgdb->exec("select * from comments where ptable = '$worktable' and pid = '$row->id' order by cdate"); $i = 0; while($corow = @pg_fetch_object($res, $i++)){ $corow->content = highlight($corow->content, $arrkeyword); if((! ereg("^<", $corow->content)) && (!ereg("", $corow->content))){ $corow->content = ereg_replace("\r", "
", $corow->content); $corow->content = ereg_replace("\n", "\n", $corow->content); if(! ereg("
\n$", $corow->content)) $corow->content .= "\n"; $corow->content = ereg_replace("[ \t]{0,}
", "", $corow->content); $corow->content = "
" . $corow->content; } else{ $corow->content = str_replace("
","
",$corow->content); $corow->content = str_replace("
","",$corow->content); } $comment_list .= "
이 댓글은 " . date("Y-m-d H:i:s", $corow->mdate) . "에 마지막으로 수정되었습니다."; } if($corow->usernum < 1){ $comment_list .= " Edit "; if($userinfo->groups[1] || $userinfo->groups[3]){ $comment_list .= "X"; } else{ $comment_list .= "X"; } } else { if(($corow->usernum == $userinfo->num) || ($userinfo->groups[1])){ if($corow->usernum == $userinfo->num){ $comment_list .= " Edit "; } $comment_list .= "X"; } } $comment_list .= "