Merge lp:~malizor/ubuntu-fr-forum/upgrade_to_1.4.5 into lp:ubuntu-fr-forum

Proposed by Nicolas Delvaux
Status: Merged
Merged at revision: 128
Proposed branch: lp:~malizor/ubuntu-fr-forum/upgrade_to_1.4.5
Merge into: lp:ubuntu-fr-forum
Diff against target: 14535 lines (+5286/-4909)
110 files modified
BDD_update.sql (+32/-0)
BDD_update1.sql (+0/-115)
BDD_update2.sql (+0/-95)
INSTALL-ufr (+56/-0)
README (+31/-93)
README-ufr (+93/-0)
admin_bans.php (+36/-8)
admin_categories.php (+22/-23)
admin_censoring.php (+27/-9)
admin_forums.php (+6/-2)
admin_groups.php (+5/-10)
admin_index.php (+16/-16)
admin_loader.php (+2/-2)
admin_maintenance.php (+188/-8)
admin_options.php (+72/-18)
admin_permissions.php (+2/-2)
admin_prune.php (+0/-217)
admin_ranks.php (+3/-3)
admin_reports.php (+13/-5)
admin_users.php (+432/-5)
common.js (+32/-0)
db_update.php (+246/-107)
delete.php (+8/-4)
edit.php (+35/-8)
extern.php (+136/-87)
footer.php (+27/-65)
header.php (+136/-51)
help.php (+11/-10)
include/cache.php (+163/-37)
include/common.php (+19/-10)
include/common_admin.php (+29/-15)
include/dblayer/common_db.php (+1/-1)
include/dblayer/mysql.php (+12/-2)
include/dblayer/mysql_innodb.php (+12/-2)
include/dblayer/mysqli.php (+12/-2)
include/dblayer/mysqli_innodb.php (+12/-2)
include/dblayer/pgsql.php (+11/-1)
include/dblayer/sqlite.php (+31/-2)
include/email.php (+17/-4)
include/functions.php (+377/-148)
include/functions.php.orig (+0/-1749)
include/parser.php (+32/-60)
include/parser.php.backup (+0/-969)
include/search_idx.php (+17/-16)
include/template/admin.tpl (+52/-79)
include/template/posts.tpl (+12/-2)
include/template/topics.tpl (+17/-2)
index.php (+32/-8)
install.php (+305/-242)
lang/English/admin_bans.php (+3/-2)
lang/English/admin_censoring.php (+2/-3)
lang/English/admin_forums.php (+1/-0)
lang/English/admin_maintenance.php (+17/-0)
lang/English/admin_options.php (+14/-3)
lang/English/admin_plugin_example.php (+0/-17)
lang/English/admin_prune.php (+0/-23)
lang/English/admin_reports.php (+7/-6)
lang/English/admin_users.php (+37/-0)
lang/English/common.php (+10/-6)
lang/English/delete.php (+1/-1)
lang/English/forum.php (+4/-1)
lang/English/help.php (+1/-0)
lang/English/install.php (+120/-0)
lang/English/mail_templates/new_reply.tpl (+2/-2)
lang/English/mail_templates/new_reply_full.tpl (+2/-2)
lang/English/mail_templates/new_topic.tpl (+11/-0)
lang/English/mail_templates/new_topic_full.tpl (+18/-0)
lang/English/misc.php (+5/-3)
lang/English/post.php (+3/-0)
lang/English/profile.php (+3/-0)
lang/English/search.php (+55/-39)
lang/English/topic.php (+2/-1)
lang/English/update.php (+77/-0)
lang/Francais/admin_bans.php (+3/-2)
lang/Francais/admin_censoring.php (+1/-2)
lang/Francais/admin_forums.php (+2/-0)
lang/Francais/admin_maintenance.php (+18/-2)
lang/Francais/admin_options.php (+15/-4)
lang/Francais/admin_plugin_example.php (+0/-17)
lang/Francais/admin_prune.php (+0/-23)
lang/Francais/admin_reports.php (+2/-1)
lang/Francais/admin_users.php (+37/-0)
lang/Francais/common.php (+11/-4)
lang/Francais/forum.php (+4/-2)
lang/Francais/help.php (+2/-1)
lang/Francais/install.php (+120/-0)
lang/Francais/mail_templates/new_reply.tpl (+1/-1)
lang/Francais/mail_templates/new_reply_full.tpl (+1/-1)
lang/Francais/mail_templates/new_topic.tpl (+11/-0)
lang/Francais/mail_templates/new_topic_full.tpl (+18/-0)
lang/Francais/mail_templates/rename.tpl (+12/-0)
lang/Francais/misc.php (+7/-4)
lang/Francais/post.php (+4/-1)
lang/Francais/prof_reg.php (+4/-3)
lang/Francais/profile.php (+7/-3)
lang/Francais/search.php (+17/-1)
lang/Francais/topic.php (+2/-1)
lang/Francais/update.php (+77/-0)
login.php (+40/-7)
misc.php (+98/-34)
moderate.php (+82/-12)
plugins/AMP_Example.php (+0/-132)
post.php (+152/-29)
profile.php (+100/-56)
register.php (+14/-8)
search.php (+154/-55)
search.php.orig (+872/-0)
userlist.php (+2/-2)
viewforum.php (+80/-26)
viewtopic.php (+91/-50)
To merge this branch: bzr merge lp:~malizor/ubuntu-fr-forum/upgrade_to_1.4.5
Reviewer Review Type Date Requested Status
Nicolas Delvaux (community) Needs Resubmitting
xabilon (community) Needs Fixing
Review via email: mp+58574@code.launchpad.net

Description of the change

Et voici la fameuse mise à jour vers fluxbb 1.4.5 !

- Application du diff u-fr sur un 1.4.5 de base par moi même
- MaJ des traductions par xabilon
- "search.php" (&co) optimisé par YoBoY

Pour mettre à jour la BDD, lancez le script "BDD_update.sql" ou encore "db_update.php".

Bonus :
- Ajout d'un tutoriel d'installation pour les contributeurs ("INSTALL-ufr")
- Correction de plusieurs bugs dans le template admin en remplaçant son contenu par un copier/coller de main.tpl (à une id prêt). (sic)

To post a comment you must log in.
Revision history for this message
xabilon (xabilon) wrote :

Il y a un petit bug avec le search.php (avant les tests à grande échelle!). Lors d'une recherche "Mes messages", "Discussions sans réponse" ou "Messages récents", le fil d'Ariane en haut est de la forme :
"Forum > Discussions de la recherche > XXXXX"
Lorsqu'on clique sur "Discussions de la recherche", on est renvoyé vers le formulaire search.php, avec en bas :

"Désolé, aucun résultat n'a été trouvé pour votre recherche."

review: Needs Fixing
135. By Nicolas Delvaux

Correction de l'affichage "aucun résultat" en bas du formulaire de recherche.

Revision history for this message
Nicolas Delvaux (malizor) wrote :

Corrigé.

review: Needs Resubmitting
Revision history for this message
YoBoY (yoboy-leguesh) wrote :

c'est pas un bug de sa branche ça c'est aussi comme ça en prod ^^"

Revision history for this message
xabilon (xabilon) wrote :

C'est pas faux :)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== added file 'BDD_update.sql'
--- BDD_update.sql 1970-01-01 00:00:00 +0000
+++ BDD_update.sql 2011-04-21 10:05:56 +0000
@@ -0,0 +1,32 @@
1-- Requêtes pour transformer une BDD de fluxbb 1.4.2 en 1.4.5
2
3CREATE TABLE `forum_topic_subscriptions` SELECT * FROM `forum_subscriptions`;
4
5CREATE TABLE IF NOT EXISTS `forum_forum_subscriptions` (
6 `user_id` int(10) unsigned NOT NULL DEFAULT '0',
7 `forum_id` int(10) unsigned NOT NULL DEFAULT '0',
8 PRIMARY KEY (`user_id`,`forum_id`)
9) ENGINE=MyISAM DEFAULT CHARSET=utf8;
10
11-- MaJ des numéros de version :
12
13UPDATE forum_config SET conf_value = '1.4.5' WHERE conf_name = 'o_cur_version';
14UPDATE forum_config SET conf_value = '11' WHERE conf_name = 'o_database_revision';
15UPDATE forum_config SET conf_value = '2' WHERE conf_name = 'o_searchindex_revision';
16UPDATE forum_config SET conf_value = '2' WHERE conf_name = 'o_parser_revision';
17
18INSERT INTO forum_config VALUES ('o_forum_subscriptions', '0');
19INSERT INTO forum_config VALUES ('o_topic_subscriptions', '1');
20
21-- C'est tout :-)
22COMMIT;
23
24-- N'oubliez pas de vider le cache de fluxbb !
25
26
27
28-- Si la migration s'est bien passée, vous pouvez nettoyer via les requêtes suivantes :
29
30-- DROP TABLE `forum_subscriptions`;
31-- DELETE FROM `forum_config` WHERE `conf_name` = 'o_subscriptions';
32-- COMMIT;
033
=== removed file 'BDD_update1.sql'
--- BDD_update1.sql 2010-10-08 13:18:35 +0000
+++ BDD_update1.sql 1970-01-01 00:00:00 +0000
@@ -1,115 +0,0 @@
1USE ubuntu_fr;
2
3-- Requêtes données par le script db_update.php
4
5ALTER TABLE forum_users ADD dst TINYINT(1) NOT NULL DEFAULT 0 AFTER timezone;
6ALTER TABLE forum_online ADD last_post INT(10) UNSIGNED;
7ALTER TABLE forum_online ADD last_search INT(10) UNSIGNED;
8ALTER TABLE forum_users ADD last_search INT(10) UNSIGNED AFTER last_post;
9INSERT INTO forum_config (conf_name, conf_value) VALUES ('o_database_revision', '0');
10INSERT INTO forum_config (conf_name, conf_value) VALUES ('o_searchindex_revision', '0');
11INSERT INTO forum_config (conf_name, conf_value) VALUES ('o_parser_revision', '0');
12INSERT INTO forum_config (conf_name, conf_value) VALUES ('o_default_email_setting', '1');
13INSERT INTO forum_config (conf_name, conf_value) VALUES ('o_topic_views', '0');
14INSERT INTO forum_config (conf_name, conf_value) VALUES ('o_signatures', '1');
15INSERT INTO forum_config (conf_name, conf_value) VALUES ('o_smtp_ssl', '0');
16INSERT INTO forum_config (conf_name, conf_value) VALUES ('o_default_dst', '0');
17INSERT INTO forum_config (conf_name, conf_value) VALUES ('o_quote_depth', '3');
18INSERT INTO forum_config (conf_name, conf_value) VALUES ('o_feed_type', '2');
19UPDATE forum_config SET conf_name = 'o_default_timezone' WHERE conf_name = 'o_server_timezone';
20
21UPDATE forum_config SET conf_value = '8' WHERE conf_name = 'o_database_revision';
22UPDATE forum_config SET conf_value = '1' WHERE conf_name = 'o_searchindex_revision';
23UPDATE forum_config SET conf_value = '1' WHERE conf_name = 'o_parser_revision';
24UPDATE forum_config SET conf_value = '1.4.2' WHERE conf_name = 'o_cur_version';
25
26ALTER TABLE forum_groups ADD g_moderator TINYINT(1) NOT NULL DEFAULT 0 AFTER g_user_title;
27UPDATE forum_groups SET g_moderator = 1 WHERE g_id = 2;
28
29DELETE FROM forum_config WHERE conf_name = 'p_mod_edit_users';
30ALTER TABLE forum_groups ADD g_mod_edit_users TINYINT(1) NOT NULL DEFAULT 0 AFTER g_moderator;
31
32DELETE FROM forum_config WHERE conf_name = 'p_mod_rename_users';
33ALTER TABLE forum_groups ADD g_mod_rename_users TINYINT(1) NOT NULL DEFAULT 0 AFTER g_mod_edit_users;
34
35DELETE FROM forum_config WHERE conf_name = 'p_mod_change_passwords';
36ALTER TABLE forum_groups ADD g_mod_change_passwords TINYINT(1) NOT NULL DEFAULT 0 AFTER g_mod_rename_users;
37
38DELETE FROM forum_config WHERE conf_name = 'p_mod_ban_users';
39ALTER TABLE forum_groups ADD g_mod_ban_users TINYINT(1) NOT NULL DEFAULT 0 AFTER g_mod_change_passwords;
40
41TRUNCATE TABLE forum_online;
42ALTER TABLE forum_online ADD UNIQUE INDEX forum_online_user_id_ident_idx (user_id,ident);
43ALTER TABLE forum_online ADD INDEX forum_online_ident_idx (ident);
44ALTER TABLE forum_online ADD INDEX forum_online_logged_idx (logged);
45
46ALTER TABLE forum_topics ADD INDEX forum_topics_last_post_idx (last_post);
47ALTER TABLE forum_bans ADD INDEX forum_bans_username_idx (username);
48ALTER TABLE forum_users ADD UNIQUE INDEX forum_users_username_idx (username);
49
50ALTER TABLE forum_groups ADD g_view_users TINYINT(1) NOT NULL DEFAULT 1 AFTER g_read_board;
51ALTER TABLE forum_users ADD last_email_sent INT(10) UNSIGNED AFTER last_search;
52ALTER TABLE forum_groups ADD g_send_email TINYINT(1) NOT NULL DEFAULT 1 AFTER g_search_users;
53ALTER TABLE forum_groups ADD g_email_flood SMALLINT(6) NOT NULL DEFAULT 60 AFTER g_search_flood;
54UPDATE forum_groups SET g_send_email = 0 WHERE g_id = 3;
55UPDATE forum_groups SET g_email_flood = 0 WHERE g_id IN (1,2,3);
56ALTER TABLE forum_users ADD auto_notify TINYINT(1) NOT NULL DEFAULT 0 AFTER notify_with_post;
57
58-- Suppression des sujets incohérents
59
60DELETE FROM forum_topics WHERE last_poster IS NULL;
61DELETE FROM forum_topics WHERE last_post_id = 0;
62
63-- Ajout et remplissage du champ first_post_id
64
65ALTER TABLE forum_topics ADD first_post_id INT(10) UNSIGNED NOT NULL DEFAULT 0 AFTER posted;
66ALTER TABLE forum_topics ADD INDEX forum_topics_first_post_id_idx (first_post_id);
67UPDATE forum_topics INNER JOIN (SELECT MIN(id) AS first_post, topic_id FROM forum_posts GROUP BY topic_id) AS tmp ON forum_topics.id = tmp.topic_id SET first_post_id = first_post;
68
69
70ALTER TABLE forum_bans ADD ban_creator INT(10) UNSIGNED NOT NULL DEFAULT 0;
71ALTER TABLE forum_users ADD time_format TINYINT(1) NOT NULL DEFAULT 0 AFTER dst;
72ALTER TABLE forum_users ADD date_format TINYINT(1) NOT NULL DEFAULT 0 AFTER time_format;
73
74
75-- Requêtes complémentaires
76
77-- Suppression de champs obsolètes
78
79ALTER TABLE forum_forums DROP parent_forum_id;
80ALTER TABLE forum_users DROP use_avatar;
81ALTER TABLE forum_users DROP save_pass;
82ALTER TABLE forum_groups DROP g_post_polls;
83ALTER TABLE forum_groups DROP g_edit_subjects_interval;
84
85
86-- Suppression des users non vérifiés antérieurs au 15 septembre 2010
87
88DELETE FROM forum_users WHERE group_id = 32000 AND registered < 1284501600;
89OPTIMIZE TABLE forum_users;
90
91-- Passage des users non-vérifiés restants en groupe 0
92
93UPDATE forum_users SET group_id = 0 WHERE group_id = 32000;
94
95-- Changement des champs de mail à varchar(80)
96
97ALTER TABLE forum_bans CHANGE email email VARCHAR(80);
98ALTER TABLE forum_posts CHANGE poster_email poster_email VARCHAR(80);
99ALTER TABLE forum_users CHANGE email email VARCHAR(80);
100ALTER TABLE forum_users CHANGE msn msn VARCHAR(80);
101
102-- Changement des champs d'IP à varchar(39) --> IPv6
103
104ALTER TABLE forum_posts CHANGE poster_ip poster_ip VARCHAR(39);
105ALTER TABLE forum_users CHANGE registration_ip registration_ip VARCHAR(39);
106
107
108-- Changement du champ de recherche à mediumtext
109
110ALTER TABLE forum_search_cache CHANGE search_data search_data MEDIUMTEXT;
111
112
113-- Changement du champ message à mediumtext
114
115ALTER TABLE forum_posts CHANGE message message MEDIUMTEXT;
1160
=== removed file 'BDD_update2.sql'
--- BDD_update2.sql 2011-02-12 23:04:19 +0000
+++ BDD_update2.sql 1970-01-01 00:00:00 +0000
@@ -1,95 +0,0 @@
1USE ubuntu_devforum;
2
3-- phpMyAdmin SQL Dump
4-- version 3.3.2deb1
5-- http://www.phpmyadmin.net
6--
7-- Serveur: localhost
8-- Généré le : Ven 08 Octobre 2010 à 15:00
9-- Version du serveur: 5.1.41
10-- Version de PHP: 5.3.2-1ubuntu4.5ppa5~lucid1
11
12SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
13
14
15/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
16/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
17/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
18/*!40101 SET NAMES utf8 */;
19
20--
21-- Base de données: `ubuntu_devforum`
22--
23
24-- --------------------------------------------------------
25
26--
27-- Structure de la table `forum_toolbar_conf`
28--
29
30CREATE TABLE IF NOT EXISTS `forum_toolbar_conf` (
31 `conf_name` varchar(40) NOT NULL DEFAULT '',
32 `conf_value` varchar(40) NOT NULL DEFAULT '',
33 PRIMARY KEY (`conf_name`)
34) ENGINE=MyISAM DEFAULT CHARSET=utf8;
35
36--
37-- Contenu de la table `forum_toolbar_conf`
38--
39
40INSERT INTO `forum_toolbar_conf` (`conf_name`, `conf_value`) VALUES
41('enable_form', '1'),
42('enable_quickform', '1'),
43('img_pack', 'smooth'),
44('nb_smilies', '12'),
45('pop_up_width', '240'),
46('pop_up_height', '200'),
47('button_size', '4096'),
48('button_width', '32'),
49('button_height', '32');
50
51-- --------------------------------------------------------
52
53--
54-- Structure de la table `forum_toolbar_tags`
55--
56
57CREATE TABLE IF NOT EXISTS `forum_toolbar_tags` (
58 `name` varchar(20) NOT NULL DEFAULT '',
59 `code` varchar(20) NOT NULL DEFAULT '',
60 `enable_form` tinyint(1) NOT NULL DEFAULT '0',
61 `enable_quick` tinyint(1) NOT NULL DEFAULT '0',
62 `image` varchar(40) NOT NULL DEFAULT '',
63 `func` tinyint(1) NOT NULL DEFAULT '0',
64 `position` tinyint(2) unsigned NOT NULL DEFAULT '1',
65 PRIMARY KEY (`name`)
66) ENGINE=MyISAM DEFAULT CHARSET=utf8;
67
68--
69-- Contenu de la table `forum_toolbar_tags`
70--
71
72INSERT INTO `forum_toolbar_tags` (`name`, `code`, `enable_form`, `enable_quick`, `image`, `func`, `position`) VALUES
73('smilies', '', 1, 1, 'bt_smilies.png', 0, 0),
74('bold', 'b', 1, 1, 'bt_bold.png', 0, 1),
75('italic', 'i', 1, 1, 'bt_italic.png', 0, 2),
76('underline', 'u', 1, 1, 'bt_underline.png', 0, 3),
77('strike', 's', 1, 0, 'bt_strike.png', 0, 4),
78('sup', 'sup', 1, 0, 'bt_sup.png', 0, 5),
79('sub', 'sub', 1, 0, 'bt_sub.png', 0, 6),
80('heading', 'h', 0, 0, 'bt_size_plus.png', 0, 7),
81('left', 'left', 1, 0, 'bt_align_left.png', 0, 8),
82('right', 'right', 1, 0, 'bt_align_right.png', 0, 9),
83('center', 'center', 1, 0, 'bt_align_center.png', 0, 10),
84('justify', 'justify', 1, 0, 'bt_align_justify.png', 0, 11),
85('color', 'color', 0, 0, 'bt_color.png', 0, 12),
86('q', 'q', 1, 0, 'bt_quote.png', 0, 13),
87('acronym', 'acronym', 1, 0, 'bt_acronym.png', 1, 14),
88('img', 'img', 1, 1, 'bt_img.png', 2, 15),
89('code', 'code', 1, 1, 'bt_pre.png', 0, 16),
90('quote', 'quote', 1, 1, 'bt_bquote.png', 1, 17),
91('link', 'url', 1, 1, 'bt_link.png', 2, 18),
92('email', 'email', 0, 0, 'bt_email.png', 2, 19),
93('video', 'video', 1, 1, 'bt_video.png', 3, 20),
94('li', '*', 1, 0, 'bt_li.png', 0, 21),
95('list', 'list', 1, 0, 'bt_ul.png', 1, 22);
960
=== added file 'INSTALL-ufr'
--- INSTALL-ufr 1970-01-01 00:00:00 +0000
+++ INSTALL-ufr 2011-04-21 10:05:56 +0000
@@ -0,0 +1,56 @@
1Comment installer le forum ubuntu-fr en local :
2
3- créez une BDD
4- créez les trois tables suivantes :
5
6CREATE TABLE IF NOT EXISTS `forum_annonces` (
7 `forum_id` int(11) NOT NULL default '0',
8 `forum_annonce` text,
9 `forum_annonce_visible` tinyint(1) NOT NULL default '0',
10 PRIMARY KEY (`forum_id`)
11) ENGINE=MyISAM DEFAULT CHARSET=utf8;
12
13CREATE TABLE IF NOT EXISTS `forum_toolbar_tags` (
14 `name` varchar(20) NOT NULL,
15 `code` varchar(20) NOT NULL,
16 `enable_form` tinyint(1) NOT NULL default '0',
17 `enable_quick` tinyint(1) NOT NULL default '0',
18 `image` varchar(40) NOT NULL,
19 `func` tinyint(1) NOT NULL default '0',
20 `position` tinyint(2) UNSIGNED NOT NULL default '1',
21 PRIMARY KEY (`name`)
22) ENGINE=MyISAM DEFAULT CHARSET=utf8;
23
24CREATE TABLE IF NOT EXISTS `forum_toolbar_conf` (
25 `conf_name` varchar(40) NOT NULL,
26 `conf_value` varchar(40) NOT NULL,
27 PRIMARY KEY (`conf_name`)
28) ENGINE=MyISAM DEFAULT CHARSET=utf8;
29
30- Copiez les fichiers du forum dans le dossier "/var/www" (par exemple dans un sous dossier "forum")
31- Rendez vous sur la page d'installation (par exemple http://localhost/forum/install.php)
32- Renseignez tous les champs et choisissez "forum_" comme préfixe de la BDD
33- Une fois l'installation finie, vous devrez modifier la table "forum_forums" de la manière suivante:
34
35ALTER TABLE forum_forums ADD `forum_type` int(1) NOT NULL;
36
37
38Le forum est maintenant fonctionnel !!!
39...mais le CSS n'est pas encore en place.
40
41
42Ces ressources sont hébergées séparément, car elles sont communes aux divers sites de ubuntu-fr.
43Vous devez télécharger le projet STATIC:
44 bzr branch lp:ubuntu-fr-static
45
46- Placez le contenu de ce dossier dans, par exemple, "/var/www/STATIC"
47- Éditez le fichier "config.php" du forum et ajoutez y "define('UFR_STATIC', 'CHEMIN_VERS_STATIC/theme2010/');"
48Si vous avez suivi l'exemple, il faudra mettre "define('UFR_STATIC', '../STATIC/theme2010/');"
49
50Et voila, amusez vous bien ! :-)
51
52Astuces : Pour mettre le forum en mode "debug" (affichage de toutes les requêtes SQL en bas de page),
53éditez le fichier "config.php" et ajoutez y les deux lignes suivantes :
54define('PUN_DEBUG', 1);
55define('PUN_SHOW_QUERIES', 1);
56
057
=== modified file 'README'
--- README 2011-04-13 15:16:19 +0000
+++ README 2011-04-21 10:05:56 +0000
@@ -1,93 +1,31 @@
1Les fichiers modifiés par rapport à FluxBB :1 =====================
2include/templates/main.tpl2 FluxBB 1.4 Readme
33 =====================
4Fil d'ariane4
5 viewtopic.php l361 (pour la rc) l371 pour 1.45 About
6 viewforum.php l486 ----------------
7 index.php7FluxBB is an open source forum application released under the GNU General Public
8Stats8Licence. It is free to download and use and will remain so. FluxBB was conceived and
9 index.php l2499designed to be fast and light with less of the "not so essential" features that some
10 FIXME : il y a peut être une façon plus élégante de le faire10of the other forums have whilst not sacrificing essential functionality or usability.
11Redirection:11
12 functions.php l128812 Requirements
1313 ----------------
1414 - A webserver
15FLUXBB 1.4.0 :15 - PHP 4.4.0 or later
1616 - A database such as MySQL 4.1.2 or later, PostgreSQL 7.0 or later, or SQLite 2
17Liens de recherche (searchlinks) ajoutés dans header.php17
18pun_searchlinks est appelé depuis main.tpl18 Recommendations
19J'ai pris la même classe que pour les liens de navigation "navlinks" (à différencier si ça pose problème au CSS)19 -------------------
2020 - Make use of a PHP accelerator such as APC or XCache
2121 - Make sure PHP has the zlib module installed to allow FluxBB to gzip output
22Mise en forme des pages admins :22
23- inclusion des feuilles de style site_css.php dans admin.tpl23 Links
24En fait il faudrait refaire entièrement admin.tpl pour le faire correspondre à main.tpl24 ---------
25(bonjour les mises à jour de FluxBB ...) 25
26 -> ça c'est bon, je viens de le faire26 - Homepage: http://fluxbb.org
2727 - Documentation: http://fluxbb.org/docs/
2828 - Community: http://fluxbb.org/forums/
29Différentiation de la recherche rapide et du formulaire de recherche :29 - Resources: http://fluxbb.org/resources/
30id="search" changé en id="searchform"30 - IRC: irc://irc.freenode.net/fluxbb
31search.php ligne 66231 - Development: http://github.com/fluxbb/fluxbb
32
33Ajout d'une classe pour l'ip de connexion:
34viewtopic.php l286
35
36
37Décochage par défaut de la case "créer un lien" pour les déplacements de topic
38moderate.php l483
39Ligne avant modif :
40<label><input type="checkbox" name="with_redirect" value="0"<?php if ($action == 'single') echo ' checked="checked"' ?> /><?php echo $lang_misc['Leave redirect'] ?><br /></label>
41
42
43Affichage des annonces des forums (div "announce-forum")
44viewforum.php L92 à L113
45
46
47Mod affichage de l'accueil + gagnant du mois :
48Voir plugins/AP_Reception.php + lang/Francais/reception.php + index.php (L58 à L79)
49Les chaines correspondantes sont stockées dans deux nouvelles clefs de la table config: c_welcome_message et c_winner_message.
50Pas de modification de la structure de la base. Les clefs se créent automatiquement, rien de spécial à faire.
51
52
53Affichage de usertitle uniquement pour admins et modos.
54viewtopic.php l360 :
55<?php if ($pun_user['g_id'] <= 2) echo ' <dd class="usertitle"><strong>'.$user_title.'</strong></dd>'; ?>
56Ligne originale :
57<dd class="usertitle"><strong><?php echo $user_title ?></strong></dd>
58
59
60Ne pas chercher les "messages récents" et "sans réponses" dans les sections Divers:
61Ajout des conditions AND t.forum_id!=7 AND t.forum_id!=43 AND t.forum_id!=8
62dans search.php L296 305 et 335
63
64Limiter les résultats à 200 topics :
65Ajout d'un LIMIT 200 dans search.php L296 305 et 335
66
67
68Bouton pour cacher le menu navigation
69include/main.tpl : L81 ajout d'un div#hidemenu avec lien vers le javascript
70header.php : L158 à 171 inclusion de common.js, menu.js, cookie menu_hidden, et modif du CSS en fonction
71
72
73Désactivation du formulaire de recherche
74search PHP L662 : changement de search.php en index.php (renvoi vers l'accueil)
75
76On enlève "Recherche" du menu navigation
77/include/functions.php : on commente les lignes 446 et 453
78
79
8010/10/2010 XABILON
81modifs forum : index.php, style/ubuntu-light.css
82modifs static: forum-ubuntu.css, forum-kubuntu.css, forum-general.css
83
8412/10/2010 XABILON
85Supression du "Marquer tous vos messages comme lus" et "Nouveaux messages" (déplacé plus bas) dans header.php. À intégrer dans les liens de navigation.
86(attention, 2 messages et actions différents selon qu'on est sur index.php ou viewforum.php, voir code commenté dans le header L314)
87ET ATTENTION AUX LIENS VERS LES CSS ET LE META POUR GOOGLE
88Ajout de "Marquer tous vos messages comme lus" dans include/functions.php
89Traductions dans lang/Francais/common.php
90search.php (augmentation de la limite des 200)
91parser.php (balise apt)
92divers dans style/
93viewtopic.php (lien vers haut de page)
9432
=== added file 'README-ufr'
--- README-ufr 1970-01-01 00:00:00 +0000
+++ README-ufr 2011-04-21 10:05:56 +0000
@@ -0,0 +1,93 @@
1Les fichiers modifiés par rapport à FluxBB :
2include/templates/main.tpl
3
4Fil d'ariane
5 viewtopic.php l361 (pour la rc) l371 pour 1.4
6 viewforum.php l48
7 index.php
8Stats
9 index.php l249
10 FIXME : il y a peut être une façon plus élégante de le faire
11Redirection:
12 functions.php l1288
13
14
15FLUXBB 1.4.0 :
16
17Liens de recherche (searchlinks) ajoutés dans header.php
18pun_searchlinks est appelé depuis main.tpl
19J'ai pris la même classe que pour les liens de navigation "navlinks" (à différencier si ça pose problème au CSS)
20
21
22Mise en forme des pages admins :
23- inclusion des feuilles de style site_css.php dans admin.tpl
24En fait il faudrait refaire entièrement admin.tpl pour le faire correspondre à main.tpl
25(bonjour les mises à jour de FluxBB ...)
26 -> ça c'est bon, je viens de le faire
27
28
29Différentiation de la recherche rapide et du formulaire de recherche :
30id="search" changé en id="searchform"
31search.php ligne 662
32
33Ajout d'une classe pour l'ip de connexion:
34viewtopic.php l286
35
36
37Décochage par défaut de la case "créer un lien" pour les déplacements de topic
38moderate.php l483
39Ligne avant modif :
40<label><input type="checkbox" name="with_redirect" value="0"<?php if ($action == 'single') echo ' checked="checked"' ?> /><?php echo $lang_misc['Leave redirect'] ?><br /></label>
41
42
43Affichage des annonces des forums (div "announce-forum")
44viewforum.php L92 à L113
45
46
47Mod affichage de l'accueil + gagnant du mois :
48Voir plugins/AP_Reception.php + lang/Francais/reception.php + index.php (L58 à L79)
49Les chaines correspondantes sont stockées dans deux nouvelles clefs de la table config: c_welcome_message et c_winner_message.
50Pas de modification de la structure de la base. Les clefs se créent automatiquement, rien de spécial à faire.
51
52
53Affichage de usertitle uniquement pour admins et modos.
54viewtopic.php l360 :
55<?php if ($pun_user['g_id'] <= 2) echo ' <dd class="usertitle"><strong>'.$user_title.'</strong></dd>'; ?>
56Ligne originale :
57<dd class="usertitle"><strong><?php echo $user_title ?></strong></dd>
58
59
60Ne pas chercher les "messages récents" et "sans réponses" dans les sections Divers:
61Ajout des conditions AND t.forum_id!=7 AND t.forum_id!=43 AND t.forum_id!=8
62dans search.php L296 305 et 335
63
64Limiter les résultats à 200 topics :
65Ajout d'un LIMIT 200 dans search.php L296 305 et 335
66
67
68Bouton pour cacher le menu navigation
69include/main.tpl : L81 ajout d'un div#hidemenu avec lien vers le javascript
70header.php : L158 à 171 inclusion de common.js, menu.js, cookie menu_hidden, et modif du CSS en fonction
71
72
73Désactivation du formulaire de recherche
74search PHP L662 : changement de search.php en index.php (renvoi vers l'accueil)
75
76On enlève "Recherche" du menu navigation
77/include/functions.php : on commente les lignes 446 et 453
78
79
8010/10/2010 XABILON
81modifs forum : index.php, style/ubuntu-light.css
82modifs static: forum-ubuntu.css, forum-kubuntu.css, forum-general.css
83
8412/10/2010 XABILON
85Supression du "Marquer tous vos messages comme lus" et "Nouveaux messages" (déplacé plus bas) dans header.php. À intégrer dans les liens de navigation.
86(attention, 2 messages et actions différents selon qu'on est sur index.php ou viewforum.php, voir code commenté dans le header L314)
87ET ATTENTION AUX LIENS VERS LES CSS ET LE META POUR GOOGLE
88Ajout de "Marquer tous vos messages comme lus" dans include/functions.php
89Traductions dans lang/Francais/common.php
90search.php (augmentation de la limite des 200)
91parser.php (balise apt)
92divers dans style/
93viewtopic.php (lien vers haut de page)
094
=== modified file 'admin_bans.php'
--- admin_bans.php 2010-10-08 13:18:35 +0000
+++ admin_bans.php 2011-04-21 10:05:56 +0000
@@ -1,7 +1,7 @@
1<?php1<?php
22
3/**3/**
4 * Copyright (C) 2008-2010 FluxBB4 * Copyright (C) 2008-2011 FluxBB
5 * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB5 * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB
6 * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher6 * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher
7 */7 */
@@ -9,7 +9,7 @@
9// Tell header.php to use the admin template9// Tell header.php to use the admin template
10define('PUN_ADMIN_CONSOLE', 1);10define('PUN_ADMIN_CONSOLE', 1);
1111
12define('PUN_ROOT', './');12define('PUN_ROOT', dirname(__FILE__).'/');
13require PUN_ROOT.'include/common.php';13require PUN_ROOT.'include/common.php';
14require PUN_ROOT.'include/common_admin.php';14require PUN_ROOT.'include/common_admin.php';
1515
@@ -52,9 +52,18 @@
52 }52 }
53 }53 }
5454
55 // Make sure we're not banning an admin55 // Make sure we're not banning an admin or moderator
56 if (isset($group_id) && $group_id == PUN_ADMIN)56 if (isset($group_id))
57 message(sprintf($lang_admin_bans['User is admin message'], pun_htmlspecialchars($ban_user)));57 {
58 if ($group_id == PUN_ADMIN)
59 message(sprintf($lang_admin_bans['User is admin message'], pun_htmlspecialchars($ban_user)));
60
61 $result = $db->query('SELECT g_moderator FROM '.$db->prefix.'groups WHERE g_id='.$group_id) or error('Unable to fetch group info', __FILE__, __LINE__, $db->error());
62 $is_moderator_group = $db->result($result);
63
64 if ($is_moderator_group)
65 message(sprintf($lang_admin_bans['User is mod message'], pun_htmlspecialchars($ban_user)));
66 }
5867
59 // If we have a $user_id, we can try to find the last known IP of that user68 // If we have a $user_id, we can try to find the last known IP of that user
60 if (isset($user_id))69 if (isset($user_id))
@@ -183,6 +192,25 @@
183 message($lang_admin_bans['Must enter message']);192 message($lang_admin_bans['Must enter message']);
184 else if (strtolower($ban_user) == 'guest')193 else if (strtolower($ban_user) == 'guest')
185 message($lang_admin_bans['Cannot ban guest message']);194 message($lang_admin_bans['Cannot ban guest message']);
195
196 // Make sure we're not banning an admin or moderator
197 if (!empty($ban_user))
198 {
199 $result = $db->query('SELECT group_id FROM '.$db->prefix.'users WHERE username=\''.$db->escape($ban_user).'\' AND id>1') or error('Unable to fetch user info', __FILE__, __LINE__, $db->error());
200 if ($db->num_rows($result))
201 {
202 $group_id = $db->result($result);
203
204 if ($group_id == PUN_ADMIN)
205 message(sprintf($lang_admin_bans['User is admin message'], pun_htmlspecialchars($ban_user)));
206
207 $result = $db->query('SELECT g_moderator FROM '.$db->prefix.'groups WHERE g_id='.$group_id) or error('Unable to fetch group info', __FILE__, __LINE__, $db->error());
208 $is_moderator_group = $db->result($result);
209
210 if ($is_moderator_group)
211 message(sprintf($lang_admin_bans['User is mod message'], pun_htmlspecialchars($ban_user)));
212 }
213 }
186214
187 // Validate IP/IP range (it's overkill, I know)215 // Validate IP/IP range (it's overkill, I know)
188 if ($ban_ip != '')216 if ($ban_ip != '')
@@ -304,7 +332,7 @@
304332
305 $expire_after = isset($_GET['expire_after']) ? trim($_GET['expire_after']) : '';333 $expire_after = isset($_GET['expire_after']) ? trim($_GET['expire_after']) : '';
306 $expire_before = isset($_GET['expire_before']) ? trim($_GET['expire_before']) : '';334 $expire_before = isset($_GET['expire_before']) ? trim($_GET['expire_before']) : '';
307 $order_by = isset($_GET['order_by']) && in_array($_GET['order_by'], array('username', 'ip', 'email', 'expire')) ? $_GET['order_by'] : 'username';335 $order_by = isset($_GET['order_by']) && in_array($_GET['order_by'], array('username', 'ip', 'email', 'expire')) ? 'b.'.$_GET['order_by'] : 'b.username';
308 $direction = isset($_GET['direction']) && $_GET['direction'] == 'DESC' ? 'DESC' : 'ASC';336 $direction = isset($_GET['direction']) && $_GET['direction'] == 'DESC' ? 'DESC' : 'ASC';
309337
310 $query_str[] = 'order_by='.$order_by;338 $query_str[] = 'order_by='.$order_by;
@@ -319,7 +347,7 @@
319 if ($expire_after === false || $expire_after == -1)347 if ($expire_after === false || $expire_after == -1)
320 message($lang_admin_bans['Invalid date message']);348 message($lang_admin_bans['Invalid date message']);
321349
322 $conditions[] = 'expire>'.$expire_after;350 $conditions[] = 'b.expire>'.$expire_after;
323 }351 }
324 if ($expire_before != '')352 if ($expire_before != '')
325 {353 {
@@ -329,7 +357,7 @@
329 if ($expire_before === false || $expire_before == -1)357 if ($expire_before === false || $expire_before == -1)
330 message($lang_admin_bans['Invalid date message']);358 message($lang_admin_bans['Invalid date message']);
331359
332 $conditions[] = 'expire<'.$expire_before;360 $conditions[] = 'b.expire<'.$expire_before;
333 }361 }
334362
335 $like_command = ($db_type == 'pgsql') ? 'ILIKE' : 'LIKE';363 $like_command = ($db_type == 'pgsql') ? 'ILIKE' : 'LIKE';
336364
=== modified file 'admin_categories.php'
--- admin_categories.php 2010-10-08 13:18:35 +0000
+++ admin_categories.php 2011-04-21 10:05:56 +0000
@@ -1,7 +1,7 @@
1<?php1<?php
22
3/**3/**
4 * Copyright (C) 2008-2010 FluxBB4 * Copyright (C) 2008-2011 FluxBB
5 * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB5 * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB
6 * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher6 * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher
7 */7 */
@@ -9,7 +9,7 @@
9// Tell header.php to use the admin template9// Tell header.php to use the admin template
10define('PUN_ADMIN_CONSOLE', 1);10define('PUN_ADMIN_CONSOLE', 1);
1111
12define('PUN_ROOT', './');12define('PUN_ROOT', dirname(__FILE__).'/');
13require PUN_ROOT.'include/common.php';13require PUN_ROOT.'include/common.php';
14require PUN_ROOT.'include/common_admin.php';14require PUN_ROOT.'include/common_admin.php';
1515
@@ -126,23 +126,22 @@
126{126{
127 confirm_referrer('admin_categories.php');127 confirm_referrer('admin_categories.php');
128128
129 $cat_order = array_map('trim', $_POST['cat_order']);129 $categories = $_POST['cat'];
130 $cat_name = array_map('pun_trim', $_POST['cat_name']);130 if (empty($categories))
131131 message($lang_common['Bad request']);
132 $result = $db->query('SELECT id, disp_position FROM '.$db->prefix.'categories ORDER BY disp_position') or error('Unable to fetch category list', __FILE__, __LINE__, $db->error());132
133 $num_cats = $db->num_rows($result);133 foreach ($categories as $cat_id => $cur_cat)
134
135 for ($i = 0; $i < $num_cats; ++$i)
136 {134 {
137 if ($cat_name[$i] == '')135 $cur_cat['name'] = pun_trim($cur_cat['name']);
136 $cur_cat['order'] = trim($cur_cat['order']);
137
138 if ($cur_cat['name'] == '')
138 message($lang_admin_categories['Must enter name message']);139 message($lang_admin_categories['Must enter name message']);
139140
140 if ($cat_order[$i] == '' || preg_match('/[^0-9]/', $cat_order[$i]))141 if ($cur_cat['order'] == '' || preg_match('/[^0-9]/', $cur_cat['order']))
141 message($lang_admin_categories['Must enter integer message']);142 message($lang_admin_categories['Must enter integer message']);
142143
143 list($cat_id, $position) = $db->fetch_row($result);144 $db->query('UPDATE '.$db->prefix.'categories SET cat_name=\''.$db->escape($cur_cat['name']).'\', disp_position='.$cur_cat['order'].' WHERE id='.intval($cat_id)) or error('Unable to update category', __FILE__, __LINE__, $db->error());
144
145 $db->query('UPDATE '.$db->prefix.'categories SET cat_name=\''.$db->escape($cat_name[$i]).'\', disp_position='.$cat_order[$i].' WHERE id='.$cat_id) or error('Unable to update category', __FILE__, __LINE__, $db->error());
146 }145 }
147146
148 // Regenerate the quick jump cache147 // Regenerate the quick jump cache
@@ -159,7 +158,7 @@
159$num_cats = $db->num_rows($result);158$num_cats = $db->num_rows($result);
160159
161for ($i = 0; $i < $num_cats; ++$i)160for ($i = 0; $i < $num_cats; ++$i)
162 $cat_list[] = $db->fetch_row($result);161 $cat_list[] = $db->fetch_assoc($result);
163162
164$page_title = array(pun_htmlspecialchars($pun_config['o_board_title']), $lang_admin_common['Admin'], $lang_admin_common['Categories']);163$page_title = array(pun_htmlspecialchars($pun_config['o_board_title']), $lang_admin_common['Admin'], $lang_admin_common['Categories']);
165define('PUN_ACTIVE_PAGE', 'admin');164define('PUN_ACTIVE_PAGE', 'admin');
@@ -171,7 +170,7 @@
171 <div class="blockform">170 <div class="blockform">
172 <h2><span><?php echo $lang_admin_categories['Add categories head'] ?></span></h2>171 <h2><span><?php echo $lang_admin_categories['Add categories head'] ?></span></h2>
173 <div class="box">172 <div class="box">
174 <form method="post" action="admin_categories.php?action=foo">173 <form method="post" action="admin_categories.php">
175 <div class="inform">174 <div class="inform">
176 <fieldset>175 <fieldset>
177 <legend><?php echo $lang_admin_categories['Add categories subhead'] ?></legend>176 <legend><?php echo $lang_admin_categories['Add categories subhead'] ?></legend>
@@ -193,7 +192,7 @@
193192
194<?php if ($num_cats): ?> <h2 class="block2"><span><?php echo $lang_admin_categories['Delete categories head'] ?></span></h2>193<?php if ($num_cats): ?> <h2 class="block2"><span><?php echo $lang_admin_categories['Delete categories head'] ?></span></h2>
195 <div class="box">194 <div class="box">
196 <form method="post" action="admin_categories.php?action=foo">195 <form method="post" action="admin_categories.php">
197 <div class="inform">196 <div class="inform">
198 <fieldset>197 <fieldset>
199 <legend><?php echo $lang_admin_categories['Delete categories subhead'] ?></legend>198 <legend><?php echo $lang_admin_categories['Delete categories subhead'] ?></legend>
@@ -205,8 +204,8 @@
205 <select name="cat_to_delete" tabindex="3">204 <select name="cat_to_delete" tabindex="3">
206<?php205<?php
207206
208 foreach ($cat_list as $category)207 foreach ($cat_list as $cur_cat)
209 echo "\t\t\t\t\t\t\t\t\t\t\t".'<option value="'.$category[0].'">'.pun_htmlspecialchars($category[1]).'</option>'."\n";208 echo "\t\t\t\t\t\t\t\t\t\t\t".'<option value="'.$cur_cat['id'].'">'.pun_htmlspecialchars($cur_cat['cat_name']).'</option>'."\n";
210209
211?>210?>
212 </select>211 </select>
@@ -223,7 +222,7 @@
223222
224<?php if ($num_cats): ?> <h2 class="block2"><span><?php echo $lang_admin_categories['Edit categories head'] ?></span></h2>223<?php if ($num_cats): ?> <h2 class="block2"><span><?php echo $lang_admin_categories['Edit categories head'] ?></span></h2>
225 <div class="box">224 <div class="box">
226 <form method="post" action="admin_categories.php?action=foo">225 <form method="post" action="admin_categories.php">
227 <div class="inform">226 <div class="inform">
228 <fieldset>227 <fieldset>
229 <legend><?php echo $lang_admin_categories['Edit categories subhead'] ?></legend>228 <legend><?php echo $lang_admin_categories['Edit categories subhead'] ?></legend>
@@ -238,13 +237,13 @@
238 <tbody>237 <tbody>
239<?php238<?php
240239
241 foreach ($cat_list as $i => $category)240 foreach ($cat_list as $cur_cat)
242 {241 {
243242
244?>243?>
245 <tr>244 <tr>
246 <td class="tcl"><input type="text" name="cat_name[<?php echo $i ?>]" value="<?php echo pun_htmlspecialchars($category[1]) ?>" size="35" maxlength="80" /></td>245 <td class="tcl"><input type="text" name="cat[<?php echo $cur_cat['id'] ?>][name]" value="<?php echo pun_htmlspecialchars($cur_cat['cat_name']) ?>" size="35" maxlength="80" /></td>
247 <td><input type="text" name="cat_order[<?php echo $i ?>]" value="<?php echo $category[2] ?>" size="3" maxlength="3" /></td>246 <td><input type="text" name="cat[<?php echo $cur_cat['id'] ?>][order]" value="<?php echo $cur_cat['disp_position'] ?>" size="3" maxlength="3" /></td>
248 </tr>247 </tr>
249<?php248<?php
250249
251250
=== modified file 'admin_censoring.php'
--- admin_censoring.php 2010-10-08 13:18:35 +0000
+++ admin_censoring.php 2011-04-21 10:05:56 +0000
@@ -1,7 +1,7 @@
1<?php1<?php
22
3/**3/**
4 * Copyright (C) 2008-2010 FluxBB4 * Copyright (C) 2008-2011 FluxBB
5 * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB5 * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB
6 * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher6 * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher
7 */7 */
@@ -9,12 +9,12 @@
9// Tell header.php to use the admin template9// Tell header.php to use the admin template
10define('PUN_ADMIN_CONSOLE', 1);10define('PUN_ADMIN_CONSOLE', 1);
1111
12define('PUN_ROOT', './');12define('PUN_ROOT', dirname(__FILE__).'/');
13require PUN_ROOT.'include/common.php';13require PUN_ROOT.'include/common.php';
14require PUN_ROOT.'include/common_admin.php';14require PUN_ROOT.'include/common_admin.php';
1515
1616
17if (!$pun_user['is_admmod'] || ($pun_user['g_moderator'] == '1' && $pun_config['o_censoring'] == '0'))17if ($pun_user['g_id'] != PUN_ADMIN)
18 message($lang_common['No permission']);18 message($lang_common['No permission']);
1919
20// Load the admin_censoring.php language file20// Load the admin_censoring.php language file
@@ -28,11 +28,17 @@
28 $search_for = pun_trim($_POST['new_search_for']);28 $search_for = pun_trim($_POST['new_search_for']);
29 $replace_with = pun_trim($_POST['new_replace_with']);29 $replace_with = pun_trim($_POST['new_replace_with']);
3030
31 if ($search_for == '' || $replace_with == '')31 if ($search_for == '')
32 message($lang_admin_censoring['Must enter both message']);32 message($lang_admin_censoring['Must enter word message']);
3333
34 $db->query('INSERT INTO '.$db->prefix.'censoring (search_for, replace_with) VALUES (\''.$db->escape($search_for).'\', \''.$db->escape($replace_with).'\')') or error('Unable to add censor word', __FILE__, __LINE__, $db->error());34 $db->query('INSERT INTO '.$db->prefix.'censoring (search_for, replace_with) VALUES (\''.$db->escape($search_for).'\', \''.$db->escape($replace_with).'\')') or error('Unable to add censor word', __FILE__, __LINE__, $db->error());
3535
36 // Regenerate the censoring cache
37 if (!defined('FORUM_CACHE_FUNCTIONS_LOADED'))
38 require PUN_ROOT.'include/cache.php';
39
40 generate_censoring_cache();
41
36 redirect('admin_censoring.php', $lang_admin_censoring['Word added redirect']);42 redirect('admin_censoring.php', $lang_admin_censoring['Word added redirect']);
37}43}
3844
@@ -46,11 +52,17 @@
46 $search_for = pun_trim($_POST['search_for'][$id]);52 $search_for = pun_trim($_POST['search_for'][$id]);
47 $replace_with = pun_trim($_POST['replace_with'][$id]);53 $replace_with = pun_trim($_POST['replace_with'][$id]);
4854
49 if ($search_for == '' || $replace_with == '')55 if ($search_for == '')
50 message($lang_admin_censoring['Must search both message']);56 message($lang_admin_censoring['Must enter word message']);
5157
52 $db->query('UPDATE '.$db->prefix.'censoring SET search_for=\''.$db->escape($search_for).'\', replace_with=\''.$db->escape($replace_with).'\' WHERE id='.$id) or error('Unable to update censor word', __FILE__, __LINE__, $db->error());58 $db->query('UPDATE '.$db->prefix.'censoring SET search_for=\''.$db->escape($search_for).'\', replace_with=\''.$db->escape($replace_with).'\' WHERE id='.$id) or error('Unable to update censor word', __FILE__, __LINE__, $db->error());
5359
60 // Regenerate the censoring cache
61 if (!defined('FORUM_CACHE_FUNCTIONS_LOADED'))
62 require PUN_ROOT.'include/cache.php';
63
64 generate_censoring_cache();
65
54 redirect('admin_censoring.php', $lang_admin_censoring['Word updated redirect']);66 redirect('admin_censoring.php', $lang_admin_censoring['Word updated redirect']);
55}67}
5668
@@ -63,6 +75,12 @@
6375
64 $db->query('DELETE FROM '.$db->prefix.'censoring WHERE id='.$id) or error('Unable to delete censor word', __FILE__, __LINE__, $db->error());76 $db->query('DELETE FROM '.$db->prefix.'censoring WHERE id='.$id) or error('Unable to delete censor word', __FILE__, __LINE__, $db->error());
6577
78 // Regenerate the censoring cache
79 if (!defined('FORUM_CACHE_FUNCTIONS_LOADED'))
80 require PUN_ROOT.'include/cache.php';
81
82 generate_censoring_cache();
83
66 redirect('admin_censoring.php', $lang_admin_censoring['Word removed redirect']);84 redirect('admin_censoring.php', $lang_admin_censoring['Word removed redirect']);
67}85}
6886
@@ -77,12 +95,12 @@
77 <div class="blockform">95 <div class="blockform">
78 <h2><span><?php echo $lang_admin_censoring['Censoring head'] ?></span></h2>96 <h2><span><?php echo $lang_admin_censoring['Censoring head'] ?></span></h2>
79 <div class="box">97 <div class="box">
80 <form id="censoring" method="post" action="admin_censoring.php?action=foo">98 <form id="censoring" method="post" action="admin_censoring.php">
81 <div class="inform">99 <div class="inform">
82 <fieldset>100 <fieldset>
83 <legend><?php echo $lang_admin_censoring['Add word subhead'] ?></legend>101 <legend><?php echo $lang_admin_censoring['Add word subhead'] ?></legend>
84 <div class="infldset">102 <div class="infldset">
85 <p><?php echo $lang_admin_censoring['Add word info'].($pun_user['g_id'] != PUN_ADMIN ? '' : ' '.($pun_config['o_censoring'] == '1' ? sprintf($lang_admin_censoring['Censoring enabled'], '<a href="admin_options.php#censoring">'.$lang_admin_common['Options'].'</a>') : sprintf($lang_admin_censoring['Censoring disabled'], '<a href="admin_options.php#censoring">'.$lang_admin_common['Options'].'</a>'))) ?></p>103 <p><?php echo $lang_admin_censoring['Add word info'].' '.($pun_config['o_censoring'] == '1' ? sprintf($lang_admin_censoring['Censoring enabled'], '<a href="admin_options.php#censoring">'.$lang_admin_common['Options'].'</a>') : sprintf($lang_admin_censoring['Censoring disabled'], '<a href="admin_options.php#censoring">'.$lang_admin_common['Options'].'</a>')) ?></p>
86 <table cellspacing="0">104 <table cellspacing="0">
87 <thead>105 <thead>
88 <tr>106 <tr>
89107
=== modified file 'admin_forums.php'
--- admin_forums.php 2010-10-08 13:18:35 +0000
+++ admin_forums.php 2011-04-21 10:05:56 +0000
@@ -1,7 +1,7 @@
1<?php1<?php
22
3/**3/**
4 * Copyright (C) 2008-2010 FluxBB4 * Copyright (C) 2008-2011 FluxBB
5 * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB5 * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB
6 * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher6 * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher
7 */7 */
@@ -9,7 +9,7 @@
9// Tell header.php to use the admin template9// Tell header.php to use the admin template
10define('PUN_ADMIN_CONSOLE', 1);10define('PUN_ADMIN_CONSOLE', 1);
1111
12define('PUN_ROOT', './');12define('PUN_ROOT', dirname(__FILE__).'/');
13require PUN_ROOT.'include/common.php';13require PUN_ROOT.'include/common.php';
14require PUN_ROOT.'include/common_admin.php';14require PUN_ROOT.'include/common_admin.php';
1515
@@ -72,6 +72,9 @@
72 $db->query('DELETE FROM '.$db->prefix.'forums WHERE id='.$forum_id) or error('Unable to delete forum', __FILE__, __LINE__, $db->error());72 $db->query('DELETE FROM '.$db->prefix.'forums WHERE id='.$forum_id) or error('Unable to delete forum', __FILE__, __LINE__, $db->error());
73 $db->query('DELETE FROM '.$db->prefix.'forum_perms WHERE forum_id='.$forum_id) or error('Unable to delete group forum permissions', __FILE__, __LINE__, $db->error());73 $db->query('DELETE FROM '.$db->prefix.'forum_perms WHERE forum_id='.$forum_id) or error('Unable to delete group forum permissions', __FILE__, __LINE__, $db->error());
7474
75 // Delete any subscriptions for this forum
76 $db->query('DELETE FROM '.$db->prefix.'forum_subscriptions WHERE forum_id='.$forum_id) or error('Unable to delete subscriptions', __FILE__, __LINE__, $db->error());
77
75 // Regenerate the quick jump cache78 // Regenerate the quick jump cache
76 if (!defined('FORUM_CACHE_FUNCTIONS_LOADED'))79 if (!defined('FORUM_CACHE_FUNCTIONS_LOADED'))
77 require PUN_ROOT.'include/cache.php';80 require PUN_ROOT.'include/cache.php';
@@ -274,6 +277,7 @@
274 <select name="sort_by" tabindex="4">277 <select name="sort_by" tabindex="4">
275 <option value="0"<?php if ($cur_forum['sort_by'] == '0') echo ' selected="selected"' ?>><?php echo $lang_admin_forums['Last post'] ?></option>278 <option value="0"<?php if ($cur_forum['sort_by'] == '0') echo ' selected="selected"' ?>><?php echo $lang_admin_forums['Last post'] ?></option>
276 <option value="1"<?php if ($cur_forum['sort_by'] == '1') echo ' selected="selected"' ?>><?php echo $lang_admin_forums['Topic start'] ?></option>279 <option value="1"<?php if ($cur_forum['sort_by'] == '1') echo ' selected="selected"' ?>><?php echo $lang_admin_forums['Topic start'] ?></option>
280 <option value="2"<?php if ($cur_forum['sort_by'] == '2') echo ' selected="selected"' ?>><?php echo $lang_admin_forums['Subject'] ?></option>
277 </select>281 </select>
278 </td>282 </td>
279 </tr>283 </tr>
280284
=== modified file 'admin_groups.php'
--- admin_groups.php 2010-10-08 13:18:35 +0000
+++ admin_groups.php 2011-04-21 10:05:56 +0000
@@ -1,7 +1,7 @@
1<?php1<?php
22
3/**3/**
4 * Copyright (C) 2008-2010 FluxBB4 * Copyright (C) 2008-2011 FluxBB
5 * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB5 * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB
6 * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher6 * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher
7 */7 */
@@ -9,7 +9,7 @@
9// Tell header.php to use the admin template9// Tell header.php to use the admin template
10define('PUN_ADMIN_CONSOLE', 1);10define('PUN_ADMIN_CONSOLE', 1);
1111
12define('PUN_ROOT', './');12define('PUN_ROOT', dirname(__FILE__).'/');
13require PUN_ROOT.'include/common.php';13require PUN_ROOT.'include/common.php';
14require PUN_ROOT.'include/common_admin.php';14require PUN_ROOT.'include/common_admin.php';
1515
@@ -296,7 +296,8 @@
296 if (!defined('FORUM_CACHE_FUNCTIONS_LOADED'))296 if (!defined('FORUM_CACHE_FUNCTIONS_LOADED'))
297 require PUN_ROOT.'include/cache.php';297 require PUN_ROOT.'include/cache.php';
298298
299 generate_quickjump_cache();299 $group_id = $_POST['mode'] == 'add' ? $new_group_id : intval($_POST['group_id']);
300 generate_quickjump_cache($group_id);
300301
301 if ($_POST['mode'] == 'edit')302 if ($_POST['mode'] == 'edit')
302 redirect('admin_groups.php', $lang_admin_groups['Group edited redirect']);303 redirect('admin_groups.php', $lang_admin_groups['Group edited redirect']);
@@ -364,12 +365,6 @@
364 $db->query('DELETE FROM '.$db->prefix.'groups WHERE g_id='.$group_id) or error('Unable to delete group', __FILE__, __LINE__, $db->error());365 $db->query('DELETE FROM '.$db->prefix.'groups WHERE g_id='.$group_id) or error('Unable to delete group', __FILE__, __LINE__, $db->error());
365 $db->query('DELETE FROM '.$db->prefix.'forum_perms WHERE group_id='.$group_id) or error('Unable to delete group forum permissions', __FILE__, __LINE__, $db->error());366 $db->query('DELETE FROM '.$db->prefix.'forum_perms WHERE group_id='.$group_id) or error('Unable to delete group forum permissions', __FILE__, __LINE__, $db->error());
366367
367 // Regenerate the quick jump cache
368 if (!defined('FORUM_CACHE_FUNCTIONS_LOADED'))
369 require PUN_ROOT.'include/cache.php';
370
371 generate_quickjump_cache();
372
373 redirect('admin_groups.php', $lang_admin_groups['Group removed redirect']);368 redirect('admin_groups.php', $lang_admin_groups['Group removed redirect']);
374 }369 }
375 else370 else
@@ -470,7 +465,7 @@
470 <div class="blockform">465 <div class="blockform">
471 <h2><span><?php echo $lang_admin_groups['Add groups head'] ?></span></h2>466 <h2><span><?php echo $lang_admin_groups['Add groups head'] ?></span></h2>
472 <div class="box">467 <div class="box">
473 <form id="groups" method="post" action="admin_groups.php?action=foo">468 <form id="groups" method="post" action="admin_groups.php">
474 <div class="inform">469 <div class="inform">
475 <fieldset>470 <fieldset>
476 <legend><?php echo $lang_admin_groups['Add group subhead'] ?></legend>471 <legend><?php echo $lang_admin_groups['Add group subhead'] ?></legend>
477472
=== modified file 'admin_index.php'
--- admin_index.php 2010-10-08 13:18:35 +0000
+++ admin_index.php 2011-04-21 10:05:56 +0000
@@ -1,7 +1,7 @@
1<?php1<?php
22
3/**3/**
4 * Copyright (C) 2008-2010 FluxBB4 * Copyright (C) 2008-2011 FluxBB
5 * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB5 * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB
6 * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher6 * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher
7 */7 */
@@ -9,7 +9,7 @@
9// Tell header.php to use the admin template9// Tell header.php to use the admin template
10define('PUN_ADMIN_CONSOLE', 1);10define('PUN_ADMIN_CONSOLE', 1);
1111
12define('PUN_ROOT', './');12define('PUN_ROOT', dirname(__FILE__).'/');
13require PUN_ROOT.'include/common.php';13require PUN_ROOT.'include/common.php';
14require PUN_ROOT.'include/common_admin.php';14require PUN_ROOT.'include/common_admin.php';
1515
@@ -126,18 +126,18 @@
126 <h2><span><?php echo $lang_admin_index['Forum admin head'] ?></span></h2>126 <h2><span><?php echo $lang_admin_index['Forum admin head'] ?></span></h2>
127 <div id="adintro" class="box">127 <div id="adintro" class="box">
128 <div class="inbox">128 <div class="inbox">
129 <p>129 <p><?php echo $lang_admin_index['Welcome to admin'] ?></p>
130 <?php echo $lang_admin_index['Welcome to admin'] ?><br /><br />130 <ul>
131 &#160;- <?php echo $lang_admin_index['Welcome 1'] ?><br />131 <li><span><?php echo $lang_admin_index['Welcome 1'] ?></span></li>
132 &#160;- <?php echo $lang_admin_index['Welcome 2'] ?><br />132 <li><span><?php echo $lang_admin_index['Welcome 2'] ?></span></li>
133 &#160;- <?php echo $lang_admin_index['Welcome 3'] ?><br />133 <li><span><?php echo $lang_admin_index['Welcome 3'] ?></span></li>
134 &#160;- <?php echo $lang_admin_index['Welcome 4'] ?><br />134 <li><span><?php echo $lang_admin_index['Welcome 4'] ?></span></li>
135 &#160;- <?php echo $lang_admin_index['Welcome 5'] ?><br />135 <li><span><?php echo $lang_admin_index['Welcome 5'] ?></span></li>
136 &#160;- <?php echo $lang_admin_index['Welcome 6'] ?><br />136 <li><span><?php echo $lang_admin_index['Welcome 6'] ?></span></li>
137 &#160;- <?php echo $lang_admin_index['Welcome 7'] ?><br />137 <li><span><?php echo $lang_admin_index['Welcome 7'] ?></span></li>
138 &#160;- <?php echo $lang_admin_index['Welcome 8'] ?><br />138 <li><span><?php echo $lang_admin_index['Welcome 8'] ?></span></li>
139 &#160;- <?php echo $lang_admin_index['Welcome 9'] ?>139 <li><span><?php echo $lang_admin_index['Welcome 9'] ?></span></li>
140 </p>140 </ul>
141 </div>141 </div>
142 </div>142 </div>
143143
@@ -147,7 +147,7 @@
147 <dl>147 <dl>
148 <dt><?php echo $lang_admin_index['FluxBB version label'] ?></dt>148 <dt><?php echo $lang_admin_index['FluxBB version label'] ?></dt>
149 <dd>149 <dd>
150 <?php printf($lang_admin_index['FluxBB version data'], $pun_config['o_cur_version'], '<a href="admin_index.php?action=check_upgrade">'.$lang_admin_index['Check for upgrade'].'</a>') ?><br />150 <?php printf($lang_admin_index['FluxBB version data'], $pun_config['o_cur_version'], '<a href="admin_index.php?action=check_upgrade">'.$lang_admin_index['Check for upgrade'].'</a>') ?>
151 </dd>151 </dd>
152 <dt><?php echo $lang_admin_index['Server load label'] ?></dt>152 <dt><?php echo $lang_admin_index['Server load label'] ?></dt>
153 <dd>153 <dd>
@@ -164,7 +164,7 @@
164 <?php echo implode(' ', $db->get_version())."\n" ?>164 <?php echo implode(' ', $db->get_version())."\n" ?>
165<?php if (isset($total_records) && isset($total_size)): ?> <br /><?php printf($lang_admin_index['Database data rows'], forum_number_format($total_records)) ?>165<?php if (isset($total_records) && isset($total_size)): ?> <br /><?php printf($lang_admin_index['Database data rows'], forum_number_format($total_records)) ?>
166 <br /><?php printf($lang_admin_index['Database data size'], $total_size) ?>166 <br /><?php printf($lang_admin_index['Database data size'], $total_size) ?>
167<?php endif; endif; ?> </dd>167<?php endif; ?> </dd><?php endif; ?>
168 </dl>168 </dl>
169 </div>169 </div>
170 </div>170 </div>
171171
=== modified file 'admin_loader.php'
--- admin_loader.php 2010-10-08 13:18:35 +0000
+++ admin_loader.php 2011-04-21 10:05:56 +0000
@@ -1,7 +1,7 @@
1<?php1<?php
22
3/**3/**
4 * Copyright (C) 2008-2010 FluxBB4 * Copyright (C) 2008-2011 FluxBB
5 * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB5 * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB
6 * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher6 * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher
7 */7 */
@@ -9,7 +9,7 @@
9// Tell header.php to use the admin template9// Tell header.php to use the admin template
10define('PUN_ADMIN_CONSOLE', 1);10define('PUN_ADMIN_CONSOLE', 1);
1111
12define('PUN_ROOT', './');12define('PUN_ROOT', dirname(__FILE__).'/');
13require PUN_ROOT.'include/common.php';13require PUN_ROOT.'include/common.php';
14require PUN_ROOT.'include/common_admin.php';14require PUN_ROOT.'include/common_admin.php';
1515
1616
=== modified file 'admin_maintenance.php'
--- admin_maintenance.php 2010-10-08 13:18:35 +0000
+++ admin_maintenance.php 2011-04-21 10:05:56 +0000
@@ -1,7 +1,7 @@
1<?php1<?php
22
3/**3/**
4 * Copyright (C) 2008-2010 FluxBB4 * Copyright (C) 2008-2011 FluxBB
5 * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB5 * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB
6 * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher6 * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher
7 */7 */
@@ -11,7 +11,7 @@
11// Tell common.php that we don't want output buffering11// Tell common.php that we don't want output buffering
12define('PUN_DISABLE_BUFFERING', 1);12define('PUN_DISABLE_BUFFERING', 1);
1313
14define('PUN_ROOT', './');14define('PUN_ROOT', dirname(__FILE__).'/');
15require PUN_ROOT.'include/common.php';15require PUN_ROOT.'include/common.php';
16require PUN_ROOT.'include/common_admin.php';16require PUN_ROOT.'include/common_admin.php';
1717
@@ -22,12 +22,16 @@
22// Load the admin_maintenance.php language file22// Load the admin_maintenance.php language file
23require PUN_ROOT.'lang/'.$admin_language.'/admin_maintenance.php';23require PUN_ROOT.'lang/'.$admin_language.'/admin_maintenance.php';
2424
25if (isset($_GET['i_per_page']) && isset($_GET['i_start_at']))25$action = isset($_REQUEST['action']) ? trim($_REQUEST['action']) : '';
26
27if ($action == 'rebuild')
26{28{
27 $per_page = intval($_GET['i_per_page']);29 $per_page = isset($_GET['i_per_page']) ? intval($_GET['i_per_page']) : 0;
28 $start_at = intval($_GET['i_start_at']);30 $start_at = isset($_GET['i_start_at']) ? intval($_GET['i_start_at']) : 0;
29 if ($per_page < 1 || $start_at < 1)31
30 message($lang_common['Bad request']);32 // Check per page is > 0
33 if ($per_page < 1)
34 message($lang_admin_maintenance['Posts must be integer message']);
3135
32 @set_time_limit(0);36 @set_time_limit(0);
3337
@@ -110,7 +114,7 @@
110 $result = $db->query('SELECT id FROM '.$db->prefix.'posts WHERE id > '.$end_at.' ORDER BY id ASC LIMIT 1') or error('Unable to fetch next ID', __FILE__, __LINE__, $db->error());114 $result = $db->query('SELECT id FROM '.$db->prefix.'posts WHERE id > '.$end_at.' ORDER BY id ASC LIMIT 1') or error('Unable to fetch next ID', __FILE__, __LINE__, $db->error());
111115
112 if ($db->num_rows($result) > 0)116 if ($db->num_rows($result) > 0)
113 $query_str = '?i_per_page='.$per_page.'&i_start_at='.$db->result($result);117 $query_str = '?action=rebuild&i_per_page='.$per_page.'&i_start_at='.$db->result($result);
114 }118 }
115119
116 $db->end_transaction();120 $db->end_transaction();
@@ -119,6 +123,122 @@
119 exit('<script type="text/javascript">window.location="admin_maintenance.php'.$query_str.'"</script><hr /><p>'.sprintf($lang_admin_maintenance['Javascript redirect failed'], '<a href="admin_maintenance.php'.$query_str.'">'.$lang_admin_maintenance['Click here'].'</a>').'</p>');123 exit('<script type="text/javascript">window.location="admin_maintenance.php'.$query_str.'"</script><hr /><p>'.sprintf($lang_admin_maintenance['Javascript redirect failed'], '<a href="admin_maintenance.php'.$query_str.'">'.$lang_admin_maintenance['Click here'].'</a>').'</p>');
120}124}
121125
126if ($action == 'prune')
127{
128 $prune_from = trim($_POST['prune_from']);
129 $prune_sticky = intval($_POST['prune_sticky']);
130
131 if (isset($_POST['prune_comply']))
132 {
133 confirm_referrer('admin_maintenance.php');
134
135 $prune_days = intval($_POST['prune_days']);
136 $prune_date = ($prune_days) ? time() - ($prune_days * 86400) : -1;
137
138 @set_time_limit(0);
139
140 if ($prune_from == 'all')
141 {
142 $result = $db->query('SELECT id FROM '.$db->prefix.'forums') or error('Unable to fetch forum list', __FILE__, __LINE__, $db->error());
143 $num_forums = $db->num_rows($result);
144
145 for ($i = 0; $i < $num_forums; ++$i)
146 {
147 $fid = $db->result($result, $i);
148
149 prune($fid, $prune_sticky, $prune_date);
150 update_forum($fid);
151 }
152 }
153 else
154 {
155 $prune_from = intval($prune_from);
156 prune($prune_from, $prune_sticky, $prune_date);
157 update_forum($prune_from);
158 }
159
160 // Locate any "orphaned redirect topics" and delete them
161 $result = $db->query('SELECT t1.id FROM '.$db->prefix.'topics AS t1 LEFT JOIN '.$db->prefix.'topics AS t2 ON t1.moved_to=t2.id WHERE t2.id IS NULL AND t1.moved_to IS NOT NULL') or error('Unable to fetch redirect topics', __FILE__, __LINE__, $db->error());
162 $num_orphans = $db->num_rows($result);
163
164 if ($num_orphans)
165 {
166 for ($i = 0; $i < $num_orphans; ++$i)
167 $orphans[] = $db->result($result, $i);
168
169 $db->query('DELETE FROM '.$db->prefix.'topics WHERE id IN('.implode(',', $orphans).')') or error('Unable to delete redirect topics', __FILE__, __LINE__, $db->error());
170 }
171
172 redirect('admin_maintenance.php', $lang_admin_maintenance['Posts pruned redirect']);
173 }
174
175 $prune_days = trim($_POST['req_prune_days']);
176 if ($prune_days == '' || preg_match('/[^0-9]/', $prune_days))
177 message($lang_admin_maintenance['Days must be integer message']);
178
179 $prune_date = time() - ($prune_days * 86400);
180
181 // Concatenate together the query for counting number of topics to prune
182 $sql = 'SELECT COUNT(id) FROM '.$db->prefix.'topics WHERE last_post<'.$prune_date.' AND moved_to IS NULL';
183
184 if ($prune_sticky == '0')
185 $sql .= ' AND sticky=0';
186
187 if ($prune_from != 'all')
188 {
189 $prune_from = intval($prune_from);
190 $sql .= ' AND forum_id='.$prune_from;
191
192 // Fetch the forum name (just for cosmetic reasons)
193 $result = $db->query('SELECT forum_name FROM '.$db->prefix.'forums WHERE id='.$prune_from) or error('Unable to fetch forum name', __FILE__, __LINE__, $db->error());
194 $forum = '"'.pun_htmlspecialchars($db->result($result)).'"';
195 }
196 else
197 $forum = $lang_admin_maintenance['All forums'];
198
199 $result = $db->query($sql) or error('Unable to fetch topic prune count', __FILE__, __LINE__, $db->error());
200 $num_topics = $db->result($result);
201
202 if (!$num_topics)
203 message(sprintf($lang_admin_maintenance['No old topics message'], $prune_days));
204
205
206 $page_title = array(pun_htmlspecialchars($pun_config['o_board_title']), $lang_admin_common['Admin'], $lang_admin_common['Prune']);
207 define('PUN_ACTIVE_PAGE', 'admin');
208 require PUN_ROOT.'header.php';
209
210 generate_admin_menu('maintenance');
211
212?>
213 <div class="blockform">
214 <h2><span><?php echo $lang_admin_maintenance['Prune head'] ?></span></h2>
215 <div class="box">
216 <form method="post" action="admin_maintenance.php">
217 <div class="inform">
218 <input type="hidden" name="action" value="prune" />
219 <input type="hidden" name="prune_days" value="<?php echo $prune_days ?>" />
220 <input type="hidden" name="prune_sticky" value="<?php echo $prune_sticky ?>" />
221 <input type="hidden" name="prune_from" value="<?php echo $prune_from ?>" />
222 <fieldset>
223 <legend><?php echo $lang_admin_maintenance['Confirm prune subhead'] ?></legend>
224 <div class="infldset">
225 <p><?php printf($lang_admin_maintenance['Confirm prune info'], $prune_days, $forum, forum_number_format($num_topics)) ?></p>
226 <p class="warntext"><?php echo $lang_admin_maintenance['Confirm prune warn'] ?></p>
227 </div>
228 </fieldset>
229 </div>
230 <p class="buttons"><input type="submit" name="prune_comply" value="<?php echo $lang_admin_common['Prune'] ?>" /><a href="javascript:history.go(-1)"><?php echo $lang_admin_common['Go back'] ?></a></p>
231 </form>
232 </div>
233 </div>
234 <div class="clearer"></div>
235</div>
236<?php
237
238 require PUN_ROOT.'footer.php';
239 exit;
240}
241
122242
123// Get the first post ID from the db243// Get the first post ID from the db
124$result = $db->query('SELECT id FROM '.$db->prefix.'posts ORDER BY id ASC LIMIT 1') or error('Unable to fetch topic info', __FILE__, __LINE__, $db->error());244$result = $db->query('SELECT id FROM '.$db->prefix.'posts ORDER BY id ASC LIMIT 1') or error('Unable to fetch topic info', __FILE__, __LINE__, $db->error());
@@ -137,6 +257,7 @@
137 <div class="box">257 <div class="box">
138 <form method="get" action="admin_maintenance.php">258 <form method="get" action="admin_maintenance.php">
139 <div class="inform">259 <div class="inform">
260 <input type="hidden" name="action" value="rebuild" />
140 <fieldset>261 <fieldset>
141 <legend><?php echo $lang_admin_maintenance['Rebuild index subhead'] ?></legend>262 <legend><?php echo $lang_admin_maintenance['Rebuild index subhead'] ?></legend>
142 <div class="infldset">263 <div class="infldset">
@@ -169,6 +290,65 @@
169 </fieldset>290 </fieldset>
170 </div>291 </div>
171 </form>292 </form>
293
294 <form method="post" action="admin_maintenance.php" onsubmit="return process_form(this)">
295 <div class="inform">
296 <input type="hidden" name="action" value="prune" />
297 <fieldset>
298 <legend><?php echo $lang_admin_maintenance['Prune subhead'] ?></legend>
299 <div class="infldset">
300 <table class="aligntop" cellspacing="0">
301 <tr>
302 <th scope="row"><?php echo $lang_admin_maintenance['Days old label'] ?></th>
303 <td>
304 <input type="text" name="req_prune_days" size="3" maxlength="3" tabindex="5" />
305 <span><?php echo $lang_admin_maintenance['Days old help'] ?></span>
306 </td>
307 </tr>
308 <tr>
309 <th scope="row"><?php echo $lang_admin_maintenance['Prune sticky label'] ?></th>
310 <td>
311 <input type="radio" name="prune_sticky" value="1" tabindex="6" checked="checked" />&#160;<strong><?php echo $lang_admin_common['Yes'] ?></strong>&#160;&#160;&#160;<input type="radio" name="prune_sticky" value="0" />&#160;<strong><?php echo $lang_admin_common['No'] ?></strong>
312 <span><?php echo $lang_admin_maintenance['Prune sticky help'] ?></span>
313 </td>
314 </tr>
315 <tr>
316 <th scope="row"><?php echo $lang_admin_maintenance['Prune from label'] ?></th>
317 <td>
318 <select name="prune_from" tabindex="7">
319 <option value="all"><?php echo $lang_admin_maintenance['All forums'] ?></option>
320<?php
321
322 $result = $db->query('SELECT c.id AS cid, c.cat_name, f.id AS fid, f.forum_name FROM '.$db->prefix.'categories AS c INNER JOIN '.$db->prefix.'forums AS f ON c.id=f.cat_id WHERE f.redirect_url IS NULL ORDER BY c.disp_position, c.id, f.disp_position') or error('Unable to fetch category/forum list', __FILE__, __LINE__, $db->error());
323
324 $cur_category = 0;
325 while ($forum = $db->fetch_assoc($result))
326 {
327 if ($forum['cid'] != $cur_category) // Are we still in the same category?
328 {
329 if ($cur_category)
330 echo "\t\t\t\t\t\t\t\t\t\t\t".'</optgroup>'."\n";
331
332 echo "\t\t\t\t\t\t\t\t\t\t\t".'<optgroup label="'.pun_htmlspecialchars($forum['cat_name']).'">'."\n";
333 $cur_category = $forum['cid'];
334 }
335
336 echo "\t\t\t\t\t\t\t\t\t\t\t\t".'<option value="'.$forum['fid'].'">'.pun_htmlspecialchars($forum['forum_name']).'</option>'."\n";
337 }
338
339?>
340 </optgroup>
341 </select>
342 <span><?php echo $lang_admin_maintenance['Prune from help'] ?></span>
343 </td>
344 </tr>
345 </table>
346 <p class="topspace"><?php printf($lang_admin_maintenance['Prune info'], '<a href="admin_options.php#maintenance">'.$lang_admin_common['Maintenance mode'].'</a>') ?></p>
347 <div class="fsetsubmit"><input type="submit" name="prune" value="<?php echo $lang_admin_common['Prune'] ?>" tabindex="8" /></div>
348 </div>
349 </fieldset>
350 </div>
351 </form>
172 </div>352 </div>
173 </div>353 </div>
174 <div class="clearer"></div>354 <div class="clearer"></div>
175355
=== modified file 'admin_options.php'
--- admin_options.php 2010-10-08 13:18:35 +0000
+++ admin_options.php 2011-04-21 10:05:56 +0000
@@ -1,7 +1,7 @@
1<?php1<?php
22
3/**3/**
4 * Copyright (C) 2008-2010 FluxBB4 * Copyright (C) 2008-2011 FluxBB
5 * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB5 * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB
6 * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher6 * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher
7 */7 */
@@ -9,7 +9,7 @@
9// Tell header.php to use the admin template9// Tell header.php to use the admin template
10define('PUN_ADMIN_CONSOLE', 1);10define('PUN_ADMIN_CONSOLE', 1);
1111
12define('PUN_ROOT', './');12define('PUN_ROOT', dirname(__FILE__).'/');
13require PUN_ROOT.'include/common.php';13require PUN_ROOT.'include/common.php';
14require PUN_ROOT.'include/common_admin.php';14require PUN_ROOT.'include/common_admin.php';
1515
@@ -22,9 +22,7 @@
2222
23if (isset($_POST['form_sent']))23if (isset($_POST['form_sent']))
24{24{
25 // Custom referrer check (so we can output a custom error message)25 confirm_referrer('admin_options.php', $lang_admin_options['Bad HTTP Referer message']);
26 if (!preg_match('#^'.preg_quote(str_replace('www.', '', $pun_config['o_base_url']).'/admin_options.php', '#').'#i', str_replace('www.', '', (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : ''))))
27 message($lang_admin_options['Bad HTTP Referer message']);
2826
29 $form = array(27 $form = array(
30 'board_title' => pun_trim($_POST['form']['board_title']),28 'board_title' => pun_trim($_POST['form']['board_title']),
@@ -32,8 +30,8 @@
32 'base_url' => pun_trim($_POST['form']['base_url']),30 'base_url' => pun_trim($_POST['form']['base_url']),
33 'default_timezone' => floatval($_POST['form']['default_timezone']),31 'default_timezone' => floatval($_POST['form']['default_timezone']),
34 'default_dst' => $_POST['form']['default_dst'] != '1' ? '0' : '1',32 'default_dst' => $_POST['form']['default_dst'] != '1' ? '0' : '1',
35 'default_lang' => preg_replace('#[\.\\\/]#', '', pun_trim($_POST['form']['default_lang'])),33 'default_lang' => pun_trim($_POST['form']['default_lang']),
36 'default_style' => preg_replace('#[\.\\\/]#', '', pun_trim($_POST['form']['default_style'])),34 'default_style' => pun_trim($_POST['form']['default_style']),
37 'time_format' => pun_trim($_POST['form']['time_format']),35 'time_format' => pun_trim($_POST['form']['time_format']),
38 'date_format' => pun_trim($_POST['form']['date_format']),36 'date_format' => pun_trim($_POST['form']['date_format']),
39 'timeout_visit' => intval($_POST['form']['timeout_visit']),37 'timeout_visit' => intval($_POST['form']['timeout_visit']),
@@ -62,6 +60,7 @@
62 'search_all_forums' => $_POST['form']['search_all_forums'] != '1' ? '0' : '1',60 'search_all_forums' => $_POST['form']['search_all_forums'] != '1' ? '0' : '1',
63 'additional_navlinks' => pun_trim($_POST['form']['additional_navlinks']),61 'additional_navlinks' => pun_trim($_POST['form']['additional_navlinks']),
64 'feed_type' => intval($_POST['form']['feed_type']),62 'feed_type' => intval($_POST['form']['feed_type']),
63 'feed_ttl' => intval($_POST['form']['feed_ttl']),
65 'report_method' => intval($_POST['form']['report_method']),64 'report_method' => intval($_POST['form']['report_method']),
66 'mailing_list' => pun_trim($_POST['form']['mailing_list']),65 'mailing_list' => pun_trim($_POST['form']['mailing_list']),
67 'avatars' => $_POST['form']['avatars'] != '1' ? '0' : '1',66 'avatars' => $_POST['form']['avatars'] != '1' ? '0' : '1',
@@ -71,10 +70,10 @@
71 'avatars_size' => intval($_POST['form']['avatars_size']),70 'avatars_size' => intval($_POST['form']['avatars_size']),
72 'admin_email' => strtolower(pun_trim($_POST['form']['admin_email'])),71 'admin_email' => strtolower(pun_trim($_POST['form']['admin_email'])),
73 'webmaster_email' => strtolower(pun_trim($_POST['form']['webmaster_email'])),72 'webmaster_email' => strtolower(pun_trim($_POST['form']['webmaster_email'])),
74 'subscriptions' => $_POST['form']['subscriptions'] != '1' ? '0' : '1',73 'forum_subscriptions' => $_POST['form']['forum_subscriptions'] != '1' ? '0' : '1',
74 'topic_subscriptions' => $_POST['form']['topic_subscriptions'] != '1' ? '0' : '1',
75 'smtp_host' => pun_trim($_POST['form']['smtp_host']),75 'smtp_host' => pun_trim($_POST['form']['smtp_host']),
76 'smtp_user' => pun_trim($_POST['form']['smtp_user']),76 'smtp_user' => pun_trim($_POST['form']['smtp_user']),
77 'smtp_pass' => pun_trim($_POST['form']['smtp_pass']),
78 'smtp_ssl' => $_POST['form']['smtp_ssl'] != '1' ? '0' : '1',77 'smtp_ssl' => $_POST['form']['smtp_ssl'] != '1' ? '0' : '1',
79 'regs_allow' => $_POST['form']['regs_allow'] != '1' ? '0' : '1',78 'regs_allow' => $_POST['form']['regs_allow'] != '1' ? '0' : '1',
80 'regs_verify' => $_POST['form']['regs_verify'] != '1' ? '0' : '1',79 'regs_verify' => $_POST['form']['regs_verify'] != '1' ? '0' : '1',
@@ -95,9 +94,12 @@
95 if (substr($form['base_url'], -1) == '/')94 if (substr($form['base_url'], -1) == '/')
96 $form['base_url'] = substr($form['base_url'], 0, -1);95 $form['base_url'] = substr($form['base_url'], 0, -1);
9796
98 if (!file_exists(PUN_ROOT.'lang/'.$form['default_lang'].'/common.php'))97 $languages = forum_list_langs();
98 if (!in_array($form['default_lang'], $languages))
99 message($lang_common['Bad request']);99 message($lang_common['Bad request']);
100 if (!file_exists(PUN_ROOT.'style/'.$form['default_style'].'.css'))100
101 $styles = forum_list_styles();
102 if (!in_array($form['default_style'], $styles))
101 message($lang_common['Bad request']);103 message($lang_common['Bad request']);
102104
103 if ($form['time_format'] == '')105 if ($form['time_format'] == '')
@@ -125,6 +127,18 @@
125 if ($form['additional_navlinks'] != '')127 if ($form['additional_navlinks'] != '')
126 $form['additional_navlinks'] = pun_trim(pun_linebreaks($form['additional_navlinks']));128 $form['additional_navlinks'] = pun_trim(pun_linebreaks($form['additional_navlinks']));
127129
130 // Change or enter a SMTP password
131 if (isset($_POST['form']['smtp_change_pass']))
132 {
133 $smtp_pass1 = isset($_POST['form']['smtp_pass1']) ? pun_trim($_POST['form']['smtp_pass1']) : '';
134 $smtp_pass2 = isset($_POST['form']['smtp_pass2']) ? pun_trim($_POST['form']['smtp_pass2']) : '';
135
136 if ($smtp_pass1 == $smtp_pass2)
137 $form['smtp_pass'] = $smtp_pass1;
138 else
139 message($lang_admin_options['SMTP passwords did not match']);
140 }
141
128 if ($form['announcement_message'] != '')142 if ($form['announcement_message'] != '')
129 $form['announcement_message'] = pun_linebreaks($form['announcement_message']);143 $form['announcement_message'] = pun_linebreaks($form['announcement_message']);
130 else144 else
@@ -163,6 +177,9 @@
163 if ($form['feed_type'] < 0 || $form['feed_type'] > 2)177 if ($form['feed_type'] < 0 || $form['feed_type'] > 2)
164 message($lang_common['Bad request']);178 message($lang_common['Bad request']);
165179
180 if ($form['feed_ttl'] < 0)
181 message($lang_common['Bad request']);
182
166 if ($form['report_method'] < 0 || $form['report_method'] > 2)183 if ($form['report_method'] < 0 || $form['report_method'] > 2)
167 message($lang_common['Bad request']);184 message($lang_common['Bad request']);
168185
@@ -191,6 +208,7 @@
191 require PUN_ROOT.'include/cache.php';208 require PUN_ROOT.'include/cache.php';
192209
193 generate_config_cache();210 generate_config_cache();
211 clear_feed_cache();
194212
195 redirect('admin_options.php', $lang_admin_options['Options updated redirect']);213 redirect('admin_options.php', $lang_admin_options['Options updated redirect']);
196}214}
@@ -205,7 +223,7 @@
205 <div class="blockform">223 <div class="blockform">
206 <h2><span><?php echo $lang_admin_options['Options head'] ?></span></h2>224 <h2><span><?php echo $lang_admin_options['Options head'] ?></span></h2>
207 <div class="box">225 <div class="box">
208 <form method="post" action="admin_options.php?action=foo">226 <form method="post" action="admin_options.php">
209 <p class="submittop"><input type="submit" name="save" value="<?php echo $lang_admin_common['Save changes'] ?>" /></p>227 <p class="submittop"><input type="submit" name="save" value="<?php echo $lang_admin_common['Save changes'] ?>" /></p>
210 <div class="inform">228 <div class="inform">
211 <input type="hidden" name="form_sent" value="1" />229 <input type="hidden" name="form_sent" value="1" />
@@ -230,7 +248,7 @@
230 <tr>248 <tr>
231 <th scope="row"><?php echo $lang_admin_options['Base URL label'] ?></th>249 <th scope="row"><?php echo $lang_admin_options['Base URL label'] ?></th>
232 <td>250 <td>
233 <input type="text" name="form[base_url]" size="50" maxlength="100" value="<?php echo $pun_config['o_base_url'] ?>" />251 <input type="text" name="form[base_url]" size="50" maxlength="100" value="<?php echo pun_htmlspecialchars($pun_config['o_base_url']) ?>" />
234 <span><?php echo $lang_admin_options['Base URL help'] ?></span>252 <span><?php echo $lang_admin_options['Base URL help'] ?></span>
235 </td>253 </td>
236 </tr>254 </tr>
@@ -553,6 +571,15 @@
553 <span><?php echo $lang_admin_options['Menu items help'] ?></span>571 <span><?php echo $lang_admin_options['Menu items help'] ?></span>
554 </td>572 </td>
555 </tr>573 </tr>
574 </table>
575 </div>
576 </fieldset>
577 </div>
578 <div class="inform">
579 <fieldset>
580 <legend><?php echo $lang_admin_options['Feed subhead'] ?></legend>
581 <div class="infldset">
582 <table class="aligntop" cellspacing="0">
556 <tr>583 <tr>
557 <th scope="row"><?php echo $lang_admin_options['Default feed label'] ?></th>584 <th scope="row"><?php echo $lang_admin_options['Default feed label'] ?></th>
558 <td>585 <td>
@@ -560,6 +587,23 @@
560 <span><?php echo $lang_admin_options['Default feed help'] ?></span>587 <span><?php echo $lang_admin_options['Default feed help'] ?></span>
561 </td>588 </td>
562 </tr>589 </tr>
590 <tr>
591 <th scope="row"><?php echo $lang_admin_options['Feed TTL label'] ?></th>
592 <td>
593 <select name="form[feed_ttl]">
594 <option value="0"<?php if ($pun_config['o_feed_ttl'] == '0') echo ' selected="selected"'; ?>><?php echo $lang_admin_options['No cache'] ?></option>
595<?php
596
597 $times = array(5, 15, 30, 60);
598
599 foreach ($times as $time)
600 echo "\t\t\t\t\t\t\t\t\t\t\t".'<option value="'.$time.'"'.($pun_config['o_feed_ttl'] == $time ? ' selected="selected"' : '').'>'.sprintf($lang_admin_options['Minutes'], $time).'</option>'."\n";
601
602?>
603 </select>
604 <span><?php echo $lang_admin_options['Feed TTL help'] ?></span>
605 </td>
606 </tr>
563 </table>607 </table>
564 </div>608 </div>
565 </fieldset>609 </fieldset>
@@ -651,10 +695,17 @@
651 </td>695 </td>
652 </tr>696 </tr>
653 <tr>697 <tr>
654 <th scope="row"><?php echo $lang_admin_options['Subscriptions label'] ?></th>698 <th scope="row"><?php echo $lang_admin_options['Forum subscriptions label'] ?></th>
655 <td>699 <td>
656 <input type="radio" name="form[subscriptions]" value="1"<?php if ($pun_config['o_subscriptions'] == '1') echo ' checked="checked"' ?> />&#160;<strong><?php echo $lang_admin_common['Yes'] ?></strong>&#160;&#160;&#160;<input type="radio" name="form[subscriptions]" value="0"<?php if ($pun_config['o_subscriptions'] == '0') echo ' checked="checked"' ?> />&#160;<strong><?php echo $lang_admin_common['No'] ?></strong>700 <input type="radio" name="form[forum_subscriptions]" value="1"<?php if ($pun_config['o_forum_subscriptions'] == '1') echo ' checked="checked"' ?> />&#160;<strong><?php echo $lang_admin_common['Yes'] ?></strong>&#160;&#160;&#160;<input type="radio" name="form[forum_subscriptions]" value="0"<?php if ($pun_config['o_forum_subscriptions'] == '0') echo ' checked="checked"' ?> />&#160;<strong><?php echo $lang_admin_common['No'] ?></strong>
657 <span><?php echo $lang_admin_options['Subscriptions help'] ?></span>701 <span><?php echo $lang_admin_options['Forum subscriptions help'] ?></span>
702 </td>
703 </tr>
704 <tr>
705 <th scope="row"><?php echo $lang_admin_options['Topic subscriptions label'] ?></th>
706 <td>
707 <input type="radio" name="form[topic_subscriptions]" value="1"<?php if ($pun_config['o_topic_subscriptions'] == '1') echo ' checked="checked"' ?> />&#160;<strong><?php echo $lang_admin_common['Yes'] ?></strong>&#160;&#160;&#160;<input type="radio" name="form[topic_subscriptions]" value="0"<?php if ($pun_config['o_topic_subscriptions'] == '0') echo ' checked="checked"' ?> />&#160;<strong><?php echo $lang_admin_common['No'] ?></strong>
708 <span><?php echo $lang_admin_options['Topic subscriptions help'] ?></span>
658 </td>709 </td>
659 </tr>710 </tr>
660 <tr>711 <tr>
@@ -674,7 +725,10 @@
674 <tr>725 <tr>
675 <th scope="row"><?php echo $lang_admin_options['SMTP password label'] ?></th>726 <th scope="row"><?php echo $lang_admin_options['SMTP password label'] ?></th>
676 <td>727 <td>
677 <input type="text" name="form[smtp_pass]" size="25" maxlength="50" value="<?php echo pun_htmlspecialchars($pun_config['o_smtp_pass']) ?>" />728 <span><input type="checkbox" name="form[smtp_change_pass]" value="1" />&#160;&#160;<?php echo $lang_admin_options['SMTP change password help'] ?></span>
729<?php $smtp_pass = !empty($pun_config['o_smtp_pass']) ? random_key(pun_strlen($pun_config['o_smtp_pass']), true) : ''; ?>
730 <input type="password" name="form[smtp_pass1]" size="25" maxlength="50" value="<?php echo $smtp_pass ?>" />
731 <input type="password" name="form[smtp_pass2]" size="25" maxlength="50" value="<?php echo $smtp_pass ?>" />
678 <span><?php echo $lang_admin_options['SMTP password help'] ?></span>732 <span><?php echo $lang_admin_options['SMTP password help'] ?></span>
679 </td>733 </td>
680 </tr>734 </tr>
681735
=== modified file 'admin_permissions.php'
--- admin_permissions.php 2010-10-08 13:18:35 +0000
+++ admin_permissions.php 2011-04-21 10:05:56 +0000
@@ -1,7 +1,7 @@
1<?php1<?php
22
3/**3/**
4 * Copyright (C) 2008-2010 FluxBB4 * Copyright (C) 2008-2011 FluxBB
5 * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB5 * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB
6 * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher6 * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher
7 */7 */
@@ -9,7 +9,7 @@
9// Tell header.php to use the admin template9// Tell header.php to use the admin template
10define('PUN_ADMIN_CONSOLE', 1);10define('PUN_ADMIN_CONSOLE', 1);
1111
12define('PUN_ROOT', './');12define('PUN_ROOT', dirname(__FILE__).'/');
13require PUN_ROOT.'include/common.php';13require PUN_ROOT.'include/common.php';
14require PUN_ROOT.'include/common_admin.php';14require PUN_ROOT.'include/common_admin.php';
1515
1616
=== removed file 'admin_prune.php'
--- admin_prune.php 2010-10-08 13:18:35 +0000
+++ admin_prune.php 1970-01-01 00:00:00 +0000
@@ -1,217 +0,0 @@
1<?php
2
3/**
4 * Copyright (C) 2008-2010 FluxBB
5 * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB
6 * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher
7 */
8
9// Tell header.php to use the admin template
10define('PUN_ADMIN_CONSOLE', 1);
11
12define('PUN_ROOT', './');
13require PUN_ROOT.'include/common.php';
14require PUN_ROOT.'include/common_admin.php';
15
16
17if ($pun_user['g_id'] != PUN_ADMIN)
18 message($lang_common['No permission']);
19
20// Load the admin_prune.php language file
21require PUN_ROOT.'lang/'.$admin_language.'/admin_prune.php';
22
23if (isset($_GET['action']) || isset($_POST['prune']) || isset($_POST['prune_comply']))
24{
25 $prune_from = trim($_POST['prune_from']);
26 $prune_sticky = intval($_POST['prune_sticky']);
27
28 if (isset($_POST['prune_comply']))
29 {
30 confirm_referrer('admin_prune.php');
31
32 $prune_days = intval($_POST['prune_days']);
33 $prune_date = ($prune_days) ? time() - ($prune_days * 86400) : -1;
34
35 @set_time_limit(0);
36
37 if ($prune_from == 'all')
38 {
39 $result = $db->query('SELECT id FROM '.$db->prefix.'forums') or error('Unable to fetch forum list', __FILE__, __LINE__, $db->error());
40 $num_forums = $db->num_rows($result);
41
42 for ($i = 0; $i < $num_forums; ++$i)
43 {
44 $fid = $db->result($result, $i);
45
46 prune($fid, $prune_sticky, $prune_date);
47 update_forum($fid);
48 }
49 }
50 else
51 {
52 $prune_from = intval($prune_from);
53 prune($prune_from, $prune_sticky, $prune_date);
54 update_forum($prune_from);
55 }
56
57 // Locate any "orphaned redirect topics" and delete them
58 $result = $db->query('SELECT t1.id FROM '.$db->prefix.'topics AS t1 LEFT JOIN '.$db->prefix.'topics AS t2 ON t1.moved_to=t2.id WHERE t2.id IS NULL AND t1.moved_to IS NOT NULL') or error('Unable to fetch redirect topics', __FILE__, __LINE__, $db->error());
59 $num_orphans = $db->num_rows($result);
60
61 if ($num_orphans)
62 {
63 for ($i = 0; $i < $num_orphans; ++$i)
64 $orphans[] = $db->result($result, $i);
65
66 $db->query('DELETE FROM '.$db->prefix.'topics WHERE id IN('.implode(',', $orphans).')') or error('Unable to delete redirect topics', __FILE__, __LINE__, $db->error());
67 }
68
69 redirect('admin_prune.php', $lang_admin_prune['Posts pruned redirect']);
70 }
71
72 $prune_days = trim($_POST['req_prune_days']);
73 if ($prune_days == '' || preg_match('/[^0-9]/', $prune_days))
74 message($lang_admin_prune['Must be integer message']);
75
76 $prune_date = time() - ($prune_days * 86400);
77
78 // Concatenate together the query for counting number of topics to prune
79 $sql = 'SELECT COUNT(id) FROM '.$db->prefix.'topics WHERE last_post<'.$prune_date.' AND moved_to IS NULL';
80
81 if ($prune_sticky == '0')
82 $sql .= ' AND sticky=\'0\'';
83
84 if ($prune_from != 'all')
85 {
86 $prune_from = intval($prune_from);
87 $sql .= ' AND forum_id='.$prune_from;
88
89 // Fetch the forum name (just for cosmetic reasons)
90 $result = $db->query('SELECT forum_name FROM '.$db->prefix.'forums WHERE id='.$prune_from) or error('Unable to fetch forum name', __FILE__, __LINE__, $db->error());
91 $forum = '"'.pun_htmlspecialchars($db->result($result)).'"';
92 }
93 else
94 $forum = $lang_admin_prune['All forums'];
95
96 $result = $db->query($sql) or error('Unable to fetch topic prune count', __FILE__, __LINE__, $db->error());
97 $num_topics = $db->result($result);
98
99 if (!$num_topics)
100 message(sprintf($lang_admin_prune['No old topics message'], $prune_days));
101
102
103 $page_title = array(pun_htmlspecialchars($pun_config['o_board_title']), $lang_admin_common['Admin'], $lang_admin_common['Prune']);
104 define('PUN_ACTIVE_PAGE', 'admin');
105 require PUN_ROOT.'header.php';
106
107 generate_admin_menu('prune');
108
109?>
110 <div class="blockform">
111 <h2><span><?php echo $lang_admin_prune['Prune head'] ?></span></h2>
112 <div class="box">
113 <form method="post" action="admin_prune.php?action=foo">
114 <div class="inform">
115 <input type="hidden" name="prune_days" value="<?php echo $prune_days ?>" />
116 <input type="hidden" name="prune_sticky" value="<?php echo $prune_sticky ?>" />
117 <input type="hidden" name="prune_from" value="<?php echo $prune_from ?>" />
118 <fieldset>
119 <legend><?php echo $lang_admin_prune['Confirm prune subhead'] ?></legend>
120 <div class="infldset">
121 <p><?php printf($lang_admin_prune['Confirm prune info'], $prune_days, $forum, forum_number_format($num_topics)) ?></p>
122 <p class="warntext"><?php echo $lang_admin_prune['Confirm prune warn'] ?></p>
123 </div>
124 </fieldset>
125 </div>
126 <p class="buttons"><input type="submit" name="prune_comply" value="<?php echo $lang_admin_common['Prune'] ?>" /><a href="javascript:history.go(-1)"><?php echo $lang_admin_common['Go back'] ?></a></p>
127 </form>
128 </div>
129 </div>
130 <div class="clearer"></div>
131</div>
132<?php
133
134 require PUN_ROOT.'footer.php';
135}
136
137
138else
139{
140 $page_title = array(pun_htmlspecialchars($pun_config['o_board_title']), $lang_admin_common['Admin'], $lang_admin_common['Prune']);
141 $required_fields = array('req_prune_days' => $lang_admin_prune['Days old label']);
142 $focus_element = array('prune', 'req_prune_days');
143 define('PUN_ACTIVE_PAGE', 'admin');
144 require PUN_ROOT.'header.php';
145
146 generate_admin_menu('prune');
147
148?>
149 <div class="blockform">
150 <h2><span><?php echo $lang_admin_prune['Prune head'] ?></span></h2>
151 <div class="box">
152 <form id="prune" method="post" action="admin_prune.php?action=foo" onsubmit="return process_form(this)">
153 <div class="inform">
154 <input type="hidden" name="form_sent" value="1" />
155 <fieldset>
156 <legend><?php echo $lang_admin_prune['Prune subhead'] ?></legend>
157 <div class="infldset">
158 <table class="aligntop" cellspacing="0">
159 <tr>
160 <th scope="row"><?php echo $lang_admin_prune['Days old label'] ?></th>
161 <td>
162 <input type="text" name="req_prune_days" size="3" maxlength="3" tabindex="1" />
163 <span><?php echo $lang_admin_prune['Days old help'] ?></span>
164 </td>
165 </tr>
166 <tr>
167 <th scope="row"><?php echo $lang_admin_prune['Prune sticky label'] ?></th>
168 <td>
169 <input type="radio" name="prune_sticky" value="1" tabindex="2" checked="checked" />&#160;<strong><?php echo $lang_admin_common['Yes'] ?></strong>&#160;&#160;&#160;<input type="radio" name="prune_sticky" value="0" />&#160;<strong><?php echo $lang_admin_common['No'] ?></strong>
170 <span><?php echo $lang_admin_prune['Prune sticky help'] ?></span>
171 </td>
172 </tr>
173 <tr>
174 <th scope="row"><?php echo $lang_admin_prune['Prune from label'] ?></th>
175 <td>
176 <select name="prune_from" tabindex="3">
177 <option value="all"><?php echo $lang_admin_prune['All forums'] ?></option>
178<?php
179
180 $result = $db->query('SELECT c.id AS cid, c.cat_name, f.id AS fid, f.forum_name FROM '.$db->prefix.'categories AS c INNER JOIN '.$db->prefix.'forums AS f ON c.id=f.cat_id WHERE f.redirect_url IS NULL ORDER BY c.disp_position, c.id, f.disp_position') or error('Unable to fetch category/forum list', __FILE__, __LINE__, $db->error());
181
182 $cur_category = 0;
183 while ($forum = $db->fetch_assoc($result))
184 {
185 if ($forum['cid'] != $cur_category) // Are we still in the same category?
186 {
187 if ($cur_category)
188 echo "\t\t\t\t\t\t\t\t\t\t\t".'</optgroup>'."\n";
189
190 echo "\t\t\t\t\t\t\t\t\t\t\t".'<optgroup label="'.pun_htmlspecialchars($forum['cat_name']).'">'."\n";
191 $cur_category = $forum['cid'];
192 }
193
194 echo "\t\t\t\t\t\t\t\t\t\t\t\t".'<option value="'.$forum['fid'].'">'.pun_htmlspecialchars($forum['forum_name']).'</option>'."\n";
195 }
196
197?>
198 </optgroup>
199 </select>
200 <span><?php echo $lang_admin_prune['Prune from help'] ?></span>
201 </td>
202 </tr>
203 </table>
204 <p class="topspace"><?php printf($lang_admin_prune['Prune info'], '<a href="admin_options.php#maintenance">'.$lang_admin_common['Maintenance mode'].'</a>') ?></p>
205 <div class="fsetsubmit"><input type="submit" name="prune" value="<?php echo $lang_admin_common['Prune'] ?>" tabindex="5" /></div>
206 </div>
207 </fieldset>
208 </div>
209 </form>
210 </div>
211 </div>
212 <div class="clearer"></div>
213</div>
214<?php
215
216 require PUN_ROOT.'footer.php';
217}
2180
=== modified file 'admin_ranks.php'
--- admin_ranks.php 2010-10-08 13:18:35 +0000
+++ admin_ranks.php 2011-04-21 10:05:56 +0000
@@ -1,7 +1,7 @@
1<?php1<?php
22
3/**3/**
4 * Copyright (C) 2008-2010 FluxBB4 * Copyright (C) 2008-2011 FluxBB
5 * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB5 * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB
6 * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher6 * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher
7 */7 */
@@ -9,7 +9,7 @@
9// Tell header.php to use the admin template9// Tell header.php to use the admin template
10define('PUN_ADMIN_CONSOLE', 1);10define('PUN_ADMIN_CONSOLE', 1);
1111
12define('PUN_ROOT', './');12define('PUN_ROOT', dirname(__FILE__).'/');
13require PUN_ROOT.'include/common.php';13require PUN_ROOT.'include/common.php';
14require PUN_ROOT.'include/common_admin.php';14require PUN_ROOT.'include/common_admin.php';
1515
@@ -113,7 +113,7 @@
113 <div class="blockform">113 <div class="blockform">
114 <h2><span><?php echo $lang_admin_ranks['Ranks head'] ?></span></h2>114 <h2><span><?php echo $lang_admin_ranks['Ranks head'] ?></span></h2>
115 <div class="box">115 <div class="box">
116 <form id="ranks" method="post" action="admin_ranks.php?action=foo">116 <form id="ranks" method="post" action="admin_ranks.php">
117 <div class="inform">117 <div class="inform">
118 <fieldset>118 <fieldset>
119 <legend><?php echo $lang_admin_ranks['Add rank subhead'] ?></legend>119 <legend><?php echo $lang_admin_ranks['Add rank subhead'] ?></legend>
120120
=== modified file 'admin_reports.php'
--- admin_reports.php 2010-10-08 13:18:35 +0000
+++ admin_reports.php 2011-04-21 10:05:56 +0000
@@ -1,7 +1,7 @@
1<?php1<?php
22
3/**3/**
4 * Copyright (C) 2008-2010 FluxBB4 * Copyright (C) 2008-2011 FluxBB
5 * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB5 * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB
6 * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher6 * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher
7 */7 */
@@ -9,7 +9,7 @@
9// Tell header.php to use the admin template9// Tell header.php to use the admin template
10define('PUN_ADMIN_CONSOLE', 1);10define('PUN_ADMIN_CONSOLE', 1);
1111
12define('PUN_ROOT', './');12define('PUN_ROOT', dirname(__FILE__).'/');
13require PUN_ROOT.'include/common.php';13require PUN_ROOT.'include/common.php';
14require PUN_ROOT.'include/common_admin.php';14require PUN_ROOT.'include/common_admin.php';
1515
@@ -33,6 +33,14 @@
33 if ($zapped == '')33 if ($zapped == '')
34 $db->query('UPDATE '.$db->prefix.'reports SET zapped='.time().', zapped_by='.$pun_user['id'].' WHERE id='.$zap_id) or error('Unable to zap report', __FILE__, __LINE__, $db->error());34 $db->query('UPDATE '.$db->prefix.'reports SET zapped='.time().', zapped_by='.$pun_user['id'].' WHERE id='.$zap_id) or error('Unable to zap report', __FILE__, __LINE__, $db->error());
3535
36 // Delete old reports (which cannot be viewed anyway)
37 $result = $db->query('SELECT zapped FROM '.$db->prefix.'reports WHERE zapped IS NOT NULL ORDER BY zapped DESC LIMIT 10,1') or error('Unable to fetch read reports to delete', __FILE__, __LINE__, $db->error());
38 if ($db->num_rows($result) > 0)
39 {
40 $zapped_threshold = $db->result($result);
41 $db->query('DELETE FROM '.$db->prefix.'reports WHERE zapped <= '.$zapped_threshold) or error('Unable to delete old read reports', __FILE__, __LINE__, $db->error());
42 }
43
36 redirect('admin_reports.php', $lang_admin_reports['Report zapped redirect']);44 redirect('admin_reports.php', $lang_admin_reports['Report zapped redirect']);
37}45}
3846
@@ -60,7 +68,7 @@
60 $forum = ($cur_report['forum_name'] != '') ? '<span><a href="viewforum.php?id='.$cur_report['forum_id'].'">'.pun_htmlspecialchars($cur_report['forum_name']).'</a></span>' : '<span>'.$lang_admin_reports['Deleted'].'</span>';68 $forum = ($cur_report['forum_name'] != '') ? '<span><a href="viewforum.php?id='.$cur_report['forum_id'].'">'.pun_htmlspecialchars($cur_report['forum_name']).'</a></span>' : '<span>'.$lang_admin_reports['Deleted'].'</span>';
61 $topic = ($cur_report['subject'] != '') ? '<span>»&#160;<a href="viewtopic.php?id='.$cur_report['topic_id'].'">'.pun_htmlspecialchars($cur_report['subject']).'</a></span>' : '<span>»&#160;'.$lang_admin_reports['Deleted'].'</span>';69 $topic = ($cur_report['subject'] != '') ? '<span>»&#160;<a href="viewtopic.php?id='.$cur_report['topic_id'].'">'.pun_htmlspecialchars($cur_report['subject']).'</a></span>' : '<span>»&#160;'.$lang_admin_reports['Deleted'].'</span>';
62 $post = str_replace("\n", '<br />', pun_htmlspecialchars($cur_report['message']));70 $post = str_replace("\n", '<br />', pun_htmlspecialchars($cur_report['message']));
63 $post_id = ($cur_report['pid'] != '') ? '<span>»&#160;<a href="viewtopic.php?pid='.$cur_report['pid'].'#p'.$cur_report['pid'].'">Post #'.$cur_report['pid'].'</a></span>' : '<span>»&#160;'.$lang_admin_reports['Deleted'].'</span>';71 $post_id = ($cur_report['pid'] != '') ? '<span>»&#160;<a href="viewtopic.php?pid='.$cur_report['pid'].'#p'.$cur_report['pid'].'">'.sprintf($lang_admin_reports['Post ID'], $cur_report['pid']).'</a></span>' : '<span>»&#160;'.$lang_admin_reports['Deleted'].'</span>';
64 $report_location = array($forum, $topic, $post_id);72 $report_location = array($forum, $topic, $post_id);
6573
66?>74?>
@@ -122,7 +130,7 @@
122 $forum = ($cur_report['forum_name'] != '') ? '<span><a href="viewforum.php?id='.$cur_report['forum_id'].'">'.pun_htmlspecialchars($cur_report['forum_name']).'</a></span>' : '<span>'.$lang_admin_reports['Deleted'].'</span>';130 $forum = ($cur_report['forum_name'] != '') ? '<span><a href="viewforum.php?id='.$cur_report['forum_id'].'">'.pun_htmlspecialchars($cur_report['forum_name']).'</a></span>' : '<span>'.$lang_admin_reports['Deleted'].'</span>';
123 $topic = ($cur_report['subject'] != '') ? '<span>»&#160;<a href="viewtopic.php?id='.$cur_report['topic_id'].'">'.pun_htmlspecialchars($cur_report['subject']).'</a></span>' : '<span>»&#160;'.$lang_admin_reports['Deleted'].'</span>';131 $topic = ($cur_report['subject'] != '') ? '<span>»&#160;<a href="viewtopic.php?id='.$cur_report['topic_id'].'">'.pun_htmlspecialchars($cur_report['subject']).'</a></span>' : '<span>»&#160;'.$lang_admin_reports['Deleted'].'</span>';
124 $post = str_replace("\n", '<br />', pun_htmlspecialchars($cur_report['message']));132 $post = str_replace("\n", '<br />', pun_htmlspecialchars($cur_report['message']));
125 $post_id = ($cur_report['pid'] != '') ? '<span>»&#160;<a href="viewtopic.php?pid='.$cur_report['pid'].'#p'.$cur_report['pid'].'">Post #'.$cur_report['pid'].'</a></span>' : '<span>»&#160;'.$lang_admin_reports['Deleted'].'</span>';133 $post_id = ($cur_report['pid'] != '') ? '<span>»&#160;<a href="viewtopic.php?pid='.$cur_report['pid'].'#p'.$cur_report['pid'].'">'.sprintf($lang_admin_reports['Post ID'], $cur_report['pid']).'</a></span>' : '<span>»&#160;'.$lang_admin_reports['Deleted'].'</span>';
126 $zapped_by = ($cur_report['zapped_by'] != '') ? '<a href="profile.php?id='.$cur_report['zapped_by_id'].'">'.pun_htmlspecialchars($cur_report['zapped_by']).'</a>' : $lang_admin_reports['NA'];134 $zapped_by = ($cur_report['zapped_by'] != '') ? '<a href="profile.php?id='.$cur_report['zapped_by_id'].'">'.pun_htmlspecialchars($cur_report['zapped_by']).'</a>' : $lang_admin_reports['NA'];
127 $zapped_by = ($cur_report['zapped_by'] != '') ? '<strong>'.pun_htmlspecialchars($cur_report['zapped_by']).'</strong>' : $lang_admin_reports['NA'];135 $zapped_by = ($cur_report['zapped_by'] != '') ? '<strong>'.pun_htmlspecialchars($cur_report['zapped_by']).'</strong>' : $lang_admin_reports['NA'];
128 $report_location = array($forum, $topic, $post_id);136 $report_location = array($forum, $topic, $post_id);
@@ -173,4 +181,4 @@
173</div>181</div>
174<?php182<?php
175183
176require PUN_ROOT.'footer.php';
177\ No newline at end of file184\ No newline at end of file
185require PUN_ROOT.'footer.php';
178186
=== modified file 'admin_users.php'
--- admin_users.php 2010-10-08 13:18:35 +0000
+++ admin_users.php 2011-04-21 10:05:56 +0000
@@ -1,7 +1,7 @@
1<?php1<?php
22
3/**3/**
4 * Copyright (C) 2008-2010 FluxBB4 * Copyright (C) 2008-2011 FluxBB
5 * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB5 * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB
6 * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher6 * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher
7 */7 */
@@ -9,7 +9,7 @@
9// Tell header.php to use the admin template9// Tell header.php to use the admin template
10define('PUN_ADMIN_CONSOLE', 1);10define('PUN_ADMIN_CONSOLE', 1);
1111
12define('PUN_ROOT', './');12define('PUN_ROOT', dirname(__FILE__).'/');
13require PUN_ROOT.'include/common.php';13require PUN_ROOT.'include/common.php';
14require PUN_ROOT.'include/common_admin.php';14require PUN_ROOT.'include/common_admin.php';
1515
@@ -194,7 +194,7 @@
194 {194 {
195 $user_title = get_title($user_data);195 $user_title = get_title($user_data);
196196
197 $actions = '<a href="admin_users.php?ip_stats='.$user_data['id'].'">'.$lang_admin_users['Results view IP link'].'</a> <br/> <a href="search.php?action=show_user&amp;user_id='.$user_data['id'].'">'.$lang_admin_users['Results show posts link'].'</a>';197 $actions = '<a href="admin_users.php?ip_stats='.$user_data['id'].'">'.$lang_admin_users['Results view IP link'].'</a> | <a href="search.php?action=show_user_posts&amp;user_id='.$user_data['id'].'">'.$lang_admin_users['Results show posts link'].'</a>';
198198
199?>199?>
200 <tr>200 <tr>
@@ -253,6 +253,419 @@
253}253}
254254
255255
256// Move multiple users to other user groups
257else if (isset($_POST['move_users']) || isset($_POST['move_users_comply']))
258{
259 if ($pun_user['g_id'] > PUN_ADMIN)
260 message($lang_common['No permission']);
261
262 confirm_referrer('admin_users.php');
263
264 if (isset($_POST['users']))
265 {
266 $user_ids = is_array($_POST['users']) ? array_keys($_POST['users']) : explode(',', $_POST['users']);
267 $user_ids = array_map('intval', $user_ids);
268
269 // Delete invalid IDs
270 $user_ids = array_diff($user_ids, array(0, 1));
271 }
272 else
273 $user_ids = array();
274
275 if (empty($user_ids))
276 message($lang_admin_users['No users selected']);
277
278 // Are we trying to batch move any admins?
279 $result = $db->query('SELECT COUNT(*) FROM '.$db->prefix.'users WHERE id IN ('.implode(',', $user_ids).') AND group_id='.PUN_ADMIN) or error('Unable to fetch user info', __FILE__, __LINE__, $db->error());
280 if ($db->result($result) > 0)
281 message($lang_admin_users['No move admins message']);
282
283 // Fetch all user groups
284 $all_groups = array();
285 $result = $db->query('SELECT g_id, g_title FROM '.$db->prefix.'groups WHERE g_id NOT IN ('.PUN_GUEST.','.PUN_ADMIN.') ORDER BY g_title ASC') or error('Unable to fetch groups', __FILE__, __LINE__, $db->error());
286 while ($row = $db->fetch_row($result))
287 $all_groups[$row[0]] = $row[1];
288
289 if (isset($_POST['move_users_comply']))
290 {
291 $new_group = isset($_POST['new_group']) && isset($all_groups[$_POST['new_group']]) ? $_POST['new_group'] : message($lang_admin_users['Invalid group message']);
292
293 // Is the new group a moderator group?
294 $result = $db->query('SELECT g_moderator FROM '.$db->prefix.'groups WHERE g_id='.$new_group) or error('Unable to fetch group info', __FILE__, __LINE__, $db->error());
295 $new_group_mod = $db->result($result);
296
297 // Fetch user groups
298 $user_groups = array();
299 $result = $db->query('SELECT id, group_id FROM '.$db->prefix.'users WHERE id IN ('.implode(',', $user_ids).')') or error('Unable to fetch user groups', __FILE__, __LINE__, $db->error());
300 while ($cur_user = $db->fetch_assoc($result))
301 {
302 if (!isset($user_groups[$cur_user['group_id']]))
303 $user_groups[$cur_user['group_id']] = array();
304
305 $user_groups[$cur_user['group_id']][] = $cur_user['id'];
306 }
307
308 // Are any users moderators?
309 $group_ids = array_keys($user_groups);
310 $result = $db->query('SELECT g_id, g_moderator FROM '.$db->prefix.'groups WHERE g_id IN ('.implode(',', $group_ids).')') or error('Unable to fetch group moderators', __FILE__, __LINE__, $db->error());
311 while ($cur_group = $db->fetch_assoc($result))
312 {
313 if ($cur_group['g_moderator'] == '0')
314 unset($user_groups[$cur_group['g_id']]);
315 }
316
317 if (!empty($user_groups) && $new_group != PUN_ADMIN && $new_group_mod != '1')
318 {
319 // Fetch forum list and clean up their moderator list
320 $result = $db->query('SELECT id, moderators FROM '.$db->prefix.'forums') or error('Unable to fetch forum list', __FILE__, __LINE__, $db->error());
321 while ($cur_forum = $db->fetch_assoc($result))
322 {
323 $cur_moderators = ($cur_forum['moderators'] != '') ? unserialize($cur_forum['moderators']) : array();
324
325 foreach ($user_groups as $group_users)
326 $cur_moderators = array_diff($cur_moderators, $group_users);
327
328 $cur_moderators = (!empty($cur_moderators)) ? '\''.$db->escape(serialize($cur_moderators)).'\'' : 'NULL';
329 $db->query('UPDATE '.$db->prefix.'forums SET moderators='.$cur_moderators.' WHERE id='.$cur_forum['id']) or error('Unable to update forum', __FILE__, __LINE__, $db->error());
330 }
331 }
332
333 // Change user group
334 $db->query('UPDATE '.$db->prefix.'users SET group_id='.$new_group.' WHERE id IN ('.implode(',', $user_ids).')') or error('Unable to change user group', __FILE__, __LINE__, $db->error());
335
336 redirect('admin_users.php', $lang_admin_users['Users move redirect']);
337 }
338
339 $page_title = array(pun_htmlspecialchars($pun_config['o_board_title']), $lang_admin_common['Admin'], $lang_admin_common['Users'], $lang_admin_users['Move users']);
340 define('PUN_ACTIVE_PAGE', 'admin');
341 require PUN_ROOT.'header.php';
342
343 generate_admin_menu('users');
344
345?>
346 <div class="blockform">
347 <h2><span><?php echo $lang_admin_users['Move users'] ?></span></h2>
348 <div class="box">
349 <form name="confirm_move_users" method="post" action="admin_users.php">
350 <input type="hidden" name="users" value="<?php echo implode(',', $user_ids) ?>" />
351 <div class="inform">
352 <fieldset>
353 <legend><?php echo $lang_admin_users['Move users subhead'] ?></legend>
354 <div class="infldset">
355 <table class="aligntop" cellspacing="0">
356 <tr>
357 <th scope="row"><?php echo $lang_admin_users['New group label'] ?></th>
358 <td>
359 <select name="new_group" tabindex="1">
360<?php foreach ($all_groups as $gid => $group) : ?> <option value="<?php echo $gid ?>"><?php echo pun_htmlspecialchars($group) ?></option>
361<?php endforeach; ?>
362 </select>
363 <span><?php echo $lang_admin_users['New group help'] ?></span>
364 </td>
365 </tr>
366 </table>
367 </div>
368 </fieldset>
369 </div>
370 <p class="submitend"><input type="submit" name="move_users_comply" value="<?php echo $lang_admin_common['Save'] ?>" tabindex="2" /></p>
371 </form>
372 </div>
373 </div>
374 <div class="clearer"></div>
375</div>
376<?php
377
378 require PUN_ROOT.'footer.php';
379}
380
381
382// Delete multiple users
383else if (isset($_POST['delete_users']) || isset($_POST['delete_users_comply']))
384{
385 if ($pun_user['g_id'] > PUN_ADMIN)
386 message($lang_common['No permission']);
387
388 confirm_referrer('admin_users.php');
389
390 if (isset($_POST['users']))
391 {
392 $user_ids = is_array($_POST['users']) ? array_keys($_POST['users']) : explode(',', $_POST['users']);
393 $user_ids = array_map('intval', $user_ids);
394
395 // Delete invalid IDs
396 $user_ids = array_diff($user_ids, array(0, 1));
397 }
398 else
399 $user_ids = array();
400
401 if (empty($user_ids))
402 message($lang_admin_users['No users selected']);
403
404 // Are we trying to delete any admins?
405 $result = $db->query('SELECT COUNT(*) FROM '.$db->prefix.'users WHERE id IN ('.implode(',', $user_ids).') AND group_id='.PUN_ADMIN) or error('Unable to fetch user info', __FILE__, __LINE__, $db->error());
406 if ($db->result($result) > 0)
407 message($lang_admin_users['No delete admins message']);
408
409 if (isset($_POST['delete_users_comply']))
410 {
411 // Fetch user groups
412 $user_groups = array();
413 $result = $db->query('SELECT id, group_id FROM '.$db->prefix.'users WHERE id IN ('.implode(',', $user_ids).')') or error('Unable to fetch user groups', __FILE__, __LINE__, $db->error());
414 while ($cur_user = $db->fetch_assoc($result))
415 {
416 if (!isset($user_groups[$cur_user['group_id']]))
417 $user_groups[$cur_user['group_id']] = array();
418
419 $user_groups[$cur_user['group_id']][] = $cur_user['id'];
420 }
421
422 // Are any users moderators?
423 $group_ids = array_keys($user_groups);
424 $result = $db->query('SELECT g_id, g_moderator FROM '.$db->prefix.'groups WHERE g_id IN ('.implode(',', $group_ids).')') or error('Unable to fetch group moderators', __FILE__, __LINE__, $db->error());
425 while ($cur_group = $db->fetch_assoc($result))
426 {
427 if ($cur_group['g_moderator'] == '0')
428 unset($user_groups[$cur_group['g_id']]);
429 }
430
431 // Fetch forum list and clean up their moderator list
432 $result = $db->query('SELECT id, moderators FROM '.$db->prefix.'forums') or error('Unable to fetch forum list', __FILE__, __LINE__, $db->error());
433 while ($cur_forum = $db->fetch_assoc($result))
434 {
435 $cur_moderators = ($cur_forum['moderators'] != '') ? unserialize($cur_forum['moderators']) : array();
436
437 foreach ($user_groups as $group_users)
438 $cur_moderators = array_diff($cur_moderators, $group_users);
439
440 $cur_moderators = (!empty($cur_moderators)) ? '\''.$db->escape(serialize($cur_moderators)).'\'' : 'NULL';
441 $db->query('UPDATE '.$db->prefix.'forums SET moderators='.$cur_moderators.' WHERE id='.$cur_forum['id']) or error('Unable to update forum', __FILE__, __LINE__, $db->error());
442 }
443
444 // Delete any subscriptions
445 $db->query('DELETE FROM '.$db->prefix.'topic_subscriptions WHERE user_id IN ('.implode(',', $user_ids).')') or error('Unable to delete topic subscriptions', __FILE__, __LINE__, $db->error());
446 $db->query('DELETE FROM '.$db->prefix.'forum_subscriptions WHERE user_id IN ('.implode(',', $user_ids).')') or error('Unable to delete forum subscriptions', __FILE__, __LINE__, $db->error());
447
448 // Remove them from the online list (if they happen to be logged in)
449 $db->query('DELETE FROM '.$db->prefix.'online WHERE user_id IN ('.implode(',', $user_ids).')') or error('Unable to remove users from online list', __FILE__, __LINE__, $db->error());
450
451 // Should we delete all posts made by these users?
452 if (isset($_POST['delete_posts']))
453 {
454 require PUN_ROOT.'include/search_idx.php';
455 @set_time_limit(0);
456
457 // Find all posts made by this user
458 $result = $db->query('SELECT p.id, p.topic_id, t.forum_id FROM '.$db->prefix.'posts AS p INNER JOIN '.$db->prefix.'topics AS t ON t.id=p.topic_id INNER JOIN '.$db->prefix.'forums AS f ON f.id=t.forum_id WHERE p.poster_id IN ('.implode(',', $user_ids).')') or error('Unable to fetch posts', __FILE__, __LINE__, $db->error());
459 if ($db->num_rows($result))
460 {
461 while ($cur_post = $db->fetch_assoc($result))
462 {
463 // Determine whether this post is the "topic post" or not
464 $result2 = $db->query('SELECT id FROM '.$db->prefix.'posts WHERE topic_id='.$cur_post['topic_id'].' ORDER BY posted LIMIT 1') or error('Unable to fetch post info', __FILE__, __LINE__, $db->error());
465
466 if ($db->result($result2) == $cur_post['id'])
467 delete_topic($cur_post['topic_id']);
468 else
469 delete_post($cur_post['id'], $cur_post['topic_id']);
470
471 update_forum($cur_post['forum_id']);
472 }
473 }
474 }
475 else
476 // Set all their posts to guest
477 $db->query('UPDATE '.$db->prefix.'posts SET poster_id=1 WHERE poster_id IN ('.implode(',', $user_ids).')') or error('Unable to update posts', __FILE__, __LINE__, $db->error());
478
479 // Delete the users
480 $db->query('DELETE FROM '.$db->prefix.'users WHERE id IN ('.implode(',', $user_ids).')') or error('Unable to delete users', __FILE__, __LINE__, $db->error());
481
482 // Delete user avatars
483 foreach ($user_ids as $user_id)
484 delete_avatar($user_id);
485
486 redirect('admin_users.php', $lang_admin_users['Users delete redirect']);
487 }
488
489 $page_title = array(pun_htmlspecialchars($pun_config['o_board_title']), $lang_admin_common['Admin'], $lang_admin_common['Users'], $lang_admin_users['Delete users']);
490 define('PUN_ACTIVE_PAGE', 'admin');
491 require PUN_ROOT.'header.php';
492
493 generate_admin_menu('users');
494
495?>
496 <div class="blockform">
497 <h2><span><?php echo $lang_admin_users['Delete users'] ?></span></h2>
498 <div class="box">
499 <form name="confirm_del_users" method="post" action="admin_users.php">
500 <input type="hidden" name="users" value="<?php echo implode(',', $user_ids) ?>" />
501 <div class="inform">
502 <fieldset>
503 <legend><?php echo $lang_admin_users['Confirm delete legend'] ?></legend>
504 <div class="infldset">
505 <p><?php echo $lang_admin_users['Confirm delete info'] ?></p>
506 <div class="rbox">
507 <label><input type="checkbox" name="delete_posts" value="1" checked="checked" /><?php echo $lang_admin_users['Delete posts'] ?><br /></label>
508 </div>
509 <p class="warntext"><strong><?php echo $lang_admin_users['Delete warning'] ?></strong></p>
510 </div>
511 </fieldset>
512 </div>
513 <p class="buttons"><input type="submit" name="delete_users_comply" value="<?php echo $lang_admin_users['Delete'] ?>" /> <a href="javascript:history.go(-1)"><?php echo $lang_admin_common['Go back'] ?></a></p>
514 </form>
515 </div>
516 </div>
517 <div class="clearer"></div>
518</div>
519<?php
520
521 require PUN_ROOT.'footer.php';
522}
523
524
525// Ban multiple users
526else if (isset($_POST['ban_users']) || isset($_POST['ban_users_comply']))
527{
528 if ($pun_user['g_id'] != PUN_ADMIN && ($pun_user['g_moderator'] != '1' || $pun_user['g_mod_ban_users'] == '0'))
529 message($lang_common['No permission']);
530
531 confirm_referrer('admin_users.php');
532
533 if (isset($_POST['users']))
534 {
535 $user_ids = is_array($_POST['users']) ? array_keys($_POST['users']) : explode(',', $_POST['users']);
536 $user_ids = array_map('intval', $user_ids);
537
538 // Delete invalid IDs
539 $user_ids = array_diff($user_ids, array(0, 1));
540 }
541 else
542 $user_ids = array();
543
544 if (empty($user_ids))
545 message($lang_admin_users['No users selected']);
546
547 // Are we trying to ban any admins?
548 $result = $db->query('SELECT COUNT(*) FROM '.$db->prefix.'users WHERE id IN ('.implode(',', $user_ids).') AND group_id='.PUN_ADMIN) or error('Unable to fetch group info', __FILE__, __LINE__, $db->error());
549 if ($db->result($result) > 0)
550 message($lang_admin_users['No ban admins message']);
551
552 // Also, we cannot ban moderators
553 $result = $db->query('SELECT COUNT(*) FROM '.$db->prefix.'users AS u INNER JOIN '.$db->prefix.'groups AS g ON u.group_id=g.g_id WHERE g.g_moderator=1 AND u.id IN ('.implode(',', $user_ids).')') or error('Unable to fetch moderator group info', __FILE__, __LINE__, $db->error());
554 if ($db->result($result) > 0)
555 message($lang_admin_users['No ban mods message']);
556
557 if (isset($_POST['ban_users_comply']))
558 {
559 $ban_message = pun_trim($_POST['ban_message']);
560 $ban_expire = pun_trim($_POST['ban_expire']);
561 $ban_the_ip = isset($_POST['ban_the_ip']) ? intval($_POST['ban_the_ip']) : 0;
562
563 if ($ban_expire != '' && $ban_expire != 'Never')
564 {
565 $ban_expire = strtotime($ban_expire.' GMT');
566
567 if ($ban_expire == -1 || !$ban_expire)
568 message($lang_admin_users['Invalid date message'].' '.$lang_admin_users['Invalid date reasons']);
569
570 $diff = ($pun_user['timezone'] + $pun_user['dst']) * 3600;
571 $ban_expire -= $diff;
572
573 if ($ban_expire <= time())
574 message($lang_admin_users['Invalid date message'].' '.$lang_admin_users['Invalid date reasons']);
575 }
576 else
577 $ban_expire = 'NULL';
578
579 $ban_message = ($ban_message != '') ? '\''.$db->escape($ban_message).'\'' : 'NULL';
580
581 // Fetch user information
582 $user_info = array();
583 $result = $db->query('SELECT id, username, email, registration_ip FROM '.$db->prefix.'users WHERE id IN ('.implode(',', $user_ids).')') or error('Unable to fetch user info', __FILE__, __LINE__, $db->error());
584 while ($cur_user = $db->fetch_assoc($result))
585 $user_info[$cur_user['id']] = array('username' => $cur_user['username'], 'email' => $cur_user['email'], 'ip' => $cur_user['registration_ip']);
586
587 // Overwrite the registration IP with one from the last post (if it exists)
588 if ($ban_the_ip != 0)
589 {
590 $result = $db->query('SELECT p.poster_id, p.poster_ip FROM '.$db->prefix.'posts AS p INNER JOIN (SELECT MAX(id) AS id FROM '.$db->prefix.'posts WHERE poster_id IN ('.implode(',', $user_ids).') GROUP BY poster_id) AS i ON p.id=i.id') or error('Unable to fetch post info', __FILE__, __LINE__, $db->error());
591 while ($cur_address = $db->fetch_assoc($result))
592 $user_info[$cur_address['poster_id']]['ip'] = $cur_address['poster_ip'];
593 }
594
595 // And insert the bans!
596 foreach ($user_ids as $user_id)
597 {
598 $ban_username = '\''.$db->escape($user_info[$user_id]['username']).'\'';
599 $ban_email = '\''.$db->escape($user_info[$user_id]['email']).'\'';
600 $ban_ip = ($ban_the_ip != 0) ? '\''.$db->escape($user_info[$user_id]['ip']).'\'' : 'NULL';
601
602 $db->query('INSERT INTO '.$db->prefix.'bans (username, ip, email, message, expire, ban_creator) VALUES('.$ban_username.', '.$ban_ip.', '.$ban_email.', '.$ban_message.', '.$ban_expire.', '.$pun_user['id'].')') or error('Unable to add ban', __FILE__, __LINE__, $db->error());
603 }
604
605 // Regenerate the bans cache
606 if (!defined('FORUM_CACHE_FUNCTIONS_LOADED'))
607 require PUN_ROOT.'include/cache.php';
608
609 generate_bans_cache();
610
611 redirect('admin_users.php', $lang_admin_users['Users banned redirect']);
612 }
613
614 $page_title = array(pun_htmlspecialchars($pun_config['o_board_title']), $lang_admin_common['Admin'], $lang_admin_common['Bans']);
615 $focus_element = array('bans2', 'ban_message');
616 define('PUN_ACTIVE_PAGE', 'admin');
617 require PUN_ROOT.'header.php';
618
619 generate_admin_menu('users');
620
621?>
622 <div class="blockform">
623 <h2><span><?php echo $lang_admin_users['Ban users'] ?></span></h2>
624 <div class="box">
625 <form id="bans2" name="confirm_ban_users" method="post" action="admin_users.php">
626 <input type="hidden" name="users" value="<?php echo implode(',', $user_ids) ?>" />
627 <div class="inform">
628 <fieldset>
629 <legend><?php echo $lang_admin_users['Message expiry subhead'] ?></legend>
630 <div class="infldset">
631 <table class="aligntop" cellspacing="0">
632 <tr>
633 <th scope="row"><?php echo $lang_admin_users['Ban message label'] ?></th>
634 <td>
635 <input type="text" name="ban_message" size="50" maxlength="255" tabindex="1" />
636 <span><?php echo $lang_admin_users['Ban message help'] ?></span>
637 </td>
638 </tr>
639 <tr>
640 <th scope="row"><?php echo $lang_admin_users['Expire date label'] ?></th>
641 <td>
642 <input type="text" name="ban_expire" size="17" maxlength="10" tabindex="2" />
643 <span><?php echo $lang_admin_users['Expire date help'] ?></span>
644 </td>
645 </tr>
646 <tr>
647 <th scope="row"><?php echo $lang_admin_users['Ban IP label'] ?></th>
648 <td>
649 <input type="radio" name="ban_the_ip" tabindex="3" value="1" checked="checked" />&#160;<strong><?php echo $lang_admin_common['Yes'] ?></strong>&#160;&#160;&#160;<input type="radio" name="ban_the_ip" tabindex="4" value="0" checked="checked" />&#160;<strong><?php echo $lang_admin_common['No'] ?></strong>
650 <span><?php echo $lang_admin_users['Ban IP help'] ?></span>
651 </td>
652 </tr>
653 </table>
654 </div>
655 </fieldset>
656 </div>
657 <p class="submitend"><input type="submit" name="ban_users_comply" value="<?php echo $lang_admin_common['Save'] ?>" tabindex="3" /></p>
658 </form>
659 </div>
660 </div>
661 <div class="clearer"></div>
662</div>
663<?php
664
665 require PUN_ROOT.'footer.php';
666}
667
668
256else if (isset($_GET['find_user']))669else if (isset($_GET['find_user']))
257{670{
258 $form = isset($_GET['form']) ? $_GET['form'] : array();671 $form = isset($_GET['form']) ? $_GET['form'] : array();
@@ -356,8 +769,14 @@
356769
357 // Generate paging links770 // Generate paging links
358 $paging_links = '<span class="pages-label">'.$lang_common['Pages'].' </span>'.paginate($num_pages, $p, 'admin_users.php?find_user=&amp;'.implode('&amp;', $query_str));771 $paging_links = '<span class="pages-label">'.$lang_common['Pages'].' </span>'.paginate($num_pages, $p, 'admin_users.php?find_user=&amp;'.implode('&amp;', $query_str));
772
773 // Some helper variables for permissions
774 $can_delete = $can_move = $pun_user['g_id'] == PUN_ADMIN;
775 $can_ban = $pun_user['g_id'] == PUN_ADMIN || ($pun_user['g_moderator'] == '1' && $pun_user['g_mod_ban_users'] == '1');
776 $can_action = ($can_delete || $can_ban || $can_move) && $num_users > 0;
359777
360 $page_title = array(pun_htmlspecialchars($pun_config['o_board_title']), $lang_admin_common['Admin'], $lang_admin_common['Users'], $lang_admin_users['Results head']);778 $page_title = array(pun_htmlspecialchars($pun_config['o_board_title']), $lang_admin_common['Admin'], $lang_admin_common['Users'], $lang_admin_users['Results head']);
779 $page_head = array('js' => '<script type="text/javascript" src="common.js"></script>');
361 define('PUN_ACTIVE_PAGE', 'admin');780 define('PUN_ACTIVE_PAGE', 'admin');
362 require PUN_ROOT.'header.php';781 require PUN_ROOT.'header.php';
363782
@@ -377,6 +796,7 @@
377</div>796</div>
378797
379798
799<form id="search-users-form" action="admin_users.php" method="post">
380<div id="users2" class="blocktable">800<div id="users2" class="blocktable">
381 <h2><span><?php echo $lang_admin_users['Results head'] ?></span></h2>801 <h2><span><?php echo $lang_admin_users['Results head'] ?></span></h2>
382 <div class="box">802 <div class="box">
@@ -390,6 +810,8 @@
390 <th class="tc4" scope="col"><?php echo $lang_admin_users['Results posts head'] ?></th>810 <th class="tc4" scope="col"><?php echo $lang_admin_users['Results posts head'] ?></th>
391 <th class="tc5" scope="col"><?php echo $lang_admin_users['Results admin note head'] ?></th>811 <th class="tc5" scope="col"><?php echo $lang_admin_users['Results admin note head'] ?></th>
392 <th class="tcr" scope="col"><?php echo $lang_admin_users['Results actions head'] ?></th>812 <th class="tcr" scope="col"><?php echo $lang_admin_users['Results actions head'] ?></th>
813<?php if ($can_action): ?> <th class="tcmod" scope="col"><?php echo $lang_admin_users['Select'] ?></th>
814<?php endif; ?>
393 </tr>815 </tr>
394 </thead>816 </thead>
395 <tbody>817 <tbody>
@@ -406,7 +828,7 @@
406 if (($user_data['g_id'] == '' || $user_data['g_id'] == PUN_UNVERIFIED) && $user_title != $lang_common['Banned'])828 if (($user_data['g_id'] == '' || $user_data['g_id'] == PUN_UNVERIFIED) && $user_title != $lang_common['Banned'])
407 $user_title = '<span class="warntext">'.$lang_admin_users['Not verified'].'</span>';829 $user_title = '<span class="warntext">'.$lang_admin_users['Not verified'].'</span>';
408830
409 $actions = '<a href="admin_users.php?ip_stats='.$user_data['id'].'">'.$lang_admin_users['Results view IP link'].'</a> | <a href="search.php?action=show_user&amp;user_id='.$user_data['id'].'">'.$lang_admin_users['Results show posts link'].'</a>';831 $actions = '<a href="admin_users.php?ip_stats='.$user_data['id'].'">'.$lang_admin_users['Results view IP link'].'</a> | <a href="search.php?action=show_user_posts&amp;user_id='.$user_data['id'].'">'.$lang_admin_users['Results show posts link'].'</a>';
410832
411?>833?>
412 <tr>834 <tr>
@@ -416,6 +838,8 @@
416 <td class="tc4"><?php echo forum_number_format($user_data['num_posts']) ?></td>838 <td class="tc4"><?php echo forum_number_format($user_data['num_posts']) ?></td>
417 <td class="tc5"><?php echo ($user_data['admin_note'] != '') ? pun_htmlspecialchars($user_data['admin_note']) : '&#160;' ?></td>839 <td class="tc5"><?php echo ($user_data['admin_note'] != '') ? pun_htmlspecialchars($user_data['admin_note']) : '&#160;' ?></td>
418 <td class="tcr"><?php echo $actions ?></td>840 <td class="tcr"><?php echo $actions ?></td>
841<?php if ($can_action): ?> <td class="tcmod"><input type="checkbox" name="users[<?php echo $user_data['id'] ?>]" value="1" /></td>
842<?php endif; ?>
419 </tr>843 </tr>
420<?php844<?php
421845
@@ -435,6 +859,8 @@
435 <div class="inbox crumbsplus">859 <div class="inbox crumbsplus">
436 <div class="pagepost">860 <div class="pagepost">
437 <p class="pagelink"><?php echo $paging_links ?></p>861 <p class="pagelink"><?php echo $paging_links ?></p>
862<?php if ($can_action): ?> <p class="conr modbuttons"><a href="#" onclick="return select_checkboxes('search-users-form', this, '<?php echo $lang_admin_users['Unselect all'] ?>')"><?php echo $lang_admin_users['Select all'] ?></a> <?php if ($can_ban) : ?><input type="submit" name="ban_users" value="<?php echo $lang_admin_users['Ban'] ?>" /><?php endif; if ($can_delete) : ?><input type="submit" name="delete_users" value="<?php echo $lang_admin_users['Delete'] ?>" /><?php endif; if ($can_move) : ?><input type="submit" name="move_users" value="<?php echo $lang_admin_users['Change group'] ?>" /><?php endif; ?></p>
863<?php endif; ?>
438 </div>864 </div>
439 <ul class="crumbs">865 <ul class="crumbs">
440 <li><a href="admin_index.php"><?php echo $lang_admin_common['Admin'].' '.$lang_admin_common['Index'] ?></a></li>866 <li><a href="admin_index.php"><?php echo $lang_admin_common['Admin'].' '.$lang_admin_common['Index'] ?></a></li>
@@ -444,6 +870,7 @@
444 <div class="clearer"></div>870 <div class="clearer"></div>
445 </div>871 </div>
446</div>872</div>
873</form>
447<?php874<?php
448875
449 require PUN_ROOT.'footer.php';876 require PUN_ROOT.'footer.php';
@@ -453,7 +880,7 @@
453else880else
454{881{
455 $page_title = array(pun_htmlspecialchars($pun_config['o_board_title']), $lang_admin_common['Admin'], $lang_admin_common['Users']);882 $page_title = array(pun_htmlspecialchars($pun_config['o_board_title']), $lang_admin_common['Admin'], $lang_admin_common['Users']);
456 $focus_element = array('find_user', 'username');883 $focus_element = array('find_user', 'form[username]');
457 define('PUN_ACTIVE_PAGE', 'admin');884 define('PUN_ACTIVE_PAGE', 'admin');
458 require PUN_ROOT.'header.php';885 require PUN_ROOT.'header.php';
459886
460887
=== modified file 'cache/.htaccess' (properties changed: +x to -x)
=== modified file 'cache/index.html' (properties changed: +x to -x)
=== added file 'common.js'
--- common.js 1970-01-01 00:00:00 +0000
+++ common.js 2011-04-21 10:05:56 +0000
@@ -0,0 +1,32 @@
1
2function select_checkboxes(curFormId, link, new_string)
3{
4 var curForm = document.getElementById(curFormId);
5 var inputlist = curForm.getElementsByTagName("input");
6 for (i = 0; i < inputlist.length; i++)
7 {
8 if (inputlist[i].getAttribute("type") == 'checkbox' && inputlist[i].disabled == false)
9 inputlist[i].checked = true;
10 }
11
12 link.setAttribute('onclick', 'return unselect_checkboxes(\'' + curFormId + '\', this, \'' + link.innerHTML + '\')');
13 link.innerHTML = new_string;
14
15 return false;
16}
17
18function unselect_checkboxes(curFormId, link, new_string)
19{
20 var curForm = document.getElementById(curFormId);
21 var inputlist = curForm.getElementsByTagName("input");
22 for (i = 0; i < inputlist.length; i++)
23 {
24 if (inputlist[i].getAttribute("type") == 'checkbox' && inputlist[i].disabled == false)
25 inputlist[i].checked = false;
26 }
27
28 link.setAttribute('onclick', 'return select_checkboxes(\'' + curFormId + '\', this, \'' + link.innerHTML + '\')');
29 link.innerHTML = new_string;
30
31 return false;
32}
0\ No newline at end of file33\ No newline at end of file
134
=== modified file 'db_update.php'
--- db_update.php 2010-10-08 13:18:35 +0000
+++ db_update.php 2011-04-21 10:05:56 +0000
@@ -1,19 +1,19 @@
1<?php1<?php
22
3/**3/**
4 * Copyright (C) 2008-2010 FluxBB4 * Copyright (C) 2008-2011 FluxBB
5 * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB5 * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB
6 * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher6 * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher
7 */7 */
88
9// The FluxBB version this script updates to9// The FluxBB version this script updates to
10define('UPDATE_TO', '1.4.2');10define('UPDATE_TO', '1.4.5');
1111
12define('UPDATE_TO_DB_REVISION', 8);12define('UPDATE_TO_DB_REVISION', 11);
13define('UPDATE_TO_SI_REVISION', 1);13define('UPDATE_TO_SI_REVISION', 2);
14define('UPDATE_TO_PARSER_REVISION', 1);14define('UPDATE_TO_PARSER_REVISION', 2);
1515
16define('MIN_PHP_VERSION', '4.3.0');16define('MIN_PHP_VERSION', '4.4.0');
17define('MIN_MYSQL_VERSION', '4.1.2');17define('MIN_MYSQL_VERSION', '4.1.2');
18define('MIN_PGSQL_VERSION', '7.0.0');18define('MIN_PGSQL_VERSION', '7.0.0');
19define('PUN_SEARCH_MIN_WORD', 3);19define('PUN_SEARCH_MIN_WORD', 3);
@@ -34,7 +34,7 @@
34if (!function_exists('version_compare') || version_compare(PHP_VERSION, MIN_PHP_VERSION, '<'))34if (!function_exists('version_compare') || version_compare(PHP_VERSION, MIN_PHP_VERSION, '<'))
35 exit('You are running PHP version '.PHP_VERSION.'. FluxBB '.UPDATE_TO.' requires at least PHP '.MIN_PHP_VERSION.' to run properly. You must upgrade your PHP installation before you can continue.');35 exit('You are running PHP version '.PHP_VERSION.'. FluxBB '.UPDATE_TO.' requires at least PHP '.MIN_PHP_VERSION.' to run properly. You must upgrade your PHP installation before you can continue.');
3636
37define('PUN_ROOT', './');37define('PUN_ROOT', dirname(__FILE__).'/');
3838
39// Attempt to load the configuration file config.php39// Attempt to load the configuration file config.php
40if (file_exists(PUN_ROOT.'config.php'))40if (file_exists(PUN_ROOT.'config.php'))
@@ -44,9 +44,12 @@
44if (defined('FORUM'))44if (defined('FORUM'))
45 define('PUN', FORUM);45 define('PUN', FORUM);
4646
47// If PUN isn't defined, config.php is missing or corrupt or we are outside the root directory47// If PUN isn't defined, config.php is missing or corrupt
48if (!defined('PUN'))48if (!defined('PUN'))
49 exit('This file must be run from the forum root directory.');49{
50 header('Location: install.php');
51 exit;
52}
5053
51// Enable debug mode54// Enable debug mode
52if (!defined('PUN_DEBUG'))55if (!defined('PUN_DEBUG'))
@@ -115,12 +118,24 @@
115// Set the connection to UTF-8 now118// Set the connection to UTF-8 now
116$db->set_names('utf8');119$db->set_names('utf8');
117120
121// Get the forum config
122$result = $db->query('SELECT * FROM '.$db->prefix.'config') or error('Unable to fetch config.', __FILE__, __LINE__, $db->error());
123while ($cur_config_item = $db->fetch_row($result))
124 $pun_config[$cur_config_item[0]] = $cur_config_item[1];
125
126// Load language file
127$default_lang = $pun_config['o_default_lang'];
128
129if (!file_exists(PUN_ROOT.'lang/'.$default_lang.'/update.php'))
130 $default_lang = 'English';
131
132require PUN_ROOT.'lang/'.$default_lang.'/update.php';
133
118// Check current version134// Check current version
119$result = $db->query('SELECT conf_value FROM '.$db->prefix.'config WHERE conf_name=\'o_cur_version\'') or error('Unable to fetch version info.', __FILE__, __LINE__, $db->error());135$cur_version = $pun_config['o_cur_version'];
120$cur_version = $db->result($result);
121136
122if (version_compare($cur_version, '1.2', '<'))137if (version_compare($cur_version, '1.2', '<'))
123 exit('Version mismatch. The database \''.$db_name.'\' doesn\'t seem to be running a FluxBB database schema supported by this update script.');138 error(sprintf($lang_update['Version mismatch error'], $db_name));
124139
125// Do some DB type specific checks140// Do some DB type specific checks
126$mysql = false;141$mysql = false;
@@ -132,7 +147,7 @@
132 case 'mysqli_innodb':147 case 'mysqli_innodb':
133 $mysql_info = $db->get_version();148 $mysql_info = $db->get_version();
134 if (version_compare($mysql_info['version'], MIN_MYSQL_VERSION, '<'))149 if (version_compare($mysql_info['version'], MIN_MYSQL_VERSION, '<'))
135 error('You are running MySQL version '.$mysql_info['version'].'. FluxBB '.UPDATE_TO.' requires at least MySQL '.MIN_MYSQL_VERSION.' to run properly. You must upgrade your MySQL installation before you can continue.');150 error(sprintf($lang_update['You are running error'], 'MySQL', $mysql_info['version'], UPDATE_TO, MIN_MYSQL_VERSION));
136151
137 $mysql = true;152 $mysql = true;
138 break;153 break;
@@ -140,22 +155,17 @@
140 case 'pgsql':155 case 'pgsql':
141 $pgsql_info = $db->get_version();156 $pgsql_info = $db->get_version();
142 if (version_compare($pgsql_info['version'], MIN_PGSQL_VERSION, '<'))157 if (version_compare($pgsql_info['version'], MIN_PGSQL_VERSION, '<'))
143 error('You are running PostgreSQL version '.$pgsql_info['version'].'. FluxBB '.UPDATE_TO.' requires at least PostgreSQL '.MIN_PGSQL_VERSION.' to run properly. You must upgrade your PostgreSQL installation before you can continue.');158 error(sprintf($lang_update['You are running error'], 'PostgreSQL', $pgsql_info['version'], UPDATE_TO, MIN_PGSQL_VERSION));
144159
145 break;160 break;
146}161}
147162
148// Get the forum config163// Check the database, search index and parser revision and the current version
149$result = $db->query('SELECT * FROM '.$db->prefix.'config') or error('Unable to fetch config.', __FILE__, __LINE__, $db->error());
150while ($cur_config_item = $db->fetch_row($result))
151 $pun_config[$cur_config_item[0]] = $cur_config_item[1];
152
153// Check the database revision and the current version
154if (isset($pun_config['o_database_revision']) && $pun_config['o_database_revision'] >= UPDATE_TO_DB_REVISION &&164if (isset($pun_config['o_database_revision']) && $pun_config['o_database_revision'] >= UPDATE_TO_DB_REVISION &&
155 isset($pun_config['o_searchindex_revision']) && $pun_config['o_searchindex_revision'] >= UPDATE_TO_SI_REVISION &&165 isset($pun_config['o_searchindex_revision']) && $pun_config['o_searchindex_revision'] >= UPDATE_TO_SI_REVISION &&
156 isset($pun_config['o_parser_revision']) && $pun_config['o_parser_revision'] >= UPDATE_TO_PARSER_REVISION &&166 isset($pun_config['o_parser_revision']) && $pun_config['o_parser_revision'] >= UPDATE_TO_PARSER_REVISION &&
157 version_compare($pun_config['o_cur_version'], UPDATE_TO, '>='))167 version_compare($pun_config['o_cur_version'], UPDATE_TO, '>='))
158 exit('Your database is already as up-to-date as this script can make it.');168 error($lang_update['No update error']);
159169
160$default_style = $pun_config['o_default_style'];170$default_style = $pun_config['o_default_style'];
161if (!file_exists(PUN_ROOT.'style/'.$default_style.'.css'))171if (!file_exists(PUN_ROOT.'style/'.$default_style.'.css'))
@@ -164,9 +174,6 @@
164// Start a session, used to queue up errors if duplicate users occur when converting from FluxBB v1.2.174// Start a session, used to queue up errors if duplicate users occur when converting from FluxBB v1.2.
165session_start();175session_start();
166176
167if (!isset($_SESSION['dupe_users']))
168 $_SESSION['dupe_users'] = array();
169
170//177//
171// Determines whether $str is UTF-8 encoded or not178// Determines whether $str is UTF-8 encoded or not
172//179//
@@ -444,15 +451,14 @@
444while (@ob_end_clean());451while (@ob_end_clean());
445452
446453
447$stage = isset($_GET['stage']) ? $_GET['stage'] : '';454$stage = isset($_REQUEST['stage']) ? $_REQUEST['stage'] : '';
448$old_charset = isset($_GET['req_old_charset']) ? str_replace('ISO8859', 'ISO-8859', strtoupper($_GET['req_old_charset'])) : 'ISO-8859-1';455$old_charset = isset($_REQUEST['req_old_charset']) ? str_replace('ISO8859', 'ISO-8859', strtoupper($_REQUEST['req_old_charset'])) : 'ISO-8859-1';
449$start_at = isset($_GET['start_at']) ? intval($_GET['start_at']) : 0;456$start_at = isset($_REQUEST['start_at']) ? intval($_REQUEST['start_at']) : 0;
450$query_str = '';457$query_str = '';
451458
452switch ($stage)459// Show form
460if (empty($stage))
453{461{
454 // Show form
455 case '':
456462
457?>463?>
458<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">464<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
@@ -460,81 +466,159 @@
460<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr">466<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr">
461<head>467<head>
462<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />468<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
463<title>FluxBB Database Update</title>469<title><?php echo $lang_update['Update'] ?></title>
464<link rel="stylesheet" type="text/css" href="style/<?php echo $default_style ?>.css" />470<link rel="stylesheet" type="text/css" href="style/<?php echo $default_style ?>.css" />
465</head>471</head>
466<body>472<body onload="document.getElementById('install').req_db_type.focus();document.getElementById('install').start.disabled=false;">
467473
468<div id="pundb_update" class="pun">474<div id="pundb_update" class="pun">
469<div class="top-box"><div><!-- Top Corners --></div></div>475<div class="top-box"><div><!-- Top Corners --></div></div>
470<div class="punwrap">476<div class="punwrap">
471477
478<div id="brdheader" class="block">
479 <div class="box">
480 <div id="brdtitle" class="inbox">
481 <h1><span><?php echo $lang_update['Update'] ?></span></h1>
482 <div id="brddesc"><p><?php echo $lang_update['Update message'] ?></p><p><strong><?php echo $lang_update['Note']; ?></strong> <?php echo $lang_update['Members message']; ?></p></div>
483 </div>
484 </div>
485</div>
486
487<div id="brdmain">
472<div class="blockform">488<div class="blockform">
473 <h2><span>FluxBB Update</span></h2>489 <h2><span><?php echo $lang_update['Update'] ?></span></h2>
474 <div class="box">490 <div class="box">
475 <form method="get" action="<?php echo pun_htmlspecialchars($_SERVER['REQUEST_URI']) ?>" onsubmit="this.start.disabled=true">491 <form method="post" action="db_update.php">
476 <input type="hidden" name="stage" value="start" />492 <input type="hidden" name="stage" value="start" />
493 <div class="inform">
494 <fieldset>
495 <legend><?php echo $lang_update['Administrator only'] ?></legend>
496 <div class="infldset">
497 <p><?php echo $lang_update['Database password info'] ?></p>
498 <p><strong><?php echo $lang_update['Note']; ?></strong> <?php echo $lang_update['Database password note'] ?></p>
499 <label class="required"><strong><?php echo $lang_update['Database password'] ?> <span><?php echo $lang_update['Required'] ?></span></strong><br /><input type="password" id="req_db_pass" name="req_db_pass" /><br /></label>
500 </div>
501 </fieldset>
502 </div>
477 <div class="inform">503 <div class="inform">
478 <div class="forminfo">504 <div class="forminfo">
479 <p style="font-size: 1.1em">This script will update your forum database. The update procedure might take anything from a second to hours depending on the speed of the server and the size of the forum database. Don't forget to make a backup of the database before continuing.</p>505 <p><?php echo $lang_update['Intro 1'] ?></p>
480 <p style="font-size: 1.1em">Did you read the update instructions in the documentation? If not, start there.</p>506 <p><?php echo $lang_update['Intro 2'] ?></p>
481<?php507<?php
482508
483if (strpos($cur_version, '1.2') === 0)509 if (strpos($cur_version, '1.2') === 0)
484{
485 if (!function_exists('iconv') && !function_exists('mb_convert_encoding'))
486 {510 {
511 if (!function_exists('iconv') && !function_exists('mb_convert_encoding'))
512 {
487513
488?>514?>
489 <p style="font-size: 1.1em"><strong>IMPORTANT!</strong> FluxBB has detected that this PHP environment does not have support for the encoding mechanisms required to do UTF-8 conversion from character sets other than ISO-8859-1. What this means is that if the current character set is not ISO-8859-1, FluxBB won't be able to convert your forum database to UTF-8 and you will have to do it manually. Instructions for doing manual charset conversion can be found in the update instructions.</p>515 <p><?php echo $lang_update['No charset conversion'] ?></p>
490<?php516<?php
491517
492 }518 }
493519
494?>520?>
495 </div>521 </div>
496 </div>522 </div>
497 <div class="inform">523 <div class="inform">
498 <div class="forminfo">524 <div class="forminfo">
499 <p style="font-size: 1.1em"><strong>Enable conversion:</strong> When enabled this update script will, after it has made the required structural changes to the database, convert all text in the database from the current character set to UTF-8. This conversion is required if you're upgrading from version 1.2.</p>525 <p><?php echo $lang_update['Enable conversion'] ?></p>
500 <p style="font-size: 1.1em"><strong>Current character set:</strong> If the primary language in your forum is English, you can leave this at the default value. However, if your forum is non-English, you should enter the character set of the primary language pack used in the forum. <i>Getting this wrong can corrupt your database so don't just guess!</i> Note: This is required even if the old database is UTF-8.</p>526 <p><?php echo $lang_update['Current character set'] ?></p>
501 </div>527 </div>
502 <fieldset>528 <fieldset>
503 <legend>Charset conversion</legend>529 <legend><?php echo $lang_update['Charset conversion'] ?></legend>
504 <div class="infldset">530 <div class="infldset">
505 <div class="rbox">531 <div class="rbox">
506 <label><input type="checkbox" name="convert_charset" value="1" checked="checked" /><strong>Enable conversion</strong> (perform database charset conversion).<br /></label>532 <label><input type="checkbox" name="convert_charset" value="1" checked="checked" /><?php echo $lang_update['Enable conversion label'] ?><br /></label>
507 </div>533 </div>
508 <label>534 <label>
509 <strong>Current character set</strong><br />Accept default for English forums otherwise the character set of the primary language pack.<br />535 <strong><?php echo $lang_update['Current character set label'] ?></strong><br /><?php echo $lang_update['Current character set info'] ?><br />
510 <input type="text" name="req_old_charset" size="12" maxlength="20" value="<?php echo $old_charset ?>" /><br />536 <input type="text" name="req_old_charset" size="12" maxlength="20" value="<?php echo $old_charset ?>" /><br />
511 </label>537 </label>
512 </div>538 </div>
513 </fieldset>539 </fieldset>
514<?php540<?php
515541
542 }
543 else
544 echo "\t\t\t\t".'</div>'."\n";
545
546?>
547 </div>
548 <p class="buttons"><input type="submit" name="start" value="<?php echo $lang_update['Start update'] ?>" /></p>
549 </form>
550 </div>
551</div>
552</div>
553
554</div>
555<div class="end-box"><div><!-- Bottom Corners --></div></div>
556</div>
557
558</body>
559</html>
560<?php
561
562 $db->end_transaction();
563 $db->close();
564 exit;
565
566}
567
568// Read the lock file
569$lock = file_exists(FORUM_CACHE_DIR.'db_update.lock') ? trim(file_get_contents(FORUM_CACHE_DIR.'db_update.lock')) : false;
570$lock_error = false;
571
572// Generate or fetch the UID - this confirms we have a valid admin
573if (isset($_POST['req_db_pass']))
574{
575 $req_db_pass = strtolower(trim($_POST['req_db_pass']));
576
577 switch ($db_type)
578 {
579 // For SQLite we compare against the database file name, since the password is left blank
580 case 'sqlite':
581 if ($req_db_pass != strtolower($db_name))
582 error(sprintf($lang_update['Invalid file error'], 'config.php'));
583
584 break;
585 // For everything else, check the password matches
586 default:
587 if ($req_db_pass != strtolower($db_password))
588 error(sprintf($lang_update['Invalid password error'], 'config.php'));
589
590 break;
591 }
592
593 // Generate a unique id to identify this session, only if this is a valid session
594 $uid = pun_hash($req_db_pass.'|'.uniqid(rand(), true));
595 if ($lock) // We already have a lock file
596 $lock_error = true;
597 else // Create the lock file
598 {
599 $fh = @fopen(FORUM_CACHE_DIR.'db_update.lock', 'wb');
600 if (!$fh)
601 error(sprintf($lang_update['Unable to lock error'], 'cache'));
602
603 fwrite($fh, $uid);
604 fclose($fh);
605 }
606}
607else if (isset($_GET['uid']))
608{
609 $uid = trim($_GET['uid']);
610 if (!$lock || $lock != $uid) // The lock doesn't exist or doesn't match the given UID
611 $lock_error = true;
516}612}
517else613else
518 echo "\t\t\t\t".'</div>'."\n";614 error($lang_update['No password error']);
519615
520?>616// If there is an error with the lock file
521 </div>617if ($lock_error)
522 <p class="buttons"><input type="submit" name="start" value="Start update" /></p>618 error(sprintf($lang_update['Script runs error'], FORUM_CACHE_DIR.'db_update.lock'));
523 </form>619
524 </div>620switch ($stage)
525</div>621{
526
527</div>
528<div class="end-box"><div><!-- Bottom Corners --></div></div>
529</div>
530
531</body>
532</html>
533<?php
534
535 break;
536
537
538 // Start by updating the database structure622 // Start by updating the database structure
539 case 'start':623 case 'start':
540 $query_str = '?stage=preparse_posts';624 $query_str = '?stage=preparse_posts';
@@ -623,6 +707,10 @@
623 if (!array_key_exists('o_feed_type', $pun_config))707 if (!array_key_exists('o_feed_type', $pun_config))
624 $db->query('INSERT INTO '.$db->prefix.'config (conf_name, conf_value) VALUES (\'o_feed_type\', \'2\')') or error('Unable to insert config value \'o_feed_type\'', __FILE__, __LINE__, $db->error());708 $db->query('INSERT INTO '.$db->prefix.'config (conf_name, conf_value) VALUES (\'o_feed_type\', \'2\')') or error('Unable to insert config value \'o_feed_type\'', __FILE__, __LINE__, $db->error());
625709
710 // Insert new config option o_feed_ttl
711 if (!array_key_exists('o_feed_ttl', $pun_config))
712 $db->query('INSERT INTO '.$db->prefix.'config (conf_name, conf_value) VALUES (\'o_feed_ttl\', \'0\')') or error('Unable to insert config value \'o_feed_ttl\'', __FILE__, __LINE__, $db->error());
713
626 // Insert config option o_base_url which was removed in 1.3714 // Insert config option o_base_url which was removed in 1.3
627 if (!array_key_exists('o_base_url', $pun_config))715 if (!array_key_exists('o_base_url', $pun_config))
628 {716 {
@@ -961,13 +1049,46 @@
961 $db->create_table('search_words', $schema);1049 $db->create_table('search_words', $schema);
962 }1050 }
9631051
1052 // Rename the subscription table
1053 $db->rename_table('subscriptions', 'topic_subscriptions');
1054
1055 // if we don't have the forum_subscriptions table, create it
1056 if (!$db->table_exists('forum_subscriptions'))
1057 {
1058 $schema = array(
1059 'FIELDS' => array(
1060 'user_id' => array(
1061 'datatype' => 'INT(10) UNSIGNED',
1062 'allow_null' => false,
1063 'default' => '0'
1064 ),
1065 'forum_id' => array(
1066 'datatype' => 'INT(10) UNSIGNED',
1067 'allow_null' => false,
1068 'default' => '0'
1069 )
1070 ),
1071 'PRIMARY KEY' => array('user_id', 'forum_id')
1072 );
1073
1074 $db->create_table('forum_subscriptions', $schema) or error('Unable to create forum subscriptions table', __FILE__, __LINE__, $db->error());
1075 }
1076
1077 // Insert new config option o_forum_subscriptions
1078 if (!array_key_exists('o_forum_subscriptions', $pun_config))
1079 $db->query('INSERT INTO '.$db->prefix.'config (conf_name, conf_value) VALUES (\'o_forum_subscriptions\', \'1\')') or error('Unable to insert config value \'o_forum_subscriptions\'', __FILE__, __LINE__, $db->error());
1080
1081 // Rename config option o_subscriptions to o_topic_subscriptions
1082 if (!array_key_exists('o_topic_subscriptions', $pun_config))
1083 $db->query('UPDATE '.$db->prefix.'config SET conf_name=\'o_topic_subscriptions\' WHERE conf_name=\'o_subscriptions\'') or error('Unable to rename config value \'o_subscriptions\'', __FILE__, __LINE__, $db->error());
1084
964 // Change the default style if the old doesn't exist anymore1085 // Change the default style if the old doesn't exist anymore
965 if ($pun_config['o_default_style'] != $default_style)1086 if ($pun_config['o_default_style'] != $default_style)
966 $db->query('UPDATE '.$db->prefix.'config SET conf_value = \''.$db->escape($default_style).'\' WHERE conf_name = \'o_default_style\'') or error('Unable to update default style config', __FILE__, __LINE__, $db->error());1087 $db->query('UPDATE '.$db->prefix.'config SET conf_value = \''.$db->escape($default_style).'\' WHERE conf_name = \'o_default_style\'') or error('Unable to update default style config', __FILE__, __LINE__, $db->error());
9671088
968 // Should we do charset conversion or not?1089 // Should we do charset conversion or not?
969 //if (strpos($cur_version, '1.2') === 0 && isset($_GET['convert_charset']))1090 if (strpos($cur_version, '1.2') === 0 && isset($_POST['convert_charset']))
970 // $query_str = '?stage=conv_bans&req_old_charset='.$old_charset;1091 $query_str = '?stage=conv_bans&req_old_charset='.$old_charset;
9711092
972 break;1093 break;
9731094
@@ -978,7 +1099,9 @@
9781099
979 function _conv_bans($cur_item, $old_charset)1100 function _conv_bans($cur_item, $old_charset)
980 {1101 {
981 echo 'Converting ban '.$cur_item['id'].' …<br />'."\n";1102 global $lang_update;
1103
1104 echo sprintf($lang_update['Converting item'], $lang_update['ban'], $cur_item['id']).'<br />'."\n";
9821105
983 convert_to_utf8($cur_item['username'], $old_charset);1106 convert_to_utf8($cur_item['username'], $old_charset);
984 convert_to_utf8($cur_item['message'], $old_charset);1107 convert_to_utf8($cur_item['message'], $old_charset);
@@ -998,7 +1121,7 @@
998 case 'conv_categories':1121 case 'conv_categories':
999 $query_str = '?stage=conv_censors&req_old_charset='.$old_charset;1122 $query_str = '?stage=conv_censors&req_old_charset='.$old_charset;
10001123
1001 echo 'Converting categories …'."<br />\n";1124 echo sprintf($lang_update['Converting'], $lang_update['categories']).'<br />'."\n";
10021125
1003 function _conv_categories($cur_item, $old_charset)1126 function _conv_categories($cur_item, $old_charset)
1004 {1127 {
@@ -1016,7 +1139,7 @@
1016 case 'conv_censors':1139 case 'conv_censors':
1017 $query_str = '?stage=conv_config&req_old_charset='.$old_charset;1140 $query_str = '?stage=conv_config&req_old_charset='.$old_charset;
10181141
1019 echo 'Converting censor words …'."<br />\n";1142 echo sprintf($lang_update['Converting'], $lang_update['censor words']).'<br />'."\n";
10201143
1021 function _conv_censoring($cur_item, $old_charset)1144 function _conv_censoring($cur_item, $old_charset)
1022 {1145 {
@@ -1035,7 +1158,7 @@
1035 case 'conv_config':1158 case 'conv_config':
1036 $query_str = '?stage=conv_forums&req_old_charset='.$old_charset;1159 $query_str = '?stage=conv_forums&req_old_charset='.$old_charset;
10371160
1038 echo 'Converting configuration …'."<br />\n";1161 echo sprintf($lang_update['Converting'], $lang_update['configuration']).'<br />'."\n";
10391162
1040 function _conv_config($cur_item, $old_charset)1163 function _conv_config($cur_item, $old_charset)
1041 {1164 {
@@ -1053,7 +1176,7 @@
1053 case 'conv_forums':1176 case 'conv_forums':
1054 $query_str = '?stage=conv_perms&req_old_charset='.$old_charset;1177 $query_str = '?stage=conv_perms&req_old_charset='.$old_charset;
10551178
1056 echo 'Converting forums …'."<br />\n";1179 echo sprintf($lang_update['Converting'], $lang_update['forums']).'<br />'."\n";
10571180
1058 function _conv_forums($cur_item, $old_charset)1181 function _conv_forums($cur_item, $old_charset)
1059 {1182 {
@@ -1092,7 +1215,7 @@
1092 case 'conv_groups':1215 case 'conv_groups':
1093 $query_str = '?stage=conv_online&req_old_charset='.$old_charset;1216 $query_str = '?stage=conv_online&req_old_charset='.$old_charset;
10941217
1095 echo 'Converting groups …'."<br />\n";1218 echo sprintf($lang_update['Converting'], $lang_update['groups']).'<br />'."\n";
10961219
1097 function _conv_groups($cur_item, $old_charset)1220 function _conv_groups($cur_item, $old_charset)
1098 {1221 {
@@ -1125,7 +1248,9 @@
11251248
1126 function _conv_posts($cur_item, $old_charset)1249 function _conv_posts($cur_item, $old_charset)
1127 {1250 {
1128 echo 'Converting post '.$cur_item['id'].' …<br />'."\n";1251 global $lang_update;
1252
1253 echo sprintf($lang_update['Converting item'], $lang_update['post'], $cur_item['id']).'<br />'."\n";
11291254
1130 convert_to_utf8($cur_item['poster'], $old_charset);1255 convert_to_utf8($cur_item['poster'], $old_charset);
1131 convert_to_utf8($cur_item['message'], $old_charset);1256 convert_to_utf8($cur_item['message'], $old_charset);
@@ -1146,7 +1271,7 @@
1146 case 'conv_ranks':1271 case 'conv_ranks':
1147 $query_str = '?stage=conv_reports&req_old_charset='.$old_charset;1272 $query_str = '?stage=conv_reports&req_old_charset='.$old_charset;
11481273
1149 echo 'Converting ranks …'."<br />\n";1274 echo sprintf($lang_update['Converting'], $lang_update['ranks']).'<br />'."\n";
11501275
1151 function _conv_ranks($cur_item, $old_charset)1276 function _conv_ranks($cur_item, $old_charset)
1152 {1277 {
@@ -1166,7 +1291,9 @@
11661291
1167 function _conv_reports($cur_item, $old_charset)1292 function _conv_reports($cur_item, $old_charset)
1168 {1293 {
1169 echo 'Converting report '.$cur_item['id'].' …<br />'."\n";1294 global $lang_update;
1295
1296 echo sprintf($lang_update['Converting item'], $lang_update['report'], $cur_item['id']).'<br />'."\n";
11701297
1171 convert_to_utf8($cur_item['message'], $old_charset);1298 convert_to_utf8($cur_item['message'], $old_charset);
11721299
@@ -1236,7 +1363,9 @@
1236 case 'conv_subscriptions':1363 case 'conv_subscriptions':
1237 $query_str = '?stage=conv_topics&req_old_charset='.$old_charset;1364 $query_str = '?stage=conv_topics&req_old_charset='.$old_charset;
12381365
1239 alter_table_utf8($db->prefix.'subscriptions');1366 // By this stage we should have already renamed the subscription table
1367 alter_table_utf8($db->prefix.'topic_subscriptions');
1368 alter_table_utf8($db->prefix.'forum_subscriptions'); // This should actually already be utf8, but for consistency...
12401369
1241 break;1370 break;
12421371
@@ -1247,7 +1376,9 @@
12471376
1248 function _conv_topics($cur_item, $old_charset)1377 function _conv_topics($cur_item, $old_charset)
1249 {1378 {
1250 echo 'Converting topic '.$cur_item['id'].' …<br />'."\n";1379 global $lang_update;
1380
1381 echo sprintf($lang_update['Converting item'], $lang_update['topic'], $cur_item['id']).'<br />'."\n";
12511382
1252 convert_to_utf8($cur_item['poster'], $old_charset);1383 convert_to_utf8($cur_item['poster'], $old_charset);
1253 convert_to_utf8($cur_item['subject'], $old_charset);1384 convert_to_utf8($cur_item['subject'], $old_charset);
@@ -1268,9 +1399,14 @@
1268 case 'conv_users':1399 case 'conv_users':
1269 $query_str = '?stage=preparse_posts';1400 $query_str = '?stage=preparse_posts';
12701401
1402 if ($start_at == 0)
1403 $_SESSION['dupe_users'] = array();
1404
1271 function _conv_users($cur_item, $old_charset)1405 function _conv_users($cur_item, $old_charset)
1272 {1406 {
1273 echo 'Converting user '.$cur_item['id'].' …<br />'."\n";1407 global $lang_update;
1408
1409 echo sprintf($lang_update['Converting item'], $lang_update['user'], $cur_item['id']).'<br />'."\n";
12741410
1275 convert_to_utf8($cur_item['username'], $old_charset);1411 convert_to_utf8($cur_item['username'], $old_charset);
1276 convert_to_utf8($cur_item['title'], $old_charset);1412 convert_to_utf8($cur_item['title'], $old_charset);
@@ -1317,24 +1453,24 @@
1317 $username = pun_trim($_POST['dupe_users'][$id]);1453 $username = pun_trim($_POST['dupe_users'][$id]);
13181454
1319 if (pun_strlen($username) < 2)1455 if (pun_strlen($username) < 2)
1320 $errors[$id][] = 'Usernames must be at least 2 characters long. Please choose another (longer) username.';1456 $errors[$id][] = $lang_update['Username too short error'];
1321 else if (pun_strlen($username) > 25) // This usually doesn't happen since the form element only accepts 25 characters1457 else if (pun_strlen($username) > 25) // This usually doesn't happen since the form element only accepts 25 characters
1322 $errors[$id][] = 'Usernames must not be more than 25 characters long. Please choose another (shorter) username.';1458 $errors[$id][] = $lang_update['Username too long error'];
1323 else if (!strcasecmp($username, 'Guest'))1459 else if (!strcasecmp($username, 'Guest'))
1324 $errors[$id][] = 'The username guest is reserved. Please choose another username.';1460 $errors[$id][] = $lang_update['Username Guest reserved error'];
1325 else if (preg_match('/[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}/', $username) || preg_match('/((([0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}:[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){5}:([0-9A-Fa-f]{1,4}:)?[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){4}:([0-9A-Fa-f]{1,4}:){0,2}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){3}:([0-9A-Fa-f]{1,4}:){0,3}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){2}:([0-9A-Fa-f]{1,4}:){0,4}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(([0-9A-Fa-f]{1,4}:){0,5}:((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(::([0-9A-Fa-f]{1,4}:){0,5}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|([0-9A-Fa-f]{1,4}::([0-9A-Fa-f]{1,4}:){0,5}[0-9A-Fa-f]{1,4})|(::([0-9A-Fa-f]{1,4}:){0,6}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){1,7}:))/', $username))1461 else if (preg_match('/[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}/', $username) || preg_match('/((([0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}:[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){5}:([0-9A-Fa-f]{1,4}:)?[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){4}:([0-9A-Fa-f]{1,4}:){0,2}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){3}:([0-9A-Fa-f]{1,4}:){0,3}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){2}:([0-9A-Fa-f]{1,4}:){0,4}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(([0-9A-Fa-f]{1,4}:){0,5}:((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(::([0-9A-Fa-f]{1,4}:){0,5}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|([0-9A-Fa-f]{1,4}::([0-9A-Fa-f]{1,4}:){0,5}[0-9A-Fa-f]{1,4})|(::([0-9A-Fa-f]{1,4}:){0,6}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){1,7}:))/', $username))
1326 $errors[$id][] = 'Usernames may not be in the form of an IP address. Please choose another username.';1462 $errors[$id][] = $lang_update['Username IP format error'];
1327 else if ((strpos($username, '[') !== false || strpos($username, ']') !== false) && strpos($username, '\'') !== false && strpos($username, '"') !== false)1463 else if ((strpos($username, '[') !== false || strpos($username, ']') !== false) && strpos($username, '\'') !== false && strpos($username, '"') !== false)
1328 $errors[$id][] = 'Usernames may not contain all the characters \', " and [ or ] at once. Please choose another username.';1464 $errors[$id][] = $lang_update['Username bad characters error'];
1329 else if (preg_match('/(?:\[\/?(?:b|u|s|ins|del|em|i|h|colou?r|quote|code|img|url|email|list|\*)\]|\[(?:img|url|quote|list)=)/i', $username))1465 else if (preg_match('/(?:\[\/?(?:b|u|s|ins|del|em|i|h|colou?r|quote|code|img|url|email|list|\*)\]|\[(?:img|url|quote|list)=)/i', $username))
1330 $errors[$id][] = 'Usernames may not contain any of the text formatting tags (BBCode) that the forum uses. Please choose another username.';1466 $errors[$id][] = $lang_update['Username BBCode error'];
13311467
1332 $result = $db->query('SELECT username FROM '.$db->prefix.'users WHERE (UPPER(username)=UPPER(\''.$db->escape($username).'\') OR UPPER(username)=UPPER(\''.$db->escape(preg_replace('/[^\w]/', '', $username)).'\')) AND id>1') or error('Unable to fetch user info', __FILE__, __LINE__, $db->error());1468 $result = $db->query('SELECT username FROM '.$db->prefix.'users WHERE (UPPER(username)=UPPER(\''.$db->escape($username).'\') OR UPPER(username)=UPPER(\''.$db->escape(ucp_preg_replace('/[^\p{L}\p{N}]/u', '', $username)).'\')) AND id>1') or error('Unable to fetch user info', __FILE__, __LINE__, $db->error());
13331469
1334 if ($db->num_rows($result))1470 if ($db->num_rows($result))
1335 {1471 {
1336 $busy = $db->result($result);1472 $busy = $db->result($result);
1337 $errors[$id][] = 'Someone is already registered with the username '.pun_htmlspecialchars($busy).'. The username you entered is too similar. The username must differ from that by at least one alphanumerical character (a-z or 0-9). Please choose a different username.';1473 $errors[$id][] = sprintf($lang_update['Username duplicate error'], pun_htmlspecialchars($busy));
1338 }1474 }
13391475
1340 if (empty($errors[$id]))1476 if (empty($errors[$id]))
@@ -1396,7 +1532,7 @@
1396 $mail_message = trim(substr($mail_tpl, $first_crlf));1532 $mail_message = trim(substr($mail_tpl, $first_crlf));
13971533
1398 $mail_subject = str_replace('<board_title>', $pun_config['o_board_title'], $mail_subject);1534 $mail_subject = str_replace('<board_title>', $pun_config['o_board_title'], $mail_subject);
1399 $mail_message = str_replace('<base_url>', $pun_config['o_base_url'].'/', $mail_message);1535 $mail_message = str_replace('<base_url>', get_base_url().'/', $mail_message);
1400 $mail_message = str_replace('<old_username>', $old_username, $mail_message);1536 $mail_message = str_replace('<old_username>', $old_username, $mail_message);
1401 $mail_message = str_replace('<new_username>', $username, $mail_message);1537 $mail_message = str_replace('<new_username>', $username, $mail_message);
1402 $mail_message = str_replace('<board_mailer>', $pun_config['o_board_title'].' Mailer', $mail_message);1538 $mail_message = str_replace('<board_mailer>', $pun_config['o_board_title'].' Mailer', $mail_message);
@@ -1418,7 +1554,7 @@
1418<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr">1554<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr">
1419<head>1555<head>
1420<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />1556<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
1421<title>FluxBB Database Update</title>1557<title><?php echo $lang_update['Update'] ?></title>
1422<link rel="stylesheet" type="text/css" href="style/<?php echo $default_style ?>.css" />1558<link rel="stylesheet" type="text/css" href="style/<?php echo $default_style ?>.css" />
1423</head>1559</head>
1424<body>1560<body>
@@ -1428,14 +1564,14 @@
1428<div class="punwrap">1564<div class="punwrap">
14291565
1430<div class="blockform">1566<div class="blockform">
1431 <h2><span>Error converting users</span></h2>1567 <h2><span><?php echo $lang_update['Error converting users'] ?></span></h2>
1432 <div class="box">1568 <div class="box">
1433 <form method="post" action="db_update.php?stage=conv_users_dupe">1569 <form method="post" action="db_update.php?stage=conv_users_dupe&amp;uid=<?php echo $uid ?>">
1434 <input type="hidden" name="form_sent" value="1" />1570 <input type="hidden" name="form_sent" value="1" />
1435 <div class="inform">1571 <div class="inform">
1436 <div class="forminfo">1572 <div class="forminfo">
1437 <p style="font-size: 1.1em">There was an error converting some users. This can occur when converting from FluxBB v1.2 if multiple users have registered with very similar usernames, for example "bob" and "böb".</p>1573 <p style="font-size: 1.1em"><?php echo $lang_update['Error info 1'] ?></p>
1438 <p style="font-size: 1.1em">Below is a list of users who failed to convert. Please choose a new username for each user. Users who are renamed will automatically be sent an email alerting them of the change.</p>1574 <p style="font-size: 1.1em"><?php echo $lang_update['Error info 2'] ?></p>
1439 </div>1575 </div>
1440 </div>1576 </div>
1441<?php1577<?php
@@ -1448,11 +1584,11 @@
1448 <fieldset>1584 <fieldset>
1449 <legend><?php echo pun_htmlspecialchars($cur_user['username']); ?></legend>1585 <legend><?php echo pun_htmlspecialchars($cur_user['username']); ?></legend>
1450 <div class="infldset">1586 <div class="infldset">
1451 <label class="required"><strong>New username <span>(required)</span></strong><br /><input type="text" name="<?php echo 'dupe_users['.$id.']'; ?>" value="<?php if (isset($_POST['dupe_users'][$id])) echo pun_htmlspecialchars($_POST['dupe_users'][$id]); ?>" size="25" maxlength="25" /><br /></label>1587 <label class="required"><strong><?php echo $lang_update['New username'] ?> <span><?php echo $lang_update['Required'] ?></span></strong><br /><input type="text" name="<?php echo 'dupe_users['.$id.']'; ?>" value="<?php if (isset($_POST['dupe_users'][$id])) echo pun_htmlspecialchars($_POST['dupe_users'][$id]); ?>" size="25" maxlength="25" /><br /></label>
1452 </div>1588 </div>
1453 </fieldset>1589 </fieldset>
1454<?php if (!empty($errors[$id])): ?> <div class="forminfo error-info">1590<?php if (!empty($errors[$id])): ?> <div class="forminfo error-info">
1455 <h3>The following errors need to be corrected:</h3>1591 <h3><?php echo $lang_update['Correct errors'] ?></h3>
1456 <ul class="error-list">1592 <ul class="error-list">
1457<?php1593<?php
14581594
@@ -1467,7 +1603,7 @@
1467 }1603 }
14681604
1469?>1605?>
1470 <p class="buttons"><input type="submit" name="rename" value="Rename users" /></p>1606 <p class="buttons"><input type="submit" name="rename" value="<?php echo $lang_update['Rename users'] ?>" /></p>
1471 </form>1607 </form>
1472 </div>1608 </div>
1473</div>1609</div>
@@ -1502,7 +1638,7 @@
1502 $end_at = 0;1638 $end_at = 0;
1503 while ($cur_item = $db->fetch_assoc($result))1639 while ($cur_item = $db->fetch_assoc($result))
1504 {1640 {
1505 echo 'Preparsing post '.$cur_item['id'].' …<br />'."\n";1641 echo sprintf($lang_update['Preparsing item'], $lang_update['post'], $cur_item['id']).'<br />'."\n";
1506 $db->query('UPDATE '.$db->prefix.'posts SET message = \''.$db->escape(preparse_bbcode($cur_item['message'], $temp)).'\' WHERE id = '.$cur_item['id']) or error('Unable to update post', __FILE__, __LINE__, $db->error());1642 $db->query('UPDATE '.$db->prefix.'posts SET message = \''.$db->escape(preparse_bbcode($cur_item['message'], $temp)).'\' WHERE id = '.$cur_item['id']) or error('Unable to update post', __FILE__, __LINE__, $db->error());
15071643
1508 $end_at = $cur_item['id'];1644 $end_at = $cur_item['id'];
@@ -1537,7 +1673,7 @@
1537 $end_at = 0;1673 $end_at = 0;
1538 while ($cur_item = $db->fetch_assoc($result))1674 while ($cur_item = $db->fetch_assoc($result))
1539 {1675 {
1540 echo 'Preparsing signature '.$cur_item['id'].' …<br />'."\n";1676 echo sprintf($lang_update['Preparsing item'], $lang_update['signature'], $cur_item['id']).'<br />'."\n";
1541 $db->query('UPDATE '.$db->prefix.'users SET signature = \''.$db->escape(preparse_bbcode($cur_item['signature'], $temp, true)).'\' WHERE id = '.$cur_item['id']) or error('Unable to update user', __FILE__, __LINE__, $db->error());1677 $db->query('UPDATE '.$db->prefix.'users SET signature = \''.$db->escape(preparse_bbcode($cur_item['signature'], $temp, true)).'\' WHERE id = '.$cur_item['id']) or error('Unable to update user', __FILE__, __LINE__, $db->error());
15421678
1543 $end_at = $cur_item['id'];1679 $end_at = $cur_item['id'];
@@ -1593,7 +1729,7 @@
1593 $end_at = 0;1729 $end_at = 0;
1594 while ($cur_item = $db->fetch_assoc($result))1730 while ($cur_item = $db->fetch_assoc($result))
1595 {1731 {
1596 echo 'Rebuilding index for post '.$cur_item['id'].' …<br />'."\n";1732 echo sprintf($lang_update['Rebuilding index item'], $lang_update['post'], $cur_item['id']).'<br />'."\n";
15971733
1598 if ($cur_item['id'] == $cur_item['first_post_id'])1734 if ($cur_item['id'] == $cur_item['first_post_id'])
1599 update_search_index('post', $cur_item['id'], $cur_item['message'], $cur_item['subject']);1735 update_search_index('post', $cur_item['id'], $cur_item['message'], $cur_item['subject']);
@@ -1646,13 +1782,16 @@
1646 // Empty the PHP cache1782 // Empty the PHP cache
1647 forum_clear_cache();1783 forum_clear_cache();
16481784
1785 // Delete the update lock file
1786 @unlink(FORUM_CACHE_DIR.'db_update.lock');
1787
1649?>1788?>
1650<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">1789<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
16511790
1652<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr">1791<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr">
1653<head>1792<head>
1654<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />1793<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
1655<title>FluxBB Database Update</title>1794<title><?php echo $lang_update['Update'] ?></title>
1656<link rel="stylesheet" type="text/css" href="style/<?php echo $default_style ?>.css" />1795<link rel="stylesheet" type="text/css" href="style/<?php echo $default_style ?>.css" />
1657</head>1796</head>
1658<body>1797<body>
@@ -1662,12 +1801,12 @@
1662<div class="punwrap">1801<div class="punwrap">
16631802
1664<div class="blockform">1803<div class="blockform">
1665 <h2><span>FluxBB Update</span></h2>1804 <h2><span><?php echo $lang_update['Update'] ?></span></h2>
1666 <div class="box">1805 <div class="box">
1667 <div class="fakeform">1806 <div class="fakeform">
1668 <div class="inform">1807 <div class="inform">
1669 <div class="forminfo">1808 <div class="forminfo">
1670 <p style="font-size: 1.1em">Your forum database was successfully updated. You may now <a href="<?php echo PUN_ROOT ?>index.php">go to the forum index</a>.</p>1809 <p style="font-size: 1.1em"><?php printf($lang_update['Successfully updated'], sprintf('<a href="index.php">%s</a>', $lang_update['go to index'])) ?></p>
1671 </div>1810 </div>
1672 </div>1811 </div>
1673 </div>1812 </div>
@@ -1689,4 +1828,4 @@
1689$db->close();1828$db->close();
16901829
1691if ($query_str != '')1830if ($query_str != '')
1692 exit('<script type="text/javascript">window.location="db_update.php'.$query_str.'"</script><noscript>JavaScript seems to be disabled. <a href="db_update.php'.$query_str.'">Click here to continue</a>.</noscript>');1831 exit('<script type="text/javascript">window.location="db_update.php'.$query_str.'&uid='.$uid.'"</script><noscript>'.sprintf($lang_update['JavaScript disabled'], sprintf('<a href="db_update.php'.$query_str.'&uid='.$uid.'">%s</a>', $lang_update['Click here to continue'])).'</noscript>');
16931832
=== modified file 'delete.php'
--- delete.php 2010-10-08 13:18:35 +0000
+++ delete.php 2011-04-21 10:05:56 +0000
@@ -1,12 +1,12 @@
1<?php1<?php
22
3/**3/**
4 * Copyright (C) 2008-2010 FluxBB4 * Copyright (C) 2008-2011 FluxBB
5 * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB5 * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB
6 * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher6 * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher
7 */7 */
88
9define('PUN_ROOT', './');9define('PUN_ROOT', dirname(__FILE__).'/');
10require PUN_ROOT.'include/common.php';10require PUN_ROOT.'include/common.php';
1111
1212
@@ -67,7 +67,11 @@
67 delete_post($id, $cur_post['tid']);67 delete_post($id, $cur_post['tid']);
68 update_forum($cur_post['fid']);68 update_forum($cur_post['fid']);
6969
70 redirect('viewtopic.php?id='.$cur_post['tid'], $lang_delete['Post del redirect']);70 // Redirect towards the previous post
71 $result = $db->query('SELECT id FROM '.$db->prefix.'posts WHERE topic_id='.$cur_post['tid'].' AND id < '.$id.' ORDER BY id DESC LIMIT 1') or error('Unable to fetch post info', __FILE__, __LINE__, $db->error());
72 $post_id = $db->result($result);
73
74 redirect('viewtopic.php?pid='.$post_id.'#p'.$post_id, $lang_delete['Post del redirect']);
71 }75 }
72}76}
7377
@@ -108,7 +112,7 @@
108112
109<div id="postreview">113<div id="postreview">
110 <div class="blockpost">114 <div class="blockpost">
111 <div class="box<?php echo ($post_count % 2 == 0) ? ' roweven' : ' rowodd' ?>">115 <div class="box">
112 <div class="inbox">116 <div class="inbox">
113 <div class="postbody">117 <div class="postbody">
114 <div class="postleft">118 <div class="postleft">
115119
=== modified file 'edit.php'
--- edit.php 2010-10-08 13:18:35 +0000
+++ edit.php 2011-04-21 10:05:56 +0000
@@ -1,12 +1,12 @@
1<?php1<?php
22
3/**3/**
4 * Copyright (C) 2008-2010 FluxBB4 * Copyright (C) 2008-2011 FluxBB
5 * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB5 * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB
6 * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher6 * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher
7 */7 */
88
9define('PUN_ROOT', './');9define('PUN_ROOT', dirname(__FILE__).'/');
10require PUN_ROOT.'include/common.php';10require PUN_ROOT.'include/common.php';
1111
1212
@@ -19,7 +19,7 @@
19 message($lang_common['Bad request']);19 message($lang_common['Bad request']);
2020
21// Fetch some info about the post, the topic and the forum21// Fetch some info about the post, the topic and the forum
22$result = $db->query('SELECT f.id AS fid, f.forum_name, f.moderators, f.redirect_url, fp.post_replies, fp.post_topics, t.id AS tid, t.subject, t.posted, t.first_post_id, t.closed, p.poster, p.poster_id, p.message, p.hide_smilies FROM '.$db->prefix.'posts AS p INNER JOIN '.$db->prefix.'topics AS t ON t.id=p.topic_id INNER JOIN '.$db->prefix.'forums AS f ON f.id=t.forum_id LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id='.$pun_user['g_id'].') WHERE (fp.read_forum IS NULL OR fp.read_forum=1) AND p.id='.$id) or error('Unable to fetch post info', __FILE__, __LINE__, $db->error());22$result = $db->query('SELECT f.id AS fid, f.forum_name, f.moderators, f.redirect_url, fp.post_replies, fp.post_topics, t.id AS tid, t.subject, t.posted, t.first_post_id, t.sticky, t.closed, p.poster, p.poster_id, p.message, p.hide_smilies FROM '.$db->prefix.'posts AS p INNER JOIN '.$db->prefix.'topics AS t ON t.id=p.topic_id INNER JOIN '.$db->prefix.'forums AS f ON f.id=t.forum_id LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id='.$pun_user['g_id'].') WHERE (fp.read_forum IS NULL OR fp.read_forum=1) AND p.id='.$id) or error('Unable to fetch post info', __FILE__, __LINE__, $db->error());
23if (!$db->num_rows($result))23if (!$db->num_rows($result))
24 message($lang_common['Bad request']);24 message($lang_common['Bad request']);
2525
@@ -61,8 +61,13 @@
61 {61 {
62 $subject = pun_trim($_POST['req_subject']);62 $subject = pun_trim($_POST['req_subject']);
6363
64 if ($pun_config['o_censoring'] == '1')
65 $censored_subject = pun_trim(censor_words($subject));
66
64 if ($subject == '')67 if ($subject == '')
65 $errors[] = $lang_post['No subject'];68 $errors[] = $lang_post['No subject'];
69 else if ($pun_config['o_censoring'] == '1' && $censored_subject == '')
70 $errors[] = $lang_post['No subject after censoring'];
66 else if (pun_strlen($subject) > 70)71 else if (pun_strlen($subject) > 70)
67 $errors[] = $lang_post['Too long subject'];72 $errors[] = $lang_post['Too long subject'];
68 else if ($pun_config['p_subject_all_caps'] == '0' && is_all_uppercase($subject) && !$pun_user['is_admmod'])73 else if ($pun_config['p_subject_all_caps'] == '0' && is_all_uppercase($subject) && !$pun_user['is_admmod'])
@@ -85,22 +90,36 @@
85 $message = preparse_bbcode($message, $errors);90 $message = preparse_bbcode($message, $errors);
86 }91 }
8792
88 if ($message == '')93 if (empty($errors))
89 $errors[] = $lang_post['No message'];94 {
95 if ($message == '')
96 $errors[] = $lang_post['No message'];
97 else if ($pun_config['o_censoring'] == '1')
98 {
99 // Censor message to see if that causes problems
100 $censored_message = pun_trim(censor_words($message));
101
102 if ($censored_message == '')
103 $errors[] = $lang_post['No message after censoring'];
104 }
105 }
90106
91 $hide_smilies = isset($_POST['hide_smilies']) ? '1' : '0';107 $hide_smilies = isset($_POST['hide_smilies']) ? '1' : '0';
108 $stick_topic = isset($_POST['stick_topic']) ? '1' : '0';
109 if (!$is_admmod)
110 $stick_topic = $cur_post['sticky'];
92111
93 // Did everything go according to plan?112 // Did everything go according to plan?
94 if (empty($errors) && !isset($_POST['preview']))113 if (empty($errors) && !isset($_POST['preview']))
95 {114 {
96 $edited_sql = (!isset($_POST['silent']) || !$is_admmod) ? $edited_sql = ', edited='.time().', edited_by=\''.$db->escape($pun_user['username']).'\'' : '';115 $edited_sql = (!isset($_POST['silent']) || !$is_admmod) ? ', edited='.time().', edited_by=\''.$db->escape($pun_user['username']).'\'' : '';
97116
98 require PUN_ROOT.'include/search_idx.php';117 require PUN_ROOT.'include/search_idx.php';
99118
100 if ($can_edit_subject)119 if ($can_edit_subject)
101 {120 {
102 // Update the topic and any redirect topics121 // Update the topic and any redirect topics
103 $db->query('UPDATE '.$db->prefix.'topics SET subject=\''.$db->escape($subject).'\' WHERE id='.$cur_post['tid'].' OR moved_to='.$cur_post['tid']) or error('Unable to update topic', __FILE__, __LINE__, $db->error());122 $db->query('UPDATE '.$db->prefix.'topics SET subject=\''.$db->escape($subject).'\', sticky='.$stick_topic.' WHERE id='.$cur_post['tid'].' OR moved_to='.$cur_post['tid']) or error('Unable to update topic', __FILE__, __LINE__, $db->error());
104123
105 // We changed the subject, so we need to take that into account when we update the search words124 // We changed the subject, so we need to take that into account when we update the search words
106 update_search_index('edit', $id, $message, $subject);125 update_search_index('edit', $id, $message, $subject);
@@ -214,7 +233,7 @@
214?>233?>
215 <ul class="bblinks">234 <ul class="bblinks">
216 <li><span><a href="help.php#bbcode" onclick="window.open(this.href); return false;"><?php echo $lang_common['BBCode'] ?></a> <?php echo ($pun_config['p_message_bbcode'] == '1') ? $lang_common['on'] : $lang_common['off']; ?></span></li>235 <li><span><a href="help.php#bbcode" onclick="window.open(this.href); return false;"><?php echo $lang_common['BBCode'] ?></a> <?php echo ($pun_config['p_message_bbcode'] == '1') ? $lang_common['on'] : $lang_common['off']; ?></span></li>
217 <li><span><a href="help.php#img" onclick="window.open(this.href); return false;"><?php echo $lang_common['img tag'] ?></a> <?php echo ($pun_config['p_message_img_tag'] == '1') ? $lang_common['on'] : $lang_common['off']; ?></span></li>236 <li><span><a href="help.php#img" onclick="window.open(this.href); return false;"><?php echo $lang_common['img tag'] ?></a> <?php echo ($pun_config['p_message_bbcode'] == '1' && $pun_config['p_message_img_tag'] == '1') ? $lang_common['on'] : $lang_common['off']; ?></span></li>
218 <li><span><a href="help.php#smilies" onclick="window.open(this.href); return false;"><?php echo $lang_common['Smilies'] ?></a> <?php echo ($pun_config['o_smilies'] == '1') ? $lang_common['on'] : $lang_common['off']; ?></span></li>237 <li><span><a href="help.php#smilies" onclick="window.open(this.href); return false;"><?php echo $lang_common['Smilies'] ?></a> <?php echo ($pun_config['o_smilies'] == '1') ? $lang_common['on'] : $lang_common['off']; ?></span></li>
219 </ul>238 </ul>
220 </div>239 </div>
@@ -222,6 +241,14 @@
222<?php241<?php
223242
224$checkboxes = array();243$checkboxes = array();
244if ($can_edit_subject && $is_admmod)
245{
246 if (isset($_POST['stick_topic']) || $cur_post['sticky'] == '1')
247 $checkboxes[] = '<label><input type="checkbox" name="stick_topic" value="1" checked="checked" tabindex="'.($cur_index++).'" />'.$lang_common['Stick topic'].'<br /></label>';
248 else
249 $checkboxes[] = '<label><input type="checkbox" name="stick_topic" value="1" tabindex="'.($cur_index++).'" />'.$lang_common['Stick topic'].'<br /></label>';
250}
251
225if ($pun_config['o_smilies'] == '1')252if ($pun_config['o_smilies'] == '1')
226{253{
227 if (isset($_POST['hide_smilies']) || $cur_post['hide_smilies'] == '1')254 if (isset($_POST['hide_smilies']) || $cur_post['hide_smilies'] == '1')
228255
=== modified file 'extern.php'
--- extern.php 2010-10-08 13:18:35 +0000
+++ extern.php 2011-04-21 10:05:56 +0000
@@ -1,7 +1,7 @@
1<?php1<?php
22
3/**3/**
4 * Copyright (C) 2008-2010 FluxBB4 * Copyright (C) 2008-2011 FluxBB
5 * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB5 * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB
6 * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher6 * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher
7 */7 */
@@ -26,38 +26,38 @@
26 display posts) and type (output as HTML or RSS). The only26 display posts) and type (output as HTML or RSS). The only
27 mandatory variable is action. Possible/default values are:27 mandatory variable is action. Possible/default values are:
2828
29 action: feed - show most recent topics/posts (HTML or RSS)29 action: feed - show most recent topics/posts (HTML or RSS)
30 online - show users online (HTML)30 online - show users online (HTML)
31 online_full - as above, but includes a full list (HTML)31 online_full - as above, but includes a full list (HTML)
32 stats - show board statistics (HTML)32 stats - show board statistics (HTML)
3333
34 type: rss - output as RSS 2.034 type: rss - output as RSS 2.0
35 atom - output as Atom 1.035 atom - output as Atom 1.0
36 xml - output as XML36 xml - output as XML
37 html - output as HTML (<li>'s)37 html - output as HTML (<li>'s)
3838
39 fid: One or more forum IDs (comma-separated). If ignored,39 fid: One or more forum IDs (comma-separated). If ignored,
40 topics from all readable forums will be pulled.40 topics from all readable forums will be pulled.
4141
42 nfid: One or more forum IDs (comma-separated) that are to be42 nfid: One or more forum IDs (comma-separated) that are to be
43 excluded. E.g. the ID of a a test forum.43 excluded. E.g. the ID of a a test forum.
4444
45 tid: A topic ID from which to show posts. If a tid is supplied,45 tid: A topic ID from which to show posts. If a tid is supplied,
46 fid and nfid are ignored.46 fid and nfid are ignored.
4747
48 show: Any integer value between 1 and 50. The default is 15.48 show: Any integer value between 1 and 50. The default is 15.
4949
50 order: last_post - show topics ordered by when they were last50 order: last_post - show topics ordered by when they were last
51 posted in, giving information about the reply.51 posted in, giving information about the reply.
52 posted - show topics ordered by when they were first52 posted - show topics ordered by when they were first
53 posted, giving information about the original post.53 posted, giving information about the original post.
5454
55-----------------------------------------------------------------------------*/55-----------------------------------------------------------------------------*/
5656
57define('PUN_QUIET_VISIT', 1);57define('PUN_QUIET_VISIT', 1);
5858
59if (!defined('PUN_ROOT'))59if (!defined('PUN_ROOT'))
60 define('PUN_ROOT', './');60 define('PUN_ROOT', dirname(__FILE__).'/');
61require PUN_ROOT.'include/common.php';61require PUN_ROOT.'include/common.php';
6262
63// The length at which topic subjects will be truncated (for HTML output)63// The length at which topic subjects will be truncated (for HTML output)
@@ -119,10 +119,11 @@
119 header('Pragma: public');119 header('Pragma: public');
120120
121 echo '<?xml version="1.0" encoding="utf-8"?>'."\n";121 echo '<?xml version="1.0" encoding="utf-8"?>'."\n";
122 echo '<rss version="2.0">'."\n";122 echo '<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">'."\n";
123 echo "\t".'<channel>'."\n";123 echo "\t".'<channel>'."\n";
124 echo "\t\t".'<atom:link href="'.pun_htmlspecialchars(get_current_url()).'" rel="self" type="application/rss+xml" />'."\n";
124 echo "\t\t".'<title><![CDATA['.escape_cdata($feed['title']).']]></title>'."\n";125 echo "\t\t".'<title><![CDATA['.escape_cdata($feed['title']).']]></title>'."\n";
125 echo "\t\t".'<link>'.$feed['link'].'</link>'."\n";126 echo "\t\t".'<link>'.pun_htmlspecialchars($feed['link']).'</link>'."\n";
126 echo "\t\t".'<description><![CDATA['.escape_cdata($feed['description']).']]></description>'."\n";127 echo "\t\t".'<description><![CDATA['.escape_cdata($feed['description']).']]></description>'."\n";
127 echo "\t\t".'<lastBuildDate>'.gmdate('r', count($feed['items']) ? $feed['items'][0]['pubdate'] : time()).'</lastBuildDate>'."\n";128 echo "\t\t".'<lastBuildDate>'.gmdate('r', count($feed['items']) ? $feed['items'][0]['pubdate'] : time()).'</lastBuildDate>'."\n";
128129
@@ -135,11 +136,11 @@
135 {136 {
136 echo "\t\t".'<item>'."\n";137 echo "\t\t".'<item>'."\n";
137 echo "\t\t\t".'<title><![CDATA['.escape_cdata($item['title']).']]></title>'."\n";138 echo "\t\t\t".'<title><![CDATA['.escape_cdata($item['title']).']]></title>'."\n";
138 echo "\t\t\t".'<link>'.$item['link'].'</link>'."\n";139 echo "\t\t\t".'<link>'.pun_htmlspecialchars($item['link']).'</link>'."\n";
139 echo "\t\t\t".'<description><![CDATA['.escape_cdata($item['description']).']]></description>'."\n";140 echo "\t\t\t".'<description><![CDATA['.escape_cdata($item['description']).']]></description>'."\n";
140 echo "\t\t\t".'<author><![CDATA['.(isset($item['author']['email']) ? escape_cdata($item['author']['email']) : 'dummy@example.com').' ('.escape_cdata($item['author']['name']).')]]></author>'."\n";141 echo "\t\t\t".'<author><![CDATA['.(isset($item['author']['email']) ? escape_cdata($item['author']['email']) : 'dummy@example.com').' ('.escape_cdata($item['author']['name']).')]]></author>'."\n";
141 echo "\t\t\t".'<pubDate>'.gmdate('r', $item['pubdate']).'</pubDate>'."\n";142 echo "\t\t\t".'<pubDate>'.gmdate('r', $item['pubdate']).'</pubDate>'."\n";
142 echo "\t\t\t".'<guid>'.$item['link'].'</guid>'."\n";143 echo "\t\t\t".'<guid>'.pun_htmlspecialchars($item['link']).'</guid>'."\n";
143144
144 echo "\t\t".'</item>'."\n";145 echo "\t\t".'</item>'."\n";
145 }146 }
@@ -167,7 +168,7 @@
167168
168 echo "\t".'<title type="html"><![CDATA['.escape_cdata($feed['title']).']]></title>'."\n";169 echo "\t".'<title type="html"><![CDATA['.escape_cdata($feed['title']).']]></title>'."\n";
169 echo "\t".'<link rel="self" href="'.pun_htmlspecialchars(get_current_url()).'"/>'."\n";170 echo "\t".'<link rel="self" href="'.pun_htmlspecialchars(get_current_url()).'"/>'."\n";
170 echo "\t".'<link href="'.$feed['link'].'"/>'."\n";171 echo "\t".'<link href="'.pun_htmlspecialchars($feed['link']).'"/>'."\n";
171 echo "\t".'<updated>'.gmdate('Y-m-d\TH:i:s\Z', count($feed['items']) ? $feed['items'][0]['pubdate'] : time()).'</updated>'."\n";172 echo "\t".'<updated>'.gmdate('Y-m-d\TH:i:s\Z', count($feed['items']) ? $feed['items'][0]['pubdate'] : time()).'</updated>'."\n";
172173
173 if ($pun_config['o_show_version'] == '1')174 if ($pun_config['o_show_version'] == '1')
@@ -175,7 +176,7 @@
175 else176 else
176 echo "\t".'<generator>FluxBB</generator>'."\n";177 echo "\t".'<generator>FluxBB</generator>'."\n";
177178
178 echo "\t".'<id>'.$feed['link'].'</id>'."\n";179 echo "\t".'<id>'.pun_htmlspecialchars($feed['link']).'</id>'."\n";
179180
180 $content_tag = ($feed['type'] == 'posts') ? 'content' : 'summary';181 $content_tag = ($feed['type'] == 'posts') ? 'content' : 'summary';
181182
@@ -183,7 +184,7 @@
183 {184 {
184 echo "\t".'<entry>'."\n";185 echo "\t".'<entry>'."\n";
185 echo "\t\t".'<title type="html"><![CDATA['.escape_cdata($item['title']).']]></title>'."\n";186 echo "\t\t".'<title type="html"><![CDATA['.escape_cdata($item['title']).']]></title>'."\n";
186 echo "\t\t".'<link rel="alternate" href="'.$item['link'].'"/>'."\n";187 echo "\t\t".'<link rel="alternate" href="'.pun_htmlspecialchars($item['link']).'"/>'."\n";
187 echo "\t\t".'<'.$content_tag.' type="html"><![CDATA['.escape_cdata($item['description']).']]></'.$content_tag.'>'."\n";188 echo "\t\t".'<'.$content_tag.' type="html"><![CDATA['.escape_cdata($item['description']).']]></'.$content_tag.'>'."\n";
188 echo "\t\t".'<author>'."\n";189 echo "\t\t".'<author>'."\n";
189 echo "\t\t\t".'<name><![CDATA['.escape_cdata($item['author']['name']).']]></name>'."\n";190 echo "\t\t\t".'<name><![CDATA['.escape_cdata($item['author']['name']).']]></name>'."\n";
@@ -192,12 +193,12 @@
192 echo "\t\t\t".'<email><![CDATA['.escape_cdata($item['author']['email']).']]></email>'."\n";193 echo "\t\t\t".'<email><![CDATA['.escape_cdata($item['author']['email']).']]></email>'."\n";
193194
194 if (isset($item['author']['uri']))195 if (isset($item['author']['uri']))
195 echo "\t\t\t".'<uri>'.$item['author']['uri'].'</uri>'."\n";196 echo "\t\t\t".'<uri>'.pun_htmlspecialchars($item['author']['uri']).'</uri>'."\n";
196197
197 echo "\t\t".'</author>'."\n";198 echo "\t\t".'</author>'."\n";
198 echo "\t\t".'<updated>'.gmdate('Y-m-d\TH:i:s\Z', $item['pubdate']).'</updated>'."\n";199 echo "\t\t".'<updated>'.gmdate('Y-m-d\TH:i:s\Z', $item['pubdate']).'</updated>'."\n";
199200
200 echo "\t\t".'<id>'.$item['link'].'</id>'."\n";201 echo "\t\t".'<id>'.pun_htmlspecialchars($item['link']).'</id>'."\n";
201 echo "\t".'</entry>'."\n";202 echo "\t".'</entry>'."\n";
202 }203 }
203204
@@ -220,7 +221,7 @@
220221
221 echo '<?xml version="1.0" encoding="utf-8"?>'."\n";222 echo '<?xml version="1.0" encoding="utf-8"?>'."\n";
222 echo '<source>'."\n";223 echo '<source>'."\n";
223 echo "\t".'<url>'.$feed['link'].'</url>'."\n";224 echo "\t".'<url>'.pun_htmlspecialchars($feed['link']).'</url>'."\n";
224225
225 $forum_tag = ($feed['type'] == 'posts') ? 'post' : 'topic';226 $forum_tag = ($feed['type'] == 'posts') ? 'post' : 'topic';
226227
@@ -229,7 +230,7 @@
229 echo "\t".'<'.$forum_tag.' id="'.$item['id'].'">'."\n";230 echo "\t".'<'.$forum_tag.' id="'.$item['id'].'">'."\n";
230231
231 echo "\t\t".'<title><![CDATA['.escape_cdata($item['title']).']]></title>'."\n";232 echo "\t\t".'<title><![CDATA['.escape_cdata($item['title']).']]></title>'."\n";
232 echo "\t\t".'<link>'.$item['link'].'</link>'."\n";233 echo "\t\t".'<link>'.pun_htmlspecialchars($item['link']).'</link>'."\n";
233 echo "\t\t".'<content><![CDATA['.escape_cdata($item['description']).']]></content>'."\n";234 echo "\t\t".'<content><![CDATA['.escape_cdata($item['description']).']]></content>'."\n";
234 echo "\t\t".'<author>'."\n";235 echo "\t\t".'<author>'."\n";
235 echo "\t\t\t".'<name><![CDATA['.escape_cdata($item['author']['name']).']]></name>'."\n";236 echo "\t\t\t".'<name><![CDATA['.escape_cdata($item['author']['name']).']]></name>'."\n";
@@ -238,7 +239,7 @@
238 echo "\t\t\t".'<email><![CDATA['.escape_cdata($item['author']['email']).']]></email>'."\n";239 echo "\t\t\t".'<email><![CDATA['.escape_cdata($item['author']['email']).']]></email>'."\n";
239240
240 if (isset($item['author']['uri']))241 if (isset($item['author']['uri']))
241 echo "\t\t\t".'<uri>'.$item['author']['uri'].'</uri>'."\n";242 echo "\t\t\t".'<uri>'.pun_htmlspecialchars($item['author']['uri']).'</uri>'."\n";
242243
243 echo "\t\t".'</author>'."\n";244 echo "\t\t".'</author>'."\n";
244 echo "\t\t".'<posted>'.gmdate('r', $item['pubdate']).'</posted>'."\n";245 echo "\t\t".'<posted>'.gmdate('r', $item['pubdate']).'</posted>'."\n";
@@ -269,7 +270,7 @@
269 else270 else
270 $subject_truncated = pun_htmlspecialchars($item['title']);271 $subject_truncated = pun_htmlspecialchars($item['title']);
271272
272 echo '<li><a href="'.$item['link'].'" title="'.pun_htmlspecialchars($item['title']).'">'.$subject_truncated.'</a></li>'."\n";273 echo '<li><a href="'.pun_htmlspecialchars($item['link']).'" title="'.pun_htmlspecialchars($item['title']).'">'.$subject_truncated.'</a></li>'."\n";
273 }274 }
274}275}
275276
@@ -308,7 +309,7 @@
308 // Setup the feed309 // Setup the feed
309 $feed = array(310 $feed = array(
310 'title' => $pun_config['o_board_title'].$lang_common['Title separator'].$cur_topic['subject'],311 'title' => $pun_config['o_board_title'].$lang_common['Title separator'].$cur_topic['subject'],
311 'link' => $pun_config['o_base_url'].'/viewtopic.php?id='.$tid,312 'link' => get_base_url(true).'/viewtopic.php?id='.$tid,
312 'description' => sprintf($lang_common['RSS description topic'], $cur_topic['subject']),313 'description' => sprintf($lang_common['RSS description topic'], $cur_topic['subject']),
313 'items' => array(),314 'items' => array(),
314 'type' => 'posts'315 'type' => 'posts'
@@ -323,7 +324,7 @@
323 $item = array(324 $item = array(
324 'id' => $cur_post['id'],325 'id' => $cur_post['id'],
325 'title' => $cur_topic['first_post_id'] == $cur_post['id'] ? $cur_topic['subject'] : $lang_common['RSS reply'].$cur_topic['subject'],326 'title' => $cur_topic['first_post_id'] == $cur_post['id'] ? $cur_topic['subject'] : $lang_common['RSS reply'].$cur_topic['subject'],
326 'link' => $pun_config['o_base_url'].'/viewtopic.php?pid='.$cur_post['id'].'#p'.$cur_post['id'],327 'link' => get_base_url(true).'/viewtopic.php?pid='.$cur_post['id'].'#p'.$cur_post['id'],
327 'description' => $cur_post['message'],328 'description' => $cur_post['message'],
328 'author' => array(329 'author' => array(
329 'name' => $cur_post['poster'],330 'name' => $cur_post['poster'],
@@ -336,7 +337,7 @@
336 if ($cur_post['email_setting'] == '0' && !$pun_user['is_guest'])337 if ($cur_post['email_setting'] == '0' && !$pun_user['is_guest'])
337 $item['author']['email'] = $cur_post['email'];338 $item['author']['email'] = $cur_post['email'];
338339
339 $item['author']['uri'] = $pun_config['o_base_url'].'/profile.php?id='.$cur_post['poster_id'];340 $item['author']['uri'] = get_base_url(true).'/profile.php?id='.$cur_post['poster_id'];
340 }341 }
341 else if ($cur_post['poster_email'] != '' && !$pun_user['is_guest'])342 else if ($cur_post['poster_email'] != '' && !$pun_user['is_guest'])
342 $item['author']['email'] = $cur_post['poster_email'];343 $item['author']['email'] = $cur_post['poster_email'];
@@ -381,46 +382,88 @@
381 $forum_sql .= ' AND t.forum_id NOT IN('.implode(',', $nfids).')';382 $forum_sql .= ' AND t.forum_id NOT IN('.implode(',', $nfids).')';
382 }383 }
383384
384 // Setup the feed385 // Only attempt to cache if caching is enabled and we have all or a single forum
385 $feed = array(386 if ($pun_config['o_feed_ttl'] > 0 && ($forum_sql == '' || ($forum_name != '' && !isset($_GET['nfid']))))
386 'title' => $pun_config['o_board_title'].$forum_name,387 $cache_id = 'feed'.sha1($pun_user['g_id'].'|'.$lang_common['lang_identifier'].'|'.($order_posted ? '1' : '0').($forum_name == '' ? '' : '|'.$fids[0]));
387 'link' => $pun_config['o_base_url'].'/index.php',388
388 'description' => sprintf($lang_common['RSS description'], $pun_config['o_board_title']),389 // Load cached feed
389 'items' => array(),390 if (isset($cache_id) && file_exists(FORUM_CACHE_DIR.'cache_'.$cache_id.'.php'))
390 'type' => 'topics'391 include FORUM_CACHE_DIR.'cache_'.$cache_id.'.php';
391 );392
392393 $now = time();
393 // Fetch $show topics394 if (!isset($feed) || $cache_expire < $now)
394 $result = $db->query('SELECT t.id, t.poster, t.subject, t.posted, t.last_post, t.last_poster, p.message, p.hide_smilies, u.email_setting, u.email, p.poster_id, p.poster_email FROM '.$db->prefix.'topics AS t INNER JOIN '.$db->prefix.'posts AS p ON p.id='.($order_posted ? 't.first_post_id' : 't.last_post_id').' INNER JOIN '.$db->prefix.'users AS u ON u.id=p.poster_id LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id=t.forum_id AND fp.group_id='.$pun_user['g_id'].') WHERE (fp.read_forum IS NULL OR fp.read_forum=1) AND t.moved_to IS NULL'.$forum_sql.' ORDER BY '.($order_posted ? 't.posted' : 't.last_post').' DESC LIMIT '.$show) or error('Unable to fetch topic info', __FILE__, __LINE__, $db->error());
395 while ($cur_topic = $db->fetch_assoc($result))
396 {395 {
397 if ($pun_config['o_censoring'] == '1')396 // Setup the feed
398 $cur_topic['subject'] = censor_words($cur_topic['subject']);397 $feed = array(
399398 'title' => $pun_config['o_board_title'].$forum_name,
400 $cur_topic['message'] = parse_message($cur_topic['message'], $cur_topic['hide_smilies']);399 'link' => '/index.php',
401400 'description' => sprintf($lang_common['RSS description'], $pun_config['o_board_title']),
402 $item = array(401 'items' => array(),
403 'id' => $cur_topic['id'],402 'type' => 'topics'
404 'title' => $cur_topic['subject'],
405 'link' => $pun_config['o_base_url'].($order_posted ? '/viewtopic.php?id='.$cur_topic['id'] : '/viewtopic.php?id='.$cur_topic['id'].'&amp;action=new'),
406 'description' => $cur_topic['message'],
407 'author' => array(
408 'name' => $order_posted ? $cur_topic['poster'] : $cur_topic['last_poster']
409 ),
410 'pubdate' => $order_posted ? $cur_topic['posted'] : $cur_topic['last_post']
411 );403 );
412404
413 if ($cur_topic['poster_id'] > 1)405 // Fetch $show topics
414 {406 $result = $db->query('SELECT t.id, t.poster, t.subject, t.posted, t.last_post, t.last_poster, p.message, p.hide_smilies, u.email_setting, u.email, p.poster_id, p.poster_email FROM '.$db->prefix.'topics AS t INNER JOIN '.$db->prefix.'posts AS p ON p.id='.($order_posted ? 't.first_post_id' : 't.last_post_id').' INNER JOIN '.$db->prefix.'users AS u ON u.id=p.poster_id LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id=t.forum_id AND fp.group_id='.$pun_user['g_id'].') WHERE (fp.read_forum IS NULL OR fp.read_forum=1) AND t.moved_to IS NULL'.$forum_sql.' ORDER BY '.($order_posted ? 't.posted' : 't.last_post').' DESC LIMIT '.(isset($cache_id) ? 50 : $show)) or error('Unable to fetch topic info', __FILE__, __LINE__, $db->error());
415 if ($cur_topic['email_setting'] == '0' && !$pun_user['is_guest'])407 while ($cur_topic = $db->fetch_assoc($result))
416 $item['author']['email'] = $cur_topic['email'];408 {
417409 if ($pun_config['o_censoring'] == '1')
418 $item['author']['uri'] = $pun_config['o_base_url'].'/profile.php?id='.$cur_topic['poster_id'];410 $cur_topic['subject'] = censor_words($cur_topic['subject']);
419 }411
420 else if ($cur_topic['poster_email'] != '' && !$pun_user['is_guest'])412 $cur_topic['message'] = parse_message($cur_topic['message'], $cur_topic['hide_smilies']);
421 $item['author']['email'] = $cur_topic['poster_email'];413
422414 $item = array(
423 $feed['items'][] = $item;415 'id' => $cur_topic['id'],
416 'title' => $cur_topic['subject'],
417 'link' => '/viewtopic.php?id='.$cur_topic['id'].($order_posted ? '' : '&action=new'),
418 'description' => $cur_topic['message'],
419 'author' => array(
420 'name' => $order_posted ? $cur_topic['poster'] : $cur_topic['last_poster']
421 ),
422 'pubdate' => $order_posted ? $cur_topic['posted'] : $cur_topic['last_post']
423 );
424
425 if ($cur_topic['poster_id'] > 1)
426 {
427 if ($cur_topic['email_setting'] == '0' && !$pun_user['is_guest'])
428 $item['author']['email'] = $cur_topic['email'];
429
430 $item['author']['uri'] = '/profile.php?id='.$cur_topic['poster_id'];
431 }
432 else if ($cur_topic['poster_email'] != '' && !$pun_user['is_guest'])
433 $item['author']['email'] = $cur_topic['poster_email'];
434
435 $feed['items'][] = $item;
436 }
437
438 // Output feed as PHP code
439 if (isset($cache_id))
440 {
441 $fh = @fopen(FORUM_CACHE_DIR.'cache_'.$cache_id.'.php', 'wb');
442 if (!$fh)
443 error('Unable to write feed cache file to cache directory. Please make sure PHP has write access to the directory \''.pun_htmlspecialchars(FORUM_CACHE_DIR).'\'', __FILE__, __LINE__);
444
445 fwrite($fh, '<?php'."\n\n".'$feed = '.var_export($feed, true).';'."\n\n".'$cache_expire = '.($now + ($pun_config['o_feed_ttl'] * 60)).';'."\n\n".'?>');
446
447 fclose($fh);
448
449 if (function_exists('apc_delete_file'))
450 @apc_delete_file(FORUM_CACHE_DIR.'cache_'.$cache_id.'.php');
451 }
452 }
453
454 // If we only want to show a few items but due to caching we have too many
455 if (count($feed['items']) > $show)
456 $feed['items'] = array_slice($feed['items'], 0, $show);
457
458 // Prepend the current base URL onto some links. Done after caching to handle http/https correctly
459 $feed['link'] = get_base_url(true).$feed['link'];
460
461 foreach ($feed['items'] as $key => $item)
462 {
463 $feed['items'][$key]['link'] = get_base_url(true).$item['link'];
464
465 if (isset($item['author']['uri']))
466 $feed['items'][$key]['author']['uri'] = get_base_url(true).$item['author']['uri'];
424 }467 }
425468
426 $output_func = 'output_'.$type;469 $output_func = 'output_'.$type;
@@ -446,7 +489,7 @@
446 {489 {
447 if ($pun_user_online['user_id'] > 1)490 if ($pun_user_online['user_id'] > 1)
448 {491 {
449 $users[] = ($pun_user['g_view_users'] == '1') ? '<a href="'.$pun_config['o_base_url'].'/profile.php?id='.$pun_user_online['user_id'].'">'.pun_htmlspecialchars($pun_user_online['ident']).'</a>' : pun_htmlspecialchars($pun_user_online['ident']);492 $users[] = ($pun_user['g_view_users'] == '1') ? '<a href="'.pun_htmlspecialchars(get_base_url(true)).'/profile.php?id='.$pun_user_online['user_id'].'">'.pun_htmlspecialchars($pun_user_online['ident']).'</a>' : pun_htmlspecialchars($pun_user_online['ident']);
450 ++$num_users;493 ++$num_users;
451 }494 }
452 else495 else
@@ -476,11 +519,17 @@
476 require PUN_ROOT.'lang/'.$pun_config['o_default_lang'].'/index.php';519 require PUN_ROOT.'lang/'.$pun_config['o_default_lang'].'/index.php';
477520
478 // Collect some statistics from the database521 // Collect some statistics from the database
479 $result = $db->query('SELECT COUNT(id)-1 FROM '.$db->prefix.'users WHERE group_id!='.PUN_UNVERIFIED) or error('Unable to fetch total user count', __FILE__, __LINE__, $db->error());522 if (file_exists(FORUM_CACHE_DIR.'cache_users_info.php'))
480 $stats['total_users'] = $db->result($result);523 include FORUM_CACHE_DIR.'cache_users_info.php';
481524
482 $result = $db->query('SELECT id, username FROM '.$db->prefix.'users WHERE group_id!='.PUN_UNVERIFIED.' ORDER BY registered DESC LIMIT 1') or error('Unable to fetch newest registered user', __FILE__, __LINE__, $db->error());525 if (!defined('PUN_USERS_INFO_LOADED'))
483 $stats['last_user'] = $db->fetch_assoc($result);526 {
527 if (!defined('FORUM_CACHE_FUNCTIONS_LOADED'))
528 require PUN_ROOT.'include/cache.php';
529
530 generate_users_info_cache();
531 require FORUM_CACHE_DIR.'cache_users_info.php';
532 }
484533
485 $result = $db->query('SELECT SUM(num_topics), SUM(num_posts) FROM '.$db->prefix.'forums') or error('Unable to fetch topic/post count', __FILE__, __LINE__, $db->error());534 $result = $db->query('SELECT SUM(num_topics), SUM(num_posts) FROM '.$db->prefix.'forums') or error('Unable to fetch topic/post count', __FILE__, __LINE__, $db->error());
486 list($stats['total_topics'], $stats['total_posts']) = $db->fetch_row($result);535 list($stats['total_topics'], $stats['total_posts']) = $db->fetch_row($result);
@@ -492,7 +541,7 @@
492 header('Pragma: public');541 header('Pragma: public');
493542
494 echo sprintf($lang_index['No of users'], forum_number_format($stats['total_users'])).'<br />'."\n";543 echo sprintf($lang_index['No of users'], forum_number_format($stats['total_users'])).'<br />'."\n";
495 echo sprintf($lang_index['Newest user'], (($pun_user['g_view_users'] == '1') ? '<a href="'.$pun_config['o_base_url'].'/profile.php?id='.$stats['last_user']['id'].'">'.pun_htmlspecialchars($stats['last_user']['username']).'</a>' : pun_htmlspecialchars($stats['last_user']['username']))).'<br />'."\n";544 echo sprintf($lang_index['Newest user'], (($pun_user['g_view_users'] == '1') ? '<a href="'.pun_htmlspecialchars(get_base_url(true)).'/profile.php?id='.$stats['last_user']['id'].'">'.pun_htmlspecialchars($stats['last_user']['username']).'</a>' : pun_htmlspecialchars($stats['last_user']['username']))).'<br />'."\n";
496 echo sprintf($lang_index['No of topics'], forum_number_format($stats['total_topics'])).'<br />'."\n";545 echo sprintf($lang_index['No of topics'], forum_number_format($stats['total_topics'])).'<br />'."\n";
497 echo sprintf($lang_index['No of posts'], forum_number_format($stats['total_posts'])).'<br />'."\n";546 echo sprintf($lang_index['No of posts'], forum_number_format($stats['total_posts'])).'<br />'."\n";
498547
499548
=== modified file 'footer.php'
--- footer.php 2010-10-08 13:18:35 +0000
+++ footer.php 2011-04-21 10:05:56 +0000
@@ -1,7 +1,7 @@
1<?php1<?php
22
3/**3/**
4 * Copyright (C) 2008-2010 FluxBB4 * Copyright (C) 2008-2011 FluxBB
5 * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB5 * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB
6 * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher6 * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher
7 */7 */
@@ -63,72 +63,34 @@
63 <div id="brdfooternav" class="inbox">63 <div id="brdfooternav" class="inbox">
64<?php64<?php
6565
66echo "\t\t\t".'<div class="conl">'."\n";
67
68// Display the "Jump to" drop list
69if ($pun_config['o_quickjump'] == '1')
70{
71 // Load cached quick jump
72 if (file_exists(FORUM_CACHE_DIR.'cache_quickjump_'.$pun_user['g_id'].'.php'))
73 include FORUM_CACHE_DIR.'cache_quickjump_'.$pun_user['g_id'].'.php';
74
75 if (!defined('PUN_QJ_LOADED'))
76 {
77 if (!defined('FORUM_CACHE_FUNCTIONS_LOADED'))
78 require PUN_ROOT.'include/cache.php';
79
80 generate_quickjump_cache($pun_user['g_id']);
81 require FORUM_CACHE_DIR.'cache_quickjump_'.$pun_user['g_id'].'.php';
82 }
83}
84
85echo "\t\t\t".'</div>'."\n";
86
87?>
88 <div class="conr">
89<?php
90
66// If no footer style has been specified, we use the default (only copyright/debug info)91// If no footer style has been specified, we use the default (only copyright/debug info)
67$footer_style = isset($footer_style) ? $footer_style : NULL;92$footer_style = isset($footer_style) ? $footer_style : NULL;
6893
69if ($footer_style == 'index' || $footer_style == 'search')
70{
71 echo "\t\t\t".'<div class="conl">'."\n";
72
73 if (!$pun_user['is_guest'] && $pun_user['g_search'] == '1')
74 {
75 echo "\t\t\t\t".'<dl id="searchlinks">'."\n";
76 echo "\t\t\t\t\t".'<dt><strong>'.$lang_common['Search links'].'</strong></dt>'."\n";
77
78 echo "\t\t\t\t\t".'<dd><span><a href="search.php?action=show_24h">'.$lang_common['Show recent posts'].'</a></span></dd>'."\n";
79 echo "\t\t\t\t\t".'<dd><span><a href="search.php?action=show_unanswered">'.$lang_common['Show unanswered posts'].'</a></span></dd>'."\n";
80
81 if ($pun_config['o_subscriptions'] == '1')
82 echo "\t\t\t\t\t".'<dd><span><a href="search.php?action=show_subscriptions">'.$lang_common['Show subscriptions'].'</a></span></dd>'."\n";
83
84 echo "\t\t\t\t\t".'<dd><span><a href="search.php?action=show_user&amp;user_id='.$pun_user['id'].'">'.$lang_common['Show your posts'].'</a></span></dd>'."\n";
85
86 echo "\t\t\t\t".'</dl>'."\n";
87 }
88 else
89 {
90 if ($pun_user['g_search'] == '1')
91 {
92 echo "\t\t\t\t".'<dl id="searchlinks">'."\n";
93 echo "\t\t\t\t\t".'<dt><strong>'.$lang_common['Search links'].'</strong></dt>'."\n";
94
95 echo "\t\t\t\t\t".'<dd><span><a href="search.php?action=show_24h">'.$lang_common['Show recent posts'].'</a></span></dd>'."\n";
96 echo "\t\t\t\t\t".'<dd><span><a href="search.php?action=show_unanswered">'.$lang_common['Show unanswered posts'].'</a></span></dd>'."\n";
97
98 echo "\t\t\t\t".'</dl>'."\n";
99 }
100 }
101
102 echo "\t\t\t".'</div>'."\n";
103}
104else if ($footer_style == 'viewforum' || $footer_style == 'viewtopic')
105{
106 echo "\t\t\t".'<div class="conl">'."\n";
107
108 // Display the "Jump to" drop list
109 if ($pun_config['o_quickjump'] == '1')
110 {
111 // Load cached quick jump
112 if (file_exists(FORUM_CACHE_DIR.'cache_quickjump_'.$pun_user['g_id'].'.php'))
113 include FORUM_CACHE_DIR.'cache_quickjump_'.$pun_user['g_id'].'.php';
114
115 if (!defined('PUN_QJ_LOADED'))
116 {
117 if (!defined('FORUM_CACHE_FUNCTIONS_LOADED'))
118 require PUN_ROOT.'include/cache.php';
119
120 generate_quickjump_cache($pun_user['g_id']);
121 require FORUM_CACHE_DIR.'cache_quickjump_'.$pun_user['g_id'].'.php';
122 }
123 }
124
125 echo "\t\t\t".'</div>'."\n";
126}
127
128?>
129 <div class="conr">
130<?php
131
132if ($footer_style == 'index')94if ($footer_style == 'index')
133{95{
134 if ($pun_config['o_feed_type'] == '1')96 if ($pun_config['o_feed_type'] == '1')
@@ -141,7 +103,7 @@
141 if ($pun_config['o_feed_type'] == '1')103 if ($pun_config['o_feed_type'] == '1')
142 echo "\t\t\t\t".'<p id="feedlinks"><span class="rss"><a href="extern.php?action=feed&amp;fid='.$forum_id.'&amp;type=rss">'.$lang_common['RSS forum feed'].'</a></span></p>'."\n";104 echo "\t\t\t\t".'<p id="feedlinks"><span class="rss"><a href="extern.php?action=feed&amp;fid='.$forum_id.'&amp;type=rss">'.$lang_common['RSS forum feed'].'</a></span></p>'."\n";
143 else if ($pun_config['o_feed_type'] == '2')105 else if ($pun_config['o_feed_type'] == '2')
144 echo "\t\t\t\t".'<p id="feedlinks" class="actions"><span class="atom"><a href="extern.php?action=feed&amp;fid='.$forum_id.'&amp;type=atom">'.$lang_common['Atom forum feed'].'</a></span></p>'."\n";106 echo "\t\t\t\t".'<p id="feedlinks"><span class="atom"><a href="extern.php?action=feed&amp;fid='.$forum_id.'&amp;type=atom">'.$lang_common['Atom forum feed'].'</a></span></p>'."\n";
145}107}
146else if ($footer_style == 'viewtopic')108else if ($footer_style == 'viewtopic')
147{109{
148110
=== modified file 'header.php'
--- header.php 2011-04-16 22:04:53 +0000
+++ header.php 2011-04-21 10:05:56 +0000
@@ -1,7 +1,7 @@
1<?php1<?php
22
3/**3/**
4 * Copyright (C) 2008-2010 FluxBB4 * Copyright (C) 2008-2011 FluxBB
5 * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB5 * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB
6 * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher6 * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher
7 */7 */
@@ -197,33 +197,34 @@
197/* <![CDATA[ */197/* <![CDATA[ */
198function process_form(the_form)198function process_form(the_form)
199{199{
200 var element_names = new Object()200 var element_names = {
201<?php201<?php
202202 // Output a JavaScript object with localised field names
203 // Output a JavaScript array with localised field names203 $tpl_temp = count($required_fields);
204 foreach ($required_fields as $elem_orig => $elem_trans)204 foreach ($required_fields as $elem_orig => $elem_trans)
205 echo "\t".'element_names["'.$elem_orig.'"] = "'.addslashes(str_replace('&#160;', ' ', $elem_trans)).'"'."\n";205 {
206206 echo "\t\t\"".$elem_orig.'": "'.addslashes(str_replace('&#160;', ' ', $elem_trans));
207 if (--$tpl_temp) echo "\",\n";
208 else echo "\"\n\t};\n";
209 }
207?>210?>
208
209 if (document.all || document.getElementById)211 if (document.all || document.getElementById)
210 {212 {
211 for (var i = 0; i < the_form.length; ++i)213 for (var i = 0; i < the_form.length; ++i)
212 {214 {
213 var elem = the_form.elements[i]215 var elem = the_form.elements[i];
214 if (elem.name && elem.name.substring(0, 4) == "req_")216 if (elem.name && (/^req_/.test(elem.name)))
215 {217 {
216 if (elem.type && (elem.type=="text" || elem.type=="textarea" || elem.type=="password" || elem.type=="file") && elem.value=='')218 if (!elem.value && elem.type && (/^(?:text(?:area)?|password|file)$/i.test(elem.type)))
217 {219 {
218 alert("\"" + element_names[elem.name] + "\" <?php echo $lang_common['required field'] ?>")220 alert('"' + element_names[elem.name] + '" <?php echo $lang_common['required field'] ?>');
219 elem.focus()221 elem.focus();
220 return false222 return false;
221 }223 }
222 }224 }
223 }225 }
224 }226 }
225227 return true;
226 return true
227}228}
228/* ]]> */229/* ]]> */
229</script>230</script>
@@ -234,8 +235,12 @@
234// JavaScript tricks for IE6 and older235// JavaScript tricks for IE6 and older
235echo '<!--[if lte IE 6]><script type="text/javascript" src="style/imports/minmax.js"></script><![endif]-->'."\n";236echo '<!--[if lte IE 6]><script type="text/javascript" src="style/imports/minmax.js"></script><![endif]-->'."\n";
236237
237if (isset($page_head))238if (!isset($page_head))
238 echo implode("\n", $page_head)."\n";239 $page_head = array();
240
241$page_head['top'] = '<link rel="top" href="index.php" title="'.$lang_common['Forum index'].'" />';
242
243echo implode("\n", $page_head)."\n";
239244
240$tpl_temp = trim(ob_get_contents());245$tpl_temp = trim(ob_get_contents());
241$tpl_main = str_replace('<pun_head>', $tpl_temp, $tpl_main);246$tpl_main = str_replace('<pun_head>', $tpl_temp, $tpl_main);
@@ -246,8 +251,8 @@
246// START SUBST - <body>251// START SUBST - <body>
247if (isset($focus_element))252if (isset($focus_element))
248{253{
249 $tpl_main = str_replace('<body onload="', '<body onload="document.getElementById(\''.$focus_element[0].'\').'.$focus_element[1].'.focus();', $tpl_main);254 $tpl_main = str_replace('<body onload="', '<body onload="document.getElementById(\''.$focus_element[0].'\').elements[\''.$focus_element[1].'\'].focus();', $tpl_main);
250 $tpl_main = str_replace('<body>', '<body onload="document.getElementById(\''.$focus_element[0].'\').'.$focus_element[1].'.focus()">', $tpl_main);255 $tpl_main = str_replace('<body>', '<body onload="document.getElementById(\''.$focus_element[0].'\').elements[\''.$focus_element[1].'\'].focus()">', $tpl_main);
251}256}
252// END SUBST - <body>257// END SUBST - <body>
253258
@@ -258,7 +263,7 @@
258263
259264
260// START SUBST - <pun_title>265// START SUBST - <pun_title>
261$tpl_main = str_replace('<pun_title>', '<h1><span>'.pun_htmlspecialchars($pun_config['o_board_title']).'</span></h1>', $tpl_main);266$tpl_main = str_replace('<pun_title>', '<h1><a href="index.php">'.pun_htmlspecialchars($pun_config['o_board_title']).'</a></h1>', $tpl_main);
262// END SUBST - <pun_title>267// END SUBST - <pun_title>
263268
264269
@@ -268,16 +273,67 @@
268273
269274
270// START SUBST - <pun_navlinks>275// START SUBST - <pun_navlinks>
271$tpl_main = str_replace('<pun_navlinks>','<div class="inbox">'."\n\t\t\t". generate_navlinks()."\n\t\t".'</div>', $tpl_main);276$links = array();
277
278// Index should always be displayed
279//$links[] = '<li id="navindex"'.((PUN_ACTIVE_PAGE == 'index') ? ' class="isactive"' : '').'><a href="index.php">'.$lang_common['Index'].'</a></li>';
280
281if ($pun_user['g_read_board'] == '1' && $pun_user['g_view_users'] == '1')
282 $links[] = '<li id="navuserlist"'.((PUN_ACTIVE_PAGE == 'userlist') ? ' class="isactive"' : '').'><a href="userlist.php" title="Rechercher des utilisateurs">'.$lang_common['User list'].'</a></li>';
283
284if ($pun_config['o_rules'] == '1' && (!$pun_user['is_guest'] || $pun_user['g_read_board'] == '1' || $pun_config['o_regs_allow'] == '1'))
285 $links[] = '<li id="navrules"'.((PUN_ACTIVE_PAGE == 'rules') ? ' class="isactive"' : '').'><a href="misc.php?action=rules" title="Charte du Forum Ubuntu-fr">'.$lang_common['Rules'].'</a></li>';
286
287if ($pun_user['g_read_board'] == '1' && $pun_user['g_search'] == '1')
288 //$links[] = '<li id="navsearch"'.((PUN_ACTIVE_PAGE == 'search') ? ' class="isactive"' : '').'><a href="search.php">'.$lang_common['Search'].'</a></li>';
289
290if ($pun_user['is_guest'])
291{
292 $links[] = '<li id="navregister"'.((PUN_ACTIVE_PAGE == 'register') ? ' class="isactive"' : '').'><a href="register.php">'.$lang_common['Register'].'</a></li>';
293 $links[] = '<li id="navlogin"'.((PUN_ACTIVE_PAGE == 'login') ? ' class="isactive"' : '').'><a href="login.php">'.$lang_common['Login'].'</a></li>';
294}
295else
296{
297 $links[] = '<li id="navprofile"'.((PUN_ACTIVE_PAGE == 'profile') ? ' class="isactive"' : '').'><a href="profile.php?id='.$pun_user['id'].'">'.$lang_common['Profile'].'</a></li>';
298
299 if ($pun_user['is_admmod'])
300 $links[] = '<li id="navadmin"'.((PUN_ACTIVE_PAGE == 'admin') ? ' class="isactive"' : '').'><a href="admin_index.php">'.$lang_common['Admin'].'</a></li>';
301
302 $links[] = '<li id="navlogout"><a href="login.php?action=out&amp;id='.$pun_user['id'].'&amp;csrf_token='.pun_hash($pun_user['id'].pun_hash(get_remote_address())).'">'.$lang_common['Logout'].'</a></li>';
303}
304
305// liens du header intégrés au menu
306 if (in_array(basename($_SERVER['PHP_SELF']), array('index.php', 'search.php')) && !$pun_user['is_guest'])
307 $links[] = '<li id="navmark"><a href="misc.php?action=markread">'.$lang_common['Mark all as read'].'</a></li>';
308 else if (basename($_SERVER['PHP_SELF']) == 'viewforum.php')
309 $links[] = '<li id="navmark"><a href="misc.php?action=markforumread&amp;fid='.$id.'">'.$lang_common['Mark forum read'].'</a></li>';
310
311// Are there any additional navlinks we should insert into the array before imploding it?
312if ($pun_user['g_read_board'] == '1' && $pun_config['o_additional_navlinks'] != '')
313{
314 if (preg_match_all('#([0-9]+)\s*=\s*(.*?)\n#s', $pun_config['o_additional_navlinks']."\n", $extra_links))
315 {
316 // Insert any additional links into the $links array (at the correct index)
317 $num_links = count($extra_links[1]);
318 for ($i = 0; $i < $num_links; ++$i)
319 array_splice($links, $extra_links[1][$i], 0, array('<li id="navextra'.($i + 1).'">'.$extra_links[2][$i].'</li>'));
320 }
321}
322
323$tpl_temp = '<div class="inbox">'."\n\t\t\t".'<ul>'."\n\t\t\t\t".implode("\n\t\t\t\t", $links)."\n\t\t\t".'</ul>'."\n\t\t".'</div>';
324$tpl_main = str_replace('<pun_navlinks>', $tpl_temp, $tpl_main);
272// END SUBST - <pun_navlinks>325// END SUBST - <pun_navlinks>
273326
274327
275// START SUBST - <pun_status>328// START SUBST - <pun_status>
329$page_statusinfo = $page_topicsearches = array();
330
276if ($pun_user['is_guest'])331if ($pun_user['is_guest'])
277 $tpl_temp = '<div id="brdwelcome" class="inbox">'."\n\t\t\t".$lang_common['Not logged in']."\n\t\t".'</div>';332 $page_statusinfo = $lang_common['Not logged in'];
278else333else
279{334{
280 $tpl_temp = '<div id="brdwelcome" class="inbox">'."\n\t\t\t".'<ul class="conl">'."\n\t\t\t\t".'<li><span>'.$lang_common['Logged in as'].' <strong>'.pun_htmlspecialchars($pun_user['username']).'</strong></span></li>'."\n\t\t\t\t".'<li><span>'.sprintf($lang_common['Last visit'], format_time($pun_user['last_visit'])).'</span></li>';335 $page_statusinfo[] = '<li><span>'.$lang_common['Logged in as'].' <strong>'.pun_htmlspecialchars($pun_user['username']).'</strong></span></li>';
336 $page_statusinfo[] = '<li><span>'.sprintf($lang_common['Last visit'], format_time($pun_user['last_visit'])).'</span></li>';
281337
282 if ($pun_user['is_admmod'])338 if ($pun_user['is_admmod'])
283 {339 {
@@ -286,21 +342,50 @@
286 $result_header = $db->query('SELECT 1 FROM '.$db->prefix.'reports WHERE zapped IS NULL') or error('Unable to fetch reports info', __FILE__, __LINE__, $db->error());342 $result_header = $db->query('SELECT 1 FROM '.$db->prefix.'reports WHERE zapped IS NULL') or error('Unable to fetch reports info', __FILE__, __LINE__, $db->error());
287343
288 if ($db->result($result_header))344 if ($db->result($result_header))
289 $tpl_temp .= "\n\t\t\t\t".'<li class="reportlink"><span><strong><a href="admin_reports.php">'.$lang_common['New reports'].'</a></strong></span></li>';345 $page_statusinfo[] = '<li class="reportlink"><span><strong><a href="admin_reports.php">'.$lang_common['New reports'].'</a></strong></span></li>';
290 }346 }
291347
292 if ($pun_config['o_maintenance'] == '1')348 if ($pun_config['o_maintenance'] == '1')
293 $tpl_temp .= "\n\t\t\t\t".'<li class="maintenancelink"><span><strong><a href="admin_options.php#maintenance">'.$lang_common['Maintenance mode enabled'].'</a></strong></span></li>';349 $page_statusinfo[] = '<li class="maintenancelink"><span><strong><a href="admin_options.php#maintenance">'.$lang_common['Maintenance mode enabled'].'</a></strong></span></li>';
294 }350 }
295//'<li><span><a href="search.php?action=show_new">'.$lang_common['Show new posts'].'</a></span></li>'351
296// if (in_array(basename($_SERVER['PHP_SELF']), array('index.php', 'search.php')))352 if ($pun_user['g_read_board'] == '1' && $pun_user['g_search'] == '1')
297// $tpl_temp .= "\n\t\t\t".'</ul>'."\n\t\t\t".'<ul class="conr">'.($pun_user['g_search'] == '1' ? "\n\t\t\t\t" : '')."\n\t\t\t\t".'<li><span><a href="misc.php?action=markread">'.$lang_common['Mark all as read'].'</a></span></li>'."\n\t\t\t".'</ul>'."\n\t\t\t".'<div class="clearer"></div>'."\n\t\t".'</div>';353 {
298// else if (basename($_SERVER['PHP_SELF']) == 'viewforum.php')354 $page_topicsearches[] = '<a href="search.php?action=show_replies" title="'.$lang_common['Show posted topics'].'">'.$lang_common['Posted topics'].'</a>';
299// $tpl_temp .= "\n\t\t\t".'</ul>'."\n\t\t\t".'<ul class="conr">'."\n\t\t\t\t".'<li><span><a href="misc.php?action=markforumread&amp;fid='.$id.'">'.$lang_common['Mark forum read'].'</a></span></li>'."\n\t\t\t".'</ul>'."\n\t\t\t".'<div class="clearer"></div>'."\n\t\t".'</div>';355 $page_topicsearches[] = '<a href="search.php?action=show_new" title="'.$lang_common['Show new posts'].'">'.$lang_common['New posts header'].'</a>';
300// else356 }
301 $tpl_temp .= "\n\t\t\t".'</ul>'."\n\t\t\t".'<div class="clearer"></div>'."\n\t\t".'</div>';357}
302}358
303359// Quick searches
360if ($pun_user['g_read_board'] == '1' && $pun_user['g_search'] == '1')
361{
362 $page_topicsearches[] = '<a href="search.php?action=show_recent" title="'.$lang_common['Show active topics'].'">'.$lang_common['Active topics'].'</a>';
363 $page_topicsearches[] = '<a href="search.php?action=show_unanswered" title="'.$lang_common['Show unanswered topics'].'">'.$lang_common['Unanswered topics'].'</a>';
364}
365
366
367// Generate all that jazz
368$tpl_temp = '<div id="brdwelcome" class="inbox">'."\n\t\t\t";
369
370// The status information
371if (is_array($page_statusinfo))
372{
373 $tpl_temp .= "\n\t\t\t".'<ul class="conl">';
374 $tpl_temp .= "\n\t\t\t\t".implode("\n\t\t\t\t", $page_statusinfo);
375 $tpl_temp .= "\n\t\t\t".'</ul>';
376}
377else
378 $tpl_temp .= "\n\t\t\t".$page_statusinfo;
379
380// Generate quicklinks
381//if (!empty($page_topicsearches))
382//{
383// $tpl_temp .= "\n\t\t\t".'<ul class="conr">';
384// $tpl_temp .= "\n\t\t\t\t".'<li><span>'.$lang_common['Topic searches'].' '.implode(' | ', $page_topicsearches).'</span></li>';
385// $tpl_temp .= "\n\t\t\t".'</ul>'."\n\t\t\t".'<div class="clearer"></div>';
386//}
387
388$tpl_temp .= "\n\t\t".'</div>';
304389
305$tpl_main = str_replace('<pun_status>', $tpl_temp, $tpl_main);390$tpl_main = str_replace('<pun_status>', $tpl_temp, $tpl_main);
306// END SUBST - <pun_status>391// END SUBST - <pun_status>
@@ -310,31 +395,31 @@
310// START SUBST - <pun_searchlinks>395// START SUBST - <pun_searchlinks>
311if (!$pun_user['is_guest'] && $pun_user['g_search'] == '1')396if (!$pun_user['is_guest'] && $pun_user['g_search'] == '1')
312{397{
313 $tpl_searchlinks = "\n\t\t".'<li class="cat"><h2>'.$lang_common['Search links'].'</h2>'."\n";398 $tpl_searchlinks = "\n\t\t".'<li class="cat"><h2>'.$lang_common['Search links'].'</h2>'."\n";
314 $tpl_searchlinks .= "\t\t".'<div id="brdmenu" class="inbox">'."\n\t\t\t".'<ul>'."\n";399 $tpl_searchlinks .= "\t\t".'<div id="brdmenu" class="inbox">'."\n\t\t\t".'<ul>'."\n";
315 $tpl_searchlinks .= "\t\t\t\t".'<li><a href="search.php?action=show_new" title="Nouveaux messages depuis votre dernière visite">'.$lang_common['Show new posts'].'</a></li>'."\n";400 $tpl_searchlinks .= "\t\t\t\t".'<li><a href="search.php?action=show_new" title="Nouveaux messages depuis votre dernière visite">'.$lang_common['Show new posts'].'</a></li>'."\n";
316 $tpl_searchlinks .= "\t\t\t\t".'<li><a href="search.php?action=show_24h" title="300 dernières discussions actives">'.$lang_common['Show recent posts'].'</a></li>'."\n";401 $tpl_searchlinks .= "\t\t\t\t".'<li><a href="search.php?action=show_recent" title="300 dernières discussions actives">'.$lang_common['Show active topics'].'</a></li>'."\n";
317 $tpl_searchlinks .= "\t\t\t\t".'<li><a href="search.php?action=show_unanswered" title="300 dernières discussions sans réponse">'.$lang_common['Show unanswered posts'].'</a></li>'."\n";402 $tpl_searchlinks .= "\t\t\t\t".'<li><a href="search.php?action=show_unanswered" title="300 dernières discussions sans réponse">'.$lang_common['Show unanswered topics'].'</a></li>'."\n";
318 if ($pun_config['o_subscriptions'] == '1')403 if ($pun_config['o_topic_subscriptions'] == '1')
319 $tpl_searchlinks .= "\t\t\t\t".'<li><a href="search.php?action=show_subscriptions" title="Discussions auxquelles vous êtes abonné">'.$lang_common['Show subscriptions'].'</a></li>'."\n";404 $tpl_searchlinks .= "\t\t\t\t".'<li><a href="search.php?action=show_subscriptions" title="Discussions auxquelles vous êtes abonné">'.$lang_common['Show subscriptions'].'</a></li>'."\n";
320 $tpl_searchlinks .= "\t\t\t\t".'<li><a href="search.php?action=show_user&amp;user_id='.$pun_user['id'].'" title="Discussions auxquelles vous avez participé">'.$lang_common['Show your posts'].'</a></li>'."\n\t\t\t".'</ul>'."\n\t\t".'</div></li>'."\n\t";405 $tpl_searchlinks .= "\t\t\t\t".'<li><a href="search.php?action=show_replies&amp;user_id='.$pun_user['id'].'" title="Discussions auxquelles vous avez participé">'.$lang_common['Show your posts'].'</a></li>'."\n\t\t\t".'</ul>'."\n\t\t".'</div></li>'."\n\t";
321}406}
322else407else
323{408{
324 if ($pun_user['g_search'] == '1')409 if ($pun_user['g_search'] == '1')
325 {410 {
326 $tpl_searchlinks = "\n\t\t".'<li class="cat"><h2>'.$lang_common['Search links'].'</h2>'."\n";411 $tpl_searchlinks = "\n\t\t".'<li class="cat"><h2>'.$lang_common['Search links'].'</h2>'."\n";
327 $tpl_searchlinks .= "\t\t".'<div id="brdmenu" class="inbox">'."\n\t\t\t".'<ul>'."\n";412 $tpl_searchlinks .= "\t\t".'<div id="brdmenu" class="inbox">'."\n\t\t\t".'<ul>'."\n";
328 $tpl_searchlinks .= "\t\t\t\t".'<li><a href="search.php?action=show_24h" title="300 dernières discussions actives">'.$lang_common['Show recent posts'].'</a></li>'."\n";413 $tpl_searchlinks .= "\t\t\t\t".'<li><a href="search.php?action=show_24h" title="300 dernières discussions actives">'.$lang_common['Show active topics'].'</a></li>'."\n";
329 $tpl_searchlinks .= "\t\t\t\t".'<li><a href="search.php?action=show_unanswered" title="300 dernières discussions sans réponse">'.$lang_common['Show unanswered posts'].'</a></li>'."\n\t\t\t".'</ul>'."\n\t\t".'</div></li>'."\n\t";414 $tpl_searchlinks .= "\t\t\t\t".'<li><a href="search.php?action=show_unanswered" title="300 dernières discussions sans réponse">'.$lang_common['Show unanswered topics'].'</a></li>'."\n\t\t\t".'</ul>'."\n\t\t".'</div></li>'."\n\t";
330 }415 }
331}416}
332$tpl_main = str_replace('<pun_searchlinks>', $tpl_searchlinks, $tpl_main);417$tpl_main = str_replace('<pun_searchlinks>', $tpl_searchlinks, $tpl_main);
333// END SUBST -<pun_searchlinks>418// END SUBST -<pun_searchlinks>
334419
335420
336// START SUBST - <pun_announcement>421// START SUBST - <pun_announcement>
337if ($pun_config['o_announcement'] == '1')422if ($pun_user['g_read_board'] == '1' && $pun_config['o_announcement'] == '1')
338{423{
339 ob_start();424 ob_start();
340425
341426
=== modified file 'help.php'
--- help.php 2010-10-08 13:18:35 +0000
+++ help.php 2011-04-21 10:05:56 +0000
@@ -1,7 +1,7 @@
1<?php1<?php
22
3/**3/**
4 * Copyright (C) 2008-2010 FluxBB4 * Copyright (C) 2008-2011 FluxBB
5 * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB5 * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB
6 * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher6 * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher
7 */7 */
@@ -9,7 +9,7 @@
9// Tell header.php to use the help template9// Tell header.php to use the help template
10define('PUN_HELP', 1);10define('PUN_HELP', 1);
1111
12define('PUN_ROOT', './');12define('PUN_ROOT', dirname(__FILE__).'/');
13require PUN_ROOT.'include/common.php';13require PUN_ROOT.'include/common.php';
1414
1515
@@ -39,7 +39,7 @@
39 <p><?php echo $lang_help['Text style info'] ?></p>39 <p><?php echo $lang_help['Text style info'] ?></p>
40 <p><code>[b]<?php echo $lang_help['Bold text'] ?>[/b]</code> <?php echo $lang_help['produces'] ?> <samp><strong><?php echo $lang_help['Bold text'] ?></strong></samp></p>40 <p><code>[b]<?php echo $lang_help['Bold text'] ?>[/b]</code> <?php echo $lang_help['produces'] ?> <samp><strong><?php echo $lang_help['Bold text'] ?></strong></samp></p>
41 <p><code>[u]<?php echo $lang_help['Underlined text'] ?>[/u]</code> <?php echo $lang_help['produces'] ?> <samp><span class="bbu"><?php echo $lang_help['Underlined text'] ?></span></samp></p>41 <p><code>[u]<?php echo $lang_help['Underlined text'] ?>[/u]</code> <?php echo $lang_help['produces'] ?> <samp><span class="bbu"><?php echo $lang_help['Underlined text'] ?></span></samp></p>
42 <p><code>[i]<?php echo $lang_help['Italic text'] ?>[/i]</code> <?php echo $lang_help['produces'] ?> <samp><i><?php echo $lang_help['Italic text'] ?></i></samp></p>42 <p><code>[i]<?php echo $lang_help['Italic text'] ?>[/i]</code> <?php echo $lang_help['produces'] ?> <samp><em><?php echo $lang_help['Italic text'] ?></em></samp></p>
43 <p><code>[s]<?php echo $lang_help['Strike-through text'] ?>[/s]</code> <?php echo $lang_help['produces'] ?> <samp><span class="bbs"><?php echo $lang_help['Strike-through text'] ?></span></samp></p>43 <p><code>[s]<?php echo $lang_help['Strike-through text'] ?>[/s]</code> <?php echo $lang_help['produces'] ?> <samp><span class="bbs"><?php echo $lang_help['Strike-through text'] ?></span></samp></p>
44 <p><code>[del]<?php echo $lang_help['Deleted text'] ?>[/del]</code> <?php echo $lang_help['produces'] ?> <samp><del><?php echo $lang_help['Deleted text'] ?></del></samp></p>44 <p><code>[del]<?php echo $lang_help['Deleted text'] ?>[/del]</code> <?php echo $lang_help['produces'] ?> <samp><del><?php echo $lang_help['Deleted text'] ?></del></samp></p>
45 <p><code>[ins]<?php echo $lang_help['Inserted text'] ?>[/ins]</code> <?php echo $lang_help['produces'] ?> <samp><ins><?php echo $lang_help['Inserted text'] ?></ins></samp></p>45 <p><code>[ins]<?php echo $lang_help['Inserted text'] ?>[/ins]</code> <?php echo $lang_help['produces'] ?> <samp><ins><?php echo $lang_help['Inserted text'] ?></ins></samp></p>
@@ -53,14 +53,14 @@
53<div class="box">53<div class="box">
54 <div class="inbox">54 <div class="inbox">
55 <p><?php echo $lang_help['Links info'] ?></p>55 <p><?php echo $lang_help['Links info'] ?></p>
56 <p><code>[url=<?php echo $pun_config['o_base_url'].'/' ?>]<?php echo pun_htmlspecialchars($pun_config['o_board_title']) ?>[/url]</code> <?php echo $lang_help['produces'] ?> <samp><a href="<?php echo $pun_config['o_base_url'].'/' ?>"><?php echo pun_htmlspecialchars($pun_config['o_board_title']) ?></a></samp></p>56 <p><code>[url=<?php echo pun_htmlspecialchars(get_base_url(true).'/') ?>]<?php echo pun_htmlspecialchars($pun_config['o_board_title']) ?>[/url]</code> <?php echo $lang_help['produces'] ?> <samp><a href="<?php echo pun_htmlspecialchars(get_base_url(true).'/') ?>"><?php echo pun_htmlspecialchars($pun_config['o_board_title']) ?></a></samp></p>
57 <p><code>[url]<?php echo $pun_config['o_base_url'].'/' ?>[/url]</code> <?php echo $lang_help['produces'] ?> <samp><a href="<?php echo $pun_config['o_base_url'] ?>"><?php echo $pun_config['o_base_url'].'/' ?></a></samp></p>57 <p><code>[url]<?php echo pun_htmlspecialchars(get_base_url(true).'/') ?>[/url]</code> <?php echo $lang_help['produces'] ?> <samp><a href="<?php echo pun_htmlspecialchars(get_base_url(true).'/') ?>"><?php echo pun_htmlspecialchars(get_base_url(true).'/') ?></a></samp></p>
58 <p><code>[email]myname@mydomain.com[/email]</code> <?php echo $lang_help['produces'] ?> <samp><a href="mailto:myname@mydomain.com">myname@mydomain.com</a></samp></p>58 <p><code>[email]myname@mydomain.com[/email]</code> <?php echo $lang_help['produces'] ?> <samp><a href="mailto:myname@mydomain.com">myname@mydomain.com</a></samp></p>
59 <p><code>[email=myname@mydomain.com]<?php echo $lang_help['My email address'] ?>[/email]</code> <?php echo $lang_help['produces'] ?> <samp><a href="mailto:myname@mydomain.com"><?php echo $lang_help['My email address'] ?></a></samp></p>59 <p><code>[email=myname@mydomain.com]<?php echo $lang_help['My email address'] ?>[/email]</code> <?php echo $lang_help['produces'] ?> <samp><a href="mailto:myname@mydomain.com"><?php echo $lang_help['My email address'] ?></a></samp></p>
60 </div>60 </div>
61 <div class="inbox">61 <div class="inbox">
62 <p><a name="img"></a><?php echo $lang_help['Images info'] ?></p>62 <p><a name="img"></a><?php echo $lang_help['Images info'] ?></p>
63 <p><code>[img=FluxBB bbcode test]<?php echo $pun_config['o_base_url'].'/' ?>img/test.png[/img]</code> <?php echo $lang_help['produces'] ?> <samp><img src="<?php echo $pun_config['o_base_url'].'/' ?>img/test.png" alt="FluxBB bbcode test" /></samp></p>63 <p><code>[img=<?php echo $lang_help['FluxBB bbcode test'] ?>]<?php echo pun_htmlspecialchars(get_base_url(true)) ?>/img/test.png[/img]</code> <?php echo $lang_help['produces'] ?> <samp><img src="<?php echo pun_htmlspecialchars(get_base_url(true)) ?>/img/test.png" alt="<?php echo $lang_help['FluxBB bbcode test'] ?>" /></samp></p>
64 </div>64 </div>
65</div>65</div>
66<h2><span><?php echo $lang_help['Quotes'] ?></span></h2>66<h2><span><?php echo $lang_help['Quotes'] ?></span></h2>
@@ -99,17 +99,17 @@
99 <p><code>[list][*]<?php echo $lang_help['List text 1'] ?>[/*][*]<?php echo $lang_help['List text 2'] ?>[/*][*]<?php echo $lang_help['List text 3'] ?>[/*][/list]</code>99 <p><code>[list][*]<?php echo $lang_help['List text 1'] ?>[/*][*]<?php echo $lang_help['List text 2'] ?>[/*][*]<?php echo $lang_help['List text 3'] ?>[/*][/list]</code>
100 <br /><span><?php echo $lang_help['produces list'] ?></span></p>100 <br /><span><?php echo $lang_help['produces list'] ?></span></p>
101 <div class="postmsg">101 <div class="postmsg">
102 <ul><li><?php echo $lang_help['List text 1'] ?></li><li><?php echo $lang_help['List text 2'] ?></li><li><?php echo $lang_help['List text 3'] ?></li></ul>102 <ul><li><p><?php echo $lang_help['List text 1'] ?></p></li><li><p><?php echo $lang_help['List text 2'] ?></p></li><li><p><?php echo $lang_help['List text 3'] ?></p></li></ul>
103 </div>103 </div>
104 <p><code>[list=1][*]<?php echo $lang_help['List text 1'] ?>[/*][*]<?php echo $lang_help['List text 2'] ?>[/*][*]<?php echo $lang_help['List text 3'] ?>[/*][/list]</code>104 <p><code>[list=1][*]<?php echo $lang_help['List text 1'] ?>[/*][*]<?php echo $lang_help['List text 2'] ?>[/*][*]<?php echo $lang_help['List text 3'] ?>[/*][/list]</code>
105 <br /><span><?php echo $lang_help['produces decimal list'] ?></span></p>105 <br /><span><?php echo $lang_help['produces decimal list'] ?></span></p>
106 <div class="postmsg">106 <div class="postmsg">
107 <ol class="decimal"><li><?php echo $lang_help['List text 1'] ?></li><li><?php echo $lang_help['List text 2'] ?></li><li><?php echo $lang_help['List text 3'] ?></li></ol>107 <ol class="decimal"><li><p><?php echo $lang_help['List text 1'] ?></p></li><li><p><?php echo $lang_help['List text 2'] ?></p></li><li><p><?php echo $lang_help['List text 3'] ?></p></li></ol>
108 </div>108 </div>
109 <p><code>[list=a][*]<?php echo $lang_help['List text 1'] ?>[/*][*]<?php echo $lang_help['List text 2'] ?>[/*][*]<?php echo $lang_help['List text 3'] ?>[/*][/list]</code>109 <p><code>[list=a][*]<?php echo $lang_help['List text 1'] ?>[/*][*]<?php echo $lang_help['List text 2'] ?>[/*][*]<?php echo $lang_help['List text 3'] ?>[/*][/list]</code>
110 <br /><span><?php echo $lang_help['produces alpha list'] ?></span></p>110 <br /><span><?php echo $lang_help['produces alpha list'] ?></span></p>
111 <div class="postmsg">111 <div class="postmsg">
112 <ol class="alpha"><li><?php echo $lang_help['List text 1'] ?></li><li><?php echo $lang_help['List text 2'] ?></li><li><?php echo $lang_help['List text 3'] ?></li></ol>112 <ol class="alpha"><li><p><?php echo $lang_help['List text 1'] ?></p></li><li><p><?php echo $lang_help['List text 2'] ?></p></li><li><p><?php echo $lang_help['List text 3'] ?></p></li></ol>
113 </div>113 </div>
114 </div>114 </div>
115</div>115</div>
@@ -135,7 +135,8 @@
135 $smiley_groups[$smiley_img][] = $smiley_text;135 $smiley_groups[$smiley_img][] = $smiley_text;
136136
137foreach ($smiley_groups as $smiley_img => $smiley_texts)137foreach ($smiley_groups as $smiley_img => $smiley_texts)
138 echo "\t\t".'<p><code>'.implode('</code> '.$lang_common['and'].' <code>', $smiley_texts).'</code> <span>'.$lang_help['produces'].'</span> <samp><img src="'.$pun_config['o_base_url'].'/img/smilies/'.$smiley_img.'" width="15" height="15" alt="'.$smiley_texts[0].'" /></samp></p>'."\n";138 echo "\t\t".'<p><code>'.implode('</code> '.$lang_common['and'].' <code>', $smiley_texts).'</code> <span>'.$lang_help['produces'].'</span> <samp><img src="'.pun_htmlspecialchars(get_base_url(true)).'/img/smilies/'.$smiley_img.'" width="15" height="15" alt="'.$smiley_texts[0].'" /></samp></p>'."\n";
139
139?>140?>
140 </div>141 </div>
141</div>142</div>
142143
=== modified file 'include/cache.php'
--- include/cache.php 2010-10-08 13:18:35 +0000
+++ include/cache.php 2011-04-21 10:05:56 +0000
@@ -1,7 +1,7 @@
1<?php1<?php
22
3/**3/**
4 * Copyright (C) 2008-2010 FluxBB4 * Copyright (C) 2008-2011 FluxBB
5 * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB5 * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB
6 * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher6 * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher
7 */7 */
@@ -26,14 +26,14 @@
26 // Output config as PHP code26 // Output config as PHP code
27 $fh = @fopen(FORUM_CACHE_DIR.'cache_config.php', 'wb');27 $fh = @fopen(FORUM_CACHE_DIR.'cache_config.php', 'wb');
28 if (!$fh)28 if (!$fh)
29 error('Unable to write configuration cache file to cache directory. Please make sure PHP has write access to the directory \'cache\'', __FILE__, __LINE__);29 error('Unable to write configuration cache file to cache directory. Please make sure PHP has write access to the directory \''.pun_htmlspecialchars(FORUM_CACHE_DIR).'\'', __FILE__, __LINE__);
3030
31 fwrite($fh, '<?php'."\n\n".'define(\'PUN_CONFIG_LOADED\', 1);'."\n\n".'$pun_config = '.var_export($output, true).';'."\n\n".'?>');31 fwrite($fh, '<?php'."\n\n".'define(\'PUN_CONFIG_LOADED\', 1);'."\n\n".'$pun_config = '.var_export($output, true).';'."\n\n".'?>');
3232
33 fclose($fh);33 fclose($fh);
3434
35 if (function_exists('apc_delete_file'))35 if (function_exists('apc_delete_file'))
36 apc_delete_file(FORUM_CACHE_DIR.'cache_config.php');36 @apc_delete_file(FORUM_CACHE_DIR.'cache_config.php');
37}37}
3838
3939
@@ -54,14 +54,14 @@
54 // Output ban list as PHP code54 // Output ban list as PHP code
55 $fh = @fopen(FORUM_CACHE_DIR.'cache_bans.php', 'wb');55 $fh = @fopen(FORUM_CACHE_DIR.'cache_bans.php', 'wb');
56 if (!$fh)56 if (!$fh)
57 error('Unable to write bans cache file to cache directory. Please make sure PHP has write access to the directory \'cache\'', __FILE__, __LINE__);57 error('Unable to write bans cache file to cache directory. Please make sure PHP has write access to the directory \''.pun_htmlspecialchars(FORUM_CACHE_DIR).'\'', __FILE__, __LINE__);
5858
59 fwrite($fh, '<?php'."\n\n".'define(\'PUN_BANS_LOADED\', 1);'."\n\n".'$pun_bans = '.var_export($output, true).';'."\n\n".'?>');59 fwrite($fh, '<?php'."\n\n".'define(\'PUN_BANS_LOADED\', 1);'."\n\n".'$pun_bans = '.var_export($output, true).';'."\n\n".'?>');
6060
61 fclose($fh);61 fclose($fh);
6262
63 if (function_exists('apc_delete_file'))63 if (function_exists('apc_delete_file'))
64 apc_delete_file(FORUM_CACHE_DIR.'cache_bans.php');64 @apc_delete_file(FORUM_CACHE_DIR.'cache_bans.php');
65}65}
6666
6767
@@ -82,14 +82,14 @@
82 // Output ranks list as PHP code82 // Output ranks list as PHP code
83 $fh = @fopen(FORUM_CACHE_DIR.'cache_ranks.php', 'wb');83 $fh = @fopen(FORUM_CACHE_DIR.'cache_ranks.php', 'wb');
84 if (!$fh)84 if (!$fh)
85 error('Unable to write ranks cache file to cache directory. Please make sure PHP has write access to the directory \'cache\'', __FILE__, __LINE__);85 error('Unable to write ranks cache file to cache directory. Please make sure PHP has write access to the directory \''.pun_htmlspecialchars(FORUM_CACHE_DIR).'\'', __FILE__, __LINE__);
8686
87 fwrite($fh, '<?php'."\n\n".'define(\'PUN_RANKS_LOADED\', 1);'."\n\n".'$pun_ranks = '.var_export($output, true).';'."\n\n".'?>');87 fwrite($fh, '<?php'."\n\n".'define(\'PUN_RANKS_LOADED\', 1);'."\n\n".'$pun_ranks = '.var_export($output, true).';'."\n\n".'?>');
8888
89 fclose($fh);89 fclose($fh);
9090
91 if (function_exists('apc_delete_file'))91 if (function_exists('apc_delete_file'))
92 apc_delete_file(FORUM_CACHE_DIR.'cache_ranks.php');92 @apc_delete_file(FORUM_CACHE_DIR.'cache_ranks.php');
93}93}
9494
9595
@@ -100,58 +100,184 @@
100{100{
101 global $db, $lang_common, $pun_user;101 global $db, $lang_common, $pun_user;
102102
103 $groups = array();
104
103 // If a group_id was supplied, we generate the quick jump cache for that group only105 // If a group_id was supplied, we generate the quick jump cache for that group only
104 if ($group_id !== false)106 if ($group_id !== false)
105 $groups[0] = $group_id;107 {
108 // Is this group even allowed to read forums?
109 $result = $db->query('SELECT g_read_board FROM '.$db->prefix.'groups WHERE g_id='.$group_id) or error('Unable to fetch user group read permission', __FILE__, __LINE__, $db->error());
110 $read_board = $db->result($result);
111
112 $groups[$group_id] = $read_board;
113 }
106 else114 else
107 {115 {
108 // A group_id was now supplied, so we generate the quick jump cache for all groups116 // A group_id was not supplied, so we generate the quick jump cache for all groups
109 $result = $db->query('SELECT g_id FROM '.$db->prefix.'groups') or error('Unable to fetch user group list', __FILE__, __LINE__, $db->error());117 $result = $db->query('SELECT g_id, g_read_board FROM '.$db->prefix.'groups') or error('Unable to fetch user group list', __FILE__, __LINE__, $db->error());
110 $num_groups = $db->num_rows($result);118 $num_groups = $db->num_rows($result);
111119
112 for ($i = 0; $i < $num_groups; ++$i)120 while ($row = $db->fetch_row($result))
113 $groups[] = $db->result($result, $i);121 $groups[$row[0]] = $row[1];
114 }122 }
115123
116 // Loop through the groups in $groups and output the cache for each of them124 // Loop through the groups in $groups and output the cache for each of them
117 foreach ($groups as $group_id)125 foreach ($groups as $group_id => $read_board)
118 {126 {
119 // Output quick jump as PHP code127 // Output quick jump as PHP code
120 $fh = @fopen(FORUM_CACHE_DIR.'cache_quickjump_'.$group_id.'.php', 'wb');128 $fh = @fopen(FORUM_CACHE_DIR.'cache_quickjump_'.$group_id.'.php', 'wb');
121 if (!$fh)129 if (!$fh)
122 error('Unable to write quick jump cache file to cache directory. Please make sure PHP has write access to the directory \'cache\'', __FILE__, __LINE__);130 error('Unable to write quick jump cache file to cache directory. Please make sure PHP has write access to the directory \''.pun_htmlspecialchars(FORUM_CACHE_DIR).'\'', __FILE__, __LINE__);
123131
124 $output = '<?php'."\n\n".'if (!defined(\'PUN\')) exit;'."\n".'define(\'PUN_QJ_LOADED\', 1);'."\n\n".'?>';132 $output = '<?php'."\n\n".'if (!defined(\'PUN\')) exit;'."\n".'define(\'PUN_QJ_LOADED\', 1);'."\n".'$forum_id = isset($forum_id) ? $forum_id : 0;'."\n\n".'?>';
125 $output .= "\t\t\t\t".'<form id="qjump" method="get" action="viewforum.php">'."\n\t\t\t\t\t".'<div><label><span><?php echo $lang_common[\'Jump to\'] ?>'.'<br /></span>'."\n\t\t\t\t\t".'<select name="id" onchange="window.location=(\'viewforum.php?id=\'+this.options[this.selectedIndex].value)">'."\n";133
126134 if ($read_board == '1')
127
128 $result = $db->query('SELECT c.id AS cid, c.cat_name, f.id AS fid, f.forum_name, f.redirect_url FROM '.$db->prefix.'categories AS c INNER JOIN '.$db->prefix.'forums AS f ON c.id=f.cat_id LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id='.$group_id.') WHERE fp.read_forum IS NULL OR fp.read_forum=1 ORDER BY c.disp_position, c.id, f.disp_position', true) or error('Unable to fetch category/forum list', __FILE__, __LINE__, $db->error());
129
130 $cur_category = 0;
131 while ($cur_forum = $db->fetch_assoc($result))
132 {135 {
133 if ($cur_forum['cid'] != $cur_category) // A new category since last iteration?136 $result = $db->query('SELECT c.id AS cid, c.cat_name, f.id AS fid, f.forum_name, f.redirect_url FROM '.$db->prefix.'categories AS c INNER JOIN '.$db->prefix.'forums AS f ON c.id=f.cat_id LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id='.$group_id.') WHERE fp.read_forum IS NULL OR fp.read_forum=1 ORDER BY c.disp_position, c.id, f.disp_position') or error('Unable to fetch category/forum list', __FILE__, __LINE__, $db->error());
137
138 if ($db->num_rows($result))
134 {139 {
135 if ($cur_category)140 $output .= "\t\t\t\t".'<form id="qjump" method="get" action="viewforum.php">'."\n\t\t\t\t\t".'<div><label><span><?php echo $lang_common[\'Jump to\'] ?>'.'<br /></span>'."\n\t\t\t\t\t".'<select name="id" onchange="window.location=(\'viewforum.php?id=\'+this.options[this.selectedIndex].value)">'."\n";
136 $output .= "\t\t\t\t\t\t".'</optgroup>'."\n";141
137142 $cur_category = 0;
138 $output .= "\t\t\t\t\t\t".'<optgroup label="'.pun_htmlspecialchars($cur_forum['cat_name']).'">'."\n";143 while ($cur_forum = $db->fetch_assoc($result))
139 $cur_category = $cur_forum['cid'];144 {
145 if ($cur_forum['cid'] != $cur_category) // A new category since last iteration?
146 {
147 if ($cur_category)
148 $output .= "\t\t\t\t\t\t".'</optgroup>'."\n";
149
150 $output .= "\t\t\t\t\t\t".'<optgroup label="'.pun_htmlspecialchars($cur_forum['cat_name']).'">'."\n";
151 $cur_category = $cur_forum['cid'];
152 }
153
154 $redirect_tag = ($cur_forum['redirect_url'] != '') ? ' &gt;&gt;&gt;' : '';
155 $output .= "\t\t\t\t\t\t\t".'<option value="'.$cur_forum['fid'].'"<?php echo ($forum_id == '.$cur_forum['fid'].') ? \' selected="selected"\' : \'\' ?>>'.pun_htmlspecialchars($cur_forum['forum_name']).$redirect_tag.'</option>'."\n";
156 }
157
158 $output .= "\t\t\t\t\t\t".'</optgroup>'."\n\t\t\t\t\t".'</select>'."\n\t\t\t\t\t".'<input type="submit" value="<?php echo $lang_common[\'Go\'] ?>" accesskey="g" />'."\n\t\t\t\t\t".'</label></div>'."\n\t\t\t\t".'</form>'."\n";
140 }159 }
141
142 $redirect_tag = ($cur_forum['redirect_url'] != '') ? ' &gt;&gt;&gt;' : '';
143 $output .= "\t\t\t\t\t\t\t".'<option value="'.$cur_forum['fid'].'"<?php echo ($forum_id == '.$cur_forum['fid'].') ? \' selected="selected"\' : \'\' ?>>'.pun_htmlspecialchars($cur_forum['forum_name']).$redirect_tag.'</option>'."\n";
144 }160 }
145161
146 $output .= "\t\t\t\t\t\t".'</optgroup>'."\n\t\t\t\t\t".'</select>'."\n\t\t\t\t\t".'<input type="submit" value="<?php echo $lang_common[\'Go\'] ?>" accesskey="g" />'."\n\t\t\t\t\t".'</label></div>'."\n\t\t\t\t".'</form>'."\n";
147
148 fwrite($fh, $output);162 fwrite($fh, $output);
149163
150 fclose($fh);164 fclose($fh);
151165
152 if (function_exists('apc_delete_file'))166 if (function_exists('apc_delete_file'))
153 apc_delete_file(FORUM_CACHE_DIR.'cache_quickjump_'.$group_id.'.php');167 @apc_delete_file(FORUM_CACHE_DIR.'cache_quickjump_'.$group_id.'.php');
154 }168 }
155}169}
170
171
172//
173// Generate the censoring cache PHP script
174//
175function generate_censoring_cache()
176{
177 global $db;
178
179 $result = $db->query('SELECT search_for, replace_with FROM '.$db->prefix.'censoring') or error('Unable to fetch censoring list', __FILE__, __LINE__, $db->error());
180 $num_words = $db->num_rows($result);
181
182 $search_for = $replace_with = array();
183 for ($i = 0; $i < $num_words; $i++)
184 {
185 list($search_for[$i], $replace_with[$i]) = $db->fetch_row($result);
186 $search_for[$i] = '/(?<=[^\p{L}\p{N}])('.str_replace('\*', '[\p{L}\p{N}]*?', preg_quote($search_for[$i], '/')).')(?=[^\p{L}\p{N}])/iu';
187 }
188
189 // Output censored words as PHP code
190 $fh = @fopen(FORUM_CACHE_DIR.'cache_censoring.php', 'wb');
191 if (!$fh)
192 error('Unable to write censoring cache file to cache directory. Please make sure PHP has write access to the directory \''.pun_htmlspecialchars(FORUM_CACHE_DIR).'\'', __FILE__, __LINE__);
193
194 fwrite($fh, '<?php'."\n\n".'define(\'PUN_CENSOR_LOADED\', 1);'."\n\n".'$search_for = '.var_export($search_for, true).';'."\n\n".'$replace_with = '.var_export($replace_with, true).';'."\n\n".'?>');
195
196 fclose($fh);
197
198 if (function_exists('apc_delete_file'))
199 @apc_delete_file(FORUM_CACHE_DIR.'cache_censoring.php');
200}
201
202
203//
204// Generate the stopwords cache PHP script
205//
206function generate_stopwords_cache()
207{
208 $stopwords = array();
209
210 $d = dir(PUN_ROOT.'lang');
211 while (($entry = $d->read()) !== false)
212 {
213 if ($entry{0} == '.')
214 continue;
215
216 if (is_dir(PUN_ROOT.'lang/'.$entry) && file_exists(PUN_ROOT.'lang/'.$entry.'/stopwords.txt'))
217 $stopwords = array_merge($stopwords, file(PUN_ROOT.'lang/'.$entry.'/stopwords.txt'));
218 }
219 $d->close();
220
221 // Tidy up and filter the stopwords
222 $stopwords = array_map('pun_trim', $stopwords);
223 $stopwords = array_filter($stopwords);
224
225 // Output stopwords as PHP code
226 $fh = @fopen(FORUM_CACHE_DIR.'cache_stopwords.php', 'wb');
227 if (!$fh)
228 error('Unable to write stopwords cache file to cache directory. Please make sure PHP has write access to the directory \''.pun_htmlspecialchars(FORUM_CACHE_DIR).'\'', __FILE__, __LINE__);
229
230 fwrite($fh, '<?php'."\n\n".'$cache_id = \''.generate_stopwords_cache_id().'\';'."\n".'if ($cache_id != generate_stopwords_cache_id()) return;'."\n\n".'define(\'PUN_STOPWORDS_LOADED\', 1);'."\n\n".'$stopwords = '.var_export($stopwords, true).';'."\n\n".'?>');
231
232 fclose($fh);
233
234 if (function_exists('apc_delete_file'))
235 @apc_delete_file(FORUM_CACHE_DIR.'cache_stopwords.php');
236}
237
238
239//
240// Load some information about the latest registered users
241//
242function generate_users_info_cache()
243{
244 global $db;
245
246 $stats = array();
247
248 $result = $db->query('SELECT COUNT(id)-1 FROM '.$db->prefix.'users WHERE group_id!='.PUN_UNVERIFIED) or error('Unable to fetch total user count', __FILE__, __LINE__, $db->error());
249 $stats['total_users'] = $db->result($result);
250
251 $result = $db->query('SELECT id, username FROM '.$db->prefix.'users WHERE group_id!='.PUN_UNVERIFIED.' ORDER BY registered DESC LIMIT 1') or error('Unable to fetch newest registered user', __FILE__, __LINE__, $db->error());
252 $stats['last_user'] = $db->fetch_assoc($result);
253
254 // Output users info as PHP code
255 $fh = @fopen(FORUM_CACHE_DIR.'cache_users_info.php', 'wb');
256 if (!$fh)
257 error('Unable to write users info cache file to cache directory. Please make sure PHP has write access to the directory \''.pun_htmlspecialchars(FORUM_CACHE_DIR).'\'', __FILE__, __LINE__);
258
259 fwrite($fh, '<?php'."\n\n".'define(\'PUN_USERS_INFO_LOADED\', 1);'."\n\n".'$stats = '.var_export($stats, true).';'."\n\n".'?>');
260
261 fclose($fh);
262
263 if (function_exists('apc_delete_file'))
264 @apc_delete_file(FORUM_CACHE_DIR.'cache_users_info.php');
265}
266
267
268//
269// Delete all feed caches
270//
271function clear_feed_cache()
272{
273 $d = dir(FORUM_CACHE_DIR);
274 while (($entry = $d->read()) !== false)
275 {
276 if (substr($entry, 0, 10) == 'cache_feed' && substr($entry, -4) == '.php')
277 @unlink(FORUM_CACHE_DIR.$entry);
278 }
279 $d->close();
280}
281
156282
157define('FORUM_CACHE_FUNCTIONS_LOADED', true);283define('FORUM_CACHE_FUNCTIONS_LOADED', true);
158284
=== modified file 'include/common.php'
--- include/common.php 2010-10-08 13:18:35 +0000
+++ include/common.php 2011-04-21 10:05:56 +0000
@@ -1,7 +1,7 @@
1<?php1<?php
22
3/**3/**
4 * Copyright (C) 2008-2010 FluxBB4 * Copyright (C) 2008-2011 FluxBB
5 * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB5 * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB
6 * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher6 * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher
7 */7 */
@@ -10,11 +10,11 @@
10 exit('The constant PUN_ROOT must be defined and point to a valid FluxBB installation root directory.');10 exit('The constant PUN_ROOT must be defined and point to a valid FluxBB installation root directory.');
1111
12// Define the version and database revision that this code was written for12// Define the version and database revision that this code was written for
13define('FORUM_VERSION', '1.4.2');13define('FORUM_VERSION', '1.4.5');
1414
15define('FORUM_DB_REVISION', 8);15define('FORUM_DB_REVISION', 11);
16define('FORUM_SI_REVISION', 1);16define('FORUM_SI_REVISION', 2);
17define('FORUM_PARSER_REVISION', 1);17define('FORUM_PARSER_REVISION', 2);
1818
19// Block prefetch requests19// Block prefetch requests
20if (isset($_SERVER['HTTP_X_MOZ']) && $_SERVER['HTTP_X_MOZ'] == 'prefetch')20if (isset($_SERVER['HTTP_X_MOZ']) && $_SERVER['HTTP_X_MOZ'] == 'prefetch')
@@ -38,10 +38,6 @@
38if (defined('FORUM'))38if (defined('FORUM'))
39 define('PUN', FORUM);39 define('PUN', FORUM);
4040
41// If PUN isn't defined, config.php is missing or corrupt
42if (!defined('PUN'))
43 exit('The file \'config.php\' doesn\'t exist or is corrupt. Please run <a href="install.php">install.php</a> to install FluxBB first.');
44
45// Load the functions script41// Load the functions script
46require PUN_ROOT.'include/functions.php';42require PUN_ROOT.'include/functions.php';
4743
@@ -54,6 +50,13 @@
54// Reverse the effect of register_globals50// Reverse the effect of register_globals
55forum_unregister_globals();51forum_unregister_globals();
5652
53// If PUN isn't defined, config.php is missing or corrupt
54if (!defined('PUN'))
55{
56 header('Location: install.php');
57 exit;
58}
59
57// Record the start time (will be used to calculate the generation time for the page)60// Record the start time (will be used to calculate the generation time for the page)
58$pun_start = get_microtime();61$pun_start = get_microtime();
5962
@@ -130,7 +133,10 @@
130 !isset($pun_config['o_searchindex_revision']) || $pun_config['o_searchindex_revision'] < FORUM_SI_REVISION ||133 !isset($pun_config['o_searchindex_revision']) || $pun_config['o_searchindex_revision'] < FORUM_SI_REVISION ||
131 !isset($pun_config['o_parser_revision']) || $pun_config['o_parser_revision'] < FORUM_PARSER_REVISION ||134 !isset($pun_config['o_parser_revision']) || $pun_config['o_parser_revision'] < FORUM_PARSER_REVISION ||
132 version_compare($pun_config['o_cur_version'], FORUM_VERSION, '<'))135 version_compare($pun_config['o_cur_version'], FORUM_VERSION, '<'))
133 exit('Your FluxBB database is out-of-date and must be upgraded in order to continue. Please run <a href="'.PUN_ROOT.'db_update.php">db_update.php</a> in order to complete the upgrade process.');136 {
137 header('Location: db_update.php');
138 exit;
139 }
134140
135// Enable output buffering141// Enable output buffering
136if (!defined('PUN_DISABLE_BUFFERING'))142if (!defined('PUN_DISABLE_BUFFERING'))
@@ -191,3 +197,6 @@
191 define('PUN_SEARCH_MIN_WORD', 3);197 define('PUN_SEARCH_MIN_WORD', 3);
192if (!defined('PUN_SEARCH_MAX_WORD'))198if (!defined('PUN_SEARCH_MAX_WORD'))
193 define('PUN_SEARCH_MAX_WORD', 20);199 define('PUN_SEARCH_MAX_WORD', 20);
200
201if (!defined('FORUM_MAX_COOKIE_SIZE'))
202 define('FORUM_MAX_COOKIE_SIZE', 4048);
194203
=== modified file 'include/common_admin.php'
--- include/common_admin.php 2010-10-08 13:18:35 +0000
+++ include/common_admin.php 2011-04-21 10:05:56 +0000
@@ -1,7 +1,7 @@
1<?php1<?php
22
3/**3/**
4 * Copyright (C) 2008-2010 FluxBB4 * Copyright (C) 2008-2011 FluxBB
5 * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB5 * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB
6 * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher6 * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher
7 */7 */
@@ -33,28 +33,42 @@
33?>33?>
34<div id="adminconsole" class="block2col">34<div id="adminconsole" class="block2col">
35 <div id="adminmenu" class="blockmenu">35 <div id="adminmenu" class="blockmenu">
36 <h2><span><?php echo ($is_admin) ? $lang_admin_common['Admin menu'] : $lang_admin_common['Moderator menu'] ?></span></h2>36 <h2><span><?php echo $lang_admin_common['Moderator menu'] ?></span></h2>
37 <div class="box">37 <div class="box">
38 <div class="inbox">38 <div class="inbox">
39 <ul>39 <ul>
40 <li<?php if ($page == 'index') echo ' class="isactive"'; ?>><a href="admin_index.php"><?php echo $lang_admin_common['Index'] ?></a></li>40 <li<?php if ($page == 'index') echo ' class="isactive"'; ?>><a href="admin_index.php"><?php echo $lang_admin_common['Index'] ?></a></li>
41<?php if ($is_admin): ?> <li<?php if ($page == 'categories') echo ' class="isactive"'; ?>><a href="admin_categories.php"><?php echo $lang_admin_common['Categories'] ?></a></li>41 <li<?php if ($page == 'users') echo ' class="isactive"'; ?>><a href="admin_users.php"><?php echo $lang_admin_common['Users'] ?></a></li>
42<?php endif; ?><?php if ($is_admin): ?> <li<?php if ($page == 'forums') echo ' class="isactive"'; ?>><a href="admin_forums.php"><?php echo $lang_admin_common['Forums'] ?></a></li>42<?php if ($is_admin || $pun_user['g_mod_ban_users'] == '1'): ?> <li<?php if ($page == 'bans') echo ' class="isactive"'; ?>><a href="admin_bans.php"><?php echo $lang_admin_common['Bans'] ?></a></li>
43<?php endif; ?> <li<?php if ($page == 'users') echo ' class="isactive"'; ?>><a href="admin_users.php"><?php echo $lang_admin_common['Users'] ?></a></li>43<?php endif; if ($is_admin || $pun_config['o_report_method'] == '0' || $pun_config['o_report_method'] == '2'): ?> <li<?php if ($page == 'reports') echo ' class="isactive"'; ?>><a href="admin_reports.php"><?php echo $lang_admin_common['Reports'] ?></a></li>
44<?php if ($is_admin): ?> <li<?php if ($page == 'groups') echo ' class="isactive"'; ?>><a href="admin_groups.php"><?php echo $lang_admin_common['User groups'] ?></a></li>44<?php endif; ?> </ul>
45<?php endif; ?><?php if ($is_admin): ?> <li<?php if ($page == 'options') echo ' class="isactive"'; ?>><a href="admin_options.php"><?php echo $lang_admin_common['Options'] ?></a></li>45 </div>
46<?php endif; ?><?php if ($is_admin): ?> <li<?php if ($page == 'permissions') echo ' class="isactive"'; ?>><a href="admin_permissions.php"><?php echo $lang_admin_common['Permissions'] ?></a></li>46 </div>
47<?php endif; ?><?php if ($is_admin || $pun_config['o_censoring'] == '1'): ?> <li<?php if ($page == 'censoring') echo ' class="isactive"'; ?>><a href="admin_censoring.php"><?php echo $lang_admin_common['Censoring'] ?></a></li>47<?php
48<?php endif; ?><?php if ($is_admin): ?> <li<?php if ($page == 'ranks') echo ' class="isactive"'; ?>><a href="admin_ranks.php"><?php echo $lang_admin_common['Ranks'] ?></a></li>48
49<?php endif; ?><?php if ($is_admin || $pun_user['g_mod_ban_users'] == '1'): ?> <li<?php if ($page == 'bans') echo ' class="isactive"'; ?>><a href="admin_bans.php"><?php echo $lang_admin_common['Bans'] ?></a></li>49 if ($is_admin)
50<?php endif; ?><?php if ($is_admin): ?> <li<?php if ($page == 'prune') echo ' class="isactive"'; ?>><a href="admin_prune.php"><?php echo $lang_admin_common['Prune'] ?></a></li>50 {
51<?php endif; ?><?php if ($is_admin): ?> <li<?php if ($page == 'maintenance') echo ' class="isactive"'; ?>><a href="admin_maintenance.php"><?php echo $lang_admin_common['Maintenance'] ?></a></li>51
52<?php endif; ?> <li<?php if ($page == 'reports') echo ' class="isactive"'; ?>><a href="admin_reports.php"><?php echo $lang_admin_common['Reports'] ?></a></li>52?>
53 <h2 class="block2"><span><?php echo $lang_admin_common['Admin menu'] ?></span></h2>
54 <div class="box">
55 <div class="inbox">
56 <ul>
57 <li<?php if ($page == 'options') echo ' class="isactive"'; ?>><a href="admin_options.php"><?php echo $lang_admin_common['Options'] ?></a></li>
58 <li<?php if ($page == 'permissions') echo ' class="isactive"'; ?>><a href="admin_permissions.php"><?php echo $lang_admin_common['Permissions'] ?></a></li>
59 <li<?php if ($page == 'categories') echo ' class="isactive"'; ?>><a href="admin_categories.php"><?php echo $lang_admin_common['Categories'] ?></a></li>
60 <li<?php if ($page == 'forums') echo ' class="isactive"'; ?>><a href="admin_forums.php"><?php echo $lang_admin_common['Forums'] ?></a></li>
61 <li<?php if ($page == 'groups') echo ' class="isactive"'; ?>><a href="admin_groups.php"><?php echo $lang_admin_common['User groups'] ?></a></li>
62 <li<?php if ($page == 'censoring') echo ' class="isactive"'; ?>><a href="admin_censoring.php"><?php echo $lang_admin_common['Censoring'] ?></a></li>
63 <li<?php if ($page == 'ranks') echo ' class="isactive"'; ?>><a href="admin_ranks.php"><?php echo $lang_admin_common['Ranks'] ?></a></li>
64 <li<?php if ($page == 'maintenance') echo ' class="isactive"'; ?>><a href="admin_maintenance.php"><?php echo $lang_admin_common['Maintenance'] ?></a></li>
53 </ul>65 </ul>
54 </div>66 </div>
55 </div>67 </div>
56<?php68<?php
5769
70 }
71
58 // See if there are any plugins72 // See if there are any plugins
59 $plugins = forum_list_plugins($is_admin);73 $plugins = forum_list_plugins($is_admin);
6074
@@ -121,7 +135,7 @@
121 // Delete topics135 // Delete topics
122 $db->query('DELETE FROM '.$db->prefix.'topics WHERE id IN('.$topic_ids.')') or error('Unable to prune topics', __FILE__, __LINE__, $db->error());136 $db->query('DELETE FROM '.$db->prefix.'topics WHERE id IN('.$topic_ids.')') or error('Unable to prune topics', __FILE__, __LINE__, $db->error());
123 // Delete subscriptions137 // Delete subscriptions
124 $db->query('DELETE FROM '.$db->prefix.'subscriptions WHERE topic_id IN('.$topic_ids.')') or error('Unable to prune subscriptions', __FILE__, __LINE__, $db->error());138 $db->query('DELETE FROM '.$db->prefix.'topic_subscriptions WHERE topic_id IN('.$topic_ids.')') or error('Unable to prune subscriptions', __FILE__, __LINE__, $db->error());
125 // Delete posts139 // Delete posts
126 $db->query('DELETE FROM '.$db->prefix.'posts WHERE id IN('.$post_ids.')') or error('Unable to prune posts', __FILE__, __LINE__, $db->error());140 $db->query('DELETE FROM '.$db->prefix.'posts WHERE id IN('.$post_ids.')') or error('Unable to prune posts', __FILE__, __LINE__, $db->error());
127141
128142
=== modified file 'include/dblayer/common_db.php'
--- include/dblayer/common_db.php 2010-10-08 13:18:35 +0000
+++ include/dblayer/common_db.php 2011-04-21 10:05:56 +0000
@@ -1,7 +1,7 @@
1<?php1<?php
22
3/**3/**
4 * Copyright (C) 2008-2010 FluxBB4 * Copyright (C) 2008-2011 FluxBB
5 * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB5 * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB
6 * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher6 * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher
7 */7 */
88
=== modified file 'include/dblayer/mysql.php'
--- include/dblayer/mysql.php 2010-10-08 13:18:35 +0000
+++ include/dblayer/mysql.php 2011-04-21 10:05:56 +0000
@@ -1,7 +1,7 @@
1<?php1<?php
22
3/**3/**
4 * Copyright (C) 2008-2010 FluxBB4 * Copyright (C) 2008-2011 FluxBB
5 * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB5 * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB
6 * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher6 * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher
7 */7 */
@@ -230,7 +230,7 @@
230 $result = $this->query('SHOW INDEX FROM '.($no_prefix ? '' : $this->prefix).$table_name);230 $result = $this->query('SHOW INDEX FROM '.($no_prefix ? '' : $this->prefix).$table_name);
231 while ($cur_index = $this->fetch_assoc($result))231 while ($cur_index = $this->fetch_assoc($result))
232 {232 {
233 if ($cur_index['Key_name'] == ($no_prefix ? '' : $this->prefix).$table_name.'_'.$index_name)233 if (strtolower($cur_index['Key_name']) == strtolower(($no_prefix ? '' : $this->prefix).$table_name.'_'.$index_name))
234 {234 {
235 $exists = true;235 $exists = true;
236 break;236 break;
@@ -301,6 +301,16 @@
301 }301 }
302302
303303
304 function rename_table($old_table, $new_table, $no_prefix = false)
305 {
306 // If there new table exists and the old one doesn't, then we're happy
307 if ($this->table_exists($new_table, $no_prefix) && !$this->table_exists($old_table, $no_prefix))
308 return true;
309
310 return $this->query('ALTER TABLE '.($no_prefix ? '' : $this->prefix).$old_table.' RENAME TO '.($no_prefix ? '' : $this->prefix).$new_table) ? true : false;
311 }
312
313
304 function add_field($table_name, $field_name, $field_type, $allow_null, $default_value = null, $after_field = null, $no_prefix = false)314 function add_field($table_name, $field_name, $field_type, $allow_null, $default_value = null, $after_field = null, $no_prefix = false)
305 {315 {
306 if ($this->field_exists($table_name, $field_name, $no_prefix))316 if ($this->field_exists($table_name, $field_name, $no_prefix))
307317
=== modified file 'include/dblayer/mysql_innodb.php'
--- include/dblayer/mysql_innodb.php 2010-10-08 13:18:35 +0000
+++ include/dblayer/mysql_innodb.php 2011-04-21 10:05:56 +0000
@@ -1,7 +1,7 @@
1<?php1<?php
22
3/**3/**
4 * Copyright (C) 2008-2010 FluxBB4 * Copyright (C) 2008-2011 FluxBB
5 * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB5 * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB
6 * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher6 * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher
7 */7 */
@@ -244,7 +244,7 @@
244 $result = $this->query('SHOW INDEX FROM '.($no_prefix ? '' : $this->prefix).$table_name);244 $result = $this->query('SHOW INDEX FROM '.($no_prefix ? '' : $this->prefix).$table_name);
245 while ($cur_index = $this->fetch_assoc($result))245 while ($cur_index = $this->fetch_assoc($result))
246 {246 {
247 if ($cur_index['Key_name'] == ($no_prefix ? '' : $this->prefix).$table_name.'_'.$index_name)247 if (strtolower($cur_index['Key_name']) == strtolower(($no_prefix ? '' : $this->prefix).$table_name.'_'.$index_name))
248 {248 {
249 $exists = true;249 $exists = true;
250 break;250 break;
@@ -315,6 +315,16 @@
315 }315 }
316316
317317
318 function rename_table($old_table, $new_table, $no_prefix = false)
319 {
320 // If there new table exists and the old one doesn't, then we're happy
321 if ($this->table_exists($new_table, $no_prefix) && !$this->table_exists($old_table, $no_prefix))
322 return true;
323
324 return $this->query('ALTER TABLE '.($no_prefix ? '' : $this->prefix).$old_table.' RENAME TO '.($no_prefix ? '' : $this->prefix).$new_table) ? true : false;
325 }
326
327
318 function add_field($table_name, $field_name, $field_type, $allow_null, $default_value = null, $after_field = null, $no_prefix = false)328 function add_field($table_name, $field_name, $field_type, $allow_null, $default_value = null, $after_field = null, $no_prefix = false)
319 {329 {
320 if ($this->field_exists($table_name, $field_name, $no_prefix))330 if ($this->field_exists($table_name, $field_name, $no_prefix))
321331
=== modified file 'include/dblayer/mysqli.php'
--- include/dblayer/mysqli.php 2010-10-08 13:18:35 +0000
+++ include/dblayer/mysqli.php 2011-04-21 10:05:56 +0000
@@ -1,7 +1,7 @@
1<?php1<?php
22
3/**3/**
4 * Copyright (C) 2008-2010 FluxBB4 * Copyright (C) 2008-2011 FluxBB
5 * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB5 * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB
6 * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher6 * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher
7 */7 */
@@ -237,7 +237,7 @@
237 $result = $this->query('SHOW INDEX FROM '.($no_prefix ? '' : $this->prefix).$table_name);237 $result = $this->query('SHOW INDEX FROM '.($no_prefix ? '' : $this->prefix).$table_name);
238 while ($cur_index = $this->fetch_assoc($result))238 while ($cur_index = $this->fetch_assoc($result))
239 {239 {
240 if ($cur_index['Key_name'] == ($no_prefix ? '' : $this->prefix).$table_name.'_'.$index_name)240 if (strtolower($cur_index['Key_name']) == strtolower(($no_prefix ? '' : $this->prefix).$table_name.'_'.$index_name))
241 {241 {
242 $exists = true;242 $exists = true;
243 break;243 break;
@@ -308,6 +308,16 @@
308 }308 }
309309
310310
311 function rename_table($old_table, $new_table, $no_prefix = false)
312 {
313 // If there new table exists and the old one doesn't, then we're happy
314 if ($this->table_exists($new_table, $no_prefix) && !$this->table_exists($old_table, $no_prefix))
315 return true;
316
317 return $this->query('ALTER TABLE '.($no_prefix ? '' : $this->prefix).$old_table.' RENAME TO '.($no_prefix ? '' : $this->prefix).$new_table) ? true : false;
318 }
319
320
311 function add_field($table_name, $field_name, $field_type, $allow_null, $default_value = null, $after_field = null, $no_prefix = false)321 function add_field($table_name, $field_name, $field_type, $allow_null, $default_value = null, $after_field = null, $no_prefix = false)
312 {322 {
313 if ($this->field_exists($table_name, $field_name, $no_prefix))323 if ($this->field_exists($table_name, $field_name, $no_prefix))
314324
=== modified file 'include/dblayer/mysqli_innodb.php'
--- include/dblayer/mysqli_innodb.php 2010-10-08 13:18:35 +0000
+++ include/dblayer/mysqli_innodb.php 2011-04-21 10:05:56 +0000
@@ -1,7 +1,7 @@
1<?php1<?php
22
3/**3/**
4 * Copyright (C) 2008-2010 FluxBB4 * Copyright (C) 2008-2011 FluxBB
5 * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB5 * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB
6 * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher6 * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher
7 */7 */
@@ -250,7 +250,7 @@
250 $result = $this->query('SHOW INDEX FROM '.($no_prefix ? '' : $this->prefix).$table_name);250 $result = $this->query('SHOW INDEX FROM '.($no_prefix ? '' : $this->prefix).$table_name);
251 while ($cur_index = $this->fetch_assoc($result))251 while ($cur_index = $this->fetch_assoc($result))
252 {252 {
253 if ($cur_index['Key_name'] == ($no_prefix ? '' : $this->prefix).$table_name.'_'.$index_name)253 if (strtolower($cur_index['Key_name']) == strtolower(($no_prefix ? '' : $this->prefix).$table_name.'_'.$index_name))
254 {254 {
255 $exists = true;255 $exists = true;
256 break;256 break;
@@ -321,6 +321,16 @@
321 }321 }
322322
323323
324 function rename_table($old_table, $new_table, $no_prefix = false)
325 {
326 // If there new table exists and the old one doesn't, then we're happy
327 if ($this->table_exists($new_table, $no_prefix) && !$this->table_exists($old_table, $no_prefix))
328 return true;
329
330 return $this->query('ALTER TABLE '.($no_prefix ? '' : $this->prefix).$old_table.' RENAME TO '.($no_prefix ? '' : $this->prefix).$new_table) ? true : false;
331 }
332
333
324 function add_field($table_name, $field_name, $field_type, $allow_null, $default_value = null, $after_field = null, $no_prefix = false)334 function add_field($table_name, $field_name, $field_type, $allow_null, $default_value = null, $after_field = null, $no_prefix = false)
325 {335 {
326 if ($this->field_exists($table_name, $field_name, $no_prefix))336 if ($this->field_exists($table_name, $field_name, $no_prefix))
327337
=== modified file 'include/dblayer/pgsql.php'
--- include/dblayer/pgsql.php 2010-10-08 13:18:35 +0000
+++ include/dblayer/pgsql.php 2011-04-21 10:05:56 +0000
@@ -1,7 +1,7 @@
1<?php1<?php
22
3/**3/**
4 * Copyright (C) 2008-2010 FluxBB4 * Copyright (C) 2008-2011 FluxBB
5 * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB5 * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB
6 * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher6 * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher
7 */7 */
@@ -352,6 +352,16 @@
352 }352 }
353353
354354
355 function rename_table($old_table, $new_table, $no_prefix = false)
356 {
357 // If there new table exists and the old one doesn't, then we're happy
358 if ($this->table_exists($new_table, $no_prefix) && !$this->table_exists($old_table, $no_prefix))
359 return true;
360
361 return $this->query('ALTER TABLE '.($no_prefix ? '' : $this->prefix).$old_table.' RENAME TO '.($no_prefix ? '' : $this->prefix).$new_table) ? true : false;
362 }
363
364
355 function add_field($table_name, $field_name, $field_type, $allow_null, $default_value = null, $after_field = null, $no_prefix = false)365 function add_field($table_name, $field_name, $field_type, $allow_null, $default_value = null, $after_field = null, $no_prefix = false)
356 {366 {
357 if ($this->field_exists($table_name, $field_name, $no_prefix))367 if ($this->field_exists($table_name, $field_name, $no_prefix))
358368
=== modified file 'include/dblayer/sqlite.php'
--- include/dblayer/sqlite.php 2010-10-08 13:18:35 +0000
+++ include/dblayer/sqlite.php 2011-04-21 10:05:56 +0000
@@ -1,7 +1,7 @@
1<?php1<?php
22
3/**3/**
4 * Copyright (C) 2008-2010 FluxBB4 * Copyright (C) 2008-2011 FluxBB
5 * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB5 * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB
6 * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher6 * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher
7 */7 */
@@ -182,7 +182,7 @@
182182
183 function affected_rows()183 function affected_rows()
184 {184 {
185 return ($this->query_result) ? @sqlite_changes($this->query_result) : false;185 return ($this->link_id) ? @sqlite_changes($this->link_id) : false;
186 }186 }
187187
188188
@@ -349,6 +349,35 @@
349 }349 }
350350
351351
352 function rename_table($old_name, $new_name, $no_prefix = false)
353 {
354 // If there new table exists and the old one doesn't, then we're happy
355 if ($this->table_exists($new_table, $no_prefix) && !$this->table_exists($old_table, $no_prefix))
356 return true;
357
358 $table = $this->get_table_info($old_name, $no_prefix);
359
360 // Create new table
361 $newtable = str_replace('CREATE TABLE '.($no_prefix ? '' : $this->prefix).$this->escape($old_name).' (', 'CREATE TABLE '.($no_prefix ? '' : $this->prefix).$this->escape($new_name).' (', $table['sql']);
362 $result = $this->query($newtable) ? true : false;
363
364 // Recreate indexes
365 if (!empty($table['indices']))
366 {
367 foreach ($table['indices'] as $cur_index)
368 $result &= $this->query($cur_index) ? true : false;
369 }
370
371 // Copy content across
372 $result &= $this->query('INSERT INTO '.($no_prefix ? '' : $this->prefix).$this->escape($new_name).' SELECT * FROM '.($no_prefix ? '' : $this->prefix).$this->escape($old_name)) ? true : false;
373
374 // Drop old table
375 $result &= $this->drop_table(($no_prefix ? '' : $this->prefix).$this->escape($table_name));
376
377 return $result;
378 }
379
380
352 function get_table_info($table_name, $no_prefix = false)381 function get_table_info($table_name, $no_prefix = false)
353 {382 {
354 // Grab table info383 // Grab table info
355384
=== modified file 'include/email.php'
--- include/email.php 2010-10-08 13:18:35 +0000
+++ include/email.php 2011-04-21 10:05:56 +0000
@@ -1,7 +1,7 @@
1<?php1<?php
22
3/**3/**
4 * Copyright (C) 2008-2010 FluxBB4 * Copyright (C) 2008-2011 FluxBB
5 * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB5 * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB
6 * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher6 * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher
7 */7 */
@@ -10,6 +10,7 @@
10if (!defined('PUN'))10if (!defined('PUN'))
11 exit;11 exit;
1212
13require PUN_ROOT.'include/utf8/utils/ascii.php';
1314
14//15//
15// Validate an email address16// Validate an email address
@@ -43,6 +44,18 @@
4344
4445
45//46//
47// Only encode with base64, if there is at least one unicode character in the string
48//
49function encode_mail_text($str)
50{
51 if (utf8_is_ascii($str))
52 return $str;
53
54 return '=?UTF-8?B?'.base64_encode($str).'?=';
55}
56
57
58//
46// Wrapper for PHP's mail()59// Wrapper for PHP's mail()
47//60//
48function pun_mail($to, $subject, $message, $reply_to_email = '', $reply_to_name = '')61function pun_mail($to, $subject, $message, $reply_to_email = '', $reply_to_name = '')
@@ -62,15 +75,15 @@
62 $reply_to_name = pun_trim(preg_replace('#[\n\r:]+#s', '', str_replace('"', '', $reply_to_name)));75 $reply_to_name = pun_trim(preg_replace('#[\n\r:]+#s', '', str_replace('"', '', $reply_to_name)));
6376
64 // Set up some headers to take advantage of UTF-877 // Set up some headers to take advantage of UTF-8
65 $from = "=?UTF-8?B?".base64_encode($from_name)."?=".' <'.$from_email.'>';78 $from = encode_mail_text($from_name).' <'.$from_email.'>';
66 $subject = "=?UTF-8?B?".base64_encode($subject)."?=";79 $subject = encode_mail_text($subject);
6780
68 $headers = 'From: '.$from."\r\n".'Date: '.gmdate('r')."\r\n".'MIME-Version: 1.0'."\r\n".'Content-transfer-encoding: 8bit'."\r\n".'Content-type: text/plain; charset=utf-8'."\r\n".'X-Mailer: FluxBB Mailer';81 $headers = 'From: '.$from."\r\n".'Date: '.gmdate('r')."\r\n".'MIME-Version: 1.0'."\r\n".'Content-transfer-encoding: 8bit'."\r\n".'Content-type: text/plain; charset=utf-8'."\r\n".'X-Mailer: FluxBB Mailer';
6982
70 // If we specified a reply-to email, we deal with it here83 // If we specified a reply-to email, we deal with it here
71 if (!empty($reply_to_email))84 if (!empty($reply_to_email))
72 {85 {
73 $reply_to = "=?UTF-8?B?".base64_encode($reply_to_name)."?=".' <'.$reply_to_email.'>';86 $reply_to = encode_mail_text($reply_to_name).' <'.$reply_to_email.'>';
7487
75 $headers .= "\r\n".'Reply-To: '.$reply_to;88 $headers .= "\r\n".'Reply-To: '.$reply_to;
76 }89 }
7790
=== modified file 'include/functions.php'
--- include/functions.php 2011-04-18 14:00:54 +0000
+++ include/functions.php 2011-04-21 10:05:56 +0000
@@ -1,7 +1,7 @@
1<?php1<?php
22
3/**3/**
4 * Copyright (C) 2008-2010 FluxBB4 * Copyright (C) 2008-2011 FluxBB
5 * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB5 * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB
6 * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher6 * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher
7 */7 */
@@ -25,31 +25,46 @@
2525
26 $now = time();26 $now = time();
2727
28 // We assume it's a guest28 // If the cookie is set and it matches the correct pattern, then read the values from it
29 $cookie = array('user_id' => 1, 'password_hash' => 'Guest');29 if (isset($_COOKIE[$cookie_name]) && preg_match('/^(\d+)\|([0-9a-fA-F]+)\|(\d+)\|([0-9a-fA-F]+)$/', $_COOKIE[$cookie_name], $matches))
3030 {
31 // If a cookie is set, we get the user_id and password hash from it31 $cookie = array(
32 if (isset($_COOKIE[$cookie_name]))32 'user_id' => intval($matches[1]),
33 list($cookie['user_id'], $cookie['password_hash'], $cookie['expiration_time']) = @unserialize($_COOKIE[$cookie_name]);33 'password_hash' => $matches[2],
3434 'expiration_time' => intval($matches[3]),
35 if ($cookie['user_id'] > 1)35 'cookie_hash' => $matches[4],
36 {36 );
37 }
38
39 // If it has a non-guest user, and hasn't expired
40 if (isset($cookie) && $cookie['user_id'] > 1 && $cookie['expiration_time'] > $now)
41 {
42 // If the cookie has been tampered with
43 if (forum_hmac($cookie['user_id'].'|'.$cookie['expiration_time'], $cookie_seed.'_cookie_hash') != $cookie['cookie_hash'])
44 {
45 $expire = $now + 31536000; // The cookie expires after a year
46 pun_setcookie(1, pun_hash(uniqid(rand(), true)), $expire);
47 set_default_user();
48
49 return;
50 }
51
37 // Check if there's a user with the user ID and password hash from the cookie52 // Check if there's a user with the user ID and password hash from the cookie
38 $result = $db->query('SELECT u.*, g.*, o.logged, o.idle FROM '.$db->prefix.'users AS u INNER JOIN '.$db->prefix.'groups AS g ON u.group_id=g.g_id LEFT JOIN '.$db->prefix.'online AS o ON o.user_id=u.id WHERE u.id='.intval($cookie['user_id'])) or error('Unable to fetch user information', __FILE__, __LINE__, $db->error());53 $result = $db->query('SELECT u.*, g.*, o.logged, o.idle FROM '.$db->prefix.'users AS u INNER JOIN '.$db->prefix.'groups AS g ON u.group_id=g.g_id LEFT JOIN '.$db->prefix.'online AS o ON o.user_id=u.id WHERE u.id='.intval($cookie['user_id'])) or error('Unable to fetch user information', __FILE__, __LINE__, $db->error());
39 $pun_user = $db->fetch_assoc($result);54 $pun_user = $db->fetch_assoc($result);
4055
41 // If user authorisation failed56 // If user authorisation failed
42 if (!isset($pun_user['id']) || md5($cookie_seed.$pun_user['password']) !== $cookie['password_hash'])57 if (!isset($pun_user['id']) || forum_hmac($pun_user['password'], $cookie_seed.'_password_hash') !== $cookie['password_hash'])
43 {58 {
44 $expire = $now + 31536000; // The cookie expires after a year59 $expire = $now + 31536000; // The cookie expires after a year
45 pun_setcookie(1, md5(uniqid(rand(), true)), $expire);60 pun_setcookie(1, pun_hash(uniqid(rand(), true)), $expire);
46 set_default_user();61 set_default_user();
4762
48 return;63 return;
49 }64 }
5065
51 // Send a new, updated cookie with a new expiration timestamp66 // Send a new, updated cookie with a new expiration timestamp
52 $expire = (intval($cookie['expiration_time']) > $now + $pun_config['o_timeout_visit']) ? $now + 1209600 : $now + $pun_config['o_timeout_visit'];67 $expire = ($cookie['expiration_time'] > $now + $pun_config['o_timeout_visit']) ? $now + 1209600 : $now + $pun_config['o_timeout_visit'];
53 pun_setcookie($pun_user['id'], $pun_user['password'], $expire);68 pun_setcookie($pun_user['id'], $pun_user['password'], $expire);
5469
55 // Set a default language if the user selected language no longer exists70 // Set a default language if the user selected language no longer exists
@@ -159,10 +174,10 @@
159//174//
160function get_current_url($max_length = 0)175function get_current_url($max_length = 0)
161{176{
162 $protocol = (!isset($_SERVER['HTTPS']) || strtolower($_SERVER['HTTPS']) == 'off') ? 'http://' : 'https://';177 $protocol = get_current_protocol();
163 $port = (isset($_SERVER['SERVER_PORT']) && (($_SERVER['SERVER_PORT'] != '80' && $protocol == 'http://') || ($_SERVER['SERVER_PORT'] != '443' && $protocol == 'https://')) && strpos($_SERVER['HTTP_HOST'], ':') === false) ? ':'.$_SERVER['SERVER_PORT'] : '';178 $port = (isset($_SERVER['SERVER_PORT']) && (($_SERVER['SERVER_PORT'] != '80' && $protocol == 'http') || ($_SERVER['SERVER_PORT'] != '443' && $protocol == 'https')) && strpos($_SERVER['HTTP_HOST'], ':') === false) ? ':'.$_SERVER['SERVER_PORT'] : '';
164179
165 $url = urldecode($protocol.$_SERVER['HTTP_HOST'].$port.$_SERVER['REQUEST_URI']);180 $url = urldecode($protocol.'://'.$_SERVER['HTTP_HOST'].$port.$_SERVER['REQUEST_URI']);
166181
167 if (strlen($url) <= $max_length || $max_length == 0)182 if (strlen($url) <= $max_length || $max_length == 0)
168 return $url;183 return $url;
@@ -173,6 +188,53 @@
173188
174189
175//190//
191// Fetch the current protocol in use - http or https
192//
193function get_current_protocol()
194{
195 $protocol = 'http';
196
197 // Check if the server is claiming to using HTTPS
198 if (!empty($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) != 'off')
199 $protocol = 'https';
200
201 // If we are behind a reverse proxy try to decide which protocol it is using
202 if (defined('FORUM_BEHIND_REVERSE_PROXY'))
203 {
204 // Check if we are behind a Microsoft based reverse proxy
205 if (!empty($_SERVER['HTTP_FRONT_END_HTTPS']) && strtolower($_SERVER['HTTP_FRONT_END_HTTPS']) != 'off')
206 $protocol = 'https';
207
208 // Check if we're behind a "proper" reverse proxy, and what protocol it's using
209 if (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']))
210 $protocol = strtolower($_SERVER['HTTP_X_FORWARDED_PROTO']);
211 }
212
213 return $protocol;
214}
215
216//
217// Fetch the base_url, optionally support HTTPS and HTTP
218//
219function get_base_url($support_https = false)
220{
221 global $pun_config;
222 static $base_url;
223
224 if (!$support_https)
225 return $pun_config['o_base_url'];
226
227 if (!isset($base_url))
228 {
229 // Make sure we are using the correct protocol
230 $base_url = str_replace(array('http://', 'https://'), get_current_protocol().'://', $pun_config['o_base_url']);
231 }
232
233 return $base_url;
234}
235
236
237//
176// Fill $pun_user with default values (for guests)238// Fill $pun_user with default values (for guests)
177//239//
178function set_default_user()240function set_default_user()
@@ -224,6 +286,41 @@
224286
225287
226//288//
289// SHA1 HMAC with PHP 4 fallback
290//
291function forum_hmac($data, $key, $raw_output = false)
292{
293 if (function_exists('hash_hmac'))
294 return hash_hmac('sha1', $data, $key, $raw_output);
The diff has been truncated for viewing.

Subscribers

People subscribed via source and target branches