差分
このページの2つのバージョン間の差分を表示します。
| 次のリビジョン | 前のリビジョン | ||
| dokuwiki:downloadcount [2006/11/24] – 作成 admin | dokuwiki:downloadcount [不明な日付] (現在) – 外部編集 (不明な日付) 127.0.0.1 | ||
|---|---|---|---|
| 行 1: | 行 1: | ||
| + | ====== ダウンロード数をカウントする ====== | ||
| + | ダウンロード数をカウントします。 | ||
| + | * 連続した同じIPアドレスはカウントしません。 | ||
| + | * データベースを使うので、ファイルを作成しません。 | ||
| + | * データベースの設定は、ユーザー認証のMySQLの設定を使うので、設定済みであれば設定不要。 | ||
| + | - データベースにテーブルを作成しておく。< | ||
| + | CREATE TABLE `dlcount` ( | ||
| + | `id` VARCHAR( 255 ) NOT NULL DEFAULT '', | ||
| + | `count` INT( 15 ) UNSIGNED NOT NULL DEFAULT ' | ||
| + | `ip` VARCHAR( 15 ) DEFAULT NULL , | ||
| + | PRIMARY KEY ( `id` ) | ||
| + | ) | ||
| + | </ | ||
| + | - lib/ | ||
| + | //handle image resizing | ||
| + | if((substr($MIME, | ||
| + | $FILE = get_resized($FILE, | ||
| + | } | ||
| + | |||
| + | if(!(substr($MIME, | ||
| + | |||
| + | // finally send the file to the client | ||
| + | sendFile($FILE, | ||
| + | |||
| + | /* ------------------------------------------------------------------------ */ | ||
| + | function Download_count($ID) { | ||
| + | global $conf; | ||
| + | $dlc_server=$conf[' | ||
| + | $dlc_user=$conf[' | ||
| + | $dlc_password=$conf[' | ||
| + | $dlc_database=$conf[' | ||
| + | $dlc_table=" | ||
| + | $dlc_ip = $_SERVER[' | ||
| + | $con = @mysql_connect ($dlc_server, | ||
| + | if ($con) { | ||
| + | $res=mysql_select_db($dlc_database, | ||
| + | if ($res) { | ||
| + | $query = " | ||
| + | $res = @mysql_query($query, | ||
| + | $row = @mysql_fetch_object($res); | ||
| + | $count = intval($row-> | ||
| + | if (@mysql_num_rows($res) == 0) { | ||
| + | $query = " | ||
| + | $res2 = @mysql_query($query, | ||
| + | $count = 1; | ||
| + | } else { | ||
| + | if ($dlc_ip != $row-> | ||
| + | $count++; | ||
| + | $query = " | ||
| + | $res2 = @mysql_query($query, | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | </ | ||