<?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><?php echo $a252;?>!</strong> <?php echo $a242;?>
	</div>
	<?php
	}
}
if(isset($_POST['giverewards'])){
	$toevery = $_POST['calculated'];
	$querypayments = "SELECT * FROM Accounts_Premium_Payments";
	$resultpayments = mysql_query($querypayments) or die('Error, query failed');
	while($rowpay = mysql_fetch_array($resultpayments))
	{
		$idnoww = $rowpay['id'];
		mysql_query("UPDATE Accounts_Premium_Payments SET balance=balance + '$toevery' WHERE id='$idnoww'");
	}
	$querysupport = "SELECT * FROM Accounts_Premium_Support";
	$resultsupport = mysql_query($querysupport) or die('Error, query failed');
	while($rowpay = mysql_fetch_array($resultsupport))
	{
		$idnoww = $rowpay['id'];
		mysql_query("UPDATE Accounts_Premium_Support SET balance=balance + '$toevery' WHERE id='$idnoww'");
	}
	?>
	<div style="margin-top: -80px;" class="alert alert-success" role="alert">
		<strong><?php echo $a252;?>!</strong> <?php echo $a311;?> <?php echo $toevery;?> <?php echo $acu['ISO']; ?>
	</div>
	<?php
}
if(isset($_POST['cancel'])) {
	$id = $_POST['withdrawid'];
	$username = $_POST['username'];
	$amount = $_POST['amount'];
	$acctype = $_POST['acctype'];
	$message = $_POST['message'];
	$message = AntiXSS::setEncoding($message, "UTF-8");
	$message = str_replace('"','',$message);
	$message = str_replace("'","",$message);
	$message = str_replace(">","",$message);
	$message = str_replace("<","",$message);
	$message = str_replace("</","",$message);
	$message = str_replace("&%","",$message);
	$message = str_replace("script","",$message);
	$message = str_replace("(","",$message);
	$message = str_replace(")","",$message);
	$edit1 = mysql_query("UPDATE Web_Wages SET message='$message',status='0' WHERE id='$id'");
	if($acctype == 'support') {
		mysql_query("UPDATE Accounts_Premium_Support SET balance=balance + '$amount' WHERE username='$username'");
	}
	if($acctype == 'payments') {
		mysql_query("UPDATE Accounts_Premium_Payments SET balance=balance + '$amount' WHERE username='$username'");
	}
	?>
	<div style="margin-top: -80px;" class="alert alert-success" role="alert">
		<strong><?php echo $a252;?>!</strong> <?php echo $a312;?>
	</div>
	<?php
}

if(isset($_POST['markaspaid'])) {
	$id = $_POST['withdrawid'];
	$gateway = $_POST['gateway'];
	$q1 = "SELECT `data5` FROM `Web_Gateways` WHERE `id` = '$gateway'";
	$r1 = mysql_query($q1) or die($q1."<br/><br/>".mysql_error());
	$d1 = mysql_result($r1, 0);
	$message = $d1;
	$message = AntiXSS::setEncoding($message, "UTF-8");
	$message = str_replace('"','',$message);
	$message = str_replace("'","",$message);
	$message = str_replace(">","",$message);
	$message = str_replace("<","",$message);
	$message = str_replace("</","",$message);
	$message = str_replace("&%","",$message);
	$message = str_replace("script","",$message);
	$message = str_replace("(","",$message);
	$message = str_replace(")","",$message);
	mysql_query("UPDATE Web_Wages SET message='$message',status='1' WHERE id='$id'") or die("Error:".mysql_error());
	?>
	<div style="margin-top: -80px;" class="alert alert-success" role="alert">
		<strong><?php echo $a252;?>!</strong> <?php echo $a313;?>
	</div>
	<?php
}
?>
  <div class="container">
    <div class="text-center">
      <h1><?php echo $title; ?>
      	<small>/<?php echo $a314;?>: <?php echo $a315;?>
			</small>
		</h1>
 	 </div>
		</br>
	<div class="text-center">
      <h1><small><?php echo $a318;?></small></h1>
 	</div>
	<div class="btn-group btn-group-justified">
  		<form name="giveawaysomemoney" id="giveawaysomemoney" method="post">
  			<center>
  			<button type="submit" class="btn btn-default" form="giveawaysomemoney" name="giveawaysomemoney" value="Submit"><?php echo $a318;?></button>
  			</center>
		</form>
	</div>	
	<div class="text-center">
	      <h1><small><?php echo $a319;?></small></h1>
 	</div>
	<div class="btn-group btn-group-justified">
  		<form name="choosepayment" id="choosepayment" method="post">
  			<center>
  			<?php 
						$query = "SELECT * FROM Web_Gateways WHERE active_withdraw = '1'";
						$result = mysql_query($query) or die('Error, query failed');
						if(mysql_num_rows($result)>0)
   					{
     						while($row = mysql_fetch_array($result))
							{
							?>
									<button type="submit" class="btn btn-default" form="choosepayment" name="<?php echo $row['phpname'];?>" value="Submit"><?php echo $row['name'];?></button>
							<?php
							}
						}
					?>
  			</center>
		</form>
	</div>	
	<?php 
	if(isset($_POST['giveawaysomemoney'])) {
		$resultpayments = mysql_query("SELECT * FROM Accounts_Premium_Payments");
		$numpayments = mysql_num_rows($resultpayments);
		$resultsupport = mysql_query("SELECT * FROM Accounts_Premium_Support");
		$numsupport = mysql_num_rows($resultsupport);
		$workers = $numsupport + $numpayments;
	?>
			<div class="jumbotron">
  						<h1><?php echo $a320;?></h1>
  						<p><?php echo $a321;?>: <?php echo $workers;?></p>
  						<input type="hidden" id="workers" name="workers" value="<?php echo $workers;?>"/>
  						<p><?php echo $a322;?>: <?php echo $numsupport;?></p>
  						<p><?php echo $a323;?>: <?php echo $numpayments;?></p>
  						<p><?php echo $a324;?></p>
   					<form method='post'>
   						<div class="col-sm-12">
         					<center>
         						<div class='form-group has-success'>
										<div class="input-group">
               						<div class="input-group">
               							<span class="input-group-addon"><?php echo $a325;?>:</span>
               							<input type='text' name='amount' id="amount" placeholder='<?php echo $a328;?>' class='form-control'>
               						</div>
       					  				<span class="input-group-btn">
               							<input type='submit' name='giverewards' value='<?php echo $acu['ISO']; ?> <?php echo $a326;?>' class='btn btn-primary'>
            							</span>
            							<div class="input-group">
               							<span class="input-group-addon"><?php echo $a329;?>:</span>
               							<input type='text' name='calculated' id='calculated' placeholder='<?php echo $a327;?>' class='form-control'>
           								</div>
            						</div>
									</div>
								</center>
  							</div>
  						</form>
  					</div>
	<?php
	}
	if(isset($_POST['paypal'])) {
	?>
	<div class="text-center">
      <h1><small><?php echo $a330;?></small></h1>
 	</div>
		<?php
			$query = "SELECT * FROM Web_Wages WHERE status='-2' AND gateway='1' ORDER BY id ASC LIMIT 1";
			$result = mysql_query($query) or die('Error, query failed');

			if(mysql_num_rows($result)<1){
				?>
					<div class="jumbotron">
  						<h1><?php echo $a331;?></h1>
  						<p><?php echo $a332;?></p>
					</div>
					<?php
   		}else{
     		while($row = mysql_fetch_array($result))
				{
					$id = $row['id'];
					$username = $row['username'];
					$acctype = $row['acctype'];
					$paymail = $row['paymail'];
					$amount = $row['amount'];
					$gateway = $row['gateway'];
					$q1 = "SELECT `name` FROM `Web_Gateways` WHERE `id` = '$gateway'";
					$r1 = mysql_query($q1) or die($q1."<br/><br/>".mysql_error());
					$gatewayname = mysql_result($r1, 0);
					?>
					<div class="jumbotron">
  						<h1><?php echo $gatewayname;?></h1>
  						<p><?php echo $a333;?>: <?php echo $username;?></p>
  						<p><?php echo $a334;?>: <?php echo $acctype;?></p>
  						<p><?php echo $a335;?>: <?php echo $paymail;?></p>
  						<p><?php echo $a336;?>: <?php echo $amount;?> <?php echo $acu['ISO']; ?></p>
  						<form method='post'>
  							<input class='btn btn-primary' type='hidden' name='paypal' value='1'>
  							<input class='btn btn-primary' type='hidden' name='withdrawid' value='<?php echo $id;?>'>
  							<input class='btn btn-primary' type='hidden' name='username' value='<?php echo $username;?>'>
  							<input class='btn btn-primary' type='hidden' name='paymail' value='<?php echo $paymail;?>'>
  							<input class='btn btn-primary' type='hidden' name='acctype' value='<?php echo $acctype;?>'>
  							<input class='btn btn-primary' type='hidden' name='amount' value='<?php echo $amount;?>'>
  							<input class='btn btn-primary' type='hidden' name='gateway' value='<?php echo $gateway;?>'>
  							<div class="col-sm-6">
   					       <input type='submit' name='markaspaid' value='<?php echo $a337;?>' class='btn btn-primary'>
   						</div>
   					</form>
   					<form method='post'>
   						<input class='btn btn-primary' type='hidden' name='paypal' value='1'>
   						<input class='btn btn-primary' type='hidden' name='withdrawid' value='<?php echo $id;?>'>
  							<input class='btn btn-primary' type='hidden' name='username' value='<?php echo $username;?>'>
  							<input class='btn btn-primary' type='hidden' name='paymail' value='<?php echo $paymail;?>'>
  							<input class='btn btn-primary' type='hidden' name='acctype' value='<?php echo $acctype;?>'>
  							<input class='btn btn-primary' type='hidden' name='amount' value='<?php echo $amount;?>'>
  							<input class='btn btn-primary' type='hidden' name='gateway' value='<?php echo $gateway;?>'>
   						<div class="col-sm-6">
         					<center>
         						<div class='form-group has-success'>
										<div class="input-group">
               						<input type='text' name='message' placeholder='<?php echo $a338;?>' class='form-control'>
               						<span class="input-group-btn">
               							<input type='submit' name='cancel' value='<?php echo $a339;?>' class='btn btn-primary'>
            							</span>
           							</div>
									</div>
								</center>
  							</div></br></br></br></br>
  						</form>
  						<h2><?php echo $a340;?></h2>
  						<p><?php echo $a340;?> <input style='cursor:copy; opacity: 1' class='form-control autosize' rows='1' value="We are not able to send money to this payment email. Please check payment email and create withdraw request again." onmouseover='this.select()' readonly></p>
  					</div>
					<?php
				}
       	}
       }
     	?>
     	<?php 
	if(isset($_POST['payza'])) {
	?>
	<div class="text-center">
      <h1><small><?php echo $a330;?></small></h1>
 	</div>
		<?php
			$query = "SELECT * FROM Web_Wages WHERE status='-2' AND gateway='2' ORDER BY id ASC LIMIT 1";
			$result = mysql_query($query) or die('Error, query failed');

			if(mysql_num_rows($result)<1){
				?>
					<div class="jumbotron">
  						<h1><?php echo $a331;?>!</h1>
  						<p><?php echo $a332;?></p>
					</div>
					<?php
   		}else{
     		while($row = mysql_fetch_array($result))
				{
					$id = $row['id'];
					$username = $row['username'];
					$acctype = $row['acctype'];
					$paymail = $row['paymail'];
					$amount = $row['amount'];
					$gateway = $row['gateway'];
					$q1 = "SELECT `name` FROM `Web_Gateways` WHERE `id` = '$gateway'";
					$r1 = mysql_query($q1) or die($q1."<br/><br/>".mysql_error());
					$gatewayname = mysql_result($r1, 0);
					?>
					<div class="jumbotron">
  						<h1><?php echo $gatewayname;?></h1>
  						<p><?php echo $a333;?>: <?php echo $username;?></p>
  						<p><?php echo $a334;?>: <?php echo $acctype;?></p>
  						<p><?php echo $a335;?>: <?php echo $paymail;?></p>
  						<p><?php echo $a336;?>: <?php echo $amount;?> <?php echo $acu['ISO']; ?></p>
  						<form method='post'>
  							<input class='btn btn-primary' type='hidden' name='payza' value='1'>
  							<input class='btn btn-primary' type='hidden' name='withdrawid' value='<?php echo $id;?>'>
  							<input class='btn btn-primary' type='hidden' name='username' value='<?php echo $username;?>'>
  							<input class='btn btn-primary' type='hidden' name='paymail' value='<?php echo $paymail;?>'>
  							<input class='btn btn-primary' type='hidden' name='acctype' value='<?php echo $acctype;?>'>
  							<input class='btn btn-primary' type='hidden' name='amount' value='<?php echo $amount;?>'>
  							<input class='btn btn-primary' type='hidden' name='gateway' value='<?php echo $gateway;?>'>
  							<div class="col-sm-6">
   					       <input type='submit' name='markaspaid' value='<?php echo $a337;?>' class='btn btn-primary'>
   						</div>
   					</form>
   					<form method='post'>
   						<input class='btn btn-primary' type='hidden' name='payza' value='1'>
   						<input class='btn btn-primary' type='hidden' name='withdrawid' value='<?php echo $id;?>'>
  							<input class='btn btn-primary' type='hidden' name='username' value='<?php echo $username;?>'>
  							<input class='btn btn-primary' type='hidden' name='paymail' value='<?php echo $paymail;?>'>
  							<input class='btn btn-primary' type='hidden' name='acctype' value='<?php echo $acctype;?>'>
  							<input class='btn btn-primary' type='hidden' name='amount' value='<?php echo $amount;?>'>
  							<input class='btn btn-primary' type='hidden' name='gateway' value='<?php echo $gateway;?>'>
   						<div class="col-sm-6">
         					<center>
         						<div class='form-group has-success'>
										<div class="input-group">
               						<input type='text' name='message' placeholder='<?php echo $a338;?>' class='form-control'>
               						<span class="input-group-btn">
               							<input type='submit' name='cancel' value='<?php echo $a339;?>' class='btn btn-primary'>
            							</span>
           							</div>
									</div>
								</center>
  							</div></br></br></br></br>
  						</form>
  						<h2><?php echo $a340;?></h2>
  						<p><?php echo $a341;?> <input style='cursor:copy; opacity: 1' class='form-control autosize' rows='1' value="We are not able to send money to this payment email. Please check payment email and create withdraw request again." onmouseover='this.select()' readonly></p>
  					</div>
					<?php
				}
       	}
       }
     	?>
   <?php 
	if(isset($_POST['skrill'])) {
	?>
	<div class="text-center">
      <h1><small><?php echo $a330;?></small></h1>
 	</div>
		<?php
			$query = "SELECT * FROM Web_Wages WHERE status='-2' AND gateway='5' ORDER BY id ASC LIMIT 1";
			$result = mysql_query($query) or die('Error, query failed');

			if(mysql_num_rows($result)<1){
				?>
					<div class="jumbotron">
  						<h1><?php echo $a331;?></h1>
  						<p><?php echo $a332;?></p>
					</div>
					<?php
   		}else{
     		while($row = mysql_fetch_array($result))
				{
					$id = $row['id'];
					$username = $row['username'];
					$acctype = $row['acctype'];
					$paymail = $row['paymail'];
					$amount = $row['amount'];
					$gateway = $row['gateway'];
					$q1 = "SELECT `name` FROM `Web_Gateways` WHERE `id` = '$gateway'";
					$r1 = mysql_query($q1) or die($q1."<br/><br/>".mysql_error());
					$gatewayname = mysql_result($r1, 0);
					?>
					<div class="jumbotron">
  						<h1><?php echo $gatewayname;?></h1>
  						<p><?php echo $a333;?>: <?php echo $username;?></p>
  						<p><?php echo $a334;?>: <?php echo $acctype;?></p>
  						<p><?php echo $a335;?>: <?php echo $paymail;?></p>
  						<p><?php echo $a336;?>: <?php echo $amount;?> <?php echo $acu['ISO']; ?></p>
  						<form method='post'>
  							<input class='btn btn-primary' type='hidden' name='skrill' value='1'>
  							<input class='btn btn-primary' type='hidden' name='withdrawid' value='<?php echo $id;?>'>
  							<input class='btn btn-primary' type='hidden' name='username' value='<?php echo $username;?>'>
  							<input class='btn btn-primary' type='hidden' name='paymail' value='<?php echo $paymail;?>'>
  							<input class='btn btn-primary' type='hidden' name='acctype' value='<?php echo $acctype;?>'>
  							<input class='btn btn-primary' type='hidden' name='amount' value='<?php echo $amount;?>'>
  							<input class='btn btn-primary' type='hidden' name='gateway' value='<?php echo $gateway;?>'>
  							<div class="col-sm-6">
   					       <input type='submit' name='markaspaid' value='<?php echo $a337;?>' class='btn btn-primary'>
   						</div>
   					</form>
   					<form method='post'>
   						<input class='btn btn-primary' type='hidden' name='skrill' value='1'>
   						<input class='btn btn-primary' type='hidden' name='withdrawid' value='<?php echo $id;?>'>
  							<input class='btn btn-primary' type='hidden' name='username' value='<?php echo $username;?>'>
  							<input class='btn btn-primary' type='hidden' name='paymail' value='<?php echo $paymail;?>'>
  							<input class='btn btn-primary' type='hidden' name='acctype' value='<?php echo $acctype;?>'>
  							<input class='btn btn-primary' type='hidden' name='amount' value='<?php echo $amount;?>'>
  							<input class='btn btn-primary' type='hidden' name='gateway' value='<?php echo $gateway;?>'>
   						<div class="col-sm-6">
         					<center>
         						<div class='form-group has-success'>
										<div class="input-group">
               						<input type='text' name='message' placeholder='<?php echo $a338;?>' class='form-control'>
               						<span class="input-group-btn">
               							<input type='submit' name='cancel' value='<?php echo $a339;?>' class='btn btn-primary'>
            							</span>
           							</div>
									</div>
								</center>
  							</div></br></br></br></br>
  						</form>
  						<h2><?php echo $a340;?></h2>
  						<p><?php echo $a341;?> <input style='cursor:copy; opacity: 1' class='form-control autosize' rows='1' value="We are not able to send money to this payment email. Please check payment email and create withdraw request again." onmouseover='this.select()' readonly></p>
  					</div>
					<?php
				}
       	}
       }
     	?>
</div>

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