·Î±×ÀÎ | ȸ¿ø°¡ÀÔ | °í°´¹®ÀÇ
Ȱ¿ë°­Á > Ȱ¿ë°­ÁÂ
ActivePerl À» ¼³Ä¡Çϰí CGI °ü·Ã ÇÁ·Î±×·¥µéÀ» ¼³Ä¡Çغ¸ÀÚ. Write by [À̱ٻó]
- ActivePerl ¼³Ä¡Çϱâ
- ActivePerl ¼³Ä¡ Å×½ºÆ® Çϱâ
- Flash Counter ÇÁ·Î±×·¥ ¼³Ä¡
- Technote ¼³Ä¡ Çϱâ.
- Windows 2003 IIS 6.0 ¿¡¼­ÀÇ CGI ¼³Á¤
- onelinechat ¼³Ä¡
Flash Counter ÇÁ·Î±×·¥ ¼³Ä¡

ÀÌÁ¦ °¡Àå °£´ÜÇÑ ÇÁ·Î±×·¥ÀÎ Flash Counter ÇÁ·Î±×·¥À» ¼³Ä¡ÇØ º¼±î¿ä ?
´Ù¿î·Îµå´Â

/apmtip/cgi_source/flashcount.zip

¿¡¼­ ´Ù¿î·Îµå ¹ÞÀ¸½Ç ¼ö ÀÖ½À´Ï´Ù.

ÀÚ ±×·³ ´Ù¿î·Îµå ¹ÞÀº ÆÄÀÏÀÇ ¾ÐÃàÀ» ÇØÁ¦ ÇϽðí.
Apache ÀÇ DocumentRoot ÀÇ flashcount µð·ºÅ丮¿¡ º¹»ç ÇÕ´Ï´Ù.

APM_Setup À¸·Î ¿¹¸¦ µé¸é

C:\APM_Setup\htdocs\flashcount

µð·ºÅ丮°¡ µÇ°ÚÁÒ ?

count.html , count.cgi , count.swf , count.txt

ÀÌ·¸°Ô 4°³ÀÇ ÆÄÀÏÀÌ ÀÖÁÒ ?

±×·³ count.cgi ÆÄÀÏÀ» ÆíÁý±â·Î ¿­¾î º¼±î¿ä ?

#!/usr/bin/perl # #¼³Á¤___###################################################################### $cgi = "./count.cgi"; #CGI½ºÅ©¸³Æ®°¡ ÀÖ´Â ÁÖ¼Ò $file = "./count.txt"; #·Î±×ÆÄÀÏÀÌ ÀÖ´Â ÁÖ¼Ò $cookiename = 'count'; #ÄíŰÀ̸§(º¯°æ°¡´É) $dday = 90; #ÄíŰÀÇ ±âÇÑÀÏ $uselock = 0; #¶ô »ç¿ë¿©ºÎ(0=no 1=yes) ################################################################################# &lock_open(CNT, "+<$file"); $cnt = <CNT>; ($total_c,$yesterday_c,$today_c,$lastday) = split(/,/, $cnt); $total_c++; $today_c++; $your_c = &get_cookie($cookiename) + 1; #####¿À´Ã°ú ¾îÁ¦ÀÇ ¿¬¿ùÀÏ Ãëµæ $ENV{'TZ'} = 'JST-9'; ( $sec, $min, $hour, $day, $mon, $year ) = localtime(time); ($sec2, $min2, $hour2, $day2, $mon2, $year2 ) = localtime(time-24*60*60); $mon++; $year += 1900; $today = "$year-$mon-$day\n"; $mon2++; $year2 += 1900; $yesterday = "$year2-$mon2-$day2\n"; #####¿¬¿ùÀÏ ºñ±³ if ($today ne $lastday) { if ($yesterday ne $lastday) { $yesterday_c = 0; } else { $yesterday_c = $today_c; } $today_c = 1; $lastday = $today; } #####6ÀÚ¸®¼ö º¯È¯ $total_c = sprintf("%06d", $total_c); $today_c = sprintf("%06d", $today_c); $yesterday_c = sprintf("%06d", $yesterday_c); $your_c = sprintf("%06d", $your_c); seek(CNT, 0, 0); print CNT "$total_c,$yesterday_c,$today_c,$lastday\n"; &unlock_close(CNT); #####HTTPÇì´õ print "Content-type: text/plain\n"; &set_cookie($cookiename); print "\n"; print "cgi=$cgi&total=$total_c&yes=$yesterday_c&today=$today_c&you=$your_c&load=end&"; exit(0); #####ÆÄÀ϶ô ¿­±â sub lock_open { local(*FILE, $name) = @_; if (!open(FILE, $name)) { print "content-type: text/plain\n\n"; print "$nameÆÄÀÏÀ» ¿­ ¼ö ¾ø½À´Ï´Ù.\n"; exit(0); } if ($uselock) { eval("flock(FILE, 2)"); if ($@) { print "content-type: text/plain\n\n"; print "$@ÀÌ È¯°æ¿¡¼­´Â flock Àº »ç¿ëÇÒ ¼ö ¾ø½À´Ï´Ù\$uselock = 0 À¸·Î ÇØÁÖ¼¼¿ä\n"; exit(0); } } seek(FILE, 0, 0); } #####ÆÄÀ϶ô ´Ý±â sub unlock_close { local(*FILE) = @_; if ($uselock) { eval("flock(FILE, 8)"); } close(FILE); } #####===ÄíŰó¸®===############################################################################ #####ÄíŰÀ¯È¿±â°£ sub get_cookie_date { $ENV{'TZ'} = 'JST-9'; my( $csec, $cmin, $chour, $cday, $cmon, $cyear, $cwday ) = localtime(time + $dday*60*60*24); my(@month) = qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec); my(@week) = qw(Sun Mon Tue Wed Thu Fri Sat); return sprintf("%s, %d-%s-%04d %02d:%02d:%02d GMT", $week[$cwday],$cday,$month[$cmon+1],$cyear+1900,$chour,$cmin,$csec); } #####ÄíŰÀÇ Ãâ·Â sub set_cookie { local($cookiename2) = @_; $cookiedate = &get_cookie_date; print "Set-Cookie: $cookiename=$your_c; expires=$cookiedate; \n"; } #####ÄíŰÀÇ Ãëµæ sub get_cookie { local($cookiename1) = @_; @pairs = split(/; /, $ENV{'HTTP_COOKIE'}); foreach $pair (@pairs) { ($name, $value) = split(/=/, $pair); if ($name eq $cookiename) { return $value; } } return ''; } ###################################################################################################
±×·³ À§ÀÇ ¼Ò½º¸¦ º¸½Ã¸é ¸Ç À­ÁÙ¿¡ #!/usr/bin/perl À§ÀÇ ³»¿ëÀÌ ÀÖÁÒ ? ±×·³ ÀÌ °ÍÀ» #!C:/Perl/bin/perl.exe ÀÌ·¸°Ô perl.exe ÀÇ À§Ä¡·Î º¯°æÇϽðí ÀúÀåÇÕ´Ï´Ù. ÀÚ ±×·³ ÀúÀåÇϰí ÀÌ CGI ÇÁ·Î±×·¥ÀÌ µ¿ÀÛÇϳª Å×½ºÆ®¸¦ ÇØº¸½Ã·Á¸é. http://localhost/flashcount/count.cgi cgi=./count.cgi&total=000002&yes=000000&today=000002&you=000001&load=end& ÀÌ·¸°Ô ³ª¿Â´Ù¸é Á¤»óÀÛÀ¸·Î µ¿ÀÛ Çϴ°ÍÀ̰ÚÁÒ ? ¿¹¿¡¼­ ó·³ 500 ¿¡·¯°¡ ³ª¿Â´Ù¸é.. CGI ¼Ò½ºÀÇ ÀÌ»óÀÌ ÀÖ³ª È®ÀÎÇØ º¸½Ã±â ¹Ù¶ø´Ï´Ù. ÀÚ ±×·³.. count.html ÆÄÀÏÀ» ¿­¾î º¼±î¿ä ? Flash count ÇÁ·Î±×·¥ÀÇ ¿¹¸¦ ³ªÅ¸³»´Â HTML ¼Ò½º ÀÔ´Ï´Ù.
<html> <head> <title>flash-counter</title> <meta http-equiv="Content-Type" content="text/html"> </head> <body bgcolor="#ffffff"> <p align="center"> <p align="center"> <embed src="http://yourhome/count.swf?cgi=http://yourhome/count.cgi&" type="application/x-shockwave-flash" width="150" height="70" bgcolor="#ffffff"> </embed> </p> </body> </html>
ÀÌ·¸°Ô µÇ¾î ÀÖÁÒ ?
<embed src="http://yourhome/count.swf?cgi=http://yourhome/count.cgi&" type="application/x-shockwave-flash" width="150" height="70" bgcolor="#ffffff"></embed>
ÀÌ ºÎºÐÀ».
<embed src="/flashcount/count.swf?cgi=/flashcount/count.cgi&" type="application/x-shockwave-flash" width="150" height="70" bgcolor="#ffffff"></embed>
ÀÌ·¸°Ô ¼öÁ¤ÇÕ´Ï´Ù. /flashcount/ ´Â flash count °¡ ¼³Ä¡µÈ °æ·Î°ÚÁÒ ? ±×·³ http://localhost/flashcount/count.html ÀÌ·¸°Ô count.html ÆÄÀÏÀ» ½ÇÇàÇØ º¼±î¿ä ? Flash Count °¡ Àß ³ª¿À´Â°ÍÀ» º¼ ¼ö ÀÖÁÒ ? ^^;;
ÀÌÀü±Û ActivePerl ¼³Ä¡ Å×½ºÆ® Çϱâ
´ÙÀ½±Û Technote ¼³Ä¡ Çϱâ.
À̸ÞÀϹ«´Ü¼öÁý°ÅºÎ , ±¤°íÁ¦ÈÞ¹®ÀÇ , E-Mail, MSN : okstart@apmsetup.com