½ÃÀÛÆäÀÌÁö·Î Áñ°Üã±âÃß°¡
·Î±×ÀÎ
ȸ¿ø°¡ÀÔ l Ã⼮üũ l ¸¶ÀÌÆäÀÌÁö l CGIMALL
happycgi
ÀÚ·á½Ç »çÀÌÆ®µî·Ï ·©Å·100 ÇÁ·Î±×·¥¸®ºä °ü¸®ÀÚÃßõÀÚ·á Ãʺ¸°¡À̵å
Ä¿¹Â´ÏƼ
Àüü ÆîÃ帱â
Äü¸Þ´º¸µÅ© jquery , CSS , PHP , Javascript , ¹«·áÆùÆ® , ASP
»ó¼¼°Ë»ö
Ȩ > PHP > PHP ¼Ò½ºÃ¢°í > À¥ À¯Æ¿¸®Æ¼ >  UsersOnline (ÇöÁ¢¼Ó»ç¿ëÀÚ¼ö Ç¥½Ã) 1.0.0 »ó¼¼Á¤º¸
»çÀÌÆ®µî·Ï
Ŭ¶ó¿ìµåű×
Javascript
PHP
ASP
CSS
html
mysql
jquery
image
Mobile
API
slide
°Ô½ÃÆÇ
¸Þ´º
ÇöÀçÁ¢¼ÓÀÚ ¸í »õ·Î°íħ
UsersOnline (ÇöÁ¢¼Ó»ç¿ëÀÚ¼ö Ç¥½Ã) 1.0.0
¼Ò½ºÅë°èÁ¤º¸ ¿À·ù½Å°í ¹× ¹®ÀÇ
ÇØÇÇÆÀ
³×ƼÁð
Æ®À§ÅÍ·Î º¸³»±â ÆäÀ̽ººÏÀ¸·Î º¸³»±â
¼Ò½ººÐ·ù À¥ À¯Æ¿¸®Æ¼
´Ù¿î·Îµå Ƚ¼ö 1051 ȸ
°£´Ü¼³¸í Á¢¼ÓÁßÀÎ »ç¿ëÀÚÀÇ ¼ö¸¦ º¸¿©Áִ Ŭ·¡½º ÆÄÀÏÀÔ´Ï´Ù.
Æò°¡Çϱâ ÈǸ¢ÇÔ ¸Å¿ìÁÁÀ½ ÁÁÀ½ ±¦ÂúÀ½ º¸Åë º°·Î
¼Ò½º´Ù¿î·Îµå µ¥¸ð ¹Ì¸®º¸±â°¡ ¾ø½À´Ï´Ù ½ºÅ©·¦Çϱâ
==============
¼Ò °³ (INTRO)
==============

À¥»çÀÌÆ®ÀÇ ÇöÀç Á¢¼ÓµÈ »ç¿ëÀÚÀÇ ¼ö¸¦ º¸¿©Áִ Ŭ·¡½º È­ÀÏÀÔ´Ï´Ù. MYSQL ÀÇ DB
¸¦ »ç¿ëÇÏ¿© IP ±âÁØÀ¸·Î Á¤ÇØÁø ½Ã°£³»¿¡ Á¢¼ÓÇß´ø »ç¿ëÀÚ¸¦ º¸¿©ÁÖ´Â ¹æ½ÄÀ¸·Î
°ÔÀÌÆ®¿þÀ̸¦ ÀÌ¿ëÇÑ µ¿ÀÏÇÑ IP »ç¿ëÀÚ¸¦ ±¸ºÐÇÏÁö´Â ¸øÇÏÁö¸¸ ÀϹÝÀûÀÎ »ç¿ë¿¡´Â
¹«¸®°¡ ¾ø´Â Ŭ·¡½º ¼Ò½ºÀÔ´Ï´Ù.


==============
¶óÀ̼¾½º
==============

º°µµ ±âÀç ¾øÀ½


==============
¼³Ä¡È¯°æ
==============

MYSQL

=============
¼³ Ä¡
=============

Ŭ·¡½ºÀÇ ¼³Ä¡´Â ºñ±³Àû °£´ÜÇÕ´Ï´Ù.

1) include µð·ºÅ丮³ª Àû´çÇÑ À¥ÀÇ µð·ºÅ丮¿¡ class.UserOnline.inc
ÆÄÀÏÀ» ¾÷·Îµå ÇÕ´Ï´Ù.

2) DB Å×À̺íÀ» ¸¸µì´Ï´Ù. ½ºÅ°¸¶´Â ¾Æ·¡¿Í °°½À´Ï´Ù.
CREATE TABLE usersonline (
timestamp int(15) DEFAULT ``0`` NOT NULL,
ip varchar(40) NOT NULL,
file varchar(100) NOT NULL,
INDEX (timestamp),
INDEX ip(ip),
INDEX file(file)
);

3) DB ¿¡ °ü·ÃµÈ ºÎºÐ¿¡ ȯ°æ¼³Á¤À» ÇÕ´Ï´Ù.
¼³Á¤ºÎºÐÀº ¼Ò½ºÀÇ »ó´ÜÀÇ ¾Æ·¡ºÎºÐÀ» ¼öÁ¤ÇÏ¸é µË´Ï´Ù.

var $host = ``localhost``; <-- DB È£½ºÆ®
var $database = ``websapp``; <-- DB ¸í
var $user = ````; <-- DB À¯Àú¸í
var $password = ````; <-- DB Æнº¿öµå


4) Á¢¼ÓÀÚ¸¦ º¸¿©ÁÖ±æ ¿øÇÏ´Â PHP ¼Ò½º¿¡¼­ ¾Æ·¡ÀÇ ¼Ò½º¸¦ Æ÷ÇÔ½ÃÅ°¸é
ÇöÀçÀÇ Á¢¼ÓÀÚÀÇ ¼ö°¡ Ãâ·ÂµË´Ï´Ù.

include(``class.UsersOnline.inc``);
$ol = new UsersOnline();
$ol->printNumber(); <-- Á¢¼ÓÀÚ Ãâ·ÂºÎºÐ


==============
ÁÖ ÀÇ
==============


ÀϹÝÀûÀÎÀ¸·Î class.UserOnline.inc ÆÄÀÏÀÇ È®ÀåÀÚ¸¦ php ³ª php3 ·Î
¹Ù²Ù¾î »ç¿ëÇϴ°ÍÀÌ º¸¾ÈÀûÀÎ Ãø¸é¿¡¼­ ÁÁ½À´Ï´Ù.

¹Ù²Ù¾ú´Ù¸é Á¢¼ÓÀÚ¸¦ º¸¿©ÁÖ´Â ºÎºÐ¿¡¼­ include(``class.UsersOnline.inc``);
ºÎºÐ¿¡¼­µµ ÆÄÀϸíÀ» ¹Ù²Ù¾î ÁÝ´Ï´Ù.


==============
¼Ò ½º
==============
¼Ò½º´Â ´Ù¿î·Îµå ¹ÞÀ¸¸é µ¿ÀÏÇÑ ¼Ò½º¿Í ¿¹Á¦ÆÄÀÏÀÌ ÀÖ½À´Ï´Ù.


/*
UsersOnline ver 1.0.0
Author: Daniel Kushner
Email: daniel@websapp.com
Release: 08 Nov 2001
Copyright 2001

Database table scheme:

CREATE TABLE usersonline (
timestamp int(15) DEFAULT ``0`` NOT NULL,
ip varchar(40) NOT NULL,
file varchar(100) NOT NULL,
INDEX (timestamp),
INDEX ip(ip),
INDEX file(file)
);

*/

class UsersOnline {

/* public: connection parameters */
var $host = ``localhost``;
var $database = ``websapp``;
var $user = ````;
var $password = ````;

var $timeoutSeconds = 120;
var $numberOfUsers = 0;

function UsersOnline() {
$this->refresh();
}

function getNumber() {
return $this->numberOfUsers;
}

function printNumber() {
if($this->numberOfUsers == 1) {
echo "$this->numberOfUsers User online";
} else {
echo "$this->numberOfUsers Users online";
}
}

function refresh() {
global $REMOTE_ADDR, $PHP_SELF;

$currentTime = time();
$timeout = $currentTime - $this->timeoutSeconds;

mysql_connect($this->host, $this->user, $this->password)
or die(``Error conecting to database``);

mysql_db_query($this->database,
"INSERT INTO usersonline VALUES
(``$currentTime``,``$REMOTE_ADDR``,``$PHP_SELF``)")
or die(``Error writing to database``);

mysql_db_query($this->database,
"DELETE FROM usersonline WHERE timestamp < $timeout")
or die(``Error deleting from database``);

$result = mysql_db_query($this->database,
"SELECT DISTINCT ip FROM usersonline
WHERE file=``$PHP_SELF``")
or die(``Error reading from database``);

$this->numberOfUsers = mysql_num_rows($result);

mysql_close();
}

}

?>


ÀÚ·áÃâó http://www.codelib.co.kr
³×ƼÁð ÀÇ°ß   ÀÌ¿ëÇϽŠÀÚ·áÀÇ Èı⸦ ÀÚÀ¯·Ó°Ô ÀÛ¼ºÇϼ¼¿ä. (»ó¾÷ÀûÀÎ ±¤°í ¹× µµ¹è¼º ±Û µîÀº »çÀüÅ뺸¾øÀÌ »èÁ¦µÉ ¼ö ÀÖ½À´Ï´Ù.)
³»¿ë ¾ÆÀ̵ð ÀÇ°ß³²±â±â
µî·ÏµÈ ÀÇ°ßÀÌ ¾ø½À´Ï´Ù.
1
À̸§
³»¿ë
:³×¸Â¾Æ¿ä: :È­³ª´Â±º¿ä: :Àá¿Í: :¿ì¿ïÇØ: :À̰ǾƳÄ: :¿ÕÇÏÇÏ: ¿Õ¿ôÀ½~ ³î·¥~
Æò°¡Çϱâ ÈǸ¢ÇÔ ¸Å¿ìÁÁÀ½ ÁÁÀ½ ±¦ÂúÀ½ º¸Åë º°·Î
µµ¹è¹æÁöÅ°
 56321073 º¸ÀÌ´Â µµ¹è¹æÁöÅ°¸¦ ÀÔ·ÂÇϼ¼¿ä.