$_SESSION['bagis_odeme_prefill'] = [ 'ts' => time(), 'odeme_yontemi' => $odemeYontemi, 'ad_soyad' => $adSoyad, 'email' => $email, 'aciklama' => $aciklama, 'telefon' => $tel, 'telefon_local' => $telLocal, 'telefon_ulke_secim' => (string)($_POST['telefon_ulke_secim'] ?? ''), 'musteri_tipi' => (string)($_POST['musteri_tipi'] ?? ''), 'vergi_dairesi' => (string)($_POST['vergi_dairesi'] ?? ''), 'vergi_no' => (string)($_POST['vergi_no'] ?? ''), ]; } } catch (Throwable $e) { // sessiz } if ($adSoyad === '' || mb_strlen($adSoyad) < 3) { throw new RuntimeException('Lütfen ad soyad girin.'); } if ($tel !== '' && mb_strlen($tel) < 6) { throw new RuntimeException('Telefon çok kısa.'); } if ($email !== '' && !filter_var($email, FILTER_VALIDATE_EMAIL)) { throw new RuntimeException('E-posta formatı geçersiz.'); } $siparisId = (int)($_POST['order_id'] ?? 0); $order = null; if ($siparisId > 0 && function_exists('bagis_siparis_get')) { $order = bagis_siparis_get($siparisId); if (!$order) $siparisId = 0; } if ($siparisId <= 0) { if (!function_exists('bagis_siparis_olustur_sepetten')) { throw new RuntimeException('Sipariş oluşturma fonksiyonu bulunamadı.'); } $siparisId = (int)bagis_siparis_olustur_sepetten($dil_id, $odemeYontemi); if ($siparisId <= 0) throw new RuntimeException('Sipariş oluşturulamadı.'); if (function_exists('bagis_siparis_get')) { $order = bagis_siparis_get($siparisId); } } if (!$order || !is_array($order)) { throw new RuntimeException('Sipariş bulunamadı.'); } // Siparişe bağışçı bilgileri yaz if (function_exists('bagis_siparis_bagisci_bilgileri_guncelle')) { bagis_siparis_bagisci_bilgileri_guncelle($siparisId, $dil_id, $adSoyad, $tel, $email, $aciklama); } // Havale/EFT => sonuç if ($odemeYontemi === 'havale_eft') { try { if (function_exists('db') && function_exists('db_table_exists_site') && function_exists('db_column_exists_site') && db_table_exists_site('b_bagis_siparisleri') && db_column_exists_site('b_bagis_siparisleri', 'odeme_durumu')) { db()->prepare("UPDATE b_bagis_siparisleri SET odeme_durumu = 'havale_bekleniyor' WHERE id = ? LIMIT 1")->execute([$siparisId]); } } catch (Throwable $e) { // sessiz } // SMS: havale talebi alındı (best-effort) try { if (function_exists('bagis_sms_send_by_order')) { $rSms = bagis_sms_send_by_order($siparisId, 'HAVALETESEKKUR', 'havale_bekleniyor'); if (!($rSms['ok'] ?? false) && function_exists('odeme_log_write')) { try { odeme_log_write('bagis', [ 'ts' => date('c'), 'event' => 'bagis_havale_sms_failed', 'order_id' => (int)$siparisId, 'result' => $rSms, ]); } catch (Throwable $e2) { // sessiz } } } } catch (Throwable $e) { // sessiz } $sonucUrl = function_exists('site_url') ? site_url($dil_kod . '/bagis-sonuc') : '/' . rawurlencode($dil_kod) . '/bagis-sonuc'; $sonucUrl .= '?durum=havale_bekleniyor&order_id=' . rawurlencode((string)$siparisId); if ($isAjax) site_json(['ok' => true, 'redirect' => $sonucUrl]); if (!headers_sent()) header('Location: ' . $sonucUrl, true, 302); exit; } // Kredi kartı => bankaya yönlendirme formu if (!function_exists('bagis_banka_pos_varsayilan_get')) { throw new RuntimeException('POS fonksiyonları yüklenemedi.'); } $pos = bagis_banka_pos_varsayilan_get(); if (!$pos || !is_array($pos)) throw new RuntimeException('Aktif POS bulunamadı.'); $cfg = (array)($pos['config'] ?? []); $provider = strtolower(trim((string)($cfg['provider'] ?? ''))); if ($provider !== 'ziraat_est') throw new RuntimeException('POS provider ziraat_est değil.'); $ccNo = preg_replace('~\D+~', '', (string)($_POST['cc_number'] ?? '')); if (strlen($ccNo) > 16) { throw new RuntimeException('Kart numarası en fazla 16 hane olmalı.'); } $ccCvv = preg_replace('~\D+~', '', (string)($_POST['cc_cvv'] ?? '')); $ccHolder = trim((string)($_POST['cc_holder'] ?? '')); $ccExp = trim((string)($_POST['cc_exp'] ?? '')); $mm = ''; $yy = ''; if (preg_match('~^(\d{2})\s*/\s*(\d{2})$~', $ccExp, $m)) { $mm = $m[1]; $yy = $m[2]; } else { $digits = preg_replace('~\D+~', '', $ccExp); if (strlen($digits) >= 4) { $mm = substr($digits, 0, 2); $yy = substr($digits, 2, 2); } } $mm = str_pad(preg_replace('~\D+~', '', $mm), 2, '0', STR_PAD_LEFT); $yy = preg_replace('~\D+~', '', $yy); if ($ccNo === '' || $ccCvv === '' || $mm === '' || $yy === '') { throw new RuntimeException('Kart bilgileri eksik.'); } $card = [ 'pan' => $ccNo, 'cv2' => $ccCvv, 'exp_month' => $mm, 'exp_year' => $yy, 'holder' => $ccHolder, 'holder_name' => $ccHolder, ]; if (!function_exists('ziraat_est_build_3d_form')) { throw new RuntimeException('Ziraat provider fonksiyonu yok: ziraat_est_build_3d_form'); } $formHtml = ziraat_est_build_3d_form($order, $pos, $card, $dil_kod); if ($isAjax) { site_json(['ok' => false, 'error' => 'Kredi kartı ödemesi AJAX ile başlatılamaz.'], 400); } echo ''; echo ''; echo '' . $e('Bankaya yönlendiriliyor...') . ''; echo ''; echo $formHtml; echo ''; exit; } catch (Throwable $inner) { if ($isAjax) site_json(['ok' => false, 'error' => $inner->getMessage()], 400); echo ''; echo ''; echo '' . $e('Ödeme başlatılamadı') . ''; echo ''; echo '

' . $e('Ödeme başlatılamadı') . '

'; echo '

' . $e($inner->getMessage()) . '

'; echo '

' . $e('Geri dön') . '

'; echo ''; exit; } } case 'uye_giris': { $girisUrl = function_exists('site_url') ? site_url($dil_kod . '/giris') : '/' . rawurlencode($dil_kod) . '/giris'; $hesabimPath = function_exists('site_url') ? (string)(parse_url((string)site_url($dil_kod . '/hesabim'), PHP_URL_PATH) ?: '/' . rawurlencode($dil_kod) . '/hesabim') : '/' . rawurlencode($dil_kod) . '/hesabim'; $returnTo = function_exists('guvenli_redirect_hedef') ? guvenli_redirect_hedef($return_to, $hesabimPath) : $hesabimPath; $kullanici = trim((string)($_POST['kullanici'] ?? ($_POST['email'] ?? ''))); $sifre = (string)($_POST['sifre'] ?? ''); $form = ['kullanici' => $kullanici]; $errors = []; if (!function_exists('uye_tablosu_var_mi') || !uye_tablosu_var_mi()) { $errors[] = 'Uyelik sistemi henuz hazir degil.'; } else { if ($kullanici === '') { $errors[] = 'E-posta veya cep telefonu gerekli.'; } if (trim($sifre) === '') { $errors[] = 'Sifre gerekli.'; } if (!$errors && function_exists('uye_giris_limit_kontrol')) { $limit = uye_giris_limit_kontrol($kullanici, 8, 900); if (empty($limit['ok'])) { $errors[] = 'Cok fazla basarisiz deneme. Lutfen daha sonra tekrar deneyin.'; } } } $uye = null; if (!$errors) { $uye = function_exists('uye_dogrula') ? uye_dogrula($kullanici, $sifre) : null; if (!is_array($uye) || empty($uye['id'])) { if (function_exists('uye_giris_limit_basarisiz')) { uye_giris_limit_basarisiz($kullanici, 8, 900); } $errors[] = 'Kullanici veya sifre hatali.'; } } if ($errors) { if (function_exists('form_flash_set')) { form_flash_set('uye_giris_form', [ 'form' => $form, 'errors' => $errors, 'return_to' => $returnTo, ]); } $target = $girisUrl . '?return_to=' . rawurlencode($returnTo); if ($isAjax) { site_json(['ok' => false, 'error' => implode(' ', $errors), 'redirect' => $target], 400); } if (!headers_sent()) { header('Location: ' . $target, true, 302); } exit; } if (function_exists('uye_session_giris')) { uye_session_giris($uye); } if (function_exists('uye_giris_limit_sifirla')) { uye_giris_limit_sifirla($kullanici); } $target = function_exists('site_url') ? site_url(ltrim($returnTo, '/')) : $returnTo; if ($isAjax) { site_json(['ok' => true, 'redirect' => $target]); } if (!headers_sent()) { header('Location: ' . $target, true, 302); } exit; } case 'uye_kayit': { $uyeOlUrl = function_exists('site_url') ? site_url($dil_kod . '/uye-ol') : '/' . rawurlencode($dil_kod) . '/uye-ol'; $hesabimPath = function_exists('site_url') ? (string)(parse_url((string)site_url($dil_kod . '/hesabim'), PHP_URL_PATH) ?: '/' . rawurlencode($dil_kod) . '/hesabim') : '/' . rawurlencode($dil_kod) . '/hesabim'; $returnTo = function_exists('guvenli_redirect_hedef') ? guvenli_redirect_hedef($return_to, $hesabimPath) : $hesabimPath; $ad = trim((string)($_POST['ad'] ?? '')); $soyad = trim((string)($_POST['soyad'] ?? '')); $email = mb_strtolower(trim((string)($_POST['email'] ?? '')), 'UTF-8'); $telefon = trim((string)($_POST['cep_telefonu'] ?? '')); $sifre = (string)($_POST['sifre'] ?? ''); $sifre2 = (string)($_POST['sifre2'] ?? ''); $kvkk = (int)($_POST['kvkk'] ?? 0) === 1; $form = [ 'ad' => $ad, 'soyad' => $soyad, 'email' => $email, 'cep_telefonu' => $telefon, 'kvkk' => $kvkk ? 1 : 0, ]; $errors = []; if (!function_exists('uye_tablosu_var_mi') || !uye_tablosu_var_mi()) { $errors[] = 'Uyelik sistemi henuz hazir degil.'; } if (mb_strlen($ad) < 2) { $errors[] = 'Ad en az 2 karakter olmali.'; } if (mb_strlen($soyad) < 2) { $errors[] = 'Soyad en az 2 karakter olmali.'; } if (!function_exists('uye_email_gecerli_mi') || !uye_email_gecerli_mi($email)) { $errors[] = 'Gecerli bir e-posta girin.'; } if (!function_exists('uye_telefon_gecerli_mi') || !uye_telefon_gecerli_mi($telefon)) { $errors[] = 'Gecerli bir cep telefonu girin.'; } if (mb_strlen($sifre) < 6) { $errors[] = 'Sifre en az 6 karakter olmali.'; } if (!hash_equals($sifre, $sifre2)) { $errors[] = 'Sifre tekrari uyusmuyor.'; } if (!$kvkk) { $errors[] = 'Devam etmek icin KVKK onayi gerekli.'; } if (!$errors && function_exists('uye_bul_email') && uye_bul_email($email)) { $errors[] = 'Bu e-posta adresi zaten kayitli.'; } if (!$errors && function_exists('uye_bul_telefon') && uye_bul_telefon($telefon)) { $errors[] = 'Bu cep telefonu zaten kayitli.'; } if ($errors) { if (function_exists('form_flash_set')) { form_flash_set('uye_kayit_form', [ 'form' => $form, 'errors' => $errors, 'return_to' => $returnTo, ]); } $target = $uyeOlUrl . '?return_to=' . rawurlencode($returnTo); if ($isAjax) { site_json(['ok' => false, 'error' => implode(' ', $errors), 'redirect' => $target], 400); } if (!headers_sent()) { header('Location: ' . $target, true, 302); } exit; } $uye = function_exists('uye_kaydet') ? uye_kaydet($ad, $soyad, $email, $telefon, $sifre) : null; if (!is_array($uye) || empty($uye['id'])) { throw new RuntimeException('Uyelik kaydi olusturulamadi.'); } if (function_exists('uye_session_giris')) { uye_session_giris($uye); } $target = function_exists('site_url') ? site_url(ltrim($returnTo, '/')) : $returnTo; if ($isAjax) { site_json(['ok' => true, 'redirect' => $target]); } if (!headers_sent()) { header('Location: ' . $target, true, 302); } exit; } case 'uye_cikis': { $homePath = function_exists('site_url') ? (string)(parse_url((string)site_url($dil_kod), PHP_URL_PATH) ?: '/' . rawurlencode($dil_kod)) : '/' . rawurlencode($dil_kod); $returnTo = function_exists('guvenli_redirect_hedef') ? guvenli_redirect_hedef($return_to, $homePath) : $homePath; if (function_exists('uye_cikis')) { uye_cikis(); } $target = function_exists('site_url') ? site_url(ltrim($returnTo, '/')) : $returnTo; if ($isAjax) { site_json(['ok' => true, 'redirect' => $target]); } if (!headers_sent()) { header('Location: ' . $target, true, 302); } exit; } default: // Bu dispatcher tanımadığı action'lara dokunmaz. return; } } catch (Throwable $e) { if ($isAjax) { site_json(['ok' => false, 'error' => $e->getMessage()], 400); } // Non-AJAX: en güvenlisi sayfaya geri dönmek. if (!headers_sent()) { header('Location: ' . $return_to, true, 302); } exit; } } } https://www.insajans.com.tr/sitemap-tr.xml 2026-08-03T11:28:30+00:00 https://www.insajans.com.tr/sitemap-en.xml 2026-08-03T11:28:30+00:00