A Programming Blog
Hello mobile user!
<form action='/mailer.php' method='post' name='form1' id='form1'>
Your e-mail:<br>
<input name='from' type='text' id='from' value=''><br><br>
Subject:<br>
<input name='subject' type='text' id='subject' value=''><br><br>
Type verification image:<br>
<input name='verif_box' type='text' id='verif_box'>
<?php echo "<img src='verificationimage.php?". rand(0, 9999)." alt='verification image, type it in the box' width='60' height='24' align='absbottom'><br><br>n";
//if the variable "wrong_code" is sent from previous page then display the error field
if (isset($_GET['wrong_code'])) {
echo "<div>Wrong verification code</div><br>n";
}
?>
Message:<br>
<textarea name='message' cols='6' rows='5' id='message'></textarea>
<input name='Submit' type='submit' value='Send Message'>
</form><?php
header('Content-type: image/jpeg');
$width = 60;
$height = 24;
$my_image = imagecreatetruecolor($width, $height);
imagefill($my_image, 0, 0, 0xFFFFFF);
// add noise
$red=mt_rand(0,125);
$green=mt_rand(0,125);
$blue=mt_rand(0,125);
$color1=imagecolorallocate($my_image,$red,$green,$blue);
$red=mt_rand(125,255);
$green=mt_rand(125,255);
$blue=mt_rand(125,255);
$color2=imagecolorallocate($my_image,$red,$green,$blue);
for ($c = 0; $c < 480; $c++) {
if ($c%2==0) {
$color=$color1;
} else $color=$color2;
$x = rand(0, $width-1);
$y = rand(0, $height-1);
imagesetpixel($my_image, $x, $y, $color);
//imagesetpixel($my_image, $x, $y, 0x000000);
}
$x = rand(1, 10);
$y = rand(1, 10);
$rand_string = rand(10000, 99999);
imagestring($my_image, 5, $x, $y, $rand_string, 0x000000);
setcookie('tntcon', (md5($rand_string) . 'a4xn'));
imagejpeg($my_image);
imagedestroy($my_image);
?><?php
if (!function_exists(GetSerializedArray)) {
function GetSerializedArray($path)
{
$str = get_contents_flock($path);
$array = @unserialize($str);
if (is_array($array)) {
return $array;
} else return false;
}
}
if (!function_exists(get_contents_flock)) {
function get_contents_flock($file)
{
if (@file_exists($file)) {
$fp = @fopen($file, 'rt');
if ($fp === false) {
return false;
} else {
if (@flock($fp, LOCK_SH) === false) {
return false;
} else {
$contents = @file_get_contents($file);
if ($contents === false) {
return false;
} else {
@flock($fp, LOCK_UN);
@fclose($fp);
return $contents;
}
}
}
} else return false;
}
}
// load the variables form address bar
$subject = $_POST["subject"];
$subject = filter_var($subject, FILTER_SANITIZE_SPECIAL_CHARS);
$message = $_POST["message"];
$message = filter_var($message, FILTER_SANITIZE_SPECIAL_CHARS);
$from = $_POST["from"];
$from = filter_var($from, FILTER_SANITIZE_EMAIL);
$verif_box = $_POST["verif_box"];
// remove the backslashes that normally appears when entering " or '
$message = stripslashes($message);
$subject = stripslashes($subject);
$from = stripslashes($from);
// check to see if verificaton code was correct
if (md5($verif_box) . 'a4xn' == $_COOKIE['tntcon']) {
// if verification code was correct send the message and show this page
$Config_Global = GetSerializedArray("path/to/file.dat");
$ScriptDomain = $_SERVER["HTTP_HOST"];
if (stripos($ScriptDomain, "www.") === 0) {
$ScriptDomain = substr($ScriptDomain, 4);
}
mail("$Config_Global[eMail]", $ScriptDomain.' Form: ' . $subject, $_SERVER['REMOTE_ADDR'] . "nn" . $message, "From: $from");
// delete the cookie so it cannot sent again by refreshing this page
setcookie('tntcon', '');
?>
<!DOCTYPE html>
<!-- Created Sun Nov 10 21:31:49 2019 -->
<HTML>
<HEAD>
<TITLE><?php echo $ScriptDomain; ?> Form</TITLE>
<meta http-equiv = "refresh" content = "1; url = https://regalcoding.com" />
</HEAD>
<BODY BGCOLOR="#FFFFFF" TOPMARGIN=0>
<center>Thank you, your message has been sent.</center>
</body>
</HTML>
<?php
} else if (isset($message) and $message != "") {
// if verification code was incorrect then return to contact page and show error
header("Location:" . $_SERVER['HTTP_REFERER'] . "&subject=$subject&from=$from&wrong_code=true&message=$message");
exit;
} else {
echo "no variables received, this page cannot be accessed directly";
exit;
}
?>