Categories
php script

A php error.

Yesterday, I changed my php version up from 5.2.12 to 5.3.1. Then, I have an error on apache err. log.

It says “PHP Warning:  date(): It is not safe to rely on the system’s timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function.”

They say new php specification requires more strict definition. So, I added a line that “date.timezone = (string $timezone_identifier)”.

Mmm…It’s too much of a bother.

Edit:
   New version “php5.3” doesn’t have a line “#extension=php_mcrypt.dll
” in the file “php.ini” and two files “libmysql.dll, libmcrypt.dll” in the folder “PHP”.
   I think libmysql.dll —> php_mysqli.dll, and some dlls are united into the folder “PHP\ext”.
   I deleted three files “libmysql.dll, libmcrypt.dll and php_gd2.dll” from “windows sys32”.

Categories
php script

php scripts for my counters.

Note 1:
I uniformed methods of my counter increment.

Note 2:
I’ve described my policy of the copyright on this site.

Categories
php script

Board: Hisho no Tori

I’ve made a board for “Hisho no Tori”.
Please write your impression and demand.

The board uses a cookie to memorize your name and email address temporarily.
All right?

Edit(2011.Sep.10):
Edit(2014.Aug.17):
My site was renewed on Sep. 8. With this, the Board URL was changed to /bbs/Board for 12kokuki

Categories
php script

PHP-Text Counter

i made a PHP-Text Counter for i-mode. when we access the net by mobile phones, the host name/ip address is frequently changed. so i use ‘USER_AGENT’ and ‘TIME’ elements for preventing double-count. like this.

 

 

<?php
 $filename = “./counter.dat”; // datのパス

 $UA = htmlspecialchars($_SERVER[‘HTTP_USER_AGENT’]);//ユーザーエージェントの取得
 if (strncmp($UA, “Mozil”, 5) <>0 && strncmp($UA, “Opera”, 5) <>0 && strncmp($UA, “Lynx/”, 5) <>0 && strncmp($UA, “HotJa”, 5) <>0) {
 $HIJI = date(“U”);//アクセス年月日時刻の取得
 $file = fopen($filename,”r+”);
 flock($file, 2);
 $count = fgets($file,256);//直前のカウント数の取得
 $lastUA = fgets($file,256);//直前のユーザーエージェントの取得
 $lastHIJI = fgets($file,256);//直前のアクセス年月日時刻の取得
 $count = chop($count);
 $lastUA = chop($lastUA);
 $lastHIJI = chop($lastHIJI);
 $dffrHiJI = $HIJI – $lastHIJI;
 if($lastUA != $UA)                        //ユーザーエージェントが直前のものと異なる場合カウントアップ
 {$count = $count + 1;
 $lastUA = $UA;
 $lastHIJI = $HIJI;
 } elseif($dffrHiJI > 1200)               //ユーザーエージェントが直前のものと同じでも20分以上経っている場合はカウントアップ
 {$count = $count + 1;
 $lastHIJI = $HIJI;}
 ftruncate($file,0);
 rewind($file);
 fwrite($file, $count);
 fwrite($file, “\n”);
 fwrite($file, $lastUA);
 fwrite($file, “\n”);
 fwrite($file, $lastHIJI);
 flock($file, 3);
 fclose($file);
}
?>