[PHP] デコメテンプレートのダウンロード偽装処理

DoCoMo
application/x-decomail-template .dmt

au
application/x-kddi-htmlmail .khm

SoftBank
application/x-htmlmail-template .hmt

DoCoMoとSoftBankはGET、POSTメソッドで対応。

auのみオブジェクトによる記述が必須。

プログラムを介してのダウンロードなど行う場合は、上記理由によりGETアクションとなる。

例:

data属性にプログラムと引数を渡して処理。

以下はざっくりとしたサンプル(auの場合)。


download.php

[Apache] .htaccessでの携帯サイト振り分け方法

.htaccessでの携帯サイト振り分け方法

.htaccessに、下記のように記述します。
全キャリア共通の携帯ページにアクセスさせる場合↓


    RewriteEngine On
    RewriteCond %{HTTP_USER_AGENT} ^(DoCoMo|KDDI|DDIPOKET|UP\.Browser|J-PHONE|Vodafone|SoftBank)
    RewriteRule ^$ /mobile/ [R]

後は保存したときにhtaccess.txtなどで保存して、FTPでアップした後に.htaccessに書き換えるだけ。
すべてのキャリアでいけるはずです。
上記の場合のディレクトリ構造は
┌─
├mobile[携帯用ディレクトリ]
│└index.html[携帯用トップページ]
├.htaccess[作成したファイル]
│index.html[PC用ページ]
└─

のような構成の場合です。mobileの部分を各自の携帯用ディレクトリに入れて使ってください。

↓各キャリアごとの場合


    Options +FollowSymLinks
    RewriteEngine On

    RewriteCond %{HTTP_USER_AGENT} DoCoMo
    RewriteRule ^$ http://example.jp/i/index.html [R]

    RewriteCond %{HTTP_USER_AGENT} J-PHONE
    RewriteRule ^$ http://example.jp/j/index.html [R]

    RewriteCond %{HTTP_USER_AGENT} UP.Browser
    RewriteRule ^$ http://example.jp/au/index.html [R]

[Linux] 共有メモリ設定(shmmax & shmall) PostgreSQL8.3.1編

PostgreSQLでは共有メモリと呼ばれるものを使用しています。
デフォルトの設定で大概行けるのですが、制限に引っかかる可能性がある為、
しっかり計算して設定しておく方が無難です。

■必要な共有メモリ

設定値

計算式

max_connections 1800 + 270 × max_locks_per_transaction
autocacuum_max_works 1800 + 270 × max_locks_per_transaction
max_prepared_transactions 770 + 270 × max_locks_per_transaction
shared_buffers 8KBごとに8400バイト
wal_buffers 8KBごとに8200バイト
max_fsm_relations 70
max_fsm_pages 6
固定サイズ 770KB

設定はrootで行って下さい。
【設定例】

#expr 100 '*' 1024 '*' 1024 > /proc/sys/kernel/shmmax
#expr 100 '*' 1024 '*' 1024 > /proc/sys/kernel/shmall