<?php

error_reporting(0);
function getactive($get_id)
				{				
				include("../datacon.php");
				date_default_timezone_set('Africa/Nairobi'); 
				$ii = date("d") ;
				if ( $ii < 23){
					$DateFf=(date("Y-m-")) . "23";
					$DateTt=date('Y-m-j' , strtotime("-1 months", strtotime($DateFf))); 
					$DateT = $DateFf;
					$DateF = $DateTt;
				} else {
					$DateF=(date("Y-m-")) . "23";
					$DateT=date('Y-m-j' , strtotime("+1 months", strtotime($DateF))); 
				}
				
				//$DateF ="2014-11-23";
				//$DateT= "2014-12-31";
				//echo $DateT . $DateF ;
				$SQL="SELECT mpesaact FROM mpesacode where mpesanumber='$session_id'  and mpesaact=0 ";
				//echo $SQL;
			  	@$result = mysql_query($SQL,$db);	
				@$MyResult22 = mysql_result($result,0,"mpesaact");
				//echo "<br>".$MyResult22; 
				//exit();	
				if ($MyResult22==""){$MyResult22=1;}
				if ($MyResult22 == 0){return false;}
				$SQL="SELECT id FROM prpurchased where userid='$session_id' and (left(prregdate,10)>='$DateF' and left(prregdate,10)<='$DateT')";
				//echo $SQL;
			  	@$result = mysql_query($SQL,$db);	
				@$MyResult224 = mysql_result($result,0,"id");
				//echo "<br>".$MyResult22; 
				//exit();	
				return true;
				if ($MyResult224<>""){
				$date1=date("Y-m-d");
					if ($date1 > $DateT){
					//return false;
					}else{
				return true;}
				}
			   	$SQL="SELECT prregdate FROM prpurchased where userid='$session_id' and (left(prregdate,10)>='$DateF' and left(prregdate,10)<='$DateT')";
				//echo $SQL;
			  	@$result = mysql_query($SQL,$db);	
				@$MyResult = mysql_result($result,0,"prregdate");
				if ($MyResult == ''){return false;}
				if ($MyResult <> ''){
					$SQL="SELECT count(prregdate) as prdb FROM prpurchased where userid='$session_id'";
					//echo $SQL;
					@$result = mysql_query($SQL,$db);	
					mysql_result($result,0,"prdb");
					@$MyResult = mysql_result($result,0,"prdb");
					$bdate = strtotime('2014-08-23');
						$edate = strtotime(date("Y-m-d"));
						$age = 0;
						
						if($edate < $bdate) {
							//prenatal
							$age = -1;
						} else {
							while($bdate < $edate) {
								$age++;
								$bdate = strtotime('+1 MONTH', $bdate);
								if ($bdate > $edate) {
									$age--;
								}
							}
						}
						

						if ($MyResult >=  $age){
						
							return true;
							
						}
					}
				
				return false;											
				}
				
				?>