File name: visit/viewstat.wel (8,192 bytes) Text file viewer v1.2
    1 : #!/bin/wel¢Ò
    2 : ¢Ò
    3 : /*  viewstat.wel¢Ò
    4 : ¢Ò
    5 :     Åë°è ±â·Ï ¸·´ë ±×·¡ÇÁ º¸±â(¼­±¤Çö)¢Ò
    6 : ¢Ò
    7 :     ¼öÁ¤: 2000/12/29¢Ò
    8 : ¢Ò
    9 : */¢Ò
   10 : ¢Ò
   11 : function dump_login(string msg)¢Ò
   12 : {¢Ò
   13 : /"<html>¢Ò
   14 : <body bgcolor={$Qbcolor} onLoad='document.input.Qpasswd.focus()'>¢Ò
   15 : <center>¢Ò
   16 : <br>¢Ò
   17 : <table border=2 cellspacing=0 width=540 bgcolor=#c0c0c0>¢Ò
   18 : <tr><td>¢Ò
   19 :   <table border=1 cellspacing=1 bgcolor=#d0d0d0 width=100%>¢Ò
   20 :    <tr><td align=center bgcolor=#000080>¢Ò
   21 :        <font color=#ffffff><b>¹æ¹® Åë°è ±×·¡ÇÁ º¸±â</b></font></td></tr>¢Ò
   22 :    <tr><td height=150>¢Ò
   23 :     <table border=0 cellspacing=0 width=100%>¢Ò
   24 :     <form name='input' method='POST' action='viewstat.wel'>¢Ò
   25 :     <tr><td width=50% align=right><b>µ¥ÀÌÅͺ£À̽º¸í: </b></td>¢Ò
   26 :      <td><input type=text name='Qdb' value='{$Qdb}' width=16></td></tr>¢Ò
   27 :     <tr><td width=50% align=right><b>Å× ÀÌ ºí ¸í: </b></td>¢Ò
   28 :      <td><input type=text name='Qtable' value='{$Qtable}' width=16></td></tr>¢Ò
   29 :     <tr><td width=50% align=right><b>¾Ï È£: </b></td>¢Ò
   30 :      <td><input type=password name='Qpasswd' value='' width=16></td></tr>¢Ò
   31 :     <tr><td colspan=2 align=center>{$msg}&nbsp;</td></tr>¢Ò
   32 :     <tr><td colspan=2 align=center>¢Ò
   33 :     <input type='submit' value=' ±â ·Ï º¸ ±â '></td></tr>¢Ò
   34 :     </table></td></tr></form>¢Ò
   35 :   </table>¢Ò
   36 :   <table border=1 cellspacing=1 bgcolor=#d0d0d0 width=100%>¢Ò
   37 :    <tr><td align=center bgcolor=#000080>¢Ò
   38 :       <font color=#ffffff><b>Query º¯¼ö ¼³¸í</b></font></td></tr>¢Ò
   39 :    <tr><td>¢Ò
   40 :     <table border=0 cellspacing=0 width=100%>¢Ò
   41 :     <tr><td><pre><font size=2>¢Ò
   42 :  Qhost -----&gt; ¿¬°áÇÒ mSQL ¼­¹öÀÇ ÁÖ¼Ò(ÃʱⰪ: {$Qhost})¢Ò
   43 :  Qdb -------&gt; data base name(ÃʱⰪ: {$Qdb})¢Ò
   44 :  Qtable ----&gt; table name(ÃʱⰪ: {$Qtable})¢Ò
   45 :  Qlevel ----&gt; ¸·´ë ±×·¡ÇÁÀÇ ´«±Ý¼ö(1¿¡¼­ 20±îÁö ¹üÀ§, ÃʱⰪ: {$Qlevel})¢Ò
   46 :  Qdot ------&gt; ¸·´ë ±×·¡ÇÁÀÇ ´«±ÝÀÇ Å©±â(pixel´ÜÀ§, ÃʱⰪ: {$Qdot})¢Ò
   47 :  Qrefresh --&gt; ºÐ´ÜÀ§ÀÇ °»½Å ÁÖ±â(0À̸é refreshÇÏÁö ¾ÊÀ½, ÃʱⰪ: {$Qbcolor})¢Ò
   48 :  Qbcolor ---&gt; º»¹®ÀÇ ¹è°æ»ö(ÃʱⰪ: {$Qbcolor})¢Ò
   49 :  Qtext -----&gt; º»¹®ÀÇ ±ÛÀÚ»ö(ÃʱⰪ: {$Qtext})¢Ò
   50 :  Qpasswd ---&gt; ¾ÏÈ£</font></pre>¢Ò
   51 :     </table></td></tr>¢Ò
   52 :   </table></td></tr>¢Ò
   53 : </table>¢Ò
   54 : </center>¢Ò
   55 : </body>¢Ò
   56 : </html>¢Ò
   57 : "/¢Ò
   58 :  return;¢Ò
   59 : }¢Ò
   60 : ¢Ò
   61 : function print_style()¢Ò
   62 :  {¢Ò
   63 :    print("<style type='text/css'><!-- \n",¢Ò
   64 :          "#tr { font-size:8pt; font-family:'±¼¸²'; letter-spacing:-1; color:#000000; padding-top:1px; padding-right:1px; }\n",¢Ò
   65 :          "#td { text-align: center; font-size:",Qdot,"px; padding-top:2px; }\n",¢Ò
   66 :          "#f1 { background-color:#f00000;font-size:",Qdot,"px; line-height:",Qdot+2,"px; }\n",¢Ò
   67 :          "#f2 { background-color:#000080;font-size:",Qdot,"px; line-height:",Qdot+2,"px; }\n",¢Ò
   68 :          "#f3 { background-color:#c0c0c0;font-size:",Qdot,"px; line-height:",Qdot+2,"px; }\n",¢Ò
   69 :          " --></style>\n");¢Ò
   70 :    return;¢Ò
   71 :  }¢Ò
   72 : ¢Ò
   73 : function Print_BarGraph(string title, string arrayname, int snumber, int enumber, int highlight)¢Ò
   74 : {¢Ò
   75 :   max= min= parser(arrayname~"[snumber]");¢Ò
   76 :   for(i=snumber+1; i<=enumber; i++)¢Ò
   77 :    {¢Ò
   78 :      cnt= parser(arrayname~"[i]");¢Ò
   79 :      if(cnt>max) max= cnt;¢Ò
   80 :       else if(cnt<min) min= cnt;¢Ò
   81 :    }¢Ò
   82 :   range= max - min;¢Ò
   83 :   print("<font size=3 color=#ff5050><b>", title, "</b></font><br>\n");¢Ò
   84 :   print("<table border=1 cellspacing=0 bgcolor=#f0f0f0 width=100%><tr><td>");¢Ò
   85 :   print("<table border=1 cellspacing=0 cellpadding=0 width=100%>\n");¢Ò
   86 :   if(range==0) bar= 0;¢Ò
   87 :   if(Qlevel<1 || Qlevel>20) Qlevel= 10;¢Ò
   88 :   print("<tr>\n");¢Ò
   89 :   for(i=snumber; i<=enumber; i++)¢Ò
   90 :    {¢Ò
   91 :      print("<td id=td>");¢Ò
   92 :      if(range>0) bar= real(parser(arrayname~"[i]")-min) / range * Qlevel;¢Ò
   93 :      if(bar<Qlevel)¢Ò
   94 :       {¢Ò
   95 :          print("<font id=f3>");¢Ò
   96 :          for(j=Qlevel; j>bar; j--) print("&nbsp;&nbsp;<br>");¢Ò
   97 :          print("</font>");¢Ò
   98 :       }¢Ò
   99 :      if(bar>0)¢Ò
  100 :       {¢Ò
  101 :          if(i==highlight) fkind= "f1"; else fkind= "f2";¢Ò
  102 :          print("<font id=", fkind, ">");¢Ò
  103 :          for(j=bar; j>=1; j--) print("&nbsp;&nbsp;<br>");¢Ò
  104 :          print("</font>");¢Ò
  105 :       }¢Ò
  106 :      print("</td>\n");¢Ò
  107 :    }¢Ò
  108 :   print("</tr>\n");¢Ò
  109 :   print("<tr align=center bgcolor=#e8e450 id=tr>");¢Ò
  110 :   for(i=snumber; i<=enumber; i++)¢Ò
  111 :    {¢Ò
  112 :       print("<td>");¢Ò
  113 :       if(i!=highlight) print(name[i]);¢Ò
  114 :         else print("<font color=red>", name[i], "</font>");¢Ò
  115 :       print("</td>");¢Ò
  116 :    }¢Ò
  117 :   print("</tr>\n<tr align=center bgcolor=#50d090 id=tr>");¢Ò
  118 :   for(i=snumber; i<=enumber; i++)¢Ò
  119 :    {¢Ò
  120 :       print("<td>");¢Ò
  121 :       if(i!=highlight) print(parser(arrayname~"[i]"));¢Ò
  122 :         else print("<font color=red>", parser(arrayname~"[i]"), "</font>");¢Ò
  123 :       print("</td>");¢Ò
  124 :    }¢Ò
  125 :   print("</tr>\n</table>\n</td></tr></table>\n");¢Ò
  126 :   return;¢Ò
  127 : }¢Ò
  128 : ¢Ò
  129 : free name[31];¢Ò
  130 : int dcnt[31], hcnt[23], wcnt[6];¢Ò
  131 : ¢Ò
  132 : function int dump_graph()¢Ò
  133 : {¢Ò
  134 :   qstr= "select * from " ~ Qtable;¢Ò
  135 :   socket= msqlConnect(Qhost);¢Ò
  136 :   if(socket==MSQL_ERR)¢Ò
  137 :     {¢Ò
  138 :        print("mSQL ¼­¹ö '", Qhost, "'¸¦ ¿¬°áÇÒ ¼ö ¾ø½À´Ï´Ù!!!\n");¢Ò
  139 :        return(-1);¢Ò
  140 :     }¢Ò
  141 :   if(msqlSelectDB(socket, Qdb)==MSQL_ERR)¢Ò
  142 :     {¢Ò
  143 :        print("µ¥ÀÌÅÍ º£À̽º '", Qdb,"'¸¦ °³¹æÇÒ ¼ö ¾ø½À´Ï´Ù!!!\n");¢Ò
  144 :        return(-1);¢Ò
  145 :     }¢Ò
  146 :   if(msqlQuery(socket, qstr)==MSQL_ERR)¢Ò
  147 :     {¢Ò
  148 :        print("Query ¿¡·¯: ", qstr, "\n");¢Ò
  149 :        return(-1);¢Ò
  150 :     }¢Ò
  151 : ¢Ò
  152 :   result= msqlStoreResult();¢Ò
  153 :   fields_count= msqlNumFields(result);¢Ò
  154 :   row= msqlFetchRow(result);¢Ò
  155 : ¢Ò
  156 :   di= hi= wi= 0;¢Ò
  157 :   for(j=0; j<fields_count; j++)¢Ò
  158 :     {¢Ò
  159 :        if(j<=31) dcnt[di++]= row[j];¢Ò
  160 :          else if(j<=55) hcnt[hi++]= row[j];¢Ò
  161 :            else if(j<=62) wcnt[wi++]= row[j];¢Ò
  162 :              else if(j==63) total= row[j];¢Ò
  163 :                else if(j==64) fdate= row[j];¢Ò
  164 :                  else if(j==65) ldate= row[j];¢Ò
  165 :     }¢Ò
  166 :   msqlFreeResult(result);¢Ò
  167 :   msqlClose(socket);¢Ò
  168 : ¢Ò
  169 :   server= getenv("SERVER_NAME");¢Ò
  170 :   cy= iyear(), cm= imonth(), cd= iday();¢Ò
  171 :   print("<font color=#f0f000><b>http://", server, "</b></font>");¢Ò
  172 :   print("<font size=2>(", date(3), " ", time(3), ")</font><br>\n");¢Ò
  173 : ¢Ò
  174 :   print("<table border=0 cellspacing=10><tr align=center><td colspan=2 nowrap>");¢Ò
  175 : ¢Ò
  176 :     first= left(fdate,4) ~ "/" ~ mid(fdate,5,2) ~ "/" ~ mid(fdate,7,2)¢Ò
  177 :          ~ "-" ~ mid(fdate,9,2) ~ ":" ~ mid(fdate,11,2) ~ ":" ~ mid(fdate,13);¢Ò
  178 :     last=  left(ldate,4) ~ "/" ~ mid(ldate,5,2) ~ "/" ~ mid(ldate,7,2)¢Ò
  179 :         ~ "-" ~ mid(ldate,9,2) ~ ":" ~ mid(ldate,11,2) ~ ":" ~ mid(ldate,13);¢Ò
  180 :     title= "ÀÏÀÚº° Á¢¼ÓÅë°è<font color=#f0f000>(ÃÑ "¢Ò
  181 :          ~ total ~ "°Ç, </b><font size=2>"¢Ò
  182 :          ~  first ~ "ºÎÅÍ " ~ last ~ "±îÁö</font><b>)</font>";¢Ò
  183 :     arrayname= "dcnt", snumber= 1, enumber= 31, highlight= cd;¢Ò
  184 :     for(i=snumber; i<=enumber; i++) name[i]= i;¢Ò
  185 :     Print_BarGraph(title, arrayname, snumber, enumber, highlight);¢Ò
  186 : ¢Ò
  187 :   print("</td></tr>\n<tr align=center><td nowrap>");¢Ò
  188 : ¢Ò
  189 :     title= "½Ã°£´ëº° Á¢¼ÓÅë°è";¢Ò
  190 :     arrayname= "hcnt", snumber= 0, enumber= 23, highlight= left(time(0),2);¢Ò
  191 :     for(i=snumber; i<=enumber; i++) name[i]= i;¢Ò
  192 :     Print_BarGraph(title, arrayname, snumber, enumber, highlight);¢Ò
  193 : ¢Ò
  194 :   print("</td><td nowrap>");¢Ò
  195 : ¢Ò
  196 :     title= "¿äÀϺ° Á¢¼ÓÅë°è", week= "ÀÏ¿ùÈ­¼ö¸ñ±ÝÅä";¢Ò
  197 :     arrayname= "wcnt", snumber= 0, enumber= 6, highlight= iweek(cy, cm, cd);¢Ò
  198 :     for(i=snumber; i<=enumber; i++) name[i]= mid(week,i*2+1,2);¢Ò
  199 :     Print_BarGraph(title, arrayname, snumber, enumber, highlight);¢Ò
  200 : ¢Ò
  201 :   print("</td></tr></table>");¢Ò
  202 :   return(0);¢Ò
  203 : }¢Ò
  204 : ¢Ò
  205 : Qhost= "";          // host nameÀÇ ÃʱⰪ¢Ò
  206 : Qdb= "visit";       // data base nameÀÇ ÃʱⰪ¢Ò
  207 : Qtable= "stat";     // table nameÀÇ ÃʱⰪ¢Ò
  208 : Qlevel= 10;         // graphÀÇ level ÃʱⰪ¢Ò
  209 : Qrefresh= 0;        // refreshÁÖ±â ÃʱⰪ(ºÐ´ÜÀ§, 0À̸é refreshÇÏÁö ¾ÊÀ½)¢Ò
  210 : Qbcolor= "#000000"; // º»¹® ¹è°æ»ö ÃʱⰪ¢Ò
  211 : Qtext= "#ffffff";   // º»¹® ¹®ÀÚ»ö ÃʱⰪ¢Ò
  212 : Qdot=8;             // graphÀÇ ÇÑ ºí·°ÀÇ Å©±â(pixel´ÜÀ§)¢Ò
  213 : ¢Ò
  214 : varcnt= htmlquery("GET") + htmlquery("POST");¢Ò
  215 : Qrefresh*= 60; // ºÐ´ÜÀ§·Î º¯È¯¢Ò
  216 : if(varcnt==0) dump_login("");¢Ò
  217 :  else¢Ò
  218 :   {¢Ò
  219 :      passwd= decode(cgipasswd, "", "@cgipasswd");¢Ò
  220 :      if(Qpasswd!=passwd)¢Ò
  221 :       {¢Ò
  222 :          msg= "<font color=#f00000><b>¾ÏÈ£°¡ ÀÏÄ¡ÇÏÁö ¾Ê½À´Ï´Ù!</b></font>";¢Ò
  223 :          dump_login(msg);¢Ò
  224 :       }¢Ò
  225 :      else¢Ò
  226 :       {¢Ò
  227 :          print("<html>\n<head>\n");¢Ò
  228 :          if(Qrefresh>0)¢Ò
  229 :            print("<meta http-equiv=refresh content=", Qrefresh, ">\n");¢Ò
  230 :          print_style();¢Ò
  231 :          print("</head>\n");¢Ò
  232 :          print("<body bgcolor=", Qbcolor, " text=", Qtext, "><center>");¢Ò
  233 :          rt= dump_graph();¢Ò
  234 :          if(rt!=0) print("ºñÁ¤»óÀûÀ¸·Î Á¾·áµÇ¾ú½À´Ï´Ù.!!!");¢Ò
  235 :          print("</center></body></html>\n");¢Ò
  236 :          print("<!-- Runtime: ", runtime()/1000000.0, "sec -->");¢Ò
  237 :       }¢Ò
  238 :   }¢Ò
  239 : ¢Ò
  240 : //////////////////////////// ÇÁ·Î±×·¥ Á¾·á /////////////////////////////¢Ò
File name: visit/viewstat.wel (8,192 bytes) Wesoft Corp. ¨Ï 2001 All rights reserved.