function curlKullan($url) {
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_TIMEOUT, 10);
curl_setopt($curl, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.16) Gecko/20110319 Firefox/3.6.16");
$curlData = curl_exec($curl);
curl_close($curl);
return $curlData;
}
require_once("functions.php");
$aranan=Temizleme($_REQUEST["aranan"]);
$islem=Temizleme($_REQUEST["islem"]);
if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
$IpAddress = $_SERVER['HTTP_CLIENT_IP'];
} elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$IpAddress = $_SERVER['HTTP_X_FORWARDED_FOR'];
} else {
$IpAddress = $_SERVER['REMOTE_ADDR'];
}
$qrdate = date("Y-m-d");
if($islem == 1) { // güvenlik recaptha
$type=intval($_REQUEST["type"]);
if($type == 2) {
$db->query("Select * from qr_karaliste where qrText = '$aranan' and ipaddress = '$IpAddress' and logdate = '$qrdate' "); // TABLO İSMİ, WHERE ŞARTI, LİMİT, ORDER
$ipkaralisteRow = $db->row();
$karalisteRowID = $ipkaralisteRow->ID;
$karalisteSecurity = $ipkaralisteRow->security;
$karalisteHit = $ipkaralisteRow->hit;
if($karalisteSecurity > 0) {
$korumagir = 1;
}
} else {
$korumagir = 1;
}
if($korumagir == 1) { // kara-listede varsa
$recaptcha = $_POST['g-recaptcha-response'];
if (empty($recaptcha)) { echo 'Güvenlik Bölümünü Boş Geçmeyin.
'; exit; }
if (!empty($recaptcha)) {
$google_url = "https://www.google.com/recaptcha/api/siteverify";
$secret = '6Leqia8UAAAAAIVHeMbYTThKQQ5-PgKeB5k5ZouJ';
//kullanıcının ip adresi
$ip = $_SERVER['REMOTE_ADDR'];
//istek adresini oluşturuyoruz
$url = $google_url . "?secret=" . $secret . "&response=" . $recaptcha . "&remoteip=" . $ip;
$res = curlKullan($url);
$res = json_decode($res, true);
//echo $url;
//print_r($res);
//işlem başarılıysa çalışacak kısım
if (!$res['success']) {
echo 'Güvenlik Bölümünü Lütfen Doğru şekilde doldurun.
';
exit;
} else {
$db->query("Select * from qr_karaliste where qrText = '$aranan' and ipaddress = '$IpAddress' and logdate = '$qrdate' "); // TABLO İSMİ, WHERE ŞARTI, LİMİT, ORDER
$ipkaraliste = $db->count();
$ipkaralisteResult = $db->row();
$ipkaralisteHit = $ipkaralisteResult->hit;
if($ipkaraliste != 0) { // kara listede yoksa
$dogrulama_basarili = 1;
}
if($ipkaralisteHit > '2') { // Captha geçilmiş ama kara listede sms girmesi için güvenlik arttır.
$guvenlik = 2;
$phone=Temizleme($_REQUEST["phone"]);
$phoneCode=Temizleme($_REQUEST["phoneCode"]);
if($type == 2) {
$db->query("Select * from qr_session where phone = '$phone' and qrText = '$aranan' and ipaddress = '$IpAddress' and logdate = '$qrdate' "); // TABLO İSMİ, WHERE ŞARTI, LİMİT, ORDER
} else {
$db->query("Select * from qr_karaliste where phone = '$phone' and phoneCode = '$phoneCode' and qrText = '$aranan' and ipaddress = '$IpAddress' and logdate = '$qrdate' "); // TABLO İSMİ, WHERE ŞARTI, LİMİT, ORDER
}
$smskodliste = $db->count();
if($smskodliste != 0) { // phone ve phoneCode doğru demektir.
if($type != 2) {
// phoneCode boşalt
$db->query("Update qr_karaliste set phoneCode='' where phone = '$phone' and qrText='$aranan' and logdate='$qrdate' and ipaddress = '$IpAddress'");
}
$dogrulama_basarili = 1;
} else {
$dogrulama_basarili = 0;
}
}
//echo $dogrulama_basarili;
if($ipkaraliste != 0) { // kara listede ise - kara listeden başarılı captcha yapmış demektir hit sayıcaz
$db->query("Update qr_karaliste set hit=hit+1 where qrText='$aranan' and logdate='$qrdate' and ipaddress = '$IpAddress'");
}
}
}
} else {
$dogrulama_basarili = 1;
}
if($type == 2 && $dogrulama_basarili == 1) {
$db->select('project', array('qrText' => $aranan,'status' => 0), 1, 'ID DESC'); // TABLO İSMİ, WHERE ŞARTI, LİMİT, ORDER
$project_row = $db->row();
$projectID = $project_row->ID;
$qrSecurityBayi = $project_row->qrSecurityBayi;
if($qrSecurityBayi == 1) { // kısıtlı olan
$phone=Temizleme($_REQUEST["phone"]);
$phoneCode=Temizleme($_REQUEST["phoneCode"]);
$db->query("Select * from qr_session where phone = '$phone' and qrText = '$aranan' and status='0' "); // TABLO İSMİ, WHERE ŞARTI, LİMİT, ORDER
$smskodliste = $db->count();
if($smskodliste != 0) { // status ve phone ve phoneCode doğru demektir o zaman yonlendirilsin.
// phoneCode boşalt
$db->query("Update qr_session set status='1' where phone = '$phone' and qrText='$aranan' ");
$dogrulama_basarili = 1;
} else {
$dogrulama_basarili = 0;
}
}
}
}
$db->select('project', array('qrText' => $aranan,'status' => 0,), 1, 'ID DESC'); // TABLO İSMİ, WHERE ŞARTI, LİMİT, ORDER
$say = $db->count();
if($say != 0) { // yok
if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
$IpAddress = $_SERVER['HTTP_CLIENT_IP'];
} elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$IpAddress = $_SERVER['HTTP_X_FORWARDED_FOR'];
} else {
$IpAddress = $_SERVER['REMOTE_ADDR'];
}
//$IpAddress = $_SERVER['REMOTE_ADDR'];
$qrdate = date("Y-m-d");
$db->select('project', array('qrText' => $aranan,'status' => 0,), 1, 'ID DESC'); // TABLO İSMİ, WHERE ŞARTI, LİMİT, ORDER
$project_row = $db->row();
$projectID = $project_row->ID;
$qrSecurity = $project_row->qrSecurity;
$qrSecurityBayi = $project_row->qrSecurityBayi;
if($qrSecurity == 1) { // kısıtlama olan çağırılıyorsa
$db->select('project_log', array('qrText' => $aranan,'ipaddress' => "$IpAddress",'logdate' => "$qrdate"), 1, 'ID DESC'); // qr,ip,date eşleşen
$project_log = $db->row();
$kisitli_hit = $project_log->hit;
if($kisitli_hit > 0) { // 1'den büyüksa
$guvenlik = 1;
$db->query("Select * from qr_karaliste where qrText = '$aranan' and ipaddress = '$IpAddress' and logdate = '$qrdate' "); // TABLO İSMİ, WHERE ŞARTI, LİMİT, ORDER
$ipkaraliste = $db->count();
if($ipkaraliste == 0) {
// Kara listeye ekleniyor.
$db->insert(
'qr_karaliste',
array(
'qrText' => $aranan,
'ipaddress' => $IpAddress,
'logdate' => $qrdate,
'useragent' => $user_agent,
'hit' => 0,
)
);
}
}
}
// Bugünün tarihini alalım
$currentDateTime = date('Y-m-d H:i:s');
$db->query("Select SUM(hit) as toplamhit from project_log where qrText = '$aranan' and ipaddress = '$IpAddress' and logdatetime >= NOW() - INTERVAL 2 MINUTE "); // TABLO İSMİ, WHERE ŞARTI, LİMİT, ORDER
$twominute_sorgu = $db->result();
$twominute_sorgu_say = intval($twominute_sorgu[0]->toplamhit);
$guvenlik = 0;
$db->query("Select * from qr_karaliste where qrText = '$aranan' and ipaddress = '$IpAddress' and logdate = '$qrdate' "); // TABLO İSMİ, WHERE ŞARTI, LİMİT, ORDER
$ipkaraliste = $db->count();
$db->query("Select * from qr_karaliste where qrText = '$aranan' and ipaddress = '$IpAddress' and logdate = '$qrdate' "); // TABLO İSMİ, WHERE ŞARTI, LİMİT, ORDER
$ipkaralisteResult = $db->row();
$ipkaralisteHit = $ipkaralisteResult->hit;
if($twominute_sorgu_say > '5') { // 2 dakika içinde 5 kereden fazla geldiyse
$guvenlik = 1;
}
if($ipkaraliste != 0) { // kara listede varsa
$guvenlik = 1;
}
if($ipkaralisteHit > '2') { // Captha geçilmiş ama kara listede sms girmesi için güvenlik arttır.
$guvenlik = 2;
}
//echo $ipkaraliste;
if($dogrulama_basarili != 1) {
if($guvenlik == 1 || $guvenlik == 2 || $qrSecurityBayi == 1) {
?>