AvocadoAmber/AvocadoEdition_Light/bbs/scrap_popin_update.php

106 lines
4 KiB
PHP
Raw Normal View History

2022-09-17 20:50:50 +09:00
<?php
2024-09-23 11:07:19 +09:00
include_once "./_common.php";
2022-09-17 20:50:50 +09:00
include_once G5_PATH . "/head.sub.php";
2022-09-17 20:50:50 +09:00
2024-09-19 20:57:39 +09:00
if (!$is_member) {
$href = './login.php?' . $qstr . '&amp;url=' . urlencode('./board.php?bo_table=' . $bo_table . '&amp;wr_id=' . $wr_id);
echo '<script> alert(\'회원만 접근 가능합니다.\'); top.location.href = \'' . str_replace('&amp;', '&', $href) . '\'; </script>';
exit;
2022-09-17 20:50:50 +09:00
}
// 게시글 존재하는지
2024-09-19 20:57:39 +09:00
if (!$write['wr_id'])
alert_close('스크랩하시려는 게시글이 존재하지 않습니다.');
2022-09-17 20:50:50 +09:00
2024-09-30 01:58:32 +09:00
$sql = "SELECT count(*) as cnt FROM {$g5['scrap_table']}
2022-09-17 20:50:50 +09:00
where mb_id = '{$member['mb_id']}'
and bo_table = '$bo_table'
and wr_id = '$wr_id' ";
$row = sql_fetch($sql);
2024-09-19 20:57:39 +09:00
if ($row['cnt']) {
echo '
2022-09-17 20:50:50 +09:00
<script>
2024-09-19 20:57:39 +09:00
if (confirm(\'이미 스크랩하신 글 입니다.' . "\n\n" . '지금 스크랩을 확인하시겠습니까?\'))
2022-09-17 20:50:50 +09:00
document.location.href = \'./scrap.php\';
else
window.close();
</script>
<noscript>
<p>이미 스크랩하신 입니다.</p>
<a href="./scrap.php">스크랩 확인하기</a>
2024-09-19 20:57:39 +09:00
<a href="./board.php?bo_table=' . $bo_table . '&amp;wr_id=' . $wr_id . '">돌아가기</a>
2022-09-17 20:50:50 +09:00
</noscript>';
2024-09-19 20:57:39 +09:00
exit;
2022-09-17 20:50:50 +09:00
}
$wr_content = trim($_POST['wr_content']);
// 덧글이 넘어오고 코멘트를 쓸 권한이 있다면
2024-09-19 20:57:39 +09:00
if ($wr_content && ($member['mb_level'] >= $board['bo_comment_level'])) {
$wr = get_write($write_table, $wr_id);
// 원글이 존재한다면
if ($wr['wr_id']) {
$mb_id = $member['mb_id'];
$wr_name = addslashes(clean_xss_tags($board['bo_use_name'] ? $member['mb_name'] : $member['mb_nick']));
$wr_password = $member['mb_password'];
$wr_email = addslashes($member['mb_email']);
$wr_homepage = addslashes(clean_xss_tags($member['mb_homepage']));
2024-09-30 01:58:32 +09:00
$sql = "SELECT max(wr_comment) as max_comment FROM $write_table
2022-09-17 20:50:50 +09:00
where wr_parent = '$wr_id' and wr_is_comment = '1' ";
2024-09-19 20:57:39 +09:00
$row = sql_fetch($sql);
$row['max_comment'] += 1;
2022-09-17 20:50:50 +09:00
2024-09-30 01:58:32 +09:00
$sql = "INSERT INTO $write_table
2022-09-17 20:50:50 +09:00
set ca_name = '{$wr['ca_name']}',
wr_option = '',
wr_num = '{$wr['wr_num']}',
wr_reply = '',
wr_parent = '$wr_id',
wr_is_comment = '1',
wr_comment = '{$row['max_comment']}',
wr_content = '$wr_content',
mb_id = '$mb_id',
wr_password = '$wr_password',
wr_name = '$wr_name',
wr_email = '$wr_email',
wr_homepage = '$wr_homepage',
2024-09-19 20:57:39 +09:00
wr_datetime = '" . G5_TIME_YMDHIS . "',
2022-09-17 20:50:50 +09:00
wr_ip = '{$_SERVER['REMOTE_ADDR']}' ";
2024-09-19 20:57:39 +09:00
sql_query($sql);
2022-09-17 20:50:50 +09:00
2024-09-19 20:57:39 +09:00
$comment_id = sql_insert_id();
2022-09-17 20:50:50 +09:00
2024-09-19 20:57:39 +09:00
// 원글에 코멘트수 증가
2024-09-30 01:58:32 +09:00
sql_query("UPDATE $write_table SET wr_comment = wr_comment + 1 where wr_id = '$wr_id' ");
2022-09-17 20:50:50 +09:00
2024-09-19 20:57:39 +09:00
// 새글 INSERT
2024-09-30 01:58:32 +09:00
sql_query("INSERT INTO {$g5['board_new_table']} ( bo_table, wr_id, wr_parent, bn_datetime, mb_id ) values ( '$bo_table', '$comment_id', '$wr_id', '" . G5_TIME_YMDHIS . "', '{$member['mb_id']}' ) ");
2022-09-17 20:50:50 +09:00
2024-09-19 20:57:39 +09:00
// 코멘트 1 증가
2024-09-30 01:58:32 +09:00
sql_query("UPDATE {$g5['board_table']} SET bo_count_comment = bo_count_comment + 1 where bo_table = '$bo_table' ");
2022-09-17 20:50:50 +09:00
2024-09-19 20:57:39 +09:00
// 포인트 부여
insert_point($member['mb_id'], $board['bo_comment_point'], "{$board['bo_subject']} {$wr_id}-{$comment_id} 코멘트쓰기", $bo_table, $comment_id, '코멘트');
}
2022-09-17 20:50:50 +09:00
}
2024-09-30 01:58:32 +09:00
$sql = "INSERT INTO {$g5['scrap_table']} ( mb_id, bo_table, wr_id, ms_datetime ) values ( '{$member['mb_id']}', '$bo_table', '$wr_id', '" . G5_TIME_YMDHIS . "' ) ";
2022-09-17 20:50:50 +09:00
sql_query($sql);
delete_cache_latest($bo_table);
echo <<<HEREDOC
<script>
if (confirm('이 글을 스크랩 하였습니다.\\n\\n지금 스크랩을 확인하시겠습니까?'))
document.location.href = './scrap.php';
else
window.close();
</script>
<noscript>
<p> 글을 스크랩 하였습니다.</p>
<a href="./scrap.php">스크랩 확인하기</a>
</noscript>
HEREDOC;