<!DOCTYPE html>

<html lang="tr">

<head>

<meta charset="UTF-8">

<meta name="viewport" content="width=device-width, initial-scale=1.0">

<title>IP Kayıt Sistemi</title>

<style>

body {

font-family: Arial, sans-serif;

max-width: 800px;

margin: 0 auto;

padding: 20px;

background-color: #f5f5f5;

text-align: center;

}

.container {

background: white;

padding: 30px;

border-radius: 10px;

box-shadow: 0 2px 10px rgba(0,0,0,0.1);

}

.ip-display {

font-size: 24px;

color: #333;

margin: 20px 0;

padding: 15px;

background: #f8f9fa;

border-radius: 5px;

}

.status {

margin: 20px 0;

padding: 10px;

border-radius: 5px;

}

.success {

background: #d4edda;

color: #155724;

border: 1px solid #c3e6cb;

}

.error {

background: #f8d7da;

color: #721c24;

border: 1px solid #f5c6cb;

}

.download-btn {

background: #007bff;

color: white;

border: none;

padding: 10px 20px;

border-radius: 5px;

cursor: pointer;

font-size: 16px;

margin: 10px;

}

.download-btn:hover {

background: #0056b3;

}

</style>

</head>

<body>

<div class="container">

<h1>IP Kayıt Sistemi</h1>

<div class="ip-display" id="ipDisplay">IP adresiniz alınıyor...</div>

<div class="status" id="status"></div>

<button class="download-btn" onclick="downloadIPFile()">IP Listesini İndir (bob.json)</button>

<button class="download-btn" onclick="clearIPData()">IP Listesini Temizle</button>

<div id="ipList" style="margin-top: 20px; text-align: left;"></div>

</div>


<script>

// LocalStorage'dan IP listesini al

function getIPList() {

const stored = localStorage.getItem('bobIPList');

return stored ? JSON.parse(stored) : [];

}


// LocalStorage'a IP listesini kaydet

function saveIPList(ipList) {

localStorage.setItem('bobIPList', JSON.stringify(ipList));

}


// IP listesini ekranda göster

function displayIPList() {

const ipList = getIPList();

const ipListDiv = document.getElementById('ipList');

if (ipList.length === 0) {

ipListDiv.innerHTML = '<p>Henüz kayıtlı IP bulunmuyor.</p>';

return;

}

let html = `<h3>Kayıtlı IP'ler (${ipList.length} adet):</h3>`;

ipList.forEach((item, index) => {

html += `

<div style="border: 1px solid #ddd; padding: 10px; margin: 5px 0; border-radius: 5px;">

<strong>IP ${index + 1}:</strong> ${item.ip}<br>

<small>Tarih: ${new Date(item.timestamp).toLocaleString('tr-TR')}</small>

</div>

`;

});

ipListDiv.innerHTML = html;

}


// IP'yi kaydet

async function saveIP() {

try {

// IP adresini ipify'dan al

const response = await fetch('https://api.ipify.org?format=json');

const data = await response.json();

const ip = data.ip;

// IP'yi ekranda göster

document.getElementById('ipDisplay').textContent = `IP Adresiniz: ${ip}`;

// Mevcut IP listesini al

const ipList = getIPList();

// Bu IP daha önce kaydedilmiş mi kontrol et

const existingIP = ipList.find(item => item.ip === ip);

if (!existingIP) {

// Yeni IP kaydı oluştur

const ipRecord = {

ip: ip,

timestamp: new Date().toISOString(),

userAgent: navigator.userAgent

};

// Listeye ekle

ipList.push(ipRecord);

// LocalStorage'a kaydet

saveIPList(ipList);

document.getElementById('status').className = 'status success';

document.getElementById('status').textContent = 'IP adresiniz başarıyla kaydedildi!';

} else {

document.getElementById('status').className = 'status success';

document.getElementById('status').textContent = 'IP adresiniz zaten kayıtlı!';

}

// IP listesini göster

displayIPList();

} catch (error) {

console.error('Hata:', error);

document.getElementById('status').className = 'status error';

document.getElementById('status').textContent = 'IP alınırken hata oluştu: ' + error.message;

document.getElementById('ipDisplay').textContent = 'IP alınamadı';

}

}


// JSON dosyasını indir

function downloadIPFile() {

const ipList = getIPList();

if (ipList.length === 0) {

alert('İndirilecek IP kaydı bulunmuyor!');

return;

}

const dataStr = JSON.stringify(ipList, null, 2);

const dataBlob = new Blob([dataStr], { type: 'application/json' });

// Download linki oluştur

const link = document.createElement('a');

link.href = URL.createObjectURL(dataBlob);

link.download = 'bob.json';

link.click();

URL.revokeObjectURL(link.href);

}


// IP verilerini temizle

function clearIPData() {

if (confirm('Tüm IP kayıtlarını silmek istediğinizden emin misiniz?')) {

localStorage.removeItem('bobIPList');

document.getElementById('status').className = 'status success';

document.getElementById('status').textContent = 'Tüm IP kayıtları temizlendi!';

document.getElementById('ipList').innerHTML = '<p>Henüz kayıtlı IP bulunmuyor.</p>';

}

}


// Sayfa yüklendiğinde çalışacaklar

document.addEventListener('DOMContentLoaded', function() {

saveIP(); // IP'yi kaydet

displayIPList(); // IP listesini göster

// Her 10 saniyede bir IP'yi kontrol et (isteğe bağlı)

setInterval(saveIP, 10000);

});

</script>

</body>

</html>