<?php
define("root", $_SERVER['DOCUMENT_ROOT']);
session_start();
require(root."/___simple_config.php");
require(root."/".adminFolder."/_common.php");
require(root."/".adminFolder."/_lib/db.php");
require(root."/".adminFolder."/_lib/main.php");
require(root."/".adminFolder."/_lib/mail.php");
global $mainHttpHost;
$pageUrl = "/".adminFolder."/alerts";
$a=cekpost(cleanQuery($_REQUEST["a"]), "");
if ($a=="notifonce") {
	if ($b=="nobar") {
		if (isset($_SESSION["notifnobar"]) && $_SESSION["notifnobar"]!="") {
			echo 0;
		} else {
			echo 1;
			$_SESSION["notifnobar"] = 1;
		}
	}
}
if ($a=="check") {
	$b=cekpost(cleanQuery($_REQUEST["b"]), "");
	$lempar = '';
	if ($b=="sms") {
		$lempar = getSMSCreditCP();
	} else 
	if ($b=="nobar") {
		$stgl = date('d-m-Y', time());
		$etgl = $stgl;
		$q_stgl = strtotime($stgl);
		$q_etgl = strtotime($etgl)+86400;
		
		$rs=array(); $q = "SELECT * FROM stream_match WHERE 1=1 
			AND UNIX_TIMESTAMP(FROM_UNIXTIME(tanggal))>=UNIX_TIMESTAMP(FROM_UNIXTIME(".$q_stgl.")) 
			AND UNIX_TIMESTAMP(FROM_UNIXTIME(tanggal))< UNIX_TIMESTAMP(FROM_UNIXTIME(".$q_etgl.")) 
			ORDER BY tanggal";
		callRS($rs, $q);
		if (count($rs)!=0) {
			for ($i=0;$i<count($rs);$i++) {
				$startTime = $rs[$i]["tanggal"] - (15 * 60);
				$startTime = $rs[$i]["tanggal"];
				if (isset($rs[$i]["video_stream"]) && trim($rs[$i]["video_stream"])!="" && trim($rs[$i]["video_stream"])!='<div class="video-wrapper"></div>') {
				} else {
					if (isset($rs[$i]["video_highlight"]) && trim($rs[$i]["video_highlight"])!="" && trim($rs[$i]["video_highlight"])!='<div class="video-wrapper"></div>') {						
					} else {
						if ($startTime<=time() && (time()-$startTime)<=(15*60)) {
							$lempar = "nonton";
						} else 
						if ($startTime>=time() && ($startTime-time())<=(15*60)) {
							$lempar = "nonton";
						}
					}
				}
			}
		} else {
			
		}
	} else 
	if ($b=="all") {
		$rs=array();$q="SELECT COUNT(kddeposit) AS jdepo FROM deposits WHERE isactive=1 AND ispending=1";
		callRS($rs, $q);
		
		$lempar .= "deposit";
		$lempar .= "$";
		$lempar .= $rs[0]["jdepo"];
		$lempar .= "$$";
		
		$rs=array();$q="SELECT COUNT(kdwithdraw) AS jwd FROM withdraws WHERE isactive=1 AND ispending=1";
		callRS($rs, $q);
		
		$lempar .= "withdraw";
		$lempar .= "$";
		$lempar .= $rs[0]["jwd"];
		$lempar .= "$$";
		
		$rs=array();$q="SELECT COUNT(kdmember) AS jmem FROM members WHERE isactive=1 AND kdaccount=0 AND isdeleted=0";
		callRS($rs, $q);
		
		$lempar .= "member";
		$lempar .= "$";
		$lempar .= $rs[0]["jmem"];
		#$lempar .= "$$";
		#$lempar .= "x";
	}
	echo $lempar;
}
?>