0

キャプチャを使用した非常に単純なフォームでの作業キャプチャを扱うのはこれが初めてなので、ビルド済みのセットアップ「quickcaptcha1.0」を使用しています。

現在、すべてが正常に機能しています。フォーム、キャプチャ、変数間にあるリンクの量に関係していると私が考えているプロセスを除いて、

これが私が考えていることです。フォームがユーザーに表示され、ユーザーが情報を入力します。キャプチャは、送信ボタンの後に「requestresult.php」を介してチェックされ、成功した場合は「resultsettings.php」に渡され、resultsettingsで「requestprocess.php」に送信されます。最初のrequest.phpフォーム。

よくわかりません。現在、本文情報と入力情報が添付されていないメールと、そのすぐ下に何も表示されていないメールが2通送信されています。

これがコードです。

request.php:

<?
        /* Subject and Email Variables */

    $emailSubject = 'Request Form';
    $webMaster = 'info@mywebhost.com';

        /* Gathering Data Variables */

    $nameField = $_POST['name'];
    $aliasField = $_POST['alias'];
    $cellField = $_POST['cell'];
    $emailField = str_replace( "\r\n", '', $_POST['email'] );
    $boardField = $_POST['board'];
    $refname1Field = $_POST['refname1'];
    $refcontact1Field = $_POST['refcontact1'];
    $refname2Field = $_POST['refname2'];
    $workinfoField = $_POST['workinfo'];
    $worknameField = $_POST['workname'];
    $workaddyField = $_POST['workaddy'];
    $switchnoField = $_POST['switchno'];
    $directnoField = $_POST['directno'];



        ?>
        <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org /TR/xhtml1/DTD/xhtml1-transitional.dtd">
        <html xmlns="http://www.w3.org/1999/xhtml">
        <head>
        <link href="nrlayouts.css" rel=stylesheet type=text/css />
        <script type="text/javascript">
       // <![CDATA[
        function display(obj,id1,id2) {
        txt = obj.options[obj.selectedIndex].value;
        document.getElementById(id1).style.display = 'none';
         document.getElementById(id2).style.display = 'none';
        if ( txt.match(id1) ) {
         document.getElementById(id1).style.display = 'block';
        }
        if ( txt.match(id2) ) {
        document.getElementById(id2).style.display = 'block';
        }
        }
        // ]]>
        </script>

        </head>
          <body bgcolor="#CCC"><form action="requestresult.php" method="post">
              <table width="540" border="0" cellspacing="5" cellpadding="0">
                <tr>
                  <td width="250" align="right"><label for="name7">Full Name:</label>        </td>
                  <td width="250" align="left"><input type="text" name="name"        id="name" />         </td>
                 </tr>
                <tr>
                  <td width="250" align="right"><label for="alias">Alias:</label></td>
                  <td width="250" align="left"><input type="text" name="alias" id="alias" />     </td>
                </tr>
                <tr>
                  <td width="250" align="right"><label for="cell">Cellphone:</label>        </td>
                  <td width="250" align="left"><input type="text" name="cell"        id="cell" />     </td>
                </tr>
                <tr>
                  <td width="250" align="right"><label for="email">Email:</label></td>
                  <td width="250" align="left"><input type="text" name="email" id="email" />     </td>
                </tr>
                <tr>
                  <td width="250" align="right"><label for="board">Board:</label></td>
                  <td width="250" align="left"><input type="text" name="board" id="board" /></td>
                </tr>
                <td class="title">References?</td>
         <td class="field">
         <select name="type" onchange="display(this,'References','workinfo');">
         <option>Do you have References?:</option>
         <option value="References">Yes</option>
         <option value="workinfo">No</option>
         </select>
                </tr>
         </thead>
         <tfoot>
         <tr>
         <td class="title">Please Prove You are Human:  <img          src="quickcaptcha/imagebuilder.php" border="1"></td>
          <td><input MAXLENGTH=8 SIZE=8 name="userstring" type="text" value=""></td>
          <td></td>
          </tr>
          <tr>
          <td class="align-center" colspan="2"><input type="submit" name="submit" value="Send Email!" /> <input type="reset" value="Reset" /></td>
          </tr>
          </tfoot>
           <tbody id="References" style="display: none;">
         <tr>
         <td class="title">Reference Name:</td>
         <td class="field"><input type="text" name="refname1" size="20" maxlength="20" />        </td>
          </tr>
          <tr>
          <td class="title">Reference Contact:</td>
           <td class="field"><input type="text" name="refcontact1" size="20" maxlength="30" /></td>
           </tr>
          <tr>
            <td class="title">Reference Name:</td>
             <td class="field"><input type="text" name="refname2" size="20" maxlength="20" /></td>
           </tr>
            <tr>
           <td class="title">Reference Contact:</td>
           <td class="field"><input type="text" name="refcontact2" size="20" maxlength="30" /></td>
           </tr>
           </tbody>
           <tbody id="workinfo" style="display: none;">
           <tr>
           <td class="title">Work Information:</td>
           <td class="field"><input type="text" name="workinfo" size="20" maxlength="30" />         </td>
           </tr>
           <tr>
           <td class="title">Employer's Name:</td>
           <td class="field"><input type="text" name="workname" size="20" maxlength="30" /></td>
           </tr>
           <tr>
           <td class="title">Employer's Address:</td>
           <td class="field"><input type="textarea" name="workaddy" size="20" maxlength="30" /></td>
            </tr>
            <tr>
            <td class="title">Main Switchboard Number:</td>
            <td class="field"><input type="text" name="switchno" size="20" maxlength="20"/>          </td>
            </tr>
            <tr>
            <td class="title">Direct Line:</td>
                   <td class="field"><input type="text" name="directno" size="20" maxlength="20" />       </td>
             </tr>
              </table>
            </form>
            </body>
            </html>

requestsettings.php

<?php

    // This string contains allowable characters for the image.
    // To reduce confusion, zero and the letter 'o' have been removed,
    // and QuickCaptcha is NOT case-sensitive.
    $acceptedChars = 'ABCDEFGHIJKLMNPQRSTUVWXYZ123456789';

    // Number of characters in image.
    $stringlength = 5;

    // Where to go when the correct / incorrect code is entered.
    $success = "requestprocess.php";
    $failure = "failure.html";

    // A value between 0 and 100 describing how much color overlap
    // there is between text and other objects.  Lower is more
    // secure against bots, but also harder to read.
    $contrast = 60;

    // Various obfuscation techniques.
    $num_polygons = 3; // Number of triangles to draw.  0 = none
    $num_ellipses = 6;  // Number of ellipses to draw.  0 = none
    $num_lines = 0;  // Number of lines to draw.  0 = none
    $num_dots = 0;  // Number of dots to draw.  0 = none

    $min_thickness = 2;  // Minimum thickness in pixels of lines
    $max_thickness = 8;  // Maximum thickness in pixles of lines
    $min_radius = 5;  // Minimum radius in pixels of ellipses
    $max_radius = 15;  // Maximum radius in pixels of ellipses

    // How opaque should the obscuring objects be. 0 is opaque, 127
    // is transparent.
    $object_alpha = 75;
    ?>

requestresult.php:

<?php

    include "requestsettings.php";

    session_start();
    $string = strtoupper($_SESSION['string']);
    $userstring = strtoupper($_POST['userstring']); 
    session_destroy();   

    if (($string == $userstring) && (strlen($string) > 4)) {
header("Location: $success");
exit();
      } else {
header("Location: $failure");
exit();
       }
      ?>

requestprocess.php

<?php
      include_once "request.php";

$emailSubject = 'Request Form';
$webMaster = 'info@mywebhost.com';


$body = <<<EOD
   <br><hr><br>
  Name: $nameField <br>
  Alias: $aliasField <br>
  Cellphone: $cellField <br>
  Email: $emailField <br>
  Board: $boardField <br>
  Reference Name1: $refname1Field <br>
  Reference Contact1: $refcontact1Field <br>
  Reference Name2: $refname2Field <br>
  Reference Contact2: $refcontact2Field <br>
  Work Information: $workinfoField <br>
  Work Name: $worknameField <br>
  Work Address: $workaddyField <br>
  Switchboard Number: $switchnoField <br>
  Direct Line: $directnoField <br>
    EOD;

$headers = "From: $emailField\r\n";
$headers .= "Content-type: text/html\r\n";
$success = mail($webMaster, $emailSubject, $body, $headers);

      /* Results rendered as HTML */
     $result = "Thank you!  Your request will be answered shortly.";
        if($success){
echo "$result";
      }else{
echo "There was an error with your submission";
exit;
      }
     ?>

imagebuilder.php

<?php
include "settings.php";

// Keep #'s reasonable.
$min_thickness = max(1,$min_thickness);
$max_thickness = min(20,$max_thickness);
// Make radii into height/width
$min_radius *= 2;
$max_radius *= 2;
// Renormalize contrast
$contrast = 255 * ($contrast / 100.0);
$o_contrast = 1.3 * $contrast;

$width = 15 * imagefontwidth (5);
$height = 2.5 * imagefontheight (5);
$image = imagecreatetruecolor ($width, $height);
imagealphablending($image, true);
$black = imagecolorallocatealpha($image,0,0,0,0);

// Build the  validation string
$max = strlen($acceptedChars)-1;
$password = NULL;
for($i=0; $i < $stringlength; $i++) {
    $cnum[$i] = $acceptedChars{mt_rand(0, $max)};
    $password .= $cnum[$i];
}

// Add string to image
$rotated = imagecreatetruecolor (70, 70);
$x = 0;
for ($i = 0; $i < $stringlength; $i++) {
    $buffer = imagecreatetruecolor (20, 20);
    $buffer2 = imagecreatetruecolor (40, 40);

    // Get a random color
    $red = mt_rand(0,255);
    $green = mt_rand(0,255);
    $blue = 255 - sqrt($red * $red + $green * $green);
    $color = imagecolorallocate ($buffer, $red, $green, $blue);

    // Create character
    imagestring($buffer, 5, 0, 0, $cnum[$i], $color);

    // Resize character
    imagecopyresized ($buffer2, $buffer, 0, 0, 0, 0, 25 + mt_rand(0,12), 25 + mt_rand(0,12), 20, 20);

    // Rotate characters a little
    $rotated = imagerotate($buffer2, mt_rand(-25, 25),imagecolorallocatealpha($buffer2,0,0,0,0)); 
    imagecolortransparent ($rotated, imagecolorallocatealpha($rotated,0,0,0,0));

    // Move characters around a little
    $y = mt_rand(1, 3);
    $x += mt_rand(2, 6); 
    imagecopymerge ($image, $rotated, $x, $y, 0, 0, 40, 40, 100);
    $x += 22;

    imagedestroy ($buffer); 
    imagedestroy ($buffer2); 
}

// Draw polygons
if ($num_polygons > 0) for ($i = 0; $i < $num_polygons; $i++) {
    $vertices = array (
        mt_rand(-0.25*$width,$width*1.25),mt_rand(-0.25*$width,$width*1.25),
        mt_rand(-0.25*$width,$width*1.25),mt_rand(-0.25*$width,$width*1.25),
        mt_rand(-0.25*$width,$width*1.25),mt_rand(-0.25*$width,$width*1.25)
    );
    $color = imagecolorallocatealpha ($image, mt_rand(0,$o_contrast), mt_rand(0,$o_contrast), mt_rand(0,$o_contrast), $object_alpha);
    imagefilledpolygon($image, $vertices, 3, $color);  
}

// Draw random circles
if ($num_ellipses > 0) for ($i = 0; $i < $num_ellipses; $i++) {
    $x1 = mt_rand(0,$width);
    $y1 = mt_rand(0,$height);
    $color = imagecolorallocatealpha ($image, mt_rand(0,$o_contrast), mt_rand(0,$o_contrast), mt_rand(0,$o_contrast), $object_alpha);
//  $color = imagecolorallocate($image, mt_rand(0,$o_contrast), mt_rand(0,$o_contrast), mt_rand(0,$o_contrast));
    imagefilledellipse($image, $x1, $y1, mt_rand($min_radius,$max_radius), mt_rand($min_radius,$max_radius), $color);  
}

// Draw random lines
if ($num_lines > 0) for ($i = 0; $i < $num_lines; $i++) {
    $x1 = mt_rand(-$width*0.25,$width*1.25);
    $y1 = mt_rand(-$height*0.25,$height*1.25);
    $x2 = mt_rand(-$width*0.25,$width*1.25);
    $y2 = mt_rand(-$height*0.25,$height*1.25);
    $color = imagecolorallocatealpha ($image, mt_rand(0,$o_contrast), mt_rand(0,$o_contrast), mt_rand(0,$o_contrast), $object_alpha);
    imagesetthickness ($image, mt_rand($min_thickness,$max_thickness));
    imageline($image, $x1, $y1, $x2, $y2 , $color);  
}

// Draw random dots
if ($num_dots > 0) for ($i = 0; $i < $num_dots; $i++) {
    $x1 = mt_rand(0,$width);
    $y1 = mt_rand(0,$height);
    $color = imagecolorallocatealpha ($image, mt_rand(0,$o_contrast), mt_rand(0,$o_contrast), mt_rand(0,$o_contrast),$object_alpha);
    imagesetpixel($image, $x1, $y1, $color);
}

session_start();
$_SESSION['string'] = $password;

header('Content-type: image/png');
imagepng($image);
imagedestroy($image);

?>
4

1 に答える 1

2

変更されたフォーム(request.php)は次のとおりです- 注: imagebuilder.phpファイルへのパスを必ず変更してください

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org /TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <link href="nrlayouts.css" rel=stylesheet type=text/css />
    <script type="text/javascript">
   // <![CDATA[
    function display(obj,id1,id2) {
    txt = obj.options[obj.selectedIndex].value;
    document.getElementById(id1).style.display = 'none';
     document.getElementById(id2).style.display = 'none';
    if ( txt.match(id1) ) {
     document.getElementById(id1).style.display = 'block';
    }
    if ( txt.match(id2) ) {
    document.getElementById(id2).style.display = 'block';
    }
    }
    // ]]>
    </script>

    </head>
      <body bgcolor="#CCC">
          <table width="540" border="0" cellspacing="5" cellpadding="0">
<form action="requestprocess.php" method="post">
            <tr>
              <td width="250" align="right"><label for="name7">Full Name:</label>        </td>
              <td width="250" align="left"><input type="text" name="name"        id="name" />         </td>
             </tr>
            <tr>
              <td width="250" align="right"><label for="alias">Alias:</label></td>
              <td width="250" align="left"><input type="text" name="alias" id="alias" />     </td>
            </tr>
            <tr>
              <td width="250" align="right"><label for="cell">Cellphone:</label>        </td>
              <td width="250" align="left"><input type="text" name="cell"        id="cell" />     </td>
            </tr>
            <tr>
              <td width="250" align="right"><label for="email">Email:</label></td>
              <td width="250" align="left"><input type="text" name="email" id="email" />     </td>
            </tr>
            <tr>
              <td width="250" align="right"><label for="board">Board:</label></td>
              <td width="250" align="left"><input type="text" name="board" id="board" /></td>
            </tr>
            <td class="title">References?</td>
     <td class="field">
     <select name="type" onchange="display(this,'References','workinfo');">
     <option>Do you have References?:</option>
     <option value="References">Yes</option>
     <option value="workinfo">No</option>
     </select>
            </tr>
     </thead>
     <tfoot>
     <tr>
     <td class="title">Please Prove You are Human:  <img src="imagebuilder.php" border="1"></td>
      <td><input MAXLENGTH=8 SIZE=8 name="userstring" type="text" value=""></td>
      <td></td>
      </tr>
      <tr>
      <td class="align-center" colspan="2"><input type="submit" name="submit" value="Send Email!" /> <input type="reset" value="Reset" /></td>
      </tr>
      </tfoot>
       <tbody id="References" style="display: none;">
     <tr>
     <td class="title">Reference Name:</td>
     <td class="field"><input type="text" name="refname1" size="20" maxlength="20" />        </td>
      </tr>
      <tr>
      <td class="title">Reference Contact:</td>
       <td class="field"><input type="text" name="refcontact1" size="20" maxlength="30" /></td>
       </tr>
      <tr>
        <td class="title">Reference Name:</td>
         <td class="field"><input type="text" name="refname2" size="20" maxlength="20" /></td>
       </tr>
        <tr>
       <td class="title">Reference Contact:</td>
       <td class="field"><input type="text" name="refcontact2" size="20" maxlength="30" /></td>
       </tr>
       </tbody>
       <tbody id="workinfo" style="display: none;">
       <tr>
       <td class="title">Work Information:</td>
       <td class="field"><input type="text" name="workinfo" size="20" maxlength="30" />         </td>
       </tr>
       <tr>
       <td class="title">Employer's Name:</td>
       <td class="field"><input type="text" name="workname" size="20" maxlength="30" /></td>
       </tr>
       <tr>
       <td class="title">Employer's Address:</td>
       <td class="field"><input type="textarea" name="workaddy" size="20" maxlength="30" /></td>
        </tr>
        <tr>
        <td class="title">Main Switchboard Number:</td>
        <td class="field"><input type="text" name="switchno" size="20" maxlength="20"/>          </td>
        </tr>
        <tr>
        <td class="title">Direct Line:</td>
               <td class="field"><input type="text" name="directno" size="20" maxlength="20" />       </td>
         </tr>
        </form>
          </table>

        </body>
        </html>

これが変更されたプロセスです(requestprocess.php)

<?php

$emailSubject = 'Request Form';
$webMaster = 'youremail@somewhere.com';

        /* Gathering Data Variables */

    $nameField = $_POST['name'];
    $aliasField = $_POST['alias'];
    $cellField = $_POST['cell'];
    $emailField = str_replace( "\r\n", '', $_POST['email'] );
    $boardField = $_POST['board'];
    $refname1Field = $_POST['refname1'];
    $refcontact1Field = $_POST['refcontact1'];
    $refname2Field = $_POST['refname2'];
    $workinfoField = $_POST['workinfo'];
    $worknameField = $_POST['workname'];
    $workaddyField = $_POST['workaddy'];
    $switchnoField = $_POST['switchno'];
    $directnoField = $_POST['directno'];

$body = "
   <br><hr><br>
  Name: $nameField <br>
  Alias: $aliasField <br>
  Cellphone: $cellField <br>
  Email: $emailField <br>
  Board: $boardField <br>
  Reference Name1: $refname1Field <br>
  Reference Contact1: $refcontact1Field <br>
  Reference Name2: $refname2Field <br>
  Reference Contact2: $refcontact2Field <br>
  Work Information: $workinfoField <br>
  Work Name: $worknameField <br>
  Work Address: $workaddyField <br>
  Switchboard Number: $switchnoField <br>
  Direct Line: $directnoField <br>
";


$headers = "From: $emailField\r\n";
$headers .= "Content-type: text/html\r\n";
$success = mail($webMaster, $emailSubject, $body, $headers);

      /* Results rendered as HTML */
     $result = "Thank you! Your request will be answered shortly.";

// NOTE: produces an error, commented out
//        if($success){
echo "$result";
//      }else{
//echo "There was an error with your submission";
//exit;
//      }

?>

これがrequestsettings.phpです(変更された行14、$ success = ... etc)

<?php

// This string contains allowable characters for the image.
// To reduce confusion, zero and the letter 'o' have been removed,
// and QuickCaptcha is NOT case-sensitive.
$acceptedChars = 'ABCDEFGHIJKLMNPQRSTUVWXYZ123456789';

// Number of characters in image.
$stringlength = 5;

// Where to go when the correct / incorrect code is entered.
//    $success = "requestprocess.php";

$success = "success.html";
$failure = "failure.html";

// A value between 0 and 100 describing how much color overlap
// there is between text and other objects.  Lower is more
// secure against bots, but also harder to read.
$contrast = 60;

// Various obfuscation techniques.
$num_polygons = 3; // Number of triangles to draw.  0 = none
$num_ellipses = 6;  // Number of ellipses to draw.  0 = none
$num_lines = 0;  // Number of lines to draw.  0 = none
$num_dots = 0;  // Number of dots to draw.  0 = none

$min_thickness = 2;  // Minimum thickness in pixels of lines
$max_thickness = 8;  // Maximum thickness in pixles of lines
$min_radius = 5;  // Minimum radius in pixels of ellipses
$max_radius = 15;  // Maximum radius in pixels of ellipses

// How opaque should the obscuring objects be. 0 is opaque, 127
// is transparent.
$object_alpha = 75;
?>

いくつかのファイルを変更しました。好みに合わせて変更できますが、コピーを使用してテストします。それがあなたのためにどのように機能するかを私に知らせてください、それは私のために機能しました。

于 2013-03-15T02:12:13.213 に答える