File name: visit/visit.wel (4,617 bytes) Text file viewer v1.2
    1 : #!/bin/wel¢Ò
    2 : ¢Ò
    3 : /*  visit.wel¢Ò
    4 : ¢Ò
    5 :     À¥ »çÀÌÆ® ¹æ¹® ±â·Ï ÇÁ·Î±×·¥(Á¶¿µÀÏ)¢Ò
    6 : ¢Ò
    7 :     Copyright (c) 2000/01/10 by Wesoft¢Ò
    8 :     All Rights Reserved.¢Ò
    9 : ¢Ò
   10 : */¢Ò
   11 : ¢Ò
   12 : // ¹æ¹®ÀÚ ±â·ÏÀ» ÇÏÁö ¾ÊÀ» network ÁÖ¼Ò(IP) ÀϺκÐÀ» "" ¾È¿¡ ±â·ÏÇϽʽÿä¢Ò
   13 : // IPÀÇ ÀϺκи¸ ±â·ÏÇÒ °æ¿ì¿¡´Â ²À '.'À¸·Î ³¡³ªµµ·Ï Çϼ¼¿ä¢Ò
   14 : // ¿¹¸¦ µé¾î 172.168.1.0 ºÎÅÍ 172.168.1.255±îÁö´Â ¹æ¹®ÀÚ ±â·ÏÀ» ÇÏÁö ¾Ê°íÀÚ¢Ò
   15 : // ÇÒ°æ¿ì¿¡´Â deny_ip1= "172.168.1.";¿Í °°Àº ÇüÅ·ΠÇÏ´Â °ÍÀÌ ÁÁ½À´Ï´Ù.¢Ò
   16 : ¢Ò
   17 : deny_ip1= "192.168.1."; // ÀÚ½ÅÀÇ È¯°æ¿¡ ¾Ë¸Â°Ô ÁöÁ¤ÇØ ÁÖ¼¼¿ä¢Ò
   18 : deny_ip2= "";¢Ò
   19 : deny_ip3= "";¢Ò
   20 : ¢Ò
   21 : // º¯¼ö ÃʱⰪ ¼³Á¤ ºÎºÐ¢Ò
   22 : ¢Ò
   23 : host= "";                 // ¿¬°áÇÒ mSQL ¼­¹öÁÖ¼Ò¢Ò
   24 : dbname= "visit";          // ¿¬°áÇÒ mSQL ¹æ¹®±â·Ï µ¥ÀÌÅÍ º£À̽º À̸§¢Ò
   25 : stat_table= "stat";       // ¿¬°áÇÒ mSQL Åë°è µ¥ÀÌÅÍ º£À̽º À̸§¢Ò
   26 : LogFile= "log/visit.log"; // log ÆÄÀÏ(LogFile=""; ·Î Çϸé log¸¦ ³²±âÁö ¾ÊÀ½)¢Ò
   27 : if(tablename=="") tablename= dbname; // ¹æ¹®±â·Ï Å×À̺í À̸§¢Ò
   28 : ¢Ò
   29 : vip = getenv("REMOTE_ADDR");¢Ò
   30 : vhost = getenv("REMOTE_HOST");¢Ò
   31 : ¢Ò
   32 : if(no_out!=1) next_html= "<script>location.href='/index1.html'</script>";¢Ò
   33 : ¢Ò
   34 : htmlquery("GET");¢Ò
   35 : ¢Ò
   36 : IP_addr= " (" ~ vip ~ ")";¢Ò
   37 : IP_strlen= len(IP_addr);¢Ò
   38 : if(IP_strlen<19) IP_addr~= strep(" ", 19 - IP_strlen);¢Ò
   39 : ¢Ò
   40 : logwrite=¢Ò
   41 : {[¢Ò
   42 :    if(LogFile!="")¢Ò
   43 :     {¢Ò
   44 :        logwrite_msg= date(2) ~ "-" ~ time(1) ~ IP_addr ~ msg;¢Ò
   45 :        system("echo \"" ~ logwrite_msg ~ "\" >> " ~ LogFile);¢Ò
   46 :     }¢Ò
   47 : ]}¢Ò
   48 : ¢Ò
   49 : deny_len1= len(lrtrim(deny_ip1));¢Ò
   50 : if(deny_len1==0) vip1= vip; else vip1= left(vip, deny_len1);¢Ò
   51 : ¢Ò
   52 : deny_len2= len(lrtrim(deny_ip2));¢Ò
   53 : if(deny_len2==0) vip2= vip; else vip2= left(vip, deny_len2);¢Ò
   54 : ¢Ò
   55 : deny_len3= len(lrtrim(deny_ip3));¢Ò
   56 : if(deny_len3==0) vip3= vip; else vip3= left(vip, deny_len3);¢Ò
   57 : ¢Ò
   58 : // vip==""ÀÎ °æ¿ì´Â terminal¿¡¼­ ¸í·É¾î¸¦ ÀÔ·ÂÇÏ¿© ½ÇÇàÇÒ¶§¢Ò
   59 : if(vip=="" || vip1==deny_ip1 || vip2==deny_ip2 || vip3==deny_ip3)¢Ò
   60 :  {¢Ò
   61 :     print(next_html);¢Ò
   62 :     return;¢Ò
   63 :  }¢Ò
   64 : ¢Ò
   65 : socket= msqlConnect(host);¢Ò
   66 : if(socket==MSQL_ERR)¢Ò
   67 :  {¢Ò
   68 :     print(next_html);¢Ò
   69 :     msg= "Connect err: host(" ~ host ~ ")";¢Ò
   70 :     parser(logwrite);¢Ò
   71 :     return;¢Ò
   72 :  }¢Ò
   73 : ¢Ò
   74 : msg= "mSQL server connected";¢Ò
   75 : parser(logwrite);¢Ò
   76 : ¢Ò
   77 : if(msqlSelectDB(socket, dbname)==MSQL_ERR)¢Ò
   78 :  {¢Ò
   79 :     print(next_html);¢Ò
   80 :     msqlClose(socket);¢Ò
   81 :     msg= "SelectDB err: dbname(" ~ dbname ~ ")";¢Ò
   82 :     parser(logwrite);¢Ò
   83 :     return;¢Ò
   84 :  }¢Ò
   85 : ¢Ò
   86 : vdate = date(0);¢Ò
   87 : vyear = left(vdate,4);¢Ò
   88 : vmonth = mid(vdate,5,2);¢Ò
   89 : vday = right(vdate,2);¢Ò
   90 : vweek = iweek(vyear,vmonth,vday);¢Ò
   91 : vtime = time(0);¢Ò
   92 : vhour = left(vtime,2);¢Ò
   93 : vminute = mid(vtime,3,2);¢Ò
   94 : vsecond = right(vtime,2);¢Ò
   95 : ¢Ò
   96 : qstr= "insert into " ~ tablename¢Ò
   97 :     ~ "(ip, host, year, month, day, hour, minute, second, week) "¢Ò
   98 :     ~ "values('" ~vip  ~ "','"¢Ò
   99 :                ~vhost  ~ "','"¢Ò
  100 :                ~vyear  ~ "','"¢Ò
  101 :                ~vmonth ~ "','"¢Ò
  102 :                ~vday   ~ "','"¢Ò
  103 :                ~vhour  ~ "','"¢Ò
  104 :               ~vminute ~ "','"¢Ò
  105 :               ~vsecond ~ "','"¢Ò
  106 :                 ~vweek ~ "')";¢Ò
  107 : ¢Ò
  108 : rt= msqlQuery(socket, qstr);¢Ò
  109 : if(rt==MSQL_ERR)¢Ò
  110 :  {¢Ò
  111 :     msg= "Query err: qstr(" ~ qstr ~ ")";¢Ò
  112 :     parser(logwrite);¢Ò
  113 :  }¢Ò
  114 : ¢Ò
  115 : //////////////////////////// Åë°è Å×ÀÌºí ´©Àû //////////////////////////¢Ò
  116 : ¢Ò
  117 :   rt= msqlQuery(socket, "select * from " ~ stat_table);¢Ò
  118 :   if(rt==MSQL_ERR)¢Ò
  119 :    {¢Ò
  120 :       msg= "Query err: qstr(" ~ qstr ~ ")";¢Ò
  121 :       parser(logwrite);¢Ò
  122 :    }¢Ò
  123 :   result= msqlStoreResult();¢Ò
  124 :   fields_count= msqlNumFields(result);¢Ò
  125 :   rows_count= msqlNumRows(result);¢Ò
  126 :   if(rows_count<1)¢Ò
  127 :     {¢Ò
  128 :        msqlFreeResult(result);¢Ò
  129 :        msqlClose(socket);¢Ò
  130 :        msg= "stat table: not exist record";¢Ò
  131 :        parser(logwrite);¢Ò
  132 :        print(next_html);¢Ò
  133 :        return;¢Ò
  134 :     }¢Ò
  135 :   row= msqlFetchRow(result);¢Ò
  136 : ¢Ò
  137 :   int dcnt[31], hcnt[23], wcnt[6];¢Ò
  138 :   di= hi= wi= 0;¢Ò
  139 :   for(j=0; j<fields_count; j++)¢Ò
  140 :     {¢Ò
  141 :        field= row[j];¢Ò
  142 :        if(j<=31) dcnt[di++]= field;¢Ò
  143 :          else if(j<=55) hcnt[hi++]= field;¢Ò
  144 :            else if(j<=62) wcnt[wi++]= field;¢Ò
  145 :              else if(j==63) total= field;¢Ò
  146 :                else if(j==64) fdate= field;¢Ò
  147 :     }¢Ò
  148 :   msqlFreeResult(result);¢Ò
  149 : ¢Ò
  150 :   dcnt[vday]++;¢Ò
  151 :   hcnt[vhour]++;¢Ò
  152 :   wcnt[vweek]++;¢Ò
  153 :   total++;¢Ò
  154 :   ldate= vdate ~ vtime;¢Ò
  155 :   qstr= "insert into " ~ stat_table ~ " values(";¢Ò
  156 :   for(i=0; i<=31; i++) qstr~= dcnt[i] ~ ",";¢Ò
  157 :   for(i=0; i<=23; i++) qstr~= hcnt[i] ~ ",";¢Ò
  158 :   for(i=0; i<=6; i++) qstr~= wcnt[i] ~ ",";¢Ò
  159 :   qstr~= total ~ ",'" ~ fdate ~ "','" ~ ldate ~ "')";¢Ò
  160 : ¢Ò
  161 :   rt= msqlQuery(socket, "delete from " ~ stat_table ~ " where d0 >= 0");¢Ò
  162 :   if(rt==MSQL_ERR)¢Ò
  163 :    {¢Ò
  164 :       msg= "Query err: qstr(" ~ qstr ~ ")";¢Ò
  165 :       parser(logwrite);¢Ò
  166 :    }¢Ò
  167 :   rt= msqlQuery(socket, qstr);¢Ò
  168 :   if(rt==MSQL_ERR)¢Ò
  169 :    {¢Ò
  170 :       msg= "Query err: qstr(" ~ qstr ~ ")";¢Ò
  171 :       parser(logwrite);¢Ò
  172 :    }¢Ò
  173 : ¢Ò
  174 : //////////////////////////// Åë°è Å×À̺í Á¾·á //////////////////////////¢Ò
  175 : ¢Ò
  176 : msqlClose(socket);¢Ò
  177 : ¢Ò
  178 : msg= "mSQL server disconnected";¢Ò
  179 : parser(logwrite);¢Ò
  180 : ¢Ò
  181 : print(next_html);¢Ò
  182 : ¢Ò
  183 : //////////////////////////// ÇÁ·Î±×·¥ Á¾·á /////////////////////////////¢Ò
File name: visit/visit.wel (4,617 bytes) Wesoft Corp. ¨Ï 2001 All rights reserved.