improved gmail import script

This commit is contained in:
SJ 2015-04-07 11:43:03 +02:00
parent d3e2a39210
commit 1b4e34167d

View File

@ -3,12 +3,14 @@
ini_set("session.save_path", "/tmp");
$webuidir = "";
$email = "";
$daemonize = 0;
$opts = 'hd::';
$lopts = array(
'webui:'
'webui:',
'email:'
);
@ -26,6 +28,10 @@ if($options = getopt($opts, $lopts)) {
$daemonize = 1;
}
if(isset($options['email'])) {
$email = $options['email'];
}
}
else {
display_help();
@ -80,20 +86,24 @@ if($daemonize == 1) {
}
}
else {
poll_imap_accounts();
poll_imap_accounts($email);
}
function poll_imap_accounts() {
function poll_imap_accounts($email = '') {
$db = Registry::get('db');
$ug = new ModelUserGoogle();
$g = new ModelGoogleGoogle();
if($email) {
$query = $db->query("SELECT email FROM " . TABLE_GOOGLE . " WHERE email=?", array($email));
} else {
$query = $db->query("SELECT email FROM " . TABLE_GOOGLE);
}
if(isset($query->rows)) {
foreach($query->rows as $q) {
@ -110,8 +120,9 @@ function display_help() {
echo("\nUsage: $phpself --webui [PATH] [OPTIONS...]\n\n");
echo("\t--webui=\"[REQUIRED: path to the Piler WebUI Directory]\"\n\n");
echo("options:\n");
echo("\t-d Daemonize the imap polling\n");
echo("\t-h Prints this help screen and exits\n");
echo("\t--email: Email address to poll. Leave it empty to poll all email addresses\n");
echo("\t-d: Daemonize the imap polling\n");
echo("\t-h: Prints this help screen and exits\n");
}