<?php
session_start();
require_once("inc.php");
require_once('Text/CAPTCHA.php');
if(!isset($_SESSION['address']))
die("You should be signed in to continue... Click to <a href=\"signin.php\">sign in</a>");
if(!isset($_GET['to'])) {
die("You should have defined who to send your message! Go back and try again.");
}
$tpl->caching = 0;
$captcha = Text_CAPTCHA::factory('Image');
$text_image_options = array(
'font_size'=>'20',
'font_path'=>'./',
'font_file'=>'Arial.ttf'
);
$captcha->init(100,60,NULL,$text_image_options);
if (PEAR::isError($captcha)) {
echo 'Error generating CAPTCHA!';
exit;
}
$image_data = $captcha->getCAPTCHAAsPNG();
$fname = 'images/captchas/'.md5(session_id()).'png';
@unlink($fname);
$handle = fopen($fname, 'w+');
fwrite($handle, $image_data);
fclose($handle);
unset($_SESSION['captcha_phrase']);
$_SESSION['captcha_phrase'] = $captcha->getPhrase();
ob_start();
?>
<form method="POST" action="sendmessage1.php">
<input type="hidden" name="to" value="<?=addslashes($_GET["to"])?>" />
<p><strong>Send a message to this person:</strong></p>
<p><textarea name="message"></textarea></p>
<p>Please enter the text in the image below:<br /><input type="text" name="captcha" /><br /><img src="<?=$fname?>" style="width:100px;height:60px;" alt="" /></p>
<p><input type="submit" value="Continue" /></p>
</form>
<?php
$content = ob_get_contents();
ob_end_clean();
$tpl->assign("content",$content);
$tpl->display("static.tpl");
?>