|
From: Paul S. O. <ps...@us...> - 2001-11-23 19:01:53
|
Update of /cvsroot/phpbb/phpBB2
In directory usw-pr-cvs1:/tmp/cvs-serv5027
Modified Files:
posting.php profile.php
Log Message:
More search updates + user posts
Index: posting.php
===================================================================
RCS file: /cvsroot/phpbb/phpBB2/posting.php,v
retrieving revision 1.105
retrieving revision 1.106
diff -C2 -r1.105 -r1.106
*** posting.php 2001/11/23 01:04:31 1.105
--- posting.php 2001/11/23 19:01:51 1.106
***************
*** 89,106 ****
global $db;
! $word_id_sql = "";
! if( count($word_id_list) )
! {
! for($i = 0; $i < count($word_id_list); $i++ )
! {
! if( $word_id_sql != "" )
! {
! $word_id_sql .= ", ";
! }
! $word_id_sql .= $word_id_list[$i]['word_id'];
! }
! $word_id_sql = "WHERE word_id IN ($word_id_sql) ";
! }
!
$sql = "SELECT SUM(forum_posts) AS total_posts
FROM " . FORUMS_TABLE ;
--- 89,93 ----
global $db;
! // 0.01-0.06s
$sql = "SELECT SUM(forum_posts) AS total_posts
FROM " . FORUMS_TABLE ;
***************
*** 117,120 ****
--- 104,114 ----
$common_threshold = floor($row['total_posts'] * $percent);
+ $word_id_sql = "";
+ if( count($word_id_list) )
+ {
+ $word_id_sql = "WHERE word_id IN (" . implode(", ", $word_id_list) . ") ";
+ }
+
+ // 0.020-0.024s
$sql = "SELECT word_id
FROM " . SEARCH_MATCH_TABLE . "
***************
*** 128,131 ****
--- 122,126 ----
}
+ // No matches
if( $word_count = $db->sql_numrows($result) )
{
***************
*** 159,176 ****
}
}
- else
- {
- return 0;
- }
}
- else
- {
- return 0;
- }
}
- else
- {
- return 0;
- }
return $word_count;
--- 154,159 ----
***************
*** 236,239 ****
--- 219,223 ----
case 'mysql':
case 'mysql4':
+ // 0.07s
$sql = "SELECT w.word_id
FROM " . SEARCH_WORD_TABLE . " w
***************
*** 254,257 ****
--- 238,242 ----
if( $word_id_sql )
{
+ // 0.07s (about 15-20 words)
$sql = "DELETE FROM " . SEARCH_WORD_TABLE . "
WHERE word_id IN ($word_id_sql)";
***************
*** 286,292 ****
$synonym_array = @file($phpbb_root_path . "language/lang_" . $board_config['default_lang'] . "/search_synonyms.txt");
$search_text = clean_words($post_text, $stopword_array, $synonym_array);
- // $search_title = clean_words($post_title, $stopword_array, $synonym_array);
-
$search_matches = split_words($search_text);
--- 271,276 ----
$synonym_array = @file($phpbb_root_path . "language/lang_" . $board_config['default_lang'] . "/search_synonyms.txt");
+ // 0.3s
$search_text = clean_words($post_text, $stopword_array, $synonym_array);
$search_matches = split_words($search_text);
***************
*** 294,330 ****
{
$word = array();
! for ($j = 0; $j < count($search_matches); $j++)
{
! $this_word = strtolower(trim($search_matches[$j]));
! $new_word = true;
! for($k = 0; $k < count($word); $k++)
{
! if( $this_word == $word[$k] || $this_word == "" )
{
! $new_word = false;
}
- }
-
- if( $new_word )
- {
- $word[] = $this_word;
- }
- }
! $word_sql_in = "";
! for ($j = 0; $j < count($word); $j++)
! {
! if( $word_sql_in != "" )
! {
! $word_sql_in .= ", ";
! }
! $word_sql_in .= "'" . $word[$j] . "'";
}
$sql = "SELECT word_id, word_text, word_common
FROM " . SEARCH_WORD_TABLE . "
! WHERE word_text IN ($word_sql_in)";
$result = $db->sql_query($sql);
if( !$result )
--- 278,304 ----
{
$word = array();
+ sort($search_matches);
! $word_text_sql = "";
! for ($i = 0; $i < count($search_matches); $i++)
{
! $search_matches[$i] = trim($search_matches[$i]);
! if( $search_matches[$i] != "" && $search_matches[$i] != $search_matches[$i-1] )
{
! $word[] = $search_matches[$i];
!
! if( $word_text_sql != "" )
{
! $word_text_sql .= ", ";
}
! $word_text_sql .= "'" . $search_matches[$i] . "'";
! }
}
$sql = "SELECT word_id, word_text, word_common
FROM " . SEARCH_WORD_TABLE . "
! WHERE word_text IN ($word_text_sql)";
$result = $db->sql_query($sql);
if( !$result )
***************
*** 333,380 ****
}
if( $word_check_count = $db->sql_numrows($result) )
{
! $check_words = $db->sql_fetchrowset($result);
}
$match_word = array();
! for ($j = 0; $j < count($word); $j++)
{
! if( $word[$j] )
! {
! $new_match = true;
! $word_common = false;
! if( $word_check_count )
{
! for($k = 0; $k < $word_check_count; $k++)
! {
! if( $word[$j] == $check_words[$k]['word_text'] )
! {
! if( $check_words[$k]['word_common'] )
! {
! $word_common = true;
! }
!
! $new_match = false;
! }
!
! }
}
! if( !$word_common )
! {
! $match_word[] = "'" . $word[$j] . "'";
! }
! if( $new_match )
{
! $sql = "INSERT INTO " . SEARCH_WORD_TABLE . " (word_text)
! VALUES ('". addslashes($word[$j]) . "')";
! $result = $db->sql_query($sql);
! if( !$result )
! {
! message_die(GENERAL_ERROR, "Couldn't insert new word", "", __LINE__, __FILE__, $sql);
! }
}
}
--- 307,348 ----
}
+ $check_words = array();
+ $word_id_list = array();
if( $word_check_count = $db->sql_numrows($result) )
{
! while( $row = $db->sql_fetchrow($result) )
! {
! $check_words[$row['word_text']] = $row['word_common'];
! $word_id_list[] = $row['word_id'];
! }
}
$match_word = array();
! for ($i = 0; $i < count($word); $i++)
{
! $new_match = true;
! $word_common = false;
! if( $word_check_count )
! {
! if( isset($check_words[$word[$i]]) )
{
! $new_match = false;
}
+ }
! if( !$check_words[$word[$i]] )
! {
! $match_word[] = "'" . $word[$i] . "'";
! }
! if( $new_match )
! {
! $sql = "INSERT INTO " . SEARCH_WORD_TABLE . " (word_text, word_common)
! VALUES ('". $word[$i] . "', 0)";
! $result = $db->sql_query($sql);
! if( !$result )
{
! message_die(GENERAL_ERROR, "Couldn't insert new word", "", __LINE__, __FILE__, $sql);
}
}
***************
*** 392,400 ****
message_die(GENERAL_ERROR, "Couldn't insert new word matches", "", __LINE__, __FILE__, $sql);
}
-
}
! remove_common(0.15, $check_words);
return;
}
--- 360,377 ----
message_die(GENERAL_ERROR, "Couldn't insert new word matches", "", __LINE__, __FILE__, $sql);
}
}
+
+ /*
+ $mtime = explode(" ",microtime());
+ $starttime = $mtime[1] + $mtime[0];
+
+ $mtime = explode(" ", microtime());
+ $endtime = $mtime[1] + $mtime[0];
+ echo "<BR><BR> TIMING1 >>>>>>>>> " . ($endtime - $starttime) . "<BR><BR>\n";
! */
+ remove_common(0.15, $word_id_list);
+
return;
}
***************
*** 1488,1493 ****
{
$row = $db->sql_fetchrow($result);
! if( $userdata['user_id'] != $row['poster_id'] && !$is_auth['auth_mod'])
{
$message = ( $delete || $mode == "delete" ) ? $lang['Delete_own_posts'] : $lang['Edit_own_posts'];
--- 1465,1472 ----
{
$row = $db->sql_fetchrow($result);
+
+ $poster_id = $row['poster_id'];
! if( $userdata['user_id'] != $poster_id && !$is_auth['auth_mod'])
{
$message = ( $delete || $mode == "delete" ) ? $lang['Delete_own_posts'] : $lang['Edit_own_posts'];
***************
*** 1632,1638 ****
if( $delete || $mode == "delete" )
{
$sql = "DELETE FROM " . SEARCH_MATCH_TABLE . "
WHERE post_id = $post_id";
! $result = $db->sql_query($sql, BEGIN_TRANSACTION);
if( !$result )
{
--- 1611,1625 ----
if( $delete || $mode == "delete" )
{
+ $sql = "UPDATE " . USERS_TABLE . "
+ SET user_posts = user_posts - 1
+ WHERE user_id = " . $poster_id;
+ if( !$db->sql_query($sql, BEGIN_TRANSACTION) )
+ {
+ message_die(GENERAL_MESSAGE, "Couldn't update users post count", "", __LINE__, __FILE__, $sql);
+ }
+
$sql = "DELETE FROM " . SEARCH_MATCH_TABLE . "
WHERE post_id = $post_id";
! $result = $db->sql_query($sql);
if( !$result )
{
***************
*** 1640,1643 ****
--- 1627,1633 ----
}
+ //
+ // Removes redundant words from wordlist table
+ //
remove_unmatched_words();
***************
*** 1864,1867 ****
--- 1854,1860 ----
}
+ //
+ // Clear out the old matches
+ //
$sql = "DELETE FROM " . SEARCH_MATCH_TABLE . "
WHERE post_id = $post_id";
***************
*** 1879,1883 ****
$sql = "UPDATE " . POSTS_TEXT_TABLE . "
SET post_text = '$post_message', post_subject = '$post_subject'
! WHERE post_id = $post_id";
if( $is_first_post_topic )
--- 1872,1876 ----
$sql = "UPDATE " . POSTS_TEXT_TABLE . "
SET post_text = '$post_message', post_subject = '$post_subject'
! WHERE post_id = $post_id";
if( $is_first_post_topic )
Index: profile.php
===================================================================
RCS file: /cvsroot/phpbb/phpBB2/profile.php,v
retrieving revision 1.139
retrieving revision 1.140
diff -C2 -r1.139 -r1.140
*** profile.php 2001/11/22 01:13:49 1.139
--- profile.php 2001/11/23 19:01:51 1.140
***************
*** 249,253 ****
// Get the users percentage of total posts
! if($profiledata['user_posts'] != 0)
{
$total_posts = get_db_stat("postcount");
--- 249,253 ----
// Get the users percentage of total posts
! if( $profiledata['user_posts'] != 0 && $total_posts != 0 )
{
$total_posts = get_db_stat("postcount");
|