/dkp_wizard/testdir/uploaddkp.php
PHP | 440 lines | 367 code | 45 blank | 28 comment | 56 complexity | 64b79ae55eb184e32c57e366bdebb9bb MD5 | raw file
Possible License(s): GPL-3.0
- <?php
- /******************************
- * WoWRoster.net Roster
- * Copyright 2002-2006
- * Licensed under the Creative Commons
- * "Attribution-NonCommercial-ShareAlike 2.5" license
- *
- * Short summary
- * http://creativecommons.org/licenses/by-nc-sa/2.5/
- *
- * Full license information
- * http://creativecommons.org/licenses/by-nc-sa/2.5/legalcode
- * -----------------------------
- *
- * $Id: uploaddkp.php 64 2007-02-11 23:36:30Z mathos $
- *
- ******************************/
- session_start();
- require('../config/siteSettings.php');
- require('../config/site.php');
- require('config/adminClass.php');
- $ndkp = new nurfedAdmin;
- if($_GET[logout] == 'xxx') {
- $ndkp->logOut();
- }
- $ndkp->dbUser=$dbUser;
- $ndkp->dbPassword=$dbPassword;
- $ndkp->dbServer=$dbServer;
- $ndkp->dBase=$dBase;
- $ndkp->vars=$_GET;
- $ndkp->displayhtml('header');
- $bosskills = array();
- $lootlog = array();
- $attlog = array();
- $raiddata = array();
- $eventlog = array();
- $unknown_player = array();
- $unknown_item = array();
- $meta_attend = array();
- $alt_lookup = array();
- $ifbuf = array();
- if (count($_FILES) > 0)
- {
- foreach ($_FILES as $filefield => $file)
- {
- $filename = $file['tmp_name'];
- if (strtolower($file['name']) == 'ordo_dkp.lua')
- {
- $ifbuf = file($filename);
- }
- else
- {
- print("No Valid File Received<br>");
- exit;
- }
- }
- //$ifbuf = file('Ordo_DKP.lua');
- $block = '';
- $ts = 0;
- $maxts = 0;
-
- foreach($ifbuf as $buf) {
- if(preg_match('/^ORDO_SAVED_([A-Z]+) = {/', $buf, $matches)) {
- $block = strtolower($matches[1]);
- } elseif(preg_match('/^\t\["?(\d+)"?\] = {/', $buf, $matches)) {
- $ts = $matches[1];
- if($ts > $maxts) { $maxts = $ts; }
- $store = '$' . $block . '[] = "' . $ts . '";';
- #print "<pre>$store</pre>\n";
- eval($store);
- } elseif(preg_match('/^\t\["(.+)"\] = \"(.+)\",/', $buf, $matches)) {
- $name = $matches[1];
- $data = $matches[2];
- $raiddata[$block][$name] = $data;
- # print "<p>" . $block . ":" . $name . " = " . $raiddata[$block][$name] . "</p>";
- } elseif(preg_match('/^\t\t\["?([^"\]]+)"?\] = "?([^"\]]+)"?,/', $buf, $matches)) {
- $fieldname = $matches[1];
- $data = $matches[2];
- # print "<pre>\$raiddata[$block][$ts][$fieldname] = $data</pre>\n";
- $raiddata[$block][$ts][$fieldname] = $data;
- if($fieldname == 'player') {
- if(!player_exists($data)) {
- $unknown_player[] = $data;
- }
- }
- if($fieldname == 'item') {
- if(!item_exists($data)) {
- $unknown_item[] = $data;
- }
- }
- if($fieldname == 'playerlist') {
- $pbuf = split(" ",$data);
- foreach($pbuf as $p) {
- if($p != '') {
- if(!player_exists($p)) {
- $unknown_player[] = $p;
- } else {
- $meta_attend[] = $p;
- }
- }
- }
- }
- }
- }
-
- $maxts++;
-
- sort($bosskills);
- sort($lootlog);
- sort($attlog);
-
- $playercount = update_alts();
- for($i=0; $i<count($meta_attend); $i++) {
- $meta_attend[$i] = alt_map_to_main($meta_attend[$i]);
- }
-
- sort($unknown_player);
- sort($unknown_item);
- sort($meta_attend);
- $unknown_player = array_unique($unknown_player);
- $unknown_item = array_unique($unknown_item);
- $meta_attend = array_unique($meta_attend);
-
- $attlog[] = $maxts;
- $raiddata['attlog'][$maxts]['location'] = 'Meta Snapshot';
- $raiddata['attlog'][$maxts]['comments'] = 'Smart snapshot auto-generated by sDKP';
- $raiddata['attlog'][$maxts]['playerlist'] = '';
- foreach($meta_attend as $player) {
- $raiddata['attlog'][$maxts]['playerlist'] .= $player . ' ';
- }
- ?>
- <table id="mainpage">
- <tr><td valign="top">
- <div id='maincontent'>
- <h1 class="titles">Unknown Members (<?php print count($unknown_player) ?>)</h1>
- <div style="margin-left: 30px;">
- <?php list_unknown_players(); ?>
- </div>
- <h1 class="titles">Unknown Items (<?php print count($unknown_item) ?>)</h1>
- <div style="margin-left: 30px;">
- <?php list_unknown_items(); ?>
- </div>
- <h1><?php print $playercount; ?> Players Mapped</h1>
- <div class="break"></div>
-
- <h1 class="titles">Attendance Records (<?php print count($attlog); ?>)</h1>
- <div style="margin-left: 30px;">
- <?php list_attlogs(); ?>
- </div>
- <div class="break"></div>
-
- <h1 class="titles">Boss Kills (<?php print count($bosskills); ?>)</h1>
- <div style="margin-left: 30px;">
- <?php list_bosskills(); ?>
- </div>
- <div class="break"></div>
-
- </div>
- <td valign="top">
- <div id='rightcontent'>
- <?php include('../includes/newsitems.php'); ?>
- <div class="break"></div>
- <?php include('../includes/moreNDKP.php'); ?>
- </div>
- </td>
- </tr>
- </table>
- </div>
- <div id="footer">
- Brought to you by <a href="http://slacker.com/~nugget/projects/slackerdkp/">SlackerDKP</a>
- </div>
- <?php
- }
- else
- {
- echo '<form enctype="multipart/form-data" method="post"><input name="dkpfile" type="file"><br><input type="submit"></form>';
- }
- function alt_map_to_main($name) {
- global $alt_lookup;
- if($alt_lookup[$name]) {
- return $alt_lookup[$name];
- } else {
- return $name;
- }
- }
- function update_alts() {
- global $raiddata, $alt_lookup;
- $sql = "update NDKP_members set alt_of = 0";
- $result = mysql_query($sql);
- $playercount = 0;
- while (list($key,$val) = each($raiddata)) {
- # print "<p>$key</p>";
- if($key == 'alts') {
- while (list($alt,$main) = each($val)) {
- $sql = "select player_id from NDKP_members where name = '$main'";
- $result = mysql_fetch_assoc(mysql_query($sql));
- $main_id = $result['player_id'];
- $sql = "update NDKP_members set alt_of = '$main_id' where name = '$alt'";
- mysql_query($sql);
- $alt_lookup[$alt] = $main;
- $playercount++;
- }
- }
- }
- return $playercount;
- }
- function player_exists($name) {
- $sql = "select player_id from NDKP_members where name = '$name'";
- $result = mysql_query($sql);
- if(mysql_affected_rows()>0) {
- //print $sql.'<BR>';
- $result = mysql_fetch_assoc($result);
- $result = $result["player_id"];
- }else{
- $sql = "select player_id from NDKP_alternates where altname = '$name'";
- $result = mysql_query($sql);
- if(mysql_affected_rows()>0) {
- //print $sql.'<BR>';
- $result = mysql_fetch_assoc($result);
- $result = $result["player_id"];
- }
- }
- return $result;
- }
- function list_unknown_players() {
- global $unknown_player, $raiddata;
- print "<ol>\n";
- foreach($unknown_player as $player) {
- print "<li style=\"color: red;\">$player";
- if($raiddata[classes][$player]) {
- print '<form action="modules/addPlayer.php" method="post">';
- print '<input type="hidden" name="player" value="' . $player . '"/>';
- print '<input type="hidden" name="class" value="' . $raiddata[classes][$player] . '"/>';
- print '<input type="submit" value="Add"/>';
- print '</form>';
- }
- print "</li>\n";
- }
- print "</ol>\n";
- }
- function item_exists($name) {
- $name = addslashes($name);
- $sql = "select item_id from NDKP_items where name = '$name'";
- $result = mysql_query($sql);
- if($result) {
- $result = mysql_fetch_assoc($result);
- $result = $result["item_id"];
- }
- return $result;
- }
- function list_unknown_items() {
- global $unknown_item;
- print "<ol>\n";
- foreach($unknown_item as $item) {
- print "<li style=\"color: red;\">$item</li>\n";
- }
- print "</ol>\n";
- }
- function list_attlogs() {
- global $raiddata;
- global $attlog;
- print "<ol>\n";
- foreach($attlog as $attrec) {
- $ts = strftime("%m/%d/%y %H:%M:%S",$attrec);
- $plist = str_replace(' ', "\n", $raiddata[attlog][$attrec][playerlist]);
- $type = 'start';
- if($raiddata[attlog][$attrec][comments] == 'Meta Snapshot') {
- $type = 'end';
- }
- print "<li>";
- print $raiddata[attlog][$attrec][location] . " at " . $ts;
- if($record = att_exists($attrec)) {
- att_edit_form($record);
- } else {
- att_add_form($ts,$type,$raiddata[attlog][$attrec][comments],$plist);
- }
- print "</li>\n";
- }
- print "</ol>\n";
- }
- function att_add_form($ts,$type,$comments,$playerlist) {
- $comments = addslashes($comments);
- print '<form action="modules/attendance.php" method="post">';
- print '<input type="hidden" name="raiddate" value="' . $ts . '">';
- print '<input type="hidden" name="type" value="' . $type . '">';
- print '<input type="hidden" name="notes" value="' . $comments . '">';
- print '<input type="hidden" name="attendance" value="' . $playerlist . '">';
- print '<input style="width: 200px" name="submit" value="Add Attendance" type="submit">';
- print '</form>';
- }
- function att_edit_form($record) {
- # print '<form action="edit-timeClock.php" method="get">';
- # print '<input type="hidden" name="id" value="' . $record . '">';
- # print '<input style="width: 200px" name="submit" value="Edit Attendance" type="submit">';
- # print '</form>';
- print '<br /><i>This record has already been added</i> ';
- print ' [<a href="edit-timeClock.php?id=' . $record . '">edit</a>]';
- }
- function att_exists($attrec) {
- $ts = strftime("%Y-%m-%d %H:%M:%S",$attrec);
- $sql = "select id from NDKP_attendancetype where date = '$ts'";
- $result = mysql_query($sql);
- if($result) {
- $result = mysql_fetch_assoc($result);
- $result = $result["id"];
- }
- return $result;
- }
- function list_bosskills() {
- global $raiddata;
- global $bosskills;
- print "<ol>\n";
- for($i=0; $i<count($bosskills); $i++) {
- $bossrec = $bosskills[$i];
- $nextrec = $bosskills[$i+1];
- if(!$nextrec) {
- $nextrec = 9999999999;
- }
- $ts = strftime("%m/%d/%y %H:%M:%S",$bossrec);
- $plist = str_replace(' ', "\n", $raiddata[bosskills][$bossrec][playerlist]);
- print "<li>";
- print $raiddata[bosskills][$bossrec][bossname] . " at " . $ts;
- if($record = boss_exists($bossrec)) {
- boss_edit_form($record);
- } else {
- boss_add_form($bossrec,$nextrec,$ts,
- $raiddata[bosskills][$bossrec][bossname],
- $raiddata[bosskills][$bossrec][location],
- $raiddata[bosskills][$bossrec][comments],
- $plist);
- }
- print "</li>\n";
- }
- print "</ol>\n";
- }
- function boss_add_form($epochlow,$epochhigh,$ts,$bossname,$location,$comments,$playerlist) {
- $comments = addslashes($comments);
- $location = addslashes($location);
- $bossname = addslashes($bossname);
- print '<form action="modules/addRaid.php" method="post">';
- print '<input type="hidden" name="raiddate" value="' . $ts . '">';
- print '<input type="hidden" name="newdungeon" value="' . $location . '">';
- print '<input type="hidden" name="newboss" value="' . $bossname . '">';
- print '<input type="hidden" name="notes" value="' . $comments . '">';
- print '<input type="hidden" name="attendance" value="' . $playerlist . '">';
- print '<input style="width: 200px" name="submit" value="Add Raid" type="submit">';
- boss_loot_fields($epochlow,$epochhigh);
- print '</form>';
- }
- function boss_loot_fields($low,$high) {
- global $lootlog;
- global $raiddata;
- global $eventlog;
- $items = 0; $known_items = 0;
- $thiskill = 0;
- for ($i=0; $i<=count($eventlog); $i++) {
- $ets = $raiddata[eventlog][$i][ts];
- $etype = $raiddata[eventlog][$i][type];
- if($etype == 'BOSSKILL') {
- if($ets == $low) {
- $thiskill = 1;
- } else {
- if($thiskill == 1) {
- $thiskill = 0;
- }
- }
- }
- if($etype == 'LOOT') {
- $ltype = 'bid';
- if(isset($raiddata[lootlog][$ets][type])) {
- $ltype = $raiddata[lootlog][$ets][type];
- }
- if(($thiskill == 1) and ($ltype != 'DE') and ($ltype != 'bank')) {
- $items++;
- if($item_id = item_exists($raiddata[lootlog][$ets][item])) {
- $known_items++;
- print "\n\n";
- print '<input type="hidden" name="looters[]" value="' . player_exists($raiddata[lootlog][$ets][player]) . '">';
- print '<input type="hidden" name="items[]" value="' . $item_id . '">';
- print '<input type="hidden" name="fullprice[]" value="1">';
- print "\n\n";
- }
- }
- }
-
- }
- print "<i>$items items ($known_items known)</i>";
- }
- function boss_edit_form($record) {
- print '<br /><i>This record has already been added (raid #' . $record . ')</i> ';
- # print ' [<a href="editRaid.php?id=' . $record . '">edit</a>]';
- }
- function boss_exists($bossrec) {
- $ts = strftime("%Y-%m-%d %H:%M:%S",$bossrec);
- $sql = "select raid_id from NDKP_raids where raid_date = '$ts'";
- $result = mysql_query($sql);
- if($result) {
- $result = mysql_fetch_assoc($result);
- $result = $result["raid_id"];
- }
- return $result;
- }
- ?>
- </body>
- </html>