<p class="flushleft">
morimoto@xantia.citroen.org<br>
-$Id: index.html,v 1.22 2004-09-11 15:53:42 morimoto Exp $
+$Id: index.html,v 1.23 2004-09-11 16:18:24 morimoto Exp $
</p>
<h2>ÀâÌÀ</h2>
# ¥Á¥ã¥Í¥ë¤´¤È¤Ë¡¢¤³¤Î¹Ô¿ô¤Þ¤Çµ²±
web_lines = 20
+# ȯ¸À¸å ̤ÆÉ¥á¥Ã¥»¡¼¥¸¤Î¤ß¤òɽ¼¨¤¹¤ë¤« Á´È¯¸À¤òɽ¼¨¤¹¤ë¤«?
+# ¥Ç¥£¥Õ¥©¥ë¥È¤ÏÁ´È¯¸Àɽ¼¨
+# show_newmsgonly = yes
+
# ¥¢¥¯¥»¥¹Ç§¾Ú. ¤³¤³¤ò¾Êά¤·¤Æ¤·¤Þ¤¦¤È
# ¥Ñ¥¹¥ï¡¼¥Éǧ¾Ú¤·¤Ê¤¤¤Î¤Ç¡¢Àܳ¤Ï´Êñ¤Ç¤¹¤¬¡¢URL ¤¬¤Ð¤ì¤Æ¤·¤Þ¤¦¤È
# ï¤Ç¤âÆɤá¤Þ¤¹¤·¡¢Ã¯¤Ç¤â¤¢¤Ê¤¿¤ËÀ®¤ê¤¹¤Þ¤·¤Æȯ¸À¤Ç¤¤Þ¤¹¡£
web_password = 2055
################################################################
+# options for AirH" Phone
+################################################################
+# AirH" Phone ¤Ê¤É Cookie ÂбþüËö¤Ç¥¯¥Ã¥¡¼¤ò»È¤¦¾ì¹ç
+# use_cookie = yes
+
+################################################################
# options for au (ezweb)
################################################################
# au_subscriber_id = 050999999999999_mb.ezweb.ne.jp
# (subscriber_id ¤Çǧ¾Ú¤Ç¤¤Ê¤«¤Ã¤¿¾ì¹ç¤Ï Ä̾ï¤Î basic auth ¤ò
# ¹Ô¤¤¤Þ¤¹)
-# ȯ¸À¸å ̤ÆÉ¥á¥Ã¥»¡¼¥¸¤Î¤ß¤òɽ¼¨¤¹¤ë¤« Á´È¯¸À¤òɽ¼¨¤¹¤ë¤«?
-# ¥Ç¥£¥Õ¥©¥ë¥È¤ÏÁ´È¯¸Àɽ¼¨
-# show_newmsgonly = yes
-
+################################################################
+# options for Vodafone live!
+################################################################
# ¤â¤· Vodafone live! (J-Phone) ¤Ê¤É¤Î http port ¤ò»ØÄê¤Ç¤¤Ê¤¤Ã¼Ëö¤Ç¡¢port 80 ¤ò
# Àêͤ»¤º keitairc ¤ò»È¤¤¤¿¤¤¤Ê¤é¡¢¤¿¤È¤¨¤Ð keitairc ¤ò port 8765 ¤Ç
# Ω¤Á¤¢¤²¡¢apache ¤Î httpd.conf ¤Î
<p>
keitairc ¤òµ¯Æ°¤·¤Æ·ÈÂÓ¤«¤é¥¢¥¯¥»¥¹¤¹¤ë¤È¡¢
+web_username ¤È web_password ¤Ç»ØÄꤷ¤¿¥æ¡¼¥¶Ì¾¤È¥Ñ¥¹¥ï¡¼¥É¤Çǧ¾Ú¤ò¹Ô¤Ê¤Ã¤¿¤Î¤Á¡¢
¤¤¤Þ»²²Ã¤·¤Æ¤¤¤ëÁ´¤Æ¤Î¥Á¥ã¥Í¥ë¤Î¥ê¥¹¥È¤¬½Ð¤Þ¤¹¡£
ȯ¸ÀÆâÍƤ¬¿·¤·¤¤¥Á¥ã¥Í¥ë¤«¤é½ç¤ËʤӤޤ¹¡£
-¥Á¥ã¥Í¥ë¤Î¥ê¥¹¥È¤ÏÅÅÏõ¡¤Î 0 ¤ò²¡¤¹¤È¹¹¿·¤Ç¤¤Þ¤¹¡£
+¥Á¥ã¥Í¥ë¤Î¥ê¥¹¥È¤ÏÅÅÏõ¡¤Î 0 ¤ò²¡¤¹¤È¹¹¿·¤Ç¤¤Þ¤¹¡£<br>
+¤Ê¤ª¡¢AirH" Phone¤Ê¤ÉCookieÂбþµ¡¼ï¤Ç¤Ï¡¢
+use_cookie = yes »ØÄê¤ò¤¹¤ì¤Ð¡¢°Ê¹ß¤Î¥æ¡¼¥¶Ì¾¡¦¥Ñ¥¹¥ï¡¼¥Éǧ¾Ú¤ò¾Êά¤Ç¤¤Þ¤¹¡£
</p>
<p>
¤Ë cvs ¥ê¥Ý¥¸¥È¥ê, BTS ¤Ê¤É¤¬¤¢¤ê¤Þ¤¹¡£
</p>
+<h2>¥»¥¥å¥ê¥Æ¥£</h2>
+<ul>
+<li><tt>use_cookie = yes</tt> ¤ÇüËö¤ËÊݸ¤µ¤ì¤ë¥¯¥Ã¥¡¼¤ÎÆâÍƤÏ
+°Å¹æ²½¤µ¤ì¤Æ¤¤¤Ê¤¤¤Î¤Ç¡¢¥¯¥Ã¥¡¼ÆâÍƤ¬Ï³±Ì¤¹¤ë¤È¥æ¡¼¥¶Ì¾¥Ñ¥¹¥ï¡¼¥É¤âϳ±Ì¤·¤Þ¤¹¡£
+<li>¤½¤â¤½¤â¤³¤³¤Ç»È¤ï¤ì¤Æ¤¤¤ë¥æ¡¼¥¶Ì¾¥Ñ¥¹¥ï¡¼¥Éǧ¾Ú¤Ï http basic ǧ¾Ú¤Ê¤Î¤Ç
+ÄÌ¿®Ï©¤òʿʸ¤Çή¤ì¤Þ¤¹¡£
+</ul>
+
<h2>Changes</h2>
<dl>
+<dt>1.28
+<dd>AirH" Phone¤Ê¤ÉCookieÂбþüËö¤Î¤¿¤á¤Ë¡¢CookieÂбþ¤·¤Þ¤·¤¿¡£
+°ìÅ٥桼¥¶Ì¾¡¢¥Ñ¥¹¥ï¡¼¥Éǧ¾Ú¤ò¹Ô¤Ê¤¨¤Ð¡¢Cookie¤Ëµ²±¤µ¤ì¤ë¤Î¤Ç¡¢
+¼¡¤«¤é¤Ï¥æ¡¼¥¶Ì¾¡¢¥Ñ¥¹¥ï¡¼¥É¤òÆþÎϤ¹¤ëɬÍפ¬¤¢¤ê¤Þ¤»¤ó¡£
+~/.keitairc¤Ë<tt>use_cookie = yes<tt>¤ÎÄɲä¬É¬ÍפǤ¹¡£
+(thanks to
+<a href="http://naimune.com/keitairc/">http://naimune.com/keitairc/</a>:
+¤Ò¤Á¤µ¤È¤¸¤å¤ó»á)
+
<dt>1.27
<dd>̤ÆɥХåե¡¤Î°·¤¤¤¬¤ª¤«¤·¤«¤Ã¤¿
#!/usr/bin/perl
# keitairc
-# $Id: keitairc,v 1.27 2004-09-07 04:20:58 morimoto Exp $
+# $Id: keitairc,v 1.28 2004-09-11 16:18:24 morimoto Exp $
#
# Copyright (c) 2003 Jun Morimoto <morimoto@xantia.citroen.org>
# This program is covered by the GNU General Public License 2
# Depends: libjcode-pm-perl, libpoe-component-irc-perl,
# liburi-perl, libwww-perl, libappconfig-perl
-my $rcsid = q$Id: keitairc,v 1.27 2004-09-07 04:20:58 morimoto Exp $;
+my $rcsid = q$Id: keitairc,v 1.28 2004-09-11 16:18:24 morimoto Exp $;
my ($version) = $rcsid =~ m#,v ([0-9.]+)#;
use strict;
use constant true => 1;
use constant false => 0;
+use constant cookie_ttl => 86400*3; # 3 days
my $config = AppConfig->new(
{
},
qw(irc_nick irc_username irc_desc
irc_server irc_port irc_password
- au_subscriber_id
+ au_subscriber_id use_cookie
web_port web_title web_lines web_root
web_username web_password show_newmsgonly)
);
# chk
my ($message_added);
+my $user_agent;
+
# irc component
POE::Component::IRC->new('keitairc');
POE::Session->new(
return;
}
+ # cookie
+ my $cookie_authorized;
+ if($config->use_cookie){
+ my %cookie;
+ for(split(/; */, $request->header('Cookie'))){
+ my ($name, $value) = split(/=/);
+ $value =~ s/%([0-9A-Fa-f][0-9A-Fa-f])/pack('C', hex($1))/eg;
+ $cookie{$name} = $value;
+ }
+
+ if($cookie{username} eq $config->web_username &&
+ $cookie{passwd} eq $config->web_password){
+ $cookie_authorized = true;
+ }
+ }
+
# authorization
- unless(defined($config->au_subscriber_id) &&
- ($request->header('x-up-subno') eq $config->au_subscriber_id)) {
+ unless($cookie_authorized){
+ unless(defined($config->au_subscriber_id) &&
+ $request->header('x-up-subno') eq $config->au_subscriber_id){
if(defined($config->web_username)){
- unless($request->headers->authorization_basic eq
- $config->web_username . ':' . $config->web_password){
- my $response = HTTP::Response->new(401);
- $response->push_header(WWW_Authenticate =>
- qq(Basic Realm="keitairc"));
- $heap->{client}->put($response);
- $kernel->yield('shutdown');
- return;
- }
+ unless($request->headers->authorization_basic eq
+ $config->web_username . ':' . $config->web_password){
+ my $response = HTTP::Response->new(401);
+ $response->push_header(WWW_Authenticate =>
+ qq(Basic Realm="keitairc"));
+ $heap->{client}->put($response);
+ $kernel->yield('shutdown');
+ return;
+ }
}
+ }
}
my $uri = $request->uri;
$content .= '<input type="text" name="m" size="10">';
$content .= '<input type="submit" accesskey="1" value="OK[1]">';
$content .= qq(<a accesskey="8" href="$docroot">ch list[8]</a><br>);
- # $content .= '<input type="submit" accesskey="1" value="聆">';
$content .= '</form>';
my $canon_channel = &canon_name($channel);
$content .= '</body></html>';
my $response = HTTP::Response->new(200);
+
+ if($config->use_cookie){
+ my ($sec, $min, $hour, $mday, $mon, $year, $wday) =
+ localtime(time + cookie_ttl);
+ my $expiration =
+ sprintf('%.3s, %.2d-%.3s-%.4s %.2d:%.2d:%.2d',
+ qw(Sun Mon Tue Wed Thu Fri Sat)[$wday],
+ $mday,
+ qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec)[$mon],
+ $year + 1900,
+ $hour,
+ $min,
+ $sec);
+ $response->push_header('Set-Cookie',
+ sprintf("username=%s; expires=%s; \n",
+ $config->web_username, $expiration));
+ $response->push_header('Set-Cookie',
+ sprintf("passwd=%s; expires=%s; \n",
+ $config->web_password, $expiration));
+ }
+
$response->push_header('Content-type', 'text/html; charset=Shift_JIS');
$response->content(Jcode->new($content)->sjis);
$heap->{client}->put($response);