<?php
require_once __DIR__.'/../includes/db.php';
require_once __DIR__.'/../includes/auth.php';

date_default_timezone_set('Asia/Makassar');

if (session_status() !== PHP_SESSION_ACTIVE) {
    session_start();
}

if (!function_exists('esc')) {
    function esc($value)
    {
        return htmlspecialchars((string)$value, ENT_QUOTES, 'UTF-8');
    }
}

function lembaga_redirect($message)
{
    header('Location: lembaga_desa.php?msg='.rawurlencode((string)$message));
    exit;
}

function lembaga_initial($name)
{
    $name = trim((string)$name);
    if ($name === '') {
        return 'LD';
    }

    $parts = preg_split('/\s+/', $name) ?: [];
    $initial = '';
    foreach (array_slice($parts, 0, 2) as $part) {
        $initial .= function_exists('mb_substr')
            ? mb_substr($part, 0, 1, 'UTF-8')
            : substr($part, 0, 1);
    }

    return strtoupper($initial !== '' ? $initial : 'LD');
}

$jenisOptions = [
    'Badan Permusyawaratan Desa (BPD)',
    'Lembaga Pemberdayaan Masyarakat (LPM)',
    'Pemberdayaan dan Kesejahteraan Keluarga (PKK)',
    'Karang Taruna',
    'Posyandu',
    'Perlindungan Masyarakat (Linmas)',
    'Rukun Tetangga/Rukun Warga',
    'Lembaga Adat',
    'Lembaga Keagamaan',
    'Kelompok Tani/Nelayan',
    'Lainnya',
];

$act = $_GET['a'] ?? 'list';
if ($act === 'edit') {
    $act = 'form';
}

if (!isset($_SESSION['csrf_lembaga_desa'])) {
    $_SESSION['csrf_lembaga_desa'] = bin2hex(random_bytes(32));
}
$csrfToken = $_SESSION['csrf_lembaga_desa'];

$tableCheck = $mysqli->query("SHOW TABLES LIKE 'lembaga_desa'");
$tableReady = $tableCheck && $tableCheck->num_rows > 0;
$errorText = '';

if ($act === 'delete' && $_SERVER['REQUEST_METHOD'] === 'POST') {
    $id = (int)($_POST['id'] ?? 0);
    $token = $_POST['csrf_token'] ?? '';

    if (!is_string($token) || !hash_equals($csrfToken, $token)) {
        lembaga_redirect('csrf');
    }

    if (!$tableReady || $id <= 0) {
        lembaga_redirect('notfound');
    }

    $stmt = $mysqli->prepare('DELETE FROM lembaga_desa WHERE id = ?');
    if (!$stmt) {
        lembaga_redirect('error');
    }

    $stmt->bind_param('i', $id);
    $stmt->execute();
    $deleted = $stmt->affected_rows > 0;
    $stmt->close();

    lembaga_redirect($deleted ? 'deleted' : 'notfound');
}

if ($act === 'save' && $_SERVER['REQUEST_METHOD'] === 'POST') {
    $id = (int)($_POST['id'] ?? 0);
    $token = $_POST['csrf_token'] ?? '';
    $nama = trim((string)($_POST['nama_lembaga'] ?? ''));
    $singkatan = trim((string)($_POST['singkatan'] ?? ''));
    $jenis = trim((string)($_POST['jenis'] ?? ''));
    $ketua = trim((string)($_POST['ketua'] ?? ''));
    $nomorSk = trim((string)($_POST['nomor_sk'] ?? ''));
    $masaBakti = trim((string)($_POST['masa_bakti'] ?? ''));
    $alamat = trim((string)($_POST['alamat'] ?? ''));
    $telepon = trim((string)($_POST['telepon'] ?? ''));
    $email = trim((string)($_POST['email'] ?? ''));
    $deskripsi = trim((string)($_POST['deskripsi'] ?? ''));
    $status = trim((string)($_POST['status'] ?? 'aktif'));
    $urutan = max(0, (int)($_POST['urutan'] ?? 0));

    if (!is_string($token) || !hash_equals($csrfToken, $token)) {
        $errorText = 'Token keamanan tidak valid. Muat ulang halaman.';
    } elseif (!$tableReady) {
        $errorText = 'Tabel lembaga desa belum tersedia. Jalankan file database_idm_lembaga.sql terlebih dahulu.';
    } elseif ($nama === '' || $jenis === '' || $ketua === '') {
        $errorText = 'Nama lembaga, jenis lembaga, dan ketua/pimpinan wajib diisi.';
    } elseif (!in_array($jenis, $jenisOptions, true)) {
        $errorText = 'Jenis lembaga tidak valid.';
    } elseif (!in_array($status, ['aktif', 'nonaktif'], true)) {
        $errorText = 'Status lembaga tidak valid.';
    } elseif ($email !== '' && !filter_var($email, FILTER_VALIDATE_EMAIL)) {
        $errorText = 'Format email lembaga tidak valid.';
    } elseif ($id > 0) {
        $stmt = $mysqli->prepare(
            'UPDATE lembaga_desa
             SET nama_lembaga = ?, singkatan = ?, jenis = ?, ketua = ?, nomor_sk = ?, masa_bakti = ?, alamat = ?, telepon = ?, email = ?, deskripsi = ?, status = ?, urutan = ?
             WHERE id = ?'
        );

        if ($stmt) {
            $stmt->bind_param(
                'sssssssssssii',
                $nama,
                $singkatan,
                $jenis,
                $ketua,
                $nomorSk,
                $masaBakti,
                $alamat,
                $telepon,
                $email,
                $deskripsi,
                $status,
                $urutan,
                $id
            );

            if ($stmt->execute()) {
                $stmt->close();
                lembaga_redirect('updated');
            }

            $errorText = 'Data lembaga gagal diperbarui: '.$stmt->error;
            $stmt->close();
        } else {
            $errorText = 'Query pembaruan gagal disiapkan: '.$mysqli->error;
        }
    } else {
        $stmt = $mysqli->prepare(
            'INSERT INTO lembaga_desa
             (nama_lembaga, singkatan, jenis, ketua, nomor_sk, masa_bakti, alamat, telepon, email, deskripsi, status, urutan)
             VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)'
        );

        if ($stmt) {
            $stmt->bind_param(
                'sssssssssssi',
                $nama,
                $singkatan,
                $jenis,
                $ketua,
                $nomorSk,
                $masaBakti,
                $alamat,
                $telepon,
                $email,
                $deskripsi,
                $status,
                $urutan
            );

            if ($stmt->execute()) {
                $stmt->close();
                lembaga_redirect('saved');
            }

            $errorText = 'Data lembaga gagal disimpan: '.$stmt->error;
            $stmt->close();
        } else {
            $errorText = 'Query penyimpanan gagal disiapkan: '.$mysqli->error;
        }
    }

    if ($errorText !== '') {
        $act = 'form';
    }
}

$edit = null;
if ($act === 'form') {
    $editId = (int)($_GET['id'] ?? $_POST['id'] ?? 0);
    if ($editId > 0 && $tableReady && $_SERVER['REQUEST_METHOD'] !== 'POST') {
        $stmt = $mysqli->prepare('SELECT * FROM lembaga_desa WHERE id = ? LIMIT 1');
        if ($stmt) {
            $stmt->bind_param('i', $editId);
            $stmt->execute();
            $edit = $stmt->get_result()->fetch_assoc();
            $stmt->close();
        }

        if (!$edit) {
            lembaga_redirect('notfound');
        }
    }
}

$rows = [];
if ($tableReady) {
    $result = $mysqli->query('SELECT * FROM lembaga_desa ORDER BY urutan ASC, nama_lembaga ASC, id DESC');
    if ($result) {
        while ($row = $result->fetch_assoc()) {
            $rows[] = $row;
        }
    }
}

$totalAktif = 0;
$jenisAktif = [];
foreach ($rows as $row) {
    if ($row['status'] === 'aktif') {
        $totalAktif++;
    }
    $jenisAktif[$row['jenis']] = true;
}

$messageMap = [
    'saved' => ['success', 'Data lembaga desa berhasil disimpan.'],
    'updated' => ['success', 'Data lembaga desa berhasil diperbarui.'],
    'deleted' => ['success', 'Data lembaga desa berhasil dihapus.'],
    'notfound' => ['error', 'Data lembaga desa tidak ditemukan.'],
    'csrf' => ['error', 'Token keamanan tidak valid. Silakan ulangi proses.'],
    'error' => ['error', 'Proses data lembaga desa gagal dilakukan.'],
];
$message = $messageMap[$_GET['msg'] ?? ''] ?? null;

$formData = [
    'id' => 0,
    'nama_lembaga' => '',
    'singkatan' => '',
    'jenis' => 'Badan Permusyawaratan Desa (BPD)',
    'ketua' => '',
    'nomor_sk' => '',
    'masa_bakti' => '',
    'alamat' => '',
    'telepon' => '',
    'email' => '',
    'deskripsi' => '',
    'status' => 'aktif',
    'urutan' => 0,
];

if ($edit) {
    $formData = array_merge($formData, $edit);
}
if ($_SERVER['REQUEST_METHOD'] === 'POST' && $act === 'form') {
    foreach (array_keys($formData) as $key) {
        if (isset($_POST[$key])) {
            $formData[$key] = $_POST[$key];
        }
    }
}

include __DIR__.'/../includes/header.php';
?>

<style>
.master-shell{animation:fadeIn .35s ease}.master-head{margin-bottom:20px;display:flex;align-items:flex-start;justify-content:space-between;gap:18px}.master-eyebrow{margin-bottom:4px;display:flex;align-items:center;gap:7px;color:var(--g600);font-size:11px;font-weight:800;text-transform:uppercase;letter-spacing:.06em}.master-head h2{margin:0;font-size:24px;line-height:1.25;letter-spacing:-.03em}.master-head p{margin:6px 0 0;color:var(--muted);font-size:12px}.master-actions{display:flex;gap:9px;flex-wrap:wrap}
.master-btn{min-height:40px;padding:0 15px;display:inline-flex;align-items:center;justify-content:center;gap:7px;border:0;border-radius:9px;font-size:12px;font-weight:800;transition:.2s}.master-btn:hover{transform:translateY(-1px);box-shadow:var(--shadow)}.master-btn-primary{color:#fff;background:linear-gradient(135deg,var(--g600),var(--g800))}.master-btn-light{color:var(--g800);background:#fff;border:1px solid var(--line)}.master-btn-danger{color:#b42318;background:#fff1f0;border:1px solid #ffd5d2}.master-btn-small{min-height:32px;padding:0 10px;font-size:10px}
.master-stats{margin-bottom:18px;display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:12px}.master-stat{padding:17px;display:flex;align-items:center;gap:12px;background:#fff;border:1px solid var(--line);border-radius:12px;box-shadow:var(--shadow)}.master-stat i{width:42px;height:42px;display:grid;place-items:center;color:var(--g700);background:var(--g100);border-radius:11px;font-size:20px}.master-stat small,.master-stat strong{display:block}.master-stat small{color:var(--muted);font-size:9px;font-weight:700;text-transform:uppercase}.master-stat strong{margin-top:2px;font-size:17px}
.master-panel{background:#fff;border:1px solid var(--line);border-radius:13px;box-shadow:var(--shadow);overflow:hidden}.master-panel-head{padding:17px 19px;display:flex;align-items:center;justify-content:space-between;gap:15px;border-bottom:1px solid var(--line)}.master-panel-head h3{margin:0;font-size:15px}.master-panel-head p{margin:2px 0 0;color:var(--muted);font-size:10px}.master-panel-body{padding:20px}.master-alert{margin-bottom:16px;padding:12px 14px;display:flex;align-items:flex-start;gap:9px;border-radius:9px;font-size:11px;font-weight:600}.master-alert-success{color:#08713b;background:#e9fff3;border:1px solid #c8f4db}.master-alert-error{color:#a1261c;background:#fff1f0;border:1px solid #ffd3cf}
.master-table-wrap{overflow-x:auto}.master-table{width:100%;min-width:1050px;border-collapse:collapse}.master-table th,.master-table td{padding:12px 13px;border-bottom:1px solid var(--line);text-align:left;vertical-align:middle}.master-table th{color:var(--muted);background:var(--g50);font-size:9px;font-weight:800;text-transform:uppercase;letter-spacing:.04em}.master-table td{font-size:11px}.master-table tbody tr:hover{background:#fbfffc}.master-table tbody tr:last-child td{border-bottom:0}
.lembaga-name{display:flex;align-items:center;gap:10px}.lembaga-avatar{width:36px;height:36px;flex:0 0 auto;display:grid;place-items:center;color:#fff;background:linear-gradient(135deg,var(--g500),var(--g800));border-radius:10px;font-size:11px;font-weight:800}.lembaga-name strong,.lembaga-name small{display:block}.lembaga-name small{margin-top:2px;color:var(--muted);font-size:9px}.type-badge{display:inline-flex;padding:5px 8px;color:#165f3d;background:var(--g100);border-radius:7px;font-size:9px;font-weight:700}.status-badge{display:inline-flex;align-items:center;gap:5px;padding:5px 8px;border-radius:999px;font-size:9px;font-weight:800}.status-active{color:#08713b;background:#ddfbea}.status-inactive{color:#66736c;background:#edf1ef}.master-row-actions{display:flex;gap:6px;align-items:center}.master-row-actions form{margin:0}.master-empty{padding:45px 20px;text-align:center;color:var(--muted)}.master-empty i{display:block;margin-bottom:8px;color:var(--g500);font-size:38px}
.master-form{display:grid;grid-template-columns:1fr 1fr;gap:17px}.master-field{display:grid;gap:6px}.master-field-full{grid-column:1/-1}.master-field label{font-size:11px;font-weight:800}.required{color:var(--red)}.master-input{width:100%;min-height:43px;padding:10px 12px;color:var(--ink);background:#fff;border:1px solid var(--line);border-radius:9px;outline:none;font:inherit;transition:.2s}.master-input:focus{border-color:var(--g500);box-shadow:0 0 0 3px rgba(21,196,106,.13)}textarea.master-input{min-height:115px;resize:vertical}.master-help{color:var(--muted);font-size:9px}.master-section{grid-column:1/-1;margin-top:4px;padding:9px 11px;display:flex;align-items:center;gap:7px;color:var(--g700);background:var(--g50);border:1px solid var(--g100);border-radius:8px;font-size:10px;font-weight:800;text-transform:uppercase;letter-spacing:.04em}.master-form-actions{grid-column:1/-1;padding-top:5px;display:flex;gap:9px;flex-wrap:wrap}
@media(max-width:900px){.master-stats{grid-template-columns:1fr}.master-form{grid-template-columns:1fr}.master-field-full,.master-section,.master-form-actions{grid-column:1}.master-head{flex-direction:column}.master-actions{width:100%}}@media(max-width:560px){.master-btn{width:100%}.master-row-actions .master-btn{width:auto}}
</style>

<div class="master-shell">
    <div class="master-head">
        <div><div class="master-eyebrow"><i class="ri-community-fill"></i> Data Desa</div><h2><?= $act === 'form' ? ((int)$formData['id'] > 0 ? 'Edit Lembaga Desa' : 'Tambah Lembaga Desa') : 'Lembaga Desa' ?></h2><p>Kelola profil, kepengurusan, masa bakti, dan status lembaga desa.</p></div>
        <div class="master-actions"><?php if ($act === 'form'): ?><a class="master-btn master-btn-light" href="lembaga_desa.php"><i class="ri-arrow-left-line"></i>Kembali</a><?php else: ?><a class="master-btn master-btn-primary" href="lembaga_desa.php?a=form"><i class="ri-add-circle-fill"></i>Tambah Lembaga</a><?php endif; ?></div>
    </div>

    <?php if (!$tableReady): ?><div class="master-alert master-alert-error"><i class="ri-database-2-line"></i><span>Tabel <strong>lembaga_desa</strong> belum tersedia. Jalankan <strong>database_idm_lembaga.sql</strong> pada database terlebih dahulu.</span></div><?php endif; ?>
    <?php if ($message): ?><div class="master-alert master-alert-<?= esc($message[0]) ?>"><i class="<?= $message[0] === 'success' ? 'ri-checkbox-circle-fill' : 'ri-error-warning-fill' ?>"></i><span><?= esc($message[1]) ?></span></div><?php endif; ?>
    <?php if ($errorText !== ''): ?><div class="master-alert master-alert-error"><i class="ri-error-warning-fill"></i><span><?= esc($errorText) ?></span></div><?php endif; ?>

    <?php if ($act !== 'form'): ?>
        <div class="master-stats">
            <div class="master-stat"><i class="ri-community-fill"></i><div><small>Total Lembaga</small><strong><?= count($rows) ?></strong></div></div>
            <div class="master-stat"><i class="ri-checkbox-circle-fill"></i><div><small>Lembaga Aktif</small><strong><?= $totalAktif ?></strong></div></div>
            <div class="master-stat"><i class="ri-apps-2-fill"></i><div><small>Jenis Lembaga</small><strong><?= count($jenisAktif) ?></strong></div></div>
        </div>

        <div class="master-panel">
            <div class="master-panel-head"><div><h3>Daftar Lembaga Desa</h3><p>Urutan tampilan mengikuti nilai urutan terkecil.</p></div></div>
            <?php if (!$rows): ?>
                <div class="master-empty"><i class="ri-community-line"></i><strong>Belum ada data lembaga</strong><p>Tambahkan lembaga desa melalui tombol di atas.</p></div>
            <?php else: ?>
                <div class="master-table-wrap"><table class="master-table"><thead><tr><th>Lembaga</th><th>Jenis</th><th>Ketua/Pimpinan</th><th>SK & Masa Bakti</th><th>Kontak</th><th>Status</th><th>Urutan</th><th>Aksi</th></tr></thead><tbody>
                <?php foreach ($rows as $row): ?>
                    <tr>
                        <td><div class="lembaga-name"><span class="lembaga-avatar"><?= esc(lembaga_initial($row['nama_lembaga'])) ?></span><div><strong><?= esc($row['nama_lembaga']) ?></strong><small><?= $row['singkatan'] !== '' ? esc($row['singkatan']) : 'Tanpa singkatan' ?></small></div></div></td>
                        <td><span class="type-badge"><?= esc($row['jenis']) ?></span></td>
                        <td><strong><?= esc($row['ketua']) ?></strong></td>
                        <td><div><?= $row['nomor_sk'] !== '' ? 'SK: '.esc($row['nomor_sk']) : 'SK: -' ?></div><small><?= $row['masa_bakti'] !== '' ? 'Masa bakti: '.esc($row['masa_bakti']) : 'Masa bakti: -' ?></small></td>
                        <td><div><?= $row['telepon'] !== '' ? esc($row['telepon']) : '-' ?></div><small><?= $row['email'] !== '' ? esc($row['email']) : '' ?></small></td>
                        <td><span class="status-badge <?= $row['status'] === 'aktif' ? 'status-active' : 'status-inactive' ?>"><i class="ri-checkbox-blank-circle-fill"></i><?= $row['status'] === 'aktif' ? 'Aktif' : 'Nonaktif' ?></span></td>
                        <td><strong><?= (int)$row['urutan'] ?></strong></td>
                        <td><div class="master-row-actions"><a class="master-btn master-btn-light master-btn-small" href="lembaga_desa.php?a=form&id=<?= (int)$row['id'] ?>"><i class="ri-edit-2-fill"></i>Edit</a><form method="post" action="lembaga_desa.php?a=delete" onsubmit="return confirm('Yakin ingin menghapus lembaga ini?');"><input type="hidden" name="csrf_token" value="<?= esc($csrfToken) ?>"><input type="hidden" name="id" value="<?= (int)$row['id'] ?>"><button class="master-btn master-btn-danger master-btn-small" type="submit"><i class="ri-delete-bin-6-fill"></i>Hapus</button></form></div></td>
                    </tr>
                <?php endforeach; ?>
                </tbody></table></div>
            <?php endif; ?>
        </div>
    <?php else: ?>
        <div class="master-panel">
            <div class="master-panel-head"><div><h3><?= (int)$formData['id'] > 0 ? 'Perbarui Data Lembaga' : 'Form Lembaga Baru' ?></h3><p>Kolom nama, jenis, dan ketua/pimpinan wajib diisi.</p></div></div>
            <div class="master-panel-body">
                <form class="master-form" method="post" action="lembaga_desa.php?a=save">
                    <input type="hidden" name="csrf_token" value="<?= esc($csrfToken) ?>"><input type="hidden" name="id" value="<?= (int)$formData['id'] ?>">
                    <div class="master-section"><i class="ri-building-4-fill"></i>Identitas Lembaga</div>
                    <div class="master-field"><label for="namaLembaga">Nama Lembaga <span class="required">*</span></label><input class="master-input" id="namaLembaga" name="nama_lembaga" maxlength="180" value="<?= esc($formData['nama_lembaga']) ?>" placeholder="Nama lengkap lembaga" required></div>
                    <div class="master-field"><label for="singkatan">Singkatan</label><input class="master-input" id="singkatan" name="singkatan" maxlength="50" value="<?= esc($formData['singkatan']) ?>" placeholder="Contoh: BPD"></div>
                    <div class="master-field master-field-full"><label for="jenis">Jenis Lembaga <span class="required">*</span></label><select class="master-input" id="jenis" name="jenis" required><?php foreach ($jenisOptions as $option): ?><option value="<?= esc($option) ?>" <?= $formData['jenis'] === $option ? 'selected' : '' ?>><?= esc($option) ?></option><?php endforeach; ?></select></div>

                    <div class="master-section"><i class="ri-team-fill"></i>Kepengurusan</div>
                    <div class="master-field"><label for="ketua">Ketua/Pimpinan <span class="required">*</span></label><input class="master-input" id="ketua" name="ketua" maxlength="150" value="<?= esc($formData['ketua']) ?>" placeholder="Nama ketua atau pimpinan" required></div>
                    <div class="master-field"><label for="masaBakti">Masa Bakti</label><input class="master-input" id="masaBakti" name="masa_bakti" maxlength="80" value="<?= esc($formData['masa_bakti']) ?>" placeholder="Contoh: 2025–2030"></div>
                    <div class="master-field master-field-full"><label for="nomorSk">Nomor SK</label><input class="master-input" id="nomorSk" name="nomor_sk" maxlength="120" value="<?= esc($formData['nomor_sk']) ?>" placeholder="Nomor surat keputusan pembentukan/pengangkatan"></div>

                    <div class="master-section"><i class="ri-contacts-book-2-fill"></i>Kontak dan Informasi</div>
                    <div class="master-field"><label for="telepon">Telepon/WhatsApp</label><input class="master-input" id="telepon" name="telepon" maxlength="30" value="<?= esc($formData['telepon']) ?>" placeholder="Nomor kontak lembaga"></div>
                    <div class="master-field"><label for="email">Email</label><input class="master-input" id="email" name="email" type="email" maxlength="150" value="<?= esc($formData['email']) ?>" placeholder="email@contoh.id"></div>
                    <div class="master-field master-field-full"><label for="alamat">Alamat/Sekretariat</label><textarea class="master-input" id="alamat" name="alamat" placeholder="Alamat sekretariat lembaga"><?= esc($formData['alamat']) ?></textarea></div>
                    <div class="master-field master-field-full"><label for="deskripsi">Deskripsi, Tugas, dan Fungsi</label><textarea class="master-input" id="deskripsi" name="deskripsi" placeholder="Jelaskan profil singkat, tugas, fungsi, atau program lembaga"><?= esc($formData['deskripsi']) ?></textarea></div>

                    <div class="master-section"><i class="ri-settings-3-fill"></i>Pengaturan Tampilan</div>
                    <div class="master-field"><label for="status">Status <span class="required">*</span></label><select class="master-input" id="status" name="status" required><option value="aktif" <?= $formData['status'] === 'aktif' ? 'selected' : '' ?>>Aktif</option><option value="nonaktif" <?= $formData['status'] === 'nonaktif' ? 'selected' : '' ?>>Nonaktif</option></select></div>
                    <div class="master-field"><label for="urutan">Urutan Tampilan</label><input class="master-input" id="urutan" name="urutan" type="number" min="0" value="<?= (int)$formData['urutan'] ?>"><span class="master-help">Nilai lebih kecil tampil lebih dahulu.</span></div>
                    <div class="master-form-actions"><button class="master-btn master-btn-primary" type="submit" <?= !$tableReady ? 'disabled' : '' ?>><i class="ri-save-3-fill"></i><?= (int)$formData['id'] > 0 ? 'Perbarui Lembaga' : 'Simpan Lembaga' ?></button><a class="master-btn master-btn-light" href="lembaga_desa.php"><i class="ri-close-circle-fill"></i>Batal</a></div>
                </form>
            </div>
        </div>
    <?php endif; ?>
</div>

<?php include __DIR__.'/../includes/footer.php'; ?>
