diff --git a/phpBB/adm/admin_forums.php b/phpBB/adm/admin_forums.php index 9ea4d9aa0c..b3152ee10a 100644 --- a/phpBB/adm/admin_forums.php +++ b/phpBB/adm/admin_forums.php @@ -82,6 +82,9 @@ switch ($mode) $enable_prune = (!empty($_POST['enable_prune'])) ? 1 : 0; $prune_days = (isset($_POST['prune_days'])) ? intval($_POST['prune_days']) : 7; $prune_freq = (isset($_POST['prune_freq'])) ? intval($_POST['prune_freq']) : 1; + $prune_old_polls = (!empty($_POST['prune_old_polls'])) ? 1 : 0; + $prune_announce = (!empty($_POST['prune_announce'])) ? 1 : 0; + $prune_sticky = (!empty($_POST['prune_sticky'])) ? 1 : 0; $forum_password = (isset($_POST['forum_password'])) ? htmlspecialchars(stripslashes($_POST['forum_password'])) : ''; $forum_password_confirm = (isset($_POST['forum_password_confirm'])) ? htmlspecialchars(stripslashes($_POST['forum_password_confirm'])) : ''; @@ -106,6 +109,17 @@ switch ($mode) $error[] = $user->lang['FORUM_DATA_NEGATIVE']; } + // Set forum flags + // 1 = link tracking + // 2 = prune old polls + // 4 = prune announcements + // 8 = prune stickies + $forum_flags = 0; + $forum_flags += ($forum_link_track) ? 1 : 0; + $forum_flags += ($prune_old_polls) ? 2 : 0; + $forum_flags += ($prune_announce) ? 4 : 0; + $forum_flags += ($prune_sticky) ? 8 : 0; + // What are we going to do tonight Brain? The same thing we do everynight, // try to take over the world ... or decide whether to continue update // and if so, whether it's a new forum/cat/link or an existing one @@ -166,12 +180,12 @@ switch ($mode) 'forum_type' => (int) $forum_type, 'forum_status' => (int) $forum_status, 'forum_link' => (string) $forum_link, - 'forum_link_track' => (int) $forum_link_track, 'forum_password' => (string) $forum_password, 'forum_topics_per_page' => (int) $forum_topics_per_page, 'forum_style' => (int) $forum_style, 'forum_image' => (string) $forum_image, 'display_on_index' => (int) $display_on_index, + 'forum_flags' => (int) $forum_flags, 'enable_icons' => (int) $enable_icons, 'enable_prune' => (int) $enable_prune, 'prune_days' => (int) $prune_days, @@ -229,12 +243,12 @@ switch ($mode) 'forum_type' => (int) $forum_type, 'forum_status' => (int) $forum_status, 'forum_link' => (string) $forum_link, - 'forum_link_track' => (int) $forum_link_track, 'forum_topics_per_page' => (int) $forum_topics_per_page, 'forum_password' => (string) $forum_password, 'forum_style' => (int) $forum_style, 'forum_image' => (string) $forum_image, 'display_on_index' => (int) $display_on_index, + 'forum_flags' => (int) $forum_flags, 'enable_icons' => (int) $enable_icons, 'enable_prune' => (int) $enable_prune, 'prune_days' => (int) $prune_days, @@ -305,17 +319,24 @@ switch ($mode) $statuslist = ''; - $topic_icons_yes = ($enable_icons) ? 'checked="checked"' : ''; - $topic_icons_no = (!$enable_icons) ? 'checked="checked"' : ''; + $topic_icons_yes = ($enable_icons) ? ' checked="checked"' : ''; + $topic_icons_no = (!$enable_icons) ? ' checked="checked"' : ''; - $display_index_yes = ($display_on_index) ? 'checked="checked"' : ''; - $display_index_no = (!$display_on_index) ? 'checked="checked"' : ''; + $display_index_yes = ($display_on_index) ? ' checked="checked"' : ''; + $display_index_no = (!$display_on_index) ? ' checked="checked"' : ''; - $prune_enable_yes = ($prune_enabled) ? 'checked="checked"' : ''; - $prune_enable_no = (!$prune_enabled) ? 'checked="checked"' : ''; + $prune_enable_yes = ($enable_prune) ? ' checked="checked"' : ''; + $prune_enable_no = (!$enable_prune) ? ' checked="checked"' : ''; - $forum_link_track_yes = ($forum_link_track) ? 'checked="checked"' : ''; - $forum_link_track_no = (!$forum_link_track) ? 'checked="checked"' : ''; + $prune_old_polls_yes = ($forum_flags & 2) ? ' checked="checked"' : ''; + $prune_old_polls_no = (!($forum_flags & 2)) ? ' checked="checked"' : ''; + $prune_announce_yes = ($forum_flags & 4) ? ' checked="checked"' : ''; + $prune_announce_no = (!($forum_flags & 4)) ? ' checked="checked"' : ''; + $prune_sticky_yes = ($forum_flags & 8) ? ' checked="checked"' : ''; + $prune_sticky_no = (!($forum_flags & 8)) ? ' checked="checked"' : ''; + + $forum_link_track_yes = ($forum_flags & 1) ? ' checked="checked"' : ''; + $forum_link_track_no = (!($forum_flags & 1)) ? ' checked="checked"' : ''; $navigation = '' . $user->lang['FORUM_INDEX'] . ''; @@ -479,6 +500,18 @@ switch ($mode) lang['AUTO_PRUNE_DAYS'] ?>:
lang['AUTO_PRUNE_DAYS_EXPLAIN']; ?> lang['DAYS']; ?> + + lang['PRUNE_OLD_POLLS'] ?>:
lang['PRUNE_OLD_POLLS_EXPLAIN']; ?> + /> lang['YES']; ?>   /> lang['NO']; ?> + + + lang['PRUNE_ANNOUNCEMENTS'] ?>: + /> lang['YES']; ?>   /> lang['NO']; ?> + + + lang['PRUNE_STICKY'] ?>: + /> lang['YES']; ?>   /> lang['NO']; ?> + lang['FORUM_TOPICS_PAGE'] ?>:
lang['FORUM_TOPICS_PAGE_EXPLAIN']; ?> diff --git a/phpBB/adm/admin_prune.php b/phpBB/adm/admin_prune.php index 8593625f0f..275ffb71a4 100644 --- a/phpBB/adm/admin_prune.php +++ b/phpBB/adm/admin_prune.php @@ -44,7 +44,7 @@ if (!$auth->acl_get('a_prune')) } // Get the forum ID for pruning -$forum_id = (isset($_REQUEST['f'])) ? intval($_REQUEST['f']) : -1; +$forum_id = (isset($_REQUEST['f'])) ? intval($_REQUEST['f']) : 0; // Check for submit to be equal to Prune. If so then proceed with the pruning. if (isset($_POST['doprune'])) @@ -140,20 +140,23 @@ adm_page_header($user->lang['PRUNE']); // If they haven't selected a forum for pruning yet then // display a select box to use for pruning. -if ($forum_id == -1) +if (!$forum_id) { // Output a selection table if no forum id has been specified. - $select_list = '' . make_forum_select(false, false, false); + $select_list = make_forum_select(false, false, false); ?> -
+">
- + + + +
lang['SELECT_FORUM']; ?>
    
@@ -176,15 +179,28 @@ else

lang['FORUM'] . ': ' . $forum_name; ?>

-
+">
- + - + + - + + + + + + + + + + + + +
lang['FORUM_PRUNE']; ?>lang['FORUM_PRUNE']; ?>
lang['PRUNE_NOT_POSTED'], ''); ?>lang['PRUNE_NOT_POSTED']; ?>
lang['PRUNE_OLD_POLLS'] ?>:
lang['PRUNE_OLD_POLLS_EXPLAIN']; ?>
lang['YES']; ?>   lang['NO']; ?>
lang['PRUNE_ANNOUNCEMENTS'] ?>: lang['YES']; ?>   lang['NO']; ?>
lang['PRUNE_STICKY'] ?>: lang['YES']; ?>   lang['NO']; ?>
diff --git a/phpBB/common.php b/phpBB/common.php index 926c692c86..c1524004dc 100644 --- a/phpBB/common.php +++ b/phpBB/common.php @@ -144,6 +144,7 @@ define('FORUMS_WATCH_TABLE', $table_prefix.'forums_watch'); define('GROUPS_TABLE', $table_prefix.'groups'); define('GROUPS_MODERATOR_TABLE', $table_prefix.'groups_moderator'); define('ICONS_TABLE', $table_prefix.'icons'); +define('LANG_TABLE', $table_prefix.'lang'); define('LOG_ADMIN_TABLE', $table_prefix.'log_admin'); define('LOG_MOD_TABLE', $table_prefix.'log_moderator'); define('MODERATOR_TABLE', $table_prefix.'moderator_cache'); diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 1e72f42fc4..4f8aca41e7 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -337,7 +337,7 @@ function make_jumpbox($action, $forum_id = false, $select_all = false) function language_select($default = '') { global $db, $phpbb_root_path, $phpEx; -/* + $sql = "SELECT lang_iso, lang_local_name FROM " . LANG_TABLE . " ORDER BY lang_english_name"; @@ -352,37 +352,6 @@ function language_select($default = '') $db->sql_freeresult($result); return $lang_options; -*/ - $dir = @opendir($phpbb_root_path . 'language'); - - $user = array(); - while ($file = readdir($dir)) - { - $path = $phpbb_root_path . 'language/' . $file; - - if (is_file($path) || is_link($path) || $file == '.' || $file == '..') - { - continue; - } - - if (file_exists($path . '/iso.txt')) - { - list($displayname) = @file($path . '/iso.txt'); - $lang[$displayname] = $file; - } - } - @closedir($dir); - - @asort($lang); - @reset($lang); - - foreach ($lang as $displayname => $filename) - { - $selected = (strtolower($default) == strtolower($filename)) ? ' selected="selected"' : ''; - $user_select .= ''; - } - - return $user_select; } // Pick a template/theme combo, diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index c14f105f41..4760e88905 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -1059,22 +1059,26 @@ function verify_data($type, $fieldname, &$need_update, &$data) } } -function prune($forum_id, $prune_date = '', $auto_sync = TRUE) +function prune($forum_id, $prune_date, $prune_flags = 0, $auto_sync = true) { global $db; - // Those without polls ... - // NOTE: can't remember why only those without polls :) -- Ashe + $sql_and = ''; + if (!($prune_flags & 4)) + { + $sql_and .= ' AND topic_type <> ' . POST_ANNOUNCE; + } + if (!($prune_flags & 8)) + { + $sql_and .= ' AND topic_type <> ' . POST_STICKY; + } + $sql = 'SELECT topic_id FROM ' . TOPICS_TABLE . " - WHERE t.forum_id = $forum_id - AND poll_start = 0 - AND t.topic_type <> " . POST_ANNOUNCE; - - if ($prune_date != '') - { - $sql .= ' AND topic_last_post_time < ' . $prune_date; - } + WHERE forum_id = $forum_id + AND topic_last_post_time < $prune_date + AND poll_start = 0 + $sql_and"; $result = $db->sql_query($sql); $topic_list = array(); @@ -1084,18 +1088,40 @@ function prune($forum_id, $prune_date = '', $auto_sync = TRUE) } $db->sql_freeresult($result); + if ($prune_flags & 2) + { + $sql = 'SELECT topic_id + FROM ' . TOPICS_TABLE . " + WHERE forum_id = $forum_id + AND poll_start > 0 + AND poll_last_vote < $prune_date + AND topic_last_post_time < $prune_date + $sql_and"; + $result = $db->sql_query($sql); + + while ($row = $db->sql_fetchrow($result)) + { + $topic_list[] = $row['topic_id']; + } + $db->sql_freeresult($result); + + $topic_list = array_unique($topic_list); + } + return delete_topics('topic_id', $topic_list, $auto_sync); } // Function auto_prune(), this function now relies on passed vars -function auto_prune($forum_id, $prune_days, $prune_freq) +function auto_prune($forum_id, $prune_flags, $prune_days, $prune_freq) { + global $db; + $prune_date = time() - ($prune_days * 86400); $next_prune = time() + ($prune_freq * 86400); - prune($forum_id, $prune_date); + prune($forum_id, $prune_date, $prune_flags, true); - $sql = "UPDATE " . FORUMS_TABLE . " + $sql = 'UPDATE ' . FORUMS_TABLE . " SET prune_next = $next_prune WHERE forum_id = $forum_id"; $db->sql_query($sql); diff --git a/phpBB/includes/session.php b/phpBB/includes/session.php index 9f350c868e..ee234922d0 100644 --- a/phpBB/includes/session.php +++ b/phpBB/includes/session.php @@ -289,12 +289,12 @@ class session $SID = '?sid='; // Delete existing session, update last visit info first! - $sql = "UPDATE " . USERS_TABLE . " - SET user_lastvisit = " . intval($this->data['session_time']) . " - WHERE user_id = " . $this->data['user_id']; + $sql = 'UPDATE ' . USERS_TABLE . ' + SET user_lastvisit = ' . $this->data['session_time'] . ' + WHERE user_id = ' . $this->data['user_id']; $db->sql_query($sql); - $sql = "DELETE FROM " . SESSIONS_TABLE . " + $sql = 'DELETE FROM ' . SESSIONS_TABLE . " WHERE session_id = '" . $this->session_id . "' AND session_user_id = " . $this->data['user_id']; $db->sql_query($sql); @@ -310,10 +310,10 @@ class session global $db, $config; // Get expired sessions, only most recent for each user - $sql = "SELECT session_user_id, session_page, MAX(session_time) AS recent_time - FROM " . SESSIONS_TABLE . " - WHERE session_time < " . ($current_time - $config['session_length']) . " - GROUP BY session_user_id, session_page"; + $sql = 'SELECT session_user_id, session_page, MAX(session_time) AS recent_time + FROM ' . SESSIONS_TABLE . ' + WHERE session_time < ' . ($current_time - $config['session_length']) . ' + GROUP BY session_user_id, session_page'; $result = $db->sql_query_limit($sql, 5); $del_user_id = ''; @@ -322,10 +322,10 @@ class session { do { - if (intval($row['session_user_id']) != ANONYMOUS) + if ($row['session_user_id'] != ANONYMOUS) { - $sql = "UPDATE " . USERS_TABLE . " - SET user_lastvisit = " . $row['recent_time'] . ", user_lastpage = '" . $db->sql_escape($row['session_page']) . "' + $sql = 'UPDATE ' . USERS_TABLE . ' + SET user_lastvisit = ' . $row['recent_time'] . ", user_lastpage = '" . $db->sql_escape($row['session_page']) . "' WHERE user_id = " . $row['session_user_id']; $db->sql_query($sql); } @@ -339,7 +339,7 @@ class session if ($del_user_id != '') { // Delete expired sessions - $sql = "DELETE FROM " . SESSIONS_TABLE . " + $sql = 'DELETE FROM ' . SESSIONS_TABLE . " WHERE session_user_id IN ($del_user_id) AND session_time < " . ($current_time - $config['session_length']); $db->sql_query($sql); diff --git a/phpBB/install/schemas/mysql_basic.sql b/phpBB/install/schemas/mysql_basic.sql index 6742e5df2f..d863d1871a 100644 --- a/phpBB/install/schemas/mysql_basic.sql +++ b/phpBB/install/schemas/mysql_basic.sql @@ -218,6 +218,10 @@ INSERT INTO phpbb_styles_template (template_id, template_name, template_path, po INSERT INTO phpbb_styles_theme (theme_id, css_data, css_external) VALUES (1, 'body {background: white url(\'templates/subSilver/images/background.png\') repeat-x;}\nth { background-image: url(\'templates/subSilver/images/cellpic3.gif\') }\ntd.cat { background-image: url(\'templates/subSilver/images/cellpic1.gif\') }\ntd.rowpic { background-image: url(\'templates/subSilver/images/cellpic2.jpg\'); background-repeat: repeat-y }\ntd.icqback { background-image: url(\'templates/subSilver/images/icon_icq_add.gif\'); background-repeat: no-repeat }', 'subSilver/subSilver.css'); +# -- Language +INSERT INTO phpbb_lang (lang_id, lang_iso, lang_dir, lang_english_name, lang_local_name, lang_author) VALUES (1, 'en', 'en', 'English [ UK ]', 'English [ UK ]', 'phpBB Group'); + + # -- Forums INSERT INTO phpbb_forums (forum_id, forum_name, forum_desc, left_id, right_id, parent_id, forum_type, forum_posts, forum_topics, forum_topics_real, forum_last_post_id, forum_last_poster_id, forum_last_poster_name, forum_last_post_time) VALUES (1, 'My first Category', '', 1, 4, 0, 0, 1, 1, 1, 1, 2, 'Admin', 972086460); @@ -241,6 +245,7 @@ INSERT INTO phpbb_groups (group_id, group_name, group_type) VALUES (2, 'INACTIVE INSERT INTO phpbb_groups (group_id, group_name, group_type) VALUES (3, 'REGISTERED', 3); INSERT INTO phpbb_groups (group_id, group_name, group_type) VALUES (4, 'SUPER_MODERATORS', 3); INSERT INTO phpbb_groups (group_id, group_name, group_type) VALUES (5, 'ADMINISTRATORS', 3); +INSERT INTO phpbb_groups (group_id, group_name, group_type) VALUES (6, 'BANNED', 3); # -- User -> Group @@ -277,7 +282,7 @@ INSERT INTO phpbb_auth_groups (group_id, forum_id, auth_option_id, auth_setting) INSERT INTO phpbb_auth_groups (group_id, forum_id, auth_option_id, auth_setting) SELECT 2, 0, auth_option_id, 0 FROM phpbb_auth_options WHERE auth_option IN ('u_%'); INSERT INTO phpbb_auth_groups (group_id, forum_id, auth_option_id, auth_setting) SELECT 3, 0, auth_option_id, 1 FROM phpbb_auth_options WHERE auth_option IN ('u_', 'u_sendemail', 'u_readpm', 'u_sendpm', 'u_viewprofile', 'u_chgavatar', 'u_chgemail', 'u_chgpasswd', 'u_search'); -INSERT INTO phpbb_auth_groups (group_id, forum_id, auth_option_id, auth_setting) SELECT 3, 2, auth_option_id, 2 FROM phpbb_auth_options WHERE auth_option IN ('u_viewonline', 'u_chgcolor', 'u_chgname'); +INSERT INTO phpbb_auth_groups (group_id, forum_id, auth_option_id, auth_setting) SELECT 3, 2, auth_option_id, 2 FROM phpbb_auth_options WHERE auth_option IN ('u_viewonline', 'u_chgname'); INSERT INTO phpbb_auth_groups (group_id, forum_id, auth_option_id, auth_setting) SELECT 5, 0, auth_option_id, 1 FROM phpbb_auth_options WHERE auth_option IN ('u_%'); diff --git a/phpBB/install/schemas/mysql_schema.sql b/phpBB/install/schemas/mysql_schema.sql index ed0557951c..39907f3d54 100644 --- a/phpBB/install/schemas/mysql_schema.sql +++ b/phpBB/install/schemas/mysql_schema.sql @@ -207,7 +207,6 @@ CREATE TABLE phpbb_forums ( forum_name varchar(150) NOT NULL, forum_desc text, forum_link varchar(200) DEFAULT '' NOT NULL, - forum_link_track tinyint(1) DEFAULT '0' NOT NULL, forum_password varchar(32) DEFAULT '' NOT NULL, forum_style tinyint(4) UNSIGNED, forum_image varchar(50) DEFAULT '' NOT NULL, @@ -221,6 +220,7 @@ CREATE TABLE phpbb_forums ( forum_last_poster_id mediumint(8) DEFAULT '0' NOT NULL, forum_last_post_time int(11) DEFAULT '0' NOT NULL, forum_last_poster_name varchar(30), + forum_flags tinyint(4) DEFAULT '0' NOT NULL, display_on_index tinyint(1) DEFAULT '1' NOT NULL, enable_icons tinyint(1) DEFAULT '1' NOT NULL, enable_prune tinyint(1) DEFAULT '0' NOT NULL, diff --git a/phpBB/language/en/lang_admin.php b/phpBB/language/en/lang_admin.php index 6bc725237b..f16e2175cd 100644 --- a/phpBB/language/en/lang_admin.php +++ b/phpBB/language/en/lang_admin.php @@ -644,7 +644,13 @@ $lang = array_merge($lang, array( 'AUTO_PRUNE_FREQ' => 'Auto-prune Frequency', 'AUTO_PRUNE_FREQ_EXPLAIN' => 'Time in days between pruning events.', 'AUTO_PRUNE_DAYS' => 'Auto-prune Post Age', - 'AUTO_PRUNE_DAYS_EXPLAIN' => 'Number of days since last post after which topic is removed.', + 'AUTO_PRUNE_DAYS_EXPLAIN' => 'Number of days since last post after which topic is removed.', + 'PRUNE_OLD_POLLS' => 'Prune Old Polls', + 'PRUNE_OLD_POLLS_EXPLAIN' => 'Removes topics with polls not voted in for post age days.', + 'PRUNE_FINISHED_POLLS' => 'Prune Closed Polls', + 'PRUNE_FINISHED_POLLS_EXPLAIN'=> 'Removes topics with polls which have ended.', + 'PRUNE_ANNOUNCEMENTS' => 'Prune Announcements', + 'PRUNE_STICKY' => 'Prune Stickies', 'FORUM_TOPICS_PAGE' => 'Topics Per Page', 'FORUM_TOPICS_PAGE_EXPLAIN' => 'If non-zero this value will override the default topics per page setting.', 'FORUM_PASSWORD' => 'Forum Password', diff --git a/phpBB/posting.php b/phpBB/posting.php index b6bdaa1acc..2864310d61 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -39,7 +39,6 @@ include($phpbb_root_path . 'includes/message_parser.'.$phpEx); // Start session management $user->start(); -$user->setup(); $auth->acl($user->data); // Grab only parameters needed here @@ -164,6 +163,8 @@ if ($sql != '') $topic_id = intval($row['topic_id']); $post_id = intval($row['post_id']); + $user->setup(false, $row['forum_style']); + if ($row['forum_password']) { login_forum_box($row); diff --git a/phpBB/viewforum.php b/phpBB/viewforum.php index 1346fcc73c..ff5eb34021 100644 --- a/phpBB/viewforum.php +++ b/phpBB/viewforum.php @@ -101,7 +101,7 @@ $db->sql_freeresult($result); if ($forum_data['forum_link']) { // Does it have click tracking enabled? - if ($forum_data['forum_link_track']) + if ($forum_data['forum_flags'] & 1) { $sql = 'UPDATE ' . FORUMS_TABLE . ' SET forum_posts = forum_posts + 1 @@ -173,17 +173,17 @@ if ($forum_data['forum_type'] == FORUM_POST) trigger_error($message); } -/* + // Do the forum Prune - cron type job ... - if ($config['prune_enable'] && $auth->acl_get('a_')) + if ($auth->acl_get('a_')) { - if ($forum_data['prune_next'] < time() && $forum_data['prune_enable']) + if ($forum_data['prune_next'] < time() && $forum_data['enable_prune']) { - require($phpbb_root_path . 'includes/functions_admin.'.$phpEx); - auto_prune($forum_id, $forum_data['prune_days'], $forum_data['prune_freq']); + include_once($phpbb_root_path . 'includes/functions_admin.'.$phpEx); + auto_prune($forum_id, $forum_data['forum_flags'], $forum_data['prune_days'], $forum_data['prune_freq']); } } -*/ + // Forum rules, subscription info and word censors $s_watching_forum = $s_watching_forum_img = '';