3.php

main 96 lines · 3.1 KB Raw
Alex Alex Commit Initial commit 01/10/2026 09:20
1<?php
2/** Step 3 - which server this site sits in front of, and how it is named. */
3
4if (!defined('ZNOTE_INSTALL')) { http_response_code(403); die('Direct access denied.'); }
5
6$engines = array(
7 'TFS_10' => 'TFS 1.1 - 1.4.2',
8 'TFS_16' => 'TFS 1.6',
9 'CANARY' => 'Canary / OTServBR-Global',
10 'TFS_03' => 'TFS 0.3.6+ / 0.4 / OTX',
11 'TFS_02' => 'TFS 0.2.13+',
12 'OTHIRE' => 'OTHire',
13);
14
15if ($_SERVER['REQUEST_METHOD'] === 'POST') {
16
17 $engine = (string)($_POST['ServerEngine'] ?? '');
18 $title = trim((string)($_POST['site_title'] ?? ''));
19 $url = rtrim(trim((string)($_POST['site_url'] ?? '')), '/');
20
21 if (!isset($engines[$engine])) {
22 install_error('Pick a server engine.');
23 } elseif ($title === '') {
24 install_error('The site needs a name.');
25 } else {
26 install_state(array(
27 'ServerEngine' => $engine,
28 'site_title' => $title,
29 'site_url' => $url,
30 'server_path' => rtrim(trim((string)($_POST['server_path'] ?? '')), '/\\'),
31 ));
32 install_max_step(4);
33 header('Location: ' . install_url(4));
34 exit;
35 }
36}
37
38// A sensible default URL, from the request itself.
39$guessUrl = install_get('site_url');
40if ($guessUrl === '') {
41 $scheme = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ? 'https' : 'http';
42 $host = (string)($_SERVER['HTTP_HOST'] ?? 'localhost');
43 $base = rtrim(dirname((string)($_SERVER['SCRIPT_NAME'] ?? '')), '/\\');
44 $base = preg_replace('#/install$#', '', $base);
45 $guessUrl = $scheme . '://' . $host . $base;
46}
47?>
48<h1>Server</h1>
49<p class="lead">Which engine you run, and how the site introduces itself.</p>
50
51<form method="post">
52 <div class="field">
53 <label class="lbl" for="ServerEngine">Server engine</label>
54 <select id="ServerEngine" name="ServerEngine">
55 <?php foreach ($engines as $key => $label): ?>
56 <option value="<?= ih($key) ?>" <?= install_get('ServerEngine', 'TFS_10') === $key ? 'selected' : '' ?>>
57 <?= ih($label) ?>
58 </option>
59 <?php endforeach; ?>
60 </select>
61 <p class="hint">
62 TFS 1.0 is not supported. TFS 1.6 and Canary differ from 1.x only in a few column
63 names, which ZnoteX handles for you.
64 </p>
65 </div>
66
67 <div class="row">
68 <div class="field">
69 <label class="lbl" for="site_title">Site name</label>
70 <input type="text" id="site_title" name="site_title"
71 value="<?= ih(install_get('site_title', 'My Open Tibia Server')) ?>" required>
72 </div>
73 <div class="field">
74 <label class="lbl" for="site_url">Site URL</label>
75 <input type="text" id="site_url" name="site_url" value="<?= ih($guessUrl) ?>">
76 <p class="hint">Used in e-mails. No trailing slash.</p>
77 </div>
78 </div>
79
80 <div class="field">
81 <label class="lbl" for="server_path">Server folder <em>(optional)</em></label>
82 <input type="text" id="server_path" name="server_path"
83 value="<?= ih(install_get('server_path')) ?>"
84 placeholder="C:/forgottenserver or /home/ots">
85 <p class="hint">
86 Where <code>data/</code> and <code>config.lua</code> live. Needed by the creature
87 library, the spell list and the server info page. You can set it later.
88 </p>
89 </div>
90
91 <div class="actions">
92 <button class="btn" type="submit">Continue</button>
93 <a class="btn ghost" href="<?= install_url(2) ?>">Back</a>
94 </div>
95</form>
96
Top