<?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
	}
}

///////////////////////////////////////////////////////////////////
			if(isset($_POST['editprocess'])) {
				// GET AD ID FROM FORM
				$id = $_POST['requestvalue'];
				$username = $_POST['username'];
				$email = $_POST['email'];
				$ppemail = $_POST['ppemail'];
				$pzemail = $_POST['pzemail'];
				$skrillemail = $_POST['skrillemail'];
				$twocheckoutemail = $_POST['twocheckoutemail'];
				$g2aemail = $_POST['g2aemail'];
				$pin = $_POST['pin'];
				$ip = $_POST['ip'];
				$active = $_POST['active'];
				if(!empty($_POST['password'])) {
					$password = md5($_POST['password']);
					$edit = mysql_query("UPDATE Accounts_Premium_Payments SET ppemail='$ppemail',pzemail='$pzemail',skrillemail='$skrillemail',2checkoutemail='$twocheckoutemail',g2aemail='$g2aemail',email='$email',username='$username',password='$password',status='$active',pincode='$pin',ip='$ip' WHERE id='$id'");
				}else {
					$edit = mysql_query("UPDATE Accounts_Premium_Payments SET ppemail='$ppemail',pzemail='$pzemail',skrillemail='$skrillemail',2checkoutemail='$twocheckoutemail',g2aemail='$g2aemail',email='$email',username='$username',status='$active',pincode='$pin',ip='$ip' WHERE id='$id'");
				}
				?>
					<div style="margin-top: -80px;" class="alert alert-success" role="alert">
						<strong>Well done!</strong> Support Account edited
					</div>
				<?php

			}// WHEN FORM NOT SUBMITTED
///////////////////////////////////////////////////////////////////
			if(isset($_POST['addpayments'])) {
				// GET AD ID FROM FORM
				$id = $_POST['requestvalue'];
				$username = $_POST['username'];
				$password = md5($_POST['password']);
				$email = $_POST['email'];
				$ppemail = $_POST['ppemail'];
				$pzemail = $_POST['pzemail'];
				$skrillemail = $_POST['skrillemail'];
				$twocheckoutemail = $_POST['twocheckoutemail'];
				$g2aemail = $_POST['g2aemail'];
				$pin = $_POST['pin'];
				$ip = $_POST['ip'];
				$active = $_POST['active'];
				$sqlinsert = mysql_query("INSERT INTO Accounts_Premium_Payments VALUES('','$username','$password','0','$email','$pin','$active','$ppemail','$pzemail','$skrillemail','$twocheckoutemail','$g2aemail','$ip','0','0','0','0','0','0','0','0')");
				?>
					<div style="margin-top: -80px;" class="alert alert-success" role="alert">
						<strong>Well done!</strong> Support account added
					</div>
				<?php

			}// WHEN FORM NOT SUBMITTED
///////////////////////////////////////////////////////////////////
			if(isset($_POST['deleterequest'])) {
				// GET AD ID FROM FORM
				$id = $_POST['requestvalue'];
				$query = "SELECT * FROM Accounts_Premium_Payments ORDER BY id ASC";
				$result = mysql_query($query) or die('Error, query failed');
				$numadmins = mysql_num_rows($result);
				$delete = mysql_query("DELETE FROM Accounts_Premium_Payments WHERE id='$id'");
				?>
							<div style="margin-top: -80px;" class="alert alert-success" role="alert">
								<strong>Well done!</strong> Support account deleted
							</div>
				<?php

			}// WHEN FORM NOT SUBMITTED
///////////////////////////////////////////////////////////////////
?>
  <div class="container">
    <div class="text-center">
      <h1><?php echo $title; ?>
      	<small>/Active is: Admin Account
			</small>
		</h1>
 	 </div>
 	 </br>
 	 <?php 
 	 
 	 if(isset($_POST['editrequest'])) {
				// GET AD ID FROM FORM
				$id = $_POST['requestvalue'];
				$slect = mysql_query("Select * FROM Accounts_Premium_Payments WHERE id='$id'");
				$resultas = mysql_fetch_array($slect);
				?>
	<div class="row">
      <div class="col-md-8 col-md-offset-2">
        <div class="well">
			<div class="row">
				<center>
				<form name="csrf_form" id="campaignform" action="" method="POST">
					<div data-original-title="Enter your long URL" data-toggle="tooltip" data-placement="top" title="555" class="input-group">
							<center>
							<span class="input-group-btn">
								<input class="form-control" value="<?php echo $resultas['username']; ?>" placeholder="Username" name="username" type="text">
								<input value="Edit" class="btn btn-default" style="width: 150px;" name="editprocess" type="submit">
							</span>	
							</center>				
					</div>
					<div data-original-title="Enter your long URL" data-toggle="tooltip" data-placement="top" title="555" class="input-group">
							<center>
							<span class="input-group-btn">
								<input class="form-control" placeholder="******" name="password" type="text">
								<input class="form-control" value="<?php echo $resultas['pincode']; ?>" placeholder="PIN Code" name="pin" type="text">
								<input class="form-control" value="<?php echo $resultas['ip']; ?>" placeholder="IP Address (Optional)" name="ip" type="text">
								<input class="form-control" value="<?php echo $resultas['email']; ?>" placeholder="Email" name="email" type="text">
								<input class="form-control" value="<?php echo $resultas['ppemail']; ?>" placeholder="PayPal Email" name="ppemail" type="text">
								<input class="form-control" value="<?php echo $resultas['pzemail']; ?>" placeholder="Payza Email" name="pzemail" type="text">
								<input class="form-control" value="<?php echo $resultas['skrillemail']; ?>" placeholder="Skrill Email" name="skrillemail" type="text">
								<input class="form-control" value="<?php echo $resultas['2checkoutemail']; ?>" placeholder="2Checkout Email" name="twocheckoutemail" type="text">
								<input class="form-control" value="<?php echo $resultas['g2aemail']; ?>" placeholder="G2A Email" name="g2aemail" type="text">
							</span>	
							</center>				
					</div>
					<div data-original-title="Enter your long URL" data-toggle="tooltip" data-placement="top" title="555" class="input-group">
							<center>
							<input id="activated" class="toggle toggle-left" name="active" value="1" type="radio" <?php if($resultas['status'] == '1'){echo 'checked';}?>><label style="min-width:30.2%;width:auto" class="btn btn-default" for="activated" class="btn">Activated</label>
							<input id="deactivated" class="toggle toggle-right" name="active" value="0" type="radio" <?php if($resultas['status'] == '0'){echo 'checked';}?>><label style="min-width:30.2%;width:auto" class="btn btn-default" for="deactivated" class="btn">Deactivated</label>
							</center>				
					</div>
					<input type="hidden" name="csrf_token" value="<?php echo $token; ?>">
					<input type="hidden" name="requestvalue" value="<?php echo $id; ?>">
				</form>
				</br>
				</center>
			</div>
        </div>
      </div>
    </div>
				<?php

	}else {
	?>
 	 <div class="row">
      <div class="col-md-8 col-md-offset-2">
        <div class="well">
			<div class="row">
				<center>
				<form name="csrf_form" id="campaignform" action="" method="POST">
					<div data-original-title="Enter your long URL" data-toggle="tooltip" data-placement="top" title="555" class="input-group">
							<center>
							<span class="input-group-btn">
								<input class="form-control" placeholder="Username" name="username" type="text">
								<input value="Add" class="btn btn-default" style="width: 150px;" name="addpayments" type="submit">
							</span>	
							</center>				
					</div>
					<div data-original-title="Enter your long URL" data-toggle="tooltip" data-placement="top" title="555" class="input-group">
							<center>
							<span class="input-group-btn">
								<input class="form-control" placeholder="Password" name="password" type="text">
								<input class="form-control" placeholder="PIN Code" name="pin" type="text">
								<input class="form-control" placeholder="IP Address (Optional)" name="ip" type="text">
								<input class="form-control" placeholder="Email" name="email" type="text">
								<input class="form-control" placeholder="PayPal Email" name="ppemail" type="text">
								<input class="form-control" placeholder="PayZa Email" name="pzemail" type="text">
								<input class="form-control" placeholder="Skrill Email" name="skrillemail" type="text">
								<input class="form-control" placeholder="2Checkout Email" name="twocheckoutemail" type="text">
								<input class="form-control" placeholder="G2A Email" name="g2aemail" type="text">
							</span>	
							</center>				
					</div>
					<div data-original-title="Enter your long URL" data-toggle="tooltip" data-placement="top" title="555" class="input-group">
							<center>
							<input id="activated" class="toggle toggle-left" name="active" value="1" type="radio" checked><label style="min-width:30.2%;width:auto" class="btn btn-default" for="activated" class="btn">Activated</label>
							<input id="deactivated" class="toggle toggle-right" name="active" value="0" type="radio"><label style="min-width:30.2%;width:auto" class="btn btn-default" for="deactivated" class="btn">Deactivated</label>
							</center>				
					</div>
					<input type="hidden" name="csrf_token" value="<?php echo $token; ?>">
					<input type="hidden" name="requestvalue" value="<?php echo $id; ?>">
				</form>
				</br>
				</center>
			</div>
        </div>
      </div>
    </div>
    <?php 
    }
    ?>
   <div class="text-center">
      <h1><small>List of Admin accounts</small></h1>
 	</div>
		<div class="col-sm-12">
          <table class="table table-bordered" style="width:100%;max-width:100%"  data-effect="fade">
										<thead>
											<tr>
												<th style='color: #DF691A; background-color: #2B3E50;border-collapse: collapse;border: 1px solid #DF691A;'>#</th>
												<th style='color: #DF691A; background-color: #2B3E50;border-collapse: collapse;border: 1px solid #DF691A;'>Username</th>
												<th style='color: #DF691A; background-color: #2B3E50;border-collapse: collapse;border: 1px solid #DF691A;'>PIN</th>
												<th style='color: #DF691A; background-color: #2B3E50;border-collapse: collapse;border: 1px solid #DF691A;'>Email</th>
												<th style='color: #DF691A; background-color: #2B3E50;border-collapse: collapse;border: 1px solid #DF691A;'>IP</th>
												<th style='color: #DF691A; background-color: #2B3E50;border-collapse: collapse;border: 1px solid #DF691A;'><?php echo $a061; ?></th>
											</tr>
										</thead>
		<?php
			$query = "SELECT * FROM Accounts_Premium_Payments ORDER BY id ASC";
			$result = mysql_query($query) or die('Error, query failed');

			// print the random numbers
			
			if(mysql_num_rows($result)<1){
   echo "
						<tr>
							<td>0 accounts of type support</td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
						</tr>
   ";
   }else{
	$numberoflink = 0;
     while($row = mysql_fetch_array($result))
				{
					$numberoflink = $numberoflink + 1;
					$status = $row['status'];
					if($status == 1) {
						$statusnow = 'Active';
					}else if($status == 0) {
						$statusnow = 'Deactivated';
					}
					?>
										<tr>
											<td style='color: #FFF; background-color: #DF691A;border-collapse: collapse;border: 1px solid #2B3E50;'>
												<h5><?php echo $numberoflink; ?></h5>
											</td>
											<td style='color: #FFF; background-color: #DF691A;border-collapse: collapse;border: 1px solid #2B3E50;'>
												<h5><?php echo $row['username']; ?></h5>
											</td>
											<td style='color: #FFF; background-color: #DF691A;border-collapse: collapse;border: 1px solid #2B3E50;'>
												<h5><?php echo $row['pincode']; ?></h5>
											</td>
											<td style='color: #FFF; background-color: #DF691A;border-collapse: collapse;border: 1px solid #2B3E50;'>
												<h5><?php echo $row['email']; ?></h5>
											</td>
											<td style='color: #FFF; background-color: #DF691A;border-collapse: collapse;border: 1px solid #2B3E50;'>
												<h5><?php echo $row['ip']; ?></h5>
											</td>
					<?php
					echo "				<form name='actions' action='' method='POST'>
											<td style='color: #FFF; background-color: #DF691A;border-collapse: collapse;border: 1px solid #2B3E50;'>
												<input type='hidden' name='requestvalue' value='{$row['id']}'>
												<input style ='float:right' value='$a090' class='btn btn-default' name='editrequest' type='submit'>
												<input style ='float:right' value='$a111' class='btn btn-default' name='deleterequest' type='submit'>
											</td>
											</form>
										</tr>";

				}

       }
	?>
									</table>
        </div>
        
</div>

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