HEX
Server: Apache/2.4.58 (Ubuntu)
System: Linux ip-172-31-18-78 6.17.0-1017-aws #17~24.04.1-Ubuntu SMP Tue May 26 21:09:53 UTC 2026 aarch64
User: ubuntu (1000)
PHP: 8.2.31
Disabled: NONE
Upload Files
File: /var/www/nclive/backend/filter_examlist.php
<?php
header("Access-Control-Allow-Origin: *");
header('Content-Type: application/json');
include "config.php";
	// ini_set('display_errors', 1);
	// ini_set('display_startup_errors', 1);
	// error_reporting(E_ALL);
	$json = file_get_contents('php://input');
	$data = json_decode($json);
	$slug = $data->slug;
	$filterType=$data->filter;
if($filterType=='today'){
	$current=date('Y-m-d');
	$filterDate = "and date(sel.update_date)='$current'";
	$type = "Today";

} else if ($filterType=='yesterday'){
	$current=date('Y-m-d',strtotime('-1 days'));
	$filterDate = "and date(sel.update_date)='$current'";
	$type = "Yesterday";

} else if ($filterType=='lastweek'){
	$current=date('Y-m-d',strtotime('-7 days'));
	$filterDate = "and date(sel.update_date)>='$current'";
	$type = "Last Week";

} else if ($filterType=='lastmonth'){
	$current=date('Y-m-d',strtotime('-30 days'));
	$filterDate = "and date(sel.update_date)>='$current'";
	$type = "Last Month";

} else {
	$filterDate = "";
	$type = "All";
}

 $examData="select sel.exam_id, sel.entity_id, sel.display_text, sel.links, sel.date_type, sel.date, see.name as entity_name, se.exam_name, se.url_slug, cat.name as category_name, cat.img_icon FROM sp_exam_links as sel LEFT JOIN sp_exam_links as sel2 ON (sel2.exam_id=sel.exam_id AND sel.entity_id=sel2.entity_id AND sel.id > sel2.id ) LEFT JOIN sp_exam_entity as see ON see.id=sel.entity_id LEFT JOIN sp_exam as se on se.exam_id=sel.exam_id LEFT JOIN sp_exam_category as cat ON cat.cat_id=se.cat_id WHERE see.entity_id='$slug' and sel2.id IS NULL $filterDate and sel.status!='0' and se.status!='0' group by sel.exam_id order by sel.update_date desc";
	$sqlExamData=$db->prepare($examData);
	$sqlExamData->execute();
	$number_of_rows = $sqlExamData->rowCount(); 
	$examArray = array();
	if($number_of_rows==0)
	{
		$examArray[]=array("type"=>$type,"exam_name"=>"No New Updates","exam_link"=>"","url_slug"=>"","display_text"=>"", "entity_name"=>"","category_name"=>"","cat_image"=>"", "date"=>"","date_type"=>"");
	}
	else
	{

		while($rowExamData=$sqlExamData->fetch())
		{
			$links = $rowExamData["links"];
			$exam_name = $rowExamData["exam_name"];
			$url_slug = $rowExamData["url_slug"];
			$display_text = $rowExamData["display_text"];
			$date_type = $rowExamData["date_type"];
			$dates = $rowExamData["date"];
			$entity_name = $rowExamData["entity_name"];
			$category_name = $rowExamData["category_name"];
			$img_icon='/images/'.$rowExamData["img_icon"];
			if($category_name==""){
				$cat_name = "State";
				$img = '/images/entrance_exams.png';
			} else{
				$cat_name = $category_name;
				$img = $img_icon;
			}
			
			$date="";
			if($date_type=="N"){
				$d=explode(",",$dates);
				$e=array();
				for($p=0;$p<count($d);$p++){
					$new_date = date('d M Y', strtotime($d[$p]));
					$e[]=$new_date;
					$date=implode(" , ",$e);
				}
			}
			if($date_type=="FT"){
				$dd=explode(",",$dates);
				$date1 = date('d M Y', strtotime($dd[0]));
				$date2 = date('d M Y', strtotime($dd[1]));
				$date=' From '.$date1.' To '.$date2;
			}

			$examArray[]=array("type"=>$type,"exam_name"=>$exam_name,"exam_link"=>$links,"url_slug"=>$url_slug,"display_text"=>$display_text, "entity_name"=>$entity_name,"category_name"=>$cat_name,"cat_image"=>$img, "date"=>$date,"date_type"=>$date_type);
			
		}
	}
	$ExamList=array("ExamList"=>$examArray);

	echo json_encode($ExamList);