| 1 | <?php |
|---|
| 2 | /** |
|---|
| 3 | * Displays a form to send feedback to the site administrator, as specified in wikka.config.php |
|---|
| 4 | * |
|---|
| 5 | * It first validates the form, then sends it using the mail() function; |
|---|
| 6 | * |
|---|
| 7 | * @package Actions |
|---|
| 8 | * @version $Id:feedback.php$ |
|---|
| 9 | * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License |
|---|
| 10 | * @filesource |
|---|
| 11 | * |
|---|
| 12 | * @uses Wakka::FormClose() |
|---|
| 13 | * @uses Wakka::FormOpen() |
|---|
| 14 | * @uses Wakka::GetSafeVar() |
|---|
| 15 | * @uses Wakka::GetWakkaName() |
|---|
| 16 | * @uses Wakka::Href() |
|---|
| 17 | * @uses Config::$admin_email |
|---|
| 18 | * @uses Config::$root_page |
|---|
| 19 | */ |
|---|
| 20 | |
|---|
| 21 | |
|---|
| 22 | $name = $this->GetSafeVar('name', 'post'); |
|---|
| 23 | $email = $this->GetSafeVar('email', 'post'); |
|---|
| 24 | $comments = $this->GetSafeVar('comments', 'post'); |
|---|
| 25 | |
|---|
| 26 | $form = T_("<p>Fill in the form below to send us your comments:</p>\n"). |
|---|
| 27 | $this->FormOpen(). |
|---|
| 28 | '<label for="name">'.T_("Name: ").'</label><input name="name" value="'.$name.'" type="text" /><br />'."\n". |
|---|
| 29 | '<input type="hidden" name="mail" value="result">'."\n". |
|---|
| 30 | '<label for="email">'.T_("Email: ").'</label><input name="email" value="'.$email.'" type="text" /><br />'."\n". |
|---|
| 31 | '<label for="comments">'.T_("Comments:").'</label><br />'."\n".'<textarea name="comments" rows="15" cols="40">'.$comments.'</textarea><br / >'."\n". |
|---|
| 32 | '<input type="submit" value="'.T_("Send").'" />'."\n". |
|---|
| 33 | $this->FormClose(); |
|---|
| 34 | |
|---|
| 35 | if ($this->GetSafeVar('mail', 'post')=='result') |
|---|
| 36 | { |
|---|
| 37 | |
|---|
| 38 | list($user, $host) = sscanf($email, "%[a-zA-Z0-9._-]@%[a-zA-Z0-9._-]"); |
|---|
| 39 | if (!$name) |
|---|
| 40 | { |
|---|
| 41 | // a valid name must be entered |
|---|
| 42 | echo '<p class="error">'.T_("Please enter your name").'</p>'."\n"; |
|---|
| 43 | echo $form; |
|---|
| 44 | } elseif (!$email || !strchr($email, '@') || !$user || !$host) |
|---|
| 45 | { |
|---|
| 46 | // a valid email address must be entered |
|---|
| 47 | echo '<p class="error">'.T_("Please enter a valid email address").'</p>'."\n"; |
|---|
| 48 | echo $form; |
|---|
| 49 | } elseif (!$comments) |
|---|
| 50 | { |
|---|
| 51 | // some text must be entered |
|---|
| 52 | echo '<p class="error">'.T_("Please enter some text").'</p>'."\n"; |
|---|
| 53 | echo $alert; |
|---|
| 54 | echo $form; |
|---|
| 55 | } else |
|---|
| 56 | { |
|---|
| 57 | // send email and display message |
|---|
| 58 | $msg = 'Name:\t'.$name."\n"; |
|---|
| 59 | $msg .= 'Email:\t'.$email."\n"; |
|---|
| 60 | $msg .= "\n".$comments."\n"; |
|---|
| 61 | $recipient = $this->GetConfigValue('admin_email'); |
|---|
| 62 | $subject = sprintf(T_("Feedback from %s"),$this->GetWakkaName()); |
|---|
| 63 | $mailheaders = 'From:'.$email."\n"; |
|---|
| 64 | $mailheaders .= 'Reply-To:'.$email; |
|---|
| 65 | mail($recipient, $subject, $msg, $mailheaders); |
|---|
| 66 | echo sprintf(T_('Thanks for your interest! Your feedback has been sent to %s. Return to the <a href=\"%s\">main page</a>'),$recipient, $this->Href('', $this->GetConfigValue('root_page'))); |
|---|
| 67 | // optionally displays the feedback text |
|---|
| 68 | //echo $this->Format('---- **'.T_("Name: ").'** '.$name.'---**'.T_("Email: ").'** '.$email.'---**'.T_("Comments:").'** ---'.$comments'); |
|---|
| 69 | } |
|---|
| 70 | } else |
|---|
| 71 | { |
|---|
| 72 | echo $form; |
|---|
| 73 | } |
|---|
| 74 | ?> |
|---|