Bouton "Rappel" ne fonctionne plus.

Résolu/Fermé
Max747 Messages postés 258 Date d'inscription vendredi 11 juillet 2014 Statut Membre Dernière intervention 11 janvier 2024 - 22 oct. 2018 à 10:28
Max747 Messages postés 258 Date d'inscription vendredi 11 juillet 2014 Statut Membre Dernière intervention 11 janvier 2024 - 24 oct. 2018 à 09:52
Bonjour,

Dans mon jeu d'échecs par e-mail il existe un bouton de rappel qui est utilisé pour rappeler à l'adversaire de jouer.
Cependant celui ci pour une raison qui m'est inconnu ne fonctionne plus.
Voici en image où il se trouve:

Le message apparaissant lorsque l'on clique dessus:

Le fichier commands.js en ligne 174
// these functions interact with the server

function disableButtons( )
{
	if ( ! watchgame)
	{
	    getObject("btnUndo").disabled = true;
		getObject("btnDraw").disabled = true;
		getObject("btnResign").disabled = true;
		 //document.querySelector('btnUndo').disabled = true;
		 //document.querySelector('btnDraw').disabled = true;
		 //document.querySelector('btnResign').disabled = true;
	}
}

function undo( )
{
	disableButtons( );
	document.gamedata.requestUndo.value = "yes";

	my_alert("gamedata.requestUndo = " + document.gamedata.requestUndo.value);

	document.gamedata.submit( );
}

function draw( )
{
	disableButtons( );
	document.gamedata.requestDraw.value = "yes";

	my_alert("gamedata.requestDraw = " + document.gamedata.requestDraw.value);

	document.gamedata.submit( );
}

function resigngame( )
{
	disableButtons( );
	document.gamedata.resign.value = "yes";

	my_alert("gamedata.resign = " + document.gamedata.resign.value);

	document.gamedata.submit( );
}

function displayMainmenu( )
{
	this.disabled = true;
	disableButtons( );
	window.open('index.php', '_self');
}

function reloadPage(btnReload)
{
	btnReload.disabled = true;
	disableButtons( );
	window.open('chess.php', '_self');
}

function downloadPGN( )
{
	window.open('./includes/openpgn.inc.php', '_self')
}

function replay( )
{
	if (document.gamemenu.btnReplay.value == "Revoir partie")
	{
		document.gamemenu.btnReplay.value = "Continue";

		// pause the refresh timer
		clearTimeout(intervalId);

		// disable the board
		isBoardDisabled = true;

		// run the replay scripts
		var replayBoard = htmlBoard( );
		getObject('chessboard').innerHTML = replayBoard;

		// reset the moves with movable ones
		displayMoves(true);

		// get the FEN array
		currMoveIdx = FEN.length - 1;

		// display the captured pieces
		FENToCapt(numMoves);
		displayCaptPieces( );

		// make the replay buttons and hide game buttons
		getObject('gamebuttons').style.display = 'none';
		var navButtons = '<form id="navigation" action="">';
		navButtons += '<span id="navbuttons">';
		navButtons += '<input id="start" title="Début" type="button" value="Début" />';
		navButtons += '<input id="jmpback" title="5 demi-coups avant" type="button" value=" << " />';
		navButtons += '<input id="prev" title="1 demi-coup avant" type="button" value=" < " />';
		navButtons += '<input id="next" title="1 demi-coup après" type="button" value=" > " />';
		navButtons += '<input id="jmpfwd" title="5 demi-coups après" type="button" value=" >> " />';
		navButtons += '<input id="end" title="Fin" type="button" value="Fin" /><br>';
		navButtons += '<input style="width:100px" id="invert" title="Inverser" type="button" value="< Tourner" />';
		navButtons += '<input style="width:100px" id="invert2" title="Inverser" type="button" value="Tourner >" disabled />';
		navButtons += '</span>';
		navButtons += '</form>';
		getObject('gamenav').innerHTML = navButtons;

		function invert1(){ /*toggleInvert( )*/

			document.getElementById("invert").disabled = true;
			document.getElementById("invert2").disabled = false;
			document.getElementById("theBoard").style.transform = "rotate(180deg)";
			document.getElementById("theBoard").style.transition = ".3s";
			for (var i=0; i < 64; i++) { 
				var element =  document.getElementById("sq"+i);
				if (typeof(element) != 'undefined' && element != null)
					{
						document.getElementById("sq"+i).style.transform = "rotate(180deg)";
					}
				
			}
		};
		function invert2(){ /*toggleInvert( )*/

			document.getElementById("invert2").disabled = true;
			document.getElementById("invert").disabled = false;
			document.getElementById("theBoard").style.transform = "rotate(0deg)";
			document.getElementById("theBoard").style.transition = ".3s";
			for (var i=0; i < 64; i++) { 
				var element =  document.getElementById("sq"+i);
				if (typeof(element) != 'undefined' && element != null)
					{
						document.getElementById("sq"+i).style.transform = "rotate(0deg)";
						//document.getElementById("theBoard").style.transition = ".3s";
					}
			}
			//document.getElementById("invert").style.display = "block";
			//document.getElementById("invert2").style.display = "none";


		};


		// set the replay button actions - définir les actions du bouton de relecture
		
		getObject("start").onclick = function( ){if(document.getElementById("invert").disabled == true){invert2();moveJmp(-10000);invert1();}else{moveJmp(-10000)} ;};
		getObject("jmpback").onclick = function( ){if(document.getElementById("invert").disabled == true){invert2();moveJmp(-5);invert1();}else{moveJmp(-5)};};
		getObject("prev").onclick = function( ){if(document.getElementById("invert").disabled == true){invert2();moveJmp(-1);invert1();}else{moveJmp(-1)};};
		getObject("next").onclick = function( ){if(document.getElementById("invert").disabled == true){invert2();moveJmp(1);invert1();}else{moveJmp(1)};};
		getObject("jmpfwd").onclick = function( ){if(document.getElementById("invert").disabled == true){invert2();moveJmp(5);invert1();}else{moveJmp(5)};};
		getObject("end").onclick = function( ){if(document.getElementById("invert").disabled == true){invert2();moveJmp(10000);invert1();}else{moveJmp(10000)};};
		getObject("invert").onclick = function( ){invert1()};
		getObject("invert2").onclick = function( ){invert2()};

		//document.querySelector('start').onclick = function( ){if(document.getElementById("invert").disabled == true){invert2();moveJmp(-10000);invert1();}else{moveJmp(-10000)} ;};
		//document.querySelector('jmpback').onclick = function( ){if(document.getElementById("invert").disabled == true){invert2();moveJmp(-5);invert1();}else{moveJmp(-5)};};
		//document.querySelector('prev').onclick = function( ){if(document.getElementById("invert").disabled == true){invert2();moveJmp(-1);invert1();}else{moveJmp(-1)};};
		//document.querySelector('next').onclick = function( ){if(document.getElementById("invert").disabled == true){invert2();moveJmp(1);invert1();}else{moveJmp(1)};};
		//document.querySelector('jmpfwd').onclick = function( ){if(document.getElementById("invert").disabled == true){invert2();moveJmp(5);invert1();}else{moveJmp(5)};};
		//document.querySelector('end').onclick = function( ){if(document.getElementById("invert").disabled == true){invert2();moveJmp(10000);invert1();}else{moveJmp(10000)};};
		//document.querySelector('invert').onclick = function( ){invert1()};
		//document.querySelector('invert2').onclick = function( ){invert2()};




	}
	else if (document.gamemenu.btnReplay.value == "Continue")
	{
		// just refresh the page, everything resets itself
		window.location.replace('chess.php');
	}
}

function wakeUp( )
{
	if (confirm('Confirmez le mail de rappel.'))
	{
		document.wakeup.submit( );
	}
}

function promotepawn( )
{
	var blackPawnFound = false;
	var whitePawnFound = false;
	var i = -1;

	// search for the promoting pawn
	while ( ! blackPawnFound &&  ! whitePawnFound && i < 8)
	{
		i++;

		/* check for black pawn being promoted */
		if (board[0][i] == (BLACK | PAWN))
			blackPawnFound = true;

		/* check for white pawn being promoted */
		if (board[7][i] == (WHITE | PAWN))
			whitePawnFound = true;
	}

	/* to which piece is the pawn being promoted to? */
	var promotedTo = 0;
	for (var j = 0; j <= 3; j++)
	{
		if (document.gamedata.promotion[j].checked)
			promotedTo = parseInt(document.gamedata.promotion[j].value);
	}

	/* change pawn to promoted piece */
	var enemyColor = "black";
	if (blackPawnFound)
	{
		enemyColor = "white";
		board[0][i] = (BLACK | promotedTo);

		my_alert("Promotion pour: (noirs) " + board[0][i]);

	}
	else if (whitePawnFound)
	{
		board[7][i] = (WHITE | promotedTo);

		my_alert("Promotion pour: (blancs) " + board[7][i]);
	}
	else
	{
		alert("ATTENTION ! : Le site ne trouve pas le pion à promouvoir");
	}

	/* update board and database */
	document.gamedata.submit( );
}


Le message d'alerte indiquant que le rappel à échoué:


Le fichier chess.php se rapportant à ce message de rappel échoué en ligne 327:
<?php
// set the session cookie parameters so the cookie is only valid for this game
$parts = pathinfo($_SERVER['REQUEST_URI']);
$path = $parts['dirname'];
if (empty($parts['extension'])) {
	$path .= '/'.$parts['jeuxechecs_fr'];
}
$path = str_replace('\\', '/', $path).'/';
session_set_cookie_params(time()+365*24*3600, $path);
session_start( );
//print_r($_COOKIE); 
// load 'always needed' settings
require_once './includes/config.inc.php';
require_once './includes/html.inc.php';

// include outside functions
require_once './includes/chessconstants.inc.php';
require_once './includes/chessutils.inc.php';
require_once './includes/gui.inc.php';
require_once './includes/chessdb.inc.php';
//******************************************************************************
//  load basic information
//******************************************************************************
// check if loading game
if (isset($_POST['game_id']))
{
	$_SESSION['game_id'] = (int) $_POST['game_id'];
}

// make sure we have game id data
if (empty($_SESSION['game_id'])) {
	header('Location: index.php');
	exit;
}

if (isset($_SESSION['game_id']) || ! isset($_SESSION['white']))
{
	// get White's data
	$query = "
		SELECT p_id
			, p_username
			, p_email
		FROM ".T_PLAYER."
			, ".T_GAME."
		WHERE ".T_PLAYER.".p_id = ".T_GAME.".g_white_player_id
			AND ".T_GAME.".g_id = '{$_SESSION['game_id']}'
	";
	$_SESSION['white'] = $mysql->fetch_assoc($query, __LINE__, __FILE__);

	// get Black's data
	$query = "
		SELECT p_id
			, p_username
			, p_email
		FROM ".T_PLAYER."
			, ".T_GAME."
		WHERE ".T_PLAYER.".p_id = ".T_GAME.".g_black_player_id
			AND ".T_GAME.".g_id = '{$_SESSION['game_id']}'
	";
	$_SESSION['black'] = $mysql->fetch_assoc($query, __LINE__, __FILE__);

	// get players' color
	if ($_SESSION['white']['p_username'] == $_SESSION['username'])
	{
		$_SESSION['player'] = &$_SESSION['white'];
		$_SESSION['player']['p_color'] = 'white';
		$_SESSION['opponent'] = &$_SESSION['black'];
		$_SESSION['opponent']['p_color'] = 'black';
	}
	else
	{
		$_SESSION['player'] = &$_SESSION['black'];
		$_SESSION['player']['p_color'] = 'black';
		$_SESSION['opponent'] = &$_SESSION['white'];
		$_SESSION['opponent']['p_color'] = 'white';
	}

	// get id960 and position
	$query = "
		SELECT g_id960
		FROM ".T_GAME."
		WHERE g_id = '{$_SESSION['game_id']}'
	";
	$_SESSION['id960'] = $mysql->fetch_value($query, __LINE__, __FILE__);
}
$initpos = id960_to_pos($_SESSION['id960']);

$promoting = false; // init the promotion flag
$undoing   = false; // init the undo flag

// get FEN array (this should probably be in an include somewhere)
$i = 0;
$query = "
	SELECT h_fen
	FROM ".T_HISTORY."
	WHERE h_game_id = '{$_SESSION['game_id']}'
	ORDER BY h_time
";
$FENarray = $mysql->fetch_value_array($query, __LINE__, __FILE__);

$num_moves = count($FENarray) - 1; // remove one for initpos

loadGame( ); // sets up board using last entry in ".T_HISTORY." table (chessdb.inc.php)
FENtomoves( ); // creates movesArray from FENarray (chessutils.inc.php)

// find out if it's the current player's turn
$FENitems = explode(' ',$FENarray[$num_moves]);
$curTurn  = $colorArray[$FENitems[1]]; // convert w -> white, b -> black

$isPlayersTurn = ($curTurn == $_SESSION['player']['p_color']) ? true : false;

//*/


//******************************************************************************
//  save incoming information
//******************************************************************************

checkDatabase( ); // check the database data against the current FEN to make sure the game is ended properly (chessdb.inc.php)

processMessages( ); // processes the messages (undo, resign, etc) (chessdb.inc.php)

// are we undoing ?
if ($undoing && 0 < $num_moves)
{
	call("UNDO REQUEST");
	// just remove the last FEN entered into the history table
	$query = "
		SELECT MAX(h_time)
		FROM ".T_HISTORY."
		WHERE h_game_id = '{$_SESSION['game_id']}'
	";
	$max_time = $mysql->fetch_value($query, __LINE__, __FILE__);

	$query = "
		DELETE FROM ".T_HISTORY."
		WHERE h_game_id = '{$_SESSION['game_id']}'
			AND h_time = '{$max_time}'
		LIMIT 1
	";
	$mysql->query($query, __LINE__, __FILE__);

	if (!DEBUG) header("Location: ./chess.php");
}
// or saving the promotion
elseif ( isset($_POST['promotion']) && '' != $_POST['promotion'] && false != $_POST['promoting'] )
{
	call("SAVING PROMOTION");
	savePromotion( ); // inserts promoted piece and saves to database (chessdb.inc.php)

	if (!DEBUG) header("Location: ./chess.php");
}
// or making a move
elseif ( ( isset($_POST['fromRow']) && '' != $_POST['fromRow'] && '' != $_POST['fromCol'] && '' != $_POST['toRow'] && '' != $_POST['toCol'] ) || ( isset($_POST['castleMove']) && 'false' != $_POST['castleMove'] ) )
{
	call("MAKING A MOVE");
	call($_POST);
	call($_POST['fromRow']);

	/* ensure it's the current player moving                                 */
	/* NOTE: if not, this will currently ignore the command...               */
	/*       perhaps the status should be instead?                           */
	/*       (Could be confusing to player if they double-click or something */
	$is_valid = true;
	if ('white' == $curTurn) // white's move
	{
		call("WHITE");
		call($board[$_POST['fromRow']][$_POST['fromCol']]);

		// ensure that piece being moved isn't black (and is a piece)
		if (('black' == $pieceColor[$board[$_POST['fromRow']][$_POST['fromCol']]]) || ('0' == $board[$_POST['fromRow']][$_POST['fromCol']]))
			$is_valid = false; // if test passes, piece was black
	}
	else // black' move
	{
		call("BLACK");
		call($pieceColor[$board[$_POST['fromRow']][$_POST['fromCol']]]);

		// ensure that piece being moved isn't white (and is a piece)
		if (("white" == $pieceColor[$board[$_POST['fromRow']][$_POST['fromCol']]]) || ('0' == $board[$_POST['fromRow']][$_POST['fromCol']]))
			$is_valid = false; // if test passes, piece was white
	}

	if ($is_valid)
	{
		call("IS VALID");
		saveGame( ); // (chessdb.inc.php)

		// reload a fresh page to avoid errors
		// and to display the new database data
		if (!DEBUG) header("Location: ./chess.php");
	}
}
// or we need to select the promoting piece
elseif ('P' == strtoupper($movesArray[$num_moves]['piece']) && ( ! isset($movesArray[$num_moves]['promo']) || null == $movesArray[$num_moves]['promo']))
{
	if($movesArray[$num_moves]['toRow'] == 7 || $movesArray[$num_moves]['toRow'] == 0)
	{
		$promoting = true;
	}
}
//*/


//******************************************************************************
//  submit chat message
//******************************************************************************
if (isset($_POST['txtChatbox']) && ('' != $_POST['txtChatbox']))
{
	$_POST = sani($_POST);

	$private = (isset($_POST['private']) && 'on' == $_POST['private']) ? 'Yes' : 'No';

	// select the last post entered and make sure it is not a IE error duplicate message
	// (same message within 1 second)
	$query = "
		SELECT COUNT(*)
		FROM ".T_CHAT."
		WHERE c_message = '{$_POST['txtChatbox']}'
			AND c_time BETWEEN
				DATE_SUB(NOW( ), INTERVAL 1 SECOND)
				AND DATE_ADD(NOW( ), INTERVAL 1 SECOND)
	";
	$count = $mysql->fetch_value($query, __LINE__, __FILE__);
	
	date_default_timezone_set('Europe/Paris');
    $test = new DateTime();
    $d= date_format($test, 'Y-m-d H:i:s');
	if (0 == $count)
	{
	    //$dat= date('d-m-Y-G-i',strtotime("+1 hours"));
	    
		$query = "
			INSERT INTO ".T_CHAT."
				(c_game_id, c_player_id, c_time, c_message, c_private)
			VALUES
				('{$_SESSION['game_id']}', '{$_SESSION['player_id']}', '{$d}', '{$_POST['txtChatbox']}', '{$private}')
		";
		$mysql->query($query, __LINE__, __FILE__);
	}

	// refresh the page to avoid double posts
	if (!DEBUG) header('Location: chess.php');
}
//*/


//******************************************************************************
//  send wake up email
//******************************************************************************
$wake_up_sent = false;
/*echo $_POST['wakeID'];
echo "<br/>";
echo $_SESSION['game_id'];
echo "<br/>";
echo $_POST['wakeID'];
echo "<br/>";
exit();*/
if ( isset($_POST['wakeID']) && $_SESSION['game_id'] == $_POST['wakeID'] )
{
	call("webchessMail('wakeup',{$_SESSION['opponent']['p_email']},'',{$_SESSION['username']},{$_SESSION['game_id']})");
	$wake_up_sent = webchessMail('wakeup',$_SESSION['opponent']['p_email'],'',$_SESSION['username'],$_SESSION['game_id']);
}
//*/


//******************************************************************************
//  load game from database for display
//******************************************************************************

// get FEN array
$query = "
	SELECT h_fen
	FROM ".T_HISTORY."
	WHERE h_game_id = '{$_SESSION['game_id']}'
	ORDER BY h_time
";
$FENarray = $mysql->fetch_value_array($query, __LINE__, __FILE__);

$num_moves = count($FENarray) - 1; // remove one for initpos

loadGame( ); // sets up board using last entry in ".T_HISTORY." table (chessdb.inc.php)

// convert the current FEN array to an array of standard moves
FENtomoves( ); // (chessutils.inc.php)


// find out if it's the current player's turn
$FENitems = explode(' ',$FENarray[$num_moves]);
$curTurn  = $colorArray[$FENitems[1]];

$isPlayersTurn = ($curTurn == $_SESSION['player']['p_color']) ? true : false;

//*/

// set the display to show whos turn, or shared
if ($_SESSION['shared'])
{
	$turn = "Partagé";
}
elseif ($isPlayersTurn)
{
	$turn = "Votre coup";
}
else
{
	$turn = "Coup adverse";
}


$head_extra = '
	<script type="text/javascript">//<![CDATA[
		var watchgame = false;
		function redo( )
		{
			window.location.replace(\'chess.php\');
		}
		';

		// ouput confirmation for wake up email
		if ($wake_up_sent)
		{
			$head_extra .= "alert('Envoi Wake Up par e-mail effectué.');\n    ";
		}
		elseif (isset($_POST['wakeID']) && ! $wake_up_sent)
		{
			$head_extra .= "alert('Envoi Wake Up par e-mail échoué !!');\n    ";
		}

		// transfer game data to javacript vars
		$head_extra .= getJSFEN( );  // writes 'FEN' array, and 'result' (gui.inc.php)
		$head_extra .= getTurn( );   // writes 'isBoardDisabled', 'isPlayersTurn', and 'perspective' (gui.inc.php)
		$head_extra .= getMoves( );  // writes the 'moves' array (gui.inc.php)
		$head_extra .= getStatus( ); // writes 'whosMove', 'gameState', and 'statusMsg' (gui.inc.php)

		$head_extra .= "var DEBUG = ".JS_DEBUG.";\n    ";
		$head_extra .= "var numMoves = FEN.length - 1;\n    ";

		// if it's not the player's turn, enable auto-refresh
		$autoRefresh = ( ! $isPlayersTurn && ! isBoardDisabled( ) && ! $_SESSION['shared'] );
		$head_extra .= "var autoreload = ";

		if ( ! $autoRefresh || (0 == $CFG_MINAUTORELOAD) )
		{
			$head_extra .= "0";
		}
		elseif ( $_SESSION['pref_auto_reload'] >= $CFG_MINAUTORELOAD )
		{
			$head_extra .= $_SESSION['pref_auto_reload'];
		}
		else
		{
			$head_extra .= $CFG_MINAUTORELOAD;
		}

		$vs = get_medal($_SESSION['white']['p_username']).$_SESSION['white']['p_username']." - ".get_medal($_SESSION['black']['p_username']).$_SESSION['black']['p_username'];

		$head_extra .= ";
			var gameId = '{$_SESSION['game_id']}';
			var players = '{$vs}';
			var promoting = '{$promoting}';
			var isGameOver = '{$isGameOver}';
			var lastMoveIndicator = '{$_SESSION['pref_show_last_move']}';
			var id960 = '{$_SESSION['id960']}';
			var initpos = '{$initpos}';
			var parties_gagnees = '{$_SESSION['wins']}';
		";

		$head_extra .= "var currentTheme = '";
		$head_extra .= (isset($_SESSION['pref_theme']) ? $_SESSION['pref_theme'] : "Style A") . '\';

			//]]>
		</script>
		<!-- the \'variables\' javascript must come first !! -->
		<script type="text/javascript" src="javascript/variables.js"></script>
		<script type="text/javascript" src="javascript/chessutils.js"></script>
		<script type="text/javascript" src="javascript/commands.js"></script>
		<script type="text/javascript" src="javascript/validation.js"></script>
	';

	if ($isPlayersTurn || $_SESSION['shared'] || $promoting)
	{
		$head_extra .= "\n	<script type=\"text/javascript\" src=\"javascript/isCheckMate.js\"></script>";
	}

	if ( ! isBoardDisabled( ) || $_SESSION['shared'])
	{
		$head_extra .= "\n	<script type=\"text/javascript\" src=\"javascript/squareclicked.js\"></script>";
	}

	$head_extra .= '<script type="text/javascript" src="javascript/board.js"></script>
		<script type="text/javascript" src="javascript/highlight.js"></script>
	';
	echo get_header(null, $turn, $head_extra)
?>

<div id='centrer_jeu'>
<div id="centrer_menu_partie">
			<a href="index.php"><input type="button" class="button" value="<= Accueil =>"/></a>
				<input type="button" id="btnUndo" class="button" value="Demander à rejouer" />
				<input type="button" id="btnDraw" class="button" value="Demander la nulle" disabled="disabled" />
				<input type="button" id="btnResign" class="button" value="Abandonner" />
				<br/><br/>		
</div>
		<div id="history">
			<?php // case avec dernier coup : ?>
			<span style='display:none;' id="curmove"> </span> 
			<h2 id="players"></h2>
			<h2 id="gameid"></h2>
			<div id="gamebody"></div>
		</div>			
		<div id="board">
		
			<div id="checkmsg"></div>
			<div id="statusmsg"></div>
					
		<br>
				<div id="gamebuttons">
					<span id="castle">Pour roquer : cliquez sur le roi, et ensuite sur la tour du côté du roque.
					<a href="#" class="help" onclick="window.open('./help/c960castling.html','help','resizable,scrollbars,width=550,height=500,top=50,left=50','_blank');return false;">?</a></span>
				</div>
			<h3>Pièces capturées:</h3>
			<div id="captheading"></div>
			<div id="captures"></div>
			<br>
			
			<div id="date">
			<?php 
			/*timezone();
			setlocale(LC_TIME,'fr_FR');					 
			echo 'Nous sommes '.strftime("%A %d %B %Y").'. ';
			echo ' Il est: '.strftime("%Hh %M").'<br/>';*/
			?>
			</div>
			<form name="gamedata" method="post" action="chess.php">
				
				<div id="chessboard"></div>

					<?php
					if ($promoting && ( ! $isPlayersTurn || $_SESSION['shared'])) // Write promotion dialog only to the correct player
					{
						echo getPromotion( );
					}

					if ($isUndoRequested)
					{
						echo getUndoRequest( );
					}

					if ($isDrawRequested)
					{
						echo getDrawRequest( );
					}
				?>

				
				<input type="hidden" name="requestUndo" value="no" />
				<input type="hidden" name="requestDraw" value="no" />
				<input type="hidden" name="resign" value="no" />
				<input type="hidden" name="fromRow" value="" />
				<input type="hidden" name="fromCol" value="" />
				<input type="hidden" name="toRow" value="" />
				<input type="hidden" name="toCol" value="<?php if ($promoting) echo $movesArray[$num_moves]['toCol']; ?>" />
				<input type="hidden" name="castleMove" value="false" />
				<input type="hidden" name="promoting" value="<?php echo ($promoting ? 'true' : 'false'); ?>" />

			</form>
			<div id="gamenav"></div>
			<form name="gamemenu" id="gamemenu" method="post" action="chess.php" style="display:inline;">
				<input type="button" id="btnReload" value="Recharger" disabled="disabled" />
				<input type="button" id="btnReplay" value="Revoir partie" disabled="disabled" />
				<input type="button" id="btnPGN" value="PGN" disabled="disabled" />
			</form>
			<form name="wakeup" id="wakeup" method="post" action="chess.php" style="display:inline;">
				<?php
					// test for opponents email, and if none, disable the wake up button
					$temp = ('' == $_SESSION['opponent']['p_email']) ? ' disabled="disabled"' : ''; // check the var and disable if no email is found
				?>
				<input type="button" id="btnWakeUp" value="Rappel" onclick="wakeUp( );"<?php echo $temp; ?> />
				<input type="hidden" name="wakeID" value="<?php echo $_SESSION['game_id']; ?>" /><a href="#" class="help" onclick="window.open('./help/wakeup.html','help','resizable,scrollbars,width=550,height=500,top=50,left=50','_blank');return false;">?</a>
			</form>
		</div>
		<?php
				// collect the public chat messages
				$query = "
					SELECT distinct c_message
						, c_private
						, p_username
						,DAY(c_time) AS jour, MONTH(c_time) AS mois, Year(c_time) AS annee, HOUR(c_time) AS heure, MINUTE(c_time) AS minute
					FROM ".T_CHAT."
						LEFT JOIN ".T_PLAYER."
							ON ".T_CHAT.".c_player_id = ".T_PLAYER.".p_id
					WHERE c_game_id = '{$_SESSION['game_id']}'
						AND (
							(c_private = 'No')
					";
					
				// include private message data if game is not shared
				if ('1' != $_SESSION['shared'])
				{
					$query .= "
							OR (c_private='Yes'
								AND ".T_CHAT.".c_player_id = '{$_SESSION['player_id']}')
					";
				}

				$query .= "
						)
					ORDER BY c_time DESC
				";
            	
				$result = $mysql->fetch_array($query, __LINE__, __FILE__);
				$i = 0;
				// on n'affiche pas le tableau si on a pas de résultats ..
				$nb_res = count($result); 
				if($nb_res > 0){
				?>
				<div id="chat">
				<h2><center>Chat<center></h2>	
					<div id="date">
					<?php
					setlocale(LC_TIME,'fr_FR');	
					//$a=strftime("%A %d %B %Y");
					//echo htmlentities($a);
					//$y='Nous sommes le '.strftime("%A %d %B %Y").'. ';
					echo 'Nous sommes le '.strftime("%A %d %B %Y").'. ';
					//echo $y;
					echo ' Il est: '.strftime("%Hh %M").'<br/>';
					?></div>
					
					<div class="info"></div>
					<div id="chatholder">
					<table class="chat" style='table-layout: fixed;'>
						<col />
						<col class="message" />
						<tr>
							<th style='width:90px' >Joueurs</th>
							<th >Messages</th>
						</tr>
				
				<?php }else{ ?>
				<div id="chat">
					<h2>chat</h2>
				<div class="info"></div>
					<div id="chatholder">
					<table class="chat">
						<col />
						<col class="message" />
						<tr>
							<th>Aucun message</th>
						</tr>


				<?php }
				foreach ($result as $chat)
				{
					$alt = ' class="';
					$alt .= (0 == $i % 2) ? ' alt' : '';
					$alt .= ('Yes' == $chat['c_private']) ? ' mine' : '';
					$alt .= ( $_SESSION['username'] != $chat['p_username']  ) ? ' opp' : '';
					$alt .= '"';
					$mois=array("","/ 01 /","/ 02 /","/ 03 /","/ 04 /","/ 05 /","/ 06 /","/ 07 /","/ 08 /","/ 09 /","/ 10 /","/ 11 /","/ 12 /");
					//$mois=array("","janvier","février","mars","avril","mai","juin","juillet","août","septembre","octobre","novembre","décembre");
					$chat['c_message']=nl2br($chat['c_message']); 
					if($chat['minute'] < 10 ){$chat['minute'] = "0".$chat['minute'];}
					echo "
				<tr{$alt}>
					<td class=\"player\">{$chat['p_username']}:<br/>
			        {$chat['jour']} {$mois[$chat['mois']]} {$chat['annee']}<br/> 
					{$chat['heure']}:{$chat['minute']}</td>
					<td style = 'hyphens: auto;word-wrap: break-word;'>  {$chat['c_message']}</td>
				</tr>";
					$i++;
				}
				
				
				?>

			</table>
			</div>
			<br>
			<br>
			<form action="chess.php" method="post" name="chatdata" style="display:inline;">
<textarea style="width:339px;max-width:373px;max-height:90px;" name="txtChatbox" tabindex="2" cols="39" rows="4" onfocus="clearTimeout(intervalId);" onblur="if(''==this.value){intervalId = setTimeout('redo( )', autoreload * 1000);}"
tabindex="2" placeholder="Ecrivez vos commentaires ici..."></textarea> 							
				<br>
				<!--<label for="private"><input type="checkbox" id="private" name="private" tabindex="1" />Privé</label> -->
				 <input type="submit" id="btnSubmit" name="chat" tabindex="3" value="Envoi" />
			</form>
		</div>
		</div>
	</div>
	<div id="footerspacer"> </div>
	<?php // NE PAS ENLEVER FENBLOCK : sinon on ne peu plus revoir les coups précédents ?>
	<div id="FENblock"></div>
<?php call($GLOBALS);?>
</body>
</html>
<!-- 
			</table>
			</div>
			<br>
			<br>
			<form action="chess.php" method="post" name="chatdata" style="display:inline;">
				<textarea style="width:339px;max-width:373px;max-height:60px;" name="txtChatbox" tabindex="2" cols="39" rows="4" onfocus="clearTimeout(intervalId);" onblur="if(''==this.value){intervalId = setTimeout('redo( )', autoreload * 1000);}"></textarea> 				
				<br>
				<label for="private"><input type="checkbox" id="private" name="private" tabindex="1" />Privé</label> 
				 <input type="submit" id="btnSubmit" name="chat" tabindex="3" value="Envoi" />
			</form>
		</div>
		</div>
	</div>
	<div id="footerspacer_jeu"> </div>
<?php call($GLOBALS);?>
</body>
</html> -->


<?php 


Le fichier board.js où se trouve le bouton en ligne 662
function getObject(obj) {
	if (document.getElementById) {  // Mozilla, FireFox, Explorer 5+, Opera 5+, Konqueror, Safari, iCab, Ice, OmniWeb 4.5
		if (typeof obj == "string") {
			if (document.getElementById(obj)) {
				return document.getElementById(obj);
			} else {
				return document.getElementsByName(obj)[0];
			}
		} else {
			return obj.style;
		}
	}
	if (document.all) {       // Explorer 4+, Opera 6+, iCab, Ice, Omniweb 4.2-
		if (typeof obj == "string") {
			return document.all(obj);
		} else {
			return obj.style;
		}
	}
	if (document.layers) {      // Netscape 4, Ice, Escape, Omniweb 4.2-
		if (typeof obj == "string") {
			return document.layers(obj);
		} else {
			return obj.style;
		}
	}
	alert('Objet non trouvé : ' + obj);
	return false;
}


function isGameDrawn( )
{
	var i,j;

	// Stalemate?  // is all this needed, it is generated in php, so...
	if (gameState == 'stalemate')
	{
		var myColor = WHITE;

		if (0 <= numMoves && 'b' == FEN[FEN.length - 1].split(' ')[1])
		{
			myColor = BLACK;
		}

		if (0 == countMoves(myColor))
		{
			alert('Nulle (pat)\nVous devriez offrir la nulle à votre adversaire.');
		}

		return "stalemate";
	}

	// Is the game drawn due to insufficient material to checkmate?
	var count = 0;
	var canCheckmate = false;

	for (i = 0; i < 8; i++)
	{
		for (j = 0; j < 8; j++)
		{
			if (board[i][j] != 0 && (board[i][j] & COLOR_MASK) != KING)
			{
				if ((board[i][j] & COLOR_MASK) != KNIGHT && (board[i][j] & COLOR_MASK) != BISHOP)
					canCheckmate = true;
				else
					count++;
			}
		}
	}
	if (count < 2 && ! canCheckmate)
	{
		alert('Nulle (materiel insuffisant pour mater)\nVous devriez offrir la nulle à votre adversaire.');
		return "material";
	}

	// Is the game drawn because this is the third time that the exact same position arises?
	if (numMoves >= 0 && isThirdTimePosDraw(FEN))
	{
		alert('Nulle (cette position a été rencontrée trois fois)\nVous devriez offrir la nulle à votre adversaire.');
		return "3";
	}

	// Draw because of no capture or pawn move for the last 50 moves?
	if (numMoves >= 0 && isFiftyMoveDraw(FEN[FEN.length-1]))
	{
		alert('Nulle (règle des 50 coups)\nVous devriez offrir la nulle à votre adversaire.');
		return "50";
	}

	return false;
}


function displayCaptPieces( )
{
	var i,j;
	var color = 'white';
	var html = '<div>';
	var piece = '';
	var item;

	for(i = 0; i < captPieces.length; i++)
	{
		for(j = 0; j < captPieces[i].length; j++)
		{
			piece = color + '_' + captPieces[i][j];
			html += '<img src="images/' + currentTheme + '/' + piece + '.' + ((-1 !== currentTheme.indexOf('gnuchess')) ? 'png' : 'gif') + '" width="';
			html += parseInt(50 * 3 / 5) + '" height="' + parseInt(50 * 3 / 5) + '" alt="' + piece + '" />';
		}

		html += "</div>\n<div>";
		color = 'black';
	}

	html += '</div>';
	getObject('captures').innerHTML = html;
}


if (0 < numMoves) { // if we have not made a move yet, don't get the previous move
	var prevMove = new previousMove( ); // the previous move info as object
}

var takenPiece = 0; // the captured piece img in the captures section
var captEnPass = 0; // the square the en passant captured pawn was on
function unhighlightCurMove( )
{
	unhighlight(getObject('tsq' + prevMove.fromSq));
	unhighlight(getObject('tsq' + prevMove.toSq));

	if (takenPiece) // if we have a captured piece highlighted
	{
		unhighlight(takenPiece); // unhighlight it
		takenPiece = 0; // and erase the var so we don't keep highlighting it
	}

	if (captEnPass) // if we have an en passant capture
	{
		unhighlight(captEnPass); // unhighlight it
		captEnPass = 0; // and erase the var so we don't keep highlighting it
	}
}


function highlightCurMove( )
{
	var item;

	// check for en passant move
	if (undefined != prevMove.captSq && prevMove.captSq != prevMove.toSq)
	{
		captEnPass = getObject('tsq' + prevMove.captSq);
	}

	if (prevMove.captPiece)
	{
		if ('w' == pieceColor[prevMove.captPiece])
		{
			item = 'white_' + pieceLtrToName[prevMove.captPiece.toLowerCase( )];
		}
		else
		{
			item = 'black_' + pieceLtrToName[prevMove.captPiece.toLowerCase( )];
		}

		var capt = getObject('captures').getElementsByTagName('img');

		var i;
		for (i = 0; i < capt.length; i++)
		{
			if (capt[i].alt == item)
			{
				takenPiece = capt[i];
				break;
			}
		}
	}

	highlight(getObject('tsq' + prevMove.fromSq), 'highlighted');
	setTimeout('highlightCurMoveTo( )', 300);
	setTimeout('unhighlightCurMove( )', 900);
}


function highlightCurMoveTo( )
{
	if (takenPiece)
	{
		highlight(takenPiece, 'taken_highlighted');

		if (captEnPass)
		{
			highlight(captEnPass, 'taken_highlighted');
			highlight(getObject('tsq' + prevMove.toSq), 'highlighted');
		}
		else
		{
			highlight(getObject('tsq' + prevMove.toSq), 'taken_highlighted');
		}
	}
	else
	{
		highlight(getObject('tsq' + prevMove.toSq), 'highlighted');
	}
}


function displayCurFEN(moveIdx)
{
	if (undefined != moveIdx)
	{
		getObject('FENblock').innerHTML = FEN[moveIdx];
	}
	else
	{
		getObject('FENblock').innerHTML = FEN[FEN.length - 1];
	}
}


// these will throw errors, but initializing them as 'undefined' is the
// only way to ensure all-around compatibility no matter what the original colors are.
function moveTo(objMoveId)
{
	var theBoard;

	if (0 < currMoveIdx) // don't try to reset the empty span, it throws errors
	{
		unhighlight(getObject('m' + currMoveIdx)); // reset the previous move box background color
	}

	currMoveIdx = parseInt(objMoveId.id.slice(1)); // get the move number
	FENToBoard(FEN[currMoveIdx]); // convert that FEN to the board var
	displayCurFEN(currMoveIdx); // display that FEN
	FENToCapt(currMoveIdx); // get the captures up to that point
	displayCaptPieces( ); // display those captures
	theBoard = htmlBoard( ); // convert the board var to html code
	getObject('chessboard').innerHTML = theBoard; // display that board
	highlight(getObject('m' + currMoveIdx), 'curmove_highlighted'); // change the move box background color
}


function moveJmp(moveDelta)
{
	var moveIdx = currMoveIdx;

	if (moveIdx + moveDelta > FEN.length - 1)
	{
		moveIdx = FEN.length - 1;
	}
	else if (moveIdx + moveDelta < 0)
	{
		moveIdx = 0;
	}
	else
	{
		moveIdx += moveDelta;
	}

	moveTo(getObject('m' + moveIdx + ''));
}


function displayMoves(replay)
{
	var i;
	var alt = '';
	var objGamebody = getObject('gamebody');
	var theMoves = '\n<span id="m0"></span>';
	var moveId = 1;
	theMoves += '\n<table class="moveList">\n';

	for (i = 0; i < moves.length; i++)
	{
		if ( (i + 1) % 2 == 0)
		{
			alt = ' class="alt"';
		}
		else
		{
			alt = '';
		}

		if ('1' == isGameOver || replay || 'mate' == gameState)
		{
			theMoves += '<tr'+alt+'>\n<td class="mn">' + (i+1) + '.</td>\n';
			theMoves += '<td id="m' + (moveId) + '" class="wm" onclick="moveTo(this);">' + moves[i][0] + '</td>\n';
			theMoves += '<td id="m' + (moveId+1) + '" class="bm" onclick="moveTo(this);">' + moves[i][1] + '</td>\n</tr>';
			moveId = moveId + 2;
		}
		else
		{
			theMoves += '<tr'+alt+'>\n<td class="mn">' + (i+1) + '.</td>\n<td class="wm">';
			theMoves += moves[i][0] + '</td>\n<td class="bm">' + moves[i][1] + '</td>\n</tr>';
		}
	}

	theMoves += '\n</table>\n';

	if ('' != result)
	{
		theMoves += '<span class="ctr">Result: ' + result + '</span>\n';
	}

	objGamebody.innerHTML = theMoves;
	element = document.getElementById('gamebody');
    element.scrollTop = element.scrollHeight;
}


function toggleInvert( )
{
	if ('black' == perspective)
		perspective = 'white';
	else
		perspective = 'black';

	theBoard = htmlBoard( );
	getObject('chessboard').innerHTML = theBoard;
}


function htmlBoard( )
{ // Returns the HTML-code for the current chessboard (Note: Fixed square size and theme)
	var i,j,k;
	var classWSquare;
	var classBSquare;
	var classHeader;
	var fileLabel;
	var xtra;
	var mtra;
	var colorside;
	var invertBoard = (perspective == 'black');
	var rank = 8;
	var rankLabel = rank;

	if ('' == isBoardDisabled && ! watchgame)
	{
		classWSquare = 'light_enabled';
		classBSquare = 'dark_enabled';
		classHeader = 'header_enabled';
	}
	else
	{
		classWSquare = 'light_disabled';
		classBSquare = 'dark_disabled';
		classHeader = 'header_disabled';
	}

	var sqBackground = [classBSquare, classWSquare];

	if (invertBoard)
	{
		rankLabel = 1;
		colorside = "white";
	}
	else
	{
		colorside = "black";
	}

	j = 1;

	//changement du plateau selon le nombre de parteis gagnées

	if(parties_gagnees < 100){
			theBoard = '\n<div id="theBoard" style="background: url(./images/bois.png);">\n';
			var couleur = 'style="color:#111;"'; //correspond aux lettres et chiffres du bord de l'échiquier
	}else if(parties_gagnees >= 100){
			theBoard = '\n<div id="theBoard" style="background: url(./images/marbre.png);">\n';
			var couleur = 'style="color:#555;"'; //correspond aux lettres et chiffres du bord de l'échiquier
	}

	

	theBoard += '<div class="' + classHeader + ' ' + colorside + 'corner"> <\/div>\n';

	for(i = 0; i < 8; i++)
	{
		if(invertBoard)
			fileLabel = Files[7-i];
		else
			fileLabel = Files[i];

		theBoard += '<div '+couleur+' id="file_t' + i + '" class="' + classHeader + ' horz">' + fileLabel + '<\/div>\n';
	}

	theBoard += '<div class="' + classHeader + ' ' + colorside + 'corner"> <\/div>\n';
	theBoard += '<div '+couleur+' id="rank_l' + rank-- + '" class="' + classHeader + ' vert">' + rankLabel + '</div>\n';

	for (k = 63; k >= 0; k--)
	{
		if ((k+1) % 8 == 0)
		{
			i = k - 7;

			if (invertBoard)
				i = 63 - i;
		}
		else
		{
			if (invertBoard)
				i--;
			else
				i++;
		}

		var row = parseInt(i / 8);
		var col = i % 8;

		if (prevMove && row == prevMove.fromRow && col == prevMove.fromCol && '' == isBoardDisabled && ! watchgame && lastMoveIndicator)
			xtra = " fromSquare";
		else if (prevMove && row == prevMove.toRow && col == prevMove.toCol && '' == isBoardDisabled && ! watchgame && lastMoveIndicator)
			xtra = " toSquare";
		else
			xtra = "";

		theBoard += '<div id="tsq' + i + '" class="' + sqBackground[j] + xtra + '">';
		var piece = '';
		var source = '';

		if(board[row][col] != 0)
		{
			piece = getPieceColor(board[row][col]) + '_' + getPieceName(board[row][col]);
			source = 'images/' + currentTheme + '/' + piece + '.' + ((-1 !== currentTheme.indexOf('gnuchess')) ? 'png' : 'gif'); // Update the square
			theBoard += '<img alt="' + piece + '" id="sq' + i + '" ';
			theBoard += 'src="' + source + '" width="50" height="50" />';
		}
		else
		{
			theBoard += '';
		}
		theBoard += '<\/div>\n';
		if ( (k % 8) === 0 )
		{
			theBoard += '<div '+couleur+' id="rank_r' + (rank+1) + '" class="' + classHeader + ' vert">' + rankLabel + '<\/div>\n';
			if (k != 0)
			{
				if(invertBoard)
					rankLabel = 9 - rank;
				else
					rankLabel = rank;

				theBoard += '<div '+couleur+' id="rank_l' + rank-- + '" class="' + classHeader + ' vert">' + rankLabel + '</div>\n';
			}
		}
		else
		{
			j = 1 - j;
		}
	}

	if ("white" == colorside)
		colorside = "black";
	else
		colorside = "white";

	theBoard += '<div '+couleur+' class="' + classHeader + ' ' + colorside + 'corner"> <\/div>\n';

	for (i = 0; i < 8; i++)
	{
		if (invertBoard)
			fileLabel = Files[7-i];
		else
			fileLabel = Files[i];

		xtra = "";mtra = ""; // erase any previous values
		if ("518" != id960 && "header_disabled" != classHeader) // if we are not in a normal game and not disabled
		{
			if ("c" == fileLabel || "g" == fileLabel)
			{
				xtra = "<span class=\"kingto\">K</span>";
				mtra = "<span class=\"spacer\">K</span>";
			}
			else if ("d" == fileLabel)
			{
				xtra = "<span class=\"rookato\">R</span>";
				mtra = "<span class=\"spacer\">R</span>";
			}
			else if ("f" == fileLabel)
			{
				xtra = "<span class=\"rookhto\">R</span>";
				mtra = "<span class=\"spacer\">R</span>";
			}

			var LorigARookPos = origARookPos;
			var LorigKingPos  = origKingPos;
			var LorigHRookPos = origHRookPos;

			if (invertBoard)
			{
				LorigARookPos = 7 - LorigARookPos;
				LorigKingPos  = 7 - LorigKingPos;
				LorigHRookPos = 7 - LorigHRookPos;
			}

			if (i == LorigARookPos)
				fileLabel = '<span class="origarook">' + fileLabel + '</span>';
			else if (i == LorigKingPos)
				fileLabel = '<span class="origking">' + fileLabel + '</span>';
			else if (i == LorigHRookPos)
				fileLabel = '<span class="orighrook">' + fileLabel + '</span>';
		}

		theBoard += '<div '+couleur+' id="file_b' + i + '" class="' + classHeader + ' horz">' + mtra + fileLabel + xtra + '<\/div>\n';
	}

	theBoard += '<div class="' + classHeader + ' ' + colorside + 'corner"> <\/div>\n<\/div>\n';
	return theBoard;
}


// only do disabled = true for btnWakeUp, it is set as disabled if no email is present.

FENToBoard(FEN[FEN.length - 1]); // save the last entry in the FEN array to the board
var theBoard = htmlBoard( ); // The HTML code for the board
var currMoveIdx = 0;
var intervalId = 0;
window.onload = function( )
{
	var i;
	var lastMove;
	var navButtons;
	var gameIdDisplay;
	var invertBoard = (perspective == 'black');

	getObject('chessboard').innerHTML = theBoard;
	//displayCurFEN( );
	FENToCapt(numMoves);
	displayCaptPieces( );


	if (0 != gameId) // is it a database game ?
	{
		gameIdDisplay = 'Partie '  + gameId;
		getObject('btnPGN').disabled = false;
	}
	else // or a PGN file game
	{
		gameIdDisplay = 'PGN Game';
	}

	if ( ! watchgame)
	{
		if ('518' != id960) // if it's a Chess960 game
		{
			gameIdDisplay += ' - ' + id960 // display the id
		}
		else // or a regular game
		{
			getObject("castle").style.display = 'none';
		}
	}

	if ('1' != isBoardDisabled && ! watchgame)
	{
		if (0 < numMoves)
		{
			getObject("btnUndo").disabled = false;
		}

		getObject("btnDraw").disabled = false;
		getObject("btnResign").disabled = false;
		//document.querySelector('btnResign').disabled = false;
	}

	if ( ! watchgame) // are we playing the game
	{
		displayMoves( );

		getObject("btnReload").disabled = false;
		getObject("btnReplay").disabled = false;
		getObject("btnReload").onclick = function( ) { reloadPage(this); };
		getObject("btnReplay").onclick = function( ) { replay( ); };


		if (0 < moves.length) // if there are moves
		{
			lastMove = moves.length + '-'; // get the move number

			if ('' != moves[moves.length-1][1]) // if we are showing a black move
			{
				getObject('curmove').innerHTML = lastMove + ' ... ' + moves[moves.length-1][1];
			}
			else // we are showing a white move
			{
				getObject('curmove').innerHTML = lastMove + ' ' + moves[moves.length-1][0];
			}

			if ('1' != isGameOver)
			{
				getObject("curmove").onclick = function( ) { highlightCurMove( ); };
			}
		}

		if ('check' == gameState)
		{
			getObject('checkmsg').style.display = '';
			getObject('checkmsg').innerHTML = 'Echec !';

			// convert the board border to red if in check
			var divs = document.all ? document.all : document.getElementById("theBoard").getElementsByTagName("div");

			for ( var i = 0; i < divs.length; i++)
			{
				if (divs[i].className.match(/.*?(horz|vert).*?/))
				{
					divs[i].style.backgroundColor = "#BF2F35"; // TODO : stylefix
				}
			}
		}

		if ('' != statusMessage)
		{
			getObject('statusmsg').style.display = '';
			getObject('statusmsg').innerHTML = statusMessage;

			// if the statusMessage says anything about undo's
			// prevent multiple undo's from being requested
			if (statusMessage.match(/ undo /i))
			{
				getObject('btnUndo').disabled = true;
			}
		}
	}
	else // or just watching the game
	{
		displayMoves(true);
	}

	getObject('gameid').innerHTML = gameIdDisplay;
	getObject('players').innerHTML = players;

	//getObject('btnMainMenu').disabled = false;
	getObject('btnPGN').disabled = false;

	//getObject('btnMainMenu').onclick = function( ) { displayMainmenu( ); };
	getObject('btnPGN').onclick = function( ) { downloadPGN( ); };

	if ( ! watchgame)
	{
	    getObject("btnUndo").onclick = function() { 
        alert("Votre demande d'annulation de coup est en attente.");
        undo();
        };
        getObject("btnDraw").onclick = function() { 
        alert("Votre demande de match nul est en attente.");
        draw(); 
        };
        getObject("btnResign").onclick = function() { 
        alert("Votre demande d'abandon est validée.");
        resigngame(); 
        };
	}

	if ('1' == isGameOver || watchgame || 'mate' == gameState) // Allow game replay
	{
		if ( ! watchgame)
		{
			getObject('gamebuttons').style.display = 'none';
			getObject('btnWakeUp').disabled = true;
			getObject('btnReload').disabled = true;
			getObject('btnReplay').disabled = true;
		}

		currMoveIdx = FEN.length - 1;
		navButtons = '<form id="navigation" action="">';
		navButtons += '<span id="navbuttons">';
		navButtons += '<input id="start" title="Début de la partie" type="button" value="Start" />';
		navButtons += '<input id="jmpback" title="Retour en arrière de 5 demi-coups" type="button" value=" << " />';
		navButtons += '<input id="prev" title="Retour en arrière d\'un demi-coup" type="button" value=" < " />';
		navButtons += '<input id="next" title="Avancer d\'un demi-coup" type="button" value=" > " />';
		navButtons += '<input id="jmpfwd" title="Avancer de 5 demi-coups" type="button" value=" >> " />';
		navButtons += '<input id="end" title="Fin de la partie" type="button" value="End" /> <br> ';
		navButtons += '<input style="width:100px" id="invert" title="Inverser" type="button" value="< Tourner" />';
		navButtons += '<input style="width:100px" id="invert2" title="Inverser" type="button" value="Tourner >" disabled />';
		navButtons += '</span>';
		navButtons += '</form>';

		function invert1(){ /*toggleInvert( )*/

			document.getElementById("invert").disabled = true;
			document.getElementById("invert2").disabled = false;
			document.getElementById("theBoard").style.transform = "rotate(180deg)";
			document.getElementById("theBoard").style.transition = ".3s";
			for (var i=0; i < 64; i++) { 
				var element =  document.getElementById("sq"+i);
				if (typeof(element) != 'undefined' && element != null)
					{
						document.getElementById("sq"+i).style.transform = "rotate(180deg)";
					}
				
			}
		};
		function invert2(){ /*toggleInvert( )*/

			document.getElementById("invert2").disabled = true;
			document.getElementById("invert").disabled = false;
			document.getElementById("theBoard").style.transform = "rotate(0deg)";
			document.getElementById("theBoard").style.transition = ".3s";
			for (var i=0; i < 64; i++) { 
				var element =  document.getElementById("sq"+i);
				if (typeof(element) != 'undefined' && element != null)
					{
						document.getElementById("sq"+i).style.transform = "rotate(0deg)";
						//document.getElementById("theBoard").style.transition = ".3s";
					}
			}
			//document.getElementById("invert").style.display = "block";
			//document.getElementById("invert2").style.display = "none";


		};

		getObject('gamenav').innerHTML = navButtons;
		getObject("start").onclick = function( ){if(document.getElementById("invert").disabled == true){invert2();moveJmp(-10000);invert1();}else{moveJmp(-10000)} ;};
		getObject("jmpback").onclick = function( ){if(document.getElementById("invert").disabled == true){invert2();moveJmp(-5);invert1();}else{moveJmp(-5)};};
		getObject("prev").onclick = function( ){if(document.getElementById("invert").disabled == true){invert2();moveJmp(-1);invert1();}else{moveJmp(-1)};};
		getObject("next").onclick = function( ){if(document.getElementById("invert").disabled == true){invert2();moveJmp(1);invert1();}else{moveJmp(1)};};
		getObject("jmpfwd").onclick = function( ){if(document.getElementById("invert").disabled == true){invert2();moveJmp(5);invert1();}else{moveJmp(5)};};
		getObject("end").onclick = function( ){if(document.getElementById("invert").disabled == true){invert2();moveJmp(10000);invert1();}else{moveJmp(10000)};};
		getObject("invert").onclick = function( ){invert1()};
		getObject("invert2").onclick = function( ){invert2()};
	}
	else // game is not over and we are not replaying it
	{
		isGameDrawn( ); // Alert the players it's stalemate, 50 move draw or the same position has occurred three times

		if (true == isPlayersTurn)
		{ // No need to set event handlers unless it's the player's move
			for(i = 0; i < 64; i++)
			{
				getObject('tsq' + i).onclick = function( ) { squareClicked(this); };
			}
			getObject('btnWakeUp').disabled = true;
		}

		if (autoreload > 0 && ! DEBUG) // if we need the board refreshed
		{
			intervalId = setTimeout("window.location.replace('chess.php')", autoreload * 1000); // start the refresh loop
		}
	}
}


L'image de l'inspecteur:

La console n'indique rien.

Merci de bien vouloir m'aider à faire fonctionner à nouveau ce bouton.
En sachant que tous les autres (Recharger (btnReload), Revoir la partie ( btnReplay) et PGN) fonctionnent.
Merci.





10 réponses

jordane45 Messages postés 38314 Date d'inscription mercredi 22 octobre 2003 Statut Modérateur Dernière intervention 24 novembre 2024 4 705
22 oct. 2018 à 10:52
Bonjour,
La fonction JS ne contient que :

function wakeUp( )
{
	if (confirm('Confirmez le mail de rappel.'))
	{
		document.wakeup.submit( );
	}
}


Autrement dit... elle déclenche le submit d'un formulaire HTML / PHP
Le formulaire étant le suivant :
<form name="wakeup" id="wakeup" method="post" action="chess.php" style="display:inline;">
				<?php
					// test for opponents email, and if none, disable the wake up button
					$temp = ('' == $_SESSION['opponent']['p_email']) ? ' disabled="disabled"' : ''; // check the var and disable if no email is found
				?>
				<input type="button" id="btnWakeUp" value="Rappel" onclick="wakeUp( );"<?php echo $temp; ?> />
				<input type="hidden" name="wakeID" value="<?php echo $_SESSION['game_id']; ?>" /><a href="#" class="help" onclick="window.open('./help/wakeup.html','help','resizable,scrollbars,width=550,height=500,top=50,left=50','_blank');return false;">?</a>
			</form>


Formulaire, qui une fois validé, lance le code
if ( isset($_POST['wakeID']) && $_SESSION['game_id'] == $_POST['wakeID'] )
{
	call("webchessMail('wakeup',{$_SESSION['opponent']['p_email']},'',{$_SESSION['username']},{$_SESSION['game_id']})");
	$wake_up_sent = webchessMail('wakeup',$_SESSION['opponent']['p_email'],'',$_SESSION['username'],$_SESSION['game_id']);
}


et pour finir... ce code fait appel à des fonctions (PHP ) qui ne se trouvent pas dans les fichiers que tu nous montres
=> webchessMail()

Bref, il semble que ton souci soit côté PHP et non Javascript. (donc mauvais forum)
Et sans toutes les infos nécéssaires.. impossible pour nous de te renseigner.


NB: Nous donner pleins d'infos ... c'est bien.... cibler les infos utiles.. c'est mieux.
Essaye d'affiner les infos que tu nous donnes... on n'a pas toujours le temps (ou l'envie...) de se palucher 30000 lignes de code pour trouver où se situe l'erreur...






0
Max747 Messages postés 258 Date d'inscription vendredi 11 juillet 2014 Statut Membre Dernière intervention 11 janvier 2024
22 oct. 2018 à 11:37
Je suis bien conscient que les personnes qui aident les faibles en programmation ne désirent pas étudier 3000 lignes de code ainsi.
C'est pourquoi que je m' efforce de cibler au maximum les infos.
D'y inclure des images. Cependant ne cernant pas toujours le cheminement des actions de codes, il peut m'arriver de passer à côté d'une information importante.
Tu voudras bien m'en excuser car cela est indépendant de ma volonté.
Ceci étant précisé, je peux désormais te présenter le fichier que tu me demandes webchessmail.inc.php et que voici ci dessous avec en ligne 5 la fonction webchessMail afin de communiquer par e-mail:
<?php
// get required scripts
require_once 'config.inc.php';

function webchessMail($type, $msgTo, $move, $opponent, $game_id)
{
	global $CFG_MAILADDRESS, $CFG_MAINPAGE, $CFG_USEEMAIL;

	// make sure we can use email
	if ( ! $CFG_USEEMAIL)
	{
		return false;
	}

	// make sure there's an email address given
	if ('' == $msgTo && ! DEBUG)
	{
		return false;
	}
//header('Content-Type: text/html;charset=iso-8859-1');
//header('Content-Type: text/html;charset= utf-8’);
//header('Content-Type: text/html;charset=iso-8859-1');
	// default subject header prefix
	$subject = 'CheckMat: ';

	// load specific message and subject
	switch($type)
	{
		case 'test':
			$subject .= 'Test Message';
			$message = "Félicitations !!\n"
							 . "Si vous voyez ce message, c'est que vous avez réglé avec succès votre notification par email !\n"
							 . "Maintenant, allez à {$CFG_MAINPAGE} pour jouer aux échecs !\n";
			break;
//------------------------------------------------------------------------------
		case 'invitation':
			$subject .= "{$opponent} vous a invité à jouer une nouvelle partie";
			$message = $opponent." vous a invité à jouer une nouvelle partie.\n"
							 . "Allez à {$CFG_MAINPAGE} pour accepter ou décliner cette invitation.\n";
			break;
//------------------------------------------------------------------------------
		case 'withdrawal':
			$subject .= 'Invitation annulée';
			$message = "Votre adversaire, {$opponent} a annulé son invitation à jouer une nouvelle partie.\n"
							 . "Allez à {$CFG_MAINPAGE} pour inviter un joueur, ou poursuivre une partie.\n";
			break;
//------------------------------------------------------------------------------
		case 'resignation':
			$subject .= "{$opponent} a abandonné la partie {$game_id}.";
			$message = "Votre adversaire, {$opponent} a abandonné la partie {$game_id}.\n\n"
							 . "Allez à {$CFG_MAINPAGE} pour commencer une nouvelle partie.\n";
			break;
//------------------------------------------------------------------------------
		case 'move':
			$subject .= "{$opponent} a joué {$move} dans la partie {$game_id}.";
			$message = "Votre adversaire, {$opponent} a joué le coup :\n"
							 . "{$move}\n\n"
							 . "C'est à vous de jouer\n"
							 . "Allez à {$CFG_MAINPAGE} pour jouer.\n";
			break;
//------------------------------------------------------------------------------
		case 'accepted':
			$subject .= 'Invitation acceptée';
			$message = $opponent." a accepté votre invitation à jouer une nouvelle partie.\n"
							 . "Allez à {$CFG_MAINPAGE} pour jouer.\n";
			break;
//------------------------------------------------------------------------------
		case 'declined':
			$subject .= 'Invitation déclinée';
			$message = $opponent." a decliné votre invitation à jouer une nouvelle partie.\n"
							 . "Allez à {$CFG_MAINPAGE} pour annuler votre invitation.\n";
			break;
//------------------------------------------------------------------------------
		case 'deletewarning':
			$subject .= 'Alerte d\'effacement de partie';
			$message = "Votre partie ({$game_id}) va être bientôt effacée.\n"
							 . "Allez à {$CFG_MAINPAGE} pour la revoir.\n";
			break;
//------------------------------------------------------------------------------
		case 'passupdate':
			$subject .= 'Notification de ré-initialisation de mot de passe!!';
			$message = "Votre mot de passe pour CheckMat a été ré-initialisé.\n"
							 . "Votre nouveau de passe est : change!me\n\n"
							 . "Allez à {$CFG_MAINPAGE} pour vous connecter maintenant, selectionnez 'personel' dans le menu,\n"
							 . "et changez votre mot de passe pour quelque chose de plus sécurisé.\n";
			break;
//------------------------------------------------------------------------------
		case 'wakeup':
			$subject .= 'Fonction Réveil';
			$message = "Votre adversaire, {$opponent} vous a adressé un e-mail de réveil.\n"
							 . "C'est à votre tour de jouer dans la partie #{$game_id}.\n\n"
							 . "Allez à {$CFG_MAINPAGE} pour jouer.\n";
			break;
//------------------------------------------------------------------------------
		case 'checkmate':
			$subject .= 'Echec et mat !';
			$message = "Votre adversaire, {$opponent} vous a mis échec et mat.\n"
							 . "Vous aurez plus de chance la prochaine fois.\n\n"
							 . "Allez à {$CFG_MAINPAGE} pour commencer une nouvelle partie.\n";
			break;
		// ToDo: mailmsgundorequest.php ??
	}

	$message .= "\n\n----------------------------------------------\n"
						. "Ce message a été  envoyé  automatiquement\n"
						. 'par CheckMat et ne requiert pas de réponse.';
//$message = htmlentities($message); 
	$headers = "From: CheckMat <{$CFG_MAILADDRESS}>\r\n";
	// Some MTAs may require for you to uncomment the following line. Do so if mail notification doesn't work
//  $headers = "To: {$msgTo}\r\n" . $headers;

	call('---MAIL---');
	call($msgTo);
	call($subject);
	call($message);
	call($headers);

	return mail($msgTo,$subject,$message,$headers);
}


Ainsi que le fichier config.inc.php puisqu'il est souvent question de la variable $CFG_MAINPAGE que l'on retrouve dans le fichier webchessmail.inc.php
<?php

/* Database settings */
/* ----------------- */
	/*$CFG_HOSTNAME = 'localhost';
	$CFG_USERNAME = 'root';
	$CFG_PASSWORD = '';
	$CFG_DATABASE = 'jeuxechecs_fr';/*
	/*$CFG_HOSTNAME = '127.0.0.1';
	$CFG_USERNAME = 'root';
	$CFG_PASSWORD = '';
	$CFG_DATABASE = 'echecs';*/
	$CFG_HOSTNAME = 'XXXXXX';
	$CFG_USERNAME = 'XXXXXX';
	$CFG_PASSWORD = 'XXXXXX';
	$CFG_DATABASE = 'XXXXXX';

/* Table settings */
/* -------------- */
	$prefix = 'wc2_'; // table name prefix

	define('T_CHAT'      , $prefix . 'chat'); // the in-game chat/personal notes table
	define('T_GAME'      , $prefix . 'game'); // the game data table
	define('T_HISTORY'   , $prefix . 'history'); // the moves history table
	define('T_MESSAGE'   , $prefix . 'message'); // the game message table
	define('T_PLAYER'    , $prefix . 'player'); // the player data table
	define('T_STAT'      , $prefix . 'stat'); // the stats table
	define('T_TALK'      , $prefix . 'talk'); // the player messaging table
	define('T_TALK_GLUE' , $prefix . 'talk_glue'); // the message glue table

/* Root Admin setting */
/* ------------------ */
	$CFG_ROOT_ADMIN = 'mathieu'; // Permanent admin username (case-sensitive)

/* Server / Site settings */
/* ---------------------- */
	/*
		  --- PLEASE READ ---
		this first setting is the color theme for your webchess installation
		look inside the /css directory and you will find several css files with a
		filename like c_{color_name}.css.  pick one, and enter that name here, or you can easily
		create your own, using one of the included styles as a guide.
		if you do create your own, please add a pull request to my repo at
		https://github.com/benjamw/chess/ so that others may have access to it.
	*/

	$CFG_COLOR_CSS      = 'c_new.css'; // the name of the color css file you wish to use (in the /css directory)

	$CFG_MAINPAGE       = 'http://www.jeuxechecs.fr/echecs/'; // The home page of the webchess script (include closing / )

	$CFG_SITENAME       = 'http://www.jeuxechecs.fr'; // The name of your website

	$CFG_SESSIONTIMEOUT = 0; // Number of minutes before session timeout (0 to disable)

	$CFG_EXPIREGAME     = 60; // Number of days before untouched games are deleted (0 to disable)

	$CFG_EXPIREUSERS    = 0; // Number of days before untouched accounts are deleted (0 to disable) <30>

	$CFG_MINAUTORELOAD  = 25; // Minimum number of secs between automatic page reloads (0 to disable)

	$CFG_USEEMAIL       = true; // SMTP operations.  Test it before putting it into production

	$CFG_MAILADDRESS    = 'XXXX@XXXXcom'; // Email address people see when receiving WebChess generated mail
	//Adresse électronique que les gens voient lors de la réception du courrier généré par WebChess

	$CFG_MAXUSERS       = 0; // Maximum number of users allowed (0 to disable)

	$CFG_CHANGEUSERNAME = false; // Whether a user can change their username from the main menu

	$CFG_NEWUSERS       = true; // Whether a new user can register
    
    $CFG_LONGDATE       = ' j / m / Y à \&\n\b\s\p\;G:i '; // PHP date format

	$CFG_SHORTDATE      = 'Y.m.d H:i'; // PHP date format

	$CFG_CHESS960       = true; // Whether users can play Chess960 (Fischer Random Chess) games

	$CFG_RATING_START   = 1500; // the starting ELO rating for new players

	$CFG_RATING_STEP    = 32; // the max ELO rating change allowed per game

	//$CFG_NAVLINKS       = '<a href="/">Accueil</a>'; // your site's nav links

/* MySQL Error / debug settings */
/* ---------------------------- */
	define ('DB_ERR_EMAIL_ERRORS', true); // (true / false) set to true to email errors to TO address below
	define ('DB_ERR_LOG_ERRORS'  , true); // (true / false) set to true to log errors in mysql.err file
	define ('DB_ERR_TO'          , 'XXXXX@XXXXXcom'); // set your TO email address
	define ('DB_ERR_SUBJECT'     , 'CheckMat Query Error'); // don't really need to change this
	define ('DB_ERR_FROM'        , $CFG_MAILADDRESS); // set your FROM email address (can be the same as TO above)
	define ('DB_STATS_LOG'       , true); // (true / false) set to true to log query stats in mysql.err file (or database)
	define ('FILE_PATH_END'      , 'echec/'); // set the name of the directory containing the script (with wrapping / )

/* DEVELOPER USE ONLY */
/* ------------------ */
/* INCLUDE SOME GLOBAL INCLUDES */
require_once 'mysql.class.php';
require_once 'chessgame.inc.php';

// instantiate the class and connect to the database
$mysql = new mysql($CFG_HOSTNAME, $CFG_USERNAME, $CFG_PASSWORD, $CFG_DATABASE);
$mysql->connect_select(__LINE__,__FILE__);
//@mysqli_set_charset($mysql->linkid,'utf8');
@mysqli_set_charset($mysql->linkid,'utf8mb4');
// instantiate the chess class
$chess = new ChessGame( );

define('DEBUG', false); // set to true for output of debugging code
define('JS_DEBUG', 0); // set to 1 for really annoying jvascript debug

if (defined('DEBUG') && DEBUG)
{
	ini_set('display_errors', 'On');
	error_reporting(-1);
	$mysql->error_debug = true; // Allows for error debug output
	$mysql->query_debug = true; // Allows for output of all queries all the time
	$mysql->super_debug = false; // Allows output of ALL debugging output
}

require_once('func.global.php');
require_once('func.array.php');
require_once('func.bitwise.php');
require_once('message.class.php');
require_once('phpass.class.php');

$CFG_SESSIONTIMEOUT *= 60; // convert minutes to seconds
date_default_timezone_set('Europe/Paris');

Merci beaucoup de bien vouloir m'aider à trouver la solution.
0
jordane45 Messages postés 38314 Date d'inscription mercredi 22 octobre 2003 Statut Modérateur Dernière intervention 24 novembre 2024 4 705
22 oct. 2018 à 12:04
Tu es en local ou sur un serveur ?
Si en local, as tu paramétré le smtp ?
Si sur un serveur, es-tu sûr que la fonction mail est autorisée ?

Au cas où, ça serait pas mal de voir ce que contiennent les variables du fichier webchessmail.inc.php (ligne 118 )
en faisant, par exemple

print_r(array(($msgTo,$subject,$message,$headers));
return mail($msgTo,$subject,$message,$headers);


tu peux aussi faire un test simple pour voir si la fonction php "mail" fonctionne
if(mail('tonadressemail@truc.fr', 'TEST', "Message de test")){
  echo "OK";
}else{
  echo " La fonction mail ne marche pas !";
}




NB: Si tu es en LOCAL et non sur un serveur, il faut utiliser FakeSendMail.
Tu trouveras des tutos pour l'installer et l'utiliser avec ton logiciel ( Wamp, Xampp .... )
Si tu es sur un serveur et que le test ne fonctionne pas... c'est que le serveur n'autorise pas l'utilisation de cette fonction php. Dans ce cas.. il ta faudra voir avec ton hébergeur.
Bien entendu, tu peux remplacer ce code d'envoi par l'utilisation de la class php : phpMailer et utiliser une adresse (gmail par exemple) pour générer l'envoi de mail. Là aussi tu trouveras les tutos sur le net à ce sujet.
0
Max747 Messages postés 258 Date d'inscription vendredi 11 juillet 2014 Statut Membre Dernière intervention 11 janvier 2024
22 oct. 2018 à 12:28
Merci pour tous ces renseignements.
Je suis sur serveur.
Voici en image ce que contiennent les variables du fichier webchessmail.inc.php

Ainsi que la réception de l'e-mail dans mon logiciel messagerie Outlook express:

Par contre je ne vois pas où placer le code suivant que tu m'indiques:
if(mail('tonadressemail@truc.fr', 'TEST', "Message de test")){
  echo "OK";
}else{
  echo " La fonction mail ne marche pas !";
}

Dans le fichier webchessmail.inc.php ?
0
Max747 Messages postés 258 Date d'inscription vendredi 11 juillet 2014 Statut Membre Dernière intervention 11 janvier 2024
22 oct. 2018 à 13:23
Je viens de placer le code permettant de savoir si la fonction mail fonctionne dans le fichier webchessmail.inc.php
comme ceci:
	call('---MAIL---');
	call($msgTo);
	call($subject);
	call($message);
	call($headers);
//print_r(array($msgTo,$subject,$message,$headers));
if(mail('xxxx@xxxx.fr', 'TEST', "Message de test")){
  echo "OK";
}else{
  echo " La fonction mail ne marche pas !";
}
	return mail($msgTo,$subject,$message,$headers);
}


Et voici le message retourné:

J'ai bien sûr inscrit un e-mail valide à la place des xxxx.
Et vu le résultat du test il me semble que la fonction webchessMail aurait un problème alors que je reçois certaines information du site concernant les coups joués par exemple.
0
jordane45 Messages postés 38314 Date d'inscription mercredi 22 octobre 2003 Statut Modérateur Dernière intervention 24 novembre 2024 4 705
22 oct. 2018 à 13:50
Ce qui m'étonne c'est que tu nous as montré, dans ton message précédent, un mail envoyé par cette fonction dans ta boite mail.
La fonction doit donc marcher....
peux tu créer un fichier test.php et y placer le code que je t'ai donné puis appeller cette page pour voir le résultat ?

NB: Le code est assez bordélique... sans parler du fait qu'il utiliser une vielle extension mysql considérée désormais comme obsolète. Même si ça n'est pas la cause du souci, une refonte du code serait la bienvenue...et ne pourrait qu'améliorer le fonctionnement et la maintenabilité du code
par exemple : https://forums.commentcamarche.net/forum/affich-37584947-php-gestion-des-erreurs-debogage-et-ecriture-du-code

Nb² : Juste au cas où, il serait bien également de vérifier l'encodage de tes fichiers( chapitre 1 du lien suivant )
https://forums.commentcamarche.net/forum/affich-37584944-php-html-caracteres-accentues-et-l-utf8
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
Max747 Messages postés 258 Date d'inscription vendredi 11 juillet 2014 Statut Membre Dernière intervention 11 janvier 2024
22 oct. 2018 à 14:33
Oui c'est déconcertant de voir que je reçois bien les messages en provenance de mon site tel les coups joués par les adversaires.
Voici en image ce qui est retourné par le fichier que j'ai créée:

Avec les codes correspondants:
<?php
if(mail('tonadressemail@truc.fr', 'TEST', "Message de test")){
  echo "OK";
}else{
  echo " La fonction mail ne marche pas !";
}
?>

A tout hasard voici un fichier nommé index.inc.php dont tu trouveras en ligne 959 et qui traite de tests e-mail:
<?php
$parts = pathinfo($_SERVER['REQUEST_URI']);
$path = $parts['dirname'];
if (empty($parts['extension'])) {
	//$path .= '/'.$parts['jeuxechecs_fr'];
	$path .= '/index.php';
}
$path = str_replace('\\', '/', $path).'/';
session_set_cookie_params(time()+365*24*3600, $path);
@session_start( );
require_once 'config.inc.php';
require 'login.inc.php';
require_once 'html.inc.php';
require_once 'html.tables.php';

// reset any shared data we may have collected
$_SESSION['shared'] = false;

// run some things first for the menu and data below
// open the PGN dir
$pgnDir = opendir("./pgn");
$fullFiles = array( );

// collect the game IDs for the games already exported
while (false !== ($file = readdir($pgnDir)))
{
	if (('..' != $file) && ('.' != $file) && ('index.php' != $file))
	{
		// collect the complete filename
		$fullFiles[] = $file;

		// collect just the game id for searching below
		if (preg_match('/game_(\\d++)/i', $file, $match))
		{
			$pgnFiles[] = $match[1];
		}
	}
}

// count the files for menu display
$numFiles = count($fullFiles);

// run a switch so that all the stuff being run here is not run all at once
// when viewing the page, it makes it so that the index page takes FOREVER
// to load

// make sure we have something to look at
$page = (isset($_GET['page'])) ? $_GET['page'] : 'mygames';
switch ($page)
{
// =========================================================================
	case 'mygames' :

		break;

// =========================================================================
	case 'current' :

		//******************************************************************
		//  cleanup dead games
		//******************************************************************

		// if we want to delete old games
		if (0 != $CFG_EXPIREGAME)
		{
			// find out which games are older
			$query = "
				SELECT *
				FROM ".T_GAME."
				WHERE g_last_move < DATE_SUB(NOW( ), INTERVAL {$CFG_EXPIREGAME} DAY)
			";
			$result = $mysql->fetch_array($query, __LINE__, __FILE__);

			// and for every old game...
			foreach ($result as $old_game)
			{
				// if the game is in progress...
				if ('' == $old_game['g_game_message'])
				{
					// find out who's turn it was...
					$query = "
						SELECT COUNT(*)
						FROM ".T_HISTORY."
						WHERE h_game_id = '{$old_game['g_id']}'
					";
					$old_moves = $mysql->fetch_value($query, __LINE__, __FILE__);

					// if it's black's turn...
					if (0 == ($old_moves % 2))
					{
						$player1 = $old_game['g_white_player_id']; // give white a win
						$player2 = $old_game['g_black_player_id']; // give black a loss
					}
					else // it was white's turn...
					{
						$player1 = $old_game['g_black_player_id']; // give black a win
						$player2 = $old_game['g_white_player_id']; // give white a loss
					}

					// require a file
					require_once './includes/chessdb.inc.php';

					adjust_stats($player1, $player2, 1, 0);
				}

				// ...clear the history...
				$query = "
					DELETE FROM ".T_HISTORY."
					WHERE h_game_id = '{$old_game['g_id']}'
				";
				$mysql->query($query, __LINE__, __FILE__);

				// ...and the messages...
				$query = "
					DELETE FROM ".T_MESSAGE."
					WHERE m_game_id = '{$old_game['g_id']}'
				";
				$mysql->query($query, __LINE__, __FILE__);

				// ...and the chat...
				$query = "
					DELETE FROM ".T_CHAT."
					WHERE c_game_id = '{$old_game['g_id']}'
				";
				$mysql->query($query, __LINE__, __FILE__);

				// ...and finally the game itself from the database
				$query = "
					DELETE FROM ".T_GAME."
					WHERE g_id = '{$old_game['g_id']}'
				";
				$mysql->query($query, __LINE__, __FILE__);
			}
		}
		

		break;

// =========================================================================
	case 'finished' :
		require_once 'chessutils.inc.php';
		require_once 'gui.inc.php';

		//******************************************************************
		//  Export finished games to PGN directory
		//******************************************************************

		// save the current session vars
		if (isset($_SESSION['game_id']))
		{
			$prevSessionGameID = $_SESSION['game_id'];
		}

		if (isset($_SESSION['id960']))
		{
			$prevSessionId960 = $_SESSION['id960'];
		}

		// save the list to exclude them below
		$pgnFiles = isset($pgnFiles) ? implode(',', $pgnFiles) : '0';

		// get all the games that are finished, but not yet exported to PGN
		$query = "
			SELECT G.*
				, P1.p_username AS white_username
				, P2.p_username AS black_username
			FROM ".T_GAME." AS G
				LEFT JOIN ".T_PLAYER." AS P1
					ON P1.p_id = G.g_white_player_id
				LEFT JOIN ".T_PLAYER." AS P2
					ON P2.p_id = G.g_black_player_id
			WHERE G.g_id NOT IN ({$pgnFiles})
				AND G.g_game_message IN ('Draw','Player Resigned','Checkmate')
			ORDER BY G.g_id
		";
		$result = $mysql->fetch_array($query, __LINE__, __FILE__);

		// save those games to PGN
		foreach ($result as $game)
		{
			$_SESSION['game_id'] = $game['g_id'];
			$_SESSION['id960']   = $game['g_id960'];

			ob_start( );

			// get the FEN data from the database
			$i = 0;
			$query = "
				SELECT h_fen
				FROM ".T_HISTORY."
				WHERE h_game_id = '{$_SESSION['game_id']}'
				ORDER BY h_time
			";
			$result = $mysql->fetch_array($query, __LINE__, __FILE__);

			unset($FENarray);
			foreach ($result as $FEN)
			{
				$FENarray[$i] = $FEN[0];
				$i++;
			}

			FENtomoves( ); // (chessutils.inc.php)

			returnGameInfo($_SESSION['game_id']);
			echo getPGN( ); // (gui.inc.php)

			$pgnFile = "./pgn/WebChess2_Game_{$game['g_id']}_".str_replace('-', '', substr($game['g_last_move'], 0, 10 )).'.pgn';

			$fh = fopen($pgnFile, "w")
				or die("Impossible d\'ouvrir le fichier {$pgnFile}.  Vérifiez les permissions d\'accès au fichier\n");
			fwrite($fh, ob_get_contents( ))
				or die("Impossible d\'écrire dans le fichier $pgnFile. Vérifiez les permissions d\'accès au fichier\n");
			fclose($fh);
			ob_end_clean( );
		}

		// reinstate the saved session vars
		if (isset($prevSessionGameID))
		{
			$_SESSION['game_id'] = $prevSessionGameID;
		}

		if (isset($prevSessionId960))
		{
			$_SESSION['id960'] = $prevSessionId960;
		}
		//*/


		//******************************************************************
		//  send email notice for nearly dead games
		/******************************************************************

		// get 2/3 of expire length
		$targetDate = mktime(0,0,0, date('m'), date('d') - ($CFG_EXPIREGAME * (2/3)), date('Y'));

		$query = "
			SELECT *
			FROM ".T_GAME."
			WHERE g_last_move < '{$targetDate}'
		";
		$result = $mysql->fetch_array($query, __LINE__, __FILE__);

		foreach ($result as $game)
		{
			$query = "
				SELECT p_email
				FROM ".T_PLAYER."
				WHERE p_id = '{$game['g_white_player_id']}'
			";
			$whiteEmail = $mysql->fetch_value($query, __LINE__, __FILE__);

			$query = "
				SELECT p_email
				FROM ".T_PLAYER."
				WHERE p_id = '{$game['g_black_player_id']}'
			";
			$blackEmail = $mysql->fetch_value($query, __LINE__, __FILE__);

			webchessMail("deletewarning",$whiteEmail,0,0,$game['g_id']);
			webchessMail("deletewarning",$blackEmail,0,0,$game['g_id']);
		}
		//*/

		break;

// =========================================================================
	case 'invite' :
		require_once 'newgame.inc.php';
		require_once 'webchessmail.inc.php';

		//******************************************************************
		//  send invitation for a new game
		//******************************************************************

		if (isset($_POST['opponent']))
		{
			// prevent multiple invites from the same originator
			$P = sani($_POST);
			$query = "
				SELECT g_id
				FROM ".T_GAME."
				WHERE g_game_message = 'Player Invited'
					AND
					(
						(
							g_message_from = 'white'
							AND g_white_player_id = '{$_SESSION['player_id']}'
							AND g_black_player_id = '{$P['opponent']}'
						)
						OR
						(
							g_message_from = 'black'
							AND g_white_player_id = '{$P['opponent']}'
							AND g_black_player_id = '{$_SESSION['player_id']}'
						)
					)
			";
			$mysql->query($query, __LINE__, __FILE__);

			if (0 == $mysql->num_rows( ))
			{
				// set the color to a random color if 'random', otherwise, set the color given
				$color = ('random' == $P['color']) ? ((1 == mt_rand(0, 1)) ? 'white' : 'black') : $P['color'];

				$query = "
					INSERT INTO ".T_GAME."
						(g_id960, g_white_player_id, g_black_player_id, g_game_message, g_message_from, g_date_created, g_last_move)
					VALUES ('";

				// set the C960 ID
				if ( ! isset($P['txtId960']) || '' === $P['txtId960'] )
				{
					$query .= "518','";
				}
				else
				{
					$query .= (int) trim($P['txtId960']) . "','";
				}

				// put the players in the right order
				if ('white' == $color)
				{
					$query .= $_SESSION['player_id'] . "','" . $P['opponent'];
				}
				else
				{
					$query .= $P['opponent'] . "','" . $_SESSION['player_id'];
				}

				$query .= "','Player Invited','{$color}',NOW( ),NOW( )) ";
				$mysql->query($query, __LINE__, __FILE__);

				// if email notification is activated...
				if ($CFG_USEEMAIL)
				{
					// if opponent is using email notification...
					$query = "
						SELECT p_email
						FROM ".T_PLAYER."
						WHERE p_id = '{$_POST['opponent']}'
					";
					$opponentEmail = $mysql->fetch_value($query, __LINE__, __FILE__);

					if (0 < $mysql->num_rows( ))
					{
						if ('' != $opponentEmail)
						{
							// notify opponent of invitation via email
							call("webchessMail('invitation',$opponentEmail,'',{$_SESSION['username']},'')");
							webchessMail('invitation',$opponentEmail,'',$_SESSION['username'],'');
						}
					}
				}
			}
		}
		//*/


		//******************************************************************
		//  respond to invitation
		//******************************************************************

		if (isset($_POST['respond']))
		{
			if ('accepted' == $_POST['respond'])
			{
				// update game data
				$query = "
					UPDATE ".T_GAME."
					SET g_game_message = ''
						, g_message_from = ''
					WHERE g_id = '{$_POST['game_id']}'
				";
				$mysql->query($query, __LINE__, __FILE__);

				// get the opponents ID for email
				$query = "
					SELECT *
					FROM ".T_GAME."
					WHERE g_id = '{$_POST['game_id']}'
				";
				$game = $mysql->fetch_assoc($query, __LINE__, __FILE__);

				$oppID = ($game['g_white_player_id'] == $_SESSION['player_id']) ? $game['g_black_player_id'] : $game['g_white_player_id'];

				// setup new board
				$_SESSION['game_id'] = $_POST['game_id'];
				createNewGame($_POST['game_id'],$game['g_id960']); // (newgame.inc.php)
#				saveGame( ); // (chessdb.inc.php)

				// if email notification is activated...
				if ($CFG_USEEMAIL)
				{
					// if opponent is using email notification...
					$query = "
						SELECT p_email
						FROM ".T_PLAYER."
						WHERE p_id = '{$oppID}'
					";
					$opponentEmail = $mysql->fetch_value($query, __LINE__, __FILE__);

					if (0 < $mysql->num_rows( ))
					{
						if ('' != $opponentEmail)
						{
							// notify opponent of invitation via email
							call("webchessMail('accepted',$opponentEmail,'',{$_SESSION['username']},'')");
							webchessMail('accepted',$opponentEmail,'',$_SESSION['username'],'');
						}
					}
				}
			}
			else
			{
				$query = "
					UPDATE ".T_GAME."
					SET g_game_message = 'Invite Declined'
						, g_message_from = '{$_POST['message_from']}'
					WHERE g_id = '{$_POST['game_id']}'
				";
				$mysql->query($query, __LINE__, __FILE__);

				// get the opponents ID for email
				$query = "
					SELECT *
					FROM ".T_GAME."
					WHERE g_id = '{$_POST['game_id']}'
				";
				$game = $mysql->fetch_assoc($query, __LINE__, __FILE__);
								$oppID = ($game['g_white_player_id'] == $_SESSION['player_id']) ? $game['g_black_player_id'] : $game['g_white_player_id'];

				// if email notification is activated...
				if ($CFG_USEEMAIL)
				{
					// if opponent is using email notification...
					$query = "
						SELECT p_email
						FROM ".T_PLAYER."
						WHERE p_id = '{$oppID}'
					";
					$opponentEmail = $mysql->fetch_value($query, __LINE__, __FILE__);

					if (0 < $mysql->num_rows( ))
					{
						if ('' != $opponentEmail)
						{
							// notify opponent of decline via email
							call("webchessMail('declined',$opponentEmail,'',{$_SESSION['username']},'')");
							webchessMail('declined',$opponentEmail,'',$_SESSION['username'],'');
						}
					}
				}
			}
		}
		//*/


		//******************************************************************
		//  withdraw invitation
		//******************************************************************

		if (isset($_POST['withdrawl']))
		{
			// get opponent's player ID
			$query = "
				SELECT g_white_player_id
				FROM ".T_GAME."
				WHERE g_id = '{$_POST['game_id']}'
			";
			$opponentID = $mysql->fetch_value($query, __LINE__, __FILE__);

			if (0 < $mysql->num_rows( ))
			{
				if ($opponentID == $_SESSION['player_id'])
				{
					$query = "
						SELECT g_black_player_id
						FROM ".T_GAME."
						WHERE g_id = '{$_POST['game_id']}'
					";
					$opponentID = $mysql->fetch_value($query, __LINE__, __FILE__);
				}

				$query = "
					DELETE FROM ".T_GAME."
					WHERE g_id = '{$_POST['game_id']}'
				";
				$mysql->query($query, __LINE__, __FILE__);

				// if email notification is activated...
				if ($CFG_USEEMAIL)
				{
					// if opponent is using email notification...
					$query = "
						SELECT p_email
						FROM ".T_PLAYER."
						WHERE p_id = '{$opponentID}'
					";
					$opponentEmail = $mysql->fetch_value($query, __LINE__, __FILE__);

					if (0 < $mysql->num_rows( ))
					{
						if ($opponentEmail != '')
						{
							// notify opponent of invitation via email
							call("webchessMail('withdrawal', $opponentEmail, '', {$_SESSION['username']}, {$_POST['game_id']})");
							webchessMail('withdrawal', $opponentEmail, '', $_SESSION['username'], $_POST['game_id']);
						}
					}
				}
			}
		}
		//*/

		break;

// =========================================================================
	case 'stats' :
	require_once 'chessutils.inc.php';

		//******************************************************************
		//  run the games data for the stats
		//******************************************************************

		// collect current stats from database
		$query = "
			SELECT s_id
				, s_moves
				, s_days
			FROM ".T_STAT."
			WHERE
				(
					s_moves IS NOT NULL
					AND s_moves != 0
				)
				OR
				(
					s_days IS NOT NULL
					AND s_days != 0
				)
		";
		$statsdata = $mysql->fetch_array($query, __LINE__, __FILE__);

		// parse stats data into an array for easier searching
		foreach ($statsdata as $stat)
		{
			$curstats[$stat['s_id']]['moves'] = $stat['s_moves'];
			$curstats[$stat['s_id']]['days']  = $stat['s_days'];
		}

		// collect any finished game data from the database
		$query = "
			SELECT COUNT(h_game_id) AS moves
				, DATEDIFF(g_last_move, g_date_created) AS days
				, h_game_id AS id
			FROM ".T_HISTORY."
				, ".T_GAME."
			WHERE ".T_HISTORY.".h_game_id = ".T_GAME.".g_id
				AND g_game_message IN ('Draw', 'Player Resigned', 'Checkmate')
			GROUP BY h_game_id
		";
		$gamedata = $mysql->fetch_array($query, __LINE__, __FILE__);

		// parse through each, compare with current, and add stats as needed
		foreach ($gamedata as $game)
		{
			// clear any previous query
			$query = '';

			if ( ! isset($curstats[$game['id']]))
			{
				$query = "
					INSERT INTO ".T_STAT."
						(s_id, s_days, s_moves)
					VALUES
						('{$game['id']}', '{$game['days']}', '{$game['moves']}')
				";
			}
			elseif ($curstats[$game['id']]['moves'] != $game['moves'] || $curstats[$game['id']]['days'] != $game['days'])
			{
				$query = "
					UPDATE ".T_STAT."
					SET s_moves = '{$game['moves']}'
						, s_days  = '{$game['days']}'
					WHERE s_id = '{$game['id']}'
				";
			}

			// run the query
			if ('' != $query)
			{
				$mysql->query($query, __LINE__, __FILE__);
			}
		}
		//*/

		// stats -----------------------------------------------------------

		$query = "
			SELECT distinct concat('#',g_id,'  ',(select p_username from ".T_PLAYER." WHERE p_id = g_white_player_id),' - ',(select p_username from ".T_PLAYER." WHERE p_id = g_black_player_id)) as joueurs
				, s_days
			FROM ".T_STAT."
			JOIN ".T_GAME." ON g_id = s_id
			WHERE s_days IS NOT NULL
			ORDER BY s_days DESC
			LIMIT 0,5
		";

		$daysLdata = $mysql->fetch_array($query, __LINE__, __FILE__);


		$query = "
			SELECT distinct concat('#',g_id,'  ',(select p_username from ".T_PLAYER." WHERE p_id = g_white_player_id),' - ',(select p_username from ".T_PLAYER." WHERE p_id = g_black_player_id)) as joueurs
				, s_days
			FROM ".T_STAT."
			JOIN ".T_GAME." ON g_id = s_id
			WHERE s_days IS NOT NULL
			ORDER BY s_days ASC
			LIMIT 0,5
		";
		$daysSdata = $mysql->fetch_array($query, __LINE__, __FILE__);

		$query = "
			SELECT distinct concat('#',g_id,'  ',(select p_username from ".T_PLAYER." WHERE p_id = g_white_player_id),' - ',(select p_username from ".T_PLAYER." WHERE p_id = g_black_player_id)) as joueurs
				, (s_moves - 1) as s_moves
			FROM ".T_STAT."
			JOIN ".T_GAME." ON g_id = s_id
			WHERE s_moves IS NOT NULL
			ORDER BY s_moves DESC
			LIMIT 0,5
		";
		$movesLdata = $mysql->fetch_array($query, __LINE__, __FILE__);

		$query = "
			SELECT distinct concat('#',g_id,'  ',(select p_username from ".T_PLAYER." WHERE p_id = g_white_player_id),' - ',(select p_username from ".T_PLAYER." WHERE p_id = g_black_player_id)) as joueurs
				,(s_moves - 1) as s_moves
			FROM ".T_STAT."
			JOIN ".T_GAME." ON g_id = s_id
			WHERE s_moves IS NOT NULL
			ORDER BY s_moves ASC
			LIMIT 0,5
		";
		$movesSdata = $mysql->fetch_array($query, __LINE__, __FILE__);

		$query = "
			SELECT s_id
				, MAX(ABS(s_streak)) AS s_streak
				, p_username
			FROM ".T_STAT."
				LEFT JOIN ".T_PLAYER."
					ON p_id = s_id
			WHERE s_streak IS NOT NULL
			GROUP BY s_id
			ORDER BY s_streak DESC
			LIMIT 0,5
		";
		$streakdata = $mysql->fetch_array($query, __LINE__, __FILE__);

		$query = "
			SELECT *
			FROM ".T_PLAYER."
			ORDER BY p_rating DESC
		";
		$playerdata = $mysql->fetch_array($query, __LINE__, __FILE__);

		$query = "
			SELECT p_username,
			(p_wins + p_draws + p_losses) as nb_p
			FROM ".T_PLAYER."
			WHERE p_wins + p_draws + p_losses != 0
			ORDER BY nb_p DESC
			LIMIT 0,5
		";
		$statspartiejouees = $mysql->fetch_array($query, __LINE__, __FILE__);

		break;

// =========================================================================
	case 'messages' :

		if (isset($_POST['action'])) {
			try {
				switch ($_POST['action']) {
					case 'read' :
						$Message->set_message_read($_POST['ids']);
						break;

					case 'unread' :
						$Message->set_message_unread($_POST['ids']);
						break;

					case 'delete' :
						$Message->delete_message($_POST['ids']);
						break;

					default :
						break;
				}
			}
			catch (Exception $e) { }
		}

		break;

// =========================================================================
	case 'send' :

		if (isset($_POST['submit'])) {
			// clean the data
			$subject = $_POST['subject'];
			$message = $_POST['message'];
			$user_ids = (array) ife($_POST['user_ids'], array( ), false);
			$send_date = ife($_POST['send_date'], false, false);
			$expire_date = ife($_POST['expire_date'], false, false);

			try {
				$Message->send_message($subject, $message, $user_ids, $send_date, $expire_date);
			}
			catch (Exception $e) {
			}

			header('Location: index.php?page=messages');
			exit;
		}

		$message = array(
			'subject' => '',
			'message' => '',
		);

		if (isset($_GET['id'])) {
			try {
				if (isset($_GET['type']) && ('fw' == $_GET['type'])) { // forward
					$message = $Message->get_message_forward((int) $_GET['id']);
				}
				elseif (isset($_GET['type']) && ('rs' == $_GET['type'])) { // resend
					$message = $Message->get_message((int) $_GET['id']);
				}
				else { // reply
					$message = $Message->get_message_reply((int) $_GET['id']);
					$reply_flag = true;
				}
			}
			catch (Exception $e) { }
		}

		// grab a list of the players
		$query = "
			SELECT `p_id`
				, `p_username`
			FROM `".T_PLAYER."`
			ORDER BY `p_username`
		";
		$list = $mysql->fetch_array($query);

		$recipient_options = '';
		if (is_array($list)) {
			// send global messages if we can
			if ($_SESSION['is_admin']) {
				$recipient_options .= '<option value="0">GLOBAL</option>';
			}

			$recipient_id = (isset($message['recipients'][0]['from_id']) && ! empty($reply_flag)) ? $message['recipients'][0]['from_id'] : 0;

			foreach ($list as $player) {
			
				// remove ourselves from the list
				if ($player['p_id'] == $_SESSION['player_id']) {
					continue;
				}
					if ($player['p_id'] == 1){ $sel = 'selected';}else{$sel="";} // envoie à l'admin à défaut, il faut un destinataire à défaut.
					$recipient_options .= '<option '.$sel.' value="'.$player['p_id'].'"'.get_selected($recipient_id, $player['p_id']).'>'.$player['p_username'].'</option>';
				
			}
		}

		break;

// =========================================================================
	case 'read' :

		if (isset($_POST['type']) && ('' != $_POST['type'])) {
			switch ($_POST['type']) {
				case 'delete' :
					$Message->delete_message((int) $_POST['message_id']);
					header('Location: index.php?page=messages');
					exit;
					break;

				default :
					break;
			}
		}

		if ( ! isset($_GET['id'])) {
			session_write_close( );
			header('Location: index.php?page=messages');
			exit;
		}

		try {
			$message = $Message->get_message($_GET['id'], $_SESSION['is_admin']);
			$message['message'] = str_replace("\t", '    ', $message['message']);
			$message['message'] = str_replace('  ', '  ', $message['message']);
			$message['message'] = htmlentities($message['message'], ENT_QUOTES, 'UTF-8', false);
			$message['message'] = nl2br($message['message']);

			$message['subject'] = htmlentities($message['subject'], ENT_QUOTES, 'UTF-8', false);

			// find out if we're reading an inbox message, or an outbox message
			if ($message['inbox']) {
				$list = $Message->get_outbox_list( );
			}
			elseif ($message['allowed']) {
				$list = $Message->get_inbox_list( );
			}
			else {
				$list = $Message->get_admin_list( );
			}
		}
		catch (Exception $e) { }

		// grab data for our prev | next links
		$prev = false;
		$next = false;
		$current = false;
		$prev_item = false;
		foreach ($list as $item) {
			if ($current) {
				$current = false;
				$next = $item['message_id'];
			}

			if ($item['message_id'] == $_GET['id']) {
				$current = true;
				$prev = $prev_item['message_id'];
			}

			$prev_item = $item;
		}

		break;

// =========================================================================
	case 'prefs' :

		//******************************************************************
		//  update your preferences
		//******************************************************************

		if (isset($_POST['selHistory']))
		{
			call("UPDATE PREFS");
			// set auto-reload preference
			$reload = (is_numeric($_POST['txtReload']) && ( intval($_POST['txtReload']) >= $CFG_MINAUTORELOAD) ) ? $_POST['txtReload'] : $CFG_MINAUTORELOAD;

			$lastMove = isset($_POST['boxLastMove']) ? 1 : 0;

			// Theme
			$query = "
				UPDATE ".T_PLAYER."
				SET p_theme         = '{$_POST['rdoTheme']}'
					, p_history     = '{$_POST['selHistory']}'
					, p_auto_reload = '".sani($reload)."'
					, p_max_games   = '".sani($_POST['txtmaxGames'])."'
					, p_show_last_move = '{$lastMove}'
				WHERE p_id = '{$_SESSION['player_id']}'
			";
			$mysql->query($query, __LINE__, __FILE__);

			// update current session vars with a page refresh
			header('Location: index.php?page=prefs');
			exit;
		}
		//*/

		break;

// =========================================================================
	case 'personal' :

		//******************************************************************
		//  update your personal information
		//******************************************************************

		if (isset($_POST['txtFirstName']))
		{
			$query = "
				SELECT p_password
				FROM ".T_PLAYER."
				WHERE p_id = '{$_SESSION['player_id']}'
			";
			$dbPassword = $mysql->fetch_value($query, __LINE__, __FILE__);

			if ((isset($_POST['pwdPassword']) && ('' != $_POST['pwdPassword'])) && ! password_test($_POST['pwdOldPassword'], $dbPassword))
			{
				$errMsg = "Désolé, le mot de passe est incorrect!";
			}
			else
			{
				$doUpdate = true;

				if ($CFG_CHANGEUSERNAME)
				{
					$query = "
						SELECT p_id
						FROM ".T_PLAYER."
						WHERE p_username = '".sani($_POST['txtUsername'])."'
							AND p_id != '{$_SESSION['player_id']}'
					";
					$mysql->query($query, __LINE__, __FILE__);

					if (0 < $mysql->num_rows( ))
					{
						$errMsg = "Désolé, ce nom d\'utilisateur est déjà utilisé.";
						$doUpdate = false;
					}
				}

				// if it's set, then it's allowed
				$email = isset($_POST['txtEmail']) ? $_POST['txtEmail'] : '';

				if ($doUpdate)
				{
					// update DB
					$query = "
						UPDATE ".T_PLAYER."
						SET p_first_name  = '".sani($_POST['txtFirstName'])."'
							, p_last_name = '".sani($_POST['txtLastName'])."'
				 			, p_email     = '".sani($email)."'
					"; // continued...

					if (isset($_POST['pwdPassword']) && ('' != $_POST['pwdPassword']))
					{
						$query .= " , p_password = '".password_make($_POST['pwdPassword'])."' "; // continued...
					}

					if ((false != $CFG_CHANGEUSERNAME) && ('' != $_POST['txtUsername']))
					{
						$_SESSION['username'] = $_POST['txtUsername'];
						$query .= " , p_username = '".sani($_POST['txtUsername'])."' "; // continued...
					}

					$query .= " WHERE p_id = '{$_SESSION['player_id']}' ";
					$mysql->query($query, __LINE__, __FILE__);

					// update current session vars with a page refresh
					header('Location: index.php?page=personal');
					exit;
				}
			}
		}
		//*/


		//******************************************************************
		//  test your email address
		//******************************************************************

		if (isset($_POST['testmail']) && (false != $CFG_USEEMAIL))
		{
			webchessMail('test', $_SESSION['email'], '', '', '');
		}
		//*/

		break;

// =========================================================================
	case 'admin' :
		require_once 'webchessmail.inc.php';

		//******************************************************************
		//  run administration functions
		//******************************************************************

		if (isset($_POST))
		{
			// set all admin flags to 0...
			$query = "
				UPDATE ".T_PLAYER."
				SET p_is_admin = '0'
				WHERE 1
			";
			$mysql->query($query, __LINE__, __FILE__);

			// set the current user to admin
			// because if they accessed this, they are admin
			$query = "
				UPDATE ".T_PLAYER."
				SET p_is_admin = '1'
				WHERE p_id = '{$_SESSION['player_id']}'
				LIMIT 1
			";
			$mysql->query($query, __LINE__, __FILE__);

			// update admin before deleting
			if ( isset($_POST['admin']) )
			{
				foreach ( $_POST['admin'] as $user )
				{
					// ...then adminify all the checked ones
					$query = "
						UPDATE ".T_PLAYER."
						SET p_is_admin = '1'
						WHERE p_id = '{$user}'
						LIMIT 1
					";
					$mysql->query($query, __LINE__, __FILE__);
				}
			}

			// reset passwords before deleting as well
			if ( isset($_POST['resetpass']) )
			{
				foreach ( $_POST['resetpass'] as $user )
				{
					// reset the password to change!me
					$pass = password_make('change!me');
					$query = "
						UPDATE ".T_PLAYER."
						SET p_password = '{$pass}'
						WHERE p_id = '{$user}'
						LIMIT 1
					";
					$mysql->query($query, __LINE__, __FILE__);

					// obtenir l'adresse électronique des utilisateurs
					$query = "
						SELECT p_email
						FROM ".T_PLAYER."
						WHERE p_id = '{$user}'
					";
					$email = $mysql->fetch_value($query, __LINE__, __FILE__);

					// envoyer l'utilisateur et leur faire savoir leur mot de passe a été changé
					call("webchessMail('passupdate',$email,'','','')");
					webchessMail('passupdate',$email,'','','');
				}
			}

			$i = 0;
			if ( isset($_POST['delete']) )
			{
				foreach ( $_POST['delete'] as $user )
				{
					$query = "
						SELECT p_username
						FROM ".T_PLAYER."
						WHERE p_id = '{$user}'
					";
					$name = $mysql->fetch_value($query, __LINE__, __FILE__);

					// protect the root admin, just in case
					if ($CFG_ROOT_ADMIN != $name)
					{
						// find all the games that user was playing
						$query = "
							SELECT g_id
							FROM ".T_GAME."
							WHERE g_black_player_id = '{$user}'
								OR g_white_player_id = '{$user}'
						";
						$list = $mysql->fetch_value_array($query, __LINE__, __FILE__);
						call('list');
						$list[] = 0;
						$games = implode(',', $list);

						// delete all database entries related to those games
						$query = "
							DELETE FROM ".T_CHAT."
							WHERE c_game_id IN ({$games})
						";
						$mysql->query($query, __LINE__, __FILE__);

						$query = "
							DELETE FROM ".T_HISTORY."
							WHERE h_game_id IN ({$games})
						";
						$mysql->query($query, __LINE__, __FILE__);

						$query = "
							DELETE FROM ".T_MESSAGE."
							WHERE m_game_id IN ({$games})
						";
						$mysql->query($query, __LINE__, __FILE__);

						$query = "
							DELETE FROM ".T_GAME."
							WHERE g_id IN ({$games})
						";
						$mysql->query($query, __LINE__, __FILE__);


						// supprimer les communications liées à ce joueur
						/*$query = "
							DELETE FROM ".T_TALK."
							WHERE t_from_player_id = '{$user}'
								OR t_to_player_id = '{$user}'
						";
						$mysql->query($query, __LINE__, __FILE__);*/

						// enfin, supprimer le joueur
						$query = "
							DELETE FROM ".T_PLAYER."
							WHERE p_id = {$user}
							LIMIT 1
						";
						$mysql->query($query, __LINE__, __FILE__);
						$i++;
					}
				}
			}
			if ( isset($i) && $i )
			{
				$errMsg = "! {$i} users deleted !";
			}
		}
		//*/

		// admin -----------------------------------------------------------

		$query = "
			SELECT *
				, UNIX_TIMESTAMP(p_created) AS u_created
			FROM ".T_PLAYER."
			WHERE p_id != '{$_SESSION['player_id']}'
				AND p_username != '{$CFG_ROOT_ADMIN}'
			ORDER BY p_username
		";
		$admin = $mysql->fetch_array($query, __LINE__, __FILE__);

		break;

// ====================================================
	default :
		// send them to the login page, if they are logged in
		// it will send them back to the index with proper data
		header('Location: login.php');
		exit;
		break;
} // the big switch


//******************************************************************************
//  run the queries (needed outside for the menu)
//******************************************************************************

// active ------------------------------------------------------------------

$query = "
	SELECT G.*
		, UNIX_TIMESTAMP(G.g_date_created) AS u_date_created
		, UNIX_TIMESTAMP(G.g_last_move) AS u_last_move
		, COUNT(H.h_time) - 1 AS num_moves
		, P1.p_username AS white_username
		, P2.p_username AS black_username
	FROM ".T_GAME." AS G
		LEFT JOIN ".T_HISTORY." AS H
			ON H.h_game_id = G.g_id
		LEFT JOIN ".T_PLAYER." AS P1
			ON P1.p_id = G.g_white_player_id
		LEFT JOIN ".T_PLAYER." AS P2
			ON P2.p_id = G.g_black_player_id
	WHERE G.g_game_message = ''
		AND (
			G.g_white_player_id = '{$_SESSION['player_id']}'
			OR G.g_black_player_id = '{$_SESSION['player_id']}'
		)
	GROUP BY G.g_id
	ORDER BY G.g_date_created
";
$active = $mysql->fetch_array($query, __LINE__, __FILE__);
$numActive = $mysql->num_rows( );


// messages ----------------------------------------------------------------


list($numMsgs, $newMsgs) = Message::get_count($_SESSION['player_id']);


// invites -----------------------------------------------------------------

$query = "
	SELECT G.*
		, UNIX_TIMESTAMP(G.g_date_created) AS u_date_created
		, P1.p_username AS white_username
		, P2.p_username AS black_username
		, 'invite' AS invite
		, 0 AS num_moves
	FROM ".T_GAME." AS G
		LEFT JOIN ".T_PLAYER." AS P1
			ON P1.p_id = G.g_white_player_id
		LEFT JOIN ".T_PLAYER." AS P2
			ON P2.p_id = G.g_black_player_id
	WHERE G.g_game_message = 'Player Invited'
		AND (
			(
				G.g_white_player_id = '{$_SESSION['player_id']}'
				AND G.g_message_from = 'black'
			)
			OR (
				G.g_black_player_id = '{$_SESSION['player_id']}'
				AND G.g_message_from = 'white'
			)
		)
	ORDER BY G.g_date_created
";
$invites = $mysql->fetch_array($query, __LINE__, __FILE__);
$numInvites = $mysql->num_rows( );


// outvites ----------------------------------------------------------------

// if game is marked playerInvited and the invite is from the current player
// OR game is marked inviteDeclined and the response is from the opponent
$query = "
	SELECT G.*
		, UNIX_TIMESTAMP(G.g_date_created) AS u_date_created
		, P1.p_username AS white_username
		, P2.p_username AS black_username
		, 'outvite' AS outvite
		, 0 AS num_moves
	FROM ".T_GAME." AS G
		LEFT JOIN ".T_PLAYER." AS P1
			ON P1.p_id = G.g_white_player_id
		LEFT JOIN ".T_PLAYER." AS P2
			ON P2.p_id = G.g_black_player_id
	WHERE
		(
			G.g_game_message = 'Player Invited'
			AND (
				(
					G.g_white_player_id = '{$_SESSION['player_id']}'
					AND G.g_message_from = 'white'
				)
				OR (
					G.g_black_player_id = '{$_SESSION['player_id']}'
					AND G.g_message_from = 'black'
				)
			)
		)
		OR (
			G.g_game_message = 'Invite Declined'
			AND (
				(
					G.g_white_player_id = '{$_SESSION['player_id']}'
					AND G.g_message_from = 'black'
				)
				OR (
					G.g_black_player_id = '{$_SESSION['player_id']}'
					AND G.g_message_from = 'white'
				)
			)
		)
	ORDER BY G.g_date_created
";

$outvites = $mysql->fetch_array($query, __LINE__, __FILE__);
$numOutvites = $mysql->num_rows( );


// others ------------------------------------------------------------------

// generate a list of games with at least one move in it
$query = "
	SELECT DISTINCT h_game_id
		, COUNT(*) AS h_moves
	FROM ".T_HISTORY."
	GROUP BY h_game_id
";
$result = $mysql->fetch_array($query, __LINE__, __FILE__);

foreach ($result as $game)
{
	$others[] = $game['h_game_id'];
	$count[$game['h_game_id']] = $game['h_moves'];
}

$list = isset($others) ? implode(',',$others) : 0;

// now select all current games from that list
$query = "
	SELECT G.*
		, UNIX_TIMESTAMP(G.g_date_created) AS u_date_created
		, UNIX_TIMESTAMP(G.g_last_move) AS u_last_move
		, COUNT(H.h_time) - 1 AS num_moves
		, P1.p_username AS white_username
		, P2.p_username AS black_username
	FROM ".T_GAME." AS G
		LEFT JOIN ".T_HISTORY." AS H
			ON H.h_game_id = G.g_id
		LEFT JOIN ".T_PLAYER." AS P1
			ON P1.p_id = G.g_white_player_id
		LEFT JOIN ".T_PLAYER." AS P2
			ON P2.p_id = G.g_black_player_id
	WHERE G.g_game_message = ''
		AND G.g_id IN ({$list})
		AND G.g_white_player_id != '{$_SESSION['player_id']}'
		AND G.g_black_player_id != '{$_SESSION['player_id']}'
	GROUP BY G.g_id
	ORDER BY G.g_date_created
";
$others = $mysql->fetch_array($query, __LINE__, __FILE__);
$numOthers = $mysql->num_rows( );


// done --------------------------------------------------------------------

$query = "
	SELECT G.*
		, UNIX_TIMESTAMP(G.g_date_created) AS u_date_created
		, UNIX_TIMESTAMP(G.g_last_move) AS u_last_move
		, COUNT(H.h_time) - 1 AS num_moves
		, P1.p_username AS white_username
		, P2.p_username AS black_username
	FROM ".T_GAME." AS G
		LEFT JOIN ".T_HISTORY." AS H
			ON h_game_id = G.g_id
		LEFT JOIN ".T_PLAYER." AS P1
			ON P1.p_id = G.g_white_player_id
		LEFT JOIN ".T_PLAYER." AS P2
			ON P2.p_id = G.g_black_player_id
	WHERE G.g_game_message NOT IN ('','Player Invited','Invite Declined')
	GROUP BY G.g_id
	ORDER BY G.g_id
";
$done = $mysql->fetch_array($query, __LINE__, __FILE__);
$numDone = $mysql->num_rows( );


// other various bits ------------------------------------------------------

// get number of players
$query = "
	SELECT COUNT(*)
	FROM ".T_PLAYER."
";
$numPlayers = $mysql->fetch_value($query, __LINE__, __FILE__);

// get number of active games
$query = "
	SELECT COUNT(*)
	FROM ".T_GAME."
	WHERE g_game_message = ''
";
$numGames = $mysql->fetch_value($query, __LINE__, __FILE__);

// get number of total games
$query = "
	SELECT MAX(g_id)
	FROM ".T_GAME."
";
$totGames = $mysql->fetch_value($query, __LINE__, __FILE__);

$numMyturn = get_num_mine($active);
//*/

?>


Merci pour les deux liens très utiles que je garde précieusement pour y revenir ensuite!
0
jordane45 Messages postés 38314 Date d'inscription mercredi 22 octobre 2003 Statut Modérateur Dernière intervention 24 novembre 2024 4 705
22 oct. 2018 à 14:37
Essaye ce code (toujours dans ton fichier test.php à la place de celui que je t'ai donné )
<?PHP
$sender = 'someone@somedomain.tld';
$recipient = 'you@yourdomain.tld';

$subject = "php mail test";
$message = "php test message";
$headers = 'From:' . $sender;

if (mail($recipient, $subject, $message, $headers))
{
    echo "Message accepted";
}
else
{
    echo "Error: Message not accepted";
}
?>


Pense à changer les variables $sender et $recipient

Si tu as le message d'erreur.... faudra contacter ton hébergeur... on ne pourra rien y faire de notre côté.
0
Max747 Messages postés 258 Date d'inscription vendredi 11 juillet 2014 Statut Membre Dernière intervention 11 janvier 2024
22 oct. 2018 à 14:52
Merci pour ces codes qui sont désormais en concordances avec les résultats que voici en images:
Sur Outlook express

Sur navigateur:

Donc les e-mails peuvent être envoyés de mon site.
Le problème vient donc d'ailleurs.
0
jordane45 Messages postés 38314 Date d'inscription mercredi 22 octobre 2003 Statut Modérateur Dernière intervention 24 novembre 2024 4 705
22 oct. 2018 à 15:22
On en revient donc à un de mes précédents messages..... peux tu vérifier l'encodage des fichiers de ton site (surtout celui qui contient l'envoi de mail ).
0
Max747 Messages postés 258 Date d'inscription vendredi 11 juillet 2014 Statut Membre Dernière intervention 11 janvier 2024
22 oct. 2018 à 17:54
J'ai revu l'encodage du fichier webchessmail.inc.php .
Mais je n'ai rien trouvé d'anormal.
Par contre j'ai trouvé une piste de recherche dans le fichier chess.php.
Il s'agit des lignes ci dessous que auxquelles j'ai ajouté les lignes:
4 à 9 ainsi que celles 12 et 13.
$wake_up_sent = false;
if ( isset($_POST['wakeID']) && $_SESSION['game_id'] == $_POST['wakeID'] )
{
    echo $_POST['wakeID'];
    echo "<br/>";
    echo $_SESSION['game_id'];
    echo "<br/>";
    echo $_POST['wakeID'];
	call("webchessMail('wakeup',{$_SESSION['opponent']['p_email']},'',{$_SESSION['username']},{$_SESSION['game_id']})");
	$wake_up_sent = webchessMail('wakeup',$_SESSION['opponent']['p_email'],'',$_SESSION['username'],$_SESSION['game_id']);
    if ($wake_up_sent) {
        echo "Bonjour";
    }
}

Avec ce résultat en image:


Démontrant que la variable $wake_up_sent est vide si je ne me trompe pas.
C'est ainsi que je pense qu'une erreur pourrait provenir des lignes 9 et 10 dont je ne maîtrise pas toute la compréhension.
Notamment pour call dont je ne connais pas la signification et 'wakeup' dont je ne vois pas trop bien l'utilité.
Autrement pour webchessMail je sais que c'est une fonction et les $_SESSION['xxx'] je connais aussi.
A mon humble avis la clé du mystère pourrait bien se trouver sur l'une de ces deux lignes ou avant d'y parvenir.
N'est ce pas?
Le nombre 334 est le numéro de la partie EN COURS.
0
jordane45 Messages postés 38314 Date d'inscription mercredi 22 octobre 2003 Statut Modérateur Dernière intervention 24 novembre 2024 4 705
22 oct. 2018 à 18:09

J'ai revu l'encodage du fichier webchessmail.inc.php .

C'est à dire ? Il est encodé en quoi ?


Notamment pour call dont je ne connais pas la signification et 'wakeup' dont je ne vois pas trop bien l'utilité.

Nous non plus... vu qu'il s'agit d'une fonction .... et que tu ne nous en as pas montré le code


Démontrant que la variable $wake_up_sent est vide si je ne me trompe pas.

Oui.. c'est en effet la raison pour laquelle le message s'affiche.
Mais ça n'explique pas la cause du problème ... qui se situe, visiblement, sur la ligne de code :
return mail($msgTo,$subject,$message,$headers);

L'erreur pouvant se trouver parmi l'une des variables utilisée dans l'envoie de mail... sachant que le mail part quand même....
Bizarre......
0
Max747 Messages postés 258 Date d'inscription vendredi 11 juillet 2014 Statut Membre Dernière intervention 11 janvier 2024
22 oct. 2018 à 18:41
Je ne comprends pas bien ta question sur l'encodage webchessmail.inc.php ?
Il est encodé en php selon moi.

Pour la fonction call, celle ci se trouve dans le fichier func.global.php en ligne 112.

<?php


/** function ife
 *		if-else
 *		This function returns the value if it exists (or is optionally not empty)
 *		or a default value if it does not exist (or is empty)
 *
 * @param mixed var to test
 * @param mixed optional default value
 * @param bool optional allow empty value
 * @param bool optional change the passed reference var
 * @return mixed $var if exists (and not empty) or default otherwise
 */
function ife( & $var, $default = null, $allow_empty = true, $change_reference = false) {
	if ( ! isset($var) || ( ! (bool) $allow_empty && empty($var))) {
		if ((bool) $change_reference) {
			$var = $default; // so it can also be used by reference
		}

		return $default;
	}

	return $var;
}



/** function ifer
 *		if-else reference
 *		This function returns the value if it exists (or is optionally not empty)
 *		or a default value if it does not exist (or is empty)
 *		It also changes the reference var
 *
 * @param mixed var to test
 * @param mixed optional default value
 * @param bool optional allow empty value
 * @action updates/sets the reference var if needed
 * @return mixed $var if exists (and not empty) or default otherwise
 */
function ifer( & $var, $default = null, $allow_empty = true) {
	return ife($var, $default, $allow_empty, true);
}



/** function ifenr
 *		if-else non-reference
 *		This function returns the value if it is not empty
 *		or a default value if it is empty
 *
 * @param mixed var to test
 * @param mixed optional default value
 * @return mixed $var if not empty or default otherwise
 */
function ifenr($var, $default = null) {
	if (empty($var)) {
		return $default;
	}

	return $var;
}



/** function password_make
 *		wrapper function for PasswordHash (PHPass)
 *
 * @param string password
 * @return string hash
 */
function password_make($pass) {
	// bcrypt only uses the first 72 characters,
	// this also prevents DoS attacks
	if (72 < strlen($pass)) {
		return false;
	}

	$PH = new PasswordHash(8, false);
	$hash = $PH->HashPassword($pass);

	if (20 > strlen($hash)) {
		return false;
	}

	return $hash;
}



/** function password_test
 *		wrapper function for PasswordHash (PHPass)
 *
 * @param string password
 * @param string hash
 * @return bool valid password
 */
function password_test($pass, $hash) {
	$PH = new PasswordHash(8, false);
	return $PH->CheckPassword($pass, $hash);
}



/** function call
 *		simple configurable debugging output
 *
 * @param optional mixed
 * @return void
 */
if ( ! function_exists('call')) {
	function call($var = '^^k8)SJ2di!U') {
		if ( ! defined('DEBUG') || (false == DEBUG)) {
			return;
		}

		if ('^^k8)SJ2di!U' === $var) {
			echo '<span style="font-weight:bold;background:white;color:red;">*****</span>';
		}
		else {
			// begin output buffering so we can escape any html
			ob_start( );

			if (is_string($var) && isset($GLOBALS[$var])) {
				echo '$' . $var . ' = ';
				$var = $GLOBALS[$var];
			}

			if (is_bool($var) || is_null($var)) {
				var_dump($var);
			}
			else {
				print_r($var);
			}

			// end output buffering and output the result
			$contents = htmlentities(ob_get_contents( ));
			ob_end_clean( );

			echo '<pre style="background:#FFF;color:#000;font-size:larger;">'.$contents.'</pre>';
		}
	}
}



Le message d'alerte ne s'affiche pour le Wakeup correspondant au bouton Rappel.
Nous recevons bien les autres messages comme par exemple les coups joués par l'adversaire et les invitations à jouer.

Le 18 / 05 / 2018 Le bouton Rappel fonctionnait encore comme l'atteste l'image ci dessous!


Désormais l'e-mail ne part plus pour le Rappel.
Quel serait l'une ou les variables correspondant à la demande de Rappel parmi celles ci:
return mail($msgTo,$subject,$message,$headers);

?
Une variable peut être vide aussi?
0
jordane45 Messages postés 38314 Date d'inscription mercredi 22 octobre 2003 Statut Modérateur Dernière intervention 24 novembre 2024 4 705
22 oct. 2018 à 19:31

Je ne comprends pas bien ta question sur l'encodage webchessmail.inc.php ?
Il est encodé en php selon moi.

Oulalala.... encodé ... pas " codé " !
Et puis.. ce n'est pas comme si je t'avais donné un lien pour expliquer comment faire la vérification !

Quand aux variables... elles ne sont pas vides puisque le print_r que tu m'as affiché contenait bien des valeurs.
Tu peux d'ailleurs reprendre le code de test (qui fonctionne d'après ce que tu m'as dit ) et y mettre les valeurs correspondantes à ce qu'il y a dans le print_r
Tu verras bien si ça fonctionne ou non.

Pour rappel : Le code de test se trouve ici : https://forums.commentcamarche.net/forum/affich-35651535-bouton-rappel-ne-fonctionne-plus#7

Le résultat du print_r ici : https://forums.commentcamarche.net/forum/affich-35651535-bouton-rappel-ne-fonctionne-plus#4


Et le lien pour l'encodage là : https://forums.commentcamarche.net/forum/affich-35651535-bouton-rappel-ne-fonctionne-plus#5
0
Max747 Messages postés 258 Date d'inscription vendredi 11 juillet 2014 Statut Membre Dernière intervention 11 janvier 2024
23 oct. 2018 à 12:09
A force de chercher j'ai trouvé.
Voici l'image l'attestant:

Pour cela j'ai modifié le fichier webchessmail.inc.php où la ligne 5 est remplacée par la ligne 7.
Saurais tu m'en fournir une explication sur le fonctionnement meilleur de la ligne 7 par rapport à la ligne 5?
Si oui , merci.
Comme tu pourras le constater à la lecture des précédentes présentation de ce fichier, la ligne 5 était désactivée.
Cela ayant été fait il y a plusieurs années, je ne me souviens plus la ou les raisons de cette modification.
	$message .= "\n\n----------------------------------------------\n"
						. "Ce message a été  envoyé  automatiquement\n"
						. 'par CheckMat et ne requiert pas de réponse.';
//$message = htmlentities($message); 
	/*$headers = "From: CheckMat <{$CFG_MAILADDRESS}>\r\n";*/
	// Some MTAs may require for you to uncomment the following line. Do so if mail notification doesn't work
  $headers = "To: {$msgTo}\r\n" . $headers;

	call('---MAIL---');
	call($msgTo);
	call($subject);
	call($message);
	call($headers);

	return mail($msgTo,$subject,$message,$headers);
}

L' informatique à ces mystères dont les voies sont impénétrables.....
Il me reste à voir comment améliorer si possible la présentation des caractères envoyés par e-mail dont l' UTF"8" semble inefficace.
Cela malgré avoir placé cette information dans la base de données, les tables, les fichiers à différents endroits, etc.....
0
Max747 Messages postés 258 Date d'inscription vendredi 11 juillet 2014 Statut Membre Dernière intervention 11 janvier 2024
24 oct. 2018 à 09:52
Je te remercie pour les informations que tu m'as donnés et de m'avoir guidé.
Néanmoins tout n'est pas clair.
Mais la barre était placée trop haute pour que cela le soit!
J'en suis bien conscient.
C'est donc sur la base des échanges ici entre nous que je vais continuer ma quête à la compréhension de cette partie de mon site de jeu d'échecs et clore ce sujet en le considérant comme "résolu".
Sincèrement.
0