"",
"subtitle"=>"",
"home_banner"=>""
], JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE));
$prediksi = json_decode(file_get_contents($dataFile), true) ?: [];
$settings = json_decode(file_get_contents($settingsFile), true) ?: [];
// admin credentials (as requested)
$ADMIN_USER = "wbmaaiqbal";
$ADMIN_PASS = password_hash("Aabb335577", PASSWORD_DEFAULT);
// ---------- HANDLERS ----------
// admin login
if(isset($_POST['login'])){
if(
($_POST['username'] ?? '') === $ADMIN_USER &&
password_verify($_POST['password'] ?? '', $ADMIN_PASS)
){
$_SESSION['admin'] = true;
header('Location: ?admin');
exit;
} else {
$error = "Username / password salah.";
}
}
// admin logout
if(isset($_POST['logout'])){
session_destroy();
header('Location: index.php');
exit;
}
// save site settings
if(isset($_POST['save_settings']) && isset($_SESSION['admin'])){
$settings['site_title'] = trim($_POST['site_title'] ?? $settings['site_title']);
$settings['subtitle'] = trim($_POST['subtitle'] ?? $settings['subtitle']);
if(!empty($_FILES['banner']['name'])){
$ext = pathinfo($_FILES['banner']['name'], PATHINFO_EXTENSION);
$fname = 'banner_'.time().'.'.$ext;
$target = $uploadDir . '/' . $fname;
if(move_uploaded_file($_FILES['banner']['tmp_name'], $target)){
$settings['home_banner'] = 'uploads/' . $fname;
}
}
file_put_contents($settingsFile, json_encode($settings, JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE));
header('Location: ?admin');
exit;
}
// add prediksi (admin)
if (isset($_POST['add']) && isset($_SESSION['admin'])) {
$item = [
// 🔑 IDENTITAS (WAJIB)
'id' => uniqid(),
'pasaran' => trim($_POST['pasaran'] ?? ''),
'jam' => trim($_POST['jam'] ?? ''),
// 📝 KONTEN
'judul' => trim($_POST['judul'] ?? 'Judul Prediksi'),
'sub' => trim($_POST['sub'] ?? ''),
'desc' => trim($_POST['desc'] ?? ''),
'detail' => trim($_POST['detail'] ?? ''),
// 🔢 ANGKA
'angka_main' => trim($_POST['angka_main'] ?? ''),
'top4d' => trim($_POST['top4d'] ?? ''),
'top3d' => trim($_POST['top3d'] ?? ''),
'top2d' => trim($_POST['top2d'] ?? ''),
'colok_bebas'=> trim($_POST['colok_bebas'] ?? ''),
'colok_2d' => trim($_POST['colok_2d'] ?? ''),
// 🐲 SHIO
'shio' => trim($_POST['shio'] ?? ''),
'icon_shio' => trim($_POST['icon_shio'] ?? ''),
// 🖼️ GAMBAR
'gambar' => [],
// 🕒 META
'created_at' => time(),
// 🔢 URUTAN (POSISI TETAP)
'urutan' => intval($_POST['urutan'] ?? 0),
];
// upload up to 6 files
if(isset($_FILES['foto']) && is_array($_FILES['foto']['name'])){
for($i=0;$i 8, hapus item paling lama (di akhir array) beserta gambarnya
$MAX_HISTORY_PER_PASARAN = 8;
if(count($prediksi) > $MAX_HISTORY_PER_PASARAN){
$old = array_pop($prediksi); // ambil dan hapus item terakhir
if(!empty($old['gambar']) && is_array($old['gambar'])){
foreach($old['gambar'] as $g){
$path = __DIR__ . '/' . $g;
if(file_exists($path)) @unlink($path);
}
}
}
// simpan
file_put_contents($dataFile, json_encode($prediksi, JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE));
header('Location: ?admin');
exit;
}
// save edits to a prediksi (admin)
if(isset($_POST['save_edit']) && isset($_SESSION['admin'])){
$id = (int)($_POST['id'] ?? -1);
if(isset($prediksi[$id])){
$prediksi[$id]['judul'] = trim($_POST['judul'] ?? $prediksi[$id]['judul']);
$prediksi[$id]['sub'] = trim($_POST['sub'] ?? $prediksi[$id]['sub']);
$prediksi[$id]['desc'] = trim($_POST['desc'] ?? $prediksi[$id]['desc']);
$prediksi[$id]['detail'] = trim($_POST['detail'] ?? $prediksi[$id]['detail']);
// Field baru
$prediksi[$id]['angka_main'] = trim($_POST['angka_main'] ?? $prediksi[$id]['angka_main']);
$prediksi[$id]['top4d'] = trim($_POST['top4d'] ?? $prediksi[$id]['top4d']);
$prediksi[$id]['top3d'] = trim($_POST['top3d'] ?? $prediksi[$id]['top3d']);
$prediksi[$id]['top2d'] = trim($_POST['top2d'] ?? $prediksi[$id]['top2d']);
$prediksi[$id]['colok_bebas'] = trim($_POST['colok_bebas'] ?? $prediksi[$id]['colok_bebas']);
$prediksi[$id]['colok_2d'] = trim($_POST['colok_2d'] ?? $prediksi[$id]['colok_2d']);
$prediksi[$id]['shio'] = trim($_POST['shio'] ?? $prediksi[$id]['shio']);
$prediksi[$id]['icon_shio'] = trim($_POST['icon_shio'] ?? $prediksi[$id]['icon_shio']);
// upload additional images (append, up to total 6)
if(isset($_FILES['foto_edit']) && is_array($_FILES['foto_edit']['name'])){
for($i = 0; $i < count($_FILES['foto_edit']['name']) && count($prediksi[$id]['gambar']) < 6; $i++){
if($_FILES['foto_edit']['error'][$i] === UPLOAD_ERR_OK && !empty($_FILES['foto_edit']['name'][$i])){
$safe = preg_replace('/[^A-Za-z0-9_\-\.]/', '', basename($_FILES['foto_edit']['name'][$i]));
$fname = time() . '_e' . $i . '_' . $safe;
$target = $uploadDir . '/' . $fname;
if(move_uploaded_file($_FILES['foto_edit']['tmp_name'][$i], $target)){
$prediksi[$id]['gambar'][] = 'uploads/' . $fname;
}
}
}
}
file_put_contents($dataFile, json_encode($prediksi, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE));
}
header('Location: ?admin');
exit;
}
// delete prediksi (admin)
if(isset($_GET['del']) && isset($_SESSION['admin'])){
$id = (int)$_GET['del'];
if(isset($prediksi[$id])){
foreach($prediksi[$id]['gambar'] ?? [] as $g){
$path = __DIR__ . '/' . $g;
if(file_exists($path)) @unlink($path);
}
array_splice($prediksi, $id, 1);
file_put_contents($dataFile, json_encode($prediksi, JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE));
}
header('Location: ?admin');
exit;
}
// remove single image from a prediksi (admin)
if(isset($_GET['delimg']) && isset($_SESSION['admin'])){
$id = (int)($_GET['id'] ?? -1);
$idx= (int)($_GET['img'] ?? -1);
if(isset($prediksi[$id]['gambar'][$idx])){
$path = __DIR__ . '/' . $prediksi[$id]['gambar'][$idx];
if(file_exists($path)) @unlink($path);
array_splice($prediksi[$id]['gambar'], $idx, 1);
file_put_contents($dataFile, json_encode($prediksi, JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE));
}
header('Location: ?admin&edit='.$id);
exit;
}
// placeholders if empty (frontend only)
$placeholders = [];
if(empty($prediksi)){
for($i=1;$i<=15;$i++){
$placeholders[] = [
'judul' => "Prediksi Contoh #$i",
'sub' => "PASANG POOLS ONLINE",
'desc' => "Contoh deskripsi singkat nomor $i.",
'detail'=> "Ini adalah contoh detail prediksi nomor $i. Edit via admin untuk mengganti isi lengkapnya.",
'gambar'=> []
];
}
}
$source = !empty($prediksi) ? $prediksi : $placeholders;
// helper - escape
function e($s){ return htmlspecialchars($s ?? '', ENT_QUOTES); }
?>
= e($settings['site_title'] ?? 'Prediksi Togel') ?>
Selamat Datang di APKTOGEL
APKTOGEL adalah platform hiburan online modern dengan sistem stabil,
cepat, dan responsif untuk semua perangkat.
Kami menghadirkan tampilan profesional, keamanan data tingkat tinggi,
serta layanan yang siap membantu member selama 24 jam penuh.
Akses mudah tanpa aplikasi tambahan — cukup buka browser, ketik di Google,
dan langsung nikmati seluruh fitur yang tersedia.
Bergabunglah bersama ribuan member aktif dan rasakan pengalaman berbeda
dengan sistem terpercaya dan transparan.
Prediksi tidak ditemukan
";
} else {
$p = $source[$id];
?>
= e($p['judul']) ?>
✅ ANGKA MAIN:
= e($p['angka_main']) ?>
TOP 4D (BB):
= nl2br(e($p['top4d'])) ?>
TOP 3D (BB):
= nl2br(e($p['top3d'])) ?>
TOP 2D (BB):
= nl2br(e($p['top2d'])) ?>
COLOK BEBAS:
= e($p['colok_bebas']) ?>
COLOK 2D:
= e($p['colok_2d']) ?>
SHIO JITU:
= e($p['shio']) ?>
= e($p['icon_shio'] ?? '') ?>
🔁 Prediksi Sebelumnya
$prev) {
if ($xi === $id) continue;
// 🔑 FILTER UTAMA
if (
strtoupper(trim($prev['pasaran'])) !== strtoupper(trim($p['pasaran'])) ||
trim($prev['jam']) !== trim($p['jam'])
) {
continue;
}
if($count >= 8) break;
$thumb = !empty($prev['gambar'][0]) ? $prev['gambar'][0] : 'https://ik.imagekit.io/apkproject/default_icon.png';
?>
Belum ada prediksi sebelumnya untuk pasaran ini.
';
}
?>