当前位置:编程学习 > CGI >>

网站 PAGEVIEW 分析系统 CGI (原创)

答案:目前分析log文件的软件有很多,如果一个小的站点只想知道访问量
就大才小用了,并且安装这些软件也很麻烦
我写了个分析log的cgi,速度还可以呦 希望大家喜欢

程序代码:
#!/bin/sh
#pv-cgi write by larry lee

# need type
LOGFILE="htm|html|php";
# log file path and filename
LOGACCESS=" /home/webadm/logs/access_log";

# disable filename globbing
set -f
echo Content-type: text/html
echo

echo CGI/1.0 PageView script report:\<br\>
echo \<br\>

echo argc is $#. argv is "$*".
echo \<br\>PageView:

if [ "$#" = "0" ]
then
egrep '('$LOGFILE')' $LOGACCESS | wc -l
fi

if [ "$#" = "1" ]
then
grep "$*" $LOGACCESS | egrep '('$LOGFILE')' | wc -l
fi

echo \<br\>
echo "<script>"
echo "function submit1(){"
echo "var url;"
echo "url='/cgi-bin/pv-cgi?'+document.calendar.day.value+'/'+document.calendar.month.value+'/'+document.calendar.year.value;"
echo "window.location.href=>echo "}"
echo "</script>"
echo "<FORM METHOD=POST name=calendar>"
echo "<select name=year>"
echo "<option value=2002 >2000</option>"
echo "<option value=2001 selected>2001</option>"
echo "<option value=2002 >2002</option>"
echo "</select>"
echo "<select name=month>"
echo "<option value=Jan>1</option>"
echo "<option value=Feb>2</option>"
echo "<option value=Mar>3</option>"
echo "<option value=Apr>4</option>"
echo "<option value=May>5</option>"
echo "<option value=Jun>6</option>"
echo "<option value=Jul>7</option>"
echo "<option value=Aug>8</option>"
echo "<option value=Sep>9</option>"
echo "<option value=Oct>10</option>"
echo "<option value=Nov>11</option>"
echo "<option value=Dec>12</option>"
echo "</select>"
echo "<select name=day>"
echo "<option value=01>1</option>"
echo "<option value=02>2</option>"
echo "<option value=03>3</option>"
echo "<option value=04>4</option>"
echo "<option value=05>5</option>"
echo "<option value=06>6</option>"
echo "<option value=07>7</option>"
echo "<option value=08>8</option>"
echo "<option value=09>9</option>"
echo "<option value=10>10</option>"
echo "<option value=11>11</option>"
echo "<option value=12>12</option>"
echo "<option value=13>13</option>"
echo "<option value=14>14</option>"
echo "<option value=15>15</option>"
echo "<option value=16>16</option>"
echo "<option value=17>17</option>"
echo "<option value=18>18</option>"
echo "<option value=19>19</option>"
echo "<option value=20>20</option>"
echo "<option value=21>21</option>"
echo "<option value=22>22</option>"
echo "<option value=23>23</option>"
echo "<option value=24>24</option>"
echo "<option value=25>25</option>"
echo "<option value=26>26</option>"
echo "<option value=27>27</option>"
echo "<option value=28>28</option>"
echo "<option value=29>29</option>"
echo "<option value=30>30</option>"
echo "<option value=31>31</option>"
echo "</select>"
echo "<INPUT TYPE=button name=select value=Select onclick=submit1()>"
echo "</FORM>"

上一个:实战 FastCGI(转)五(完)
下一个:大家有没有碰到过unix上,一个目录文件太多,无法删除的现象,我为大家写了个perl的程序删除

更多图片编程知识:
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,