index.cgi
changeset 15 164da420a326
parent 13 deb39a02243b
child 17 bf0ff90e2cf5
equal deleted inserted replaced
14:2de6e3df1dd2 15:164da420a326
    33 my $SELF = read_conf "conf/self";   
    33 my $SELF = read_conf "conf/self";   
    34 my $SENDER = read_conf "conf/sender";
    34 my $SENDER = read_conf "conf/sender";
    35 my $SENDMAIL = "/usr/sbin/sendmail -f $SENDER -t";
    35 my $SENDMAIL = "/usr/sbin/sendmail -f $SENDER -t";
    36 
    36 
    37 my %FIELDS = (
    37 my %FIELDS = (
    38     MAN => [qw[givenname surname mail]],
    38     MAN => [qw[givenname surname email]],
    39     OPT => [qw[tel]]
    39     OPT => [qw[tel]]
    40 );
    40 );
    41 
    41 
    42 my %ttconfig = (
    42 my %ttconfig = (
    43     INCLUDE_PATH => "templates",
    43     INCLUDE_PATH => "templates",
    84     if (path_info() =~ /^\/?user\.(.*)$/) {
    84     if (path_info() =~ /^\/?user\.(.*)$/) {
    85 	my $uuid = $1;
    85 	my $uuid = $1;
    86 	my $confirmed = param("confirm") eq "yes";
    86 	my $confirmed = param("confirm") eq "yes";
    87 	my %data = confirm($uuid => $confirmed);
    87 	my %data = confirm($uuid => $confirmed);
    88 
    88 
       
    89 	if ($data{error}) {
       
    90 	    $tt->process("html.denied.tpl");
       
    91 	    exit 0;
       
    92 	}
       
    93 
    89 	open(my $sendmail, "|$SENDMAIL") or die "Can't open $SENDMAIL: $!\n";
    94 	open(my $sendmail, "|$SENDMAIL") or die "Can't open $SENDMAIL: $!\n";
    90 	$tt->process("mail.confirmed.tpl", {
    95 	$tt->process("mail.confirmed.tpl", {
    91 	    to => $data{mail},
    96 	    to => $data{email},
    92 	    confirmed => $confirmed,
    97 	    confirmed => $confirmed,
    93 	}, $sendmail)
    98 	}, $sendmail)
    94 	or die $tt->error();
    99 	or die $tt->error();
    95 	close($sendmail) or die "sendmail: $!\n";
   100 	close($sendmail) or die "sendmail: $!\n";
    96 
   101 
   144 		param(-name => $param, value => $1);
   149 		param(-name => $param, value => $1);
   145 		$value{$param} = $1;
   150 		$value{$param} = $1;
   146 	    }
   151 	    }
   147 
   152 
   148 	    # Mail needs extra check
   153 	    # Mail needs extra check
   149 	    if ($value{mail} and not valid($value{mail})) {
   154 	    if ($value{email} and not valid($value{email})) {
   150 		push @{$warn{mail}}, "Keine gültig erscheinende Mail-Adresse.";
   155 		push @{$warn{email}}, "Keine gültig erscheinende Mail-Adresse.";
   151 	    }
   156 	    }
   152 
   157 
   153 	    foreach (keys %warn) {
   158 	    foreach (keys %warn) {
   154 		$warn{$_} = join " ", @{$warn{$_}};
   159 		$warn{$_} = join " ", @{$warn{$_}};
   155 	    }
   160 	    }
   159 
   164 
   160 		open(my $sendmail => "|$SENDMAIL")
   165 		open(my $sendmail => "|$SENDMAIL")
   161 		    or die "Can't open $SENDMAIL: $!\n";
   166 		    or die "Can't open $SENDMAIL: $!\n";
   162 
   167 
   163 		$tt->process("mail.form-ack.tpl", {
   168 		$tt->process("mail.form-ack.tpl", {
   164 		    to => $value{mail},
   169 		    to => $value{email},
   165 		    url => {
   170 		    url => {
   166 			yes => "$SELF/user.$r{uuid}?confirm=yes",
   171 			yes => "$SELF/user.$r{uuid}?confirm=yes",
   167 			no  => "$SELF/user.$r{uuid}?confirm=no",
   172 			no  => "$SELF/user.$r{uuid}?confirm=no",
   168 		    }
   173 		    }
   169 		}, $sendmail)
   174 		}, $sendmail)
   183 	$tt->process("html.form.tpl", {
   188 	$tt->process("html.form.tpl", {
   184 	    warn => %warn ? \%warn : undef,
   189 	    warn => %warn ? \%warn : undef,
   185 	    value => {
   190 	    value => {
   186 		givenname => scalar param("givenname"),
   191 		givenname => scalar param("givenname"),
   187 		surname => scalar param("surname"),
   192 		surname => scalar param("surname"),
   188 		mail => scalar param("mail"),
   193 		email => scalar param("email"),
   189 	    },
   194 	    },
   190 	} ) or die $tt->error();
   195 	} ) or die $tt->error();
   191 	exit 0;
   196 	exit 0;
   192     }
   197     }
   193 
   198 
   265 sub do_invite() {
   270 sub do_invite() {
   266 	my ($tt) = @_;
   271 	my ($tt) = @_;
   267 	my %warn;
   272 	my %warn;
   268 	my $sent;
   273 	my $sent;
   269 
   274 
   270 	if (param("mail")) {
   275 	if (param("email")) {
   271 	    if (not valid param("mail")) {
   276 	    if (not valid param("email")) {
   272 		$warn{mail} = "INVALID";
   277 		$warn{email} = "INVALID";
   273 	    }
   278 	    }
   274 	    else {
   279 	    else {
   275 		my $xxx = encrypt(time);
   280 		my $xxx = encrypt(time);
   276 		$xxx =~ s/\+/-/g;
   281 		$xxx =~ s/\+/-/g;
   277 		$xxx =~ s/\//_/g;
   282 		$xxx =~ s/\//_/g;
   279 		# send mail
   284 		# send mail
   280 		open(my $sendmail => "|$SENDMAIL")
   285 		open(my $sendmail => "|$SENDMAIL")
   281 		    or die "Can't open sendmail: $!\n";
   286 		    or die "Can't open sendmail: $!\n";
   282 
   287 
   283 		$tt->process("mail.invitation.tpl", {
   288 		$tt->process("mail.invitation.tpl", {
   284 		    to   => scalar(param("mail")),
   289 		    to   => scalar(param("email")),
   285 		    url  => "$SELF/tmp.$xxx"}, $sendmail)
   290 		    url  => "$SELF/tmp.$xxx"}, $sendmail)
   286 		or die $tt->error();
   291 		or die $tt->error();
   287 		close($sendmail)
   292 		close($sendmail)
   288 			or die "problem sending mail to "
   293 			or die "problem sending mail to "
   289 				. param("mail");
   294 				. param("email");
   290 
   295 
   291 		$sent = param("mail");
   296 		$sent = param("email");
   292 	    }
   297 	    }
   293 	}
   298 	}
   294 	$tt->process("html.invitation.tpl", {
   299 	$tt->process("html.invitation.tpl", {
   295 	    sent => $sent,
   300 	    sent => $sent,
   296 	    warn => %warn ? \%warn : undef,
   301 	    warn => %warn ? \%warn : undef,
   297 	    expires => $EXPIRATION,
   302 	    expires => $EXPIRATION,
   298 	    value => { mail => scalar param("mail") },
   303 	    value => { email => scalar param("email") },
   299 	});
   304 	});
   300 }
   305 }
   301 
   306 
   302 sub do_show($$) {
   307 sub do_show($$) {
   303     my ($tt, $object) = @_;
   308     my ($tt, $object) = @_;