From 8eb5dbe69a07855ebe921fcd644d35e094eda718 Mon Sep 17 00:00:00 2001 From: Janos SUTO Date: Sat, 3 Nov 2018 16:35:41 +0100 Subject: [PATCH] More util refactoring Signed-off-by: Janos SUTO --- etc/config-site.dist.php | 12 +++++++----- util/automated-search.php | 37 ++++++++++++++++++------------------- util/daily-report.php | 15 ++++++--------- util/gmail-imap-import.php | 10 ++++++---- 4 files changed, 37 insertions(+), 37 deletions(-) diff --git a/etc/config-site.dist.php b/etc/config-site.dist.php index ac57e3e0..efe66d78 100644 --- a/etc/config-site.dist.php +++ b/etc/config-site.dist.php @@ -1,11 +1,13 @@ 0, 'sort' => $sort, 'order' => $order, - 'type' => 'search', - 'search' => $search_expression, + 'type' => SEARCH_STR, + SEARCH_STR => $search_expression, 'searchtype' => 'expert' ); @@ -178,7 +180,7 @@ if($auto_search == 1) $queries = $sa->get(); foreach ($queries as $query) { - $data['search'] = $query['query']; + $data[SEARCH_STR] = $query['query']; $data['id'] = $query['id']; do_search($data, $automated_search_recipients); @@ -248,7 +250,7 @@ function do_search($data = array(), $automated_search_recipients = array()) $mail->send_smtp_email(SMARTHOST, SMARTHOST_PORT, SMTP_DOMAIN, SMTP_FROMADDR, $automated_search_recipients, $msg); } else { - print "search = " . $data['search'] . "\n"; + print "search = " . $data[SEARCH_STR] . "\n"; print_r($all_ids); print $EOL . $EOL; } @@ -261,17 +263,14 @@ function do_search($data = array(), $automated_search_recipients = array()) function display_help() { $phpself = basename(__FILE__); - echo("\nUsage: $phpself [OPTIONS...] --webui [PATH] --search '[SEARCH EXPRESSION]' | --auto\n\n"); - echo("\nThe results go to the recipients defined in \$automated_search_recipients, see config-site.php\n\n"); + echo "\nUsage: $phpself [OPTIONS...] --webui [PATH] --search '[SEARCH EXPRESSION]' | --auto\n\n"; + echo "\nThe results go to the recipients defined in \$automated_search_recipients, see config-site.php\n\n"; - echo("\t--webui=\"[REQUIRED: path to the piler webui directory]\"\n"); - echo("\t--search=\"[REQUIRED (unless you specify --auto): the search expression]\"\n\n"); - echo("options:\n"); - echo("\t-a | --auto: Perform an automated search based on queries defined via the piler gui\n"); - echo("\t-y | --yesterday: Search \"yesterday\"\n"); - echo("\t-d | --dry-run: Only print the found IDs\n"); - echo("\t-h | --help: Prints this help screen and exits\n"); + echo "\t--webui=\"[REQUIRED: path to the piler webui directory]\"\n"; + echo "\t--search=\"[REQUIRED (unless you specify --auto): the search expression]\"\n\n"; + echo "options:\n"; + echo "\t-a | --auto: Perform an automated search based on queries defined via the piler gui\n"; + echo "\t-y | --yesterday: Search \"yesterday\"\n"; + echo "\t-d | --dry-run: Only print the found IDs\n"; + echo "\t-h | --help: Prints this help screen and exits\n"; } - - -?> diff --git a/util/daily-report.php b/util/daily-report.php index 28390440..cfc2cb7a 100644 --- a/util/daily-report.php +++ b/util/daily-report.php @@ -23,7 +23,7 @@ if ( $options = getopt( $opts, $lopts ) ) $webuidir = $options['webui']; } else { - echo("\nError: must provide path to WebUI directory\n\n"); + echo "\nError: must provide path to WebUI directory\n\n"; display_help(); exit; @@ -190,12 +190,9 @@ if($fp) { function display_help() { $phpself = basename(__FILE__); - 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-v Provide a verbose output\n"); - echo("\t-h Prints this help screen and exits\n"); + 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-v Provide a verbose output\n"; + echo "\t-h Prints this help screen and exits\n"; } - - -?> diff --git a/util/gmail-imap-import.php b/util/gmail-imap-import.php index fb13e36a..3a261f00 100644 --- a/util/gmail-imap-import.php +++ b/util/gmail-imap-import.php @@ -1,5 +1,7 @@ rows)) { foreach($query->rows as $q) { - $access_token = $ug->refresh_access_token($q['email']); - $g->download_users_emails($q['email'], $access_token); + $access_token = $ug->refresh_access_token($q[EMAIL_STR]); + $g->download_users_emails($q[EMAIL_STR], $access_token); } } }