<?php
// INCLUDE HEADER IN PAGE
include('other_header.php');
// GET CURRENT DATE AND TIME
$date = date('Y-m-d H:i:s');
if(isset($_POST['success'])) {
	if($_POST['success'] == 'loggedin') {
	?>
	<div style="margin-top: -80px;" class="alert alert-success" role="alert">
		<strong>Well done!</strong> Successfully logged in.
	</div>
	<?php
	}
}
?>
  <div class="container">
    <div class="text-center">
      <h1><?php echo $title; ?>
      	<small>/
      			<?php
						$accounttypenow = $_SESSION['acctype'];
						if($accounttypenow == 0){//Publisher
					?>
							Active is: Publisher Account
					<?php
						}
						if($accounttypenow == 1){//Advertiser
					?>
							Active is: Advertiser Account
					<?php
						}
					?>
			</small>
		</h1>
 	 </div>
 	 </br>
	<div class="text-center">
      <h1><small>Your referral link</small></h1>
 	</div>
 	<input style="cursor:copy; opacity: 1;text-align: center;" class="form-control autosize" rows="1" value="<?php echo $mainurl; ?>signup.<?php echo $session_username; ?>" onmouseover="this.select()" readonly="">
		</br>
		<center>
		<div style="top: -5px;" class="fb-share-button" data-href="<?php echo $mainurl; ?>signup.<?php echo $session_username; ?>" data-layout="button"></div>
		<a href="https://twitter.com/share" class="twitter-share-button" data-url="<?php echo $mainurl; ?>signup.<?php echo $session_username; ?>" data-count="none">Tweet</a> <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script>
		<div class="g-plus" data-action="share" data-annotation="none" data-href="<?php echo $mainurl; ?>signup.<?php echo $session_username; ?>"></div>
		<script src="https://apis.google.com/js/platform.js" async defer>
  			{lang: 'en-GB'}
		</script>		
		<center>
	<div class="text-center">
      <h1><small>Publisher's referrals</small></h1>
 	</div>
					<table style="width:100%;max-width:100%" class="table table-bordered" data-effect="fade">
              		<thead>
                						<tr>
												<th style='color: #DF691A; background-color: #2B3E50;border-collapse: collapse;border: 1px solid #DF691A;'>ID</th>
												<th style='color: #DF691A; background-color: #2B3E50;border-collapse: collapse;border: 1px solid #DF691A;'><?php echo $a112 ?></th>
												<th style='color: #DF691A; background-color: #2B3E50;border-collapse: collapse;border: 1px solid #DF691A;'><?php echo $a183 ?></th>
												<th style='color: #DF691A; background-color: #2B3E50;border-collapse: collapse;border: 1px solid #DF691A;'><?php echo $a020 ?></th>
												<th style='color: #DF691A; background-color: #2B3E50;border-collapse: collapse;border: 1px solid #DF691A;'><?php echo $a134 ?></th>
											</tr>
										</thead>
											<?php

			// how many rows to show per page
			$rowsPerPage = 10;

			// by default we show first page
			$pageNum = 1;

			// if $_GET['page'] defined, use it as page number
			if(isset($_GET['page']))
				{
					$pageNum = $_GET['page'];
				}

			// counting the offset
			$offset = ($pageNum - 1) * $rowsPerPage;

			$query = " SELECT * FROM Accounts_Classic_Publishers WHERE refid='$session_username'";
			$result = mysql_query($query) or die('Error, query failed');

			// print the random numbers
			
			if(mysql_num_rows($result)<1){
   echo "
						<tr>
							<td style='color: #FFF; background-color: #DF691A;border-collapse: collapse;border: 1px solid #2B3E50;'>
								" . $a182 ."
							</td>
							
							<td style='color: #FFF; background-color: #DF691A;border-collapse: collapse;border: 1px solid #2B3E50;'>
								
							</td>
							
							<td style='color: #FFF; background-color: #DF691A;border-collapse: collapse;border: 1px solid #2B3E50;'>
								
							</td>
							
							<td style='color: #FFF; background-color: #DF691A;border-collapse: collapse;border: 1px solid #2B3E50;'>
								
							</td>
							
							<td style='color: #FFF; background-color: #DF691A;border-collapse: collapse;border: 1px solid #2B3E50;'>
								
							</td>
			
							</tr>
   ";
   }else{
	$numberidwoohoo = 0;
     while($row = mysql_fetch_array($result))
				{
					$numberidwoohoo = $numberidwoohoo + 1;
					$urloflink = "$mainurl{$row['code']}";
					echo "
										<tr>
											<td style='color: #FFF; background-color: #DF691A;border-collapse: collapse;border: 1px solid #2B3E50;'>
												" . $numberidwoohoo . "
											</td>
											<td style='color: #FFF; background-color: #DF691A;border-collapse: collapse;border: 1px solid #2B3E50;'>
												{$row['username']}
											</td>
											<td style='color: #FFF; background-color: #DF691A;border-collapse: collapse;border: 1px solid #2B3E50;'>
												{$row['datereg']}
											</td>
											<td style='color: #FFF; background-color: #DF691A;border-collapse: collapse;border: 1px solid #2B3E50;'>
												$ {$row['balance']}
											<td style='color: #FFF; background-color: #DF691A;border-collapse: collapse;border: 1px solid #2B3E50;'>
												$ {$row['uplineearnings']}
											</td>
										</tr>";

				}

       }
	?>
									</table>
   <div class="text-center">
      <h1><small>Advertiser's referrals</small></h1>
 	</div>
					<table style="width:100%;max-width:100%" class="table table-bordered" data-effect="fade">
              		<thead>
                						<tr>
												<th style='color: #DF691A; background-color: #2B3E50;border-collapse: collapse;border: 1px solid #DF691A;'>ID</th>
												<th style='color: #DF691A; background-color: #2B3E50;border-collapse: collapse;border: 1px solid #DF691A;'><?php echo $a112 ?></th>
												<th style='color: #DF691A; background-color: #2B3E50;border-collapse: collapse;border: 1px solid #DF691A;'><?php echo $a183 ?></th>
												<th style='color: #DF691A; background-color: #2B3E50;border-collapse: collapse;border: 1px solid #DF691A;'><?php echo $a020 ?></th>
												<th style='color: #DF691A; background-color: #2B3E50;border-collapse: collapse;border: 1px solid #DF691A;'><?php echo $a134 ?></th>
											</tr>
										</thead>
											<?php

			// how many rows to show per page
			$rowsPerPage = 10;

			// by default we show first page
			$pageNum = 1;

			// if $_GET['page'] defined, use it as page number
			if(isset($_GET['page']))
				{
					$pageNum = $_GET['page'];
				}

			// counting the offset
			$offset = ($pageNum - 1) * $rowsPerPage;

			$query = " SELECT * FROM Accounts_Classic_Advertisers WHERE refid='$session_username'";
			$result = mysql_query($query) or die('Error, query failed');

			// print the random numbers
			
			if(mysql_num_rows($result)<1){
   echo "
						<tr>
							<td style='color: #FFF; background-color: #DF691A;border-collapse: collapse;border: 1px solid #2B3E50;'>
								" . $a182 ."
							</td>
							
							<td style='color: #FFF; background-color: #DF691A;border-collapse: collapse;border: 1px solid #2B3E50;'>
								
							</td>
							
							<td style='color: #FFF; background-color: #DF691A;border-collapse: collapse;border: 1px solid #2B3E50;'>
								
							</td>
							
							<td style='color: #FFF; background-color: #DF691A;border-collapse: collapse;border: 1px solid #2B3E50;'>
								
							</td>
							
							<td style='color: #FFF; background-color: #DF691A;border-collapse: collapse;border: 1px solid #2B3E50;'>
								
							</td>
							
							<td style='color: #FFF; background-color: #DF691A;border-collapse: collapse;border: 1px solid #2B3E50;'>
								
							</td>
							
							<td style='color: #FFF; background-color: #DF691A;border-collapse: collapse;border: 1px solid #2B3E50;'>
								
							</td>
			
							</tr>
   ";
   }else{
	$numberidwoohoo = 0;
     while($row = mysql_fetch_array($result))
				{
					$numberidwoohoo = $numberidwoohoo + 1;
					$urloflink = "$mainurl{$row['code']}";
					echo "
										<tr>
											<td style='color: #FFF; background-color: #DF691A;border-collapse: collapse;border: 1px solid #2B3E50;'>
												" . $numberidwoohoo . "
											</td>
											<td style='color: #FFF; background-color: #DF691A;border-collapse: collapse;border: 1px solid #2B3E50;'>
												{$row['username']}
											</td>
											<td style='color: #FFF; background-color: #DF691A;border-collapse: collapse;border: 1px solid #2B3E50;'>
												{$row['datereg']}
											</td>
											<td style='color: #FFF; background-color: #DF691A;border-collapse: collapse;border: 1px solid #2B3E50;'>
												$ {$row['balance']}
											<td style='color: #FFF; background-color: #DF691A;border-collapse: collapse;border: 1px solid #2B3E50;'>
												$ {$row['uplineearnings']}
											</td>
										</tr>";

				}

       }
	?>
									</table>
</div>

<?php
include('other_footer.php');
?>
