Jump to content

PHP Captcha help


lorddemos90

Recommended Posts

I am using a code that I found that I really like that allows users to add feedback and rate a page.  However, there is no protection from bots on it.  I downloaded a few php Captcha scripts, but have no idea how to add them to the script.  I have no idea where to add the actual processing alteration as I can't really tell where where the actual form processor is. 

 

 

<html>
<head>
<SCRIPT language=JavaScript>
function textCounter(field, countfield, maxlimit) {
if (field.value.length > maxlimit)
field.value = field.value.substring(0, maxlimit);
else
countfield.value = maxlimit - field.value.length;
}
</SCRIPT>
<script language="JavaScript">
<!--
function emo(emo){
document.all.comment.value += emo;
document.all.comment.focus();
return;
}
//-->
</script>
<style>
TD 		{font-family: Verdana; color: #ffffff; font-size: 8pt;}
INPUT       	{font-family:Verdana;font-size:10pt;background:#000000;color:#FFFFFF;}
TEXTAREA     	{font-family:Verdana;font-size:10pt;background:#000000;color:#FFFFFF;}
hr		{color: #f5f9fd; height: 1px;}
</style>

</head>
<body>
<?php
//Copyright Scriptsez.net
extract($HTTP_GET_VARS);
extract($HTTP_POST_VARS);
function smile(){
?>
<a href="javascript:emo('  ')"><img src="images/smile.gif" border=0 alt=""></a>
    <a href="javascript:emo(' ' ) "><img src="images/sad.gif" border=0 alt=""></a>
    <a href="javascript:emo(' :C ')"><img src="images/mad.gif" border=0 alt=":C"></a>
    <a href="javascript:emo(' ;Y ')"><img src="images/thumbsup.gif" border=0 alt=";Y"></a>
    <a href="javascript:emo(' :i) ')"><img src="images/info.gif"border=0 alt=":i)"></a>
    <a href="javascript:emo(' :Q) ')"><img src="images/question.gif"border=0 alt=":Q)"></a>Drag smileys to use. <?php
}
$ip = getenv(REMOTE_ADDR);
$name = str_replace ("|~|","", $name);
$comment = str_replace ("\n", "<br>", $comment);
$comment = str_replace ("|~|", "", $comment);
$comment = str_replace ("", "<img src='images/smile.gif' border=0>", $comment);
$comment = str_replace ("", "<img src='images/sad.gif' border=0>", $comment);
$comment = str_replace (":C", "<img src='images/mad.gif' border=0>", $comment);
$comment = str_replace (";Y", "<img src='images/thumbsup.gif' border=0>", $comment);
$comment = str_replace (":i)", "<img src='images/info.gif' border=0>", $comment);
$comment = str_replace (":Q)", "<img src='images/question.gif' border=0>", $comment);
$name = stripslashes ($name);
$comment = stripslashes ($comment);
$lis="0";
$user=file("badwords.txt");
for($x=0;$x<sizeof($user);$x++) {
$comment = str_replace($temp[0],"-",$comment);
$jemp = explode(";",$user[$x]);
$opp[$x] = "$jemp[0];";
$list[$lis] = $opp[$x];
$lis++; 
}
if(sizeof($list) != "0") {
for($y=0;$y<sizeof($list);$y++) {
$temp = explode(";",$list[$y]);
$temq=ucwords($temp[0]);
$temr=ucfirst($temp[0]);
$tems=strtoupper($temp[0]);
$comment = str_replace ($temp[0],"-", $comment);
$comment = str_replace ($tep,"-", $comment);
$comment = str_replace ($temq,"-", $comment);
$comment = str_replace ($temr,"-", $comment);
$comment = str_replace ($tems,"-", $comment);
$name = str_replace ($temp[0],"-",$name);
$name = str_replace ($temq,"-",$name);
$name = str_replace ($temr,"-",$name);
$name = str_replace ($tems,"-",$name);
}
}
$today = date("M:d:Y");
$ficdest=explode(".",basename($PHP_SELF)); 
$mfile="review/".$ficdest[0].".txt";
if(file_exists($mfile)) { 
}else{
$m_compteur=fopen($mfile, "w"); 
fclose($m_compteur); 
}
$compt=fopen($mfile, "r"); 
$old_stats=file($mfile);
$am = count($old_stats)-1;
$stats=explode("|~|", $old_stats[$am]);
fclose($compt);
//echo "$stats[4]";
if (strlen($name)>="1" && strlen($comment)>="1" && strlen($rate)>="1" && $stats[4]!=$ip){
if(file_exists($mfile)) { 
$compteur=fopen($mfile, "a+"); 
fputs ($compteur, "[list]|~|");
fputs ($compteur, "$name");
fputs ($compteur, "|~|");
fputs ($compteur, "$comment");
fputs ($compteur, "|~|");
fputs ($compteur, "$today");
fputs ($compteur, "|~|");
fputs ($compteur, "$ip");
fputs ($compteur, "|~|");
fputs ($compteur, "$rate");
fputs ($compteur, "|~|");
fputs ($compteur, "\n");
fclose($compteur);
echo "<CENTER><FONT COLOR=\"#0000FF\" face=arial>Your Review has been added.</FONT></CENTER>";
}
}
elseif(strlen($name)>="1" && strlen($comment)>="1" && strlen($rate)>="1" && $stats[4]==$ip){
echo "<CENTER><FONT COLOR='red' face=arial>You have already reviewed</FONT></CENTER>";
}elseif(strlen($name)>="1" && strlen($comment)>="1" && strlen($rate)=="0") {
echo "<CENTER><FONT COLOR='red' face=arial>Please select rating</FONT></CENTER>";
}
$main_file_m = $mfile;
$latest_rev = 10;   //Number of latest reviews to show
$lines_review = file($main_file_m);
$abc = count($lines_review);
$uli = $abc - $latest_rev;
echo "<center><table width=90% border=0 cellspacing=0 cellpadding=2 bordercolor=#3a4f6c>";
for($cv = $abc; $cv >= $uli ;$cv--){
if(substr($lines_review[$cv], 0, 6 )=="[list]"){
$lpop = explode("|~|",$lines_review[$cv]);
if ($lpop[5]=="10"){
$img="images/b10.jpg";
}elseif	($lpop[5]>="9"){
$img="images/b9.jpg"; }
elseif	($lpop[5]>="8"){
$img="images/b8.jpg"; }elseif	($lpop[5]>="7"){
$img="images/b7.jpg"; }elseif	($lpop[5]>="6"){
$img="images/b6.jpg"; }elseif	($lpop[5]>="5"){
$img="images/b5.jpg"; }elseif	($lpop[5]>="4"){
$img="images/b4.jpg"; }elseif	($lpop[5]>="3"){
$img="images/b3.jpg"; }elseif	($lpop[5]>="2"){
$img="images/b2.jpg"; }elseif	($lpop[5]>="1"){
$img="images/b1.jpg"; }
$bar="<img src='$img'>";
$mesi=wordwrap($lpop[2], 50, "\n", 1);
echo "<tr><td bgcolor=#999999>$lpop[1] Reviewed on $lpop[3] $bar</td></tr><tr><td bgcolor=#000000>$mesi </td></tr>";
}
}
$maximum="10";
$lp=file($mfile);
$abd = count($lp);
if ($abd > $maximum) {
$fw = fopen ("review/".$ficdest[0].".tmp", "w");
fclose($fw);
$folename = $mfile; 
$fd = fopen ($folename, "r"); 
$puff = fread ($fd, filesize($folename)); 
fclose ($fd);
$last_file = fopen ("review/".$ficdest[0].".tmp", "a+");
fwrite ($last_file, $puff);
fclose($last_file);
$fz = fopen ($mfile, "w");
fwrite ($fz, "");
fclose($fz);
$lines14 = file("review/".$ficdest[0].".tmp");
$a1 = count($lines14);
$u = $a1 - $maximum;
for($i1 = $a1; $i1 > $u;$i1--){
$msg_old =  $lines14[$i1] . $msg_old;
}
$fz = fopen ($mfile, "a+");
fwrite ($fz,$msg_old);
fclose($fz);
}
$fz = fopen ("review/".$ficdest[0].".tmp", "w");
fwrite ($fz, "");
fclose($fz);
?>
</td></table>
<form method='post'>
<table width='90%' border='0' cellspacing='0' bordercolor=#FFFFFF bgcolor=#000000>
<tr><b><font size=1>
<td bgcolor=#666666><b>Add a Review</b></td>
</tr>
<tr><td><table border='0'cellspacing='0' align=middle bgcolor=#000000>
<tr><td><font size=1>
Name:      <BR></font></b></td><td><input type='text' maxlength="50" name='name' size=20 style="font-weight:10"></td><td>Rating: <select name=rate><option value="">Select<option value="10">10 (Good)<option value="9">9<option value="8">8<option value="7">7<option value="6">6<option value="5">5<option value="4">4<option value="3">3<option value="2">2<option value="1">1 (Bad)</select></td></tr></table><table>
<tr valign='top'><td></td><td align=middle><?php 
smile();
?></td><tr><td><font size=1>
Comment:<BR></b></td>
<td><textarea cols='35' rows='3' name='comment' onkeydown=textCounter(this.form.comment,this.form.descriptionleft,150); onkeyup=textCounter(this.form.comment,this.form.descriptionleft,150);></textarea><br>Characters Left <INPUT maxLength=3 name=descriptionleft readOnly size=3 tabIndex=150 value=150 style='BORDER-RIGHT: 0px; BORDER-TOP:0px;BORDER-LEFT:0px; BORDER-BOTTOM:0px;BACKGROUND-COLOR: #666666;'></td></tr>
<tr><td></td><td>
<input type='submit' value='Add Review' style="background:#666666;border-width:1;Border-color:#3a4f6c;"></td></tr>
</table>
</table>
</form>
</font>

Link to comment
https://forums.phpfreaks.com/topic/65341-php-captcha-help/
Share on other sites

  • 5 weeks later...

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.