function get_permissions($user_id) { global $sql; global $pref; $userclass = 0; $can_edit = 0; $can_approve = 0; $can_report = 0; $can_schedule = 0; $can_delete = 0; $can_submit_media = 0; $can_delete_media = 0; $match_id = $this->fields['MatchID']; $event_id = $this->fields['Event']; $event = new Event($event_id); $type = $event->getField('Type'); $competition_type = $event->getCompetitionType(); $mStatus = $this->fields['Status']; $reported_by = $this->fields['ReportedBy']; // Is the user a moderator? $q_Mods = "SELECT " . TBL_EVENTMODS . ".*" . " FROM " . TBL_EVENTMODS . " WHERE (" . TBL_EVENTMODS . ".Event = '{$event_id}')" . " AND (" . TBL_EVENTMODS . ".User = "******")"; $result_Mods = $sql->db_Query($q_Mods); $numMods = mysql_numrows($result_Mods); switch ($event->getMatchPlayersType()) { case 'Players': $reporter_matchteam = 0; $q_Reporter = "SELECT DISTINCT " . TBL_SCORES . ".*" . " FROM " . TBL_MATCHS . ", " . TBL_SCORES . ", " . TBL_PLAYERS . ", " . TBL_GAMERS . ", " . TBL_USERS . " WHERE (" . TBL_MATCHS . ".MatchID = '{$match_id}')" . " AND (" . TBL_SCORES . ".MatchID = " . TBL_MATCHS . ".MatchID)" . " AND (" . TBL_PLAYERS . ".PlayerID = " . TBL_SCORES . ".Player)" . " AND (" . TBL_PLAYERS . ".Gamer = " . TBL_GAMERS . ".GamerID)" . " AND (" . TBL_GAMERS . ".User = '******')"; $result_Reporter = $sql->db_Query($q_Reporter); $numRows = mysql_numrows($result_Reporter); if ($numRows > 0) { $reporter_matchteam = mysql_result($result_Reporter, 0, TBL_SCORES . ".Player_MatchTeam"); } // Is the user an opponent of the reporter? $q_Opps = "SELECT DISTINCT " . TBL_SCORES . ".*" . " FROM " . TBL_MATCHS . ", " . TBL_SCORES . ", " . TBL_PLAYERS . ", " . TBL_GAMERS . ", " . TBL_USERS . " WHERE (" . TBL_MATCHS . ".MatchID = '{$match_id}')" . " AND (" . TBL_SCORES . ".MatchID = " . TBL_MATCHS . ".MatchID)" . " AND (" . TBL_PLAYERS . ".PlayerID = " . TBL_SCORES . ".Player)" . " AND (" . TBL_SCORES . ".Player_MatchTeam != '{$reporter_matchteam}')" . " AND (" . TBL_PLAYERS . ".Gamer = " . TBL_GAMERS . ".GamerID)" . " AND (" . TBL_GAMERS . ".User = "******")"; $result_Opps = $sql->db_Query($q_Opps); $numOpps = mysql_numrows($result_Opps); break; case 'Teams': $reporter_matchteam = 0; $q_Reporter = "SELECT DISTINCT " . TBL_SCORES . ".*" . " FROM " . TBL_MATCHS . ", " . TBL_SCORES . ", " . TBL_TEAMS . ", " . TBL_PLAYERS . ", " . TBL_GAMERS . ", " . TBL_USERS . " WHERE (" . TBL_MATCHS . ".MatchID = '{$match_id}')" . " AND (" . TBL_SCORES . ".MatchID = " . TBL_MATCHS . ".MatchID)" . " AND (" . TBL_TEAMS . ".TeamID = " . TBL_SCORES . ".Team)" . " AND (" . TBL_PLAYERS . ".Team = " . TBL_TEAMS . ".TeamID)" . " AND (" . TBL_PLAYERS . ".Gamer = " . TBL_GAMERS . ".GamerID)" . " AND (" . TBL_GAMERS . ".User = '******')"; $result_Reporter = $sql->db_Query($q_Reporter); $numRows = mysql_numrows($result_Reporter); if ($numRows > 0) { $reporter_matchteam = mysql_result($result_Reporter, 0, TBL_SCORES . ".Player_MatchTeam"); } // Is the user an opponent of the reporter? $q_Opps = "SELECT DISTINCT " . TBL_SCORES . ".*" . " FROM " . TBL_MATCHS . ", " . TBL_SCORES . ", " . TBL_TEAMS . ", " . TBL_PLAYERS . ", " . TBL_GAMERS . ", " . TBL_USERS . " WHERE (" . TBL_MATCHS . ".MatchID = '{$match_id}')" . " AND (" . TBL_SCORES . ".MatchID = " . TBL_MATCHS . ".MatchID)" . " AND (" . TBL_SCORES . ".Player_MatchTeam != '{$reporter_matchteam}')" . " AND (" . TBL_TEAMS . ".TeamID = " . TBL_SCORES . ".Team)" . " AND (" . TBL_PLAYERS . ".Team = " . TBL_TEAMS . ".TeamID)" . " AND (" . TBL_PLAYERS . ".Gamer = " . TBL_GAMERS . ".GamerID)" . " AND (" . TBL_GAMERS . ".User = "******")"; $result_Opps = $sql->db_Query($q_Opps); $numOpps = mysql_numrows($result_Opps); //dbg: echo "numOpps: $numOpps, mt: $reporter_matchteam<br />"; break; default: } // Is the user a player in the match & not banned? switch ($event->getMatchPlayersType()) { case 'Players': $q_UserPlayers = "SELECT DISTINCT " . TBL_SCORES . ".*" . " FROM " . TBL_MATCHS . ", " . TBL_SCORES . ", " . TBL_PLAYERS . ", " . TBL_GAMERS . ", " . TBL_USERS . " WHERE (" . TBL_MATCHS . ".MatchID = '" . $match_id . "')" . " AND (" . TBL_SCORES . ".MatchID = " . TBL_MATCHS . ".MatchID)" . " AND (" . TBL_PLAYERS . ".PlayerID = " . TBL_SCORES . ".Player)" . " AND (" . TBL_PLAYERS . ".Banned != 1)" . " AND (" . TBL_PLAYERS . ".Gamer = " . TBL_GAMERS . ".GamerID)" . " AND (" . TBL_GAMERS . ".User = "******")"; $result_UserPlayers = $sql->db_Query($q_UserPlayers); $numUserPlayers = mysql_numrows($result_UserPlayers); //dbg: echo "numUserPlayers: $numUserPlayers<br>"; break; case 'Teams': $q_UserPlayers = "SELECT DISTINCT " . TBL_SCORES . ".*" . " FROM " . TBL_MATCHS . ", " . TBL_SCORES . ", " . TBL_TEAMS . ", " . TBL_PLAYERS . ", " . TBL_GAMERS . ", " . TBL_USERS . " WHERE (" . TBL_MATCHS . ".MatchID = '" . $match_id . "')" . " AND (" . TBL_SCORES . ".MatchID = " . TBL_MATCHS . ".MatchID)" . " AND (" . TBL_TEAMS . ".TeamID = " . TBL_SCORES . ".Team)" . " AND (" . TBL_TEAMS . ".Banned != 1)" . " AND (" . TBL_PLAYERS . ".Team = " . TBL_TEAMS . ".TeamID)" . " AND (" . TBL_PLAYERS . ".Banned != 1)" . " AND (" . TBL_PLAYERS . ".Gamer = " . TBL_GAMERS . ".GamerID)" . " AND (" . TBL_GAMERS . ".User = "******")"; $result_UserPlayers = $sql->db_Query($q_UserPlayers); $numUserPlayers = mysql_numrows($result_UserPlayers); //dbg: echo "numUserPlayers: $numUserPlayers<br>"; break; default: } if ($user_id == $reported_by && $mStatus == 'pending') { $can_edit = 1; } if (check_class($pref['eb_mod_class'])) { $can_delete = 1; } if ($user_id == $event->getField('Owner')) { $userclass |= eb_UC_EVENT_OWNER; $can_delete = 1; $can_approve = 1; $can_report = 1; $can_schedule = 1; $can_edit = 1; $can_submit_media = 1; $can_delete_media = 1; } if ($numMods > 0) { $userclass |= eb_UC_EB_MODERATOR; $can_delete = 1; $can_approve = 1; $can_report = 1; $can_schedule = 1; $can_edit = 1; $can_submit_media = 1; $can_delete_media = 1; } if (check_class($pref['eb_mod_class'])) { $userclass |= eb_UC_EB_MODERATOR; $can_approve = 1; $can_report = 1; $can_schedule = 1; $can_edit = 1; $can_submit_media = 1; $can_delete_media = 1; } if ($numOpps > 0) { $userclass |= eb_UC_EVENT_PLAYER; $can_approve = 1; } if ($numUserPlayers > 0) { $can_report = 1; } if ($numPlayed > 0 && check_class($pref['eb_media_submit_class'])) { $can_submit_media = 1; } if ($userclass < $event->getField('MatchesApproval')) { $can_approve = 0; } if ($event->getField('MatchesApproval') == eb_UC_NONE) { $can_approve = 0; } if ($mStatus != 'pending') { $can_approve = 0; } if ($mStatus != 'scheduled') { $can_report = 0; } if ($can_edit == 1) { if ($competition_type == 'Tournament' && $mStatus != 'scheduled') { $can_edit = 0; } } //echo "m($match_id).perm.can_report=$can_report<br>"; $permissions = array(); $permissions['userclass'] = $userclass; $permissions['can_edit'] = $can_edit; $permissions['can_approve'] = $can_approve; $permissions['can_report'] = $can_report; $permissions['can_schedule'] = $can_schedule; $permissions['can_delete'] = $can_delete; $permissions['can_submit_media'] = $can_submit_media; $permissions['can_delete_media'] = $can_delete_media; //echo "match $match_id permissions:<br>"; //var_dump($permissions); return $permissions; }
$apmFileName = 'tmp/'.$player['id']."_".md5($name).".png"; createAPMImage($player['apm'],$b->getGameLength(),$apmFileName); $apmString .= sprintf("%s:<br /><img src=\"$apmFileName\" /><br />\n",$player['name']); } */ } $text .= "</table><br />"; if ($obsCount > 0) { $text .= "Observers ({$obsCount}): {$obsString}<br />\n"; } } else { // No errors, create the match $match_id = $match->insert(); // Create scores for ($i = 0; $i < $nbr_players; $i++) { switch ($event->getMatchPlayersType()) { case 'Players': $q = "INSERT INTO " . TBL_SCORES . "(MatchID,Player,Player_MatchTeam,Player_Score,Player_Rank,Faction,Color,sColor,APM)\r\n\t\t\t\t\t\t\tVALUES (\r\n\t\t\t\t\t\t\t{$match_id},\r\n\t\t\t\t\t\t\t'" . $scores[$i]['Player'] . "',\r\n\t\t\t\t\t\t\t'" . $scores[$i]['Player_MatchTeam'] . "',\r\n\t\t\t\t\t\t\t0,\r\n\t\t\t\t\t\t\t'" . $scores[$i]['Player_Rank'] . "',\r\n\t\t\t\t\t\t\t'" . $scores[$i]['Faction'] . "',\r\n\t\t\t\t\t\t\t'" . $scores[$i]['Color'] . "',\r\n\t\t\t\t\t\t\t'" . $scores[$i]['sColor'] . "',\r\n\t\t\t\t\t\t\t'" . $scores[$i]['APM'] . "'\r\n\t\t\t\t\t\t\t)"; break; case 'Teams': break; default: $q = ''; } $result = $sql->db_Query($q); } // Update scores stats $match->match_scores_update(); // Automatically Update Players stats only if Match Approval is Disabled if ($event->getField('MatchesApproval') == eb_UC_NONE) { switch ($event->getMatchPlayersType()) {
function challengeAccept() { global $sql; global $tp; global $time; global $pref; $challenge_time = $_POST['challengedate']; // Get info about the challenge $q = "SELECT DISTINCT " . TBL_CHALLENGES . ".*, " . TBL_USERS . ".*, " . TBL_EVENTS . ".*, " . TBL_GAMES . ".*" . " FROM " . TBL_CHALLENGES . ", " . TBL_USERS . ", " . TBL_EVENTS . ", " . TBL_GAMES . " WHERE (" . TBL_CHALLENGES . ".ChallengeID = '" . $this->fields['ChallengeID'] . "')" . " AND (" . TBL_USERS . ".user_id = " . TBL_CHALLENGES . ".ReportedBy)" . " AND (" . TBL_CHALLENGES . ".Event = " . TBL_EVENTS . ".EventID)" . " AND (" . TBL_EVENTS . ".Game = " . TBL_GAMES . ".GameID)"; $result = $sql->db_Query($q); $numChallenges = mysql_numrows($result); if ($numChallenges > 0) { $event_id = mysql_result($result, 0, TBL_EVENTS . ".EventID"); $event = new Event($event_id); $cReportedBy = mysql_result($result, 0, TBL_USERS . ".user_id"); $cReportedByNickName = mysql_result($result, 0, TBL_USERS . ".user_name"); $cEventgame = mysql_result($result, 0, TBL_GAMES . ".Name"); $cEventgameicon = mysql_result($result, 0, TBL_GAMES . ".Icon"); $cStatus = mysql_result($result, 0, TBL_CHALLENGES . ".Status"); $cTime = mysql_result($result, 0, TBL_CHALLENGES . ".TimeReported"); $cChallengerpID = mysql_result($result, 0, TBL_CHALLENGES . ".ChallengerPlayer"); $cChallengedpID = mysql_result($result, 0, TBL_CHALLENGES . ".ChallengedPlayer"); $cChallengertID = mysql_result($result, 0, TBL_CHALLENGES . ".ChallengerTeam"); $cChallengedtID = mysql_result($result, 0, TBL_CHALLENGES . ".ChallengedTeam"); // Create Match ------------------------------------------ $comments = ''; $q = "INSERT INTO " . TBL_MATCHS . "(Event,ReportedBy,TimeReported, Comments, Status, TimeScheduled)\r\n\t\t\tVALUES ({$event_id}," . USERID . ", {$time}, '{$comments}', 'scheduled', {$challenge_time})"; $result = $sql->db_Query($q); $last_id = mysql_insert_id(); $match_id = $last_id; $q = "INSERT INTO " . TBL_SCORES . "(MatchID,Player,Team,Player_MatchTeam,Player_Rank)\r\n\t\t\tVALUES ({$match_id},{$cChallengerpID},{$cChallengertID},1,1)\r\n\t\t\t"; $result = $sql->db_Query($q); $q = "INSERT INTO " . TBL_SCORES . "(MatchID,Player,Team,Player_MatchTeam,Player_Rank)\r\n\t\t\tVALUES ({$match_id},{$cChallengedpID},{$cChallengedtID},2,2)\r\n\t\t\t"; $result = $sql->db_Query($q); $this->deleteChallenge(); // Send notification to all the players. $fromid = 0; $subject = SITENAME . " " . EB_MATCHR_L52; switch ($event->getMatchPlayersType()) { case 'Players': $q_Players = "SELECT DISTINCT " . TBL_USERS . ".*" . " FROM " . TBL_MATCHS . ", " . TBL_SCORES . ", " . TBL_PLAYERS . ", " . TBL_GAMERS . ", " . TBL_USERS . " WHERE (" . TBL_MATCHS . ".MatchID = '{$match_id}')" . " AND (" . TBL_SCORES . ".MatchID = " . TBL_MATCHS . ".MatchID)" . " AND (" . TBL_PLAYERS . ".PlayerID = " . TBL_SCORES . ".Player)" . " AND (" . TBL_PLAYERS . ".Gamer = " . TBL_GAMERS . ".GamerID)" . " AND (" . TBL_GAMERS . ".User = "******".user_id)"; $result_Players = $sql->db_Query($q_Players); $numPlayers = mysql_numrows($result_Players); //echo "numPlayers: $numPlayers<br>"; break; case 'Teams': $q_Players = "SELECT DISTINCT " . TBL_USERS . ".*" . " FROM " . TBL_MATCHS . ", " . TBL_SCORES . ", " . TBL_TEAMS . ", " . TBL_PLAYERS . ", " . TBL_GAMERS . ", " . TBL_USERS . " WHERE (" . TBL_MATCHS . ".MatchID = '{$match_id}')" . " AND (" . TBL_SCORES . ".MatchID = " . TBL_MATCHS . ".MatchID)" . " AND (" . TBL_TEAMS . ".TeamID = " . TBL_SCORES . ".Team)" . " AND (" . TBL_PLAYERS . ".Team = " . TBL_TEAMS . ".TeamID)" . " AND (" . TBL_PLAYERS . ".Gamer = " . TBL_GAMERS . ".GamerID)" . " AND (" . TBL_GAMERS . ".User = "******".user_id)"; $result_Players = $sql->db_Query($q_Players); $numPlayers = mysql_numrows($result_Players); //echo "numPlayers: $numPlayers<br>"; break; default: } if ($numPlayers > 0) { for ($j = 0; $j < $numPlayers; $j++) { $pname = mysql_result($result_Players, $j, TBL_USERS . ".user_name"); $pemail = mysql_result($result_Players, $j, TBL_USERS . ".user_email"); $message = EB_MATCHR_L53 . $pname . EB_MATCHR_L54 . EB_MATCHR_L55 . $event->getField('Name') . EB_MATCHR_L56; if (check_class($pref['eb_pm_notifications_class'])) { $sendto = mysql_result($result_Players, $j, TBL_USERS . ".user_id"); sendNotification($sendto, $subject, $message, $fromid); } if (check_class($pref['eb_email_notifications_class'])) { // Send email require_once e_HANDLER . "mail.php"; sendemail($pemail, $subject, $message); } } } } }