aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/upgrade.php
diff options
context:
space:
mode:
authorBart van Bragt <bartvb@users.sourceforge.net>2002-01-03 11:06:22 +0000
committerBart van Bragt <bartvb@users.sourceforge.net>2002-01-03 11:06:22 +0000
commitf02324d2cb243a1ba293b6eeb66c6eeff343edc0 (patch)
tree1d0d91fa98faeb434bc77486e77cff850353c908 /phpBB/upgrade.php
parent6c8b10c87a50b03d4e9c7f933b53dce6350cc918 (diff)
downloadforums-f02324d2cb243a1ba293b6eeb66c6eeff343edc0.tar
forums-f02324d2cb243a1ba293b6eeb66c6eeff343edc0.tar.gz
forums-f02324d2cb243a1ba293b6eeb66c6eeff343edc0.tar.bz2
forums-f02324d2cb243a1ba293b6eeb66c6eeff343edc0.tar.xz
forums-f02324d2cb243a1ba293b6eeb66c6eeff343edc0.zip
Moved all search functions to includes/search.php Paul; please review
git-svn-id: file:///svn/phpbb/trunk@1781 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB/upgrade.php')
-rw-r--r--phpBB/upgrade.php152
1 files changed, 3 insertions, 149 deletions
diff --git a/phpBB/upgrade.php b/phpBB/upgrade.php
index b1a0b846cd..942622e379 100644
--- a/phpBB/upgrade.php
+++ b/phpBB/upgrade.php
@@ -38,37 +38,7 @@ $dbms = 'mysql';
include('includes/db.'.$phpEx);
include('includes/bbcode.'.$phpEx);
-
-//
-// Set smiley path, uncomment the following line to set the path manually
-//
-//$smiley_path = '/forums/images/smiles/';
-//
-/*
-if( !isset($smiley_path) )
-{
- // Did we get a path through the URL?
- if(isset($HTTP_GET_VARS['smiley_path']))
- {
- $smiley_path = $HTTP_GET_VARS['smiley_path'];
- }
- else
- {
- // Check the current directory name
- $base_dir = dirname($PHP_SELF);
- if ($base_dir != '/phpBB2' && $base_dir != '\phpBB2')
- {
- // User isn't installing in the default /phpBB2/ dir, probably installing in 1.4 dir?
- $smiley_path = $base_dir . '/images/smiles/';
- }
- else
- {
- // Fall back to the default 1.4 path
- $smiley_path = '/phpBB/images/smiles/';
- }
- }
-}
-*/
+include('includes/search.'.$phpEx);
set_time_limit(0); // Unlimited execution time
@@ -92,122 +62,6 @@ $months = array(
// ---------------
// Begin functions
//
-function clean_words($entry, &$search, &$replace)
-{
- // Weird, $init_match doesn't work with static when double quotes (") are used...
- static $init_match = array('^', '$', '&', '(', ')', '<', '>', '`', "'", '|', ',', '@', '_', '?', '%');
- static $init_replace = array(" ", " ", " ", " ", " ", " ", " ", " ", "", " ", " ", " ", " ", " ", " ");
-
- static $later_match = array("-", "~", "+", ".", "[", "]", "{", "}", ":", "\\", "/", "=", "#", "\"", ";", "*", "!");
- static $later_replace = array(" ", " ", " ", " ", " ", " ", " ", " ", " ", " " , " ", " ", " ", " ", " ", " ", " ");
-
- static $sgml_match = array("&nbsp;", "&szlig;", "&agrave;", "&aacute;", "&acirc;", "&atilde;", "&auml;", "&aring;", "&aelig;", "&ccedil;", "&egrave;", "&eacute;", "&ecirc;", "&euml;", "&igrave;", "&iacute;", "&icirc;", "&iuml;", "&eth;", "&ntilde;", "&ograve;", "&oacute;", "&ocirc;", "&otilde;", "&ouml;", "&oslash;", "&ugrave;", "&uacute;", "&ucirc;", "&uuml;", "&yacute;", "&thorn;", "&yuml;");
- static $sgml_replace = array(" ", "s", "a", "a", "a", "a", "a", "a", "a", "c", "e", "e", "e", "e", "i", "i", "i", "i", "o", "n", "o", "o", "o", "o", "o", "o", "u", "u", "u", "u", "y", "t", "y");
-
- static $accent_match = array("ß", "à", "á", "â", "ã", "ä", "å", "æ", "ç", "è", "é", "ê", "ë", "ì", "í", "î", "ï", "ð", "ñ", "ò", "ó", "ô", "õ", "ö", "ø", "ù", "ú", "û", "ü", "ý", "þ", "ÿ");
- static $accent_replace = array("s", "a", "a", "a", "a", "a", "a", "a", "c", "e", "e", "e", "e", "i", "i", "i", "i", "o", "n", "o", "o", "o", "o", "o", "o", "u", "u", "u", "u", "y", "t", "y");
-
- $entry = " " . strip_tags(strtolower($entry)) . " ";
-
- $entry = str_replace($sgml_match, $sgml_match, $entry);
- $entry = str_replace($accent_match, $accent_replace, $entry);
-
- // Replace line endings by a space
- $entry = preg_replace("/[\n\r]/is", " ", $entry);
- // Remove URL's
- $entry = preg_replace("/\b[a-z0-9]+:\/\/[a-z0-9\.\-]+(\/[a-z0-9\?\.%_\-\+=&\/]+)?/si", " ", $entry);
-
- // Filter out strange characters like ^, $, &, change "it's" to "its"
- // str_replace with arrays is buggy in some PHP versions so traverse the arrays manually ;(
- for($i = 0; $i < count($init_match); $i++)
- {
- $entry = str_replace($init_match[$i], $init_replace[$i], $entry);
- }
-
- // Quickly remove BBcode.
- $entry = preg_replace("/\[code:[0-9]+:[0-9a-z]{10,}\].*?\[\/code:[0-9]+:[0-9a-z]{10,}\]/is", " ", $entry);
- $entry = preg_replace("/\[img\].*?\[\/img\]/is", " ", $entry);
- $entry = preg_replace("/\[\/?[a-z\*=\+\-]+[0-9a-z]?(\:[a-z0-9]+)?:[a-z0-9]{10,}(\:[a-z0-9]+)?=?.*?\]/si", " ", $entry);
- // URLs
- $entry = preg_replace("/\[\/?[a-z\*]+[=\+\-]?[0-9a-z]+?:[a-z0-9]{10,}[=.*?]?\]/si", " ", $entry);
- $entry = preg_replace("/\[\/?url(=.*?)?\]/si", " ", $entry);
- // Numbers
- $entry = preg_replace("/\b[0-9]+\b/si", " ", $entry);
- // HTML entities like &1234;
- $entry = preg_replace("/\b&[a-z]+;\b/is", " ", $entry);
- // 'words' that consist of <2 or >50 characters are removed.
- $entry = preg_replace("/\b[a-z0-9]{1,2}?\b/si", " ", $entry);
- $entry = preg_replace("/\b[a-z0-9]{50,}?\b/si", " ", $entry);
-
- // Remove some more strange characters
- for($i = 0; $i < count($later_match); $i++)
- {
- $entry = str_replace($later_match[$i], $later_replace[$i], $entry);
- }
-
- return $entry;
-}
-
-function split_words(&$entry)
-{
- preg_match_all("/\b(\w[\w']*\w+|\w+?)\b/", $entry, $split_entries);
-
- return $split_entries[1];
-}
-
-function remove_common($percent, $delete_common = 0)
-{
- global $db;
-
- $sql = "SELECT COUNT(DISTINCT post_id) as total_posts
- FROM " . SEARCH_MATCH_TABLE;
- $result = query($sql, "Couldn't select post count");
-
- $total_posts = $db->sql_fetchrow($result);
-
- $total_posts = $total_posts['total_posts'];
-
- $common_threshold = floor($total_posts * ( $percent / 100 ));
-
- $sql = "SELECT word_id
- FROM " . SEARCH_MATCH_TABLE . "
- GROUP BY word_id
- HAVING count(word_id) > $common_threshold";
- $result = query($sql, "Couldn't select matches");
-
- $common_words = $db->sql_numrows($result);
-
- while($row = $db->sql_fetchrow($result))
- {
- $common_word_ids[] = $row['word_id'];
- }
- $db->sql_freeresult($result);
-
- if(count($common_word_ids) != 0)
- {
- $common_word_ids = implode(',',$common_word_ids);
- }
- else
- {
- // We didn't remove any common words
- return 0;
- }
-
- $sql = "UPDATE ". SEARCH_WORD_TABLE ."
- SET word_common = 1
- WHERE word_id IN ($common_word_ids)";
- $result = query($sql, "Couldn't update search_wordmatch table common word field");
-
- if( $delete_common)
- {
- $sql = "DELETE FROM ".SEARCH_MATCH_TABLE."
- WHERE word_id IN ($common_word_ids)";
- $result = query($sql, "Couldn't delete common words");
- }
-
- return $common_words;
-}
-
function common_header()
{
?>
@@ -1789,7 +1643,7 @@ if( !empty($next) )
{
print "<br>Removing common words (words that appear in more than $common_percent of the posts)<br>\n";
flush();
- print "Removed " . remove_common($common_percent, 1) . " words that where too common.<br>";
+ print "Removed " . remove_common_global($common_percent, 1) . " words that where too common.<br>";
}
}
@@ -1963,4 +1817,4 @@ if( !empty($next) )
print "<br />If the upgrade completed without error you may click <a href=\"index.$phpEx\">Here</a> to proceed to the index<br />";
-?> \ No newline at end of file
+?>