WWW

[알림판목록 I] [알림판목록 II] [글목록][이 전][다 음]
[ WWW ] in KIDS
글 쓴 이(By): cherub (匿生匿死)
날 짜 (Date): 1998년 9월  9일 수요일 오전 08시 46분 06초
제 목(Title): Re: [re]홈페이지에


제가 그냥 깔작거려봤는데요...(무지 허잡허져..-_-;;)

그래두 혹 도움이 되실까하고...

카운터 실행 될때 로그 남기도록 한겁니다...윈도우에서 돌려본거라..

어떨지 모르겠군요...

그럼...도움이 되시길 바랍니다..

랭귀쥐는 펄이구요..

주저리: 꼽사리 질문...릴로드 할때 카운터 안되게 하려면 어떤 방법
        으로 릴로드 되는걸 체크하져?

        ....아래꺼 연결시킬때 ssi로 연결시키구요..count.cgi?st=xxx하면
        st값만 바꺼서 여러번 울거 묵을 수 있어요..-_-;;

-------------------------------< cut here >-------------------------
require 'D:/InetPub/cgi-bin/board/cgi-lib.pl';

&ReadParse(*in);

$Data_dir="D:/InetPub/cgi-bin/Counter/$in{'st'}";

mkdir ($Data_dir,0777);

$C_Data="$Data_dir/counter.dat";
$Connect="$Data_dir/access.log";

&PrintHeader;
############################# counter

open (fileHD,"<$C_Data");
$cc = <fileHD>;
close(fileHD);

if (-z fileHD){
$cc=1; 
}
else{
$cc++;
}
open (fileHD,">$C_Data");
print fileHD $cc; 
print "$cc";
close(fileHD);

##############################################################
## log 남기는 부분

($sec,$min,$hour,$day,$mon,$year,$wday,$yday,$isdst)=localtime(time);
$mon=$mon+1;
# 요일을 사용하기 위한 배열선언
@weekday=("일","월","화","수","목","금","토");

if($year>=98){ $year="19".$year;}
else{ $year="20".$year; }

$mon="0".$mon if($mon<10);
$day="0".$day if($day<10);
$hour="0".$hour if($hour<10);
$min="0".$min if($min<10);

open (file,">>$Connect");
@log = <file>;

print file 
"\n$year/$mon/$day|$weekday[$wday]|$hour:$min|$ENV{'REMOTE_HOST'}|$ENV{'REMOTE_
IDENT'}|$ENV{'HTTP_USER_AGENT'}";
close(file);

-----------------------------< cut here >-------------------------------
#cgi-lib.pl입니다..

#!/usr/bin/perl -- -*- C -*-
# Perl Routines to Manipulate CGI input
# S.E.Brenner@bioc.cam.ac.uk

# input data를 파싱해 주는 함수
# 입력값은 데이타를 가지고갈 포인터
sub ReadParse {
  local (*in) = @_ if @_;
  local ($i, $key, $val);
  # Read in text
  if (&MethGet) {
    $in = $ENV{'QUERY_STRING'};
  } elsif ($ENV{'REQUEST_METHOD'} eq "POST") {
    read(STDIN,$in,$ENV{'CONTENT_LENGTH'});
    $ENV{'QUERY_STRING'}=$in;
  }
  @in = split(/&/,$in);
  foreach $i (0 .. $#in) {
    # Convert plus's to spaces
    $in[$i] =~ s/\+/ /g;
    # Split into key and value.  
    ($key, $val) = split(/=/,$in[$i],2); # splits on the first =.
    # Convert %XX from hex numbers to alphanumeric
    $key =~ s/%(..)/pack("c",hex($1))/ge;
    $key =~ tr/[^A-Za-z0-9\-\_\$\+\=\~\.\,]//;# allow only safe chars
    $val =~ s/%(..)/pack("c",hex($1))/ge;
    $val =~ tr/[^A-Za-z0-9\-\_\$\+\=\~\.\,]//;# allow only safe chars
    # Associate key and value
    $in{$key} .= "\0" if (defined($in{$key})); # \0 is the multiple separator
    $in{$key} .= $val;
  }
  return length($in); 
}

# HTML header를 출력한다.
# MINE부분만을 리턴한다.
sub PrintHeader {
  return "Content-type: text/html\n\n";
}

# MethGet
# Return true if this cgi call was using the GET request, false otherwise
sub MethGet {
  return ($ENV{'REQUEST_METHOD'} eq "GET");
}

# MyURL
# Returns a URL to the script
sub MyURL  {
  return  'http://' . $ENV{'SERVER_NAME'} .  $ENV{'SCRIPT_NAME'};
}

# CgiError
# Prints out an error message which containes appropriate headers,
# markup, etcetera.
# Parameters:
#  If no parameters, gives a generic error message
#  Otherwise, the first parameter will be the title and the rest will 
#  be given as different paragraphs of the body
sub CgiError {
  local (@msg) = @_;
  local ($i,$name);
  if (!@msg) {
    $name = &MyURL;
    @msg = ("Error: script $name encountered fatal error");
  };
  print &PrintHeader;
  print "<html><head><title>$msg[0]</title></head>\n";
  print "<body><h1>$msg[0]</h1>\n";
  foreach $i (1 .. $#msg) {
    print "<p>$msg[$i]</p>\n";
  }
  print "</body></html>\n";
}

# 변수들을 출력한다.
sub PrintVariables {
  local (%in) = @_;
  local ($old, $out, $output);
  $old = $*;  $* =1;
  $output .=  "<DL COMPACT>";
  foreach $key (sort keys(%in)) {
    foreach (split("\0", $in{$key})) {
      ($out = $_) =~ s/\n/<BR>/g;
      $output .=  "<DT><B>$key</B><DD><I>$out</I><BR>";
    }
  }
  $output .=  "</DL>";
  $* = $old;
  return $output;
}

1;# return ture;

--------------------------------------------------------------------
엄마야, 누나야 강변살자...    ^^   _______              ^^     
뜰에는 반짝이는 금모래빛..      __//    __\____    ^^         ^^       
뒷문 밖에는 갈잎에 노래..._____///_____//______\________________________
엄마야, 누나야 강변살자...__---     -----__   --- -_______  ---_____----  
[알림판목록 I] [알림판목록 II] [글 목록][이 전][다 음]
키 즈 는 열 린 사 람 들 의 모 임 입 니 다.