Jump to content

Need help with image verification


atyourservice

Recommended Posts

Hello there, I am definitely not a php programmer and have been unsuccessfully trying to ammend a script I found for image verification from the website http://www.phpjabbers.com/captcha-image-verification-php19.html onto the following code:

 

<?

//require_once("admin/dbstart.php");

//require_once("admin/feedback_class.php");

//require_once("admin/fb_reply_class.php");

 

//$FB = new feedback();

//$FBR = new fb_reply();

 

//if($frm_name AND $frm_msg) {

// $FB->insert($frm_name, $frm_msg, $REMOTE_ADDR);

// $frm_name = "";

// $frm_msg = "";

// $msg = "<font color=green><b>Thank you for your feedback.<br>We will review your feedback, and post it shortly. Enjoy your visit.</b></font>";

//}

 

//0 -> get not-active and active feedback

//y -> get active feedback

//n -> get not-active feedback

 

//$FB->fechforfront();

?>

<html>

<head>

<title>FeedBack</title>

</head>

<BODY >

<?

require("admin/dbstart.php");

require("admin/feedback_class.php");

require("admin/fb_reply_class.php");

$FB = new feedback();

$FBR = new fb_reply();

if($frm_name AND $frm_msg) {

$FB->insert($frm_name, $frm_msg, $REMOTE_ADDR);

$frm_name = "";

$frm_msg = "";

$msg = "<FONT color=green><B>Thank you for your feedback.<BR>We will review your feedback, and post it shortly. Enjoy your visit.</B></FONT>";

}

//0 get not-active and active feedback

//y get active feedback

//n get not-active feedback

$FB->fechforfront();

?>

 

<SCRIPT>

function check_form() {

if(document.form_fback.frm_name.value == "" || document.form_fback.frm_msg.value == "") {

  alert("Please insture that you have entered you name, and your message accordigly.");

} else {

  document.form_fback.submit();

}

}

</SCRIPT>

<?if($msg) {?>

<TABLE cellSpacing=2 cellPadding=2 width="95%" align=center bgColor=#000000>

<TBODY>

<TR>

<TD align=middle bgColor=#f0f0f0><?echo $msg;?></TD></TR></TBODY></TABLE><BR><?}?>

<TABLE cellSpacing=2 cellPadding=2 width="95%" align=center bgColor=#000000>

<TBODY>

<TR>

<TD><FONT color=#ffffff size=+4><B>Visitors' Corner</B></FONT>

<br>

<img src="FridEh2.jpg" align="center">

</TD></TR>

<TR>

<TD bgColor=#f0f0f0><FONT size=5><BR>Welcome to the “Visitors' Corner”. Your feedback is important to us. In addition to being interested in technical feedbacks, we are also glad to hear any comments that viewers might have on Frid's career, including all three principle categories, covering his 40 years in the United States as well as those beyond in Canada and England.<BR><BR><B>Words of caution:<BR><B>1. We will make no attempt to correct grammatical errors or spelling mistakes in the published feedback. <BR><B>2.  From now on feedbacks containing more than 100 words will not be read, let alone be posted on Visitors' Corner. <BR><B> 3. This section will not welcome requests for autographs... nor generally for information beyond the limits of the areas explored on this site.</I><BR></FONT><BR><FONT size=4>Below, in the "User feedback" section are samples of the kinds of feedback that are important to us.<BR><BR>When you're done, all you have to do is click the "Submit" button at the bottom of the page.<BR><BR></FONT>

<TABLE>

<FORM  name=form_fback method=post>

<TBODY>

<TR>

<TD align=right width="1%"><FONT size=4>Your alias:</FONT></TD>

<TD><INPUT maxLength=35 size=35 value="<?echo $frm_name;?>" name=frm_name></TD></TR>

<TR>

<TD vAlign=top noWrap align=right width="1%"><FONT size=4>Feedback message:</FONT></TD>

<TD><TEXTAREA name=frm_msg rows=15 cols=50><?echo $frm_msg;?></TEXTAREA></TD></TR>

<TR>

<TD> </TD>

<TD><INPUT onclick=check_form(); type=button value=" Submit "></TD></TR></FORM></TBODY></TABLE><BR>

<CENTER><BR><FONT size=5><B><I></CENTER></B></FONT></FONT></TD></TR></TBODY></TABLE><BR><?if($FB->count) {?>

<TABLE cellSpacing=2 cellPadding=2 width="95%" align=center bgColor=#000000>

<TBODY>

<TR>

<TD bgColor=#000000><FONT color=#ffffff size=+3><B>User feedback</B></FONT></TD></TR>

<?

$i=0;

while($FB->id[$i] != "") {

$FBR->fetch($FB->id[$i]);

echo "

<TR>

<TD bgColor=#f0f0f0><IMG src='note02b.gif'> <FONT color=#000000 size=5><B>Posted by <U>".$FB->name[$i]."</U> on ".$FB->date_stamp[$i]."</B></FONT>";

echo "<BR>

<HR>

<B><FONT size=4>".$FB->message[$i]."</FONT></B><BR>";

if($FBR->message) {

echo "

<HR>

<FONT size=4><I><B>Reply:<BR>".nl2br($FBR->message)."</B></I></FONT><BR><BR>";

}

echo "</TD></TR>";

$i++;

}

?> </TBODY></TABLE><?}?></BODY>

</html>

 

Could someone PLEASE help me as I am desperate to get rid of a Spam issue.

If you can help, please e-mail me at support@atyourserviceonline.ca.

 

Many thanks in advance

Link to comment
Share on other sites

This is my feedback form but to get the image verification to work you need to upload arial.ttf to the same location as capthca.php

 

<?php
// Change to your own email address
$your_email = "you@yourdomain.com";

// This is what is displayed in the email subject line
// Change it if you want
$subject = "Message via your contact form";

// This is displayed when the email has been sent
$thankyou_message = "<p>Thankyou. Your message has been sent.</p>";

$self = $_SERVER['REQUEST_URI'];

$name = $_POST['txtName'];
$email = $_POST['txtEmail'];
$message = $_POST['txtMessage'];
$send = $_POST['send'];

$msg="<p>Please fill in this form if you have any queries or suggestions.</p>";

echo ($msg);

$form = "
    <form method=\"post\" action=\"$self\">

    <p><label for=\"txtName\">Name:</label>
    <input type=\"text\" title=\"Please enter your name\" id=\"txtName\" name=\"txtName\" size=\"40\" value=\"$name\" /></p>

    <p><label for=\"txtEmail\">Email:</label>
    <input type=\"text\" title=\"Please enter your email address\" id=\"txtEmail\" name=\"txtEmail\" size=\"40\" value=\"$email\"/></p>

    <p><label for=\"txtMessage\">Comments:</label>
    <textarea title=\"Please enter your message\" id=\"txtMessage\" name=\"txtMessage\" rows=\"20\" cols=\"45\">$message</textarea></p>

    <p>Please enter the text that you see in the image into the box below. You are asked to do this in order to verify that this message is not being performed by an automated process.</p>
    
    <p><label> </label></p>
    <div class=\"captcha\"><img src=\"includes/captcha.php\" alt=\"security image\" /></div>

    <p><label for=\"verify\">Anti-Spam key:</label>
    <input type=\"text\" title=\"Please enter the anti-spam key\" name=\"verify\" id=\"verify\" size=\"40\" /></p>

    <p><label> </label>
    <input type=\"submit\" class=\"sendbutton\" name=\"send\" value=\"Submit\" /></p>

</form>";

if($send)
{
    $valid=true;

if( !$name )
{ 
    $errmsg.="Please enter your name:<br />";
    $valid=false;
}

if( !$email )
{
    $errmsg.="Please enter your email address:<br />";
    $valid=false;
}
else
{
	$email = trim($email);
	$_name = "/^[-!#$%&\'*+\\.\/0-9=?A-Z^_`{|}~]+";
	$_host = "([-0-9A-Z]+\.)+";
	$_tlds = "([0-9A-Z]){2,4}$/i";

	if( !preg_match($_name."@".$_host.$_tlds,$email))
	{
		$errmsg.="Email address has incorrect format!<br />";
		$valid=false;
	}
}

if( !$message )
{ 
    $errmsg.="Please enter your message:<br />";
    $valid=false; 
}

if (empty($_POST['verify']) && $_POST['verify'] == $_SESSION['captchstr'])
{
    $errmsg.="Please enter security image:<br />";
    $valid=false;
}
}

if( $valid !=true )
    {
echo( "<span style=\"font-weight: bold; color:red;\">".$errmsg."</span>" . $form );
    }

else {

    // Stop the form being used from an external URL
    // Get the referring URL
    $referer = $_SERVER['HTTP_REFERER'];
    // Get the URL of this page
    $this_url = "http://".$_SERVER['HTTP_HOST'].$_SERVER["REQUEST_URI"];
    // If the referring URL and the URL of this page don't match then
    // display a message and don't send the email.
    if ($referer != $this_url) {
        echo "You do not have permission to use this script from another URL.<br />";
echo "If you are behind a firewall please check your referrer settings.";
        exit;
    }

    // The URLs matched so send the email
    if( mail($your_email, $subject, $message, "From: $name <$email>"));
    {
    	// Display the thankyou message
    	echo $thankyou_message;
    }
}
?>

 

this is the bit that compares the text entered by the user with the capthca SESSION

if (empty($_POST['verify']) && $_POST['verify'] == $_SESSION['captchstr'])

 

This is captcha.php

<?php
session_start();
$strlength = rand(4,7);
$captchastr = "";
for($i=1;$i<=$strlength;$i++)
{
$textornumber = rand(1,3);
if($textornumber == 1)
{
$captchastr .= chr(rand(49,57));
}
if($textornumber == 2)
{
$captchastr .= chr(rand(65,78));
}
if($textornumber == 3)
{
$captchastr .= chr(rand(80,90));
}
}
$randcolR = rand(100,230);
$randcolG = rand(100,230);
$randcolB = rand(100,230);

//initialize image $captcha is handle dimensions 200,50
$captcha = imageCreate(190,50);
$backcolor = imageColorAllocate($captcha, $randcolR, $randcolG, $randcolB);

$txtcolor = imageColorAllocate($captcha, ($randcolR - 60), ($randcolG - 60), ($randcolB - 60));
for($i=1;$i<=$strlength;$i++)
{

$clockorcounter = rand(1,2);
if ($clockorcounter == 1)
{
$rotangle = rand(0,45);
}
if ($clockorcounter == 2)
{
$rotangle = rand(315,360);
}

//$i*25 spaces the characters 25 pixels apart
imagettftext($captcha,rand(14,20),$rotangle,($i*25),30,$txtcolor,"/arial.ttf",substr($captchastr,($i-1),1));
}
for($i=1; $i<=4;$i++)
{
imageellipse($captcha,rand(1,200),rand(1,50),rand(50,100),rand(12,25),$txtcolor);
}
for($i=1; $i<=4;$i++)
{
imageellipse($captcha,rand(1,200),rand(1,50),rand(50,100),rand(12,25),$backcolor);
}
//Send the headers (at last possible time)
header('Content-type: image/png');

//Output the image as a PNG
imagePNG($captcha);

//Delete the image from memory
imageDestroy($captcha);

$_SESSION["captchastr"] = $captchastr;
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.