aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes
diff options
context:
space:
mode:
authorPaul S. Owen <psotfx@users.sourceforge.net>2002-04-02 14:04:18 +0000
committerPaul S. Owen <psotfx@users.sourceforge.net>2002-04-02 14:04:18 +0000
commit51d9bdeca72e22dfa2f7cecc3e7867b125ee899b (patch)
tree679053f4374226e2bdfb02af19f942b842040354 /phpBB/includes
parent374f7adca2dd41e3a20739c74514fbca87a01e55 (diff)
downloadforums-51d9bdeca72e22dfa2f7cecc3e7867b125ee899b.tar
forums-51d9bdeca72e22dfa2f7cecc3e7867b125ee899b.tar.gz
forums-51d9bdeca72e22dfa2f7cecc3e7867b125ee899b.tar.bz2
forums-51d9bdeca72e22dfa2f7cecc3e7867b125ee899b.tar.xz
forums-51d9bdeca72e22dfa2f7cecc3e7867b125ee899b.zip
Various updates with any luck they fix a few minor issues without causing new ones ...
git-svn-id: file:///svn/phpbb/trunk@2462 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB/includes')
-rw-r--r--phpBB/includes/functions.php19
-rw-r--r--phpBB/includes/functions_admin.php27
-rw-r--r--phpBB/includes/functions_post.php3
-rw-r--r--phpBB/includes/functions_search.php18
-rw-r--r--phpBB/includes/prune.php26
-rw-r--r--phpBB/includes/usercp_activate.php28
6 files changed, 52 insertions, 69 deletions
diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php
index 8ae87f656f..13fe5bd60c 100644
--- a/phpBB/includes/functions.php
+++ b/phpBB/includes/functions.php
@@ -214,15 +214,6 @@ function init_userprefs($userdata)
$board_config['board_timezone'] = $userdata['user_timezone'];
}
}
- /*switch( getenv('HTTP_ACCEPT_LANGUAGE') )
- {
- case 'en-gb':
- $board_config['default_lang'] = 'english';
- break;
- case 'fr':
- $board_config['default_lang'] = 'french';
- break;
- }*/
if ( !file_exists($phpbb_root_path . 'language/lang_' . $board_config['default_lang'] . '/lang_main.'.$phpEx) )
{
@@ -314,8 +305,8 @@ function encode_ip($dotquad_ip)
function decode_ip($int_ip)
{
- $hexipbang = explode('.',chunk_split($int_ip, 2, '.'));
- return hexdec($hexipbang[0]).'.'.hexdec($hexipbang[1]).'.'.hexdec($hexipbang[2]).'.'.hexdec($hexipbang[3]);
+ $hexipbang = explode('.', chunk_split($int_ip, 2, '.'));
+ return hexdec($hexipbang[0]). '.' . hexdec($hexipbang[1]) . '.' . hexdec($hexipbang[2]) . '.' . hexdec($hexipbang[3]);
}
//
@@ -350,7 +341,7 @@ function generate_pagination($base_url, $num_items, $per_page, $start_item, $add
if ( $total_pages == 1 )
{
- return "";
+ return '';
}
$on_page = floor($start_item / $per_page) + 1;
@@ -442,7 +433,7 @@ function generate_pagination($base_url, $num_items, $per_page, $start_item, $add
function phpbb_preg_quote($str, $delimiter)
{
$text = preg_quote($str);
- $text = str_replace($delimiter, "\\" . $delimiter, $text);
+ $text = str_replace($delimiter, '\\' . $delimiter, $text);
return $text;
}
@@ -470,7 +461,7 @@ function obtain_word_list(&$orig_word, &$replacement_word)
{
do
{
- $orig_word[] = "#\b(" . str_replace("\*", "\w*?", phpbb_preg_quote($row['word'], "#")) . ")\b#i";
+ $orig_word[] = '#\b(' . str_replace('\*', '\w*?', phpbb_preg_quote($row['word'], '#')) . ')\b#i';
$replacement_word[] = $row['replacement'];
}
while ( $row = $db->sql_fetchrow($result) );
diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php
index 5d5df857fa..456742fd38 100644
--- a/phpBB/includes/functions_admin.php
+++ b/phpBB/includes/functions_admin.php
@@ -90,9 +90,11 @@ function sync($type, $id)
break;
case 'forum':
- $sql = "SELECT MAX(post_id) AS last_post, COUNT(post_id) AS total
- FROM " . POSTS_TABLE . "
- WHERE forum_id = $id";
+ $sql = "SELECT MAX(p.post_id) AS last_post, COUNT(p.post_id) AS total
+ FROM " . POSTS_TABLE . " p, " . TOPICS_TABLE . " t
+ WHERE p.forum_id = $id
+ AND t.topic_id = p.topic_id
+ AND t.topic_status <> " . TOPIC_MOVED;
if ( !$result = $db->sql_query($sql) )
{
message_die(GENERAL_ERROR, 'Could not get post ID', '', __LINE__, __FILE__, $sql);
@@ -118,21 +120,14 @@ function sync($type, $id)
message_die(GENERAL_ERROR, 'Could not get topic count', '', __LINE__, __FILE__, $sql);
}
- if ( $row = $db->sql_fetchrow($result) )
- {
- $total_topics = ($row['total']) ? $row['total'] : 0;
- }
- else
- {
- $total_topics = 0;
- }
+ $total_topics = ( $row = $db->sql_fetchrow($result) ) ? ( ( $row['total'] ) ? $row['total'] : 0 ) : 0;
$sql = "UPDATE " . FORUMS_TABLE . "
SET forum_last_post_id = $last_post, forum_posts = $total_posts, forum_topics = $total_topics
WHERE forum_id = $id";
- if ( !$result = $db->sql_query($sql) )
+ if ( !$db->sql_query($sql) )
{
- message_die(GENERAL_ERROR, "Could not update forum $id", '', __LINE__, __FILE__, $sql);
+ message_die(GENERAL_ERROR, 'Could not update forum', '', __LINE__, __FILE__, $sql);
}
break;
@@ -142,7 +137,7 @@ function sync($type, $id)
WHERE topic_id = $id";
if ( !$result = $db->sql_query($sql) )
{
- message_die(GENERAL_ERROR, "Could not get post ID", '', __LINE__, __FILE__, $sql);
+ message_die(GENERAL_ERROR, 'Could not get post ID', '', __LINE__, __FILE__, $sql);
}
if ( $row = $db->sql_fetchrow($result) )
@@ -150,9 +145,9 @@ function sync($type, $id)
$sql = "UPDATE " . TOPICS_TABLE . "
SET topic_replies = " . ( $row['total_posts'] - 1 ) . ", topic_first_post_id = " . $row['first_post'] . ", topic_last_post_id = " . $row['last_post'] . "
WHERE topic_id = $id";
- if ( !($result = $db->sql_query($sql)) )
+ if ( !$db->sql_query($sql) )
{
- message_die(GENERAL_ERROR, "Could not update topic $id", '', __LINE__, __FILE__, $sql);
+ message_die(GENERAL_ERROR, 'Could not update topic', '', __LINE__, __FILE__, $sql);
}
}
diff --git a/phpBB/includes/functions_post.php b/phpBB/includes/functions_post.php
index 2dc3bd2bfa..ce1049ac13 100644
--- a/phpBB/includes/functions_post.php
+++ b/phpBB/includes/functions_post.php
@@ -527,7 +527,8 @@ function delete_post($mode, &$post_data, &$message, &$meta, &$forum_id, &$topic_
if ( $post_data['first_post'] )
{
$sql = "DELETE FROM " . TOPICS_TABLE . "
- WHERE topic_id = $topic_id";
+ WHERE topic_id = $topic_id
+ OR topic_moved_id = $topic_id";
if ( !($db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Error in deleting post', '', __LINE__, __FILE__, $sql);
diff --git a/phpBB/includes/functions_search.php b/phpBB/includes/functions_search.php
index b74ac398b4..f42ff475c4 100644
--- a/phpBB/includes/functions_search.php
+++ b/phpBB/includes/functions_search.php
@@ -206,7 +206,7 @@ function add_search_words($post_id, $post_text, $post_title = '')
default:
$sql = "INSERT INTO " . SEARCH_WORD_TABLE . " (word_text)
VALUES ('" . $word[$i] . "')";
- if( !($result = $db->sql_query($sql)) )
+ if( !$db->sql_query($sql) )
{
message_die(GENERAL_ERROR, 'Could not insert new word', '', __LINE__, __FILE__, $sql);
}
@@ -230,7 +230,7 @@ function add_search_words($post_id, $post_text, $post_title = '')
break;
}
- if ( !($result = $db->sql_query($sql)) )
+ if ( !$db->sql_query($sql) )
{
message_die(GENERAL_ERROR, 'Could not insert new word', '', __LINE__, __FILE__, $sql);
}
@@ -247,7 +247,7 @@ function add_search_words($post_id, $post_text, $post_title = '')
SELECT $post_id, word_id, $title_match
FROM " . SEARCH_WORD_TABLE . "
WHERE word_text IN ($match_sql)";
- if ( !($result = $db->sql_query($sql)) )
+ if ( !$db->sql_query($sql) )
{
message_die(GENERAL_ERROR, 'Could not insert new word matches', '', __LINE__, __FILE__, $sql);
}
@@ -314,7 +314,6 @@ function remove_common($mode, $fraction, $word_id_list = array())
{
$common_word_id .= ( ( $common_word_id != '' ) ? ', ' : '' ) . $row['word_id'];
}
-
$db->sql_freeresult($result);
if ( $common_word_id != '' )
@@ -322,14 +321,14 @@ function remove_common($mode, $fraction, $word_id_list = array())
$sql = "UPDATE " . SEARCH_WORD_TABLE . "
SET word_common = " . TRUE . "
WHERE word_id IN ($common_word_id)";
- if ( !($result = $db->sql_query($sql)) )
+ if ( !$db->sql_query($sql) )
{
message_die(GENERAL_ERROR, 'Could not delete word list entry', '', __LINE__, __FILE__, $sql);
}
$sql = "DELETE FROM " . SEARCH_MATCH_TABLE . "
WHERE word_id IN ($common_word_id)";
- if ( !($result = $db->sql_query($sql)) )
+ if ( !$db->sql_query($sql) )
{
message_die(GENERAL_ERROR, 'Could not delete word match entry', '', __LINE__, __FILE__, $sql);
}
@@ -378,7 +377,7 @@ function remove_search_post($post_id_sql)
{
$sql = "DELETE FROM " . SEARCH_WORD_TABLE . "
WHERE word_id IN ($word_id_sql)";
- if ( !($result = $db->sql_query($sql, END_TRANSACTION)) )
+ if ( !$db->sql_query($sql) )
{
message_die(GENERAL_ERROR, 'Could not delete word list entry', '', __LINE__, __FILE__, $sql);
}
@@ -403,7 +402,7 @@ function remove_search_post($post_id_sql)
GROUP BY word_id
HAVING COUNT(word_id) = 1
)";
- if ( !($result = $db->sql_query($sql, END_TRANSACTION)) )
+ if ( !$db->sql_query($sql) )
{
message_die(GENERAL_ERROR, 'Could not delete old words from word table', '', __LINE__, __FILE__, $sql);
}
@@ -415,7 +414,7 @@ function remove_search_post($post_id_sql)
$sql = "DELETE FROM " . SEARCH_MATCH_TABLE . "
WHERE post_id IN ($post_id_sql)";
- if ( !($db->sql_query($sql)) )
+ if ( !$db->sql_query($sql) )
{
message_die(GENERAL_ERROR, 'Error in deleting post', '', __LINE__, __FILE__, $sql);
}
@@ -457,6 +456,7 @@ function username_search($search_match)
{
$username_list .= '<option>' . $lang['No_match']. '</option>';
}
+ $db->sql_freeresult($result);
}
$gen_simple_header = TRUE;
diff --git a/phpBB/includes/prune.php b/phpBB/includes/prune.php
index c59217eea1..84f552ec91 100644
--- a/phpBB/includes/prune.php
+++ b/phpBB/includes/prune.php
@@ -26,6 +26,7 @@ if ( !defined('IN_PHPBB') )
}
require($phpbb_root_path . 'includes/functions_search.'.$phpEx);
+require($phpbb_root_path . 'includes/functions_admin.'.$phpEx);
function prune($forum_id, $prune_date)
{
@@ -38,12 +39,13 @@ function prune($forum_id, $prune_date)
FROM " . POSTS_TABLE . " p, " . TOPICS_TABLE . " t
WHERE t.forum_id = $forum_id
AND t.topic_vote = 0
- AND t.topic_type <> " . POST_ANNOUNCE . "
+ AND t.topic_type <> " . POST_ANNOUNCE . "
AND p.post_id = t.topic_last_post_id";
if ( $prune_date != '' )
{
$sql .= " AND p.post_time < $prune_date";
}
+
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not obtain lists of topics to prune', '', __LINE__, __FILE__, $sql);
@@ -76,7 +78,7 @@ function prune($forum_id, $prune_date)
{
$sql = "DELETE FROM " . TOPICS_TABLE . "
WHERE topic_id IN ($sql_topics)";
- if ( !($result = $db->sql_query($sql, BEGIN_TRANSACTION)) )
+ if ( !$db->sql_query($sql, BEGIN_TRANSACTION) )
{
message_die(GENERAL_ERROR, 'Could not delete topics during prune', '', __LINE__, __FILE__, $sql);
}
@@ -85,7 +87,7 @@ function prune($forum_id, $prune_date)
$sql = "DELETE FROM " . POSTS_TABLE . "
WHERE post_id IN ($sql_post)";
- if ( !($result = $db->sql_query($sql)) )
+ if ( !$db->sql_query($sql) )
{
message_die(GENERAL_ERROR, 'Could not delete post_text during prune', '', __LINE__, __FILE__, $sql);
}
@@ -94,27 +96,21 @@ function prune($forum_id, $prune_date)
$sql = "DELETE FROM " . POSTS_TEXT_TABLE . "
WHERE post_id IN ($sql_post)";
- if ( !($result = $db->sql_query($sql)) )
+ if ( !$db->sql_query($sql) )
{
message_die(GENERAL_ERROR, 'Could not delete post during prune', '', __LINE__, __FILE__, $sql);
}
$sql = "DELETE FROM " . SEARCH_MATCH_TABLE . "
WHERE post_id IN ($sql_post)";
- if ( !($result = $db->sql_query($sql)) )
+ if ( !$db->sql_query($sql) )
{
message_die(GENERAL_ERROR, 'Could not delete search matches', '', __LINE__, __FILE__, $sql);
}
remove_search_post($sql_post);
- $sql = "UPDATE " . FORUMS_TABLE . "
- SET forum_topics = forum_topics - $pruned_topics, forum_posts = forum_posts - $pruned_posts
- WHERE forum_id = $forum_id";
- if ( !($result = $db->sql_query($sql)) )
- {
- message_die(GENERAL_ERROR, 'Could not update forum data after prune', '', __LINE__, __FILE__, $sql);
- }
+ sync('forum', $forum_id);
return array ('topics' => $pruned_topics, 'posts' => $pruned_posts);
}
@@ -144,12 +140,12 @@ function auto_prune($forum_id = 0)
if ( $row['prune_freq'] && $row['prune_days'] )
{
$prune_date = time() - ( $row['prune_days'] * 86400 );
- prune($forum_id, $prune_date);
-
$next_prune = time() + ( $row['prune_freq'] * 86400 );
+ $pruned = prune($forum_id, $prune_date);
+
$sql = "UPDATE " . FORUMS_TABLE . "
- SET prune_next = $next_prune
+ SET prune_next = $next_prune
WHERE forum_id = $forum_id";
if ( !$db->sql_query($sql) )
{
diff --git a/phpBB/includes/usercp_activate.php b/phpBB/includes/usercp_activate.php
index bfc4a92a36..4e2e865460 100644
--- a/phpBB/includes/usercp_activate.php
+++ b/phpBB/includes/usercp_activate.php
@@ -23,7 +23,7 @@
if ( !defined('IN_PHPBB') )
{
- die("Hacking attempt");
+ die('Hacking attempt');
exit;
}
@@ -34,7 +34,7 @@ if ( $result = $db->sql_query($sql) )
{
if ( $row = $db->sql_fetchrow($result) )
{
- $sql_update_pass = ( $row['user_newpasswd'] != "" ) ? ", user_password = '" . str_replace("\'", "''", $row['user_newpasswd']) . "', user_newpasswd = ''" : "";
+ $sql_update_pass = ( $row['user_newpasswd'] != '' ) ? ", user_password = '" . str_replace("\'", "''", $row['user_newpasswd']) . "', user_newpasswd = ''" : "";
$sql = "UPDATE " . USERS_TABLE . "
SET user_active = 1, user_actkey = ''" . $sql_update_pass . "
@@ -46,24 +46,24 @@ if ( $result = $db->sql_query($sql) )
include($phpbb_root_path . 'includes/emailer.'.$phpEx);
$emailer = new emailer($board_config['smtp_delivery']);
- $email_headers = "From: " . $board_config['board_email'] . "\nReturn-Path: " . $board_config['board_email'] . "\r\n";
+ $email_headers = 'From: ' . $board_config['board_email'] . "\nReturn-Path: " . $board_config['board_email'] . "\r\n";
- $emailer->use_template("admin_welcome_activated", $row['user_lang']);
+ $emailer->use_template('admin_welcome_activated', $row['user_lang']);
$emailer->email_address($row['user_email']);
$emailer->set_subject();//$lang['Account_activated_subject']
$emailer->extra_headers($email_headers);
$emailer->assign_vars(array(
- "SITENAME" => $board_config['sitename'],
- "USERNAME" => $username,
- "PASSWORD" => $password_confirm,
- "EMAIL_SIG" => str_replace("<br />", "\n", "-- \n" . $board_config['board_email_sig']))
+ 'SITENAME' => $board_config['sitename'],
+ 'USERNAME' => $username,
+ 'PASSWORD' => $password_confirm,
+ 'EMAIL_SIG' => str_replace('<br />', "\n", "-- \n" . $board_config['board_email_sig']))
);
$emailer->send();
$emailer->reset();
$template->assign_vars(array(
- "META" => '<meta http-equiv="refresh" content="10;url=' . append_sid("index.$phpEx") . '">')
+ 'META' => '<meta http-equiv="refresh" content="10;url=' . append_sid("index.$phpEx") . '">')
);
message_die(GENERAL_MESSAGE, $lang['Account_active_admin']);
@@ -71,16 +71,16 @@ if ( $result = $db->sql_query($sql) )
else
{
$template->assign_vars(array(
- "META" => '<meta http-equiv="refresh" content="10;url=' . append_sid("index.$phpEx") . '">')
+ 'META' => '<meta http-equiv="refresh" content="10;url=' . append_sid("index.$phpEx") . '">')
);
- $message = ( $sql_update_pass == "" ) ? $lang['Account_active'] : $lang['Password_activated'];
+ $message = ( $sql_update_pass == '' ) ? $lang['Account_active'] : $lang['Password_activated'];
message_die(GENERAL_MESSAGE, $message);
}
}
else
{
- message_die(GENERAL_ERROR, "Couldn't update users table", "", __LINE__, __FILE__, $sql_update);
+ message_die(GENERAL_ERROR, 'Could not update users table', '', __LINE__, __FILE__, $sql_update);
}
}
else
@@ -90,7 +90,7 @@ if ( $result = $db->sql_query($sql) )
}
else
{
- message_die(GENERAL_ERROR, "Couldn't obtain user information", "", __LINE__, __FILE__, $sql);
+ message_die(GENERAL_ERROR, 'Could not obtain user information', '', __LINE__, __FILE__, $sql);
}
-?>
+?> \ No newline at end of file