<?php
//Load time function (in footer)
$time = microtime(true);
$time = explode(' ', $time);
$time = $time[1] + $time[0];
$start = $time;

$session_username = mysql_real_escape_string($_SESSION['username']);
$session_password = mysql_real_escape_string($_SESSION['password']);

if($_POST['premiumloginsubmit']){
	$secrethash = $_POST['secret_hash'];
	echo"<script type='text/javascript'>window.location= 'premium.Login.$secrethash'</script>";
}

// ADVERTISER DATA
$startq1 = mysql_query("SELECT * FROM Accounts_Classic_Advertisers WHERE username='$session_username' AND password='$session_password'");
$startf1 = mysql_num_rows($startq1);
$seeA = mysql_fetch_array($startq1);

// PUBLISHER DATA
$startq2 = mysql_query("SELECT * FROM Accounts_Classic_Advertisers WHERE username='$session_username' AND password='$session_password'");
$startf2 = mysql_num_rows($startq2);
$seeP = mysql_fetch_array($startq2);

if($page != '404'){
	if(isset($_SESSION['username']) || isset($_SESSION['password']))  {
		echo"<script type='text/javascript'>window.location= 'p.Dashboard'</script>";
	}
}
?>
<!DOCTYPE html>
<html lang="en"><head>
  <meta charset="utf-8">
  <title><?php echo"$title"?></title>
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta name="title" content="<?php echo $sa['title']; ?>">
  <meta name="description" content="<?php echo $sa['description']; ?>">
  <meta name="author" content="Jozef Vojtáš" >
  <link rel="icon" type="image/png" href="<?php echo $iconurl; ?>">
  
  <!-- Google Web Font -->
  <link href="http://fonts.googleapis.com/css?family=Open+Sans:300,300italic,700&subset=latin,latin-ext" rel="stylesheet" type="text/css">
  
  <!-- Bootstrap 3 Plan styles -->
  <link id="plan-theme" href="data/templates/frontend/superhero/assets/css/bootstrap.css" rel="stylesheet">
  <link href="data/templates/frontend/superhero/assets/fonts/font-awesome.css" rel="stylesheet" type="text/css" />

  <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
  <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
    <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
  <![endif]-->

  <!-- Docs Custom styles -->
  <style>

    body {
      padding: 120px 0 0 0; 
    }
    footer {
      background-color: white;
      border-top: 1px solid #ddd;
      padding: 30px;
      margin-top: 50px;
    }  
    .row > [class*="col-"] {
      margin-bottom: 30px;
    }
    .navbar-container {
      position: relative;
      min-height: 100px;
    }
    .navbar-container .navbar.navbar-fixed-top,
    .navbar-container .navbar.navbar-fixed-bottom {
      position: absolute;
      top: 50px;
      z-index: 0;
    }
    .navbar-container .navbar.navbar-fixed-top .container,
    .navbar-container .navbar.navbar-fixed-bottom .container {
      max-width: 90%;
    }
    .btn-group {
      margin-bottom: 10px
    }
    .form-inline select, 
    .form-inline input[type="text"], 
    .form-inline input[type="password"] {
      width: 180px;
    }
    .input-group {
      margin-bottom: 10px;
    }
    .pagination { margin-top :0;}
    .navbar-inverse {margin: 110px 0} 
    input[type="radio"].toggle {
    display: none;
}

input[type="radio"].toggle:checked + label {
    background-color: #3B4B5C;
    cursor: default;
    color: #E6E6E6;
    border-color: transparent;
    text-shadow: 0 1px 1px rgba(40, 40, 40, 0.75);
}

input[type="radio"].toggle + label {
    width: 20%;
}

input[type="radio"].toggle:checked + label.btn:hover {
    background-color: #445260;
    background-position: 0 0;
    -webkit-transition: none;
    -moz-trainsition: none;
    transition: none;
}

input[type="radio"].toggle-left + label {
    border-right: 0;
    -webkit-border-top-right-radius: 0;
    -webkit-border-bottom-right-radius: 0;
    -moz-border-top-right-radius: 0;
    -moz-border-bottom-right-radius: 0;
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

input[type="radio"].toggle-right + label {
    -webkit-border-top-left-radius: 0;
    -webkit-border-bottom-left-radius: 0;
    -moz-border-top-left-radius: 0;
    -moz-border-bottom-left-radius: 0;
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}
  </style>
  
</head>

<body onload="runOnLoad()">

  <nav class="navbar navbar-inverse navbar-fixed-top" role="navigation" style="margin: 0"><!-- WHITE navbar-superhero -->
    <div class="container">
		<?php 
  		if($showicon == '1') { 
  		?>
			<a class="navbar-brand" href="f.home"><img style="margin-top: -6px; height: 35px;" src="<?php echo $iconurl; ?>"></a>
		<?php
		}
  		if($showtitle == '1') { 
  		?>
			<a class="navbar-brand" href="f.home"><?php echo"$title"?></a>
		<?php
		}
		?>
      <!-- Brand and toggle get grouped for better mobile display -->
      <div class="navbar-header navbar-right">
        <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#main-nav">
          <span class="sr-only">Toggle navigation</span>
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
        </button>
      </div>

      <!-- Collect the nav links, forms, and other content for toggling -->
      <div class="collapse navbar-collapse" id="main-nav">
        <ul class="nav navbar-nav">
          <?php
				$queryis = "SELECT * FROM Web_Header_Menu WHERE up='0' ORDER BY ordernum ASC";
				$resultis = mysql_query($queryis) or die('Error, query failed');
     			while($rowss = mysql_fetch_array($resultis))
				{
					$id = $rowss['id'];
					$name = $rowss['name'];
					$local = $rowss['local'];
					$modal = $rowss['modal'];
					$link = $rowss['link'];
					$querynext = "SELECT * FROM Web_Header_Menu WHERE up='$id' ORDER BY ordernum ASC";
					$resultnext = mysql_query($querynext) or die('Error, query failed');
					if(mysql_num_rows($resultnext)<1){
   				?>
   					<li>
            			<a <?php 
            			if($modal == '1'){
            				echo 'data-toggle="modal" ';
            			} 
            			?>href="<?php echo $link; ?>">
            			<?php 
            			if($local == 0){
            				echo $name;
            			} 
            			if($local == 1){
            				$translationtext = $name;
								$translationtext = str_replace("[","",$translationtext);
								$translationtext = str_replace("]","",$translationtext);
            				echo $LANG[$translationtext]['definition'];
            			} 
            			?></a>
         			</li>
   				<?php
   				}else{
   					?>
   						<li class="dropdown">
            				<a href="#" class="dropdown-toggle" data-toggle="dropdown">
            				<?php 
            				if($local == 0){
            					echo $name;
            				} if($local == 1){
            					$translationtext = $name;
									$translationtext = str_replace("[","",$translationtext);
									$translationtext = str_replace("]","",$translationtext);
            					echo $LANG[$translationtext]['definition'];
            				} 
            				?> <b class="caret"></b></a>
            				<ul class="dropdown-menu">
   					<?php
     					while($rowe = mysql_fetch_array($resultnext))
						{
							$namee = $rowe['name'];
							$locale = $rowe['local'];
							$modale = $rowss['modal'];
							$linke = $rowe['link'];
							?>
										<li><a 
										<?php 
            						if($modale == '1'){
            							echo 'data-toggle="modal" ';
            						} 
            						?>href="<?php echo $linke; ?>">
										<?php 
										if($local == 0){
											echo $namee;
										} 
										if($locale == 1){
											$translationtext = $namee;
											$translationtext = str_replace("[","",$translationtext);
											$translationtext = str_replace("]","",$translationtext);
            							echo $LANG[$translationtext]['definition'];
										} 
										?></a></li>
							<?php
						}
						?>
							 	</ul>
          				</li> 
						<?php
					}
				}
          ?>
        </ul>
		<ul class="nav navbar-nav navbar-right">
			<li class="dropdown">
				<a href="#" class="dropdown-toggle" data-toggle="dropdown"><i class="fa fa-language"></i> <b class="caret"></b></a>
				<ul class="dropdown-menu">
					<li><a href="language.english">English</a></li>
					<li><a href="language.slovak">Slovak</a></li>
					<li><a href="language.german">German</a></li>
					<li><a href="language.chinese">Chinese</a></li>
					<li><a href="language.portuguese">Portuguese</a></li>
					<li><a href="language.russian">Russian</a></li>
					<li><a href="language.czech">Czech</a></li>
					<li><a href="language.spanish">Spanish</a></li>
					<li><a href="language.french">French</a></li>
					<li><a href="language.arabic">Arabic</a></li>
					<li><a href="language.croatian">Croatian</a></li>
					<li><a href="language.danish">Danish</a></li>
					<li><a href="language.hungarian">Hungarian</a></li>
					<li><a href="language.italian">Italian</a></li>
					<li><a href="language.japanese">Japanese</a></li>
					<li><a href="language.polish">Polish</a></li>
					<li><a href="language.slovenian">Slovenian</a></li>
					<li><a href="language.swedish">Swedish</a></li>
				</ul>
			</li> 
			<?php 
// IF LOGGED IN SHOW USER PANEL
if($_SESSION['username']) {
?>
			
			<li>
				<a href="#"> 
				<i class="fa fa-sign-in"></i> <?php
				$accounttypenow = $_SESSION['acctype'];
				if($accounttypenow == 0){$accounttypeloggedin = 'Publisher';}
				if($accounttypenow == 1){$accounttypeloggedin = 'Advertiser';}
				echo $accounttypeloggedin . ': ' . $_SESSION['username'];
				?> 
				</a>
			</li>
			<li>
				<a href="switch"> <i class="fa fa-sign-in"></i> <?php
				$accounttypenotnow = $_SESSION['acctype'];
				if($accounttypenotnow == 1){$accounttypeloggedin = 'Publisher';}
				if($accounttypenotnow == 0){$accounttypeloggedin = 'Advertiser';}
				echo 'Switch to: ' . $accounttypeloggedin;
				?> </a>
			</li>
			<li>
				<a href="p.Dashboard"> <i class="fa fa-sign-in"></i> <?php echo $a037;?></a>
			</li>
			<li>
				<a href="logout"> <i class="fa fa-plus"></i> <?php echo $a041;?></a>
			</li>
<?php
}
//IF LOGGED OUT SHOW LOGIN / JOIN NOW PANEL
else
{
?>
			<li>
				<a data-toggle="modal" href="#signin"> <i class="fa fa-sign-in"></i> <?php echo $a043;?></a>
			</li>
			<?php 
			if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
    			$uip = $_SERVER['HTTP_CLIENT_IP'];
			} elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
    			$uip = $_SERVER['HTTP_X_FORWARDED_FOR'];
			} else {
			    $uip = $_SERVER['REMOTE_ADDR'];
			}
			$startq1 = mysql_query("SELECT * FROM Accounts_Premium_Admin WHERE ip='$uip'");
			$startf1 = mysql_num_rows($startq1);
			if($startf1 > 0) {
				?>
				<li>
					<a data-toggle="modal" href="#premiumlogin"> <i class="fa fa-sign-in"></i> Premium Login</a>
				</li>
				<?php
			}
			?>
			<li>
				<a data-toggle="modal" href="#signup"> <i class="fa fa-plus"></i> <?php echo $a042;?></a>
			</li>
<?php
}
?>
		</ul>
      </div><!-- /.navbar-collapse -->
    </div>
  </nav>
<?php
		if($sa['paymentproof'] != '0') {
			$query = "SELECT * FROM Web_Withdraws WHERE status='1' ORDER BY id DESC LIMIT ".$sa['hwmchproofs'];
			$result = mysql_query($query) or die('Error, query failed');

			// print the random numbers
			
			if(mysql_num_rows($result)<1){
   		}else{
   			$proofmove = '1';	
   		?>
   		<div style="width: 100%; margin-top: -80px;" class="alert alert-info">
  				<p>
   				<marquee behavior="scroll" direction="left">
   					Fresh Payouts: 
   		<?php
     		while($row = mysql_fetch_array($result))
				{
					?>
					<label style="margin-left:25px" class="label label-default">					
					<?php
					$text = $row['client_paymail'];
					$textLength = strlen($text);
					$maxChars = $textLength/3;
					if ($textLength > $maxChars){$hiddenusername = substr_replace($text, '***', $maxChars/2, $textLength-$maxChars);}
					?>
   				<?php echo $hiddenusername;?>
					</label>
					<label class="label label-success">	
					<?php echo $row['amount'];?> <?php echo $acu['ISO']; ?> 
					</label>
   				<?php
				}
			?>
					</marquee>
  				</p>
			</div>
		<?php
       	}
       }
		?>