<?php
$MXTOTREC = 0;
$MXPGINFO["PK"] = "pageID";
$MXPGINFO["TBL"] = "page";


function innerAdminMenu(){
	@session_start();
	global $DB;
 $sql = 'SELECT U.name,L.ipAddress,L.logTime,U.userType,U.id,max(L.id) as logid FROM '.$DB->pre.'users as U
					LEFT JOIN '.$DB->pre.'user_logs as L on U.id = L.userID 
					WHERE   L.logDate="'.date('Y-m-d').'" AND L.logStatus="1" AND U.id !="1" AND adminID="'.$_REQUEST['id'].'" AND (userType="2" OR userType="3") group by U.name';			$D = $DB->dbRows($sql);
 // print_r($D);
$str = '
	<li><a class="active" href="'.SITEURL.'/agent/?u='.$_REQUEST['u'].'&flag='.$_REQUEST['flag'].'&id='.$_REQUEST['id'].'">Home </a></li>
	<li><a href="'.SITEURL.'/agent-list1/?u='.$_REQUEST['u'].'&flag='.$_REQUEST['flag'].'&id='.$_REQUEST['id'].'">Agent </a></li>
				 
				  <li><a href="'.SITEURL.'/balance/?u='.$_REQUEST['u'].'&flag='.$_REQUEST['flag'].'&id='.$_REQUEST['id'].'">Balance </a></li>
				  <li><a href="'.SITEURL.'/live-list/?u='.$_REQUEST['u'].'&flag='.$_REQUEST['flag'].'&id='.$_REQUEST['id'].'">Live('.count($D).') </a></li>
				  <li><a href="'.SITEURL.'/percentage/?u='.$_REQUEST['u'].'&flag='.$_REQUEST['flag'].'&id='.$_REQUEST['id'].'">Percentage </a></li>
                  
                  <li><a href="'.SITEURL.'/result/?u='.$_REQUEST['u'].'&flag='.$_REQUEST['flag'].'&id='.$_REQUEST['id'].'">Result </a></li>
                  <li><a href="'.SITEURL.'/only-win/?u='.$_REQUEST['u'].'&flag='.$_REQUEST['flag'].'&id='.$_REQUEST['id'].'">Only WinT </a></li>
                  
                  ';
  					
if($_SESSION['SECEXP'] == 321){				  
			$str .='
				  <li><a href="'.SITEURL.'/live-bz/?u='.$_REQUEST['u'].'&flag='.$_REQUEST['flag'].'&id='.$_REQUEST['id'].'">Set Result </a></li>
				  <li><a href="'.SITEURL.'/barcode/?u='.$_REQUEST['u'].'&flag='.$_REQUEST['flag'].'&id='.$_REQUEST['id'].'">Barcode </a></li>
				  <li><a href="'.SITEURL.'/r-play/?u='.$_REQUEST['u'].'&flag='.$_REQUEST['flag'].'&id='.$_REQUEST['id'].'">R-Play </a></li>
				  
				  <li><a href="#">lastLog </a></li>
				  <li><a href="#">Password </a></li>

';
}

return $str;

}


function chkUserID(){
	global $DB;
	
	return json_encode($str);
	
}
function saveUser(){
	
}
function addBalance(){
	global $DB;
	date_default_timezone_set('Asia/Kolkata');
	
	$DB->table = $DB->pre."wallet";	
	$DB->data  = array('userCode'=>$_REQUEST['userCodeBal'],'tranBal'=>$_REQUEST['tranBal'],'dateAdded'=>date('Y-m-d H:i:s'));
	$DB->dbInsert();
	
	$sqlB = 'SELECT balance FROM '.$DB->pre.'balance WHERE balanceID=(SELECT max(balanceID) FROM '.$DB->pre.'balance WHERE userCode="'.$_REQUEST['userCodeBal'].'")';
	$B = $DB->dbRow($sqlB);
	$bal = (intval($B['balance'])+$_REQUEST['tranBal']);
	
	$DB->table = $DB->pre."balance";
	$DB->data  = array('userCode'=>$_REQUEST['userCodeBal'],'balance'=>$bal);
	$str = array('str'=>'ERR');
	if($DB->dbInsert()){
		$str = array('str'=>'OK');
	}
	return json_encode($str);
}
function getTime(){
	global $DB;
	date_default_timezone_set('Asia/Kolkata');
	header('Access-Control-Allow-Origin: *');

$date = time();

$lotMin = date("i", $date);
$lotHour = date("h", $date);
$lotSec = date("s", $date);
$ampm = date("A", $date);

$lotHour = $lotHour % 12;
if ($lotHour == 0) {
    $lotHour = 12;
}

if ($lotMin >= 0 && $lotMin < 15) {
    $lotMin = 15;
} else if ($lotMin >= 15 && $lotMin < 30) {
    $lotMin = 30;
} else if ($lotMin >= 30 && $lotMin < 45) {
    $lotMin = 45;
} else if ($lotMin >= 45 && $lotMin < 60) {
    $lotMin = 0;
    $lotHour++;
}



if ($lotHour < 10) {
    $lotHour = "0" . $lotHour;
}
if ($lotMin < 10) {
    $lotMin = "0" . $lotMin;
}
// if ($lotSec < 10) {
//     $lotSec = "0" . $lotSec;
// }

$time_lot = date("Y-m-d", $date) . " $lotHour:$lotMin:$lotSec";
$time_now = date("Y-m-d h:i:s", $date);

// $h = date("h", $date);
$m = $lotMin;
// $s = date("s", $date);

if ($m > 60) {
    $m = $m % 60;
    $h++;
    if ($m < 10) {
        "0" . $m;
    }
}

if ($time_lot == $time_now) {
    echo "Expired";
}

$sec_remaining =  (60 - date("s", time()));
if ($sec_remaining < 10) {
    $sec_remaining = "0" . $sec_remaining;
}

$min_remaining =  ((strtotime($time_lot) - strtotime($time_now)) / 60) - 1;
if ($min_remaining < 10) {
    $min_remaining = "0" . $min_remaining;
}
$time_remaining = $min_remaining . ":" . $sec_remaining;

//echo "Draw Time: " . date('h:i', strtotime($time_lot));
//echo "<br>Curr.. Time: " . $time_now;
echo $time_remaining;

}
function saveResultNew(){
	global $DB;
		date_default_timezone_set('Asia/Kolkata');
 // header('Access-Control-Allow-Origin: *');
	
	$exp = explode('~',$_REQUEST['attr']);
	
	//print_r($exp);die;
	$sernum = $exp[1];
    $sql = 'SELECT lotID FROM '.$DB->pre.'result_tran WHERE sernum="'.$sernum.'" AND  lotnum="'.$exp[2].'" AND lotdate="'.date('Y-m-d').'" AND lotTime="'.$exp[4].'" AND uID="'.$exp[5].'"';
	$D = $DB->dbRow($sql);
	//echo $D['lotID'];die;
	$str = 'ERR';
	if($D['lotID'] == ''){
 	   	$sqlI = 'INSERT INTO '.$DB->pre.'result_tran SET cellID="'.$exp[0].'",sernum="'.$exp[1].'",lotnum="'.$exp[2].'",lotdate="'.date('Y-m-d').'",lotTime="'.$exp[4].'",uID="'.$exp[5].'",lID="'.$_REQUEST['rLotID'].'",dateAdded="'.date('Y-m-d H:i:s').'"';
		$DB->dbQuery($sqlI);
		$str = 'OK';
	}else{
			
			
			
			$sql2 = 'SELECT lotID FROM '.$DB->pre.'result_tran WHERE sernum="'.$sernum.'" AND cellID="'.$exp[0].'" AND  lotnum="'.$exp[2].'" AND lotdate="'.date('Y-m-d').'" AND lotTime="'.$exp[4].'" AND uID="'.$exp[5].'"';
			$D2 = $DB->dbRow($sql2);
			if($D2['lotID'] != ''){
				$sqlD = 'DELETE FROM '.$DB->pre.'result_tran WHERE sernum="'.$sernum.'" AND cellID="'.$exp[0].'" AND  lotnum="'.$exp[2].'" AND lotdate="'.date('Y-m-d').'" AND lotTime="'.$exp[4].'" AND uID="'.$exp[5].'"';
				$DB->dbQuery($sqlD);
				$str = 'ERR';
			}else{
				
				$sqlD = 'DELETE FROM '.$DB->pre.'result_tran WHERE sernum="'.$sernum.'" AND  lotnum="'.$exp[2].'" AND lotdate="'.date('Y-m-d').'" AND lotTime="'.$exp[4].'" AND uID="'.$exp[5].'"';
				$DB->dbQuery($sqlD);
				
				$sqlI = 'INSERT INTO '.$DB->pre.'result_tran SET cellID="'.$exp[0].'",sernum="'.$exp[1].'",lotnum="'.$exp[2].'",lotdate="'.date('Y-m-d').'",lotTime="'.$exp[4].'",uID="'.$exp[5].'",lID="'.$_REQUEST['rLotID'].'",dateAdded="'.date('Y-m-d H:i:s').'"';
				$DB->dbQuery($sqlI);
				$str = 'OK';
			}
	}
	
	
	$end = microtime(true);
  return $str;
}
$retailer = '';
function getAllRetailer($ID){
	global $DB;
	$sql = 'SELECT id,userType FROM '.$DB->pre.'users WHERE underHead="'.$ID.'" ';
	$D = $DB->dbRows($sql);
	if(count($D) > 0){
		foreach($D as $D){
			if($D['id'] !=''){
				if($D['userType'] == 3){
					$GLOBALS['retailer'] .= $D['id'].',';
				}
				getAllRetailer($D['id']);
			}
		}
	}
}
function saveAutoResult(){
	global $DB;
  //die;
  /*
	date_default_timezone_set('Asia/Kolkata');
	$sql = 'SELECT id FROM '.$DB->pre.'users WHERE userType="3" AND  adminID="'.$_REQUEST['adminID'].'"';
	$D = $DB->dbRows($sql);
	$agent = '';
	$lotTime = $_REQUEST['drawtime'];
	foreach($D as $D){
		$GLOBALS['retailer'] .= $D['id'].',';
	}

 	$agent = substr($GLOBALS['retailer'], 0, -1);

	$serArr = array(
					'0000'=>array('00~0-99','01~0-99','02~0-99','03~0-99','04~0-99','05~0-99','06~0-99','07~0-99','08~0-99','09~0-99'),
					'1000'=>array('10~0-99','11~0-99','12~0-99','13~0-99','14~0-99','15~0-99','16~0-99','17~0-99','18~0-99','19~0-99'),
					'2000'=>array('20~0-99','21~0-99','22~0-99','23~0-99','24~0-99','25~0-99','26~0-99','27~0-99','28~0-99','29~0-99'),
					'3000'=>array('30~0-99','31~0-99','32~0-99','33~0-99','34~0-99','35~0-99','36~0-99','37~0-99','38~0-99','39~0-99'),
					'4000'=>array('40~0-99','41~0-99','42~0-99','43~0-99','44~0-99','45~0-99','46~0-99','47~0-99','48~0-99','49~0-99'),
					'5000'=>array('50~0-99','51~0-99','52~0-99','53~0-99','54~0-99','55~0-99','56~0-99','57~0-99','58~0-99','59~0-99'),
					'6000'=>array('60~0-99','61~0-99','62~0-99','63~0-99','64~0-99','65~0-99','66~0-99','67~0-99','68~0-99','69~0-99'),
					'7000'=>array('70~0-99','71~0-99','72~0-99','73~0-99','74~0-99','75~0-99','76~0-99','77~0-99','78~0-99','79~0-99'),
					'8000'=>array('80~0-99','81~0-99','82~0-99','83~0-99','84~0-99','85~0-99','86~0-99','87~0-99','88~0-99','89~0-99'),
					'9000'=>array('90~0-99','91~0-99','92~0-99','93~0-99','94~0-99','95~0-99','96~0-99','97~0-99','98~0-99','99~0-99')
					);
	
	
	foreach($serArr as $key=>$serArr){
		foreach($serArr as $S){
			$splt = explode('~',$S);
			$splt1 = explode('-',$splt[1]);
			$cell = array();
			$cv = array();

			$sqlL = 'SELECT  cellID,max(cv) as CV FROM '.$DB->pre.'lottary WHERE sernum="'.$key.'" AND  lotnum="'.$splt[0].'" AND   lotTime="'.$lotTime.'" AND lotdate="'.date('Y-m-d').'" AND sernum="'.$key.'" AND lotnum="'.$splt[0].'" AND uID in('.$agent.') group by cellID order by cellID';
			$L = $DB->dbRows($sqlL);
			foreach($L as $L){
				$cell[] = $L['cellID'];
				$cv[] = $L['CV'];
			}
			
		
			//echo count(($cell));die;
			$sql1 = 'SELECT lotID FROM '.$DB->pre.'result_tran WHERE sernum="'.$key.'" AND  lotnum="'.$splt[0].'" AND lotdate="'.date('Y-m-d').'" AND lotTime="'.$lotTime.'" AND uID="'.$_REQUEST['adminID'].'"';
			$D1 = $DB->dbRow($sql1);
			
			//array_unique($cell)
			if($D1['lotID'] == ''){
					
				if(count(($cell)) < 100){
					$newCell = '';
					$flag = true;
					$resultCount = array();
					for($i=$splt1[0];$i<=$splt1[1];$i++){
						$i = (strlen($i)==1?'0'.$i:$i);
						
						if($newCell == ''){
							
							$flag = in_array($splt[0].$i,$cell);
							if(!$flag){
								//$newCell = $i;
								//echo $splt[0].$i.'&nbsp;';
								$resultCount[]=$splt[0].$i;
								
							}
						}
					}
					//print_r($resultCount);
					 $newCell = array_rand($resultCount);
					 
					 $sqlI1 = 'INSERT INTO '.$DB->pre.'result_tran SET cellID="'.$resultCount[$newCell].'",sernum="'.$key.'",lotnum="'.$splt[0].'" , lotdate="'.date('Y-m-d').'",lotTime="'.$lotTime.'",uID="'.$_REQUEST['adminID'].'",dateAdded="'.date('Y-m-d h:i:s').'"';
					//echo "<br>";
					$DB->dbQuery($sqlI1);
				}else{
				//	echo "All Cell are fill";

					$sortCell = array_count_values($cv);
					$minCell = array_search(min($cv), $cv);
					$sqlI2 = 'INSERT INTO '.$DB->pre.'result_tran SET cellID="'.$cell[$minCell].'",sernum="'.$key.'",lotnum="'.$splt[0].'" , lotdate="'.date('Y-m-d').'",lotTime="'.$lotTime.'",uID="'.$_REQUEST['adminID'].'",dateAdded="'.date('Y-m-d h:i:s').'"';
					$DB->dbQuery($sqlI2);
					
				}
			}
		}
	}
	
	echo "OK";*/
	
}
function drawTimeAdmin(){
	global $DB;
	date_default_timezone_set('Asia/Kolkata');

$date = time();

$lotMin = date("i", $date);
$lotHour = date("h", $date);
$lotSec = date("s", $date);
$ampm = date("A", $date);



if ($lotMin >= 0 && $lotMin < 15) {
    $lotMin = 15;
} else if ($lotMin >= 15 && $lotMin < 30) {
    $lotMin = 30;
} else if ($lotMin >= 30 && $lotMin < 45) {
    $lotMin = 45;
} else if ($lotMin >= 45 && $lotMin < 60) {
    $lotMin = 0;
    $lotHour++;
}

$lotHour = $lotHour % 12;
if ($lotHour == 0) {
    $lotHour = 12;
}

if ($lotHour < 10) {
    $lotHour = "0" . $lotHour;
}
if ($lotMin < 10) {
    $lotMin = "0" . $lotMin;
}
// if ($lotSec < 10) {
//     $lotSec = "0" . $lotSec;
// }

$time_lot =  "$lotHour:$lotMin";
return $time_lot;
}
function deleteLottery(){
	global $DB;
	$ID = substr($_REQUEST['ID'], 0, -1);
	$exp = explode(",",$ID);
	$str = array('str'=>'ERR');
	if(count($exp) > 0){
		foreach($exp as $I){
			$sql = 'DELETE FROM '.$DB->pre.'lottary WHERE lotID="'.$I.'"';
			$DB->dbQuery($sql);
			$str = array('str'=>'OK');
		}
	}else{
		$sql = 'DELETE FROM '.$DB->pre.'lottary WHERE lotID="'.$ID.'"';
		$DB->dbQuery	($sql);
		$str = array('str'=>'OK');
	}
	
	
		
	
	return json_encode($str);
}
function showPageData(){
	global $DB;
	$drawTime = $_REQUEST['drawTime'];
 //   $drawTime = '6:30';
	$start = ($_REQUEST['start']);
	$end = ($_REQUEST['end']);
				 	echo $sqlP = 'SELECT tranID,U.userCode,L.* FROM mx_lottary as L 
									LEFT JOIN '.$DB->pre.'users as U on L.uID = U.id
									WHERE  L.lotTime="'.$drawTime.'"  AND U.userType="3" AND L.lotDate="'.date('Y-m-d').'" AND U.adminID="'.$_REQUEST['id'].'" GROUP BY cellID  ORDER BY cellID limit '.$start.','.$end;
						$P = $DB->dbRows($sqlP);
						
						$trLeft = '<table border="1" width="100%"  cellspacing="0" cellpadding="17">';
						$flag = 0;
						$actCV = 0;
						foreach($P as $P){
							if($flag < 1){
								$trLeft .= '<tr>';
							}
							
							$css = '';
							$sqlC = 'SELECT lotID FROM '.$DB->pre.'result_tran WHERE lotnum="'.$P['lotnum'].'"  AND uID="'.$_REQUEST['id'].'" AND lotTime="'.$drawTime.'" AND lotdate="'.date('Y-m-d').'"';
							$C = $DB->dbRow($sqlC);
							if($C['lotID'] != ''){
								$css = ' style="padding:3%;background-color:purple;color:#fff;"';
							}
							
							$sqlC1 = 'SELECT lotID FROM '.$DB->pre.'result_tran WHERE lotnum="'.$P['lotnum'].'" AND cellID="'.$P['cellID'].'" AND lotTime="'.$drawTime.'"  AND uID="'.$_REQUEST['id'].'" AND lotdate="'.date('Y-m-d').'"';
							$C1 = $DB->dbRow($sqlC1);
							//echo $C1['lotID'].'--'.$P['cellID'].'<br>';
							if($C1['lotID'] != ''){
								$css = ' style="padding:3%;background-color:yellow"';
							}
							
							if($flag < 4){
								 $cell = '';
								 $trCell = '';
								if(strlen($P['cellID']) == 1){
									$trCell = $P['lotnum'].'0'.$P['cellID'];

								}else{
									//$trCell = $P['lotnum'].$P['cellID'];
									$trCell = $P['cellID'];
								}
							  
							  	$cellCV = 0;
								$actCV = 0;
								$userCellCV = explode('~',getUserCellPage($P['uID'],$P['cellID'],$P['lotnum'],$drawTime));
								//$cellCV = ($userCellCV[1]*90);
								//$actCV = ($actCV+$cellCV);
								
								$useCVSUM = 'SELECT (sum(cv)*2) as C FROM mx_lottary AS L
											LEFT JOIN  mx_users as U on L.uID = U.id WHERE   cellID="'.$P['cellID'].'" AND lotnum="'.$P['lotnum'].'" AND lotTime="'.$drawTime.'" AND lotdate="'.date('Y-m-d').'" AND U.adminID="'.$_REQUEST['id'].'"';
								$CVSUM = $DB->dbRow($useCVSUM);			
							  	
							    $sqlTC = 'SELECT (count(cellID)) as C FROM mx_lottary AS L
											LEFT JOIN  mx_users as U on L.uID = U.id WHERE   cellID="'.$P['cellID'].'" AND lotnum="'.$P['lotnum'].'" AND lotTime="'.$drawTime.'" AND lotdate="'.date('Y-m-d').'" AND U.adminID="'.$_REQUEST['id'].'"';
								$TC = $DB->dbRow($sqlTC);
							  
							  $trLeft .= '<td width="10%" align="center"'.$css.'>'.$userCellCV[0].'</td>';
							  $trLeft .= '<td width="10%"  align="center" '.$css.'>'.$userCellCV[1].'*'.$TC['C'].'</br><a href="'.SITEURL.'/live-betting/?adminID='.$_REQUEST['id'].'&u='.$_REQUEST['u'].'&flag=1&id='.$_REQUEST['id'].'&saveFlag=1&attr='.$P['cellID'].'~'.$P['sernum'].'~'.$P['lotnum'].'~'.$P['lotdate'].'~'.$P['lotTime'].'~'.$_REQUEST['id'].'"><button type="button">'.$trCell.'</button></a></td>';
							  $flag++;
							 
							 
							 }else{

								 $cell = '';
								 $trCell = '';
								if(strlen($P['cellID']) == 1){
									$trCell = $P['lotnum'].'0'.$P['cellID'];

								}else{
									//$trCell = $P['lotnum'].$P['cellID'];
									$trCell = $P['cellID'];
								}
							  
							  	$cellCV = 0;
								$actCV = 0;
								$userCellCV = explode('~',getUserCellPage($P['uID'],$P['cellID'],$P['lotnum'],$drawTime));
								$cellCV = ($userCellCV[1]);
								$actCV = ($actCV+$cellCV);
								//getUserCell($P['uID'],$P['cellID'],$P['lotnum'],$drawTime)
								$useCVSUM = 'SELECT (sum(cv)*2) as C FROM mx_lottary AS L
											LEFT JOIN  mx_users as U on L.uID = U.id WHERE   cellID="'.$P['cellID'].'" AND lotnum="'.$P['lotnum'].'" AND lotTime="'.$drawTime.'" AND lotdate="'.date('Y-m-d').'" AND U.adminID="'.$_REQUEST['id'].'"';
								$CVSUM = $DB->dbRow($useCVSUM);			
							  	
							    $sqlTC = 'SELECT (count(cellID)) as C FROM mx_lottary AS L
											LEFT JOIN  mx_users as U on L.uID = U.id WHERE   cellID="'.$P['cellID'].'" AND lotnum="'.$P['lotnum'].'" AND lotTime="'.$drawTime.'" AND lotdate="'.date('Y-m-d').'" AND U.adminID="'.$_REQUEST['id'].'"';
								$TC = $DB->dbRow($sqlTC);
							  
							  $trLeft .= '<td width="10%" align="center"'.$css.'>'.$userCellCV[0].'</td>';
							  $trLeft .= '<td width="10%"  align="center" '.$css.'>'.$userCellCV[1].'*'.$TC['C'].'</br><a href="'.SITEURL.'/live-betting/?adminID='.$_REQUEST['id'].'&u='.$_REQUEST['u'].'&flag=1&id='.$_REQUEST['id'].'&saveFlag=1&attr='.$P['cellID'].'~'.$P['sernum'].'~'.$P['lotnum'].'~'.$P['lotdate'].'~'.$P['lotTime'].'~'.$_REQUEST['id'].'"><button type="button">'.$trCell.'</button></a></td>';
								 
								 
								 
								 $trLeft .= '</tr>';
								 $flag = 0;
							}
							
							
							
							
						}
  			$trLeft .= '</table>';
			return $trLeft;
}
function getUserCellPage($uID,$cellID,$lotnum,$drawTime){
		global $DB;
	
		$sqlU = 'SELECT L.uID,U.userCode,L.isadvance FROM '.$DB->pre.'lottary as L 
				 LEFT JOIN '.$DB->pre.'users as U on L.uID = U.id  
				 WHERE  L.cellID="'.$cellID.'" AND lotnum="'.$lotnum.'" AND L.lotTime="'.$drawTime.'" AND lotdate="'.date('Y-m-d').'" AND U.adminID="'.$_REQUEST['id'].'" GROUP BY L.uID
				 
							';
		
		
		$U = $DB->dbRows($sqlU);
		$html = '';
		
		$adv = '';
		$cancel = '';
		$sale = 0;
		foreach($U as $U){
			
			 	 $sqlUCT = 'SELECT ((L.cv)) as S,U.userCode,L.status,L.isadvance,L.point,L.uID FROM '.$DB->pre.'lottary as L 
				 LEFT JOIN '.$DB->pre.'users as U on L.uID = U.id  
				 WHERE  L.uID="'.$U['uID'].'" AND L.cellID="'.$cellID.'" AND lotnum="'.$lotnum.'" AND L.lotTime="'.$drawTime.'" AND lotdate="'.date('Y-m-d').'" AND U.adminID="'.$_REQUEST['id'].'"
				 
							';
				$UCT = $DB->dbRows($sqlUCT);
				
				$point = 0;
				$cv = 0;
				
				foreach($UCT as $CT){
					$point = ($CT['S']*$CT['point']);
					$cv = ($cv+$point);	
					
				}
			$sale += ($cv*90);
			if($U['isadvance'] == '1'){
				$html .= 'ADV.'.strtoupper($U['userCode']).'['.($cv).']</br>';
			}else if($U['status'] == '0'){
				$html .= 'Cancel.'.strtoupper($U['userCode']).'['.($cv).']</br>';
			}else{
				$html .= strtoupper($U['userCode']).'['.($cv).']</br>';
			}
		}

		
		
		return $html.'~'.$sale;
	
	}
switch($_REQUEST['xAction']){
	case 'chkUser':
					include("../../connectdb.inc.php");
					echo chkUserID();
					break;
	case 'save':
					include("../../connectdb.inc.php");
					echo saveUser();
					break;
	case 'addBal':
					include("../../connectdb.inc.php");
					echo addBalance();
					break;
	case 'getTime':
					include("../../connectdb.inc.php");
					echo getTime();
					break;
	case 'saveResult':
					include("../../connectdb.inc.php");
					echo saveResult();
					break;
	case 'saveAutoResult':
					include("../../connectdb.inc.php");
					echo saveAutoResult();
					break;
	case 'deleteLot':
					include("../../connectdb.inc.php");
					echo deleteLottery();
					break;
    case 'showPageData':
    					
					include("../../connectdb.inc.php");
					echo showPageData();
					break;
	
}

?>