1 |
<?php
|
1 |
<?php
|
2 |
//
|
2 |
//
|
3 |
// mateuszbb - minimalistic bulletinboard-like forum
|
3 |
// mateuszbb - minimalistic bulletinboard-like forum
|
4 |
// Copyright (C) 2021-2023 Mateusz Viste
|
4 |
// Copyright (C) 2021-2023 Mateusz Viste
|
5 |
//
|
5 |
//
|
6 |
|
6 |
|
7 |
global $TRIP_SALT;
|
7 |
global $TRIP_SALT;
|
8 |
global $INITYEAR;
|
8 |
global $INITYEAR;
|
9 |
global $DATADIR;
|
9 |
global $DATADIR;
|
10 |
global $NICE_URLS;
|
10 |
global $NICE_URLS;
|
11 |
global $STR;
|
11 |
global $STR;
|
12 |
global $LANG;
|
12 |
global $LANG;
|
13 |
|
13 |
|
14 |
include 'mateuszbb-config.php';
|
14 |
include 'mateuszbb-config.php';
|
15 |
|
15 |
|
16 |
|
16 |
|
17 |
// *** TRANSLATION STRINGS *****************************************
|
17 |
// *** TRANSLATION STRINGS *****************************************
|
18 |
|
18 |
|
19 |
$STR = array();
|
19 |
$STR = array();
|
20 |
$STR['en']['opnewthread'] = 'open a new thread';
|
20 |
$STR['en']['opnewthread'] = 'open a new thread';
|
21 |
$STR['en']['newthread'] = 'New thread';
|
21 |
$STR['en']['newthread'] = 'New thread';
|
22 |
$STR['en']['latestentry'] = 'latest entry:';
|
22 |
$STR['en']['latestentry'] = 'latest entry:';
|
23 |
$STR['en']['searchterm'] = 'searched term:';
|
23 |
$STR['en']['searchterm'] = 'searched term:';
|
24 |
$STR['en']['noresults'] = 'No results';
|
24 |
$STR['en']['noresults'] = 'No results';
|
25 |
$STR['en']['reply'] = 'reply';
|
25 |
$STR['en']['reply'] = 'reply';
|
26 |
$STR['en']['jumptoend'] = 'jump to end';
|
26 |
$STR['en']['jumptoend'] = 'jump to end';
|
27 |
$STR['en']['listthreads'] = 'list of threads';
|
27 |
$STR['en']['listthreads'] = 'list of threads';
|
28 |
$STR['en']['author'] = 'author:';
|
28 |
$STR['en']['author'] = 'author:';
|
29 |
$STR['en']['address'] = 'address:';
|
29 |
$STR['en']['address'] = 'address:';
|
30 |
$STR['en']['date'] = 'date:';
|
30 |
$STR['en']['date'] = 'date:';
|
31 |
$STR['en']['nameornick'] = 'your name or nick';
|
31 |
$STR['en']['nameornick'] = 'your name or nick';
|
32 |
$STR['en']['threadsubj'] = 'subject';
|
32 |
$STR['en']['threadsubj'] = 'subject';
|
33 |
$STR['en']['yourmsg'] = 'Your message';
|
33 |
$STR['en']['yourmsg'] = 'Your message';
|
34 |
$STR['en']['cancel'] = 'cancel';
|
34 |
$STR['en']['cancel'] = 'cancel';
|
35 |
$STR['en']['send'] = 'send';
|
35 |
$STR['en']['send'] = 'send';
|
36 |
$STR['en']['archives'] = 'archives';
|
36 |
$STR['en']['archives'] = 'archives';
|
37 |
$STR['en']['backtocur'] = 'go back to current threads';
|
37 |
$STR['en']['backtocur'] = 'go back to current threads';
|
38 |
$STR['en']['search'] = 'search';
|
38 |
$STR['en']['search'] = 'search';
|
39 |
$STR['en']['password'] = 'password';
|
39 |
$STR['en']['password'] = 'password';
|
40 |
$STR['en']['optional'] = 'optional';
|
40 |
$STR['en']['optional'] = 'optional';
|
41 |
$STR['en']['passhelp'] = 'Providing a password here will generate a unique digital signature on your message.';
|
41 |
$STR['en']['passhelp'] = 'Providing a password here will generate a unique digital signature on your message.';
|
42 |
$STR['en']['captcha'][1] = 'check the FIRST box';
|
42 |
$STR['en']['captcha'][1] = 'check the FIRST box';
|
43 |
$STR['en']['captcha'][2] = 'check the MIDDLE box';
|
43 |
$STR['en']['captcha'][2] = 'check the MIDDLE box';
|
44 |
$STR['en']['captcha'][3] = 'check the LAST box';
|
44 |
$STR['en']['captcha'][3] = 'check the LAST box';
|
45 |
$STR['en']['captcha'][4] = 'check the FIRST and LAST boxes';
|
45 |
$STR['en']['captcha'][4] = 'check the FIRST and LAST boxes';
|
46 |
$STR['en']['captcha'][5] = 'check the TWO LAST boxes';
|
46 |
$STR['en']['captcha'][5] = 'check the TWO LAST boxes';
|
47 |
|
47 |
|
- |
|
48 |
// PL translations by Mateusz Viste
|
48 |
$STR['pl']['opnewthread'] = 'stwórz nowy wątek';
|
49 |
$STR['pl']['opnewthread'] = 'stwórz nowy wątek';
|
49 |
$STR['pl']['newthread'] = 'Nowy wątek';
|
50 |
$STR['pl']['newthread'] = 'Nowy wątek';
|
50 |
$STR['pl']['latestentry'] = 'ostatni wpis:';
|
51 |
$STR['pl']['latestentry'] = 'ostatni wpis:';
|
51 |
$STR['pl']['searchterm'] = 'szukane wyrażenie:';
|
52 |
$STR['pl']['searchterm'] = 'szukane wyrażenie:';
|
52 |
$STR['pl']['noresults'] = 'Brak wyników';
|
53 |
$STR['pl']['noresults'] = 'Brak wyników';
|
53 |
$STR['pl']['reply'] = 'odpowiedz';
|
54 |
$STR['pl']['reply'] = 'odpowiedz';
|
54 |
$STR['pl']['jumptoend'] = 'skocz do końca';
|
55 |
$STR['pl']['jumptoend'] = 'skocz do końca';
|
55 |
$STR['pl']['listthreads'] = 'lista wątków';
|
56 |
$STR['pl']['listthreads'] = 'lista wątków';
|
56 |
$STR['pl']['author'] = 'autor:';
|
57 |
$STR['pl']['author'] = 'autor:';
|
57 |
$STR['pl']['address'] = 'adres:';
|
58 |
$STR['pl']['address'] = 'adres:';
|
58 |
$STR['pl']['date'] = 'data:';
|
59 |
$STR['pl']['date'] = 'data:';
|
59 |
$STR['pl']['nameornick'] = 'imię, nazwisko lub pseudonim';
|
60 |
$STR['pl']['nameornick'] = 'imię, nazwisko lub pseudonim';
|
60 |
$STR['pl']['threadsubj'] = 'tytuł wątku';
|
61 |
$STR['pl']['threadsubj'] = 'tytuł wątku';
|
61 |
$STR['pl']['yourmsg'] = 'Twoja wiadomość';
|
62 |
$STR['pl']['yourmsg'] = 'Twoja wiadomość';
|
62 |
$STR['pl']['cancel'] = 'anuluj';
|
63 |
$STR['pl']['cancel'] = 'anuluj';
|
63 |
$STR['pl']['send'] = 'wyślij';
|
64 |
$STR['pl']['send'] = 'wyślij';
|
64 |
$STR['pl']['archives'] = 'archiwum';
|
65 |
$STR['pl']['archives'] = 'archiwum';
|
65 |
$STR['pl']['backtocur'] = 'powrót do bieżących wątków';
|
66 |
$STR['pl']['backtocur'] = 'powrót do bieżących wątków';
|
66 |
$STR['pl']['search'] = 'szukaj';
|
67 |
$STR['pl']['search'] = 'szukaj';
|
67 |
$STR['pl']['password'] = 'hasło';
|
68 |
$STR['pl']['password'] = 'hasło';
|
68 |
$STR['pl']['optional'] = 'opcjonale';
|
69 |
$STR['pl']['optional'] = 'opcjonale';
|
69 |
$STR['pl']['passhelp'] = 'Podanie hasła pozwoli wygenerować unikalny podpis elektroniczny przy twojej wiadomości.';
|
70 |
$STR['pl']['passhelp'] = 'Podanie hasła pozwoli wygenerować unikalny podpis elektroniczny przy twojej wiadomości.';
|
70 |
$STR['pl']['captcha'][1] = 'zaznacz PIERWSZE pole';
|
71 |
$STR['pl']['captcha'][1] = 'zaznacz PIERWSZE pole';
|
71 |
$STR['pl']['captcha'][2] = 'zaznacz ŚRODKOWE pole';
|
72 |
$STR['pl']['captcha'][2] = 'zaznacz ŚRODKOWE pole';
|
72 |
$STR['pl']['captcha'][3] = 'zaznacz OSTATNIE pole';
|
73 |
$STR['pl']['captcha'][3] = 'zaznacz OSTATNIE pole';
|
73 |
$STR['pl']['captcha'][4] = 'zaznacz PIERWSZE i OSTATNIE pole';
|
74 |
$STR['pl']['captcha'][4] = 'zaznacz PIERWSZE i OSTATNIE pole';
|
74 |
$STR['pl']['captcha'][5] = 'zaznacz DWA OSTATNIE pola';
|
75 |
$STR['pl']['captcha'][5] = 'zaznacz DWA OSTATNIE pola';
|
75 |
|
76 |
|
- |
|
77 |
// pt-BR translations courtesty of Luzemário Dantas
|
- |
|
78 |
$STR['pt']['opnewthread'] = 'abrir novo tópico';
|
- |
|
79 |
$STR['pt']['newthread'] = 'Novo tópico';
|
- |
|
80 |
$STR['pt']['latestentry'] = 'entrada mais recente:';
|
- |
|
81 |
$STR['pt']['searchterm'] = 'termo pesquisado:';
|
- |
|
82 |
$STR['pt']['noresults'] = 'Sem resultados';
|
- |
|
83 |
$STR['pt']['reply'] = 'responder';
|
- |
|
84 |
$STR['pt']['jumptoend'] = 'ir para o final';
|
- |
|
85 |
$STR['pt']['listthreads'] = 'lista de tópicos';
|
- |
|
86 |
$STR['pt']['author'] = 'autor:';
|
- |
|
87 |
$STR['pt']['address'] = 'endereço:';
|
- |
|
88 |
$STR['pt']['date'] = 'data:';
|
- |
|
89 |
$STR['pt']['nameornick'] = 'seu nome ou apelido';
|
- |
|
90 |
$STR['pt']['threadsubj'] = 'assunto';
|
- |
|
91 |
$STR['pt']['yourmsg'] = 'Sua mensagem';
|
- |
|
92 |
$STR['pt']['cancel'] = 'cancelar';
|
- |
|
93 |
$STR['pt']['send'] = 'enviar';
|
- |
|
94 |
$STR['pt']['archives'] = 'arquivos';
|
- |
|
95 |
$STR['pt']['backtocur'] = 'voltar ao tópico atuai';
|
- |
|
96 |
$STR['pt']['search'] = 'pesquisar';
|
- |
|
97 |
$STR['pt']['password'] = 'senha';
|
- |
|
98 |
$STR['pt']['optional'] = 'opcional';
|
- |
|
99 |
$STR['pt']['passhelp'] = 'Fornecer uma senha aqui vai gerar uma assinatura digital única na sua mensagem.';
|
- |
|
100 |
$STR['pt']['captcha'][1] = 'marque a PRIMEIRA caixa';
|
- |
|
101 |
$STR['pt']['captcha'][2] = 'marque a caixa do MEIO';
|
- |
|
102 |
$STR['pt']['captcha'][3] = 'marque a ÚLTIMA caixa';
|
- |
|
103 |
$STR['pt']['captcha'][4] = 'marque a PRIMEIRA e ÚLTIMA caixas';
|
- |
|
104 |
$STR['pt']['captcha'][5] = 'marque as DUAS ÚLTIMAS caixas';
|
- |
|
105 |
|
76 |
// *****************************************************************
|
106 |
// *****************************************************************
|
77 |
|
107 |
|
78 |
|
108 |
|
79 |
function data_dluga($timestamp) {
|
109 |
function data_dluga($timestamp) {
|
80 |
date_default_timezone_set('UTC');
|
110 |
date_default_timezone_set('UTC');
|
81 |
return(date('d.m.Y, H:i:s', $timestamp) . ' UTC');
|
111 |
return(date('d.m.Y, H:i:s', $timestamp) . ' UTC');
|
82 |
}
|
112 |
}
|
83 |
|
113 |
|
84 |
|
114 |
|
85 |
// returns an array with the list of languages requested by the browser, in
|
115 |
// returns an array with the list of languages requested by the browser, in
|
86 |
// the order of preference
|
116 |
// the order of preference
|
87 |
function getpreflang() {
|
117 |
function getpreflang() {
|
88 |
$res = array();
|
118 |
$res = array();
|
89 |
if (! isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) return($res);
|
119 |
if (! isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) return($res);
|
90 |
$langlist = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']);
|
120 |
$langlist = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']);
|
91 |
foreach ($langlist as $lang) {
|
121 |
foreach ($langlist as $lang) {
|
92 |
$res[] = strtolower(substr($lang, 0, 2));
|
122 |
$res[] = strtolower(substr($lang, 0, 2));
|
93 |
}
|
123 |
}
|
94 |
return(array_unique($res));
|
124 |
return(array_unique($res));
|
95 |
}
|
125 |
}
|
96 |
|
126 |
|
97 |
|
127 |
|
98 |
function mateuszbb_rss() {
|
128 |
function mateuszbb_rss() {
|
99 |
global $DATADIR;
|
129 |
global $DATADIR;
|
100 |
global $RSS_TITLE;
|
130 |
global $RSS_TITLE;
|
101 |
|
131 |
|
102 |
$db = new SQLite3($DATADIR . 'mateuszbb.sqlite3', SQLITE3_OPEN_READONLY);
|
132 |
$db = new SQLite3($DATADIR . 'mateuszbb.sqlite3', SQLITE3_OPEN_READONLY);
|
103 |
if (! $db) {
|
133 |
if (! $db) {
|
104 |
echo "SQL ERROR: ACCESS DENIED\n";
|
134 |
echo "SQL ERROR: ACCESS DENIED\n";
|
105 |
return false;
|
135 |
return false;
|
106 |
}
|
136 |
}
|
107 |
$sqlres = $db->query('SELECT thread, msgid, author FROM rss ORDER BY msgid DESC, thread DESC LIMIT 100;');
|
137 |
$sqlres = $db->query('SELECT thread, msgid, author FROM rss ORDER BY msgid DESC, thread DESC LIMIT 100;');
|
108 |
if (! $sqlres) {
|
138 |
if (! $sqlres) {
|
109 |
echo "SQL ERROR: QUERY FAILED\n";
|
139 |
echo "SQL ERROR: QUERY FAILED\n";
|
110 |
return false;
|
140 |
return false;
|
111 |
}
|
141 |
}
|
112 |
|
142 |
|
113 |
header('content-type: application/rss+xml');
|
143 |
header('content-type: application/rss+xml');
|
114 |
|
144 |
|
115 |
echo '<?xml version="1.0" encoding="utf-8" ?>' . "\n";
|
145 |
echo '<?xml version="1.0" encoding="utf-8" ?>' . "\n";
|
116 |
echo '<rss version="2.0">' . "\n";
|
146 |
echo '<rss version="2.0">' . "\n";
|
117 |
echo "<channel>\n";
|
147 |
echo "<channel>\n";
|
118 |
echo "<title>" . htmlspecialchars($RSS_TITLE, ENT_XML1) . "</title>\n";
|
148 |
echo "<title>" . htmlspecialchars($RSS_TITLE, ENT_XML1) . "</title>\n";
|
119 |
echo "<link>" . selfurl(). "</link>\n";
|
149 |
echo "<link>" . selfurl(). "</link>\n";
|
120 |
|
150 |
|
121 |
while ($row = $sqlres->fetchArray()) {
|
151 |
while ($row = $sqlres->fetchArray()) {
|
122 |
$rawtitle = file_get_contents($DATADIR . 'threads/' . $row['thread'] . '/title.txt');
|
152 |
$rawtitle = file_get_contents($DATADIR . 'threads/' . $row['thread'] . '/title.txt');
|
123 |
if (empty($rawtitle)) continue;
|
153 |
if (empty($rawtitle)) continue;
|
124 |
$title = htmlspecialchars($rawtitle, ENT_XML1, 'UTF-8');
|
154 |
$title = htmlspecialchars($rawtitle, ENT_XML1, 'UTF-8');
|
125 |
$author = htmlspecialchars($row['author'], ENT_XML1, 'UTF-8');
|
155 |
$author = htmlspecialchars($row['author'], ENT_XML1, 'UTF-8');
|
126 |
if ($NICE_URLS) {
|
156 |
if ($NICE_URLS) {
|
127 |
$link = selfurl();
|
157 |
$link = selfurl();
|
128 |
if (substr($link, -1) !== '/') $link .= '/';
|
158 |
if (substr($link, -1) !== '/') $link .= '/';
|
129 |
$link .= "{$row['thread']}";
|
159 |
$link .= "{$row['thread']}";
|
130 |
} else {
|
160 |
} else {
|
131 |
$link = selfurl('thread=' . $row['thread']);
|
161 |
$link = selfurl('thread=' . $row['thread']);
|
132 |
}
|
162 |
}
|
133 |
$link .= '#' . $row['msgid'];
|
163 |
$link .= '#' . $row['msgid'];
|
134 |
echo "<item>\n";
|
164 |
echo "<item>\n";
|
135 |
echo "<title>{$author} @ '{$title}'</title>\n";
|
165 |
echo "<title>{$author} @ '{$title}'</title>\n";
|
136 |
echo "<link>" . htmlspecialchars($link, ENT_XML1) . "</link>\n";
|
166 |
echo "<link>" . htmlspecialchars($link, ENT_XML1) . "</link>\n";
|
137 |
echo "<description>{$author} @ '{$title}'</description>\n";
|
167 |
echo "<description>{$author} @ '{$title}'</description>\n";
|
138 |
echo "<pubDate>" . date('r', $row['msgid']) . "</pubDate>\n";
|
168 |
echo "<pubDate>" . date('r', $row['msgid']) . "</pubDate>\n";
|
139 |
echo "<guid>" . htmlspecialchars($link, ENT_XML1) . "</guid>\n";
|
169 |
echo "<guid>" . htmlspecialchars($link, ENT_XML1) . "</guid>\n";
|
140 |
echo "</item>\n";
|
170 |
echo "</item>\n";
|
141 |
}
|
171 |
}
|
142 |
$db->close();
|
172 |
$db->close();
|
143 |
|
173 |
|
144 |
echo "</channel>\n";
|
174 |
echo "</channel>\n";
|
145 |
echo "</rss>\n";
|
175 |
echo "</rss>\n";
|
146 |
return true;
|
176 |
return true;
|
147 |
}
|
177 |
}
|
148 |
|
178 |
|
149 |
|
179 |
|
150 |
function formularz($thread = '') {
|
180 |
function formularz($thread = '') {
|
151 |
global $STR;
|
181 |
global $STR;
|
152 |
global $LANG;
|
182 |
global $LANG;
|
153 |
|
183 |
|
154 |
if (empty($thread)) {
|
184 |
if (empty($thread)) {
|
155 |
echo '<form class="minibb" method="POST" action="' . selfurl() . '#title" id="formularz">' . "\n";
|
185 |
echo '<form class="minibb" method="POST" action="' . selfurl() . '#title" id="formularz">' . "\n";
|
156 |
echo '<input type="hidden" name="action" value="createthread">' . "\n";
|
186 |
echo '<input type="hidden" name="action" value="createthread">' . "\n";
|
157 |
} else {
|
187 |
} else {
|
158 |
echo '<form class="minibb" method="POST" action="' . selfurl() . '" id="formularz">' . "\n";
|
188 |
echo '<form class="minibb" method="POST" action="' . selfurl() . '" id="formularz">' . "\n";
|
159 |
echo '<input type="hidden" name="action" value="newpost">' . "\n";
|
189 |
echo '<input type="hidden" name="action" value="newpost">' . "\n";
|
160 |
echo '<input type="hidden" name="thread" value="' . $thread . '">' . "\n";
|
190 |
echo '<input type="hidden" name="thread" value="' . $thread . '">' . "\n";
|
161 |
}
|
191 |
}
|
162 |
|
192 |
|
163 |
echo '<div class="minibb-formfields">' . "\n";
|
193 |
echo '<div class="minibb-formfields">' . "\n";
|
164 |
echo '<div class="minibb-formlabelgroup"><p>' . $STR[$LANG]['nameornick'] . '</p><input type="text" name="login" pattern=".*[^\s].*" minlength="1" maxlength="40" title="' . $STR[$LANG]['nameornick'] . '" required></div><div class="minibb-formlabelgroup"><p>' . $STR[$LANG]['password'] . ' (<span title="' . $STR[$LANG]['passhelp'] . '" style="text-decoration-line: underline; text-decoration-style: dotted;">' . $STR[$LANG]['optional'] . '</span>)</p><input type="password" name="pass" maxlength="40"></div>' . "\n";
|
194 |
echo '<div class="minibb-formlabelgroup"><p>' . $STR[$LANG]['nameornick'] . '</p><input type="text" name="login" pattern=".*[^\s].*" minlength="1" maxlength="40" title="' . $STR[$LANG]['nameornick'] . '" required></div><div class="minibb-formlabelgroup"><p>' . $STR[$LANG]['password'] . ' (<span title="' . $STR[$LANG]['passhelp'] . '" style="text-decoration-line: underline; text-decoration-style: dotted;">' . $STR[$LANG]['optional'] . '</span>)</p><input type="password" name="pass" maxlength="40"></div>' . "\n";
|
165 |
if (empty($thread)) {
|
195 |
if (empty($thread)) {
|
166 |
echo '<div class="minibb-formlabelgroup" style="width: 100%;">' . "\n";
|
196 |
echo '<div class="minibb-formlabelgroup" style="width: 100%;">' . "\n";
|
167 |
echo "<p>" . $STR[$LANG]['threadsubj'] . "</p>\n";
|
197 |
echo "<p>" . $STR[$LANG]['threadsubj'] . "</p>\n";
|
168 |
echo '<input type="text" name="title" title="' . $STR[$LANG]['threadsubj'] . '" maxlength="64" pattern=".*[^\s].*" required>' . "\n";
|
198 |
echo '<input type="text" name="title" title="' . $STR[$LANG]['threadsubj'] . '" maxlength="64" pattern=".*[^\s].*" required>' . "\n";
|
169 |
echo "</div>\n";
|
199 |
echo "</div>\n";
|
170 |
}
|
200 |
}
|
171 |
echo '<textarea name="msg" placeholder="' . $STR[$LANG]['yourmsg'] . '">' . "\n";
|
201 |
echo '<textarea name="msg" placeholder="' . $STR[$LANG]['yourmsg'] . '">' . "\n";
|
172 |
echo '</textarea><br>' . "\n";
|
202 |
echo '</textarea><br>' . "\n";
|
173 |
echo '</div>' . "\n";
|
203 |
echo '</div>' . "\n";
|
174 |
// --- CAPTCHA ---
|
204 |
// --- CAPTCHA ---
|
175 |
$capid = rand(1, 5);
|
205 |
$capid = rand(1, 5);
|
176 |
echo '<div class="minibb-formcaptcha">' . $STR[$LANG]['captcha'][$capid] . ': <input type="checkbox" name=c1> <input type="checkbox" name=c2> <input type="checkbox" name=c3>' . "\n";
|
206 |
echo '<div class="minibb-formcaptcha">' . $STR[$LANG]['captcha'][$capid] . ': <input type="checkbox" name=c1> <input type="checkbox" name=c2> <input type="checkbox" name=c3>' . "\n";
|
177 |
echo '<input type="hidden" name="capid" value="' . $capid . '">';
|
207 |
echo '<input type="hidden" name="capid" value="' . $capid . '">';
|
178 |
// ---------------
|
208 |
// ---------------
|
179 |
echo '<div class="minibb-formbtns">';
|
209 |
echo '<div class="minibb-formbtns">';
|
180 |
echo '<a href="' . selfurl() . '">' . $STR[$LANG]['cancel'] . '</a> <input type="submit" value="' . $STR[$LANG]['send'] . '">' . "\n";
|
210 |
echo '<a href="' . selfurl() . '">' . $STR[$LANG]['cancel'] . '</a> <input type="submit" value="' . $STR[$LANG]['send'] . '">' . "\n";
|
181 |
echo '</div>';
|
211 |
echo '</div>';
|
182 |
echo '</form>';
|
212 |
echo '</form>';
|
183 |
}
|
213 |
}
|
184 |
|
214 |
|
185 |
function wyswietl_watek_w_liscie($threadid, $tytul, $lastauthor, $lastupdate) {
|
215 |
function wyswietl_watek_w_liscie($threadid, $tytul, $lastauthor, $lastupdate) {
|
186 |
global $NICE_URLS;
|
216 |
global $NICE_URLS;
|
187 |
global $STR;
|
217 |
global $STR;
|
188 |
global $LANG;
|
218 |
global $LANG;
|
189 |
|
219 |
|
190 |
echo '<a href="';
|
220 |
echo '<a href="';
|
191 |
if (!$NICE_URLS) {
|
221 |
if (!$NICE_URLS) {
|
192 |
echo selfurl("thread=$threadid");
|
222 |
echo selfurl("thread=$threadid");
|
193 |
} else {
|
223 |
} else {
|
194 |
echo $threadid;
|
224 |
echo $threadid;
|
195 |
}
|
225 |
}
|
196 |
echo '" class="minibb-threaditem">' . "\n";
|
226 |
echo '" class="minibb-threaditem">' . "\n";
|
197 |
echo '<h2>' . htmlspecialchars($tytul) . "</h2>\n";
|
227 |
echo '<h2>' . htmlspecialchars($tytul) . "</h2>\n";
|
198 |
echo '<p>' . $STR[$LANG]['latestentry'] . ' ' . htmlspecialchars($lastauthor) . ', ' . htmlspecialchars(data_dluga($lastupdate)) . "</p>\n";
|
228 |
echo '<p>' . $STR[$LANG]['latestentry'] . ' ' . htmlspecialchars($lastauthor) . ', ' . htmlspecialchars(data_dluga($lastupdate)) . "</p>\n";
|
199 |
echo "</a>\n";
|
229 |
echo "</a>\n";
|
200 |
}
|
230 |
}
|
201 |
|
231 |
|
202 |
function sprawdz_captcha($CAPARR) {
|
232 |
function sprawdz_captcha($CAPARR) {
|
203 |
//echo "<!-- capid={$CAPARR['capid']} c1={$CAPARR['c1']} c2={$CAPARR['c2']} c3={$CAPARR['c3']}-->\n";
|
233 |
//echo "<!-- capid={$CAPARR['capid']} c1={$CAPARR['c1']} c2={$CAPARR['c2']} c3={$CAPARR['c3']}-->\n";
|
204 |
switch ($CAPARR['capid']) {
|
234 |
switch ($CAPARR['capid']) {
|
205 |
case 1:
|
235 |
case 1:
|
206 |
if (($CAPARR['c1']) && (!$CAPARR['c2']) && (!$CAPARR['c3'])) return(true);
|
236 |
if (($CAPARR['c1']) && (!$CAPARR['c2']) && (!$CAPARR['c3'])) return(true);
|
207 |
break;
|
237 |
break;
|
208 |
case 2:
|
238 |
case 2:
|
209 |
if ((!$CAPARR['c1']) && ($CAPARR['c2']) && (!$CAPARR['c3'])) return(true);
|
239 |
if ((!$CAPARR['c1']) && ($CAPARR['c2']) && (!$CAPARR['c3'])) return(true);
|
210 |
break;
|
240 |
break;
|
211 |
case 3:
|
241 |
case 3:
|
212 |
if ((!$CAPARR['c1']) && (!$CAPARR['c2']) && ($CAPARR['c3'])) return(true);
|
242 |
if ((!$CAPARR['c1']) && (!$CAPARR['c2']) && ($CAPARR['c3'])) return(true);
|
213 |
break;
|
243 |
break;
|
214 |
case 4:
|
244 |
case 4:
|
215 |
if (($CAPARR['c1']) && (!$CAPARR['c2']) && ($CAPARR['c3'])) return(true);
|
245 |
if (($CAPARR['c1']) && (!$CAPARR['c2']) && ($CAPARR['c3'])) return(true);
|
216 |
break;
|
246 |
break;
|
217 |
case 5:
|
247 |
case 5:
|
218 |
if ((!$CAPARR['c1']) && ($CAPARR['c2']) && ($CAPARR['c3'])) return(true);
|
248 |
if ((!$CAPARR['c1']) && ($CAPARR['c2']) && ($CAPARR['c3'])) return(true);
|
219 |
break;
|
249 |
break;
|
220 |
}
|
250 |
}
|
221 |
return(false);
|
251 |
return(false);
|
222 |
}
|
252 |
}
|
223 |
|
253 |
|
224 |
|
254 |
|
225 |
// zwraca akcję na podstawie globalnych POST lub GET
|
255 |
// zwraca akcję na podstawie globalnych POST lub GET
|
226 |
function getvar_action() {
|
256 |
function getvar_action() {
|
227 |
if (!empty($_POST['action'])) return $_POST['action'];
|
257 |
if (!empty($_POST['action'])) return $_POST['action'];
|
228 |
if (!empty($_GET['action'])) return $_GET['action'];
|
258 |
if (!empty($_GET['action'])) return $_GET['action'];
|
229 |
return('');
|
259 |
return('');
|
230 |
}
|
260 |
}
|
231 |
|
261 |
|
232 |
function getvar_thread() {
|
262 |
function getvar_thread() {
|
233 |
if (!empty($_POST['thread'])) return intval($_POST['thread']);
|
263 |
if (!empty($_POST['thread'])) return intval($_POST['thread']);
|
234 |
if (!empty($_GET['thread'])) return intval($_GET['thread']);
|
264 |
if (!empty($_GET['thread'])) return intval($_GET['thread']);
|
235 |
return(-1);
|
265 |
return(-1);
|
236 |
}
|
266 |
}
|
237 |
|
267 |
|
238 |
function getvar_archiveyear() {
|
268 |
function getvar_archiveyear() {
|
239 |
if (!empty($_POST['arch'])) return intval($_POST['arch']);
|
269 |
if (!empty($_POST['arch'])) return intval($_POST['arch']);
|
240 |
if (!empty($_GET['arch'])) return intval($_GET['arch']);
|
270 |
if (!empty($_GET['arch'])) return intval($_GET['arch']);
|
241 |
return(-1);
|
271 |
return(-1);
|
242 |
}
|
272 |
}
|
243 |
|
273 |
|
244 |
|
274 |
|
245 |
// funkcja która zapisuje nowe wiadomości
|
275 |
// funkcja która zapisuje nowe wiadomości
|
246 |
function mateuszbb_preprocess() {
|
276 |
function mateuszbb_preprocess() {
|
247 |
global $TRIP_SALT;
|
277 |
global $TRIP_SALT;
|
248 |
global $DATADIR;
|
278 |
global $DATADIR;
|
249 |
global $NICE_URLS;
|
279 |
global $NICE_URLS;
|
250 |
global $ERRSTR; // zmienna zawierająca komunikat błędu (jeśli jakiś wystąpił)
|
280 |
global $ERRSTR; // zmienna zawierająca komunikat błędu (jeśli jakiś wystąpił)
|
251 |
global $STR;
|
281 |
global $STR;
|
252 |
global $LANG;
|
282 |
global $LANG;
|
253 |
|
283 |
|
254 |
$action = getvar_action();
|
284 |
$action = getvar_action();
|
255 |
$thread = getvar_thread();
|
285 |
$thread = getvar_thread();
|
256 |
$archiveyear = getvar_archiveyear();
|
286 |
$archiveyear = getvar_archiveyear();
|
257 |
|
287 |
|
258 |
// negotiate language
|
288 |
// negotiate language
|
259 |
$LANG = 'en'; // preselect english as default language
|
289 |
$LANG = 'en'; // preselect english as default language
|
260 |
foreach (getpreflang() as $l) {
|
290 |
foreach (getpreflang() as $l) {
|
261 |
if (!empty($STR[$l])) {
|
291 |
if (!empty($STR[$l])) {
|
262 |
$LANG = $l;
|
292 |
$LANG = $l;
|
263 |
break;
|
293 |
break;
|
264 |
}
|
294 |
}
|
265 |
}
|
295 |
}
|
266 |
|
296 |
|
267 |
// write access: check how many messages the user posted during last 24h
|
297 |
// write access: check how many messages the user posted during last 24h
|
268 |
if (($action === 'createthread') || ($action === 'newpost')) {
|
298 |
if (($action === 'createthread') || ($action === 'newpost')) {
|
269 |
$db = new SQLite3($DATADIR . 'mateuszbb.sqlite3');
|
299 |
$db = new SQLite3($DATADIR . 'mateuszbb.sqlite3');
|
270 |
if ($db) {
|
300 |
if ($db) {
|
271 |
$db->exec('DELETE FROM ip_msg_counters24h WHERE msgid < strftime(\'%s\', \'now\') - 24*3600;');
|
301 |
$db->exec('DELETE FROM ip_msg_counters24h WHERE msgid < strftime(\'%s\', \'now\') - 24*3600;');
|
272 |
$count24h = intval($db->querySingle("SELECT count(*) FROM ip_msg_counters24h WHERE ipaddr = '{$_SERVER['REMOTE_ADDR']}'"));
|
302 |
$count24h = intval($db->querySingle("SELECT count(*) FROM ip_msg_counters24h WHERE ipaddr = '{$_SERVER['REMOTE_ADDR']}'"));
|
273 |
$db->close();
|
303 |
$db->close();
|
274 |
if ($count24h >= 10) {
|
304 |
if ($count24h >= 10) {
|
275 |
$ERRSTR = "BŁĄD: Z TWOJEGO ADRESU NAPISANO JUŻ {$count24h} WIADOMOŚCI W PRZECIĄGU OSTATNICH 24H. SPRÓBUJ PONOWNIE ZA JAKIŚ CZAS.";
|
305 |
$ERRSTR = "BŁĄD: Z TWOJEGO ADRESU NAPISANO JUŻ {$count24h} WIADOMOŚCI W PRZECIĄGU OSTATNICH 24H. SPRÓBUJ PONOWNIE ZA JAKIŚ CZAS.";
|
276 |
$action = '';
|
306 |
$action = '';
|
277 |
}
|
307 |
}
|
278 |
}
|
308 |
}
|
279 |
}
|
309 |
}
|
280 |
|
310 |
|
281 |
// new thread creation (+switch to read thread)
|
311 |
// new thread creation (+switch to read thread)
|
282 |
if ($action === 'createthread') {
|
312 |
if ($action === 'createthread') {
|
283 |
// captcha check
|
313 |
// captcha check
|
284 |
if (!sprawdz_captcha($_POST)) {
|
314 |
if (!sprawdz_captcha($_POST)) {
|
285 |
echo "<p>BŁĄD: NIEPRAWIDŁOWE CAPTCHA</p>\n";
|
315 |
echo "<p>BŁĄD: NIEPRAWIDŁOWE CAPTCHA</p>\n";
|
286 |
goto DONE;
|
316 |
goto DONE;
|
287 |
}
|
317 |
}
|
288 |
//
|
318 |
//
|
289 |
$thread = time();
|
319 |
$thread = time();
|
290 |
if (empty($_POST['login']) || (empty($_POST['msg'])) || (empty($_POST['title']))) {
|
320 |
if (empty($_POST['login']) || (empty($_POST['msg'])) || (empty($_POST['title']))) {
|
291 |
echo '<p>BŁĄD: pusty nick, wiadomość lub tytuł</p>' . "\n";
|
321 |
echo '<p>BŁĄD: pusty nick, wiadomość lub tytuł</p>' . "\n";
|
292 |
goto DONE;
|
322 |
goto DONE;
|
293 |
}
|
323 |
}
|
294 |
if (!mkdir($DATADIR . 'threads/' . $thread, 0755, true)) {
|
324 |
if (!mkdir($DATADIR . 'threads/' . $thread, 0755, true)) {
|
295 |
echo '<p>BŁĄD: nie zdołano utworzyć wątku nr ' . $thread . "</p>\n";
|
325 |
echo '<p>BŁĄD: nie zdołano utworzyć wątku nr ' . $thread . "</p>\n";
|
296 |
goto DONE;
|
326 |
goto DONE;
|
297 |
}
|
327 |
}
|
298 |
// zapisz tytuł
|
328 |
// zapisz tytuł
|
299 |
file_put_contents($DATADIR . 'threads/' . $thread . '/title.txt', trim($_POST['title']));
|
329 |
file_put_contents($DATADIR . 'threads/' . $thread . '/title.txt', trim($_POST['title']));
|
300 |
// ustaw co trzeba żeby zapisać wiadomość
|
330 |
// ustaw co trzeba żeby zapisać wiadomość
|
301 |
$action = 'newpost';
|
331 |
$action = 'newpost';
|
302 |
}
|
332 |
}
|
303 |
|
333 |
|
304 |
// nowy post do istniejącego wątku
|
334 |
// nowy post do istniejącego wątku
|
305 |
if (($action === 'newpost') && ($thread >= 0) && (!empty($_POST['msg'])) && (!empty($_POST['login']))) {
|
335 |
if (($action === 'newpost') && ($thread >= 0) && (!empty($_POST['msg'])) && (!empty($_POST['login']))) {
|
306 |
$postid = time();
|
336 |
$postid = time();
|
307 |
if (!sprawdz_captcha($_POST)) {
|
337 |
if (!sprawdz_captcha($_POST)) {
|
308 |
$ERRSTR = "BŁĄD: NIEPRAWIDŁOWE CAPTCHA";
|
338 |
$ERRSTR = "BŁĄD: NIEPRAWIDŁOWE CAPTCHA";
|
309 |
goto DONE;
|
339 |
goto DONE;
|
310 |
}
|
340 |
}
|
311 |
// nadpisz lastauthor i lastupdate
|
341 |
// nadpisz lastauthor i lastupdate
|
312 |
$lastupdate = array('lastupdate' => $postid, 'lastauthor' => trim($_POST['login']));
|
342 |
$lastupdate = array('lastupdate' => $postid, 'lastauthor' => trim($_POST['login']));
|
313 |
file_put_contents($DATADIR . 'threads/' . $thread . '/lastupdate', serialize($lastupdate));
|
343 |
file_put_contents($DATADIR . 'threads/' . $thread . '/lastupdate', serialize($lastupdate));
|
314 |
// oblicz tripkod, jeśli hasło zostało ustawione
|
344 |
// oblicz tripkod, jeśli hasło zostało ustawione
|
315 |
$tripsig = '';
|
345 |
$tripsig = '';
|
316 |
if (!empty(trim($_POST['pass']))) {
|
346 |
if (!empty(trim($_POST['pass']))) {
|
317 |
$tripsig = hash('whirlpool', trim($_POST['login']) . '#' . trim($_POST['pass']) . $TRIP_SALT);
|
347 |
$tripsig = hash('whirlpool', trim($_POST['login']) . '#' . trim($_POST['pass']) . $TRIP_SALT);
|
318 |
}
|
348 |
}
|
319 |
// zapisz wiadomość
|
349 |
// zapisz wiadomość
|
320 |
$msg = array('author' => trim($_POST['login']), 'ip' => $_SERVER['REMOTE_ADDR'], 'trip' => $tripsig, 'msg' => trim($_POST['msg']));
|
350 |
$msg = array('author' => trim($_POST['login']), 'ip' => $_SERVER['REMOTE_ADDR'], 'trip' => $tripsig, 'msg' => trim($_POST['msg']));
|
321 |
file_put_contents($DATADIR . 'threads/' . $thread . '/' . $postid, serialize($msg));
|
351 |
file_put_contents($DATADIR . 'threads/' . $thread . '/' . $postid, serialize($msg));
|
322 |
// zaktualizuj metadane dot. ostatniego wpisu, ostatniego autora i ilości wpisów dla tego IP w ciągu ostatniej godziny
|
352 |
// zaktualizuj metadane dot. ostatniego wpisu, ostatniego autora i ilości wpisów dla tego IP w ciągu ostatniej godziny
|
323 |
$db = new SQLite3($DATADIR . 'mateuszbb.sqlite3');
|
353 |
$db = new SQLite3($DATADIR . 'mateuszbb.sqlite3');
|
324 |
if ($db) {
|
354 |
if ($db) {
|
325 |
$db->exec('CREATE TABLE IF NOT EXISTS newest (thread INTEGER PRIMARY KEY, lastupdate INTEGER NOT NULL, lastauthor TEXT NOT NULL);');
|
355 |
$db->exec('CREATE TABLE IF NOT EXISTS newest (thread INTEGER PRIMARY KEY, lastupdate INTEGER NOT NULL, lastauthor TEXT NOT NULL);');
|
326 |
$db->exec('CREATE INDEX IF NOT EXISTS lastupdated ON newest (lastupdate);');
|
356 |
$db->exec('CREATE INDEX IF NOT EXISTS lastupdated ON newest (lastupdate);');
|
327 |
$db->exec('CREATE TABLE IF NOT EXISTS ip_msg_counters24h (threadid INTEGER NOT NULL, msgid INTEGER NOT NULL, ipaddr TEXT NOT NULL);');
|
357 |
$db->exec('CREATE TABLE IF NOT EXISTS ip_msg_counters24h (threadid INTEGER NOT NULL, msgid INTEGER NOT NULL, ipaddr TEXT NOT NULL);');
|
328 |
$db->exec('CREATE TABLE IF NOT EXISTS rss (thread INTEGER NOT NULL, msgid INTEGER NOT NULL, author TEXT NOT NULL);');
|
358 |
$db->exec('CREATE TABLE IF NOT EXISTS rss (thread INTEGER NOT NULL, msgid INTEGER NOT NULL, author TEXT NOT NULL);');
|
329 |
$db->exec('CREATE INDEX IF NOT EXISTS rss_msgid ON rss (msgid);');
|
359 |
$db->exec('CREATE INDEX IF NOT EXISTS rss_msgid ON rss (msgid);');
|
330 |
$login_escaped = $db->escapeString(trim($_POST['login']));
|
360 |
$login_escaped = $db->escapeString(trim($_POST['login']));
|
331 |
$db->exec("INSERT OR REPLACE INTO newest (thread, lastupdate, lastauthor) VALUES ({$thread}, {$postid}, '{$login_escaped}');");
|
361 |
$db->exec("INSERT OR REPLACE INTO newest (thread, lastupdate, lastauthor) VALUES ({$thread}, {$postid}, '{$login_escaped}');");
|
332 |
$db->exec("INSERT INTO rss (thread, msgid, author) VALUES ({$thread}, {$postid}, '{$login_escaped}');");
|
362 |
$db->exec("INSERT INTO rss (thread, msgid, author) VALUES ({$thread}, {$postid}, '{$login_escaped}');");
|
333 |
$db->exec("INSERT INTO ip_msg_counters24h (threadid, msgid, ipaddr) VALUES ({$thread}, {$postid}, '{$_SERVER['REMOTE_ADDR']}');");
|
363 |
$db->exec("INSERT INTO ip_msg_counters24h (threadid, msgid, ipaddr) VALUES ({$thread}, {$postid}, '{$_SERVER['REMOTE_ADDR']}');");
|
334 |
$db->close();
|
364 |
$db->close();
|
335 |
} else {
|
365 |
} else {
|
336 |
echo "SQL ERROR WHILE WRITING STATS\n";
|
366 |
echo "SQL ERROR WHILE WRITING STATS\n";
|
337 |
}
|
367 |
}
|
338 |
// przekieruj
|
368 |
// przekieruj
|
339 |
if ($NICE_URLS) {
|
369 |
if ($NICE_URLS) {
|
340 |
$newurl = "{$thread}#{$postid}";
|
370 |
$newurl = "{$thread}#{$postid}";
|
341 |
} else {
|
371 |
} else {
|
342 |
$newurl = selfurl("thread={$thread}") . "#{$postid}";
|
372 |
$newurl = selfurl("thread={$thread}") . "#{$postid}";
|
343 |
}
|
373 |
}
|
344 |
header("Location: {$newurl}");
|
374 |
header("Location: {$newurl}");
|
345 |
echo "<html><head></head><body><a href=\"{$newurl}\">KLIKNIJ TUTAJ</a></body></html>\n";
|
375 |
echo "<html><head></head><body><a href=\"{$newurl}\">KLIKNIJ TUTAJ</a></body></html>\n";
|
346 |
exit();
|
376 |
exit();
|
347 |
}
|
377 |
}
|
348 |
|
378 |
|
349 |
DONE:
|
379 |
DONE:
|
350 |
|
380 |
|
351 |
}
|
381 |
}
|
352 |
|
382 |
|
353 |
|
383 |
|
354 |
function mateuszbb_tytulwatku($id) {
|
384 |
function mateuszbb_tytulwatku($id) {
|
355 |
global $DATADIR;
|
385 |
global $DATADIR;
|
356 |
return file_get_contents($DATADIR . 'threads/' . $id . '/title.txt');
|
386 |
return file_get_contents($DATADIR . 'threads/' . $id . '/title.txt');
|
357 |
}
|
387 |
}
|
358 |
|
388 |
|
359 |
|
389 |
|
360 |
// wyświetlanie UI itd
|
390 |
// wyświetlanie UI itd
|
361 |
function mateuszbb_start() {
|
391 |
function mateuszbb_start() {
|
362 |
global $TRIP_SALT;
|
392 |
global $TRIP_SALT;
|
363 |
global $ERRSTR;
|
393 |
global $ERRSTR;
|
364 |
global $DATADIR;
|
394 |
global $DATADIR;
|
365 |
global $INITYEAR;
|
395 |
global $INITYEAR;
|
366 |
global $LANG;
|
396 |
global $LANG;
|
367 |
global $STR;
|
397 |
global $STR;
|
368 |
global $NICE_URLS;
|
398 |
global $NICE_URLS;
|
369 |
global $SEARCH_API_URL;
|
399 |
global $SEARCH_API_URL;
|
370 |
|
400 |
|
371 |
// read global variables
|
401 |
// read global variables
|
372 |
$action = getvar_action();
|
402 |
$action = getvar_action();
|
373 |
$thread = getvar_thread();
|
403 |
$thread = getvar_thread();
|
374 |
$archiveyear = getvar_archiveyear();
|
404 |
$archiveyear = getvar_archiveyear();
|
375 |
|
405 |
|
376 |
// wyświetl błąd, jeśli jakiś wystąpił w mateuszbb_preprocess()
|
406 |
// wyświetl błąd, jeśli jakiś wystąpił w mateuszbb_preprocess()
|
377 |
if (!empty($ERRSTR)) {
|
407 |
if (!empty($ERRSTR)) {
|
378 |
echo "<p class=\"minibb-errstr\">{$ERRSTR}</p>\n";
|
408 |
echo "<p class=\"minibb-errstr\">{$ERRSTR}</p>\n";
|
379 |
$action = '';
|
409 |
$action = '';
|
380 |
echo '<p><a href="./">Wróć do głównej strony</a></p>' . "\n";
|
410 |
echo '<p><a href="./">Wróć do głównej strony</a></p>' . "\n";
|
381 |
goto DONE;
|
411 |
goto DONE;
|
382 |
}
|
412 |
}
|
383 |
|
413 |
|
384 |
// szukanie
|
414 |
// szukanie
|
385 |
if (isset($_POST['szukaj']) && (!empty(trim($_POST['szukaj'])))) {
|
415 |
if (isset($_POST['szukaj']) && (!empty(trim($_POST['szukaj'])))) {
|
386 |
$q = trim($_POST['szukaj']);
|
416 |
$q = trim($_POST['szukaj']);
|
387 |
$query = $SEARCH_API_URL . urlencode($q);
|
417 |
$query = $SEARCH_API_URL . urlencode($q);
|
388 |
echo '<p>' . $STR[$LANG]['searchterm'] . ' ' . htmlentities($q) . '</p>';
|
418 |
echo '<p>' . $STR[$LANG]['searchterm'] . ' ' . htmlentities($q) . '</p>';
|
389 |
$results = file_get_contents($query);
|
419 |
$results = file_get_contents($query);
|
390 |
$resarr = json_decode($results, true)['items'];
|
420 |
$resarr = json_decode($results, true)['items'];
|
391 |
|
421 |
|
392 |
$licznik = 0;
|
422 |
$licznik = 0;
|
393 |
foreach ($resarr as $r) {
|
423 |
foreach ($resarr as $r) {
|
394 |
if (mb_substr($r['link'], -1) === '/') continue;
|
424 |
if (mb_substr($r['link'], -1) === '/') continue;
|
395 |
echo '<a href=' . $r['link'] . ' class="minibb-searchresult">';
|
425 |
echo '<a href=' . $r['link'] . ' class="minibb-searchresult">';
|
396 |
echo "<div><h1>{$r['title']}</h1><p>{$r['htmlSnippet']}</p></div></a>\n";
|
426 |
echo "<div><h1>{$r['title']}</h1><p>{$r['htmlSnippet']}</p></div></a>\n";
|
397 |
$licznik++;
|
427 |
$licznik++;
|
398 |
}
|
428 |
}
|
399 |
|
429 |
|
400 |
if ($licznik == 0) echo "<p>" . $STR[$LANG]['noresults'] . "</p>\n";
|
430 |
if ($licznik == 0) echo "<p>" . $STR[$LANG]['noresults'] . "</p>\n";
|
401 |
|
431 |
|
402 |
goto DONE;
|
432 |
goto DONE;
|
403 |
}
|
433 |
}
|
404 |
|
434 |
|
405 |
// new thread form
|
435 |
// new thread form
|
406 |
if ($action === 'newthread') {
|
436 |
if ($action === 'newthread') {
|
407 |
echo '<h2 class="minibb-threadtitle">' . $STR[$LANG]['newthread'] . '</h2>' . "\n";
|
437 |
echo '<h2 class="minibb-threadtitle">' . $STR[$LANG]['newthread'] . '</h2>' . "\n";
|
408 |
formularz();
|
438 |
formularz();
|
409 |
goto DONE;
|
439 |
goto DONE;
|
410 |
}
|
440 |
}
|
411 |
|
441 |
|
412 |
// zobacz listę wątków
|
442 |
// zobacz listę wątków
|
413 |
if ((empty($action)) && ($thread < 0) && ($archiveyear <= 0)) {
|
443 |
if ((empty($action)) && ($thread < 0) && ($archiveyear <= 0)) {
|
414 |
echo '<div class="minibb-toolbar" style="justify-content: space-between;">';
|
444 |
echo '<div class="minibb-toolbar" style="justify-content: space-between;">';
|
415 |
echo '<form action="' . selfurl() . '" method="POST"><input type="text" name="szukaj" placeholder="' . $STR[$LANG]['search'] . '"></form>';
|
445 |
echo '<form action="' . selfurl() . '" method="POST"><input type="text" name="szukaj" placeholder="' . $STR[$LANG]['search'] . '"></form>';
|
416 |
echo '<a href="' . selfurl('action=newthread') . '#formularz">' . $STR[$LANG]['opnewthread'] . '</a>';
|
446 |
echo '<a href="' . selfurl('action=newthread') . '#formularz">' . $STR[$LANG]['opnewthread'] . '</a>';
|
417 |
echo "</div>\n";
|
447 |
echo "</div>\n";
|
418 |
$db = new SQLite3($DATADIR . 'mateuszbb.sqlite3', SQLITE3_OPEN_READONLY);
|
448 |
$db = new SQLite3($DATADIR . 'mateuszbb.sqlite3', SQLITE3_OPEN_READONLY);
|
419 |
if ($db) {
|
449 |
if ($db) {
|
420 |
$sqlres = $db->query('SELECT thread, lastupdate, lastauthor FROM newest ORDER BY lastupdate DESC LIMIT 30;');
|
450 |
$sqlres = $db->query('SELECT thread, lastupdate, lastauthor FROM newest ORDER BY lastupdate DESC LIMIT 30;');
|
421 |
if (!$sqlres) {
|
451 |
if (!$sqlres) {
|
422 |
echo "SQL ERROR\n";
|
452 |
echo "SQL ERROR\n";
|
423 |
} else {
|
453 |
} else {
|
424 |
while ($row = $sqlres->fetchArray()) {
|
454 |
while ($row = $sqlres->fetchArray()) {
|
425 |
$title = mateuszbb_tytulwatku($row['thread']);
|
455 |
$title = mateuszbb_tytulwatku($row['thread']);
|
426 |
if (empty($title)) {
|
456 |
if (empty($title)) {
|
427 |
echo "<!-- BŁĄD: nie zdołano załadować wątku nr {$row['thread']} -->\n";
|
457 |
echo "<!-- BŁĄD: nie zdołano załadować wątku nr {$row['thread']} -->\n";
|
428 |
continue;
|
458 |
continue;
|
429 |
}
|
459 |
}
|
430 |
wyswietl_watek_w_liscie($row['thread'], $title, $row['lastauthor'], $row['lastupdate']);
|
460 |
wyswietl_watek_w_liscie($row['thread'], $title, $row['lastauthor'], $row['lastupdate']);
|
431 |
}
|
461 |
}
|
432 |
}
|
462 |
}
|
433 |
$db->close();
|
463 |
$db->close();
|
434 |
} else {
|
464 |
} else {
|
435 |
echo "<p>BŁĄD DOSTĘPU DO BAZY DANYCH</p>";
|
465 |
echo "<p>BŁĄD DOSTĘPU DO BAZY DANYCH</p>";
|
436 |
}
|
466 |
}
|
437 |
|
467 |
|
438 |
echo '<div style="display: flex; justify-content: space-between; font-size: 0.9em; opacity: 0.8; margin: 0.6em 0.5em 0 0.5em;">' . "\n";
|
468 |
echo '<div style="display: flex; justify-content: space-between; font-size: 0.9em; opacity: 0.8; margin: 0.6em 0.5em 0 0.5em;">' . "\n";
|
439 |
echo '<div>' . $STR[$LANG]['archives'] . ':';
|
469 |
echo '<div>' . $STR[$LANG]['archives'] . ':';
|
440 |
for ($y = $INITYEAR; $y <= intval(gmdate('Y')); $y++) {
|
470 |
for ($y = $INITYEAR; $y <= intval(gmdate('Y')); $y++) {
|
441 |
if ($NICE_URLS) {
|
471 |
if ($NICE_URLS) {
|
442 |
echo " <a href=\"{$y}\">{$y}</a>";
|
472 |
echo " <a href=\"{$y}\">{$y}</a>";
|
443 |
} else {
|
473 |
} else {
|
444 |
echo ' <a href="' . selfurl("arch={$y}") . '">' . $y . '</a>';
|
474 |
echo ' <a href="' . selfurl("arch={$y}") . '">' . $y . '</a>';
|
445 |
}
|
475 |
}
|
446 |
}
|
476 |
}
|
447 |
echo "</div>\n";
|
477 |
echo "</div>\n";
|
448 |
echo '<a href="rss.php"><img style="height: 1em;" src="mateuszbb_rss.svg"></a>' . "\n";
|
478 |
echo '<a href="rss.php"><img style="height: 1em;" src="mateuszbb_rss.svg"></a>' . "\n";
|
449 |
echo "</div>\n";
|
479 |
echo "</div>\n";
|
450 |
|
480 |
|
451 |
// display the main page footer if any is defined
|
481 |
// display the main page footer if any is defined
|
452 |
if (file_exists('mateuszforum-mainfooter.htm')) {
|
482 |
if (file_exists('mateuszforum-mainfooter.htm')) {
|
453 |
readfile('mateuszbb-mainfooter.htm');
|
483 |
readfile('mateuszbb-mainfooter.htm');
|
454 |
}
|
484 |
}
|
455 |
|
485 |
|
456 |
goto DONE;
|
486 |
goto DONE;
|
457 |
}
|
487 |
}
|
458 |
|
488 |
|
459 |
// wyświetl archiwum
|
489 |
// wyświetl archiwum
|
460 |
if ($archiveyear > 0) {
|
490 |
if ($archiveyear > 0) {
|
461 |
echo '<div class="minibb-toolbar" id="title"><a href="' . selfurl() . '">' . $STR[$LANG]['backtocur'] . '</a></div>' . "\n";
|
491 |
echo '<div class="minibb-toolbar" id="title"><a href="' . selfurl() . '">' . $STR[$LANG]['backtocur'] . '</a></div>' . "\n";
|
462 |
echo "<h1>" . $STR[$LANG]['archives'] . " {$archiveyear}</h1>\n";
|
492 |
echo "<h1>" . $STR[$LANG]['archives'] . " {$archiveyear}</h1>\n";
|
463 |
$threads = scandir($DATADIR . 'threads/', SCANDIR_SORT_ASCENDING);
|
493 |
$threads = scandir($DATADIR . 'threads/', SCANDIR_SORT_ASCENDING);
|
464 |
foreach ($threads as $t) {
|
494 |
foreach ($threads as $t) {
|
465 |
if (!preg_match('/^[0-9][0-9]*$/', $t)) continue; // skip anything that is not a thread id
|
495 |
if (!preg_match('/^[0-9][0-9]*$/', $t)) continue; // skip anything that is not a thread id
|
466 |
if (intval(gmdate('Y', $t)) != $archiveyear) continue; // skip threads out of the targeted year
|
496 |
if (intval(gmdate('Y', $t)) != $archiveyear) continue; // skip threads out of the targeted year
|
467 |
$title = file_get_contents($DATADIR . 'threads/' . $t . '/title.txt');
|
497 |
$title = file_get_contents($DATADIR . 'threads/' . $t . '/title.txt');
|
468 |
$link = $t;
|
498 |
$link = $t;
|
469 |
if (! $NICE_URLS) $link = selfurl("thread={$t}");
|
499 |
if (! $NICE_URLS) $link = selfurl("thread={$t}");
|
470 |
echo '<span style="font-family: monospace;">[' . gmdate("Y-m-d", $t) . "]</span> <a href=\"{$link}\">{$title}</a><br>\n";
|
500 |
echo '<span style="font-family: monospace;">[' . gmdate("Y-m-d", $t) . "]</span> <a href=\"{$link}\">{$title}</a><br>\n";
|
471 |
}
|
501 |
}
|
472 |
goto DONE;
|
502 |
goto DONE;
|
473 |
}
|
503 |
}
|
474 |
|
504 |
|
475 |
// zobacz wątek
|
505 |
// zobacz wątek
|
476 |
if ((empty($action)) && ($thread >= 0)) {
|
506 |
if ((empty($action)) && ($thread >= 0)) {
|
477 |
// załaduj listę postów (i zapamiętaj ostatnią pozycję)
|
507 |
// załaduj listę postów (i zapamiętaj ostatnią pozycję)
|
478 |
$listapostow = scandir($DATADIR . 'threads/' . $thread . '/');
|
508 |
$listapostow = scandir($DATADIR . 'threads/' . $thread . '/');
|
479 |
// usuń pozycje które nie są żadnym msgid (np. title.txt) i zapamiętaj ostatni msgid
|
509 |
// usuń pozycje które nie są żadnym msgid (np. title.txt) i zapamiętaj ostatni msgid
|
480 |
$posty = array();
|
510 |
$posty = array();
|
481 |
foreach ($listapostow as $p) {
|
511 |
foreach ($listapostow as $p) {
|
482 |
if (!preg_match('/^[0-9][0-9]*$/', $p)) continue; // skip anything that is not a messageid
|
512 |
if (!preg_match('/^[0-9][0-9]*$/', $p)) continue; // skip anything that is not a messageid
|
483 |
$posty[] = $p;
|
513 |
$posty[] = $p;
|
484 |
$ostatnipost = $p;
|
514 |
$ostatnipost = $p;
|
485 |
}
|
515 |
}
|
486 |
// toolbar (ostatni wątek / odpowiedz / powrót do forum)
|
516 |
// toolbar (ostatni wątek / odpowiedz / powrót do forum)
|
487 |
echo '<div class="minibb-toolbar" id="title">';
|
517 |
echo '<div class="minibb-toolbar" id="title">';
|
488 |
echo '<a href="#' . $ostatnipost . '">' . $STR[$LANG]['jumptoend'] . '</a> <a href="#formularz">' . $STR[$LANG]['reply'] . '</a> <a href="' . selfurl() . '">' . $STR[$LANG]['listthreads'] . '</a></div>' . "\n";
|
518 |
echo '<a href="#' . $ostatnipost . '">' . $STR[$LANG]['jumptoend'] . '</a> <a href="#formularz">' . $STR[$LANG]['reply'] . '</a> <a href="' . selfurl() . '">' . $STR[$LANG]['listthreads'] . '</a></div>' . "\n";
|
489 |
// wyświetl tytuł wątku
|
519 |
// wyświetl tytuł wątku
|
490 |
echo '<h2 class="minibb-threadtitle">' . htmlspecialchars(file_get_contents($DATADIR . 'threads/' . $thread . '/title.txt')) . "</h2>\n";
|
520 |
echo '<h2 class="minibb-threadtitle">' . htmlspecialchars(file_get_contents($DATADIR . 'threads/' . $thread . '/title.txt')) . "</h2>\n";
|
491 |
// wyświetl listę wątków
|
521 |
// wyświetl listę wątków
|
492 |
foreach ($posty as $p) {
|
522 |
foreach ($posty as $p) {
|
493 |
$msg = unserialize(file_get_contents($DATADIR . 'threads/' . $thread . '/' . $p));
|
523 |
$msg = unserialize(file_get_contents($DATADIR . 'threads/' . $thread . '/' . $p));
|
494 |
echo '<div class="minibb-post" id="' . $p . '">' . "\n";
|
524 |
echo '<div class="minibb-post" id="' . $p . '">' . "\n";
|
495 |
echo '<div class="minibb-postheader"><a href="#' . $p . '" style="text-decoration: inherit; color: inherit;"><div class="minibb-postauthor">' . "\n";
|
525 |
echo '<div class="minibb-postheader"><a href="#' . $p . '" style="text-decoration: inherit; color: inherit;"><div class="minibb-postauthor">' . "\n";
|
496 |
echo $STR[$LANG]['author'] . ' ' . htmlspecialchars($msg['author']) . "<br>\n";
|
526 |
echo $STR[$LANG]['author'] . ' ' . htmlspecialchars($msg['author']) . "<br>\n";
|
497 |
echo $STR[$LANG]['address'] . ' ' . htmlspecialchars($msg['ip']) . "<br>\n";
|
527 |
echo $STR[$LANG]['address'] . ' ' . htmlspecialchars($msg['ip']) . "<br>\n";
|
498 |
echo $STR[$LANG]['date'] . ' ' . htmlspecialchars(data_dluga($p)) . "</div></a>\n";
|
528 |
echo $STR[$LANG]['date'] . ' ' . htmlspecialchars(data_dluga($p)) . "</div></a>\n";
|
499 |
if (!empty($msg['trip'])) {
|
529 |
if (!empty($msg['trip'])) {
|
500 |
echo '<div class="minibb-trip">';
|
530 |
echo '<div class="minibb-trip">';
|
501 |
echo chunk_split($msg['trip'], 16, "\n");
|
531 |
echo chunk_split($msg['trip'], 16, "\n");
|
502 |
echo "</div>\n";
|
532 |
echo "</div>\n";
|
503 |
}
|
533 |
}
|
504 |
echo "</div>\n";
|
534 |
echo "</div>\n";
|
505 |
|
535 |
|
506 |
// symbole html
|
536 |
// symbole html
|
507 |
$bodyprocessed = htmlspecialchars($msg['msg']);
|
537 |
$bodyprocessed = htmlspecialchars($msg['msg']);
|
508 |
|
538 |
|
509 |
// dodaj podgląd pod linki do obrazków, ale tylko jeśli link jest sam w linijce
|
539 |
// dodaj podgląd pod linki do obrazków, ale tylko jeśli link jest sam w linijce
|
510 |
$bodyprocessed = preg_replace('~^(http[s]?://[^<>[:space:]]+[[:alnum:]/]\.(jpg|png))($|[\r\n])~m', "$1\n<img src=\"$1\">\n", $bodyprocessed);
|
540 |
$bodyprocessed = preg_replace('~^(http[s]?://[^<>[:space:]]+[[:alnum:]/]\.(jpg|png))($|[\r\n])~m', "$1\n<img src=\"$1\">\n", $bodyprocessed);
|
511 |
|
541 |
|
512 |
// olinkuj linki
|
542 |
// olinkuj linki
|
513 |
$bodyprocessed = preg_replace("~([^\"]|^)(http[s]?://[^<>[:space:]]+[[:alnum:]/])~", "$1<a href=\"$2\">$2</a>", $bodyprocessed);
|
543 |
$bodyprocessed = preg_replace("~([^\"]|^)(http[s]?://[^<>[:space:]]+[[:alnum:]/])~", "$1<a href=\"$2\">$2</a>", $bodyprocessed);
|
514 |
|
544 |
|
515 |
// oflaguj cytaty (linijki zaczynające się od ">")
|
545 |
// oflaguj cytaty (linijki zaczynające się od ">")
|
516 |
$bodyprocessed = preg_replace('/^(> .*)[\r]?\n/m', '<blockquote>$1</blockquote>', $bodyprocessed);
|
546 |
$bodyprocessed = preg_replace('/^(> .*)[\r]?\n/m', '<blockquote>$1</blockquote>', $bodyprocessed);
|
517 |
|
547 |
|
518 |
echo '<div class="minibb-postbody">' . $bodyprocessed . '</div>' . "\n";
|
548 |
echo '<div class="minibb-postbody">' . $bodyprocessed . '</div>' . "\n";
|
519 |
echo "</div>\n";
|
549 |
echo "</div>\n";
|
520 |
}
|
550 |
}
|
521 |
// formularz odpowiedzi i do domu
|
551 |
// formularz odpowiedzi i do domu
|
522 |
formularz($thread);
|
552 |
formularz($thread);
|
523 |
goto DONE;
|
553 |
goto DONE;
|
524 |
}
|
554 |
}
|
525 |
|
555 |
|
526 |
DONE:
|
556 |
DONE:
|
527 |
}
|
557 |
}
|
528 |
?>
|
558 |
?>
|
529 |
|
559 |
|