' . "\n"; echo '' . "\n"; echo "\n\n"; // "Back" softkey on every deck if (!empty($opt['back'])) { echo '' . "\n"; } echo "

$t

\n"; } else { header('Content-Type: application/xhtml+xml; charset=utf-8'); echo '' . "\n"; echo '' . "\n"; echo '' . "\n"; echo "\n$t - " . e(SITE_NAME) . "\n"; echo '' . "\n"; // Canonical URL drops the WAPSID session param and the markup switch, // so search engines consolidate on the clean page. $canon = 'https://' . ($_SERVER['HTTP_HOST'] ?? 'wap.txt3.net') . (strtok($_SERVER['REQUEST_URI'] ?? '/index.php', '?')); echo '' . "\n"; echo '' . "\n"; echo "\n\n
\n"; echo '

' . e(SITE_NAME) . "

\n"; nav_bar(); echo "

$t

\n"; } } function nav_bar(): void { if (is_wml()) return; $me = current_user(); echo '\n"; } function page_end(): void { if (!$GLOBALS['__page_open']) return; // Always offer a link to the OTHER markup mode, in both modes, so a client // that switched (or was detected wrongly) can always get back. $other = is_wml() ? 'html' : 'wml'; $otherLbl = is_wml() ? 'xhtml view' : 'wml view'; // Keep the user on the page they are looking at, minus any old m= override. $self = strtok($_SERVER['REQUEST_URI'] ?? '/index.php', '?'); $qs = $_GET; unset($qs['m'], $qs[session_name()]); $qs['m'] = $other; if (is_wml()) { echo '

' . e($otherLbl) . "

\n"; echo "\n\n"; } else { echo '
' . e(SITE_NAME) . ' · ' . '' . e($otherLbl) . '' . "
\n
\n\n\n"; } $GLOBALS['__page_open'] = false; } // ---------------------------------------------------------------- primitives function p_para(string $text, string $class = ''): void { $t = nl2br_mode(e($text)); if (is_wml()) echo "

$t

\n"; else echo '$t

\n"; } function nl2br_mode(string $escaped): string { return str_replace(["\r\n", "\n"], is_wml() ? "
" : "
", $escaped); } function p_err(string $t): void { if (is_wml()) echo '

! ' . e($t) . "

\n"; else echo '

' . e($t) . "

\n"; } function p_ok(string $t): void { if (is_wml()) echo '

' . e($t) . "

\n"; else echo '

' . e($t) . "

\n"; } // A vertical list of links -- one

per line in WML,

    in XHTML. function p_links(array $links): void { if (!$links) return; if (is_wml()) { foreach ($links as $l) { echo '

    ' . e($l[1]) . "

    \n"; } } else { echo "\n"; } } function p_link(string $path, string $label, array $q = []): void { $a = '' . e($label) . ''; echo is_wml() ? "

    $a

    \n" : "

    $a

    \n"; } function p_rule(): void { if (!is_wml()) echo "
    \n"; } // ---------------------------------------------------------------- forms // $fields: list of ['name'=>, 'label'=>, 'type'=>text|password|textarea|select|hidden, // 'value'=>, 'options'=>[v=>label], 'maxlength'=>, 'format'=>] function p_form(string $action, array $fields, string $submit, array $hidden = []): void { $hidden['csrf'] = csrf_token(); if (is_wml()) { // WML: inputs are declared in the card body, the issues the POST. foreach ($fields as $f) { $type = $f['type'] ?? 'text'; if ($type === 'hidden') { $hidden[$f['name']] = $f['value'] ?? ''; continue; } echo '

    ' . e($f['label']) . ':
    '; if ($type === 'select') { echo ''; } else { // WML has no textarea; a plain input is the portable choice. echo ''; } echo "

    \n"; } echo '' . "\n"; echo ' ' . "\n"; foreach ($hidden as $k => $v) { echo ' ' . "\n"; } foreach ($fields as $f) { if (($f['type'] ?? 'text') === 'hidden') continue; echo ' ' . "\n"; } echo " \n\n"; } else { echo '
    ' . "\n
    \n"; foreach ($hidden as $k => $v) { echo '' . "\n"; } foreach ($fields as $f) { $type = $f['type'] ?? 'text'; $nm = e($f['name']); if ($type === 'hidden') { echo '' . "\n"; continue; } echo '


    \n"; if ($type === 'textarea') { echo '"; } elseif ($type === 'select') { echo ''; } else { echo ''; } echo "

    \n"; } echo '

    ' . "\n"; echo "
    \n
    \n"; } } // Pager: prev/next links function p_pager(string $path, int $page, bool $more, array $q = []): void { $out = []; if ($page > 1) $out[] = ['/'.ltrim($path,'/'), '< Prev', $q + ['p' => $page - 1]]; if ($more) $out[] = ['/'.ltrim($path,'/'), 'Next >', $q + ['p' => $page + 1]]; if ($out) p_links($out); } function bail(string $title, string $msg, string $backPath = '/index.php'): void { page_start($title, ['back' => $backPath]); p_err($msg); p_link($backPath, 'Back'); page_end(); exit; } function redirect(string $path, array $q = []): void { header('Location: ' . url($path, $q)); exit; }