<?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(mysql_real_escape_string($_POST['editaccd'])) 
{
	// GET VALUES FROM FORM
	$yname = mysql_real_escape_string($_POST['yname']);
	$yname = AntiXSS::setEncoding($yname, "UTF-8");
	$yname = str_replace('"','',$yname);
	$yname = str_replace("'","",$yname);
	$yname = str_replace(">","",$yname);
	$yname = str_replace("<","",$yname);
	$yname = str_replace("</","",$yname);
	$yname = str_replace("&%","",$yname);
	$yname = str_replace("script","",$yname);
	$yname = str_replace("(","",$yname);
	$yname = str_replace(")","",$yname);
	$yaddress = mysql_real_escape_string($_POST['yaddress']);
	$yaddress = AntiXSS::setEncoding($yaddress, "UTF-8");
	$yaddress = str_replace('"','',$yaddress);
	$yaddress = str_replace("'","",$yaddress);
	$yaddress = str_replace(">","",$yaddress);
	$yaddress = str_replace("<","",$yaddress);
	$yaddress = str_replace("</","",$yaddress);
	$yaddress = str_replace("&%","",$yaddress);
	$yaddress = str_replace("script","",$yaddress);
	$yaddress = str_replace("(","",$yaddress);
	$yaddress = str_replace(")","",$yaddress);
	$ycity = mysql_real_escape_string($_POST['ycity']);
	$ycity = AntiXSS::setEncoding($ycity, "UTF-8");
	$ycity = str_replace('"','',$ycity);
	$ycity = str_replace("'","",$ycity);
	$ycity = str_replace(">","",$ycity);
	$ycity = str_replace("<","",$ycity);
	$ycity = str_replace("</","",$ycity);
	$ycity = str_replace("&%","",$ycity);
	$ycity = str_replace("script","",$ycity);
	$ycity = str_replace("(","",$ycity);
	$ycity = str_replace(")","",$ycity);
	$yzip = mysql_real_escape_string($_POST['yzip']);
	$yzip = AntiXSS::setEncoding($yzip, "UTF-8");
	$yzip = str_replace('"','',$yzip);
	$yzip = str_replace("'","",$yzip);
	$yzip = str_replace(">","",$yzip);
	$yzip = str_replace("<","",$yzip);
	$yzip = str_replace("</","",$yzip);
	$yzip = str_replace("&%","",$yzip);
	$yzip = str_replace("script","",$yzip);
	$yzip = str_replace("(","",$yzip);
	$yzip = str_replace(")","",$yzip);
	$ytel = mysql_real_escape_string($_POST['ytel']);
	$ytel = AntiXSS::setEncoding($ytel, "UTF-8");
	$ytel = str_replace('"','',$ytel);
	$ytel = str_replace("'","",$ytel);
	$ytel = str_replace(">","",$ytel);
	$ytel = str_replace("<","",$ytel);
	$ytel = str_replace("</","",$ytel);
	$ytel = str_replace("&%","",$ytel);
	$ytel = str_replace("script","",$ytel);
	$ytel = str_replace("(","",$ytel);
	$ytel = str_replace(")","",$ytel);
	$ppem = mysql_real_escape_string($_POST['paypalemail']);
	$ppem = AntiXSS::setEncoding($ppem, "UTF-8");
	$ppem = str_replace('"','',$ppem);
	$ppem = str_replace("'","",$ppem);
	$ppem = str_replace(">","",$ppem);
	$ppem = str_replace("<","",$ppem);
	$ppem = str_replace("</","",$ppem);
	$ppem = str_replace("&%","",$ppem);
	$ppem = str_replace("script","",$ppem);
	$ppem = str_replace("(","",$ppem);
	$ppem = str_replace(")","",$ppem);
	$apem = mysql_real_escape_string($_POST['payzaemail']);
	$apem = AntiXSS::setEncoding($apem, "UTF-8");
	$apem = str_replace('"','',$apem);
	$apem = str_replace("'","",$apem);
	$apem = str_replace(">","",$apem);
	$apem = str_replace("<","",$apem);
	$apem = str_replace("</","",$apem);
	$apem = str_replace("&%","",$apem);
	$apem = str_replace("script","",$apem);
	$apem = str_replace("(","",$apem);
	$apem = str_replace(")","",$apem);
	$skrillem = mysql_real_escape_string($_POST['skrillemail']);
	$skrillem = AntiXSS::setEncoding($skrillem, "UTF-8");
	$skrillem = str_replace('"','',$skrillem);
	$skrillem = str_replace("'","",$skrillem);
	$skrillem = str_replace(">","",$skrillem);
	$skrillem = str_replace("<","",$skrillem);
	$skrillem = str_replace("</","",$skrillem);
	$skrillem = str_replace("&%","",$skrillem);
	$skrillem = str_replace("script","",$skrillem);
	$skrillem = str_replace("(","",$skrillem);
	$skrillem = str_replace(")","",$skrillem);
	$checkoutem = mysql_real_escape_string($_POST['2checkoutemail']);
	$checkoutem = AntiXSS::setEncoding($checkoutem, "UTF-8");
	$checkoutem = str_replace('"','',$checkoutem);
	$checkoutem = str_replace("'","",$checkoutem);
	$checkoutem = str_replace(">","",$checkoutem);
	$checkoutem = str_replace("<","",$checkoutem);
	$checkoutem = str_replace("</","",$checkoutem);
	$checkoutem = str_replace("&%","",$checkoutem);
	$checkoutem = str_replace("script","",$checkoutem);
	$checkoutem = str_replace("(","",$checkoutem);
	$checkoutem = str_replace(")","",$checkoutem);
	$g2aem = mysql_real_escape_string($_POST['g2aemail']);
	$g2aem = AntiXSS::setEncoding($g2aem, "UTF-8");
	$g2aem = str_replace('"','',$g2aem);
	$g2aem = str_replace("'","",$g2aem);
	$g2aem = str_replace(">","",$g2aem);
	$g2aem = str_replace("<","",$g2aem);
	$g2aem = str_replace("</","",$g2aem);
	$g2aem = str_replace("&%","",$g2aem);
	$g2aem = str_replace("script","",$g2aem);
	$g2aem = str_replace("(","",$g2aem);
	$g2aem = str_replace(")","",$g2aem);
	if ((isset($yname)) && (isset($yaddress)) && (isset($ycity)) && (isset($yzip)) && (isset($ytel))){
		//EDIT USER VALUES IN DB WITH NEW VALUES
		$sql1 = mysql_query("UPDATE `Accounts_Classic_Publishers` SET `name` = '$yname', `address` = '$yaddress', `city` = '$ycity', `zipcode` = '$yzip', `telephone` = '$ytel', `paypalemail` = '$ppem', `payzaemail` = '$apem', `skrillemail` = '$skrillem', `2checkoutemail` = '$checkoutem', `g2aemail` = '$g2aem' WHERE `username` = '$session_username'") or die(mysql_error());
		$sql1 = mysql_query("UPDATE `Accounts_Classic_Advertisers` SET `name` = '$yname', `address` = '$yaddress', `city` = '$ycity', `zipcode` = '$yzip', `telephone` = '$ytel', `paypalemail` = '$ppem', `payzaemail` = '$apem', `skrillemail` = '$skrillem', `2checkoutemail` = '$checkoutem', `g2aemail` = '$g2aem' WHERE `username` = '$session_username'") or die(mysql_error());
		?>
		<div style="margin-top: -80px;" class="alert alert-success" role="alert">
			<strong>Well done!</strong> <?php echo $session_username; ?>
		</div>
		<?php
	}else{
		?>
		<div style="margin-top: -80px;" class="alert alert-error" role="alert">
			<strong>Sorry!</strong> Fill all
		</div>
		<?php
	}
			
}


// IF CHANGING PASSWORD
if(mysql_real_escape_string($_POST['editpass'])) 
{
	// GER CURRENT PASSWORD FROM FORM
	$cpass = mysql_real_escape_string(md5($_POST['cpass']));
	$cpass = AntiXSS::setEncoding($cpass, "UTF-8");
	$cpass = str_replace('"','',$cpass);
	$cpass = str_replace("'","",$cpass);
	$cpass = str_replace(">","",$cpass);
	$cpass = str_replace("<","",$cpass);
	$cpass = str_replace("</","",$cpass);
	$cpass = str_replace("&%","",$cpass);
	$cpass = str_replace("script","",$cpass);
	$cpass = str_replace("(","",$cpass);
	$cpass = str_replace(")","",$cpass);
	// GET NEW PASS FROM FORM
	$npass = mysql_real_escape_string(md5($_POST['npass']));
	$npass = AntiXSS::setEncoding($npass, "UTF-8");
	$npass = str_replace('"','',$npass);
	$npass = str_replace("'","",$npass);
	$npass = str_replace(">","",$npass);
	$npass = str_replace("<","",$npass);
	$npass = str_replace("</","",$npass);
	$npass = str_replace("&%","",$npass);
	$npass = str_replace("script","",$npass);
	$npass = str_replace("(","",$npass);
	$npass = str_replace(")","",$npass);
	// GET REPEADED NEW PASS FROM FORM
	$rnpass = mysql_real_escape_string(md5($_POST['rnpass']));
	$rnpass = AntiXSS::setEncoding($rnpass, "UTF-8");
	$rnpass = str_replace('"','',$rnpass);
	$rnpass = str_replace("'","",$rnpass);
	$rnpass = str_replace(">","",$rnpass);
	$rnpass = str_replace("<","",$rnpass);
	$rnpass = str_replace("</","",$rnpass);
	$rnpass = str_replace("&%","",$rnpass);
	$rnpass = str_replace("script","",$rnpass);
	$rnpass = str_replace("(","",$rnpass);
	$rnpass = str_replace(")","",$rnpass);
	// IF CURRENT PASS = WITH PASSWORD IN DB
	if($cpass == $seeP['password']) 
	{
		// IF IN FORM WAS ENTERED ALL VALUES
		if($cpass&&$npass&&$rnpass) 
		{
			// IF NEW PASSWORD = WITH REPEADED PASSWORD
			if($npass == $rnpass) 
			{
				//EDIT PASSWORD IN DATABASE
				$changevalues = mysql_query("UPDATE Accounts_Classic_Publishers SET password='$npass' WHERE username='$session_username'");
				$changevalues = mysql_query("UPDATE Accounts_Classic_Advertisers SET password='$npass' WHERE username='$session_username'");
				// PRINT SUCCESS INFO
				?>
				<div style="margin-top: -80px;" class="alert alert-success" role="alert">
					<strong>Well done!</strong> Successfully changed password
				</div>
				<?php
			}
		// PRINT ERROR INFO >> PASSWORDS NOT MATCHES
		else{
		?>
		<div style="margin-top: -80px;" class="alert alert-error" role="alert">
			<strong>Sorry!</strong> Please enter same passwords
		</div>
		<?php
		}

		}
	// ERROR >> MUST FILL ALL FIELDS
	else{
		?>
		<div style="margin-top: -80px;" class="alert alert-success" role="alert">
			<strong>Sorry!</strong> Fill all
		</div>
		<?php	
	}

	}
// ENTERED PASSWORD IS NOT EQUAL WITH PASSWORD IN DB
else{
	?>
	<div style="margin-top: -80px;" class="alert alert-error" role="alert">
		<strong>Sorry!</strong> Must enter same password as you have now
	</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>Account settings - <?php echo $session_username; ?></small></h1>
 	</div>
		<div class="row">
      <div class="col-md-8 col-md-offset-2">
		<div class="row">
			<div class="col-md-8 col-md-offset-2">

			<form name="csrf_form" method="POST">
				<input type="hidden" name="csrf_token" value="<?php echo $token; ?>">
				<div class="input-group">
					<span style="width: 220px; min-width: 220px; max-width: 220px;" class="input-group-addon">Vaše meno</span>
					<input style="width: 250px; max-width: 250px; min-width: 250px;" value="<?php echo $seeP['name']; ?>" type="text" class="form-control" name="yname">
				</div>
				<div class="input-group">
					<span style="width: 220px; min-width: 220px; max-width: 220px;" class="input-group-addon">Vaša adresa</span>
					<input style="width: 250px; max-width: 250px; min-width: 250px;" value="<?php echo $seeP['address']; ?>" type="text" class="form-control" name="yaddress">
				</div>
				<div class="input-group">
					<span style="width: 220px; min-width: 220px; max-width: 220px;" class="input-group-addon">Mesto</span>
					<input style="width: 250px; max-width: 250px; min-width: 250px;" value="<?php echo $seeP['city']; ?>" type="text" class="form-control" name="ycity">
				</div>
				<div class="input-group">
					<span style="width: 220px; min-width: 220px; max-width: 220px;" class="input-group-addon">PSČ</span>
					<input style="width: 250px; max-width: 250px; min-width: 250px;" value="<?php echo $seeP['zipcode']; ?>" type="text" class="form-control" name="yzip">
				</div>
				<div class="input-group">
					<span style="width: 220px; min-width: 220px; max-width: 220px;" class="input-group-addon">Mobilené číslo</span>
					<input style="width: 250px; max-width: 250px; min-width: 250px;" value="<?php echo $seeP['telephone']; ?>" type="text" class="form-control" name="ytel">
				</div>
				<div class="input-group">
					<span style="width: 220px; min-width: 220px; max-width: 220px;" class="input-group-addon">Paypal Email</span>
					<input style="width: 250px; max-width: 250px; min-width: 250px;" value="<?php echo $seeP['paypalemail']; ?>" type="text" class="form-control" name="paypalemail">
				</div>
				<div class="input-group">
					<span style="width: 220px; min-width: 220px; max-width: 220px;" class="input-group-addon">Payza Email</span>
					<input style="width: 250px; max-width: 250px; min-width: 250px;" value="<?php echo $seeP['payzaemail']; ?>" type="text" class="form-control" name="payzaemail">
				</div>
				<div class="input-group">
					<span style="width: 220px; min-width: 220px; max-width: 220px;" class="input-group-addon">Skrill Email</span>
					<input style="width: 250px; max-width: 250px; min-width: 250px;" value="<?php echo $seeP['skrillemail']; ?>" type="text" class="form-control" name="skrillemail">
				</div>
				<div class="input-group">
					<span style="width: 220px; min-width: 220px; max-width: 220px;" class="input-group-addon">2checkout Email</span>
					<input style="width: 250px; max-width: 250px; min-width: 250px;" value="<?php echo $seeP['2checkoutemail']; ?>" type="text" class="form-control" name="2checkoutemail">
				</div>
				<div class="input-group">
					<span style="width: 220px; min-width: 220px; max-width: 220px;" class="input-group-addon">G2APay Email</span>
					<input style="width: 250px; max-width: 250px; min-width: 250px;" value="<?php echo $seeP['g2aemail']; ?>" type="text" class="form-control" name="g2aemail">
				</div>
				<div class="input-group">
					<span style="width: 220px; min-width: 220px; max-width: 220px;" class="input-group-addon">Krajina</span>
					<input style="width: 250px; max-width: 250px; min-width: 250px;" value="<?php echo $seeP['country']; ?>" value="<?php echo $ma['country']; ?>" type="text" class="form-control" name="country" readonly>
				</div>
				<div class="input-group">
					<input name="editaccd" value="<?php echo"$a094"; ?>" class="btn btn-block btn-lg" type="submit">
				</div>
			</form>
			</div>
			</br>
			</br>
			</br>
        </div>
      </div>
    </div>
    
    
   <div class="text-center">
      <h1><small>Heslo</small></h1>
 	</div>
    <div class="row">
      <div class="col-md-8 col-md-offset-2">
		<div class="row">
			<div class="col-md-8 col-md-offset-2">
			<form name="csrf_form" method="POST">
				<input type="hidden" name="csrf_token" value="<?php echo $token; ?>">
				<div class="input-group">
					<span style="width: 220px; min-width: 220px; max-width: 220px;" class="input-group-addon">Aktuálne heslo</span>
					<input style="width: 250px; max-width: 250px; min-width: 250px;" type="password" class="form-control" name="cpass">
				</div>
				<div class="input-group">
					<span style="width: 220px; min-width: 220px; max-width: 220px;" class="input-group-addon">Nové heslo</span>
					<input style="width: 250px; max-width: 250px; min-width: 250px;" type="password" class="form-control" name="npass">
				</div>
				<div class="input-group">
					<span style="width: 220px; min-width: 220px; max-width: 220px;" class="input-group-addon">Zopakujte nové heslo</span>
					<input style="width: 250px; max-width: 250px; min-width: 250px;" type="password" class="form-control" name="rpass">
				</div>
				<div class="input-group">
					<input name="editpass" value="<?php echo"$a094"; ?>" class="btn btn-block btn-lg" type="submit">
				</div>
			</form>
			</div>
			</br>
			</br>
			</br>
        </div>
      </div>
    </div>
</div>

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