Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- File: get-all-emails.sh
- /*******************/
- #! /bin/bash
- # Email Address extraction script to get Thunderbird EMail addresses from email files.
- # Get current directory
- DIR="$( cd -P "$( dirname "$0" )" && pwd )"
- curdir="$DIR";
- user=username;
- tbpath='profile.default';
- old_fil='/home/$user/myfiles/all-addresses.old.txt';
- out_fil='/home/$user/myfiles/all-addresses.txt';
- grpfl1='^\(From\|To\|Cc\|CC\Bcc\|BCC\):';
- grpfl2='[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}';
- # Declare the first gmail.com dir for Thunderbird
- tbdir="/home/$user/.thunderbird/$tbpath/ImapMail/imap.googlemail.com/[Gmail].sbd";
- # Change to First TB directory
- echo "$tbdir";
- cd "$tbdir";
- # Run the grep statement to get the addresses
- grep $grpfl1 'All Mail' | grep -o -E $grpfl2 | sort -f | uniq -i > $outfil
- # Declare the second gmail.com dir for Thunderbird
- tbdir="/home/$user/.thunderbird/"$tbpath"/ImapMail/imap.googlemail-1.com/[Gmail].sbd";
- echo "Processing Dir=> $tbdir";
- cd "$tbdir";
- # Run the grep statement to get the addresses
- grep $grpfl1 'All Mail' | grep -o -E $grpfl2 | sort -f | uniq -i > $outfil
- # Declare the third gmail.com dir for Thunderbird
- tbdir="/home/$user/.thunderbird/$tbpath/ImapMail/imap.googlemail-2.com/[Gmail].sbd";
- echo "Processing Dir=> $tbdir";
- cd "$tbdir";
- # Run the grep statement to get the addresses
- grep $grpfl1 'All Mail' | grep -o -E $grpfl2 | sort -f | uniq -i > $outfil
- # Declare the forth gmail.com dir for Thunderbird
- tbdir="/home/$user/.thunderbird/$tbpath/ImapMail/imap.googlemail-3.com/[Gmail].sbd";
- echo "Processing Dir=> $tbdir";
- cd "$tbdir";
- # Run the grep statement to get the addresses
- grep $grpfl1 'All Mail' | grep -o -E $grpfl2 | sort -f | uniq -i > $outfil
- # Declare the fifth gmail.com dir for Thunderbird
- tbdir="/home/$user/.thunderbird/$tbpath/ImapMail/imap.googlemail-4.com/[Gmail].sbd";
- echo "Processing Dir=> $tbdir";
- cd "$tbdir";
- # Run the grep statement to get the addresses
- grep $grpfl1 'All Mail' | grep -o -E $grpfl2 | sort -f | uniq -i > $outfil
- # Sort the output for unique addresses
- cp $out_fil $old_fil;
- sort $old_fil | uniq -u > $out_fil
- # Change back to current directory
- cd "$curdir";
- nano $out_fil;
- /*******************/
- File: get-all-emails.php
- /*******************/
- <?php
- /***************************************************************************/
- /* Name: get-all-emails.php */
- /* Author: Nyle E. Davis Create Date: 15/01/30 */
- /* Purpose: This file contains the processing to read all Thunderbird */
- /* email db and collect all address into the 'outfil' specified. */
- /***************************************************************************/
- include_once ( 'config.php' );
- include_once ( EM_DIR."/em_objects.php" );
- include_once ( EM_DIR."/em_stdio/em_stdio.php" );
- include_once ( EM_DIR."/em_stdio/em_directory.php" );
- $cur_dir = getcwd();
- $new_ray = array();
- $pth_stm = "/home/$p_user/.thunderbird/";
- $out_fil = "/home/$p_user/myfiles/all-addresses.txt";
- $old_fil = "/home/$p_user/myfiles/all-addresses.old.txt";
- $grpfl1 = '^\(From\|To\|Cc\|CC\Bcc\|BCC\):';
- $grpfl2 = '[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}';
- $em_dir = new em_directory();
- $fil_ray = $em_dir->read_dir ( $pth_stm, '.sbd' );
- foreach ( $fil_ray as $dir ) {
- if ( !is_dir ( $dir ) ) { continue; }
- $good_dir = strip_tail ( $dir );
- $last_11 = substr ( $good_dir, -11 );
- if ( $last_11 === '[Gmail].sbd' ) {
- if ( !in_array ( $good_dir, $new_ray ) ) {
- $new_ray[] = $good_dir;
- } // end if
- } else { continue; }
- } // end foreach $fil_ray
- echo exec ( "rm -fR $out_fil" );
- echo exec ( "touch $out_fil" );
- $fil_ray = sort ( $new_ray );
- foreach ( $new_ray as $pdir ) {
- echo "Processing Dir=> $pdir \n";
- echo exec ( chdir ( "$pdir" ) );
- $prc_cmd = "grep $grpfl1 'All Mail' | grep -o -E $grpfl2 ".
- "| sort -f | uniq -i > $out_fil";
- echo exec ( "$prc_cmd" );
- } // end foreach $fil_ray
- echo exec ( chdir ( "$cur_dir" ) );
- echo exec ( "cp $out_fil $old_fil" );
- echo exec ( "sort $old_fil | uniq -u $out_fil" );
- echo exec ( "nano $out_fil" );
- function strip_tail ( $mydir ) {
- $l2 = substr ( $mydir, -2 );
- if ( $l2 == '/.' ) { $mydir = substr ( $mydir,0,strlen ($mydir)-2 ); }
- $l3 = substr ( $mydir, -3 );
- if ( $l3 == '/..' ) { $mydir = substr ( $mydir,0,strlen ($mydir)-3 ); }
- return $mydir;
- } // end function strip_tail
- ?>
- /*******************/
- File: config.php
- /*******************/
- <?php
- /***************************************************************************/
- /* Author: Nyle E. Davis Create Date: 08/14/10 */
- /* E-Mail: davisoftaec@gmail.com Revision: unknown */
- /* Purpose: This file contains the preset vars and definitions that */
- /* direct the calling and processing for the current process. */
- /***************************************************************************/
- /* Mod by: Nyle E. Davis Mod Date: 12/08/30 */
- /* Change: Added this header to this file for proper tracking and */
- /* documentation of changes to the file. */
- /***************************************************************************/
- /* Mod by: Nyle E. Davis Mod Date: 12/09/05 */
- /* Change: Added debug vars of: */
- /* DBUG_ME ==> Does array and var dumps, */
- /* INFO_ME ==> Allow run of phpinfo() statements, */
- /* PRUN_ME ==> Does other process run debugging. */
- /* SHOW_ME ==> Shows/echos all set vars, */
- /* STOP_ME ==> Stop processing with a die() statement. */
- /* $et_ray ==> Error array that is called by/within the modules. */
- /* Requires a one line call to be set just before the */
- /* "return" statement or other "end of module" call */
- /* so processing errors in $_GET and $_POST and other */
- /* system vars can be displayed. */
- /* Notes: The debug var PRUN_ME can be assigned values of 0-9 where 0 is */
- /* off and the other values can turn on upto 9 debugging tests. */
- /***************************************************************************/
- // Define the constants for debugging
- define ( 'DBUG_ME', 1 ); // 0=off, 1=on
- define ( 'INFO_ME', 0 ); // 0=off, 1=on
- define ( 'PRUN_ME', 0 ); // 0=off, 1-9=on by test type
- define ( 'SHOW_ME', 1 ); // 0=off, 1=on
- define ( 'STOP_ME', 0 ); // 0=off, 1=on end where set in code.
- $et_ray = array(); // Add the module names to test in this array
- // End debugging constants
- // Define the PAGE constants
- if ( !defined('TITLE1') ) {
- define('TITLE1', 'Interactive Topical Bible');
- $_GET['TITLE1'] = TITLE1;
- } // end if !isset TITLE1
- if ( !defined('TITLE2') ) {
- define('TITLE2', 'A better Bible Resource');
- $_GET['TITLE2'] = TITLE2;
- } // end if !isset TITLE1
- if ( !defined('TITLE3') ) {
- define('TITLE3', 'Topic Search');
- } // end if !isset TITLE1
- $_GET['TITLE3'] = TITLE3;
- // End PAGE constants
- // Get the Default DIR constants
- $mode = php_sapi_name();
- if ($mode=='cli') {
- $droot = '/var/www';
- $lnbrk = '\n';
- $lnfmt = '';
- $lnumt = '';
- } else {
- $droot = $_SERVER['DOCUMENT_ROOT'];
- $lnbrk = '<br>';
- $lnfmt = '<pre>';
- $lnumt = '<pre>';
- } // end if $mode
- $emdir = $droot.'/Frameworks/EM/';
- $fcdir = $droot.'/functions/';
- define ('EM_DIR', $emdir);
- include_once (EM_DIR."em_stdio/em_directory.php");
- $edir = new em_directory();
- $froot = $edir->froot;
- $nroot = $edir->nroot;
- $proot = $edir->proot;
- $sroot = $edir->sroot;
- $crdir = getcwd().'/';
- // Set the directory constants
- define ('DOC_DIR', $droot);
- define ('FNC_DIR', $froot);
- define ('NET_DIR', $nroot);
- define ('PTH_DIR', $proot);
- define ('SCP_DIR', $sroot);
- define ('CUR_DIR', $crdir);
- // Open EM Standard IO
- include_once (EM_DIR."em_stdio/em_stdio.php");
- $emio = new em_io();
- // Define the Process constants
- $p_user = 'username';
- define ( 'FIL_DIR', "/media/$p_user/3a582561-dd48-4822-b4dd-37375f6e6a24/".
- "backups/DB_Backups/mysql_backup/" );
- define ( 'MAIL_DIR', "/home/$p_user/.thunderbird/" );
- // Define the DB constants
- define('DB_ENG', 'mysql'); // Set the DB engine
- define('DB_HST', 'localhost'); // Set the DB Host
- define('DB_PRF', 'cb_'); // Set the DB Table Prefix
- define('DB_PRT', '3306'); // Set the DB Port
- define('DB_USE', 'forecasts'); // Set the DB to use
- $sys = gethostname();
- if (strpos($sys,'Aspire')) {
- define('DB_USR', 'oldmanriver');
- define('DB_PWD', 'domains4meNU2');
- } elseif ($sys=='New-Off-DT') {
- //define('DB_USR', 'oldmanriver');
- //define('DB_PWD', 'domains4meNU2');
- define('DB_USR', 'ndavis');
- define('DB_PWD', 'nomened1497');
- } // end if $sys
- include_once (EM_DIR."em_dio/em_dio.php");
- $edb = new em_dio();
- // End DB constants
- if (SHOW_ME==2) {
- echo "H=> ".DB_HST." <br>";
- echo "U=> ".DB_USR." <br>";
- echo "P=> ".DB_PWD." <br>";
- echo "CR=> ".CUR_DIR." <br>";
- echo "DR=> ".DOC_DIR." <br>";
- echo "FR=> ".FNC_DIR." <br>";
- echo "NR=> ".NET_DIR." <br>";
- echo "PR=> ".PTH_DIR." <br>";
- echo "SR=> ".SCP_DIR." <br>";
- echo "SN=> $sys <br>";
- }
- // end definitions
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement