Subversion Repositories SvarDOS

Rev

Rev 2000 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2000 Rev 2003
Line 1... Line 1...
1
<?php
1
<?php
2
//
2
//
3
// mateuszbb - minimalist bulletin board forum. MIT license.
3
// mateuszbb - minimalist bulletin board forum. MIT license.
4
//
4
//
5
// VERSION 20240906
5
// VERSION 20240909
6
//
6
//
7
// Copyright (C) 2021-2024 Mateusz Viste
7
// Copyright (C) 2021-2024 Mateusz Viste
8
//
8
//
9
// Permission is hereby granted, free of charge, to any person obtaining a copy
9
// Permission is hereby granted, free of charge, to any person obtaining a copy
10
// of this software and associated documentation files (the “Software”), to
10
// of this software and associated documentation files (the “Software”), to
Line 70... Line 70...
70
$STR['en']['captcha'][1]  = 'check the FIRST box';
70
$STR['en']['captcha'][1]  = 'check the FIRST box';
71
$STR['en']['captcha'][2]  = 'check the MIDDLE box';
71
$STR['en']['captcha'][2]  = 'check the MIDDLE box';
72
$STR['en']['captcha'][3]  = 'check the LAST box';
72
$STR['en']['captcha'][3]  = 'check the LAST box';
73
$STR['en']['captcha'][4]  = 'check the FIRST and LAST boxes';
73
$STR['en']['captcha'][4]  = 'check the FIRST and LAST boxes';
74
$STR['en']['captcha'][5]  = 'check the TWO LAST boxes';
74
$STR['en']['captcha'][5]  = 'check the TWO LAST boxes';
-
 
75
$STR['en']['msglimit'] = "At most {$MAXDAILYPOSTS} messages are allowed from any single IP address for a period of 24h. This limit has been reached for your IP address. Please try again later.";
75
 
76
 
76
// DE translations by Robert Riebisch
77
// DE translations by Robert Riebisch
77
$STR['de']['opnewthread'] = 'Neues Thema eröffnen';
78
$STR['de']['opnewthread'] = 'Neues Thema eröffnen';
78
$STR['de']['newthread']   = 'Neues Thema';
79
$STR['de']['newthread']   = 'Neues Thema';
79
$STR['de']['latestentry'] = 'Neuester Eintrag:';
80
$STR['de']['latestentry'] = 'Neuester Eintrag:';
Line 130... Line 131...
130
$STR['pl']['captcha'][1]  = 'zaznacz PIERWSZE pole';
131
$STR['pl']['captcha'][1]  = 'zaznacz PIERWSZE pole';
131
$STR['pl']['captcha'][2]  = 'zaznacz ŚRODKOWE pole';
132
$STR['pl']['captcha'][2]  = 'zaznacz ŚRODKOWE pole';
132
$STR['pl']['captcha'][3]  = 'zaznacz OSTATNIE pole';
133
$STR['pl']['captcha'][3]  = 'zaznacz OSTATNIE pole';
133
$STR['pl']['captcha'][4]  = 'zaznacz PIERWSZE i OSTATNIE pole';
134
$STR['pl']['captcha'][4]  = 'zaznacz PIERWSZE i OSTATNIE pole';
134
$STR['pl']['captcha'][5]  = 'zaznacz DWA OSTATNIE pola';
135
$STR['pl']['captcha'][5]  = 'zaznacz DWA OSTATNIE pola';
-
 
136
$STR['pl']['msglimit'] = "Dopuszcza się maksymalnie {$MAXDAILYPOSTS} postów w ciągu 24h. Ten limit został już osiągnięty dla twojego adresu IP. Spróbuj ponownie za jakiś czas.";
135
 
137
 
136
// pt-BR translations courtesty of Luzemário Dantas
138
// pt-BR translations courtesty of Luzemário Dantas
137
$STR['pt']['opnewthread'] = 'abrir novo tópico';
139
$STR['pt']['opnewthread'] = 'abrir novo tópico';
138
$STR['pt']['newthread']   = 'Novo tópico';
140
$STR['pt']['newthread']   = 'Novo tópico';
139
$STR['pt']['latestentry'] = 'entrada mais recente:';
141
$STR['pt']['latestentry'] = 'entrada mais recente:';
Line 214... Line 216...
214
  if (! $sqlres) {
216
  if (! $sqlres) {
215
    echo "SQL ERROR: QUERY FAILED\n";
217
    echo "SQL ERROR: QUERY FAILED\n";
216
    return false;
218
    return false;
217
  }
219
  }
218
 
220
 
219
  header('content-type: application/rss+xml');
221
  header('content-type: text/xml');
220
 
222
 
221
  echo '<?xml version="1.0" encoding="utf-8" ?>' . "\n";
223
  echo '<?xml version="1.0" encoding="utf-8" ?>' . "\n";
222
  echo '<rss version="2.0">' . "\n";
224
  echo '<rss version="2.0">' . "\n";
223
  echo "<channel>\n";
225
  echo "<channel>\n";
224
  echo "<title>" . htmlspecialchars($RSS_TITLE, ENT_XML1) . "</title>\n";
226
  echo "<title>" . htmlspecialchars($RSS_TITLE, ENT_XML1) . "</title>\n";
Line 234... Line 236...
234
    // AUTHOR
236
    // AUTHOR
235
    $author = htmlspecialchars($row['author'], ENT_XML1, 'UTF-8');
237
    $author = htmlspecialchars($row['author'], ENT_XML1, 'UTF-8');
236
 
238
 
237
    // CONTENT
239
    // CONTENT
238
    $rawcontent = loadmsg($row['thread'], $row['msgid'])['msg'];
240
    $rawcontent = loadmsg($row['thread'], $row['msgid'])['msg'];
-
 
241
    // remove all quoted lines
-
 
242
    $rawcontent = preg_replace('/^>.*/m', '(...)', $rawcontent);
-
 
243
    // trim out whitespaces
-
 
244
    $rawcontent = trim($rawcontent);
-
 
245
    // shorten the message to 256 chars
239
    $rawcontent_shorter =  mb_substr($rawcontent, 0, 256);
246
    $rawcontent_shorter =  mb_substr($rawcontent, 0, 256);
240
    if (strlen($rawcontent) > strlen($rawcontent_shorter)) $rawcontent_shorter .= " (...)";
247
    if (strlen($rawcontent) > strlen($rawcontent_shorter)) $rawcontent_shorter .= " (...)";
-
 
248
    // escape xml chars
241
    $content = htmlspecialchars($rawcontent_shorter, ENT_XHTML, 'UTF-8');
249
    $content = htmlspecialchars($rawcontent_shorter, ENT_XHTML, 'UTF-8');
-
 
250
    // remove all newlines (replace by a space)
-
 
251
    $content = str_replace(array("\r\n", "\r"), "\n", $content);
-
 
252
    $content = str_replace(array("\n\n\n\n", "\n\n\n", "\n\n"), ' ', $content);
242
 
253
 
243
    // LINK
254
    // LINK
244
    if ($NICE_URLS) {
255
    if ($NICE_URLS) {
245
      $link = selfurl();
256
      $link = selfurl();
246
      if (substr($link, -1) !== '/') $link .= '/';
257
      if (substr($link, -1) !== '/') $link .= '/';
Line 412... Line 423...
412
  if ($db) {
423
  if ($db) {
413
    $db->exec('DELETE FROM ip_msg_counters24h WHERE msgid < strftime(\'%s\', \'now\') - 24*3600;');
424
    $db->exec('DELETE FROM ip_msg_counters24h WHERE msgid < strftime(\'%s\', \'now\') - 24*3600;');
414
    $count24h = intval($db->querySingle("SELECT count(*) FROM ip_msg_counters24h WHERE ipaddr = '{$_SERVER['REMOTE_ADDR']}'"));
425
    $count24h = intval($db->querySingle("SELECT count(*) FROM ip_msg_counters24h WHERE ipaddr = '{$_SERVER['REMOTE_ADDR']}'"));
415
    $db->close();
426
    $db->close();
416
    if ($count24h >= $MAXDAILYPOSTS) {
427
    if ($count24h >= $MAXDAILYPOSTS) {
417
      $ERRSTR = "BŁĄD: Z TWOJEGO ADRESU NAPISANO JUŻ {$count24h} WIADOMOŚCI W PRZECIĄGU OSTATNICH 24H. SPRÓBUJ PONOWNIE ZA JAKIŚ CZAS.";
428
      $ERRSTR = $STR[$LANG]['msglimit'];
418
      $action = '';
429
      $action = '';
419
    }
430
    }
420
  }
431
  }
421
}
432
}
422
 
433
 
Line 531... Line 542...
531
// leaf array represents one thread
542
// leaf array represents one thread
532
function mateuszbb_getactivethreads($n, $maxinact = -1) {
543
function mateuszbb_getactivethreads($n, $maxinact = -1) {
533
  global $DATADIR;
544
  global $DATADIR;
534
  $result = array();
545
  $result = array();
535
 
546
 
-
 
547
  try { /* some versions of sqlite throw an exception if db does not exist, while other versions simply return false */
536
  $db = new SQLite3($DATADIR . 'mateuszbb.sqlite3', SQLITE3_OPEN_READONLY);
548
    $db = new SQLite3($DATADIR . 'mateuszbb.sqlite3', SQLITE3_OPEN_READONLY);
-
 
549
  } catch (Exception $e) {
-
 
550
    return(false);
-
 
551
  }
537
  if (! $db) return(false);
552
  if (! $db) return(false);
538
 
553
 
539
  $minupdatedate = 0;
554
  $minupdatedate = 0;
540
  if ($maxinact >= 0) $minupdatedate = time() - (intval($maxinact) * 86400);
555
  if ($maxinact >= 0) $minupdatedate = time() - (intval($maxinact) * 86400);
541
 
556
 
Line 602... Line 617...
602
 
617
 
603
// wyświetl błąd, jeśli jakiś wystąpił w mateuszbb_preprocess()
618
// wyświetl błąd, jeśli jakiś wystąpił w mateuszbb_preprocess()
604
if (!empty($ERRSTR)) {
619
if (!empty($ERRSTR)) {
605
  echo "<p class=\"minibb-errstr\">{$ERRSTR}</p>\n";
620
  echo "<p class=\"minibb-errstr\">{$ERRSTR}</p>\n";
606
  $action = '';
621
  $action = '';
-
 
622
  goto DONE;
-
 
623
}
-
 
624
 
-
 
625
// upewnij się że sqlite3 jest dostępny
-
 
626
if (!extension_loaded('sqlite3')) {
607
  echo '<p><a href="./">Wróć do głównej strony</a></p>' . "\n";
627
  echo "<p class=\"minibb-errstr\">SQLITE3 extension not found</p>\n";
-
 
628
  $action = '';
608
  goto DONE;
629
  goto DONE;
609
}
630
}
610
 
631
 
611
// szukanie
632
// szukanie
612
if (isset($_POST['szukaj']) && (!empty(trim($_POST['szukaj'])))) {
633
if (isset($_POST['szukaj']) && (!empty(trim($_POST['szukaj'])))) {