묻고답하기

<?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 남기남
김영송 그 페이지에 머문 시간을 입력폼에 나타내기.  
요코 이미지맵 써서 아이프레임 안에 하이퍼 링크를 시켰는데 반응이 없어요 ;;;;  
김경완 parse error가 뜨네요.. 뭐가 잘못되었는지.. [3] 2007.08.10
박과장 메뉴 표시줄은 어떻게 만드는지? [1] 2007.08.10
내안의휴식 폼메일에 관한 질문입니다.  
가람 저희 컴에서는 잘 뜨는데, 친구네 컴에서는 엑박으로 뜰때;; [2] 2007.08.10
김인식 위키백과사전처럼 만들수 없나요?  
정인걸 이 스크립트에서 뭐가 잘못됬길래...홈페이지가 안뜨나요 ㅠㅠ  
김경완 다시 한번 질문올립니다..  
Tombow 죄송하지만 폰트 질문요... [2] 2007.08.10
김양훈 너무 급해요.. 이미지가 모두 x표시되서 나오는데 어떻게 해야하죠? [3] 2007.08.10
정상혁 웹페이지에서 플래시 제어. [1] 2007.08.10
오승민 자동으로 새창열기가 한번만 되게 할 수 없을까요 ?  
황완섭 너무너무 간절해서 글 올립니다... 해상도에 맞게 브라우져창 열기  
민영기 phpmyadmin을 사용중에 아이디와 비번을 잊어버렸습니다. [4] 2007.08.10
백승렬 배경음악이 잘 나오다가 얼마전부터 안나오네요?  
빛의바다 노프레임으로 페이지를 만들었는데 여백이 생겼어요...;; [2] 2007.08.10
권수원 Photoshop7.0에서요 선긋기는 어떻게 합니까? [1] 2007.08.10
정인걸 신청서 추천바랍니다..  
이중경 구문 해석의 의문점 질문입니다. [2] 2007.08.10
밤거리 nzeo 위에 있는 메뉴와 같이 커뮤니티 | 웹스터티 | 제로보드 |다운로드 | 온라인게임 [2] 2007.08.10
Alee 싸이월드 미니 홈피 따라하기 [3] 2007.08.10
harry98 gmax어디서 받죠?  
이봉호 이미지 주위를 자연스럽게 검은색으로 처리하려면 어떻게 하나요? [1] 2007.08.10
강원철 설문조사 php인데요 틀린곳좀 잡아주세요 ㅠ.ㅜ [1] 2007.08.10
강주경 프레임 링크 관련 질문입니다~!!  
김지만 제로보드질문 쪽지 오면 새창으로 뜨는거 ㅠㅠ  
한현석 파일 다운로드 횟수 카운트 하는 카운터  
A+ 트래픽과 하드용량 제한[질문] [1] 2007.08.10
최봉수 글 뒤에 배경을 넣고 싶어요 어떻게 해야하죠?ㅠ_ㅠ