Skip to content

Instantly share code, notes, and snippets.

@false-git
Created January 9, 2014 06:55
Show Gist options
  • Save false-git/8330415 to your computer and use it in GitHub Desktop.
Save false-git/8330415 to your computer and use it in GitHub Desktop.
*** /usr/ports/net/asterisk/work/asterisk-1.8.25.0/contrib/scripts/vmail.cgi Sat Sep 20 09:52:20 2008
--- vmail.cgi Thu Jan 9 13:45:11 2014
***************
*** 20,25 ****
--- 20,26 ----
use DBI;
use Fcntl qw ( O_WRONLY O_CREAT O_EXCL );
use Time::HiRes qw ( usleep );
+ use DateTime::Format::Strptime;
$context=""; # Define here your by default context (so you dont need to put voicemail@context in the login)
***************
*** 43,49 ****
}
);
! $astpath = "/_asterisk";
$stdcontainerstart = "<table align=center width=600><tr><td>\n";
$footer = "<hr><font size=-1><a href=\"http://www.asterisk.org\">The Asterisk Open Source PBX</a> Copyright 2004-2008, <a href=\"http://www.digium.com\">Digium, Inc.</a></a>";
--- 44,50 ----
}
);
! $astpath = ".";
$stdcontainerstart = "<table align=center width=600><tr><td>\n";
$footer = "<hr><font size=-1><a href=\"http://www.asterisk.org\">The Asterisk Open Source PBX</a> Copyright 2004-2008, <a href=\"http://www.digium.com\">Digium, Inc.</a></a>";
***************
*** 145,151 ****
$context = "default";
}
if (!$filename) {
! $filename = "/etc/asterisk/voicemail.conf";
}
# print header;
# print "Including <h2>$filename</h2> while in <h2>$category</h2>...\n";
--- 146,152 ----
$context = "default";
}
if (!$filename) {
! $filename = "/usr/local/etc/asterisk/voicemail.conf";
}
# print header;
# print "Including <h2>$filename</h2> while in <h2>$category</h2>...\n";
***************
*** 153,159 ****
while(<VMAIL>) {
chomp;
if (/include\s\"([^\"]+)\"$/) {
! ($tmp, $category) = &check_login("/etc/asterisk/$1", $category);
if (length($tmp)) {
# print "Got '$tmp'\n";
return ($tmp, $category);
--- 154,160 ----
while(<VMAIL>) {
chomp;
if (/include\s\"([^\"]+)\"$/) {
! ($tmp, $category) = &check_login("/usr/local/etc/asterisk/$1", $category);
if (length($tmp)) {
# print "Got '$tmp'\n";
return ($tmp, $category);
***************
*** 200,206 ****
my ($mbox, $context) = split(/\@/, param('mailbox'));
my $pass = param('password');
my ($found, $fullname) = (0, "");
! open VMAIL, "</etc/asterisk/users.conf";
while (<VMAIL>) {
chomp;
if (m/\[(.*)\]/) {
--- 201,207 ----
my ($mbox, $context) = split(/\@/, param('mailbox'));
my $pass = param('password');
my ($found, $fullname) = (0, "");
! open VMAIL, "</usr/local/etc/asterisk/users.conf";
while (<VMAIL>) {
chomp;
if (m/\[(.*)\]/) {
***************
*** 242,248 ****
$context = "default";
}
if (!$filename) {
! $filename = "/etc/asterisk/voicemail.conf";
}
if (!$category) {
$category = "general";
--- 243,249 ----
$context = "default";
}
if (!$filename) {
! $filename = "/usr/local/etc/asterisk/voicemail.conf";
}
if (!$category) {
$category = "general";
***************
*** 251,257 ****
while (<VMAIL>) {
chomp;
if (/include\s\"([^\"]+)\"$/) {
! ($tmp, $category) = &validmailbox($mbox, $context, "/etc/asterisk/$1");
if ($tmp) {
return ($tmp, $category);
}
--- 252,258 ----
while (<VMAIL>) {
chomp;
if (/include\s\"([^\"]+)\"$/) {
! ($tmp, $category) = &validmailbox($mbox, $context, "/usr/local/etc/asterisk/$1");
if ($tmp) {
return ($tmp, $category);
}
***************
*** 298,304 ****
local $tmp2;
local $tmp;
if (!$filename) {
! $filename = "/etc/asterisk/voicemail.conf";
}
if (!$category) {
$category = "general";
--- 299,305 ----
local $tmp2;
local $tmp;
if (!$filename) {
! $filename = "/usr/local/etc/asterisk/voicemail.conf";
}
if (!$category) {
$category = "general";
***************
*** 310,316 ****
chomp;
s/\;.*$//;
if (/include\s\"([^\"]+)\"$/) {
! ($tmp2, $category) = &mailbox_options($context, $current, "/etc/asterisk/$1", $category);
# print "Got '$tmp2'...\n";
$tmp .= $tmp2;
} elsif (/\[(.*)\]/) {
--- 311,317 ----
chomp;
s/\;.*$//;
if (/include\s\"([^\"]+)\"$/) {
! ($tmp2, $category) = &mailbox_options($context, $current, "/usr/local/etc/asterisk/$1", $category);
# print "Got '$tmp2'...\n";
$tmp .= $tmp2;
} elsif (/\[(.*)\]/) {
***************
*** 443,448 ****
--- 444,453 ----
}
}
close(MSG);
+ my $fmt = DateTime::Format::Strptime->new(pattern => '%a %b %e %r %Z %Y');
+ my $origdate = $fmt->parse_datetime($fields->{'origdate'});
+ $origdate->set_time_zone('Asia/Tokyo');
+ $fields->{'origdate'} = $origdate->strftime('%Y/%m/%d(%a) %H:%M:%S');
$fields->{'msgid'} = $msg;
} else { print "<BR>Unable to open '$msg' in '$mailbox', '$folder'\n<B>"; }
$fields;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment