- if ($form->submitted && $form->validate) {
- if ($form->submitted eq 'Login') {
- $session->param("name", $form->field("name"));
- if (defined $form->field("do") &&
- $form->field("do") ne 'signin') {
- redirect($q, cgiurl(
- do => $form->field("do"),
- page => $form->field("page"),
- title => $form->field("title"),
- subpage => $form->field("subpage"),
- from => $form->field("from"),
- ));
- }
- else {
- redirect($q, $config{url});
- }
- }
- elsif ($form->submitted eq 'Register') {
- my $user_name=$form->field('name');
- if (userinfo_setall($user_name, {
- 'email' => $form->field('email'),
- 'password' => $form->field('password'),
- 'regdate' => time
- })) {
- $form->field(name => "confirm_password", type => "hidden");
- $form->field(name => "email", type => "hidden");
- $form->text("Registration successful. Now you can Login.");
- print $session->header(-charset=>'utf-8');
- print misctemplate($form->title, $form->render(submit => ["Login"]));
- }
- else {
- error("Error saving registration.");
- }
- }
- elsif ($form->submitted eq 'Mail Password') {
- my $user_name=$form->field("name");
- my $template=template("passwordmail.tmpl");
- $template->param(
- user_name => $user_name,
- user_password => userinfo_get($user_name, "password"),
- wikiurl => $config{url},
- wikiname => $config{wikiname},
- REMOTE_ADDR => $ENV{REMOTE_ADDR},
- );
-
- eval q{use Mail::Sendmail};
- sendmail(
- To => userinfo_get($user_name, "email"),
- From => "$config{wikiname} admin <$config{adminemail}>",
- Subject => "$config{wikiname} information",
- Message => $template->output,
- ) or error("Failed to send mail");
-
- $form->text("Your password has been emailed to you.");
- $form->field(name => "name", required => 0);
- print $session->header(-charset=>'utf-8');
- print misctemplate($form->title, $form->render(submit => ["Login", "Register", "Mail Password"]));
- }