hdknr’s posterous

 
Filed under

php

 

ウィジェットで初期値入力/休日表示カレンダープラグインその6 | PHPで感じるほんの少しの喜び

WordPressのupdate_option関数は、その値が存在しなければ、自動的にデータベースへ追加してくれる便利な機能です。

Filed under  //   PHP   wordpress  

Comments [0]

宮城・仙台のWEBシステム研究会 「アイ・ドリーム」 » [CakePHP+PHP] Cookieが使えない携帯端末でSessionを機能させる方法

すべてのURLにセッションIDをつけるのは手間がかかるので、
PHPのconfigureのときに、「–enable-track-sid」オプションを付けてmakeする。
または、php.iniのsession.use_trans_sidを1に設定する。
そうすることで、セッションIDを埋め込む必要がなくなる。
フォームでもhiddenタグが追加される。

session.use_trans_sid

Filed under  //   DoCoMo   PHP   Session  

Comments [0]

正規表現の詳細 - PHP関数マニュアル検索@pedia

Unicode 文字プロパティ

PHP 4.4.0 および 5.1.0 以降、UTF-8 モード を設定した場合に、 一般的な文字タイプにマッチする新たなエスケープシーケンスが 3 つ追加されました。

\p{xx}
xx プロパティを持つ文字
\P{xx}
xx プロパティを持たない文字
\X
拡張 Unicode シーケンス

ここで xx で表されているプロパティ名は、Unicode で 一般カテゴリプロパティ (general category properties) として規定されているものに なります。すべての文字は、いずれかひとつのプロパティを持ちます。 プロパティは、2 文字の略語で表されます。Perl と同じく、 開き波カッコとプロパティ名との間にハット文字を記述することで否定を指定できます。 たとえば、\p{^Lu}\P{Lu} と同じです。

\p もしくは \P の後に、一文字だけを記述すると その文字で始まるすべてのプロパティが指定されたことになります。 この場合、否定の指定をしていない場合、波カッコを使用しなくても構いません。 以下の 2 つの例は等価になります。

      \p{L}
      \pL
     
使用可能なプロパティコード C その他 (Other) Cc コントロール文字 (Control) Cf 非可視整形用文字 (Format) Cn 未定義コードポイント (Unassigned) Co 私的利用領域 (Private use) Cs サロゲート (Surrogate) L アルファベット (Letter) Ll 小文字アルファベット (Lower case letter) Lm 擬似文字 (Modifier letter) Lo その他の文字 (Other letter) Lt タイトル文字 (Title case letter) Lu 大文字アルファベット (Upper case letter) M 記号 (Mark) Mc 修飾文字 (Spacing mark) Me 他の文字を囲むための文字 (Enclosing mark) Mn 他の文字を修飾するための文字 (Non-spacing mark) N 数字 (Number) Nd 10 進数字 (Decimal number) Nl 数値を表す文字 (Letter number) No その他の数字 (Other number) P 句読記号 (Punctuation) Pc 連結用句読記号 (Connector punctuation) Pd ダッシュ (Dash punctuation) Pe 閉じ句読記号 (Close punctuation) Pf 末尾句読記号 (Final punctuation) Pi 先頭句読記号 (Initial punctuation) Po その他の句読記号 (Other punctuation) Ps 開き句読記号 (Open punctuation) S 記号 (Symbol) Sc 通貨記号 (Currency symbol) Sk 合わせ文字 (Modifier symbol) Sm 数学記号 (Mathematical symbol) So その他の記号 (Other symbol) Z 区切り文字 (Separator) Zl 行区切り文字 (Line separator) Zp 段落区切り文字 (Paragraph separator) Zs 空白文字 (Space separator)

"Greek" や "InMusicalSymbols" といった拡張プロパティ (extended properties) は PCRE によりサポートされていません。

大小文字を区別しないマッチングを設定していても、これらのエスケープ シーケンスには影響しません。たとえば、\p{Lu} は 常に小文字にのみマッチします。

\X は、拡張 Unicode シーケンスを構成する Unicode 文字群に マッチします。\X は、(?>\PM\pM*) と等価です。

つまり、記号 (mark) プロパティの付いていない文字と、その後に続く 0 以上の 記号プロパティ付きの文字にマッチし、その並びをアトミック (atomic) な まとまりとして取り扱います。記号プロパティ付きの文字とは、アクセント記号などの 直前の文字に対して影響するようなもののことです。

Unicode プロパティを使った文字列マッチングは速くありません。PCRE は 15,000 以上のデータからなるストラクチャを検索する必要が有るためです。 そのため、PCRE では、\d\w といった 以前から有るエスケープシーケンスは Unicode プロパティを使用しないように なっています。

Filed under  //   PHP   Regex  

Comments [0]

Apache Log Analyzer 2 Feed - Index - Simone Carletti's Codestuffs

Apache Log Analyzer 2 Feed

ApacheLogAnalyzer2Feed is a really powerful open source PHP 5 class to parse and analyze Apache Web Server log files. Results are converted into a feed to let users subscribe them with a feed reader.

You can define custom filters based on logs data — for instance User-Agent, IP, requested page... — and combine them to select just a limited resultset.
The class can easily be extended with additional filters and custom feed handlers.

Quick Start

Would you like to be informed each time GoogleBot visits your website?

ApacheLogAnalyzer2Feed is the solution! ApacheLogAnalyzer2Feed will analyze server logs for you returning results in a custom feed.
Simply using the following code fragment you'll be able to track Googlebot directly from your feed reader.

Filed under  //   analyzer   apache   log   PHP  

Comments [0]

Example usage of AX in PHP OpenID - Stack Overflow

Ran into the same issue. Some digging in AX.php got me a working start. Haven't looked for any bugs, nor tested beyond basic, nor tested with anyone other than Google. This is not pretty: needs error handling, etc. But this should get you started. Will post an update if I have something robust...

First to throw ...

//      oid_request.php

// Just tested this with/for Google, needs trying with others ...
$oid_identifier
= 'https://www.google.com/accounts/o8/id';

// Includes required files
require_once
"Auth/OpenID/Consumer.php";
require_once
"Auth/OpenID/FileStore.php";
require_once
"Auth/OpenID/AX.php";

// Starts session (needed for YADIS)
session_start
();

// Create file storage area for OpenID data
$store
= new Auth_OpenID_FileStore('./oid_store');

// Create OpenID consumer
$consumer
= new Auth_OpenID_Consumer($store);

// Create an authentication request to the OpenID provider
$auth
= $consumer->begin($oid_identifier);

// Create attribute request object
// See http://code.google.com/apis/accounts/docs/OpenID.html#Parameters for parameters
// Usage: make($type_uri, $count=1, $required=false, $alias=null)
$attribute
[] = Auth_OpenID_AX_AttrInfo::make('http://axschema.org/contact/email',2,1, 'email');
$attribute
[] = Auth_OpenID_AX_AttrInfo::make('http://axschema.org/namePerson/first',1,1, 'firstname');
$attribute
[] = Auth_OpenID_AX_AttrInfo::make('http://axschema.org/namePerson/last',1,1, 'lastname');

// Create AX fetch request
$ax
= new Auth_OpenID_AX_FetchRequest;

// Add attributes to AX fetch request
foreach($attribute as $attr){
        $ax
->add($attr);
}

// Add AX fetch request to authentication request
$auth
->addExtension($ax);

// Redirect to OpenID provider for authentication
$url
= $auth->redirectURL('http://localhost:4001', 'http://localhost:4001/oid_catch.php');
header
('Location: ' . $url);

... and then to catch

<?php

//      oid_catch.php

// Includes required files
require_once
"Auth/OpenID/Consumer.php";
require_once
"Auth/OpenID/FileStore.php";
require_once
"Auth/OpenID/AX.php";

// Starts session (needed for YADIS)
session_start
();

// Create file storage area for OpenID data
$store
= new Auth_OpenID_FileStore('./oid_store');

// Create OpenID consumer
$consumer
= new Auth_OpenID_Consumer($store);

// Create an authentication request to the OpenID provider
$auth
= $consumer->complete('http://localhost:4001/oid_catch.php);

if ($response->status == Auth_OpenID_SUCCESS) {
        // Get registration informations
        $ax = new Auth_OpenID_AX_FetchResponse();
        $obj = $ax->fromSuccessResponse($response);

        // Print me raw
        echo '<pre>';
        print_r($obj->data);
        echo '
</pre>';
        exit;


} else {
  // Failed
}

Those ought to be the basics...

Filed under  //   Janrain   OpenID   PHP   PHP-Openid  

Comments [0]

Nginx HTTP Server + PHP5 (With fast-cgi And xcache) On Ubuntu Feisty Fawn | HowtoForge - Linux Howtos and Tutorials

We've just asked Nginx to listen to fcgi on port 9000. So we have to start now the fcgi process. I've chosen to use spawn-fcgi and to make my own init script of it (so the process will start after reboot). To have spawn-fcgi you have to get lighttpd configured but without the need to install it. Let's grab the latest version:

 wget http://www.lighttpd.net/download/lighttpd-1.4.18.tar.bz2

 tar -xvjf lighttpd-1.4.18.tar.bz2 

cd lighttpd-1.4.18

 ./configure

 make

 cp src/spawn-fcgi /usr/bin/spawn-fcgi

Note that we did not type make install so lighttpd is not running!

Filed under  //   fastcgi   nginx   PHP   spawn-fcgi  

Comments [0]

Picok

Picok stands for Personal Information Cockpit. It's an open source software package, aimed at enableing users to build their personal information dashboards. The users content is loaded into small draggable boxes, so called portlets, and layed out in a tabbed column-based interface. There are a quite few standard portlets shipped with Picok, but since it is an open system, maintainers of picok installations can easily create portlets of their own.

Filed under  //   Dashboard   oss   PHP  

Comments [0]

Downloads - sweetcron - Google Code

Check out this website I found at code.google.com

 

Sweetcron is a self-hosted lifestreaming application that supports themes & plugins. It is based on the CodeIgniter php framework, from EllisLab.

Filed under  //   codelgniter   lifestreaming   PHP   sweetcron  

Comments [0]