스크랩 기능에 겸손한 JS 작업 중
This commit is contained in:
@ -1,34 +1,34 @@
|
||||
<?
|
||||
include_once('./_common.php');
|
||||
|
||||
if (!$member[mb_id])
|
||||
if (!$is_member)
|
||||
alert_close('회원만 조회하실 수 있습니다.');
|
||||
|
||||
$g4['title'] = $member[mb_nick].'님의 스크랩';
|
||||
$g4['title'] = $member['mb_nick'].'님의 스크랩';
|
||||
include_once($g4['path'].'/head.sub.php');
|
||||
|
||||
$list = array();
|
||||
|
||||
$sql_common = " from {$g4[scrap_table]} where mb_id = '{$member[mb_id]}' ";
|
||||
$sql_common = " from {$g4['scrap_table']} where mb_id = '{$member['mb_id']}' ";
|
||||
$sql_order = " order by ms_id desc ";
|
||||
|
||||
$sql = " select count(*) as cnt {$sql_common} ";
|
||||
$sql = " select count(*) as cnt $sql_common ";
|
||||
$row = sql_fetch($sql);
|
||||
$total_count = $row[cnt];
|
||||
$total_count = $row['cnt'];
|
||||
|
||||
$rows = $config[cf_page_rows];
|
||||
$rows = $config['cf_page_rows'];
|
||||
$total_page = ceil($total_count / $rows); // 전체 페이지 계산
|
||||
if (!$page) $page = 1; // 페이지가 없으면 첫 페이지 (1 페이지)
|
||||
$from_record = ($page - 1) * $rows; // 시작 열을 구함
|
||||
|
||||
$list = array();
|
||||
|
||||
$sql = " select *
|
||||
{$sql_common}
|
||||
{$sql_order}
|
||||
limit {$from_record}, {$rows} ";
|
||||
$sql = " select *
|
||||
$sql_common
|
||||
$sql_order
|
||||
limit $from_record, $rows ";
|
||||
$result = sql_query($sql);
|
||||
for ($i=0; $row=sql_fetch_array($result); $i++)
|
||||
for ($i=0; $row=sql_fetch_array($result); $i++)
|
||||
{
|
||||
$list[$i] = $row;
|
||||
|
||||
@ -36,27 +36,27 @@ for ($i=0; $row=sql_fetch_array($result); $i++)
|
||||
$num = $total_count - ($page - 1) * $rows - $i;
|
||||
|
||||
// 게시판 제목
|
||||
$sql2 = " select bo_subject from {$g4[board_table]} where bo_table = '{$row[bo_table]}' ";
|
||||
$sql2 = " select bo_subject from {$g4['board_table']} where bo_table = '{$row['bo_table']}' ";
|
||||
$row2 = sql_fetch($sql2);
|
||||
if (!$row2[bo_subject]) $row2[bo_subject] = '[게시판 없음]';
|
||||
if (!$row2['bo_subject']) $row2['bo_subject'] = '[게시판 없음]';
|
||||
|
||||
// 게시물 제목
|
||||
$tmp_write_table = $g4[write_prefix] . $row[bo_table];
|
||||
$sql3 = " select wr_subject from {$tmp_write_table} where wr_id = '{$row[wr_id]}' ";
|
||||
$tmp_write_table = $g4['write_prefix'] . $row['bo_table'];
|
||||
$sql3 = " select wr_subject from $tmp_write_table where wr_id = '{$row['wr_id']}' ";
|
||||
$row3 = sql_fetch($sql3, FALSE);
|
||||
$subject = get_text(cut_str($row3[wr_subject], 100));
|
||||
if (!$row3[wr_subject])
|
||||
$row3[wr_subject] = '[글 없음]';
|
||||
$subject = get_text(cut_str($row3['wr_subject'], 100));
|
||||
if (!$row3['wr_subject'])
|
||||
$row3['wr_subject'] = '[글 없음]';
|
||||
|
||||
$list[$i][num] = $num;
|
||||
$list[$i][opener_href] = './board.php?bo_table='.$row[bo_table];
|
||||
$list[$i][opener_href_wr_id] = './board.php?bo_table='.$row[bo_table].'&wr_id='.$row[wr_id];
|
||||
$list[$i][bo_subject] = $row2[bo_subject];
|
||||
$list[$i][subject] = $subject;
|
||||
$list[$i][del_href] = './scrap_delete.php?ms_id='.$row[ms_id].'&page='.$page;
|
||||
$list[$i]['num'] = $num;
|
||||
$list[$i]['opener_href'] = './board.php?bo_table='.$row['bo_table'];
|
||||
$list[$i]['opener_href_wr_id'] = './board.php?bo_table='.$row['bo_table'].'&wr_id='.$row['wr_id'];
|
||||
$list[$i]['bo_subject'] = $row2['bo_subject'];
|
||||
$list[$i]['subject'] = $subject;
|
||||
$list[$i]['del_href'] = './scrap_delete.php?ms_id='.$row['ms_id'].'&page='.$page;
|
||||
}
|
||||
|
||||
$member_skin_path = $g4['path'].'/skin/member/'.$config[cf_member_skin];
|
||||
$member_skin_path = $g4['path'].'/skin/member/'.$config['cf_member_skin'];
|
||||
include_once($member_skin_path.'/scrap.skin.php');
|
||||
|
||||
include_once($g4['path'].'/tail.sub.php');
|
||||
|
||||
@ -3,7 +3,7 @@ include_once('./_common.php');
|
||||
|
||||
include_once($g4['path'].'/head.sub.php');
|
||||
|
||||
if (!$member[mb_id]) {
|
||||
if (!$is_member) {
|
||||
$href = './login.php?'.$qstr.'&url='.urlencode('./board.php?bo_table='.$bo_table.'&wr_id='.$wr_id);
|
||||
echo <<<HEREDOC
|
||||
<script>
|
||||
@ -11,6 +11,10 @@ if (!$member[mb_id]) {
|
||||
opener.location.href = '$href';
|
||||
window.close();
|
||||
</script>
|
||||
<noscript>
|
||||
<p>회원만 접근 가능합니다.</p>
|
||||
<a href="$href">로그인하기</a>
|
||||
</noscript>
|
||||
HEREDOC;
|
||||
exit;
|
||||
}
|
||||
@ -24,27 +28,32 @@ echo <<<HEREDOC
|
||||
</script>
|
||||
HEREDOC;
|
||||
|
||||
if ($write[wr_is_comment])
|
||||
if ($write['wr_is_comment'])
|
||||
alert_close('코멘트는 스크랩 할 수 없습니다.');
|
||||
|
||||
$sql = " select count(*) as cnt from {$g4[scrap_table]}
|
||||
where mb_id = '{$member[mb_id]}'
|
||||
and bo_table = '{$bo_table}'
|
||||
and wr_id = '{$wr_id}' ";
|
||||
$sql = " select count(*) as cnt from {$g4['scrap_table']}
|
||||
where mb_id = '{$member['mb_id']}'
|
||||
and bo_table = '$bo_table'
|
||||
and wr_id = '$wr_id' ";
|
||||
$row = sql_fetch($sql);
|
||||
if ($row[cnt]) {
|
||||
if ($row['cnt']) {
|
||||
echo <<<HEREDOC
|
||||
<script>
|
||||
if (confirm('이미 스크랩하신 글 입니다.'.PHP_EOL.PHP_EOL.'지금 스크랩을 확인하시겠습니까?'))
|
||||
if (confirm('이미 스크랩하신 글 입니다.\\n\\n지금 스크랩을 확인하시겠습니까?'))
|
||||
document.location.href = './scrap.php';
|
||||
else
|
||||
window.close();
|
||||
</script>
|
||||
<noscript>
|
||||
<p>이미 스크랩하신 글 입니다.</p>
|
||||
<a href="./scrap.php">스크랩 확인하기</a>
|
||||
<a href="./board.php?bo_table={$bo_table}&wr_id=$wr_id">돌아가기</a>
|
||||
</noscript>
|
||||
HEREDOC;
|
||||
exit;
|
||||
}
|
||||
|
||||
$member_skin_path = $g4['path'].'/skin/member/'.$config[cf_member_skin];
|
||||
$member_skin_path = $g4['path'].'/skin/member/'.$config['cf_member_skin'];
|
||||
include_once($member_skin_path.'/scrap_popin.skin.php');
|
||||
|
||||
include_once($g4['path'].'/tail.sub.php');
|
||||
|
||||
@ -3,93 +3,102 @@ include_once('./_common.php');
|
||||
|
||||
include_once($g4['path'].'/head.sub.php');
|
||||
|
||||
if (!$member[mb_id])
|
||||
if (!$is_member)
|
||||
{
|
||||
$href = './login.php?'.$qstr.'&url='.urlencode('./board.php?bo_table='.$bo_table.'&wr_id='.$wr_id);
|
||||
echo '<script> alert(\'회원만 접근 가능합니다.\'); top.location.href = \''.$href.'\'; </script>';
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = " select count(*) as cnt from $g4[scrap_table]
|
||||
where mb_id = '$member[mb_id]'
|
||||
$sql = " select count(*) as cnt from {$g4['scrap_table']}
|
||||
where mb_id = '{$member['mb_id']}'
|
||||
and bo_table = '$bo_table'
|
||||
and wr_id = '$wr_id' ";
|
||||
$row = sql_fetch($sql);
|
||||
if ($row[cnt])
|
||||
if ($row['cnt'])
|
||||
{
|
||||
echo '
|
||||
<script>
|
||||
if (confirm(\'이미 스크랩하신 글 입니다.'.PHP_EOL.PHP_EOL.'지금 스크랩을 확인하시겠습니까?\'))
|
||||
<script>
|
||||
if (confirm(\'이미 스크랩하신 글 입니다.'."\n\n".'지금 스크랩을 확인하시겠습니까?\'))
|
||||
document.location.href = \'./scrap.php\';
|
||||
else
|
||||
window.close();
|
||||
</script>';
|
||||
</script>
|
||||
<noscript>
|
||||
<p>이미 스크랩하신 글 입니다.</p>
|
||||
<a href="./scrap.php">스크랩 확인하기</a>
|
||||
<a href="./board.php?bo_table='.$bo_table.'&wr_id='.$wr_id.'">돌아가기</a>
|
||||
</noscript>';
|
||||
exit;
|
||||
}
|
||||
|
||||
// 덧글이 넘어오고 코멘트를 쓸 권한이 있다면
|
||||
if ($wr_content && ($member[mb_level] >= $board[bo_comment_level]))
|
||||
if ($wr_content && ($member['mb_level'] >= $board['bo_comment_level']))
|
||||
{
|
||||
$wr = get_write($write_table, $wr_id);
|
||||
// 원글이 존재한다면
|
||||
if ($wr[wr_id])
|
||||
if ($wr['wr_id'])
|
||||
{
|
||||
$mb_id = $member[mb_id];
|
||||
$wr_name = $member[mb_nick];
|
||||
$wr_password = $member[mb_password];
|
||||
$wr_email = $member[mb_email];
|
||||
$wr_homepage = $member[mb_homepage];
|
||||
$mb_id = $member['mb_id'];
|
||||
$wr_name = $member['mb_nick'];
|
||||
$wr_password = $member['mb_password'];
|
||||
$wr_email = $member['mb_email'];
|
||||
$wr_homepage = $member['mb_homepage'];
|
||||
|
||||
$sql = " select max(wr_comment) as max_comment from {$write_table}
|
||||
where wr_parent = '{$wr_id}' and wr_is_comment = 1 ";
|
||||
$sql = " select max(wr_comment) as max_comment from $write_table
|
||||
where wr_parent = '$wr_id' and wr_is_comment = '1' ";
|
||||
$row = sql_fetch($sql);
|
||||
$row[max_comment] += 1;
|
||||
$row['max_comment'] += 1;
|
||||
|
||||
$sql = " insert into $write_table
|
||||
set ca_name = '{$wr[ca_name]}',
|
||||
set ca_name = '{$wr['ca_name']}',
|
||||
wr_option = '',
|
||||
wr_num = '{$wr[wr_num]}',
|
||||
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}',
|
||||
wr_datetime = '{$g4[time_ymdhis]}',
|
||||
wr_ip = '{$_SERVER[REMOTE_ADDR]}' ";
|
||||
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',
|
||||
wr_datetime = '{$g4['time_ymdhis']}',
|
||||
wr_ip = '{$_SERVER['REMOTE_ADDR']}' ";
|
||||
sql_query($sql);
|
||||
|
||||
$comment_id = mysql_insert_id();
|
||||
|
||||
// 원글에 코멘트수 증가
|
||||
sql_query(" update {$write_table} set wr_comment = wr_comment + 1 where wr_id = '{$wr_id}' ");
|
||||
sql_query(" update $write_table set wr_comment = wr_comment + 1 where wr_id = '$wr_id' ");
|
||||
|
||||
// 새글 INSERT
|
||||
//sql_query(" insert into $g4[board_new_table] ( bo_table, wr_id, wr_parent, bn_datetime ) values ( '$bo_table', '$comment_id', '$wr_id', '$g4[time_ymdhis]' ) ");
|
||||
sql_query(" insert into {$g4[board_new_table]} ( bo_table, wr_id, wr_parent, bn_datetime, mb_id ) values ( '{$bo_table}', '{$comment_id}', '{$wr_id}', '{$g4[time_ymdhis]}', '{$member[mb_id]}' ) ");
|
||||
sql_query(" insert into {$g4['board_new_table']} ( bo_table, wr_id, wr_parent, bn_datetime, mb_id ) values ( '$bo_table', '$comment_id', '$wr_id', '{$g4['time_ymdhis']}', '{$member['mb_id']}' ) ");
|
||||
|
||||
// 코멘트 1 증가
|
||||
sql_query(" update {$g4[board_table]} set bo_count_comment = bo_count_comment + 1 where bo_table = '{$bo_table}' ");
|
||||
sql_query(" update {$g4['board_table']} set bo_count_comment = bo_count_comment + 1 where bo_table = '$bo_table' ");
|
||||
|
||||
// 포인트 부여
|
||||
insert_point($member[mb_id], $board[bo_comment_point], '{$board[bo_subject]} {$wr_id}-{$comment_id} 코멘트쓰기', $bo_table, $comment_id, '코멘트');
|
||||
insert_point($member['mb_id'], $board['bo_comment_point'], "{$board['bo_subject']} {$wr_id}-{$comment_id} 코멘트쓰기", $bo_table, $comment_id, '코멘트');
|
||||
}
|
||||
}
|
||||
|
||||
$sql = " insert into {$g4[scrap_table]} ( mb_id, bo_table, wr_id, ms_datetime )
|
||||
values ( '{$member[mb_id]}', '{$bo_table}', '{$wr_id}', '{$g4[time_ymdhis]}' ) ";
|
||||
$sql = " insert into {$g4['scrap_table']} ( mb_id, bo_table, wr_id, ms_datetime )
|
||||
values ( '{$member['mb_id']}', '$bo_table', '$wr_id', '{$g4['time_ymdhis']}' ) ";
|
||||
sql_query($sql);
|
||||
|
||||
echo <<<HEREDOC
|
||||
<script>
|
||||
if (confirm('이 글을 스크랩 하였습니다.'.PHP_EOL.PHP_EOL.'지금 스크랩을 확인하시겠습니까?'))
|
||||
if (confirm('이 글을 스크랩 하였습니다.'."\n\n".'지금 스크랩을 확인하시겠습니까?'))
|
||||
document.location.href = './scrap.php';
|
||||
else
|
||||
window.close();
|
||||
</script>
|
||||
<noscript>
|
||||
<p>이 글을 스크랩 하였습니다.</p>
|
||||
<a href="./scrap.php">스크랩 확인하기</a>
|
||||
</noscript>
|
||||
HEREDOC;
|
||||
?>
|
||||
|
||||
@ -120,7 +120,7 @@ if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가
|
||||
|
||||
<? if ($scrap_href || $good_href || $nogood_href) { ?>
|
||||
<div id="bo_v_act">
|
||||
<? if ($scrap_href) { ?><a href="javascript:;" class="btn02" onclick="win_scrap('<?=$scrap_href?>');">스크랩</a><? } ?>
|
||||
<? if ($scrap_href) { ?><a href="<? echo $scrap_href; ?>" onclick="win_scrap(this.href); return false;" target="_blank" class="btn02">스크랩</a><? } ?>
|
||||
<? if ($good_href) {?><a href="<?=$good_href?>" class="btn02" target="hiddenframe">추천 <strong><?=number_format($view['wr_good'])?></strong></a><? } ?>
|
||||
<? if ($nogood_href) {?><a href="<?=$nogood_href?>" class="btn02" target="hiddenframe">비추천 <strong><?=number_format($view['wr_nogood'])?></strong></a><? } ?>
|
||||
</div>
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
<?
|
||||
if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가
|
||||
if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가
|
||||
?>
|
||||
|
||||
<div id="scrap" class="new_win">
|
||||
@ -19,11 +19,11 @@ if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가
|
||||
<tbody>
|
||||
<? for ($i=0; $i<count($list); $i++) { ?>
|
||||
<tr>
|
||||
<td class="td_num"><?=$list[$i][num]?></td>
|
||||
<td class="td_board"><a href="javascript:;" onclick="opener.document.location.href='<?=$list[$i][opener_href]?>';"><?=$list[$i][bo_subject]?></a></td>
|
||||
<td><a href="javascript:;" onclick="opener.document.location.href='<?=$list[$i][opener_href_wr_id]?>';"><?=$list[$i][subject]?></a></td>
|
||||
<td class="td_datetime"><?=$list[$i][ms_datetime]?></td>
|
||||
<td class="td_mng"><a href="javascript:del('<?=$list[$i][del_href]?>');">삭제</a></td>
|
||||
<td class="td_num"><?=$list[$i]['num']?></td>
|
||||
<td class="td_board"><a href="<?=$list[$i]['opener_href']?>" target="_blank" onclick="opener.document.location.href='<?=$list[$i]['opener_href']?>'; return false;"><?=$list[$i]['bo_subject']?></a></td>
|
||||
<td><a href="<?=$list[$i]['opener_href_wr_id']?>" target="_blank" onclick="opener.document.location.href='<?=$list[$i]['opener_href_wr_id']?>'; return false;"><?=$list[$i]['subject']?></a></td>
|
||||
<td class="td_datetime"><?=$list[$i]['ms_datetime']?></td>
|
||||
<td class="td_mng"><a href="<? echo $list[$i]['del_href']; ?>" onclick="del(this.href); return false;">삭제</a></td>
|
||||
</tr>
|
||||
<? } ?>
|
||||
|
||||
@ -32,10 +32,18 @@ if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가
|
||||
</table>
|
||||
|
||||
<div class="pg">
|
||||
<?=get_paging($config[cf_write_pages], $page, $total_page, "?$qstr&page=");?>
|
||||
<?=get_paging($config['cf_write_pages'], $page, $total_page, "?$qstr&page=");?>
|
||||
</div>
|
||||
|
||||
<div class="btn_win">
|
||||
<a href="javascript:window.close();">창닫기</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="btn_win"></div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
$(function() {
|
||||
$("div.btn_win").html("<a>창닫기</a>");
|
||||
|
||||
$("div.btn_win a").click(function() {
|
||||
window.close();
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@ -1,5 +1,5 @@
|
||||
<?
|
||||
if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가
|
||||
if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가
|
||||
?>
|
||||
|
||||
<div id="scrap_do" class="new_win">
|
||||
@ -14,7 +14,7 @@ if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가
|
||||
<tbody>
|
||||
<tr>
|
||||
<th scope="row">제목</th>
|
||||
<td><?=get_text(cut_str($write[wr_subject], 255))?></td>
|
||||
<td><?=get_text(cut_str($write['wr_subject'], 255))?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row"><label for="wr_content">댓글</label></th>
|
||||
@ -23,8 +23,6 @@ if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
</form>
|
||||
|
||||
<p>
|
||||
스크랩을 하시면서 감사 혹은 격려의 댓글을 남기실 수 있습니다.
|
||||
</p>
|
||||
@ -32,4 +30,5 @@ if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가
|
||||
<div class="btn_win">
|
||||
<input type="submit" value="스크랩">
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
Reference in New Issue
Block a user