Webcount 調整

  1. 解壓縮後,目錄 counter 下 readme.txt 檔案有安裝及設定說明可參考。php 程式只有 counter.php,修改如下:
    [root@dywang counter]# diff -uNw ../../counter/counter.php counter.php 
    --- ../../counter/counter.php	2013-02-16 22:17:21.000000000 +0800
    +++ counter.php	2015-01-03 12:00:10.659053758 +0800
    
  2. 更改增加計數器動作間隔,原先設定 2 小時內同一 ip 訪問都只算 1 次,改成只要重新整理都計算。
    @@ -29,7 +29,7 @@
     
     /* END CONFIGURATION */
     
    -$iprt=7200; # 1 hour is 3600 seconds, I P Residence Time
    +$iprt=1; #7200; # 1 hour is 3600 seconds, I P Residence Time
     $ips=array();
     $ipfh=fopen($visitors_ips_file,"r");
     $flag=0;
    
  3. 將數字改成固定 12 位數,不足的位數補 0。
    @@ -64,6 +64,8 @@
     $cfh=fopen($counter_file,"r");
     $line=fgets($cfh);
     $count=trim($line);
    +$cc=strlen($count);
    +for($i=$cc; $i<12; $i++) $count= '0'.$count;
     CreateCounterImage ($count);
     $cfh=fopen($counter_file,"w");
    
  4. 計數影像寬度由 80 加寬至 140。
    @@ -72,7 +74,7 @@
     $write = fputs($cfh, $count);
     
     function CreateCounterImage ($count){ # creates a captcha image and returns the value written on it
    -  $im = ImageCreate(80, 20);  # we create an image providing width and height (in pixels) as arguments. Edit this for changing the image counter size
    +  $im = ImageCreate(140, 20);  # we create an image providing width and height (in pixels) as arguments. Edit this for changing the image counter size
       $selbgcol=rand(0,4);
       
       /* ALLOCATING COLORS TO THE IMAGE */
    
  5. 修改計數器隨機背景顏色中的橘色。
    @@ -80,7 +82,7 @@
       $red = ImageColorAllocate($im, 189, 5, 8);#RED
       $black =  ImageColorAllocate($im, 0, 0, 0);#BLACK
       $green  = ImageColorAllocate($im, 115, 211, 45);#GREEN
    -  $orange = ImageColorAllocate($im, 252, 149, 26);#ORANGE
    +  $orange = ImageColorAllocate($im, 252, 149, 16);#ORANGE
       $blue = ImageColorAllocate($im, 72, 103, 173);#BLUE 
       $white = ImageColorAllocate($im, 255, 255, 255); # the numbers (text) in the counter will always be white and the above colors are used randomly for the background
    
  6. 修改計數器數字左邊邊界由 12 改成 16。
    @@ -95,7 +97,7 @@
       
       # we now write the string text to the image. The last number in the arguments list of ImageString moves the image text vertically, small number -> text goes up, big number text goes down
       # default color for text is white, as defined in the colors list above and then used as last argument in the ImageString call. Feel free to play with the colors here
    -  ImageString($im, 8, 12, 2, $new_string, $white); # 
    +  ImageString($im, 8, 16, 2, $new_string, $white); # 
      
       #output to browser
       ImagePNG($im, "counter.png");