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/exam_list_by_entity.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);
$refr = $_SERVER['HTTP_REFERER'];
//if($refr!='')
//{
	$json = file_get_contents('php://input');
	$data = json_decode($json);
	$slug = $data->slug;


	if(isset($slug))
	{
		$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 and sel.status!='0' and se.status!='0' order by sel.update_date desc limit 200 ";
		$sqlExamData=$db->prepare($examData);
		$sqlExamData->execute();
		
		$examArray = array();

		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("exam_name"=>$exam_name,"exam_link"=>$links,"url_slug"=>$url_slug,"display_text"=>$display_text, "entity_name"=>$entity_name, "entity_slug"=>$slug, "category_name"=>$cat_name, "cat_image"=>$img, "date"=>$date,"date_type"=>$date_type);
			$examArrayMain[]=$examArray;
		}
	}
else
{
	$examArray=array("status"=>"error","message"=>"unauthorized access",);
	$examArrayMain[]=$examArray;
}

echo json_encode($examArrayMain);