Arama butonu
Bu konudaki kullanıcılar: 1 misafir
1
Cevap
1732
Tıklama
0
Öne Çıkarma
PHP sayfa içerisinde Php Çağırma
H
7 yıl
Yüzbaşı
Konu Sahibi

Arkadaşlar merhaba. Komik olacak ama basit tarzda bir site oluşturdum pek fazla bilgim yok.

Site HTML5 bir template idi. Ancak bazı php kodları çalıştırabilmem için sayfayı html olarak düzenledikten sonra .html uzantısını .php yapıp hostinge attım gayet iyi çalışıyor.

Problem şu ki contact form bölümüne math tarzında kibar bir captcha eklemeliyim. Ücretsiz bir tane buldum. Harika. Ancak index sayfası içinde kodlar direk görünsün istemiyorum. Bunun yerine contact formun içinden dosya çağırılsın istiyorum ancak başaramadım.

Şimdi Contact formumun kodları şu şekilde;

quote:

<div class="row">
<div class="6u 12u$(mobile)">
<input type="text" name="name" id="name" placeholder="İsim - Soyisim" required autofocus>
</div>
<div class="6u$ 12u$(mobile)">
<input type="text" name="email" id="email" placeholder="Email" required>
</div>
<div class="12u$">
<input type="text" name="subject" id="subject" placeholder="Konu" required>
</div>
<div class="12u$">
<textarea name="message" id="message" placeholder="Mesajınız" required rows="8"></textarea>
</div>
Tam Bu Alana captcha Gelecek
<div class="12u$">
<input type="submit" value="Gönder" />

</div>


Captcha.php Kodları Şu şekilde:

quote:

<?php
## config ##
$captcha_title = 'Dokažite da niste robot! Upišite rezultat';
$captcha_textcolor = '000000';
$captcha_width = '75';
$captcha_height = '24';
$captcha_type = 'c';
$captcha_name = 'demo';

## print ##
echo '
<script type="text/javascript">
$(document).ready(function() {
$("#reload_ecaptcha").click(function(){

var current_time = new Date();
var normalPath = "ecaptcha.php?w='.$captcha_width.'&h='.$captcha_height.'&t='.$captcha_type.'&c='.$captcha_textcolor.'&n='.$captcha_name.'&time="+current_time;
$("#ecaptcha").attr({ src: normalPath });

});
});
</script>
<div style="margin:5px 0;">'.$captcha_title.': <br/>
<span id="reload_ecaptcha" style="cursor:pointer;"><img src="refresh.png" alt="" title="reload" /></span>
<img src="ecaptcha.php?w='.$captcha_width.'&h='.$captcha_height.'&t='.$captcha_type.'&c='.$captcha_textcolor.'&n='.$captcha_name.'" id="ecaptcha" alt="" style="width:'.$captcha_width.'px;height:'.$captcha_height.'px;" /> <input name="ecaptcha" size="5" type="text" style="font-weight: bolder;margin-top: 3px;position: absolute;" />
</div>';
?>


ecaptcha.php ise bu şekilde;

quote:

<?

/*
* File: ecaptcha_security.php
* Author: Predrag Kopricanec
* Copyright: 2013 Ebit IT
* Date: 10/01/2013
* Updated: 10/01/2013
* Requirements: PHP 4/5 with GD and FreeType libraries
* Link:http://tools.tramot.com/
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details:
*http://www.gnu.org/licenses/gpl.html
*
*/

# Check is SESSION started
if ((function_exists('session_status') && session_status() !== PHP_SESSION_ACTIVE) || !session_id()){
session_start();
}

# overrides the default PHP memory limit.
ini_set('memory_limit', '-1');

# make GD Font Path
putenv('GDFONTPATH='.realpath('.'));

class eCaptchaSecurity {

#font type
var $font = 'Halant.ttf';

public $width;
public $height;
public $type;
public $font_color;
public $captcha_name;

function generateCase($cap_type){
$global_arr = array();

#simple
//summation
for ($i = 1; $i <= 20; $i++) {
$max_sum=20;
$sum = 0;
for ($b = 0; $b < $max_sum; $b++) {
if(($i+$b)<=$max_sum){
$global_arr[$i.' + '.$b.' ='] = $i+$b;
$sum = $i+$b;
}
}
}

#simple & middle
if($cap_type == 'm' || $cap_type == 'c'){
//subtraction
for ($i = 1; $i <= 20; $i++) {
$max_sum=20;
$sum = 0;
for ($b = 1; $b < $max_sum; $b++) {
if(($i-$b)>0 && ($i-$b)<=$max_sum){
$global_arr[$i.' - '.$b.' ='] = $i-$b;
$sum = $i-$b;
}
}
}
}

#simple & middle & complex
if($cap_type == 'c'){
//multiplication
for ($i = 1; $i <= 20; $i++) {
$max_sum=20;
$sum = 0;
for ($b = 1; $b < $max_sum; $b++) {
if(($i*$b)<=$max_sum){
$global_arr[$i.' x '.$b.' ='] = $i*$b;
$sum = $i*$b;
}
}
}
//divide
for ($i = 1; $i <= 20; $i++) {
$max_sum=20;
$sum = 0;
for ($b = 1; $b < $max_sum; $b++) {
if(is_int($i/$b) && ($i/$b)<=$max_sum){
$global_arr[$i.' / '.$b.' ='] = $i/$b;
$sum = $i/$b;
}
}
}
}


return $global_arr;
}


function eCaptchaSecurity($width='75',$height='26',$type='',$font_color,$captcha_name=''){

global $_SESSION;

putenv('GDFONTPATH=' . realpath('.'));

$fontsizeinPX = 19;
$fontsizeinPT = ($fontsizeinPX*3)/4;

//get text color
list($r, $g, $b) = sscanf($font_color, "#%02x%02x%02x");

// The text to draw
$exp_code = $this->generateCase($type);
//get random code
$text = array_rand($exp_code, 1);

// make session code
$_SESSION['code_'.$captcha_name] = $exp_code[$text];

// Create the image
$im = imagecreatetruecolor($width, $height);
imagealphablending($im,false);

// Create some colors
$shadow_color = imagecolorallocatealpha($im, floor((1+$r)/2), floor((1+$g)/2), floor((1+$b)/2), 85);
$text_color = imagecolorallocate($im, $r, $g, $b);

$col=imagecolorallocatealpha($im,255,255,255,127);
imagefilledrectangle($im, 0, 0, 399, 29, $col);
imagealphablending($im,true);

// Add some shadow to the text
imagettftext($im, $fontsizeinPT, 0, 6, 21, $shadow_color, $this->font, $text) or die('Error in imagettftext function');

// Add the text
imagettftext($im, $fontsizeinPT, 0, 5, 20, $text_color, $this->font, $text) or die('Error in imagettftext function');

/* output captcha image to browser */
header('Content-Type: image/png');
imagealphablending($im,false);
imagesavealpha($im,true);

// Using imagepng() results in clearer text compared with imagejpeg()
imagepng($im);
imagedestroy($im);

exit();
}
}
//$_SESSION['e_cap_debug'] = $_GET;
unset($_SESSION['e_cap_debug']);
$captcha = new eCaptchaSecurity (
(isset($_GET['w']) ? str_replace('amp;','',$_GET['w']) : '75'),
(isset($_GET['h']) ? str_replace('amp;','',$_GET['h']) : '26'),
(isset($_GET['t']) ? str_replace('amp;','',$_GET['t']) : 's'),
(isset($_GET['c']) ? '#'.str_replace('amp;','',$_GET['c']) : '#555555'),
(isset($_GET['n']) ? str_replace('amp;','',$_GET['n']) : 'ecaptcha')
);


?>


Bunun orjinal hali yani indirdiğim siteden görmek isterseniz;

http://www.freemathcaptcha.com/english/example-using-a-mathematical-captcha_2/



S
7 yıl
Yüzbaşı

oraya <?php include 'ecaptcha.php'; ?> yazarsanız istediğiniz olur sanırım



DH Mobil uygulaması ile devam edin. Mobil tarayıcınız ile mümkün olanların yanı sıra, birçok yeni ve faydalı özelliğe erişin. Gizle ve güncelleme çıkana kadar tekrar gösterme.