Archive for the ‘CakePHP1.2’ Category

csvファイルのダウンロード

火曜日, 8月 31st, 2010

VIA:CakePHP1.2 を使って簡単に Csv ダウンロードを実装する方法
VIA:CSV Helper (PHP 5)
Read the rest of this entry »



App外に共通で使用するComponentやHelperをPluginとして置く

金曜日, 8月 27th, 2010

VIA:第4回CakePHP勉強会@TokyoのLTで発表してきました!

具体的には、
/path/to/plugins/tools/controllers/components/hoge.php
var $components = array(‘Tools.Hoge’);
/path/to/plugins/tools/views/helpers/hoge.php
var $helpers = array(‘Tools.Hoge’);
/path/to/plugins/tools/models/behaviors/hoge.php
var $actsAs = array(‘Tools.Hoge’);
となります。

共通で使用できるものは一緒にした方が複数appから利用しやすいしメンテしやすい。



CakephpでSecurimage(captcha)を使う

木曜日, 8月 26th, 2010

携帯で、CAPTCHAを設定してみた。
「そこそこ見やすく、数字のみ」を基準にSecurimageKCAPTCHAを比較してみた。どちらもCakephpで使用した実績はあるらしい(Googleで検索すると出てくるので)
KCAPTCHAは標準でGoggleのCaptchaのようなグニャグニャ数字がでるらしいが、GoogleのChaptchaは個人的には見づらいと思う。
設定しだいでは見やすくなるのかもしれないが、ちょっと調べる時間がとれない。
と、いうことで、Securimageを使用。
Read the rest of this entry »



session idの長さ

木曜日, 8月 26th, 2010

VIA:CakePHP に use_trans_sid 風の処理を組み込む
VIA:PHPのSession IDの長さを変更する

if( preg_match('/^[0-9a-f]{32}$/', $sid) ){
    session_id($sid);
    $this->_needs_session_renew=true; //for Session Fixation
}


データベース接続情報を取得する

木曜日, 8月 26th, 2010

VIA:DB接続情報をDSN形式で取得
VIA:getDSN

/**
 * getDSN
 *  - Gets a DSN for the other apps to connect to
 *    the database independent from CakePHP
 */
function getDSN()
{
    $this->db =& ConnectionManager::getDataSource('default');
    $c = $this->db->config;
    return "{$c['driver']}://{$c['login']}:{$c['password']}@{$c['host']}/{$c['database']}";

} //end getDSN()


携帯キャリアによってrenderの処理を変える

木曜日, 8月 26th, 2010

VIA:携帯によって表示を変える

function render( $action = null, $layout = null, $file = null )
{
        if( !empty( $_SERVER["HTTP_USER_AGENT"] ) )
        {
                $ua     = $_SERVER["HTTP_USER_AGENT"];
                if( strpos( $ua, "DoCoMo" ) !== FALSE ){
                        $action = "i_" . ( $action ? $action : $this->action );
                        $layout = "i_" . $this->layout;
                }else if( strpos( $ua, "UP.Browser" ) !== FALSE ){
                        $action = "a_" . ( $action ? $action : $this->action );
                        $layout = "a_" . $this->layout;
                }else if(
                        strpos( $ua, "SoftBank" ) !== FALSE ||
                        strpos( $ua, "Vodafone" ) !== FALSE ||
                        strpos( $ua, "J-PHONE" ) !== FALSE ){
                        $action = "j_" . ( $action ? $action : $this->action );
                        $layout = "j_" . $this->layout;
                }
        }
        return parent::render( $action, $layout, $file );
}


1.2RCのLIKE,BETWEEN,INの書き方

水曜日, 8月 25th, 2010

VIA:1.2RCのLIKE,BETWEEN,INの書き方まとめ

$conditions = array("Post.title LIKE" => "%post%");
$conditions = array("Post.date BETWEEN ? AND ?" => array("2008-1-1", "2009-1-1"));
$conditions = array("Post.title LIKE ?" => array("%post%"));
$conditions = array("Post.id" => array(1,2,3,4,5));

VIA:3.7.3.7 複雑な find の条件



携帯からの写メール

火曜日, 8月 24th, 2010

VIA:マルチパートなメールを解析する PEAR::Mail::mimeDecode をラップするクラス
VIA:携帯メール解析

メール受信をトリガーにしてPHPを実行する処理

■メール転送
さくらサーバーの「.mailfilter」
/MailBox/メールアドレス/内、パーミッション600、文字コードEUC、改行LF

to "| /home/USERID/www/PHPプログラム名.php"
exit

PLESKサーバーのQMAIL
/var/qmail/mailnames/ドメイン名/メールアドレス/.qmail、文字コードEUC、改行LF

| /var/www/vhosts/ドメイン名/httpdocs/PHPプログラム名.php

Read the rest of this entry »



参考URLメモ

火曜日, 8月 24th, 2010

■参考

■TIPS

■bakery

■携帯

■Smarty

■その他



afterFilterで文字コード変換

火曜日, 8月 24th, 2010

function beforeFilter() {
        parent::beforeFilter();
}

function afterFilter(){
        parent::afterFilter();
        $this->output = mb_convert_kana($this->output, 'rak', 'UTF-8');
        $this->output = mb_convert_encoding($this->output, 'SJIS', 'UTF-8');
}