";
$email_img = "
";
$home_img = "
";
$new_img = "
";
$reply_img = "
";
$arrow_img = "
";
$file_img = "
";
$icon = "img";
if ($task == "alldelete") {
$query = "delete from $board";
$query_result = mysql_query($query);
}
function GetUpPath($board) {
$query = "SELECT uppath from conf where board = '$board' ";
$query_result = mysql_query($query);
if(!$query_result) return "";
$data_array = mysql_fetch_array($query_result);
return $data_array[uppath];
}
function GetConf($board, $field) {
$query = "SELECT $field from conf where board = '$board' ";
$query_result = mysql_query($query);
if(!$query_result) return "";
$data_array = mysql_fetch_array($query_result);
return $data_array[$field];
}
function CountUp($id, $subtask) {
global $board;
global $page;
if($subtask == "recommendation")
$count_up_query = "UPDATE $board set recommendation=recommendation+1 where id=$id ";
elseif($subtask == "delrequest")
$count_up_query = " update $board set delrequest=delrequest+1 where id=$id ";
$query_result = mysql_query($count_up_query);
if(!$query_result) {
$err_msg = mysql_error();
echo("$err_msg");
}
echo(" ");
}
function ReplyForm() {
global $board;
global $id;
global $page;
global $title;
global $content;
global $depth;
global $filter;
$reply_query = "SELECT name, title, content, depth, filter from $board where id=$id ";
$query_result = mysql_query($reply_query);
if(!$query_result) {
$err_msg = mysql_error();
echo("$err_msg");
}
$data_array = mysql_fetch_array($query_result);
for($i=0;$i<$data_array[depth]+3;$i++) {
$line = $line."----------";
}
$title = "".$data_array[title];
$content = eregi_replace("
", "\n", $data_array[content]);
$content = "$line\n$data_array[name]´ÔÀÇ ±ÛÀÔ´Ï´Ù.\n\n$content\n$line\n\n";
$depth = $data_array[depth]+1;
$filter = $data_array[filter];
WriteForm();
}
function PasswordCheck() {
global $php_self;
global $db;
global $board;
global $task;
global $subtask;
global $orgtask;
global $id;
global $page;
global $password;
if($subtask == "list") {
$admin_password = GetConf($board, "list");
$cur_admin_password = crypt($password, $admin_password);
if($cur_admin_password == $admin_password) {
ShowData();
}
else ScriptErrMsg("ºñ¹Ð¹øÈ£°¡ ÀÏÄ¡ÇÏÁö ¾Ê½À´Ï´Ù.");
}
if($subtask == "write") {
$admin_password = GetConf($board, "writing");
if($password == $admin_password) WriteForm();
else ScriptErrMsg("ºñ¹Ð¹øÈ£°¡ ÀÏÄ¡ÇÏÁö ¾Ê½À´Ï´Ù.");
}
else if($subtask == "modify") {
$check_query = " select password from $board where id=$id ";
$query_result = mysql_query($check_query);
if(!$query_result) {
$err_msg = mysql_error();
echo("$err_msg");
}
$data_array = mysql_fetch_array($query_result);
$save_password = $data_array[password];
$cur_save_password = crypt($password, $save_password);
$admin_password = GetConf($board, "modify");
if($cur_save_password == $save_password || $password == $admin_password) {
ModifyForm();
}
else {
ScriptErrMsg("ºñ¹Ð¹øÈ£°¡ ÀÏÄ¡ÇÏÁö ¾Ê½À´Ï´Ù.");
}
}
elseif($subtask == "delete") {
$check_query = " select password from $board where id=$id ";
$query_result = mysql_query($check_query);
if(!$query_result) {
$err_msg = mysql_error();
echo("$err_msg");
}
$data_array = mysql_fetch_array($query_result);
$save_password = $data_array[password];
$cur_save_password = crypt($password, $save_password);
$admin_password = GetConf($board, "modify");
$cur_admin_password = crypt($password, $admin_password);
if($cur_save_password == $save_password || $password == $admin_password) {
DeleteData();
echo(" ");
}
else ScriptErrMsg("ºñ¹Ð¹øÈ£°¡ ÀÏÄ¡ÇÏÁö ¾Ê½À´Ï´Ù.");
}
elseif($subtask == "alldelete") {
$admin_password = GetConf($board, "deletion");
if($password == $admin_password) {
echo("
");
}
else ScriptErrMsg("ºñ¹Ð¹øÈ£°¡ ÀÏÄ¡ÇÏÁö ¾Ê½À´Ï´Ù.");
}
}
function PasswordCheckForm() {
global $php_self;
global $db;
global $board;
global $task;
global $subtask;
global $orgtask;
global $id;
global $page;
global $table_color;
echo("
");
}
function WriteCheckForm() {
global $php_self;
global $db;
global $board;
global $subtask;
global $id;
global $page;
echo("
");
}
function ModifyForm() {
global $board;
global $page;
global $id;
global $name;
global $title;
global $email;
global $homepage;
global $content;
global $date;
global $depth;
global $userfile;
$modify_query = "SELECT * from $board where id = $id ";
$query_result = mysql_query($modify_query);
if(!$query_result) {
$err_msg = mysql_error();
echo("$err_msg");
}
$data_array = mysql_fetch_array($query_result);
$data_array[name] = stripslashes($data_array[name]);
$data_array[title] = stripslashes($data_array[title]);
$data_array[email] = stripslashes($data_array[email]);
$data_array[homepage] = stripslashes($data_array[homepage]);
$data_array[content] = stripslashes($data_array[content]);
$data_array[userfile] = stripslashes($data_array[userfile]);
$name = $data_array[name];
$title = $data_array[title];
$email = $data_array[email];
$homepage = $data_array[homepage];
$content = eregi_replace("
", "\n", $data_array[content]);
$depth = $data_array[depth];
$userfile = $data_array[userfile];
WriteForm();
}
function DeleteData() {
global $php_self;
global $board;
global $id;
global $page;
$up_path = GetUpPath($board);
$select_query = "SELECT * from $board where id=$id ";
$query_result = mysql_query($select_query);
if(!$query_result) {
$data_array = mysql_fetch_array($query_result) or
die("ÀڷḦ »èÁ¦Çϴµ¥ ¹®Á¦°¡ ¹ß»ýÇÏ¿´½À´Ï´Ù.(÷ºÎÆÄÀÏ Á¤º¸ Àбâ)");
if(($data_array[userfile] != 'none' and $data_array[filesize] > 0) and
file_exists($up_path."/".$data_array[userfile])) {
unlink($up_path."/".$data_array[userfile]);
}
}
$delete_query = "DELETE from $board where id=$id ";
$result_query = mysql_query($delete_query);
if(!$result_query) {
$err_msg = mysql_error();
echo("$err_msg");
}
}
function NumberRead() {
global $icon;
global $board;
global $php_self;
global $id;
global $page;
global $email_img;
global $home_img;
global $new_img;
global $reply_img;
global $arrow_img;
////////////////////////// Á¶È¸¼ö Áõ°¡ //////////////////////
$count_up_query = "UPDATE $board set count=count+1 where id=$id ";
$query_result = mysql_query($count_up_query);
if(!$query_result) {
$err_msg = mysql_error();
echo("$err_msg");
}
/////////////////////// ÇØ´ç ±Û DB¿¡¼ Àбâ ///////////////////////
$number_read_query = "SELECT * from $board where id=$id ";
$query_result = mysql_query($number_read_query);
if(!$query_result) {
$err_msg = mysql_error();
echo("$err_msg");
}
$data_array = mysql_fetch_array($query_result);
$data_array[name] = stripslashes($data_array[name]);
$data_array[title] = stripslashes($data_array[title]);
$data_array[email] = stripslashes($data_array[email]);
$data_array[homepage] = stripslashes($data_array[homepage]);
$data_array[content] = stripslashes($data_array[content]);
echo ("
| À̸§ : $data_array[name] |
Á¦¸ñ : [ $data_array[title] ] |
Á¶È¸¼ö : $data_array[count] |
\n");
if($data_array[email] != "") {
echo ("
|
$email_img $data_array[email]
|
");
}
if($data_array[homepage] != "") {
echo("
|
$home_img http://$data_array[homepage]
|
\n");
}
echo("
| $td1_font $data_array[content] |
\n");
$filename = $data_array[userfile];
$filesize = $data_array[filesize];
if($data_array[userfile] != "none" and $data_array[filesize] != 0) {
echo("|
÷ºÎÆÄÀÏ:$data_array[userfile] ($data_array[filesize]) | ");
}
else {
echo("÷ºÎÆÄÀÏ : ¾øÀ½ | ");
}
echo ("ÀÛ¼ºÀÏÀÚ : $data_array[date] $data_array[time] |
");
if(eregi(".gif", $data_array[userfile]) ||
eregi(".jpg", $data_array[userfile]) ||
eregi(".bmp", $data_array[userfile])) {
echo (" |
");
}
//////////////////////// °ü·Ã±Û º¸±â /////////////////////////////
$filter_query = "SELECT * from $board where filter=$data_array[filter] ORDER BY id DESC";
$query_result = mysql_query($filter_query);
if(!$query_result) {
$err_msg = mysql_error();
echo($err_msg);
}
$today = strftime("%Y-%m-%d"); // ¿À´Ã ³¯Â¥
$filter_total = mysql_affected_rows();
if($filter_total > 1) {
$filter_total_temp = $filter_total - 1;
echo ("
| |
Á¦¸ñ |
ÀÐÀ½ |
³¯Â¥ |
À̸§ |
\n");
for($i=0;$i<$filter_total;$i++) {
mysql_data_seek($query_result, $i);
$reldata_array = mysql_fetch_array($query_result);
$today_title = "";
if($today == $reldata_array[date]) $today_title = $new_img;
$depth = $reldata_array[depth];
$reply_title = "";
if($depth) {
for($j=0;$j<$depth;$j++) $reply_title = $reply_title."  ";
$reply_title = $reply_title.$reply_img;
}
if($id == $reldata_array[id]) $this = $arrow_img;
else $this = " ";
echo ("
| $this |
$file_title$reply_title$reldata_array[title]$today_title
|
$reldata_array[count] |
$reldata_array[date] |
$reldata_array[name] |
\n");
}
echo "
";
}
echo ("
\n");
///////////////////////// ¾Õ±Û º¸±â ////////////////////////////
$prev_query = "SELECT id, title from $board where id > $id ORDER BY id LIMIT 1";
$query_result = mysql_query($prev_query);
if(!$query_result) {
$err_msg = mysql_error();
echo($err_msg);
}
if(mysql_affected_rows() > 0) {
$prev_array = mysql_fetch_array($query_result);
echo "";
echo " ";
}
///////////////////////// ´ÙÀ½±Û º¸±â ////////////////////////////
$next_query = " select id, title from $board where id < $id ORDER BY id DESC LIMIT 1";
$query_result = mysql_query($next_query);
if(!$query_result) {
$err_msg = mysql_error();
echo($err_msg);
}
if(mysql_affected_rows() > 0) {
$next_array = mysql_fetch_array($query_result);
echo "";
echo " ";
}
echo (" | ");
///////// list, write, reply, recommendation, delrequest,delete, modify ¹öư Ãâ·Â ///////////
echo ("
|
|
\n");
}
function DataWrite() {
global $board;
global $php_self;
global $task;
global $id;
global $page;
global $name;
global $email;
global $password;
global $title;
global $IfHTML;
global $email;
global $homepage;
global $content;
global $remote_addr;
global $depth;
global $filter;
global $up_path;
global $up_file;
global $up_file_name;
$up_path = GetUpPath($board);
if($name == "" || $password == "" || $title == "" || $content == "") {
ScriptErrMsg('À̸§, ¾ÏÈ£, Á¦¸ñ, ³»¿ëÀº Çʼö ÀÔ·Â »çÇ×ÀÔ´Ï´Ù.');
exit;
}
$board = addslashes($board);
$name = addslashes($name);
$title = addslashes($title);
$email = addslashes($email);
$homepage = addslashes($homepage);
$content = addslashes($content);
$remote_addr = addslashes($remote_addr);
$content = eregi_replace("\n", "
", $content);
if($task == "write" || $task == "reply") $file_info = UpLoad();
if($password) $password = crypt($password);
if($task == "write") {
$filter_index_query = "SELECT id, filter from $board ORDER BY id DESC LIMIT 1 ";
echo($filter_index_query);
$query_result = mysql_query($filter_index_query);
$data_array = mysql_fetch_array($query_result);
if(mysql_affected_rows() == 0) {
$cnt_id = 1;
$filter = 1;
}
else {
$cnt_id = $data_array[id] + 1;
$filter = $data_array[filter] + 1;
}
$write_query = "INSERT into $board values($cnt_id,'$name','$title','','$email','$homepage',".
"'$content',curdate(),curtime(),'$remote_addr','$password','',$filter,".
"'$file_info[name]','$file_info[size]','')";
}
else if($task == "reply") {
$list_up_query = "UPDATE $board set id=(id+1)*(-1) where id >= $id ";
$query_result = mysql_query($list_up_query);
if(!$query_result) {
$err_msg = mysql_error();
echo("$err_msg
");
}
$list_up_query = "UPDATE $board set id=id*(-1) where id < 0 ";
$query_result = mysql_query($list_up_query);
if(!$query_result) {
$err_msg = mysql_error();
echo("$err_msg
");
}
$write_query = "INSERT into $board values($id,'$name','$title','','$email','$homepage',".
"'$content',curdate(),curtime(),'$remote_addr','$password','$depth',$filter,".
"'$file_info[name]','$file_info[size]','')";
}
else if($task == "modify") {
$write_query = "UPDATE $board set name='$name',title='$title',email='$email',".
"homepage='$homepage',content='$content',ip='$remote_addr',password='$password'".
" where id=$id";
}
$query_result = mysql_query($write_query);
if($query_result)
echo("");
else {
$err_msg = mysql_error();
echo("$err_msg");
}
}
function WriteForm() {
global $icon;
global $php_self;
global $board;
global $subtask;
global $page;
global $id;
global $name;
global $title;
global $email;
global $homepage;
global $content;
global $depth;
global $filter;
global $userfile;
global $must_img;
global $table_color;
global $board;
if($board == "free") {
$top_image = "plaza_img03.gif";
$title_image = "plaza_img06.gif";
}
else {
$top_image = "plaza_img02.gif";
$title_image = "plaza_img04.gif";
}
include ("header.htm");
echo("\n");
include ("tail.htm");
}
function ShowData() {
global $icon;
global $php_self;
global $page;
global $task;
global $page_term;
global $board;
global $titlesearch;
global $contentsearch;
global $namesearch;
global $search;
global $new_img;
global $reply_img;
global $file_img;
global $table_color;
$today = strftime("%Y-%m-%d"); // ¿À´Ã ³¯Â¥
$jump_line = 0;
$line_count = 0;
if($task == "search" || $search) {
if($titlesearch!="yes" && $contentsearch!="yes" && $namesearch!="yes")
ScriptErrMsg("°Ë»ö Çʵ带 ¼±ÅÃÇØ ÁֽʽÿÀ.");
if($search == "")
ScriptErrMsg("°Ë»ö¾î¸¦ ÀÔ·ÂÇØ ÁֽʽÿÀ.");
if($titlesearch == "yes") {
if(eregi("LIKE", $where_query))
$where_query = $where_query." OR title LIKE '%$search%' ";
else
$where_query = $where_query." title LIKE '%$search%' ";
}
if($contentsearch == "yes") {
if(eregi("LIKE", $where_query))
$where_query = $where_query." OR content LIKE '%$search%' ";
else
$where_query = $where_query." content LIKE '%$search%' ";
}
if($namesearch == "yes") {
if(eregi("LIKE", $where_query))
$where_query = $where_query." OR name LIKE '%$search%' ";
else
$where_query = $where_query." name LIKE '%$search%' ";
}
$show_query = "SELECT * from $board "." where ".$where_query." ORDER BY id DESC ";
}
else $show_query = "SELECT * from $board ORDER BY id DESC";
$query_result = mysql_query($show_query);
if(!$query_result) {
$err_msg = mysql_error();
echo($err_msg);
}
$total = mysql_affected_rows();
$first = $page * $page_term;
$prev_page = $page - 1;
$next_page = $page + 1;
$i = 0;
if ($board == "free") {
echo("
 |
");
}
echo ("
|
| ¹øÈ£ |
Á¦¸ñ |
ÀÐÀ½ |
³¯Â¥ |
À̸§ |
\n");
for($i = $first;$i < ($next_page * $page_term) && $i < $total;$i++) {
mysql_data_seek($query_result, $i);
$data_array = mysql_fetch_array($query_result);
$data_array[name] = stripslashes($data_array[name]);
$data_array[title] = stripslashes($data_array[title]);
$data_array[email] = stripslashes($data_array[email]);
$data_array[homepage] = stripslashes($data_array[homepage]);
$data_array[content] = stripslashes($data_array[content]);
$today_title = "";
if($today == $data_array[date]) $today_title = $new_img;
$file_title = "";
if($data_array[userfile] != "none") $file_title = $file_img;
$depth = $data_array[depth];
$reply_title = "";
if($depth) {
for($j=0;$j<$depth;$j++)
$reply_title = $reply_title."  ";
$reply_title = $reply_title.$reply_img;
}
$DATE = explode(" ",$data_array[date]);
$data_array[date] = $DATE[0];
if(($i%2) == 0) $tr_bg = "#F8F8F8";
else $tr_bg = "#EBEBEB";
// °¢ ¸ñ·ÏÀÇ ³»¿ëÀ» Ãâ·Â
echo ("
| $data_array[id] |
$file_title$reply_title$data_array[title]$today_title |
$data_array[count] |
$data_array[date] |
$data_array[name] |
\n");
}
echo ("
\n");
}
function ShowList() {
global $icon;
global $php_self;
global $task;
global $board;
global $new_img;
global $reply_img;
global $file_img;
$query = "SELECT * from $board order by date desc limit 4";
$result = mysql_query($query);
if(!$result) {
$err = mysql_error();
echo "$err
";
}
$cnt = mysql_affected_rows();
for($i=0; $i<$cnt; $i++) {
$data_array = mysql_fetch_array($result);
echo ("
| |
 |
$data_array[title] |
 |
\n");
}
}
####### task¿¡ ´ëÇÑ ÇÔ¼öµé°ú board¸í¿¡ µû¸¥ image¸¦ ´Ù¸£°Ô ÁÜ #####
if($board == "free") {
$top_image = "plaza_img03.gif";
$title_image = "plaza_img06.gif";
}
else {
$top_image = "plaza_img02.gif";
$title_image = "plaza_img04.gif";
}
if($task == "write" || $task == "modify" || $task == "reply")
DataWrite();
elseif($task == "numberread") {
include ("header.htm");
if(GetConf($board, "reading") != "") {
echo(" ");
}
else NumberRead();
include ("tail.htm");
}
elseif($task == "replyform") {
if(GetConf($board, "reply") != "") {
echo(" ");
}
ReplyForm();
}
elseif($task == "writeform") {
if(GetConf($board, "writing") != "") {
echo(" ");
}
else {
WriteForm();
}
}
elseif($task == "modifyform") {
if(GetConf($board, "modify") != "") {
echo(" ");
}
else {
ModifyForm();
}
}
elseif($task == "deleteform") {
include ("header.htm");
if(GetConf($board, "deletion") != "") {
echo(" ");
}
else {
PasswordCheck();
}
include ("tail.htm");
}
elseif($task == "checkform") {
include ("header.htm");
PasswordCheckForm();
include ("tail.htm");
}
elseif($task == "check") {
PasswordCheck();
}
elseif($task == "download") {
$up_path = GetUpPath($board);
DownLoad($id, $filename);
}
elseif($task == "countup") {
CountUp($id, $subtask);
}
elseif($task == "list") {
ShowList();
}
else {
include ("header.htm");
if(GetConf($board, "list") != "") {
echo(" ");
}
else ShowData();
include ("tail.htm");
}
mysql_close();
?>