<?php
require_once "include/config.php";
$action=isset($_POST['action'])?$_POST['action']:null;
if ($action=='send') {
$headers = "";
$headers .= "To: {$user} <{$user}>\r\n";
$headers .= "From: {$_POST["name"]} <{$_POST["email"]}>\r\n";
$headers .= "In-Reply-To: {$_POST["msgId"]}\r\n";
$headers .= "References: {$_POST["msgId"]}\r\n";
$to = $user;
$message = $_POST["message"];
$title = $_POST["title"];
mail($to, $title, $message, $headers);
print '<div align="center"><br/><br/>Message sent</div>';
print '<script language="JavaScript">window.close()</script>';
} else {
require_once "include/Gallina.php";
$g = new Gallina ($user, $password, $timezone);
$g->Connect ();
$source = $g->GMailer->getMessageSource ($_REQUEST["id"]);
if (preg_match("/Message-ID:\s<(\S*)>/",$source , $match)) {
$msgId = $match[1];
}
print '<html>';
print '<head>';
print '<title>Comment</title>';
print '<link rel="stylesheet" type="text/css" href="gallina/gallina.css" />';
print '<style>';
print 'body { padding: 20px; }';
print '</style>';
print '</head>';
print '<body>';
print '<h1>Comment</h1>';
print '<form name="form1" method="post" action="reply.php">';
print '<input type="hidden" name="action" value ="send" />';
print '<input type="hidden" name="msgId" value ="'.$msgId.'" />';
print '<input type="hidden" name="title" value ="'.$_REQUEST["title"].'" />';
print 'Name:<br/>';
print '<input type="text" name="name" style="width: 100%;" /><br/>';
print 'Email:<br/>';
print '<input type="text" name="email" style="width: 100%;" /><br/>';
print 'Comments:<br/>';
print '<textarea name="message" style="width: 100%;" rows="6"></textarea><br/>';
print '<input type="submit" name="buttonSubmit" value="Send" />';
print "</form>";
print '</body>';
print '</html>';
}
?>