9.ºê¶ó¿ìÀú ±¸ºÐ


  »ç¿ëÀÚ°¡ ¹«½¼ ºê¶ó¿ìÀú¸¦ ¾²´À³Ä¿¡ µû¶ó¼­ ¸Þ½ÃÁö¸¦ µû·Îµû·Î Ãâ·ÂÇÏ´Â CGI¸¦ Çϳª ÀÛ¼ºÇغ¸ÀÚ. ¿©±â¼­ ¾Ë¾Æ¾ß ÇÒ °ÍÀº »ç¿ëÀÚ°¡ »ç¿ëÇÏ´Â ºê¶ó¿ìÀú Á¤º¸°¡ ƯÁ¤ÇÑ È¯°æº¯¼ö(HTTP_USER_AGENT)·Î ÀúÀåµÈ´Ù´Â Á¡ÀÌ´Ù. º¸ÀÚ!

#include <stdio.h>

main()
{
    char *UserAgent;

    UserAgent = getenv("HTTP_USER_AGENT");

    printf("Content-type: text/html\n\n");

    if( strstr(UserAgent, "MSIE") != NULL ){
       printf("<h1> Explorer </h1>\n");
    }else if( strstr(UserAgent, "Mozilla") != NULL ){
       printf("<h1> Netscape </h1>\n");
    }else{
       printf(" UserAgent is [%s]\n", UserAgent);
    }
}

  * ½ÇÇà°á°ú´Â Á¢¼ÓÇÏ´Â ºê¶ó¿ìÀú¿¡ µû¶ó ´Ù¸¥ ¸Þ½ÃÁö¸¦ Ãâ·ÂÇÏ°Ô µÈ´Ù. »ç½Ç HTTP_USER_AGENTÀÇ È¯°æº¯¼ö´Â ºê¶ó¿ìÀú¸¶´Ù ÀÌ·¸°Ô »ý°å´Ù.

Netscape 3.01Mozilla/3.01Gold (Win95; I)
Explorer 4.0Mozilla/4.0 (compatible; MSIE 4.01; Windows 95)
Netscape 4.5Mozilla/4.5 [en] (Win95; I)


  ´Ù¸¥ ºê¶ó¿ìÀúÀÇ °æ¿ì¿¡ È®ÀÎÇØ º¸°í ½Í´Ù¸é, ´ÜÁö getenv("HTTP_USER_AGENT")ÀÇ return°ªÀÌ ¹®ÀÚ¿­À̹ǷÎ, ÀÌ°É º°µµÀÇ Á¶ÀÛ¾øÀÌ ±×´ë·Î Ãâ·ÂÇϸé À§¿Í °°Àº ¹®ÀÚ¿­À» ¾òÀ» ¼ö ÀÖÀ» °ÍÀÌ´Ù.

  ÀÌ·¸°Ô Ȱ¿ëÇÒ ¼ö Àִ ȯ°æº¯¼ö´Â Á¾·ù°¡ ¸¹´Ù.´ÙÀ½Àå¿¡¼­ ȯ°æº¯¼öµéÀ» ¾Ë¾Æº¸ÀÚ.

- Last Update : 2001.7.9 by Deadfire(http://www.deadfire.net)

CGI with C Ȱ¿ë
ºê¶ó¿ìÀú±¸ºÐ
ȯ°æº¯¼öLIST
Ŭ¶óÀ̾ðƮǮ
¼­¹öǪ½¬
Form Mail
ÁøÇàÇöȲº¸±â
Cookie
MD5
File Download
SSI
Redirection
File Upload
GD1.2
Database
¸¶Ä¡¸ç

Copyright ¨Ï 1997 ~, Deadfire Program Master