 <?php 
  //  function run(){
        //do something time consuming
echo "<img src='../img/loadinggreen.gif' alt='Loading...'>";
echo "Loading.";
	

		$ThisScreen='Mine' ;
		require_once("getAct.php");
	//require_once("ses.php");
 require_once("datacon.php");

			   function getsubrided($MeUserid)
				{
				include ("datacon.php");
			   	$SQL="Select regby from operators_reg where userreged='$MeUserid' order by regno";
			  	@$result = mysql_query($SQL,$db);	
				return mysql_result($result,0,"regby");
				}
				function getfname($MeUserid)
				{
				include("datacon.php");
			   	$SQL="Select fname from operators where Userid='$MeUserid' order by fname";
			  	@$result = mysql_query($SQL,$db);	
				return @mysql_result($result,0,"fname");
				}
				function getgender($MeUserid)
				{
				include("datacon.php");
			   	$SQL="Select gender from operators where Userid='$MeUserid' order by gender";
			  	@$result = mysql_query($SQL,$db);	
				return @mysql_result($result,0,"gender");
				}
				
				function getproductb($MeUserid)
				{
				include("datacon.php");
				$SQL="SELECT count(prregdate) as prdb FROM prpurchased where userid='$MeUserid'";
				//echo $SQL;
			  	@$result = mysql_query($SQL,$db);	
				return @mysql_result($result,0,"prdb");
				}
				function getsname($MeUserid)
				{
				include("datacon.php");
			   	$SQL="Select sname from operators where Userid='$MeUserid' order by sname";
			  	@$result = mysql_query($SQL,$db);	
				return @mysql_result($result,0,"sname");
				}
				function getdatereg($MeUserid)
				{
				include("datacon.php");
			   	$SQL="Select left(prregdate,10) as datr from prpurchased where Userid='$MeUserid' order by prregdate";
			  	@$result = mysql_query($SQL,$db);	
				return mysql_result($result,0,"datr");
				}
				function getcounty($MeUserid)
				{
				include("datacon.php");
			   	$SQL="Select county from operators where Userid='$MeUserid'";
			  	@$result = mysql_query($SQL,$db);	
				return @mysql_result($result,0,"county");
				}
			   function rowCount($arryC){
			   $rows = count($arryC);
			   $ColumC=0;
				for ($row = 0; $row < 1; $row++) {
					$cols = count($arryC[$row]);
						for($col = 0; $col < $cols; $col++ ) {
						$ColumC++;
						}
				}
				return $ColumC;
     			}

			   function arryCounter($arryC) {
			   			foreach($arryC as $key => $value) {
							@$counter += count($value);
						}
						return $counter;
				} 
				function loadarrays()
				{
				include("datacon.php");
			   	$SQL="Select userreged, regby, regno from operators_reg  order by datereg";
			   	@$result = mysql_query($SQL,$db);
				//echo $SQL;	
				$N=0;
				while (@mysql_result($result,$N,"userreged") <> ''){//|| $N < 3
					$arr[0][$N] =mysql_result($result,$N,"userreged");
					$arr[1][$N] =mysql_result($result,$N,"regby");
					$arr[2][$N] =mysql_result($result,$N,"regno");
					$arr[3][$N] =ucfirst(strtolower(getfname(mysql_result($result,$N,"userreged"))));
					$arr[4][$N] =ucfirst(strtolower(getsname(mysql_result($result,$N,"userreged"))));
					$arr[5][$N] =getgender(mysql_result($result,$N,"userreged"));
					$arr[6][$N] =getactive(mysql_result($result,$N,"userreged"));
					$arr[7][$N] =getproductb(mysql_result($result,$N,"userreged"));
					$dreg =getdatereg(mysql_result($result,$N,"userreged"));
					$arr[8][$N] =date("D d, M Y", strtotime($dreg));
					$arr[9][$N] =getcounty(mysql_result($result,$N,"userreged"));
					
					$N++;
					//echo $N;
				}
				//print_r($arr);
					return @$arr;
				}
				
			   function microtime_float($MeUserid,$ll,$level,$arrp,$arrpC)
				{
				
				$N=0;
				for ($f=0;$f <$arrpC;$f++){//|| $N < 3
					if (@$arrp[1][$f] == $MeUserid){
					$arr[$ll][$N] =$arrp[0][$f];
					$N++;
					}
				}
				
					return @$arr;
				}
				
				//$arrp=loadarrays();
				
				//print_r($arrp);
				//exit();
//}

echo ".";
$arr=loadarrays();
$acti=0;
$acti=getactive($MeUser);
if ($acti==""){$acti=0;}
if ($MeUser=="Admin"){$acti=1;}
echo ".".$acti."..";
//$_SESSION['acti']=$acti;
//$arr=run();
//

$arr2=json_encode($arr);
$_SESSION['arr2']=$arr2;
//print_r($arr2);
?>
<html>
<head>
<title>Downline for <?php echo $MeUser; ?></title>
<script language="javascript" type="text/javascript">
<!--l
var NewArray = [];
var Iacvtive = <?php echo $acti; ?>;
var adN = 0;
var act = 0;
var deact = 0;
var Col= 0;
var row= 0;
var narry= new Array;
function getarry(Userd){
var myArray = <?php echo  ($arr2); ?>;
var len = 1;
var ccf=0;
//alert("Niko"+myArray[1][0]+"---"+Userd);
narry[0]=1;
narry[1]=2;
narry[2]=3;
while(len!=0){
for (var r=0; r<myArray[1].length; r++) {
//alert("Is "+r+":"+myArray[1][r]+"is equal to "+Userd);
if (myArray[1][r] == Userd){
var act2=myArray[6][r];
if (Boolean(act2)){act++;}else{deact++;}
//alert("Niko"+len);
//alert("Niko Array"+myArray[0][r]);
//document.write("<td align='center' onclick=''><br>"+myArray[1][r]+" <br><img src='../img/user-icon.jpg' height=50> <br>"+myArray[0][r]+"</td>");
adN++;
narry.push(myArray[0][r]);
//document.write(" <td onclick='myarry('"+myArray[0][r]+"')'>"+Userd+"<BR>"+r+":"+narry[r]+"len:"+len+"adN:"+adN+"<BR>Col:"+Col+"row"+row+"---<td>");
}
}
len=len-1;
}
////alert(NewArray.join('\n'));
return narry;
}
function myarry(Userd){
document.write("<img src='../img/loadinggreen.gif' alt='Loading...'>");
var retval = new Array;
var arr1 = [""+Userd+""];
NewArray[0] = arr1;
var stage12=12;
var c=0;
var bgco="";
while(stage10> 0){
if (c==0) {bgco="bgcolor='green'";}
if (c==1) {bgco="bgcolor='white'";}
if (c==2) {bgco="bgcolor='blue'";}
if (c==3) {bgco="bgcolor='purple'";}
if (c==4) {bgco="bgcolor='yellow'";}
if (c==5) {bgco="bgcolor='Beige'";}
if (c==6) {bgco="bgcolor='pink'";}
if (c==7) {bgco="bgcolor='Bisque'";}
if (c==8) {bgco="bgcolor='grey'";}
if (c==9) {bgco="bgcolor='pink'";}
if (c==10) {bgco="bgcolor='orange'";}

//document.write("<tr "+bgco+">");
var rowCount = NewArray[c].length;
Col++;
for (var i=0; i<rowCount; i++) {
var getV=NewArray[c][i];
retval=getarry(getV);
NewArray[Col] = retval;
Userd =NewArray[c][i];
}
narry=[];
c++;
stage10--;
//alert(stage12);
//document.write("Wait....");
document.write("<meta http-equiv='refresh' content='1;url=dlineu.php?downlineu="+adN+"&act="+act+"'>");
}
if (Iacvtive == 1){
document.write("<a href=dlineu.php?downlineu="+adN+"&act="+act+"&deact="+deact+">Click here</a><br>");
window.location = "dlineu.php?downlineu="+adN+"&act="+act+"&deact="+deact;
}else{
document.write("<a href=wapactivate.php?downlineu="+adN+"&act="+act+"&deact="+deact+">Click here</a><br>");
window.location = "../wapactivate.php";
}
//startTime();
}
//-->
</script>
</head>
<body onLoad="myarry('<?php echo $MeUser; ?>')">

<P>

<script language="javascript" type="text/javascript">
<!--
var myArray = <?php echo  ($arr2); ?>;
var alen=myArray.length;
for (var i=0; i<myArray[alen][i].length; i++) {
document.write("Element " +i+ " contains: " +myArray[0][i]+ "<br />");
}
//-->
</script>

<input type="submit" onClick="myarry('<?php echo $MeUser; ?>')" value="<?php echo $MeUser; ?>">
</p>
<div id="lbmessages"> </div>

</body>
</html>
