rendered paste body<?if(!$includes){include("fabrication/includes/phpbin/system/database.php");} //remove old records //$delete = database::db("DELETE from lmsearch"); //search the lovemark, lmuser, lmcomment and lmvideo tables //search the _fr_page, _fr_page1, _fr_collection, _fr_collection1, _fr_collection2 $qLovemark = database::db("SELECT lovemarkid, lmname FROM lovemark WHERE status = 0", "multi"); $qUser = database::db("SELECT lmuserid, firstname, lastname, occupation FROM lmuser WHERE status = 0 and verified = 1", "multi"); $qComment = database::db("SELECT lmcommentid, commentheading, commenttext, lovemarkid FROM lmcomment WHERE status = 0", "multi"); $qVideo = database::db("SELECT lmvideoid, videoheading, videotext, lovemarkid FROM lmvideo WHERE status = 0", "multi"); $qPage = database::db("SELECT _fr_navid, pagename, pagedesc FROM _fr_page WHERE status = 0", "multi"); $qPage1 = database::db("SELECT _fr_page1id, _fr_pageid, page1name, page1desc FROM _fr_page1 WHERE status = 0", "multi"); $qCollection = database::db("SELECT _fr_navid, collectionname, collectiondesc FROM _fr_collection WHERE status = 0", "multi"); $qCollection1 = database::db("SELECT _fr_collection1id, _fr_collectionid, collection1name, collection1desc FROM _fr_collection1 WHERE status = 0", "multi"); $qCollection2 = database::db("SELECT _fr_collection2id, _fr_collection1id, collection2name, collection2desc FROM _fr_collection2 WHERE status = 0", "multi"); $counter1 = count($qLovemark["lovemarkid"]); $counter2 = $counter1+count($qUser["lmuserid"]); $counter3 = $counter2+count($qComment["lmcommentid"]); $counter4 = $counter3+count($qVideo["lmvideoid"]); $counter5 = $counter4+count($qPage["_fr_navid"]); $counter6 = $counter5+count($qPage1["_fr_pageid"]); $counter7 = $counter6+count($qCollection["_fr_navid"]); $counter8 = $counter7+count($qCollection1["_fr_collectionid"]); $counter9 = $counter8+count($qCollection2["_fr_collection1id"]); $r = 0; //reset the counter for each loop $SearchArray = Array (); for ($x=0; $x < $counter1; $x++){ $SearchArray["id"][$x] = $qLovemark["lovemarkid"][$r]; $SearchArray["text0"][$x] = $qLovemark["lmname"][$r]; $SearchArray["tablename"][$x] = "lovemark"; $r++; } $r = 0; for ($x=$counter1; $x < $counter2; $x++){ $SearchArray["id"][$x] = $qUser["lmuserid"][$r]; $SearchArray["text0"][$x] = $qUser["firstname"][$r]; $SearchArray["text1"][$x] = $qUser["lastname"][$r]; $SearchArray["text2"][$x] = $qUser["occupation"][$r]; $SearchArray["tablename"][$x] = "lmuser"; $r++; } $r = 0; for ($x=$counter2; $x < $counter3; $x++){ $SearchArray["id"][$x] = $qComment["lmcommentid"][$r]; $SearchArray["parentid"][$x] = $qComment["lovemarkid"][$r]; $SearchArray["text0"][$x] = $qComment["commentheading"][$r]; $SearchArray["text1"][$x] = $qComment["commenttext"][$r]; $SearchArray["tablename"][$x] = "lmcomment"; $r++; } $r = 0; for ($x=$counter3; $x < $counter4; $x++){ $SearchArray["id"][$x] = $qVideo["lmvideoid"][$r]; $SearchArray["parentid"][$x] = $qVideo["lovemarkid"][$r]; $SearchArray["text0"][$x] = $qVideo["videoheading"][$r]; $SearchArray["text1"][$x] = $qVideo["videotext"][$r]; $SearchArray["tablename"][$x] = "lmvideo"; $r++; } $r = 0; for ($x=$counter4; $x < $counter5; $x++){ $SearchArray["id"][$x] = $qPage["_fr_navid"][$r]; $SearchArray["text0"][$x] = $qPage["pagename"][$r]; $SearchArray["text1"][$x] = $qPage["pagedesc"][$r]; $SearchArray["tablename"][$x] = "_fr_page"; $r++; } $r = 0; for ($x=$counter5; $x < $counter6; $x++){ $SearchArray["id"][$x] = $qPage1["_fr_page1id"][$r]; $SearchArray["parentid"][$x] = $qPage1["_fr_pageid"][$r]; $SearchArray["text0"][$x] = $qPage1["page1name"][$r]; $SearchArray["text1"][$x] = $qPage1["page1desc"][$r]; $SearchArray["tablename"][$x] = "_fr_page1"; $r++; } $r = 0; for ($x=$counter6; $x < $counter7; $x++){ $SearchArray["id"][$x] = $qCollection["_fr_navid"][$r]; $SearchArray["text0"][$x] = $qCollection["collectionname"][$r]; $SearchArray["text1"][$x] = $qCollection["collectiondesc"][$r]; $SearchArray["tablename"][$x] = "_fr_collection"; $r++; } $r = 0; for ($x=$counter7; $x < $counter8; $x++){ $SearchArray["id"][$x] = $qCollection1["_fr_collection1id"][$r]; $SearchArray["parentid"][$x] = $qCollection1["_fr_collectionid"][$r]; $SearchArray["text0"][$x] = $qCollection1["collection1name"][$r]; $SearchArray["text1"][$x] = $qCollection1["collection1desc"][$r]; $SearchArray["tablename"][$x] = "_fr_collection1"; $r++; } $r = 0; for ($x=$counter8; $x < $counter9; $x++){ $qGetParent = database::db("SELECT _fr_collectionid FROM _fr_collection1 WHERE _fr_collection1id = ".$qCollection2["_fr_collection1id"][$r], "single"); $SearchArray["id"][$x] = $qCollection2["_fr_collection2id"][$r]; $SearchArray["parentid"][$x] = $qGetParent["_fr_collectionid"]; $SearchArray["text0"][$x] = $qCollection2["collection2name"][$r]; $SearchArray["text1"][$x] = $qCollection2["collection2desc"][$r]; $SearchArray["tablename"][$x] = "_fr_collection2"; $r++; } echo $x." records<br /><br /><br />"; $records = $x; $x=0; //remove unnecessary tags function filtertags($text){ $text = nl2br($text); $text = str_replace("<br />","",$text); $text = str_replace("<br>","",$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 recordif ($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 recordif ($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"; ?>