<?php include "../datacon.php"; ?>
<?php 
error_reporting(0);
  //  function run(){
        //do something time consuming
//exit();
echo "Loading.";	
		$ThisScreen='Mine' ;
	include("ses.php");
 include("../datacon.php");
			   function getclub($MeUserid)
				{
				include ("../datacon.php");
			   	$SQL="Select level from platinum where phonenumber='$MeUserid' order by level ";
			  	$result = mysql_query($SQL);	
				return mysql_result($result,0,"level");
				}
			   function getsubrided($MeUserid)
				{
				include ("../datacon.php");
			   	$SQL="Select reg_under from platinum 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 date from platinum where phonenumber='$MeUserid' order by date";
			  	$result = mysql_query($SQL);	
				return @mysql_result($result,0,"date");
				}
				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 getcountry($MeUserid)
				{
				include("../datacon.php");
			   	$SQL="Select country from operators where Username='$MeUserid'";
			  	$result = mysql_query($SQL);	
				return @mysql_result($result,0,"country");
				}
			   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 from platinum  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[10][$N] =getcountry(mysql_result($result,$N,"phonenumber"));
					$arr[21][$N] =getclub(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>
<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=0;
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;
//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='black'";

if (src2 == "Male") {src='male-icon.png';}
if (src2 == "Female") {src='female-icon.png';}
//alert("Niko"+len);
//alert("Niko Array"+myArray[0][r]);
document.write("<td>");
document.write("<table width='100%' "+bgco2+" > <tr> <td "+bgco+" "+mycount+" align='center'><font size=3 face'tahoma'>"+srcN+mycount+"</font></td>");
document.write("</tr> </table>");
document.write("<table width='100%' "+bgco2+" > <tr> <td align='center' "+bgco+"><font size=3 face'tahoma'>"+myArray[1][r]+"</font></td> </tr><tr>");
document.write("</tr> </table>");
document.write("<table width='100%' "+bgco2+"> <tr> <td align='center' bgcolor='#CCFF99' onclick=''> "+myArray[8][r]+" <br> "+myArray[10][r]+" <br>  "+myArray[9][r]+" <br> <a href='userdline.php?userl="+myArray[0][r]+"' target='_blank'> <img src='"+src+"' height=50> </a> <br> <font size=3 face'tahoma'>"+myArray[3][r]+" <br> "+myArray[4][r]+" <br> "+myArray[0][r]+" <br> </font></td>");
document.write("</tr> </table>");
document.write("<table width='100%' "+bgco2+"> <tr> <td "+bgco+" align='center' >Club "+myArray[21][r]+"</font></td> </tr><tr>");
document.write("</tr> </table>");
document.write("</td>");
mycount++;
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("<table bgcolor='green'>");
var retval = new Array;
var arr1 = [""+Userd+""];
NewArray[0] = arr1;
var stage12=12;
var c=0;
while(stage12 > 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='Beige'";}
if (c==5) {bgco="bgcolor='yellow'";}
if (c==6) {bgco="bgcolor='Bisque'";}
if (c==7) {bgco="bgcolor='grey'";}
if (c==8) {bgco="bgcolor='pink'";}
if (c==9) {bgco="bgcolor='orange'";}
if (c==10) {bgco="bgcolor='red'";}
if (c==11) {bgco="bgcolor='#CCFF99'";}
var cc = c+1;
document.write("<tr "+bgco+"> <td "+bgco+"><font size=6>"+cc+"</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("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>

