Smiles-War
30
14
index.php
voici un exemple possible pour votre index.php
on se connecte:
on se connecte:
<?php <>
include("configg9.php");
dbconnect();
$bouton = array ();
initialisation des variables
//initialisation des variables:
if ($nums== '' ){
srand((double)microtime()*1000000);
$r1 = rand(1,1000000);
$r2 = rand(1,1000000);
$nums=$r1*$r2;$su="";
}else{
$result = mysql_query ("SELECT ki FROM smi_ses where nums= $nums ");
$row = mysql_fetch_array($result);
$su= $row[0];
}
gestion des jetons
//heure serveur
$result = mysql_query ("select date from smi");
$row = mysql_fetch_array($result);
$h3 = $row[0];
$h=date("H"); $i=date("i"); $s=date("s"); $h1=date("His", mktime($h,$i,$s));$h4=$h3-$h1;
if (($h4 > 20000)or($h4 < -10000)) {mysql_query ("update smi set date = $h1 ");$test="+1jeton";
mysql_query ("update smi_perso set jeton = jeton+1 where jeton<10");
}
$prochain=6000+$h4;
debut de création de la page html
$msg.="<html><head><title>smiles prochain jeton dans $prochain secondes $test</title></head><body ><form name=smilewar action=index.php target=_top method=post><table height=100% width=100% border=1><tr><td height=30>SMILE WAR<img src=img/logo.gif></center></td><td>";
menu créé en fonction de l'identification
//menu
if ($su== ){
$msg.="<img src=img/puce.gif> <a href=?p=1&nums=$nums>inscription</a><br><img src=img/puce.gif> <a href=?p=2&nums=$nums>jouer</a><br>";
}
else{
$msg.="<img src=img/puce.gif> <a href=?p=4&nums=$nums>jouer</a><br><img src=img/puce.gif> <a href=?p=3&nums=$nums>deconnecter</a><br>";
}
$msg.="</td>";
// actions
switch($act)
{
case"inscrire";
include("cache/inscrire.php");
break;
case"identifier";
$msg.="<td>";$p=2;
$result= mysql_query("SELECT count(*) FROM smi_perso where nom= $nomsmile and pass= $pass1 ");
$row = mysql_fetch_array($result);
$passok = $row[0];
if ($passok==1)
{mysql_query("INSERT INTO smi_ses (date, nums,ki, pass)VALUES ( $now , $nums , $nomsmile , $pass1 )");
$msg.="<hr>identifié <a href=index.php?p=4&nums=$nums>acceder au jeu</a>";}else{$msg.="<hr>Erreur de mot de passe";}
break;
}
// pages
switch($p)
{
case"";
case"0";
$msg.="<td>Vous voila incarnant un smiley.<br>Votre mission si vous l acceptez est de défendre votre campement de smile contre les autres.<br>Vous aurez à choisir votre camp.<br>";
$result= mysql_query("SELECT count(*) FROM smi_perso where type=1");
$row = mysql_fetch_array($result);
$ERE = $row[0];
$result= mysql_query("SELECT count(*) FROM smi_perso where type=2");
$row = mysql_fetch_array($result);
$tri = $row[0];
$msg.="il ya $ERE smiles heureux et $tri smiles tristes</td>";
break;
case"3";
mysql_query("DELETE FROM smi_ses where nums=$nums");
$msg.="<td>déconnection effectuée</td>";
break;
case"1";
// inscription
include("cache/page1.php");
break;
case"2";
$msg.="<td>identification";
$msg.="<table><tr><td>Nom du Smile:</td><td><input type=text value= votre smile name=nomsmile title= le nom de votre smile ></td></tr>";
$msg.="<tr><td>Mot de passe:</td><td><input type=password value= name=pass1></td></tr>";
$msg.="</td></tr></table>";array_push ($bouton, "identifier");
break;
case"4";
// partie jouer
include("cache/page4.php");
break;
case"5";
// tableau de chasse
include("cache/page5.php");
break;
}
dbdeconnect();
// boutons
$msg.="<tr><td colspan=2 height=30>";
$msg.="<input type=\"hidden\" value=\"".$nums."\" name=\"nums\">";
$imax=count($bouton);
$msg.="$imax action(s) possible ";
for ($i = 0; $i < $imax; $i++)
$msg.="<input type=\"submit\" value=\"".$bouton[$i]."\" name=\"act\">";
$msg.="</form>";
echo"$msg";
?></td></tr></table>
<center><a href=http://www.jouer.org>Jeu open source</a></center>
</body></html>
2005-04-14 03:01:57