TYPE: CODE FRAGMENT VERSION: VERSION 1.0 Requires: no_search_words.txt, no_search_tables.txt
Php / **************************************************************** ********************************************************* JHSearch () WAS Written by James R Hartford Jhsearch () May Be Used and Modified Free, But i ask that you please note the original author (James R Hartford) and refer to the function by its original name (JHsearch ()) If you do make changes that I may find useful, please email them to jim@jarzion.com and I will INCLUDE YOUREURCH () Database connection is set up for mysql but can be change if needed. ****************************************************************************************************** *********************************************************** / ////////// '' '' '' '' '' '' '' '' '' '' '' '' '' '' ' ''; / **************************************************************** ****************************** BELOW IS An Example of How The JHSearch Function Can Be Used and Display Test for the Table Name and Display The Resul Table. **************************************************************************************************************************************************************************************************************** *************************************************** / $ SearchResult = JHSearch ("Test A"); if ($ SearchResult) <1) {$ OTPUT = "No results {$ sr = array_keys ($ searchResult); for ($ I = 0; $ I ) {IF ($ SR [$ SR] $ I] == "Site_info") {// this is checking to see reason the table name is Media for ($ C = 0; $ C
}}}} ($ SR [$ I] == "Class") {// this is checking to see reason the table name is Media for ($ C = 0; $ SEARCHRESULT [$ SR [$ I ]); $ C ) {Echo "Class:". $ SearchResult [$ SR [$ I]] [$ C] ['Title']. " Array_diff ($ TABLES, $ TABLETAKEOUT); $ TABLES = Jharray_reIndex ($ TABLES); $ RESULTCOUNT = 0; // Build The Search Query for ($ I = 0; $ TABLES) && Count ($ SEARCHCRIT) > 0; $ i ) {$ query = "Select * from"; $ query. = $ TABLES [$ I]. "Where"; $ q = "show fields from". $ TABLES [$ I]; $ fields = JhrQuery ($ = 0; $ m } IF ($ TABLES [$ I]] [0]! = "") {$ RealResult [$ TABLES [$ I]] = TempResult [$ TABLES [$ I]];}} Return $ RealResult; } / ******************************************************* ******** Function: Jhgetnos ($ where); purpose: paare a text file to find out what not to search author: james r Hartford ************** *********************************************************************************************************************** {// Get the Words That Should Not Be Searched for if ($ Where == "Words") {$ filename = "no_search_words.txt";} // Get the Tables That Should Not Be Searched Else IF ($ Where == "Tables") {$ filename = "no_search_tables.txt";} $ handle = fopen ($ FileName, "R"); $ Contents = Explode ("", FREAD ($ Handle, FileSize)); fclose ($ handle); return $ contents;} / *************************************************** ***************** Function: jharray_reindex ($ array); purpose: Reindex an Array Author: James r Hartford ************** ***************************** **************** / Function Jharray_reIndex ($ SomeArray) {$ Keys = Array_Keys ($ SomeArray); for ($ I = 0; $ I
";}}} / * #### ######################################################################################################################################################################################################################################################################################################## ######## ################################################################################################################################################################################################################################################################################################## ############## ********************************* ****************************************** Function: JHSearch ($ search_string) Purpose: Search An entire Database and return the results in a 3 dimensional array Words found in no_search_words.txt will not be searched Table names found in no_search_tables.txt will not be searched result example:... $ result [table_name] [row] [field_name] Author: James R Hartford * *********************************************************** ********* / Function JHSearch ($ String) {$ newstring = $ string; $ searchcrit = expedition ("", $ newstr ing); // get the words to be searched $ dontsearchwords = JHgetnos ( "words"); // get the words not to search into an array // get the actual search criteria $ searchcrit = array_diff ($ searchcrit, $ dontsearchwords) $ Searchcrit = jharray_reindex ($ searchcrip); // get the tables to search $ query = "show tables"; $ TABLES = JHRQUERY ($ query); for ($ i = 0; $ i
"; $ tempResult [$ tables [$ i]] = JHRquery ($ query);