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.
//IMPORTANT: //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! // PLEASE EDIT file "DB.PHP" to reflect your database login info //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! require('db1845.php'); //establish database connection <------------------File needs to me edited to match your infomation 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['last'], $b['last']); //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 (!isset($_POST['area'])) $user_errors[]='No locality chosen.'; //Locality is not passed with POST 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 $area=safe($_POST['area']); //process POST value $name=safe($_POST['surname']); //process POST value $result = mysql_query('SELECT * FROM griffiths'); //get all from table of REGIONS/TOWNS called "Contents" if ($result===FALSE) $user_errors[]='Database ERROR, please try again later.'; //for some reason table is not found or else if (count($user_errors)==0){ //see if there are no previous errors in our error array $index=0; //reset while ($myrow = mysql_fetch_row($result)){//walk through the returned values $list[$index][0]=(int) $myrow[0]; //prim key $list[$index][1]=(string) $myrow[1];//name $list[$index][2]=(int) $myrow[2];//belongs_to $index++;//increment } $index=0; //reset //match the locality that was passed with POST to the table of Contents foreach ($list as $row){//walk through the array that holds data from SQL table "CONTENTS" we received ealier if ($row[1]==$area) {$index=$row[0]; break;} //got it, leave the loop } if (($index==0) && ($area!='Search All')) $user_errors[]='Locality is not recognized.'; //Did not find it then error or if it was SEARCH ALL then it is ok and no error } if (count($user_errors)==0){ //see if there are no previous errors in our error array foreach ($list as $row){//walk through the array that holds data from SQL table "CONTENTS" we received ealier if ((($index==0) && ($row[2]>0)) || (($index>0) &&($row[2]==$index))) $list_array[]=$row[1]; //If it is a region then get all sub-cities in the array, if it was ALL then get all cities in the array but no regions } if (count($list_array)==0) $list_array[0]=$list[$index-1][1]; //if passed was no region or all then it is a city and has no "children," assign it to itself $index=0;//reset $list=array();//reset array for RE-USE $temp = 0; if (strlen($_POST['xparish']) > 0) { $temp = 2; $xparish = $_POST['xparish']; } if (strlen($_POST['tland']) > 0) { $tland = $_POST['tland']; $temp++; } foreach ($list_array as $cell) {//walk through the array that holds the cities that need to be searched // $result = mysql_query('SELECT * FROM '.$cell.' WHERE lastname LIKE "%'.trim($surname).'%"'); //get all "like" records switch ($temp) { case 0 : $result = mysql_query('SELECT * FROM '.$cell.' WHERE lastname LIKE "%'.trim($name).'%"'); break; case 1 : $result = mysql_query('SELECT * FROM '.$cell.' WHERE lastname LIKE "%'.trim($name).'%" AND townland LIKE "%'.trim($tland).'%"'); break; case 2 : $result = mysql_query('SELECT * FROM '.$cell.' WHERE parish LIKE "%'.trim($xparish).'%" AND lastname LIKE "%'.trim($name).'%"'); break; case 3 : $result = mysql_query('SELECT * FROM '.$cell.' WHERE lastname LIKE "%'.trim($name).'%" AND townland LIKE "%'.trim($tland).'%" AND parish LIKE "%'.trim($xparish).'%"'); break; } 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]['last']=(string) $myrow[1]; //surname $list[$index]['first']=(string) $myrow[2];//first name $list[$index]['townland']=(string) $myrow[3];//age $list[$index]['parish']=(string) $myrow[4];//relation $list[$index]['county']=(string) $cell;//assignes current city that we search to this value (absent from database) $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['last']==$name){//if an exact match then copy to a new array and delete this value from the original array $match[$index_m]['last']=$list[$index]['last']; //copies the value $match[$index_m]['first']=$list[$index]['first'];//copies the value $match[$index_m]['townland']=$list[$index]['townland'];//copies the value $match[$index_m]['parish']=$list[$index]['parish'];//copies the value $match[$index_m]['county']=$list[$index]['county'];//copies the value unset($list[$index]); //remove value from memory $index_m++;//increment } elseif((strlen($val['last'])>strlen($name))&&(substr($val['last'],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]['last']=$list[$index]['last'];//copies the value $half_match[$index_h]['first']=$list[$index]['first'];//copies the value $half_match[$index_h]['townland']=$list[$index]['townland'];//copies the value $half_match[$index_h]['parish']=$list[$index]['parish'];//copies the value $half_match[$index_h]['county']=$list[$index]['county'];//copies the value unset($list[$index]);//remove value from memory $index_h++;//increment } $index++;//increment } } } ob_start('ob_gzhandler');//start compression of the next output ?>