<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!-- page_morpion.php avec $_SESSION 16/06/23-->
<?php
session_set_cookie_params
(360000,"/");
session_start();
include(
"header.php");
?>
<title>Bertrand&gt;Morpion</title>
<meta name="Description" content="Jeux du morpion">
<?php
    
if (isMobile() || $m==1)
        {
        echo(
'<link rel="stylesheet" href="morpion/style_morpion-mobi.css">');
        }
        else
        {
        echo(
'<link rel="stylesheet" href="morpion/style_morpion.css">');
        }
    
?>
    
</head>
<body>
<?php

//déclaration des variables
if (!isset($_GET["clic"]))    {$_SESSION["clic"] = '';}
else
    
$_SESSION["clic"] = $_GET["clic"];
if (!isset(
$_SESSION["a1"]))    {$_SESSION["a1"] = '';}
if (!isset(
$_SESSION["a2"]))    {$_SESSION["a2"] = '';}
if (!isset(
$_SESSION["a3"]))    {$_SESSION["a3"] = '';}
if (!isset(
$_SESSION["b1"]))    {$_SESSION["b1"] = '';}
if (!isset(
$_SESSION["b2"]))    {$_SESSION["b2"] = '';}
if (!isset(
$_SESSION["b3"]))    {$_SESSION["b3"] = '';}
if (!isset(
$_SESSION["c1"]))    {$_SESSION["c1"] = '';}
if (!isset(
$_SESSION["c2"]))    {$_SESSION["c2"] = '';}
if (!isset(
$_SESSION["c3"]))    {$_SESSION["c3"] = '';}
if (!isset(
$_SESSION["TOUR_JOUEUR"]))    {$_SESSION["TOUR_JOUEUR"] = 'croix';}
if (!isset(
$_SESSION["win"]))    {$_SESSION["win"] = 'false';}
if (!isset(
$_SESSION["clic"])) {$_SESSION["clic"] = "";}
if (isset(
$_GET["debug"]))    {$_SESSION["debug"] = "";}

// nouvelle partie
if($_SESSION["clic"] == "destroy")
    {
    
$_SESSION["clic"] == "";
    
session_destroy();
    echo 
'<script type="text/JavaScript"> window.location.href = "page_morpion_session.php"; </script>';
    }

if(
$_SESSION["clic"] == "a1" && $_SESSION["a1"] == "")
    
$_SESSION["a1"] = $_SESSION['TOUR_JOUEUR'];
if(
$_SESSION["clic"] == "a2" && $_SESSION["a2"] == "")
    
$_SESSION["a2"] = $_SESSION['TOUR_JOUEUR'];
if(
$_SESSION["clic"] == "a3" && $_SESSION["a3"] == "")
    
$_SESSION["a3"] = $_SESSION['TOUR_JOUEUR'];
if(
$_SESSION["clic"] == "b1" && $_SESSION["b1"] == "")
    
$_SESSION["b1"] = $_SESSION['TOUR_JOUEUR'];
if(
$_SESSION["clic"] == "b2" && $_SESSION["b2"] == "")
    
$_SESSION["b2"] = $_SESSION['TOUR_JOUEUR'];
if(
$_SESSION["clic"] == "b3" && $_SESSION["b3"] == "")
    
$_SESSION["b3"] = $_SESSION['TOUR_JOUEUR'];
if(
$_SESSION["clic"] == "c1" && $_SESSION["c1"] == "")
    
$_SESSION["c1"] = $_SESSION['TOUR_JOUEUR'];
if(
$_SESSION["clic"] == "c2" && $_SESSION["c2"] == "")
    
$_SESSION["c2"] = $_SESSION['TOUR_JOUEUR'];
if(
$_SESSION["clic"] == "c3" && $_SESSION["c3"] == "")
    
$_SESSION["c3"] = $_SESSION['TOUR_JOUEUR'];

//calcul si c'est gagnant
if ($_SESSION["a1"]!="" && $_SESSION["a1"]==$_SESSION["b1"] && $_SESSION["b1"]==$_SESSION["c1"])    {$_SESSION["who_win"]=$_SESSION["a1"];$_SESSION["win"]="true";}
if (
$_SESSION["a2"]!="" && $_SESSION["a2"]==$_SESSION["b2"] && $_SESSION["b2"]==$_SESSION["c2"])    {$_SESSION["who_win"]=$_SESSION["a2"];$_SESSION["win"]="true";}
if (
$_SESSION["a3"]!="" && $_SESSION["a3"]==$_SESSION["b3"] && $_SESSION["b3"]==$_SESSION["c3"])    {$_SESSION["who_win"]=$_SESSION["a3"];$_SESSION["win"]="true";}
if (
$_SESSION["a1"]!="" && $_SESSION["a1"]==$_SESSION["a2"] && $_SESSION["a2"]==$_SESSION["a3"])    {$_SESSION["who_win"]=$_SESSION["a1"];$_SESSION["win"]="true";}
if (
$_SESSION["b1"]!="" && $_SESSION["b1"]==$_SESSION["b2"] && $_SESSION["b2"]==$_SESSION["b3"])    {$_SESSION["who_win"]=$_SESSION["b1"];$_SESSION["win"]="true";}
if (
$_SESSION["c1"]!="" && $_SESSION["c1"]==$_SESSION["c2"] && $_SESSION["c2"]==$_SESSION["c3"])    {$_SESSION["who_win"]=$_SESSION["c1"];$_SESSION["win"]="true";}
if (
$_SESSION["a1"]!="" && $_SESSION["a1"]==$_SESSION["b2"] && $_SESSION["b2"]==$_SESSION["c3"])    {$_SESSION["who_win"]=$_SESSION["a1"];$_SESSION["win"]="true";}
if (
$_SESSION["a3"]!="" && $_SESSION["a3"]==$_SESSION["b2"] && $_SESSION["b2"]==$_SESSION["c1"])    {$_SESSION["who_win"]=$_SESSION["a3"];$_SESSION["win"]="true";}

if (
$m==1)
    {
    include(
"aff_icone.php");
    echo(
'<h1>Jeux du morpion</h1>');
    }
?>
<div id="div_morpion">
<p class="case_a1">
    <?php
    
if ($_SESSION["a1"]=="rond")    {echo('<img src="morpion/morpion_rond.jpg" alt="rond">');}
    if (
$_SESSION["a1"]=="croix")    {echo('<img src="morpion/morpion_croix.jpg" alt="croix">');}
    if (
$_SESSION["a1"]!="rond" && $_SESSION["a1"]!="croix" && $_SESSION["win"]=="false")
        {
        echo(
'<a href="page_morpion_session.php?clic=a1"><img border=0 src="morpion/morpion_vide.jpg" alt="vide"></a>');
        }
    
?>
</p>
<p class="case_a2">
    <?php
    
if ($_SESSION["a2"]=="rond")    {echo('<img src="morpion/morpion_rond.jpg" alt="rond">');}
    if (
$_SESSION["a2"]=="croix")    {echo('<img src="morpion/morpion_croix.jpg" alt="croix">');}
    if (
$_SESSION["a2"]!="rond" && $_SESSION["a2"]!="croix" && $_SESSION["win"]=="false")
        {
        echo(
'<a href="page_morpion_session.php?clic=a2"><img border=0 src="morpion/morpion_vide.jpg" alt="vide"></a>');
        }
    
?>
</p>
<p class="case_a3">
    <?php
    
if ($_SESSION["a3"]=="rond")    {echo('<img src="morpion/morpion_rond.jpg" alt="rond">');}
    if (
$_SESSION["a3"]=="croix")    {echo('<img src="morpion/morpion_croix.jpg" alt="croix">');}
    if (
$_SESSION["a3"]!="rond" && $_SESSION["a3"]!="croix" && $_SESSION["win"]=="false")
        {
        echo(
'<a href="page_morpion_session.php?clic=a3"><img border=0 src="morpion/morpion_vide.jpg" alt="vide"></a>');
        }
    
?>
</p>

<p class="case_b1">
    <?php
    
if ($_SESSION["b1"]=="rond")    {echo('<img src="morpion/morpion_rond.jpg" alt="rond">');}
    if (
$_SESSION["b1"]=="croix")    {echo('<img src="morpion/morpion_croix.jpg" alt="croix">');}
    if (
$_SESSION["b1"]!="rond" && $_SESSION["b1"]!="croix" && $_SESSION["win"]=="false")
        {
        echo(
'<a href="page_morpion_session.php?clic=b1"><img border=0 src="morpion/morpion_vide.jpg" alt="vide"></a>');
        }
    
?>
</p>

<p class="case_b2">
    <?php
    
if ($_SESSION["b2"]=="rond")    {echo('<img src="morpion/morpion_rond.jpg" alt="rond">');}
    if (
$_SESSION["b2"]=="croix")    {echo('<img src="morpion/morpion_croix.jpg" alt="croix">');}
    if (
$_SESSION["b2"]!="rond" && $_SESSION["b2"]!="croix" && $_SESSION["win"]=="false")
        {
        echo(
'<a href="page_morpion_session.php?clic=b2"><img border=0 src="morpion/morpion_vide.jpg" alt="vide"></a>');
        }
    
?>
</p>

<p class="case_b3">
    <?php
    
if ($_SESSION["b3"]=="rond")    {echo('<img src="morpion/morpion_rond.jpg" alt="rond">');}
    if (
$_SESSION["b3"]=="croix")    {echo('<img src="morpion/morpion_croix.jpg" alt="croix">');}
    if (
$_SESSION["b3"]!="rond" && $_SESSION["b3"]!="croix" && $_SESSION["win"]=="false")
        {
        echo(
'<a href="page_morpion_session.php?clic=b3"><img border=0 src="morpion/morpion_vide.jpg" alt="vide"></a>');
        }
    
?>
</p>

<p class="case_c1">
    <?php
    
if ($_SESSION["c1"]=="rond")    {echo('<img src="morpion/morpion_rond.jpg" alt="rond">');}
    if (
$_SESSION["c1"]=="croix")    {echo('<img src="morpion/morpion_croix.jpg" alt="croix">');}
    if (
$_SESSION["c1"]!="rond" && $_SESSION["c1"]!="croix" && $_SESSION["win"]=="false")
        {
        echo(
'<a href="page_morpion_session.php?clic=c1"><img border=0 src="morpion/morpion_vide.jpg" alt="vide"></a>');
        }
    
?>
</p>
<p class="case_c2">
    <?php
    
if ($_SESSION["c2"]=="rond")    {echo('<img src="morpion/morpion_rond.jpg" alt="rond">');}
    if (
$_SESSION["c2"]=="croix")    {echo('<img src="morpion/morpion_croix.jpg" alt="croix">');}
    if (
$_SESSION["c2"]!="rond" && $_SESSION["c2"]!="croix" && $_SESSION["win"]=="false")
        {
        echo(
'<a href="page_morpion_session.php?clic=c2"><img border=0 src="morpion/morpion_vide.jpg" alt="vide"></a>');
        }
    
?>
</p>
<p class="case_c3">
    <?php
    
if ($_SESSION["c3"]=="rond")    {echo('<img src="morpion/morpion_rond.jpg" alt="rond">');}
    if (
$_SESSION["c3"]=="croix")    {echo('<img src="morpion/morpion_croix.jpg" alt="croix">');}
    if (
$_SESSION["c3"]!="rond" && $_SESSION["c3"]!="croix" && $_SESSION["win"]=="false")
        {
        echo(
'<a href="page_morpion_session.php?clic=c3"><img border=0 src="morpion/morpion_vide.jpg" alt="vide"></a>');
        }
    
?>
</p>
<?php
if ($m!=0)
    {
    echo(
'<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>');    
    }
?>
</div>
<?php
if ($m!=1)
    {
    echo(
'<div id="div_titre">
    <h1>Jeux du morpion</h1>
    </div>'
);
    }
?>
<div id="div_resultat">
    <h2>
    <?php 
    
if ($_SESSION["win"]=="true")
        {echo(
$_SESSION["who_win"]." gagné<br>");}
    if (
$_SESSION["win"]=="false" && ($_SESSION["a1"]=="rond" || $_SESSION["a1"]=="croix") && ($_SESSION["b1"]=="rond" || $_SESSION["b1"]=="croix") && ($_SESSION["c1"]=="rond" || $_SESSION["c1"]=="croix") && ($_SESSION["a2"]=="rond" || $_SESSION["a2"]=="croix") && ($_SESSION["b2"]=="rond" || $_SESSION["b2"]=="croix") && ($_SESSION["c2"]=="rond" || $_SESSION["c2"]=="croix") && ($_SESSION["a3"]=="rond" || $_SESSION["a3"]=="croix") && ($_SESSION["b3"]=="rond" || $_SESSION["b3"]=="croix") && ($_SESSION["c3"]=="rond" || $_SESSION["c3"]=="croix"))
        {echo(
"jeux terminé<br>");}
    
?>
    </h2>
</div>

<?php
echo("
<div id=\"case_legende\">
    <a href=\"page_morpion_session.php?clic=destroy\">nouvelle partie</a><br>
    <a href=\"page_morpion.php\">version GET</a><br>
    <a href=\"page_morpion_session.php?debug\">mode debug</a><br>
Code source de ce jeu - <a target=_blank href=\"morpion/show_source_session.php\">morpion</a> - GPL<br>
"
);

if(isset(
$_SESSION["debug"]))
    echo 
'<pre>'.print_r($_SESSIONtrue).'</pre>';
echo(
"</div>");

//init TOUR_JOUEUR = rond
if(!isset($_SESSION['TOUR_JOUEUR']))
    {
    
$_SESSION['TOUR_JOUEUR'] = "rond";
    }
    
//vérif après premier tour            ex. $_SESSION[a3]=rond
if(isset($_GET["clic"]))
    if(
$_SESSION[$_SESSION["clic"]] == $_SESSION['TOUR_JOUEUR'])
        {
        
//inversion de TOUR_JOUEUR
        
if($_SESSION['TOUR_JOUEUR'] == "rond")
            
$_SESSION['TOUR_JOUEUR'] = "croix";
        else
            
$_SESSION['TOUR_JOUEUR'] = "rond";
        }

?>



<?php
if ($m==0)
    {
    include(
"aff_icone.php");
    }

?>
<div id="div_bas">
    <p class="copyright">
        <a href="https://validator.w3.org/check?uri=referer">
            <img src="https://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>
        <a href="https://jigsaw.w3.org/css-validator/check/referer">
                <img style="border:0;width:88px;height:31px" src="https://jigsaw.w3.org/css-validator/images/vcss" alt="CSS Valide !"></a>
    </p>

    <?php
    
include("copyright.txt");
    
?>
</div>

<?php
if ($m==1)
        echo(
'</div>');
?>

</body>
</html>