#
# sample ~/.keitairc for keitairc 2.x
#
-# $Id: dot.keitairc,v 1.4 2008-02-23 16:21:10 morimoto Exp $
+# $Id: dot.keitairc,v 1.5 2008-02-23 18:58:22 morimoto Exp $
# $Source: /home/ishikawa/work/keitairc/tmp/keitairc/etc/dot.keitairc,v $
################################################################
# web_title = keitairc
# Number of history per irc channel. Set to 100 by default.
# web_lines = 100
+# root directory for web access. Set to / by default.
+# web_root = /
################################################################
# Authorization setup
# Set to /var/run by default.
# pid_dir = /var/run
+# Verbose logging
+# debug = 1
+
################################################################
# Obsoleted options
################################################################
# au_pcsv option is obsoleted from keitairc 2.0
# use_cookie is obsoleted from keitairc 2.0
-# web_root is obsoleted from keitairc 2.0
# web_username is obsoleted from keitairc 2.0
# show_newmsgonly is obsoleted from keitairc 2.0
#!/usr/bin/perl
# keitairc
-# $Id: keitairc,v 1.41 2008-02-23 16:21:10 morimoto Exp $
+# $Id: keitairc,v 1.42 2008-02-23 18:58:22 morimoto Exp $
# $Source: /home/ishikawa/work/keitairc/tmp/keitairc/keitairc,v $
#
# Copyright (c) 2003-2008 Jun Morimoto <morimoto@mrmt.net>
::log_debug("dispatch: $uri");
+ {
+ # chop off $cf->web_root()
+ my $root = $cf->web_root();
+ $uri =~ s|$root|/|;
+ }
+
if($uri eq '/'){
return action_root($request);
}
# password mismatch
my $view = new Keitairc::View($cf, $ci);
- return $view->redirect("/");
+ return $view->redirect('/');
}
################################################################
sub log{
my $m = shift;
warn "keitairc: $m\n";
- # TODO
}
sub log_die{
my $m = shift;
die "keitairc: $m\n";
- # TODO
}
sub log_debug{
my $m = shift;
- warn "keitairc: $m\n";
- # TODO
+ if($cf->debug()){
+ warn "keitairc(debug): $m\n";
+ }
}
__END__
# -*-perl-*-
# Keitairc::Config
-# $Id: Config.pm,v 1.5 2008-02-23 16:21:10 morimoto Exp $
+# $Id: Config.pm,v 1.6 2008-02-23 18:58:22 morimoto Exp $
# $Source: /home/ishikawa/work/keitairc/tmp/keitairc/lib/Keitairc/Config.pm,v $
#
# Copyright (c) 2008 Jun Morimoto <morimoto@mrmt.net>
irc_server irc_port irc_password
au_subscriber_id au_pcsv
docomo_foma_icc
+ softbank_serial_key
use_cookie cookie_ttl session_ttl
web_port web_title web_lines web_root
web_username web_password web_host
show_newmsgonly ping_delay reconnect_delay
- smtp_server smtp_from smtp_to
+ smtp_server smtp_from smtp_to debug
template_dir version daemonize pid_dir plugin_dir)
);
$me->irc_port(6667);
$me->web_port(8080);
$me->web_title('keitairc');
- $me->web_line(100);
+ $me->web_lines(100);
+ $me->web_root('/');
$me->ping_delay(30);
$me->reconnect_delay(10);
$me->cookie_ttl(86400 * 3); # 3 days
::log("use_cookie has obsoleted from keitairc 2.0");
}
- if(defined $me->web_root()){
- ::log("web_root has obsoleted from keitairc 2.0");
- }
-
if(defined $me->au_pcsv()){
::log("au_pcsv has obsoleted from keitairc 2.0");
}
# -*-perl-*-
# Keitairc::IrcCallback
-# $Id: IrcCallback.pm,v 1.4 2008-02-23 15:36:56 morimoto Exp $
+# $Id: IrcCallback.pm,v 1.5 2008-02-23 18:58:22 morimoto Exp $
# $Source: /home/ishikawa/work/keitairc/tmp/keitairc/lib/Keitairc/IrcCallback.pm,v $
#
# Copyright (c) 2008 Jun Morimoto <morimoto@mrmt.net>
$buddy = $who;
}
$ib->join($buddy); # XXX: join $buddy if not joined
+ my $cid = $ib->name2cid($buddy);
Encode::from_to($msg, 'jis', 'euc-jp');
- $ib->add_message($buddy, $msg, $who);
+ $ib->add_message($cid, $msg, $who);
$heap->{seen_traffic} = 1;
$heap->{disconnect_msg} = 1;
}
# -*-perl-*-
# Keitairc::View
-# $Id: View.pm,v 1.6 2008-01-14 05:21:09 morimoto Exp $
+# $Id: View.pm,v 1.7 2008-02-23 18:58:22 morimoto Exp $
# $Source: /home/ishikawa/work/keitairc/tmp/keitairc/lib/Keitairc/View.pm,v $
#
# Copyright (c) 2008 Jun Morimoto <morimoto@mrmt.net>
my $me = shift;
my $path = shift;
- $path = sprintf('http://%s:%d%s%s',
- $me->{Config}->web_host(),
- $me->{Config}->web_port(),
- $path);
+ if($me->{Config}->web_root() eq '/'){
+ $path = sprintf('http://%s:%d%s%s',
+ $me->{Config}->web_host(),
+ $me->{Config}->web_port(),
+ $path);
+ }else{
+ # Softbank
+ $path =~ s|^/||;
+ $path = sprintf('http://%s%s%s',
+ $me->{Config}->web_host(),
+ $me->{Config}->web_root(),
+ $path);
+ }
+
::log_debug("path [$path]");
+
my $response = HTTP::Response->new(302);
$response->push_header('Location', $path);
$response;
my $vars = shift;
my $p = {};
+ $p->{root} = $me->{Config}->web_root();
$p->{title} = $me->{Config}->web_title();
$p->{version} = $me->{Config}->version();
$p->{timestamp} = timestamp();
# -*-perl-*-
# keitairc/lib/plugins/10url
# URL\8f\88\97\9d
-# $Id: 10url,v 1.3 2008-01-15 12:21:00 morimoto Exp $
+# $Id: 10url,v 1.4 2008-02-23 18:58:22 morimoto Exp $
# $Source: /home/ishikawa/work/keitairc/tmp/keitairc/lib/plugins/10url,v $
$plugin = {
message_replace_imprementation => sub {
my ($session_id, $param) = @_;
if($param =~ m/^http/){
- return sprintf('<a href="/%s/url/%s">%s</a>', $session_id, $param, $param);
+ return sprintf('<a href="%s%s/url/%s">%s</a>',
+ $::cf->web_root(),
+ $session_id, $param, $param);
}
- return sprintf('<a href="/%s/url/http://%s">%s</a>', $session_id, $param, $param);
+ return sprintf('<a href="%s%s/url/http://%s">%s</a>',
+ $::cf->web_root(),
+ $session_id, $param, $param);
},
action_imprementation => sub {
# -*-perl-*-
# keitairc/lib/plugins/20mail
# \83\81\81[\83\8b\83A\83h\83\8c\83X
-# $Id: 20mail,v 1.2 2008-01-13 12:12:55 morimoto Exp $
+# $Id: 20mail,v 1.3 2008-02-23 18:58:22 morimoto Exp $
# $Source: /home/ishikawa/work/keitairc/tmp/keitairc/lib/plugins/20mail,v $
$plugin = {
message_replace_regexp => '\b(\w[\w.+=-]*\@[\w.-]+[\w]\.[\w]{2,4})\b',
message_replace_imprementation => sub {
my ($session_id, $param) = @_;
- sprintf('<a href="/%s/mail/%s">%s</a>', $session_id, $param, $param);
+ sprintf('<a href="%s%s/mail/%s">%s</a>',
+ $::cf->web_root(), $session_id, $param, $param);
},
action_imprementation => sub {
# -*-perl-*-
# keitairc/lib/plugins/20phone
# \93d\98b\94Ô\8d\86
-# $Id: 20phone,v 1.3 2008-01-13 12:12:55 morimoto Exp $
+# $Id: 20phone,v 1.4 2008-02-23 18:58:22 morimoto Exp $
# $Source: /home/ishikawa/work/keitairc/tmp/keitairc/lib/plugins/20phone,v $
$plugin = {
message_replace_regexp => '\b(0\d{1,3})([-(]?)(\d{2,4})([-)]?)(\d{4})\b',
message_replace_imprementation => sub {
my ($session_id, $p1, $p2, $p3, $p4, $p5) = @_;
- sprintf('<a href="/%s/phone/%s%s%s">%s%s%s%s%s</a>',
+ sprintf('<a href="%s%s/phone/%s%s%s">%s%s%s%s%s</a>',
+ $::cf->web_root(),
$session_id,
$p1, $p3, $p5,
$p1, $p2, $p3, $p4, $p5);
404: No such action (<!-- tmpl_var action -->)<br />
<hr />
- <a accesskey="0" href="/">[0] Û¸Þ²Ý</a>
+ <a accesskey="0" href="<!-- tmpl_var root -->">[0] Û¸Þ²Ý</a>
<hr />
<!-- tmpl_var timestamp --><br />
keitairc <!-- tmpl_var version -->
</tmpl_if>
<tmpl_if is_softbank>
- <a accesskey="1" href="/<!-- tmpl_var session_id -->/location_receiver/<!-- tmpl_var cid -->" z>[1] \88Ê\92u\8fî\95ñ\91ª\92è</a><br />
- <a accesskey="2" href="location:auto?url=http://<!-- tmpl_var web_host -->:<!-- tmpl_var web_port -->/<!-- tmpl_var session_id -->/location_receiver/<!-- tmpl_var cid -->">[1] \88Ê\92u\8fî\95ñ\91ª\92è(3GC\92[\96\96)</a><br />
+ <a accesskey="1" href="<!-- tmpl_var root --><!-- tmpl_var session_id -->/location_receiver/<!-- tmpl_var cid -->" z>[1] \88Ê\92u\8fî\95ñ\91ª\92è</a><br />
+ <a accesskey="2" href="location:auto?url=http://<!-- tmpl_var web_host -->:<!-- tmpl_var root -->/<!-- tmpl_var session_id -->/location_receiver/<!-- tmpl_var cid -->">[2] \88Ê\92u\8fî\95ñ\91ª\92è(3GC\92[\96\96)</a><br />
</tmpl_if>
<hr />
<img src="<!-- tmpl_var map_image_url -->" width="160" height="240" alt="" />
</center>
\8c»\8dÝ\88Ê\92u\82Í<!-- tmpl_var address -->\82Å\82·\81B<br />
- <form action="/<!-- tmpl_var session_id -->/all/<!-- tmpl_var cid -->" method="post">
+ <form action="<!-- tmpl_var root --><!-- tmpl_var session_id -->/all/<!-- tmpl_var cid -->" method="post">
<tmpl_if is_ipod>
<input type="text" name="m" value="\8c»\8dÝ\88Ê\92u L:<!-- tmpl_var address -->" />
<tmpl_else>
</tmpl_if>
<hr />
- <a accesskey="8" href="/<!-- tmpl_var session_id -->/index">[8] Á¬ÈÙؽÄ</a><br />
+ <a accesskey="8" href="<!-- tmpl_var root --><!-- tmpl_var session_id -->/index">[8] Á¬ÈÙؽÄ</a><br />
<hr />
<!-- tmpl_var timestamp --><br />
keitairc <!-- tmpl_var version -->
Ò-Ù±ÄÞÚ½ <!-- tmpl_var mail -->
<hr />
- <form method="post" action="/<!-- tmpl_var session_id -->/postme">
+ <form method="post" action="<!-- tmpl_var root --><!-- tmpl_var session_id -->/postme">
<a accesskey="1" href="mailto:<!-- tmpl_var mail -->">[1] Ò-Ù\82ð\8dì\90¬</a><br />
Ò-Ù±ÄÞÚ½\82ðºËß-<br />
<input type="text" name="text" value="<!-- tmpl_var mail -->" />
</form>
<hr />
- <a accesskey="8" href="/<!-- tmpl_var session_id -->/index">[8] Á¬ÈÙؽÄ</a>
+ <a accesskey="8" href="<!-- tmpl_var root --><!-- tmpl_var session_id -->/index">[8] Á¬ÈÙؽÄ</a>
<hr />
<!-- tmpl_var timestamp --><br />
keitairc <!-- tmpl_var version -->
\93d\98b\94Ô\8d\86 <!-- tmpl_var phone -->
<hr />
- <form method="post" action="/<!-- tmpl_var session_id -->/postme">
+ <form method="post" action="<!-- tmpl_var root --><!-- tmpl_var session_id -->/postme">
<a accesskey="1" href="tel:<!-- tmpl_var phone -->">[1] \93d\98b\82ð\82©\82¯\82é</a><br />
<tmpl_if docomo>
<a accesskey="2" href="tel-av:<!-- tmpl_var phone -->">[2] TV\93d\98b\82ð\82©\82¯\82é</a><br />
</form>
<hr />
- <a accesskey="8" href="/<!-- tmpl_var session_id -->/index">[8] Á¬ÈÙؽÄ</a>
+ <a accesskey="8" href="<!-- tmpl_var root --><!-- tmpl_var session_id -->/index">[8] Á¬ÈÙؽÄ</a>
<hr />
<!-- tmpl_var timestamp --><br />
keitairc <!-- tmpl_var version -->
</tmpl_if>
<hr />
- <a accesskey="8" href="/<!-- tmpl_var session_id -->/index">[8] Á¬ÈÙؽÄ</a>
+ <a accesskey="8" href="<!-- tmpl_var root --><!-- tmpl_var session_id -->/index">[8] Á¬ÈÙؽÄ</a>
<hr />
<!-- tmpl_var timestamp --><br />
keitairc <!-- tmpl_var version -->
<!-- tmpl_var url -->
<hr />
<font color="#f3333">\82±\82ÌÍß-¼Þ\82Å\82Í[\96ß\82é]ÎÞÀÝ\82Í\8eg\82¦\82Ü\82¹\82ñ</font><br />
- <form method="post" action="/<!-- tmpl_var session_id -->/postme">
+ <form method="post" action="<!-- tmpl_var root --><!-- tmpl_var session_id -->/postme">
<a accesskey="1" href="<!-- tmpl_var url -->">
[1] \92¼\90Ú±¸¾½</a><br />
<a accesskey="2" href="http://mgw.hatena.ne.jp/?url=<!-- tmpl_var escaped_url -->&noimage=0&split=1">
</form>
<hr />
- <a accesskey="8" href="/<!-- tmpl_var session_id -->/index">[8] Á¬ÈÙؽÄ</a>
+ <a accesskey="8" href="<!-- tmpl_var root --><!-- tmpl_var session_id -->/index">[8] Á¬ÈÙؽÄ</a>
<hr />
<!-- tmpl_var timestamp --><br />
keitairc <!-- tmpl_var version -->