#!/usr/bin/perl ####################################### # File: evolution2kmail.cgi # By: Tim Coston # Date: 02 May 01 # Last Modified: 02 May 01 tlc # # # Coston Enterprises, Inc. # www.coston.net ######################################## $scriptname = "evolution2kmail.cgi"; $ver = "1.00"; ######################################## ########################################### # Change the below variables to suite your system ########################################### # Absolute Path to Evolution Directory $evolution_dir = "/home/mike/evolution/local"; # Absolute Path to kMail Directory $kmail_dir = "/home/mike/Mail"; # Absolute Path to this CGI Directory $cgi_dir = "/home/tcoston/CEIPerl/CEIEvolution"; # Set this to 0 if you want to skip the comversion # for the Evolution Specific dirs listed: # Contacts # Calendar # Executive-Summary # Tasks $include_all = 0; opendir(EVO, "$evolution_dir"); @ev_files = readdir(EVO); closedir(EVO); $ev_count = 0; foreach (@ev_files) { next if($_ eq "."||$_ eq ".."); $ev_count++; } #foreach opendir(KMA, "$kmail_dir"); @km_files = readdir(KMA); closedir(KMA); $km_count = 0; foreach (@km_files) { next if($_ eq "."||$_ eq ".."); $km_count++; } #foreach print qq~ CEIEvolution! evolution2kmail - Mail Conversion Path Data: Evolution Dir: $evolution_dir File Count: $ev_count kMail Dir: $kmail_dir File Count: $km_count CEIEvolution Dir: $cgi_dir Conversion in Progress....... ~; foreach $one (@ev_files) { $one_lc = lc($one); next if($one eq "." || $one eq ".."); if($include_all == 0) { next if($one_lc eq "calendar"|| $one_lc eq "contacts"|| $one_lc eq "executive-summary"|| $one_lc eq "tasks"); } #if if(-d "$evolution_dir/$one") { $my_type = "directory"; } elsif (-f "$evolution_dir/$one") { $my_type = "file"; } else { $my_type = "unknown"; } print "$one - $my_type\n"; if(-f "$evolution_dir/$one/mbox") { $new_name = "/$one"; print "---MBOX FOUND $new_name ---\n"; open(OLD, "$evolution_dir/$one/mbox"); @mbox_contents = ; close(OLD); if($one eq "Drafts" || $one eq "Trash" || $one eq "Sent" || $one eq "Inbox" || $one eq "Outbox") { $one = $one_lc; } if($one eq "sent") { $one = "sent-mail"; } open(NMB, ">>$kmail_dir/$one"); print NMB @mbox_contents; close(NMB); $mbox_count++; } #if if(-d "$evolution_dir/$one") { opendir(TMP, "$evolution_dir/$one"); @sub_dir = readdir(TMP); closedir(TMP); foreach $two (@sub_dir) { next if($two eq "."||$two eq ".."); print " -"."$two\n"; if($two eq "subfolders") { opendir(TMP2, "$evolution_dir/$one/subfolders"); @sub_fol = readdir(TMP2); closedir(TMP2); foreach $three (@sub_fol) { next if($three eq "."||$three eq ".."); print " -"."$three\n"; if(-f "$evolution_dir/$one/subfolders/$three/mbox") { $new_name = "/.$one.directory/$three"; print "---MBOX FOUND: $new_name ---\n"; open(OLD2, "$evolution_dir/$one/subfolders/$three/mbox"); @submbox_contents = ; close(OLD2); $new_dir ="$kmail_dir/."."$one."."directory"; unless(-d "$new_dir") { mkdir("$new_dir", 0777); } open(NMB2, ">>$new_dir/$three"); print NMB2 @submbox_contents; close(NMB2); $mbox_count++; } #if } #foreach } #if } #foreach } #if } #foreach print qq~ $mbox_count mail folders converted ---------------------- Comversion Complete FREE TO DISTRIBUTE UNMODIFIED Coston Enteprises, Inc. www.coston.net ~; exit;