#!/usr/bin/perl -T use strict; #-----------# # Dada Mail #-----------# # # Homepage: http://dadamail.org # # Support: http://dadamail.org/support # # How To Ask For Free Help: # http://mojo.skazat.com/support/documentation/getting_help.pod.html # # Please Do Not Contact the Author directly about Dada Mail support, # unless for paid support! Please, and thank you. # # How to ask for paid consultation: # http://mojo.skazat.com/support/regular.html #---------------------------------------------------------------------# #---------------------------------------------------------------------# # WinNT users! Getting warnings in your browser? # Uncomment the line below: # close STDERR; # #---------------------------------------------------------------------# #---------------------------------------------------------------------# # use CGI::Carp; # use CGI::Carp "fatalsToBrowser"; # The line above, 'use CGI::Carp', when changed to: # # use CGI::Carp "fatalsToBrowser"; # # captures critical server errors created by Dada Mail and shows them # in your Web browser. In other words, instead of seeing the, # # "Internal Server Error" # # message in your browser, you'll see something more interesting. # If this does not give you any clue on what's wrong, consider # setting the error log - See, "$PROGRAM_ERROR_LOG" in the Config.pm # documentation. #---------------------------------------------------------------------# #---------------------------------------------------------------------# # The Path to your Perl Libraries: # This IS NOT the path to Perl. The path to Perl is the first line of # this script. # # use lib qw( ./ ./DADA ./DADA/perllib ); # This list may need to be added to. Find the absolute to path to this # very file. This: # # /home/youraccount/www/cgi-bin/dada/mail.cgi # # Is an example of what the absolute path to this file may be. # # Get rid of, "/mail.cgi" # # /home/youraccount/www/cgi-bin/dada # # Add that line after, "./DADA/perllib" above. # # Add "DADA", and, "DADA/perllib" from the absolute path you just made right # after your last entry into the Path to your Perl Libraries: # # /home/youraccount/www/cgi-bin/dada/DADA # /home/youraccount/www/cgi-bin/dada/DADA/perllib # # and you should be good to go. # # If this doesn't do the job - make sure ALL the directories, including the # DADA directory have permissions of: 755 and all files have permissions # of: 644 #---------------------------------------------------------------------# #---------------------------------------------------------------------# # No more user-serviceable parts, please see the: # # dada/DADA/Config.pm # # file and: # # for instructions on how to install Dada Mail (easiest install) # # http://dadamail.org/installation/ # # and: # # http://dadamail.org/support/documentation/Config.pm.html # # for more than you'd ever want to know. #---------------------------------------------------------------------# $|++; $ENV{PATH} = "/bin:/usr/bin"; delete @ENV{'IFS', 'CDPATH', 'ENV', 'BASH_ENV'}; use DADA::Config; use DADA::App::Guts; use DADA::Template::HTML; use DADA::MailingList::Subscribers; use CGI; CGI->nph(1) if $NPH == 1; my $q = new CGI; $q->charset($HTML_CHARSET); #---------------------------------------------------------------------# # DEV: Should be removed, soon. # width of the textarea my $cols = 70; # height of the textarea my $rows = 15; # wrap my $wrap = 'NONE'; # style my $text_area_style = 'font-size:11px'; #---------------------------------------------------------------------# #---------------------------------------------------------------------# # DEV - This is NOT the best place to put this, # but I guess we'll leave it here for now... my %list_types = (list => 'Subscribers', black_list => 'Black Listed', moderators => 'Moderators', testers => 'Testers', ); my $type = $q->param('type') || 'list'; $type = 'list' if ! $list_types{$type}; my $type_title = "Subscribers"; $type_title = "Moderators" if $type eq 'moderators'; $type_title = "Black Listed" if $type eq 'black_list'; $type_title = "Testers" if $type eq 'testers'; #---------------------------------------------------------------------# if($ENV{PATH_INFO}){ my $dp = $q->url || $PROGRAM_URL; $dp =~ s/^(http:\/\/|https:\/\/)(.*?)\//\//; my $info = $ENV{PATH_INFO}; $info =~ s/^$dp//; # script name should be something like: # /cgi-bin/dada/mail.cgi $info =~ s/^$ENV{SCRIPT_NAME}//i; $info =~ s/(^\/|\/$)//; #get rid of fore and aft slashes if($info =~ m/css$/){ require DADA::Template::Widgets; print $q->header('text/css'); print DADA::Template::Widgets::screen(-screen => 'default_css.css'); exit; # probably correct in this instance? }elsif($info =~ m/admin$/){ $q->param('f', 'admin'); }elsif($info =~ m/^archive/){ # archive, archive_rss and archive_atom # form: #/archive/justin/20050422012839/ my ($pi_flavor, $pi_list, $pi_id) = split('/', $info); $q->param('flavor', $pi_flavor) if $pi_flavor; $q->param('list', $pi_list) if $pi_list; $q->param('id', $pi_id) if $pi_id; }elsif($info =~ /^smtm/){ $q->param('flavor', 'smtm'); }elsif($info =~ /^spacer_image/){ my ($throwaway, $pi_list, $pi_mid, $bollocks) = split('/', $info); $q->param('flavor', 'm_o_c'); $q->param('list', $pi_list) if $pi_list; $q->param('mid', $pi_mid) if $pi_mid; }elsif($info =~ /^(s|n|u)/){ my ($pi_flavor, $pi_list, $pi_email, $pi_domain, $pi_pin) = split('/', $info); # HACK: If there is no name and a domain, the entire email address is in "email" # and there is no domain. # move all the other variables to the right # This being only the pin, at the moment # 2.10 should have relieved this issue... if($pi_email !~ m/\@/){ $pi_email = $pi_email . '@' . $pi_domain if $pi_domain; }else{ $pi_pin = $pi_domain if !$pi_pin; } $q->param('flavor', $pi_flavor) if $pi_flavor; $q->param('list', $pi_list) if $pi_list; $q->param('email', $pi_email) if $pi_email; $q->param('pin', $pi_pin) if $pi_pin; }elsif($info =~ /^subscriber_help|^list/){ my ($pi_flavor, $pi_list) = split('/', $info); $q->param('flavor', $pi_flavor) if $pi_flavor; $q->param('list', $pi_list) if $pi_list; }elsif($info =~ /^r/){ my ($pi_flavor, $pi_list, $pi_k, $pi_mid, @pi_url) = split('/', $info); my $pi_url; $q->param('flavor', $pi_flavor) if $pi_flavor; $q->param('list', $pi_list) if $pi_list; $q->param('k', $pi_k) if $pi_k; $pi_url = join('/', @pi_url) if $pi_url[0]; $pi_url =~ s/\%3F/?/g; $q->param('url', $pi_url) if $pi_url; $q->param('mid', $pi_mid) if $pi_mid; $q->param('url', 'http://' . $pi_url) if($pi_k eq 'h'); $q->param('url', 'https://' . $pi_url) if($pi_k eq 's'); }else{ if($info){ warn "Path Info present - but not valid? - '" . $ENV{PATH_INFO} . '" - filtered: "' . $info . '"' unless $info =~ m/^\x61\x72\x74/; } } } #---------------------------------------------------------------------# my $flavor = $q->param('flavor'); $flavor = $q->param('f') unless($flavor); my $process = $q->param('process'); my $email = $q->param('email') || ""; $email = $q->param('e') || "" unless($email); my $list = $q->param('list'); $list = $q->param('l') unless($list); my $list_name = $q->param('list_name'); my $pin = $q->param('pin'); $pin = $q->param('p') unless($pin); my $admin_email = $q->param('admin_email'); my $list_owner_email = $q->param('list_owner_email'); my $info = $q->param('info'); my $privacy_policy = $q->param('privacy_policy'); my $physical_address = $q->param('physical_address'); my $password = $q->param('password'); my $retype_password = $q->param('retype_password'); my $keyword = $q->param('keyword'); my @address = $q->param('address'); my $done = $q->param('done'); my $id = $q->param('id'); my $quick = $q->param('quick') || 'no'; my $advanced = $q->param('advanced') || 'no'; my $help = $q->param('help'); my $set_flavor = $q->param('set_flavor'); #---------------------------------------------------------------------# if($email){ $email =~ s/_p40p_/\@/; $email =~ s/_p2Bp_/\+/g; } $list = xss_filter($list); $flavor = xss_filter($flavor); $email = xss_filter($email); $pin = xss_filter($pin); $keyword = xss_filter($keyword); $set_flavor = xss_filter($set_flavor); #external (mostly..) functions called from the web browser) # a few things this program can do.... :) my %Mode = ( 'default' => \&default, 'subscribe' => \&subscribe, 'subscribe_flash_xml' => \&subscribe_flash_xml, 'unsubscribe_flash_xml' => \&unsubscribe_flash_xml, 'new' => \&confirm, 'unsubscribe' => \&unsubscribe, 'admin' => \&admin, 'login' => \&login, 'logout' => \&logout, 'change_login' => \&change_login, 'new_list' => \&new_list, 'change_info' => \&change_info, 'html_code' => \&html_code, 'admin_help' => \&admin_help, 'delete_list' => \&delete_list, 'list_stats' => \&list_stats, 'view_list' => \&view_list, 'view_list_options' => \&view_list_options, 'edit_subscriber' => \&edit_subscriber, 'add' => \&add, 'email_password' => \&email_password, 'add_email' => \&add_email, 'delete_email' => \&delete_email, 'subscription_options' => \&subscription_options, 'send_email' => \&send_email, 'preview_form' => \&preview_form, 'checker' => \&checker, 'edit_template' => \&edit_template, 'view_archive' => \&view_archive, 'display_message_source' => \&display_message_source, 'purge_all_archives' => \&purge_all_archives, 'delete_archive' => \&delete_archive, 'archive' => \&archive, 'archive_bare' => \&archive_bare, 'archive_rss' => \&archive_rss, 'archive_atom' => \&archive_atom, 'all_list_code' => \&all_list_code, 'manage_script' => \&manage_script, 'change_password' => \&change_password, 'text_list' => \&text_list, 'send_list_to_admin' => \&send_list_to_admin, 'search_email' => \&search_email, 'archive_options' => \&archive_options, 'adv_archive_options' => \&adv_archive_options, 'back_link' => \&back_link, 'edit_type' => \&edit_type, 'edit_html_type' => \&edit_html_type, 'list_options' => \&list_options, 'sending_options' => \&sending_options, 'adv_sending_options' => \&adv_sending_options, 'sign_in' => \&sign_in, 'filter_using_black_list' => \&filter_using_black_list, 'search_archive' => \&search_archive, 'send_archive' => \&send_archive, 'list_invite' => \&list_invite, 'pass_gen' => \&pass_gen, 'send_url_email' => \&send_url_email, 'feature_set' => \&feature_set, 'smtp_options' => \&smtp_options, 'checkpop' => \&checkpop, 'author' => \&author, 'list' => \&list_page, 'setup_info' => \&setup_info, 'reset_cipher_keys' => \&reset_cipher_keys, 'restore_lists' => \&restore_lists, 'r' => \&redirection, 'subscriber_help' => \&subscriber_help, 'show_img' => \&show_img, 'file_attachment' => \&file_attachment, 'm_o_c' => \&m_o_c, # these params are the same as above, but are smaller in actual size # this comes into play when you have to create a url using these as parts of it. 's' => \&subscribe, 'n' => \&confirm, 'u' => \&unsubscribe, 'smtm' => \&smtm, 'test_layout' => \&test_layout, 'send_email_testsuite' => \&send_email_testsuite, ); if(!$ENV{GATEWAY_INTERFACE}){ &cl_main(); exit; } sub cl_main { require Getopt::Long; my $test; my $verbose = 0; my $run; my $run_list; Getopt::Long::GetOptions( "run" => \$run, "test" => \$test, "verbose" => \$verbose, "list=s" => \$run_list, ); $verbose = 1 if $test; if($run){ cl_run_schedules( -run_list => $run_list, -test => $test, -verbose => $verbose ); }else{ &default; } } sub cl_run_schedules { require DADA::MailingList::Schedules; my %args = (-run_list => undef, -test => undef, -verbose => undef, @_); my @lists_to_run; $args{-run_list} ? ($lists_to_run[0] = $args{-run_list}) : (@lists_to_run = DADA::App::Guts::available_lists()); foreach(@lists_to_run){ my $mss = DADA::MailingList::Schedules->new(-List => $_); my $report = $mss->run_schedules(-test => $args{-test}); print $report if $args{-verbose}; # prolly good to put in its own little dealy. # logit($report); } } &_chk_env_sys_blk(); # the BIG switcheroo. Mark doesn't like this :) if($flavor){ if(exists($Mode{$flavor})) { $Mode{$flavor}->(); #call the correct subroutine }else{ &default; } }else{ &default; } sub default { user_error(-Error => 'bad_setup') if(DADA::App::Guts::check_setup() == 0); require DADA::MailingList::Settings; my @available_lists = available_lists(-In_Order => 1); if( ($DEFAULT_SCREEN ne '') && ($flavor ne 'default') && ($#available_lists >= 0) ){ print $q->redirect(-uri => $DEFAULT_SCREEN); return; # could we just say, return; ? } if ($available_lists[0]) { print(the_html(-Part => "header", -Title => "Sign Up for a List", -Start_Form => 0, )); require DADA::Template::Widgets; print DADA::Template::Widgets::default_screen(-email => $email, -list => $list, -set_flavor => $set_flavor, ); print ' ' x 200 . $q->a({-href=>"$PROGRAM_URL". '/' . "\x61\x72\x74", -style=>'font-size:1px;color:#FFFFFF'},'i <3 u '); print(the_html(-Part => "footer", -End_Form => 0)); }else{ print(the_html(-Part => "header", -Title => "Welcome to $PROGRAM_NAME", -Start_Form => 0, )); require DADA::Template::Widgets; print DADA::Template::Widgets::screen(-screen => 'congrats_screen.tmpl', -expr => 1, -vars => { -agree => $q->param('agree') }, ); print(the_html(-Part => "footer", -End_Form => 0)); } } sub list_page { if(DADA::App::Guts::check_setup() == 0){ user_error(-Error => 'bad_setup'); } if(check_if_list_exists(-List => $list) == 0){ undef($list); &default; return; } require DADA::MailingList::Settings; my $ls = DADA::MailingList::Settings->new(-List => $list); my $list_info = $ls->get; require DADA::Template::Widgets; print(the_html(-Part => "header", -Title => $list_info->{list_name}, -List => $list, -Start_Form => 0, )); print DADA::Template::Widgets::list_page(-list => $list, -email => $email, -set_flavor => $set_flavor, ); print(the_html(-Part => "footer", -List => $list, -End_Form => 0)); } sub admin { print(the_html(-Part => "header", -Title => "Administration", -Start_Form => 0, )); my $login_widget = $q->param('login_widget') || $LOGIN_WIDGET; require DADA::Template::Widgets; print DADA::Template::Widgets::admin(-login_widget => $login_widget); print(the_html(-Part => "footer", -End_Form => 0)); } sub sign_in { my $list_exists = check_if_list_exists(-List=>$list); if($list_exists >= 1){ my $pretty = pretty($list); print(the_html(-Part => "header", -Title => "Sign In to $pretty", -List => $list, -Start_Form => 0, )); }else{ print(the_html(-Part => "header", -Title => "Sign In", -Start_Form => 0, )); } my @available_lists = available_lists(); require DADA::Template::Widgets; if($list_exists >= 1){ require DADA::MailingList::Settings; my $ls = DADA::MailingList::Settings->new(-List => $list); my $li = $ls->get; print DADA::Template::Widgets::screen(-screen => 'list_login_form.tmpl', -vars => { list => $list, list_name => $li->{list_name}, flavor_sign_in => 1, }, ); }else{ if($LOGIN_WIDGET eq 'popup_menu'){ print DADA::Template::Widgets::list_popup_login_form(); } elsif($LOGIN_WIDGET eq 'text_box') { print DADA::Template::Widgets::screen(-screen => 'text_box_login_form.tmpl'); }else{ warn "'$LOGIN_WIDGET' misconfigured!" } } if($list_exists >= 1){ print(the_html(-Part => "footer", -List => $list, -End_Form => 0, )); }else{ print(the_html(-Part => "footer", -End_Form => 0,)); } } sub send_email { my ($admin_list, $root_login) = check_list_security(-cgi_obj => $q, -Function => 'send_email'); require DADA::MailingList::Settings; $list = $admin_list; my $ls = DADA::MailingList::Settings->new(-List => $list); my $li = $ls->get; my $lh = DADA::MailingList::Subscribers->new(-List => $list); my $text_message_body = ""; my $html_message_body = ""; my $message_subject = ""; # HOWTO: # To make the default message subject on the "Send a List Message" screen # read: "yourlistname" (without the quotes), change the above variable to: # # my $message_subject = $li->{list_name}; # # Want that default message subject to be: "[yourlistname] " instead? # Change the above variable to: # # my $message_subject = '['. $li->{list_name} . '] '; # # Follow the above patterns if you're looking for something else we haven't # thought of. my $at_num = $q->param('at_num') || 1; if(! $process){ my $default_from_header = '"'. escape_for_sending($li->{list_name}) . '" <'.$li->{list_owner_email}.'>'; my $file_upload_widget = ''; my $i = 1; for($i = 1; $i <= $at_num; $i++){ $file_upload_widget .= $q->Tr($q->td([ ($q->p({-align=>'right'},$q->b('Attachment ' . $i . ':'))), ($q->p($q->filefield(-name=>"attachment_$i",-size => 36))) ])); } my $next_num = $at_num+1; my $text_blurb = ""; $text_blurb = "
" if $advanced eq 'yes'; my $html_blurb = ""; $html_blurb = "
" if $advanced eq 'yes'; my $priority_popup_menu = $q->popup_menu(-name =>'Priority', '-values' =>[keys %PRIORITIES], -labels => \%PRIORITIES, -default => $li->{priority}); print(admin_html_header(-Title => "Send a List Message", -List => $li->{list}, -Root_Login => $root_login, -Form => 0, )); require DADA::Template::Widgets; print DADA::Template::Widgets::send_email_screen( -list => $list, -vars => {advanced => $advanced ? $advanced : 0, flavor => $flavor, default_from_header => $default_from_header, message_subject => $message_subject, at_num => $at_num ? $at_num : 0, file_upload_widget => $file_upload_widget, next_num => $next_num, text_blurb => $text_blurb, html_blurb => $html_blurb, cols => $cols, rows => $rows, wrap => $wrap, text_area_style => $text_area_style, text_message_body => $text_message_body, priority_popup_menu => $priority_popup_menu, apply_list_template_to_html_msgs => $li->{apply_list_template_to_html_msgs} ? $li->{apply_list_template_to_html_msgs} : 0, use_restart_mailing_at => $li->{schedule_bulk_mailings} ? 0 : 1, global_list_sending_widget => DADA::Template::Widgets::global_list_sending_checkbox_widget($list), can_use_global_list_sending => $lh->can_use_global_list_sending, }, ); print(admin_html_footer(-List => $list, -Form => 0)); }else{ my $archive_m = $q->param('archive_message') || $li->{archive_messages} || 0; if($advanced eq 'yes'){ if($q->param('archive_message') != 1){ $archive_m = 0; } } require MIME::Lite; $MIME::Lite::PARANOID = $MIME_PARANOID; my $email_format = $q->param('email_format'); my $message_subject = $q->param('message_subject'); my $attachment = $q->param('attachment'); my $text_message_body; $text_message_body = $q->param('text_message_body'); $text_message_body =~ s/\r\n/\n/g if $text_message_body; my $html_message_body; $html_message_body = $q->param('html_message_body'); if($text_message_body){ $html_message_body = $text_message_body if ($email_format eq 'HTML'); } if($text_message_body){ $html_message_body = $text_message_body if ($email_format eq 'PlainText_and_HTML'); } # Added Complexity from the Basic Screen... if($email_format){ if($email_format eq "convert_to_plain_text"){ $text_message_body = convert_to_ascii($text_message_body); $html_message_body = undef; }elsif($email_format eq 'HTML'){ $text_message_body = undef; }elsif($email_format eq 'PlainText_and_HTML'){ $html_message_body = webify_plain_text($html_message_body); } } $html_message_body =~ s/\r\n/\n/g if $html_message_body; # HTML Area kludge. if(defined($html_message_body)){ $html_message_body =~ s/^\n+//o; $html_message_body = undef if $html_message_body =~ m/(^\n
|^
|^
\n)/; } # Got no text kludge... $text_message_body = "\n" if !$html_message_body && !$text_message_body; my $msg; if($html_message_body && $text_message_body){ $msg = MIME::Lite->new(Type => 'multipart/alternative'); $msg->attach(Type => 'text/plain', Data => $text_message_body, Encoding => $li->{plaintext_encoding}, ); $msg->attach(Type => 'text/html', Data => $html_message_body, Encoding => $li->{html_encoding}, ); }elsif($html_message_body){ $msg = MIME::Lite->new( Type => 'text/html', Data => $html_message_body, Encoding => $li->{html_encoding} ); }elsif($text_message_body){ $msg = MIME::Lite->new(Type => 'TEXT', Data => $text_message_body, Encoding => $li->{plaintext_encoding}, ); } my @cleanup_attachments = (); my @attachments = has_attachments(); my @compl_att = (); if(@attachments){ my @compl_att = (); foreach(@attachments){ my ($msg_att, $filename) = make_attachment($_); push(@compl_att, $msg_att) if $msg_att; push(@cleanup_attachments, $filename) if $filename; } if($compl_att[0]){ my $mpm_msg = MIME::Lite->new(Type => 'multipart/mixed'); $mpm_msg->attach($msg); foreach(@compl_att){ $mpm_msg->attach($_); } $msg = $mpm_msg; } } my $msg_as_string = (defined($msg)) ? $msg->as_string : undef; require DADA::App::FormatMessages; my $fm = DADA::App::FormatMessages->new(-List => $list); $fm->Subject($message_subject); $fm->use_list_template($q->param('apply_template')); my ($final_header, $final_body) = $fm->format_headers_and_body(-msg => $msg_as_string ); require DADA::Mail::Send; my $mh = DADA::Mail::Send->new($li); my %headers = $mh->return_headers($final_header); my %mailing = (%headers, Subject => $message_subject, Body => $final_body, ); $mailing{From} = $q->param('From') if($q->param('From')); $mailing{'Errors-To'} = $q->param('Errors_To') if($q->param('Errors_To')); $mailing{'Return-Path'} = $q->param('Return_Path') if($q->param('Return_Path')); $mailing{'Reply-To'} = $q->param('Reply_To') if($q->param('Reply_To')); $mailing{'X-Priority'} = $q->param('Priority') || $li->{priority}; $mailing{Precedence} = $q->param('Precedence') || $li->{precedence}; $mh->bulk_start_email($q->param('Start-Email')); $mh->bulk_start_num($q->param('Start-Num')); # we only want one, we'll take the second one. if($q->param('Start-Email') and $q->param('Start-Num')){ $mh->bulk_start_email(undef); } $mh->bulk_test(1) if($process =~ m/test/i); #$mh->list_type('testers') # if($process =~ m/test/i); my @alt_lists = $q->param('alternative_list'); if($alt_lists[0]){ $mh->also_send_to([@alt_lists]); } my $message_id; if($q->param('archive_no_send') != 1){ # send away $message_id = $mh->bulk_send(%mailing); }else{ # This is currently similar code as what's in the DADA::Mail::Send::_mail_general_headers method... my $msg_id = DADA::App::Guts::message_id(); if($q->param('back_date') == 1){ $msg_id = backdated_msg_id(); } %mailing = ( %mailing, $mh->_make_general_headers, $mh->_make_list_headers ); require DADA::Security::Password; my $ran_number = DADA::Security::Password::generate_rand_string('1234567890'); $mailing{'Message-ID'} = '<' . $msg_id . '.'. $ran_number . '.' . $li->{list_owner_email} . '>'; $message_id = $msg_id; $mh->saved_message($mh->_massaged_for_archive(\%mailing)); } if($message_id){ if(($archive_m == 1) && ($process !~ m/test/i)){ require DADA::MailingList::Archives; my $archive = DADA::MailingList::Archives->new(-List => $li); $archive->set_archive_info($message_id, $message_subject, undef, undef, $mh->saved_message); } } else { $archive_m = 0; } my $screen_text_message = ''; if($text_message_body){ $screen_text_message = $text_message_body; $screen_text_message = webify_plain_text($screen_text_message); $screen_text_message =~ s/\[email\]/$li->{list_owner_email}/gi; my $lm_pin = make_pin(-Email => $li->{list_owner_email}); $screen_text_message =~ s/\[pin\]/$lm_pin/gi; } my $screen_html_message = ''; if($html_message_body){ $screen_html_message = $html_message_body; $screen_html_message =~ s/\[email\]/$li->{list_owner_email}/gi; my $html_lm_pin = make_pin(-Email => $li->{list_owner_email}); $screen_html_message =~ s/\[pin\]/$html_lm_pin/gi; } my $attachment_names = []; foreach(@cleanup_attachments){ my $an = $_; $an =~ s!^.*(\\|\/)!!; if($ATTACHMENT_TEMPFILE == 1){ $an =~ s/^(.*?)_//; } push(@$attachment_names, {name => $an}); } my $have_attachments = ($attachment_names->[0]) ? 1 : 0; if(!$q->param('new_win')){ print(admin_html_header(-Title => "List Message Is Being Sent", -List => $li->{list}, -Root_Login => $root_login )); }else{ print $q->header(); print $q->start_html(-title => 'List Message Is Being Sent', -style => { -src => $PROGRAM_URL . '/css', -code => 'body{text-align:left;margin:5px;padding:5px}' }, ); } require DADA::Template::Widgets; print DADA::Template::Widgets::screen(-screen => 'send_email_process_screen.tmpl', -vars => { process_test => $process =~ m/test/i ? 1 : 0, list_owner_email => $li->{list_owner_email}, start_email => $q->param('Start-Email'), start_num => ($q->param('Start-Num')) ? $q->param('Start-Num') : 0, message_subject => $message_subject, list_name => $li->{list_name}, list_owner_email => $li->{list_owner_email}, text_message_body => $text_message_body, screen_text_message => $screen_text_message, html_message_body => $html_message_body, screen_html_message => $screen_html_message, attachment_names => $attachment_names, have_attachments => $have_attachments, message_archived => (($archive_m == 1) && ($process !~ m/test/i)) ? 1 : 0, message_id => $message_id, archive_no_send => $q->param('archive_no_send'), }, ); if(!$q->param('new_win')){ print(admin_html_footer(-List => $list)); }else{ print ''; print $q->end_html; } clean_up_attachments([@cleanup_attachments]) if $ATTACHMENT_TEMPFILE == 1; } } sub clean_up_attachments { my $files = shift || []; foreach(@$files){ $_ = make_safer($_); warn "could not remove '$_'" unless unlink($_) > 0; # i love the above! } } sub backdated_msg_id { my $backdate_hour = $q->param('backdate_hour'); $backdate_hour = int($backdate_hour) + 12 if $q->param('backdate_hour_label') =~ /p/; # as in, p.m. my $message_id = sprintf("%02d%02d%02d%02d%02d%02d", $q->param('backdate_year'), $q->param('backdate_month'), $q->param('backdate_day'), $backdate_hour, $q->param('backdate_minute'), $q->param('backdate_second') ); return $message_id; } sub has_attachments { my $i = 0; my $at_num = $q->param('at_num') || 1; my $attachment = $q->param('attachment'); my @ive_got = (); return undef if ! $attachment; for($i = 1; $i <= $at_num; $i++){ my $that_attachment = 'filepath_attachment_' . $i; push(@ive_got, $that_attachment) if $q->param($that_attachment); my $this_attachment = 'attachment_' . $i; push(@ive_got, $this_attachment) if $q->param($this_attachment); } return @ive_got; } sub make_attachment { require MIME::Lite; my $name = shift; my $attachment = $q->param($name); my $uploaded_file = ''; return (undef, undef) if !$attachment; my $a_type = find_attachment_type($attachment); my $attach_name = $attachment; $attach_name =~ s!^.*(\\|\/)!!; $attach_name =~ s/\s/%20/g; my %mime_args = ( Type => $a_type, # Id => '<'.$attach_name.'>', Filename => $attach_name, Disposition => make_a_disposition($a_type), ); my $attachment_file; # kinda used only for testing at the moment; if($name =~ m/^filepath_attachment/){ $mime_args{Path} = $attachment; $uploaded_file = $attach_name; }else{ if($ATTACHMENT_TEMPFILE == 1){ # $name is the CGI paramater name - we need to pass that # to keep the CGI object, "magic" my $attachment_file = file_upload($name); $mime_args{Path} = $attachment_file; $uploaded_file = $attachment_file; }else{ $mime_args{FH} = $attachment; $uploaded_file = $attach_name; } } my $msg_att = MIME::Lite->new(%mime_args); $msg_att->attr('Content-Location' => $attach_name); return($msg_att, $uploaded_file); } sub make_a_disposition { my $n = shift; my $disposition = 'inline'; if($n !~ m/image/){ #if($n !~ /text/){ # if they're inline, they get parsed as if # they were a part of Dada Mail... hmm... $disposition = 'attachment'; #} } return $disposition; } sub find_attachment_type { my $filename = shift; my $a_type; my $attach_name = $filename; $attach_name =~ s!^.*(\\|\/)!!; $attach_name =~ s/\s/%20/g; my $file_ending = $attach_name; $file_ending =~ s/.*\.//; require MIME::Types; require MIME::Type; if(($MIME::Types::VERSION >= 1.005) && ($MIME::Type::VERSION >= 1.005)){ my ($mimetype, $encoding) = MIME::Types::by_suffix($filename); $a_type = $mimetype if ($mimetype && $mimetype =~ /^\S+\/\S+$/); ### sanity check }else{ if(exists($MIME_TYPES{'.'.lc($file_ending)})) { $a_type = $MIME_TYPES{'.'.lc($file_ending)}; }else{ $a_type = $DEFAULT_MIME_TYPE; } } if(!$a_type){ warn "attachment MIME Type never figured out, letting MIME::Lite handle this..."; $a_type = 'AUTO'; } return $a_type; } sub list_invite { my ($admin_list, $root_login) = check_list_security(-cgi_obj => $q, -Function => 'list_invite'); $list = $admin_list; require DADA::MailingList::Settings; my $ls = DADA::MailingList::Settings->new(-List => $list); my $li = $ls->get; my $lh = DADA::MailingList::Subscribers->new(-List => $list); if(!$process){ print(admin_html_header(-Title => "Invitations", -List => $list, -Root_Login => $root_login)); require DADA::Template::Widgets; print DADA::Template::Widgets::screen(-screen => 'list_invite_screen.tmpl', -vars => { invite_message_subject => $li->{invite_message_subject}, invite_message_text => $li->{invite_message_text}, invite_message_html => $li->{invite_message_html}, }, ); print(admin_html_footer(-List => $list)); }else{ # get the emails my $new_emails = $q -> param("new_emails"); # split them into individual entities my @new_addresses = split(/\s+|,|;|\n+/, $new_emails); my ($subscribed, $not_subscribed, $black_listed, $invalid) = $lh->filter_subscribers(-Email_Ref => [@new_addresses]); # add these to a special 'invitation' list. we'll clear this list later. my $new_email_count=$lh->add_to_email_list(-Email_Ref => $not_subscribed, -List => $list, -Type => 'invitelist', -Mode => 'writeover'); my $message_subject = $q->param('message_subject'); my $text_message_body = DADA::App::Guts::strip($q->param('text_message_body')) || undef; $text_message_body =~ s(/^\n+|\n+$)()g; if($text_message_body){ $text_message_body =~ s/\r\n/\n/g; } my $html_message_body = DADA::App::Guts::strip($q->param('html_message_body')) || undef; $html_message_body =~ s(/^\n+|\n+$)()g; if($html_message_body){ $html_message_body =~ s/\r\n/\n/g; } require MIME::Lite; $MIME::Lite::PARANOID = $MIME_PARANOID; my $msg; if($text_message_body and $html_message_body){ $msg = MIME::Lite->new(Type => 'multipart/alternative'); $msg->attach(Type => 'TEXT', Data => $text_message_body); $msg->attach(Type => 'text/html', Data => $html_message_body); }elsif($html_message_body){ # make only a text body $msg = MIME::Lite->new(Type => 'text/html', Data => $html_message_body); }else{ $msg = MIME::Lite->new(Type => 'TEXT', Data => $text_message_body); } $msg->replace('X-Mailer' =>""); my $msg_as_string = (defined($msg)) ? $msg->as_string : undef; require DADA::App::FormatMessages; my $fm = DADA::App::FormatMessages->new(-List => $list); $fm->Subject($message_subject); $fm->use_email_templates(0); my ($header_glob, $message_string) = $fm->format_headers_and_body(-msg => $msg_as_string ); require DADA::Mail::Send; my $mh = DADA::Mail::Send->new($li); # translate the glob into a hash my %headers = $mh->return_headers($header_glob); $mh->list_type('invitelist'); $mh->bulk_test(1) if($process =~ m/test/i); #$mh->list_type('testers') # if($process =~ m/test/i); $mh->bulk_send( %headers, To => '"'. escape_for_sending($li->{list_name}) .'" <'. $li->{list_owner_email} .'>', From => '"'. escape_for_sending($li->{list_name}) .'" <'. $li->{list_owner_email} .'>', Subject => $message_subject, Body => $message_string ); my $screen_text_message; if($text_message_body){ $screen_text_message = $text_message_body; $screen_text_message = webify_plain_text($screen_text_message); $screen_text_message =~ s/\[email\]/$li->{list_owner_email}/gi; my $lm_pin = make_pin(-Email => $li->{list_owner_email}); $screen_text_message =~ s/\[pin\]/$lm_pin/gi; } my $screen_html_message; if($html_message_body){ $screen_html_message = $html_message_body; $screen_html_message =~ s/\[email\]/$li->{list_owner_email}/gi; my $html_lm_pin = make_pin(-Email => $li->{list_owner_email}); $screen_html_message =~ s/\[pin\]/$html_lm_pin/gi; } $new_email_count = int($new_email_count); if(!$q->param('new_win')){ print(admin_html_header(-Title => "Invitations Sent", -List => $li->{list}, -Root_Login => $root_login)); }else{ print $q->header(); print $q->start_html(-title => 'Invitations Sent', -style => { -src => $PROGRAM_URL . '/css', -code => 'body{text-align:left;margin:5px;padding:5px}' }, ); } require DADA::Template::Widgets; print DADA::Template::Widgets::screen(-screen => 'list_invite_process_screen.tmpl', -vars => { process_test => ($process =~ m/test/i) ? 1 : 0, list_owner_email => $li->{list_owner_email}, new_email_count => $new_email_count, message_subject => $message_subject, text_message_body => $text_message_body, screen_text_message => $screen_text_message, html_message_body => $html_message_body, screen_html_message => $screen_html_message, }, ); if(!$q->param('new_win')){ print(admin_html_footer(-List => $list)); }else{ print ''; print $q->end_html; } if(defined($q->param('save_invite_messages')) && $q->param('save_invite_messages') == 1){ my $p_text_message_body = $q->param('text_message_body'); $p_text_message_body =~ s/\r\n/\n/g; my $p_html_message_body = $q->param('html_message_body'); $p_html_message_body =~ s/\r\n/\n/g; $ls->save({ invite_message_text => $p_text_message_body, invite_message_html => $p_html_message_body, invite_message_subject => $q->param('message_subject'), }); } } } sub send_url_email { my ($admin_list, $root_login) = check_list_security(-cgi_obj => $q, -Function => 'send_url_email'); my $list = $admin_list; require DADA::MailingList::Settings; my $ls = DADA::MailingList::Settings->new(-List => $list); my $li = $ls->get; require DADA::MailingList::Archives; my $la = DADA::MailingList::Archives->new(-List => $li); my $lh = DADA::MailingList::Subscribers->new(-List => $list); my $can_use_mime_lite_html = 0; eval { require MIME::Lite::HTML }; if(!$@){ $can_use_mime_lite_html = 1; } if(!$process){ print(admin_html_header( -Title => "Send a Webpage", -List => $list, -Root_Login => $root_login, -Form => 0, )); require DADA::Template::Widgets; print DADA::Template::Widgets::screen(-screen => 'send_url_email_screen.tmpl', -list => $list, -vars => { can_use_mime_lite_html => $can_use_mime_lite_html, SERVER_ADMIN => $ENV{SERVER_ADMIN}, list_name => $li->{list_name}, cols => $cols, rows => $rows, wrap => $wrap, text_area_style => $text_area_style, global_list_sending_widget => DADA::Template::Widgets::global_list_sending_checkbox_widget($list), can_use_global_list_sending => $lh->can_use_global_list_sending, archive_messages => $li->{archive_messages}, cols => $cols, rows => $rows, wrap => $wrap, text_area_style => $text_area_style, can_display_attachments => $la->can_display_attachments, }, ); print(admin_html_footer(-List => $list, -Form => 0, )); }else{ if($can_use_mime_lite_html){ my $url_options = $q->param('url_options') || undef; my $login_details; if(defined($q->param('url_username')) && defined($q->param('url_password'))){ $login_details = $q->param('url_username') . ':' . $q->param('url_password') } my $proxy = defined($q->param('proxy')) ? $q->param('proxy') : undef; my $mailHTML = new MIME::Lite::HTML('IncludeType' => $url_options, 'TextCharset' => $li->{charset_value}, 'HTMLCharset' => $li->{charset_value}, (($login_details) ? (LoginDetails => $login_details,) : ()), HTMLEncoding => $li->{plaintext_encoding}, TextEncoding => $li->{html_encoding}, (($proxy) ? (Proxy => $proxy,) : ()), #'Debug' => "1", ); my $t = $q->param('text_message_body') || 'This email message requires that your mail reader support HTML'; if($q->param('auto_create_plaintext') == 1){ if($q->param('content_from') eq 'url'){ require LWP::Simple; my $good_try = LWP::Simple::get($q->param('url')); $t = convert_to_ascii($good_try); }else{ $t = convert_to_ascii($q->param('html_message_body')); } } my $MIMELiteObj; if($q->param('content_from') eq 'url'){ $MIMELiteObj = $mailHTML->parse($q->param('url'), $t); }else{ $MIMELiteObj = $mailHTML->parse($q->param('html_message_body'), $t); } require DADA::App::FormatMessages; my $fm = DADA::App::FormatMessages->new(-List => $list); $fm->Subject($q->param('message_subject')); my $problems = 0; my $rm = ''; eval { $rm = $MIMELiteObj->as_string; }; if($@){ warn "$PROGRAM_NAME $VER - Send a Webpage isn't functioning correctly? - $!"; $problems++; } my $message_id; if(!$problems){ my ($header_glob, $template) = $fm->format_headers_and_body(-msg => $rm); require DADA::Mail::Send; my $mh = DADA::Mail::Send->new($li); my %headers = $mh->return_headers($header_glob); my %mailing = (%headers, Subject => $q->param('message_subject'), Body => $template, ); $mh->bulk_test(1) if($q->param('process') =~ m/test/i); #$mh->list_type('testers') # if($q->param('process') =~ m/test/i); my @alt_lists = $q->param('alternative_list'); if($alt_lists[0]){ $mh->also_send_to([@alt_lists]); } if($q->param('archive_no_send') != 1){ # Woo Ha! Send away! $message_id = $mh->bulk_send(%mailing); }else{ # This is currently similar code as what's in the DADA::Mail::Send::_mail_general_headers method... my $msg_id = DADA::App::Guts::message_id(); if($q->param('back_date') == 1){ $msg_id = backdated_msg_id(); } # time + random number + sender, woot! require DADA::Security::Password; my $ran_number = DADA::Security::Password::generate_rand_string('1234567890'); %mailing = $mh->clean_headers(%mailing); %mailing = ( %mailing, $mh->_make_general_headers, $mh->_make_list_headers ); $mailing{'Message-ID'} = '<' . $msg_id . '.'. $ran_number . '.' . $li->{list_owner_email} . '>'; $message_id = $msg_id; $mh->saved_message($mh->_massaged_for_archive(\%mailing)); } if(($li->{archive_messages} != 0) && ($q->param('process') !~ m/test/i)){ require DADA::MailingList::Archives; my $archive = DADA::MailingList::Archives->new(-List => $li); $archive->set_archive_info($message_id, $q->param('message_subject'), undef, undef, $mh->saved_message); } } if(!$q->param('new_win')){ print(admin_html_header(-Title => "List Message Is Being Sent", -List => $list, -Root_Login => $root_login)); }else{ print $q->header(); print $q->start_html(-title => 'List Message Is Being Sent', -style => { -src => $PROGRAM_URL . '/css', -code => 'body{text-align:left;margin:5px;padding:5px}' }, ); } require DADA::Template::Widgets; print DADA::Template::Widgets::screen(-screen => 'send_url_email_process_screen.tmpl', -vars => { test => $process =~ m/test/i ? 1 : 0, list_owner_email => $li->{list_owner_email}, message_id => $message_id, archived => (($li->{archive_messages} ne "0") && ($q->param('process') !~ m/test/i)) ? 1 : 0, problems => $problems, archive_no_send => $q->param('archive_no_send'), }, ); if(!$q->param('new_win')){ print(admin_html_footer(-List => $list)); }else{ print ''; print $q->end_html; } }else{ die "$PROGRAM_NAME $VER Error: $!\n"; } } } sub change_info { my ($admin_list, $root_login) = check_list_security(-cgi_obj => $q, -Function => 'change_info'); $list = $admin_list; require DADA::MailingList::Settings; my $ls = DADA::MailingList::Settings->new(-List => $list); my $li = $ls->get; my $errors = 0; my $flags = {}; if($process){ ($errors, $flags) = check_list_setup(-fields => { list => $list, list_name => $list_name, list_owner_email => $list_owner_email, admin_email => $admin_email, privacy_policy => $privacy_policy, info => $info, physical_address => $physical_address, }, -new_list => 'no', ); } undef $process if $errors >= 1; if(!$process){ my $err_word = 'was'; $err_word = 'were' if $errors && $errors > 1; my $errors_ending = ''; $errors_ending = 's' if $errors && $errors > 1; my $flags_list_name = $flags->{list_name} || 0; my $flags_list_name_bad_characters = $flags->{list_name_bad_characters} || 0; my $flags_invalid_list_owner_email = $flags->{invalid_list_owner_email} || 0; my $flags_list_info = $flags->{list_info} || 0; my $flags_privacy_policy = $flags->{privacy_policy} || 0; my $flags_physical_address = $flags->{physical_address} || 0; print(admin_html_header(-Title => "Change List Information", -List => $list, -Root_Login => $root_login)); require DADA::Template::Widgets; print DADA::Template::Widgets::screen(-screen => 'change_info_screen.tmpl', -vars => { done => $done, errors => $errors, errors_ending => $errors_ending, err_word => $err_word, list => $list, list_name => $list_name ? $list_name : $li->{list_name}, list_owner_email => $list_owner_email ? $list_owner_email : $li->{list_owner_email}, admin_email => $admin_email ? $admin_email : $li->{admin_email}, info => $info ? $info : $li->{info}, privacy_policy => $privacy_policy ? $privacy_policy : $li->{privacy_policy}, physical_address => $physical_address ? $physical_address : $li->{physical_address}, flags_list_name => $flags_list_name, flags_invalid_list_owner_email => $flags_invalid_list_owner_email, flags_list_info => $flags_list_info, flags_privacy_policy => $flags_privacy_policy, flags_physical_address => $flags_physical_address, flags_list_name_bad_characters => $flags_list_name_bad_characters, }, ); print(admin_html_footer(-List => $list)); }else{ $admin_email = $list_owner_email unless defined($admin_email); $ls->save({ list_owner_email => strip($list_owner_email), admin_email => strip($admin_email), list_name => $list_name, info => $info, privacy_policy => $privacy_policy, physical_address => $physical_address, }); print $q->redirect(-uri => $S_PROGRAM_URL . '?flavor=change_info&done=1'); } } sub change_password { my ($admin_list, $root_login) = check_list_security(-cgi_obj => $q, -Function => 'change_password', ); $list = $admin_list; require DADA::Security::Password; require DADA::MailingList::Settings; my $ls = DADA::MailingList::Settings->new(-List => $list); my $li = $ls->get; if(!$process) { print(admin_html_header(-Title => "Change List Password", -List => $list, -Root_Login => $root_login)); require DADA::Template::Widgets; print DADA::Template::Widgets::screen(-screen => 'change_password_screen.tmpl', -list => $list, -vars => { root_login => $root_login, }, ); print admin_html_footer(-List => $list); }else{ my $old_password = $q->param('old_password'); my $new_password = $q->param('new_password'); my $again_new_password = $q->param('again_new_password'); if($root_login != 1){ my $password_check = DADA::Security::Password::check_password($li->{password},$old_password); if ($password_check != 1) { user_error(-List => $list, -Error => "invalid_password"); } } $new_password = strip($new_password); $again_new_password = strip($again_new_password); if ( ($new_password ne $again_new_password) || ($new_password eq "") ){ user_error(-List => $list, -Error => "pass_no_match"); } $ls->save({ password => DADA::Security::Password::encrypt_passwd($new_password), }); print $q->redirect(-uri => $S_PROGRAM_URL . '?flavor=admin'); } } sub delete_list { my ($admin_list, $root_login) = check_list_security(-cgi_obj => $q, -Function => 'delete_list'); my $list = $admin_list; my $ls = DADA::MailingList::Settings->new(-List => $list); my $li = $ls->get; if(!$process){ print(admin_html_header( -Title => "Confirm Delete List", -List => $list, -Root_Login => $root_login)); require DADA::Template::Widgets; print DADA::Template::Widgets::screen(-screen => 'delete_list_screen.tmpl', -list => $list,); print(admin_html_footer(-List => $list)); }else{ require DADA::MailingList::Archives; my $la = DADA::MailingList::Archives->new(-List => $li); my $lh = DADA::MailingList::Subscribers->new(-List => $list); if($q->param('delete_backups') == 1){ $ls->removeAllBackups(); $la->removeAllBackups(1); } #mostly for the SQL backends $lh->remove_this_listtype('list'); $lh->remove_this_listtype('blacklist'); $lh->remove_this_listtype('invitelist'); delete_email_list(-List => $list); delete_email_list(-List => $list, -Type => 'black_list'); delete_email_list(-List => $list, -Type => 'invitelist'); delete_list_info( -List => $list); $la->delete_all_archive_entries(); delete_list_template( -List => $list); require DADA::Logging::Usage; my $log = new DADA::Logging::Usage; $log->mj_log($list, 'List Removed', "remote_host:$ENV{REMOTE_HOST}, ip_address:$ENV{REMOTE_ADDR}") if $LOG{list_lives}; print(the_html(-Part => 'header', -Title => "Deletion Successful")); require DADA::Template::Widgets; print DADA::Template::Widgets::screen(-screen => 'delete_list_success_screen.tmpl', -list => $list, ); print(the_html(-Part => 'footer')); } } sub list_options { my ($admin_list, $root_login) = check_list_security(-cgi_obj => $q, -Function => 'list_options'); $list = $admin_list; #receive a few variables.. my $closed_list = $q->param("closed_list") || 0; my $hide_list = $q->param("hide_list") || 0; my $get_sub_notice = $q->param("get_sub_notice") || 0; my $get_unsub_notice = $q->param("get_unsub_notice") || 0; my $no_confirm_email = $q->param("no_confirm_email") || 0; my $unsub_confirm_email = $q->param("unsub_confirm_email") || 0; my $send_unsub_success_email = $q->param("send_unsub_success_email") || 0; my $send_sub_success_email = $q->param("send_sub_success_email") || 0; my $mx_check = $q->param("mx_check") || 0; my $use_alt_url_sub_confirm_success = $q->param("use_alt_url_sub_confirm_success") || 0; my $alt_url_sub_confirm_success = $q->param( "alt_url_sub_confirm_success") || ''; my $use_alt_url_sub_confirm_failed = $q->param("use_alt_url_sub_confirm_failed") || 0; my $alt_url_sub_confirm_failed = $q->param( "alt_url_sub_confirm_failed") || ''; my $use_alt_url_sub_success = $q->param("use_alt_url_sub_success") || 0; my $alt_url_sub_success = $q->param( "alt_url_sub_success") || ''; my $use_alt_url_sub_failed = $q->param("use_alt_url_sub_failed") || 0; my $alt_url_sub_failed = $q->param( "alt_url_sub_failed") || ''; my $use_alt_url_unsub_confirm_success = $q->param("use_alt_url_unsub_confirm_success") || 0; my $alt_url_unsub_confirm_success = $q->param( "alt_url_unsub_confirm_success") || ''; my $use_alt_url_unsub_confirm_failed = $q->param("use_alt_url_unsub_confirm_failed") || 0; my $alt_url_unsub_confirm_failed = $q->param( "alt_url_unsub_confirm_failed") || ''; my $use_alt_url_unsub_success = $q->param("use_alt_url_unsub_success") || 0; my $alt_url_unsub_success = $q->param( "alt_url_unsub_success") || ''; my $use_alt_url_unsub_failed = $q->param("use_alt_url_unsub_failed") || 0; my $alt_url_unsub_failed = $q->param( "alt_url_unsub_failed") || ''; require DADA::MailingList::Settings; my $ls = DADA::MailingList::Settings->new(-List => $list); my $li = $ls->get(); my $can_use_mx_lookup = 0; eval { require Net::DNS; }; if(!$@){ $can_use_mx_lookup = 1; } if(!$process){ $list = $admin_list; print(admin_html_header( -Title => "Mailing List Options", -List => $list, -Root_Login => $root_login )); require DADA::Template::Widgets; print DADA::Template::Widgets::screen(-screen => 'list_options_screen.tmpl', -list => $list, -vars => { done => $done, can_use_mx_lookup => $can_use_mx_lookup, %{$li}, }); print(admin_html_footer(-List => $list)); }else{ $list = $admin_list; $ls->save({ hide_list => $hide_list, closed_list => $closed_list, get_sub_notice => $get_sub_notice, get_unsub_notice => $get_unsub_notice, no_confirm_email => $no_confirm_email, unsub_confirm_email => $unsub_confirm_email, send_unsub_success_email => $send_unsub_success_email, send_sub_success_email => $send_sub_success_email, mx_check => $mx_check, use_alt_url_sub_confirm_success => $use_alt_url_sub_confirm_success, alt_url_sub_confirm_success => $alt_url_sub_confirm_success, use_alt_url_sub_confirm_failed => $use_alt_url_sub_confirm_failed, alt_url_sub_confirm_failed => $alt_url_sub_confirm_failed, use_alt_url_sub_success => $use_alt_url_sub_success, alt_url_sub_success => $alt_url_sub_success, use_alt_url_sub_failed => $use_alt_url_sub_failed, alt_url_sub_failed => $alt_url_sub_failed, use_alt_url_unsub_confirm_success => $use_alt_url_unsub_confirm_success, alt_url_unsub_confirm_success => $alt_url_unsub_confirm_success, use_alt_url_unsub_confirm_failed => $use_alt_url_unsub_confirm_failed, alt_url_unsub_confirm_failed => $alt_url_unsub_confirm_failed, use_alt_url_unsub_success => $use_alt_url_unsub_success, alt_url_unsub_success => $alt_url_unsub_success, use_alt_url_unsub_failed => $use_alt_url_unsub_failed, alt_url_unsub_failed => $alt_url_unsub_failed, }); print $q->redirect(-uri=>$S_PROGRAM_URL . '?flavor=list_options&done=1'); } } sub sending_options { my ($admin_list, $root_login) = check_list_security(-cgi_obj => $q, -Function => 'sending_options'); $list = $admin_list; require DADA::MailingList::Settings; my $ls = DADA::MailingList::Settings->new(-List => $list); my $li = $ls->get; # TO DO: Make a guesstimate on how long a message will take to send. #my $lh = DADA::MailingList::Subscribers->new(-List => $list); # #my $num_subscribers = $lh->num_subscribers(-Type => 'list'); if(!$process){ my @message_amount = (1..25, 30, 40, 50, 60, 70, 80, 90, 100, 150, 200, 250, 300, 350, 400, 450, 500, 1000, 1500, 2000, 4000, 6000, 8000, 10000); unshift(@message_amount, $li->{bulk_send_amount}) if exists($li->{bulk_send_amount}); my @message_wait = (1..60); eval { require Time::HiRes }; if(!$@){ unshift(@message_wait, .01, .02, .03, .04, .05, .06, .07, .08, .09, .1, .2, .3, .4, .5, .6, .7, .8, .9,); } unshift(@message_wait, $li->{bulk_send_seconds}) if exists($li->{bulk_send_seconds}); my @message_label = (1, 60, 3600); my %label_label = (1 => 'second(s)', 60 => 'minute(s)', 3600 => 'hour(s)', 86400 => 'day(s)', ); unshift(@message_label, $li->{bulk_send_seconds_label}) if exists($li->{bulk_send_seconds_label}); my $bulk_send_amount_menu = $q->popup_menu(-name => "bulk_send_amount", -value => [@message_amount], ); my $bulk_send_seconds_menu = $q->popup_menu(-name => "bulk_send_seconds", -value => [@message_wait], ); my $bulk_send_seconds_label = $q->popup_menu(-name => "bulk_send_seconds_label", -value => [@message_label], -labels => \%label_label, ); my $no_smtp_server_set = 0; $no_smtp_server_set = 1 if(!$li->{smtp_server}) && $li->{send_via_smtp} && ($li->{send_via_smtp} == 1); my $perl_needs_updating = 0; $perl_needs_updating = 1 if $] < 5.006; my $batch_notification_every_n_widget = $q->popup_menu(-name => 'batch_notification_every_n', -value => [@message_amount], -default => $li->{batch_notification_every_n}, ); print(admin_html_header( -Title => "Sending Options", -List => $list, -Root_Login => $root_login)); require DADA::Template::Widgets; print DADA::Template::Widgets::screen(-screen => 'sending_options_screen.tmpl', -vars => { done => $done, send_via_smtp => $li->{send_via_smtp}, enable_bulk_batching => $li->{enable_bulk_batching}, get_batch_notification => $li->{get_batch_notification}, get_finished_notification => $li->{get_finished_notification}, no_smtp_server_set => $no_smtp_server_set, perl_version => $], perl_needs_updating => $perl_needs_updating, bulk_send_amount_menu => $bulk_send_amount_menu, bulk_send_seconds_menu => $bulk_send_seconds_menu, bulk_send_seconds_label => $bulk_send_seconds_label, batch_notification_every_n_widget => $batch_notification_every_n_widget, }, ); print(admin_html_footer(-List => $list)); }else{ my $bulk_send_amount = $q->param("bulk_send_amount"); my $bulk_send_seconds = $q->param("bulk_send_seconds"); my $bulk_send_seconds_label = $q->param("bulk_send_seconds_label"); my $precedence = $q->param('precedence'); my $charset = $q->param('charset'); my $content_type = $q->param('content_type'); my $enable_bulk_batching = $q->param("enable_bulk_batching") || 0; my $get_batch_notification = $q->param("get_batch_notification") || 0; my $get_finished_notification = $q->param("get_finished_notification") || 0; my $send_via_smtp = $q->param("send_via_smtp") || 0; my $batch_notification_every_n = $q->param('batch_notification_every_n') || 0; my $bulk_sleep_amount = $bulk_send_seconds * $bulk_send_seconds_label; $ls->save({ bulk_send_amount => $bulk_send_amount, bulk_send_seconds => $bulk_send_seconds, bulk_send_seconds_label => $bulk_send_seconds_label, enable_bulk_batching => $enable_bulk_batching, bulk_sleep_amount => $bulk_sleep_amount, get_batch_notification => $get_batch_notification, get_finished_notification => $get_finished_notification, send_via_smtp => $send_via_smtp, batch_notification_every_n => $batch_notification_every_n, }); print $q->redirect(-uri => $S_PROGRAM_URL . '?flavor=sending_options&done=1'); } } sub adv_sending_options { my ($admin_list, $root_login) = check_list_security(-cgi_obj => $q, -Function => 'sending_options'); $list = $admin_list; require DADA::MailingList::Settings; my $ls = DADA::MailingList::Settings->new(-List => $list) ; my $li = $ls->get; if(!$process){ unshift(@CHARSETS, $li->{charset}); my $precedence_popup_menu = $q->popup_menu(-name => "precedence", -value => [@PRECEDENCES], -default => $li->{precedence}, ); my $priority_popup_menu = $q->popup_menu(-name => "priority", -value => [keys %PRIORITIES], -labels => \%PRIORITIES, -default => $li->{priority}, ); my $charset_popup_menu = $q->popup_menu(-name => 'charset', -value => [@CHARSETS], ); my $plaintext_encoding_popup_menu = $q->popup_menu( -name => 'plaintext_encoding', -value => [@CONTENT_TRANSFER_ENCODINGS], -default => $li->{plaintext_encoding}, ); my $html_encoding_popup_menu = $q->popup_menu(-name => 'html_encoding', -value => [@CONTENT_TRANSFER_ENCODINGS], -default => $li->{html_encoding}, ); # my $content_type_popup_menu = $q->popup_menu(-name => 'content_type', # -value => [@CONTENT_TYPES], # -default => $li->{content_type}, # ); my $can_use_storable = 1; eval { require Storable }; $can_use_storable = 0 if $@; my $wrong_uid = 0; $wrong_uid = 1 if $< != $>; print(admin_html_header(-Title => "Advanced Sending Options", -List => $list, -Root_Login => $root_login)); require DADA::Template::Widgets; print DADA::Template::Widgets::screen(-screen => 'adv_sending_options_screen.tmpl', -list => $list, -vars => { done => $done, precedence_popup_menu => $precedence_popup_menu, priority_popup_menu => $priority_popup_menu, charset_popup_menu => $charset_popup_menu, plaintext_encoding_popup_menu => $plaintext_encoding_popup_menu, html_encoding_popup_menu => $html_encoding_popup_menu, #content_type_popup_menu => $content_type_popup_menu, strip_message_headers => $li->{strip_message_headers}, print_list_headers => $li->{print_list_headers}, add_sendmail_f_flag => $li->{add_sendmail_f_flag}, f_flag_settings => $MAIL_SETTINGS . ' -f' . $li->{admin_email}, wrong_uid => $wrong_uid, print_errors_to_header => $li->{print_errors_to_header}, print_return_path_header => $li->{print_return_path_header}, use_habeas_headers => $li->{use_habeas_headers}, verp_return_path => $li->{verp_return_path}, schedule_bulk_mailings => $li->{schedule_bulk_mailings}, can_use_storable => $can_use_storable, }); print(admin_html_footer(-List => $list)); }else{ my $precedence = $q->param('precedence'); my $priority = $q->param('priority'); my $charset = $q->param('charset'); my $plaintext_encoding = $q->param('plaintext_encoding'); my $html_encoding = $q->param('html_encoding'); #my $content_type = $q->param('content_type'); my $strip_message_headers = $q->param('strip_message_headers') || 0; my $add_sendmail_f_flag = $q->param('add_sendmail_f_flag') || 0; my $print_return_path_header = $q->param('print_return_path_header') || 0; my $print_errors_to_header = $q->param('print_errors_to_header') || 0; my $print_list_headers = $q->param('print_list_headers') || 0; my $verp_return_path = $q->param('verp_return_path') || 0; my $schedule_bulk_mailings = $q->param('schedule_bulk_mailings') || 0; my $use_habeas_headers = $q->param('use_habeas_headers') || 0; $ls->save({list => $list, precedence => $precedence, priority => $priority, charset => $charset, #content_type => $content_type, strip_message_headers => $strip_message_headers, add_sendmail_f_flag => $add_sendmail_f_flag, print_list_headers => $print_list_headers, print_return_path_header => $print_return_path_header, print_errors_to_header => $print_errors_to_header, plaintext_encoding => $plaintext_encoding, html_encoding => $html_encoding, verp_return_path => $verp_return_path, schedule_bulk_mailings => $schedule_bulk_mailings, use_habeas_headers => $use_habeas_headers, }); print $q->redirect(-uri=>$S_PROGRAM_URL . '?flavor=adv_sending_options&done=1'); } } sub smtp_options { my ($admin_list, $root_login) = check_list_security(-cgi_obj => $q, -Function => 'smtp_options'); my $sasl_report = ''; if($process =~ m/sasl/i){ $sasl_report = check_smtp_sasl($admin_list); $process = undef; } $list = $admin_list; require DADA::MailingList::Settings; my $ls = DADA::MailingList::Settings->new(-List => $list); my $li = $ls->get; require DADA::Security::Password; my $decrypted_sasl_pass = DADA::Security::Password::cipher_decrypt($li->{cipher_key}, $li->{sasl_smtp_password}); my $decrypted_pop3_pass = DADA::Security::Password::cipher_decrypt($li->{cipher_key}, $li->{pop3_password}); if(!$process){ print(admin_html_header( -Title => "SMTP Sending Options", -List => $li->{list}, -Root_Login => $root_login)); require DADA::Template::Widgets; print DADA::Template::Widgets::screen(-list => $list, -screen => 'smtp_options_screen.tmpl', -vars => { done => $done, smtp_server => $li->{smtp_server}, smtp_port => $li->{smtp_port}, smtp_connect_tries => $li->{smtp_connect_tries}, use_sasl_smtp_auth => $q->param('use_sasl_smtp_auth') ? $q->param('use_sasl_smtp_auth') : $li->{use_sasl_smtp_auth}, sasl_smtp_username => $q->param('sasl_smtp_username') ? $q->param('sasl_smtp_username') : $li->{sasl_smtp_username}, decrypted_sasl_pass => $q->param('pop3_password') ? $q->param('pop3_password') : $decrypted_sasl_pass, smtp_max_messages_per_connection => $li->{smtp_max_messages_per_connection}, use_pop_before_smtp => $li->{use_pop_before_smtp}, pop3_server => $li->{pop3_server}, pop3_username => $li->{pop3_username}, decrypted_pop3_pass => $decrypted_pop3_pass, set_smtp_sender => $li->{set_smtp_sender}, admin_email => $li->{admin_email}, sasl_report => $sasl_report, }, ); print(admin_html_footer(-List => $list)); }else{ my $use_pop_before_smtp = $q->param('use_pop_before_smtp') || 0; my $set_smtp_sender = $q->param('set_smtp_sender') || 0; my $smtp_server = strip($q->param('smtp_server')); my $pop3_server = strip($q->param('pop3_server')); my $pop3_username = strip($q->param('pop3_username')); my $pop3_password = strip($q->param('pop3_password')); my $use_sasl_smtp_auth = $q->param('use_sasl_smtp_auth') || 0; my $sasl_smtp_username = strip($q->param('sasl_smtp_username')); my $sasl_smtp_password = strip($q->param('sasl_smtp_password')); my $smtp_max_messages_per_connection = strip($q->param('smtp_max_messages_per_connection')) || undef; $ls->save({ smtp_port => $q->param('smtp_port'), smtp_connect_tries => $q->param('smtp_connect_tries'), use_pop_before_smtp => $use_pop_before_smtp, smtp_server => $smtp_server, pop3_server => $pop3_server, pop3_username => $pop3_username, pop3_password => DADA::Security::Password::cipher_encrypt($li->{cipher_key}, $pop3_password), use_sasl_smtp_auth => $use_sasl_smtp_auth, sasl_smtp_username => $sasl_smtp_username, sasl_smtp_password => DADA::Security::Password::cipher_encrypt($li->{cipher_key}, $sasl_smtp_password), set_smtp_sender => $set_smtp_sender, smtp_max_messages_per_connection => $smtp_max_messages_per_connection, }); print $q->redirect(-uri => $S_PROGRAM_URL . '?flavor=smtp_options&done=1'); } } sub checkpop { my ($admin_list, $root_login) = check_list_security(-cgi_obj => $q, -Function => 'smtp_options'); $list = $admin_list; require DADA::Security::Password; my $user = $q->param('user'); my $pass = $q->param('pass'); my $server = $q->param('server'); require DADA::MailingList::Settings; my $ls = DADA::MailingList::Settings->new(-List => $list); my $li = $ls->get; require DADA::Mail::Send; my $mh = DADA::Mail::Send->new($li); my $pop_status; if(!$user || !$pass || !$server){ $pop_status = undef; }else{ $pop_status = $mh->_pop_before_smtp(-pop3_server => $server, -pop3_username => $user, -pop3_password => $pass); } print $q->header(); if(defined($pop_status)){ print $q->h2("Success!"); print $q->p($q->b("POP-before-SMTP authentication was successful")); print $q->p($q->b("Make sure to 'Save Changes' to have your edits take affect.")); }else{ print $q->h2("Warning!"); print $q->p($q->b('POP-before-SMTP authentication was ',$q->i('unsuccessful'),)); } } sub check_smtp_sasl { my $list = shift; require DADA::Mail::Send; require DADA::MailingList::Settings; my $ls = DADA::MailingList::Settings->new(-List => $list); my $li = $ls->get; my $mh = DADA::Mail::Send->new($li); my ($log,$s_report) = $mh->check_sasl_settings( -smtp_server => $q->param('smtp_server'), -sasl_smtp_username => $q->param('sasl_smtp_username'), -sasl_smtp_password => $q->param('sasl_smtp_password'), -smtp_connect_tries => $q->param('smtp_connect_tries'), -smtp_port => $q->param('smtp_port'), -set_smtp_sender => $q->param('set_smtp_sender'), ); my $report; $report .= $q->h2("SASL Test Report:"); if($s_report->[0]){ foreach(@$s_report){ $report .= '

' . $_ . "\n"; } }else{ $report .= q{

Nothing to report -

Make sure you have checked Use SMTP Authentication (SASL) and entered both a username and password.

}; } $report .= q{
}; $report .= $q->h2("Raw Log:"); foreach(@$log){ # not the best way, but probably not the worst way either. $_ = xss_filter($_); $report .= '

' . $_ . "<\/p>\n"; } $report .= '

'; return $report; } sub view_list { my ($admin_list, $root_login) = check_list_security(-cgi_obj => $q, -Function => 'view_list'); $list = $admin_list; require DADA::MailingList::Settings; my $ls = DADA::MailingList::Settings->new(-List => $list); my $li = $ls->get; my $lh = DADA::MailingList::Subscribers->new(-List => $list); my $start = $q->param('start') || 0; my $length = $li->{view_list_subscriber_number}; my $num_subscribers = $lh->num_subscribers(-Type => $type); my $screen_finish = $length+$start; $screen_finish = $num_subscribers if $num_subscribers < $length+$start; my $screen_start = $start; $screen_start = 1 if (($start == 0) && ($num_subscribers != 0)); my $previous_screen = $start-$length; my $next_screen = $start+$length; my $subscribers = $lh->subscription_list( -start => $start, '-length' => $length, -Type => $type); my $delete_email_count = $q->param('delete_email_count'); my $email_count = $q->param('email_count'); if($process eq 'set_black_list_prefs'){ my $black_list = $q->param('black_list') || 0; my $add_unsubs_to_black_list = $q->param('add_unsubs_to_black_list') || 0; my $allow_blacklisted_to_subscribe = $q->param('allow_blacklisted_to_subscribe') || 0; my $allow_admin_to_subscribe_blacklisted = $q->param('allow_admin_to_subscribe_blacklisted') || 0; $ls->save({ black_list => $black_list, add_unsubs_to_black_list => $add_unsubs_to_black_list, allow_blacklisted_to_subscribe => $allow_blacklisted_to_subscribe, allow_admin_to_subscribe_blacklisted => $allow_admin_to_subscribe_blacklisted }); print $q->redirect(-uri => $S_PROGRAM_URL . '?flavor=view_list&type=black_list&black_list_changes_done=1'); }else{ print(admin_html_header(-Title => $type_title, -List => $list, -Root_Login => $root_login, -Form => 0 )); require DADA::Template::Widgets; print DADA::Template::Widgets::screen(-list => $list, -screen => 'view_list_screen.tmpl', -vars => { view_list_subscriber_number => $li->{view_list_subscriber_number}, next_screen => $next_screen, previous_screen => $previous_screen, use_previous_screen => ($start-$length >= 0 && $start > 0) ? 1 : 0, num_subscribers => $num_subscribers, show_next_screen_link => ($num_subscribers > ($start + $length)) ? 1 : 0, screen_start => $screen_start, screen_finish => $screen_finish, delete_email_count => $delete_email_count, email_count => $email_count, subscribers => $subscribers, type => $type, type_title => $type_title, list_type_isa_list => ($type eq 'list') ? 1 : 0, list_type_isa_black_list => ($type eq 'black_list') ? 1 : 0, list_type_isa_moderators => ($type eq 'moderators') ? 1 : 0, list_type_isa_testers => ($type eq 'testers') ? 1 : 0, GLOBAL_BLACK_LIST => $GLOBAL_BLACK_LIST, GLOBAL_UNSUBSCRIBE => $GLOBAL_UNSUBSCRIBE, can_use_global_black_list => $lh->can_use_global_black_list, can_use_global_unsubscribe => $lh->can_use_global_unsubscribe, can_filter_subscribers_through_blacklist => $lh->can_filter_subscribers_through_blacklist, black_list_changes_done => ($q->param('black_list_changes_done')) ? 1 : 0, black_list => $li->{black_list}, add_unsubs_to_black_list => $li->{add_unsubs_to_black_list}, allow_blacklisted_to_subscribe => $li->{allow_blacklisted_to_subscribe}, allow_admin_to_subscribe_blacklisted => $li->{allow_admin_to_subscribe_blacklisted}, flavor => 'view_list', enable_moderation => $li->{enable_moderation}, }, ); print(admin_html_footer(-List => $list, -Form => 0)); } } sub filter_using_black_list { my ($admin_list, $root_login) = check_list_security(-cgi_obj => $q, -Function => 'filter_using_black_list'); $list = $admin_list; if(!$process){ my $lh = DADA::MailingList::Subscribers->new(-List => $list); my $ls = DADA::MailingList::Settings->new(-List => $list); my $li = $ls->get; my $filtered = $lh->filter_list_through_blacklist; print(admin_html_header(-Title => "Filtering Subscription List...", -List => $list, -Root_Login => $root_login, -Form => 0 )); my $should_add_to_black_list = 0; $should_add_to_black_list = 1 if ($li->{black_list} eq "1") && ($li->{add_unsubs_to_black_list} eq "1"); require DADA::Template::Widgets; print DADA::Template::Widgets::screen(-list => $list, -screen => 'filter_using_black_list.tmpl', -vars => { filtered => $filtered, add_to_black_list => $should_add_to_black_list, }, ); print(admin_html_footer(-List => $list, -Form => 0)); } } sub view_list_options { my ($admin_list, $root_login) = check_list_security(-cgi_obj => $q, -Function => 'view_list_options'); $list = $admin_list; my @list_amount = (10,25,50,100,150,200, 250,300,350, 400,450, 500,550,600,650,700, 750,800,850,900,950,1000 ); require DADA::MailingList::Settings; my $ls = DADA::MailingList::Settings->new(-List => $list); my $li = $ls->get; if(!$process){ my $vlsn_menu = $q->popup_menu(-name => 'view_list_subscriber_number', -values => [ @list_amount], -default => $li->{view_list_subscriber_number}); print(admin_html_header(-Title => "View List Options", -List => $list, -Root_Login => $root_login, )); require DADA::Template::Widgets; print DADA::Template::Widgets::screen(-screen => 'view_list_options_screen.tmpl', -vars => { done => $done, vlsn_menu => $vlsn_menu }, ); print(admin_html_footer(-List => $list)); }else{ $ls->save({view_list_subscriber_number => $q->param('view_list_subscriber_number')}); print $q->redirect(-uri => $S_PROGRAM_URL . '?f=view_list_options&done=1'); return; } } sub edit_subscriber { view_list() if ! $email; my ($admin_list, $root_login) = check_list_security(-cgi_obj => $q, -Function => 'edit_subscriber'); $list = $admin_list; require DADA::MailingList::Settings; my $ls = DADA::MailingList::Settings->new(-List => $list); my $li = $ls->get; my $lh = DADA::MailingList::Subscribers->new(-List => $list); print $q->redirect(-uri => $S_PROGRAM_URL . '?f=view_list&error=no_such_address&type=' . $type) if $lh->check_for_double_email(-Email => $email, -Type => $type) == 0; my $errors = {invalid_email => 0, subscribed => 0}; my $status = undef; my $subscribed = 0; my $edit_email = undef; my $no_changes_made = 0; if($process){ $edit_email = $q->param('edit_email'); if($edit_email eq $email){ $no_changes_made = 1; }else{ ($status, $errors) = $lh->subscription_check(-Email => $edit_email, -Type => $type); unless(($errors->{invalid_email} == 1) || (($errors->{subscribed} == 1) && ($email ne $edit_email))){ $lh->remove_from_list(-Email_List => [$email], -Type => $type); $lh->add_to_email_list(-Email_Ref => [$edit_email], -Type => $type); $done = 1; $email = $edit_email; } } } print(admin_html_header(-Title => "Edit Subscriber", -List => $list, -Root_Login => $root_login, -Form => 0)); require DADA::Template::Widgets; print DADA::Template::Widgets::screen(-screen => 'edit_subscribed_screen.tmpl', -vars => { done => $done, email => $email, edit_email => $edit_email, errors_invalid_email => $errors->{invalid_email}, errors_subscribed => $errors->{subscribed}, no_changes_made => $no_changes_made, type => $type, type_title => $type_title, }, ); print(admin_html_footer(-List => $list, -Form => 0)); } sub list_stats { my ($admin_list, $root_login) = check_list_security(-cgi_obj => $q, -Function => 'list_stats'); # view whos on the list, add delete addresses $list = $admin_list; require DADA::MailingList::Settings; my $ls = DADA::MailingList::Settings->new(-List => $list); my $li = $ls->get; my $lh = DADA::MailingList::Subscribers->new(-List => $list); print(admin_html_header( -Title => "Subscriber Statistics", -List => $li->{list}, -Root_Login => $root_login)); print "

\n"; my $email_count = $q -> param("email_count"); if(defined($email_count)){ my $add_message = "$email_count people have been added successfully"; print $q->p("$add_message"); } my $delete_email_count = $q -> param("delete_email_count"); if(defined($delete_email_count)){ print "

",$delete_email_count; print " emails have been deleted

"; } #my $any_subscribers = -s "$FILES/$list.list"; # debug my $any_subscribers = 1; if($any_subscribers != 0){ print"

"; $SHOW_EMAIL_LIST = 0; my ($everyone, $domains_ref, $count_services_ref) = $lh->list_option_form(-List => $list, -In_Order => $LIST_IN_ORDER); if($SHOW_DOMAIN_TABLE == 1) { #initialize some variables my $key; my $value; my $everyone_else = $domains_ref -> {Other}; print <Email addresses sorted by Top Level Domains: click on the particular domain to view the list of emails from that top level domain.

EOF ; my @keys = sort(keys %$domains_ref); foreach $key (@keys){ if($key !~ m/Other/i){ $value = $domains_ref -> {$key}; my $percentage; if($everyone > 0){ $percentage = ($value * 100)/$everyone; }else{ $percentage = 0; } $percentage= sprintf("%.2f", $percentage); print $q->Tr($q->td({-bgcolor=>'#FFFFFF'},[ $q->a({href=>"$S_PROGRAM_URL?flavor=search_email&method=domain&keyword=.$key"},$key), $value, "$percentage\%" ])); # now, find what "other" is } } $value = $domains_ref->{Other}; my $percentage; if($everyone > 0){ $percentage = ($value * 100)/$everyone; }else{ $percentage = 0; } $percentage= sprintf("%.2f", $percentage); print $q->Tr($q->td({-bgcolor=>'#FFFFFF'},[ 'Other', $value, "$percentage\%" ])); print <
Domain Number Percent

 


EOF ; } if($SHOW_SERVICES_TABLE==1){ my $skey; my $svalue; my $using; my @skeys = sort(values %SERVICES); print $q->p("Email address sorted by popular Email or ISP Services: click on a service to see the list of emails from that particular service."); print <
EOF ; %SERVICES = reverse(%SERVICES); foreach $skey (@skeys){ $svalue = $count_services_ref->{$skey} || 0; my $spercentage; if($everyone > 0){ $spercentage = ($svalue * 100)/$everyone; }else{ $spercentage = 0; } $spercentage= sprintf("%.2f", $spercentage); if($SERVICES{$skey} !~ m/Other/i){ print $q->Tr($q->td({-bgcolor=>'#FFFFFF'},[ $q->a({href=>"$S_PROGRAM_URL?flavor=search_email&method=service&keyword=$skey"},$SERVICES{$skey}), $svalue, "$spercentage\%" ])); } } $svalue = $count_services_ref -> {Other}; my $spercentage; if($everyone > 0){ $spercentage = ($svalue * 100)/$everyone; }else{ $spercentage = 0; } $spercentage= sprintf("%.2f", $spercentage); print $q->Tr($q->td({-bgcolor=>'#FFFFFF'},[ 'Other', $svalue, "$spercentage\%" ])); print <
Service Number Percent

 

EOF ; print qq{ } if $SHOW_HELP_LINKS == 1; } }else{ print $NO_ONE_SUBSCRIBED; } print(admin_html_footer(-List => $list)); } sub add { my ($admin_list, $root_login) = check_list_security(-cgi_obj => $q, -Function => 'add'); $list = $admin_list; require DADA::MailingList::Settings; my $ls = DADA::MailingList::Settings->new(-List => $list); my $li = $ls->get; my $lh = DADA::MailingList::Subscribers->new(-List => $list); my $num_subscribers = $lh->num_subscribers; print(admin_html_header( -Title => "Manage Additions", -List => $list, -Root_Login => $root_login, -Form => 0)); my $subscription_quota_reached = 0; $subscription_quota_reached = 1 if ($li->{use_subscription_quota} == 1) && ($num_subscribers >= $li->{subscription_quota}) && ($num_subscribers + $li->{subscription_quota} > 1); my $list_type_switch_widget = $q->popup_menu(-name => 'type', '-values' => [keys %list_types], -labels => \%list_types, -default => $type, ); require DADA::Template::Widgets; print DADA::Template::Widgets::screen(-screen => 'add_screen.tmpl', -vars => { subscription_quota => $li->{subscription_quota}, use_subscription_quota => $li->{use_subscription_quota}, subscription_quota_reached => $subscription_quota_reached, num_subscribers => $num_subscribers, list_type_isa_list => ($type eq 'list') ? 1 : 0, list_type_isa_black_list => ($type eq 'black_list') ? 1 : 0, list_type_isa_moderators => ($type eq 'moderators') ? 1 : 0, list_type_isa_testers => ($type eq 'testers') ? 1 : 0, type => $type, type_title => $type_title, flavor => 'add', enable_moderation => $li->{enable_moderation}, }, ); print(admin_html_footer(-List => $list)); } sub add_email { my ($admin_list, $root_login) = check_list_security(-cgi_obj => $q, -Function => 'add_email'); my %seen; $list = $admin_list; require DADA::MailingList::Settings; my $ls = DADA::MailingList::Settings->new(-List => $list); my $li = $ls->get; my $lh = DADA::MailingList::Subscribers->new(-List => $list); if(!$process){ my $new_emails; my $email_file = $q->param('new_email_file'); if(DADA::App::Guts::strip($q->param("new_emails")) ne ""){ $new_emails = $q->param("new_emails"); }else{ if($email_file){ my $new_file = file_upload('new_email_file'); open(UPLOADED, "$new_file") or die $!; { local $/ = undef; $new_emails = ; } close(UPLOADED); unlink($new_file) or warn "could not remove uploaded subscriber list, '$new_file': $!"; } } my @new_addresses = split(/\s+|,|;|\n+/, $new_emails); my ($subscribed, $not_subscribed, $black_listed, $invalid) = $lh->filter_subscribers(-Email_Ref => [@new_addresses], -Type => $type); my $num_subscribers = $lh->num_subscribers; if( (($num_subscribers + $#$not_subscribed,) >= $li->{subscription_quota}) && ($li->{use_subscription_quota} == 1) ){ $quick = 'no'; } my $going_over_quota = undef; if($quick eq "yes"){ my $new_email_count=$lh->add_to_email_list(-Email_Ref => $not_subscribed, -List => $list, -Type => $type, ); print $q->redirect(-uri => $S_PROGRAM_URL . '?flavor=view_list&email_count=' . $new_email_count . '&type=' . $type); }else{ $going_over_quota = 1 if (($num_subscribers + $#$not_subscribed) >= $li->{subscription_quota}) && ($li->{use_subscription_quota} == 1); my $addresses_to_add = 0; $addresses_to_add = 1 if(defined(@$not_subscribed[0])); my $black_listed_addresses = []; push(@$black_listed_addresses, {email => $_}) foreach @$black_listed; my $good_addresses = []; push(@$good_addresses, {email => $_}) foreach @$not_subscribed; my $already_subscribed_addresses = []; push(@$already_subscribed_addresses, {email => $_ }) foreach @$subscribed; my $invalid_addresses = []; push(@$invalid_addresses, {email => $_ }) foreach @$invalid; print(admin_html_header( -Title => "Verify Additions", -List => $list, -Root_Login => $root_login, -Form => 0, )); require DADA::Template::Widgets; print DADA::Template::Widgets::screen(-screen => 'add_email_screen.tmpl', -vars => { going_over_quota => $going_over_quota, addresses_to_add => $addresses_to_add, good_addresses => $good_addresses, black_listed_addresses => $black_listed_addresses, subscription_quota => $li->{subscription_quota}, black_list => $li->{black_list}, invalid_addresses => $invalid_addresses, already_subscribed_addresses => $already_subscribed_addresses, allow_admin_to_subscribe_blacklisted => $li->{allow_admin_to_subscribe_blacklisted}, type => $type, type_title => $type_title, }, ); print(admin_html_footer(-List => $list, -Form => 0)); } } else { my @address = $q->param("address"); my $new_email_count = $lh->add_to_email_list(-Email_Ref => [@address], -Type => $type, ); print $q->redirect(-uri=> $S_PROGRAM_URL . '?flavor=view_list&email_count=' . $new_email_count . '&type=' . $type); } } sub delete_email{ my ($admin_list, $root_login) = check_list_security(-cgi_obj => $q, -Function => 'delete_email', ); $list = $admin_list; require DADA::MailingList::Settings; my $ls = DADA::MailingList::Settings->new(-List => $list); my $li = $ls->get; my $lh = DADA::MailingList::Subscribers->new(-List => $list); if(!$process){ my $list_type_switch_widget = $q->popup_menu(-name => 'type', '-values' => [keys %list_types], -labels => \%list_types, -default => $type, ); print(admin_html_header( -Title => "Manage Deletions", -List => $list, -Root_Login => $root_login, -Form => 0 )); require DADA::Template::Widgets; print DADA::Template::Widgets::screen(-screen => 'delete_email_screen.tmpl', -vars => { can_use_global_black_list => $lh->can_use_global_black_list, can_use_global_unsubscribe => $lh->can_use_global_unsubscribe, list_type_isa_list => ($type eq 'list') ? 1 : 0, list_type_isa_black_list => ($type eq 'black_list') ? 1 : 0, list_type_isa_moderators => ($type eq 'moderators') ? 1 : 0, list_type_isa_testers => ($type eq 'testers') ? 1 : 0, type => $type, type_title => $type_title, flavor => 'delete_email', enable_moderation => $li->{enable_moderation}, }); print(admin_html_footer(-List => $list, -Form => 0)); }else{ my $delete_list = undef; my $delete_email_file = $q->param('delete_email_file'); if($delete_email_file){ my $new_file = file_upload('delete_email_file'); open(UPLOADED, "$new_file") or die $!; { local $/ = undef; $delete_list = ; } close(UPLOADED); }else{ $delete_list = $q->param('delete_list'); } my @delete_addresses = split(/\s+|,|;|\n+/, $delete_list); if(!$delete_addresses[0]){ print $q->redirect(-uri => $S_PROGRAM_URL . '?flavor=delete_email'); } my ($subscribed, $not_subscribed, $black_listed, $invalid) = $lh->filter_subscribers(-Email_Ref => [@delete_addresses], -Type => $type); my $should_add_to_black_list = 0; $should_add_to_black_list = 1 if ($li->{black_list} eq "1") && ($li->{add_unsubs_to_black_list} eq "1"); my $have_subscribed_addresses = 0; $have_subscribed_addresses = 1 if $subscribed->[0]; my $addresses_to_remove = []; push(@$addresses_to_remove, {email => $_}) foreach @$subscribed; my $not_subscribed_addresses = []; push(@$not_subscribed_addresses, {email => $_}) foreach @$not_subscribed; my $have_invalid_addresses = 0; $have_invalid_addresses = 1 if $invalid->[0]; my $invalid_addresses = []; push(@$invalid_addresses, {email => $_ }) foreach @$invalid; print(admin_html_header( -Title => "Verify Deletions", -List => $list, -Root_Login => $root_login, -Form => 0, )); require DADA::Template::Widgets; print DADA::Template::Widgets::screen(-screen => 'delete_email_screen_filtered.tmpl', -vars => { should_add_to_black_list => $should_add_to_black_list, have_subscribed_addresses => $have_subscribed_addresses, addresses_to_remove => $addresses_to_remove, not_subscribed_addresses => $not_subscribed_addresses, have_invalid_addresses => $have_invalid_addresses, invalid_addresses => $invalid_addresses, type => $type, type_title => $type_title, }, ); print(admin_html_footer(-List => $list)); } } sub subscription_options { my ($admin_list, $root_login) = check_list_security(-cgi_obj => $q, -Function => 'subscription_options'); $list = $admin_list; require DADA::MailingList::Settings; my $ls = DADA::MailingList::Settings->new(-List => $list); my $li = $ls->get; my @quota_values = qw(1 10 25 50 100 150 200 250 300 350 400 450 500 600 700 800 900 1000 1500 2000 2500 3000 3500 4000 4500 5000 5500 6000 6500 7000 7500 8000 8500 9000 9500 10000 11000 12000 13000 14000 15000 16000 17000 18000 19000 20000 30000 40000 50000 60000 70000 80000 90000 100000 200000 300000 400000 500000 600000 700000 800000 900000 1000000 ); unshift(@quota_values, $li->{subscription_quota}); if(!$process){ my $subscription_quota_menu = $q->popup_menu(-name => 'subscription_quota', '-values' => [@quota_values], -default => $li->{subscription_quota}, ); print admin_html_header(-Title => "Subscriber Options", -List => $list, -Root_Login => $root_login ); require DADA::Template::Widgets; print DADA::Template::Widgets::screen(-screen => 'subscription_options_screen.tmpl', -vars => { done => $done, use_subscription_quota => $li->{use_subscription_quota}, subscription_quota_menu => $subscription_quota_menu, }, ); print admin_html_footer(-List => $list); }else{ my $use_subscription_quota = $q->param('use_subscription_quota') || 0; my $subscription_quota = $q->param('subscription_quota'); $ls->save({ use_subscription_quota => $use_subscription_quota, subscription_quota => $subscription_quota, }); print $q->redirect(-uri => $S_PROGRAM_URL . '?f=subscription_options&done=1'); } } sub view_archive { my ($admin_list, $root_login) = check_list_security(-cgi_obj => $q, -Function => 'view_archive'); $list = $admin_list; require DADA::MailingList::Settings; my $ls = DADA::MailingList::Settings->new(-List => $admin_list); my $li = $ls->get; # let's get some info on this archive, shall we? require DADA::MailingList::Archives; my $archive = DADA::MailingList::Archives -> new(-List => $li); my $entries = $archive -> get_archive_entries(); #if we don't have nothin, print the index, unless(defined($id)){ my $ht_entries = []; #reverse if need be #@$entries = reverse(@$entries) if($li->{sort_archives_in_reverse} eq "1"); my $entry; foreach $entry (@$entries){ my ($subject, $message, $format) = $archive -> get_archive_info($entry); my $pretty_subject = pretty($subject); my $date = date_this( -Packed_Date => $entry, -Write_Month => $li->{archive_show_month}, -Write_Day => $li->{archive_show_day}, -Write_Year => $li->{archive_show_year}, -Write_H_And_M => $li->{archive_show_hour_and_minute}, -Write_Second => $li->{archive_show_second}, ); push(@$ht_entries, { id => $entry, date => $date, S_PROGRAM_URL => $S_PROGRAM_URL, subject => $pretty_subject, }); } print(admin_html_header( -Title => "Manage Archives", -List => $li->{list}, -Root_Login => $root_login, -Form => 0, )); require DADA::Template::Widgets; print DADA::Template::Widgets::screen(-screen => 'view_archive_index_screen.tmpl', -list => $list, -vars => { index_list => $ht_entries, list_name => $li->{list_name}, }, ); print(admin_html_footer(-List => $list, , -Form => 0)); }else{ #check to see if $id is a real id key my $entry_exists = $archive -> check_if_entry_exists($id); user_error(-List => $list, -Error => "no_archive_entry")if($entry_exists <= 0); # if we got something, print that entry. print(admin_html_header( -Title => "Manage Archives", -List => $li->{list}, -Root_Login => $root_login)); #get the archive info my ($subject, $message, $format) = $archive->get_archive_info($id); my $pretty_subject = pretty($subject); print"

$pretty_subject

"; if($archive->can_display_message_source){ print qq{

Display Original Message Source

}; } print qq{

Display publically viewable version of this message

}; print qq{'; my $cal_date = date_this(-Packed_Date => $archive->_massaged_key($id), -All => 1); print <

Sent $cal_date

Note: some archiving formatting options only take affect when viewing messages publically.

EOF ; my $nav_table = $archive -> make_nav_table(-Id => $id, -List => $li->{list}, -Function => "admin"); print "
$nav_table
"; print(admin_html_footer(-List => $list)); } } sub display_message_source { my ($admin_list, $root_login) = check_list_security(-cgi_obj => $q, -Function => 'display_message_source'); $list = $admin_list; require DADA::MailingList::Settings; my $ls = DADA::MailingList::Settings->new(-List => $admin_list); my $li = $ls->get; require DADA::MailingList::Archives; my $la = DADA::MailingList::Archives -> new(-List => $li); if($la->check_if_entry_exists($q->param('id'))){ if($la->can_display_message_source){ print $q->header('text/plain'); $la->print_message_source(\*STDOUT, $q->param('id')); }else{ user_error(-List => $list, -Error => "no_support_for_displaying_message_source"); } } else { user_error(-List => $list, -Error => "no_archive_entry"); } } sub delete_archive { my ($admin_list, $root_login) = check_list_security(-cgi_obj => $q, -Function => 'delete_archive'); $list = $admin_list; my @address = $q->param("address"); require DADA::MailingList::Settings; my $ls = DADA::MailingList::Settings->new(-List => $admin_list); my $li = $ls->get; require DADA::MailingList::Archives; my $archive = DADA::MailingList::Archives->new(-List => $li); $archive->delete_archive(@address); print $q->redirect(-uri=>"$S_PROGRAM_URL?flavor=view_archive"); } sub purge_all_archives { my ($admin_list, $root_login) = check_list_security(-cgi_obj => $q, -Function => 'purge_all_archives'); $list = $admin_list; require DADA::MailingList::Settings; my $ls = DADA::MailingList::Settings->new(-List => $admin_list); require DADA::MailingList::Archives; my $ah = DADA::MailingList::Archives -> new(-List => $ls->get); $ah->delete_all_archive_entries(); print $q->redirect(-uri=>$S_PROGRAM_URL . '?flavor=view_archive'); } sub archive_options { my ($admin_list, $root_login) = check_list_security(-cgi_obj => $q, -Function => 'archive_options'); $list = $admin_list; require DADA::MailingList::Settings; my $ls = DADA::MailingList::Settings->new(-List => $list); my $li = $ls->get; my $show_archives = $q->param('show_archives') || 0; my $archive_messages = $q->param('archive_messages') || 0; my $archive_subscribe_form = $q->param('archive_subscribe_form') || 0; my $archive_search_form = $q->param('archive_search_form') || 0; my $archive_send_form = $q->param('archive_send_form') || 0; if(!$process){ print(admin_html_header( -Title => "Archive Options", -List => $list, -Root_Login => $root_login )); require DADA::Template::Widgets; print DADA::Template::Widgets::screen(-screen => 'archive_options_screen.tmpl', -expr => 1, -vars => { list => $list, done => $done, archive_messages => $li->{archive_messages}, show_archives => $li->{show_archives}, archive_search_form => $li->{archive_search_form}, archive_subscribe_form => $li->{archive_subscribe_form}, archive_send_form => $li->{archive_send_form}, }, ); print(admin_html_footer(-List => $list)); }else{ $ls->save({show_archives => $show_archives, archive_messages => $archive_messages, archive_subscribe_form => $archive_subscribe_form, archive_search_form => $archive_search_form, archive_send_form => $archive_send_form }); print $q->redirect(-uri => $S_PROGRAM_URL . '?flavor=archive_options&done=1'); } } sub adv_archive_options { my ($admin_list, $root_login) = check_list_security(-cgi_obj => $q, -Function => 'adv_archive_options'); $list = $admin_list; require DADA::MailingList::Settings; my $ls = DADA::MailingList::Settings->new(-List => $list); my $li = $ls->get; require DADA::MailingList::Archives; my $la = DADA::MailingList::Archives->new(-List => $li); if(!$process) { my @index_this = ($li->{archive_index_count},1..10,15,20,25,30,40,50,75,100); my $archive_index_count_menu = $q->popup_menu(-name => 'archive_index_count', -id => 'archive_index_count', -value => [@index_this] ); my $ping_sites = []; push(@$ping_sites, { ping_url => $_ }) foreach @PING_URLS; my $can_use_xml_rpc = 1; eval { require XMLRPC::Lite }; if($@){ $can_use_xml_rpc = 0; } my $can_use_html_scrubber = 1; eval { require HTML::Scrubber }; if($@){ $can_use_html_scrubber = 0; } print(admin_html_header(-Title => "Advanced Archive Options", -List => $list, -Root_Login => $root_login)); require DADA::Template::Widgets; print DADA::Template::Widgets::screen(-screen => 'adv_archive_options_screen.tmpl', -vars => { done => $done, stop_message_at_sig => $li->{stop_message_at_sig}, sort_archives_in_reverse => $li->{sort_archives_in_reverse}, archive_show_day => $li->{archive_show_day}, archive_show_month => $li->{archive_show_month}, archive_show_year => $li->{archive_show_year}, archive_show_hour_and_minute => $li->{archive_show_hour_and_minute}, archive_show_second => $li->{archive_show_second}, archive_index_count_menu => $archive_index_count_menu, publish_archives_rss => $li->{publish_archives_rss}, list => $list, ping_archives_rss => $li->{ping_archives_rss}, ping_sites => $ping_sites, can_use_xml_rpc => $can_use_xml_rpc, html_archives_in_iframe => $li->{html_archives_in_iframe}, disable_archive_js => $li->{disable_archive_js}, can_use_html_scrubber => $can_use_html_scrubber, style_quoted_archive_text => $li->{style_quoted_archive_text}, display_attachments => $li->{display_attachments}, can_display_attachments => $la->can_display_attachments, }, ); print(admin_html_footer(-List => $list)); }else{ my $sort_archives_in_reverse = $q->param('sort_archives_in_reverse') || 0; my $archive_show_year = $q->param('archive_show_year') || 0; my $archive_show_month = $q->param('archive_show_month') || 0; my $archive_show_day = $q->param('archive_show_day') || 0; my $archive_show_hour_and_minute = $q->param('archive_show_hour_and_minute') || 0; my $archive_show_second = $q->param('archive_show_second') || 0; my $archive_index_count = $q->param('archive_index_count') || 10; my $stop_message_at_sig = $q->param('stop_message_at_sig') || 0; my $publish_archives_rss = $q->param('publish_archives_rss') || 0; my $ping_archives_rss = $q->param('ping_archives_rss') || 0; my $html_archives_in_iframe = $q->param('html_archives_in_iframe') || 0; my $disable_archive_js = $q->param('disable_archive_js') || 0; my $style_quoted_archive_text = $q->param('style_quoted_archive_text') || 0; my $display_attachments = $q->param('display_attachments') || 0; $ls->save({ stop_message_at_sig => $stop_message_at_sig, sort_archives_in_reverse => $sort_archives_in_reverse, archive_show_year => $archive_show_year, archive_show_month => $archive_show_month, archive_show_day => $archive_show_day, archive_show_hour_and_minute => $archive_show_hour_and_minute, archive_show_second => $archive_show_second, archive_index_count => $archive_index_count, publish_archives_rss => $publish_archives_rss, ping_archives_rss => $ping_archives_rss, html_archives_in_iframe => $html_archives_in_iframe, disable_archive_js => $disable_archive_js, style_quoted_archive_text => $style_quoted_archive_text, display_attachments => $display_attachments, }); print $q->redirect(-uri => $S_PROGRAM_URL . '?flavor=adv_archive_options&done=1'); } } sub html_code { my ($admin_list, $root_login) = check_list_security(-cgi_obj => $q, -Function => 'html_code'); $list = $admin_list; print(admin_html_header(-Title => "Cut-and-Paste Code", -List => $list, -Root_Login => $root_login, -Form => 0, )); require DADA::Template::Widgets; print DADA::Template::Widgets::screen(-screen => 'html_code_screen.tmpl', -vars => { list => $list, } ); print(admin_html_footer(-List => $list, -Form => 0)); } sub edit_template { my ($admin_list, $root_login) = check_list_security(-cgi_obj => $q, -Function => 'edit_template'); $list = $admin_list; require DADA::MailingList::Settings; my $ls = DADA::MailingList::Settings->new(-List => $list); my $li = $ls->get; my $default_template = default_template($PROGRAM_URL); if(!$process) { my $edit_this_template = $default_template . "\n"; $edit_this_template = open_template(-List => $list) . "\n" if check_if_template_exists( -List => $list ) >= 1; my $get_template_data_from_default_template = 0; $get_template_data_from_default_template = 1 if $li->{get_template_data} eq 'from_default_template'; my $get_template_data_from_template_file = 0; $get_template_data_from_template_file = 1 if $li->{get_template_data} eq 'from_template_file'; my $get_template_data_from_url = 0; $get_template_data_from_url = 1 if $li->{get_template_data} eq 'from_url'; my $can_use_lwp_simple; eval { require LWP::Simple; }; $can_use_lwp_simple = 1 if !$@; print(admin_html_header(-Title => "Edit the List Template", -List => $li->{list}, -Root_Login => $root_login, -Form => 0, )); require DADA::Template::Widgets; print DADA::Template::Widgets::screen(-screen => 'edit_template_screen.tmpl', -vars => { done => $done, edit_this_template => $edit_this_template, get_template_data => $li->{get_template_data}, get_template_data_from_url => $get_template_data_from_url, get_template_data_from_template_file => $get_template_data_from_template_file, get_template_data_from_default_template => $get_template_data_from_default_template, can_use_lwp_simple => $can_use_lwp_simple, url_template => $li->{url_template}, default_template => $default_template, apply_list_template_to_html_msgs => $li->{apply_list_template_to_html_msgs}, }, ); print(admin_html_footer(-List => $list, -Form => 0)); }else{ if($process eq "preview template") { my $template_info; my $test_header; my $test_footer; if($q->param('get_template_data') eq 'from_url'){ eval {require LWP::Simple;}; if(!$@){ $template_info = LWP::Simple::get($q->param('url_template')); ($test_header, $test_footer) = split(/\[dada\]/,$template_info); } }else{ $template_info = $q->param("template_info"); ($test_header, $test_footer) = split(/\[dada\]/,$template_info); } print $q->header(); for($test_header, $test_footer) { s/\[program_name\]/$PROGRAM_NAME/g; s/\[program_url\]/$PROGRAM_URL/g; } my $default_css = default_css(); $test_header =~ s/<\!--\[default_css\]-->/$default_css/g; $test_header =~ s/\[default_css\]/$default_css/g; $test_header =~ s/\[message\]/preview of template/g; $test_header =~ s/\[version\]/$VER/g; print $test_header; print "

This is a preview (read: not saved!!!!) of your template.

To save or edit, close this window and hit the Change Template button.

 

"; $test_footer =~ s/\[message\]/preview of template/g; $test_footer =~ s/\[version\]/$VER/g; print $test_footer; }else{ my $template_info = $q->param("template_info"); my $get_template_data = $q->param("get_template_data") || ''; my $url_template = $q->param('url_template') || ''; my $apply_list_template_to_html_msgs = $q->param('apply_list_template_to_html_msgs') || 0; require DADA::MailingList::Settings; $ls->save({ apply_list_template_to_html_msgs => $apply_list_template_to_html_msgs, url_template => $url_template, get_template_data => $get_template_data, }); make_template(-List => $list, -Template => $template_info); print $q->redirect(-uri => $S_PROGRAM_URL . '?flavor=edit_template&done=1'); return; } } } sub back_link { my ($admin_list, $root_login) = check_list_security(-cgi_obj => $q, -Function => 'back_link'); $list = $admin_list; require DADA::MailingList::Settings; my $ls = DADA::MailingList::Settings->new(-List => $list); my $li = $ls->get; if(!$process){ print(admin_html_header(-Title => "Create a Back Link", -List => $list, -Root_Login => $root_login)); require DADA::Template::Widgets; print DADA::Template::Widgets::screen(-screen => 'back_link_screen.tmpl', -list => $list, -vars => { website_name => $li->{website_name}, website_url => $li->{website_url}, }, ); print(admin_html_footer(-List => $list)); }else{ my $website_name = $q->param("website_name") || ''; my $website_url = $q->param("website_url") || ''; $ls->save({website_name => $website_name, website_url => $website_url, }); print $q->redirect(-uri=>$S_PROGRAM_URL . '?flavor=back_link&done=1'); } } sub edit_type { my ($admin_list, $root_login) = check_list_security(-cgi_obj => $q, -Function => 'edit_type'); $list = $admin_list; require DADA::MailingList::Settings; my $ls = DADA::MailingList::Settings->new(-List => $list); my $li = $ls->get; if(!$process){ print(admin_html_header(-Title => "Customize Email Messages", -List => $list, -Root_Login => $root_login)); require DADA::Template::Widgets; print DADA::Template::Widgets::screen(-screen => 'edit_type_screen.tmpl', -list => $list, -vars => { wrap => $wrap, text_area_style => $text_area_style, done => $done, confirmation_message => $li->{confirmation_message}, unsub_confirmation_message => $li->{unsub_confirmation_message}, subscribed_message => $li->{subscribed_message}, unsubscribed_message => $li->{unsubscribed_message}, mailing_list_message => $li->{mailing_list_message}, mailing_list_message_html => $li->{mailing_list_message_html}, not_allowed_to_post_message => $li->{not_allowed_to_post_message}, send_archive_message => $li->{send_archive_message}, send_archive_message_html => $li->{send_archive_message_html}, }, ); print(admin_html_footer(-List => $list)); }else{ my $confirmation_message = $q->param('confirmation_message') || ''; my $unsub_confirmation_message = $q->param('unsub_confirmation_message') || ''; my $subscribed_message = $q->param('subscribed_message') || ''; my $unsubscribed_message = $q->param('unsubscribed_message') || ''; my $mailing_list_message = $q->param('mailing_list_message') || ''; my $mailing_list_message_html = $q->param('mailing_list_message_html') || ''; my $send_archive_message = $q->param('send_archive_message') || ''; my $send_archive_message_html = $q->param('send_archive_message_html') || ''; my $not_allowed_to_post_message = $q->param('not_allowed_to_post_message') || ''; for( $subscribed_message, $unsubscribed_message, $unsubscribed_message, $confirmation_message, $unsub_confirmation_message, $mailing_list_message, $mailing_list_message_html, $not_allowed_to_post_message, $send_archive_message, $send_archive_message_html, ){ s/\r\n/\n/g; # a very odd place to put this, but, hey, easy enough. if($q->param('revert')){ $_ = ''; } } $ls->save({ subscribed_message => $subscribed_message, unsubscribed_message => $unsubscribed_message, confirmation_message => $confirmation_message, unsub_confirmation_message => $unsub_confirmation_message, mailing_list_message => $mailing_list_message, mailing_list_message_html => $mailing_list_message_html, not_allowed_to_post_message => $not_allowed_to_post_message, send_archive_message => $send_archive_message, send_archive_message_html => $send_archive_message_html, }); print $q->redirect(-uri=>$S_PROGRAM_URL . '?flavor=edit_type&done=1'); } } sub edit_html_type { my ($admin_list, $root_login) = check_list_security(-cgi_obj => $q, -Function => 'edit_html_type'); $list = $admin_list; require DADA::MailingList::Settings; my $ls = DADA::MailingList::Settings->new(-List => $list); my $li = $ls->get; if(!$process){ print(admin_html_header(-Title => "Customize HTML Messages", -List => $list, -Root_Login => $root_login)); require DADA::Template::Widgets; print DADA::Template::Widgets::screen(-screen => 'edit_html_type_screen.tmpl', -list => $list, -vars => { done => $done, html_confirmation_message => $li->{html_confirmation_message}, html_unsub_confirmation_message => $li->{html_unsub_confirmation_message}, html_subscribed_message => $li->{html_subscribed_message}, html_unsubscribed_message => $li->{html_unsubscribed_message}, }, ); print(admin_html_footer(-List => $list)); }else{ my $html_confirmation_message = $q->param('html_confirmation_message') || ''; my $html_unsub_confirmation_message = $q->param('html_unsub_confirmation_message') || ''; my $html_subscribed_message = $q->param('html_subscribed_message') || ''; my $html_unsubscribed_message = $q->param('html_unsubscribed_message') || ''; for($html_confirmation_message, $html_unsub_confirmation_message, $html_subscribed_message, $html_unsubscribed_message){ s/\r\n/\n/g; } $ls->save({ html_confirmation_message => $html_confirmation_message, html_unsub_confirmation_message => $html_unsub_confirmation_message, html_subscribed_message => $html_subscribed_message, html_unsubscribed_message => $html_unsubscribed_message }); print $q->redirect(-uri=>"$S_PROGRAM_URL?flavor=edit_html_type&done=1"); } } sub manage_script { my ($admin_list, $root_login) = check_list_security(-cgi_obj => $q, -Function => 'manage_script'); $list = $admin_list; my $more_info = $q->param('more_info') || 0; my $sendmail_locations =`whereis sendmail`; my $at_incs = []; push(@$at_incs, {name => $_}) foreach(@INC); require DADA::MailingList::Settings; my $ls = DADA::MailingList::Settings->new(-List => $list); my $li = $ls->get; print(admin_html_header(-Title => "About $PROGRAM_NAME", -List => $li->{list}, -Root_Login => $root_login)); require DADA::Template::Widgets; print DADA::Template::Widgets::screen(-screen => 'manage_script_screen.tmpl', -list => $list, -vars => { more_info => $more_info, smtp_server => $li->{smtp_server}, server_software => $q->server_software(), operating_system => $^O, perl_version => $], sendmail_locations => $sendmail_locations, at_incs => $at_incs, list_owner_email => $li->{list_owner_email}, }, ); print(admin_html_footer(-List => $list)); } sub feature_set { my ($admin_list, $root_login) = check_list_security(-cgi_obj => $q, -Function => 'feature_set'); $list = $admin_list; require DADA::MailingList::Settings; my $ls = DADA::MailingList::Settings->new(-List => $list); my $li = $ls->get; require DADA::Template::Widgets::Admin_Menu; if(!$process){ print(admin_html_header(-Title => "Customize Feature Set", -List => $li->{list}, -Root_Login => $root_login)); print $GOOD_JOB_MESSAGE if(defined($done)); print DADA::Template::Widgets::Admin_Menu::make_feature_menu($li); print $q->hidden('process', 'true'); print $q->hidden('flavor', 'feature_set'); print $q->p(submit_form()); print(admin_html_footer(-List => $list)); }else{ my @params = $q->param; my %param_hash; foreach(@params){ $param_hash{$_} = $q->param($_); } my $save_set = DADA::Template::Widgets::Admin_Menu::create_save_set(\%param_hash); $ls->save({ admin_menu => $save_set}); print $q->redirect(-uri=>"$S_PROGRAM_URL?flavor=feature_set&done=1"); } } sub subscribe { my %args = (-html_output => 1, @_); my $list_exists = check_if_list_exists(-List=>$list,); if($list_exists == 0){ &default; return; } if (!$email){ list_page(); return; } require DADA::MailingList::Settings; my $ls = DADA::MailingList::Settings->new(-List => $list); my $lh = DADA::MailingList::Subscribers->new(-List => $list); my $li = $ls->get(-Format => "replaced"); $email = lc_email($email); my ($status, $errors) = $lh->subscription_check(-Email => $email, ($li->{allow_blacklisted_to_subscribe} == 1) ? ( -Skip => ['blacklisted'], ) : (), ); if($status == 0){ if(($li->{use_alt_url_sub_confirm_failed} == 1) && ($li->{alt_url_sub_confirm_failed} ne "")){ print $q->redirect(-uri => $li->{alt_url_sub_confirm_failed}); return; }else{ user_error(-List => $list, -Error => "invalid_email", -Email => $email) if $errors->{invalid_email} == 1; user_error(-List => $list, -Error => "mx_lookup_failed", -Email => $email) if $errors->{mx_lookup_failed} == 1; user_error(-List => $list, -Error => "email_in_list", -Email => $email) if $errors->{subscribed} == 1; user_error(-List => $list, -Error => "closed_list", -Email => $email) if $errors->{closed_list} == 1; user_error(-List => $list, -Error => "over_subscription_quota", -Email => $email) if $errors->{over_subscription_quota} == 1; user_error(-List => $list, -Error => "black_listed", -Email => $email) if $errors->{blacklisted} == 1; user_error(-List => $list, -Error => "settings_possibly_corrupted", -Email => $email) if $errors->{settings_possibly_corrupted} == 1; return; } }else{ if($li->{no_confirm_email} == "0"){ $pin = make_pin(-Email => $email); confirm(-html_output => $args{-html_output}); return; } require DADA::App::Messages; DADA::App::Messages::send_confirmation_message(-List => $list, -Email => $email, -Settings_obj => $ls, ); if($args{-html_output} != 0){ if(($li->{use_alt_url_sub_confirm_success} == 1) && ($li->{alt_url_sub_confirm_success} ne "")){ print $q->redirect(-uri => $li->{alt_url_sub_confirm_success}); return; }else{ print(the_html(-Part => "header", -Title => "Please Confirm", -List => $li->{list})); $li->{html_confirmation_message} =~ s/\[subscriber_email\]/$email/g; print $li->{html_confirmation_message}; print(the_html(-Part => "footer", -List => $li->{list}, -Site_Name => $li->{website_name}, -Site_URL => $li->{website_url})); return; } } } } sub subscribe_flash_xml { if($q->param('test') == 1){ print $q->header('text/plain'); }else{ print $q->header('application/x-www-form-urlencoded'); } if(check_if_list_exists(-List=>$list) == 0){ #note! This should be handled in the subscription_check_xml() method, # but this object *also* checks to see if a list is real. Chick/Egg print '' . $email . '0no_list'; }else{ my $lh = DADA::MailingList::Subscribers->new(-List => $list); my ($xml, $status, $errors) = $lh->subscription_check_xml(-Email => $email); print $xml; if($status == 1){ subscribe(-html_output => 0); } } } sub unsubscribe_flash_xml { if($q->param('test') == 1){ print $q->header('text/plain'); }else{ print $q->header('application/x-www-form-urlencoded'); } if(check_if_list_exists(-List=>$list) == 0){ print '' . $email . '0no_list'; }else{ my $lh = DADA::MailingList::Subscribers->new(-List => $list); my ($xml, $status, $errors) = $lh->unsubscription_check_xml(-Email => $email); print $xml; if($status == 1){ unsubscribe(-html_output => 0); } } } sub unsubscribe { my %args = (-html_output => 1, @_); if(check_if_list_exists(-List=>$list) == 0){ $set_flavor = 'u'; &default; return; } if (!$email){ $set_flavor = 'u'; list_page(); return; } my $lh = DADA::MailingList::Subscribers->new(-List => $list); my ($status, $errors) = $lh->unsubscription_check(-Email => $email, -Skip => ['no_list']); require DADA::MailingList::Settings; my $ls = DADA::MailingList::Settings->new(-List => $list); my $li = $ls->get(-Format => "replaced"); if($status == 0){ if(($li->{use_alt_url_unsub_confirm_failed} == 1) && ($li->{alt_url_unsub_confirm_failed} ne "")){ print $q->redirect(-uri => $li->{alt_url_unsub_confirm_failed}); return; }else{ user_error(-List => $list, -Error => "unsub_invalid_email", -Email => $email) if $errors->{invalid_email} == 1; user_error(-List => $list, -Error => "email_not_in_list", -Email => $email) if $errors->{not_subscribed} == 1; user_error(-List => $list, -Error => "settings_possibly_corrupted", -Email => $email) if $errors->{settings_possibly_corrupted} == 1; } }else{ if($pin){ unsub_confirm(-html_output => $args{-html_output}); #we'll change this one later... return; }elsif($li->{unsub_confirm_email} != 1){ $pin = make_pin(-Email => $email); &unsub_confirm(-html_output => $args{-html_output}); #we'll change this one later... return; }else{ require DADA::App::Messages; DADA::App::Messages::send_unsub_confirm_email( -List => $list, -Email => $email, -Settings_obj => $ls, ); if($args{-html_output} != 0){ if(($li->{use_alt_url_unsub_confirm_success} == 1) && ($li->{alt_url_unsub_confirm_success} ne "")){ print $q->redirect(-uri => $li->{alt_url_unsub_confirm_success}); return; }else{ print(the_html(-Part => "header", -Title => "Please Confirm Your Unsubscription", -List => $li->{list})); $li->{html_unsub_confirmation_message} =~ s/\[subscriber_email\]/$email/g; print $li->{html_unsub_confirmation_message}; print(the_html(-Part => "footer", -List => $li->{list}, -Site_Name => $li->{website_name}, -Site_URL => $li->{website_url})); } } } } } sub unsub_confirm { my %args = (-html_output => 1, @_); if(check_if_list_exists(-List=>$list) == 0){ &default; return; } my $lh = DADA::MailingList::Subscribers->new(-List => $list); my($status, $errors) = $lh->unsubscription_check(-Email => $email); user_error(-List => $list, -Error => "no_list", -Email => $email) if $errors->{no_list} == 1; require DADA::MailingList::Settings; my $ls = DADA::MailingList::Settings ->new(-List => $list); my $li = $ls->get(-Format => "replaced"); $status = 0 if check_email_pin(-Email => $email, -Pin => $pin) == 1; if($status == 0){ if(($li->{use_alt_url_unsub_failed} == 1) && ($li->{alt_url_unsub_failed} ne "")){ print $q->redirect(-uri => $li->{alt_url_unsub_failed}); return; }else{ user_error(-List => $list, -Error => 'invalid_pin', -Email => $email) if check_email_pin(-Email => $email, -Pin => $pin) == 1; user_error(-List => $list, -Error => "invalid_email", -Email => $email) if $errors->{invalid_email} == 1; user_error(-List => $list, -Error => "email_not_in_list", -Email => $email) if $errors->{not_subscribed} == 1; user_error(-List => $list, -Error => "no_list", -Email => $email) if $errors->{no_list} == 1; user_error(-List => $list, -Error => "settings_possibly_corrupted", -Email => $email) if $errors->{settings_possibly_corrupted} == 1; } }else{ my $rm_status = $lh->remove_from_list(-Email_List =>[$email],-List => $list); user_error(-List => $list, -Error => 'no_list', -Email => $email) if $rm_status eq 'no list'; user_error(-List => $list, -Error => 'too_busy', -Email => $email) if $rm_status eq 'too busy'; if(($li->{black_list} eq "1") and ($li->{add_unsubs_to_black_list} eq "1")){ $lh->add_to_email_list(-Email_Ref => [$email], -Type => 'black_list'); } require DADA::App::Messages; DADA::App::Messages::send_owner_happenings($list, $email, "unsubscribed"); if($li->{send_unsub_success_email} == 1){ require DADA::App::Messages; DADA::App::Messages::send_unsubscription_email(-List => $list, -Email => $email, -List_Info => $li); } if($args{-html_output} != 0){ if(($li->{use_alt_url_unsub_success} == 1) && ($li->{alt_url_unsub_success} ne "")){ print $q->redirect(-uri => $li->{alt_url_unsub_success}); return; }else{ print(the_html(-Part => "header", -Title => "Unsubscription Successful", -List => $list)); $li->{html_unsubscribed_message} =~ s/\[subscriber_email\]/$email/g; print $li->{html_unsubscribed_message}; print(the_html(-Part => "footer", -List => $list, -Site_Name => $li->{website_name}, -Site_URL => $li->{website_url})); return; } } } } sub confirm { my %args = (-html_output => 1, @_) ; $email = lc_email($email); my ($invalid_pin) = check_email_pin(-Email => $email, -Pin => $pin); if ($invalid_pin >= 1) { user_error(-List => $list, -Error => "invalid_pin", -Email => $email,); return; } require DADA::MailingList::Settings; my $lh = DADA::MailingList::Subscribers->new(-List => $list); my ($status, $errors) = $lh->subscription_check(-Email => $email); user_error(-List => $list, -Error => "no_list", -Email => $email) if $errors->{no_list} == 1; my $ls = DADA::MailingList::Settings->new(-List => $list); my $li = $ls->get(-Format => 'replaced'); if($status == 0){ if(($li->{use_alt_url_sub_failed} == 1) && ($li->{alt_url_failed} ne "")){ print $q->redirect(-uri => $li->{alt_url_sub_failed}); return; }else{ user_error(-List => $list, -Error => "invalid_email", -Email => $email) if $errors->{invalid_email} == 1; user_error(-List => $list, -Error => "mx_lookup_failed", -Email => $email) if $errors->{mx_lookup_failed} == 1; user_error(-List => $list, -Error => "email_in_list", -Email => $email) if $errors->{subscribed} == 1; user_error(-List => $list, -Error => "closed_list", -Email => $email) if $errors->{closed_list} == 1; user_error(-List => $list, -Error => "over_subscription_quota", -Email => $email) if $errors->{over_subscription_quota} == 1; user_error(-List => $list, -Error => "settings_possibly_corrupted", -Email => $email) if $errors->{settings_possibly_corrupted} == 1; unless($li->{allow_blacklisted_to_subscribe} eq "1"){ user_error(-List => $list, -Error => "black_listed", -Email => $email) if $errors->{blacklisted} == 1; } return; } }else{ $lh->add_to_email_list(-List => $list, -Email_Ref => [$email]); if($li->{send_sub_success_email} == 1){ require DADA::App::Messages; DADA::App::Messages::send_subscribed_message(-List => $list, -Email => $email, -Settings_obj => $ls, ); } require DADA::App::Messages; DADA::App::Messages::send_owner_happenings($list, $email, "subscribed"); if($args{-html_output} != 0){ if(($li->{use_alt_url_sub_success} == 1) && ($li->{alt_url_sub_success} ne "")){ print $q->redirect(-uri => $li->{alt_url_sub_success}); return; }else{ print(the_html(-Part => "header", -Title => "Subscription Successful", -List => $li->{list})); $li->{html_subscribed_message} =~ s/\[subscriber_email\]/$email/g; print $li->{html_subscribed_message}; print(the_html(-Part => "footer", -List => $li->{list}, -Site_Name => $li->{website_name}, -Site_URL => $li->{website_url})); return; } } } } sub all_list_code { print $q->header(); my $available_lists_ref = available_lists(-As_Ref=>1); if ($available_lists_ref->[0] ne undef) { print qq{

Choose a list:

Enter your email address:

}; require DADA::Template::Widgets; print DADA::Template::Widgets::list_popup_menu(); print qq{
}; }else{ print $q->p('There are no lists available right now.'); } } sub search_email { my ($admin_list, $root_login) = check_list_security(-cgi_obj => $q, -Function => 'search_email'); my $method = $q->param("method"); $list = $admin_list; require DADA::MailingList::Settings; my $ls = DADA::MailingList::Settings->new(-List => $list); my $li = $ls->get; my $lh = DADA::MailingList::Subscribers->new(-List => $list, -Path => $FILES); # debug my $any_subscribers = 1; unless($any_subscribers > 0){ print(admin_html_header(-Title => "Search Emails", -List => $li->{list}, -Root_Login => $root_login)); print $NO_ONE_SUBSCRIBED; print(admin_html_footer(-List => $list)); return; } print(admin_html_header(-Title => "Email Search Results", -List => $li->{list}, -Root_Login => $root_login)); if(defined($keyword)){ print '
'; print ''; if(($li->{black_list} eq "1") and ($li->{add_unsubs_to_black_list} eq "1")){ print $q->hidden('add_to_black_list',1); } my $found = $lh->search_email_list(-List => $list, -Method => $method, -Keyword => $keyword, -Type => $type, ); if($found == 0) { print "

Sorry, no matches were found. You may want to try and revise your search.

\n"; }else{ print '

check all :: uncheck all

'; print ''; print ''; print "


\n"; print "

A total of ",$found," email addresses were found when searching for \"",$keyword,"\""; print " when using ",$method," search."; } print <

Search Again:

EOF ; print(admin_html_footer(-List => $list)); }else{ print <Search through every email address on your list:
EOF ; print(admin_html_footer(-List => $list)); } } sub text_list { my ($admin_list, $root_login) = check_list_security(-cgi_obj => $q, -Function => 'text_list'); $list = $admin_list; require DADA::MailingList::Settings; my $ls = DADA::MailingList::Settings->new(-List => $list); my $li = $ls->get; my $lh = DADA::MailingList::Subscribers->new(-List => $list); my $email; print $q->header('text/plain'); print "Email Addresses for List: " . $li->{list_name} . "\n"; print "=" x 72, "\n"; my $email_count = $lh->print_out_list(-List=>$list, -Type => $type); print "=" x 72, "\n"; print "Total: $email_count \n\n"; } sub send_list_to_admin { my ($admin_list, $root_login) = check_list_security(-cgi_obj => $q, -Function => 'send_list_to_admin'); $list = $admin_list; require DADA::MailingList::Settings; my $ls = DADA::MailingList::Settings->new(-List => $list); my $li = $ls->get; my $email; my ($sec, $min, $hour, $day, $month, $year) = (localtime)[0,1,2,3,4,5]; $year = $year + 1900; $month = $month + 1; my $lh = DADA::MailingList::Subscribers->new(-List => $list); my $tmp_file = $lh->write_plaintext_list(-Type => $type); my $message = <{list_name} as of $month/$day/$year - $hour:$min:$sec. This was sent to the list owner ($li->{list_owner_email}) from the list control panel. -$PROGRAM_NAME EOF ; require MIME::Lite; MIME::Lite->quiet(1) if $MIME_HUSH == 1; ### I know what I'm doing $MIME::Lite::PARANOID = $MIME_PARANOID; my $msg = MIME::Lite->new(Type => 'multipart/mixed'); $msg -> attach(Type => 'TEXT', Data => $message); my $listname = $li->{list} . '_' . $type . '.list'; $msg->attach(Type => 'TEXT', Path => $tmp_file, Filename => $listname, Disposition => 'inline', Encoding => $li->{plaintext_encoding}, ); $msg->replace('X-Mailer' =>""); my $msg_headers = $msg->header_as_string(); my $msg_body = $msg->body_as_string(); require DADA::Mail::Send; my $mh = DADA::Mail::Send->new($li); my %mail_headers = $mh->return_headers($msg_headers); my %mailing = ( %mail_headers, To => '"'. escape_for_sending($li->{list_name}) .'" <'. $li->{list_owner_email} .'>', Subject => "$li->{list_name} $type subscriber list $month/$day/$year", Body => $msg_body, ); $mh->send(%mailing); unlink($tmp_file); print $q->redirect(-uri => "$S_PROGRAM_URL?flavor=view_list&type=" . $type); } sub preview_form { my $code = $q->param("code"); my ($admin_list, $root_login) = check_list_security(-cgi_obj => $q, -Function => 'preview_form'); print $q->header(); print < Form Preview

$code

close the window

EOF ; } sub new_list { require DADA::Security::Password; my $root_password = $q->param('root_password'); my $agree = $q->param('agree'); if(!$process) { my $errors = shift; my $flags = shift; my $pw_check; if(!$PROGRAM_ROOT_PASSWORD){ user_error(-List => $list, -Error => "no_root_password"); }elsif($ROOT_PASS_IS_ENCRYPTED == 1){ #encrypted password check $pw_check = DADA::Security::Password::check_password($PROGRAM_ROOT_PASSWORD, $root_password); }else{ # unencrypted password check if($PROGRAM_ROOT_PASSWORD eq $root_password){$pw_check = 1} } if ($pw_check == 1){ my @t_lists = available_lists(); $agree = 'yes' if $errors; if((!$t_lists[0]) && ($agree ne 'yes') && (!$process)){ print $q->redirect(-uri => "$S_PROGRAM_URL?agree=no"); } if(($LIST_QUOTA) && (($#t_lists + 1) >= $LIST_QUOTA)){ user_error(-List => $list, -Error => "over_list_quota"); } if(!$t_lists[0]){ $help = 1; } my $ending = undef; my $err_word = undef; if($errors){ $ending = ''; $err_word = 'was'; $ending = 's' if $errors > 1; $err_word = 'were' if $errors > 1; } print(the_html(-Part => "header", -Title => "Create a New List", )); require DADA::Template::Widgets; print DADA::Template::Widgets::screen(-screen => 'new_list_screen.tmpl', -vars => { errors => $errors, ending => $ending, err_word => $err_word, help => $help, root_password => $root_password, flags_list_name => $flags->{list_name}, list_name => $list_name, flags_list_exists => $flags->{list_exists}, flags_list => $flags->{list}, flags_shortname_too_long => $flags->{shortname_too_long}, flags_slashes_in_name => $flags->{slashes_in_name}, flags_weird_characters => $flags->{weird_characters}, flags_quotes => $flags->{quotes}, list => $list, flags_password => $flags->{password}, password => $password, flags_retype_password => $flags->{retype_password}, flags_password_ne_retype_password => $flags->{password_ne_retype_password}, retype_password => $retype_password, flags_invalid_list_owner_email => $flags->{invalid_list_owner_email}, list_owner_email => $list_owner_email, flags_list_info => $flags->{list_info}, info => $info, flags_privacy_policy => $flags->{privacy_policy}, privacy_policy => $privacy_policy, flags_physical_address => $flags->{physical_address}, physical_address => $physical_address, flags_list_name_bad_characters => $flags->{list_name_bad_characters}, }, ); print(the_html(-Part => "footer")); }else{ user_error(-List => $list, -Error => "invalid_root_password"); } }else{ chomp($list); $list =~ s/^\s+//; $list =~ s/\s+$//; $list =~ s/ /_/g; my $list_exists = check_if_list_exists(-List=>$list); my ($list_errors,$flags) = check_list_setup(-fields => {list => $list, list_name => $list_name, list_owner_email => $list_owner_email, password => $password, retype_password => $retype_password, info => $info, privacy_policy => $privacy_policy, physical_address => $physical_address, } ); if($list_errors >= 1){ undef($process); new_list($list_errors, $flags); }elsif($list_exists >= 1){ &user_error(-List => $list, -Error => "list_already_exists"); }else{ $admin_email = $list_owner_email if ! $admin_email; $admin_email = lc_email($admin_email); $list_owner_email = lc_email($list_owner_email); $password = DADA::Security::Password::encrypt_passwd($password); my %new_info = (list => $list, list_owner_email => $list_owner_email, admin_email => $admin_email, list_name => $list_name, password => $password, info => $info, privacy_policy => $privacy_policy, physical_address => $physical_address, ); %new_info = (%new_info, %LIST_SETUP_DEFAULTS); require DADA::MailingList; my $ls = DADA::MailingList::Create(-name => $list); $ls->save({%new_info}); my $status; require DADA::Logging::Usage; my $log = new DADA::Logging::Usage; $log->mj_log($list, 'List Created', "remote_host:$ENV{REMOTE_HOST}, ip_address:$ENV{REMOTE_ADDR}") if $LOG{list_lives}; my $li = $ls->get; my $escaped_list = uriescape($li->{list}); print(the_html(-Part => "header", -Title => "Your New List Has Been Created", )); require DADA::Template::Widgets; print DADA::Template::Widgets::screen(-screen => 'new_list_created_screen.tmpl', -vars => { list_name => $li->{list_name}, list => $li->{list}, escaped_list => $escaped_list, list_owner_email => $li->{list_owner_email}, info => $li->{info}, privacy_policy => $li->{privacy_policy}, physical_address => $li->{physical_address}, }, ); print(the_html(-Part => "footer")); } } } sub archive { # are we dealing with a real list? my $list_exists = check_if_list_exists(-List => $list); user_error(-List => $list, -Error => 'no_list') if ($list_exists == 0); my $start = $q->param('start') || 0; require DADA::MailingList::Settings; my $lh = DADA::MailingList::Settings->new(-List => $list); my $li = $lh->get; user_error(-List => $list, -Error => "no_show_archives") if ($li->{show_archives} == 0); require DADA::MailingList::Archives; my $archive = DADA::MailingList::Archives->new(-List => $li); my $entries = $archive->get_archive_entries(); ###### These are all little thingies. my $archive_send_form = ''; $archive_send_form = archive_send_form($list,$id, $q->param('send_archive_errors')) if $li->{archive_send_form} == 1 && defined($id); my $nav_table = ''; $nav_table = $archive->make_nav_table(-Id => $id, -List => $li->{list}) if defined($id); my $rss_link = $li->{publish_archives_rss} ? 1 : 0; my $archive_search_form = ''; $archive_search_form = $archive->make_search_form($li->{list}) if $li->{archive_search_form} == 1; my $archive_subscribe_form = ""; if($li->{hide_list} ne "1"){ $li->{info} =~ s/\n\n/

/gi; $li->{info} =~ s/\n/
/gi; unless ($li->{archive_subscribe_form} eq "0"){ $archive_subscribe_form .= "

" . $li->{info} . "

\n"; $archive_subscribe_form .= "

Subscribe to " . $li->{list_name} . ":

\n"; require DADA::Template::Widgets; $archive_subscribe_form .= DADA::Template::Widgets::screen(-screen => 'list_subscribe_form.tmpl', -expr => 1, -list => $li->{list}, -vars => { -email => $email, }, ); } } my $archive_widgets = { archive_send_form => $archive_send_form, nav_table => $nav_table, rss_link => $rss_link, archive_search_form => $archive_search_form, archive_subscribe_form => $archive_subscribe_form, }; #/##### These are all little thingies. if(!$id) { my $th_entries = []; my ($begin, $stop) = $archive->create_index($start); my $i; my $stopped_at = $begin; my $num = $begin; $num++; my @archive_nums; my @archive_links; # iterate and save for($i = $begin; $i <=$stop; $i++){ my $link; if(defined($entries->[$i])){ my ($subject, $message, $format, $raw_msg) = $archive->get_archive_info($entries->[$i]); # this is so atrocious. my $date = date_this(-Packed_Date => $archive->_massaged_key($entries->[$i]), -Write_Month => $li->{archive_show_month}, -Write_Day => $li->{archive_show_day}, -Write_Year => $li->{archive_show_year}, -Write_H_And_M => $li->{archive_show_hour_and_minute}, -Write_Second => $li->{archive_show_second}); my $entry = { id => $entries->[$i], date => $date, subject => $subject, 'format' => $format, list => $list, uri_escaped_list => uriescape($list), PROGRAM_URL => $PROGRAM_URL, message_blurb => $archive->message_blurb(-key => $entries->[$i]), }; $stopped_at++; push(@archive_nums, $num); push(@archive_links, $link); $num++; push(@$th_entries, $entry); } } my $ii; for($ii=0;$ii<=$#archive_links; $ii++){ my $bullet = $archive_nums[$ii]; #fix if we're doing reverse chronologic $bullet = (($#{$entries}+1) - ($archive_nums[$ii]) +1) if($li->{sort_archives_in_reverse} == 1); # yeah, whatever. $th_entries->[$ii]->{bullet} = $bullet; } my $index_nav = $archive->create_index_nav($li->{list}, $stopped_at); print(the_html(-Part => "header", -Start_Form => 0, -Title => $li->{list_name} . " Archives", -List => $li->{list})); require DADA::Template::Widgets; print DADA::Template::Widgets::screen(-screen => 'archive_index_screen.tmpl', -vars => { list => $list, list_name => $li->{list_name}, entries => $th_entries, index_nav => $index_nav, flavor_archive => 1, %$archive_widgets, }, ); print(the_html(-Part => "footer", -End_Form => 0, -List => $li->{list}, -Site_Name => $li->{website_name}, -Site_URL => $li->{website_url})); }else{ $id = $archive->newest_entry if $id =~ /newest/i; $id = $archive->oldest_entry if $id =~ /oldest/i; $id = $archive->_massaged_key($id); my $entry_exists = $archive->check_if_entry_exists($id); user_error(-List => $list, -Error => "no_archive_entry") if($entry_exists <= 0); my ($subject, $message, $format, $raw_msg) = $archive->get_archive_info($id); print(the_html(-Part => "header", -Title => $subject, -List => $li->{list}, -Start_Form => 0, )); my ($massaged_message_for_display, $content_type) = $archive->massaged_msg_for_display(-key => $id, -body_only => 1); my $show_iframe = $li->{html_archives_in_iframe} || 0; if($content_type eq 'text/plain'){ $show_iframe = 0; } my $header_from = undef; #my $header_date = undef; my $header_subject = undef; my $in_reply_to_id; my $in_reply_to_subject; if($raw_msg){ $header_from = $archive->get_header(-header => 'From', -key => $id); $header_from = entity_protected_str($header_from); $header_subject = $archive->get_header(-header => 'Subject', -key => $id); ($in_reply_to_id, $in_reply_to_subject) = $archive->in_reply_to_info(-key => $id); } my $attachments = ($li->{display_attachments} == 1) ? $archive->attachment_list($id) : []; # this is so atrocious. my $date = date_this(-Packed_Date => $id, -Write_Month => $li->{archive_show_month}, -Write_Day => $li->{archive_show_day}, -Write_Year => $li->{archive_show_year}, -Write_H_And_M => $li->{archive_show_hour_and_minute}, -Write_Second => $li->{archive_show_second}); require DADA::Template::Widgets; print DADA::Template::Widgets::screen(-screen => 'archive_screen.tmpl', -vars => { list => $list, list_name => $li->{list_name}, id => $id, subject => $subject, massaged_msg_for_display => $massaged_message_for_display, send_archive_success => $q->param('send_archive_success') ? $q->param('send_archive_success') : undef, send_archive_errors => $q->param('send_archive_errors') ? $q->param('send_archive_errors') : undef, show_iframe => $show_iframe, %$archive_widgets, discussion_list => ($li->{group_list} == 1) ? 1 : 0, header_from => $header_from, header_subject => $header_subject, in_reply_to_id => $in_reply_to_id, in_reply_to_subject => xss_filter($in_reply_to_subject), attachments => $attachments, date => $date, }, ); print(the_html(-Part => "footer", -End_Form => 0, -List => $li->{list}, -Site_Name => $li->{website_name}, -Site_URL => $li->{website_url}, )); } } sub archive_bare { if($q->param('admin')){ my ($admin_list, $root_login) = check_list_security(-cgi_obj => $q, -Function => 'view_archive'); $list = $admin_list; } require DADA::MailingList::Archives; require DADA::MailingList::Settings; my $ls = DADA::MailingList::Settings->new(-List => $list); my $li = $ls->get; my $la = DADA::MailingList::Archives->new(-List => $li); if(!$q->param('admin')){ user_error(-List => $list, -Error => "no_show_archives") if ($li->{show_archives} == 0); } user_error(-List => $list, -Error => "no_archive_entry") if($la->check_if_entry_exists($id) <= 0); print $q->header(); my $t = $la->massaged_msg_for_display(-key => $id); print $t; } sub search_archive { user_error(-List => $list, -Error => "no_list") if (check_if_list_exists(-List => $list) <= 0); require DADA::MailingList::Settings; my $ls = DADA::MailingList::Settings->new(-List => $list); my $li = $ls->get; user_error(-List => $list, -Error => "no_show_archives") if ($li->{show_archives} == 0); require DADA::MailingList::Archives; my $archive = DADA::MailingList::Archives -> new(-List => $li); my $entries = $archive->get_archive_entries(); my $ending = ""; my $count = 0; my $ht_summaries = []; my $search_results = $archive->search_entries($keyword); if(defined(@$search_results[0]) && (@$search_results[0] ne "")){ $count = $#{$search_results}+1; $ending = 's' if defined(@$search_results[1]); my $summaries = $archive->make_search_summary($keyword, $search_results); foreach(@$search_results){ my ($subject, $message, $format) = $archive->get_archive_info($_); my $date = date_this(-Packed_Date => $_, -Write_Month => $li->{archive_show_month}, -Write_Day => $li->{archive_show_day}, -Write_Year => $li->{archive_show_year}, -Write_H_And_M => $li->{archive_show_hour_and_minute}, -Write_Second => $li->{archive_show_second}); push(@$ht_summaries, { summary => $summaries->{$_}, subject => $subject, date => $date, id => $_, PROGRAM_URL => $PROGRAM_URL, list => uriescape($list), }); } } my $search_form = ''; if($li->{archive_search_form} == 1){ $search_form = $archive->make_search_form($li->{list}); } my $archive_subscribe_form = ''; if($li->{hide_list} ne "1"){ $li->{info} =~ s/\n\n/

/gi; $li->{info} =~ s/\n/
/gi; unless ($li->{archive_subscribe_form} eq "0"){ $archive_subscribe_form .= '

' . $li->{info} . '

' . "\n"; $archive_subscribe_form .= '

Subscribe to ' . $li->{list_name} . ':

' . "\n"; require DADA::Template::Widgets; $archive_subscribe_form .= DADA::Template::Widgets::screen(-screen => 'list_subscribe_form.tmpl', -expr => 1, -vars => { email => $email, list => $li->{list}, list_name => $li->{list_name}, }, ); } } print(the_html(-Part => "header", -Title => "Archive Search Results", -List => $li->{list}, -Start_Form => 0, )); require DADA::Template::Widgets; print DADA::Template::Widgets::screen(-screen => 'search_archive_screen.tmpl', -vars => { list_name => $li->{list_name}, uriescape_list => uriescape($list), list => $list, count => $count, ending => $ending, keyword => $keyword, summaries => $ht_summaries, search_results => $ht_summaries->[0] ? 1 : 0, search_form => $search_form, archive_subscribe_form => $archive_subscribe_form, }, ); print(the_html(-Part => "footer", -List => $li->{list}, -Site_Name => $li->{website_name}, -Site_URL => $li->{website_url}, -End_Form => 0, )); } sub send_archive { my $entry = $q->param('entry'); my $sender_email = $q->param('sender_email'); my $note = $q->param('note'); my $errors = 0; my $list_exists = check_if_list_exists(-List=>$list); user_error(-List => $list, -Error => "no_list") if ($list_exists <=0); $errors++ if(check_for_valid_email($email) == 1); $errors++ if(check_for_valid_email($sender_email) == 1); $errors++ if(check_referer($q->referer())) != 1; require DADA::MailingList::Settings; my $ls = DADA::MailingList::Settings->new(-List => $list); my $li = $ls->get; $errors++ if $li->{archive_send_form} != 1; if($errors > 0){ print $q->redirect(-uri => $PROGRAM_URL . '?f=archive&l=' . $list . '&id=' . $entry . '&send_archive_errors=' . $errors); }else{ require DADA::MailingList::Archives; my $archive = DADA::MailingList::Archives->new(-List => $li); my $archive_message_url = $PROGRAM_URL . '/archive/' . $list . '/' . $entry . '/'; my ($subject, $message, $format, $raw_msg) = $archive->get_archive_info($entry); require MIME::Lite; my $msg = MIME::Lite->new(From => $sender_email, To => $email, Subject => $subject . ' (Archive)', , Type => 'multipart/mixed' ); my $pt_msg = $li->{send_archive_message}; $pt_msg =~ s/\[sender_email\]/$sender_email/g; $pt_msg =~ s/\[note\]/$note/g; $pt_msg =~ s/\[archive_message_url\]/$archive_message_url/g; my $pt = MIME::Lite->new(Type => 'text/plain', Data => $pt_msg, Encoding => $li->{plaintext_encoding}); my $html_msg = $li->{send_archive_message_html}; $html_msg =~ s/\[sender_email\]/$sender_email/g; $html_msg =~ s/\[note\]/$note/g; $html_msg =~ s/\[archive_message_url\]/$archive_message_url/g; my $html = MIME::Lite->new(Type => 'text/html', Data => $html_msg, Encoding => $li->{html_encoding} ); my $ma = MIME::Lite->new(Type => 'multipart/alternative'); $ma->attach($pt); $ma->attach($html); $msg->attach($ma); my $a_msg; if($raw_msg){ $a_msg = MIME::Lite->new(Type => 'message/rfc822', Disposition => "inline", Data => $archive->massage_msg_for_resending(-key => $entry), ); }else{ $a_msg = MIME::Lite->new(Type => 'message/rfc822', Disposition => "inline", Type => $format, Data => $message ); } $msg->attach($a_msg); require DADA::App::FormatMessages; my $fm = DADA::App::FormatMessages->new(-List => $list); $fm->use_list_template(0); $fm->use_email_templates(0); $fm->use_header_info(1); my ($final_header, $final_body) = $fm->format_headers_and_body(-msg => $msg->as_string ); require DADA::Mail::Send; my $mh = DADA::Mail::Send->new($li); $mh->send( $mh->return_headers($final_header), Body => $final_body, ); print $q->redirect(-uri => $PROGRAM_URL . '?f=archive&l=' . $list . '&id=' . $entry . '&send_archive_success=1'); } } sub archive_rss { my %args = (-type => 'rss', @_ ); my $list_exists = check_if_list_exists(-List=>$list); print $q->header('application/xml'); if ($list_exists == 0){ }else{ require DADA::MailingList::Settings; my $ls = DADA::MailingList::Settings->new(-List => $list); my $li = $ls->get; if ($li->{show_archives} == 0){ }else{ if($li->{publish_archives_rss} == 0){ }else{ require DADA::MailingList::Archives; my $archive = DADA::MailingList::Archives->new(-List => $li); if($args{-type} eq 'rss'){ print $archive->rss_index(); }elsif($args{-type} eq 'atom'){ print $archive->atom_index(); }else{ warn "wrong type of feed asked for: " . $args{-type} . ' - '. $!; } } } } } sub archive_atom { archive_rss(-type => 'atom'); } sub email_password { require DADA::MailingList::Settings; my $ls = DADA::MailingList::Settings->new(-List => $list); my $li = $ls->get; require DADA::Security::Password; if(( $li->{pass_auth_id} ne "") && ( defined($li->{pass_auth_id})) && ( $q->param('pass_auth_id') eq $li->{pass_auth_id})){ my $new_passwd = DADA::Security::Password::generate_password(); my $new_encrypt = DADA::Security::Password::encrypt_passwd($new_passwd); $ls->save({ password => $new_encrypt, pass_auth_id => '' }); require DADA::Mail::Send; my $mh = DADA::Mail::Send->new($li); my $Body = qq{ Hello, Someone asked for the $PROGRAM_NAME List Password password for: $li->{list_name} to be emailed to this address. Since you are the list owner, the password is: $new_passwd Notice, you probably didn't use this password to begin with, $PROGRAM_NAME stores passwords that are encrypted and no password it stores can be "unencrypted" So, a new, random password is generated. You may reset the password to anything you want in the list control panel. Please be sure to delete this email for security reasons. -$PROGRAM_NAME }; $mh->send(From => '"' . escape_for_sending($li->{list_name}) . '" <' . $li->{list_owner_email} . '>', To => '"List Owner for: '. escape_for_sending($li->{list_name}) .'" <'. $li->{list_owner_email} .'>', Subject => "List Password", Body => $Body, ); print $q->redirect(-uri => $S_PROGRAM_URL . '?flavor=sign_in&list=' . $list); }else{ require DADA::Mail::Send; my $mh = DADA::Mail::Send->new($li); my $rand_str = DADA::Security::Password::generate_rand_string(); $ls->save({pass_auth_id => $rand_str}); my $Body = qq{ Hello, Someone asked for the $PROGRAM_NAME List Password password for: $li->{list_name} to be emailed to this address. Before this can be done, it has to be confirmed that the list owner (meaning you) actually wants a new password to be set for this list and mailed to you. To confirm this, visit this URL: $S_PROGRAM_URL?f=email_password&l=$list&pass_auth_id=$rand_str By visiting this URL, you will reset the list password. This new password will then be emailed to you. You will then be redirected to the admin login screen. If you do not know why you were sent this email, ignore it and your password will not be changed. -$PROGRAM_NAME }; $mh->send(From => '"' . escape_for_sending($li->{list_name}) . '" <' . $li->{list_owner_email} . '>', To => '"List Owner for: '. escape_for_sending($li->{list_name}) .'" <'. $li->{list_owner_email} .'>', Subject => "Confirm List Password Change", Body => $Body ); print(the_html(-Part => "header", -Title => "Confirm Password Change", -List => $list)); print '

A confirmation email has been sent to the list owner of ' . $li->{list_name} . ' to confirm the password change.

'; print(the_html(-Part => "footer", -List => $list)); } } sub login { my $location = $q->param('referer') || $DEFAULT_ADMIN_SCREEN; $location = $DEFAULT_ADMIN_SCREEN if $location eq $PROGRAM_URL; my $admin_password = $q->param('admin_password') || ""; my $admin_list = $q->param('admin_list') || ""; $list = $admin_list; my $cookie; if(check_if_list_exists(-List=>$list) >= 1){ require DADA::Security::Password; my $dumb_cookie = $q->cookie(-name => 'blankpadding', -value => 'blank', %COOKIE_PARAMS, ); require DADA::App::Session; my $dada_session = DADA::App::Session->new(); my $login_cookie = $dada_session->login_cookie(-cgi_obj => $q, -list => $list, -password => $admin_password); if($LOG{logins}){ require DADA::Logging::Usage; my $log = new DADA::Logging::Usage; my $rh = $ENV{REMOTE_HOST} || ''; my $ra = $ENV{REMOTE_ADDR} || ''; $log->mj_log($admin_list, 'login', 'remote_host:' . $rh . ', ip_address:' . $ra); } print $q->header(-cookie => [$dumb_cookie, $login_cookie], -nph => $NPH, -Refresh =>'0; URL=' . $location); print $q->start_html(-title=>'Logging On...', -BGCOLOR=>'#FFFFFF' ); print $q->p($q->a({-href => $location}, 'Logging On...')); print $q->end_html(); $dada_session->remove_old_session_files(); }else{ user_error(-List => $list, -Error => "no_list", ); } } sub logout { my %args = (-redirect => 1, -redirect_url => $PROGRAM_URL, @_); my ($admin_list, $root_login) = check_list_security(-cgi_obj => $q, -Function => 'logout'); my $l_list = $admin_list; my $location = $args{-redirect_url}; if ($LOG{logins} != 0){ require DADA::Logging::Usage; my $log = new DADA::Logging::Usage; $log->mj_log($l_list, 'logout', "remote_host:$ENV{REMOTE_HOST}, ip_address:$ENV{REMOTE_ADDR}"); } require DADA::App::Session; my $dada_session = DADA::App::Session->new(-List => $l_list); my $logout_cookie = $dada_session->logout_cookie(-cgi_obj => $q); if($args{-redirect} == 1){ print $q->header(-COOKIE => $logout_cookie, -nph => $NPH, -Refresh =>'0; URL=' . $location, ); print $q->start_html(-title =>'Logging Out...', -BGCOLOR =>'#FFFFFF' ), $q->p($q->a( {-href => $location}, 'Logging Out...')), $q->end_html(); } } sub change_login { my ($admin_list, $root_login) = check_list_security(-cgi_obj => $q, -Function => 'change_login'); die "only for root logins!" if ! $root_login; require DADA::App::Session; my $dada_session = DADA::App::Session->new(); my $change_to_list = $q->param('change_to_list'); my $location = $q->param('location'); $q->delete_all(); $location =~ s/(\;|\&)done\=1$//; my $new_cookie = $dada_session->change_login(-cgi_obj => $q, -list => $change_to_list); print $q->header(-cookie => [$new_cookie], -nph => $NPH, -Refresh =>'0; URL=' . $location); print $q->start_html(-title=>'Switching...', -BGCOLOR=>'#FFFFFF' ); print $q->p($q->a({-href => $location}, 'Switching...')); print $q->end_html(); } sub checker { # I really don't understand how this subroutine got.. invented. my ($admin_list, $root_login) = check_list_security(-cgi_obj => $q, -Function => 'checker'); $list = $admin_list; # TODO - why isn't his here? Why aren't we reading it from the pref?! my $add_to_black_list = $q->param('add_to_black_list') || 0; my $lh = DADA::MailingList::Subscribers->new(-List => $list); my $ls = DADA::MailingList::Settings->new(-List => $list); my $li = $ls->get; my $email_count = $lh->remove_from_list(-List => $list, -Email_List => \@address, -Type => $type, ); my $should_add_to_black_list = 0; if($type eq 'list'){ if($li->{black_list} == 1 && $li->{add_unsubs_to_black_list} == 1 ){ $lh->add_to_email_list(-Email_Ref => \@address, -List => $list, -Type => 'black_list'); } } print $q->redirect(-uri=>"$S_PROGRAM_URL?flavor=view_list&delete_email_count=$email_count&type=" . $type); } sub file_upload { my $upload_file = shift; my $fu = CGI->new(); my $file = $fu->param($upload_file); if ($file ne "") { my $fileName = $file; $fileName =~ s!^.*(\\|\/)!!; eval {require URI::Escape}; if(!$@){ $fileName = URI::Escape::uri_escape($fileName, "\200-\377"); }else{ warn('no URI::Escape is installed!'); } $fileName =~ s/\s/%20/g; my $outfile = make_safer($TMP . '/' . time . '_' . $fileName); open (OUTFILE, '>' . $outfile) or warn("can't write to " . $outfile . ": $!"); while (my $bytesread = read($file, my $buffer, 1024)) { print OUTFILE $buffer; } close (OUTFILE); chmod($FILE_CHMOD, $outfile); return $outfile; } } sub pass_gen { my $pw = $q->param('pw'); print(the_html(-Part => "header", -Title => "Password Encryption")); if(!$pw){ print $q->p("Enter a password that you would like to encrypt.", $q->hidden('f', 'pass_gen'), $q->password_field(-name=>'pw', -size=>8), $q->submit(-value=>'encrypt password')); }else{ require DADA::Security::Password; my $en_pw = DADA::Security::Password::encrypt_passwd($pw); print $q->p('Your encrypted password is:'), $q->p($en_pw), $q->p('In Config.pm, use this password as your ', $q->b('$PROGRAM_ROOT_PASSWORD'), 'and set ', $q->b('$ROOT_PASS_IS_ENCRYPTED'), 'to 1.'), $q->p("When asked for your $PROGRAM_NAME Root Password, you will still type in the unencrypted pasword, not this gobbledygook."); } print(the_html(-Part => "footer")); } sub setup_info { my $root_password = $q->param('root_password') || ''; if(root_password_verification($root_password) == 1){ my $home_dir_guess = $ENV{DOCUMENT_ROOT}; my $pub_html_dir = $home_dir_guess; $pub_html_dir =~ s(^.*/)(); $home_dir_guess =~ s/\/$pub_html_dir$//g; my $sendmails = []; if ($OS !~ /^Win|^MSWin/i){ push(@$sendmails, {location => $_}) foreach(split(" ", `whereis sendmail`)); } print(the_html(-Part => "header", -Title => "Setup Information" )); require DADA::Template::Widgets; print DADA::Template::Widgets::screen(-screen => 'setup_info_screen.tmpl', -vars => { FILES => $FILES, exists_FILES => (-e $FILES) ? 1 : 0, FILES_starts_with_a_slash => ($FILES =~ m/^\//) ? 1 : 0, FILES_ends_in_a_slash => ($FILES =~ m/\/$/) ? 1 : 0, DOCUMENT_ROOT => $ENV{DOCUMENT_ROOT}, home_dir_guess => $home_dir_guess, MAILPROG => $MAILPROG, sendmails => $sendmails, }, ); print(the_html(-Part => "footer")); }else{ my $program_url_guess = $PROGRAM_URL; $program_url_guess = $q->script_name() if $PROGRAM_URL eq "" || $PROGRAM_URL eq 'http://www.changetoyoursite.com/cgi-bin/dada/mail.cgi'; # default. my $incorrect_root_password = $root_password ? 1 : 0; print(the_html(-Part => 'header', -Title => 'Setup Information', -Start_Form => 0 )); require DADA::Template::Widgets; print DADA::Template::Widgets::screen(-screen => 'setup_info_login_screen.tmpl', -vars => { program_url_guess => $program_url_guess, incorrect_root_password => $incorrect_root_password, }, ); print(the_html(-Part => 'footer', -End_Form => 0 )); } } sub reset_cipher_keys { my $root_password = $q->param('root_password'); my $root_pass_check = root_password_verification($root_password); if($root_pass_check == 1){ require DADA::Security::Password; my @lists = available_lists(); foreach(@lists){ setup_list({list=> $_, cipher_key => DADA::Security::Password::make_cipher_key()}); } print(the_html(-Part => "header", -Title => "Reset Cipher Keys")); print $q->p("Cipher keys have been reset."); print(the_html(-Part => "footer")); }else{ print(the_html(-Part => "header", -Title => "Reset Cipher Keys")); print $q->p("Please enter the correct $PROGRAM_NAME Root Password to continue, every list cipher key will be reset:", $q->br(), $q->hidden('flavor', 'reset_cipher_keys') , $q->password_field('root_password', ''), $q->submit('Continue')), $q->p('Why would you want to do this? If you are upgrading Dada Mail from any version under 2.7.1, your list needs a cipher key to encrypt sensitive information.'); print(the_html(-Part => "footer")); } } sub restore_lists { if(root_password_verification($q->param('root_password'))){ require DADA::MailingList::Settings; require DADA::MailingList::Archives; my @lists = available_lists(); if($process eq 'true'){ my %restored; foreach my $r_list(@lists){ if($q->param('restore_'.$r_list.'_settings') && $q->param('restore_'.$r_list.'_settings') == 1){ my $ls = DADA::MailingList::Settings->new(-List => $r_list); $ls->{ignore_open_db_error} = 1; $ls->restoreFromFile($q->param('settings_'.$r_list.'_version')); } } foreach my $r_list(@lists){ if($q->param('restore_'.$r_list.'_archives') && $q->param('restore_'.$r_list.'_archives') == 1){ my $ls = DADA::MailingList::Settings->new(-List => $r_list); $ls->{ignore_open_db_error} = 1; my $la = DADA::MailingList::Archives->new(-List => {list => $r_list}, ignore_open_db_error => 1); $la->restoreFromFile($q->param('archives_'.$r_list.'_version')); } } print(the_html(-Part => "header", -Title => "Restore List Information - Complete")); print $q->p("List Information restored."); print $q->p("Return to the $PROGRAM_NAME main page."); print(the_html(-Part => "footer")); }else{ my $backup_hist = {}; foreach(@lists){ my $ls = DADA::MailingList::Settings->new(-List => $_); $ls->{ignore_open_db_error} = 1; my $la = DADA::MailingList::Archives->new(-List => {list => $_}, ignore_open_db_error => 1); #yeah, it's diff from MailingList::Settings - I'm stupid. $backup_hist->{$_}->{settings} = $ls->backupDirs; $backup_hist->{$_}->{archives} = $la->backupDirs; } print(the_html(-Part => "header", -Title => "Restore List Information")); print $q->p($q->strong("Before restoring ANY of your list settings, please make on server and remote backups of all your $PROGRAM_NAME list files, no matter what facility they are in.")); print $q->p("Please also make sure your list settings are indeed corrupted and not just unreadable because of insufficient file permissions or wrong \@AnyDBM_File Config.pm settings."); # labels are for the popup menus, that's it # my %labels; foreach (sort keys %$backup_hist){ foreach(@{$backup_hist->{$_}->{settings}}){ $labels{$_} = scalar(localtime($_)); } foreach(@{$backup_hist->{$_}->{archives}}){ $labels{$_} = scalar(localtime($_)); } } # # foreach my $f_list(keys %$backup_hist){ print $q->start_table({-cellpadding => 5}); print $q->h3($f_list); print $q->Tr( $q->td({-valign => 'top'}, [ ($q->p($q->strong('Restore?'))), ($q->p($q->strong('Backup Version*:'))), ])); foreach ('settings', 'archives'){ if (scalar @{$backup_hist->{$f_list}->{$_}}){ print $q->Tr( $q->td([ ($q->p($q->checkbox( -name => 'restore_'.$f_list.'_'.$_, -id => 'restore_'.$f_list.'_'.$_, -value => 1, -label => ' ', ), '' )), ($q->p($q->popup_menu( -name => $_ . '_' . $f_list . '_version', '-values' => $backup_hist->{$f_list}->{$_}, -labels => {%labels}))), ])); }else{ print $q->Tr( $q->td([ (' '), ($q->p({-class=>'error'}, '-- No Backup Information Found --')), ])); } } print '
'; } print $q->p($q->em('*The most recent backup is usually the best')); print $q->hidden('flavor', 'restore_lists'); print $q->hidden('root_password', $q->param('root_password')); print $q->hidden('process', 'true'); # this should be changed... print submit_form(-Submit=>'Restore Checked List\'s Data'); print(the_html(-Part => "footer")); } }else{ print(the_html(-Part => "header", -Title => "Restore List Information")); print $q->p("Please enter the correct $PROGRAM_NAME Root Password to begin restoring list settings:", $q->br(), $q->hidden('flavor', 'restore_lists') , $q->password_field('root_password', ''), $q->submit('Continue...')) , $q->p($q->strong('No'), 'Changes will be made to our list files by clicking, "Continue".'); print(the_html(-Part => "footer")); } } sub test_layout { my ($admin_list, $root_login) = check_list_security(-cgi_obj => $q, -Function => 'test_layout'); print(admin_html_header(-Title => "Layout Test", -List => $admin_list, -Root_Login => $root_login)); require DADA::Template::Widgets; print DADA::Template::Widgets::screen(-screen => 'test_layout_screen.tmpl'); print(admin_html_footer(-List => $admin_list)); } sub send_email_testsuite { my ($admin_list, $root_login) = check_list_security(-cgi_obj => $q, -Function => 'send_email_testsuite', ); print(admin_html_header(-Title => "Mail Formatting Test", -List => $admin_list, -Root_Login => $root_login, -Form => 0)); require DADA::Template::Widgets; my $templates_dir = DADA::Template::Widgets::templates_dir(); print DADA::Template::Widgets::screen(-screen => 'send_email_testsuite_screen.tmpl', -vars => {templates_dir => $templates_dir}); print(admin_html_footer(-List => $admin_list, -Form => 0)); } sub subscriber_help { if(!$list){ &default; return; } if(check_if_list_exists(-List => $list) == 0){ undef($list); &default; return; } require DADA::MailingList::Settings; my $ls = DADA::MailingList::Settings->new(-List => $list); my $li = $ls->get; print(the_html(-Part => "header", -Title => "Subscription Help", -List => $list, -Start_Form => 0)); require DADA::Template::Widgets; print DADA::Template::Widgets::screen(-screen => 'subscriber_help_screen.tmpl', -vars => { list => $list, list_name => $li->{list_name}, list_owner_email => entity_protected_str($li->{list_owner_email}), } ); print(the_html(-Part => "footer", -List => $list, -End_Form => 0)); } sub show_img { file_attachment(-inline_image_mode => 1); } sub file_attachment { my %args = (-inline_image_mode => 0, @_); if(check_if_list_exists(-List=>$list) == 1){ require DADA::MailingList::Settings; my $ls = DADA::MailingList::Settings->new(-List => $list); my $li = $ls->get; if($li->{show_archives} == 1){ if($li->{display_attachments} == 1){ require DADA::MailingList::Archives; my $la = DADA::MailingList::Archives->new(-List => $li); if($la->can_display_attachments){ if($la->check_if_entry_exists($q->param('id'))){ if($args{-inline_image_mode} == 1){ print $la->view_inline_attachment(-id => $q->param('id'), -cid => $q->param('cid')); }else{ print $la->view_file_attachment(-id => $q->param('id'), -filename => $q->param('filename')); } } else { user_error(-List => $list, -Error => "no_archive_entry"); } } else { user_error(-List => $list, -Error => "no_display_attachments"); } } else { user_error(-List => $list, -Error => "no_display_attachments"); } } else { user_error(-List => $list, -Error => "no_show_archives"); } } else { user_error(-List => $list, -Error => 'no_list'); } } sub redirection { require DADA::Logging::Clickthrough; my $r = DADA::Logging::Clickthrough->new($q->param('list')); $r->r_log($q->param('mid'), $q->param('url')); if($q->param('url')){ print $q->redirect(-uri => $q->param('url')); }else{ print $q->redirect(-uri => $PROGRAM_URL); } } sub m_o_c { require DADA::Logging::Clickthrough; my $r = DADA::Logging::Clickthrough->new($q->param('list')); $r->o_log($q->param('mid')); require MIME::Base64; print$q->header('image/png'); # a simple, 1px png image. my $str = <header(); print "Dada Mail is originally written by Justin Simoni"; } sub smtm { # SHOW ME THE MONEY! print $q->redirect(-uri => 'http://dadamail.org'); } sub _chk_env_sys_blk { if($ENV{QUERY_STRING} =~ /^\x61\x72\x74/){ print $q->header('text/plain') . "\x61\x72\x74" . scalar reverse('lohraW ydnA - .htiw yawa teg nac uoy tahw si '); exit; } if($ENV{PATH_INFO} && $ENV{PATH_INFO} =~ /^\/\x61\x72\x74/){ eval {require DADA::Template::Widgets::janizariat::tatterdemalion::jibberjabber}; if(!$@){ print DADA::Template::Widgets::janizariat::tatterdemalion::jibberjabber::thimblerig($ENV{PATH_INFO}); exit; } } } __END__ =pod =head1 COPYRIGHT Copyright (c) 1999 - 2005 Justin Simoni http://justinsimoni.com All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. =cut