= \@bcat |
= \@scat |
= \@cat{Programming} |
= \@cat{wikiX} |
= \@ecat |
= \TableOfContents |
= |
= /*! wikiXmacros¿Í \\basis \\easis ÀÌ¿ë*/ |
= \def@bverb={ |
= <tt> |
= \dcSave |
= \noDefault |
= } |
= \def@everb={ |
= \dcRestore |
= </tt> |
= } |
= \def@bverbox=<table style="background-color:#eeeeee; border:1 solid;"><tr><td>\@bverb |
= \def@everbox=\@everb</td></tr></table> |
= |
= !¿ÜºÎ¿¡ ÀÚ±â ipµî·Ï½ÃÅ°±â |
= À¯µ¿ip¸¦ »ç¿ëÇÏ´Â °æ¿ì, °Ô´Ù°¡ °øÀ¯±âµîÀ» ½á¼ ÀÚ±â ip¸¦ ÀÚ±â pc¿¡¼µµ ¸ð¸£´Â °æ¿ì°¡ ÀÖ½À´Ï´Ù. |
= |
= ¿ÜºÎ¿¡ µî·ÏÇؼ Á¢¼ÓÇÏ·Á°í ÇÏ¸é ´ÙÀ½°ú °°Àº ¹æ¹ýÀÌ ÀÖ½À´Ï´Ù. |
= |
= ÀÏ´Ü ¿ÜºÎ¿¡¼ ÀÚ±â ip¸¦ ¾Æ´Â ¹æ¹ýÀº ÀÚ±â pc¿¡¼ À¥À¸·Î Àڱ⠰èÁ¤ÀÌ ÀÖ°í php¸¦ ¾µ ¼ö Àִ ȨÆäÀÌÁö¿¡ Á¢¼ÓÇÏ´Â ÇÁ·Î±×·¥À» ¬´Ï´Ù. |
= ±×¸®°í ³ª¼ ±× ȨÆäÀÌÁö¿¡¼ php·Î Á¢¼ÓÇÑ Å¬¶óÀ̾ðÆ®ÀÇ ip¸¦ ÀúÀåÇÏ¸é µË´Ï´Ù. |
= |
= C·Î Ŭ¶óÀ̾ðÆ®¸¦ ®°í, ¼¹öÀÇ PHP ½ºÅ©¸³Æ®µµ ¿Ã¸³´Ï´Ù. |
= |
- C¼Ò½º |
+ !!C¼Ò½º |
= |
= |
= \@bverbox |
= \basis |
= /* |
= * |
= * Daniel Jiseok Song |
= * kldp.netÀÇ hedicÀ» ÂüÁ¶ÇØ ¸¸µé¾ú½À´Ï´Ù. |
= * cygwin gcc¿¡¼µµ ºôµåµÇ°í linux¿¡¼µµ ºôµåÇغýÀ´Ï´Ù. ¾Æ¸¶ VisualC¿¡¼µµ ºôµåµÉ °Ì´Ï´Ù. |
= * |
= */ |
= |
= #include <stdio.h> |
= #include <string.h> |
= #ifdef WIN32 |
= #include <winsock2.h> |
= #else |
= #include <unistd.h> |
= #include <netdb.h> |
= #endif |
= #include <stdio.h> |
= #include <stdlib.h> |
= #include <sys/types.h> |
= #include <sys/socket.h> |
= #include <netinet/in.h> |
= #include <netdb.h> |
= #include <strings.h> |
= #include <unistd.h> |
= #include <pthread.h> |
= #include <errno.h> |
= #include <sys/ioctl.h> |
= |
= #define VERSION "v0.1" |
= #define URL "rommance.kldp.org" //ÀÌ°ÍÀº ÀڱⰡ °èÁ¤À» °¡Áø ¿ÜºÎ¼¹ö ÁÖ¼ÒÀÔ´Ï´Ù. (¿¹¸¦ À§ÇØ °¡»óÀÇ ÁÖ¼Ò »ç¿ë) |
= #define SURL "http://rommance.kldp.org/~rommance/ipstore.php" // ÀÌ°ÍÀº ±× ¼¹öÀÇ ¾î´À °æ·Î¿¡ Á¢¼ÓÇÒ Áö ³ªÅ¸³À´Ï´Ù. |
= |
= void get_result( int sd ) |
= { |
= char buf[100]; |
= int len; |
= int i; |
= //printf("in get_result\n"); |
= while (1) { |
= len = recv(sd, buf, 100, 0); |
= //printf("after recv\n"); |
= if (!len) |
= break; |
= //for(i=0;i<len;i++) |
= //printf("%c", buf[i]); |
= } |
= } |
= int go( void ) |
= { |
= #ifdef WIN32 |
= SOCKET sd; |
= #else |
= int sd; |
= #endif |
= struct hostent *he; |
= struct sockaddr_in sai; |
= char buf[1024]; |
= |
= //printf("before socket\r\n"); |
= sd = socket(AF_INET, SOCK_STREAM, 0); |
= #ifdef WIN32 |
= //printf("invalid socket\r\n"); |
= if (sd == INVALID_SOCKET) |
= #else |
= //printf("before sd<0\r\n"); |
= if (sd < 0) |
= #endif |
= { |
= printf("Cannot make a socket.\n"); |
= return -1; |
= } |
= |
= //printf("before he\r\n"); |
= he = gethostbyname(URL); |
= //printf("after he\r\n"); |
= memset((void *)&sai, 0, sizeof(sai)); |
= //printf("after memset\r\n"); |
= sai.sin_family = AF_INET; |
= sai.sin_port = htons(80); |
= //printf("after htons\r\n"); |
= sai.sin_addr.s_addr = ((struct in_addr *)(he->h_addr))->s_addr; |
= |
= //printf("before connect\r\n"); |
= if (connect(sd, (void *)&sai, sizeof(sai)) < 0) |
= { |
= printf("Cannot connect.\n"); |
= #ifdef WIN32 |
= closesocket(sd); |
= #else |
= close(sd); |
= #endif |
= return -1; |
= } |
= |
= // »çÀÌÆ®·Î ãÀ» ´Ü¾î¸¦ º¸³À´Ï´Ù. |
= sprintf(buf, "GET %s\n", SURL); |
= send(sd, buf, strlen(buf), 0); |
= |
= // ¼¹ö¿¡¼ Ãâ·ÂÇØ ÁÖ´Â html ¹®¼¸¦ ¹Þ¾Æ ºÐ¼®ÇÕ´Ï´Ù. |
= get_result(sd); |
= #ifdef WIN32 |
= closesocket(sd); |
= #else |
= close(sd); |
= #endif |
= |
= return 0; |
= } |
= |
= int main(int argc, char *argv[]) |
= { |
= #ifdef WIN32 |
= WORD wVersionRequired; |
= WSADATA wsaData; |
= int ErrCode; |
= #endif |
= |
= #ifdef WIN32 |
= wVersionRequired = MAKEWORD(2,0); //get wsock... |
= ErrCode = WSAStartup(wVersionRequired, &wsaData); |
= if ( ErrCode !=0) |
= { |
= printf("WSAStartup error = %d \n", ErrCode); |
= return -1; |
= } |
= #endif |
= go(); |
= |
= #ifdef WIN32 |
= WSACleanup(); |
= #endif |
= return 0; |
= } |
= |
= \easis |
= \@everbox |
= |
- ¼¹ö php ½ºÅ©¸³Æ® |
+ !!¼¹ö php ½ºÅ©¸³Æ® |
= ipstore.php |
= \@bverbox |
= \basis |
= <?php |
= |
= $ip = $_SERVER['REMOTE_ADDR']; |
= |
= echo "Your IP address is: $ip"; |
= $filename = "store/ip.txt"; // °èÁ¤ ¼¹ö¿¡¼ ÀúÀåÇÒ ÆÄÀÏ À̸§. |
= // $command="echo ".$ip." > ".$filename; |
= // shell_exec($command); |
= // echo $command; |
= $fr=fopen($filename, "a+"); |
= //$fr=fopen($filename, "w"); |
= if (!$fr) { |
= echo("Could not open file"); |
= exit; |
= } |
= fputs($fr, $ip); |
= $cur_date=time(); // ÇöÀç ½Ã°£. |
= // echo "today is ".$cur_date; |
= //$c_reg_date="<span title='".date("Y³â m¿ù dÀÏ H½Ã iºÐ |
= // sÃÊ",$cur_date)."'>".date("Y/m/d",$cur_date)."</span>"; |
= $c_reg_date=" ".date("Y/m/d H:i:s",$cur_date); |
= //echo $c_reg_date; |
= fputs($fr, $c_reg_date); |
= fputs($fr, "\r\n"); |
= fclose($fr); |
= /* |
= $line = file($filename); |
= |
= for($i=0; $i < sizeof($line); $i++) |
= { |
= echo"<img src=\"$line[$i]\">"; |
= }*/ |
= |
= ?> |
= |
= \easis |
= \@everbox |
= |
- windows¿ë ¼Ò½º |
+ !!windows¿ë ¼Ò½º |
= \@bverbox |
= \basis |
= // ipreg.cpp : Defines the entry point for the console application. |
= // |
= |
= #include "stdafx.h" |
= |
= /* |
= * |
= * |
= * Daniel Jiseok Song |
= * kldp.netÀÇ hedicÀ» ÂüÁ¶ÇØ ¸¸µé¾ú½À´Ï´Ù. |
= * cygwin gcc¿¡¼µµ ºôµåµÇ°í linux¿¡¼µµ ºôµåÇغýÀ´Ï´Ù. ¾Æ¸¶ VisualC¿¡¼µµ ºôµåµÉ °Ì´Ï´Ù. |
= * |
= */ |
= |
= #include <stdio.h> |
= #include <string.h> |
= #ifdef WIN32 |
= #include <winsock2.h> |
= #else |
= #include <unistd.h> |
= #include <netdb.h> |
= #endif |
= #include <stdio.h> |
= #include <stdlib.h> |
= #include <sys/types.h> |
= #include <Winsock2.h> |
= #include <errno.h> |
= |
= #define VERSION "v0.1" |
= #define URL "rommance.kldp.org" //ÀÌ°ÍÀº ÀڱⰡ °èÁ¤À» °¡Áø ¿ÜºÎ¼¹ö ÁÖ¼ÒÀÔ´Ï´Ù. (¿¹¸¦ À§ÇØ °¡»óÀÇ ÁÖ¼Ò »ç¿ë) |
= #define SURL "http://rommance.kldp.org/~rommance/ipstore.php" // ÀÌ°ÍÀº ±× ¼¹öÀÇ ¾î´À °æ·Î¿¡ Á¢¼ÓÇÒ Áö ³ªÅ¸³À´Ï´Ù. |
= |
= void get_result( int sd ) |
= { |
= char buf[100]; |
= int len; |
= int i; |
= //printf("in get_result\n"); |
= while (1) { |
= len = recv(sd, buf, 100, 0); |
= //printf("after recv\n"); |
= if (!len) |
= break; |
= //for(i=0;i<len;i++) |
= //printf("%c", buf[i]); |
= } |
= } |
= int go( void ) |
= { |
= #ifdef WIN32 |
= SOCKET sd; |
= #else |
= int sd; |
= #endif |
= struct hostent *he; |
= struct sockaddr_in sai; |
= char buf[1024]; |
= |
= //printf("before socket\r\n"); |
= sd = socket(AF_INET, SOCK_STREAM, 0); |
= #ifdef WIN32 |
= //printf("invalid socket\r\n"); |
= if (sd == INVALID_SOCKET) |
= #else |
= //printf("before sd<0\r\n"); |
= if (sd < 0) |
= #endif |
= { |
= printf("Cannot make a socket.\n"); |
= return -1; |
= } |
= |
= //printf("before he\r\n"); |
= he = gethostbyname(URL); |
= //printf("after he\r\n"); |
= memset((void *)&sai, 0, sizeof(sai)); |
= //printf("after memset\r\n"); |
= sai.sin_family = AF_INET; |
= sai.sin_port = htons(80); |
= //printf("after htons\r\n"); |
= sai.sin_addr.s_addr = ((struct in_addr *)(he->h_addr))->s_addr; |
= |
= //printf("before connect\r\n"); |
= if (connect(sd, (sockaddr *)&sai, sizeof(sai)) < 0) |
= { |
= printf("Cannot connect.\n"); |
= #ifdef WIN32 |
= closesocket(sd); |
= #else |
= close(sd); |
= #endif |
= return -1; |
= } |
= |
= // »çÀÌÆ®·Î ãÀ» ´Ü¾î¸¦ º¸³À´Ï´Ù. |
= sprintf(buf, "GET %s\n", SURL); |
= send(sd, buf, strlen(buf), 0); |
= |
= // ¼¹ö¿¡¼ Ãâ·ÂÇØ ÁÖ´Â html ¹®¼¸¦ ¹Þ¾Æ ºÐ¼®ÇÕ´Ï´Ù. |
= get_result(sd); |
= #ifdef WIN32 |
= closesocket(sd); |
= #else |
= close(sd); |
= #endif |
= |
= return 0; |
= } |
= |
= int main(int argc, char *argv[]) |
= { |
= #ifdef WIN32 |
= WORD wVersionRequired; |
= WSADATA wsaData; |
= int ErrCode; |
= #endif |
= |
= #ifdef WIN32 |
= wVersionRequired = MAKEWORD(2,0); //get wsock... |
= ErrCode = WSAStartup(wVersionRequired, &wsaData); |
= if ( ErrCode !=0) |
= { |
= printf("WSAStartup error = %d \n", ErrCode); |
= return -1; |
= } |
= #endif |
= go(); |
= |
= #ifdef WIN32 |
= WSACleanup(); |
= #endif |
= return 0; |
= } |
= |
= |
= \easis |
= \@everbox |
= |
= ÀÌ·¸°Ô Çسõ°í ÀÚ±â pc¿¡¼ ¿ÜºÎ¼¹ö·Î Á¢¼ÓÇϵµ·Ï ÇÁ·Î±×·¥À» ½ÇÇà½ÃÅ°¸é Á¤ÇسõÀº txt ÆÄÀÏ¿¡ ip°¡ ÀúÀåµË´Ï´Ù. |
= |
= ¸®´ª½ºÀÇ °æ¿ì Ŭ¶óÀ̾ðÆ® ÇÁ·Î±×·¥À» cron¿¡ µî·Ï½ÃÄÑ ¸Å½Ã°£ ½ÇÇà ½ÃÅ°¸é ip°¡ ¹Ù²î¾îµµ ±Ý¹æ µî·ÏµÇ°ÚÁö¿ä. |
= ¶Ç´Â ½Ã½ºÅÛÀÌ ÄÑÁú ¶§, ·Î±äÇÒ ¶§ ½ÃÀÛÇÁ·Î±×·¥À¸·Î µî·Ï½ÃÄѵµ µË´Ï´Ù. |