Recently in php script Category

A php error.

| No Comments | No TrackBacks
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".

Note 1:
I uniformed methods of my counter increment.

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

Board: Hisho no Tori

| No Comments | No TrackBacks

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?

PHP-Text Counter

| No Comments | No TrackBacks

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);
}
?>

Contact me

About my policy of copyright.

  • At translation parts.
    1. The copyright of the original belongs to the original writer.
    2. I will obey it at once because my translation has no permission when the publishing discontinuance is requested from the original writer.
    3. The copyright of the translation belongs to o6asan.
  • At other parts.
    1. All copyright of this site belongs to o6asan.
Powered by Movable Type 5.02

Links in my site

About this Archive

This page is an archive of recent entries in the php script category.

math is the previous category.

private remark is the next category.

Find recent content on the main index or look in the archives to find all content.

Recent Comments