Phjoe
Usuario Novato
Usuario Novato

Hola, tengo una pagina web con el modulo de ajedrez CompWebChess
que da error al ejecutar javascript (al intentar mover las piezas).
Lo curioso es que en mi pc, en modo local, si que me funciona.
Hay que tener algo en cuenta al subir los ficheros a miarroba en
el caso de javascript ?

La pagina es http://lacolmena.webcindario.com

Gracias.

Avatar Image
@man / @woman
@man / @woman


Casi puedo apostar a que, o falto algun archivo adicional (alguna imagen, algun archivo con funciones adicionales .js) o algo no quedo bien puesto en el codigo.

Tal vez si pusieras el error que te da se podria ayudar mejor

Phjoe
Usuario Novato
Usuario Novato

Al cargar la pagina me da los siguientes errores:

Linea: 2
Car: 1
Error: Error de sintaxis
Codigo: 0
Url: https://lacolmena.webcindario.com/chess.php

Linea: 66
Car: 1
Error: Se requiere un objeto
Codigo: 0
Url: https://lacolmena.webcindario.com/chess.php

Linea: 302
Car: 5
Error: Se esperaba un objeto
Codigo: 0
Url: https://lacolmena.webcindario.com/chess.php


chess.php
---------
<?
session_start();

/* load settings */
if (!isset($_CONFIG))
require 'configChess.php';

require('ob.lib.php');
if ($COMPRESSION) {
$ob_mode = PMA_outBufferModeGet();
if ($ob_mode) {
PMA_outBufferPre($ob_mode);
}
}


/* define constants */
require 'chessconstants.php';

/* include outside functions */
if (!isset($_CHESSUTILS))
require 'chessutils.php';
require 'gui.php';
require 'chessdb.php';
require 'move.php';
require 'undo.php';

/* allow WebChess to be run on PHP systems < 4.1.0, using old http vars */
fixOldPHPVersions();

/* check session status */
require 'sessioncheck.php';

/* Language selection */
require "languages/".$_SESSION['pref_language']."/strings.inc.php";


/* if this page is accessed directly (ie: without going through login), */
/* player is logged off by default */
if (!isset($_SESSION['playerID']))
$_SESSION['playerID'] = -1;

/* check if loading game */
if (isset($_POST['gameID']))
$_SESSION['gameID'] = $_POST['gameID'];

/* debug flag */
define ("DEBUG", 0);

/* connect to database */
require 'connectdb.php';

/* load game */
$isInCheck = ($_POST['isInCheck'] == 'true');
$isCheckMate = false;
$isPromoting = false;
$isUndoing = false;

loadHistory();
loadGame();

$p = mysql_query("SELECT * from games WHERE gameID='".$_SESSION['gameID']."'&quot;
if (mysql_num_rows($p) ==0){
//The game was deleted
echo "<script>window.location='mainmenu.php'</script>";
exit;
}
$row = mysql_fetch_array($p);
$white = $row['whitePlayer'];
$black = $row['blackPlayer'];
$timeLimit = $row['timelimit'];
$flagFall = $row['flagFall'];
$oficial = $row['oficial'];

if ($row['whitePlayer'] == $_SESSION['playerID'])
{
$MyRating = $row['ratingWhite'];
$OpponentRating = $row['ratingBlack'];

}
else
{
$MyRating = $row['ratingWhite'];
$OpponentRating = $row['ratingBlack'];
}

processMessages();

/* Verify permission */
if (!isBoardDisabled()){
if (($white != $_SESSION['playerID']) && ($black != $_SESSION['playerID']))
die($MSG_LANG["youdonthavepermission"]);
}

if (($numMoves == -1) || ($numMoves % 2 == 1)){
$mycolor2 = "white";
}
else{
$mycolor2 = "black";
}

/* find out if it's the current player's turn */
if (( (($numMoves == -1) || (($numMoves % 2) == 1)) && ($playersColor == "white&quot)
|| ((($numMoves % 2) == 0) && ($playersColor == "black&quot))
$isPlayersTurn = true;
else
$isPlayersTurn = false;

if ($white == $_SESSION['playerID'])
$opponent = $black;
else $opponent = $white;


if (!isBoardDisabled() && !$isCheckMate && $timeLimit > 0)
if (tempoEsgotado($mycolor2)){
saveRanking($_SESSION['gameID'],"resign",$mycolor2,1);
updateTimestamp();

// Update the opponent time
if ($mycolor2 == "white&quot
mysql_query("UPDATE games set timeWhite=$timeLimit*60 WHERE gameID=".$_SESSION['gameID']);
else
mysql_query("UPDATE games set timeBlack=$timeLimit*60 WHERE gameID=".$_SESSION['gameID']);

echo "<script>
alert('".$MSG_LANG["theflaghasfallen"]." $mycolor2 $MSG_LANG[lost]');
window.location='chess.php';
</script>\n";
exit;
}

if ($isUndoing)
{
doUndo();
saveGame();
}
else if ($CFG_ENABLE_CHAT && isset($_POST['chat_msg'])){
if ($_POST[chat_msg] != "&quot{
if (!get_magic_quotes_gpc())
$_POST[chat_msg] = addslashes($_POST[chat_msg]);
mysql_query("insert into chat (fromID,msg,gameID) VALUES ('".$_SESSION[playerID]."','".$_POST[chat_msg]."','".$_SESSION[gameID]."')&quot;
}
}
elseif (($_POST['promotion'] != "&quot && ($_POST['toRow'] != "&quot && ($_POST['toCol'] != "&quot)
{
savePromotion();
$board[$_POST['toRow']][$_POST['toCol']] = $_POST['promotion'] | ($board[$_POST['toRow']][$_POST['toCol']] & BLACK);
saveGame();
}
elseif (($_POST['fromRow'] != "&quot && ($_POST['fromCol'] != "&quot && ($_POST['toRow'] != "&quot && ($_POST['toCol'] != "&quot)
{
/* 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 */
$tmpIsValid = true;

if (($numMoves == -1) || ($numMoves % 2 == 1))
{
/* White's move... ensure that piece being moved is white */
if ((($board[$_POST['fromRow']][$_POST['fromCol']] & BLACK) != 0) || ($board[$_POST['fromRow']][$_POST['fromCol']] == 0))
/* invalid move */
$tmpIsValid = false;
}
else
{
/* Black's move... ensure that piece being moved is black */
if ((($board[$_POST['fromRow']][$_POST['fromCol']] & BLACK) != BLACK) || ($board[$_POST['fromRow']][$_POST['fromCol']] == 0))
/* invalid move */
$tmpIsValid = false;
}

if ($tmpIsValid)
{
saveHistory();
doMove();
saveGame();
}
}

?>
<html>
<head>
<!-- gameID: <?=$_SESSION[gameID]?> -->

<?

/* find out if it's the current player's turn */
if (( (($numMoves == -1) || (($numMoves % 2) == 1)) && ($playersColor == "white&quot)
|| ((($numMoves % 2) == 0) && ($playersColor == "black&quot))
$isPlayersTurn = true;
else
$isPlayersTurn = false;

if ($white == $_SESSION['playerID'])
$opponent = $black;
else $opponent = $white;

if ($_SESSION['isSharedPC'])
echo("<title>WebChess</title>\n&quot;
else if ($isPlayersTurn)
echo("<title>WebChess - ".$MSG_LANG["yourturn"]."</title>\n&quot;
else
echo("<title>WebChess - ".$MSG_LANG["opponentturn"]."</title>\n&quot;

echo("<meta HTTP-EQUIV='Pragma' CONTENT='no-cache'>\n&quot;
echo '<meta http-equiv="cache-control" content="no-cache">';
echo '<meta http-equiv="expires" content="-1">';

/* if it's not the player's turn, enable auto-refresh */
/*
if (!$isPlayersTurn && !isBoardDisabled() && !$_SESSION['isSharedPC'])
{
echo ("<META HTTP-EQUIV=Refresh CONTENT='&quot;

if ($_SESSION['pref_autoreload'] >= $CFG_MINAUTORELOAD)
echo ($_SESSION['pref_autoreload']);
else
echo ($CFG_MINAUTORELOAD);

echo ("; URL=chess.php?autoreload=yes'>\n&quot;
}
*/
?>
<script type="text/javascript">
<? writeJSboard(); ?>
<? writeJShistory(); ?>

if (DEBUG)
alert("Game initilization complete!&quot;

stopTimer = 0;
function refreshwindow(){
if (stopTimer == 0)
window.location='chess.php';
}

</script>

<script type="text/javascript" src="javascript/chessutils.php">
/* these are utility functions used by other functions */
</script>

<script type="text/javascript" src="javascript/commands.php">
// these functions interact with the server
</script>

<script type="text/javascript" src="javascript/validation.php">
// these functions are used to test the validity of moves
</script>

<script type="text/javascript" src="javascript/isCheckMate.php">
// these functions are used to test the validity of moves
</script>

<script type="text/javascript" src="javascript/squareclicked.php">
// this is the main function that interacts with the user everytime they click on a square
</script>

<LINK rel="stylesheet" href="modules/webchess/themes/<?=$_SESSION["pref_colortheme"]?>/board.css" type="text/css">

</style>
</head>

<body bgcolor=white text=black>

<table border="0">
<tr><td align=center>
<?
$p = mysql_query("SELECT firstName,playerID,engine FROM players WHERE playerID='$white'&quot;
$row = mysql_fetch_array($p);
$p = mysql_query("SELECT firstName,playerID,engine FROM players WHERE playerID='$black'&quot;
$row2 = mysql_fetch_array($p);
$row[0] = $row[0]." (".$MSG_LANG["white"].&quot";
$row2[0] = $row2[0]." (".$MSG_LANG["black"].&quot";
echo "<input type='button' name='btnWhiteUser' value='$row[0]' onClick=\"window.open('stats_user.php?cod=$row[1]&voltar=chess.php', '_self')\">";
echo " <B>X</B> ";
echo "<input type='button' name='btnBlackUser' value='$row2[0]' onClick=\"window.open('stats_user.php?cod=$row2[1]&voltar=chess.php', '_self')\">";
#echo "<font face=verdana size=2><a href='stats_user.php?cod=$row[1]&voltar=chess.php'>$row[0]</a> <B>x</B> <a href='stats_user.php?cod=$row2[1]&voltar=chess.php'>$row2[0]</a></font>";
if ($row["engine"] == "1" || $row2["engine"] == "1&quot
$isEngine=true;

$p = mysql_query("SELECT value FROM preferences WHERE preference='language' AND playerID=$opponent&quot;
$r = mysql_fetch_array($p);
if ($_SESSION['pref_language'] != $r[0])
$opponent_language = strtoupper($r[0]);
else $opponent_language = "";


?>
</tr></td>

<td>&nbsp;</td>
<td align=center><input type="button" value="<?=$MSG_LANG["analyze"]?>" onClick="window.open('analyze.php?whocolor=<?=$playersColor?>&game=<?=$_SESSION['gameID']?>', '_blank','location=no,toolbar=no,directories=no,menubar=no,resizable=no,status=no,scrollbars=yes,width=450,height=450')"></td>
<tr valign="top" align="center"><td>

<form name="gamedata" method="post" action="chess.php">
<input type=hidden name="gameID" value="<?=$_SESSION["gameID"]?>">
<?

/* Verify if the promotion process was completed */
if ($playersColor == "white&quot{
$promotionRow = 7;
$otherRow = 0;
}
else{
$promotionRow = 0;
$otherRow = 7;
}

for ($i = 0; $i < 8; $i++)
if (($board[$promotionRow][$i] & COLOR_MASK) == PAWN){
$isPromoting = true;
$p = mysql_query("SELECT * FROM history where toCol='$i' AND toRow='$promotionRow' AND curPiece='pawn' and curColor='$playersColor' and gameID='$_SESSION[gameID]'&quot;
$row = mysql_fetch_array($p);
$_POST['fromRow'] = $row[fromRow];
$_POST['fromCol'] = $row[fromCol];
$_POST['toRow'] = $row[toRow];
$_POST['toCol'] = $row[toCol];
}

for ($i = 0; $i < 8; $i++)
if (($board[$otherRow][$i] & COLOR_MASK) == PAWN){
writeWaitPromotion();
$isPromoting = 1;
$otherTurn = 1;
}

if ($isPromoting && !$otherTurn)
writePromotion();
?>

<?
if ($isUndoRequested)
writeUndoRequest();
?>

<?
if ($isDrawRequested)
writeDrawRequest();

?>

<? drawboard(); ?>

<!-- table border="0">
<tr><td -->
<BR>
<nobr>
<input type="button" name="btnReload" value="<?=$MSG_LANG["refresh2"]?>" onClick="window.open('chess.php', '_self')">
<? if ($CFG_ENABLE_UNDO){ ?>
<input type="button" name="btnUndo" value="<?=$MSG_LANG["undomove"]?>" <? if (isBoardDisabled()) echo("disabled='yes'&quot; else echo ("onClick='undo(\"".$MSG_LANG["undowarning"]."\&quot'&quot; ?>>
<?}?>
<input type="button" name="btnResign" value="<?=$MSG_LANG["resign"]?>" <? if (isBoardDisabled()) echo("disabled='yes'&quot; else echo ("onClick='resigngame($CFG_MIN_ROUNDS,\"".$MSG_LANG["roundwarning"]."\&quot'&quot; ?>>
<input type="button" name="btnDraw" value="<?=$MSG_LANG["askdraw"]?>" <? if (isBoardDisabled()) echo("disabled='yes'&quot; else echo ("onClick='draw($CFG_MIN_ROUNDS,\"".$MSG_LANG["roundwarning"]."\&quot'&quot; ?>>
<?if (isset($_POST['statsUser'])){ ?>
<input type="button" name="btnMainMenu" value="<?=$MSG_LANG["back"]?>" onClick="window.open('stats_user.php?cod=<?=$_POST['statsUser']?>', '_self')">
<?}else{ ?>
<input type="button" name="btnMainMenu" value="<?=$MSG_LANG["main"]?>" onClick="window.open('mainmenu.php', '_self')">
<?}?>
<!-- <input type="button" name="btnLogout" value="Sair" onClick="logout()">
-->
<input type="hidden" name="ToDo" value="Logout"> <!-- NOTE: this field is only used to Logout -->
</nobr>
<!-- /td></tr>
</table -->

<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="<?=$_POST['fromRow']?>">
<input type="hidden" name="fromCol" value="<?=$_POST['fromCol']?>">
<input type="hidden" name="toRow" value="<?=$_POST['toRow']?>">
<input type="hidden" name="toCol" value="<?=$_POST['toCol']?>">
<input type="hidden" name="isInCheck" value="false">
<input type="hidden" name="isCheckMate" value="false">

<? if ($isPromoting && $isEngine){
echo "<script>promotepawn();</script>";
} ?>

</form>

<? if ($CFG_ENABLE_CHAT && !isBoardDisabled()){ ?>

<form method=POST action="chess.php" name=chess>
<input type=hidden name="gameID" value="<?=$_SESSION["gameID"]?>">
<table border='0' width=450 bgcolor=black cellspacing=1 cellpading=1>
<tr><th bgcolor='beige' colspan='3'>CHAT
<? if ($opponent_language != "&quot{
$language = $MSG_LANG[strtolower($opponent_language)];
echo " (".$MSG_LANG['opponentlanguage'].": ".$language.&quot";
}
?>
</th></tr>
<tr><td bgcolor=white align=left><?= writeChat($_SESSION['gameID'])?></td></tr>
<tr><td align=center bgcolor=white><input type=text name=chat_msg size=50 onClick="stopTimer=1"><input type=submit value="<?=$MSG_LANG["write"]?>"></td></tr>
</table>
<form>
<?}?>

</td>

<td width="50">&nbsp;</td>

<td>
<? writeStatus(); ?>
<BR>
<? writeTime(); ?>
<br>
<? writeHistory(); ?>

<table boarder="1" width="300">
<?

//Pieces out:

$black = StartPieces();
$white = StartPieces();

$p = mysql_query("SELECT * FROM pieces WHERE gameID = ".$_SESSION['gameID']." order by color,piece&quot;
while ($row = mysql_fetch_array($p)){
if ($row['color'] == "white&quot
$white[$row['piece']]--;
else
$black[$row['piece']]--;
}


echo "<tr><td align=left>";
while(list($piece,$num) = each($white))
if ($num > 0)
for ($y=0; $y<$num; $y++)
echo "<img src='images/".$_SESSION['pref_theme']."/white_".$piece.".gif' height='25'> ";

echo "</td></tr>";
echo "<tr><td align=left>";
while(list($piece,$num) = each($black))
if ($num > 0)
for ($y=0; $y<$num; $y++)
echo "<img src='images/".$_SESSION['pref_theme']."/black_".$piece.".gif' height='25'> ";

echo "</td></tr>";
echo "</table>";

if (!isBoardDisabled()){
writePoints();
}

?>
</td></tr>
</table>

<font face=verdana size=1 color=#EEEEEE>
<script>
curDir = -1;

if (isInCheck('<?=$mycolor2?>')){
document.write("<?=$mycolor2?> is in Check<BR>&quot;
}
curDir = -1;
if (isXequeMate('<?=$mycolor2?>')){
document.write("<?=$mycolor2?> is in Check-Mate<BR>&quot;
}
if (isDraw('<?=$mycolor2?>')&&!isXequeMate('<?=$mycolor2?>')){
document.write('Javascript result: The game ends in a Draw!');
}
</script>
<?
if (!$isPlayersTurn && !isBoardDisabled() && !$_SESSION['isSharedPC'])
{
if ($_SESSION['pref_autoreload'] >= $CFG_MINAUTORELOAD)
$autoreload = $_SESSION['pref_autoreload'];
else
$autoreload = $CFG_MINAUTORELOAD;

echo "<script>
setTimeout(\"refreshwindow()\",".($autoreload*1000).&quot
</script>";
}
?>

</font>
</body>
</html>
<?
if (isset($COMPRESSION) && $COMPRESSION && isset($ob_mode) && $ob_mode) {
PMA_outBufferPost($ob_mode);
}

ATENCIÓN: Este tema no tiene actividad desde hace más de 6 MESES,
te recomendamos abrir un nuevo tema en lugar de responder al actual
Opciones:
Ir al subforo:
Permisos:
TU NO PUEDES Escribir nuevos temas
TU NO PUEDES Responder a los temas
TU NO PUEDES Editar tus propios mensajes
TU NO PUEDES Borrar tus propios mensajes
Temas similares
TemaUsuariosRespuestasVisitasActividad
Por: , el 21/Feb/2005, 01:01
gabrielfin User 2831812kFeb/05