>> Delete No. 517 article
No. 제발 부탁드려요...-_-;;

등록 2000-07-24 04:11:00 By localhost     조회 3
이름 이 관형    

		오늘도 부족한 저의 실력을 설명을 하고져 합니다.
제가 요즘 제 홈페이지의 막바지 작업을 진행 중인데
지금 카운터가 설치가 않되 고민하고 있습니다..
카운터는 쏘스를 가져와서 컴파일을 한거구요..
도와 주세요..
######################################################
먼저 count.cgi 내용
#!/usr/bin/perl
 ##########################################################################################
$cookiepass = "1624516";
$main_dir = "/usr/local/apache/htdocs/counter/hyung";
$img_url = "http://penguin.pe.kr/counter/img/today";
$img_url = "http://penguin.pe.kr/counter/img/total";
$pass = "0725";
$width = "9";
$height = "23";
###########################################################################################
 @querys = split(/&/, $ENV{'QUERY_STRING'});
foreach $query (@querys) {
($name, $value) = split(/=/, $query);
$FORM{$name} = $value;
}
 $picker = "$main_dir/fly";
$main_dir = "$main_dir/$FORM{'hyung'}";
$cookie = "1";
 if($FORM{'pass'} ne ""){
print "Content-type: text/html";
if($FORM{'id'} eq ""){
print "<title>카운터 초기화 에러 -.-</title>";
print "
  <table border=0 cellpadding=2 cellspacing=0 width=350 bgcolor=#000099>";
print "<tr><td><table border=0 cellpadding=2 cellspacing=0 width=100% bgcolor=#F5E9FF><tr><td bgcolor=#000099>";
print "
♡-.- 아이디가 적혀있지 않군요... -.-♡</td></tr><tr><td>
  ";
print "예) id=hyung
 </td></tr></table></td></tr></table>
   ";
exit 0;
}
 if($FORM{'start'} eq ""){
print "<title>초기화 에러... -.-</title>
";
print "
 <table border=0 cellpadding=2 cellspacing=0 width=350 bgcolor=#000099><tr><td><table border=0 cellpadding=2 cellspacing
=0 width=100% bgcolor=#F5E9FF>"; print "<tr><td bgcolor=#000099>
♡-.- 카운터 초기값이 빠졌어요... -.-♡</td></tr><tr><td>
  ";
print "예) start=123
 </td></tr></table></td></tr></table>
   ";
exit 0;
}
 mkdir("$main_dir",0777);
if($pass eq $FORM{'pass'}) {
open(READCOUNT, "$main_dir/counter.txt");
@readcount=;
$readcount[0] = "$FORM{'start'}";
close(READCOUNT);
open(PRINTCOUNT,">$main_dir/counter.txt");
&lock;
for(0..18){
print PRINTCOUNT "$readcount[$_]";
}
&unlock;
close(PRINTCOUNT);
 print "<title>카운터 초기화 완료</title>";
print "
  <table border=0 cellpadding=2 cellspacing=0 width=350 bgcolor=#000099><tr><td><table border=0 cellpadding=2 cellspacin
g=0 width=100% bgcolor=#F5E9FF>"; print "<tr><td bgcolor=#000099>
♡^.^ 카운터가 초기와 되었습니다. ^.^♡</td></tr>";
print "<tr><td>
  초기화된 카운터 값: $FORM{'start'}
 </td></tr></table></td></tr></table>
   ";
 }
else{
print "
Password error!!!
";
}
exit 0;
}
 &cookie;
&main_htm;
 sub cookie{
if($ENV{'HTTP_COOKIE'}) {
@cookies = split(/; /,$ENV{'HTTP_COOKIE'});
foreach(@cookies) {
($name,$value) = split(/=/,$_);
$COOKIE{$name} = $value;
}
}
}
 sub main_htm{
open(READCOUNT, "$main_dir/counter.txt");
@readcount=;
chop(@readcount);
close(READCOUNT);
$total=$readcount[0];
$today=$readcount[1];
if($FORM{'val'} eq "total"){
if($COOKIE{'NAME'} ne "$FORM{'id'}$cookiepass"){
&visit_count;
}
}
if ($cookie eq "1"){
print "Set-Cookie: NAME=$FORM{'id'}$cookiepass;
";
}
}
 sub visit_count{
if($readcount[0] eq ""){
print "Set-Cookie: NAME=$FORM{'id'}$cookiepassBACKUP;
";
 open(BACKUP01,"$main_dir/backup01.txt");
@backup=;
chop(@backup);
close(BACKUP01);
 if($backup[0] eq ""){
open(BACKUP02,"$main_dir/backup02.txt");
@backup=;
chop(@backup);
close(BACKUP02);
}
open(PRINTCOUNT,">$main_dir/counter.txt");
&lock;
for(0..18){
print PRINTCOUNT "$backup[$_]";
}
&unlock;
close(PRINTCOUNT);
$plus_num = "2";
&count_plus;
}
$plus_num = "1";
&count_plus;
}
 sub count_plus{
$total=$readcount[0];
$today=$readcount[1];
$read_date=$readcount[2];
 $Ostm = $ENV{'HTTP_USER_AGENT'};
&get_time;
$total+=$plus_num;
if($read_date eq $writedate){
$today+=$plus_num;
}
else{
$today="1";
}
$readcount[0]=$total;
$readcount[1]=$today;
@month_check=split(///, "$readcount[2]");
if($month_check[1] ne "$month"){
$readcount[$month+2]="";
}
$readcount[2]=$writedate;
@count_day=split(/|/, "$readcount[$month+2]");
$count_day[0]+=$plus_num;
@count_hour=split(/:/, "$count_day[$mday]");
$count_hour[0]+=$plus_num;
$count_hour[$hour+1]+=$plus_num;
$count_day[$mday]=join(':' , @count_hour);
$readcount[$month+2]=join('|' ,@count_day);
@week=split(/|/,$readcount[15]);
$week[$wday] +=$plus_num;
$readcount[15]=join('|',@week);
@OSM=split(/|/,$readcount[16]);
if($Ostm =~ /95/){
$OSM[0] +=$plus_num;
}elsif($Ostm =~ /98/){
$OSM[1] +=$plus_num;
}elsif($Ostm =~ /NT/){
$OSM[2] +=$plus_num;
}elsif($Ostm =~ /Macintosh/){
$OSM[3] +=$plus_num;
}elsif($Ostm =~ /UNIX/ || $Ostm =~ /Linux/){
$OSM[4] +=$plus_num;
}elsif($Ostm =~ /SunOS/){
$OSM[5] +=$plus_num;
}else{
$OSM[6] +=$plus_num;
}
$readcount[16]=join('|',@OSM);
@BRW=split(/|/,$readcount[17]);
if($Ostm =~ /Opera/){
$BRW[0] +=$plus_num;
}elsif($Ostm =~ /MSIE 4/){
$BRW[1] +=$plus_num;
}elsif($Ostm =~ /MSIE 5/){
$BRW[2] +=$plus_num;
}elsif($Ostm =~ /Mozilla/){
$BRW[3] +=$plus_num;
}else{
$BRW[4] +=$plus_num;
}
$readcount[17]=join('|',@BRW);
open(PRINTCOUNT,">$main_dir/counter.txt");
&lock;
for(0..18){
print PRINTCOUNT "$readcount[$_]";
}
&unlock;
close(PRINTCOUNT);
if($readcount[0] ne ""){
if($total%2){
&backup01;
}
else{
&backup02;
}
}
}
  sub get_time{
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime(time);
$month=($mon+1);
if($year ne "99"){
if($year > 100){
$year=($year-100)+2000;
}
elsif($year < 10){
$year=2000+$year;
}
else{
$year="2000";
}
}
else{
$year="1999";
}
$writedate="$year/$month/$mday";
}
 sub backup01{
open(BACKUP01,">$main_dir/backup01.txt");
for(0..18){
print BACKUP01 "$readcount[$_]";}
close(BACKUP01);
}
 sub backup02{
open(BACKUP02,">$main_dir/backup02.txt");
for(0..18){
print BACKUP02 "$readcount[$_]";}
close(BACKUP02);
}
 if($FORM{'img'} ne ""){
$num_img = "$img_url/$FORM{'img'}";
}
else{
$num_img = "$img_url/a";
}
 if($FORM{'pos'} eq ""){
$pos_num = 6;
}
elsif(($FORM{'pos'} >= 1) && ($FORM{'pos'} <= 50)){
$pos_num = $FORM{'pos'};
}
else{
$pos_num = 6;
}
 open(READCOUNT, "$main_dir/counter.txt");
@readcount=;
chop(@readcount);
close(READCOUNT);
$total=$readcount[0];
$today=$readcount[1];
  if($FORM{'val'} eq "total"){
$temp_file = "$main_dir/picker1.tmp";
$num_data = sprintf("%.$pos_numd",$total);
 }
elsif($FORM{'val'} eq "today"){
$temp_file = "$main_dir/picker2.tmp";
$num_data = sprintf("%.$pos_numd",$today);
 }
 print "Content-type: image/gif";
 @w = split(//,$num_data);
$ww = $#w + 1;
 $Imgwidth = ($ww * $width);
$Imgheight = $height;
 open(FLY,"> $temp_file");
 print FLY "new";
print FLY "size $Imgwidth,$Imgheight";
  $wpos = 0;
foreach (split(//,$num_data)){
 print FLY "copy $wpos,0,-1,-1,-1,-1,$num_img/$_.gif";
$wpos = ($wpos + $width);
}
 print FLY "interlace";
 close(FLY);
 open(TMP,"$picker -q -i $temp_file |");
 while( ){
print;
}
close(TMP);
 unlink($temp_file);
 sub lock {
local($LockFile) = "count.loc";
local($EndTime) = time+45;
while (-s $LockFile && time < $EndTime) {
sleep(1);
}
open(LOCK, ">$main_dir/$LockFile");
print LOCK "lock";
close(LOCK);
}
 sub unlock {
local($LockFile) = "count.loc";
open(LOCK, ">$main_dir/$LockFile");
print LOCK "";
close(LOCK);
}
 1;
######################################################
다음은 view.cgi 내용
#!/usr/bin/perl
 ###########################################################################################
$main_url = "http://penguin.pe.kr/counter"; #count.cgi파일이 있는곳의 URL입니다.
$img_url = "http://penguin.pe.kr/counter/img"; #막대그래프 이미지가 있는곳의 URL입니다.
###########################################################################################
 &parse;
 $main_dir = "/usr/local/apache/htdocs/counter/$FORM{'hyung'}";
 ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime(time);
$month=($mon+1);
 if($year ne "99"){
if($year > 100){
$year=($year-100)+2000;
}
elsif($year < 10){
$year=2000+$year;
}
else{
$year="2000";
}
}
else{
$year="1999";
}
 if($FORM{'day'}){
&visit_day_form;
}
elsif($FORM{'hour_total'}){
&hour_total;
}
elsif($FORM{'week_total'}){
&week_total;
}
else{
&visit_month_form;
}
 sub visit_month_form{
 $month +=0;
$mday +=0;
 if(!$FORM{'mon'}){
$FORM{'mon'}=$month;
}
 &count_file_open;
@count_line=split(/|/ , $months_line[$FORM{'mon'}+2]);
$total=$count_line[0];
$ck_x='0';
for(1..31){
@hour_line=split(/:/, $count_line[$_]);
$read_line[$ck_x]=($hour_line[0]);
$ck_x += 1;
}
 @high_line=@read_line;
@high_line=reverse(sort jangryal(@high_line));
$high_line[0]=1 if($high_line[0]<1);
$best_high=250/$high_line[0];
 $how_year=$year;
 if($FORM{'mon'}>$month){
$how_year-=1;
}
 print "Content-type: text/html";
 print <
 <title> $how_year년 $FORM{'mon'}월 방문통계</title>
   <table border="0" cellpadding="2" cellspacing="0" width="98%" bgcolor="#FF000A">
<tr>
<td><table border="0" cellpadding="3" cellspacing="0" width="100%" bgcolor="#FFFFFF">
<tr>
<td>
☞월-일 접속통계 | 일-시 접속통계 | 시간대별 누산 | 요일,OS별 누산 </td>
</tr>
</table></td>
</tr>
</table>
   END
 print "
<table border=0 cellspacing=0 cellpadding=2 width=98% bgcolor=#EFEFEF><tr><td width=54>
月통계▶</td>";
for(1..12){
 if($FORM{'mon'} != $_){
print "<td align=right>";
print " ";
print "$_月</td>";
}else{
print "<td align=right> $_月</td>";
}
 }
print "<td widht=13></td></tr><tr><td width=54>
 접속수▶</td>";
for(3..14){
@split_mon_hit=split(/|/,$months_line[$_]);
print "<td align=right>";
if($FORM{'mon'} != ($_ - 2)){
print " $split_mon_hit[0]";
}else{
print " $split_mon_hit[0]";
}
print "</td>";
}
print "<td widht=13></td></tr></table>
 ";
 print <
 <table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td colspan=2>
DATE [ $how_year年 $FORM{'mon'}月 날자별 접속횟수 ]</td>
</tr>
END
for(1..31){
$width_x=$best_high*$read_line[$_-1];
$width_x=$width_x<1?1:$width_x;
print "<tr><td width=21>";
if($_ < 10){ $_ = "0$_"; }
print "";
print "$_</td>";
print "<td width=274>";
print "$read_line[$_-1]</td></tr>";
}
print "</tr></table>";
&banner;
print "";
exit;
}
 sub visit_day_form{
$month +=0;
$mday +=0;
if(!$FORM{'mon'}){
$FORM{'mon'}=$month;
}
if(!$FORM{'day'}){
$FORM{'day'}=$mday;
}
&count_file_open;
@day_line=split(/|/ , $months_line[$FORM{'mon'}+2]);
@hour_line=split(/:/ , $day_line[$FORM{'day'}]);
$total=$hour_line[0];
@high_line=@hour_line;
@high_line=reverse(sort jangryal(@high_line));
 $high_line[1]=1 if($high_line[1]<1);
$best_high= 250/$high_line[1];
$how_year="$year";
if($FORM{'mon'}>$month){
$how_year-=1;
}
 print "Content-type: text/html";
 print <
 <title> $how_year년 $FORM{'mon'}월 $FORM{'day'}일 시간별 방문통계</title>
   <table border="0" cellpadding="2" cellspacing="0" width="98%" bgcolor="#0000CC">
<tr>
<td><table border="0" cellpadding="3" cellspacing="0" width="100%" bgcolor="#FFFFFF">
<tr>
<td>
월-일 접속통계 | ☞일-시 접속통계 | 시간대별 누산 | 요일,OS별 누산 </td>
</tr>
</table></td>
</tr>
</table>
   <table border="0" cellpadding="0" cellspacing="0" width="80%">
<tr>
<td colspan=2>HOUR [ $how_year年 $FORM{'mon'}月 $FORM{'day'}日 시간대별 접속횟수 ]</td>
</tr>
END
 for(1..24){
$width_x=$best_high*$hour_line[$_];
$width_x= 1 if($width_x < 1);
$w_t=$_-1;
$what_time=$_ < 11 ? "0$w_t" : $w_t ;
print "<tr><td width=21>$what_time</td>";
print "<td width=274>";
print "$hour_line[$_]</td></tr>";
}
print "</table>";
&banner;
print "";
exit;
}
 sub hour_total{
 $month +=0;
$mday +=0;
&count_file_open;
 for(3..14){
@month=split(/|/, $months_line[$_]);
for(1..31){
@dates=split(/:/,$month[$_]);
for(0..23){
$com = $_ +1;
$HOUR{"hour_$_"} += $dates[$com];
}
}
}
 $best_com=0;
for(0..23){
$best_com=$HOUR{"hour_$_"} if($HOUR{"hour_$_"} > $best_com);
}
 $best_com=1 if($best_com < 1);
$long_size=250/$best_com;
 print "Content-type: text/html";
 print <
 <title> 시간대별 누산통계</title>
    <table border="0" cellpadding="2" cellspacing="0" width="98%" bgcolor="#FF000A">
<tr>
<td><table border="0" cellpadding="3" cellspacing="0" width="100%" bgcolor="#FFFFFF">
<tr>
<td>
월-일 접속통계 | 일-시 접속통계 | ☞시간대별 누산 | 요일,OS별 누산 </td>
</tr>
</table></td>
</tr>
</table>
   <table border="0" cellpadding="0" cellspacing="0" width="80%">
<tr><td colspan=2>HOUR [ 시간대별 접속횟수 누산통계 ]</td>
</tr>
END
 for(0..23){
$hour_num=$_ < 10?"0$_":$_;
$cont_num=$HOUR{"hour_$_"};
$width_num=$long_size * $cont_num;
$width_num=1 if($width_num < 1);
$cont_num="" if($cont_num < 1);
print "<tr><td width=21>$hour_num</td>";
print "<td width=274>";
print "$cont_num</td></tr>";
}
print "</table>";
&banner;
print "";
exit;
}
 sub week_total{
$month +=0;
$mday +=0;
&count_file_open;
@week_line=split(/|/,$months_line[15]);
 foreach $key(@week_line){
$best_long=$key if($key > $best_long);
}
 $best_long=1 if($best_long < 1);
$gr_size=250/$best_long;
@week_text=("日","月","火","水","木","金","土");
 if($months_line[16]){
@OSTM=split(/|/,$months_line[16]);
foreach $key(@OSTM){
$os_long=$key if($key > $os_long);
}
 $os_long=1 if($os_long < 1);
$os_size=250/$os_long;
$w95 =$os_size*$OSTM[0];
$w98 =$os_size*$OSTM[1];
$wnt =$os_size*$OSTM[2];
$mac =$os_size*$OSTM[3];
$unix =$os_size*$OSTM[4];
$sun =$os_size*$OSTM[5];
$wex =$os_size*$OSTM[6];
}
$w95 +=1;
$w98 +=1;
$wnt +=1;
$mac +=1;
$unix +=1;
$sun +=1;
$wex +=1;
 if($months_line[17]){
@BRW=split(/|/,$months_line[17]);
foreach $key(@BRW){
$brw_long=$key if($key > $brw_long);
}
 $brw_long=1 if($brw_long < 1);
$brw_size=250/$brw_long;
$bre3 =$brw_size*$BRW[0];
$bre4 =$brw_size*$BRW[1];
$bre5 =$brw_size*$BRW[2];
$bnes =$brw_size*$BRW[3];
$brx =$brw_size*$BRW[4];
}
 $bre3 +=1;
$bre4 +=1;
$bre5 +=1;
$bnes +=1;
$brx +=1;
 print "Content-type: text/html";
 print <
  <title> 요일,OS별 누산통계</title>
   <table border="0" cellpadding="2" cellspacing="0" width="98%" bgcolor="#0000CC">
<tr>
<td><table border="0" cellpadding="3" cellspacing="0" width="100%" bgcolor="#FFFFFF">
<tr>
<td>
월-일 접속통계 | 일-시 접속통계 | 시간대별 누산 | ☞요일,OS별 누산 </td>
</tr>
</table></td>
</tr>
</table>
     [ 요일, OS별 접속횟수 누산 통계 ]
  <table border=0 cellpadding=1 cellspacing=0 width=80%><tr><td colspan=2>▶요일별</td></tr>
END
 for(0..6){
$width = $gr_size * $week_line[$_] ;
$width += 1;
print "<tr><td width=40>$week_text[$_]요일</td><td width=270> $week_line[$_]</td></tr>";
}
print "</table>";
 print "
<table border=0 cellpadding=1 cellspacing=0 width=80%><tr><td colspan=2>▶운영체제별</td></tr>";
print "<tr><td width=70>Windows95</td><td width=270> $OSTM[0]</td></tr>";
print "<tr><td width=70>Windows98</td><td width=270> $OSTM[1]</td></tr>";
print "<tr><td width=70>WindowsNT</td><td width=270> $OSTM[2]</td></tr>";
print "<tr><td width=70>Macintosh</td><td width=270> $OSTM[3]</td></tr>";
print "<tr><td width=70>Unix/Linux</td><td width=270> $OSTM[4]</td></tr>";
print "<tr><td width=70>SunOS</td><td width=270> $OSTM[5]</td></tr>";
print "<tr><td width=70>기 타</td><td width=170> $OSTM[6]</td></tr></table>";
print "
<table border=0 cellpadding=1 cellspacing=0 width=80%><tr><td colspan=2>▶부라우저 별</td></tr>";
print "<tr><td width=90>익스플로러4.xx</td><td width=270> $BRW[1]</td></tr>";
print "<tr><td width=90>익스플로러5.xx</td><td width=270> $BRW[2]</td></tr>";
print "<tr><td width=90>네스케이프</td><td width=270> $BRW[3]</td></tr>";
print "<tr><td width=90>오 페 라</td><td width=270> $BRW[0]</td></tr>";
print "<tr><td width=90>기 타</td><td width=270> $BRW[4]</td></tr></table>";
&banner;
print "";
exit;
}
 sub count_file_open{
open(VISIT, "$main_dir/counter.txt");
@months_line=;
close(VISIT);
chop(@months_line);
}
 sub banner{
print <
  <table border="0" cellpadding="0" cellspacing="0" width="60%">
<tr>
<td>
★Created by ensoo★</td>
</tr>
<tr>
<td>
 ★Powered by sepal★</td>
</tr>
</table>
   END
}
 sub jangryal{
local($num_a, $num_b);
$num_a=$a=~/^[0-9]+/;
$num_b=$b=~/^[0-9]+/;
$retval=$a<=>$b;
$retval;
}
 sub parse{
@args = split(/&/, $ENV{'QUERY_STRING'});
 foreach $pair (@args) {
($name, $value) = split(/=/, $pair);
$FORM{$name} = $value;
}
}
 1;
#####################################################
그리고 이미지 디렉토리는 counter 디렉토리 않에 있습니다
img 디렉토리 않에는 today 디렉토리와 total 디렉토리가
있습니다.
그리고 설명서를 보시려면은...
http://www.penguin.pe.kr/설명서.htm 그리고 카운터를 보시려면은 ...
http://www.penguin.pe.kr/main.html 를 주소줄에 기록을 하시면 보실수 있습니다..
[관리자] 패스워드를 입력 하십시오. 답장이 존재하면 함께 삭제됩니다.[ 목록 | 이전 ]
패스워드:    

Copyleft 1999-2026 by JSBoard Open Project
Theme Designed by IDOO All right reserved