Browse files

Changed the config and renamed the report file. All leagues will use …

…the same PHP script
  • Loading branch information...
1 parent 96cb0b7 commit b661581f291dffd09e8fab8790e378df08fe4dc3 Vladimir Jimenez committed Apr 6, 2012
Showing with 162 additions and 16 deletions.
  1. +9 −4 auxfuncts.cpp
  2. +11 −10 leagueOverSeer.cfg
  3. +1 −2 leagueOverSeer.h
  4. +141 −0 leagueOverSeer.php
View
13 auxfuncts.cpp
@@ -29,22 +29,27 @@ int leagueOverSeer::loadConfig(const char* cmdLine) //Load the plugin configurat
if (config.errors) bz_shutdown(); //Shutdown the server
//Extract all the data in the configuration file and assign it to plugin variables
+ LEAGUE = config.item(section, "LEAGUE");
rotLeague = toBool(config.item(section, "ROTATIONAL_LEAGUE"));
mapchangePath = (config.item(section, "MAPCHANGE_PATH")).c_str();
gameoverReport = toBool(config.item(section, "GAMEOVER_REPORT"));
- REPORT_URL = config.item(section, "MATCH_REPORT_URL");
- QUERY_URL = config.item(section, "TEAM_QUERY_URL");
+ LEAGUE_URL = config.item(section, "MATCH_REPORT_URL");
gracePeriod = atoi((config.item(section, "GRACE_PERIOD")).c_str());
DEBUG = atoi((config.item(section, "DEBUG_LEVEL")).c_str());
mottoReplacer = toBool(config.item(section, "MOTTOFILTER_REPLACER"));
rejoinPrevention = toBool(config.item(section, "REJOIN_PREVENTION"));
//Check for errors in the configuration data. If there is an error, shut down the server
- if (REPORT_URL == "" || QUERY_URL == "")
+ if (strcmp(LEAGUE, "") == 0)
{
- bz_debugMessage(0, "*** DEBUG::Match Over Seer::No URLs were choosen to report matches or query teams. ***");
+ bz_debugMessage(0, "*** DEBUG::Match Over Seer::No league was specified ***");
bz_shutdown();
}
+ if (strcmp(LEAGUE_URL, "") == 0)
+ {
+ bz_debugMessage(0, "*** DEBUG::Match Over Seer::No URLs were choosen to report matches or query teams. ***");
+ bz_shutdown();
+ }
if (gracePeriod > bz_getTimeLimit())
{
bz_debugMessage(0, "*** DEBUG::Match Over Seer::Invalid grace period in the configuration file. ***");
View
21 leagueOverSeer.cfg
@@ -5,6 +5,11 @@
# this configuration file.
[matchOverSeer]
+ # League
+ # ------
+ # Supported leagues: DUC, GU, OL
+
+ LEAGUE = OL
# Rotational League
# -----------------
@@ -27,21 +32,17 @@
# /gameover Report
# ----------------
# If you would like the plugin to report any match that was ended
- # by a /gameover or /superkill, then make sure that this value is
- # set to 'true' and if you don't want the match to be reported, be
- # sure to set it to 'false'
+ # by a /gameover, then make sure that this value is set to 'true'
+ # and if you don't want the match to be reported, be sure to set
+ # it to 'false'
- GAMEOVER_REPORT = true
+ GAMEOVER_REPORT = false
# Website URLs
# -----------
- # The first URL is the URL where match data will be sent to be added
- # to the league website. The second URL, is the URL that will be used
- # to query the site and return the team that each player on the server
- # belongs too.
+ # The URL of the main leagueOverSeer PHP script.
- MATCH_REPORT_URL = http://localhost/auto_report.php
- TEAM_QUERY_URL = http://localhost/team_query.php
+ LEAGUE_OVER_SEER_URL = http://localhost/leagueOverSeer.php
# Debug Level
# -----------
View
3 leagueOverSeer.h
@@ -50,10 +50,9 @@ class leagueOverSeer : public bz_Plugin, public bz_CustomSlashCommandHandler, pu
//All the variables that will be used in the plugin
bool officialMatch, matchCanceled, funMatch, rotLeague, gameoverReport, mottoReplacer, rejoinPrevention;
- double matchStartTime;
double lastQuery[256];
int DEBUG, gracePeriod, RTW, GTW, BTW, PTW;
- std::string REPORT_URL, QUERY_URL, map;
+ std::string LEAGUE_URL, LEAGUE, map;
const char* mapchangePath;
struct teamQueries { //Stores all the queries that a player request
View
141 leagueOverSeer.php
@@ -0,0 +1,141 @@
+<?php
+$ips = array('78.129.242.95', '78.129.242.11', '207.192.70.176', '97.107.129.174', '85.210.203.221');
+if (!in_array($_SERVER['REMOTE_ADDR'], $ips)) die('Error: 403 - Forbidden');
+
+ini_set('display_errors', 'off');
+
+require('.config/cfg.php');
+
+function section_entermatch_calculateRating ($scoreA, $scoreB, $oldA, $oldB, &$newRed, &$newGreen){
+ if ($scoreA > $scoreB)
+ $score = 1;
+ elseif ($scoreA < $scoreB)
+ $score = -1;
+ else $score = 0;
+
+ $factor = 50.0;
+ $S = 1.0 / (1 + pow(10.0, ($oldB - $oldA) / 400.0));
+ $Sc = ($score + 1) / 2.0;
+ $diff = abs($factor * ($Sc - $S));
+ if($diff < 1)
+ $diff = 1;
+ $d = floor($diff + 0.5);
+ if($Sc - $S < 0)
+ $d = -$d;
+ if($Sc - $S == 0)
+ $d = 0;
+ $newRed = $oldA + $d;
+ $newGreen = $oldB - $d;
+}
+
+//$_POST['players'] = 'mdskpr"brad"allejo"kierra"dexter"wayney"red-der"nth"rabbit"-faith-';
+if (isset($_POST['players'])) {
+ $players = explode('"', $_POST['players']);
+ //if (count($players) == 0))
+ $where = '';
+ foreach ($players AS $p) {
+ $where .= "l_player.callsign = '".mysql_real_escape_string($p)."' OR ";
+ }
+ $where = substr($where, 0, -4);
+ $res = mysql_query("SELECT l_player.callsign,l_team.name league_team FROM l_player LEFT JOIN l_team ON l_player.team = l_team.id WHERE $where ORDER BY l_team.name");
+ if (mysql_num_rows($res) == 0) {
+ echo "Could not get data";
+ }
+ else {
+ $lastTeam = '';
+ while ($row = mysql_fetch_object($res)) {
+ if (empty($row->league_team)) $row->league_team = 'Teamless';
+ if (($lastTeam != $row->league_team) || (empty($lastTeam))) echo "*** $row->league_team ***\n";
+ echo "$row->callsign\n";
+ $lastTeam = $row->league_team;
+ }
+ }
+}
+else if (isset($_POST['redTeamWins'])) {
+
+// remove this
+// 0|1|140|2011-12-19 23:56:56|hix|mdskpr"Rexflex"llrr"Your Imagination"ayden"apodemus sylvaticus"D3ad Turtle|tox"123456789"dgdog"brad|hix
+die("{$_POST['redTeamWins']}|{$_POST['greenTeamWins']}|{$_POST['matchTime']}|{$_POST['matchDate']}|{$_POST['mapPlayed']}|{$_POST['redPlayers']}|{$_POST['greenPlayers']}|{$_POST['mapPlayed']}");
+/*$_POST['redTeamWins'] = 0;
+$_POST['greenTeamWins'] = 1;
+$_POST['matchTime'] = 140;
+$_POST['matchDate'] = '2011-12-19 23:56:56';
+$_POST['mapPlayed'] = 'hix';
+$_POST['redPlayers'] = 'mdskpr"Rexflex"llrr"Your Imagination"ayden"apodemus sylvaticus"D3ad Turtle';
+$_POST['greenPlayers'] = 'tox"123456789"dgdog"brad';*/
+
+
+$_POST['redTeamWins'] = (int)$_POST['redTeamWins'];
+$_POST['greenTeamWins'] = (int)$_POST['greenTeamWins'];
+$_POST['matchTime'] = (int)$_POST['matchTime'] / 60;
+$_POST['matchDate'] = mysql_real_escape_string($_POST['matchDate']);
+$_POST['mapPlayed'] = mysql_real_escape_string($_POST['mapPlayed']);
+$_POST['redPlayers'] = mysql_real_escape_string($_POST['redPlayers']);
+$_POST['greenPlayers'] = mysql_real_escape_string($_POST['greenPlayers']);
+
+
+/*$arr = explode("\n", $_POST['data']);
+$info = explode(" ", $arr[0]);
+$redScore = $info[0];
+$greenScore = $info[1];
+$map = substr($info[2], 0, -5);
+$time = round($info[3]/60);
+unset($arr[0]);*/
+
+
+
+$_POST['redPlayers'] = explode('"', stripslashes($_POST['redPlayers']));
+$_POST['greenPlayers'] = explode('"', stripslashes($_POST['greenPlayers']));
+
+/*foreach ($arr AS $p) {
+ if ($p == "") continue;
+ $team = substr($p, 0, 1);
+ if ($team == 1) $redTeam[] = substr($p, 1);
+ else if ($team == 2) $greenTeam[] = substr($p, 1);
+}*/
+
+$res = mysql_query("SELECT team,name,score FROM l_player LEFT JOIN l_team ON l_player.team = l_team.id WHERE callsign = '{$_POST['redPlayers'][0]}'") or die('Error: database error.'.mysql_error());
+$row = mysql_fetch_assoc($res);
+$redTeamID = $row['team'];
+$redOldScore = $row['score'];
+$redTeamName = $row['name'];
+
+$res = mysql_query("SELECT team,name,score FROM l_player LEFT JOIN l_team ON l_player.team = l_team.id WHERE callsign = '{$_POST['greenPlayers'][0]}'") or die('Error: database error.');
+$row = mysql_fetch_assoc($res);
+$greenTeamID = $row['team'];
+$greenOldScore = $row['score'];
+$greenTeamName = $row['name'];
+
+if (($redTeamID < 1) || ($greenTeamID < 1) || ($redTeamID == $greenTeamID)) die('Error: teams could not be detected.');
+
+section_entermatch_calculateRating($redScore, $greenScore, $redOldScore, $greenOldScore, &$newRed, &$newGreen);
+
+$diff = abs($newGreen - $greenOldScore);
+
+$now = gmdate("Y-m-d H:i:s");
+
+$log = "Red: {$_POST['redTeamWins']} - Green: {$_POST['greenTeamWins']} - Map: {$_POST['mapPlayed']} - Time: $now - Red Team: $redTeamID [$redOldScore => $newRed] - Green Team: $greenTeamID [$greenOldScore => $newGreen]\n";
+
+if ($_POST['redTeamWins'] > $_POST['greenTeamWins'])
+ $sql = "INSERT INTO bzl_match (team1,score1,team2,score2,tsactual,identer,tsenter,oldrankt1,oldrankt2,newrankt1,newrankt2,length,map) VALUES($redTeamID,{$_POST['redTeamWins']},$greenTeamID,{$_POST['greenTeamWins']},'$now',337,'$now',$redOldScore,$greenOldScore,$newRed,$newGreen,{$_POST['matchTime']},'{$_POST['mapPlayed']}')";
+else
+ $sql = "INSERT INTO bzl_match (team1,score1,team2,score2,tsactual,identer,tsenter,oldrankt1,oldrankt2,newrankt1,newrankt2,length,map) VALUES($greenTeamID,{$_POST['greenTeamWins']},$redTeamID,{$_POST['redTeamWins']},'$now',337,'$now',$greenOldScore,$redOldScore,$newGreen,$newRed,{$_POST['matchTime']},'{$_POST['mapPlayed']}')";
+mysql_query($sql) or die('Error: database error.');
+//echo '<br /><br />'.$sql.'<br /><br />';
+
+mysql_query("UPDATE l_team SET score = $newRed, active = 'yes' WHERE id = $redTeamID");
+mysql_query("UPDATE l_team SET score = $newGreen, active = 'yes' WHERE id = $greenTeamID");
+
+if ($_POST['redTeamWins'] > $_POST['greenTeamWins'])
+ echo "Match entered: (+/- $diff) $redTeamName [{$_POST['redTeamWins']}] vs [{$_POST['greenTeamWins']}] $greenTeamName";
+else
+ echo "Match entered: (+/- $diff) $greenTeamName [{$_POST['greenTeamWins']}] vs [{$_POST['redTeamWins']}] $redTeamName";
+
+//file_put_contents('lol.txt', "\n\n(+/- $diff) $redTeamName [$redScore] vs [$greenScore] $greenTeamName\n{$_POST['redTeamWins']}|{$_POST['greenTeamWins']}|{$_POST['matchTime']}|{$_POST['matchDate']}|{$_POST['mapPlayed']}|{$_POST['redPlayers']}|{$_POST['greenPlayers']}|{$_POST['mapPlayed']}", FILE_APPEND);
+
+file_put_contents('autoreport39103.txt', $log, FILE_APPEND);
+}
+else {
+echo "Error: 404 - Not Found";
+}
+?>

0 comments on commit b661581

Please sign in to comment.