019440th since April 04, 2007
Xicheng's web log
----- a place to make mistakes and learn from scratch
1 -
4 of
totally 9
entries
in
Aug, 2007 found
Next »
Aug 25, 2007 ( Saturday )
( 349 )
Mozilla CSS Extensions
Aug 7, 2007 ( Tuesday )
( 163 )
Redirection
With HTML::Mason
(1) Internal redirect: use subrequest like $m->subexec('/path/to/comp') and in the destination component, undef the inherit flag. (Note: this works only on Mason component, cannot parse URIs with query strings)
(2) External redirect: $m->redirect($url), $url can be any URIs or Mason components
With mod_perl:
(1) Internal redirect: $r->internal_redirect, or you can change $r->uri, $r->args in PerlTransHandler to make a rewrite of your request URI;
(2) External redirect: $r->err_headers_out( Location => $url );
You can always set HTTP header 'Location' to conduct a redirection.
(1) Internal redirect: use subrequest like $m->subexec('/path/to/comp') and in the destination component, undef the inherit flag. (Note: this works only on Mason component, cannot parse URIs with query strings)
(2) External redirect: $m->redirect($url), $url can be any URIs or Mason components
With mod_perl:
(1) Internal redirect: $r->internal_redirect, or you can change $r->uri, $r->args in PerlTransHandler to make a rewrite of your request URI;
(2) External redirect: $r->err_headers_out( Location => $url );
You can always set HTTP header 'Location' to conduct a redirection.
Aug 6, 2007 ( Monday )
( 180 )
Send email with Net::SMTP
I am now using Net::SMTP to send feedback emails:
package MyApp::Mail;
use strict;
use warnings;
use Carp qw/carp/;
use Net::SMTP;
sub send_mail
{
my($from, $to, $subject, $body) = @_;
carp "From missing" if not defined $from;
carp "To missing" if not defined $to;
my $mail_message = <<END_MAIL;
To : $to
From : $from
Subject : $subject
$body
END_MAIL
my $smtp = Net::SMTP->new(
'xichengjia.com',
Timeout => 60,
Debug => 0,
);
$smtp->mail($from) or carp "cant specify a sender [$from]\n";
$smtp->to($to) or carp "cant specify a recipient [$to]\n";
$smtp->data([$mail_message]) or carp "can't specify a message";
$smtp->dataend() or carp "fail to end sending data";
$smtp->quit() or carp "failed to quit\n";
}
1;
It's been working well so far.. ...More
package MyApp::Mail;
use strict;
use warnings;
use Carp qw/carp/;
use Net::SMTP;
sub send_mail
{
my($from, $to, $subject, $body) = @_;
carp "From missing" if not defined $from;
carp "To missing" if not defined $to;
my $mail_message = <<END_MAIL;
To : $to
From : $from
Subject : $subject
$body
END_MAIL
my $smtp = Net::SMTP->new(
'xichengjia.com',
Timeout => 60,
Debug => 0,
);
$smtp->mail($from) or carp "cant specify a sender [$from]\n";
$smtp->to($to) or carp "cant specify a recipient [$to]\n";
$smtp->data([$mail_message]) or carp "can't specify a message";
$smtp->dataend() or carp "fail to end sending data";
$smtp->quit() or carp "failed to quit\n";
}
1;
It's been working well so far.. ...More
Aug 4, 2007 ( Saturday )
( 120 )
Blog settled down at grokthis.net
Several modifications on the code
(1) Some Enviromental parameters changed. i.e. $ENV{REMOTE_ADDR} is not the visiting address any more. Switch to $ENV{HTTP_X_FORWARDED_FOR}
(2) local time is the server local time which has 4 hours difference from EDT. change from
scalar localtime
to
scalar localtime(time - 5)
and MySQL related DBIx code: change
NOW()
to
date_add(now(),interval -4 hour)
under per-directory configuration file .htaccess:
* RewriteBase /, and no leading slash to the destination URI
* use Options +-Indexes to control directory access
Most stuff now works pretty well. One problem left is the viewvc.cgi which can be used to access my cvs repository. The scripts needs RCS toolchains, and my current server doesnot have them. Will talk to Eric Monday.. ...More
(1) Some Enviromental parameters changed. i.e. $ENV{REMOTE_ADDR} is not the visiting address any more. Switch to $ENV{HTTP_X_FORWARDED_FOR}
(2) local time is the server local time which has 4 hours difference from EDT. change from
scalar localtime
to
scalar localtime(time - 5)
and MySQL related DBIx code: change
NOW()
to
date_add(now(),interval -4 hour)
under per-directory configuration file .htaccess:
* RewriteBase /, and no leading slash to the destination URI
* use Options +-Indexes to control directory access
Most stuff now works pretty well. One problem left is the viewvc.cgi which can be used to access my cvs repository. The scripts needs RCS toolchains, and my current server doesnot have them. Will talk to Eric Monday.. ...More
| More entries: 1 2 3 Next » | End |
[ Previous Page ] | [ Blog Main ]
Monthly archives
Site Statistics
Newest comments
My links
Add new links
Advanced Search
Blog
