<?php
ini_set('session.cookie_secure', '1');
ini_set('session.cookie_lifetime', '2592000');
ob_start(); //Turns on output buffering 
session_start();
require('core/config.php');

class PartyStarter {
	// creates header
	function header()
	{
		echo "test";
	}
	function bootstrap() {
		echo '<link rel="stylesheet" href="css/bootstrap.min.css">';
	}
	function buildloggedoutheader() {
		require('core/config.php');
		if(isset($_SESSION['user'])) {
	 $query = $con->prepare('SELECT money FROM users WHERE id=:id');
	 $query->bindParam(':id', $id);
     $query->execute();	
     $money = $query->fetch(PDO::FETCH_ASSOC)["money"];
		$currencyIcon = "$";
		
		if ($money < 1000000) {
         // Anything less than a million
         $money = $currencyIcon.number_format($money);
        } else if ($money < 1000000000) {
         // Anything less than a billion
         $money = $currencyIcon.number_format($money / 1000000, 1) . 'M';
        } else {
         // At least a billion
         $money = $currencyIcon.number_format($money / 1000000000, 1) . 'B';
        
		}
		// messy shit sorry mario1 fix it urself :trol:
		
	     $rightside = '<li class="nav-item"><a class="nav-link">'.$money.'</a></li>        <li class="nav-item">
          <a class="nav-link" href="/logout">Logout</a>
        </li>';
        } else {
	     $rightside = '
        <li class="nav-item">
          <a class="nav-link" href="/register">Register</a>
        </li>
        <li class="nav-item">
          <a class="nav-link" href="/login">Login</a>
        </li>';
        }
	    echo '<style> body, html { background-color: #2b3036; } </style>';
		echo '<link rel="stylesheet" href="css/bootstrap.min.css">
<nav class="navbar navbar-expand-lg navbar-light" style="background-color: #ff7700;">
  <div class="container-fluid">
    <a class="navbar-brand" href="/"><img src="/assets/win7.png" width="30" height="30" class="d-inline-block align-top" alt=""> '.$sitename.' </a>
    <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarColor03" aria-controls="navbarColor03" aria-expanded="false" aria-label="Toggle navigation">
      <span class="navbar-toggler-icon"></span>
    </button>
    <div class="collapse navbar-collapse" id="navbarColor03">
      <ul class="navbar-nav me-auto ml-auto" style="color: #FFFFFF;">
        <li class="nav-item" style="color: #FFFFFF;">
          <a class="nav-link active" href="/home">Home
            <span class="visually-hidden">(current)</span>
          </a>
        </li>
        <li class="nav-item">
          <a class="nav-link" href="/games">Games</a>
        </li>
        <li class="nav-item">
          <a class="nav-link" href="/catalog">Catalog</a>
        </li>
        <li class="nav-item">
          <a class="nav-link" href="/about">About</a>
        </li>
      </ul>
      <ul class="navbar-nav">
        <li class="nav-item">
        </li>
'.$rightside.'
      </ul>
    </div>
  </div>
</nav>';
	}
	

}
?>