mirror of
https://github.com/phpbb/phpbb.git
synced 2025-10-20 11:20:42 +02:00
Hard-coded HTML into admin modules ... no point in continuing to template this stuff since no one (or few) rarely bother to make use of the feature. Lots of changes for permissions, sessions, etc. some new styling stuff present (inc. editing templates though not complete), lots of bugs and non-functioning stuff ... any 'existing' modules will cause the right hand panel to fail ... remove them. If I catch anyone nicking graphics from here I'll kill 'em ...
git-svn-id: file:///svn/phpbb/trunk@2675 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/***************************************************************************
|
||||
* admin_search.php
|
||||
* admin_search.php
|
||||
* -------------------
|
||||
* begin : Saturday, Feb 13, 2001
|
||||
* copyright : (C) 2001 The phpBB Group
|
||||
@@ -32,6 +32,10 @@ if ( !empty($setmodules) )
|
||||
return;
|
||||
}
|
||||
|
||||
define('IN_PHPBB', 1);
|
||||
//
|
||||
// Include files
|
||||
//
|
||||
$phpbb_root_path = '../';
|
||||
require($phpbb_root_path . 'extension.inc');
|
||||
require('pagestart.' . $phpEx);
|
||||
@@ -48,44 +52,68 @@ if ( !$acl->get_acl_admin('general') )
|
||||
//
|
||||
// Start indexing
|
||||
//
|
||||
if ( isset($HTTP_POST_VARS['start']) )
|
||||
if ( isset($HTTP_POST_VARS['start']) || isset($HTTP_GET_VARS['batchstart']) )
|
||||
{
|
||||
//
|
||||
// Do not change anything below this line.
|
||||
//
|
||||
set_time_limit(0);
|
||||
@set_time_limit(0);
|
||||
|
||||
$common_percent = 0.4; // Percentage of posts in which a word has to appear to be marked as common
|
||||
|
||||
print "<html>\n<body>\n";
|
||||
|
||||
//
|
||||
// Try and load stopword and synonym files
|
||||
//
|
||||
// This needs fixing! Shouldn't be hardcoded to English files!
|
||||
$stopword_array = file($phpbb_root_path . "language/lang_english/search_stopwords.txt");
|
||||
$synonym_array = file($phpbb_root_path . "language/lang_english/search_synonyms.txt");
|
||||
$stopword_array = array();
|
||||
$synonym_array = array();
|
||||
|
||||
$dir = opendir($phpbb_root_path . 'language/');
|
||||
while ( $file = readdir($dir) )
|
||||
{
|
||||
if ( ereg('^lang_', $file) && !is_file($phpbb_root_path . 'language/' . $file) && !is_link($phpbb_root_path . 'language/' . $file) )
|
||||
{
|
||||
unset($tmp_array);
|
||||
$tmp_array = @file($phpbb_root_path . 'language/' . $file . '/search_stopwords.txt');
|
||||
|
||||
if ( is_array($tmp_array) )
|
||||
{
|
||||
$stopword_array = array_merge($stopword_array, $tmp_array);
|
||||
}
|
||||
|
||||
unset($tmp_array);
|
||||
$tmp_array = @file($phpbb_root_path . 'language/' . $file . '/search_synonyms.txt');
|
||||
|
||||
if ( is_array($tmp_array) )
|
||||
{
|
||||
$synonym_array = array_merge($synonym_array, $tmp_array);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
closedir($dir);
|
||||
|
||||
$sql = "UPDATE " . CONFIG_TABLE . "
|
||||
SET config_value = '1'
|
||||
WHERE config_name = 'board_disable'";
|
||||
$db->sql_query($sql);
|
||||
|
||||
//
|
||||
// Fetch a batch of posts_text entries
|
||||
//
|
||||
$sql = "SELECT COUNT(*) as total, MAX(post_id) as max_post_id
|
||||
FROM ". POSTS_TEXT_TABLE;
|
||||
if ( !($result = $db->sql_query($sql)) )
|
||||
{
|
||||
$error = $db->sql_error();
|
||||
die("Couldn't get maximum post ID :: " . $sql . " :: " . $error['message']);
|
||||
}
|
||||
FROM " . POSTS_TEXT_TABLE;
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
$max_post_id = $db->sql_fetchrow($result);
|
||||
|
||||
$totalposts = $max_post_id['total'];
|
||||
$max_post_id = $max_post_id['max_post_id'];
|
||||
|
||||
$postcounter = (!isset($HTTP_GET_VARS['batchstart'])) ? 0 : $HTTP_GET_VARS['batchstart'];
|
||||
$postcounter = ( !isset($HTTP_GET_VARS['batchstart']) ) ? 0 : $HTTP_GET_VARS['batchstart'];
|
||||
|
||||
$batchsize = 200; // Process this many posts per loop
|
||||
$batchcount = 0;
|
||||
$batchsize = 200; // Process this many posts per loop
|
||||
for(;$postcounter <= $max_post_id; $postcounter += $batchsize)
|
||||
{
|
||||
$batchstart = $postcounter + 1;
|
||||
@@ -97,35 +125,20 @@ if ( isset($HTTP_POST_VARS['start']) )
|
||||
WHERE post_id
|
||||
BETWEEN $batchstart
|
||||
AND $batchend";
|
||||
if( !($result = $db->sql_query($sql)) )
|
||||
{
|
||||
$error = $db->sql_error();
|
||||
die("Couldn't get post_text :: " . $sql . " :: " . $error['message']);
|
||||
}
|
||||
|
||||
$rowset = $db->sql_fetchrowset($result);
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
$post_rows = count($rowset);
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
if( $post_rows )
|
||||
if ( $row = $db->sql_fetchrow($result) )
|
||||
{
|
||||
do
|
||||
{
|
||||
|
||||
// $sql = "LOCK TABLES ".POST_TEXT_TABLE." WRITE";
|
||||
// $result = $db->sql_query($sql);
|
||||
print "\n<p>\n<a href='$PHP_SELF?batchstart=$batchstart'>Restart from posting $batchstart</a><br>\n";
|
||||
// print "\n<p>\n<a href='$PHP_SELF?batchstart=$batchstart'>Restart from posting $batchstart</a><br>\n";
|
||||
|
||||
// For every post in the batch:
|
||||
for($post_nr = 0; $post_nr < $post_rows; $post_nr++ )
|
||||
{
|
||||
print ".";
|
||||
flush();
|
||||
|
||||
$post_id = $rowset[$post_nr]['post_id'];
|
||||
$post_id = $row['post_id'];
|
||||
|
||||
$matches = array();
|
||||
$matches['text'] = split_words(clean_words("post", $rowset[$post_nr]['post_text'], $stopword_array, $synonym_array));
|
||||
$matches['title'] = split_words(clean_words("post", $rowset[$post_nr]['post_subject'], $stopword_array, $synonym_array));
|
||||
$matches['text'] = split_words(clean_words('post', $row['post_text'], $stopword_array, $synonym_array));
|
||||
$matches['title'] = split_words(clean_words('post', $row['post_subject'], $stopword_array, $synonym_array));
|
||||
|
||||
while( list($match_type, $match_ary) = @each($matches) )
|
||||
{
|
||||
@@ -140,8 +153,7 @@ if ( isset($HTTP_POST_VARS['start']) )
|
||||
}
|
||||
|
||||
// For all words in the posting
|
||||
$sql_in = "";
|
||||
|
||||
$sql_in = '';
|
||||
$sql_insert = '';
|
||||
$sql_select = '';
|
||||
|
||||
@@ -150,8 +162,7 @@ if ( isset($HTTP_POST_VARS['start']) )
|
||||
|
||||
for($j = 0; $j < $num_matches; $j++)
|
||||
{
|
||||
$this_word = strtolower(trim($match_ary[$j]));
|
||||
if ( $this_word != '' )
|
||||
if ( $this_word = strtolower(trim($match_ary[$j])) )
|
||||
{
|
||||
$word_count[$this_word] = ( isset($word_count[$this_word]) ) ? $word_count[$this_word] + 1 : 0;
|
||||
$comma = ($sql_insert != '')? ', ': '';
|
||||
@@ -163,66 +174,48 @@ if ( isset($HTTP_POST_VARS['start']) )
|
||||
|
||||
if ( $sql_insert == '' )
|
||||
{
|
||||
die("no words found");
|
||||
message_die(ERROR, 'No words found to index');
|
||||
}
|
||||
|
||||
$sql = 'INSERT IGNORE INTO ' . SEARCH_WORD_TABLE . "
|
||||
(word_text)
|
||||
$sql = "INSERT IGNORE INTO " . SEARCH_WORD_TABLE . " (word_text)
|
||||
VALUES $sql_insert";
|
||||
if ( !$result = $db->sql_query($sql) )
|
||||
{
|
||||
$error = $db->sql_error();
|
||||
die("Couldn't INSERT words :: " . $sql . " :: " . $error['message']);
|
||||
}
|
||||
$db->sql_query($sql);
|
||||
|
||||
// Get the word_id's out of the DB (to see if they are already there)
|
||||
$sql = "SELECT word_id, word_text
|
||||
FROM " . SEARCH_WORD_TABLE . "
|
||||
WHERE word_text IN ($sql_select)
|
||||
GROUP BY word_text";
|
||||
$result = $db->sql_query($sql);
|
||||
if ( !$result )
|
||||
{
|
||||
$error = $db->sql_error();
|
||||
die("Couldn't select words :: " . $sql . " :: " . $error['message']);
|
||||
}
|
||||
$result2 = $db->sql_query($sql);
|
||||
|
||||
$sql_insert = array();
|
||||
while( $row = $db->sql_fetchrow($result) )
|
||||
while( $row = $db->sql_fetchrow($result2) )
|
||||
{
|
||||
$sql_insert[] = "($post_id, " . $row['word_id'] . ", $title_match)";
|
||||
}
|
||||
|
||||
$db->sql_freeresult($result);
|
||||
$db->sql_freeresult($result2);
|
||||
|
||||
$sql = "INSERT INTO " . SEARCH_MATCH_TABLE . "
|
||||
(post_id, word_id, title_match)
|
||||
VALUES " . implode(", ", $sql_insert);
|
||||
$result = $db->sql_query($sql);
|
||||
if ( !$result )
|
||||
{
|
||||
$error = $db->sql_error();
|
||||
die("Couldn't insert new word match :: " . $sql . " :: " . $error['message']);
|
||||
}
|
||||
$sql = "INSERT INTO " . SEARCH_MATCH_TABLE . " (post_id, word_id, title_match)
|
||||
VALUES " . implode(', ', $sql_insert);
|
||||
$db->sql_query($sql);
|
||||
|
||||
} // All posts
|
||||
}
|
||||
|
||||
// $sql = "UNLOCK TABLES";
|
||||
// $result = $db->sql_query($sql);
|
||||
|
||||
while ( $row = $db->sql_fetchrow($result) );
|
||||
}
|
||||
|
||||
// Remove common words after the first 2 batches and after every 4th batch after that.
|
||||
if( $batchcount % 4 == 3 )
|
||||
if ( $batchcount % 4 == 3 )
|
||||
{
|
||||
print "<br>Removing common words (words that appear in more than $common_percent of the posts)<br>\n";
|
||||
flush();
|
||||
print "Removed ". remove_common("global", $common_percent) ." words that where too common.<br>";
|
||||
// print "<br>Removing common words (words that appear in more than $common_percent of the posts)<br>\n";
|
||||
// flush();
|
||||
// print "Removed ". remove_common("global", $common_percent) ." words that where too common.<br>";
|
||||
}
|
||||
}
|
||||
|
||||
echo "<br>Done";
|
||||
exit;
|
||||
|
||||
}
|
||||
else if ( isset($HTTP_POST_VARS['cancel']) )
|
||||
|
Reference in New Issue
Block a user