function ebattles_upgrade() { global $sql; if (versionsCompare($eb_version_string, "0.9.0") < 0) { require_once e_PLUGIN . "ebattles/include/gamer.php"; // To revision 0.9.0 $q = "UPDATE " . TBL_EVENTS . " SET Type = 'Clan Ladder' WHERE (Type = 'ClanWar')"; $result = $sql->db_Query($q); $q = "ALTER TABLE " . TBL_PLAYERS . " ADD Gamer int(10) unsigned NOT NULL"; $result = $sql->db_Query($q); $q = "ALTER TABLE " . TBL_PLAYERS . " ADD INDEX (Gamer)"; $result = $sql->db_Query($q); $q = "ALTER TABLE " . TBL_PLAYERS . " ADD FOREIGN KEY (Gamer) REFERENCES " . TBL_GAMERS . " (GamerID)"; $result = $sql->db_Query($q); $q = "CREATE TABLE " . TBL_GAMERS . "\r\n\t\t\t(\r\n\t\t\tGamerID int NOT NULL AUTO_INCREMENT,\r\n\t\t\tPRIMARY KEY(GamerID),\r\n\t\t\tUser int(10) unsigned NOT NULL,\r\n\t\t\tINDEX (User),\r\n\t\t\tFOREIGN KEY (User) REFERENCES " . TBL_USERS . " (user_id),\r\n\t\t\tGame int NOT NULL,\r\n\t\t\tINDEX (Game),\r\n\t\t\tFOREIGN KEY (Game) REFERENCES " . TBL_GAMES . " (GameID),\r\n\t\t\tName varchar(64) NOT NULL default '',\r\n\t\t\tUniqueGameID varchar(64) NOT NULL default ''\r\n\t\t\t) ENGINE = MyISAM;"; $result = $sql->db_Query($q); $q = "SELECT DISTINCT " . TBL_PLAYERS . ".*, " . TBL_EVENTS . ".*, " . TBL_USERS . ".*" . " FROM " . TBL_PLAYERS . ", " . TBL_EVENTS . ", " . TBL_USERS . " WHERE (" . TBL_PLAYERS . ".Event = " . TBL_EVENTS . ".EventID)" . " AND (" . TBL_USERS . ".user_id = " . TBL_PLAYERS . ".User)"; $result = $sql->db_Query($q); $nbrplayers = mysql_numrows($result); for ($i = 0; $i < $nbrplayers; $i++) { $pid = mysql_result($result, $i, TBL_PLAYERS . ".PlayerID"); $puid = mysql_result($result, $i, TBL_PLAYERS . ".User"); $puname = mysql_result($result, $i, TBL_USERS . ".user_name"); $pgame = mysql_result($result, $i, TBL_EVENTS . ".Game"); $gamerID = updateGamer($puid, $pgame, $puname, ""); $q2 = "UPDATE " . TBL_PLAYERS . " SET Gamer='{$gamerID}' WHERE (PlayerId = '{$pid}')"; $result2 = $sql->db_Query($q2); } } }
/** * eventAddPlayer - add a user to an event */ function eventAddPlayer($user, $team = 0, $notify) { global $sql; global $time; $q = "SELECT " . TBL_USERS . ".*" . " FROM " . TBL_USERS . " WHERE (" . TBL_USERS . ".user_id = '{$user}')"; $result = $sql->db_Query($q); $username = mysql_result($result, 0, TBL_USERS . ".user_name"); $useremail = mysql_result($result, 0, TBL_USERS . ".user_email"); // Find gamer for that user $q = "SELECT " . TBL_GAMERS . ".*" . " FROM " . TBL_GAMERS . " WHERE (" . TBL_GAMERS . ".Game = '" . $this->fields['Game'] . "')" . " AND (" . TBL_GAMERS . ".User = '******')"; $result = $sql->db_Query($q); $num_rows = mysql_numrows($result); if ($num_rows == 0) { // Need to create gamer before coming here (i.e. when player joins a division.) // If the gamer does not exist, create one. $gamerID = updateGamer($user, $this->fields['Game'], $username, ""); } else { $gamerID = mysql_result($result, 0, TBL_GAMERS . ".GamerID"); } // Find next available seed $q = "SELECT " . TBL_PLAYERS . ".*" . " FROM " . TBL_PLAYERS . " WHERE (" . TBL_PLAYERS . ".Event = '" . $this->fields['EventID'] . "')" . " ORDER BY " . TBL_PLAYERS . ".Seed, " . TBL_PLAYERS . ".Joined"; $result = $sql->db_Query($q); $numPlayers = mysql_numrows($result); $looking_for_seed = 1; $set_seed = true; for ($player = 0; $player < $numPlayers; $player++) { $pseed = mysql_result($result, $player, TBL_PLAYERS . ".Seed"); //if(isset($pseed) && ($pseed!=0)) $set_seed = true; if ($pseed == $looking_for_seed) { $looking_for_seed++; } } // Is the user already signed up for the team? $q = "SELECT " . TBL_PLAYERS . ".*" . " FROM " . TBL_PLAYERS . ", " . TBL_GAMERS . " WHERE (" . TBL_PLAYERS . ".Event = '" . $this->fields['EventID'] . "')" . " AND (" . TBL_PLAYERS . ".Team = '{$team}')" . " AND (" . TBL_PLAYERS . ".Gamer = '{$gamerID}')"; $result = $sql->db_Query($q); $num_rows = mysql_numrows($result); echo "num_rows: {$num_rows}<br>"; if ($num_rows == 0) { $q = " INSERT INTO " . TBL_PLAYERS . "(Event,Gamer,Team,ELORanking,TS_mu,TS_sigma,G2_r,G2_RD,G2_sigma,Joined)\r\n\t\t\tVALUES (" . $this->fields['EventID'] . ",{$gamerID},{$team}," . $this->fields['ELO_default'] . "," . $this->fields['TS_default_mu'] . "," . $this->fields['TS_default_sigma'] . "," . $this->fields['G2_default_r'] . "," . $this->fields['G2_default_RD'] . "," . $this->fields['G2_default_sigma'] . ",{$time})"; $sql->db_Query($q); echo "player created, query: {$q}<br>"; $last_id = mysql_insert_id(); if ($set_seed == true) { $q = "UPDATE " . TBL_PLAYERS . " SET Seed = '" . $looking_for_seed . "' WHERE (PlayerID = '" . $last_id . "')"; $sql->db_Query($q); } if ($this->getField('FixturesEnable') == TRUE && $this->getField('Status') == 'active') { $this->brackets(true); } $this->setFieldDB('IsChanged', 1); if ($notify) { $sendto = $user; $subject = SITENAME . " " . $this->fields['Name']; $message = EB_EVENTS_L26 . $username . EB_EVENTS_L27 . $this->fields['Name'] . EB_EVENTS_L29 . EB_EVENTS_L31; sendNotification($sendto, $subject, $message, $fromid = 0); // Send email //$message = EB_EVENTS_L26.$username.EB_EVENTS_L27.$this->fields['Name'].EB_EVENTS_L30."<a href='".SITEURLBASE.e_PLUGIN_ABS."ebattles/eventinfo.php?eventid=$this->fields['EventID']'>$this->fields['Name']</a>.".EB_EVENTS_L31.USERNAME.EB_EVENTS_L32; $message = EB_EVENTS_L26 . $username . EB_EVENTS_L27 . $this->fields['Name'] . EB_EVENTS_L30 . SITEURLBASE . e_PLUGIN_ABS . "ebattles/eventinfo.php?eventid=" . $this->fields['EventID'] . EB_EVENTS_L31; require_once e_HANDLER . "mail.php"; sendemail($useremail, $subject, $message); } } }
function addMember($user, $notify) { global $sql; global $time; $div_id = $this->fields['DivisionID']; $game_id = $this->fields['Game']; $q = "SELECT " . TBL_USERS . ".*" . " FROM " . TBL_USERS . " WHERE (" . TBL_USERS . ".user_id = '{$user}')"; $result = $sql->db_Query($q); $Name = mysql_result($result, 0, TBL_USERS . ".user_name"); $UniqueGameID = ""; $gamerID = updateGamer($user, $game_id, $Name, $UniqueGameID); $q = " INSERT INTO " . TBL_MEMBERS . "(Division,User,timestamp)\r\n\t\tVALUES ({$div_id},{$user},{$time})"; $sql->db_Query($q); // User will automatically be signed up to all current events this division participates in $q_2 = "SELECT " . TBL_TEAMS . ".*, " . TBL_EVENTS . ".*" . " FROM " . TBL_TEAMS . ", " . TBL_EVENTS . " WHERE (" . TBL_TEAMS . ".Division = '{$div_id}')" . " AND (" . TBL_TEAMS . ".Event = " . TBL_EVENTS . ".EventID)" . " AND (" . TBL_EVENTS . ".Status != 'finished')"; $result_2 = $sql->db_Query($q_2); $num_rows_2 = mysql_numrows($result_2); if ($num_rows_2 > 0) { for ($j = 0; $j < $num_rows_2; $j++) { $event_id = mysql_result($result_2, $j, TBL_EVENTS . ".EventID"); $event = new Event($event_id); $team_id = mysql_result($result_2, $j, TBL_TEAMS . ".TeamID"); $team_banned = mysql_result($result_2, $j, TBL_TEAMS . ".Banned"); // Verify there is no other player for that user/event/team $q = "SELECT COUNT(*) as NbrPlayers" . " FROM " . TBL_PLAYERS . " WHERE (Event = '{$event_id}')" . " AND (Team = '{$team_id}')" . " AND (User = "******")"; $result = $sql->db_Query($q); $row = mysql_fetch_array($result); $nbrplayers = $row['NbrPlayers']; if ($nbrplayers == 0) { $q = " INSERT INTO " . TBL_PLAYERS . "(Event,Gamer,Team,ELORanking,TS_mu,TS_sigma,G2_r,G2_RD,G2_sigma,Joined,Banned)\r\n\t\t\t\t\tVALUES ({$event_id}, {$gamerID}, {$team_id}, " . $event->getField('ELO_default') . ", " . $event->getField('TS_default_mu') . ", " . $event->getField('TS_default_sigma') . "," . $event->fields['G2_default_r'] . "," . $event->fields['G2_default_RD'] . "," . $event->fields['G2_default_sigma'] . ",{$time}, {$team_banned})"; $sql->db_Query($q); $event->setFieldDB('IsChanged', 1); } } } if ($notify) { list($cname, $ctag, $cid) = $this->getClanInfo(); $sendto = $user; $subject = SITENAME . " " . $cname; $message = EB_CLANM_L39 . $username . EB_CLANM_L40 . $cname . EB_CLANM_L41 . EB_CLANM_L43; sendNotification($sendto, $subject, $message, $fromid = 0); // Send email $message = EB_CLANM_L39 . $username . EB_CLANM_L39 . $cname . EB_CLANM_L42 . SITEURLBASE . e_PLUGIN_ABS . "ebattles/claninfo.php?clanid=" . $cid . EB_CLANM_L43; require_once e_HANDLER . "mail.php"; sendemail($useremail, $subject, $message); } }
* ClanInfo_process.php * */ require_once e_PLUGIN . 'ebattles/include/clan.php'; require_once e_PLUGIN . 'ebattles/include/event.php'; if (isset($_POST['joindivision'])) { $div_id = $_POST['division']; $division = new Division($div_id); $q = "SELECT " . TBL_CLANS . ".*, " . TBL_DIVISIONS . ".*" . " FROM " . TBL_CLANS . ", " . TBL_DIVISIONS . " WHERE (" . TBL_DIVISIONS . ".DivisionID = '{$div_id}')" . " AND (" . TBL_DIVISIONS . ".Clan = " . TBL_CLANS . ".ClanID)"; $result = $sql->db_Query($q); $clan_password = mysql_result($result, 0, TBL_CLANS . ".password"); $gid = mysql_result($result, 0, TBL_DIVISIONS . ".Game"); if ($clan_password == "" || $_POST['joindivisionPassword'] == $clan_password) { $Name = $_POST["gamername"]; $UniqueGameID = $_POST["gameruniquegameid"]; $gamerID = updateGamer(USERID, $gid, $Name, $UniqueGameID); $division->addMember(USERID, FALSE); } } if (isset($_POST['quitdivision'])) { $div_id = $_POST['division']; $division = new Division($div_id); // Check that the member has made no games with this division $q_MemberScores = "SELECT " . TBL_MEMBERS . ".*, " . TBL_TEAMS . ".*, " . TBL_PLAYERS . ".*, " . TBL_SCORES . ".*" . " FROM " . TBL_MEMBERS . ", " . TBL_TEAMS . ", " . TBL_PLAYERS . ", " . TBL_SCORES . " WHERE (" . TBL_MEMBERS . ".User = "******")" . " AND (" . TBL_MEMBERS . ".Division = '{$div_id}')" . " AND (" . TBL_TEAMS . ".Division = '{$div_id}')" . " AND (" . TBL_PLAYERS . ".Team = " . TBL_TEAMS . ".TeamID)" . " AND (" . TBL_SCORES . ".Player = " . TBL_PLAYERS . ".PlayerID)"; $result_MemberScores = $sql->db_Query($q_MemberScores); $numMemberScores = mysql_numrows($result_MemberScores); if ($numMemberScores == 0) { $division->deleteMemberPlayers(); $division->deleteMember(); } }
header("Location: eventinfo.php?eventid={$event_id}"); } if (isset($_POST['teamcheckinevent'])) { $team_id = $_POST['team']; checkinTeam($team_id); if ($event->getField('FixturesEnable') == TRUE && $event->getField('Status') == 'active') { $event->brackets(true); } $event->setFieldDB('IsChanged', 1); header("Location: eventinfo.php?eventid={$event_id}"); } if (isset($_POST['joinevent'])) { if ($event->getField('password') == "" || $_POST['joinEventPassword'] == $event->getField('password')) { $Name = $_POST["gamername"]; $UniqueGameID = $_POST["gameruniquegameid"]; updateGamer(USERID, $event->getField('Game'), $Name, $UniqueGameID); // Check gold here. if (is_gold_system_active() && $gold_obj->gold_balance(USERID) < $event->getField('GoldEntryFee')) { $error_str .= EB_EVENT_L98 . " {$GOLD_PREF['gold_currency_name']}" . "</br>"; $error_str .= EB_EVENT_L99 . $gold_obj->formation($gold_obj->gold_balance(USERID)) . "</br>"; } else { $event->eventAddPlayer(USERID, 0, FALSE); if (is_gold_system_active() && $event->getField('GoldEntryFee') > 0) { $gold_param['gold_user_id'] = USERID; $gold_param['gold_who_id'] = 0; $gold_param['gold_amount'] = $event->getField('GoldEntryFee'); $gold_param['gold_type'] = EB_L1; $gold_param['gold_action'] = "debit"; $gold_param['gold_plugin'] = "ebattles"; $gold_param['gold_log'] = EB_GOLD_L7 . ": event=" . $event_id . ", user=" . USERID; $gold_param['gold_forum'] = 0;