📁 PHP Dosya Yöneticisi
/
/
home
/
demodesigncom
/
blogscripti.demodesign.com.tr
/
admin
/
inc
📝
fonksiyonlar.php
← Geri Dön
<?php $TurnStile = $db->prepare("SELECT * FROM moduller WHERE id = :id"); $TurnStile->bindValue(':id', 1, PDO::PARAM_INT); $TurnStile->execute(); $turnstile = $TurnStile->fetch(PDO::FETCH_ASSOC); $BenzerYazilar = $db->prepare("SELECT * FROM moduller WHERE id = :id"); $BenzerYazilar->bindValue(':id', 2, PDO::PARAM_INT); $BenzerYazilar->execute(); $benzeryazilar = $BenzerYazilar->fetch(PDO::FETCH_ASSOC); $Icindekiler = $db->prepare("SELECT * FROM moduller WHERE id = :id"); $Icindekiler->bindValue(':id', 3, PDO::PARAM_INT); $Icindekiler->execute(); $icindekiler = $Icindekiler->fetch(PDO::FETCH_ASSOC); $OncekiYazilar = $db->prepare("SELECT * FROM moduller WHERE id = :id"); $OncekiYazilar->bindValue(':id', 4, PDO::PARAM_INT); $OncekiYazilar->execute(); $oncekiyazilar = $OncekiYazilar->fetch(PDO::FETCH_ASSOC); $Iletisim = $db->prepare("SELECT * FROM moduller WHERE id = :id"); $Iletisim->bindValue(':id', 5, PDO::PARAM_INT); $Iletisim->execute(); $iletisim = $Iletisim->fetch(PDO::FETCH_ASSOC); $Amp = $db->prepare("SELECT * FROM moduller WHERE id = :id"); $Amp->bindValue(':id', 6, PDO::PARAM_INT); $Amp->execute(); $amp = $Amp->fetch(PDO::FETCH_ASSOC); $Hakkimizda = $db->prepare("SELECT * FROM moduller WHERE id = :id"); $Hakkimizda->bindValue(':id', 7, PDO::PARAM_INT); $Hakkimizda->execute(); $hakkimizda = $Hakkimizda->fetch(PDO::FETCH_ASSOC); $Pwa = $db->prepare("SELECT * FROM moduller WHERE id = :id"); $Pwa->bindValue(':id', 11, PDO::PARAM_INT); $Pwa->execute(); $pwa = $Pwa->fetch(PDO::FETCH_ASSOC); $Doviz = $db->prepare("SELECT * FROM moduller WHERE id = :id"); $Doviz->bindValue(':id', 10, PDO::PARAM_INT); $Doviz->execute(); $doviz = $Doviz->fetch(PDO::FETCH_ASSOC); $ayarlar = $db->prepare("SELECT * FROM ayarlar WHERE id = :id"); $ayarlar->bindValue(':id', 1, PDO::PARAM_INT); $ayarlar->execute(); $siteayar = $ayarlar->fetch(PDO::FETCH_ASSOC); $script = $db->prepare("SELECT * FROM script WHERE id = :id"); $script->bindValue(':id', 1, PDO::PARAM_INT); $script->execute(); $scriptcek = $script->fetch(PDO::FETCH_ASSOC); $Yonetim = $db->prepare("SELECT * FROM yonetim WHERE id = :id"); $Yonetim->bindValue(':id', $_SESSION['id']); $Yonetim->execute(); $kullanici = $Yonetim->fetch(PDO::FETCH_ASSOC); $Manset = $db->prepare("SELECT * FROM moduller WHERE id = :id"); $Manset->bindValue(':id', 12, PDO::PARAM_INT); $Manset->execute(); $manset = $Manset->fetch(PDO::FETCH_ASSOC); @define('SITE_URL', $_SERVER['HTTP_HOST'], true); @define('ADMIN_URL', 'https://' . $_SERVER['HTTP_HOST'] . '/admin/', true); @define('SITEADI', $siteayar['baslik'], true); @define('LOGO', $siteayar['logo'], true); @define('SLOGAN', $siteayar['slogan'], true); @define('SITEACIKLAMA', $siteayar['seoacikla'], true); class Odeme { public $merchant_id = '256924'; public $merchant_key = '1TC3JTxNQgByB4Ju'; public $merchant_salt = 'YghX5UxboUBLshhb'; function formGetir($siparisid, $fiyat) { $siteURL = "https://" . $_SERVER['SERVER_NAME']; $merchant_id = $this->merchant_id; $merchant_key = $this->merchant_key; $merchant_salt = $this->merchant_salt; $email = 'info@example.com'; $payment_amount = $fiyat * 100; $merchant_oid = $siparisid; $user_name = $_SESSION['first_name'] . ' ' . $_SESSION['last_name']; $user_address = 'Adres'; $user_phone = '5555555555'; $merchant_ok_url = $siteURL . "/siparis?siparisid=$siparisid&durum=ok"; $merchant_fail_url = $siteURL . "/siparis?siparisid=$siparisid&durum=fail"; $user_basket = base64_encode(json_encode(array(array("bakiye ekleme", "1.00", 1)))); // 1. ürün (Ürün Ad - Birim Fiyat - Adet ) if (isset($_SERVER["HTTP_CLIENT_IP"])) { $ip = $_SERVER["HTTP_CLIENT_IP"]; } elseif (isset($_SERVER["HTTP_X_FORWARDED_FOR"])) { $ip = $_SERVER["HTTP_X_FORWARDED_FOR"]; } else { $ip = $_SERVER["REMOTE_ADDR"]; } $user_ip = $ip; $timeout_limit = "30"; $debug_on = 1; $test_mode = 1; $no_installment = 0; $max_installment = 0; $currency = "TL"; $hash_str = $merchant_id . $user_ip . $merchant_oid . $email . $payment_amount . $user_basket . $no_installment . $max_installment . $currency . $test_mode; $paytr_token = base64_encode(hash_hmac('sha256', $hash_str . $merchant_salt, $merchant_key, true)); $post_vals = array( 'merchant_id' => $merchant_id, 'user_ip' => $user_ip, 'merchant_oid' => $merchant_oid, 'email' => $email, 'payment_amount' => $payment_amount, 'paytr_token' => $paytr_token, 'user_basket' => $user_basket, 'debug_on' => $debug_on, 'no_installment' => $no_installment, 'max_installment' => $max_installment, 'user_name' => $user_name, 'user_address' => $user_address, 'user_phone' => $user_phone, 'merchant_ok_url' => $merchant_ok_url, 'merchant_fail_url' => $merchant_fail_url, 'timeout_limit' => $timeout_limit, 'currency' => $currency, 'test_mode' => $test_mode ); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "https://www.paytr.com/odeme/api/get-token"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $post_vals); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($ch, CURLOPT_FRESH_CONNECT, true); curl_setopt($ch, CURLOPT_TIMEOUT, 20); $result = @curl_exec($ch); if (curl_errno($ch)) die("PAYTR IFRAME connection error. err:" . curl_error($ch)); curl_close($ch); $result = json_decode($result, 1); if ($result['status'] == 'success') $token = $result['token']; else die("PAYTR IFRAME failed. reason:" . $result['reason']); ?> <script src="https://www.paytr.com/js/iframeResizer.min.js"></script> <iframe src="https://www.paytr.com/odeme/guvenli/<?= $token ?>" id="paytriframe" frameborder="0" scrolling="no" style="width: 100%;"></iframe> <script>iFrameResize({}, '#paytriframe');</script> <?php } function paytrSonuc() { global $db; global $sistem; $post = $_POST; $siparisID = $post['merchant_oid']; $merchant_key = $this->merchant_key; $merchant_salt = $this->merchant_salt; $hash = base64_encode(hash_hmac('sha256', $post['merchant_oid'] . $merchant_salt . $post['status'] . $post['total_amount'], $merchant_key, true)); if ($hash != $post['hash']) die('PAYTR notification failed: bad hash'); if ($post['status'] == 'success') { $db->veriGuncelle("siparisler", array("Durum"), array(1, $siparisID), "SiparisID"); } else { ## $post['failed_reason_code'] - başarısız hata kodu ## $post['failed_reason_msg'] - başarısız hata mesajı $db->veriEkle("odemehatalari", array("NULL", "?"), array($post['merchant_oid'] . " - " . $post['failed_reason_code'] . " - " . $post['failed_reason_msg'])); } echo "OK"; exit; } } function format_tarih($tarih) { $tsayir = explode(' ', $tarih); $sadetarih = explode('-', $tsayir[0]); return $sadetarih[1] . '.' . $sadetarih[2] . '.' . $sadetarih[0]; } function format_tarih_saat($tarih) { $tsayir = explode(' ', $tarih); $sadetarih = explode('-', $tsayir[0]); return $sadetarih[2] . '.' . $sadetarih[1] . '.' . $sadetarih[0] . ' ' . $tsayir[1]; } function indirimliFiyat($fiyat, $indirimOrani) { $indirimMiktari = $fiyat * $indirimOrani / 100; $indirimliFiyat = $fiyat - $indirimMiktari; return $indirimliFiyat; } function smsGonder($gsm, $mesaj, $db) { $bilgigetir = $db->query("SELECT * FROM ayarlar WHERE id = 1")->fetch(PDO::FETCH_ASSOC); $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => 'https://api.netgsm.com.tr/sms/send/get', CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => 'POST', CURLOPT_POSTFIELDS => array('usercode' => $bilgigetir['netgsmuser'], 'password' => $bilgigetir['netgsmpass'], 'gsmno' => $gsm, 'message' => $mesaj, 'msgheader' => $bilgigetir['netgsmheader'], 'filter' => '0', 'startdate' => '', 'stopdate' => ''), )); $response = curl_exec($curl); curl_close($curl); return $response; } function ekleYazi($baslik, $kategori = NULL, $etiket = NULL, $icerik, $seobaslik, $seodescription, $resimgaleri = NULL, $resim = NULL, $tur, $gizlih = NULL) { global $db; if ($kategori) { $kategori = $kategori; $etiketler = implode(",", $etiket); $turs = 'blog'; } else { $turs = 'sayfa'; $etiketler = NULL; $kategori = NULL; } if (!empty($resimgaleri)) { $resimAlani = $resimgaleri; } elseif (!empty($resim) && isset($_FILES['resim'])) { $file_temp = $resim['tmp_name']; $file_name = $resim['name']; $file_ext = pathinfo($file_name, PATHINFO_EXTENSION); $file_size = $resim['size']; $file_error = $resim['error']; // check if file size is less than 5MB if ($file_size > 5000000) { return false; } // check if file is of an allowed type $allowed_types = array('jpg', 'jpeg', 'png', 'gif', 'webp'); if (!in_array($file_ext, $allowed_types)) { return false; } // move file to desired location $new_filename = $file_name . '-' . uniqid() . '.' . $file_ext; $file_destination = '../uploads/' . $new_filename; move_uploaded_file($file_temp, $file_destination); // Convert the image to WebP $webp_destination = '../uploads/' . $file_name . '-' . uniqid() . '.webp'; $image = imagecreatefromstring(file_get_contents($file_destination)); imagewebp($image, $webp_destination, 80); // Bind the WebP destination path to the statement $resimAlani = $webp_destination; } else { $resimAlani = ''; } $sql = "INSERT INTO blog (baslik, kategori, etiket, icerik, seolink, seobaslik, seodescription, resim, tur, gizlih) VALUES (:baslik, :kategori, :etiket, :icerik, :seolink, :seobaslik, :seodescription, :resim, :tur, :gizlih)"; $stmt = $db->prepare($sql); $stmt->bindParam(":baslik", $baslik); $stmt->bindParam(":kategori", $kategori); $stmt->bindParam(":etiket", $etiketler); $stmt->bindParam(":icerik", $icerik); $stmt->bindValue(":seolink", seolink($baslik)); $stmt->bindParam(":seobaslik", $seobaslik); $stmt->bindParam(":seodescription", $seodescription); $stmt->bindParam(":resim", $resimAlani); $stmt->bindParam(":tur", $turs); $stmt->bindParam(":gizlih", $gizlih); $stmt->execute(); if ($kategori) { echo '<div class="alert alert-success d-flex align-items-center" role="alert"> <span class="alert-icon text-success me-2"> <i class="ti ti-check ti-xs"></i> </span> Kaydedildi </div><script> setTimeout(function() { const url = "/admin/blog"; history.pushState(null, null, url); location.reload(); }, 3000); </script>'; } else { echo '<div class="alert alert-success d-flex align-items-center" role="alert"> <span class="alert-icon text-success me-2"> <i class="ti ti-check ti-xs"></i> </span> Kaydedildi </div><script> setTimeout(function() { const url = "/admin/sayfalar"; history.pushState(null, null, url); location.reload(); }, 3000); </script>'; } } function yaziDuzenle($id, $baslik, $kategori = NULL, $etiket = NULL, $icerik, $seobaslik, $seodescription, $seolink, $resimgaleri, $resim) { global $db; if (!empty($resimgaleri)) { $resimAlani = $resimgaleri; } elseif (!empty($resim) && isset($_FILES['resim'])) { // Aşağıdaki işlemler yalnızca $resim ve $_FILES['resim'] değerleri dolu olduğunda gerçekleşir $file_temp = $resim['tmp_name']; $file_name = $resim['name']; $file_ext = pathinfo($file_name, PATHINFO_EXTENSION); $file_size = $resim['size']; $file_error = $resim['error']; // Dosya boyutunun 5MB'dan küçük olduğunu kontrol et if ($file_size > 5000000) { return false; } // Dosyanın izin verilen türlerden biri olduğunu kontrol et $allowed_types = array('jpg', 'jpeg', 'png', 'gif', 'webp'); if (!in_array($file_ext, $allowed_types)) { return false; } // Dosyayı hedef konuma taşı $new_filename = $file_name . '-' . uniqid() . '.' . $file_ext; $file_destination = '../uploads/' . $new_filename; move_uploaded_file($file_temp, $file_destination); // Resmi WebP formatına dönüştür $webp_destination = '../uploads/' . $file_name . '-' . uniqid() . '.webp'; $image = imagecreatefromstring(file_get_contents($file_destination)); imagewebp($image, $webp_destination, 80); // WebP hedef yolunu ifadeye bağla $resimAlani = $webp_destination; } // Güncelleme işlemlerini gerçekleştir $sql = "UPDATE blog SET baslik = :baslik, kategori = :kategori, etiket = :etiket, icerik = :icerik, seobaslik = :seobaslik, seodescription = :seodescription, seolink = :seolink"; if (!empty($resimgaleri) || (!empty($_FILES['resim']) && isset($_FILES['resim']))) { $sql .= ", resim = :resim"; } $sql .= " WHERE id = :id"; $stmt = $db->prepare($sql); $stmt->bindParam(":baslik", $baslik); $stmt->bindParam(":kategori", $kategori); $stmt->bindParam(":etiket", $etiket); $stmt->bindParam(":icerik", $icerik); $stmt->bindParam(":seobaslik", $seobaslik); $stmt->bindParam(":seodescription", $seodescription); $stmt->bindParam(":seolink", $seolink); if (!empty($resimgaleri) || (!empty($_FILES['resim']))) { $stmt->bindParam(":resim", $resimAlani); } $stmt->bindParam(":id", $id); $stmt->execute(); echo '<div class="alert alert-success d-flex align-items-center" role="alert"> <span class="alert-icon text-success me-2"> <i class="ti ti-check ti-xs"></i> </span> Güncellendi </div><script> setTimeout(function() { const url = "/admin/yazi-duzenle?id=' . $id . '"; history.pushState(null, null, url); location.reload(); }, 3000); </script>'; } function ekleVeri($baslik, $kategori = NULL, $etiket = NULL, $icerik, $seobaslik, $seodescription, $resimgaleri = NULL, $resim = NULL, $tur, $gizlih = NULL) { global $db; if ($kategori) { $kategori = $kategori; $etiketler = implode(",", $etiket); $turs = 'blog'; } else { $turs = 'sayfa'; $etiketler = NULL; $kategori = NULL; } if (!empty($resimgaleri)) { $resimAlani = $resimgaleri; } elseif (!empty($resim) && isset($_FILES['resim'])) { $file_temp = $resim['tmp_name']; $file_name = $resim['name']; $file_ext = pathinfo($file_name, PATHINFO_EXTENSION); $file_size = $resim['size']; $file_error = $resim['error']; // check if file size is less than 5MB if ($file_size > 5000000) { return false; } // check if file is of an allowed type $allowed_types = array('jpg', 'jpeg', 'png', 'gif', 'webp'); if (!in_array($file_ext, $allowed_types)) { return false; } // move file to desired location $new_filename = $file_name . '-' . uniqid() . '.' . $file_ext; $file_destination = '../uploads/' . $new_filename; move_uploaded_file($file_temp, $file_destination); // Convert the image to WebP $webp_destination = '../uploads/' . $file_name . '-' . uniqid() . '.webp'; $image = imagecreatefromstring(file_get_contents($file_destination)); imagewebp($image, $webp_destination, 80); // Bind the WebP destination path to the statement $resimAlani = $webp_destination; } else { $resimAlani = ''; } $sql = "INSERT INTO blog (baslik, kategori, etiket, icerik, seolink, seobaslik, seodescription, resim, tur, gizlih) VALUES (:baslik, :kategori, :etiket, :icerik, :seolink, :seobaslik, :seodescription, :resim, :tur, :gizlih)"; $stmt = $db->prepare($sql); $stmt->bindParam(":baslik", $baslik); $stmt->bindParam(":kategori", $kategori); $stmt->bindParam(":etiket", $etiketler); $stmt->bindParam(":icerik", $icerik); $stmt->bindValue(":seolink", seolink($baslik)); $stmt->bindParam(":seobaslik", $seobaslik); $stmt->bindParam(":seodescription", $seodescription); $stmt->bindParam(":resim", $resimAlani); $stmt->bindParam(":tur", $turs); $stmt->bindParam(":gizlih", $gizlih); $stmt->execute(); if ($tur == 'blog') { echo '<div class="alert alert-success d-flex align-items-center" role="alert"> <span class="alert-icon text-success me-2"> <i class="ti ti-check ti-xs"></i> </span> Kaydedildi </div><script> setTimeout(function() { const url = "/admin/blog"; history.pushState(null, null, url); location.reload(); }, 3000); </script>'; } else { echo '<div class="alert alert-success d-flex align-items-center" role="alert"> <span class="alert-icon text-success me-2"> <i class="ti ti-check ti-xs"></i> </span> Kaydedildi </div><script> setTimeout(function() { const url = "/admin/sayfalar"; history.pushState(null, null, url); location.reload(); }, 3000); </script>'; } } function ekleCat($baslik, $aciklama, $gizlih, $resim = NULL) { global $db; if (!empty($resim) && isset($_FILES['resim'])) { $file_temp = $resim['tmp_name']; $file_name = $resim['name']; $file_ext = pathinfo($file_name, PATHINFO_EXTENSION); $file_size = $resim['size']; $file_error = $resim['error']; // check if file size is less than 5MB if ($file_size > 5000000) { return false; } // check if file is of an allowed type $allowed_types = array('jpg', 'jpeg', 'png', 'gif', 'webp'); if (!in_array($file_ext, $allowed_types)) { return false; } // move file to desired location $new_filename = $file_name . '-' . uniqid() . '.' . $file_ext; $file_destination = '../uploads/' . $new_filename; move_uploaded_file($file_temp, $file_destination); // Convert the image to WebP $webp_destination = '../uploads/' . $file_name . '-' . uniqid() . '.webp'; $image = imagecreatefromstring(file_get_contents($file_destination)); imagewebp($image, $webp_destination, 80); // Bind the WebP destination path to the statement $resimAlani = $webp_destination; } else { $resimAlani = ''; } $sql = "INSERT INTO kategori (name, aciklama, slug, gizlih, resim) VALUES (:namxe, :aciklama, :slug, :gizlih, :resim)"; $stmt = $db->prepare($sql); $stmt->bindParam(":namxe", $baslik); $stmt->bindParam(":aciklama", $aciklama); $stmt->bindValue(":slug", seolink($baslik)); $stmt->bindParam(":gizlih", $gizlih); $stmt->bindParam(":resim", $resimAlani); if ($stmt->execute()) { return '<div class="alert alert-success d-flex align-items-center" role="alert"> <span class="alert-icon text-success me-2"> <i class="ti ti-check ti-xs"></i> </span> Kaydedildi </div><script> setTimeout(function() { const url = "/admin/kategori"; history.pushState(null, null, url); location.reload(); }, 3000); </script>'; } else { return '<div class="alert alert-success d-flex align-items-center" role="alert"> <span class="alert-icon text-success me-2"> <i class="ti ti-check ti-xs"></i> </span> Kaydedildi </div><script> setTimeout(function() { const url = "/admin/kategori"; history.pushState(null, null, url); location.reload(); }, 3000); </script>'; } } function veriekle($table, $data, $file = null, $db) { // prepare SQL statement $sql = "INSERT INTO " . $table . " ("; $sql_values = "VALUES ("; foreach ($data as $key => $value) { $sql .= "`" . $key . "`, "; $sql_values .= ":" . $key . ", "; } if (!is_null($file)) { $sql .= "`resim`, "; $sql_values .= ":resim, "; } $sql = rtrim($sql, ", "); $sql_values = rtrim($sql_values, ", "); $sql .= ") " . $sql_values . ")"; $stmt = $db->prepare($sql); foreach ($data as $key => &$value) { $stmt->bindParam(':' . $key, $value); } if (!is_null($file)) { $file_temp = $file['tmp_name']; $file_name = $file['name']; $file_ext = pathinfo($file_name, PATHINFO_EXTENSION); $file_size = $file['size']; $file_error = $file['error']; if (!empty($file_name)) { // check if file size is less than 5MB if ($file_size > 5000000) { return false; } // check if file is of an allowed type $allowed_types = array('jpg', 'jpeg', 'png', 'gif'); if (!in_array($file_ext, $allowed_types)) { return false; } // move file to desired location $new_filename = $file_name . '-' . uniqid() . '.' . $file_ext; $file_destination = '../uploads/' . $new_filename; move_uploaded_file($file_temp, $file_destination); // Convert the image to WebP $webp_destination = '../uploads/' . $file_name . '-' . uniqid() . '.webp'; $image = imagecreatefromstring(file_get_contents($file_destination)); imagewebp($image, $webp_destination, 80); // Bind the WebP destination path to the statement $stmt->bindParam(':resim', $webp_destination); } else { $stmt->bindParam(':resim', null, PDO::PARAM_NULL); } } if ($stmt->execute()) { return '<div class="alert alert-success d-flex align-items-center" role="alert"> <span class="alert-icon text-success me-2"> <i class="ti ti-check ti-xs"></i> </span> Kaydedildi </div><script> setTimeout(function() { const url = "/admin/' . $table . '"; history.pushState(null, null, url); location.reload(); }, 3000); </script>'; } else { $error = $stmt->errorInfo(); echo '<div class="alert alert-danger" role="alert">'; echo 'Hata Kodu: ' . $error[1] . '<br>'; echo 'Hata Mesajı: ' . $error[2] . '<br>'; echo 'Hata Kaynağı: ' . $error[0] . '<br>'; echo '</div>'; return $error[1]; } } function veriguncelle($table, $id, $data, $file = null, $db) { // Eğer dosya yüklenmediyse veya hatalıysa resim alanını güncellemeyin if (empty($file) || $file['error'] != 0) { $sql = "UPDATE " . $table . " SET "; foreach ($data as $key => $value) { $sql .= "`" . $key . "` = :" . $key . ", "; } $sql = rtrim($sql, ", "); $sql .= " WHERE id = :id"; $stmt = $db->prepare($sql); $stmt->bindParam(':id', $id); foreach ($data as $key => &$value) { $stmt->bindParam(':' . $key, $value); } if ($stmt->execute()) { if ($table == "ayarlar") { return '<div class="alert alert-success d-flex align-items-center" role="alert"> <span class="alert-icon text-success me-2"> <i class="ti ti-check ti-xs"></i> </span> Güncellendi </div><script> setTimeout(function() { const url = "/admin/genel-ayarlar?ayar=site"; history.pushState(null, null, url); location.reload(); }, 3000); </script>'; } return '<div class="alert alert-success d-flex align-items-center" role="alert"> <span class="alert-icon text-success me-2"> <i class="ti ti-check ti-xs"></i> </span> Güncellendi </div><script> setTimeout(function() { const url = "/admin/' . $table . '"; history.pushState(null, null, url); location.reload(); }, 3000); </script>'; } else { $error = $stmt->errorInfo(); echo '<div class="alert alert-danger" role="alert">'; echo 'Hata Kodu: ' . $error[1] . '<br>'; echo 'Hata Mesajı: ' . $error[2] . '<br>'; echo 'Hata Kaynağı: ' . $error[0] . '<br>'; echo '</div>'; return $error[1]; } } else { // Dosya yüklendiğinde resim alanını da güncelle $file_temp = $file['tmp_name']; $file_name = $file['name']; $file_ext = pathinfo($file_name, PATHINFO_EXTENSION); $file_size = $file['size']; if ($file_size > 5000000) { return false; } $allowed_types = array('jpg', 'jpeg', 'png', 'gif'); if (!in_array($file_ext, $allowed_types)) { return false; } $new_filename = $file_name . '-' . rand(100, 1000) . '.' . $file_ext; $file_destination = '../uploads/' . $new_filename; if (move_uploaded_file($file_temp, $file_destination)) { $data['resim'] = $file_destination; } $sql = "UPDATE " . $table . " SET "; foreach ($data as $key => $value) { $sql .= "`" . $key . "` = :" . $key . ", "; } $sql = rtrim($sql, ", "); $sql .= " WHERE id = :id"; $stmt = $db->prepare($sql); $stmt->bindParam(':id', $id); foreach ($data as $key => &$value) { $stmt->bindParam(':' . $key, $value); } if ($stmt->execute()) { if ($table == "ayarlar") { return '<div class="alert alert-success d-flex align-items-center" role="alert"> <span class="alert-icon text-success me-2"> <i class="ti ti-check ti-xs"></i> </span> Güncellendi </div><script> setTimeout(function() { const url = "/admin/genel-ayarlar?ayar=site"; history.pushState(null, null, url); location.reload(); }, 3000); </script>'; } return '<div class="alert alert-success d-flex align-items-center" role="alert"> <span class="alert-icon text-success me-2"> <i class="ti ti-check ti-xs"></i> </span> Güncellendi </div><script> setTimeout(function() { const url = "/admin/' . $table . '"; history.pushState(null, null, url); location.reload(); }, 3000); </script>'; } else { $error = $stmt->errorInfo(); echo '<div class="alert alert-danger" role="alert">'; echo 'Hata Kodu: ' . $error[1] . '<br>'; echo 'Hata Mesajı: ' . $error[2] . '<br>'; echo 'Hata Kaynağı: ' . $error[0] . '<br>'; echo '</div>'; return $error[1]; } } } function verisil($table, $id, $db) { $sql = "DELETE FROM $table WHERE id = :id"; $stmt = $db->prepare($sql); $stmt->bindParam(':id', $id); if ($stmt->execute()) { return '<div class="alert alert-danger d-flex align-items-center" role="alert"> <span class="alert-icon text-danger me-2"> <i class="fas fa-times"></i> </span> Silindi </div><script> setTimeout(function() { const url = "https://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'] . '/"; var params = new URLSearchParams(window.location.search); params.delete("sil"); var newUrl = window.location.origin + window.location.pathname; history.pushState(null, null, newUrl); location.reload(); }, 3000); </script>'; } else { return '<div class="alert alert-danger mg-b-0" role="alert"> <a href="#" class="alert-link">Hata</a> ...</div>'; } } function cokluveri($table, $db) { $stmt = $db->prepare("SELECT * FROM $table "); $stmt->execute(); return $stmt->fetchAll(PDO::FETCH_ASSOC); } function tekveri($id, $table, $db) { $stmt = $db->prepare("SELECT * FROM " . $table . " WHERE id = :id"); $stmt->bindParam(":id", $id); $stmt->execute(); return $stmt->fetch(PDO::FETCH_ASSOC); } function seolink($text) { $find = array('Ç', 'Ş', 'Ğ', 'Ü', 'İ', 'Ö', 'ç', 'ş', 'ğ', 'ü', 'ö', 'ı', '+', '#', '.'); $replace = array('c', 's', 'g', 'u', 'i', 'o', 'c', 's', 'g', 'u', 'o', 'i', 'plus', 'sharp'); $text = strtolower(str_replace($find, $replace, $text)); $text = preg_replace("@[^A-Za-z0-9\-_\.\+]@i", ' ', $text); $text = trim(preg_replace('/\s+/', ' ', $text)); $text = str_replace(' ', '-', $text); return $text; } function schemaekle($baslik, $aciklama, $resim, $tarih, $sitebaslik) { $creative_work = array( "@context" => "https://schema.org/", "@type" => "CreativeWork", "name" => $baslik, "description" => strip_tags($aciklama), "image" => 'https://' . $_SERVER['HTTP_HOST'] . '/' . $resim, "author" => array( "@type" => "Person", "name" => "Author" ), "publisher" => array( "@type" => "Organization", "name" => $sitebaslik ), "datePublished" => $tarih, "dateModified" => $tarih ); echo '<script type="application/ld+json">' . json_encode($creative_work, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT) . '</script>'; } function gzipKontrol() { $kontrol = str_replace(" ", "", strtolower($_SERVER['HTTP_ACCEPT_ENCODING'])); $kontrol = explode(",", $kontrol); return in_array("gzip", $kontrol); } function bosluksil($kaynak) { return preg_replace("/\s+/", " ", $kaynak); } function phpPress($kaynak) { if (!gzipKontrol() || headers_sent() || !$gzip_pres) return $sayfa_cikti; header("Content-Encoding: gzip"); return gzencode($sayfa_cikti); } // Function to track hits and visitor data function hit($contentId, $db) { // Check if the user's IP and content ID combination already exists in the hits table $stmt = $db->prepare("SELECT id FROM content_hits WHERE content_id = :contentId AND visitor_ip = :visitorIP"); $stmt->bindParam(':contentId', $contentId); $visitorIP = $_SERVER['REMOTE_ADDR']; $stmt->bindParam(':visitorIP', $visitorIP); $stmt->execute(); if ($stmt->rowCount() === 0) { // Update the database to track hits on the specific content $stmt = $db->prepare("UPDATE blog SET hit = hit + 1 WHERE id = :contentId"); $stmt->bindParam(':contentId', $contentId); $stmt->execute(); // Get the visitor's country using a geo-location service $visitorCountry = getCountryFromIP($visitorIP); // Get the visitor's browser information $visitorBrowser = getVisitorBrowser(); // Get the user agent string from the request headers $userAgent = $_SERVER['HTTP_USER_AGENT']; // Get the timestamp of the current visit $timestamp = time(); // Insert the data into the tracking table $stmt = $db->prepare("INSERT INTO content_hits (content_id, visitor_ip, visitor_country, visitor_browser, timestamp, user_agent) VALUES (:contentId, :visitorIP, :visitorCountry, :visitorBrowser, :timestamp, :userAgent)"); $stmt->bindParam(':contentId', $contentId); $stmt->bindParam(':visitorIP', $visitorIP); $stmt->bindParam(':visitorCountry', $visitorCountry); $stmt->bindParam(':visitorBrowser', $visitorBrowser); $stmt->bindParam(':timestamp', $timestamp); $stmt->bindParam(':userAgent', $userAgent); $stmt->execute(); } } // Function to get the visitor's country based on their IP address using a geo-location service function getCountryFromIP($ip) { // API endpoint for IP geolocation lookup $apiUrl = "http://ip-api.com/json/{$ip}"; // Retrieve IP information from the API $response = file_get_contents($apiUrl); // Parse the JSON response into an associative array $data = json_decode($response, true); // Check if the API call was successful and the country is available if ($data && $data['status'] === 'success' && isset($data['country'])) { // Return the country from the API response return $data['country']; } else { // If there was an error or the country data is not available, return a default value or handle the error as needed. return 'UNKNOWN_COUNTRY'; } } // Function to get the visitor's browser information function getVisitorBrowser() { // Get the user agent string from the request headers $userAgent = $_SERVER['HTTP_USER_AGENT']; // Check for common mobile keywords to determine if the user is on a mobile device $isMobile = preg_match('/(android|iphone|ipad|ipod|mobile|samsung|webos)/i', $userAgent); // Check for common tablet keywords to determine if the user is on a tablet device $isTablet = preg_match('/(tablet|ipad|playbook|kindle)/i', $userAgent); // Determine the type of device based on the presence of mobile and tablet keywords if ($isMobile) { return 'Mobile'; } elseif ($isTablet) { return 'Tablet'; } else { return 'Desktop'; } } // Assuming you have already created a PDO database connection ($db) // Example usage of the hit() function $contentId = 123; // Replace 123 with the actual content ID you want to track hit($contentId, $db); function generateTableOfContents($content) { $targetTags = ['h2', 'h3']; $dom = new DOMDocument(); $dom->loadHTML($content); $headingTags = []; foreach ($targetTags as $tag) { $tags = $dom->getElementsByTagName($tag); foreach ($tags as $heading) { $headingTags[] = [ 'level' => intval(substr($heading->tagName, 1)), 'text' => $heading->nodeValue, 'id' => seolink($heading->nodeValue), 'node' => $heading ]; } } $toc = '<div class="table-of-contents" style="background: #f9f9f9; border: 1px solid #aaa; padding: 10px; margin-bottom: 1em; width: 100%; display: table; font-size: 95%;">'; $toc .= '<p style="text-align: center; font-weight: 700; margin: 0; padding: 0;">İçindekiler</p>'; $toc .= '<ul style="margin-top: 0">'; foreach ($headingTags as $heading) { $toc .= '<li>'; $toc .= '<a href="' . $_SERVER['REQUEST_URI'] . '#' . $heading['id'] . '">' . $heading['text'] . '</a>'; $toc .= '</li>'; $newTag = $dom->createElement('h' . $heading['level']); $newTag->setAttribute('id', $heading['id']); $newTag->nodeValue = $heading['text']; $heading['node']->parentNode->replaceChild($newTag, $heading['node']); } $toc .= '</ul>'; $toc .= '</div>'; $contentWithToc = $toc . $dom->saveHTML(); return $contentWithToc; } function preventSQLInjection($input) { $cleanedInput = trim($input); $cleanedInput = stripslashes($cleanedInput); $cleanedInput = htmlspecialchars($cleanedInput); $blockedKeywords = array("union", "select", "insert", "cast", "set", "declare", "drop", "update", "md5", "benchmark"); foreach ($blockedKeywords as $keyword) { if (stripos($cleanedInput, $keyword) !== false) { die("Geçersiz giriş."); } } return $cleanedInput; } function preventXSS($input) { $cleanedInput = trim($input); $cleanedInput = stripslashes($cleanedInput); $cleanedInput = htmlspecialchars($cleanedInput); $blockedKeywords = array("<script", "</script", "<iframe", "</iframe"); foreach ($blockedKeywords as $keyword) { if (stripos($cleanedInput, $keyword) !== false) { die("Geçersiz giriş."); } } return $cleanedInput; } function generatePWA($siteName, $startUrl, $iconUrl, $iconUrll, $serviceWorkerUrl) { $manifest = [ 'name' => $siteName, 'short_name' => $siteName, 'start_url' => $startUrl, 'icons' => [ [ 'src' => $iconUrl, 'sizes' => '192x192', 'type' => 'image/png' ], [ 'src' => $iconUrll, 'sizes' => '512x512', 'type' => 'image/png' ] ], 'display' => 'standalone', 'theme_color' => '#d33', 'background_color' => '#ffffff' ]; file_put_contents('manifest.json', json_encode($manifest, JSON_PRETTY_PRINT)); $serviceWorker = file_get_contents('service-worker-template.js'); // Örnek: service-worker-template.js dosyasında servis çalışanı kodu file_put_contents('service-worker.js', $serviceWorker); $registerServiceWorker = "<script> if ('serviceWorker' in navigator) { navigator.serviceWorker.register('$serviceWorkerUrl').then((registration) => { console.log('Service Worker registered with scope:', registration.scope); }).catch((error) => { console.log('Service Worker registration failed:', error); }); } </script>"; return $registerServiceWorker; } function clearAllCookies() { if (isset($_COOKIE)) { foreach ($_COOKIE as $cookie_name => $cookie_value) { setcookie($cookie_name, '', time() - 3600, '/'); } } } function compress_image($source_url, $destination_url, $quality) { $info = getimagesize($source_url); if ($info['mime'] == 'image/jpeg' || $info['mime'] == 'image/jpg') { $image = imagecreatefromjpeg($source_url); } elseif ($info['mime'] == 'image/png') { $image = imagecreatefrompng($source_url); } if ($image) { imagejpeg($image, $destination_url, $quality); imagedestroy($image); } }
💾 Kaydet
İptal
📝 Yeniden Adlandır
İptal
Kaydet
🔐 Dosya İzinleri (chmod)
İzin Değeri:
Hızlı Seçim:
777
755
644
600
777
= Herkes okur/yazar/çalıştırır
755
= Sahip tam, diğerleri okur/çalıştırır
644
= Sahip okur/yazar, diğerleri okur
600
= Sadece sahip okur/yazar
İptal
Uygula