function isSessionIDValid($config, $xsid) { $bValid = false; //Instantiate the CR3DCQuery Class $oR3DCQuery = new CR3DCQuery($config); $oR3DCQuery->CheckSIDTimeout(); if ($xsid != "") { if ($oR3DCQuery->CheckLogin($config, $xsid)) { $session = base64_decode($xsid); list($uniq, $player_id) = preg_split("/\\|/", $session); if ($uniq != "" && is_numeric($player_id)) { $bValid = true; $oR3DCQuery->UpdateSIDTimeout($config, $xsid); $oR3DCQuery->SetPlayerCreditsInit($player_id); } } } if ($oR3DCQuery->ELOIsActive()) { $oR3DCQuery->ELOCreateRatings(); } $oR3DCQuery->MangeGameTimeOuts(); $oR3DCQuery->Close(); unset($oR3DCQuery); return $bValid; }
?> layout.css" type="text/css"> <?php include $Root_Path . "includes/javascript.php"; ?> </head> <body> <script Language='javascript'> function ListByLetter(strLetter){ document.frmfindPlayer.txtSearch.value = strLetter; document.frmfindPlayer.submit(); } </script> <?php include "./skins/" . $SkinName . "/layout_cfg.php"; ?> </body> </html> <?php ////////////////////////////////////////////////////////////// $oR3DCQuery->Close(); unset($oR3DCQuery); ////////////////////////////////////////////////////////////// ob_end_flush();
function mobile_movehmm($config) { if ($_GET['gameid'] != "" && $_GET['from'] != "" && $_GET['to'] != "") { //Instantiate theCR3DCQuery Class $oR3DCQuery = new CR3DCQuery($config); $xsid = $_GET['sid']; $session = base64_decode($xsid); list($uniq, $player_id) = preg_split("/\\|/", $session); $movefrom = $_GET['from']; $moveto = $_GET['to']; $bmove_error = false; //Create Move String $movestr = $movefrom . "," . $moveto; $movestr2 = $movefrom . "-" . $moveto; // get the fen for the game $fen = $oR3DCQuery->GetHackedFEN($xsid, $_GET['gameid']); //$fen3 = $oR3DCQuery->GetHackedFEN($xsid, $_GET['gameid']); $bturn = $oR3DCQuery->IsPlayersTurn($config, $player_id, $_GET['gameid']); echo "FEN: {$fen}<br/>"; ChessHelper::load_chess_game($_GET['gameid']); $turn = $fen = ChessHelper::$CB->GetFENForCurrentPosition(); echo "FEN: {$fen}<br/>"; if ($bturn) { //check to see if the move is valid if (is_Move_legal($fen, $movestr2)) { $oR3DCQuery->CurrentGameMovePiece($config, $_GET['gameid'], $xsid, $player_id, $movestr); $initiator = ""; $w_player_id = ""; $b_player_id = ""; $status = ""; $completion_status = ""; $start_time = ""; $next_move = ""; $oR3DCQuery->GetGameInfoByRef($config, $_GET['gameid'], $initiator, $w_player_id, $b_player_id, $status, $completion_status, $start_time, $next_move); //checkmate if (get_GameState() == 1) { //if($w_player_id == $player_id){ if ($next_move == 'w') { /////////////////////////////////////////////////////////////////////// //ELO Point Calculation if ($oR3DCQuery->ELOIsActive() && $oR3DCQuery->IsGameRated($_GET['gameid'])) { $bcurpoints = $oR3DCQuery->ELOGetRating($b_player_id); $wcurpoints = $oR3DCQuery->ELOGetRating($w_player_id); //Calculate black player $bnewpoints = $oR3DCQuery->ELOCalculation($bcurpoints, $wcurpoints, 1, 1, $oR3DCQuery->GetPlayerGameCount($b_player_id)); //Calculate white player $wnewpoints = $oR3DCQuery->ELOCalculation($wcurpoints, $bcurpoints, 0, 1, $oR3DCQuery->GetPlayerGameCount($w_player_id)); //update points $oR3DCQuery->ELOUpdateRating($b_player_id, $bnewpoints); $oR3DCQuery->ELOUpdateRating($w_player_id, $wnewpoints); } /////////////////////////////////////////////////////////////////////// $oR3DCQuery->UpdateGameStatus($config, $_GET['gameid'], "C", "B"); } else { /////////////////////////////////////////////////////////////////////// //ELO Point Calculation if ($oR3DCQuery->ELOIsActive() && $oR3DCQuery->IsGameRated($_GET['gameid'])) { $bcurpoints = $oR3DCQuery->ELOGetRating($b_player_id); $wcurpoints = $oR3DCQuery->ELOGetRating($w_player_id); //Calculate black player $bnewpoints = $oR3DCQuery->ELOCalculation($bcurpoints, $wcurpoints, 0, 1, $oR3DCQuery->GetPlayerGameCount($b_player_id)); //Calculate white player $wnewpoints = $oR3DCQuery->ELOCalculation($wcurpoints, $bcurpoints, 1, 1, $oR3DCQuery->GetPlayerGameCount($w_player_id)); //update points $oR3DCQuery->ELOUpdateRating($b_player_id, $bnewpoints); $oR3DCQuery->ELOUpdateRating($w_player_id, $wnewpoints); } /////////////////////////////////////////////////////////////////////// $oR3DCQuery->UpdateGameStatus($config, $_GET['gameid'], "C", "W"); } $oR3DCQuery->CachePlayerPointsByPlayerID($b_player_id); $oR3DCQuery->CachePlayerPointsByPlayerID($w_player_id); } else { if (get_GameState() == 2) { /////////////////////////////////////////////////////////////////////// //ELO Point Calculation if ($oR3DCQuery->ELOIsActive() && $oR3DCQuery->IsGameRated($_GET['gameid'])) { $bcurpoints = $oR3DCQuery->ELOGetRating($b_player_id); $wcurpoints = $oR3DCQuery->ELOGetRating($w_player_id); //Calculate black player $bnewpoints = $oR3DCQuery->ELOCalculation($bcurpoints, $wcurpoints, 0.5, 1, $oR3DCQuery->GetPlayerGameCount($b_player_id)); //Calculate white player $wnewpoints = $oR3DCQuery->ELOCalculation($wcurpoints, $bcurpoints, 0.5, 1, $oR3DCQuery->GetPlayerGameCount($w_player_id)); //update points $oR3DCQuery->ELOUpdateRating($b_player_id, $bnewpoints); $oR3DCQuery->ELOUpdateRating($w_player_id, $wnewpoints); } /////////////////////////////////////////////////////////////////////// $oR3DCQuery->UpdateGameStatus($config, $_GET['gameid'], "C", "D"); $bmove_error = false; $oR3DCQuery->CachePlayerPointsByPlayerID($b_player_id); $oR3DCQuery->CachePlayerPointsByPlayerID($w_player_id); } } } else { $bmove_error = true; } } else { $bmove_error = true; } $oR3DCQuery->Close(); unset($oR3DCQuery); } else { $bmove_error = true; } if ($bmove_error) { echo "<RESPONSE>\n"; echo "<MOVE>false</MOVE>\n"; echo "</RESPONSE>\n"; } else { echo "<RESPONSE>\n"; echo "<MOVE>true</MOVE>\n"; mobile_get_full_game_update(); echo "<LASTMOVE>" . ChessHelper::get_last_move() . "</LASTMOVE>"; echo "</RESPONSE>\n"; } }
function CheckPlayerBillingTerm($config) { include $config; $db = 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("Couldn't select the database"); /************/ //$result = mysql_query("SELECT * FROM c4m_playerorders WHERE o_orderstatus = 'p' AND DATE_FORMAT('2005-05-07 18:18:18','%Y-%m-%d') >= DATE_FORMAT(o_datedue,'%Y-%m-%d')") or die("Couldn't Check The End Dates."); $result = mysql_query("SELECT * FROM c4m_playerorders WHERE o_orderstatus = 'p' AND DATE_FORMAT(NOW(),'%Y-%m-%d') >= DATE_FORMAT(o_datedue,'%Y-%m-%d')") or die("Couldn't Check The End Dates."); /***********/ $num = mysql_numrows($result); $i = 0; while ($i < $num) { $o_id = mysql_result($result, $i, "o_id"); $o_username = mysql_result($result, $i, "o_username"); $o_firstname = mysql_result($result, $i, "o_firstname"); $o_lastname = mysql_result($result, $i, "o_lastname"); $o_address = mysql_result($result, $i, "o_address"); $o_citytown = mysql_result($result, $i, "o_citytown"); $o_country = mysql_result($result, $i, "o_country"); $o_provincestatearea = mysql_result($result, $i, "o_provincestatearea"); $o_postalcode = mysql_result($result, $i, "o_postalcode"); $o_email = mysql_result($result, $i, "o_email"); $o_phonea = mysql_result($result, $i, "o_phonea"); $o_phoneb = mysql_result($result, $i, "o_phoneb"); $o_phonec = mysql_result($result, $i, "o_phonec"); $o_redemptioncode = mysql_result($result, $i, "o_redemptioncode"); $o_dateoforder = mysql_result($result, $i, "o_dateoforder"); $o_paymentterm = mysql_result($result, $i, "o_paymentterm"); $o_datepaid = mysql_result($result, $i, "o_datepaid"); $o_datedue = mysql_result($result, $i, "o_datedue"); $o_orderstatus = mysql_result($result, $i, "o_orderstatus"); //echo "[".$o_id."] ".$o_username." - ".$o_datedue." - ".$o_orderstatus."<br>"; // set order to finished $update = "UPDATE c4m_playerorders SET o_orderstatus = 'f' WHERE o_id=" . $o_id; mysql_query($update, $db) or die(mysql_error()); // create new order $insert = "INSERT INTO c4m_playerorders VALUES(NULL, '" . $o_username . "', '" . $o_firstname . "', '" . $o_lastname . "', '" . $o_address . "', '" . $o_citytown . "', '" . $o_country . "', '" . $o_provincestatearea . "', '" . $o_postalcode . "', '" . $o_email . "', '" . $o_phonea . "', '" . $o_phoneb . "', '" . $o_phonec . "', '', NOW(), '" . $o_paymentterm . "', NULL, NULL, 'u')"; mysql_query($insert, $db) or die(mysql_error()); //Select the new Order ID $query1 = "SELECT o_id FROM c4m_playerorders WHERE o_username = '******' AND o_orderstatus='u' ORDER BY o_id DESC LIMIT 1"; $return1 = mysql_query($query1, $db) or die(mysql_error()); $num1 = mysql_numrows($return1); $orderid = 0; if ($num1 != 0) { $orderid = mysql_result($return1, 0, 0); } // Send email $query2 = "SELECT * FROM c4m_emailmessageconfig"; $return2 = mysql_query($query2, $db) or die(mysql_error()); $num2 = mysql_numrows($return2); if ($num2 != 0) { $o_regover = mysql_result($return2, 0, "o_regover"); $subject = "Chess Membership Renewal"; // configure message body $body = $o_regover; $body = str_replace("[NAME]", $o_firstname . " " . $o_lastname, $body); $body = str_replace("[OID]", $orderid, $body); $body = str_replace("[UNAME]", $o_username, $body); //Instantiate theCR3DCQuery Class $oR3DCQuery = new CR3DCQuery($config); $oR3DCQuery->SendEmail($o_email, $conf['registration_email'], $conf['site_name'], $subject, $body); $oR3DCQuery->Close(); unset($oR3DCQuery); } $i++; } }