├── data
├── epx.png
├── fsmileys.png
├── pwrd_mysql.png
├── pwrd_perl.png
├── pwrd_pgsql.png
├── buttonicons.png
├── pwrd_apache.png
├── pwrd_mariadb.png
├── pwrd_modperl.png
├── pwrd_sqlite.png
├── default2
│ └── icons.png
├── pwrd_lighttpd.png
└── google.js
├── example
├── script.htaccess
├── opensearch.xml
├── attach.htaccess
├── MwfPlgAuthz.pm
├── MwfPlgMsgDisplay.pm
└── MwfPlgEvent.pm
├── script
├── MwfConfigGlobalDefault.pm
├── user_logout.pl
├── note_delete.pl
├── group_add.pl
├── forum.pl
├── user_delete.pl
├── categ_add.pl
├── chat_delete.pl
├── ajax_dataversion.pl
├── ajax_usernames.pl
├── categ_delete.pl
├── report_delete.pl
├── board_add.pl
├── topic_stick.pl
├── forum_help.pl
├── user_unsubscribe.pl
├── post_lock.pl
├── topic_lock.pl
├── group_delete.pl
├── board_delete.pl
├── spawn_test.pl
├── chat_add.pl
├── categ_toggle.pl
├── forum_feeds.pl
├── post_like.pl
├── ajax_check.pl
├── post_approve.pl
├── MwfConfigDefault.pm
├── categ_admin.pl
├── branch_delete.pl
├── poll_delete.pl
├── log_delete.pl
├── user_ticket.pl
├── forum_policy.pl
├── group_admin.pl
├── topic_delete.pl
├── poll_lock.pl
├── branch_lock.pl
├── user_notify.pl
├── message_delete.pl
├── attach_show.pl
├── cron_admin.pl
├── topic_info.pl
├── user_mark.pl
├── user_wipe.pl
├── chat_show.pl
├── message_export.pl
├── post_delete.pl
├── board_archive.pl
├── board_merge.pl
├── user_confirm.pl
├── spawn_upgrade.pl
├── user_migrate.pl
├── user_set.pl
├── forum_activity.pl
├── user_name.pl
├── user_countries.pl
├── user_password.pl
├── categ_options.pl
├── cron_bounce.pl
└── report_list.pl
├── doc
└── doc.css
└── util
├── util_groupconcat4pg.sql
├── util_deleteusers.pl
├── util_tables2engine.sql
├── util_citext.pl
├── util_text2medium.sql
├── util_fixtablecase.sql
├── util_fixcharset.pl
├── util_replace.pl
└── util_cleancfg.pl
/data/epx.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/quit/mwForum/master/data/epx.png
--------------------------------------------------------------------------------
/data/fsmileys.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/quit/mwForum/master/data/fsmileys.png
--------------------------------------------------------------------------------
/data/pwrd_mysql.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/quit/mwForum/master/data/pwrd_mysql.png
--------------------------------------------------------------------------------
/data/pwrd_perl.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/quit/mwForum/master/data/pwrd_perl.png
--------------------------------------------------------------------------------
/data/pwrd_pgsql.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/quit/mwForum/master/data/pwrd_pgsql.png
--------------------------------------------------------------------------------
/data/buttonicons.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/quit/mwForum/master/data/buttonicons.png
--------------------------------------------------------------------------------
/data/pwrd_apache.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/quit/mwForum/master/data/pwrd_apache.png
--------------------------------------------------------------------------------
/data/pwrd_mariadb.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/quit/mwForum/master/data/pwrd_mariadb.png
--------------------------------------------------------------------------------
/data/pwrd_modperl.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/quit/mwForum/master/data/pwrd_modperl.png
--------------------------------------------------------------------------------
/data/pwrd_sqlite.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/quit/mwForum/master/data/pwrd_sqlite.png
--------------------------------------------------------------------------------
/data/default2/icons.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/quit/mwForum/master/data/default2/icons.png
--------------------------------------------------------------------------------
/data/pwrd_lighttpd.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/quit/mwForum/master/data/pwrd_lighttpd.png
--------------------------------------------------------------------------------
/example/script.htaccess:
--------------------------------------------------------------------------------
1 | # Disable browsing this directory
2 |
3 | Options -Indexes
4 |
5 | # Deny downloading of Perl modules
6 |
7 |
8 | Order allow,deny
9 | Deny from all
10 |
11 |
--------------------------------------------------------------------------------
/example/opensearch.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | Example Forum
4 | Search the Example forum.
5 |
6 | http://www.example.org/favicon.ico
7 | utf-8
8 | utf-8
9 |
10 |
--------------------------------------------------------------------------------
/script/MwfConfigGlobalDefault.pm:
--------------------------------------------------------------------------------
1 | package MwfConfigGlobal;
2 | use strict;
3 | use warnings;
4 | our ($VERSION, $gcfg);
5 | $VERSION = "2.23.0";
6 |
7 | #------------------------------------------------------------------------------
8 | # Multi-forum options
9 | # Only touch if you want to use the multi-forum support. See FAQ.html.
10 |
11 | # Map hostnames or URL paths to forums
12 | #$gcfg->{forums} = {
13 | # 'foo.example.com' => 'MwfConfigFoo',
14 | # 'bar.example.com' => 'MwfConfigBar',
15 | #};
16 | #$gcfg->{forums} = {
17 | # '/perl/foo' => 'MwfConfigFoo',
18 | # '/perl/bar' => 'MwfConfigBar',
19 | #};
20 |
21 | # Database name of one of the used databases under MySQL
22 | #$gcfg->{dbName} = "";
23 |
24 | #-----------------------------------------------------------------------------
25 | # Advanced options
26 |
27 | # Print page creation time?
28 | # Measures runtime, not CPU-time and not overhead like compilation time.
29 | $gcfg->{pageTime} = 0;
30 |
31 | # Script filename extension
32 | $gcfg->{ext} = ".pl";
33 |
34 | #-----------------------------------------------------------------------------
35 | # Return OK
36 | 1;
37 |
--------------------------------------------------------------------------------
/doc/doc.css:
--------------------------------------------------------------------------------
1 | body {
2 | background-color: white;
3 | font-family: verdana, sans-serif;
4 | font-size: 13px;
5 | }
6 |
7 | h1, h2, h3, h4 {
8 | font-family: arial, sans-serif;
9 | }
10 |
11 | h2 {
12 | margin-top: 30px;
13 | border-top: 1px solid black;
14 | padding-top: 10px;
15 | }
16 |
17 | h3, h4 {
18 | margin-left: 15px;
19 | }
20 |
21 | code, samp, kbd, var, dl.ids dt {
22 | font-family: 'andale mono', monospace;
23 | font-size: 12px;
24 | }
25 |
26 | var {
27 | white-space: nowrap;
28 | }
29 |
30 | code {
31 | color: teal;
32 | }
33 |
34 | samp {
35 | color: maroon;
36 | }
37 |
38 | kbd {
39 | color: green;
40 | }
41 |
42 | var, dl.ids dt {
43 | color: gray;
44 | font-style: normal;
45 | }
46 |
47 | p {
48 | margin-left: 15px;
49 | margin-right: 15px;
50 | }
51 |
52 | pre {
53 | margin-left: 30px;
54 | margin-top: -1em;
55 | }
56 |
57 | ul.ext li, ol.ext li {
58 | margin-top: 1em;
59 | margin-bottom: 1em;
60 | }
61 |
62 | li pre {
63 | margin-left: 15px;
64 | margin-top: 0;
65 | }
66 |
67 | blockquote {
68 | font-style: italic;
69 | }
70 |
71 | a {
72 | text-decoration: none;
73 | }
74 |
75 | dt {
76 | margin: 10px 15px 0 30px;
77 | }
78 |
79 | dd {
80 | margin: 0 15px 0 45px;
81 | }
82 |
--------------------------------------------------------------------------------
/script/user_logout.pl:
--------------------------------------------------------------------------------
1 | #!/usr/bin/perl
2 | #------------------------------------------------------------------------------
3 | # mwForum - Web-based discussion forum
4 | # Copyright (c) 1999-2015 Markus Wichitill
5 | #
6 | # This program is free software; you can redistribute it and/or modify
7 | # it under the terms of the GNU General Public License as published by
8 | # the Free Software Foundation; either version 3 of the License, or
9 | # (at your option) any later version.
10 | #
11 | # This program is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | # GNU General Public License for more details.
15 | #------------------------------------------------------------------------------
16 |
17 | use strict;
18 | use warnings;
19 | no warnings qw(uninitialized redefine);
20 |
21 | # Imports
22 | use MwfMain;
23 |
24 | #------------------------------------------------------------------------------
25 |
26 | # Init
27 | my ($m, $cfg, $lng, $user, $userId) = MwfMain->new($_[0], allowBanned => 1);
28 |
29 | if ($userId) {
30 | # Check request source authentication
31 | $m->checkSourceAuth() or $m->error('errSrcAuth');
32 |
33 | # Remove id/pwd cookies
34 | $m->deleteCookie('login');
35 | }
36 |
37 | # Log action and finish
38 | $m->logAction(1, 'user', 'logout', $userId);
39 | $m->redirect('forum_show');
40 |
--------------------------------------------------------------------------------
/example/attach.htaccess:
--------------------------------------------------------------------------------
1 | # Force downloading of attachments instead of opening them in website context,
2 | # which can be very dangerous, allowing account hijacking etc. Does not have any
3 | # effect on embedded images. Very important.
4 |
5 | Header set Content-Disposition "attachment"
6 | Header set X-Download-Options "noopen"
7 |
8 | # Disable execution via CGI, PHP etc. Very important.
9 |
10 | Options -ExecCGI
11 | SetHandler default-handler
12 |
13 | # Disable browsing this directory. Always recommended, since there are so many
14 | # useless bots out there that download everything in their way.
15 | # Very important if you have private boards with attachments that are supposed
16 | # to be secret.
17 |
18 | Options -Indexes
19 |
20 | # Treat files with unregistered extensions as binary files.
21 | # Helps against "alphabet soup" downloads. Not very important.
22 |
23 | DefaultType application/octet-stream
24 |
25 | # Set more specific MIME types for feeds. Not important.
26 |
27 |
28 | ForceType application/atom+xml
29 |
30 |
31 | ForceType application/rss+xml
32 |
33 |
34 | # Block access to OpenID cache.
35 |
36 |
37 | Deny from all
38 |
39 |
40 | # Block access to PGP user keyrings. They only contain public keys, though,
41 | # so this is usually unnecessary.
42 |
43 |
44 | Deny from all
45 |
46 |
--------------------------------------------------------------------------------
/script/note_delete.pl:
--------------------------------------------------------------------------------
1 | #!/usr/bin/perl
2 | #------------------------------------------------------------------------------
3 | # mwForum - Web-based discussion forum
4 | # Copyright (c) 1999-2015 Markus Wichitill
5 | #
6 | # This program is free software; you can redistribute it and/or modify
7 | # it under the terms of the GNU General Public License as published by
8 | # the Free Software Foundation; either version 3 of the License, or
9 | # (at your option) any later version.
10 | #
11 | # This program is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | # GNU General Public License for more details.
15 | #------------------------------------------------------------------------------
16 |
17 | use strict;
18 | use warnings;
19 | no warnings qw(uninitialized redefine);
20 |
21 | # Imports
22 | use MwfMain;
23 |
24 | #------------------------------------------------------------------------------
25 |
26 | # Init
27 | my ($m, $cfg, $lng, $user, $userId) = MwfMain->new($_[0]);
28 |
29 | # Check if access should be denied
30 | $userId or $m->error('errNoAccess');
31 |
32 | # Check request source authentication
33 | $m->checkSourceAuth() or $m->error('errSrcAuth');
34 |
35 | # Delete notifications
36 | $m->dbDo("
37 | DELETE FROM notes WHERE userId = ?", $userId);
38 |
39 | # Log action and finish
40 | $m->logAction(1, 'note', 'delete', $userId);
41 | $m->redirect('forum_show', msg => 'NotesDel');
42 |
--------------------------------------------------------------------------------
/script/group_add.pl:
--------------------------------------------------------------------------------
1 | #!/usr/bin/perl
2 | #------------------------------------------------------------------------------
3 | # mwForum - Web-based discussion forum
4 | # Copyright (c) 1999-2015 Markus Wichitill
5 | #
6 | # This program is free software; you can redistribute it and/or modify
7 | # it under the terms of the GNU General Public License as published by
8 | # the Free Software Foundation; either version 3 of the License, or
9 | # (at your option) any later version.
10 | #
11 | # This program is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | # GNU General Public License for more details.
15 | #------------------------------------------------------------------------------
16 |
17 | use strict;
18 | use warnings;
19 | no warnings qw(uninitialized redefine);
20 |
21 | # Imports
22 | use MwfMain;
23 |
24 | #------------------------------------------------------------------------------
25 |
26 | # Init
27 | my ($m, $cfg, $lng, $user, $userId) = MwfMain->new($_[0]);
28 |
29 | # Check if user is admin
30 | $user->{admin} or $m->error('errNoAccess');
31 |
32 | # Check request source authentication
33 | $m->checkSourceAuth() or $m->error('errSrcAuth');
34 |
35 | # Insert new group
36 | $m->dbDo("
37 | INSERT INTO groups (title) VALUES (?)",
38 | "New Group");
39 | my $groupId = $m->dbInsertId("groups");
40 |
41 | # Log action and finish
42 | $m->logAction(1, 'group', 'add', $userId, 0, 0, 0, $groupId);
43 | $m->redirect('group_options', gid => $groupId);
44 |
--------------------------------------------------------------------------------
/util/util_groupconcat4pg.sql:
--------------------------------------------------------------------------------
1 | -------------------------------------------------------------------------------
2 | -- mwForum - Web-based discussion forum
3 | -- Copyright (c) 1999-2015 Markus Wichitill
4 | --
5 | -- This program is free software; you can redistribute it and/or modify
6 | -- it under the terms of the GNU General Public License as published by
7 | -- the Free Software Foundation; either version 3 of the License, or
8 | -- (at your option) any later version.
9 | --
10 | -- This program is distributed in the hope that it will be useful,
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | -- GNU General Public License for more details.
14 | -------------------------------------------------------------------------------
15 |
16 | CREATE OR REPLACE FUNCTION group_concat_sfunc(TEXT, INTEGER)
17 | RETURNS TEXT AS $$
18 | SELECT CASE
19 | WHEN $2 IS NULL THEN $1
20 | WHEN $1 IS NULL THEN $2::TEXT
21 | ELSE $1 || ',' || $2::TEXT
22 | END
23 | $$ LANGUAGE SQL IMMUTABLE;
24 |
25 | CREATE OR REPLACE FUNCTION group_concat_sfunc(TEXT, TEXT)
26 | RETURNS TEXT AS $$
27 | SELECT CASE
28 | WHEN $2 IS NULL THEN $1
29 | WHEN $1 IS NULL THEN $2
30 | ELSE $1 || ',' || $2
31 | END
32 | $$ LANGUAGE SQL IMMUTABLE;
33 |
34 | DROP AGGREGATE IF EXISTS group_concat(INTEGER);
35 | CREATE AGGREGATE group_concat(INTEGER) (
36 | STYPE = TEXT,
37 | SFUNC = group_concat_sfunc
38 | );
39 |
40 | DROP AGGREGATE IF EXISTS group_concat(TEXT);
41 | CREATE AGGREGATE group_concat(TEXT) (
42 | STYPE = TEXT,
43 | SFUNC = group_concat_sfunc
44 | );
45 |
--------------------------------------------------------------------------------
/script/forum.pl:
--------------------------------------------------------------------------------
1 | #!/usr/bin/perl
2 | #------------------------------------------------------------------------------
3 | # mwForum - Web-based discussion forum
4 | # Copyright (c) 1999-2015 Markus Wichitill
5 | #
6 | # This program is free software; you can redistribute it and/or modify
7 | # it under the terms of the GNU General Public License as published by
8 | # the Free Software Foundation; either version 3 of the License, or
9 | # (at your option) any later version.
10 | #
11 | # This program is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | # GNU General Public License for more details.
15 | #------------------------------------------------------------------------------
16 |
17 | use strict;
18 | use warnings;
19 | no warnings qw(uninitialized redefine);
20 |
21 | # Imports
22 | use MwfMain;
23 |
24 | #------------------------------------------------------------------------------
25 |
26 | # Init
27 | my ($m, $cfg, $lng, $user, $userId) = MwfMain->new($_[0]);
28 |
29 | # Get CGI parameters
30 | my $boardId = $m->paramInt('bid');
31 |
32 | # Update user's previous online time
33 | if ($userId) {
34 | my $prevOnCookie = int($m->getCookie('prevon') || 0);
35 | my $prevOnTime = $m->max($prevOnCookie, $user->{lastOnTime}) || $m->{now};
36 | $m->{userUpdates}{prevOnTime} = $prevOnTime;
37 | $m->setCookie('prevon', $prevOnTime);
38 | }
39 |
40 | # Log action and finish
41 | $m->logAction(2, 'forum', 'enter', $userId);
42 | if ($boardId) { $m->redirect('board_show', bid => $boardId) }
43 | else { $m->redirect('forum_show') }
44 |
--------------------------------------------------------------------------------
/script/user_delete.pl:
--------------------------------------------------------------------------------
1 | #!/usr/bin/perl
2 | #------------------------------------------------------------------------------
3 | # mwForum - Web-based discussion forum
4 | # Copyright (c) 1999-2015 Markus Wichitill
5 | #
6 | # This program is free software; you can redistribute it and/or modify
7 | # it under the terms of the GNU General Public License as published by
8 | # the Free Software Foundation; either version 3 of the License, or
9 | # (at your option) any later version.
10 | #
11 | # This program is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | # GNU General Public License for more details.
15 | #------------------------------------------------------------------------------
16 |
17 | use strict;
18 | use warnings;
19 | no warnings qw(uninitialized redefine);
20 |
21 | # Imports
22 | use MwfMain;
23 |
24 | #------------------------------------------------------------------------------
25 |
26 | # Init
27 | my ($m, $cfg, $lng, $user, $userId) = MwfMain->new($_[0]);
28 |
29 | # Check if user is admin
30 | $user->{admin} or $m->error('errNoAccess');
31 |
32 | # Get CGI parameters
33 | my $delUserId = $m->paramInt('uid');
34 | $delUserId or $m->error('errParamMiss');
35 |
36 | # Check request source authentication
37 | $m->checkSourceAuth() or $m->error('errSrcAuth');
38 |
39 | # Don't delete user #1
40 | $delUserId != 1 or $m->error("Deleting user #1 not allowed for security reasons.");
41 |
42 | # Delete user
43 | $m->deleteUser($delUserId);
44 |
45 | # Log action and finish
46 | $m->logAction(1, 'user', 'delete', $userId, 0, 0, 0, $delUserId);
47 | $m->redirect('user_admin');
48 |
--------------------------------------------------------------------------------
/script/categ_add.pl:
--------------------------------------------------------------------------------
1 | #!/usr/bin/perl
2 | #------------------------------------------------------------------------------
3 | # mwForum - Web-based discussion forum
4 | # Copyright (c) 1999-2015 Markus Wichitill
5 | #
6 | # This program is free software; you can redistribute it and/or modify
7 | # it under the terms of the GNU General Public License as published by
8 | # the Free Software Foundation; either version 3 of the License, or
9 | # (at your option) any later version.
10 | #
11 | # This program is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | # GNU General Public License for more details.
15 | #------------------------------------------------------------------------------
16 |
17 | use strict;
18 | use warnings;
19 | no warnings qw(uninitialized redefine);
20 |
21 | # Imports
22 | use MwfMain;
23 |
24 | #------------------------------------------------------------------------------
25 |
26 | # Init
27 | my ($m, $cfg, $lng, $user, $userId) = MwfMain->new($_[0]);
28 |
29 | # Check if user is admin
30 | $user->{admin} or $m->error('errNoAccess');
31 |
32 | # Check request source authentication
33 | $m->checkSourceAuth() or $m->error('errSrcAuth');
34 |
35 | # Get position
36 | my $pos = $m->fetchArray("
37 | SELECT COALESCE(MAX(pos), 0) + 1 FROM categories");
38 |
39 | # Insert new category
40 | $m->dbDo("
41 | INSERT INTO categories (title, pos) VALUES (?, ?)",
42 | 'New Category', $pos);
43 | my $categId = $m->dbInsertId("categories");
44 |
45 | # Log action and finish
46 | $m->logAction(1, 'categ', 'add', $userId, 0, 0, 0, $categId);
47 | $m->redirect('categ_options', cid => $categId);
48 |
--------------------------------------------------------------------------------
/script/chat_delete.pl:
--------------------------------------------------------------------------------
1 | #!/usr/bin/perl
2 | #------------------------------------------------------------------------------
3 | # mwForum - Web-based discussion forum
4 | # Copyright (c) 1999-2015 Markus Wichitill
5 | #
6 | # This program is free software; you can redistribute it and/or modify
7 | # it under the terms of the GNU General Public License as published by
8 | # the Free Software Foundation; either version 3 of the License, or
9 | # (at your option) any later version.
10 | #
11 | # This program is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | # GNU General Public License for more details.
15 | #------------------------------------------------------------------------------
16 |
17 | use strict;
18 | use warnings;
19 | no warnings qw(uninitialized redefine);
20 |
21 | # Imports
22 | use MwfMain;
23 |
24 | #------------------------------------------------------------------------------
25 |
26 | # Init
27 | my ($m, $cfg, $lng, $user, $userId) = MwfMain->new($_[0]);
28 |
29 | # Check if user is admin
30 | $user->{admin} or $m->error('errNoAccess');
31 |
32 | # Get CGI parameters
33 | my $action = $m->paramStrId('act');
34 | my $chatId = $m->paramInt('chatId');
35 |
36 | # Check request source authentication
37 | $m->checkSourceAuth() or $m->error('errSrcAuth');
38 |
39 | if ($action eq 'all') {
40 | # Delete all chat messages
41 | $m->dbDo("
42 | DELETE FROM chat");
43 | }
44 | else {
45 | # Delete chat message
46 | $m->dbDo("
47 | DELETE FROM chat WHERE id = ?", $chatId);
48 | }
49 |
50 | # Log action and finish
51 | $m->logAction(1, 'chat', 'delete', $userId, 0, 0, 0, $chatId);
52 | $m->redirect('chat_show', msg => 'ChatDel');
53 |
--------------------------------------------------------------------------------
/script/ajax_dataversion.pl:
--------------------------------------------------------------------------------
1 | #!/usr/bin/perl
2 | #------------------------------------------------------------------------------
3 | # mwForum - Web-based discussion forum
4 | # Copyright (c) 1999-2015 Markus Wichitill
5 | #
6 | # This program is free software; you can redistribute it and/or modify
7 | # it under the terms of the GNU General Public License as published by
8 | # the Free Software Foundation; either version 3 of the License, or
9 | # (at your option) any later version.
10 | #
11 | # This program is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | # GNU General Public License for more details.
15 | #------------------------------------------------------------------------------
16 |
17 | use strict;
18 | use warnings;
19 | no warnings qw(uninitialized redefine);
20 |
21 | # Imports
22 | use MwfMain;
23 |
24 | #------------------------------------------------------------------------------
25 |
26 | # Init
27 | my ($m, $cfg, $lng, $user, $userId) = MwfMain->new($_[0], ajax => 1);
28 |
29 | # Check if user is admin
30 | $user->{admin} or $m->error('errNoAccess');
31 |
32 | # Check if feature is enabled
33 | $cfg->{dataVersion} or $m->error("Feature is disabled.");
34 |
35 | # Increase data version
36 | my $dataVersion = $cfg->{dataVersion} + 1;
37 | $m->dbDo("
38 | UPDATE config SET value = ? WHERE name = ?", $dataVersion, 'dataVersion');
39 | $m->dbDo("
40 | UPDATE config SET value = ? WHERE name = ?", $m->{now}, 'lastUpdate');
41 |
42 | # Answer in JSON
43 | $m->printHttpHeader();
44 | print $m->json({ dataVersion => $dataVersion });
45 |
46 | # Log action and commit
47 | $m->logAction(1, 'ajax', 'dataver', $userId);
48 | $m->finish();
49 |
--------------------------------------------------------------------------------
/script/ajax_usernames.pl:
--------------------------------------------------------------------------------
1 | #!/usr/bin/perl
2 | #------------------------------------------------------------------------------
3 | # mwForum - Web-based discussion forum
4 | # Copyright (c) 1999-2015 Markus Wichitill
5 | #
6 | # This program is free software; you can redistribute it and/or modify
7 | # it under the terms of the GNU General Public License as published by
8 | # the Free Software Foundation; either version 3 of the License, or
9 | # (at your option) any later version.
10 | #
11 | # This program is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | # GNU General Public License for more details.
15 | #------------------------------------------------------------------------------
16 |
17 | use strict;
18 | use warnings;
19 | no warnings qw(uninitialized redefine);
20 |
21 | # Imports
22 | use MwfMain;
23 |
24 | #------------------------------------------------------------------------------
25 |
26 | # Init
27 | my ($m, $cfg, $lng, $user, $userId) = MwfMain->new($_[0], ajax => 1);
28 |
29 | # Print header
30 | $m->printHttpHeader();
31 |
32 | # Get CGI parameters
33 | my $name = $m->paramStr('q');
34 |
35 | # Return empty in case of errors
36 | $userId || $cfg->{userList} == 1 or $m->finish();
37 | length($name) >= 2 or $m->finish();
38 |
39 | # Fetch names
40 | my $like = $m->{pgsql} ? 'ILIKE' : 'LIKE';
41 | my $nameLike = $m->dbEscLike($name) . "%";
42 | my $names = $m->fetchAllArray("
43 | SELECT userName
44 | FROM users
45 | WHERE userName $like ?
46 | ORDER BY userName",
47 | $nameLike);
48 |
49 | # Print names
50 | print $_->[0], "\n" for @$names;
51 |
52 | # Log action and commit
53 | $m->logAction(3, 'ajax', 'unames', $userId);
54 | $m->finish();
55 |
--------------------------------------------------------------------------------
/script/categ_delete.pl:
--------------------------------------------------------------------------------
1 | #!/usr/bin/perl
2 | #------------------------------------------------------------------------------
3 | # mwForum - Web-based discussion forum
4 | # Copyright (c) 1999-2015 Markus Wichitill
5 | #
6 | # This program is free software; you can redistribute it and/or modify
7 | # it under the terms of the GNU General Public License as published by
8 | # the Free Software Foundation; either version 3 of the License, or
9 | # (at your option) any later version.
10 | #
11 | # This program is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | # GNU General Public License for more details.
15 | #------------------------------------------------------------------------------
16 |
17 | use strict;
18 | use warnings;
19 | no warnings qw(uninitialized redefine);
20 |
21 | # Imports
22 | use MwfMain;
23 |
24 | #------------------------------------------------------------------------------
25 |
26 | # Init
27 | my ($m, $cfg, $lng, $user, $userId) = MwfMain->new($_[0]);
28 |
29 | # Check if user is admin
30 | $user->{admin} or $m->error('errNoAccess');
31 |
32 | # Get CGI parameters
33 | my $categId = $m->paramInt('cid');
34 | $categId or $m->error('errParamMiss');
35 |
36 | # Check request source authentication
37 | $m->checkSourceAuth() or $m->error('errSrcAuth');
38 |
39 | # Only delete category when empty
40 | !$m->fetchArray("
41 | SELECT id FROM boards WHERE categoryId = ?", $categId)
42 | or $m->error("Category is not empty.");
43 |
44 | # Delete category
45 | $m->dbDo("
46 | DELETE FROM categories WHERE id = ?", $categId);
47 |
48 | # Log action and finish
49 | $m->logAction(1, 'categ', 'delete', $userId, 0, 0, 0, $categId);
50 | $m->redirect('categ_admin');
51 |
--------------------------------------------------------------------------------
/script/report_delete.pl:
--------------------------------------------------------------------------------
1 | #!/usr/bin/perl
2 | #------------------------------------------------------------------------------
3 | # mwForum - Web-based discussion forum
4 | # Copyright (c) 1999-2015 Markus Wichitill
5 | #
6 | # This program is free software; you can redistribute it and/or modify
7 | # it under the terms of the GNU General Public License as published by
8 | # the Free Software Foundation; either version 3 of the License, or
9 | # (at your option) any later version.
10 | #
11 | # This program is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | # GNU General Public License for more details.
15 | #------------------------------------------------------------------------------
16 |
17 | use strict;
18 | use warnings;
19 | no warnings qw(uninitialized redefine);
20 |
21 | # Imports
22 | use MwfMain;
23 |
24 | #------------------------------------------------------------------------------
25 |
26 | # Init
27 | my ($m, $cfg, $lng, $user, $userId) = MwfMain->new($_[0]);
28 |
29 | # Get CGI parameters
30 | my $repUserId = $m->paramInt('uid');
31 | my $postId = $m->paramInt('pid');
32 | $postId or $m->error('errParamMiss');
33 |
34 | # Check request source authentication
35 | $m->checkSourceAuth() or $m->error('errSrcAuth');
36 |
37 | # Get post
38 | my ($boardId, $topicId) = $m->fetchArray("
39 | SELECT boardId, topicId FROM posts WHERE id = ?", $postId);
40 | $boardId or $m->error('errPstNotFnd');
41 |
42 | # Check if user is admin or moderator
43 | $user->{admin} || $m->boardAdmin($userId, $boardId) or $m->error('errNoAccess');
44 |
45 | # Delete report
46 | $m->dbDo("
47 | DELETE FROM postReports WHERE userId = ? AND postId = ?", $repUserId, $postId);
48 |
49 | # Log action and finish
50 | $m->logAction(1, 'report', 'delete', $userId, $boardId, $topicId, $postId);
51 | $m->redirect('report_list', msg => 'PstRemRep');
52 |
--------------------------------------------------------------------------------
/script/board_add.pl:
--------------------------------------------------------------------------------
1 | #!/usr/bin/perl
2 | #------------------------------------------------------------------------------
3 | # mwForum - Web-based discussion forum
4 | # Copyright (c) 1999-2015 Markus Wichitill
5 | #
6 | # This program is free software; you can redistribute it and/or modify
7 | # it under the terms of the GNU General Public License as published by
8 | # the Free Software Foundation; either version 3 of the License, or
9 | # (at your option) any later version.
10 | #
11 | # This program is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | # GNU General Public License for more details.
15 | #------------------------------------------------------------------------------
16 |
17 | use strict;
18 | use warnings;
19 | no warnings qw(uninitialized redefine);
20 |
21 | # Imports
22 | use MwfMain;
23 |
24 | #------------------------------------------------------------------------------
25 |
26 | # Init
27 | my ($m, $cfg, $lng, $user, $userId) = MwfMain->new($_[0]);
28 |
29 | # Check if user is admin
30 | $user->{admin} or $m->error('errNoAccess');
31 |
32 | # Check request source authentication
33 | $m->checkSourceAuth() or $m->error('errSrcAuth');
34 |
35 | # Get first category id
36 | my $firstCatId = $m->fetchArray("
37 | SELECT MIN(id) FROM categories");
38 | $firstCatId
39 | or $m->error("Can't create board without existing category. Create a category first.");
40 |
41 | # Get position
42 | my $pos = $m->fetchArray("
43 | SELECT COALESCE(MAX(pos), 0) + 1 FROM boards WHERE categoryId = ?", $firstCatId);
44 |
45 | # Insert new board
46 | $m->dbDo("
47 | INSERT INTO boards (title, categoryId, pos, private) VALUES (?, ?, ?, ?)",
48 | 'New Board', $firstCatId, $pos, 1);
49 | my $boardId = $m->dbInsertId("boards");
50 |
51 | # Log action and finish
52 | $m->logAction(1, 'board', 'add', $userId, $boardId);
53 | $m->redirect('board_options', bid => $boardId);
54 |
--------------------------------------------------------------------------------
/script/topic_stick.pl:
--------------------------------------------------------------------------------
1 | #!/usr/bin/perl
2 | #------------------------------------------------------------------------------
3 | # mwForum - Web-based discussion forum
4 | # Copyright (c) 1999-2015 Markus Wichitill
5 | #
6 | # This program is free software; you can redistribute it and/or modify
7 | # it under the terms of the GNU General Public License as published by
8 | # the Free Software Foundation; either version 3 of the License, or
9 | # (at your option) any later version.
10 | #
11 | # This program is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | # GNU General Public License for more details.
15 | #------------------------------------------------------------------------------
16 |
17 | use strict;
18 | use warnings;
19 | no warnings qw(uninitialized redefine);
20 |
21 | # Imports
22 | use MwfMain;
23 |
24 | #------------------------------------------------------------------------------
25 |
26 | # Init
27 | my ($m, $cfg, $lng, $user, $userId) = MwfMain->new($_[0]);
28 |
29 | # Get CGI parameters
30 | my $topicId = $m->paramInt('tid');
31 | my $action = $m->paramStrId('act');
32 | $topicId or $m->error('errParamMiss');
33 |
34 | # Check request source authentication
35 | $m->checkSourceAuth() or $m->error('errSrcAuth');
36 |
37 | # Get board id
38 | my $boardId = $m->fetchArray("
39 | SELECT boardId FROM topics WHERE id = ?", $topicId);
40 | $boardId or $m->error('errTpcNotFnd');
41 |
42 | # Check if user is admin or moderator
43 | $user->{admin} || $m->boardAdmin($userId, $boardId) or $m->error('errNoAccess');
44 |
45 | # Lock or unlock
46 | my $sticky = $action eq "stick" ? 1 : 0;
47 |
48 | # Update
49 | $m->dbDo("
50 | UPDATE topics SET sticky = ? WHERE id = ?", $sticky, $topicId);
51 |
52 | # Log action and finish
53 | $m->logAction(1, 'topic', $sticky ? 'stick' : 'unstick', $userId, $boardId, $topicId);
54 | $m->redirect('topic_show', tid => $topicId, msg => $sticky ? 'TpcStik' : 'TpcUnstik');
55 |
--------------------------------------------------------------------------------
/script/forum_help.pl:
--------------------------------------------------------------------------------
1 | #!/usr/bin/perl
2 | #------------------------------------------------------------------------------
3 | # mwForum - Web-based discussion forum
4 | # Copyright (c) 1999-2015 Markus Wichitill
5 | #
6 | # This program is free software; you can redistribute it and/or modify
7 | # it under the terms of the GNU General Public License as published by
8 | # the Free Software Foundation; either version 3 of the License, or
9 | # (at your option) any later version.
10 | #
11 | # This program is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | # GNU General Public License for more details.
15 | #------------------------------------------------------------------------------
16 |
17 | use strict;
18 | use warnings;
19 | no warnings qw(uninitialized redefine);
20 |
21 | # Imports
22 | use MwfMain;
23 |
24 | #------------------------------------------------------------------------------
25 |
26 | # Init
27 | my ($m, $cfg, $lng, $user, $userId) = MwfMain->new($_[0]);
28 |
29 | # Print header
30 | $m->printHeader();
31 |
32 | # Print page bar
33 | my @navLinks = ({ url => $m->url('forum_show'), txt => 'comUp', ico => 'up' });
34 | $m->printPageBar(mainTitle => $lng->{hlpTitle}, navLinks => \@navLinks);
35 |
36 | # Replace placeholders in text
37 | my $help = $lng->{help};
38 | $help =~ s!\[\[dataPath\]\]!$cfg->{dataPath}!g;
39 |
40 | # Print help
41 | print
42 | "
\n",
43 | "
$lng->{hlpTxtTtl}
\n",
44 | "
\n",
45 | $help,
46 | "
\n",
47 | "
\n\n";
48 |
49 | # Print FAQ
50 | print
51 | "
\n",
52 | "
$lng->{hlpFaqTtl}
\n",
53 | "
\n",
54 | $lng->{faq},
55 | "
\n",
56 | "
\n\n";
57 |
58 | # Log action and finish
59 | $m->logAction(3, 'forum', 'help', $userId);
60 | $m->printFooter();
61 | $m->finish();
62 |
--------------------------------------------------------------------------------
/script/user_unsubscribe.pl:
--------------------------------------------------------------------------------
1 | #!/usr/bin/perl
2 | #------------------------------------------------------------------------------
3 | # mwForum - Web-based discussion forum
4 | # Copyright (c) 1999-2015 Markus Wichitill
5 | #
6 | # This program is free software; you can redistribute it and/or modify
7 | # it under the terms of the GNU General Public License as published by
8 | # the Free Software Foundation; either version 3 of the License, or
9 | # (at your option) any later version.
10 | #
11 | # This program is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | # GNU General Public License for more details.
15 | #------------------------------------------------------------------------------
16 |
17 | use strict;
18 | use warnings;
19 | no warnings qw(uninitialized redefine);
20 |
21 | # Imports
22 | use MwfMain;
23 |
24 | #------------------------------------------------------------------------------
25 |
26 | # Init
27 | my ($m, $cfg, $lng, $user, $userId) = MwfMain->new($_[0]);
28 |
29 | # Get CGI parameters
30 | my $auth = $m->paramStr('t');
31 |
32 | # Unsubscribe
33 | my $caseSensitive = $m->{mysql} ? 'BINARY' : 'TEXT';
34 | my ($boardUserId, $boardId) = $m->fetchArray("
35 | SELECT userId, boardId FROM boardSubscriptions WHERE unsubAuth = CAST(? AS $caseSensitive)",
36 | $auth);
37 | my ($topicUserId, $topicId) = $m->fetchArray("
38 | SELECT userId, topicId FROM topicSubscriptions WHERE unsubAuth = CAST(? AS $caseSensitive)",
39 | $auth);
40 | if ($boardUserId) {
41 | $m->dbDo("
42 | DELETE FROM boardSubscriptions WHERE userId = ? AND unsubAuth = CAST(? AS $caseSensitive)",
43 | $boardUserId, $auth);
44 | }
45 | elsif ($topicUserId) {
46 | $m->dbDo("
47 | DELETE FROM topicSubscriptions WHERE userId = ? AND unsubAuth = CAST(? AS $caseSensitive)",
48 | $topicUserId, $auth);
49 | }
50 | else {
51 | $m->error('errUnsNotFnd');
52 | }
53 |
54 | # Log action and finish
55 | $m->logAction(1, 'user', 'unsub', $boardUserId || $topicUserId, $boardId, $topicId);
56 | $m->redirect('forum_show', msg => $boardUserId ? 'BrdUnsub' : 'TpcUnsub');
57 |
--------------------------------------------------------------------------------
/script/post_lock.pl:
--------------------------------------------------------------------------------
1 | #!/usr/bin/perl
2 | #------------------------------------------------------------------------------
3 | # mwForum - Web-based discussion forum
4 | # Copyright (c) 1999-2015 Markus Wichitill
5 | #
6 | # This program is free software; you can redistribute it and/or modify
7 | # it under the terms of the GNU General Public License as published by
8 | # the Free Software Foundation; either version 3 of the License, or
9 | # (at your option) any later version.
10 | #
11 | # This program is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | # GNU General Public License for more details.
15 | #------------------------------------------------------------------------------
16 |
17 | use strict;
18 | use warnings;
19 | no warnings qw(uninitialized redefine);
20 |
21 | # Imports
22 | use MwfMain;
23 |
24 | #------------------------------------------------------------------------------
25 |
26 | # Init
27 | my ($m, $cfg, $lng, $user, $userId) = MwfMain->new($_[0]);
28 |
29 | # Get CGI parameters
30 | my $postId = $m->paramInt('pid');
31 | my $action = $m->paramStrId('act');
32 | $postId or $m->error('errParamMiss');
33 |
34 | # Check request source authentication
35 | $m->checkSourceAuth() or $m->error('errSrcAuth');
36 |
37 | # Get post
38 | my ($boardId, $topicId) = $m->fetchArray("
39 | SELECT boardId, topicId FROM posts WHERE id = ?", $postId);
40 | $boardId or $m->error('errPstNotFnd');
41 |
42 | # Get board
43 | my $board = $m->fetchHash("
44 | SELECT topicAdmins FROM boards WHERE id = ?", $boardId);
45 |
46 | # Check if user is admin or moderator
47 | $user->{admin} || $m->boardAdmin($userId, $boardId)
48 | || $board->{topicAdmins} && $m->topicAdmin($userId, $topicId)
49 | or $m->error('errNoAccess');
50 |
51 | # Update post
52 | my $locked = $action eq 'lock' ? 1 : 0;
53 | $m->dbDo("
54 | UPDATE posts SET locked = ? WHERE id = ?", $locked, $postId);
55 |
56 | # Log action and finish
57 | $m->logAction(1, 'post', $locked ? 'lock' : 'unlock', $userId, $boardId, $topicId, $postId);
58 | $m->redirect('topic_show', pid => $postId, msg => $locked ? 'PstLock' : 'PstUnlock');
59 |
--------------------------------------------------------------------------------
/script/topic_lock.pl:
--------------------------------------------------------------------------------
1 | #!/usr/bin/perl
2 | #------------------------------------------------------------------------------
3 | # mwForum - Web-based discussion forum
4 | # Copyright (c) 1999-2015 Markus Wichitill
5 | #
6 | # This program is free software; you can redistribute it and/or modify
7 | # it under the terms of the GNU General Public License as published by
8 | # the Free Software Foundation; either version 3 of the License, or
9 | # (at your option) any later version.
10 | #
11 | # This program is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | # GNU General Public License for more details.
15 | #------------------------------------------------------------------------------
16 |
17 | use strict;
18 | use warnings;
19 | no warnings qw(uninitialized redefine);
20 |
21 | # Imports
22 | use MwfMain;
23 |
24 | #------------------------------------------------------------------------------
25 |
26 | # Init
27 | my ($m, $cfg, $lng, $user, $userId) = MwfMain->new($_[0]);
28 |
29 | # Get CGI parameters
30 | my $topicId = $m->paramInt('tid');
31 | my $action = $m->paramStrId('act');
32 | $topicId or $m->error('errParamMiss');
33 |
34 | # Check request source authentication
35 | $m->checkSourceAuth() or $m->error('errSrcAuth');
36 |
37 | # Get board id
38 | my $boardId = $m->fetchArray("
39 | SELECT boardId FROM topics WHERE id = ?", $topicId);
40 | $boardId or $m->error('errTpcNotFnd');
41 |
42 | # Get board
43 | my $board = $m->fetchHash("
44 | SELECT topicAdmins FROM boards WHERE id = ?", $boardId);
45 |
46 | # Check if user is admin or moderator
47 | $user->{admin} || $m->boardAdmin($userId, $boardId)
48 | || $board->{topicAdmins} && $m->topicAdmin($userId, $topicId)
49 | or $m->error('errNoAccess');
50 |
51 | # Lock or unlock
52 | my $locked = $action eq "lock" ? 1 : 0;
53 |
54 | # Update
55 | $m->dbDo("
56 | UPDATE topics SET locked = ? WHERE id = ?", $locked, $topicId);
57 |
58 | # Log action and finish
59 | $m->logAction(1, 'topic', $locked ? 'lock' : 'unlock', $userId, $boardId, $topicId);
60 | $m->redirect('topic_show', tid => $topicId, msg => $locked ? "TpcLock" : "TpcUnlock");
61 |
--------------------------------------------------------------------------------
/script/group_delete.pl:
--------------------------------------------------------------------------------
1 | #!/usr/bin/perl
2 | #------------------------------------------------------------------------------
3 | # mwForum - Web-based discussion forum
4 | # Copyright (c) 1999-2015 Markus Wichitill
5 | #
6 | # This program is free software; you can redistribute it and/or modify
7 | # it under the terms of the GNU General Public License as published by
8 | # the Free Software Foundation; either version 3 of the License, or
9 | # (at your option) any later version.
10 | #
11 | # This program is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | # GNU General Public License for more details.
15 | #------------------------------------------------------------------------------
16 |
17 | use strict;
18 | use warnings;
19 | no warnings qw(uninitialized redefine);
20 |
21 | # Imports
22 | use MwfMain;
23 |
24 | #------------------------------------------------------------------------------
25 |
26 | # Init
27 | my ($m, $cfg, $lng, $user, $userId) = MwfMain->new($_[0]);
28 |
29 | # Check if user is admin
30 | $user->{admin} or $m->error('errNoAccess');
31 |
32 | # Get CGI parameters
33 | my $groupId = $m->paramInt('gid');
34 | $groupId or $m->error('errParamMiss');
35 |
36 | # Check request source authentication
37 | $m->checkSourceAuth() or $m->error('errSrcAuth');
38 |
39 | # Delete user badges
40 | $m->dbDo("
41 | DELETE FROM userBadges
42 | WHERE badge = (SELECT badge FROM groups WHERE id = ?)", $groupId);
43 |
44 | # Delete board moderator permissions
45 | $m->dbDo("
46 | DELETE FROM boardAdminGroups WHERE groupId = ?", $groupId);
47 |
48 | # Delete board member permissions
49 | $m->dbDo("
50 | DELETE FROM boardMemberGroups WHERE groupId = ?", $groupId);
51 |
52 | # Delete group admins
53 | $m->dbDo("
54 | DELETE FROM groupAdmins WHERE groupId = ?", $groupId);
55 |
56 | # Delete group memberships
57 | $m->dbDo("
58 | DELETE FROM groupMembers WHERE groupId = ?", $groupId);
59 |
60 | # Delete group
61 | $m->dbDo("
62 | DELETE FROM groups WHERE id = ?", $groupId);
63 |
64 | # Log action and finish
65 | $m->logAction(1, 'group', 'delete', $userId, 0, 0, 0, $groupId);
66 | $m->redirect('group_admin');
67 |
--------------------------------------------------------------------------------
/script/board_delete.pl:
--------------------------------------------------------------------------------
1 | #!/usr/bin/perl
2 | #------------------------------------------------------------------------------
3 | # mwForum - Web-based discussion forum
4 | # Copyright (c) 1999-2015 Markus Wichitill
5 | #
6 | # This program is free software; you can redistribute it and/or modify
7 | # it under the terms of the GNU General Public License as published by
8 | # the Free Software Foundation; either version 3 of the License, or
9 | # (at your option) any later version.
10 | #
11 | # This program is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | # GNU General Public License for more details.
15 | #------------------------------------------------------------------------------
16 |
17 | use strict;
18 | use warnings;
19 | no warnings qw(uninitialized redefine);
20 |
21 | # Imports
22 | use MwfMain;
23 |
24 | #------------------------------------------------------------------------------
25 |
26 | # Init
27 | my ($m, $cfg, $lng, $user, $userId) = MwfMain->new($_[0]);
28 |
29 | # Check if user is admin
30 | $user->{admin} or $m->error('errNoAccess');
31 |
32 | # Get CGI parameters
33 | my $boardId = $m->paramInt('bid');
34 | $boardId or $m->error('errParamMiss');
35 |
36 | # Check request source authentication
37 | $m->checkSourceAuth() or $m->error('errSrcAuth');
38 |
39 | # Delete admin groups
40 | $m->dbDo("
41 | DELETE FROM boardAdminGroups WHERE boardId = ?", $boardId);
42 |
43 | # Delete member groups
44 | $m->dbDo("
45 | DELETE FROM boardMemberGroups WHERE boardId = ?", $boardId);
46 |
47 | # Delete subscriptions
48 | $m->dbDo("
49 | DELETE FROM boardSubscriptions WHERE boardId = ?", $boardId);
50 |
51 | # Delete hidden-flags
52 | $m->dbDo("
53 | DELETE FROM boardHiddenFlags WHERE boardId = ?", $boardId);
54 |
55 | # Delete topics
56 | my $topics = $m->fetchAllArray("
57 | SELECT id FROM topics WHERE boardId = ?", $boardId);
58 | for my $topic (@$topics) {
59 | $m->deleteTopic($topic->[0]);
60 | }
61 |
62 | # Delete board
63 | $m->dbDo("
64 | DELETE FROM boards WHERE id = ?", $boardId);
65 |
66 | # Log action and finish
67 | $m->logAction(1, 'board', 'delete', $userId, $boardId);
68 | $m->redirect('board_admin');
69 |
--------------------------------------------------------------------------------
/util/util_deleteusers.pl:
--------------------------------------------------------------------------------
1 | #!/usr/bin/perl
2 | #------------------------------------------------------------------------------
3 | # mwForum - Web-based discussion forum
4 | # Copyright (c) 1999-2015 Markus Wichitill
5 | #
6 | # This program is free software; you can redistribute it and/or modify
7 | # it under the terms of the GNU General Public License as published by
8 | # the Free Software Foundation; either version 3 of the License, or
9 | # (at your option) any later version.
10 | #
11 | # This program is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | # GNU General Public License for more details.
15 | #------------------------------------------------------------------------------
16 |
17 | # Mass-delete users (and their dependencies) matching a partial SQL query.
18 |
19 | use strict;
20 | use warnings;
21 | no warnings qw(uninitialized);
22 |
23 | # Imports
24 | use Getopt::Std ();
25 | require MwfMain;
26 |
27 | # Get arguments
28 | my %opts = ();
29 | Getopt::Std::getopts('?hxf:', \%opts);
30 | my $help = $opts{'?'} || $opts{h};
31 | my $execute = $opts{x};
32 | my $forumId = $opts{f};
33 | my $sql = $ARGV[0];
34 | usage() if $help || !length($sql);
35 |
36 | # Init
37 | my ($m, $cfg, $lng) = MwfMain->newShell(forumId => $forumId);
38 |
39 | # Delete users
40 | $m->dbBegin();
41 | my $users = $m->fetchAllArray("
42 | SELECT id FROM users WHERE $sql");
43 | my $sum = 0;
44 | for my $user (@$users) {
45 | $m->deleteUser($user->[0]) if $execute;
46 | $sum++;
47 | }
48 | $m->dbCommit();
49 |
50 | # Print sum of occurrences
51 | my $verb = $execute ? "Deleted" : "Found";
52 | print "$verb $sum users\n";
53 |
54 | #------------------------------------------------------------------------------
55 |
56 | sub usage
57 | {
58 | print
59 | "\nMass-delete users. Argument is a partial SQL query that defines affected users.\n\n",
60 | "Usage: util_deleteusers.pl [-x] [-f forum] \"email = '' AND lastOnTime < 1199142000\"\n",
61 | " -x Execute deletions. Otherwise, only number of affected users is printed.\n",
62 | " -f Forum hostname or URL path when using a multi-forum installation.\n",
63 | ;
64 |
65 | exit 1;
66 | }
67 |
--------------------------------------------------------------------------------
/script/spawn_test.pl:
--------------------------------------------------------------------------------
1 | #!/usr/bin/perl
2 | #------------------------------------------------------------------------------
3 | # mwForum - Web-based discussion forum
4 | # Copyright (c) 1999-2015 Markus Wichitill
5 | #
6 | # This program is free software; you can redistribute it and/or modify
7 | # it under the terms of the GNU General Public License as published by
8 | # the Free Software Foundation; either version 3 of the License, or
9 | # (at your option) any later version.
10 | #
11 | # This program is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | # GNU General Public License for more details.
15 | #------------------------------------------------------------------------------
16 |
17 | use strict;
18 | use warnings;
19 | no warnings qw(uninitialized once);
20 |
21 | # Imports
22 | use Getopt::Std ();
23 | use MwfMain;
24 |
25 | #------------------------------------------------------------------------------
26 |
27 | # Get arguments
28 | my %opts = ();
29 | Getopt::Std::getopts('sf:', \%opts);
30 | my $spawned = $opts{s};
31 | my $forumId = $opts{f};
32 |
33 | # Init
34 | my ($m, $cfg, $lng) = MwfMain->newShell(forumId => $forumId, spawned => $spawned, upgrade => 1);
35 | my $output = "";
36 | $| = 1;
37 | output("mwForum long-running script test running...\n");
38 |
39 | # Simulate work
40 | output("Pretending to do work that takes 20 minutes...\n");
41 | for my $minute (1 .. 20) {
42 | output("Sleeping $minute...\n");
43 | sleep 60;
44 | }
45 |
46 | # Still alive?
47 | output("Nice, the script wasn't interrupted.\n");
48 | output("mwForum long-running script test done.\n");
49 |
50 | # Log action
51 | $m->dbDo("
52 | INSERT INTO log (level, entity, action, logTime, string) VALUES (1, ?, ?, ?)",
53 | 'spawn', 'test', $m->{now});
54 |
55 | #------------------------------------------------------------------------------
56 | # Print and collect output
57 |
58 | sub output
59 | {
60 | my $text = shift();
61 |
62 | print $text;
63 | $output .= $text;
64 | $m->dbDo("
65 | DELETE FROM variables WHERE name = ?", 'upgOutput');
66 | $m->dbDo("
67 | INSERT INTO variables (name, value) VALUES (?, ?)", 'upgOutput', $output);
68 | }
69 |
--------------------------------------------------------------------------------
/script/chat_add.pl:
--------------------------------------------------------------------------------
1 | #!/usr/bin/perl
2 | #------------------------------------------------------------------------------
3 | # mwForum - Web-based discussion forum
4 | # Copyright (c) 1999-2015 Markus Wichitill
5 | #
6 | # This program is free software; you can redistribute it and/or modify
7 | # it under the terms of the GNU General Public License as published by
8 | # the Free Software Foundation; either version 3 of the License, or
9 | # (at your option) any later version.
10 | #
11 | # This program is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | # GNU General Public License for more details.
15 | #------------------------------------------------------------------------------
16 |
17 | use strict;
18 | use warnings;
19 | no warnings qw(uninitialized redefine);
20 |
21 | # Imports
22 | use MwfMain;
23 |
24 | #------------------------------------------------------------------------------
25 |
26 | # Init
27 | my ($m, $cfg, $lng, $user, $userId) = MwfMain->new($_[0]);
28 |
29 | # Check if access should be denied
30 | $cfg->{chat} or $m->error('errNoAccess');
31 | $userId or $m->error('errNoAccess');
32 |
33 | # Get CGI parameters
34 | my $parentId = $m->paramInt('pid');
35 | my $body = $m->paramStr('body');
36 |
37 | # Fake board
38 | my $board = { flat => 1 };
39 |
40 | # Check request source authentication
41 | $m->checkSourceAuth() or $m->error('errSrcAuth');
42 |
43 | # Check body length
44 | length($body) or $m->error('errBdyEmpty');
45 | length($body) <= $cfg->{chatMaxLength} or $m->error('errBdyLen');
46 |
47 | # Process text
48 | my $chat = { isChat => 1, body => $body };
49 | $m->editToDb({}, $chat);
50 |
51 | # Any text left after filtering?
52 | length($chat->{body}) or $m->error('errBdyEmpty');
53 |
54 | # Insert chat message
55 | $m->dbDo("
56 | INSERT INTO chat (userId, postTime, body) VALUES (?, ?, ?)",
57 | $userId, $m->{now}, $chat->{body});
58 | my $chatId = $m->dbInsertId("chat");
59 |
60 | # Expire old messages
61 | $m->dbDo("
62 | DELETE FROM chat WHERE postTime < ? - ? * 86400", $m->{now}, $cfg->{chatMaxAge})
63 | if $cfg->{chatMaxAge};
64 |
65 | # Log action and finish
66 | $m->logAction(1, 'chat', 'add', $userId, 0, 0, 0, $chatId);
67 | $m->redirect('chat_show', msg => 'ChatAdd');
68 |
--------------------------------------------------------------------------------
/util/util_tables2engine.sql:
--------------------------------------------------------------------------------
1 | -------------------------------------------------------------------------------
2 | -- mwForum - Web-based discussion forum
3 | -- Copyright (c) 1999-2015 Markus Wichitill
4 | --
5 | -- This program is free software; you can redistribute it and/or modify
6 | -- it under the terms of the GNU General Public License as published by
7 | -- the Free Software Foundation; either version 3 of the License, or
8 | -- (at your option) any later version.
9 | --
10 | -- This program is distributed in the hope that it will be useful,
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | -- GNU General Public License for more details.
14 | -------------------------------------------------------------------------------
15 |
16 | -- MySQL: convert tables to different engine
17 | ALTER TABLE arc_boards ENGINE = XXXX;
18 | ALTER TABLE arc_topics ENGINE = XXXX;
19 | ALTER TABLE arc_posts ENGINE = XXXX;
20 | ALTER TABLE attachments ENGINE = XXXX;
21 | ALTER TABLE boardAdminGroups ENGINE = XXXX;
22 | ALTER TABLE boardHiddenFlags ENGINE = XXXX;
23 | ALTER TABLE boardMemberGroups ENGINE = XXXX;
24 | ALTER TABLE boards ENGINE = XXXX;
25 | ALTER TABLE boardSubscriptions ENGINE = XXXX;
26 | ALTER TABLE categories ENGINE = XXXX;
27 | ALTER TABLE chat ENGINE = XXXX;
28 | ALTER TABLE config ENGINE = XXXX;
29 | ALTER TABLE groupAdmins ENGINE = XXXX;
30 | ALTER TABLE groupMembers ENGINE = XXXX;
31 | ALTER TABLE groups ENGINE = XXXX;
32 | ALTER TABLE log ENGINE = XXXX;
33 | ALTER TABLE messages ENGINE = XXXX;
34 | ALTER TABLE notes ENGINE = XXXX;
35 | ALTER TABLE pollOptions ENGINE = XXXX;
36 | ALTER TABLE polls ENGINE = XXXX;
37 | ALTER TABLE pollVotes ENGINE = XXXX;
38 | ALTER TABLE postLikes ENGINE = XXXX;
39 | ALTER TABLE postReports ENGINE = XXXX;
40 | ALTER TABLE posts ENGINE = XXXX;
41 | ALTER TABLE tickets ENGINE = XXXX;
42 | ALTER TABLE topicReadTimes ENGINE = XXXX;
43 | ALTER TABLE topics ENGINE = XXXX;
44 | ALTER TABLE topicSubscriptions ENGINE = XXXX;
45 | ALTER TABLE userBadges ENGINE = XXXX;
46 | ALTER TABLE userBans ENGINE = XXXX;
47 | ALTER TABLE userIgnores ENGINE = XXXX;
48 | ALTER TABLE users ENGINE = XXXX;
49 | ALTER TABLE userVariables ENGINE = XXXX;
50 | ALTER TABLE variables ENGINE = XXXX;
51 | ALTER TABLE watchUsers ENGINE = XXXX;
52 | ALTER TABLE watchWords ENGINE = XXXX;
53 |
--------------------------------------------------------------------------------
/script/categ_toggle.pl:
--------------------------------------------------------------------------------
1 | #!/usr/bin/perl
2 | #------------------------------------------------------------------------------
3 | # mwForum - Web-based discussion forum
4 | # Copyright (c) 1999-2015 Markus Wichitill
5 | #
6 | # This program is free software; you can redistribute it and/or modify
7 | # it under the terms of the GNU General Public License as published by
8 | # the Free Software Foundation; either version 3 of the License, or
9 | # (at your option) any later version.
10 | #
11 | # This program is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | # GNU General Public License for more details.
15 | #------------------------------------------------------------------------------
16 |
17 | use strict;
18 | use warnings;
19 | no warnings qw(uninitialized redefine);
20 |
21 | # Imports
22 | use MwfMain;
23 |
24 | #------------------------------------------------------------------------------
25 |
26 | # Init
27 | my ($m, $cfg, $lng, $user, $userId) = MwfMain->new($_[0]);
28 |
29 | # Check if access should be denied
30 | $userId or $m->error('errNoAccess');
31 |
32 | # Get CGI parameters
33 | my $action = $m->paramStrId('act');
34 | my $categId = $m->paramInt('cid');
35 | $categId or $m->error('errParamMiss');
36 |
37 | # Check request source authentication
38 | $m->checkSourceAuth() or $m->error('errSrcAuth');
39 |
40 | if ($action eq 'hide') {
41 | # Hide all non-hidden boards of category
42 | $m->dbDo("
43 | INSERT INTO boardHiddenFlags (userId, boardId)
44 | SELECT :userId, id
45 | FROM boards AS boards
46 | LEFT JOIN boardHiddenFlags AS bhf
47 | ON bhf.userId = :userId
48 | AND bhf.boardId = boards.id
49 | WHERE boards.categoryId = :categId
50 | AND bhf.userId IS NULL",
51 | { userId => $userId, categId => $categId });
52 |
53 | # Log action and finish
54 | $m->logAction(1, 'categ', 'hide', $userId, 0, 0, 0, $categId);
55 | $m->redirect('forum_show');
56 | }
57 | elsif ($action eq 'show') {
58 | # Show all boards of category, except manually hidden ones
59 | $m->dbDo("
60 | DELETE FROM boardHiddenFlags
61 | WHERE userId = ?
62 | AND boardId IN (SELECT id FROM boards WHERE categoryId = ?)
63 | AND manual = 0",
64 | $userId, $categId);
65 |
66 | # Log action and finish
67 | $m->logAction(1, 'categ', 'show', $userId, 0, 0, 0, $categId);
68 | $m->redirect('forum_show');
69 | }
70 |
--------------------------------------------------------------------------------
/script/forum_feeds.pl:
--------------------------------------------------------------------------------
1 | #!/usr/bin/perl
2 | #------------------------------------------------------------------------------
3 | # mwForum - Web-based discussion forum
4 | # Copyright (c) 1999-2015 Markus Wichitill
5 | #
6 | # This program is free software; you can redistribute it and/or modify
7 | # it under the terms of the GNU General Public License as published by
8 | # the Free Software Foundation; either version 3 of the License, or
9 | # (at your option) any later version.
10 | #
11 | # This program is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | # GNU General Public License for more details.
15 | #------------------------------------------------------------------------------
16 |
17 | use strict;
18 | use warnings;
19 | no warnings qw(uninitialized redefine);
20 |
21 | # Imports
22 | use MwfMain;
23 |
24 | #------------------------------------------------------------------------------
25 |
26 | # Init
27 | my ($m, $cfg, $lng, $user, $userId) = MwfMain->new($_[0]);
28 |
29 | # Print header
30 | $m->printHeader();
31 |
32 | # Print page bar
33 | my @navLinks = ({ url => $m->url('forum_show'), txt => 'comUp', ico => 'up' });
34 | $m->printPageBar(mainTitle => $lng->{fedTitle}, navLinks => \@navLinks);
35 |
36 | # Get boards
37 | my $boards = $m->fetchAllHash("
38 | SELECT boards.id, boards.title,
39 | categories.title AS categTitle
40 | FROM boards AS boards
41 | INNER JOIN categories AS categories
42 | ON categories.id = boards.categoryId
43 | WHERE boards.private = 0
44 | ORDER BY categories.pos, boards.pos");
45 |
46 | # Print feed list
47 | my $path = "$cfg->{attachUrlPath}/xml";
48 | print
49 | "
\n\n";
77 |
78 | # Log action and finish
79 | $m->logAction(3, 'categ', 'admin', $userId);
80 | $m->printFooter();
81 | $m->finish();
82 |
--------------------------------------------------------------------------------
/script/branch_delete.pl:
--------------------------------------------------------------------------------
1 | #!/usr/bin/perl
2 | #------------------------------------------------------------------------------
3 | # mwForum - Web-based discussion forum
4 | # Copyright (c) 1999-2015 Markus Wichitill
5 | #
6 | # This program is free software; you can redistribute it and/or modify
7 | # it under the terms of the GNU General Public License as published by
8 | # the Free Software Foundation; either version 3 of the License, or
9 | # (at your option) any later version.
10 | #
11 | # This program is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | # GNU General Public License for more details.
15 | #------------------------------------------------------------------------------
16 |
17 | use strict;
18 | use warnings;
19 | no warnings qw(uninitialized redefine);
20 |
21 | # Imports
22 | use MwfMain;
23 |
24 | #------------------------------------------------------------------------------
25 |
26 | # Init
27 | my ($m, $cfg, $lng, $user, $userId) = MwfMain->new($_[0]);
28 |
29 | # Get CGI parameters
30 | my $postId = $m->paramInt('pid');
31 | $postId or $m->error('errParamMiss');
32 |
33 | # Check request source authentication
34 | $m->checkSourceAuth() or $m->error('errSrcAuth');
35 |
36 | # Get branch base post
37 | my ($boardId, $topicId, $parentId) = $m->fetchArray("
38 | SELECT boardId, topicId, parentId FROM posts WHERE id = ?", $postId);
39 | $boardId or $m->error('errPstNotFnd');
40 |
41 | # Get board
42 | my $board = $m->fetchHash("
43 | SELECT topicAdmins FROM boards WHERE id = ?", $boardId);
44 |
45 | # Get topic base post
46 | my $basePostId = $m->fetchArray("
47 | SELECT basePostId FROM topics WHERE id = ?", $topicId);
48 | $basePostId != $postId or $m->error('errPromoTpc');
49 |
50 | # Check if user is admin or moderator
51 | $user->{admin} || $m->boardAdmin($userId, $boardId)
52 | || $board->{topicAdmins} && $m->topicAdmin($userId, $topicId)
53 | or $m->error('errNoAccess');
54 |
55 | # Get posts
56 | my $posts = $m->fetchAllHash("
57 | SELECT id, parentId FROM posts WHERE topicId = ?", $topicId);
58 |
59 | # Put posts in by-parent lookup table
60 | my %postsByParent = ();
61 | push @{$postsByParent{$_->{parentId}}}, $_ for @$posts;
62 |
63 | # Delete posts
64 | my $deleteBranch = sub {
65 | my $self = shift();
66 | my $pid = shift();
67 |
68 | # Recurse through children
69 | for my $child (@{$postsByParent{$pid}}) {
70 | $child->{id} != $pid or $m->error("Post is its own parent?!");
71 | $self->($self, $child->{id});
72 | }
73 |
74 | # Delete post
75 | $m->deletePost($pid, 0, 0, 0);
76 | };
77 | $deleteBranch->($deleteBranch, $postId);
78 | $m->recalcStats($boardId, $topicId);
79 |
80 | # Log action and finish
81 | $m->logAction(1, 'branch', 'delete', $userId, $boardId, $topicId, $postId);
82 | $m->redirect('topic_show', tid => $topicId, msg => 'BrnDelete');
83 |
--------------------------------------------------------------------------------
/script/poll_delete.pl:
--------------------------------------------------------------------------------
1 | #!/usr/bin/perl
2 | #------------------------------------------------------------------------------
3 | # mwForum - Web-based discussion forum
4 | # Copyright (c) 1999-2015 Markus Wichitill
5 | #
6 | # This program is free software; you can redistribute it and/or modify
7 | # it under the terms of the GNU General Public License as published by
8 | # the Free Software Foundation; either version 3 of the License, or
9 | # (at your option) any later version.
10 | #
11 | # This program is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | # GNU General Public License for more details.
15 | #------------------------------------------------------------------------------
16 |
17 | use strict;
18 | use warnings;
19 | no warnings qw(uninitialized redefine);
20 |
21 | # Imports
22 | use MwfMain;
23 |
24 | #------------------------------------------------------------------------------
25 |
26 | # Init
27 | my ($m, $cfg, $lng, $user, $userId) = MwfMain->new($_[0]);
28 |
29 | # Get CGI parameters
30 | my $topicId = $m->paramInt('tid');
31 |
32 | # Check request source authentication
33 | $m->checkSourceAuth() or $m->error('errSrcAuth');
34 |
35 | # Get topic
36 | my ($boardId, $pollId, $topicUserId) = $m->fetchArray("
37 | SELECT topics.boardId, topics.pollId, posts.userId
38 | FROM topics AS topics
39 | INNER JOIN posts AS posts
40 | ON posts.id = topics.basePostId
41 | WHERE topics.id = ?", $topicId);
42 | $boardId or $m->error('errTpcNotFnd');
43 |
44 | # Get board
45 | my $board = $m->fetchHash("
46 | SELECT * FROM boards WHERE id = ?", $boardId);
47 | $board or $m->error('errBrdNotFnd');
48 |
49 | # Check if user can see and write to board
50 | my $boardAdmin = $user->{admin} || $m->boardAdmin($userId, $boardId)
51 | || $board->{topicAdmins} && $m->topicAdmin($userId, $topicId);
52 | $boardAdmin || $m->boardVisible($board) or $m->error('errNoAccess');
53 | $boardAdmin || $m->boardWritable($board, 1) or $m->error('errNoAccess');
54 |
55 | # Check if user owns topic or is moderator
56 | $userId == $topicUserId || $boardAdmin or $m->error('errNoAccess');
57 |
58 | # Normal topic creator may only delete if there have been no votes so far
59 | if (!$boardAdmin) {
60 | !$m->fetchArray("
61 | SELECT pollId FROM pollVotes WHERE pollId = ?", $pollId)
62 | or $m->error('errPolNoDel');
63 | }
64 |
65 | # Delete poll
66 | $m->dbDo("
67 | DELETE FROM pollVotes WHERE pollId = ?", $pollId);
68 | $m->dbDo("
69 | DELETE FROM pollOptions WHERE pollId = ?", $pollId);
70 | $m->dbDo("
71 | DELETE FROM polls WHERE id = ?", $pollId);
72 | $m->dbDo("
73 | UPDATE topics SET pollId = 0 WHERE id = ?", $topicId);
74 |
75 | # Log action and finish
76 | $m->logAction(1, 'poll', 'delete', $userId, $boardId, $topicId, undef, $pollId);
77 | $m->redirect('topic_show', tid => $topicId, msg => 'PollDel');
78 |
--------------------------------------------------------------------------------
/script/log_delete.pl:
--------------------------------------------------------------------------------
1 | #!/usr/bin/perl
2 | #------------------------------------------------------------------------------
3 | # mwForum - Web-based discussion forum
4 | # Copyright (c) 1999-2015 Markus Wichitill
5 | #
6 | # This program is free software; you can redistribute it and/or modify
7 | # it under the terms of the GNU General Public License as published by
8 | # the Free Software Foundation; either version 3 of the License, or
9 | # (at your option) any later version.
10 | #
11 | # This program is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | # GNU General Public License for more details.
15 | #------------------------------------------------------------------------------
16 |
17 | use strict;
18 | use warnings;
19 | no warnings qw(uninitialized redefine);
20 |
21 | # Imports
22 | use MwfMain;
23 |
24 | #------------------------------------------------------------------------------
25 |
26 | # Init
27 | my ($m, $cfg, $lng, $user, $userId) = MwfMain->new($_[0]);
28 |
29 | # Check if user is admin
30 | $user->{admin} or $m->error('errNoAccess');
31 |
32 | # Get CGI parameters
33 | my $maxAge = $m->paramInt('maxAge');
34 | my $submitted = $m->paramBool('subm');
35 |
36 | # Process form
37 | if ($submitted) {
38 | # Check request source authentication
39 | $m->checkSourceAuth() or $m->formError('errSrcAuth');
40 |
41 | # If there's no error, finish action
42 | if (!@{$m->{formErrors}}) {
43 | # Delete log lines older than maxAge days
44 | if (!$maxAge) {
45 | $m->dbDo("
46 | DELETE FROM log");
47 | }
48 | else {
49 | $m->dbDo("
50 | DELETE FROM log WHERE logTime < ? - ? * 86400", $m->{now}, $maxAge);
51 | }
52 |
53 | # Log action and finish
54 | $m->logAction(1, 'log', 'delete', $userId);
55 | $m->redirect('log_admin');
56 | }
57 | }
58 |
59 | # Print form
60 | if (!$submitted || @{$m->{formErrors}}) {
61 | # Print header
62 | $m->printHeader();
63 |
64 | # Print page bar
65 | my @navLinks = ({ url => $m->url('log_admin'), txt => 'comUp', ico => 'up' });
66 | $m->printPageBar(mainTitle => "Log", navLinks => \@navLinks);
67 |
68 | # Print hints and form errors
69 | $m->printFormErrors();
70 |
71 | # Print notification message form
72 | print
73 | "\n\n";
86 |
87 | # Log action and finish
88 | $m->logAction(3, 'log', 'delete', $userId);
89 | $m->printFooter();
90 | }
91 | $m->finish();
92 |
--------------------------------------------------------------------------------
/util/util_fixtablecase.sql:
--------------------------------------------------------------------------------
1 | -------------------------------------------------------------------------------
2 | -- mwForum - Web-based discussion forum
3 | -- Copyright (c) 1999-2015 Markus Wichitill
4 | --
5 | -- This program is free software; you can redistribute it and/or modify
6 | -- it under the terms of the GNU General Public License as published by
7 | -- the Free Software Foundation; either version 3 of the License, or
8 | -- (at your option) any later version.
9 | --
10 | -- This program is distributed in the hope that it will be useful,
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | -- GNU General Public License for more details.
14 | -------------------------------------------------------------------------------
15 |
16 | -- Rename tables to original case if lost under MySQL (Windows, InnoDB)
17 | ALTER TABLE boardadmingroups RENAME TO tmp_boardAdminGroups;
18 | ALTER TABLE boardhiddenflags RENAME TO tmp_boardHiddenFlags;
19 | ALTER TABLE boardmembergroups RENAME TO tmp_boardMemberGroups;
20 | ALTER TABLE boardsubscriptions RENAME TO tmp_boardSubscriptions;
21 | ALTER TABLE groupadmins RENAME TO tmp_groupAdmins;
22 | ALTER TABLE groupmembers RENAME TO tmp_groupMembers;
23 | ALTER TABLE polloptions RENAME TO tmp_pollOptions;
24 | ALTER TABLE pollvotes RENAME TO tmp_pollVotes;
25 | ALTER TABLE postlikes RENAME TO tmp_postLikes;
26 | ALTER TABLE postreports RENAME TO tmp_postReports;
27 | ALTER TABLE topicreadtimes RENAME TO tmp_topicReadTimes;
28 | ALTER TABLE topicsubscriptions RENAME TO tmp_topicSubscriptions;
29 | ALTER TABLE userbadges RENAME TO tmp_userBadges;
30 | ALTER TABLE userbans RENAME TO tmp_userBans;
31 | ALTER TABLE userignores RENAME TO tmp_userIgnores;
32 | ALTER TABLE uservariables RENAME TO tmp_userVariables;
33 | ALTER TABLE watchusers RENAME TO tmp_watchUsers;
34 | ALTER TABLE watchwords RENAME TO tmp_watchWords;
35 |
36 | ALTER TABLE tmp_boardAdminGroups RENAME TO boardAdminGroups;
37 | ALTER TABLE tmp_boardHiddenFlags RENAME TO boardHiddenFlags;
38 | ALTER TABLE tmp_boardMemberGroups RENAME TO boardMemberGroups;
39 | ALTER TABLE tmp_boardSubscriptions RENAME TO boardSubscriptions;
40 | ALTER TABLE tmp_groupAdmins RENAME TO groupAdmins;
41 | ALTER TABLE tmp_groupMembers RENAME TO groupMembers;
42 | ALTER TABLE tmp_pollOptions RENAME TO pollOptions;
43 | ALTER TABLE tmp_pollVotes RENAME TO pollVotes;
44 | ALTER TABLE tmp_postLikes RENAME TO postLikes;
45 | ALTER TABLE tmp_postReports RENAME TO postReports;
46 | ALTER TABLE tmp_topicReadTimes RENAME TO topicReadTimes;
47 | ALTER TABLE tmp_topicSubscriptions RENAME TO topicSubscriptions;
48 | ALTER TABLE tmp_userBadges RENAME TO userBadges;
49 | ALTER TABLE tmp_userBans RENAME TO userBans;
50 | ALTER TABLE tmp_userIgnores RENAME TO userIgnores;
51 | ALTER TABLE tmp_userVariables RENAME TO userVariables;
52 | ALTER TABLE tmp_watchUsers RENAME TO watchUsers;
53 | ALTER TABLE tmp_watchWords RENAME TO watchWords;
54 |
--------------------------------------------------------------------------------
/script/user_ticket.pl:
--------------------------------------------------------------------------------
1 | #!/usr/bin/perl
2 | #------------------------------------------------------------------------------
3 | # mwForum - Web-based discussion forum
4 | # Copyright (c) 1999-2015 Markus Wichitill
5 | #
6 | # This program is free software; you can redistribute it and/or modify
7 | # it under the terms of the GNU General Public License as published by
8 | # the Free Software Foundation; either version 3 of the License, or
9 | # (at your option) any later version.
10 | #
11 | # This program is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | # GNU General Public License for more details.
15 | #------------------------------------------------------------------------------
16 |
17 | use strict;
18 | use warnings;
19 | no warnings qw(uninitialized redefine);
20 |
21 | # Imports
22 | use MwfMain;
23 |
24 | #------------------------------------------------------------------------------
25 |
26 | # Init
27 | my ($m, $cfg, $lng, $user, $userId) = MwfMain->new($_[0]);
28 |
29 | # Get CGI parameters
30 | my $ticketId = $m->paramStr('t');
31 |
32 | # Get ticket
33 | my $caseSensitive = $m->{mysql} ? 'BINARY' : 'TEXT';
34 | my $ticket = $m->fetchHash("
35 | SELECT * FROM tickets WHERE id = CAST(? AS $caseSensitive) AND issueTime > ? - 2 * 86400",
36 | $ticketId, $m->{now});
37 | $ticket or $m->error('errTktNotFnd');
38 |
39 | # Get user
40 | my $dbUser = $m->getUser($ticket->{userId});
41 | $dbUser or $m->error('errUsrNotFnd');
42 |
43 | # Login ticket (freshly registered)
44 | if ($ticket->{type} eq 'usrReg') {
45 | # Set cookie
46 | $m->setCookie('login', "$dbUser->{id}:$dbUser->{loginAuth}", $dbUser->{tempLogin});
47 |
48 | # Delete user's login tickets
49 | $m->dbDo("
50 | DELETE FROM tickets WHERE userId = ? AND type = ?", $dbUser->{id}, 'usrReg');
51 |
52 | # Log action and finish
53 | $m->logAction(1, 'user', 'tkusrreg', $dbUser->{id});
54 | $m->redirect('forum');
55 | }
56 | # Login ticket (forgot password)
57 | elsif ($ticket->{type} eq 'fgtPwd') {
58 | # Set cookies
59 | $m->setCookie('login', "$dbUser->{id}:$dbUser->{loginAuth}", $dbUser->{tempLogin});
60 |
61 | # Delete user's login tickets
62 | $m->dbDo("
63 | DELETE FROM tickets WHERE userId = ? AND type = ?", $dbUser->{id}, 'fgtPwd');
64 |
65 | # Log action and finish
66 | $m->logAction(1, 'user', 'tkfgtpwd', $dbUser->{id});
67 | $m->redirect('user_password', msg => 'TkaFgtPwd');
68 | }
69 | # Email change ticket
70 | elsif ($ticket->{type} eq 'emlChg') {
71 | # Change email address
72 | $m->dbDo("
73 | UPDATE users SET email = ? WHERE id = ?", $ticket->{data}, $dbUser->{id});
74 |
75 | # Delete all email change tickets
76 | $m->dbDo("
77 | DELETE FROM tickets WHERE userId = ? AND type = ?", $dbUser->{id}, 'emlChg');
78 |
79 | # Log action and finish
80 | $m->logAction(1, 'user', 'tkemlchg', $dbUser->{id});
81 | $m->redirect('forum_show', msg => 'TkaEmlChg');
82 | }
83 |
--------------------------------------------------------------------------------
/script/forum_policy.pl:
--------------------------------------------------------------------------------
1 | #!/usr/bin/perl
2 | #------------------------------------------------------------------------------
3 | # mwForum - Web-based discussion forum
4 | # Copyright (c) 1999-2015 Markus Wichitill
5 | #
6 | # This program is free software; you can redistribute it and/or modify
7 | # it under the terms of the GNU General Public License as published by
8 | # the Free Software Foundation; either version 3 of the License, or
9 | # (at your option) any later version.
10 | #
11 | # This program is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | # GNU General Public License for more details.
15 | #------------------------------------------------------------------------------
16 |
17 | use strict;
18 | use warnings;
19 | no warnings qw(uninitialized redefine);
20 |
21 | # Imports
22 | use MwfMain;
23 |
24 | #------------------------------------------------------------------------------
25 |
26 | # Init
27 | my ($m, $cfg, $lng, $user, $userId) = MwfMain->new($_[0], allowBanned => 1);
28 |
29 | # Check if access should be denied
30 | $userId or $m->error('errNoAccess');
31 |
32 | # Get CGI parameters
33 | my $accept = $m->paramBool('accept');
34 | my $reject = $m->paramBool('reject');
35 | my $read = $m->paramBool('read');
36 | my $submitted = $m->paramBool('subm');
37 |
38 | # Process form
39 | if ($submitted) {
40 | if ($accept) {
41 | # Check request source authentication
42 | $m->checkSourceAuth() or $m->formError('errSrcAuth');
43 |
44 | # Check that policy was read
45 | $read or $m->formError('errPlcRead');
46 |
47 | # If there's no error, finish action
48 | if (!@{$m->{formErrors}}) {
49 | # Update user
50 | $m->dbDo("
51 | UPDATE users SET policyAccept = ? WHERE id = ?", $cfg->{policyVersion}, $userId);
52 |
53 | # Log action and finish
54 | $m->logAction(1, 'forum', 'policy', $userId);
55 | $m->redirect('forum_show');
56 | }
57 | }
58 | elsif ($reject) {
59 | $m->redirect('user_logout', auth => 1);
60 | }
61 | }
62 |
63 | # Print form
64 | if (!$submitted || @{$m->{formErrors}}) {
65 | # Print header
66 | $m->printHeader();
67 |
68 | # Print page bar
69 | $m->printPageBar(mainTitle => $cfg->{policyTitle});
70 |
71 | # Print hints and form errors
72 | $m->printFormErrors();
73 |
74 | # Print policy
75 | my $policyEsc = $m->escHtml($cfg->{policy}, 2);
76 | print
77 | "\n\n";
88 |
89 | # Log action and finish
90 | $m->logAction(3, 'forum', 'policy', $userId);
91 | $m->printFooter();
92 | }
93 | $m->finish();
94 |
--------------------------------------------------------------------------------
/script/group_admin.pl:
--------------------------------------------------------------------------------
1 | #!/usr/bin/perl
2 | #------------------------------------------------------------------------------
3 | # mwForum - Web-based discussion forum
4 | # Copyright (c) 1999-2015 Markus Wichitill
5 | #
6 | # This program is free software; you can redistribute it and/or modify
7 | # it under the terms of the GNU General Public License as published by
8 | # the Free Software Foundation; either version 3 of the License, or
9 | # (at your option) any later version.
10 | #
11 | # This program is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | # GNU General Public License for more details.
15 | #------------------------------------------------------------------------------
16 |
17 | use strict;
18 | use warnings;
19 | no warnings qw(uninitialized redefine);
20 |
21 | # Imports
22 | use MwfMain;
23 |
24 | #------------------------------------------------------------------------------
25 |
26 | # Init
27 | my ($m, $cfg, $lng, $user, $userId) = MwfMain->new($_[0]);
28 |
29 | # Check if user is admin
30 | $user->{admin} or $m->error('errNoAccess');
31 |
32 | # Print header
33 | $m->printHeader();
34 |
35 | # Print page bar
36 | my @navLinks = ({ url => $m->url('forum_show'), txt => 'comUp', ico => 'up' });
37 | $m->printPageBar(mainTitle => "Group Administration", navLinks => \@navLinks);
38 |
39 | # Print create board form
40 | print
41 | "\n\n";
50 |
51 | # Get groups
52 | my $groups = $m->fetchAllHash("
53 | SELECT id, title FROM groups ORDER BY title");
54 |
55 | # Print group list
56 | print
57 | "
\n",
58 | "
\n",
59 | "
Title
\n",
60 | "
Commands
\n",
61 | "
\n";
62 |
63 | for my $group (@$groups) {
64 | my $groupId = $group->{id};
65 | my $infUrl = $m->url('group_info', gid => $groupId);
66 | my $optUrl = $m->url('group_options', gid => $groupId, ori => 1);
67 | my $mbrUrl = $m->url('group_members', gid => $groupId);
68 | my $brdUrl = $m->url('group_boards', gid => $groupId, ori => 1);
69 | my $delUrl = $m->url('user_confirm', gid => $groupId, script => 'group_delete',
70 | name => $group->{title}, ori => 1);
71 | print
72 | "
\n\n"
91 | if $attach->{caption};
92 |
93 | # Log action and finish
94 | $m->logAction(2, 'attach', 'show', $userId, $board->{id}, 0, $postId, $attachId);
95 | $m->printFooter(1);
96 | $m->finish();
97 |
--------------------------------------------------------------------------------
/script/cron_admin.pl:
--------------------------------------------------------------------------------
1 | #!/usr/bin/perl
2 | #------------------------------------------------------------------------------
3 | # mwForum - Web-based discussion forum
4 | # Copyright (c) 1999-2015 Markus Wichitill
5 | #
6 | # This program is free software; you can redistribute it and/or modify
7 | # it under the terms of the GNU General Public License as published by
8 | # the Free Software Foundation; either version 3 of the License, or
9 | # (at your option) any later version.
10 | #
11 | # This program is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | # GNU General Public License for more details.
15 | #------------------------------------------------------------------------------
16 |
17 | use strict;
18 | use warnings;
19 | no warnings qw(uninitialized redefine);
20 |
21 | # Imports
22 | use MwfMain;
23 |
24 | #------------------------------------------------------------------------------
25 |
26 | # Init
27 | my ($m, $cfg, $lng, $user, $userId) = MwfMain->new($_[0]);
28 |
29 | # Check if user is admin
30 | $user->{admin} or $m->error('errNoAccess');
31 |
32 | # Get CGI parameters
33 | my $main = $m->paramBool('main');
34 | my $subs = $m->paramBool('subs');
35 | my $bounce = $m->paramBool('bounce');
36 | my $rss = $m->paramBool('rss');
37 | my $submitted = $m->paramBool('subm');
38 |
39 | # Process form
40 | if ($submitted) {
41 | # Check request source authentication
42 | $m->checkSourceAuth() or $m->formError('errSrcAuth');
43 |
44 | # If there's no error, finish action
45 | if (!@{$m->{formErrors}}) {
46 | # Spawn script
47 | if ($main) { $m->spawnScript('cron_jobs') }
48 | elsif ($subs) { $m->spawnScript('cron_subscriptions') }
49 | elsif ($bounce) { $m->spawnScript('cron_bounce') }
50 | elsif ($rss) { $m->spawnScript('cron_rss') }
51 |
52 | # Redirect to cronjob admin page
53 | $m->redirect('cron_admin');
54 | }
55 | }
56 |
57 | # Print form
58 | if (!$submitted || @{$m->{formErrors}}) {
59 | # Print header
60 | $m->printHeader();
61 |
62 | # Print page bar
63 | my @navLinks = ({ url => $m->url('forum_show'), txt => 'comUp', ico => 'up' });
64 | $m->printPageBar(mainTitle => "Cronjob Administration", navLinks => \@navLinks);
65 |
66 | # Print hints and form errors
67 | $m->printHints(["This method of manually starting cronjobs requires the"
68 | . " \$cfg->{scriptFsPath} and \$cfg->{perlBinary}"
69 | . " options to be set up."]);
70 | $m->printFormErrors();
71 |
72 | # Print execution form
73 | print
74 | "
\n",
75 | "
Execute Cronjobs
\n",
76 | "
\n",
77 | "\n",
86 | "
\n",
87 | "
\n\n";
88 |
89 | # Log action and finish
90 | $m->logAction(3, 'cron', 'admin', $userId);
91 | $m->printFooter();
92 | }
93 | $m->finish();
94 |
--------------------------------------------------------------------------------
/script/topic_info.pl:
--------------------------------------------------------------------------------
1 | #!/usr/bin/perl
2 | #------------------------------------------------------------------------------
3 | # mwForum - Web-based discussion forum
4 | # Copyright (c) 1999-2015 Markus Wichitill
5 | #
6 | # This program is free software; you can redistribute it and/or modify
7 | # it under the terms of the GNU General Public License as published by
8 | # the Free Software Foundation; either version 3 of the License, or
9 | # (at your option) any later version.
10 | #
11 | # This program is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | # GNU General Public License for more details.
15 | #------------------------------------------------------------------------------
16 |
17 | use strict;
18 | use warnings;
19 | no warnings qw(uninitialized redefine);
20 |
21 | # Imports
22 | use MwfMain;
23 |
24 | #------------------------------------------------------------------------------
25 |
26 | # Init
27 | my ($m, $cfg, $lng, $user, $userId) = MwfMain->new($_[0]);
28 |
29 | # Print header
30 | $m->printHeader();
31 |
32 | # Get CGI parameters
33 | my $topicId = $m->paramInt('tid');
34 | $topicId or $m->error('errParamMiss');
35 |
36 | # Get topic
37 | my $topic = $m->fetchHash("
38 | SELECT * FROM topics WHERE id = ?", $topicId);
39 | $topic or $m->error('errTpcNotFnd');
40 | my $boardId = $topic->{boardId};
41 |
42 | # Get board
43 | my $board = $m->fetchHash("
44 | SELECT * FROM boards WHERE id = ?", $topic->{boardId});
45 | $board or $m->error('errBrdNotFnd');
46 |
47 | # Is board visible to user?
48 | my $boardAdmin = $user->{admin} || $m->boardAdmin($userId, $boardId);
49 | $boardAdmin || $m->boardVisible($board) or $m->error('errNoAccess');
50 |
51 | # Print page bar
52 | my @navLinks = ({ url => $m->url('topic_show', tid => $topicId), txt => 'comUp', ico => 'up' });
53 | $m->printPageBar(mainTitle => "Topic Info", subTitle => $topic->{subject},
54 | navLinks => \@navLinks);
55 |
56 | # Print topic tag
57 | if ($topic->{tag}) {
58 | my ($title) = $cfg->{topicTags}{$topic->{tag}} =~ /[\w.]+\s*(.*)?/;
59 | print
60 | "
\n\n";
90 | }
91 |
92 | # Log action and finish
93 | $m->logAction(3, 'topic', 'info', $userId, $boardId, $topicId);
94 | $m->printFooter();
95 | $m->finish();
96 |
--------------------------------------------------------------------------------
/script/user_mark.pl:
--------------------------------------------------------------------------------
1 | #!/usr/bin/perl
2 | #------------------------------------------------------------------------------
3 | # mwForum - Web-based discussion forum
4 | # Copyright (c) 1999-2015 Markus Wichitill
5 | #
6 | # This program is free software; you can redistribute it and/or modify
7 | # it under the terms of the GNU General Public License as published by
8 | # the Free Software Foundation; either version 3 of the License, or
9 | # (at your option) any later version.
10 | #
11 | # This program is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | # GNU General Public License for more details.
15 | #------------------------------------------------------------------------------
16 |
17 | use strict;
18 | use warnings;
19 | no warnings qw(uninitialized redefine);
20 |
21 | # Imports
22 | use MwfMain;
23 |
24 | #------------------------------------------------------------------------------
25 |
26 | # Init
27 | my ($m, $cfg, $lng, $user, $userId) = MwfMain->new($_[0]);
28 |
29 | # Get CGI parameters
30 | my $action = $m->paramStrId('act');
31 | my $boardId = $m->paramInt('bid') || 0;
32 | my $time = $m->paramInt('time');
33 |
34 | if ($userId) {
35 | # Check request source authentication
36 | $m->checkSourceAuth() or $m->error('errSrcAuth');
37 |
38 | if ($action eq 'old') {
39 | # Mark messages as old by setting prevOnTime
40 | $m->{userUpdates}{prevOnTime} = $time;
41 | $m->setCookie('prevon', $time);
42 |
43 | # Log action and finish
44 | $m->logAction(1, 'user', 'markold', $userId);
45 | $m->redirect('forum_show', msg => 'MarkOld');
46 | }
47 | elsif ($action eq 'read') {
48 | if ($boardId) {
49 | # Mark all unread topics read
50 | my $lowestUnreadTime = $m->{now} - $cfg->{maxUnreadDays} * 86400;
51 | my $tmp = 'userMark' . int(rand(2147483647));
52 | $m->dbDo("
53 | CREATE TEMPORARY TABLE $tmp AS
54 | SELECT topics.id AS id
55 | FROM topics AS topics
56 | LEFT JOIN topicReadTimes AS topicReadTimes
57 | ON topicReadTimes.userId = :userId
58 | AND topicReadTimes.topicId = topics.id
59 | WHERE topics.boardId = :boardId
60 | AND topics.lastPostTime > :lowestUnreadTime
61 | AND (topics.lastPostTime > topicReadTimes.lastReadTime
62 | OR topicReadTimes.topicId IS NULL)",
63 | { userId => $userId, boardId => $boardId, lowestUnreadTime => $lowestUnreadTime });
64 | $m->dbDo("
65 | DELETE FROM topicReadTimes WHERE userId = ? AND topicId IN (SELECT id FROM $tmp)",
66 | $userId);
67 | $m->dbDo("
68 | INSERT INTO topicReadTimes SELECT ?, id, ? FROM $tmp", $userId, $m->{now});
69 | $m->dbDo("
70 | DROP TABLE $tmp");
71 | }
72 | else {
73 | # Mark everything read by setting fakeReadTime
74 | $m->{userUpdates}{fakeReadTime} = $time;
75 | $m->dbDo("
76 | DELETE FROM topicReadTimes WHERE userId = ?", $userId);
77 | }
78 |
79 | # Log action and finish
80 | $m->logAction(1, 'user', 'markread', $userId, $boardId);
81 | $m->redirect('forum_show', msg => 'MarkRead');
82 | }
83 | }
84 | else {
85 | if ($action eq 'old') {
86 | # Mark messages as old by setting prevOnTime in cookie
87 | $m->setCookie('prevon', $time);
88 |
89 | # Log action and finish
90 | $m->logAction(2, 'guest', 'markold');
91 | $m->redirect('forum_show', msg => 'MarkOld');
92 | }
93 | else {
94 | $m->error('errNoAccess');
95 | }
96 | }
97 |
--------------------------------------------------------------------------------
/script/user_wipe.pl:
--------------------------------------------------------------------------------
1 | #!/usr/bin/perl
2 | #------------------------------------------------------------------------------
3 | # mwForum - Web-based discussion forum
4 | # Copyright (c) 1999-2015 Markus Wichitill
5 | #
6 | # This program is free software; you can redistribute it and/or modify
7 | # it under the terms of the GNU General Public License as published by
8 | # the Free Software Foundation; either version 3 of the License, or
9 | # (at your option) any later version.
10 | #
11 | # This program is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | # GNU General Public License for more details.
15 | #------------------------------------------------------------------------------
16 |
17 | use strict;
18 | use warnings;
19 | no warnings qw(uninitialized redefine);
20 |
21 | # Imports
22 | use MwfMain;
23 |
24 | #------------------------------------------------------------------------------
25 |
26 | # Init
27 | my ($m, $cfg, $lng, $user, $userId) = MwfMain->new($_[0]);
28 |
29 | # Check if user is admin
30 | $user->{admin} or $m->error('errNoAccess');
31 |
32 | # Get CGI parameters
33 | my $wipeUserId = $m->paramInt('uid');
34 | my $submitted = $m->paramBool('subm');
35 | $wipeUserId or $m->error('errParamMiss');
36 |
37 | # Get user
38 | my $wipeUser = $m->getUser($wipeUserId);
39 | $wipeUser or $m->error('errUsrNotFnd');
40 | !$wipeUser->{admin} or $m->error("Wiping admins is not allowed for security reasons.");
41 |
42 | # Process form
43 | if ($submitted) {
44 | # Check request source authentication
45 | $m->checkSourceAuth() or $m->formError('errSrcAuth');
46 |
47 | # If there's no error, finish action
48 | if (!@{$m->{formErrors}}) {
49 | # Wipe user
50 | $m->deleteUser($wipeUserId, 1);
51 |
52 | # Log action and finish
53 | $m->logAction(1, 'user', 'wipe', $userId, 0, 0, 0, $wipeUserId);
54 | $m->redirect('user_info', uid => $wipeUserId);
55 | }
56 | }
57 |
58 | # Print form
59 | if (!$submitted || @{$m->{formErrors}}) {
60 | # Print header
61 | $m->printHeader();
62 |
63 | # Print page bar
64 | my @navLinks = ({ url => $m->url('user_info', uid => $wipeUserId), txt => 'comUp', ico => 'up' });
65 | $m->printPageBar(mainTitle => "User", subTitle => $wipeUser->{userName}, navLinks => \@navLinks);
66 |
67 | # Print hints and form errors
68 | $m->printHints([
69 | "Wiping a user account means clearing all profile fields, resetting Email, Password and OpenID".
70 | " (making login impossible), and deleting various related entries from other database tables.".
71 | " The account itself remains, and the Real Name, Email and OpenID fields will be copied into".
72 | " the Comments field (only visible to admins). Useful when a user wants to be deleted, but".
73 | " when that is undesirable for accountability reasons."]);
74 | $m->printFormErrors();
75 |
76 | # Print notification message form
77 | print
78 | "\n\n";
88 |
89 | # Log action and finish
90 | $m->logAction(3, 'user', 'wipe', $userId, 0, 0, 0, $wipeUserId);
91 | $m->printFooter();
92 | }
93 | $m->finish();
94 |
--------------------------------------------------------------------------------
/script/chat_show.pl:
--------------------------------------------------------------------------------
1 | #!/usr/bin/perl
2 | #------------------------------------------------------------------------------
3 | # mwForum - Web-based discussion forum
4 | # Copyright (c) 1999-2015 Markus Wichitill
5 | #
6 | # This program is free software; you can redistribute it and/or modify
7 | # it under the terms of the GNU General Public License as published by
8 | # the Free Software Foundation; either version 3 of the License, or
9 | # (at your option) any later version.
10 | #
11 | # This program is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | # GNU General Public License for more details.
15 | #------------------------------------------------------------------------------
16 |
17 | use strict;
18 | use warnings;
19 | no warnings qw(uninitialized redefine);
20 |
21 | # Imports
22 | use MwfMain;
23 |
24 | #------------------------------------------------------------------------------
25 |
26 | # Init
27 | my ($m, $cfg, $lng, $user, $userId) = MwfMain->new($_[0]);
28 |
29 | # Check if access should be denied
30 | $cfg->{chat} or $m->error('errNoAccess');
31 | $cfg->{chat} != 2 || $userId or $m->error('errNoAccess');
32 |
33 | # Update user's read time
34 | $m->{userUpdates}{chatReadTime} = $m->{now} if $userId;
35 |
36 | # Print header
37 | $m->printHeader();
38 |
39 | # Print page bar
40 | my @navLinks = ({ url => $m->url('forum_show'), txt => 'comUp', ico => 'up' });
41 | my @userLinks = ();
42 | push @userLinks, { url => $m->url('chat_show'), txt => 'chtRefresh', ico => 'refresh' };
43 | push @userLinks, { url => $m->url('user_confirm', script => 'chat_delete', act => 'all'),
44 | txt => 'chtDelAll', ico => 'delete' }
45 | if $user->{admin};
46 | $m->printPageBar(mainTitle => $lng->{chtTitle}, navLinks => \@navLinks, userLinks => \@userLinks);
47 |
48 | # Get chat messages
49 | my $chatReadTime = $user->{chatReadTime} || 2147483647;
50 | my $chats = $m->fetchAllHash("
51 | SELECT chat.*, chat.postTime > :chatReadTime AS unread,
52 | users.userName
53 | FROM chat AS chat
54 | INNER JOIN users AS users
55 | ON users.id = chat.userId
56 | ORDER BY chat.id DESC
57 | LIMIT :chatMaxMsgs",
58 | { chatReadTime => $chatReadTime, chatMaxMsgs => $cfg->{chatMaxMsgs} });
59 |
60 | # Print chat input field
61 | print
62 | "\n\n",
72 | if $userId;
73 |
74 | # Print chat messages
75 | print
76 | "
\n",
77 | "
$lng->{chtMsgsTtl}
\n";
78 |
79 | for my $chat (@$chats) {
80 | # Format output
81 | my $url = $m->url('user_info', uid => $chat->{userId});
82 | my $userNameStr = "$chat->{userName}";
83 | my $shortTimeStr = $m->formatTime($chat->{postTime}, $user->{timezone}, "%H:%M");
84 | $shortTimeStr = "$shortTimeStr" if $chat->{unread};
85 |
86 | print
87 | "
\n\n";
93 |
94 | # Log action and finish
95 | $m->logAction(2, 'chat', 'show', $userId);
96 | $m->printFooter();
97 | $m->finish();
98 |
--------------------------------------------------------------------------------
/script/message_export.pl:
--------------------------------------------------------------------------------
1 | #!/usr/bin/perl
2 | #------------------------------------------------------------------------------
3 | # mwForum - Web-based discussion forum
4 | # Copyright (c) 1999-2015 Markus Wichitill
5 | #
6 | # This program is free software; you can redistribute it and/or modify
7 | # it under the terms of the GNU General Public License as published by
8 | # the Free Software Foundation; either version 3 of the License, or
9 | # (at your option) any later version.
10 | #
11 | # This program is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | # GNU General Public License for more details.
15 | #------------------------------------------------------------------------------
16 |
17 | use strict;
18 | use warnings;
19 | no warnings qw(uninitialized redefine);
20 |
21 | # Imports
22 | use MwfMain;
23 |
24 | #------------------------------------------------------------------------------
25 |
26 | # Init
27 | my ($m, $cfg, $lng, $user, $userId) = MwfMain->new($_[0]);
28 |
29 | # Check if access should be denied
30 | $cfg->{messages} or $m->error('errNoAccess');
31 | $userId or $m->error('errNoAccess');
32 |
33 | # Get messages
34 | my $messages = $m->fetchAllHash("
35 | SELECT messages.*,
36 | senders.userName AS senderName,
37 | receivers.userName AS receiverName
38 | FROM messages AS messages
39 | INNER JOIN users AS senders
40 | ON senders.id = messages.senderId
41 | INNER JOIN users AS receivers
42 | ON receivers.id = messages.receiverId
43 | WHERE (messages.senderId = :userId AND messages.sentbox = 1)
44 | OR (messages.receiverId = :userId AND messages.inbox = 1)
45 | ORDER BY messages.sendTime DESC",
46 | { userId => $userId });
47 |
48 | # Print header
49 | $m->printHttpHeader({ 'content-disposition' => "attachment; filename=Messages.html" });
50 | my $fontFaceStr = $user->{fontFace} ? "font-family: '$user->{fontFace}', sans-serif;" : "";
51 | my $fontSizeStr = $user->{fontSize} ? "font-size: $user->{fontSize}px;" : "";
52 | print
53 | "\n",
54 | "\n",
55 | "\n",
56 | "$lng->{mslTitle}\n",
57 | "\n",
58 | "\n",
66 | "\n",
67 | "\n\n";
68 |
69 | # Print messages
70 | for my $msg (@$messages) {
71 | # Print message
72 | my $subject = $msg->{subject};
73 | $subject =~ s!Re: !!;
74 | my $time = $m->formatTime($msg->{sendTime}, $user->{timezone});
75 | my $timeIso = $m->formatTime($msg->{sendTime}, 0, "%Y-%m-%dT%TZ");
76 | print
77 | "\n",
78 | "\n",
79 | "
$subject
\n",
80 | "
\n",
81 | "
$lng->{mssFrom}
$msg->{senderName}
\n",
82 | "
$lng->{mssTo}
$msg->{receiverName}
\n",
83 | "
$lng->{mssDate}
\n",
84 | "
\n",
85 | "\n",
86 | "
\n$msg->{body}\n
\n",
87 | "\n\n";
88 | }
89 |
90 | print
91 | "\n",
92 | "\n";
93 |
94 | # Log action and finish
95 | $m->logAction(2, 'msg', 'export', $userId);
96 | $m->finish();
97 |
--------------------------------------------------------------------------------
/util/util_replace.pl:
--------------------------------------------------------------------------------
1 | #!/usr/bin/perl
2 | #------------------------------------------------------------------------------
3 | # mwForum - Web-based discussion forum
4 | # Copyright (c) 1999-2015 Markus Wichitill
5 | #
6 | # This program is free software; you can redistribute it and/or modify
7 | # it under the terms of the GNU General Public License as published by
8 | # the Free Software Foundation; either version 3 of the License, or
9 | # (at your option) any later version.
10 | #
11 | # This program is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | # GNU General Public License for more details.
15 | #------------------------------------------------------------------------------
16 |
17 | # Search and replace text in mwForum database fields.
18 |
19 | use strict;
20 | use warnings;
21 | no warnings qw(uninitialized);
22 |
23 | # Imports
24 | use Getopt::Std ();
25 | require MwfMain;
26 |
27 | # Get arguments
28 | my %opts = ();
29 | Getopt::Std::getopts('?hxiquf:t:c:', \%opts);
30 | my $help = $opts{'?'} || $opts{h};
31 | my $execute = $opts{x};
32 | my $caseIns = $opts{i};
33 | my $quiet = $opts{q};
34 | my $mysqlUseResult = $opts{u};
35 | my $forumId = $opts{f};
36 | my $table = $opts{t} || 'posts';
37 | my $col = $opts{c} || 'body';
38 | my $txt1 = $ARGV[0];
39 | my $txt2 = $ARGV[1];
40 | usage() if $help || !length($txt1);
41 |
42 | # Init
43 | my ($m, $cfg, $lng) = MwfMain->newShell(forumId => $forumId);
44 | $m->{dbh}{mysql_use_result} = 1 if $mysqlUseResult;
45 |
46 | # Decode UTF-8 or treat as Latin1
47 | utf8::decode($txt1) or utf8::upgrade($txt1);
48 | utf8::decode($txt2) or utf8::upgrade($txt2);
49 |
50 | # Search and replace
51 | $m->dbBegin();
52 | my $sum = 0;
53 | my $switch = $caseIns ? "(?i)" : "";
54 | my $updSth = $m->dbPrepare("
55 | UPDATE $table SET $col = ? WHERE id = ?");
56 | my $selSth = $m->fetchSth("
57 | SELECT id, $col FROM $table");
58 | my ($id, $body);
59 | $selSth->bind_columns(\($id, $body));
60 | while ($selSth->fetch()) {
61 | utf8::decode($body);
62 | my $num = $body =~ s!$switch$txt1!$txt2!go;
63 | $sum += $num;
64 | if ($execute && $num) {
65 | # Replace
66 | $m->dbExecute($updSth, $body, $id);
67 | print "Replaced $num occurrences in #$id\n" if !$quiet;
68 | }
69 | else {
70 | # Print occurrences only
71 | print "Found $num occurrences in #$id\n" if !$quiet && $num;
72 | }
73 | }
74 | $m->dbCommit();
75 |
76 | # Print sum of occurrences
77 | my $verb = $execute ? "Replaced" : "Found";
78 | print "$verb $sum occurrences\n";
79 |
80 | #------------------------------------------------------------------------------
81 |
82 | sub usage
83 | {
84 | print
85 | "\nSearch and replace in database fields.\n\n",
86 | "Usage: util_replace.pl [-xiq] [-f forum] [-t table] [-c column] [--] searchExp [replaceExp]\n",
87 | " -x Execute replacements. Otherwise, only number of occurrences is printed.\n",
88 | " -i Search-expression is case-insensitive.\n",
89 | " -q Quiet, print summary only.\n",
90 | " -f Forum hostname or URL path when using a multi-forum installation.\n",
91 | " -t Table name, default: posts.\n",
92 | " -c Column name, default: body.\n",
93 | "\nNotes:\n",
94 | " - searchExp is a regular expression.\n",
95 | " - replaceExp cannot use backreferences.\n",
96 | " - Can only be used on tables with an 'id' field.\n",
97 | " - Non-ASCII characters may not work if not passed as UTF-8 or Latin1.\n",
98 | ;
99 |
100 | exit 1;
101 | }
102 |
--------------------------------------------------------------------------------
/script/post_delete.pl:
--------------------------------------------------------------------------------
1 | #!/usr/bin/perl
2 | #------------------------------------------------------------------------------
3 | # mwForum - Web-based discussion forum
4 | # Copyright (c) 1999-2015 Markus Wichitill
5 | #
6 | # This program is free software; you can redistribute it and/or modify
7 | # it under the terms of the GNU General Public License as published by
8 | # the Free Software Foundation; either version 3 of the License, or
9 | # (at your option) any later version.
10 | #
11 | # This program is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | # GNU General Public License for more details.
15 | #------------------------------------------------------------------------------
16 |
17 | use strict;
18 | use warnings;
19 | no warnings qw(uninitialized redefine);
20 |
21 | # Imports
22 | use MwfMain;
23 |
24 | #------------------------------------------------------------------------------
25 |
26 | # Init
27 | my ($m, $cfg, $lng, $user, $userId) = MwfMain->new($_[0]);
28 |
29 | # Get CGI parameters
30 | my $postId = $m->paramInt('pid');
31 | my $notify = $m->paramBool('notify');
32 | my $reason = $m->paramStr('reason');
33 | $postId or $m->error('errParamMiss');
34 |
35 | # Check request source authentication
36 | $m->checkSourceAuth() or $m->error('errSrcAuth');
37 |
38 | # Get post
39 | my $post = $m->fetchHash("
40 | SELECT posts.*,
41 | topics.pollId, topics.subject
42 | FROM posts AS posts
43 | INNER JOIN topics AS topics
44 | ON topics.id = posts.topicId
45 | WHERE posts.id = ?", $postId);
46 | $post or $m->error('errPstNotFnd');
47 | my $boardId = $post->{boardId};
48 | my $topicId = $post->{topicId};
49 |
50 | # Get board
51 | my $board = $m->fetchHash("
52 | SELECT * FROM boards WHERE id = ?", $boardId);
53 |
54 | # Check if user can see and write to board
55 | my $boardAdmin = $user->{admin} || $m->boardAdmin($userId, $boardId)
56 | || $board->{topicAdmins} && $m->topicAdmin($userId, $topicId);
57 | $boardAdmin || $m->boardVisible($board) or $m->error('errNoAccess');
58 | $boardAdmin || $m->boardWritable($board, 1) or $m->error('errNoAccess');
59 |
60 | # Check if user owns post or is moderator
61 | $userId && $userId == $post->{userId} || $boardAdmin or $m->error('errNoAccess');
62 |
63 | # Check editing time limitation
64 | !$cfg->{postEditTime} || $m->{now} < $post->{postTime} + $cfg->{postEditTime}
65 | || $boardAdmin || $m->boardMember($userId, $boardId)
66 | or $m->error('errPstEdtTme');
67 |
68 | # Check if topic or post is locked
69 | !$m->fetchArray("
70 | SELECT locked FROM topics WHERE id = ?", $topicId)
71 | || $boardAdmin or $m->error('errTpcLocked');
72 | !$post->{locked} || $boardAdmin or $m->error('errPstLocked');
73 |
74 | # Check authorization
75 | $m->checkAuthz($user, 'deletePost');
76 |
77 | # Delete post
78 | my $trash = $cfg->{trashBoardId} && $cfg->{trashBoardId} != $boardId;
79 | my $topicDeleted = $m->deletePost($postId, $trash);
80 | $m->recalcStats($boardId, $topicId);
81 |
82 | # Add notification message
83 | if ($notify && $post->{userId} && $post->{userId} != $userId) {
84 | if ($topicDeleted) {
85 | $m->addNote('tpcDel', $post->{userId}, 'notTpcDel', tpcSbj => $post->{subject}, reason => $reason);
86 | }
87 | else {
88 | my $url = "topic_show$m->{ext}?tid=$topicId";
89 | $m->addNote('pstDel', $post->{userId}, 'notPstDel', tpcUrl => $url, reason => $reason);
90 | }
91 | }
92 |
93 | # Log action and finish
94 | $m->logAction(1, 'post', 'delete', $userId, $boardId, $topicId, $postId);
95 | $m->redirect('board_show', bid => $boardId, msg => 'PstTpcDel') if $topicDeleted;
96 | $m->redirect('topic_show', $post->{parentId} ? (pid => $post->{parentId}) : (tid => $topicId),
97 | msg => 'PstDel');
98 |
--------------------------------------------------------------------------------
/script/board_archive.pl:
--------------------------------------------------------------------------------
1 | #!/usr/bin/perl
2 | #------------------------------------------------------------------------------
3 | # mwForum - Web-based discussion forum
4 | # Copyright (c) 1999-2015 Markus Wichitill
5 | #
6 | # This program is free software; you can redistribute it and/or modify
7 | # it under the terms of the GNU General Public License as published by
8 | # the Free Software Foundation; either version 3 of the License, or
9 | # (at your option) any later version.
10 | #
11 | # This program is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | # GNU General Public License for more details.
15 | #------------------------------------------------------------------------------
16 |
17 | use strict;
18 | use warnings;
19 | no warnings qw(uninitialized redefine);
20 |
21 | # Imports
22 | use MwfMain;
23 |
24 | #------------------------------------------------------------------------------
25 |
26 | # Init
27 | my ($m, $cfg, $lng, $user, $userId) = MwfMain->new($_[0]);
28 |
29 | # Check if user is admin
30 | $user->{admin} or $m->error('errNoAccess');
31 |
32 | # Get CGI parameters
33 | my $boardId = $m->paramInt('bid');
34 | my $submitted = $m->paramBool('subm');
35 | $boardId or $m->error('errParamMiss');
36 |
37 | # Get board
38 | my $boardTitle = $m->fetchArray("
39 | SELECT title FROM boards WHERE id = ?", $boardId);
40 | $boardTitle or $m->error('errBrdNotFnd');
41 |
42 | # Process form
43 | if ($submitted) {
44 | # Check request source authentication
45 | $m->checkSourceAuth() or $m->formError('errSrcAuth');
46 |
47 | # If there's no error, finish action
48 | if (!@{$m->{formErrors}}) {
49 | # Delete old archive contents
50 | $m->dbDo("
51 | DELETE FROM arc_boards WHERE id = ?", $boardId);
52 | $m->dbDo("
53 | DELETE FROM arc_topics WHERE boardId = ?", $boardId);
54 | $m->dbDo("
55 | DELETE FROM arc_posts WHERE boardId = ?", $boardId);
56 |
57 | # Copy boards, topics and posts
58 | $m->dbDo("
59 | INSERT INTO arc_boards
60 | SELECT * FROM boards WHERE id = ?", $boardId);
61 | $m->dbDo("
62 | INSERT INTO arc_topics
63 | SELECT * FROM topics WHERE boardId = ?", $boardId);
64 | $m->dbDo("
65 | INSERT INTO arc_posts
66 | SELECT * FROM posts WHERE boardId = ?", $boardId);
67 |
68 | # Log action and finish
69 | $m->logAction(1, 'board', 'archive', $userId, $boardId);
70 | $m->redirect('board_show', bid => $boardId);
71 | }
72 | }
73 |
74 | # Print forms
75 | if (!$submitted || @{$m->{formErrors}}) {
76 | # Print header
77 | $m->printHeader();
78 |
79 | # Print page bar
80 | my @navLinks = ({ url => $m->url('board_show', bid => $boardId), txt => 'comUp', ico => 'up' });
81 | $m->printPageBar(mainTitle => "Board", subTitle => $boardTitle, navLinks => \@navLinks);
82 |
83 | # Print hints and form errors
84 | $m->printHints(["Archiving a board copies the board and its topics and posts into separate".
85 | " archive tables. Archiving a board that has been archived before will delete the old".
86 | " archive contents. See FAQ.html for details."]);
87 | $m->printFormErrors();
88 |
89 | # Print form
90 | print
91 | "\n\n";
101 |
102 | # Log action and finish
103 | $m->logAction(3, 'board', 'archive', $userId, $boardId);
104 | $m->printFooter();
105 | }
106 | $m->finish();
107 |
--------------------------------------------------------------------------------
/script/board_merge.pl:
--------------------------------------------------------------------------------
1 | #!/usr/bin/perl
2 | #------------------------------------------------------------------------------
3 | # mwForum - Web-based discussion forum
4 | # Copyright (c) 1999-2015 Markus Wichitill
5 | #
6 | # This program is free software; you can redistribute it and/or modify
7 | # it under the terms of the GNU General Public License as published by
8 | # the Free Software Foundation; either version 3 of the License, or
9 | # (at your option) any later version.
10 | #
11 | # This program is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | # GNU General Public License for more details.
15 | #------------------------------------------------------------------------------
16 |
17 | use strict;
18 | use warnings;
19 | no warnings qw(uninitialized redefine);
20 |
21 | # Imports
22 | use MwfMain;
23 |
24 | #------------------------------------------------------------------------------
25 |
26 | # Init
27 | my ($m, $cfg, $lng, $user, $userId) = MwfMain->new($_[0]);
28 |
29 | # Check if user is admin
30 | $user->{admin} or $m->error('errNoAccess');
31 |
32 | # Get CGI parameters
33 | my $oldBoardId = $m->paramInt('bid');
34 | my $newBoardId = $m->paramInt('newBoardId');
35 | my $submitted = $m->paramBool('subm');
36 | $oldBoardId or $m->error('errParamMiss');
37 |
38 | # Get board
39 | my $boardTitle = $m->fetchArray("
40 | SELECT title FROM boards WHERE id = ?", $oldBoardId);
41 | $boardTitle or $m->error('errBrdNotFnd');
42 |
43 | # Process form
44 | if ($submitted) {
45 | # Check request source authentication
46 | $m->checkSourceAuth() or $m->formError('errSrcAuth');
47 |
48 | # Check if new board selected
49 | $newBoardId or $m->formError("No board selected.");
50 |
51 | # If there's no error, finish action
52 | if (!@{$m->{formErrors}}) {
53 | # Update posts, topics and board
54 | $m->dbDo("
55 | UPDATE posts SET boardId = ? WHERE boardId = ?", $newBoardId, $oldBoardId);
56 | $m->dbDo("
57 | UPDATE topics SET boardId = ? WHERE boardId = ?", $newBoardId, $oldBoardId);
58 | $m->recalcStats([ $oldBoardId, $newBoardId ]);
59 |
60 | # Log action and finish
61 | $m->logAction(1, 'board', 'merge', $userId, $oldBoardId, 0, 0, $newBoardId);
62 | $m->redirect('board_show', bid => $oldBoardId);
63 | }
64 | }
65 |
66 | # Print forms
67 | if (!$submitted || @{$m->{formErrors}}) {
68 | # Print header
69 | $m->printHeader();
70 |
71 | # Print page bar
72 | my @navLinks = ({ url => $m->url('board_show', bid => $oldBoardId),
73 | txt => 'comUp', ico => 'up' });
74 | $m->printPageBar(mainTitle => "Board", subTitle => $boardTitle, navLinks => \@navLinks);
75 |
76 | # Print hints and form errors
77 | $m->printFormErrors();
78 |
79 | # Get boards
80 | my $boards = $m->fetchAllHash("
81 | SELECT boards.id, boards.title,
82 | categories.title AS categTitle
83 | FROM boards AS boards
84 | INNER JOIN categories AS categories
85 | ON categories.id = boards.categoryId
86 | ORDER BY categories.pos, boards.pos");
87 |
88 | # Print destination board form
89 | print
90 | "\n\n";
104 |
105 | # Log action and finish
106 | $m->logAction(3, 'board', 'merge', $userId, $oldBoardId);
107 | $m->printFooter();
108 | }
109 | $m->finish();
110 |
--------------------------------------------------------------------------------
/script/user_confirm.pl:
--------------------------------------------------------------------------------
1 | #!/usr/bin/perl
2 | #------------------------------------------------------------------------------
3 | # mwForum - Web-based discussion forum
4 | # Copyright (c) 1999-2015 Markus Wichitill
5 | #
6 | # This program is free software; you can redistribute it and/or modify
7 | # it under the terms of the GNU General Public License as published by
8 | # the Free Software Foundation; either version 3 of the License, or
9 | # (at your option) any later version.
10 | #
11 | # This program is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | # GNU General Public License for more details.
15 | #------------------------------------------------------------------------------
16 |
17 | use strict;
18 | use warnings;
19 | no warnings qw(uninitialized redefine);
20 |
21 | # Imports
22 | use MwfMain;
23 |
24 | #------------------------------------------------------------------------------
25 |
26 | # Init
27 | my ($m, $cfg, $lng, $user, $userId) = MwfMain->new($_[0]);
28 |
29 | # Get CGI parameters
30 | my ($script) = $m->paramStr('script') =~ /^([A-Za-z_0-9]+)\z/;
31 | my $act = $m->paramStrId('act');
32 | my $uid = $m->paramInt('uid');
33 | my $gid = $m->paramInt('gid');
34 | my $cid = $m->paramInt('cid');
35 | my $bid = $m->paramInt('bid');
36 | my $tid = $m->paramInt('tid');
37 | my $pid = $m->paramInt('pid');
38 | my $mid = $m->paramInt('mid');
39 | my $pollId = $m->paramInt('pollId');
40 | my $name = $m->paramStr('name');
41 | my $notify = $m->paramBool('notify');
42 |
43 | # Print header
44 | $m->printHeader();
45 |
46 | # Determine entity type
47 | my $entity = "";
48 | if ($pollId) { $entity = $lng->{cnfTypePoll} }
49 | elsif ($uid) { $entity = $lng->{cnfTypeUser} }
50 | elsif ($gid) { $entity = $lng->{cnfTypeGroup} }
51 | elsif ($cid) { $entity = $lng->{cnfTypeCateg} }
52 | elsif ($bid) { $entity = $lng->{cnfTypeBoard} }
53 | elsif ($tid) { $entity = $lng->{cnfTypeTopic} }
54 | elsif ($pid) { $entity = $lng->{cnfTypePost} }
55 | elsif ($mid) { $entity = $lng->{cnfTypeMsg} }
56 |
57 | # Determine question
58 | my $question = "";
59 | if ($script eq 'post_attach') {
60 | $question = $lng->{cnfDelAllAtt};
61 | }
62 | elsif ($entity) {
63 | my $nameEsc = $m->escHtml($m->deescHtml($name));
64 | $question = "$lng->{cnfQuestion} $entity \"$nameEsc\"$lng->{cnfQuestion2}";
65 | }
66 | elsif ($script eq 'message_delete') {
67 | $question = $lng->{cnfDelAllMsg};
68 | }
69 | elsif ($script eq 'chat_delete') {
70 | $question = $lng->{cnfDelAllCht};
71 | }
72 |
73 | # Print confirmation form
74 | print
75 | "\n\n";
109 |
110 | # Print footer
111 | $m->printFooter();
112 | $m->finish();
113 |
--------------------------------------------------------------------------------
/script/spawn_upgrade.pl:
--------------------------------------------------------------------------------
1 | #!/usr/bin/perl
2 | #------------------------------------------------------------------------------
3 | # mwForum - Web-based discussion forum
4 | # Copyright (c) 1999-2015 Markus Wichitill
5 | #
6 | # This program is free software; you can redistribute it and/or modify
7 | # it under the terms of the GNU General Public License as published by
8 | # the Free Software Foundation; either version 3 of the License, or
9 | # (at your option) any later version.
10 | #
11 | # This program is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | # GNU General Public License for more details.
15 | #------------------------------------------------------------------------------
16 |
17 | use strict;
18 | use warnings;
19 | no warnings qw(uninitialized redefine);
20 |
21 | # Imports
22 | use MwfMain;
23 |
24 | #------------------------------------------------------------------------------
25 |
26 | # Init
27 | my ($m, $cfg, $lng, $user, $userId) = MwfMain->new($_[0]);
28 |
29 | # Check if user is admin
30 | $user->{admin} or $m->error('errNoAccess');
31 |
32 | # Get CGI parameters
33 | my $test = $m->paramBool('test');
34 | my $upgrade = $m->paramBool('upgrade');
35 | my $wipe = $m->paramBool('wipe');
36 | my $submitted = $m->paramBool('subm');
37 |
38 | # Process form
39 | if ($submitted) {
40 | # Check request source authentication
41 | $m->checkSourceAuth() or $m->formError('errSrcAuth');
42 |
43 | # If there's no error, finish action
44 | if (!@{$m->{formErrors}}) {
45 | if ($upgrade) { $m->spawnScript('upgrade') }
46 | elsif ($test) { $m->spawnScript('spawn_test') }
47 | elsif ($wipe) {
48 | # Wipe last output
49 | $m->dbDo("
50 | DELETE FROM variables WHERE name = ?", 'upgOutput');
51 | }
52 |
53 | # Redirect to same page
54 | $m->redirect('spawn_upgrade');
55 | }
56 | }
57 |
58 | # Print form
59 | if (!$submitted || @{$m->{formErrors}}) {
60 | # Print header
61 | $m->printHeader();
62 |
63 | # Print page bar
64 | my @navLinks = ({ url => $m->url('forum_show'), txt => 'comUp', ico => 'up' });
65 | $m->printPageBar(mainTitle => "Upgrade", navLinks => \@navLinks);
66 |
67 | # Print hints and form errors
68 | $m->printHints([
69 | "This method of starting upgrade.pl over the browser requires the"
70 | . " \$cfg->{scriptFsPath} and \$cfg->{perlBinary}"
71 | . " options to be set up. The output below may be from the previous upgrade."
72 | . " Execution may take a while."
73 | . " Only if the output ends with 'mwForum upgrade done' has upgrade.pl run to completion."
74 | . " As it is run in the background, it should not get interrupted by any webserver"
75 | . " timeouts, though some webhosters may kill any script that runs for too long."
76 | . " Use Test to check if a script can run for 20 minutes."
77 | . " Refresh occasionally to check if scripts are done."
78 | ]);
79 | $m->printFormErrors();
80 |
81 | # Print execution form
82 | print
83 | "
\n",
84 | "
Execute
\n",
85 | "
\n",
86 | "\n",
94 | "
\n",
95 | "
\n\n";
96 |
97 | # Print last upgrade output
98 | my $output = $m->fetchArray("
99 | SELECT value FROM variables WHERE name = ?", 'upgOutput');
100 | my $outputEsc = $m->escHtml($output, 1);
101 | $outputEsc =~ s!(Error:)!$1!g;
102 | my $refreshUrl = $m->url('spawn_upgrade');
103 | print
104 | "