<?php
global $user_rg;
include ('config.php');
$login = $_SESSION["login"];
echo "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"  \"http://www.w3.org/TR/html4/loose.dtd\">
<html>
";
/*
echo"<font color=\"FF0000\">Message Admin : Si certaine page se chargent mal ou pas du tout, pas la peine de le crier partout sur le forum : nous sommes au courant. <br>Veillez nous escuser pour ce désagrement.</font>";*/
$sqlid = "SELECT id FROM matgraph_users WHERE login='".$login."'";
$reqid = mysql_query($sqlid) or die('Erreur SQL !<br>'.$sqlid.'<br>'.mysql_error());
$dataid = mysql_fetch_array($reqid);
$idlogin = $dataid['id'] ;
$_SESSION['idlogin']=$idlogin;

$req2 = "SELECT planete FROM matgraph_idjoueur WHERE idjoueur='$idlogin'";
$res2 = mysql_query($req2)or die('erreur sql<br>'.$req2.'<br>'.mysql_error());
$row2 = mysql_fetch_array($res2); 
$planete = $row2['planete'];

$sql = "SELECT place,placepris FROM matgraph_users WHERE id='$planete'";
$req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error());
$data = mysql_fetch_array($req);
if (($data['placepris'] + 1 ) <= $data['place']) {
	$place = 1 ;
}else{
	$place = -1 ; 
}

$reqpts = "SELECT vacance,pts_flotte,pts_bats,pts_def,pts_tech FROM matgraph_users WHERE idjoueur='".$idlogin."'";
$respts = mysql_query($reqpts)or die('erreur sql<br>'.$reqpts.'<br>'.mysql_error());
$rowpts = mysql_fetch_array($respts); 

if($rowpts['pts_def'] < 0 OR $rowpts['pts_flotte'] < 0) {
	if($rowpts['pts_def'] < 0) {
		$New_pts = $rowpts['pts_flotte'] + $rowpts['pts_bats'] + $rowpts['pts_tech']; 
	}else{
		$New_pts = $rowpts['pts_bats'] + $rowpts['pts_def'] + $rowpts['pts_tech']; 
	} 
}else{
	$New_pts = $rowpts['pts_flotte'] + $rowpts['pts_bats'] + $rowpts['pts_def'] + $rowpts['pts_tech']; 
}

$requete = "UPDATE matgraph_users SET pts='".$New_pts."' WHERE id='".$idlogin."'";
$resultat = mysql_query($requete)or die('erreur sql<br>'.$requete.'<br>'.mysql_error());


$req = "SELECT * FROM matgraph_axxadmin WHERE idjoueur = '".$idlogin."'";
$res = mysql_query($req) or die('Erreur SQL! <br>'.$req.'<br>'.mysql_error());
$num = mysql_num_rows($res);
if ( $num == "0" ) {
	echo '<script language="javascript" type="text/javascript">
<!--
window.location.replace("../index.php");
-->
</script>'; 
}else{
	$list=mysql_fetch_array($res);
	$user_rg=$list['rang'];
	$_SESSION['user_rg']=$user_rg;
}
echo"<head>
<title>Administration Stargate Univers</title>
<script type=\"text/javascript\">
function hidestatus(){
	window.status=''
	return true
}
if (document.layers)
	document.captureEvents(Event.MOUSEOVER | Event.MOUSEOUT)
	document.onmouseover=hidestatus
	document.onmouseout=hidestatus
</script>";

require_once ('include/general.php');
?>