//////////////////////////////////////////////////////////////////////////////////////////// // sendgamechat // Params: action, sid, gameid, msg //////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////// // sendgamechat // Params: action, sid, gameid, msg //////////////////////////////////////////////////////////////////////////////////////////// case "sendgamechat": if (isSessionIDValid($config, $xsid)) { $session = base64_decode($xsid); list($uniq, $player_id) = preg_split("/\\|/", $session); if ($_GET['gameid'] != "" && $_GET['msg'] != "") { //Instantiate theCR3DCQuery Class $oR3DCQuery = new CR3DCQuery($config); $message = "<" . $oR3DCQuery->GetUserIDByPlayerID($config, $player_id) . "> " . $_GET['msg']; $aToReplace = array("<", ">", "\\'", "\\\"", "“", "”", "„", "‘", "’", "‚"); $aReplaceWith = array("<", ">", "'", """, "“", "”", "„", "‘", "’", "‚"); $message = str_replace($aToReplace, $aReplaceWith, $message); $oR3DCQuery->SendGChat($config, $_GET['gameid'], $message); $oR3DCQuery->Close(); unset($oR3DCQuery); echo "<RESPONSE>\n"; echo "<SENTMSG>true</SENTMSG>\n"; echo "</RESPONSE>\n"; } else { echo "<RESPONSE>\n"; echo "<SENTMSG>false</SENTMSG>\n"; echo "</RESPONSE>\n"; } } else {
function create_game($ConfigFile, $requestor, $other, $req_color, $FEN) { if ($other !== "") { if ($requestor == $other) { return ""; } // verify the validity of both players $w_player_id = ""; $b_player_id = ""; if ($req_color != "" && $req_color == "w") { $w_player_id = $requestor; $b_player_id = $other; } else { $w_player_id = $other; $b_player_id = $requestor; } //include config file include $ConfigFile; // create a new game in the db $game_id = $this->gen_unique(); // connect to mysql and open database $db_my = mysql_connect($conf['database_host'], $conf['database_login'], $conf['database_pass']) or die("Couldn't connect to the database."); @mysql_select_db($conf['database_name']) or die("Unable to select database"); $st = "INSERT INTO game(game_id, initiator, w_player_id, b_player_id, start_time) VALUES('" . $game_id . "'," . $requestor . "," . $w_player_id . "," . $b_player_id . "," . time() . ")"; mysql_query($st) or die(mysql_error()); //if fen is included insert it if (trim($FEN) != "") { $st = "INSERT INTO c4m_newgameotherfen VALUES('" . $game_id . "', '" . trim($FEN) . "')"; mysql_query($st) or die(mysql_error()); } // immediately update the status of the requestor $st = "UPDATE player SET status='E' WHERE player_id=" . $requestor . ""; mysql_query($st) or die(mysql_error()); ////////////////////////////////////////////// // notify the challenged $st = "INSERT INTO message_queue(player_id, message, posted) VALUES(" . $other . ",'" . $this->add_header("G", $game_id . $this->zero_pad($requestor, 8), "C") . "'," . time() . ")"; mysql_query($st) or die(mysql_error()); //Instantiate theCR3DCQuery Class $oR3DCQuery = new CR3DCQuery($this->ChessCFGFileLocation); if ($oR3DCQuery->ChallangeNotification($other) == true) { $requestorname = $oR3DCQuery->GetUserIDByPlayerID($this->ChessCFGFileLocation, $requestor); $otherguysname = $oR3DCQuery->GetUserIDByPlayerID($this->ChessCFGFileLocation, $other); $otheremail = $oR3DCQuery->GetEmailByPlayerID($this->ChessCFGFileLocation, $other); $subject = $this->GetStringFromStringTable("IDS_CR3DCQUERY_EMAIL_TVST_19", $ConfigFile); $aTags1 = array("['otherguysname']", "['requestorname']", "['game_id']", "['siteurl']", "['sitename']"); $aReplaceTags = array($otherguysname, $requestorname, $game_id, $this->TrimRSlash($conf['site_url']), $conf['site_name']); $bodyp1 = str_replace($aTags1, $aReplaceTags, $this->GetStringFromStringTable("IDS_CR3DCQUERY_EMAIL_TVST_20", $ConfigFile)); $this->SendEmail($otheremail, $conf['registration_email'], $conf['site_name'], $subject, $bodyp1); } unset($oR3DCQuery); ////////////////////////////////////////////// return $game_id . $this->zero_pad($w_player_id, 8) . $this->zero_pad($b_player_id, 8); } else { return ""; } }
$start_time = ""; /////////////////////////////////////////////////////////////////// // Check if the game is not playable by the viewer if (!$oR3DCQuery->IsGameControlsViewableByPlayer($gid, $_SESSION['id'])) { header('Location: ./chess_members.php'); } //get current game info to display player data $oR3DCQuery->GetCurrentGameInfoByRef($config, $gid, $initiator, $w_player_id, $b_player_id, $next_move, $start_time); //get the information for the white player and put it in a div $image = $oR3DCQuery->GetAvatarImageName($w_player_id); if ($image != "") { $image = "<img src='./avatars/" . $image . "'>"; } else { $image = "<img src='./avatars/noimage.jpg'>"; } $userid = $oR3DCQuery->GetUserIDByPlayerID($config, $w_player_id); $wins = 0; $loss = 0; $draws = 0; $oR3DCQuery->GetPlayerStatusrRefByPlayerID($config, $w_player_id, $wins, $loss, $draws); if ($oR3DCQuery->ELOIsActive()) { $points = $oR3DCQuery->ELOGetRating($w_player_id); } else { $points = $oR3DCQuery->GetPointValue($wins, $loss, $draws); } $whitediv = "\n\t<div id=\"whiteclock\"></div>\n\t<div class=\"avatar\">{$image}</div>\n\t<div class=\"userid\">{$userid}</div>\n\t<div class=\"points\">{$points}</div>\n\t"; //get the information for the white player and put it in a div $image = $oR3DCQuery->GetAvatarImageName($b_player_id); if ($image != "") { $image = "<img src='./avatars/" . $image . "'>"; } else {
/////////////////////////////////////////////////////////////////// //LOGIN methods //manage cookie data if ($_COOKIE['TestCookie'] != "") { list($user1, $pass1, $languagefile1) = preg_split("/\\|/", $_COOKIE['TestCookie'], 3); $user = $user1; $pass = base64_decode($pass1); $languagefile = $languagefile1; $chkAutoLogin = "******"; } if ($user != "" && $pass != "") { $sid = $oR3DCQuery->Login($user, $pass); $id = $oR3DCQuery->GetIDByUserID($config, $user); if ($sid != "") { $_SESSION['sid'] = $sid; $_SESSION['user'] = $oR3DCQuery->GetUserIDByPlayerID($config, $id); $_SESSION['id'] = $id; $_SESSION['password'] = $pass; $_SESSION['language'] = $languagefile; //Get Chessboard colors $d = ""; $l = ""; $oR3DCQuery->GetChessBoardColors($config, $_SESSION['id'], $l, $d); $_SESSION['lcolor'] = $l; $_SESSION['dcolor'] = $d; if ($oR3DCQuery->IsPlayerDisabled($id) == false) { //Create the cookie if auto login if ($chkAutoLogin == "1") { $cookie_data = $user . "|" . base64_encode($pass) . "|" . $languagefile; setcookie("TestCookie", $cookie_data, time() + 360000); }