
<?php include "../datacon.php"; ?>
<?php 
  //  function run(){
        //do something time consuming
//exit();
echo "Loading.";	
		$ThisScreen='Mine' ;
	include("ses.php");
 include("../datacon.php");
function getdhm($MeUserid)
				{
				include ("../datacon.php");
			   	$SQL="Select dhmobile from dhpayment where regmobile='$MeUserid' order by dh_id";
			  	$result = mysql_query($SQL);	
				return mysql_result($result,0,"dhmobile");
				}
 function getstatus($MeUserid)
				{
				include ("../datacon.php");
			   	$SQL="Select status from dhpayment where regmobile='$MeUserid' order by dh_id";
			  	$result = mysql_query($SQL);	
				return mysql_result($result,0,"status");
				}
 function getamount($MeUserid)
				{
				include ("../datacon.php");
			   	$SQL="Select amount from dhpayment where regmobile='$MeUserid' order by dh_id";
			  	$result = mysql_query($SQL);	
				return mysql_result($result,0,"amount");
				}
  function getdh($MeUserid)
				{
				include ("../datacon.php");
			   	$SQL="Select destinyh from operators where Username='$MeUserid' order by Userid";
			  	$result = mysql_query($SQL);	
				return mysql_result($result,0,"destinyh");
				}
 function getclub($MeUserid)
				{
				include ("../datacon.php");
			   	$SQL="Select level from gold where phonenumber='$MeUserid' order by id";
			  	$result = mysql_query($SQL);	
				return mysql_result($result,0,"level");
				}
			   function getsubrided($MeUserid)
				{
				include ("../datacon.php");
			   	$SQL="Select reg_under from gold where phonenumber='$MeUserid' order by id";
			  	$result = mysql_query($SQL);	
				return mysql_result($result,0,"reg_under");
				}
				function getfname($MeUserid)
				{
				include("../datacon.php");
			   	$SQL="Select fname from operators where Username='$MeUserid' order by fname";
			  	$result = mysql_query($SQL);	
				return @mysql_result($result,0,"fname");
				}
				function getgender($MeUserid)
				{
				include("../datacon.php");
			   	$SQL="Select gender from operators where Username='$MeUserid' order by gender";
			  	$result = mysql_query($SQL);	
				return @mysql_result($result,0,"gender");
				}
				function getlname($MeUserid)
				{
				include("../datacon.php");
			   	$SQL="Select lname from operators where Username='$MeUserid' order by lname";
			  	$result = mysql_query($SQL);	
				return @mysql_result($result,0,"lname");
				}
				function getsname($MeUserid)
				{
				include("../datacon.php");
			   	$SQL="Select sname from operators where Username='$MeUserid' order by sname";
			  	@$result = mysql_query($SQL);	
				return @mysql_result($result,0,"sname");
				}
				function getdatereg($MeUserid)
				{
				include("../datacon.php");
			   	$SQL="Select timestam from operators where Username='$MeUserid' order by timestam";
			  	$result = mysql_query($SQL);	
				return @mysql_result($result,0,"timestam");
				}
				function getcounty($MeUserid)
				{
				include("../datacon.php");
			   	$SQL="Select county from operators where Username='$MeUserid'";
			  	$result = mysql_query($SQL);	
				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 phonenumber, reg_under, idno,level from gold  order by id";
			   	$result = mysql_query($SQL);
				//echo $SQL;	
				$N=0;
				while (@mysql_result($result,$N,"phonenumber") <> ''){//|| $N < 3
					$arr[0][$N] =mysql_result($result,$N,"phonenumber");
					$arr[1][$N] =mysql_result($result,$N,"reg_under");
					$arr[2][$N] =mysql_result($result,$N,"idno");
					$arr[3][$N] =ucfirst(strtolower(getfname(mysql_result($result,$N,"phonenumber"))));
					$arr[4][$N] =ucfirst(strtolower(getsname(mysql_result($result,$N,"phonenumber"))));
					$arr[5][$N] =getgender(mysql_result($result,$N,"phonenumber"));
					$arr[6][$N] =getactive(mysql_result($result,$N,"phonenumber"));
					$arr[7][$N] =ucfirst(strtolower(getlname(mysql_result($result,$N,"phonenumber"))));
					$dreg =getdatereg(mysql_result($result,$N,"phonenumber"));
					$arr[8][$N] =date("d/m/y", strtotime($dreg));
					$arr[9][$N] =getcounty(mysql_result($result,$N,"phonenumber"));
					$arr[11][$N] =getdh(mysql_result($result,$N,"phonenumber"));
					$arr[12][$N] =getamount(mysql_result($result,$N,"phonenumber"));
					$arr[13][$N] =getstatus(mysql_result($result,$N,"phonenumber"));;
					$arr[14][$N] =getdhm(mysql_result($result,$N,"phonenumber"));;
					$N++;
					echo $N;
				}
				//print_r($arr);
					return @$arr;
					echo getsubrided(mysql_result($result,$N,"reg_under"));
				}
				
			   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();
echo ".";
//$arr=run();
//
//exit();

$arr2=json_encode($arr);
$_SESSION['arr2']=$arr2;
//print_r($arr2);
//exit();

?>
<html>
<head>
<title>Downline </title>
<style>
  table {
    border: 1px solid black;
	  width: 100%;
}

table, th, td {
	  height: 50px;
    border: 1px solid black;
}
</style>
<script language="javascript" type="text/javascript">


<!--l
var NewArray = [];
var adN = 0;
var Col= 0;
var row= 0;
var bgco="";
var narry= new Array;
var mycol=1;
var mycount=1;
function getarry(Userd){
var myArray = <?php echo  ($arr2); ?>;
var len = 1;
var ccf=0;
var act='InActive';
narry[0]=1;
narry[1]=2;
narry[2]=3;
narry[3]=4;

//alert("Niko"+myArray[1][0]+"---"+Userd);

while(len!=0){

for (var r=0; r<myArray[1].length; r++) {
var d = new Date();
var month = new Array();
month[0] = "01";
month[1] = "02";
month[2] = "03";
month[3] = "04";
month[4] = "05";
month[5] = "06";
month[6] = "07";
month[7] = "08";
month[8] = "09";
month[9] = "10";
month[10] = "11";
month[11] = "12";
var n = month[d.getMonth()]; 
//alert("Is "+r+":"+myArray[1][r]+"is equal to "+Userd);
var srcN="";
var newuser = myArray[8][r];
var newm=newuser.substring(3, newuser.length-3);
if (newm == n){
srcN="";
}
if (myArray[1][r] == Userd ){
var act2=myArray[6][r];
var act21="false";
var bgco2="bgcolor='#CCFF99'";
var src2=myArray[5][r];
var src='../img/user-icon.jpg';
bgco2="bgcolor='green'";
var srcA='Club';

var a= myArray[12][r];
var b= myArray[13][r];
var c= myArray[14][r];
if(c==Userd){var d=a; var e=b;}
if(c!=Userd){ d=0; e='NIL';}


 document.write("<table width='35%' "+bgco2+"><td "+bgco+" "+mycount+" width='1%' > <td  width='2%' align='left' bgcolor='#CCFF99'><font size=3 face'tahoma'>"+srcN+mycount+"</font></td><td width='6%' align='left' bgcolor='#CCFF99'> <font size=3 face'tahoma'>"+myArray[3][r]+" "+myArray[4][r]+"</font> </td>  <td width='2%' align='left' bgcolor='#CCFF99'><font size=3 face'tahoma'>"+myArray[0][r]+"</font> </td><td width='2%' align='left' bgcolor='#CCFF99' ><font size=3 face'tahoma'>"+myArray[1][r]+"</font></td> <td width='5%' align='left' bgcolor='#CCFF99' ><font size=3 face'tahoma'>"+myArray[9][r]+"</font></td> <td width='2%' align='left' bgcolor='#CCFF99' ><font size=3 face'tahoma'>"+myArray[11][r]+"</font></td><td width='2%' align='left' bgcolor='#CCFF99' ><font size=3 face'tahoma'>"+d+"</font></td><td width='2%' align='left' bgcolor='#CCFF99' ><font size=3 face'tahoma'>"+e+"</font></td><td width='2%' align='left' bgcolor='#CCFF99' ><font size=3 face'tahoma'></font></td><td width='2%' align='left' bgcolor='#CCFF99' ><font size=3 face'tahoma'></font></td><td width='2%' align='left' bgcolor='#CCFF99' ><font size=3 face'tahoma'></font></td><td width='2%' align='left' bgcolor='#CCFF99' ><font size=3 face'tahoma'></font></td><td width='2%' align='left' bgcolor='#CCFF99' ><font size=3 face'tahoma'></font></td> ");

document.write(" </table>");
mycount++;



narry.push(myArray[0][r]);
//document.write("<>");
}
}
len=len-1;
}

return narry;
}
function myarry(Userd){

//.write("<table bgcolor='yellow'>");
var retval = new Array;
var arr1 = [""+Userd+""];
NewArray[0] = arr1;

var stage12=12;
var c=0;
while(stage12 > 0){
if (c) {bgco="bgcolor='green'"; var q=667;}
if (c==1) {bgco="bgcolor='white'";  q=667;}
if (c==2) {bgco="bgcolor='blue'"; q=7200;}
if (c==3) {bgco="bgcolor='purple'"; q=18000;}
if (c==4) {bgco="bgcolor='Beige'"; q=27000;}
if (c==5) {bgco="bgcolor='yellow'"; q= 36000;}
if (c==6) {bgco="bgcolor='Bisque'"; q=54000;}
if (c==7) {bgco="bgcolor='grey'"; q=81000;}
if (c==8) {bgco="bgcolor='pink'"; q=108000;}
if (c==9) {bgco="bgcolor='orange'"; q=136000;}
if (c==10) {bgco="bgcolor='red'"; q=180000;}
if (c==11) {bgco="bgcolor='#CCFF99'";q=270000;}
var cc = c+1;
document.write("<tr "+bgco+"> <td "+bgco+"><font size=6></font></td><td ><font size=6></font></td>");
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=[];
mycount=1;
c++;
stage12--;
document.write("</tr>");
}
document.write("</table>");
//document.write("</td>");
//document.write("Downline:"+adN);
//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>

