- Code: Tout sélectionner
<?php
/***************************************************************************
* elbmag.php
* -------------------
* Version : 0.5
* began : January 10, 2005
* email : Unlisted
* forums : http://vcreations.freeserverhost.com
*
***************************************************************************/
/***************************************************************************
*
* copyright (C) 2004 tHe_LiNk
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* http://www.gnu.org/copyleft/gpl.html
*
***************************************************************************/
define('IN_PHPBB', true);
define('IN_CASHMOD', true);
$phpbb_root_path = './';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.' . $phpEx);
//
// Start session management
//
$userdata = session_pagestart($user_ip, PAGE_INDEX);
init_userprefs($userdata);
//
// End session management
//
if ( !$userdata['session_logged_in'] )
{
$redirect = "secretword.$phpEx";
$redirect .= ( isset($user_id) ) ? '&user_id=' . $user_id : '';
header('Location: ' . append_sid("login.$phpEx?redirect=$redirect", true));
}
$page_title = 'Jeu du mot secret';
$pg_title = 'Mot secret';
//
//
// START GAME
$currnt = $board_config['sw_currency'];
$mypoints = $userdata[''.$currnt.''];
if ($board_config['sw_onoff'] == 'on') {
if ($board_config['sw_running'] == 1) {
if ($board_config['sw_timetoend'] == 0) {
if ( isSet($_POST['submit'])) {
$sql = "update " . CONFIG_TABLE . " set config_value='" . addSlashes($_POST['word']) . "' where config_name='sw_word'";
if ( !($db->sql_query($sql)) )
{
message_die(GENERAL_MESSAGE, 'Fatal Error Updating Secret word config<br>'.mysql_error());
}
$sql = "update " . CONFIG_TABLE . " set config_value='" . addSlashes($_POST['hint']) . "' where config_name='sw_hint'";
if ( !($db->sql_query($sql)) )
{
message_die(GENERAL_MESSAGE, 'Fatal Error Updating Secret word config<br>'.mysql_error());
}
$sql = "update " . CONFIG_TABLE . " set config_value='" . $userdata['user_id'] . "' where config_name='sw_poster'";
if ( !($db->sql_query($sql)) )
{
message_die(GENERAL_MESSAGE, 'Fatal Error Updating Secret word config<br>'.mysql_error());
}
$newendtime = time() + (86400 * $board_config['sw_runvar']);
$sql = "update " . CONFIG_TABLE . " set config_value='" . $newendtime . "' where config_name='sw_timetoend'";
if ( !($db->sql_query($sql)) )
{
message_die(GENERAL_MESSAGE, 'Fatal Error Updating Secret word config<br>'.mysql_error());
}
$sql = "update " . CONFIG_TABLE . " set config_value='1' where config_name='sw_running'";
if ( !($db->sql_query($sql)) )
{
message_die(GENERAL_MESSAGE, 'Fatal Error Updating Secret word config<br>'.mysql_error());
}
$main = '<br>Le nouveau jeu a bien été configuré.<br><br>';
} else {
if ($board_config['sw_prevwinner'] != '') { $congrats = 'Le (s) gagnant(s) du jeu précédent sont '.$board_config['sw_prevwinner'].'.<br><br>'; }
$main = '<br>'.$congrats.'Aucun nouveau jeu n\'a été configuré.<br><br>';
$main .= '<form method="POST" action="'.append_sid("secretword.$phpEx").'">
<table border="2" class="gen" align="center">
<tr><th align="center" colspan="2">Configurer un nouveau jeu</th></tr>
<tr><td align="center">Mot à trouver</td><td align="center"><input type="text" name="word" size="20"></td></tr>
<tr><td align="center">Indice(s) (limité à 255 caractères)</td><td align="center"><input type="text" name="hint" size="20"></td></tr>
<tr><td align="center" colspan="2"><input type="submit" name="submit" value="Envoyer"></td></tr>
</table>
</form>';
}
} else if ($board_config['sw_poster'] == $userdata['user_id']) {
$main = '<br>C\'est vous qui avez configuré ce jeu. Vous n\'êtes donc pas autorisé à y jouer.<br><br>';
} else {
if ($board_config['sw_timetoend'] < time()) {
$sql = "update " . CONFIG_TABLE . " set config_value='0' where config_name='sw_running'";
if ( !($db->sql_query($sql)) ) { message_die(GENERAL_MESSAGE, 'Fatal Error Updating Secret word config<br>'.mysql_error()); }
//
// Change user ids to usernames in prevwinner list
//
$sql = "update " . USERS_TABLE . " set user_playedsw='no' where user_id='{$blauname}'";
if ( !($usresult = $db->sql_query($sql)) ) { message_die(GENERAL_MESSAGE, 'Fatal Error Getting Points Information!'); }
$sql = "update " . CONFIG_TABLE . " set config_value='' where config_name='sw_word'";
if ( !($db->sql_query($sql)) ) { message_die(GENERAL_MESSAGE, 'Fatal Error Updating Secret word config<br>'.mysql_error()); }
$sql = "update " . CONFIG_TABLE . " set config_value='0' where config_name='sw_timetoend'";
if ( !($db->sql_query($sql)) ) { message_die(GENERAL_MESSAGE, 'Fatal Error Updating Secret word config<br>'.mysql_error()); }
//
// Start loops
//
$pieces = explode("|, ", $board_config['sw_currentwinner']);
$x = 0;
do {
$blauname = $pieces[$x];
// Retrieve username from ID
//
$sql = "SELECT * FROM " . USERS_TABLE . " WHERE user_id = '$blauname'";
if ( !($result = $db->sql_query($sql)) ) { message_die(GENERAL_MESSAGE, 'Fatal Error Getting Username information 2'); }
$usrnm = $db->sql_fetchrow($result);
$prevwinners = ''.$usrnm['username'].', '.$prevwinners.'';
$personspoints = $usrnm[''.$currnt.''];
//
// Do rest
$togive = $personspoints + $board_config['sw_reward'];
$sql = "update " . USERS_TABLE . " set $currnt='{$togive}' where user_id='{$blauname}'";
if ( !($usresult = $db->sql_query($sql)) ) { message_die(GENERAL_MESSAGE, 'Fatal Error Getting Points Information!'); }
$sql = "update " . USERS_TABLE . " set user_playedsw='no' where user_id='{$blauname}'";
if ( !($usresult = $db->sql_query($sql)) ) { message_die(GENERAL_MESSAGE, 'Fatal Error Getting Points Information!'); }
$x++;
} while ($x < $board_config['sw_numofwinners']);
$sql = "update " . CONFIG_TABLE . " set config_value='{$prevwinners}' where config_name='sw_prevwinner'";
if ( !($db->sql_query($sql)) ) { message_die(GENERAL_MESSAGE, 'Fatal Error Updating Secret word config<br>'.mysql_error()); }
$sql = "update " . CONFIG_TABLE . " set config_value='0' where config_name='sw_numofwinners'";
if ( !($db->sql_query($sql)) ) { message_die(GENERAL_MESSAGE, 'Fatal Error Updating Secret word config<br>'.mysql_error()); }
$sql = "update " . CONFIG_TABLE . " set config_value='' where config_name='sw_currentwinner'";
if ( !($db->sql_query($sql)) ) { message_die(GENERAL_MESSAGE, 'Fatal Error Updating Secret word config<br>'.mysql_error()); }
$pieces = explode("|, ", $board_config['sw_currentplayers']);
$x = 0;
do {
$blauname = $pieces[$x];
$sql = "update " . USERS_TABLE . " set user_playedsw='no' where user_id='{$blauname}'";
if ( !($usresult = $db->sql_query($sql)) ) { message_die(GENERAL_MESSAGE, 'Fatal Error Getting Points Information!'); }
$x++;
} while ($x < $board_config['sw_numofplayers']);
//
// End loops
//
$sql = "update " . CONFIG_TABLE . " set config_value='0' where config_name='sw_numofplayers'";
if ( !($db->sql_query($sql)) ) { message_die(GENERAL_MESSAGE, 'Fatal Error Updating Secret word config<br>'.mysql_error()); }
$sql = "update " . CONFIG_TABLE . " set config_value='' where config_name='sw_currentplayers'";
if ( !($db->sql_query($sql)) ) { message_die(GENERAL_MESSAGE, 'Fatal Error Updating Secret word config<br>'.mysql_error()); }
$sql = "update " . CONFIG_TABLE . " set config_value='' where config_name='sw_hint'";
if ( !($db->sql_query($sql)) ) { message_die(GENERAL_MESSAGE, 'Fatal Error Updating Secret word config<br>'.mysql_error()); }
$main = '<br>Le dernier jeu du mot secret vient de finir, pour voir les résultats, actualisez la page<br><a href="'.append_sid("secretword.$phpEx").'">Actualiser</a><br><br>';
} else {
if ($board_config['sw_word'] != '') {
if ($userdata['user_playedsw'] == 'no') {
$pg_title = 'Jeu du mot secret';
if ( $_POST['sub'] == 'Envoyer' ) {
$myguess = strToLower(addSlashes($_POST['guess']));
if ( $mypoints < $board_config['sw_price'] ) {
$main = '<br>Vous n\'avez pas eu assez de jenis pour participer<br><br>';
} else if ($board_config['sw_poster'] == $userdata['user_id']) {
$main = '<br>C\'est vous qui avez configuré ce jeu. Vous n\'êtes donc pas autorisé à y jouer.<br><br>';
} else {
if ($board_config['sw_price'] != '0') {
$totake = $mypoints - $board_config['sw_price'];
$sql = "update " . USERS_TABLE . " set $currnt='{$totake}' where user_id='{$userdata['user_id']}'";
if ( !($usresult = $db->sql_query($sql)) ) { message_die(GENERAL_MESSAGE, 'Fatal Error Getting Points Information!'); }
}
$main = '<br>Merci de jouer au mot secret, vous saurez si vous avez gagné à la fin du jeu.<br><br>';
$sql = "update " . USERS_TABLE . " set user_playedsw='yes' where user_id='{$userdata['user_id']}'";
if ( !($usresult = $db->sql_query($sql)) ) { message_die(GENERAL_MESSAGE, 'Fatal Error Getting Points Information!'); }
if ($myguess == strToLower($board_config['sw_word'])) {
$currentwinners = ''.$board_config['sw_currentwinner'].'|, '.$userdata['user_id'].'|, ';
if ($board_config['sw_currentwinner'] == '') { $currentwinners = ''.$userdata['user_id'].'|, '; }
$sql = "update " . CONFIG_TABLE . " set config_value='$currentwinners' where config_name='sw_currentwinner'";
if ( !($db->sql_query($sql)) ) { message_die(GENERAL_MESSAGE, 'Fatal Error Updating Secret word config<br>'.mysql_error()); }
$numtoadd = $board_config['sw_numofwinners'] + 1;
$sql = "update " . CONFIG_TABLE . " set config_value='$numtoadd' where config_name='sw_numofwinners'";
if ( !($db->sql_query($sql)) ) { message_die(GENERAL_MESSAGE, 'Fatal Error Updating Secret word config<br>'.mysql_error()); }
} else {
$currentplayers = ''.$board_config['sw_currentplayers'].'|, '.$userdata['user_id'].'|, ';
if ($board_config['sw_currentplayers'] == '') { $currentplayers = ''.$userdata['user_id'].'|, '; }
$sql = "update " . CONFIG_TABLE . " set config_value='$currentplayers' where config_name='sw_currentplayers'";
if ( !($db->sql_query($sql)) ) { message_die(GENERAL_MESSAGE, 'Fatal Error Updating Secret word config<br>'.mysql_error()); }
$numtoadd = $board_config['sw_numofplayers'] + 1;
$sql = "update " . CONFIG_TABLE . " set config_value='$numtoadd' where config_name='sw_numofplayers'";
if ( !($db->sql_query($sql)) ) { message_die(GENERAL_MESSAGE, 'Fatal Error Updating Secret word config<br>'.mysql_error()); }
}
}
} else {
if ($board_config['sw_hint'] == '') {
$hint = 'Il n\'y a pas d\'indices donnés pour ce jeu';
} else {
$hint = 'Indice: '. stripSlashes($board_config['sw_hint']).'.';
}
$main = '<br>'.$hint.'<br><form method="POST">
<p align="center"><input type="text" name="guess" size="34"><br>
<br>
<input type="submit" value="Envoyer" name="sub"></p>
</form>';
}
} else {
$main = '<br>Vous pouvez seulement avoir une proposition par jeu, veuillez attendre que le jeu recommence pour rejouer.<br><br>';
}
} else {
if ( isSet($_POST['submit'])) {
$sql = "update " . CONFIG_TABLE . " set config_value='" . addSlashes($_POST['word']) . "' where config_name='sw_word'";
if ( !($db->sql_query($sql)) )
{
message_die(GENERAL_MESSAGE, 'Fatal Error Updating Secret word config<br>'.mysql_error());
}
$sql = "update " . CONFIG_TABLE . " set config_value='" . addSlashes($_POST['hint']) . "' where config_name='sw_hint'";
if ( !($db->sql_query($sql)) )
{
message_die(GENERAL_MESSAGE, 'Fatal Error Updating Secret word config<br>'.mysql_error());
}
$sql = "update " . CONFIG_TABLE . " set config_value='" . $userdata['user_id'] . "' where config_name='sw_poster'";
if ( !($db->sql_query($sql)) )
{
message_die(GENERAL_MESSAGE, 'Fatal Error Updating Secret word config<br>'.mysql_error());
}
$newendtime = time() + (86400 * $board_config['sw_runvar']);
$sql = "update " . CONFIG_TABLE . " set config_value='" . $newendtime . "' where config_name='sw_timetoend'";
if ( !($db->sql_query($sql)) )
{
message_die(GENERAL_MESSAGE, 'Fatal Error Updating Secret word config<br>'.mysql_error());
}
$sql = "update " . CONFIG_TABLE . " set config_value='1' where config_name='sw_running'";
if ( !($db->sql_query($sql)) )
{
message_die(GENERAL_MESSAGE, 'Fatal Error Updating Secret word config<br>'.mysql_error());
}
$main = '<br>Le nouveau jeu a bien été configuré.<br><br>';
} else {
$main = '<br>'.$congrats.'Aucun nouveau jeu n\'a été configuré.<br><br>';
$main .= '<form method="POST" action="'.append_sid("secretword.$phpEx").'">
<table border="2" class="gen" align="center">
<tr><th align="center" colspan="2">Configurer un nouveau jeu</th></tr>
<tr><td align="center">Mot à trouver</td><td align="center"><input type="text" name="word" size="20"></td></tr>
<tr><td align="center">Indice(s) (limité à 255 caractères)</td><td align="center"><input type="text" name="hint" size="20"></td></tr>
<tr><td align="center" colspan="2"><input type="submit" name="submit" value="Envoyer"></td></tr>
</table>
</form>';
}
}
}
}
} else {
if ( isSet($_POST['submit'])) {
$sql = "update " . CONFIG_TABLE . " set config_value='" . addSlashes($_POST['word']) . "' where config_name='sw_word'";
if ( !($db->sql_query($sql)) )
{
message_die(GENERAL_MESSAGE, 'Fatal Error Updating Secret word config<br>'.mysql_error());
}
$sql = "update " . CONFIG_TABLE . " set config_value='" . addSlashes($_POST['hint']) . "' where config_name='sw_hint'";
if ( !($db->sql_query($sql)) )
{
message_die(GENERAL_MESSAGE, 'Fatal Error Updating Secret word config<br>'.mysql_error());
}
$sql = "update " . CONFIG_TABLE . " set config_value='" . $userdata['user_id'] . "' where config_name='sw_poster'";
if ( !($db->sql_query($sql)) )
{
message_die(GENERAL_MESSAGE, 'Fatal Error Updating Secret word config<br>'.mysql_error());
}
$newendtime = time() + (86400 * $board_config['sw_runvar']);
$sql = "update " . CONFIG_TABLE . " set config_value='" . $newendtime . "' where config_name='sw_timetoend'";
if ( !($db->sql_query($sql)) )
{
message_die(GENERAL_MESSAGE, 'Fatal Error Updating Secret word config<br>'.mysql_error());
}
$sql = "update " . CONFIG_TABLE . " set config_value='1' where config_name='sw_running'";
if ( !($db->sql_query($sql)) )
{
message_die(GENERAL_MESSAGE, 'Fatal Error Updating Secret word config<br>'.mysql_error());
}
$main = '<br>Le nouveau jeu a bien été configuré.<br><br>';
} else {
if ($board_config['sw_prevwinner'] != '') { $congrats = 'Le (s) gagnant(s) du jeu précédent sont '.$board_config['sw_prevwinner'].'.<br><br>'; }
$main = '<br>'.$congrats.'Aucun nouveau jeu n\'a été configuré.<br><br>';
$main .= '<form method="POST" action="'.append_sid("secretword.$phpEx").'">
<table border="2" class="gen" align="center">
<tr><th align="center" colspan="2">Configurer un nouveau jeu</th></tr>
<tr><td align="center">Mot à trouver</td><td align="center"><input type="text" name="word" size="20"></td></tr>
<tr><td align="center">Indice(s) (limité à 255 caractères)</td><td align="center"><input type="text" name="hint" size="20"></td></tr>
<tr><td align="center" colspan="2"><input type="submit" name="submit" value="Envoyer"></td></tr>
</table>
</form>';
}
}
} elseif ($board_config['sw_onoff'] == 'off') {
$pg_title = 'Le mot secret est désactivé';
$main = '<br>Ce jeu a été désactivé par l\'administrateur du site.<br><br>';
}
// END GAME
//
//
// Includes
include($phpbb_root_path . 'includes/page_header.' . $phpEx);
$template->assign_vars(array(
'MAIN' => $main,
'MISC' => $stats,
'TITLE' => $pg_title,
));
$template->assign_block_vars('', array());
$template->set_filenames(array(
'body' => 'secretword_body.tpl')
);
// Generate page
$template->pparse('body');
include($phpbb_root_path . 'includes/page_tail.' . $phpEx);
?>
Le probleme, c'est que (je ne sais pas vraiment pourquoi) le code exécuté est la partie (à la fin)
- Code: Tout sélectionner
} else {
if ($board_config['sw_prevwinner'] != '') { $congrats = 'Le (s) gagnant(s) du jeu précédent sont '.$board_config['sw_prevwinner'].'.<br><br>'; }
$main = '<br>'.$congrats.'Aucun nouveau jeu n\'a été configuré.<br><br>';
$main .= '<form method="POST" action="'.append_sid("secretword.$phpEx").'">
<table border="2" class="gen" align="center">
<tr><th align="center" colspan="2">Configurer un nouveau jeu</th></tr>
<tr><td align="center">Mot à trouver</td><td align="center"><input type="text" name="word" size="20"></td></tr>
<tr><td align="center">Indice(s) (limité à 255 caractères)</td><td align="center"><input type="text" name="hint" size="20"></td></tr>
<tr><td align="center" colspan="2"><input type="submit" name="submit" value="Envoyer"></td></tr>
</table>
</form>';
}
Quelqu'un peut m'aider?







