# Kurulum Talimatları

## 🌐 Web Sunucusu Kurulumu

### Adım 1: Dosyaları Yükle

FTP veya cPanel File Manager kullanarak şu dosyaları yükleyin:
```
public_html/
└── target.php
└── target_data.json
└── .htaccess
```

### Adım 2: İzinleri Ayarla

#### cPanel File Manager:
1. `target_data.json` dosyasına sağ tıklayın
2. **Change Permissions** seçin
3. İzinleri **666** yapın veya:
   - Owner: Read ✓ Write ✓
   - Group: Read ✓ Write ✓
   - Public: Read ✓ Write ✓

#### FTP (FileZilla):
1. `target_data.json` dosyasına sağ tıklayın
2. **File Permissions** seçin
3. Numeric value: **666**

#### SSH/Terminal:
```bash
cd /path/to/public_html/
chmod 666 target_data.json
chmod 644 target.php
chmod 644 .htaccess
```

### Adım 3: Test Et

Tarayıcıda açın:
```
https://clanpack.izmirkorkuevin.com/target.php
```

Başarılıysa şunu görmelisiniz:
```json
{
    "success": true,
    "data": {
        "mob_id": 0,
        "attack": false,
        "timestamp": 0
    }
}
```

---

## 🖥️ Localhost Test (XAMPP/WAMP)

### Windows - XAMPP:

1. **Dosyaları Kopyala**:
   ```
   C:\xampp\htdocs\knight\
   ├── target.php
   ├── target_data.json
   └── .htaccess
   ```

2. **Apache Başlat**:
   - XAMPP Control Panel açın
   - Apache'yi başlatın

3. **Test Et**:
   ```
   http://localhost/knight/target.php
   ```

4. **DLLMain.cpp'de URL Değiştir**:
   ```cpp
   const std::string SERVER_URL = "http://localhost/knight/target.php";
   ```

### Linux/Mac - PHP Built-in Server:

```bash
cd "sunucu dosyaları"
php -S localhost:8000
```

Test:
```
http://localhost:8000/target.php
```

DLL URL:
```cpp
const std::string SERVER_URL = "http://localhost:8000/target.php";
```

---

## 🧪 Fonksiyon Testi

### Test 1: Basit GET
```bash
curl http://localhost/knight/target.php
```

Sonuç:
```json
{"success":true,"data":{"mob_id":0,"attack":false,"timestamp":0}}
```

### Test 2: POST Attack Signal
```bash
curl -X POST http://localhost/knight/target.php \
  -H "Content-Type: application/json" \
  -d '{"mob_id":12345,"attack":true}'
```

### Test 3: GET ve Otomatik False Kontrolü
```bash
# Attack gönder
curl -X POST http://localhost/knight/target.php \
  -H "Content-Type: application/json" \
  -d '{"mob_id":99999,"attack":true}'

# Hemen oku (attack=true olmalı)
curl http://localhost/knight/target.php

# 2 saniye bekle
sleep 2

# Tekrar oku (attack=false olmalı)
curl http://localhost/knight/target.php
```

### Test 4: PHP Test Script
```bash
php test_api.php
```

---

## 🔧 Sorun Giderme

### Hata: "Permission Denied"
```bash
# İzinleri kontrol et
ls -la target_data.json

# Düzelt
chmod 666 target_data.json
```

### Hata: "File not found"
```bash
# PHP doğru dizinde mi?
pwd

# JSON dosyası var mı?
ls -la target_data.json

# Yoksa oluştur
echo '{"mob_id":0,"attack":false,"timestamp":0}' > target_data.json
chmod 666 target_data.json
```

### Hata: ".htaccess not working"
Apache `mod_rewrite` ve `mod_headers` aktif mi?
```bash
# Apache modülleri kontrol et
apache2ctl -M | grep rewrite
apache2ctl -M | grep headers

# Aktif değilse
sudo a2enmod rewrite
sudo a2enmod headers
sudo systemctl restart apache2
```

### Hata: "CORS Error"
`.htaccess` dosyasının yüklendiğinden emin olun:
```apache
<IfModule mod_headers.c>
    Header set Access-Control-Allow-Origin "*"
</IfModule>
```

---

## 🎯 Canlı Sunucu URL Güncelleme

`DLLMain.cpp` dosyasında:

```cpp
// Localhost test için
const std::string SERVER_URL = "http://localhost/knight/target.php";

// Canlı sunucu için
const std::string SERVER_URL = "https://clanpack.izmirkorkuevin.com/target.php";
```

Değiştirdikten sonra **yeniden compile** edin!

---

## ✅ Kurulum Kontrolü

Tüm adımlar tamamlandıysa:

1. ✅ `target.php` tarayıcıda açılıyor
2. ✅ JSON response dönüyor
3. ✅ POST isteği çalışıyor (test_api.php)
4. ✅ 2 saniye sonra attack otomatik false oluyor
5. ✅ DLL'de SERVER_URL doğru ayarlı

**Artık sistem hazır!** 🚀

---

## 📱 Mobil/Tablet Test

JSON API'yi mobil cihazdan test etmek için:
```
https://clanpack.izmirkorkuevin.com/target.php
```

JSON viewer uygulaması veya tarayıcı kullanın.

---

## 🔐 Güvenlik Notları

1. **Rate Limiting**: Çok fazla istek gelirse CloudFlare veya fail2ban kullanın
2. **IP Whitelist**: Sadece kendi IP'nizden erişim için `.htaccess` güncelleyin
3. **HTTPS**: Mutlaka SSL sertifikası kullanın (Let's Encrypt ücretsiz)
4. **Backup**: `target_data.json` dosyasını düzenli yedeleyin

---

## 🆘 Yardım

Sorun yaşıyorsanız:
1. PHP error log kontrol edin: `tail -f /var/log/apache2/error.log`
2. Browser console açın (F12) ve Network tab'ı inceleyin
3. `target_data.json` içeriğini manuel kontrol edin
