<?php
	session_start();
	session_regenerate_id(true);
	if(!isset($_SESSION['user'])){
		header("Location: index.php");
		exit;
	}
	
	if(!isset($_SESSION['jstoken']) || !isset($_GET['jstoken']) || $_SESSION['jstoken']!=$_GET['jstoken']){
		echo 'WHOOPS!';
		exit;
	}
	
	
	header('Content-Type: application/javascript');
	
	echo '
			window.onload = init();
			function init(){
				var user = "'.$_SESSION['user'].'";
				user = hola(user);
				document.getElementsByTagName("h1")[0].innerHTML = user;
			}
			function hola(user){
				user = "HOLA 2 "+user;
				return user;
			}
		 ';
?>