'error', 'message' => 'Geçersiz indirme bağlantısı.'];
}
$ctx = stream_context_create(['http' => ['timeout' => 60]]);
$newContent = @file_get_contents($downloadUrl, false, $ctx);
if (empty($newContent)) {
return ['status' => 'error', 'message' => 'Güncelleme dosyası boş veya indirilemedi.'];
}
if (strpos($newContent, ' 'error', 'message' => 'İndirilen dosya geçerli bir PHP dosyası değil.'];
}
if (!is_writable(__FILE__)) {
return ['status' => 'error', 'message' => 'Dosya yazma izni yok (CHMOD hatası).'];
}
if (file_put_contents(__FILE__, $newContent)) {
if (function_exists('opcache_invalidate')) opcache_invalidate(__FILE__, true);
return ['status' => 'success', 'message' => 'Güncelleme başarılı! Sayfa yenileniyor...'];
} else {
return ['status' => 'error', 'message' => 'Dosya diske yazılamadı.'];
}
}
function getLocalConfig() {
if (!file_exists(SECRET_FILE)) return false;
$content = file_get_contents(SECRET_FILE);
$json = substr($content, strpos($content, "\n") + 1);
return json_decode($json, true);
}
function saveLocalConfig($data) {
$content = "\n" . json_encode($data, JSON_PRETTY_PRINT);
return file_put_contents(SECRET_FILE, $content);
}
function callApi($action, $data = []) {
$ch = curl_init(API_URL . '?action=' . $action);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$response = curl_exec($ch);
if (curl_errno($ch)) die('
CURL Hatası: ' . curl_error($ch) . '
');
curl_close($ch);
if (empty($response)) die('HATA: API boş yanıt döndürdü!
');
$json = json_decode($response, true);
if ($json === null) die('API GEÇERSİZ YANIT:
' . htmlspecialchars($response) . '
');
return $json;
}
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['do_system_update']) && isset($_SESSION['admin_logged'])) {
$downloadUrl = $_POST['download_url'];
$targetVersion = $_POST['target_version'] ?? 'Unknown';
$res = performSelfUpdate($downloadUrl);
if ($res['status'] == 'success') {
echo '';
exit;
} else {
$updateMsg = $res['message'];
}
}
$updateAvailable = false;
$updateData = [];
if (isset($_SESSION['admin_logged'])) {
// 1 saatte bir kontrol et
if (!isset($_SESSION['last_update_check']) || (time() - $_SESSION['last_update_check'] > 3600)) {
$check = callApi('check_update');
if ($check && isset($check['status']) && $check['status'] == 'success') {
$_SESSION['latest_version_info'] = $check;
$_SESSION['last_update_check'] = time();
}
}
if (isset($_SESSION['latest_version_info'])) {
$serverVer = $_SESSION['latest_version_info']['latest_version'];
if (version_compare($serverVer, CURRENT_VERSION, '>')) {
$updateAvailable = true;
$updateData = $_SESSION['latest_version_info'];
}
}
}
if (isset($_GET['ajax_action']) && isset($_SESSION['admin_logged'])) {
$config = getLocalConfig();
$act = $_GET['ajax_action'];
$response = ['status' => 'error'];
if ($config) {
if ($act == 'get_cats') $response = callApi('get_all_categories', ['token' => $config['api_token']]);
elseif ($act == 'get_article') $response = callApi('get_article_detail', ['token' => $config['api_token'], 'slug' => $_GET['slug']]);
elseif ($act == 'update_article') {
$input = json_decode(file_get_contents('php://input'), true);
$response = callApi('update_article', ['token' => $config['api_token'], 'slug' => $input['slug'], 'title' => $input['title'], 'content' => $input['content']]);
}
}
header('Content-Type: application/json');
echo json_encode($response);
exit;
}
$config = getLocalConfig();
$stats = [];
$articles = [];
$debugInfo = [];
if ($config && isset($config['api_token'])) {
$apiStats = callApi('get_stats', ['token' => $config['api_token']]);
if ($apiStats['status'] == 'success') {
$stats = $apiStats;
if (empty($config['site_slug']) || $config['site_slug'] != $stats['site_slug']) {
$config['site_slug'] = $stats['site_slug'];
saveLocalConfig($config);
}
}
$apiArts = callApi('list_articles', ['token' => $config['api_token']]);
$articles = $apiArts['articles'] ?? [];
}
$msg = isset($updateMsg) ? $updateMsg : '';
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
if (isset($_POST['do_setup'])) {
$domain = $_SERVER['HTTP_HOST'];
$pass = trim($_POST['admin_pass']);
$res = callApi('handshake', ['domain' => $domain, 'admin_pass' => $pass]);
if ($res && $res['status'] == 'success') {
$saveData = [
'api_token' => $res['api_token'],
'site_id' => $res['site_id'],
'site_domain' => $domain,
'site_slug' => $res['site_slug'],
'local_pass_hash' => password_hash($pass, PASSWORD_DEFAULT),
'installed_at' => time()
];
saveLocalConfig($saveData);
$_SESSION['admin_logged'] = true;
header("Location: backlinksitesi.php");
exit;
} else {
$msg = $res['message'] ?? 'Kurulum hatası.';
}
}
if (isset($_POST['do_login'])) {
if (password_verify($_POST['password'], $config['local_pass_hash'])) {
$_SESSION['admin_logged'] = true;
header("Location: backlinksitesi.php");
exit;
} else {
$msg = 'Hatalı şifre.';
}
}
if (isset($_POST['generate_article']) && isset($_SESSION['admin_logged'])) {
$topic = trim($_POST['topic']);
if (!empty($topic)) {
$res = callApi('create_article', ['token' => $config['api_token'], 'topic' => $topic]);
if ($res['status'] == 'success') { $msg = 'Makale üretildi!'; header("Refresh:1"); }
else { $msg = $res['message']; }
}
}
if (isset($_POST['delete_slug'])) {
callApi('delete_article', ['token' => $config['api_token'], 'slug' => $_POST['delete_slug']]);
header("Refresh:1");
}
if (isset($_POST['update_category_id'])) {
callApi('update_category', ['token' => $config['api_token'], 'category_id' => $_POST['update_category_id']]);
header("Refresh:1");
}
}
if (isset($_GET['logout'])) { session_destroy(); header("Location: backlinksitesi.php"); exit; }
$reportUrl = "https://backlinksitesi.com/" . ($config['site_slug'] ?? '');
?>
Yönetim Paneli | BacklinkSitesi
Güncelleme Mevcut!
Yeni sürüm: v (Sizdeki: v)
Yapay Zeka İçerik Asistanı
Otomatik içerik üretin.
İçerik Arşivi
Kayıt
| Başlık |
Durum |
Okunma |
İşlem |
|
Henüz içerik üretilmedi.
|
|
Yayında |
|
|