diff --git a/util/Makefile.in b/util/Makefile.in index 83d6ff9b..ad9814db 100644 --- a/util/Makefile.in +++ b/util/Makefile.in @@ -33,6 +33,7 @@ install: $(INSTALL) -m 0755 $(srcdir)/daily-report.php $(DESTDIR)$(libexecdir)/piler $(INSTALL) -m 0755 $(srcdir)/gmail-imap-import.php $(DESTDIR)$(libexecdir)/piler $(INSTALL) -m 0755 $(srcdir)/generate_stats.php $(DESTDIR)$(libexecdir)/piler + $(INSTALL) -m 0755 $(srcdir)/mailstat.php $(DESTDIR)$(libexecdir)/piler $(INSTALL) -m 0755 $(srcdir)/sign.php $(DESTDIR)$(libexecdir)/piler $(INSTALL) -m 0755 $(srcdir)/indexer.delta.sh $(DESTDIR)$(libexecdir)/piler $(INSTALL) -m 0755 $(srcdir)/indexer.main.sh $(DESTDIR)$(libexecdir)/piler diff --git a/util/mailstat.php b/util/mailstat.php new file mode 100644 index 00000000..887cc234 --- /dev/null +++ b/util/mailstat.php @@ -0,0 +1,122 @@ +data); + +$db = new DB(DB_DRIVER, DB_HOSTNAME, DB_USERNAME, DB_PASSWORD, DB_DATABASE, DB_PREFIX); +Registry::set('DB_DATABASE', DB_DATABASE); + +Registry::set('db', $db); + +if($date1 > 0) { $date_condition = " AND sent >= $date1 "; } +if($date2 > 0) { $date_condition .= " AND sent <= $date2 "; } + + +$query = $db->query("select `from` AS email, count(`from`) AS num FROM " . VIEW_MESSAGES . " WHERE `to`=? $date_condition GROUP BY `from` ORDER BY num DESC LIMIT $page_len", array($email)); + +foreach($query->rows as $q) { + $data[] = array( + 'num' => $q['num'], + 'email' => $q['email'], + 'type' => 'rcvd' + ); + +} + + +$query = $db->query("select `to` AS email, count(`to`) AS num FROM " . VIEW_MESSAGES . " WHERE `from`=? $date_condition GROUP BY `to` ORDER BY num DESC LIMIT $page_len", array($email)); + +foreach($query->rows as $q) { + $data[] = array( + 'num' => $q['num'], + 'email' => $q['email'], + 'type' => 'sent' + ); +} + + +array_multisort($data, SORT_DESC); + +foreach ($data as $q) { + print $q['num'] . "\t" . $q['type'] . "\t" . $q['email'] . "\n"; +} + +function display_help() { + global $webuidir; + + $phpself = basename(__FILE__); + echo("\nUsage: $phpself --webui [PATH] [OPTIONS...]\n\n"); + echo("\t--webui=\"[REQUIRED: path to the Piler WebUI Directory, default: $webuidir]\"\n"); + echo("\t--email=email address to look for conversations\n"); + + echo("\noptions:\n"); + echo("\t-h Prints this help screen and exits\n"); + echo("\t--start=\"Beginning of date range to process, ok values are today, yesterday or DDMMMYYYY...anything php's strtotime can process. Optional, will default to beginning of current day.\"\n"); + echo("\t--stop=\"End of date range, same parameters as above. Optional (will default to end of current day)\"\n\n"); +} + + +?>