mirror of
https://gitlab.com/t6353/sharee.bike.git
synced 2025-02-22 11:46:27 +01:00
MailTransport reafctoring
This commit is contained in:
parent
9082b161de
commit
4262462fc8
8 changed files with 71 additions and 50 deletions
|
@ -75,7 +75,7 @@ my $response = {
|
|||
response_state => "OK, nothing todo",
|
||||
privacy_html => "site/privacy_1.html",
|
||||
agb_html => "site/agb.html",
|
||||
impress_html => "site/impress.html",
|
||||
impress_html => "site/impress_1.html",
|
||||
tariff_info_html => "site/tariff_info_1.html",
|
||||
bike_info_html => "site/bike_info.html",
|
||||
lang => "DE",
|
||||
|
|
|
@ -292,7 +292,7 @@ sub channel_map(){
|
|||
192 => "Web Bayern",
|
||||
193 => "Web Demo",#mig
|
||||
194 => "Web Example",#mig
|
||||
195 => "Web KN",#mig
|
||||
195 => "Web KN",#mig and import
|
||||
196 => "DMS Form std",#mig
|
||||
197 => "Web Form std",#mig
|
||||
198 => "primary",#mig
|
||||
|
|
|
@ -615,7 +615,7 @@ sub update_users4trans(){
|
|||
c_id4trans='$c_id4trans',
|
||||
tpl_id4trans='$tpl_id4trans',
|
||||
ctpos_activ='0',
|
||||
kind_of_trans='$kind_of_trans'
|
||||
kind_of_trans='Faktura'
|
||||
where u_id=$u_id");
|
||||
my $rows = $sth->execute();
|
||||
return $rows;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package Mod::MailTransport;
|
||||
package MailTransport;
|
||||
#
|
||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
# Copyright (c) Rainer Gümpelein, TeilRad GmbH
|
||||
|
@ -33,34 +33,15 @@ my $q = new CGI;
|
|||
my $bw = new Basework;
|
||||
my $dbt = new DBtank;
|
||||
|
||||
my $mailx_file = "/var/www/copri4/shareeconf/mailx.cfg";
|
||||
my $conf = Config::General->new($mailx_file);
|
||||
my %mailxconf = $conf->getall;
|
||||
sub mail_connect {
|
||||
my $self = shift;
|
||||
my $sendref = shift;
|
||||
|
||||
sub send_mail(){
|
||||
my $self = shift;
|
||||
my $sendref = shift;
|
||||
my $now_dt = strftime "%Y-%m-%d %H:%M:%S", localtime;
|
||||
my $mailx_file = "/var/www/copri4/shareeconf/mailx.cfg";
|
||||
my $conf = Config::General->new($mailx_file);
|
||||
my %mailxconf = $conf->getall;
|
||||
|
||||
open(EMA, ">> $dbt->{copri_conf}->{logdir}/mailtransport.log");
|
||||
|
||||
my $mail_from = $sendref->{mail_from} || $mailxconf{$sendref->{mailxcfg}}->{mail_from};
|
||||
my $mail_to = $sendref->{mail_to} || $mailxconf{$sendref->{mailxcfg}}->{mail_to};
|
||||
my $filename = $sendref->{filename} || "";
|
||||
|
||||
print EMA "\n$now_dt, start mailing to: $mail_to | subject: $sendref->{subject}\n";
|
||||
|
||||
my $html = "<html><head><title>$sendref->{subject}</title></head><body style='text-align:left;border:0px solid silver;padding:15px;margin:2%;width:90%;'>\n";
|
||||
$html .= "<div>$sendref->{message}</div>\n";
|
||||
$html .= "<div>$sendref->{signature}</div>\n" if($sendref->{signature});
|
||||
$html .= "</body></html>";
|
||||
|
||||
|
||||
$bw->log("Trying send_mail:$0",$sendref,"");
|
||||
|
||||
if(ref($sendref) eq "HASH"){
|
||||
|
||||
my $smtp = Net::SMTP->new($mailxconf{$sendref->{mailxcfg}}->{mail_gateway},
|
||||
my $smtp = Net::SMTP->new($mailxconf{$sendref->{mailxcfg}}->{mail_gateway},
|
||||
Port => 465,
|
||||
Hello => 'sharee.bike',
|
||||
Timeout => 30,
|
||||
|
@ -68,18 +49,49 @@ sub send_mail(){
|
|||
SSL => 1,
|
||||
);
|
||||
|
||||
$smtp->auth($mailxconf{$sendref->{mailxcfg}}->{sasl_username},$mailxconf{$sendref->{mailxcfg}}->{sasl_password});
|
||||
$smtp->mail($mailxconf{$sendref->{mailxcfg}}->{mail_from});
|
||||
$smtp->auth($mailxconf{$sendref->{mailxcfg}}->{sasl_username},$mailxconf{$sendref->{mailxcfg}}->{sasl_password});
|
||||
$smtp->mail($mailxconf{$sendref->{mailxcfg}}->{mail_from});
|
||||
|
||||
if($dbt->{copri_conf}->{stage} eq "test"){
|
||||
$mail_to = $mailxconf{$sendref->{mailxcfg}}->{mail_to};
|
||||
$sendref->{subject} .= "* offline Test *";
|
||||
}
|
||||
return ($smtp,\%mailxconf);
|
||||
}
|
||||
|
||||
sub mail_transport(){
|
||||
my $self = shift;
|
||||
my $smtp = shift;
|
||||
my $mailxconf = shift;
|
||||
my $sendref = shift;
|
||||
|
||||
#print Dumper($smtp);
|
||||
|
||||
my $now_dt = strftime "%Y-%m-%d %H:%M:%S", localtime;
|
||||
open(EMA, ">> $dbt->{copri_conf}->{logdir}/mailtransport.log");
|
||||
|
||||
my $mail_from = $sendref->{mail_from} || $mailxconf->{$sendref->{mailxcfg}}->{mail_from};
|
||||
my $mail_to = $sendref->{mail_to} || $mailxconf->{$sendref->{mailxcfg}}->{mail_to};
|
||||
my $subject = $sendref->{subject};
|
||||
|
||||
if($dbt->{copri_conf}->{stage} eq "test"){
|
||||
$mail_to = $mailxconf->{$sendref->{mailxcfg}}->{mail_to};
|
||||
$subject = "* offline Test * " . $sendref->{subject};
|
||||
}
|
||||
|
||||
print EMA "\n$now_dt, start mailing to: $mail_to | subject: $subject\n";
|
||||
|
||||
my $html = "<html><head><title>$subject</title></head><body style='text-align:left;border:0px solid silver;padding:15px;margin:2%;width:90%;'>\n";
|
||||
$html .= "<div>$sendref->{message}</div>\n";
|
||||
$html .= "<div>$sendref->{signature}</div>\n" if($sendref->{signature});
|
||||
$html .= "</body></html>";
|
||||
|
||||
|
||||
$bw->log("Trying send_mail by $0",$mail_to,"");
|
||||
|
||||
if(ref($sendref) eq "HASH"){
|
||||
|
||||
|
||||
if ($smtp->to($mail_to)) {
|
||||
$smtp->data();
|
||||
$smtp->datasend("To: $mail_to\n");
|
||||
$smtp->datasend("Subject: $sendref->{subject}\nMIME-Version: 1.0\nContent-Type: text/html; charset=UTF-8 \n\n");
|
||||
$smtp->datasend("Subject: $subject\nMIME-Version: 1.0\nContent-Type: text/html; charset=UTF-8 \n\n");
|
||||
$smtp->datasend($html);
|
||||
$smtp->dataend();
|
||||
} else {
|
||||
|
|
|
@ -55,13 +55,20 @@ sub sms_ack_digest {
|
|||
|
||||
my $sms_from = "Mietradcode";
|
||||
my $sms_to = $ctadr->{txt07};# || "+491799xxxx72";
|
||||
my $sms_message = "";
|
||||
|
||||
#goes to test if devel or joke bsp nr
|
||||
if($dbt->{copri_conf}->{stage} eq "test" || $ctadr->{txt07} =~ /17012345678/){
|
||||
$ctadr->{txt07} = "$dbt->{copri_conf}->{sms_to}";
|
||||
$sms_message = "* offline Test *";
|
||||
}
|
||||
if($ctadr->{txt07} =~ /^0/ || $ctadr->{txt07} !~ /\+[1-9]/){
|
||||
my $sms_tosub = $ctadr->{txt07};
|
||||
$sms_tosub =~ s/^00/\+/g;
|
||||
$sms_tosub =~ s/^0/\+49/g;
|
||||
$sms_to = $sms_tosub;
|
||||
}
|
||||
my $sms_message = "Ihr Mietradsystem SMS-Bestätigungscode lautet: $sms_ack_digest";
|
||||
$sms_message .= "Ihr Mietradsystem SMS-Bestätigungscode lautet: $sms_ack_digest";
|
||||
my $message = Encode::encode('iso-8859-1', Encode::decode('utf-8',"$sms_message"));
|
||||
|
||||
open(FILE,">>$dbt->{copri_conf}->{logdir}/sms_gtx.log");
|
||||
|
|
|
@ -30,8 +30,10 @@ my %varenv = $cf->envonline();
|
|||
my $cookie = CGI::Cookie->new(-name => 'domcookie',-value => $coo);
|
||||
print $q->header(-charset=>"utf-8", -cookie=>$cookie);
|
||||
}
|
||||
|
||||
die "no configuration available" if(!$varenv{wwwhost});
|
||||
|
||||
my $operator_key = $q->param('api_test');
|
||||
|
||||
my $lang = "de";
|
||||
my $dyn_js = "
|
||||
function onLoad() {
|
||||
|
@ -149,7 +151,7 @@ print $q->div({-style=>'margin:15px;'},$q->a({-target=>'_blank', -href=>"$user_m
|
|||
|
||||
###
|
||||
print $q->div({-style=>'margin:15px;'}," "),"\n";
|
||||
my $uriop = "$dbt->{operator}->{sharee_operator}->{operatorApp}/APIjsonserver";
|
||||
my $uriop = "$dbt->{operator}->{$operator_key}->{operatorApp}/APIjsonserver";
|
||||
print $q->div({-style=>'margin:15px;'},"-------------- $uriop --------------------"),"\n";
|
||||
my $booking_request = "$uriop?request=booking_request&bike=FR1003&authcookie=$coo";
|
||||
print $q->div({-style=>'margin:15px;'},$q->a({-target=>'_blank', -href=>"$booking_request"},"[ booking_request ]---> $booking_request")),"\n";
|
||||
|
|
|
@ -41,7 +41,8 @@ sub tpl(){
|
|||
|
||||
if($users_sharee->{c_id} && $R::sharee_edit ne "delete_account2" && ($users_sharee->{c_id} eq $varenv->{superu_id} || $dbt->{copri_conf}->{stage} eq "test")){
|
||||
my $coo = $q->cookie('domcookie') || $q->param('sessionid') || "";
|
||||
print $q->div({-style=>'text-align:right;height:25px;padding:6px 15px 6px 0px;background-color:white'},$q->a({-style=>"color:#$bgcolor1;", -href=>"$varenv->{metahost}/src/scripts/tests/index.pl?sessionid=$coo", -target=>'_blank'}," [ booking-test ] "),"$users_sharee->{txt08}",$q->a({-style=>"color:#$bgcolor1;", -href=>"logout_sharee$session"},"logout")),"\n";
|
||||
my $api_test = "sharee_kn";
|
||||
print $q->div({-style=>'text-align:right;height:25px;padding:6px 15px 6px 0px;background-color:white'},$q->a({-style=>"color:#$bgcolor1;", -href=>"$varenv->{metahost}/src/scripts/tests/index.pl?sessionid=$coo\&api_test=$api_test", -target=>'_blank'}," [ $api_test ] "),"$users_sharee->{txt08}",$q->a({-style=>"color:#$bgcolor1;", -href=>"logout_sharee$session"},"logout")),"\n";
|
||||
}
|
||||
|
||||
print "<div class='container'>\n";
|
||||
|
|
|
@ -195,17 +195,16 @@ EOF
|
|||
$debug_message = "$catch_failure && (!$ctrel->{int04} || !$ctrel->{int13}) && $tpl_id" if($debug);
|
||||
print $q->div({-class=>'content2'}, "Erst nachdem Ihre Profildaten vollständig sind erhalten Sie die Bestätigung. $debug_message"),"\n";
|
||||
}elsif((!$ctrel->{int04} || !$ctrel->{int13}) && ($tpl_id =~ /^2$|302004/) && ($path =~ /$varenv->{accounting_3}/)){
|
||||
if(1==1){
|
||||
$debug_message = "(!$ctrel->{int04} || !$ctrel->{int13}) && $tpl_id" if($debug);
|
||||
print $q->div({-class=>'content_title3',-style=>'clear:both;'}, "Fast geschafft $debug_message"),"\n";
|
||||
print $q->div({-class=>'content2'}, "Es wurden Bestätigungs-Codes an Ihre e-Mail Adresse und per SMS an Ihre Telefonnr. versandt. Nach erfolgreicher Bestätigung können Sie unsere Mieträder nutzen. Bitte beachten Sie die Anweisungen."),"\n";
|
||||
#}else{
|
||||
#print $q->div({-class=>'content1',-style=>'padding-top:1em;clear:both;'}, "E-Mail Bestätigung"),"\n";
|
||||
#print $q->div({-class=>'content2'}, "Wir haben einen Bestätigungscode an Ihre angegebene e-Mail Adresse versandt. Nach erfolgreicher Bestätigung können Sie sich einloggen und ein Leihrad mieten. Bitte beachten Sie die Anweisungen."),"\n";
|
||||
}
|
||||
|
||||
print $q->start_form(-name=>'accountscreen', -action=>"/$varenv->{mandant}/Account/$varenv->{accounting_3}$session"),"\n";
|
||||
print $q->hidden(-name=>"sessionid",-override=>1,-value=>"$R::sessionid");
|
||||
my $required = "";
|
||||
$debug_message = "(!$ctrel->{int04} || !$ctrel->{int13}) && $tpl_id" if($debug);
|
||||
print $q->div({-class=>'content_title3',-style=>'clear:both;'}, "Fast geschafft $debug_message"),"\n";
|
||||
my $acktext = "Es wurden Bestätigungs-Codes an Ihre e-Mail Adresse und per SMS an Ihre Telefonnr. versandt.";
|
||||
$acktext = "Es wurde ein Bestätigungs-Code per SMS an Ihre Telefonnr. versandt." if($ctrel->{int04} && !$ctrel->{int13});
|
||||
$acktext = "Es wurde ein Bestätigungs-Code an Ihre e-Mail Adresse versandt." if(!$ctrel->{int04} && $ctrel->{int13});
|
||||
print $q->div({-class=>'content2'}, "$acktext Nach erfolgreicher Bestätigung können Sie unsere Mieträder nutzen. Bitte beachten Sie die Anweisungen."),"\n";
|
||||
if(!$ctrel->{int04}){
|
||||
my $des = "E-Mail Bestätigungscode";
|
||||
my $key = "confirm_code";
|
||||
|
@ -599,7 +598,7 @@ Weitere Personen aus Ihrem Haushalt profitieren jedoch ebenfalls, falls Sie weit
|
|||
}
|
||||
|
||||
if(($R::failure && $R::failure =~ /\w+/ && $R::failure !~ /txt15|txt16/) || ($ctrel->{txt31} && $ctrel->{txt31} =~ /\w/)){
|
||||
print $q->div({-class=>'content2', -style=>"color:$red"}, "* Eingabefehler.<br />Bitte überprüfen Sie Ihre Profildaten damit wir das Fahrradmietsystem freischalten können. Es liegt ein Eingabefehler vor."),"\n";
|
||||
print $q->div({-class=>'content2', -style=>"color:$red"}, "* Achtung!<br />Bitte überprüfen Sie Ihre Profildaten, damit wir das Fahrradmietsystem freischalten können."),"\n";
|
||||
}
|
||||
|
||||
if($path !~ /$varenv->{accounting_3}|$varenv->{profile}/){
|
||||
|
|
Loading…
Add table
Reference in a new issue