$tokenData['expires_at']) { unset($tokens[$token]); file_put_contents($manifestPath, json_encode($tokens, JSON_PRETTY_PRINT)); header("Location: 404.php"); exit; } $id_occupant = $tokenData['id_occupant']; // Ambil data occupant $stmt = $pdo->prepare("SELECT name, nik_nip, no_hp, foto FROM occupant WHERE id_occupant = ?"); $stmt->execute([$id_occupant]); $occupant = $stmt->fetch(PDO::FETCH_ASSOC); if (!$occupant) { header("Location: 404.php"); exit; } // Proses jika form disubmit via AJAX if ($_SERVER['REQUEST_METHOD'] === 'POST') { header('Content-Type: application/json'); $name = trim($_POST['name']); $nik_nip = isset($_POST['nik_nip']) ? trim($_POST['nik_nip']) : ''; if (empty($name)) { echo json_encode(["status" => "error", "message" => "Name is required"]); exit; } $fotoPath = $occupant['foto']; // Default bawaan if (isset($_FILES['foto']) && $_FILES['foto']['error'] === UPLOAD_ERR_OK) { $allowed = ['jpg', 'jpeg', 'png', 'gif', 'webp']; $ext = strtolower(pathinfo($_FILES['foto']['name'], PATHINFO_EXTENSION)); if (!in_array($ext, $allowed)) { echo json_encode(["status" => "error", "message" => "Photo format not supported"]); exit; } if ($_FILES['foto']['size'] > 5 * 1024 * 1024) { echo json_encode(["status" => "error", "message" => "Max photo size is 5MB"]); exit; } $uploadDir = __DIR__ . '/uploads/'; if (!is_dir($uploadDir)) { mkdir($uploadDir, 0755, true); } $fotoName = 'occ_' . time() . '_' . random_int(1000, 9999) . '.' . $ext; $targetPath = $uploadDir . $fotoName; if (move_uploaded_file($_FILES['foto']['tmp_name'], $targetPath)) { $fotoPath = 'uploads/' . $fotoName; // Hapus foto lama jika ada dan bukan bawaan sistem if (!empty($occupant['foto']) && file_exists(__DIR__ . '/' . $occupant['foto'])) { @unlink(__DIR__ . '/' . $occupant['foto']); } } else { echo json_encode(["status" => "error", "message" => "Failed to upload photo. Check folder permissions."]); exit; } } // Handle base64 foto_data from camera capture $fotoData = isset($_POST['foto_data']) ? $_POST['foto_data'] : ''; if (!empty($fotoData) && strpos($fotoData, 'data:image') === 0) { $uploadDir = __DIR__ . '/uploads/'; if (!is_dir($uploadDir)) { mkdir($uploadDir, 0755, true); } // Decode base64 $parts = explode(',', $fotoData, 2); if (count($parts) === 2) { $imgBinary = base64_decode($parts[1]); if ($imgBinary !== false) { $fotoName = 'occ_' . time() . '_' . random_int(1000, 9999) . '.jpg'; $targetPath = $uploadDir . $fotoName; if (file_put_contents($targetPath, $imgBinary)) { // Hapus foto lama if (!empty($occupant['foto']) && file_exists(__DIR__ . '/' . $occupant['foto'])) { @unlink(__DIR__ . '/' . $occupant['foto']); } $fotoPath = 'uploads/' . $fotoName; } } } } try { $stmtUpdate = $pdo->prepare("UPDATE occupant SET name = ?, nik_nip = ?, foto = ? WHERE id_occupant = ?"); $stmtUpdate->execute([$name, $nik_nip, $fotoPath, $id_occupant]); // Success, invalidate token dan update pesan telegram if (isset($tokenData['msg_id'])) { $botToken = "8184881871:AAFOz6uzIgxE7rk3WttcKKrr0DtcNGIt-Ho"; $chatId = ''; $tstmt = $pdo->prepare("SELECT telegram_id FROM occupant WHERE id_occupant = ?"); $tstmt->execute([$id_occupant]); $tdata = $tstmt->fetch(PDO::FETCH_ASSOC); if ($tdata && $tdata['telegram_id']) { $chatId = $tdata['telegram_id']; @file_get_contents("https://api.telegram.org/bot$botToken/deleteMessage?chat_id=$chatId&message_id={$tokenData['msg_id']}"); if (isset($tokenData['user_msg_id'])) { @file_get_contents("https://api.telegram.org/bot$botToken/deleteMessage?chat_id=$chatId&message_id={$tokenData['user_msg_id']}"); } // Send success message that auto-deletes after 5 seconds with live countdown $successLabel = "✅ Data updated successfully"; $successText = "" . $successLabel . ""; $successPost = ['chat_id' => $chatId, 'text' => $successText, 'parse_mode' => 'HTML']; $res = @file_get_contents("https://api.telegram.org/bot$botToken/sendMessage?" . http_build_query($successPost)); $resData = json_decode($res, true); if (isset($resData['result']['message_id'])) { $successMsgId = $resData['result']['message_id']; runBackground(__DIR__ . '/auto_delete_quick.php', [$chatId, $successMsgId, $successLabel]); } } } unset($tokens[$token]); file_put_contents($manifestPath, json_encode($tokens, JSON_PRETTY_PRINT)); echo json_encode(["status" => "success", "message" => "Data updated successfully!"]); } catch (PDOException $e) { echo json_encode(["status" => "error", "message" => "Failed to save: " . $e->getMessage()]); } exit; } ?> Profile Update - Identia

Edit Profile

Update your personal identity data

Phone Number (Telegram) cannot be changed on this page.
Photo Registration

Loading camera & face detection models...

Photo Captured
5:00

Session Expired

Your 5-minute access window has ended. Please use the /edit_data command in Telegram to request a new session.