테스트 사이트 - 개발 중인 베타 버전입니다

시간 설정, 시간 오차... 채택완료

인디안바압 1년 전 조회 1,880

<?php if ($w == "u"): ?>
    <input type="hidden" name="wr_10" value="<?= $write['wr_10'] ?>">
<?php endif; ?>


<!-- 자폭 부분 -->
<?php if ($w == ""): ?>
    <tr>
        <td style='padding-left:50px; height:30px;'>· 자폭설정</td>
        <td>
            <input type="checkbox" name="bcheck" value="checkbox" onclick="chk1(this);">
            <select name="wr_10" style="FONT-SIZE: 9pt" onchange="doIt(this.value)">
                <option value="" selected>자폭안함</option>
                <option value="<?= date('Y-m-d H:i:s', strtotime('+30 seconds')) ?>">30초 후</option>
                <option value="<?= date('Y-m-d H:i:s', strtotime('+60 seconds')) ?>">60초 후</option>
                <option value="<?= date('Y-m-d H:i:s', strtotime('+300 seconds')) ?>">5분 후</option>
                <option value="<?= date('Y-m-d H:i:s', strtotime('+600 seconds')) ?>">10분 후</option>
                <option value="<?= date('Y-m-d H:i:s', strtotime('+3600 seconds')) ?>">1시간 후</option>
                <option value="<?= date('Y-m-d H:i:s', strtotime('+86400 seconds')) ?>">24시간 후</option>
            </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>
<?php endif; ?>

 

해당 소스는 게시물을 자폭하기 위한 소스입니다.

 

$BombDay = "<a href=\"javascript:alert('자폭 설정이 되어 있습니다.\\n자폭일 : ".$view[wr_10]."')\"><font color=red class=small>(자폭 설정이 작동 중입니다. 지정일: $bombdate)</font></a><br>";

 

보면 wr_10으로 시간을 저장하고 있는데...

 

문제는 시간 격차가 많이 발생합니다.

 

가령 30초를 선택하고, 제가 직접 새로고침을 연달아 누르고 있는 상태임에도

 

1분이 넘어서 작동하기도 하고 그러네요...

 

이 시간 격차 어떻게 수정하면 될까요?

 

참고로 php시간, 리눅스 시간 모두 서울라 맞춰둔 상태입니다..

 

댓글을 작성하려면 로그인이 필요합니다.

답변 2개

채택된 답변
+20 포인트
e
1년 전

자폭을 처리하는 부분의 소스가 있어야 할 것 같구요.

php 시간과 리눅스 시간의 오차는 없는지 실시간을 비교해보시구요.

 

30초를 선택하면 저장할때 시간 기준의 30초가 되야하지 않을까요?

지금은 설정하는 화면이 보여질때 기준이라 선택하고 저장하는데 몇초가 흐를수도 있겠습니다.

 

로그인 후 평가할 수 있습니다

답변에 대한 댓글 5개

인디안바압
1년 전
//자폭 시작
for ($i=0; $i<count($list); $i++) {
$count_write = 0;
$count_comment = 0;
if($list[$i][wr_10]) {
$g5[time_ymd] = date("Y-m-d H:i", G5_SERVER_TIME);
$stoday = $g5[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))


이 부분인것 같네요. 소스는 이렇구요.

지금은

<?php
// 서버 시간을 변수에 할당
$serverTime = date('Y-m-d H:i:s', G5_SERVER_TIME);
?>

<div class="form-group">
<label class="col-sm-2 control-label">자폭설정</label>
<div class="col-sm-4">
<div class="input-group input-group-sm">
<input type="hidden" name="bcheck" value="checkbox" onclick="chk1(this);">
<select name="wr_10" class="select-box form-control" onchange="doIt(this.value)">
<option value="" selected>자동 폭파 안 함</option>
<option value="<?= date('Y-m-d H:i:s', strtotime('+30 seconds', G5_SERVER_TIME)) ?>">30초 후</option>
<option value="<?= date('Y-m-d H:i:s', strtotime('+60 seconds', G5_SERVER_TIME)) ?>">60초 후</option>
<option value="<?= date('Y-m-d H:i:s', strtotime('+300 seconds', G5_SERVER_TIME)) ?>">5분 후</option>
<option value="<?= date('Y-m-d H:i:s', strtotime('+600 seconds', G5_SERVER_TIME)) ?>">10분 후</option>
<option value="<?= date('Y-m-d H:i:s', strtotime('+3600 seconds', G5_SERVER_TIME)) ?>">1시간 후</option>
<option value="<?= date('Y-m-d H:i:s', strtotime('+86400 seconds', G5_SERVER_TIME)) ?>">24시간 후</option>
</select>
<div id="mytext" class="disable-text" onclick="changeclass(this, '')">자동 폭파 사용 안 함</div>
</div>
</div>
</div>
<?php endif; ?>

이렇게 바꿨습니다. 그런데도 시간 격차가 벌어지네요.

리눅스 시간과 php시간은 서울로 맞춰서 같습니다 ㅠㅠ
e
eyekiss
1년 전
$Bd = substr($bombdate,8,2) + 7;
$bombdate7 는 7일을 더하게 되어 있네요??
인디안바압
1년 전
소스를 제가 짠게 아니라서.... https://sir.kr/bbs/board.php?bo_table=g4_tiptech&wr_id=12417&sca=&sfl=wr_subject&stx=%ED%8F%AD%ED%8C%8C&spt=0&page=1 여기보고 수정했습니다 ㅠ
e
eyekiss
1년 전
$g5[time_ymd] = date("Y-m-d H:i", G5_SERVER_TIME);
$stoday = $g5[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) {

이 부분을 아래와 같이 수정하고 해보세요

$stoday = date("Y-m-d H:i:s", G5_SERVER_TIME);
$bombdate = $list[$i][wr_10];
if ($stoday > $bombdate) {
인디안바압
1년 전
말씀대로 수정해봤는데... 증상은 동일합니다 ㅠㅠ

댓글을 작성하려면 로그인이 필요합니다.

$stoday  $bombdate7 이 두 값을 화면에 나오도록 하고

새로고침 하면서 둘 중 어디에 문제가 있는지 확인해 보세요~

로그인 후 평가할 수 있습니다

댓글을 작성하려면 로그인이 필요합니다.

답변을 작성하려면 로그인이 필요합니다.

로그인