header("Content-Type: text/html;charset=UTF-8");
$text_id = $_REQUEST['text_id'];
require 'config.php';
$conn=mysqli_connect($mysqlhost,$mysqluser,$mysqlpass,$dbname) or die("Could not connect to MySQL database.");
mysqli_set_charset($conn,'utf8');
$query="select search_text from search_texts where text_id=$text_id";
$result=mysqli_query($conn,$query);
$row=mysqli_fetch_array($result);
$search_text=$row[0];
mysqli_free_result($result);
function remove_date($conn,$text)
{
$days_found="No";
$date_found="No";
$tmp = explode(' ...',$text);
$first_part=$tmp[0];
$space_split=explode(' ',$first_part);
if((count($space_split)>=3)and(count($space_split)<=5))
{
//------- check days & hours -----
$query2 = "SELECT count(*) FROM check_days WHERE word='$first_part'";
$result2 = mysqli_query($conn,$query2);
$row2 = mysqli_fetch_array($result2);
$days_check=$row2[0];
mysqli_free_result($result2);
if($days_check>0)
{
$days_found="Yes";
}
//---------------------------
//------- check date --------
if($days_found=="No")
{
$en_month=$space_split[0];
$french_month=$space_split[1];
$year=$space_split[2];
$query3 = "SELECT count(*) FROM check_months WHERE word='$en_month' or word='$french_month'";
$result3 = mysqli_query($conn,$query3);
$row3 = mysqli_fetch_array($result3);
$month_check=$row3[0];
mysqli_free_result($result3);
if(($month_check>0)&&($year>=1970)&&($year<=2090))
{
$date_found="Yes";
}
if(count($space_split)>3)
{
$month1=$space_split[1];
$month2=$space_split[2];
$year=$space_split[3];
$query4 = "SELECT count(*) FROM check_months WHERE word='$month1' or word='$month2'";
$result4 = mysqli_query($conn,$query4);
$row4 = mysqli_fetch_array($result4);
$month_check=$row4[0];
mysqli_free_result($result4);
if(($month_check>0)&&($year>=1970)&&($year<=2090))
{
$date_found="Yes";
}
$month1=$space_split[1]." ".$space_split[2];
$month2=$space_split[3];
$year=$space_split[4];
$query5 = "SELECT count(*) FROM check_months WHERE word='$month1' or word='$month2'";
$result5 = mysqli_query($conn,$query5);
$row5 = mysqli_fetch_array($result5);
$month_check=$row5[0];
mysqli_free_result($result5);
if(($month_check>0)&&($year>=1970)&&($year<=2090))
{
$date_found="Yes";
}
}
}
//---------------------------
}
if(($days_found=="Yes")||($date_found=="Yes"))
{
unset($tmp[0]);
$text=implode(' ...',$tmp);
}
return $text;
}
?>
echo $search_text; ?>
$query="select title,result_id,text from search_results where text_id=$text_id";
$result=mysqli_query($conn,$query);
?>
while($row=mysqli_fetch_array($result))
{
$title=$row[0];
$url=$site_path."r.php?url=".$row[1];
$text=remove_date($conn,$row[2]);
?>
|
}
mysqli_free_result($result);
?>
$query="select text_id,search_text from search_texts where text_id!=$text_id order by rand() limit 30";
$result=mysqli_query($conn,$query);
?>
while($row=mysqli_fetch_array($result))
{
$text_id=$row[0];
$search_text=$row[1];
?>
|
}
mysqli_free_result($result);
?>
mysqli_close($conn);
require 'footer.php';
?>