PDA

View Full Version : captcha



jalaladdin
یک شنبه 23 مرداد 1390, 13:08 عصر
رای فرم تماس با ما از کدcaptcha استفاده کردم اما تصویر امنیتی نشان داده نمیشود به نظر شما مشکل از کجا میتونه باشد

<form action="<?php $_SERVER['PHP_SELF']?>" name="contact" method="post" class=" dir "name="signup" id="signup" >
<center><table summary="Demonstration form">
<tbody>
<tr>
<td><label for="name">نام :</label></td>
<td><input name="name" size="35" maxlength="50" type="text" ></td>
</tr>
<tr>
<td><label for="email">ایمیل:</label></td>
<td><input name="email" size="35" maxlength="25" type="text"></td>
</tr>
<tr>
<td><label for="title">عنوان:</label></td>
<td><input name="title" size="35" maxlength="25" type="text"></td>
</tr>
<tr>
<td><label for="message">پیام:</label></td>

<td><textarea style="width:250px;height:120px" name="message" type="text"rows="5" cols"100" maxlength="2000"></textarea></td>
</tr>
<tr>
<td><label for="user_code">تصویر امنیتی:</label></td>
<td><input name="user_code" size="20" type="text"><img src="visual-captcha.php" width="200" height="60" alt="Visual CAPTCHA" /></td>
</tr>
<tr>
<td> </td>

<td><input name="Submit" value="ارسال" type="submit" class="button" ></td>

<td><input type="reset" value="پاک کردن" name="B2" class="button"> </td>
</tr>
</tbody>
</table></center>
</form>

<?php
$to="a53@yahoo.com";
$subject=$_POST['subject'];
$from=$_POST['mail'];
$message=$_POST['message'];

// Additional headers
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=utf-8' . "\r\n";
$headers .= 'To: '.$to . "\r\n";
$headers .= 'From: '.$from . "\r\n";
$headers .= 'Reply-To: '.$to . "\r\n";
// Mail it
$sendmail=mail($to, $subject, $message, $headers);
if ($sendmail)
echo "پیغام شما با موفقیت ارسال شد";//Sucess Message
else
echo "خطا در ارسال متن";//Failed Message
?>
<br/>
<?php
require('php-captcha.inc.php');
if (PhpCaptcha::Validate($_POST['user_code'])) {
echo 'Valid code entered';
} else {
echo 'Invalid code entered';
}
?>
فونتها در یک پوشه بنام fonts ریختم

mohsen6500
یک شنبه 23 مرداد 1390, 13:13 عصر
خوب دوست عزیز کدهای captcha رو بذار تا ببینیم

amin1softco
یک شنبه 23 مرداد 1390, 13:38 عصر
به نظر می رسه این فایل موجود نیست visual-captcha.php
می تونی از یک همچین کدی برای درست کردنش استفاده کنی که کدش مربوط به یک سایته که یادم نیست چی بود


<?php
//Start the session so we can store what the security code actually is
session_start();

//Send a generated image to the browser
create_image();
exit();

function create_image()
{
//Let's generate a totally random string using md5
$md5_hash = md5(rand(0,999));
//We don't need a 32 character long string so we trim it down to 5
$security_code = substr($md5_hash, 15, 5);

//Set the session to store the security code
$_SESSION["security_code"] = $security_code;

//Set the image width and height
$width = 100;
$height = 20;

//Create the image resource
$image = ImageCreate($width, $height);

//We are making three colors, white, black and gray
$white = ImageColorAllocate($image, 255, 255, 255);
$black = ImageColorAllocate($image, 0, 0, 0);
$grey = ImageColorAllocate($image, 204, 204, 204);

//Make the background black
ImageFill($image, 0, 0, $black);

//Add randomly generated string in white to the image
ImageString($image, 3, 30, 3, $security_code, $white);

//Throw in some lines to make it a little bit harder for any bots to break
ImageRectangle($image,0,0,$width-1,$height-1,$grey);
imageline($image, 0, $height/2, $width, $height/2, $grey);
imageline($image, $width/2, 0, $width/2, $height, $grey);

//Tell the browser what kind of file is come in
header("Content-Type: image/jpeg");

//Output the newly created image in jpeg format
ImageJpeg($image);

//Free up resources
ImageDestroy($image);
}
?>

jalaladdin
یک شنبه 23 مرداد 1390, 18:50 عصر
این هم فایل visual-capycha.php

<?php
require('php-captcha.inc.php');
$aFonts = array('fonts/1.TTF', 'fonts/2.ttf', 'fonts/3.ttf','fonts/4.otf','fonts/5.TTF',);
$oVisualCaptcha = new PhpCaptcha($aFonts, 200, 60);
$oVisualCaptcha->DisplayShadow(true);
$oVisualCaptcha->SetBackgroundImages('images/captcha.jpg');
$oVisualCaptcha->UseColour(true);
$oVisualCaptcha->Create();
?>

jalaladdin
یک شنبه 23 مرداد 1390, 18:52 عصر
این هم کدphp-captcha.inc.php

<?php
/************************************************** *************/
/* PhpCaptcha - A visual and audio CAPTCHA generation library

Software License Agreement (BSD License)

Copyright (C) 2005-2006, Edward Eliot.
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of Edward Eliot nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission of Edward Eliot.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS IS" AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Last Updated: 18th April 2006 */
/************************************************** *************/

/************************ Documentation ************************/
/*

Documentation is available at http://www.ejeliot.com/pages/2

*/
/************************ Default Options **********************/

// start a PHP session - this class uses sessions to store the generated
// code. Comment out if you are calling already from your application


// class defaults - change to effect globally

define('CAPTCHA_SESSION_ID', 'php_captcha');
define('CAPTCHA_WIDTH', 200); // max 500
define('CAPTCHA_HEIGHT', 50); // max 200
define('CAPTCHA_NUM_CHARS', 5);
define('CAPTCHA_NUM_LINES', 70);
define('CAPTCHA_CHAR_SHADOW', false);
define('CAPTCHA_OWNER_TEXT', '');
define('CAPTCHA_CHAR_SET', ''); // defaults to A-Z
define('CAPTCHA_CASE_INSENSITIVE', true);
define('CAPTCHA_BACKGROUND_IMAGES', '');
define('CAPTCHA_MIN_FONT_SIZE', 16);
define('CAPTCHA_MAX_FONT_SIZE', 25);
define('CAPTCHA_USE_COLOUR', false);
define('CAPTCHA_FILE_TYPE', 'jpeg');
define('CAPTCHA_FLITE_PATH', '/usr/bin/flite');
define('CAPTCHA_AUDIO_PATH', '/tmp/'); // must be writeable by PHP process

/************************ End Default Options **********************/

// don't edit below this line (unless you want to change the class!)

class PhpCaptcha {
var $oImage;
var $aFonts;
var $iWidth;
var $iHeight;
var $iNumChars;
var $iNumLines;
var $iSpacing;
var $bCharShadow;
var $sOwnerText;
var $aCharSet;
var $bCaseInsensitive;
var $vBackgroundImages;
var $iMinFontSize;
var $iMaxFontSize;
var $bUseColour;
var $sFileType;
var $sCode = '';

function PhpCaptcha(
$aFonts, // array of TrueType fonts to use - specify full path
$iWidth = CAPTCHA_WIDTH, // width of image
$iHeight = CAPTCHA_HEIGHT // height of image
) {
// get parameters
$this->aFonts = $aFonts;
$this->SetNumChars(CAPTCHA_NUM_CHARS);
$this->SetNumLines(CAPTCHA_NUM_LINES);
$this->DisplayShadow(CAPTCHA_CHAR_SHADOW);
$this->SetOwnerText(CAPTCHA_OWNER_TEXT);
$this->SetCharSet(CAPTCHA_CHAR_SET);
$this->CaseInsensitive(CAPTCHA_CASE_INSENSITIVE);
$this->SetBackgroundImages(CAPTCHA_BACKGROUND_IMAGES);
$this->SetMinFontSize(CAPTCHA_MIN_FONT_SIZE);
$this->SetMaxFontSize(CAPTCHA_MAX_FONT_SIZE);
$this->UseColour(CAPTCHA_USE_COLOUR);
$this->SetFileType(CAPTCHA_FILE_TYPE);
$this->SetWidth($iWidth);
$this->SetHeight($iHeight);
}

function CalculateSpacing() {
$this->iSpacing = (int)($this->iWidth / $this->iNumChars);
}

function SetWidth($iWidth) {
$this->iWidth = $iWidth;
if ($this->iWidth > 500) $this->iWidth = 500; // to prevent perfomance impact
$this->CalculateSpacing();
}

function SetHeight($iHeight) {
$this->iHeight = $iHeight;
if ($this->iHeight > 200) $this->iHeight = 200; // to prevent performance impact
}

function SetNumChars($iNumChars) {
$this->iNumChars = $iNumChars;
$this->CalculateSpacing();
}

function SetNumLines($iNumLines) {
$this->iNumLines = $iNumLines;
}

function DisplayShadow($bCharShadow) {
$this->bCharShadow = $bCharShadow;
}

function SetOwnerText($sOwnerText) {
$this->sOwnerText = $sOwnerText;
}

function SetCharSet($vCharSet) {
// check for input type
if (is_array($vCharSet)) {
$this->aCharSet = $vCharSet;
} else {
if ($vCharSet != '') {
// split items on commas
$aCharSet = explode(',', $vCharSet);

// initialise array
$this->aCharSet = array();

// loop through items
foreach ($aCharSet as $sCurrentItem) {
// a range should have 3 characters, otherwise is normal character
if (strlen($sCurrentItem) == 3) {
// split on range character
$aRange = explode('-', $sCurrentItem);

// check for valid range
if (count($aRange) == 2 && $aRange[0] < $aRange[1]) {
// create array of characters from range
$aRange = range($aRange[0], $aRange[1]);

// add to charset array
$this->aCharSet = array_merge($this->aCharSet, $aRange);
}
} else {
$this->aCharSet[] = $sCurrentItem;
}
}
}
}
}

function CaseInsensitive($bCaseInsensitive) {
$this->bCaseInsensitive = $bCaseInsensitive;
}

function SetBackgroundImages($vBackgroundImages) {
$this->vBackgroundImages = $vBackgroundImages;
}

function SetMinFontSize($iMinFontSize) {
$this->iMinFontSize = $iMinFontSize;
}

function SetMaxFontSize($iMaxFontSize) {
$this->iMaxFontSize = $iMaxFontSize;
}

function UseColour($bUseColour) {
$this->bUseColour = $bUseColour;
}

function SetFileType($sFileType) {
// check for valid file type
if (in_array($sFileType, array('gif', 'png', 'jpeg'))) {
$this->sFileType = $sFileType;
} else {
$this->sFileType = 'jpeg';
}
}

function DrawLines() {
for ($i = 0; $i < $this->iNumLines; $i++) {
// allocate colour
if ($this->bUseColour) {
$iLineColour = imagecolorallocate($this->oImage, rand(100, 250), rand(100, 250), rand(100, 250));
} else {
$iRandColour = rand(100, 250);
$iLineColour = imagecolorallocate($this->oImage, $iRandColour, $iRandColour, $iRandColour);
}

// draw line
imageline($this->oImage, rand(0, $this->iWidth), rand(0, $this->iHeight), rand(0, $this->iWidth), rand(0, $this->iHeight), $iLineColour);
}
}

function DrawOwnerText() {
// allocate owner text colour
$iBlack = imagecolorallocate($this->oImage, 0, 0, 0);
// get height of selected font
$iOwnerTextHeight = imagefontheight(2);
// calculate overall height
$iLineHeight = $this->iHeight - $iOwnerTextHeight - 4;

// draw line above text to separate from CAPTCHA
imageline($this->oImage, 0, $iLineHeight, $this->iWidth, $iLineHeight, $iBlack);

// write owner text
imagestring($this->oImage, 2, 3, $this->iHeight - $iOwnerTextHeight - 3, $this->sOwnerText, $iBlack);

// reduce available height for drawing CAPTCHA
$this->iHeight = $this->iHeight - $iOwnerTextHeight - 5;
}

function GenerateCode() {
// reset code
$this->sCode = '';

// loop through and generate the code letter by letter
for ($i = 0; $i < $this->iNumChars; $i++) {
if (count($this->aCharSet) > 0) {
// select random character and add to code string
$this->sCode .= $this->aCharSet[array_rand($this->aCharSet)];
} else {
// select random character and add to code string
$this->sCode .= chr(rand(65, 90));
}
}

// save code in session variable
if ($this->bCaseInsensitive) {
$_SESSION[CAPTCHA_SESSION_ID] = strtoupper($this->sCode);
} else {
$_SESSION[CAPTCHA_SESSION_ID] = $this->sCode;
}
}

function DrawCharacters() {
// loop through and write out selected number of characters
for ($i = 0; $i < strlen($this->sCode); $i++) {
// select random font
$sCurrentFont = $this->aFonts[array_rand($this->aFonts)];

// select random colour
if ($this->bUseColour) {
$iTextColour = imagecolorallocate($this->oImage, rand(0, 100), rand(0, 100), rand(0, 100));

if ($this->bCharShadow) {
// shadow colour
$iShadowColour = imagecolorallocate($this->oImage, rand(0, 100), rand(0, 100), rand(0, 100));
}
} else {
$iRandColour = rand(0, 100);
$iTextColour = imagecolorallocate($this->oImage, $iRandColour, $iRandColour, $iRandColour);

if ($this->bCharShadow) {
// shadow colour
$iRandColour = rand(0, 100);
$iShadowColour = imagecolorallocate($this->oImage, $iRandColour, $iRandColour, $iRandColour);
}
}

// select random font size
$iFontSize = rand($this->iMinFontSize, $this->iMaxFontSize);

// select random angle
$iAngle = rand(-30, 30);

// get dimensions of character in selected font and text size
$aCharDetails = imageftbbox($iFontSize, $iAngle, $sCurrentFont, $this->sCode[$i], array());

// calculate character starting coordinates
$iX = $this->iSpacing / 4 + $i * $this->iSpacing;
$iCharHeight = $aCharDetails[2] - $aCharDetails[5];
$iY = $this->iHeight / 2 + $iCharHeight / 4;

// write text to image
imagefttext($this->oImage, $iFontSize, $iAngle, $iX, $iY, $iTextColour, $sCurrentFont, $this->sCode[$i], array());

if ($this->bCharShadow) {
$iOffsetAngle = rand(-30, 30);

$iRandOffsetX = rand(-5, 5);
$iRandOffsetY = rand(-5, 5);

imagefttext($this->oImage, $iFontSize, $iOffsetAngle, $iX + $iRandOffsetX, $iY + $iRandOffsetY, $iShadowColour, $sCurrentFont, $this->sCode[$i], array());
}
}
}

function WriteFile($sFilename) {
if ($sFilename == '') {
// tell browser that data is jpeg
header("Content-type: image/$this->sFileType");
}

switch ($this->sFileType) {
case 'gif':
$sFilename != '' ? imagegif($this->oImage, $sFilename) : imagegif($this->oImage);
break;
case 'png':
$sFilename != '' ? imagepng($this->oImage, $sFilename) : imagepng($this->oImage);
break;
default:
$sFilename != '' ? imagejpeg($this->oImage, $sFilename) : imagejpeg($this->oImage);
}
}

function Create($sFilename = '') {
// check for required gd functions
if (!function_exists('imagecreate') || !function_exists("image$this->sFileType") || ($this->vBackgroundImages != '' && !function_exists('imagecreatetruecolor'))) {
return false;
}

// get background image if specified and copy to CAPTCHA
if (is_array($this->vBackgroundImages) || $this->vBackgroundImages != '') {
// create new image
$this->oImage = imagecreatetruecolor($this->iWidth, $this->iHeight);

// create background image
if (is_array($this->vBackgroundImages)) {
$iRandImage = array_rand($this->vBackgroundImages);
$oBackgroundImage = imagecreatefromjpeg($this->vBackgroundImages[$iRandImage]);
} else {
$oBackgroundImage = imagecreatefromjpeg($this->vBackgroundImages);
}

// copy background image
imagecopy($this->oImage, $oBackgroundImage, 0, 0, 0, 0, $this->iWidth, $this->iHeight);

// free memory used to create background image
imagedestroy($oBackgroundImage);
} else {
// create new image
$this->oImage = imagecreate($this->iWidth, $this->iHeight);
}

// allocate white background colour
imagecolorallocate($this->oImage, 255, 255, 255);

// check for owner text
if ($this->sOwnerText != '') {
$this->DrawOwnerText();
}

// check for background image before drawing lines
if (!is_array($this->vBackgroundImages) && $this->vBackgroundImages == '') {
$this->DrawLines();
}

$this->GenerateCode();
$this->DrawCharacters();

// write out image to file or browser
$this->WriteFile($sFilename);

// free memory used in creating image
imagedestroy($this->oImage);

return true;
}

// call this method statically
function Validate($sUserCode, $bCaseInsensitive = true) {
if ($bCaseInsensitive) {
$sUserCode = strtoupper($sUserCode);
}

if (!empty($_SESSION[CAPTCHA_SESSION_ID]) && $sUserCode == $_SESSION[CAPTCHA_SESSION_ID]) {
// clear to prevent re-use
unset($_SESSION[CAPTCHA_SESSION_ID]);

return true;
}

return false;
}
}

// this class will only work correctly if a visual CAPTCHA has been created first using PhpCaptcha
class AudioPhpCaptcha {
var $sFlitePath;
var $sAudioPath;
var $sCode;

function AudioPhpCaptcha(
$sFlitePath = CAPTCHA_FLITE_PATH, // path to flite binary
$sAudioPath = CAPTCHA_AUDIO_PATH // the location to temporarily store the generated audio CAPTCHA
) {
$this->SetFlitePath($sFlitePath);
$this->SetAudioPath($sAudioPath);

// retrieve code if already set by previous instance of visual PhpCaptcha
if (isset($_SESSION[CAPTCHA_SESSION_ID])) {
$this->sCode = $_SESSION[CAPTCHA_SESSION_ID];
}
}

function SetFlitePath($sFlitePath) {
$this->sFlitePath = $sFlitePath;
}

function SetAudioPath($sAudioPath) {
$this->sAudioPath = $sAudioPath;
}

function Mask($sText) {
$iLength = strlen($sText);

// loop through characters in code and format
$sFormattedText = '';
for ($i = 0; $i < $iLength; $i++) {
// comma separate all but first and last characters
if ($i > 0 && $i < $iLength - 1) {
$sFormattedText .= ', ';
} elseif ($i == $iLength - 1) { // precede last character with "and"
$sFormattedText .= ' and ';
}
$sFormattedText .= $sText[$i];
}

$aPhrases = array(
"The %1\$s characters are as follows: %2\$s",
"%2\$s, are the %1\$s letters",
"Here are the %1\$s characters: %2\$s",
"%1\$s characters are: %2\$s",
"%1\$s letters: %2\$s"
);

$iPhrase = array_rand($aPhrases);

return sprintf($aPhrases[$iPhrase], $iLength, $sFormattedText);
}

function Create() {
$sText = $this->Mask($this->sCode);
$sFile = md5($this->sCode.time());

// create file with flite
shell_exec("$this->sFlitePath -t \"$sText\" -o $this->sAudioPath$sFile.wav");

// set headers
header('Content-type: audio/x-wav');
header("Content-Disposition: attachment;filename=$sFile.wav");

// output to browser
echo file_get_contents("$this->sAudioPath$sFile.wav");

// delete temporary file
@unlink("$this->sAudioPath$sFile.wav");
}
}

// example sub class
class PhpCaptchaColour extends PhpCaptcha {
function PhpCaptchaColour($aFonts, $iWidth = CAPTCHA_WIDTH, $iHeight = CAPTCHA_HEIGHT) {
// call parent constructor
parent::PhpCaptcha($aFonts, $iWidth, $iHeight);

// set options
$this->UseColour(true);
}
}
?>

amin1softco
یک شنبه 23 مرداد 1390, 23:12 عصر
اصل آموزش و کدش از لینک زیر قابل دریافتهhttp://www.ejeliot.com/pages/2 برای من که کار داد!!!
و به احتمال 99% کتابخانه GD فعال نیست برای فعال سازی در wamp منوی زیر را دنبال کنید
php setting -> php extension -> php_gd2

jalaladdin
دوشنبه 24 مرداد 1390, 09:46 صبح
php setting -> php extension -> php_gd2
این لینک را دنبال کردم اما تصویر امنیتی نشان داده نمیشود

amin1softco
دوشنبه 24 مرداد 1390, 14:45 عصر
برای من که درست کار میده فایل ها رو هم ضمیمه کردم شاید فونت ها رو بد انتخا کردی فایل ضمیمه رو تست کن
در ضمن باید در wamp جلوی php_gd2 یک فلش که نشونه فعال بودنشه نمایش داده بشه:متفکر:

73829

jalaladdin
دوشنبه 24 مرداد 1390, 19:11 عصر
در wamp روی php_gd2 دو بار کلیک کردم دیگه نشان نمیده مشکل از کجاست؟

amin1softco
دوشنبه 24 مرداد 1390, 19:16 عصر
ببین دفعه اول که کلیک کنی اگه فعال نباشه فعال می شه دفعه دوم که کلیک کنی فعالم که باشه غیر فعالش می کنه
سوالای سخت نپرسید :D

jalaladdin
دوشنبه 24 مرداد 1390, 22:26 عصر
برای اضافه کردن php_gd2 به قسمت php_extension چه دستوری باید در قسمت add extension بنویسم

jalaladdin
دوشنبه 24 مرداد 1390, 22:30 عصر
در قسمت php extension
php_gd2 وجود ندارد نگاهی به این عکس بندازید
73849

amin1softco
دوشنبه 24 مرداد 1390, 23:01 عصر
عزیزم یک کاره دیگه کن برو به
config file -> php.ini
بعد دنبال این خط بگرد
extension=php_gd2.dll
و سمیکولن اولش رو پاک کن و ذخیرش کن
7385173852

jalaladdin
دوشنبه 24 مرداد 1390, 23:16 عصر
همین کار رو انجام دادم مشکل همچنان باقی است

jalaladdin
سه شنبه 25 مرداد 1390, 11:42 صبح
برای بروز رسانی کد امنیتی بدین صورت کد نوشتم اما کل صفحه refresh میشود من میخوام فقط تصویر refresh شود نه کل صفحه

img src="visual-captcha.php" width="200" height="60" alt="Visual CAPTCHA" /><br><a onClick="reload(); return false;" href="">ریست کد</a>

armsoftpc
سه شنبه 25 مرداد 1390, 12:09 عصر
به نام خدا
با سلام
دوست عزیز مشکل از ومپ شماست برای من هم کار کرد.
شما می تونی آخرین نسخه از ومپ سرور رو از طریق لینک زیر دانلود کنی، php_gd2 هم خودکار فعال است و نیاز به فعال سازی ندارد.:تشویق:
http://kajdom.directdl.net/software/PHP/WampServer2.1e-x32-upload-by-www%5Bdot%5Dkajdom%5Bdot%5Dnet.exe

اگر باز هم کار نکرد مشکل از ویندوز شماست و حتی از کامپیوتر شما!!!

armsoftpc
سه شنبه 25 مرداد 1390, 14:24 عصر
به نام خدا
با سلام دوباره خدمت دوستان
من با مشکل برخوردم ، اما نه مشکل قبلی ، عکس امنیتی نمایش پیدا می کند اما وقتی آن را در کادر می نویسیم و ارسال می کنیم ، با ارور Invalid code entered رو به رو می شویم ، من عبارت را به هر طریقی که بگویید وارد کردم ولی جواب گو نبود.
لطفا دوستان چک کنند ببینند مشکل از کجاست.:اشتباه:

jalaladdin
سه شنبه 25 مرداد 1390, 19:10 عصر
همین مشکل برای من نیز وجود دارد

armsoftpc
چهارشنبه 26 مرداد 1390, 18:11 عصر
به نام خدا
با سلام
کسی به سوال ما پاسخ نمی ده ، باید دوباره تاپیک بزنیم.:گریه::کف:

amin1softco
چهارشنبه 26 مرداد 1390, 19:54 عصر
بچه ها اینم اصلاح و تست کردم کامل و درست وصحیح شما هم همین کدی که ضمیمه کردم رو اکسترکت کنید و تست بگیرید باید درست کار بده:لبخندساده: حروف حتماً باید به شکل بزرگ تایپ بشه ASDCX

jalaladdin
چهارشنبه 26 مرداد 1390, 22:41 عصر
این پیغام INVALID CODE که در فرم تماس با ما استفاده میکردم مربوط به این بود که session_start(); ازابتدای کدها حذف کرده بودم حالا که این session_start(); را اضافه کردم در ابتدای فرم تماس با ما این پیغام خطا میده به نظر شما مشکل از کجاست؟
Warning: session_start() [function.session-start (http://localhost/my/function.session-start)]: Cannot send session cache limiter - headers already sent (output started at C:\wamp\www\my\index.php:9) in C:\wamp\www\my\php-captcha.inc.php on line 2

jalaladdin
چهارشنبه 26 مرداد 1390, 22:42 عصر
با توجه به اینکه این کد را قبل از کد های htmlنوشتم

<?php
session_start();
require('php-captcha.inc.php');
if (empty($_POST['user_code'])) {
$a='کد امنیتی را وارد کنید';}
else if (PhpCaptcha::Validate($_POST['user_code'])) {
$a='کد وارد شده صحیح میباشد';
// echo 'Valid code entered';

} else {
$a='کد وارد شده صحیح نمیباشد';
//echo 'Invalid code entered';
}
?>

amin1softco
چهارشنبه 26 مرداد 1390, 22:52 عصر
به نظرم مشکل اصلی از نسخه wamp شماست ... اما

Solution : Write ob_start() before session_start() statement.

jalaladdin
پنج شنبه 27 مرداد 1390, 00:30 صبح
i wrote ob_start() before session_start() statement.
باز همان پیغام خطا نشان میدهد

Warning: session_start() [function.session-start (http://localhost/my/function.session-start)]: Cannot send session cache limiter - headers already sent (output started at C:\wamp\www\my\index.php:1) in C:\wamp\www\my\index.php on line 3

amin1softco
پنج شنبه 27 مرداد 1390, 06:24 صبح
یکمی سرچ کردم مثل اینکه وقتی فایل را با فرمت utf-8 ذخیره کنیم این اتفاق می افته :
Using UTF-8 encoding WITHOUT BOM (Byte Order Mark) seems to fix the
problem.
فایل ها رو یکبار با فرمت ANSI ذخیره کنید و تست بگیرید شاید درست شد برای رفرش کپتچا هم یکمی تغییرش دادم فایل ضمیمه

armsoftpc
پنج شنبه 27 مرداد 1390, 15:30 عصر
به نام خدا
با سلام
کد کاملا خرابه مشکل از ومپ هم نیست.
اولا که کد پر باگه ، باگ هاش رو که رفع می کنیم. این خطا رو دوباره میده.چی کار کنیم.
به نظر من مشکل از این یک تکه کده!

include "php-captcha.inc.php";
if (PhpCaptcha::Validate($_POST['user_code'])) { // فکر کنم این قسمت خرابه و جواب نمی ده
echo 'Valid code entered';
} else {
echo 'Invalid code entered';
}
فیلم انجام کار را هم برای شما ضمیمه کردم!:کف::اشتباه::متفکر:
به دلیل محدودیت های شدید سایت برنامه نویس برای آپلود ، مجبور شدم فیلم را در پرشین گیگ آپلود کنم! واقعا که!:قهقهه:
http://armpc.persiangig.com/other/captcha_bug.zip

amin1softco
پنج شنبه 27 مرداد 1390, 16:38 عصر
عزیزه من من همین فایل رو روی سرور آپلود کردم بهتره تستش کنید
http://captcha.freetzi.com/
فیلم ضمیمه رو هم ببینید.

jalaladdin
جمعه 28 مرداد 1390, 10:12 صبح
برای فرم تماس با ما بدین صورت کد نوشتم چه تغییراتی در این کد بدهم با وارد کردن کد امنیتی درست پیام ارسال شود با توجه به این کدها پیام ارسال میشود بعد جلوی تصویر امنیتی اگر کد نادرست وارد شده پیغامی مبنی بر اینکه کد امنیتی را درست وارد کنید نشان میدهد

<?php
session_start();

require('php-captcha.inc.php');
if (empty($_POST['user_code'])) {
$a='کد امنیتی را وارد کنید';}
else if (PhpCaptcha::Validate($_POST['user_code'])) {
$a='<font color="#000099">کد وارد شده صحیح میباشد</font>';
// echo 'Valid code entered';

} else {
$a='کد وارد شده صحیح نمیباشد';
//echo 'Invalid code entered';
}
?>

<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" ;Dir:rtl />
<title>Untitled Document</title>
<link href="my.css" rel="stylesheet" type="text/css" />
<link href="cs/default.css" rel="stylesheet" type="text/css" />
<link href="SpryAssets/SpryMenuBarHorizontal.css" rel="stylesheet" type="text/css" />
<link href="css/complete_form.css" rel="stylesheet" type="text/css">

</script>

<script type="text/javascript">
function refresh(){
img = document.getElementById('Captcha');
//Change the image
img.src = 'visual-captcha.php?' + Math.random();
}
</script>

<script type="text/javascript">
<!--
var timeout = 500;
var closetimer = 0;
var ddmenuitem = 0;

// open hidden layer
function mopen(id)
{
// cancel close timer
mcancelclosetime();

// close old layer
if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';

// get new layer and show it
ddmenuitem = document.getElementById(id);
ddmenuitem.style.visibility = 'visible';

}
// close showed layer
function mclose()
{
if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';
}

// go close timer
function mclosetime()
{
closetimer = window.setTimeout(mclose, timeout);
}

// cancel close timer
function mcancelclosetime()
{
if(closetimer)
{
window.clearTimeout(closetimer);
closetimer = null;
}
}

// close layer when click-out
document.onclick = mclose;
// -->
</script>


</head>

<center><body background="">
<table width="954" height="886" border="0">


</li>
<li><a href="xml.html" onmouseover="mopen('m3')" onmouseout="mclosetime()">Xml</a>

<div id="m3" onmouseover="mcancelclosetime()" onmouseout="mclosetime()">
<a href="#">ASP Dropdown</a>
<a href="#">Pulldown menu</a>
<a href="#">AJAX dropdown</a>
<a href="#">DIV dropdown</a>
</div>
</li>
<li><a href="php.html">Php</a></li>
<li><a href="asp.html">Asp</a></li>

<li><a href="contact.html">تماس با من</a></li>

</ul></td>

</tr>
<tr>


</div>
<div class="container-content-sidebar">
<div class="content-pagetitle dircss ">فرم تماس با من </div>
<div class="contentbox-container">
<div class=" dir bg-blue" >
<?php
$to="a53@yahoo.com";
$subject=$_POST['subject'];
$from=$_POST['mail'];
$message=$_POST['message'];

// Additional headers
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=utf-8' . "\r\n";
$headers .= 'To: '.$to . "\r\n";
$headers .= 'From: '.$from . "\r\n";
$headers .= 'Reply-To: '.$to . "\r\n";
// Mail it
$sendmail=mail($to, $subject, $message, $headers);
if ($sendmail)
echo "پیغام شما با موفقیت ارسال شد";//Sucess Message
else
echo "خطا در ارسال متن";//Failed Message
?>


<form action="<?php $_SERVER['PHP_SELF']?>" name="contact" method="post" class="dir" name="signup" id="signup">
<center><table summary="Demonstration form">
<tbody>
<tr>
<td><label for="name">نام :</label></td>
<td><input name="name" size="35" maxlength="50" type="text" ></td>
</tr>
<tr>
<td><label for="email">ایمیل:</label></td>
<td><input name="email" size="35" maxlength="25" type="text"></td>
</tr>
<tr>
<td><label for="title">عنوان:</label></td>
<td><input name="title" size="35" maxlength="25" type="text"></td>
</tr>
<tr>
<td><label for="message">پیام:</label></td>

<td><textarea style="width:250px;height:120px" name="message" type="text"rows="5" cols"100" maxlength="2000"></textarea></td>
</tr>
<tr>



<td></td>

<td><img src="visual-captcha.php" width="200" height="60" alt="Visual CAPTCHA" id="Captcha" /><br><input onClick="refresh();" type="button" class=" button" value="ریست کردن" ></input>


<p/><label for="user_code">کد امنیتی:</label><input name="user_code" size="20" type="text" ><br/>

<font color="#CC0033"><?php echo $a;?></td>

</tr>
<tr>
<td> </td>

<td><input name="Submit" value="ارسال" type="submit" class="button" ></td>

<td><input type="reset" value="پاک کردن" name="B2" class="button"> </td>
</tr>
</tbody>
</table></center>
</form>



<br/>

</div>



</tr>
</table>
</body></center>
</html>

amin1softco
جمعه 28 مرداد 1390, 13:01 عصر
ببنید تابع Validate تا صدا زده می شه کپتچا قبلی ارزش خودشو به دلایل امنیتی باید ازدست بده و همین اتفاق می افته شما از طرح زیر الگو بگیرید که الان در آدرس captcha.freetzi.com (http://captcha.freetzi.com) قابل تسته.................



<?php
//Continue the session
session_start();
if (isset($_POST['Submit'])){
require('php-captcha.inc.php');
if (PhpCaptcha::Validate($_POST['user_code'])) {//کد صحیح می باشد پس نامه ارسال می شود
$to=$_POST['email'];//Enter Your Email Address*
$subject=$_POST['title'];//Subject OF Mail
$from=$_POST['name'];//User Email Address
$message=$_POST['message'];//Body Of Mail

// Additional headers
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=utf-8' . "\r\n";
$headers .= 'To: '.$to . "\r\n";
$headers .= 'From: '.$from . "\r\n";
$headers .= 'Reply-To: '.$to . "\r\n";
$headers .= 'X-Mailer: PHP/'. phpversion();
// Mail it
$sendmail=mail($to, $subject, $message, $headers);
if ($sendmail)
echo "<center>"."نامه شما با موفقت ارسال شد</center><!--";//Sucess Message
else
echo "<center>"."در ارسال نامه مشکلي وجود دارد مجدد سعي کنيد</center>";//Failed Message
} else {
echo 'Invalid code entered';
}}
?>

<!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" dir="rtl" lang="fa-IR" id="vbulletin_html">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script language="javascript">
function refresh(){
img = document.getElementById('Captcha');
//Change the image
img.src = 'visual-captcha.php?' + Math.random();
}
</script>
</head>
<body>

<form action="<?php $_SERVER['PHP_SELF']?>" method="post">
<center><table summary="Demonstration form">
<tbody>
<tr>
<td><label for="name">نام :</label></td>
<td><input name="name" size="35" maxlength="50" type="text" ></td>
</tr>
<tr>
<td><label for="email">ايميل:</label></td>
<td><input name="email" size="35" maxlength="25" type="text"></td>
</tr>
<tr>
<td><label for="title">عنوان:</label></td>
<td><input name="title" size="35" maxlength="25" type="text"></td>
</tr>
<tr>
<td><label for="message">پيام:</label></td>

<td><textarea style="width:250px;height:120px;font-family:Tahoma, Geneva, sans-serif" name="message" type="text"rows="5" cols"100" maxlength="2000">
</textarea></td>
</tr>
<tr>
<td><label>تصوير امنيتي:</label></td>
<td><input name="user_code" size="20" type="text"><img src="visual-captcha.php" width="200" height="60" alt="Visual CAPTCHA" id="Captcha" /></td>
</tr>
<tr>
<td> </td>

<td><input name="Submit" value="ارسال" type="submit" class="button" ></td>

<td><input onClick="refresh();" type="button" value="پاک کردن" name="B2" class="button"> </td>
</tr>
</tbody>
</table>

</center>
</form>

<body>


راستی تو امضا یکی از بچه های سایت آموزش طراحی صفحه تماس با ما رو دیدم بهش یک نگاهیبنداز مفیده
http://www.w3devzone.com/?cat=20

armsoftpc
سه شنبه 01 شهریور 1390, 17:12 عصر
به نام خدا
با سلام دوباره به همه ی دوستان
با تشکر فراوان از دوستان عزیزمون amin1softco , jalaladdin.
دوست عزیز کد باز هم کار نمی کنه!!!:گیج:

ببخشید شما یک فیلم از کل کدها و تست آن ها با مرورگر بگیرید ، تا ما بهتر متوجه شویم.
یک درخواست دیگر هم این است که کلیه کدها یکبار دیگر تست کرده و ضمیمه نمایید.
این نکته رو هم ذکر کنم که من کد کپچا دیگری را هم امتحان کردم و کارکرد ، در اون کد پوشه ای هم به نام تمپ برای کلمه کد موقت وجود داشت اما در اینجا خبری نیست! اگه راهی به نظرتون میرسه بگید.
کد ویرایش شده خودم هم ضمیمه کرده ام ، ببینید مشکل از کجاست!:اشتباه:
74263
اگر هم امکانش هست لینک دانلود کد از سایت سازنده را بزارید تا ببینیم چی میشه!
موفق باشید.:لبخند:

amin1softco
سه شنبه 01 شهریور 1390, 18:28 عصر
به نظر من مشکل اصلیه شما با session هست و لاغیر اگه لازم بود بگو آدرس هاست رو هم بدم چون برای شما ساختم ............. فایل ضمیمه حاوی تمام فایل ها به علاوه فیلم تستشه امید وارم کارتون راه بیافته اگه نشد به نظرم xamp رو نصب کنید مشکلتون بر طرف می شه

armsoftpc
سه شنبه 01 شهریور 1390, 18:57 عصر
به نام خدا
با سلام
همانطور که شما گفتید ، کد شما نسبتا سالم است ، و زمانی که من فایل ها رو بر روی هاست آپلود کنم کار می کنه!!! که این یک مشکل.
چون همانطور که میدونید زمان ثبت نام در انجمن های ویبولتین از شما ورود کد امنیتی می خواد که مال ویبولتین و جوملا و... کار می کنه اما این کد کار نمی کنه.
به هر حال با تشکر از زحماتتون.:متفکر:
موفق و سربلند باشید.

رضا قربانی
شنبه 05 شهریور 1390, 15:44 عصر
با سلام خدمت همگی دوستان

یه captcha هم من براتون میذارم و در همون اول کدهاتون قرار بدید .


<?php
session_start();

function convertrgb( $color )
{
$color = eregi_replace( "[^0-9a-f]", "", $color );
return array( hexdec( substr( $color, 0, 2 ) ), hexdec( substr( $color, 2, 2 ) ), hexdec( substr( $color, 4, 2 ) ) );
}

function createimage( $text, $width, $height, $font = 5 )
{
global $fontColor;
global $bgColor;
global $lineColor;
if ( $img = @imagecreate( $width, $height ) )
{
list( $R, $G, $B ) = convertrgb( $fontColor );
$fontColor = imagecolorallocate( $img, $R, $G, $B );
list( $R, $G, $B ) = convertrgb( $bgColor );
$bgColor = imagecolorallocate( $img, $R, $G, $B );
list( $R, $G, $B ) = convertrgb( $lineColor );
$lineColor = imagecolorallocate( $img, $R, $G, $B );
imagefill( $img, 0, 0, $bgColor );
$i = 0;
for ( ; $i <= $width; $i += 5 )
{
@imageline( $img, $i, 0, $i, $height, $lineColor );
}
$i = 0;
for ( ; $i <= $height; $i += 5 )
{
@imageline( $img, 0, $i, $width, $i, $lineColor );
}
$hcenter = $width / 2;
$vcenter = $height / 2;
$x = round( $hcenter - imagefontwidth( $font ) * strlen( $text ) / 2 );
$y = round( $vcenter - imagefontheight( $font ) / 2 );
imagestring( $img, $font, $x, $y, $text, $fontColor );
if ( function_exists( "ImagePNG" ) )
{
header( "Content-Type: image/png" );
@imagepng( $img );
}
else if ( function_exists( "ImageGIF" ) )
{
header( "Content-Type: image/gif" );
@imagegif( $img );
}
else if ( function_exists( "ImageJPEG" ) )
{
header( "Content-Type: image/jpeg" );
@imagejpeg( $img );
}
imagedestroy( $img );
}
}

error_reporting( E_WARNING );
if ( function_exists( "session_start" ) )
{
session_start( );
}
$fontSize = 5;
$fontColor = "000000";
$bgColor = "FFFFFF";
$lineColor = "B0B0B0";
$secCode = "";
for ( $i = 0; $i < 6; ++$i )
{
$secCode .= rand( 0, 9 );
}
$_SESSION['rash_secimg'] = $secCode;
createimage( $secCode, 71, 21, $fontSize );
?>

رضا قربانی
شنبه 05 شهریور 1390, 16:14 عصر
به نام خدا
با سلام دوباره به همه ی دوستان
با تشکر فراوان از دوستان عزیزمون amin1softco , jalaladdin.
دوست عزیز کد باز هم کار نمی کنه!!!:گیج:

ببخشید شما یک فیلم از کل کدها و تست آن ها با مرورگر بگیرید ، تا ما بهتر متوجه شویم.
یک درخواست دیگر هم این است که کلیه کدها یکبار دیگر تست کرده و ضمیمه نمایید.
این نکته رو هم ذکر کنم که من کد کپچا دیگری را هم امتحان کردم و کارکرد ، در اون کد پوشه ای هم به نام تمپ برای کلمه کد موقت وجود داشت اما در اینجا خبری نیست! اگه راهی به نظرتون میرسه بگید.
کد ویرایش شده خودم هم ضمیمه کرده ام ، ببینید مشکل از کجاست!:اشتباه:
74263
اگر هم امکانش هست لینک دانلود کد از سایت سازنده را بزارید تا ببینیم چی میشه!
موفق باشید.:لبخند:


کد شما رو دریافت کردم و هیچ مشکلی نداره . (از زمپ استفاده می کنم)

armsoftpc
شنبه 05 شهریور 1390, 19:21 عصر
به نام خدا
با سلام

کد شما رو دریافت کردم و هیچ مشکلی نداره . (از زمپ استفاده می کنم)
از wamp یا xamp!:متعجب:
xamp ضعیف تره و از نسخه های قدیمی استفاده می کنه و امکانتش هم کمتره ، تازه تنظیمات رو باید به صورت دستی انجام داد ف در ضمن ما به ومپ عادت کرده ایم.
حال کدی نیست که با ومپ هم کار کنه ! مانند کپچای وردپرس ، ویبولتین ، جوملا و... .:متفکر:
مرسی از پاسختون و موفق باشید.

رضا قربانی
دوشنبه 07 شهریور 1390, 16:11 عصر
من می گم زمپ
از xamp استفاده می کنم .

مگه نمی گید wamp قویتره :لبخند: خب چرا ساپورت نمی کنه . تازه توی زمپ من هیچ تنظیماتی رو هم سیخ ندادم .

شما با ومپ عادت کردین . زمپ هم مثل اونه با یک ساعت سیخ دادن همه چی میاد تو دستت .
پیشنهاد من به برنامه نویسان اینه که با xamp کار کنن.

armsoftpc
دوشنبه 07 شهریور 1390, 18:48 عصر
به نام خدا
با سلام
دوست عزیز چرا حالا داد می زنی! سیخ کردن دیگه چیه! تازه ما خونمون سیخ نداریم! تازه به جای سیخ کردن یک راحل ارئه بده برای حل این مشکل!
در ضمن اون کسی که کد رو نوشته باید جوری بنویسه که با همه برنامه ها سازگار باشه ، در ضمن همه ی این ها از php استفاده می کنن. پس php تغییر نکرده است و یکی هستند.
سوال من هم جواب ندادید که سیستم های مدیریت محتوایی چون ویبولتین و جوملا با ومپ مشکل ندارن اما این کد داره!:لبخند:
پس باید مشکل کد رو برطرف کرد ف حالا هرکی بلد یا علی!:تشویق: