見てきた全てを記録するmod_estraier
フォワードプロキシを利用して、見てきたURL全てを記録する仕組みを考えていて、SetOutputFilter+PHP外部スクリプトでそれっぽいのを作ってみた。
trace.php
[php num=1]#!/usr/bin/php -q
<?php
/*
* CREATE TABLE log
(
* id
int(11) NOT NULL auto_increment,
* timestamp
timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
* uri
varchar(255) NOT NULL,
* title
varchar(255) NOT NULL,
* contents
text,
* PRIMARY KEY (id
),
* UNIQUE KEY uri
(uri
)
* );
/
mb_detect_order('EUC-JP,SJIS,UTF-8,ASCII');
$documentUri = getenv('DOCUMENT_URI');
$documentPathInfo = getenv('DOCUMENT_PATH_INFO');
$queryStringUnescaped = getenv('QUERY_STRING_UNESCAPED');
$buf = @file_get_contents('php://stdin');
echo $buf;
$documentUri = mysql_real_escape_string($documentUri);
$enc = 'auto'; if (preg_match('/<meta http-equiv="Content-Type" content="text\/html; charset=([^"]+)"/i', $buf, $matches)) { $enc = $matches[1]; } $buf = mb_convert_encoding($buf, 'UTF-8', $enc);
$title = ''; if(preg_match('/
$buf = mysql_real_escape_string($buf); $dbh = mysql_connect('localhost', 'user','password'); mysql_select_db('test'); $sql =<<<EOD INSERT DELAYED IGNORE INTO log SET uri = '$documentUri', title='$title', contents = '$buf' EOD; mysql_query($sql, $dbh);
ExtFilterDefine trace mode=output intype=text/html cmd="/usr/local/bin/trace.php" EnableEnv=PROXY_TRACE SetOutputFilter trace ProxyRequests On <Proxy *> SetEnv PROXY_TRACE </Proxy *>
ってかさ、あるじゃんかね、そういうの。
mod_estraierによる履歴全文検索
WWWOFFLE & Estraier で快適キャッシュ検索
コード書く前に気付けよなぁ。。。
あとこれも。
「Firefox」閲覧履歴を詳細表示・検索できる「Enhanced History Manager」