묻고답하기

제로 카운터를 달았는데 합계를 보여주는 값이 이상합니다.

카운터만 달아놓고 외부에서 쓰는 카운터를 달았쓰고 있었는데
제로보드것을 쓰려고 들어가 보니 합계를 보여주는 값이 이상합니다.

어찌된 것이 2001년이나 2002년 통계값보다 작습니다.
문제가 생긴 것은 며칠 전(9월 말 정도)에 다시 들어가보아도 전체 통계는 나오지 않아서
전체 통계값에 나오는 1값을 8로 바꾸니 1부터 다시 시작해서
다시 8을 1로 바꾸었더니 그런 증상이 나타났습니다.
8로 바꾼 것은 어쩐 일인지는 모르지만 카운터 날짜가 1로 시작되는게 아니고
8부터 시작되는 것이어서 그랬습니다.
즉 1부터 7까지가 없어서 1부터 7까지는 제가 직접 수치를 입력했습니다.
date는 엑셀에서 날짜를 역순으로 뽑아서 한 것이고요.

$total=mysql_fetch_array(mysql_query("select unique_counter, pageview from counter_main where no=1", $connect));


http://www.sonamu.biz/count/status.php3 에 보시면 값을 볼 수 있습니다.

그리고 DB 내용을 본 값입니다.


아래는 통계 소스입니다.
그리고 다시 살펴보니 1값은 계속 증가만 하네요.
혹시 카운터와 페이지 뷰 값은 2001년 것과 2002년 것을 합쳐서 넣어도 되나요?
일단은 직접 그렇게 수정해 보려고 합니다.

----
고치고나니 작년 10월로 가니 계산이 이상하게 되어 있습니다.
그래서 다시 원래상태로(1-7값이 없는) 상태로 돌리니
전체 통계 값이 안나오는군요.

그리고 admin.php를 실행하여 설치를 다시 했더니 테이블이 생성되었다고 나오고(며칠 전에도 한번 했음)
phpadmin으로 들어가서 DB를 보니 1값이 처음에 나오는게 아니라
며칠전에 생성한순서로 나오네요.
그리고 값도 초기화되어 1부터 시작하고요.


이걸 어떻게 하면 전체가 다 나오게할 수 있는지요?



<?
  include "dbconn.php3";


  // 날자 세팅
  if(!$year) $year=date("Y");
  if(!$month) $month=date("m");
  if(!$day) $day=date("d");

  // 사용자 IP 얻어옴
  $user_ip=$REMOTE_ADDR;
  $referer=$HTTP_REFERER;

  // 오늘의 날자 구함
  $today=mktime(0,0,0,$month,$day,$year);
  $yesterday=mktime(0,0,0,$month,$day,$year)-3600*24;

  // 이번달의 첫번째 날자 구함
  $month_start=mktime(0,0,0,$month,1,$year);

  // 이번달의 마지막 날자 구함
  $lastdate=01;
  while (checkdate($month,$lastdate,$year)):
    $lastdate++;  
  endwhile;
  $lastdate=mktime(0,0,0,$month,$lastdate,$year);

  if(!$no)$no=1;
?>

<!-- 헤더부분과 날짜 입력 부분 -->
<html>
<head>
   <title>ZeroPHP</title>
   <meta http-equiv=Content-Type content=text/html; charset=EUC-KR>
   <link rel=StyleSheet HREF='zerophp.css' type='text/css' title='ZZAGN CSS'>
</head>
<body topmargin='0'  leftmargin='0' marginwidth='0' marginheight='0'>
<form method=post action=<? echo $PHP_SELF; ?>>
<input type=hidden name=no value=<? echo $no; ?>>
<table border=0 cellpading=0 cellspacing=0>
<tr>
   <td align=right width=100% height=74 background=image/title.gif valign=bottom>
<?
   for($i=1;$i<=6;$i++)
   {
    echo" ";
   }
?>
   </td>
</tr>
<tr>
    <td align=center background=image/date.gif width=417 height=31>
        Year : <input type=text name=year value=<? echo $year; ?> size=4 maxlength=4 style='background-color:eeeeee; border:1 solid black;height:16'>  
        Month : <input type=text name=month value=<? echo $month; ?> size=2 maxlength=2 style='background-color:eeeeee; border:1 solid black;height:16'>  
        Day : <input type=text name=day value=<? echo $day; ?> size=2 maxlength=2 style='background-color:eeeeee; border:1 solid black;height:16'>  
        <input type=image src=image/move.gif border=0 align=absmiddle></td>
</tr>
<tr>
<td background=image/bar<? echo $no; ?>.gif height=20> </td>
</tr>
<!-- --------------------------- -->

<?

//-------------------------- 카운터 수 구해옴 -----------------------------//
  // 전체
  $total=mysql_fetch_array(mysql_query("select unique_counter, pageview from counter_main where no=1", $connect));
  $count[total_hit]=$total[0];
  $count[total_view]=$total[1];

  // 오늘 카운터 읽어오는 부분
  $detail=mysql_fetch_Array(mysql_query("select unique_counter, pageview from counter_main where date='$today'", $connect));
  $count[today_hit]=$detail[0];
  $count[today_view]=$detail[1];

  // 어제 카운터 읽어오는 부분
  $detail=mysql_fetch_Array(mysql_query("select unique_counter, pageview from counter_main where date='$yesterday'", $connect));
  $count[yesterday_hit]=$detail[0];
  $count[yesterday_view]=$detail[1];

  // 최고 카운터 읽어오는 부분
  $detail=mysql_fetch_Array(mysql_query("select max(unique_counter), max(pageview) from counter_main where no>1", $connect));
  $count[max_hit]=$detail[0];
  $count[max_view]=$detail[1];

  // 최저 카운터 읽어오는 부분
  $detail=mysql_fetch_Array(mysql_query("select min(unique_counter), min(pageview) from counter_main where no>1 and date<$today", $connect));
  $count[min_hit]=$detail[0];
  $count[min_view]=$detail[1];


//-----------------------------------------------------------------------------
// 전체카운터 (1)
//-----------------------------------------------------------------------------
if($no=="1")
{
  echo"
       <tr>
          <td height=40>
               전체 방문자수 : $count[total_hit]    
            
  전체 페이지뷰 : $count[total_view]
          </td>
       </tr>
       <tr>
          <td height=40>
               오늘 방문자수 : $count[today_hit]    
            
  오늘 페이지뷰 : $count[today_view]
          </td>
       </tr>
       <tr>
          <td height=40>
               어제 방문자수 : $count[yesterday_hit]    
            
  어제 페이지뷰 : $count[yesterday_view]
          </td>
       </tr>
       <tr>
          <td height=40>
               최고 방문자수 : $count[max_hit]    
            
  최고 페이지뷰 : $count[max_view]
          </td>
       </tr>
       <tr>
          <td height=40>
               최저 방문자수 : $count[min_hit]    
            
  최저 페이지뷰 : $count[min_view]
          </td>
       </tr>";
}

//-----------------------------------------------------------------------------
// 오늘 시간대별 카운터 (2)
//-----------------------------------------------------------------------------
elseif($no=="2")
{
  echo"
       <tr>
           <td height=25>
                 $month 월 $day 일 방문자수 : $count[today_hit]
              
     $month 월 $day 일 페이지뷰 : $count[today_view]
           </td>
       </tr>
       <tr>
           <td height=30 align=center>

           <table width=380 border=0 cellpadding=1 cellspacing=0>";
  
  $max=1;
  for($i=0;$i<24;$i++)
  {
   $time1=mktime($i,0,0,$month,$day,$year);
   $time2=mktime($i,59,59,$month,$day,$year);
   $temp=mysql_fetch_array(mysql_query("select count(*) from counter_ip where date>='$time1' and date<='$time2'", $connect));
   $time_count[$i]=$temp[0];
   if($max<$time_count[$i]) $max=$time_count[$i];
  }

  for($i=0;$i<24;$i++)
  {
   $per1=(int)($time_count[$i]/$max*100);
   if($per1>100)$per1=99;
   echo"
         <tr>
            <td width=50>- $i 시 </td>
            <td align=left>$i시 방문자수 : $time_count[$i]</td>
            <td width=80>  Unique $time_count[$i] </td>
         </tr>";
  }

  echo"
         </table>
           </td>
        </tr>
        ";
}

//-----------------------------------------------------------------------------
// 주간별 카운터 (3)
//-----------------------------------------------------------------------------
elseif($no=="3")
{
$start_day=$day;
while(date('l',mktime(0,0,0,$month,$start_day,$year))!='Sunday')
{
  $start_day--;
}
$last_day=$day;
while(date('l',mktime(0,0,0,$month,$last_day,$year))!='Saturday')
{
  $last_day++;
}

$start_time=mktime(0,0,0,$month,$start_day,$year);
$last_time=mktime(23,59,59,$month,$last_day,$year);

$detail=mysql_fetch_Array(mysql_query("select sum(unique_counter), sum(pageview) from counter_main where date>=$start_time and date<=$last_time", $connect));
$count[week_hit]=$detail[0];
$count[week_view]=$detail[1];

  echo"
       <tr>
           <td height=25>
                 $month 월 $start_day ~ $last_day 일 방문자수 : $count[week_hit]
              
     $month 월 $start_day ~ $last_day 일 페이지뷰 : $count[week_view]
           </td>
       </tr>
       <tr>
           <td height=30 align=center>

           <table width=380 border=0 cellpadding=1 cellspacing=0>";

  $max1=1;
  $max2=1;
  for($i=0;$i<7;$i++)
  {
   $time=mktime(0,0,0,$month,$start_day+$i,$year);
   $temp=mysql_fetch_array(mysql_query("select unique_counter, pageview from counter_main where date='$time'", $connect));
   $time_count1[$i]=$temp[0];
   if($max1<$time_count1[$i]) $max1=$time_count1[$i];
   $time_count2[$i]=$temp[1];
   if($max2<$time_count2[$i]) $max2=$time_count2[$i];
  }

  $week=array("일요일","월요일","화요일","수요일","목요일","금요일","토요일");
  for($i=0;$i<7;$i++)
  {
   $per1=(int)($time_count1[$i]/$max1*100+1);
   $per2=(int)($time_count2[$i]/$max2*100+1);
   if($per1>100)$per1=99;
   if($per2>100)$per2=99;
   echo"
         <tr>
            <td width=60>- $week[$i] </td>
            <td align=left>$week[$i] 방문자수 : $time_count1[$i]

                           $week[$i] 페이지뷰 : $time_count2[$i]
            </td>
            <td width=120>  Unique : $time_count1[$i]
  PageView : $time_count2[$i]</td>
         </tr>";
  }

  echo"
         </table>
           </td>
        </tr>
        ";
}

//-----------------------------------------------------------------------------
// 월간카운터 (4)
//-----------------------------------------------------------------------------
elseif($no=="4")  
{
  $total_month_counter=mysql_fetch_array(mysql_query("select sum(unique_counter), sum(pageview) from counter_main where date>='$month_start' and date<='$lastdate'", $connect));

  echo"
       <tr>
           <td height=25>
                 $month 월 방문자수 : $total_month_counter[0]
              
     $month 월 페이지뷰 : $total_month_counter[1]
           </td>
       </tr>
       <tr>
           <td height=30 align=center>
          
           <table width=380 border=0 cellpadding=1 cellspacing=0>
      ";

  // 이번달 카운터 (각각)
  $max=mysql_fetch_array(mysql_query("select max(unique_counter), max(pageview) from counter_main where date>='$month_start' and date<='$lastdate'",$connect));
  $month_counter=mysql_query("select date, unique_counter, pageview from counter_main where date>='$month_start' and date<='$lastdate'",$connect);
  while($data=mysql_fetch_array($month_counter))
  {
   $per1=$data[unique_counter]/$max[0]*100;
   $per2=$data[pageview]/$max[1]*100;
   echo"
         <tr>
            <td width=50>- ".date("d 일",$data[date])." </td>
            <td width=220 align=left>Unique : $data[unique_counter]

                PageView : $data[pageview]</td>
            <td width=140>  Unique : $data[unique_counter]
  PageView : $data[pageview]</td>
         </tr>";
  }

  echo"  
         </table>
           </td>
        </tr>
        ";
}

//-----------------------------------------------------------------------------
// 년간카운터 (5)
//-----------------------------------------------------------------------------
elseif($no=="5")
{
  $year_start=mktime(0,0,0,1,1,$year);
  $year_last=mktime(23,59,59,12,31,$year);
  $total_year_counter=mysql_fetch_array(mysql_query("select sum(unique_counter), sum(pageview) from counter_main where date>='$year_start' and date<='$year_last'+ '+ '", $connect));

  echo"
       <tr>
           <td height=25>
                 $year 년 방문자수 : $total_year_counter[0]
              
    $year 년 페이지뷰 : $total_year_counter[1]
           </td>
       </tr>
       <tr>
           <td height=30 align=center>

           <table width=380 border=0 cellpadding=1 cellspacing=0>
      ";

  // 이번달 카운터 (각각)
$max1=1;
  $max2=1;
  for($i=0;$i<7;$i++)
  {
   $time=mktime(0,0,0,$month,$start_day+$i,$year);
   $temp=mysql_fetch_array(mysql_query("select unique_counter, pageview from counter_main where date='$time'", $connect));
   $time_count1[$i]=$temp[0];
   if($max1<$time_count1[$i]) $max1=$time_count1[$i];
   $time_count2[$i]=$temp[1];
   if($max2<$time_count2[$i]) $max2=$time_count2[$i];
  }


  $mmax=array("31","28","31","30","31","30","31","31","30","31","30","31");
  $max=1;
  $max2=1;
  for($i=0;$i<12;$i++)
  {
   $sdate=mktime(0,0,0,$i+1,1,$year);
   $edate=mktime(0,0,0,$i+1,$mmax[$i],$year);
   $year_counter=mysql_query("select sum(unique_counter), sum(pageview) from counter_main where date>='$sdate' and date<='$edate'",$connect);
   $temp=mysql_fetch_array($year_counter);
   $time_count1[$i]=$temp[0];
   if($max1<$time_count1[$i]) $max1=$time_count1[$i];
   $time_count2[$i]=$temp[1];
   if($max2<$time_count2[$i]) $max2=$time_count2[$i];
  }
  
  for($i=0;$i<12;$i++)
  {
   $per1=(int)($time_count1[$i]/$max1*100+1);
   $per2=(int)($time_count2[$i]/$max2*100+1);
   if($per1>100)$per1=99;
   if($per2>100)$per2=99;
   $j=$i+1;
   echo"
         <tr>
            <td width=60>- $j 월 </td>
            <td align=left>+

                           $week[$i] 페이지뷰 : $time_count2[$i]
            </td>
            <td width=120>  Unique : $time_count1[$i]
  PageView : $time_count2[$i]</td>
         </tr>";
  }

  echo"  
         </table>
           </td>
        </tr>
        ";
}

//-----------------------------------------------------------------------------
// 접속자 방문경로?(6)
//-----------------------------------------------------------------------------
elseif($no=="6")  
{
  echo "<tr><td>";
  $ip=mysql_query("select referer, hit from counter_referer where date='$today' order by hit desc", $connect);
  while($data=mysql_fetch_array($ip))
  {
   if(strlen($data[referer])>40)
   {
    $temp=substr($data[referer],0,40);
    $text="$temp...";
   }
   else $text=$data[referer];
   if(!eregi("Typing or Bookmark", $data[referer])) $data[referer]="$text";
   echo "    - $data[referer] ($data[hit])
";
  }
  echo"</td></tr>";
}

//-----------------------------------------------------------------------------
//  하단부분
//-----------------------------------------------------------------------------
  echo"
        <tr>
            <td align=center height=30 bgcolor=#dddddd>Created by ZeroPHP.com</td>
        </tr>
        </table></form>";

?>
글쓴이 제목 최종 글
XE 공지 글 쓰기,삭제 운영방식 변경 공지 [16] 2019.03.05 by 남기남
함태준 해상도랑 색상이 완전히 이상해져서요.. [1] 2007.08.10
zip파일등을 다운받을때 ..  
김지희 노프레임에 대한 질문 [2] 2007.08.10
전재형 윈도 2000 서버 계정 용량 제한 질문.. [1] 2007.08.10
Park Jin php 에서 .. [1] 2007.08.10
콤마™ 제로카운터 ㅠㅜ  
함태준 해상도,색상이 이상해졌네요. [2] 2007.08.10
순수주의 Access 자료를 Mysql로 어떻게 넘기죠.,?  
successsssss [re] phpMyAdmin 설치하신분좀 꼭좀 필독해주세여!  
successsssss phpMyAdmin 설치하신분좀 꼭좀 필독해주세여! [2] 2007.08.10
강현호 단축아이콘.. [1] 2007.08.10
타이거마우스 URL에 리퀘스트 요청~~ [1] 2007.08.10
강성민 제로 카운터에서 Total 계산에 오류  
이드레이 [PHP] 최근 게시물을 응용한 질문!! 어캐하는지 몰것어요...( 글이 좀 길어요.^^ )  
이드레이 [PHP] 최근 게시물 추출할때 제목옆에다가 카테고리... ( 이번엔 짧은거...^^ )  
Sang KIM Autocomplete IE 브라우져에 관해서요. [1] 2007.08.10
Free 제로카운터 아이피주소 저장안되게 하는법 없나요?  
리듬버스 특정페이지에 암호를 걸려면 [3] 2007.08.10
soo♡ 포토샵에서 A4용지크기 작업시.. [2] 2007.08.10
윤필주 php 문법에 관한건데..여따 올리네요. [4] 2007.08.10
patty win nt(iis)/php/mysql 환경에서 세션에러는 어떻게 해야하나요...  
함태준 해상도... [5] 2007.08.10
Myzzix 마우스를 오버시에 색이 바뀌잖아요? 테두리는 할 수 있나요? [6] 2007.08.10
노길환 급합니다... 알려주세영 ㅜ.ㅜ  
U-torayo 레이어 관련 질문입니다ㅇㅅㅇ; [2] 2007.08.10
김진우 include 에서 <? ~<? include ?>~?>도 사용가능한지요..? [3] 2007.08.10
우성민 왜 컴마다 다르게 보이지요?? [1] 2007.08.10
순수주의 Access 에서 Mysql로 자료를 넘길때.. [1] 2007.08.10
미친개 정확한 원인이 뭔진 잘 모르겠지만..........  
B2 미디어 재생 질문이요. [1] 2007.08.10