include "./kboard.php3";
include "./bbscfg.php3";
//데이터베이스에 연결 ***************************************************************
mysql_connect($dbhost, $dbusername, $dbuserpassword);
mysql_select_db($dbname);
// *******************************************************************************
// 페이지를 셋팅합니다. ************************************************************
if($cur_page == "")
$cur_page = 1;
$start_page = ($cur_page - 1) * $max_msg_per_page;
// *******************************************************************************
// SQL Statement for Table Display ***********************************************
if($order == "")
$order = "desc";
// order값이 desc일때, 즉 목록순서로 정렬할 때이다. **********************************
if($order == "desc") {
//****************************************************************************
$result = mysql_query("select count(*) from $tablename");
if(!$result) {
print "DB Error No.1[contact to webmaster]";
exit;
}
$query_data = mysql_fetch_row($result);
$msg_total = $query_data[0];
$count_message = "총 ".$msg_total." 개의 게시물이 있습니다.";
if(($msg_total % $max_msg_per_page) == 0){
$page_total = (int) ($msg_total / $max_msg_per_page); // No remain
}
else{
$page_total = (int) ($msg_total / $max_msg_per_page) + 1;
}
$result = mysql_query("select count(*) from $tablename where ".$prefix."thread_info='000'");
if(!$result) {
print "DB Error No.2";
exit;
}
$query_data = mysql_fetch_row($result);
$thread_total = $query_data[0];
//****************************************************************************
$result = mysql_query("select ".$prefix."msg_id, ".$prefix."thread_id, ".$prefix."msg_subject, ".$prefix."author, ".$prefix."msg_hit, ".$prefix."msg_date, ".$prefix."thread_depth, ".$prefix."file1name, ".$prefix."file2name, ".$prefix."file3name, ".$prefix."category from $tablename order by ".$prefix."thread_id desc, ".$prefix."thread_info limit $start_page, $max_msg_per_page");
if(!$result) {
print "Error occurred. No 3";
exit;
}
$num_rows = mysql_num_rows($result);
}
// order값이 category일때, 즉 카테고리로 정렬할 때이다. **********************************
else if ($order == "cate") {
//****************************************************************************
$result = mysql_query("select count(*) from $tablename ");
if(!$result) {
print "DB Error No.1[contact to webmaster]";
exit;
}
$query_data = mysql_fetch_row($result);
$msg_total2 = $query_data[0];
$result = mysql_query("select count(*) from $tablename where ".$prefix."category='$categ' ");
if(!$result) {
print "DB Error No.1[contact to webmaster]";
exit;
}
$query_data = mysql_fetch_row($result);
$msg_total = $query_data[0];
$count_message = "총 ".$msg_total2.'/'.$msg_total." 개의 게시물이 있습니다.";
if(($msg_total % $max_msg_per_page) == 0){
$page_total = (int) ($msg_total / $max_msg_per_page); // No remain
}
else{
$page_total = (int) ($msg_total / $max_msg_per_page) + 1;
}
$result = mysql_query("select count(*) from $tablename where ".$prefix."thread_info='000'");
if(!$result) {
print "DB Error No.2";
exit;
}
$query_data = mysql_fetch_row($result);
$thread_total = $query_data[0];
$result = mysql_query("select ".$prefix."msg_id, ".$prefix."thread_id, ".$prefix."msg_subject, ".$prefix."author, ".$prefix."msg_hit, ".$prefix."msg_date, ".$prefix."thread_depth , ".$prefix."file1name, ".$prefix."file2name, ".$prefix."file3name,".$prefix."category from $tablename where ".$prefix."category='$categ' order by ".$prefix."msg_date desc, ".$prefix."msg_id limit $start_page, $max_msg_per_page");
if(!$result) {
echo "";
mysql_close();
exit;
}
$num_rows = mysql_num_rows($result);
}
// order값이 asc일때, 즉 시간순서로 정렬할 때이다. **********************************
else if ($order == "asc") {
//****************************************************************************
$result = mysql_query("select count(*) from $tablename");
if(!$result) {
print "DB Error No.1[contact to webmaster]";
exit;
}
$query_data = mysql_fetch_row($result);
$msg_total = $query_data[0];
$count_message = "총 ".$msg_total." 개의 게시물이 있습니다.";
if(($msg_total % $max_msg_per_page) == 0){
$page_total = (int) ($msg_total / $max_msg_per_page); // No remain
}
else{
$page_total = (int) ($msg_total / $max_msg_per_page) + 1;
}
$result = mysql_query("select count(*) from $tablename where ".$prefix."thread_info='000'");
if(!$result) {
print "DB Error No.2";
exit;
}
$query_data = mysql_fetch_row($result);
$thread_total = $query_data[0];
$result = mysql_query("select ".$prefix."msg_id, ".$prefix."thread_id, ".$prefix."msg_subject, ".$prefix."author, ".$prefix."msg_hit, ".$prefix."msg_date, ".$prefix."thread_depth , ".$prefix."file1name, ".$prefix."file2name, ".$prefix."file3name,".$prefix."category from $tablename order by ".$prefix."msg_date desc, ".$prefix."msg_id limit $start_page, $max_msg_per_page");
if(!$result) {
print "Error occurred. No 4";
mysql_close();
exit;
}
$num_rows = mysql_num_rows($result);
}
// order값이 hit일때, 즉 조회순서로 정렬할 때이다. **********************************
else if ($order == "hit") {
$result = mysql_query("select count(*) from $tablename");
if(!$result) {
print "DB Error No.1[contact to webmaster]";
exit;
}
$query_data = mysql_fetch_row($result);
$msg_total = $query_data[0];
$count_message = "총 ".$msg_total." 개의 게시물이 있습니다.";
if(($msg_total % $max_msg_per_page) == 0){
$page_total = (int) ($msg_total / $max_msg_per_page); // No remain
}
else{
$page_total = (int) ($msg_total / $max_msg_per_page) + 1;
}
$result = mysql_query("select count(*) from $tablename where ".$prefix."thread_info='000'");
if(!$result) {
print "DB Error No.2";
exit;
}
$query_data = mysql_fetch_row($result);
$thread_total = $query_data[0];
$result = mysql_query("select ".$prefix."msg_id, ".$prefix."thread_id, ".$prefix."msg_subject, ".$prefix."author, ".$prefix."msg_hit, ".$prefix."msg_date, ".$prefix."thread_depth , ".$prefix."file1name, ".$prefix."file2name, ".$prefix."file3name,".$prefix."category from $tablename order by ".$prefix."msg_hit desc, ".$prefix."msg_id desc limit $start_page, $max_msg_per_page");
if(!$result) {
print "Error occurred. No 5";
mysql_close();
exit;
}
$num_rows = mysql_num_rows($result);
}
else if ($order == "search") {
$keyword = eregi_replace("\+", " ", $keyword);
$keyword_list = split(" ", $keyword);
$total_array_num = count($keyword_list);
$sqlquery = "select count(*) from $tablename ";
$sqlquery .= " where ".$prefix.$search_option." like '%".$keyword."%' order by ".$prefix."msg_id desc";
$result = mysql_query($sqlquery);
if (!$result){
print "Error No. 5-1";
mysql_close();
exit;
}
$num_rows = mysql_fetch_row($result);
if($search_option == "msg_subject")
$count_message = "제목에서 ";
else if($search_option == "author")
$count_message = "이름에서 ";
else if($search_option == "msg_body")
$count_message = "본문에서 ";
$count_message .= "".$keyword."의 검색결과 총 ".$num_rows[0]." 개의 게시물이 있습니다.";
//Search시 페이지 생성 부분
if(($num_rows[0] % $max_msg_per_page) == 0){
$page_total = (int) ($num_rows[0] / $max_msg_per_page); // No remain
}
else{
$page_total = (int) ($num_rows[0] / $max_msg_per_page) + 1;
}
$sqlquery = "select count(*) from $tablename where ".$prefix.$search_option." like '%".$keyword."%'";
$result = mysql_query($sqlquery);
if(!$result){
print "Search Error. No 1";
mysql_close();
exit;
}
$query_data = mysql_fetch_row($result);
$msg_total = $query_data[0];
$sqlquery = "select ".$prefix."msg_id, ".$prefix."thread_id, ".$prefix."msg_subject, ".$prefix."author, ".$prefix."msg_hit, ".$prefix."msg_date, ".$prefix."thread_depth , ".$prefix."file1name, ".$prefix."file2name, ".$prefix."file3name, ".$prefix."category from $tablename ";
$sqlquery .= " where ".$prefix.$search_option." like '%".$keyword."%' order by ".$prefix."msg_id desc limit $start_page, $max_msg_per_page";
$result = mysql_query($sqlquery);
if(!$result) {
print "Search Error. No 2";
mysql_close();
exit;
}
$num_rows = mysql_num_rows($result);
}
?>
?>
; ?>) |
|
cellspacing=0 border=0 >
echo(""); echo("| 번 호 | ");
echo(""); ?>
|
echo("제 목 | ");
echo("이 름 | ");
echo("날 짜 | ");
echo("조회 | ");
?>
// Record Count Generation
$count = $start_page + 1; //BLUEICE
$revcount = $msg_total - $count + 1; //BLUEICE
for ($i = 0; $i < $num_rows; $i++){
$query_data = mysql_fetch_row($result);
$msg_id = $query_data[0];
$thread_id = $query_data[1];
$subject = $query_data[2];
$author = $query_data[3];
$msg_hit = $query_data[4];
$msg_date = $query_data[5];
$thread_depth = $query_data[6];
$file1name = $query_data[7];
$file2name = $query_data[8];
$file3name = $query_data[9];
$category = $query_data[10];
$attach_date = explode(" ", $msg_date);
$attach_date = ereg_replace( "-", "", $attach_date[0]);
$file1path = "./upload/".$attach_date."/".$msg_id."/".$file1name;
$file2path = "./upload/".$attach_date."/".$msg_id."/".$file2name;
$file3path = "./upload/".$attach_date."/".$msg_id."/".$file3name;
if($file1name != "")
$attach1 = " ";
else
$attach1 = " ";
if($file2name != "")
$attach2 = " ";
else
$attach2 = " ";
if($file3name != "")
$attach3 = " ";
else
$attach3 = " ";
$datetime = split(" ", $msg_date);
$msg_date = $datetime[0];
$msg_time = $datetime[1];
if($msg_date == date( "Y-m-d" )) {
// Add Icon
}
else {
// Add Icon
}
$thread_display = "";
if($order == "desc" && $thread_depth > 0){
for($j=1; $j<=$thread_depth; $j++){
if($j == $thread_depth)
$thread_display .= " ";
else
$thread_display .= " ";
}
}
if(($i % 2) == 1){
?>
|
echo $revcount; $revcount--; ?> |
if($category==1){
echo ("삽니다");
}
if($category==2){
echo ("팝니다");
}
?>
|
echo "";
echo "$thread_display"; ?>> echo "$subject"; ?>
|
> echo $author
?> |
echo $msg_date ?> |
echo $msg_hit
?> |
}
else{
?>
|
echo $revcount; $revcount--; ?> |
if($category==1){
echo ("삽니다");
}
if($category==2){
echo ("팝니다");
}
?>
|
echo ""
?> echo $thread_display; ?> > echo $subject; ?>
|
> echo $author
?> |
echo
$msg_date ?> |
echo $msg_hit
?> |
}
} // End of For
?>
|
$div = intval($cur_page / 10);
$remain = $cur_page % 10;
if($remain == 0)
$div = $div - 1;
$startdiv = $div * 10 + 1;
$enddiv = $startdiv + 9;
// print "startdiv : ".$startdiv." enddiv : ".$enddiv." ";
$beforediv = $startdiv - 1;
if($div != 0)
echo "<<Before ";
for($s=$startdiv; $s<=$enddiv; $s++){
if($page_total < $s){
break;
}
if($s == $cur_page)
echo "".$s." " ;
else
echo "".$s." " ;
}
if($enddiv < $page_total)
echo " Next>>";
?>
|
 |
// End of DB Connection************************************************************
mysql_close();
// *******************************************************************************
?>
?>