Está en la página 1de 2

<!

doctype html>
<html>
<head>
<meta charset='utf-8'>
</head>
<body>
<h1>Quemado</h1>
<form action="Quemado.php" method="POST">
Instrucciones <br>
Ingrese letra:<input name="letra" type="text" size="1"><
br>
<input type="submit" name="Reini
cio" value="Reiniciar">
<br>
<!--Id:<?php// echo $_GET['id'];?>-->
<input type="submit" >
<br>Reglas:<br>
-Tiene mximo 6 intentos.<br>
-Enve una letra para comenzar.<br>
</form>
<body>
<html>
<?php
session_start();
print "<pre>";
if ($_POST['Reinicio']=='Reiniciar' or ($_SESSION['er']>6)){
$_SESSION=array(); /*session_destroy()*/;
}else {
$letra=$_POST['letra'];//Letra
echo "Letra: ". $letra."\n";
$p = fopen("Palabras.txt", "r");//Para las palabras
$ls=[];
$i=0;
while(!feof($p)){
$ls[$i] = fgets($p);
$i++;}
fclose($p);
if (!isset($_SESSION['ltr'])){
$_SESSION['ltr']=substr($ls[rand(0,count($ls))], 0, -2);//Asigan
acin Letra aleatoria
}
echo $_SESSION['ltr']."\n";
$letraa=$_SESSION['ltr'];
if (!isset($_SESSION['sl'])){
for($i=0;$i<strlen($letraa);$i++){$_SESSION['sl'][$i]="_";//Vari
able para la solucin
}
}
$err=0;
for($i=0;$i<strlen($letraa);$i++){
if($letraa[$i]==$letra){
$_SESSION['sl'][$i]=$letra;
$err=1;
}

}
if($err==0){
if (isset($_SESSION['er'])){$_SESSION['er']++;}
else { $_SESSION['er']=0;}
}
if (isset($_SESSION['er'])){echo "Errores:". $_SESSION['er']; }
//Mostrar imagen
echo "\n";
$dir='Q0/'; //nombre de la carpeta
$images = glob("$dir{*.gif,*.jpg,*.png}", GLOB_BRACE);
echo '<img src="'.$images[$_SESSION['er']].'" border="0" style="width:10
0px;float:left;margin:10px;" />';
echo "\n";
//Contador de intentos
if (isset($_SESSION['v'])){
$_SESSION['v']++;}
else { $_SESSION['v']=0;}
echo "\nIntentos: ". $_SESSION['v']."\n";
if (isset($_SESSION['sl'])){
for($i=0;$i<strlen($letraa);$i++){
echo $_SESSION['sl'][$i];
}
}
echo "\n";
//Verificacin de ganar
if($letraa==implode($_SESSION['sl'])){Echo "\n<h1>Gan</h1>\n";
//$_SESSION['g']=1;
$_SESSION['er']=7;
$puntaje=strlen($letraa)*1;
$pmas=$puntaje+pmas;
//Funcin para los puntajes:
$pt = fopen("puntajes.txt", "r");//Para las palabras
$lsp=[];
$i=0;
while(!feof($pt)){
$lsp[$i] = fgets($pt);
//if (){}
//echo $_SESSION["user"];
$i++;}
fclose($pt);
}
}//Fin else reinicio
?>

También podría gustarte