Fáilte Romhat
The site is back online but there are issues with some search pages and the gallery. I am working on correcting these.
require('db1851.php'); foreach ($_POST as $key=>$var) $_POST[$key]=str_replace('`','',$_POST[$key]); //This function gets text from _POST and tweaks it to our needs then returns modified text function safe($text){ $text=(string) $text; //make sure it is a string $text=utf8_decode($text); //decode to a normal char set $text=stripslashes($text);//remove any slashes inputted by POST $text=strip_tags($text); //remove any tags that might high-jack the script $text=strtolower($text);//make letters of small case (esspecially the REGIONS that come capitalized) $text=ucwords($text);// make first letter of each word capital $text=trim($text);//remove any white space on the sides return $text; //return string } //This function is for ordering and sorting the array function comp($a, $b) { return strnatcasecmp($a['i_sname'], $b['i_sname']); //returns a value based on the sort decision } //declare our arrays $list_array=array(); //these will hold the output values $list=array(); $match=array(); $half_match=array(); $user_errors=array(); //start testing input if (count($_POST)==0) $user_errors[]='No search string received.'; //POST is empty, nothing is passed if (count($user_errors)==0) //see if there are no previous errors in our error array if ($db===FALSE) $user_errors[]='Database ERROR, please try again later.';//Stop processing because of a database connection failure if (count($user_errors)==0){ //see if there are no previous errors in our error array if (strlen($_POST['surname']) ==0) $user_errors[]='No "Surname" was specified.'; //Surname is not passed with POST elseif (strlen(trim(stripslashes($_POST['surname']))) <3) $user_errors[]='There should be at least three letters in "Surname".'; //Surname is too short (too many matches will be produced killing performance) elseif (strlen(trim(stripslashes($_POST['surname']))) >20) $user_errors[]='"Surname" is over limit of 20 characters.'; //Way to big a string, will overload a database as well } if (count($user_errors)==0){ //see if there are no previous errors in our error array $name=safe($_POST['surname']); //process POST value $index=0;//reset $list=array();//reset array for RE-USE $result = mysql_query('SELECT * FROM monaghanhearth WHERE i_sname LIKE "%'.trim($name).'%"'); if ((mysql_num_rows($result)>0) || ($result ===FALSE)) { //see if anything was returned while ($myrow = mysql_fetch_row($result)){ //walk through the returned values $list[$index]['i_sname']=(string) $myrow[1]; $list[$index]['i_townland']=(string) $myrow[2]; $list[$index]['i_parish']=(string) $myrow[3]; $list[$index]['i_barony']=(string) $myrow[4]; $list[$index]['i_link']=(string) $myrow[5]; $index++;//increment } } mysql_free_result($result);//free memory usort($list, 'comp'); //sort array based on the last name (see function 'comp()' ) $index=0;//reset $index_m=0;//new index $index_h=0;//new index foreach ($list as $val){//walk through the array that has all the values with the "like" surnames if ($val['i_sname']==$name){//if an exact match then copy to a new array and delete this value from the original array $match[$index_m]['i_sname']=$list[$index]['i_sname']; $match[$index_m]['i_townland']=$list[$index]['i_townland']; $match[$index_m]['i_parish']=$list[$index]['i_parish']; $match[$index_m]['i_barony']=$list[$index]['i_barony']; $match[$index_m]['i_link']=$list[$index]['i_link']; unset($list[$index]); $index_m++;//increment } elseif((strlen($val['i_sname'])>strlen($name))&&(substr($val['i_sname'],0,strlen($name))==$name)){ //if starts with the search string then copy to a new array and delete this value from the original array $half_match[$index_h]['i_sname']=$list[$index]['i_sname']; $half_match[$index_h]['i_townland']=$list[$index]['i_townland']; $half_match[$index_h]['i_parish']=$list[$index]['i_parish']; $half_match[$index_h]['i_barony']=$list[$index]['i_barony']; $half_match[$index_h]['i_link']=$list[$index]['i_link']; unset($list[$index]); $index_h++;//increment } $index++;//increment } } ob_start('ob_gzhandler');//start compression of the next output ?>