2008年1月11日金曜日

magic-smtpd 導入ログ

http://www.linuxmagic.com/opensource/magicmail/magic-smtpd
こちらを参考にして。

# tar -zxvf magicmail-.tar.gz
# cd magicmail-
# make
# mkdir -p /etc/magic-mail/control
# ./magic-smtpd/magic-smtpd -s

# cp magic-smtpd/magic-smtpd /var/qmail/bin/magic-smtpd
# chown root:qmail /var/qmail/bin/magic-smtpd
# mv -i /var/qmail/bin/qmail-smtpd /var/qmail/bin/qmail-smtpd.old
# ln -s /var/qmail/bin/magic-smtpd /var/qmail/bin/qmail-smtpd
# test that your email is working correctly


[root]# pwd
/etc/magic-mail/control
[root]# cat check_valid_users
1
[root]# cat ext_check_user_prog
/usr/local/bin/vpopmail-check-user.sh
[root]#

/usr/local/bin/vpopmail-check-user.sh
ALIASの部分を変更
全てにchmod +s
chown root:qmail

→/usr/local/bin/vpopmail-check-user.sh,valias,vuserinfo
--------------------------------------------------------------------------------------
#!/bin/sh
# $Header: /web/programmers/cvs/magicmail-backend/scripts/vpopmail-check-user.sh,v 1.2 200
5/02/25 20:20:09 xu Exp $


EMAIL=$1
ALIAS=`/bin/valias $EMAIL | fgrep $EMAIL >/dev/null 2>&1; echo $?`
#ALIAS=`/bin/valias $EMAIL | wc -l | /bin/grep "1" >/dev/null 2>&1 ; echo $?`
USER=`/bin/vuserinfo $EMAIL >/dev/null 2>&1; /bin/echo $? | /bin/grep "0" >/dev/null 2>&1
; /bin/echo $?`
#USER=0
if [ $ALIAS -eq 0 ] || [ $USER -eq 0 ]; then
exit 0
else
exit 1
fi
-----------------------------------------------------------------------------

2008年1月6日日曜日

Javascript カレンダー サンプル

JavaScriptによるカレンダーのサンプル
もっとも単純なもの
エラーチェックもありません。
getCalendar(2008,1); // 2008年2月

output
2008/2
Sun Mon Tue Wed Thu Fri Sat
[ -][ -][ -][ -][ -][ 1][ 2]
[ 3][ 4][ 5][ 6][ 7][ 8][ 9]
[10][11][12][13][14][15][16]
[17][18][19][20][21][22][23]
[24][25][26][27][28][29][ -]



function getCalendar (Y,M) {
dd = new Date(Y,M,1);

// week 0-6
sweek = dd.getDay();
days = new Array();
lastday = new Array(31,28,31,30,31,30,31,31,30,31,30,31);

var year = dd.getFullYear();
if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0) { lastday[1]++; }

for (i = 0; i < sweek; i++) { days[i] = "-"; //document.write(days[i]); //document.write("
");
}
j = 1;
for (j = 1; j < (lastday[M]+ 1); j++) { days[i] = j; i++; } for (; i < 35; i++) { days[i] = "-"; } // Month debug document.write("
");
document.write(Y);
document.write("/");
document.write((M +1));
document.write("
");


week = [0,0,0,0,0,0,0];
document.write("Sun Mon Tue Wed Thr Fri Sat");
document.write("
");
i = 0;
for (weeks = 0; weeks < 5; weeks++) {
for (week = 0; week < 7; week++) {
document.write("[");
day = days[i].toString();
if (day.length == 1) {
document.write(" ");
document.write(day);
} else {
document.write(day);
}
document.write("]");
i++;
}
document.write("");
}


document.write("
");
document.write("<hr />");
}

2007年11月7日水曜日

Smarty内で配列変数に任意の値がセットされているかをチェックする関数

<?
function smarty_modifier_is_in_array($string,$arr) {
  for($i = 0; $i < count($arr); $i++) {
    if($arr[$i] == $string){
      return 1;
    }
  }
  return 0;
}
?>

/usr/local/lib/php/plugins/modifier.is_in_array.php

/usr/lib/php/Smarty/libs/plugins/modifier.is_in_array.php
が設置場所になる。

配列を第一引数に持ってくると要素一つずつに対して、関数が実行され期待通りに
動いてくれないので、後ろにおく
使い方は

{"ほげほげ"|is_in_array:$arr}

あれば、1なければ0を返す。

checkboxなんかで使える。

2007年9月11日火曜日

当世風JavaScriptの書き方?

◎ECMAscriptで書く主な環境
・.NET やVistaのガジェット
・Mac OS XのDashboard
・Flash
・Firefoxのエクステンション
・DreamWeaverのエクステンション

◎「<!--」「-->」は書かない
<script>タグを使用時は書かない。
cf. 「<」「>」「&」はxhtmlではscript要素内で書いてはいけない。
どうしても書くときには下記のようにする

ex.
<script type="text/javascript">
//<![CDATA[
if(a < b)) document.write("Hello,world");
//]]>
</script>


◎イベント属性を使うときはmeta要素を記述する
<meta equiv="Content-Script-Type" content="text/javascript">


from 『基礎Ajax+ JavaScript』、佐藤和人、インプレスジャパン、2006

2007年6月27日水曜日

Smarty内での文字列のエンドーディングの変換

[参考]にしたサイト
http://tdiary.ishinao.net/20040423.html

smartyのpluginの追加方法

/usr/local/lib/php/plugins/modifier.mbconvert.php

--------------------------------------------------------
function smarty_modifier_mbconvert($string, $charset, $source_charset = 'auto') {
return mb_convert_encoding($string, $charset, $source_charset);
}
?>
--------------------------------------------------------

で、テンプレート内で
{$vals.org_name|mbconvert:"euc-jp":"utf-8"}
のようにする。



2007年6月20日水曜日

◎PostgreSQL8.2.4 install log

#cd /usr/local/src
#wget ftp://ftp.jp.postgresql.org/source/v8.2.4/postgresql-8.2.4.tar.gz
#configure --with-no-locale
#make
#make install
#mkdir /usr/local/pgsql/data
#chown postgres:postgres /usr/local/pgsql/data
# su - postgres
$ /usr/local/pgsql/bin/initdb --no-locale /usr/local/pgsql/data
$/usr/local/pgsql/bin/pg_ctl -D /usr/local/pgsql/data -l logfile start

2007年6月15日金曜日

mecab Tsearch2 postgresql install log

◎参考にしたもの
・http://mecab.sourceforge.net/
・http://sourceforge.net/project/showfiles.php?group_id=177856
・http://mecab.sourceforge.net/bindings.html
・https://www.oss.ecl.ntt.co.jp/tsearch2j/index.html

◎展開
#tar zxvf mecab-0.96.tar.gz
#tar zxvf mecab-ipadic-2.7.0-20070610.tar.gz
#tar zxvf mecab-ruby-0.96.tar.gz

◎mecab
# cd mecab-0.96
# ./configure --with-charset=utf8;make ;make check; make install

◎mecab-ipadic
# cd mecab-ipadic-2.7.0-20070610
# ./configure --with-charset=utf8;make ; make install

◎mecab-ruby
# cd mecab-ruby-0.96
# ruby extconf.rb
# make;make install

◎Tsearch2
# cdpostgresql-8.2.3/contrib/tsearch2/
# make; make install ;make installcheck

◎サンプルDBの作成
$ createdb -E UTF-8 sampledb

◎pgmecab
# wget http://www.emaki.minidns.net/Programming/postgres/pgmecab-1.1.tar.bz2
# tar jxvf pgmecab-1.1.tar.bz2
# cd pgmecab-1.1
Makefileを修正
top_builddir = /usr/local/src/postgresql-8.2.3
  postgresqlのソースへのpathを設定
MECAB_CONFIG_PATH = /usr/local/bin/mecab-config
  mecab-configへのpath
# make;make install

◎pgmecab.cに
fmgr.hヘッダファイルをincludeさせた後で、
#ifdef PG_MODULE_MAGIC
PG_MODULE_MAGIC;
#endif
のマクロを追加。8.2から必要になったらしい。

◎サンプルテーブルの作成
create table sample(i int4,t text,fti tsvector);

◎トリガーの作成
DROP TRIGGER tsvectorupdate ON tblSample;
CREATE TRIGGER tsvectorupdate BEFORE UPDATE OR INSERT ON sample
FOR EACH ROW EXECUTE PROCEDURE tsearch2(fti, pgmecab, t);

◎indexの作成
CREATE INDEX idxFTI_idx ON sample USING gist(fti);

◎サンプルクエリー
SELECT i, t
FROM sample
WHERE fti @@ to_tsquery('simple', replace(pgmecab(' する'), ' ', ''))
AND t LIKE '%オープン%';

◎ユーザー定義データ型の作成
create type finddoctype as (findindex integer, findtext text);

◎ユーザー定義関数の作成
drop function finddoc(text);
create function finddoc(text) returns setof finddoctype
as ' select findtbl.i as findindex, findtbl.t as findtext from
( select fromtbl.i, fromtbl.t from sample as fromtbl, to_tsquery(''simple'', replace(btrim(pgmecab($1),'' \n''), '' '', ''&'')) as q
where fromtbl.fti @@ q offset 0 ) as findtbl
where findtbl.t like ''%'' || $1 || ''%''; ' language sql;


sampledb=# select * from finddoc('ソース');
findindex | findtext
-----------+-------------------------------------
1 | プログラムはソースが決め手となる。
(1 row)

sampledb=# select * from finddoc('決め手');
findindex | findtext
-----------+-------------------------------------
1 | プログラムはソースが決め手となる。
(1 row)

sampledb=#

sampledb=# insert into Sample values (1, '登録テストwo
してみるのだけど、うまくいくのか心配です。');

update sample set t = '更新テストをしてみよう。日本は広いなぁ。' where i = 0;

sampledb=# delete from Sample where i = 1;