OSDN Git Service

mail uri, phone no, url to user
authormorimoto <morimoto@180c8125-5b33-4295-ad04-72a68a15b4cc>
Sun, 13 Jan 2008 12:12:55 +0000 (12:12 +0000)
committermorimoto <morimoto@180c8125-5b33-4295-ad04-72a68a15b4cc>
Sun, 13 Jan 2008 12:12:55 +0000 (12:12 +0000)
lib/Keitairc/Config.pm
lib/plugins/00postme [new file with mode: 0644]
lib/plugins/10url
lib/plugins/20mail
lib/plugins/20phone
lib/templates/mail.html
lib/templates/phone.html
lib/templates/postme.html [new file with mode: 0644]
lib/templates/url.html

index 25c6a6b..406bde8 100644 (file)
@@ -1,6 +1,6 @@
 # -*-perl-*-
 # Keitairc::Config
-# $Id: Config.pm,v 1.2 2008-01-09 18:45:53 morimoto Exp $
+# $Id: Config.pm,v 1.3 2008-01-13 12:12:55 morimoto Exp $
 # $Source: /home/ishikawa/work/keitairc/tmp/keitairc/lib/Keitairc/Config.pm,v $
 #
 # Copyright (c) 2008 Jun Morimoto <morimoto@mrmt.net>
@@ -31,6 +31,7 @@ sub new{
                   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
                   template_dir version daemonize pid_dir plugin_dir)
                );
 
diff --git a/lib/plugins/00postme b/lib/plugins/00postme
new file mode 100644 (file)
index 0000000..b8f2daf
--- /dev/null
@@ -0,0 +1,51 @@
+# -*-perl-*-
+# keitairc/lib/plugins/00postme
+# $Id: 00postme,v 1.1 2008-01-13 12:12:55 morimoto Exp $
+# $Source: /home/ishikawa/work/keitairc/tmp/keitairc/lib/plugins/00postme,v $
+
+use Net::SMTP;
+
+$plugin = {
+       name => 'postme',
+       action_imprementation => sub {
+               my ($request, $name, $session_id, $param_string) = @_;
+               my $ci = new Keitairc::ClientInfo($request);
+               my $view = new Keitairc::View($::cf, $ci);
+
+               my $error = {};
+               $error->{no_smtp_server} = 1 unless $::cf->smtp_server();
+               $error->{no_smtp_from} = 1 unless $::cf->smtp_from();
+               $error->{no_smtp_to} = 1 unless $::cf->smtp_to();
+               if(keys(%{$error})){
+                       $error->{has_error} = 1;
+                       $error->{session_id} = $session_id;
+                       return $view->render('postme.html', $error);
+               }
+
+               my $message = $request->content();
+               $message =~ s/^text=//;
+               $message =~ s/\+/ /g;
+               Encode::from_to($message, 'shiftjis', 'jis');
+
+               my $smtp = Net::SMTP->new($::cf->smtp_server());
+               $smtp->mail($::cf->smtp_from());
+               $smtp->to($::cf->smtp_to());
+               $smtp->data();
+               $smtp->datasend('To: ' . $::cf->smtp_to() . "\n");
+               $smtp->datasend("Subject: memo from keitairc\n");
+               $smtp->datasend("Content-Type: text/plain; charset=iso-2022-jp\n");
+               $smtp->datasend("MIME-Version: 1.0\n");
+               $smtp->datasend("\n");
+               $smtp->datasend($message);
+               $smtp->datasend("\n");
+               $smtp->dataend();
+               $smtp->quit();
+
+               my $p = {};
+               $p->{smtp_to} = $::cf->smtp_to();
+               $p->{session_id} = $session_id;
+               return $view->render('postme.html', $p);
+       }
+};
+
+1;
index 0a87d2e..b836ba4 100644 (file)
@@ -1,7 +1,7 @@
 # -*-perl-*-
 # keitairc/lib/plugins/10url
 # URL\8f\88\97\9d
-# $Id: 10url,v 1.1 2008-01-09 19:30:34 morimoto Exp $
+# $Id: 10url,v 1.2 2008-01-13 12:12:55 morimoto Exp $
 # $Source: /home/ishikawa/work/keitairc/tmp/keitairc/lib/plugins/10url,v $
 
 $plugin = {
@@ -21,6 +21,7 @@ $plugin = {
                my $ci = new Keitairc::ClientInfo($request);
                my $view = new Keitairc::View($::cf, $ci);
                return $view->render('url.html', {
+                       session_id => $session_id,
                        url => $param_string,
                        escaped_url => ::uri_escape($param_string),
                        ezweb => $ci->is_ezweb(),
index 608487b..c836346 100644 (file)
@@ -1,7 +1,7 @@
 # -*-perl-*-
 # keitairc/lib/plugins/20mail
 # \83\81\81[\83\8b\83A\83h\83\8c\83X
-# $Id: 20mail,v 1.1 2008-01-09 19:30:34 morimoto Exp $
+# $Id: 20mail,v 1.2 2008-01-13 12:12:55 morimoto Exp $
 # $Source: /home/ishikawa/work/keitairc/tmp/keitairc/lib/plugins/20mail,v $
 
 $plugin = {
@@ -18,6 +18,7 @@ $plugin = {
                my $ci = new Keitairc::ClientInfo($request);
                my $view = new Keitairc::View($::cf, $ci);
                return $view->render('mail.html', {
+                       session_id => $session_id,
                        mail => $param_string,
                             });
        }
index a1c7471..5684231 100644 (file)
@@ -1,7 +1,7 @@
 # -*-perl-*-
 # keitairc/lib/plugins/20phone
 # \93d\98b\94Ô\8d\86
-# $Id: 20phone,v 1.2 2008-01-13 06:22:38 morimoto Exp $
+# $Id: 20phone,v 1.3 2008-01-13 12:12:55 morimoto Exp $
 # $Source: /home/ishikawa/work/keitairc/tmp/keitairc/lib/plugins/20phone,v $
 
 $plugin = {
@@ -20,7 +20,10 @@ $plugin = {
                my ($request, $name, $session_id, $param_string) = @_;
                my $ci = new Keitairc::ClientInfo($request);
                my $view = new Keitairc::View($::cf, $ci);
-               return $view->render('phone.html', { phone => $param_string });
+               return $view->render('phone.html', {
+                       session_id => $session_id,
+                       phone => $param_string
+                            });
        }
 };
 
index acf6e58..f973d86 100644 (file)
     Ò-Ù±ÄÞÚ½ <!-- tmpl_var mail -->
     <hr />
 
-    <form action="">
+    <form method="post" action="/<!-- tmpl_var session_id -->/postme">
       <a accesskey="1" href="mailto:<!-- tmpl_var mail -->">[1] Ò-Ù\82ð\8dì\90¬</a><br />
       Ò-Ù±ÄÞÚ½\82ðºËß-<br />
-      <input type="text" value="<!-- tmpl_var mail -->" />
+      <input type="text" name="text" value="<!-- tmpl_var mail -->" />
+      <input type="submit" value="ÒÓ\91\97\90M"><br />
     </form>
 
     <hr />
-    <a accesskey="8" href="../index">[8] Á¬ÈÙؽÄ</a>
+    <a accesskey="8" href="/<!-- tmpl_var session_id -->/index">[8] Á¬ÈÙؽÄ</a>
     <hr />
     <!-- tmpl_var timestamp --><br />
     keitairc <!-- tmpl_var version -->
index f155a90..0f76252 100644 (file)
     \93d\98b\94Ô\8d\86 <!-- tmpl_var phone -->
     <hr />
 
-    <form action="">
+    <form method="post" action="/<!-- 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 />
       </tmpl_if>
       \93d\98b\94Ô\8d\86\82ðºËß-<br />
-      <input type="text" value="<!-- tmpl_var phone -->" />
+      <input type="text" name="text" value="<!-- tmpl_var phone -->" />
+      <input type="submit" value="ÒÓ\91\97\90M"><br />
     </form>
 
     <hr />
-    <a accesskey="8" href="../index">[8] Á¬ÈÙؽÄ</a>
+    <a accesskey="8" href="/<!-- tmpl_var session_id -->/index">[8] Á¬ÈÙؽÄ</a>
     <hr />
     <!-- tmpl_var timestamp --><br />
     keitairc <!-- tmpl_var version -->
diff --git a/lib/templates/postme.html b/lib/templates/postme.html
new file mode 100644 (file)
index 0000000..1781be4
--- /dev/null
@@ -0,0 +1,33 @@
+<html>
+  <head>
+    <meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS" />
+    <meta http-equiv="Cache-Control" content="max-age=0" />
+    <tmpl_if viewport>
+      <meta name="viewport" content="width=device-width" />
+      <meta name="viewport" content="initial-scale=1.0, user-scalable=yes" />
+    </tmpl_if>
+    <title><!-- tmpl_var title -->: postme</title>
+  </head>
+  <body>
+
+    <tmpl_if has_error>
+      <tmpl_if no_smtp_server>
+       smtp_server\82ª\90Ý\92è\82³\82ê\82Ä\82¢\82Ü\82¹\82ñ\81B
+      </tmpl_if>
+      <tmpl_if no_smtp_from>
+       smtp_from\82ª\90Ý\92è\82³\82ê\82Ä\82¢\82Ü\82¹\82ñ\81B
+      </tmpl_if>
+      <tmpl_if no_smtp_to>
+       smtp_to\82ª\90Ý\92è\82³\82ê\82Ä\82¢\82Ü\82¹\82ñ\81B
+      </tmpl_if>
+    <tmpl_else>
+      <!-- tmpl_var smtp_to -->\82ÉÒ-Ù\82ð\91\97\90M\82µ\82Ü\82µ\82½\81B
+    </tmpl_if>
+
+    <hr />
+    <a accesskey="8" href="/<!-- tmpl_var session_id -->/index">[8] Á¬ÈÙؽÄ</a>
+    <hr />
+    <!-- tmpl_var timestamp --><br />
+    keitairc <!-- tmpl_var version -->
+  </body>
+</html>
index be4b9da..0c73757 100644 (file)
@@ -12,7 +12,7 @@
     <!-- tmpl_var url -->
     <hr />
 
-    <form action="">
+    <form method="post" action="/<!-- 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">
          [4] PC»²ÄËÞ­-±\82ű¸¾½</a><br />
       </tmpl_if>
       URL\82ðºËß-<br />
-      <input type="text" value="<!-- tmpl_var url -->" />
+      <input type="text" name="text" value="<!-- tmpl_var url -->" />
+      <input type="submit" value="ÒÓ\91\97\90M"><br />
     </form>
 
     <hr />
+    <a accesskey="8" href="/<!-- tmpl_var session_id -->/index">[8] Á¬ÈÙؽÄ</a>
+    <hr />
     <!-- tmpl_var timestamp --><br />
     keitairc <!-- tmpl_var version -->
   </body>