글 자동폭파 (자폭/자동삭제) 하기 9월2일 수정 정보
글 자동폭파 (자폭/자동삭제) 하기 9월2일 수정본문
스킨의 view.skin.php / list.skin.php / write.skin.php 를 수정합니다 예비필드 wr_10 을 사용합니다
view.skin.php 의 상단에 아래 소스를 추가합니다.
if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가 , 아래 정도
//자폭시작
if ($view[wr_10]) {
$g4[time_ymd] = date("Y-m-d H:i", $g4[server_time]);
$stoday = $g4[time_ymd];
$bombdate = $view[wr_10];
if ($stoday > $bombdate) {
$sql = " select wr_id, mb_id, wr_is_comment from $write_table where wr_parent = '$view[wr_id]' order by wr_id ";
$result = sql_query($sql);
while ($row = sql_fetch_array($result))
{
// 원글이라면
if (!$row[wr_is_comment])
{
// 원글 포인트 삭제
if (!delete_point($row[mb_id], $bo_table, $row[wr_id], '쓰기'))
insert_point($row[mb_id], $board[bo_write_point] * (-1), "$board[bo_subject] $row[wr_id] 글삭제");
// 업로드된 파일이 있다면 파일삭제
$sql2 = " select * from $g4[board_file_table] where bo_table = '$bo_table' and wr_id = '$row[wr_id]' ";
$result2 = sql_query($sql2);
while ($row2 = sql_fetch_array($result2)){
@unlink("$g4[path]/data/file/$bo_table/$row2[bf_file]");
@unlink("$g4[path]/data/file/$bo_table/thumb/$write[wr_id]"); //썸네일 삭제
@unlink("$g4[path]/data/file/$bo_table/latest_thumb/$write[wr_id]"); //최근게시물 썸네일 삭제
}
//추천기록 삭제
sql_query(" delete from g4_board_good where wr_id = '$row[wr_id]' AND bo_table = '$bo_table' "); //수정
// 파일테이블 행 삭제
sql_query(" delete from $g4[board_file_table] where bo_table = '$bo_table' and wr_id = '$row[wr_id]' ");
$count_write++;
}
else
{
// 코멘트 포인트 삭제
if (!delete_point($row[mb_id], $bo_table, $row[wr_id], '코멘트'))
insert_point($row[mb_id], $board[bo_comment_point] * (-1), "$board[bo_subject] {$view[wr_id]}-{$row[wr_id]} 코멘트삭제");
$count_comment++;
}
}
// 게시글 삭제
sql_query(" delete from $write_table where wr_parent = '$view[wr_id]' ");
// 최근게시물 삭제
sql_query(" delete from $g4[board_new_table] where bo_table = '$bo_table' and wr_parent = '$view[wr_id]' ");
// 스크랩 삭제
sql_query(" delete from $g4[scrap_table] where bo_table = '$bo_table' and wr_id = '$view[wr_id]' ");
// 공지사항 삭제
$notice_array = explode("\n", trim($board[bo_notice]));
$bo_notice = "";
for ($k=0; $k<count($notice_array); $k++)
if ((int)$write[wr_id] != (int)$notice_array[$k])
$bo_notice .= $notice_array[$k] . "\n";
$bo_notice = trim($bo_notice);
sql_query(" update $g4[board_table] set bo_notice = '$bo_notice' where bo_table = '$bo_table' ");
// 글숫자 감소
if ($count_write > 0 || $count_comment > 0)
sql_query(" update $g4[board_table] set bo_count_write = bo_count_write - '$count_write', bo_count_comment = bo_count_comment - '$count_comment' where bo_table = '$bo_table' ");
if($view[mb_id] != $member[mb_id]){
$Bpoint = rand(10,100);
$smsg = "글을 폭파 시켰습니다. 폭탄제거 포인트 ".$Bpoint."점 획득.";
insert_point($member['mb_id'], $Bpoint, "폭탄제거 포인트", "@bomb", $write['mb_id'], "자폭");
} else {
$smsg = "글을 폭파 시켰습니다.";
}
alert($smsg, "./board.php?bo_table=$bo_table");
}
$BombDay = "<a href=\"javascript:alert('자폭 설정이 되어 있습니다.\\n자폭일 : ".$view[wr_10]."')\"><font color=red class=small>(자폭 설정이 작동 중입니다. 지정일: $bombdate)</font></a><br>";
}
//자폭 끝
그리고 원하는 부분에 <?=$BombDay?> 를 추가합니다.
언제 폭파되는지 나타내는 부분입니다.
list.skin.php 의 상단에 아래 소스를 추가합니다
//자폭 시작
for ($i=0; $i<count($list); $i++) {
$count_write = 0;
$count_comment = 0;
if($list[$i][wr_10]) {
$g4[time_ymd] = date("Y-m-d H:i", $g4[server_time]);
$stoday = $g4[time_ymd];
$bombdate = $list[$i][wr_10];
$By = substr($bombdate,0,4);
$Bm = substr($bombdate,5,2);
$Bd = substr($bombdate,8,2) + 7;
$Bh = substr($bombdate,11,2);
$Bi = substr($bombdate,14,2);
$bombdate7 = date("Y-m-d H:i",mktime($Bh,$Bi,0,$Bm,$Bd,$By) );
$bombc = $list[$i][wr_id];
if ($stoday > $bombdate7) {
$sql = " select wr_id, mb_id, wr_is_comment from $write_table where wr_parent = '$bombc' order by wr_id ";
$result = sql_query($sql);
while ($row = sql_fetch_array($result))
{
// 원글이라면
if (!$row[wr_is_comment])
{
// 원글 포인트 삭제
if (!delete_point($row[mb_id], $bo_table, $row[wr_id], '쓰기'))
insert_point($row[mb_id], $board[bo_write_point] * (-1), "$board[bo_subject] $row[wr_id] 글삭제");
// 업로드된 파일이 있다면 파일삭제
$sql2 = " select * from $g4[board_file_table] where bo_table = '$bo_table' and wr_id = '$row[wr_id]' ";
$result2 = sql_query($sql2);
while ($row2 = sql_fetch_array($result2)){
@unlink("$g4[path]/data/file/$bo_table/$row2[bf_file]");
@unlink("$g4[path]/data/file/$bo_table/thumb/$write[wr_id]"); //썸네일 삭제
@unlink("$g4[path]/data/file/$bo_table/latest_thumb/$write[wr_id]"); //최근게시물 썸네일 삭제
}
//추천기록 삭제
sql_query(" delete from g4_board_good where wr_id = '$row[wr_id]' AND bo_table = '$bo_table' "); //수정
// 파일테이블 행 삭제
sql_query(" delete from $g4[board_file_table] where bo_table = '$bo_table' and wr_id = '$row[wr_id]' ");
$count_write++;
}
else
{
// 코멘트 포인트 삭제
if (!delete_point($row[mb_id], $bo_table, $row[wr_id], '코멘트'))
insert_point($row[mb_id], $board[bo_comment_point] * (-1), "$board[bo_subject] {$view[wr_id]}-{$row[wr_id]} 코멘트삭제");
$count_comment++;
}
}
// 게시글 삭제
sql_query(" delete from $write_table where wr_parent = '$bombc' ");
// 최근게시물 삭제
sql_query(" delete from $g4[board_new_table] where bo_table = '$bo_table' and wr_parent = '$bombc' ");
// 스크랩 삭제
sql_query(" delete from $g4[scrap_table] where bo_table = '$bo_table' and wr_id = '$bombc' ");
// 공지사항 삭제
$notice_array = explode("\n", trim($board[bo_notice]));
$bo_notice = "";
for ($k=0; $k<count($notice_array); $k++)
if ((int)$bombc != (int)$notice_array[$k])
$bo_notice .= $notice_array[$k] . "\n";
$bo_notice = trim($bo_notice);
sql_query(" update $g4[board_table] set bo_notice = '$bo_notice' where bo_table = '$bo_table' ");
// 글숫자 감소
if ($count_write > 0 || $count_comment > 0)
sql_query(" update $g4[board_table] set bo_count_write = bo_count_write - '$count_write', bo_count_comment = bo_count_comment - '$count_comment' where bo_table = '$bo_table' ");
$bend = 1;
}
}
if(count($list) == $i+1 && $bend == 1){
goto_url("./board.php?bo_table=$bo_table&page=$page");}
}
//자폭 끝
그리고 echo $list[$i][subject]; 이부분 위에 아래 소스를 추가합니다. 제목을 나타내는 부분위에 넣으세요
if($list[$i][wr_10]){
echo "<img src='$board_skin_path/img/bomb.gif' align='absmiddle'>";
}
마지막으로 wirte.skin.php 를 수정합니다.
아래 스크립트를 상단 부분 아무데나 넣습니다.
<!-- 자폭값 표시 -->
<script language="JavaScript" type="text/javascript">
function changeclass(thediv,msg) {
thediv.className=(thediv.className=="redtext")?"bluetext":"redtext";
if(msg !="")
thediv.innerText=msg + "에 자동 폭파 실시";
else
thediv.innerText="자동 폭파 사용 안함";
}
function chk1(obj) {
var switchB = document.getElementById('wr_10');
if (obj.checked)
{
switchB.disabled = false;
} else {
switchB.disabled = true;
document.getElementById('wr_10').value = "";
document.getElementById('mytext').innerText="자동 폭파 사용 안함";
}
}
</script>
<script>
function doIt(_f) {
changeclass(document.getElementById('mytext'),_f);
}
</script>
<!-- 자폭값 표시 끝 -->
그리고 input 값 마구 마온곳에
<? if ($w =="u") { ?>
<input type=hidden name=wr_10 value="<?=$write[wr_10]?>">
<? } ?>
를 추가합니다.
자폭 설정을 나타낼 부분을 찾아서 아래 소스를 추가합니다
<!-- 자폭 부분 -->
<? if ($w =="") { ?>
<tr>
<td style='padding-left:20px; height:30px;'>· 자폭설정</td>
<td><input type=checkbox name="bcheck" value="checkbox" onclick="chk1(this);" >
<?
echo "<SELECT name=wr_10 style=\"FONT-SIZE: 9pt\" onchange=doIt(this.value) disabled >";
echo "<OPTION value=\"\" selected>자폭안함</option>";
echo "<option value=\"".date("Y-m-d H:i", time() + (int)(0.125*60*60*24))."\" >3시간 후</option>";
echo "<option value=\"".date("Y-m-d H:i", time() + (int)(0.25*60*60*24))."\" >6시간 후</option>";
echo "<option value=\"".date("Y-m-d H:i", time() + (int)(0.5 *60*60*24))."\">12시간 후</option>";
for($i=1;$i<31; $i++) {
echo "<option value=\"".date("Y-m-d H:i", time() + (int)($i*60*60*24))."\" >$i"."일 후</option>";
}
echo "</select>";
?>
</select>
<div id="mytext" class="redtext" style="display:inline" onclick="changeclass(this,'hi')">자동 폭파 사용 안함</div>
</td>
</tr>
<tr><td colspan=2 height=1 bgcolor=#e7e7e7></td></tr>
<? } ?>
<!-- 자폭 부분 -->
위 이미지 중 폭탄이미지를 다운받아서 스킨의 이미지 폴더에 넣습니다.
게시물을 폭파 시킨 사람에게는 10~100점 사이의 랜덤 포인트를 추가합니다.
이 것을 없에거나 수정하고 싶으신 분은 view.skin.php 수정 부분 중
$Bpoint = rand(10,100);
$smsg = "글을 폭파 시켰습니다. 폭탄제거 포인트 ".$Bpoint."점 획득.";
insert_point($member['mb_id'], $Bpoint, "폭탄제거 포인트", "@bomb", $write['mb_id'], "자폭");
이부분을 수정하세요
이전에 올렸던거에서 자폭포인트 지급 부분이 잘 못됐었는데 수정했습니다.
자바스크립트 부분도 형식에 맞게 수정 하였습니다.
자폭지정일이 7일이 지난 게시물은 list.skin.php에서 자동 삭제 합니다.
(이전엔 자폭 게시물 잔상이 한번은 보였는데 이것도 수정하였습니다)
제가 빼먹은 부분이 있을 수 있으니 안되면 알려주세요
alik님과 헐랭이 님의 소스를 참고하였습니다. 폭탄 아이콘은 alik님 홈피에서 가져왔습니다.
버그 같은게 있으면 알려주세요
8
댓글 21개
그런데 설정후..사진 파일을 올리면 사진이 두번씩 중복되는데.......저만 그런가요?
스킨의 view.list.php 파일 출력 부분을 한번 검토해보세요
보드필드(여부필드)에서 1에 10 / 2에20 / 3에30 ..이렇게 해 놓으면 그 기간지나면 자폭...
또 작성자가 보드1(10)을 선택하면 포인트10다운 보드2(20)을 선택하면 포인트20다운 .....
초보라 생각만 나지 어케 해볼 수가 없네요..;;
근데 왜 포인트가 들어가는지 아무리생각해도 이해불가...^^
쓸모가 많을 것 같은데 댓글이 없는 것도 이해불가...^^
아이디어 좋고 멋집니다.
아...다른 스킨에다가 해봤는데 어떤 스킨은 폭파부분 클릭해도 셀렉트바가 활성화가 되지 않는데 아시는 분있나요...;ㅁ;
흑..나만 안되는건가...;ㅁ;