"; $records = $x; $x=0; //remove unnecessary tags function filtertags($text){ $text = nl2br($text); $text = str_replace("
","",$text); $text = str_replace("
","",$text); $text = str_replace("'","",$text); $text = ereg_replace("^"," ",$text); $text = str_replace(".","",$text); $text = str_replace("?","",$text); $text = str_replace('"',"",$text); $text = str_replace('-',"",$text); $text = str_replace('!',"",$text); $text = str_replace(':',"",$text); $text = str_replace(';',"",$text); $text = strip_tags($text); $text = utility::removeTags($text); $text = trim($text); return $text; } //remove unnecessary characters function filterword($word){ $word = ereg_replace(",","",$word); $word = ereg_replace("\?","",$word); $word = ereg_replace("\(","",$word); $word = ereg_replace("\)","",$word); $word = ereg_replace("\.","",$word); $word = ereg_replace("\.","",$word); $word= strtolower($word); return $word; } //got through the array and input keywords into table with an associative id $wordcounter = 0; for ($x=0; $x < $records; $x++){ if ($SearchArray["text0"][$x] != ""){ $text = $SearchArray["text0"][$x]; //filter the record $text = filtertags($text); $text = filterword($text); $noise_words = file("_noisewords.txt"); //Remove all the noisewords, and transform whats left into an array for ($i=0; $i < count($noise_words); $i++) { $filterword = trim($noise_words[$i]); $filterword = strtolower($filterword); $text = eregi_replace(" $filterword ",",",$text); } $text = str_replace(" ",",",$text); $text = str_replace(",,",",",$text); $text = str_replace(",,",",",$text); //filter the words $text = trim($text); $text = addslashes($text); //create an array $eachword = explode(",", $text); for ($v=0; $v < count($eachword); $v++){ //refilter $word = filterword($eachword[$v]); if ($word != ""){ for ($n=0; $n < count($noise_words); $n++) { //ensure its not a noise word if (trim($noise_words[$n]) == $word){ $noise = 1; } } $parentid = (isset($SearchArray["parentid"][$x]))? "'".$SearchArray["parentid"][$x]."'" : "NULL"; if ($noise != 1){ $newrecord = database::db("REPLACE INTO lmsearch (keyword, tablename, id, parentid) VALUES ('". $word ."', '". $SearchArray["tablename"][$x] ."', ". $SearchArray["id"][$x] .", ". $parentid .")", "mysqlid"); $wordcounter++; } } $noise = 0; } } // if there is a text0 record //*******************//////check to see if there is a text1 record if ($SearchArray["text1"][$x] != ""){ $text = $SearchArray["text1"][$x]; //filter the record $text = filtertags($text); $text = filterword($text); $noise_words = file("_noisewords.txt"); //Remove all the noisewords, and transform whats left into an array for ($i=0; $i < count($noise_words); $i++) { $filterword = trim($noise_words[$i]); $filterword = strtolower($filterword); $text = eregi_replace(" $filterword ",",",$text); } $text = str_replace(" ",",",$text); $text = str_replace(",,",",",$text); $text = str_replace(",,",",",$text); //filter the words $text = trim($text); $text = addslashes($text); //create an array $eachword = explode(",", $text); for ($v=0; $v < count($eachword); $v++){ //refilter $word = filterword($eachword[$v]); if ($word != ""){ for ($n=0; $n < count($noise_words); $n++) { if (trim($noise_words[$n]) == $word){ $noise = 1; } } $parentid = (isset($SearchArray["parentid"][$x]))? "'".$SearchArray["parentid"][$x]."'" : "NULL"; if ($noise != 1){ $newrecord = database::db("REPLACE INTO lmsearch (keyword, tablename, id, parentid) VALUES ('". $word ."', '". $SearchArray["tablename"][$x] ."', ". $SearchArray["id"][$x] .", ". $parentid .")", "mysqlid"); $wordcounter++; } } $noise = 0; } } // if there is a text1 record //*******************//////check to see if there is a text2 record if ($SearchArray["text2"][$x] != ""){ $text = $SearchArray["text2"][$x]; //filter the record $text = filtertags($text); $text = filterword($text); $noise_words = file("_noisewords.txt"); //Remove all the noisewords, and transform whats left into an array for ($i=0; $i < count($noise_words); $i++) { $filterword = trim($noise_words[$i]); $filterword = strtolower($filterword); $text = eregi_replace(" $filterword ",",",$text); } $text = str_replace(" ",",",$text); $text = str_replace(",,",",",$text); $text = str_replace(",,",",",$text); //filter the words $text = trim($text); $text = addslashes($text); //create an array $eachword = explode(",", $text); for ($v=0; $v < count($eachword); $v++){ //refilter $word = filterword($eachword[$v]); if ($word != ""){ for ($n=0; $n < count($noise_words); $n++) { if (trim($noise_words[$n]) == $word){ $noise = 1; } } $parentid = (isset($SearchArray["parentid"][$x]))? "'".$SearchArray["parentid"][$x]."'" : "NULL"; if ($noise != 1){ $newrecord = database::db("REPLACE INTO lmsearch (keyword, tablename, id, parentid) VALUES ('". $word ."', '". $SearchArray["tablename"][$x] ."', ". $SearchArray["id"][$x] .", ". $parentid .")", "mysqlid"); $wordcounter++; } } $noise = 0; } } // if there is a text2 record $noise = 0; } //close main loop echo "Added ".$wordcounter." keywords"; ?>