묻고답하기

<?php
// 접속자수 구하기
// DB connect
include "./pboard/inc/db.inc.php";
        
// 접속한 날짜 및 시간을 구함
$timeinfo = getdate(time());
$cur_year  = $timeinfo["year"];
$cur_month = $timeinfo["mon"];
$cur_day   = $timeinfo["mday"];
$cur_time  = $timeinfo["hours"];
$cur_week  = $timeinfo["wday"];

if($cur_time < 10) $cur_time = "0".$cur_time;
$times = array(        "01" => "s_time01" , "02" => "s_time02" , "03" => "s_time03" , "04" => "s_time04" , "05" => "s_time05" , "06" => "s_time06" ,
                "07" => "s_time07" , "08" => "s_time08" , "09" => "s_time09" , "10" => "s_time10" , "11" => "s_time11" , "12" => "s_time12" ,
                "13" => "s_time13" , "14" => "s_time14" , "15" => "s_time15" , "16" => "s_time16" , "17" => "s_time17" , "18" => "s_time18" ,
                "19" => "s_time19" , "20" => "s_time20" , "21" => "s_time21" , "22" => "s_time22" , "23" => "s_time23" , "00" => "s_time24" );

// 처음 접속한경우 쿠키를 생성하여 접속한날 카운트 금지 시킴
if(!$firstVisit)
{
        counters();
}
else
{
        $cur_date = $cur_year. $cur_month . $cur_day;
        $s = strtotime($cur_date)-strtotime($firstVisit);
        $d = intval($s/86400);

        // 하루이전에 생성된 쿠기라면 카운트 증가 시킴
        if($d > 0 )
        {
                counters();
        }
}

// 카운트 입력 및 카운트 증가 처리 함수
function counters()
{
        global $cur_year, $cur_month, $cur_day, $cur_week, $conn, $cur_time, $times;
        $count_date = $cur_year.$cur_month.$cur_day;
        setcookie("firstVisit",$count_date, time()*86400,"/");
                        
        // DB insert OR update 선택
        $count_que = "SELECT * FROM counter WHERE s_year=$cur_year AND s_month=$cur_month AND s_day=$cur_day";
        $count_res = mysql_query($count_que);
        
        // 이미 값이 존재하는 경우 업데이트 시킨다.
        if(mysql_num_rows($count_res))
        {
                $update_que = "UPDATE counter SET $times[$cur_time] = $times[$cur_time]+1 , s_total = s_total + 1 WHERE s_year=$cur_year AND s_month=$cur_month AND s_day=$cur_day";
                $update_res = mysql_query($update_que, $conn);
        }
        // 값이 존재하지 않는 경우 값을 넣는다
        else
        {
                $uid_que = "SELECT MAX(uid) FROM counter";
                $uid_res = mysql_query($uid_que) or die($uid_que);
                
                // uid 구하기
                if(list($uid) = mysql_fetch_array($uid_res)) $uid = intVal($uid) + 1;
                else $uid = 1;
                
                $insert_que = "INSERT INTO counter (uid, s_year, s_month, s_day, s_week, $times[$cur_time], s_total) VALUES ($uid, $cur_year, $cur_month, $cur_day, $cur_week , 1, 1)";
                $insert_res = mysql_query($insert_que, $conn) or die($insert_que."<br>".mysql_error());
        }
}

// counter 출력 (어제 , 오늘 , 전체)
$yesterday = mktime(0,0,0,$cur_month, $cur_day -1, $cur_year);
$y_year  = date("Y", $yesterday);
$y_month = date("m", $yesterday);
$y_day   = date("d", $yesterday);
$yday_count_que = "SELECT s_total FROM counter WHERE s_year=$y_year AND s_month=$y_month AND s_day=$y_day";
$yday_count_res = mysql_query($yday_count_que , $conn) or die($yday_count_que);
if($yday_count_res)
{
        if(!list($yesterday_count) = mysql_fetch_array($yday_count_res))
                $yesterday_count = 0;
}

$today_count_que = "SELECT s_total FROM counter WHERE s_year=$cur_year AND s_month=$cur_month AND s_day=$cur_day";
$today_count_res = mysql_query($today_count_que, $conn) or die($today_count_que);
if($today_count_res)
{
        if(!list($today_count) = mysql_fetch_array($today_count_res))
                $today_count = 0;
}

$total_count_que = "SELECT SUM(s_total) FROM counter";
$total_count_res = mysql_query($total_count_que, $conn);
if($total_count_res)
{
        if(!list($total_count) = mysql_fetch_array($total_count_res))
                $total_count = 0;
}

//DB close
mysql_close($conn) ;

$counter_view = "
<table width=100%' cellpadding='0' cellspacing='0' style='border-style:solid;border-width:2px;border-color:#DBDBDB'>
<tr align='center' height='50' bgcolor='#FFFFFF'>
        <td>
                <table width='100' style='font-size:8pt;font-family:돋움'>
                        <tr><td>오늘 : </td><td align='right'>${today_count}</td></tr>
                        <tr><td>어제 : </td><td align='right'>${yesterday_count}</td></tr>
                        <tr><td>전체 : </td><td align='right'>${total_count}</td></tr>
                </table>
        </td>
</tr>
</table>
";

//echo $counter_view;
?>





증상은 http://xelloss.nared.net 입니다...ㅠㅠ
글쓴이 제목 최종 글
XE 공지 글 쓰기,삭제 운영방식 변경 공지 [16] 2019.03.05 by 남기남
데이터 이전 중 멈춥니다. [1] 2014.03.22 by
컴박살 socialxe를 설치 하려 합니다. [2] 2014.03.22 by 컴박살
컴박살 부탁드려요 1.7.4.1 --> 1.7.3.9로 다운그레이드 하려고하는데요  
모르게떠염 닉네임을 클릭 자체가 안되도록 하고 싶어요 [6] 2014.03.22 by 모르게떠염
eric79won 이거 도대체 뭐라는 에러 인건지 봐주실수 있으신지요... [4] 2014.03.22 by 마이웹
boy2 회원메뉴? 에서 현재창 이동 안 되나요? [2] file 2014.03.22 by 마이웹
EnuX 에디터 안에서 font-family 적용 문제 [5] 2014.03.22 by EnuX
KrteamENT font Awasome 메뉴 적용 문의 [4] 2014.03.22 by KrteamENT
포동이 아이프레임에서 게시물 클릭시 최상단으로 가는 방법 질문드립니다.. [1] 2014.03.22 by 담소
공업수학2 게시판 위에 나오는 홈>커뮤니티>묻고답하기 매뉴 삭제 [2] file 2014.03.22 by 담소
기쁨넘어영광 갑자기 레이아웃 관리자가 사라졌어요 [5] file 2014.03.22 by 기쁨넘어영광
졸라맨 쪽지보내기창 수정문의 [2] 2014.03.22 by W.O
eric79won xe/files/cache 폴더에 있는것들 지워도 되나요? [3] 2014.03.22 by W.O
eric79won 도메인 리뉴얼후 500 internal server error [1] 2014.03.22 by W.O
졸라맨 회원정보보기에 메뉴 추가하는 방법 [1] 2014.03.22 by W.O
콩까기 이미지 리사이즈 애드온 질문드립니다. [1] 2014.03.22 by W.O
생까는즐거움 NAVER Analytics네어버에서 연동이 안된다고 답변이 왔어요 [1] 2014.03.22 by W.O
졸라맨 통합검색 수정 문의 [1] 2014.03.22 by W.O
lord 인증메일 재발송 문제 에러 file  
zeneger 모바일 게시판에서 제목이외에 확장변수로 만든 다른것으로 바꿀수 없나요? [1] 2014.03.22 by 키스투엑스이