İstediğiniz ilin okul web adreslerini listeleyebilir, filtreleyebilir ..

  • Konbuyu başlatan Konbuyu başlatan erbay1
  • Başlangıç tarihi Başlangıç tarihi
Kodla Büyü

erbay1

Üye
Mesajlar
37
İşinize yarar mı bilemiyorum. İstediğiniz ilin tüm okullarını listeleyebilir, listede isme göre filtre yapabilir ve kadro detay bilgilerine ulaşabilirisiniz( detaylı kadro çekmeyi ve isimden türkiye geneli personel aramayı etik olmadığı ? için sildim)
Test: https://dijitalokulpanosu.com.tr/b/okul_ara.php?il=34
PHP kodu:
Kod:
<?php
/**
 * veri.php - SADELEŞTİRİLMİŞ OKUL ARAMA SİSTEMİ
 */
header('Content-Type: text/html; charset=utf-8');

// --- İLLER DİZİSİ (Orijinal Yapı) ---
$iller = [
    1 => "Adana", 2 => "Adıyaman", 3 => "Afyonkarahisar", 4 => "Ağrı", 5 => "Amasya", 6 => "Ankara", 7 => "Antalya", 8 => "Artvin",
    9 => "Aydın", 10 => "Balıkesir", 11 => "Bilecik", 12 => "Bingöl", 13 => "Bitlis", 14 => "Bolu", 15 => "Burdur", 16 => "Bursa",
    17 => "Çanakkale", 18 => "Çankırı", 19 => "Çorum", 20 => "Denizli", 21 => "Diyarbakır", 22 => "Edirne", 23 => "Elazığ", 24 => "Erzincan",
    25 => "Erzurum", 26 => "Eskişehir", 27 => "Gaziantep", 28 => "Giresun", 29 => "Gümüşhane", 30 => "Hakkari", 31 => "Hatay", 32 => "Isparta",
    33 => "Mersin", 34 => "İstanbul", 35 => "İzmir", 36 => "Kars", 37 => "Kastamonu", 38 => "Kayseri", 39 => "Kırklareli", 40 => "Kırşehir",
    41 => "Kocaeli", 42 => "Konya", 43 => "Kütahya", 44 => "Malatya", 45 => "Manisa", 46 => "Kahramanmaraş", 47 => "Mardin", 48 => "Muğla",
    49 => "Muş", 50 => "Nevşehir", 51 => "Niğde", 52 => "Ordu", 53 => "Rize", 54 => "Sakarya", 55 => "Samsun", 56 => "Siirt",
    57 => "Sinop", 58 => "Sivas", 59 => "Tekirdağ", 60 => "Tokat", 61 => "Trabzon", 62 => "Tunceli", 63 => "Şanlıurfa", 64 => "Uşak",
    65 => "Van", 66 => "Yozgat", 67 => "Zonguldak", 68 => "Aksaray", 69 => "Bayburt", 70 => "Karaman", 71 => "Kırıkkale", 72 => "Batman",
    73 => "Şırnak", 74 => "Bartın", 75 => "Ardahan", 76 => "Iğdır", 77 => "Yalova", 78 => "Karabük", 79 => "Kilis", 80 => "Osmaniye", 81 => "Düzce"
];

// --- VERİ ÇEKME FONKSİYONU (Orijinal Yapı) ---
function mebVeriCek($url, $post = false, $fields = []) {
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) Chrome/120.0.0.0');
    if ($post) {
        curl_setopt($ch, CURLOPT_POST, true);
        curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($fields));
        curl_setopt($ch, CURLOPT_REFERER, 'https://www.meb.gov.tr/baglantilar/okullar/index.php');
        curl_setopt($ch, CURLOPT_HTTPHEADER, ['X-Requested-With: XMLHttpRequest']);
    }
    $res = curl_exec($ch);
    curl_close($ch);
    return $res;
}

// LİSTELEME MANTIĞI
$ilKodu = isset($_GET['il']) ? (int)$_GET['il'] : 57;
$sehirAdi = $iller[$ilKodu] ?? "Bilinmiyor";

$resJson = mebVeriCek("https://www.meb.gov.tr/baglantilar/okullar/okullar_ajax.php", true, [
    'il' => $ilKodu, 'ilce' => 0, 'draw' => 1, 'start' => 0, 'length' => 10000
]);
$resData = json_decode($resJson, true);
$liste = $resData['data'] ?? [];
$okulSayisi = count($liste);
$baslik = "İL: " . mb_strtoupper($sehirAdi, 'UTF-8') . " ($okulSayisi OKUL)";
?>
<!DOCTYPE html>
<html lang="tr">
<head>
    <meta charset="UTF-8">
    <style>
        * { box-sizing: border-box; }
        body, html { margin: 0; padding: 0; font-family: 'Segoe UI', sans-serif; background: #f8fafc; }
        .container { max-width: 800px; margin: 20px auto; background: #fff; border: 1px solid #e2e8f0; border-radius: 8px; display: flex; flex-direction: column; height: 90vh; }
        .header { padding: 20px; background: #1e293b; color: #fff; text-align: center; font-weight: bold; border-radius: 8px 8px 0 0; }
        .search-container { padding: 15px; background: #f1f5f9; border-bottom: 1px solid #e2e8f0; }
        .il-input { width: 70px; padding: 8px; border: 1px solid #cbd5e1; border-radius: 4px; }
        .submit-btn { padding: 2px 15px; background: #2563eb; color: white; border: none; border-radius: 4px; cursor: pointer; font-weight: bold; }
        .okul-search { width: 100%; margin-top: 10px; padding: 10px; border: 1px solid #cbd5e1; border-radius: 4px; font-size: 14px; }
        .scroll-area { flex: 1; overflow-y: auto; }
        .item { padding:2px 20px; border-bottom: 1px solid #f1f5f9; text-decoration: none; display: block; color: #334155; transition: background 0.2s; }
        .item:hover { background: #eff6ff; border-left: 4px solid #2563eb; }
        .name { font-size: 14px; font-weight: 700; display: block; margin-bottom: 3px; }
        .title { font-size: 12px; color: #64748b; }
    </style>
</head>
<body>

<div class="container">
    <div class="header" id="header-baslik"><?= mb_strtoupper($baslik, 'UTF-8') ?></div>
 
    <div class="search-container">
        <form onsubmit="return ilKontrol()" method="GET" style="display:flex; gap:8px; align-items:center;">
            <label style="font-size:12px; font-weight:bold;">İL PLAKA:</label>
            <input type="number" name="il" id="ilInput" value="<?= $ilKodu ?>" class="il-input">
            <button type="submit" class="submit-btn">LİSTELE</button>
        </form>
        <input type="text" id="okulSüzgec" placeholder="Okul adı yazarak filtreleyin..." class="okul-search" onkeyup="okulAra()">
    </div>

    <div class="scroll-area" id="listeAlani">
        <?php foreach($liste as $row): $u = "https://".$row['HOST'].".meb.k12.tr"; ?>
            <a href="<?= $u ?>" target="_blank" class="item okul-item">
                <span class="name"><?= htmlspecialchars($row['OKUL_ADI']) ?></span>
                <span class="title"><?= $u ?></span>
            </a>
        <?php endforeach; ?>
    </div>
</div>

<script>
    function okulAra() {
        const aranan = document.getElementById('okulSüzgec').value.toUpperCase();
        const kartlar = document.getElementsByClassName('okul-item');
        let sayac = 0;

        for (let i = 0; i < kartlar.length; i++) {
            const metin = kartlar[i].innerText.toUpperCase();
            if (metin.indexOf(aranan) > -1) {
                kartlar[i].style.display = "";
                sayac++;
            } else {
                kartlar[i].style.display = "none";
            }
        }
        const anaBaslik = "<?= mb_strtoupper($sehirAdi, 'UTF-8') ?>";
        document.getElementById('header-baslik').innerText = "İL: " + anaBaslik + " (" + sayac + " OKUL BULUNDU)";
    }

    function ilKontrol() {
        const kod = parseInt(document.getElementById('ilInput').value);
        if (isNaN(kod) || kod < 1 || kod > 81) {
            alert("LÜTFEN GEÇERLİ BİR İL KODU GİRİNİZ (1-81)");
            return false;
        }
        return true;
    }
</script>

</body>
</html>
Adsız.webp
 
Son düzenleme:
İşinize yarar mı bilemiyorum. İstediğiniz ilin tüm okullarını listeleyebilir, listede isme göre filtre yapabilir ve kadro detay bilgilerine ulaşabilirisiniz.
PHP kodu:
Kod:
<?php

header('Content-Type: text/html; charset=utf-8');

// --- İLLER DİZİSİ ---
$iller = [
    1 => "Adana", 2 => "Adıyaman", 3 => "Afyonkarahisar", 4 => "Ağrı", 5 => "Amasya", 6 => "Ankara", 7 => "Antalya", 8 => "Artvin",
    9 => "Aydın", 10 => "Balıkesir", 11 => "Bilecik", 12 => "Bingöl", 13 => "Bitlis", 14 => "Bolu", 15 => "Burdur", 16 => "Bursa",
    17 => "Çanakkale", 18 => "Çankırı", 19 => "Çorum", 20 => "Denizli", 21 => "Diyarbakır", 22 => "Edirne", 23 => "Elazığ", 24 => "Erzincan",
    25 => "Erzurum", 26 => "Eskişehir", 27 => "Gaziantep", 28 => "Giresun", 29 => "Gümüşhane", 30 => "Hakkari", 31 => "Hatay", 32 => "Isparta",
    33 => "Mersin", 34 => "İstanbul", 35 => "İzmir", 36 => "Kars", 37 => "Kastamonu", 38 => "Kayseri", 39 => "Kırklareli", 40 => "Kırşehir",
    41 => "Kocaeli", 42 => "Konya", 43 => "Kütahya", 44 => "Malatya", 45 => "Manisa", 46 => "Kahramanmaraş", 47 => "Mardin", 48 => "Muğla",
    49 => "Muş", 50 => "Nevşehir", 51 => "Niğde", 52 => "Ordu", 53 => "Rize", 54 => "Sakarya", 55 => "Samsun", 56 => "Siirt",
    57 => "Sinop", 58 => "Sivas", 59 => "Tekirdağ", 60 => "Tokat", 61 => "Trabzon", 62 => "Tunceli", 63 => "Şanlıurfa", 64 => "Uşak",
    65 => "Van", 66 => "Yozgat", 67 => "Zonguldak", 68 => "Aksaray", 69 => "Bayburt", 70 => "Karaman", 71 => "Kırıkkale", 72 => "Batman",
    73 => "Şırnak", 74 => "Bartın", 75 => "Ardahan", 76 => "Iğdır", 77 => "Yalova", 78 => "Karabük", 79 => "Kilis", 80 => "Osmaniye", 81 => "Düzce"
];

function mebVeriCek($url, $post = false, $fields = []) {
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) Chrome/120.0.0.0');
    if ($post) {
        curl_setopt($ch, CURLOPT_POST, true);
        curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($fields));
        curl_setopt($ch, CURLOPT_REFERER, 'https://www.meb.gov.tr/baglantilar/okullar/index.php');
        curl_setopt($ch, CURLOPT_HTTPHEADER, ['X-Requested-With: XMLHttpRequest']);
    }
    $res = curl_exec($ch);
    curl_close($ch);
    return $res;
}

// 1. ADIM: AJAX PERSONEL DETAYI
if (isset($_GET['ajax_url'])) {
    $html = mebVeriCek(urldecode($_GET['ajax_url']));
    $dom = new DOMDocument();
    @$dom->loadHTML('<?xml encoding="UTF-8">' . $html);
    $xpath = new DOMXPath($dom);
    $section = $xpath->query("//section")->item(0) ?: $xpath->query("//div[contains(@class, 'icerik')]")->item(0);
    if ($section) {
        echo "<style>
            body { font-family: sans-serif; text-align: center; padding: 20px; color: #1e293b; }
            .sag_yan, footer, header, nav, .paylas, .breadcrumb, .col-sm-2, .list3 { display: none !important; }
            .col-sm-10, .icerik, .container, .row { width: 100% !important; max-width: 100% !important; margin: 0 !important; padding: 0 !important; }
            img { max-height: 450px; border-radius: 15px; box-shadow: 0 10px 30px rgba(0,0,0,0.15); margin-bottom: 20px; border: 4px solid #fff; }
            h3 { font-size: 26px; font-weight: bold; margin-top: 15px; }
        </style>";
        echo $dom->saveHTML($section);
    }
    exit;
}

// 2. ADIM: LİSTELEME
$ilKodu = isset($_GET['il']) ? (int)$_GET['il'] : 33;
$okulUrl = $_GET['okul'] ?? null;
$liste = [];
$sehirAdi = $iller[$ilKodu] ?? "Bilinmiyor";
$baslik = "Okul Listesi";

if ($ilKodu >= 1 && $ilKodu <= 81) {
    if (!$okulUrl) {
        $resJson = mebVeriCek("https://www.meb.gov.tr/baglantilar/okullar/okullar_ajax.php", true, [
            'il' => $ilKodu, 'ilce' => 0, 'draw' => 1, 'start' => 0, 'length' => 5000
        ]);
        $resData = json_decode($resJson, true);
        $liste = $resData['data'] ?? [];
        $okulSayisi = count($liste);
        $baslik = "İL: " . mb_strtoupper($sehirAdi, 'UTF-8') . " ($okulSayisi OKUL)";
    } else {
        $u = rtrim($okulUrl, '/');
        $hedef = str_contains($u, '.meb.gov.tr') ? $u . "/www/teskilat_semasi.php" : $u . "/tema/teskilat.php";
        $html = mebVeriCek($hedef);
        $dom = new DOMDocument();
        @$dom->loadHTML('<?xml encoding="UTF-8">' . $html);
        $xpath = new DOMXPath($dom);
   
        $hamBaslik = $xpath->query("//title")->item(0)->nodeValue ?? "Kadro";
        $temizOkulAdi = trim(str_ireplace(['Teşkilat Şeması', 'Okul Kadrosu', 'PERSONELİMİZ', '|', '-', 'T.C. Millî Eğitim Bakanlığı'], '', $hamBaslik));
        $baslik = $temizOkulAdi . "<BR> KADRO BİLGİLERİ";
   
        $nodes = $xpath->query("//ul[starts-with(@id, 'seviye')]/li");
        foreach ($nodes as $li) {
            $a = $li->getElementsByTagName('a')->item(0);
            if ($a) {
                $unvan = ($s = $a->getElementsByTagName('span')->item(0)) ? trim($s->nodeValue) : "";
                $isim = ""; foreach ($a->childNodes as $c) if ($c->nodeType === 3) $isim = trim($c->nodeValue);
                $pUrl = $a->getAttribute('href');
                $full = (strpos($pUrl, 'http') === false) ? $u . "/" . ltrim($pUrl, '/') : $pUrl;
                if(!empty($isim)) $liste[] = ['isim' => $isim, 'unvan' => $unvan, 'url' => $full];
            }
        }
    }
}
?>
<!DOCTYPE html>
<html lang="tr">
<head>
    <meta charset="UTF-8">
    <style>
        * { box-sizing: border-box; }
        body, html { margin: 0; padding: 0; height: 100%; overflow: hidden; font-family: 'Segoe UI', sans-serif; background: #f8fafc; }
        .layout { display: flex; width: 100vw; height: 100vh; }
        .sidebar { width: 30%; background: #fff; border-right: 1px solid #e2e8f0; display: flex; flex-direction: column; flex-shrink: 0; }
        .sidebar-header { padding: 0px; background: #1e293b; color: #fff; text-align: center; font-weight: bold; font-size: 13px; min-height: 80px; display: flex; align-items: center; justify-content: center; line-height: 1.4; }
        .scroll-area { flex: 1; overflow-y: auto; }
        .item { padding: 2px 10px; border-bottom: 1px solid #f1f5f9; cursor: pointer; text-decoration: none; display: block; color: #334155; }
        .item:hover { background: #f8fafc; }
        .item.active { background: #eff6ff; border-left: 5px solid #2563eb; }
        .name { font-size: 13px; font-weight: 700; display: block; }
        .title { font-size: 11px; color: #64748b; }
        .back-btn { display: block; padding: 12px; text-align: center; background: #f1f5f9; color: #2563eb; text-decoration: none; font-weight: bold; border-bottom: 1px solid #ddd; }
        .search-container { padding: 10px; background: #f8fafc; border-bottom: 1px solid #eee; }
        .il-input { width: 70px; padding: 6px; border: 1px solid #cbd5e1; border-radius: 4px; }
        .submit-btn { padding: 6px 12px; background: #1e293b; color: white; border: none; border-radius: 4px; cursor: pointer; font-size: 12px; }
        .okul-search { width: 100%; margin-top: 8px; padding: 8px; border: 1px solid #cbd5e1; border-radius: 4px; font-size: 12px; }
        .main-content { flex: 1; background: #fff; overflow-y: auto; position: relative; }
        #loader { display: none; text-align: center; padding: 50px; color: #94a3b8; font-weight: bold; }
        #icerik-alani { padding: 20px; }
    </style>
</head>
<body>

<div class="layout">
    <aside class="sidebar">
        <div class="sidebar-header" id="header-baslik"><?= mb_strtoupper($baslik, 'UTF-8') ?></div>
   
        <?php if($okulUrl): ?>
            <a href="veri.php?il=<?= $ilKodu ?>" class="back-btn">← OKUL LİSTESİNE DÖN</a>
        <?php else: ?>
            <div class="search-container">
                <form onsubmit="return ilKontrol()" method="GET" style="display:flex; gap:5px;">
                    <input type="number" name="il" id="ilInput" value="<?= $ilKodu ?>" class="il-input">
                    <button type="submit" class="submit-btn">Listele</button>
                </form>
                <input type="text" id="okulSüzgec" placeholder="Okul adı filtreleyin..." class="okul-search" onkeyup="okulAra()">
            </div>
        <?php endif; ?>

        <div class="scroll-area" id="listeAlani">
            <?php foreach($liste as $i => $row): ?>
                <?php if(!$okulUrl): $u = "https://".$row['HOST'].".meb.k12.tr"; ?>
                    <a href="veri.php?il=<?= $ilKodu ?>&okul=<?= urlencode($u) ?>" class="item okul-item">
                        <span class="name"><?= htmlspecialchars($row['OKUL_ADI']) ?></span>
                        <span class="title"><?= $u ?></span>
                    </a>
                <?php else: ?>
                    <div class="item <?= $i===0?'active':'' ?>" onclick="detayGetir('<?= urlencode($row['url']) ?>', this)">
                        <span class="name"><?= htmlspecialchars($row['isim']) ?></span>
                        <span class="title"><?= htmlspecialchars($row['unvan']) ?></span>
                    </div>
                <?php endif; ?>
            <?php endforeach; ?>
        </div>
    </aside>

    <main class="main-content" id="detay-ekrani">
        <div id="loader">Yükleniyor...</div>
        <div id="icerik-alani">
            <div style="text-align:center; margin-top:200px; color:#cbd5e1;"><h2>LÜTFEN SEÇİM YAPINIZ</h2></div>
        </div>
    </main>
</div>

<script>
    function okulAra() {
        const aranan = document.getElementById('okulSüzgec').value.toUpperCase();
        const kartlar = document.getElementsByClassName('okul-item');
        let sayac = 0;
        for (let i = 0; i < kartlar.length; i++) {
            const metin = kartlar[i].innerText.toUpperCase();
            if (metin.indexOf(aranan) > -1) {
                kartlar[i].style.display = "";
                sayac++;
            } else {
                kartlar[i].style.display = "none";
            }
        }
        const anaBaslik = "<?= mb_strtoupper($sehirAdi, 'UTF-8') ?>";
        document.getElementById('header-baslik').innerText = "İL: " + anaBaslik + " (" + sayac + " BULUNDU)";
    }

    function ilKontrol() {
        const kod = parseInt(document.getElementById('ilInput').value);
        if (isNaN(kod) || kod < 1 || kod > 81) {
            alert("LÜTFEN GEÇERLİ BİR İL KODU GİRİNİZ (1-81)");
            return false;
        }
        return true;
    }

    function detayGetir(url, el) {
        const icerik = document.getElementById('icerik-alani');
        const loader = document.getElementById('loader');
        document.querySelectorAll('.item').forEach(i => i.classList.remove('active'));
        el.classList.add('active');
        loader.style.display = 'block';
        icerik.style.opacity = '0.2';

        fetch('veri.php?ajax_url=' + url)
            .then(r => r.text())
            .then(data => {
                icerik.innerHTML = data;
                loader.style.display = 'none';
                icerik.style.opacity = '1';
                document.getElementById('detay-ekrani').scrollTop = 0;
            });
    }

    window.onload = () => {
        const ilk = document.querySelector('.item.active');
        if(ilk && ilk.getAttribute('onclick')) ilk.click();
    }
</script>
</body>
</html>
Hocam elinize sağlık ancak bu şekilde kişisel bilgilere erişimi kolaylaştırıcı paylaşımların açıktan olması bence sakıncalı. Demiştim. Ancak ben bunu dedikten sonra düzeltme yapmışsınız hocam hassasiyetiniz için teşekkürler, tekrar elinize sağlık.
 
Son düzenleme:
ilksms
Geri
Üst