*/ // 코드가 정리 되지 않았습니다. 알아서 잘들 보시길 // 다운로드 파일 목록 보여주기위한 pg_result 확장 class upres extends pg_result { function printheadtr($tinfo){ $str .= "파일이름크기Info \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 = "comments) $str .= " [$row->comments]"; $str .= "
$row->name
$row->cdate
$row->reads
\n"; return $str; } // 페이지 하단 간략 목록 function mkbrieflist($pgdb, $row){ global $worktable, $subcrit, $keyword; // 현재글의 최상위 글부터 상위 3개 하위 3개 보이기 // 검색어가 있을 때는 관련글하고, $s = "\n"; $s .= " \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 .= "
No.
제목
작성자
작성일
조회
\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"; $errormsg .= "이 작업은 오직 " . getGroupNames($pgdb,$allowgroups) . " 그룹 회원들만 허용합니다.

"; include("html/error.php"); exit; } // 페이지 우측 상단 서브 섹션 처리 $res = $pgdb->exec("select * from menus where criteria = '$criteria' and subcrit <> '' order by sortnum"); $i = 0; $subcrits = ""; $havesubcrit = false; $nothadsub = false; while($subrow = @pg_fetch_object($res,$i++)){ if($i > 1) $subcrits .= " | "; if($subcrit != $subrow->subcrit) { if((!$subcrit) && (! $keyword) && ($subrow->subcrit == "qna")) { $nothadsub = true; $subcrit = "qna"; $subcrits .= ""; } else $subcrits .= ""; } else $subcrits .= ""; $subcrits .= $subrow->name; if($subcrit != $subrow->subcrit) { if((!$subcrit) && (! $keyword) && ($subrow->subcrit == "qna")) $subcrits .= ""; else $subcrits .= ""; } else $subcrits .= ""; $havesubcrit = true; } if($havesubcrit && $nothadsub){ $subcritinfo = pg_fetch_object($pgdb->exec("select * from menus where criteria = '$criteria' and subcrit = 'qna'"),0); $menuinfo = $subcritinfo; $worktable = "bd_$critinfo->menuid"; } if($worktable == "bd_1"){ $errormsg = "요청하신 페이지의 주소가 타당치 못해서 바르게 처리하질 못했습니다.

페이지 주소를 다시 한번 확인해 보시고 바르게 호출해 주십시오."; 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 .= "

해당 게시물 없음

"; include("html/error.php"); exit; } if($row->deleted){ $row->subject = " "; $row->content = "

삭제된 게시물

"; $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 = "'' 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 .= "
\n
$corow->content
\n
" . highlight($corow->name, $arrkeyword); if($corow->uid != "guest") $comment_list .= "(" . highlight($corow->uid, $arrkeyword) . ")"; if(($userinfo->groups[1] || $userinfo->groups[3]) && $corow->email) $comment_list .= " "; $comment_list .= "님이 " . date("Y-m-d H:i:s", $corow->cdate) . "에 작성한 댓글입니다."; if($corow->mdate) { $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 .= ""; } else{ $comment_list .= ""; } } else { if(($corow->usernum == $userinfo->num) || ($userinfo->groups[1])){ if($corow->usernum == $userinfo->num){ $comment_list .= " Edit "; } $comment_list .= ""; } } $comment_list .= "
\n"; } } // aid의 gid의 앞으로 세 개, 뒤로 세 개 $brief_list = mkbrieflist($pgdb, $row); include("html/read.php"); ?>