barnowl_perlaimdebianrelease-1.10release-1.4release-1.5release-1.6release-1.7release-1.8release-1.9
Last change
on this file since 2566560 was
2566560,
checked in by Alex Vandiver <alexmv@mit.edu>, 18 years ago
|
Database bits
|
-
Property mode set to
100644
|
File size:
1.0 KB
|
Line | |
---|
1 | sub owl::startup { |
---|
2 | use DBI; |
---|
3 | use DateTime; |
---|
4 | use DateTime::Format::Strptime; |
---|
5 | $owl::strp = DateTime::Format::Strptime->new(pattern => "%a %b %d %T %Y"); |
---|
6 | } |
---|
7 | |
---|
8 | |
---|
9 | sub owl::db_connect { |
---|
10 | return if $owl::dbh and $owl::dbh->ping; |
---|
11 | $owl::dbh = DBI->connect("DBI:mysql:database=zephyr_log", |
---|
12 | "owl", "", {RaiseError => 1}); |
---|
13 | $owl::sth = $owl::dbh->prepare("INSERT INTO messages(sender, class, instance, opcode, sent, received, host, zsig, body) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)"); |
---|
14 | } |
---|
15 | |
---|
16 | sub owl::receive_msg { |
---|
17 | my $msg = shift; |
---|
18 | return unless $msg->is_zephyr and not $msg->is_personal; |
---|
19 | my $sent = $owl::strp->parse_datetime($msg->time); |
---|
20 | owl::db_connect(); |
---|
21 | $owl::sth->execute($msg->sender, |
---|
22 | $msg->class, |
---|
23 | $msg->instance, |
---|
24 | $msg->opcode ? $msg->opcode : undef, |
---|
25 | $sent->datetime, |
---|
26 | DateTime->now->datetime, |
---|
27 | lc $msg->hostname, |
---|
28 | $msg->zsig, |
---|
29 | $msg->body, |
---|
30 | ); |
---|
31 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.