<?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="col-sm-8 col-md-offset-2">
		<div class="text-center">
      	<h1><small>Your API key</small></h1>
 		</div>
 			<?php
 			if(isset($_POST['alllinks']))
{
	$bigtext = $_POST['alllinks'];
	$urlst = explode(",", $bigtext);
	$icount = 0;
	if(0 < sizeof($urlst))
	{
		?>
		<textarea class="form-control" name="alllinks" onmouseover='this.select()' style="cursor:copy;opacity: 1;width:600px;height:300px;" readonly>
<script src="<?php echo $mainurl; ?>get/jquery.js"></script>
<script style="text/javascript">
	$(document).ready(function() {
<?php
			$abc = 1;
	}
	while($icount < sizeof($urlst))
	{
		$cuntl = trim($urlst[$icount]);
		$icount++;
		// in case scheme relative URI is passed, e.g., //www.google.com/
		$cuntl = trim($cuntl, '/');
		
		// If scheme not included, prepend it
		if (!preg_match('#^http(s)?://#', $cuntl)) {
			$cuntl = 'http://' . $cuntl;
		}
		
		$urlParts = parse_url($cuntl);
		
		// remove www
		$cuntl = preg_replace('/^www\./', '', $urlParts['host']);
		?>
		var paragraphs = $("a[href*='<?php echo $cuntl; ?>']");
		for(var i = 0; i < paragraphs.length; i++)
		{ 
			newHref = paragraphs[i].href; 
			paragraphs[i].href = '<?php echo $mainurl ; ?>get/short.php?api=<?php echo $seeP["api"]; ?>&url=' + newHref;
		}
<?php
	}
	if ($abc == 1){
		?>
});
</script>
</textarea></br>
<form action="" method="POST">
<input class="ios_btn_spinner btn btn-primary" type="submit" name="submit" value='<?php echo $a191 ?>'>
</form>
		<?php
	}
	
}
else {
?>
											<p><?php echo $a190 ?></p>
											<form action="" method="POST">
												<textarea class="form-control" placeholder="http://google.com, http://youtube.com, http://twitter.com - Seperate them with commas" name="alllinks" style="width:100%;height:35px;"></textarea><br />
												<input class="ios_btn_spinner btn btn-primary" type="submit" name="submit" value='<?php echo $a091 ?>'>
											</form>
<?php } ?>
	</div>
</div>

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