<?php
require_once("varables.php");

$myJSON["notifs"]=array();
$myJSON['success']="خطای اعتبار سنجی";
 
if(isset($_POST["nekot"]) && isset($_POST["an1d"]))
if($_POST["nekot"] == "19911")
{
    $connect = @mysqli_connect($hostname,$username,$password,$database);
    if($connect)
    {
		@mysqli_query($connect,"SET CHARACTER SET utf8;");
		$query_all = "SELECT * FROM tbl_notifications WHERE type = 'C' ORDER BY id DESC";
		$result = @mysqli_query($connect,$query_all);
		if($result){
			while($row = @mysqli_fetch_assoc($result))	{
				if(addNumbers($row["nDate"],(int)$row["nExpire"]))
					array_push($myJSON["notifs"], $row);
				else{	
					$idd = $row["id"];
					$qd = "DELETE FROM tbl_notifications WHERE id = '".$idd."'";
					 @mysqli_query($connect,$qd);
					}
			}
			$myJSON['success']="200";
		}
			else {
				$myJSON['success']=@mysqli_error($connect);
			}
	}
	 else
		 $myJSON['success']=@mysqli_error($connect);
}
echo json_encode($myJSON);
?>
