<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
  <head> <title>Sent feedback</title> </head>
<!-- $Id: mailfeedback.php 6 2004-12-30 00:23:53Z basile $ -->
<!-- Copyright 2004 Basile STARYNKEVITCH -->
<body>

<h1>Thanks for your feedback</h1>

<?php
// this mailfeedback.php file is
//   Copyright © 2004 Basile STARYNKEVITCH
//
// This Software is licensed under the GPL licensed Version 2, 
// please read http://www.gnu.org/copyleft/gpl.html

/* 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.
 *
 * This software 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.
 */

require 'interest_config.inc';
// the included file defines:
///  for opening the database
///  $int_db_name $int_db_host $int_db_user $int_db_passwd 
///  the name of the rate and access tables $int_tb_rate $int_tb_access
///  $int_webuser the user part of the email address
///  $int_webdomain the domain part of the email address
//// example
// $int_db_name="interest_db";
// $int_db_host="localhost";
// $int_db_user="phpuser";
// $int_db_passwd="secretpassword";
// $int_tb_rate="Tb_Rate";
// $int_tb_access="Tb_Access";
// $int_webuser="webmaster";
// $int_webdomain="exampledomain.org";
?>


<?php 
echo "<p>Please email any suggestions about this page (giving its URL) to " 
     . "<a href='mailto:$int_webuser" 
     . ".NOSPAM@"
     . "$int_webdomain.invalid'> $int_webuser.NOSPAM <tt>at</tt> $int_webdomain.invalid</a>"
. " (but remove <tt>.NOSPAM</tt> and <tt>.invalid</tt> from the email address).</p>\n";
?>

<?php
// fetch data from the HTTP request
$clientip = $_SERVER['REMOTE_ADDR'];
$email = $_POST['email'];
$pagename = $_POST['page'];
$body = $_POST['body'];

/// check data
if (!preg_match("/^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$/", $clientip)) 
     die("invalid clientip '". addslashes($clientip) . "'");
if (!preg_match("/^[a-zA-Z0-9_.]+$/", $pagename))
     die("invalid pagename '" . addslashes($pagename) . "'");
     
if (!preg_match("/^ *[A-Za-z0-9_.-]+@[A-Za-z0-9_.-]+ *$/", $email, $emailparts))
     die("invalid email " . $email);

     $now=date("Y.M.d-h:i:s");
$message= "mail with " . '$Id: mailfeedback.php 6 2004-12-30 00:23:53Z basile $' . " clientip=$clientip; email=$email; at=$now; page= $page\n\n"
. $body ;
mail("$int_webuser@$int_webdomain", "[MAILPHP] $pagename $clientip", $message,
     "From: webmaster@{$_SERVER['SERVER_NAME']}\r\n"
     . "Reply-To: $email\r\n"
     . "X-Mailer: " . '$Id: mailfeedback.php 6 2004-12-30 00:23:53Z basile $' . "\r\n",
     "-fwebmaster@{$_SERVER['SERVER_NAME']}");

$bodylen= strlen($body);
echo "<p>Your $bodylen characters comment has been transmitted on $now " 
. "with your IP $clientip about page <tt>$page</tt>  with email <tt>$email</tt></p>\n";
?>
</body>
</html>
