<?php
/******************************
* GetDKP Plus
*
* © Corgan @ Server Antonidas PvE German -> www.seniorenraid.de
* ------------------
* getdkp.php
*
* Version 2.4
* 06/25/06
* 06/29/07 - Specialchar support
* 06/18/11 - multidkp support
* 07/03/01 - new item iterration
* Support English / German -> http://www.seniorenraid.de/forum/forumdisplay.php?f=13
* 07/05/13 support for dkp.exe 5.0
******************************/
############# you dont have to change anything below !!!! ######################################
#################################################################################################
$version = "2.6";
$total_players = 0;
$total_items = 0;
$total_points = 0;
$eqdkp_version = "1.3.x";
$date_created = date("d.m.y G:i:s");
$startString = "--[START]\n";
$endString = "\n--[END]";
$eqdkp_root_path = './';
include_once($eqdkp_root_path . 'common.php');
echo "function SDKP_DATA_INIT()".CRLF;
echo TAB."SDKPDATA = {}".CRLF;
echo TAB."SDKPPLAYER = {}".CRLF;
echo TAB."SDKP_SYSTEMS = {}".CRLF;
echo TAB."local tmp = nil;".CRLF;
if($conf_plus['pk_multidkp'] == 1)
{
$sql = 'SELECT multidkp_name, multidkp_disc, multidkp_id
FROM ' . MULTIDKP_TABLE . '
WHERE multidkp_name IS NOT NULL'
;
$total_multi = $db->query_first('SELECT count(*) FROM ' . MULTIDKP_TABLE . ' WHERE multidkp_name IS NOT NULL');
if ( !($multi_result = $db->query($sql)) ) {
message_die('Could not obtain MultiDKP information', '', __FILE__, __LINE__, $sql);
}
while ( $multi = $db->fetch_record($multi_result) ) {
$system = strto_wowutf($multi['multidkp_name']);
$tableoutput .= TAB.'SDKPDATA["' . $system . '"] = {};'.CRLF;
$tableoutput .= TAB.'SDKP_SYSTEMS["'.$system.'"] = "'. $system .'";'.CRLF;
}
echo $tableoutput ;
}
########################
# Multi DKP / Normal DKP
########################
$sql = "SELECT *,
m.member_name,
c.class_name as member_class,
m.member_earned + m.member_adjustment - m.member_spent as current_dkp
FROM
".$table_prefix."members m, ".$table_prefix."classes c
WHERE
m.member_class_id = c.class_id
GROUP BY
m.member_name
ORDER BY
member_name ASC";
print $sql ;
message_die('Could not obtain member DKP information', '', __FILE__, __LINE__, $sql);
}
if($conf_plus['pk_multidkp'] == 1) {
$format_record = TAB.'SDKP_DATA["%s"][%s] = {};'.CRLF;
$format_name = TAB.'SDKP_DATA["%s"][%s].name = "%s";'.CRLF;
$format_dkp_e = TAB.'SDKP_DATA["%s"][%s].earned = %s;'.CRLF;
$format_dkp_s = TAB.'SDKP_DATA["%s"][%s].spent = %s;'.CRLF;
$format_dkp_a = TAB.'SDKP_DATA["%s"][%s].adj = %s;'.CRLF;
$format_class = TAB.'SDKP_DATA["%s"][%s].class = "%s";'.CRLF;
$format_rankid = TAB.'SDKP_DATA["%s"][%s].rankid = %s;'.CRLF;
$format_rank = TAB.'SDKP_DATA["%s"][%s].rank = "%s";'.CRLF;
$format_att = TAB.'SDKP_DATA["%s"][%s].%s = %s;'.CRLF;
{
$html = new htmlPlus(); // plus html class
$member_num = 1;
while ($row = $db->fetch_record($result)) # member row
{
$sql = 'SELECT member_id, member_name, member_earned, member_spent, member_adjustment, (member_earned-member_spent+member_adjustment) AS member_current,
member_firstraid, member_lastraid, member_class_id, member_race_id, member_rank_id, r.rank_name, r.rank_id
FROM ' . MEMBERS_TABLE . ", " . MEMBER_RANKS_TABLE . " r
WHERE (member_name='".$row['member_name']."') AND (member_rank_id = r.rank_id)";
if ( !($member_result = $db->query($sql)) )
{
message_die('Could not obtain member information', '', __FILE__, __LINE__, $sql);
}
// Make sure they provided a valid member name
if ( !$member = $db->fetch_record($member_result) )
{
message_die($user->lang['error_invalid_name_provided']);
}
// Find the percent of raids they've attended in the last 30, 60 and 90 days
$percent_of_raids_30 = raid_count
(mktime(0
, 0
, 0
, date('m'), date('d')-30
, date('Y')), time(), $member['member_name']);
$percent_of_raids_60 = raid_count
(mktime(0
, 0
, 0
, date('m'), date('d')-60
, date('Y')), time(), $member['member_name']);
$percent_of_raids_90 = raid_count
(mktime(0
, 0
, 0
, date('m'), date('d')-90
, date('Y')), time(), $member['member_name']);
$member_multidkp = $html-> multiDkpMemberArray($row['member_name']) ; // create the multiDKP Table
if(!empty($member_multidkp[$row['member_name']])) {
$playername = '"'.strtolower(strto_wowutf
($row['member_name'])).'"';
echo TAB."SDKPPLAYER[$playername] = $member_num;".CRLF;
foreach ($member_multidkp[$row['member_name']] as $key) {
echo TAB.'SDKPDATA["' . $key['name'] . '"][' . $member_num . '] = { '.CRLF;
echo TAB.TAB.'["cols"] = { '.CRLF;
echo TAB
.TAB
.TAB
.'{ ["value"] = "'. strto_wowutf
($row['member_name']) . '", ["color"] = RAID_CLASS_COLORS["' . strtoupper(strto_wowutf
($row['member_class'])) . '"] or sdkp.COLOR_UNKNOWN_CLASS,},'.CRLF
;
echo TAB.TAB.TAB.'{ ["value"] = "", },'.CRLF;
echo TAB.TAB.TAB.'{ ["value"] = ' . $percent_of_raids_30 . ', ["color"] = sdkp.FUNC_COLOR_BRACKET, },'.CRLF;
echo TAB.TAB.TAB.'{ ["value"] = ' . $percent_of_raids_60 . ', ["color"] = sdkp.FUNC_COLOR_BRACKET, },'.CRLF;
echo TAB.TAB.TAB.'{ ["value"] = ' . $percent_of_raids_90 . ', ["color"] = sdkp.FUNC_COLOR_BRACKET, },'.CRLF;
echo TAB.TAB.TAB.'{ ["value"] = sdkp.FUNC_PLAYER_BID, ["color"] = sdkp.FUNC_COLOR_BRACKET, },'.CRLF;
echo TAB.TAB.TAB.'{ ["value"] = sdkp.FUNC_DKP_TOTAL, ["color"] = sdkp.FUNC_COLOR_BRACKET, },'.CRLF;
echo TAB.TAB.'},'.CRLF;
echo TAB.'};'.CRLF;
echo TAB.'tmp = SDKPDATA["' . $key['name'] . '"][' . $member_num . '].cols;'.CRLF;
echo TAB.'for i = 3, 7 do'.CRLF;
echo TAB.TAB.'tmp[i]["colorargs"] = tmp;'.CRLF;
echo TAB.'end'.CRLF;
echo TAB.'tmp[6]["args"] = tmp;'.CRLF;
echo TAB.'tmp[7]["args"] = { tmp, ' . ($key['earned'] + $key['adjust'] - $key['spend']) . ',};'.CRLF;
}
}
$member_num += 1;
}
}
}
$db->free_result($result);
echo "end".CRLF;
function strto_wowutf($str)
{
$find[] = 'à';
$find[] = 'á';
$find[] = 'â';
$find[] = 'ã';
$find[] = 'ä';
$find[] = 'æ';
$find[] = 'ç';
$find[] = 'Ä';
$find[] = 'Ö';
$find[] = 'Ü';
$find[] = 'ß';
$find[] = 'è';
$find[] = 'é';
$find[] = 'ê';
$find[] = 'ë';
$find[] = 'ì';
$find[] = 'í';
$find[] = 'î';
$find[] = 'ï';
$find[] = 'ñ';
$find[] = 'ò';
$find[] = 'ó';
$find[] = 'ô';
$find[] = 'õ';
$find[] = 'ö';
$find[] = 'ø';
$find[] = 'ù';
$find[] = 'ú';
$find[] = 'û';
$find[] = 'ü';
$find[] = 'Æ';
$replace[] = '\195\160';
$replace[] = '\195\161';
$replace[] = '\195\162';
$replace[] = '\195\163';
$replace[] = '\195\164';
$replace[] = '\195\166';
$replace[] = '\195\167';
$replace[] = '\195\132';
$replace[] = '\195\150';
$replace[] = '\195\156';
$replace[] = '\195\159';
$replace[] = '\195\168';
$replace[] = '\195\169';
$replace[] = '\195\170';
$replace[] = '\195\171';
$replace[] = '\195\172';
$replace[] = '\195\173';
$replace[] = '\195\174';
$replace[] = '\195\175';
$replace[] = '\195\177';
$replace[] = '\195\178';
$replace[] = '\195\179';
$replace[] = '\195\180';
$replace[] = '\195\181';
$replace[] = '\195\182';
$replace[] = '\195\184';
$replace[] = '\195\185';
$replace[] = '\195\186';
$replace[] = '\195\187';
$replace[] = '\195\188';
$replace[] = '\195\134';
return $str_encoded;
}
function strto_wowutfItem($str)
{
return $str_encoded;
}
// I find this name a little misleading because the result won't be valid UTF8 data
function cp1252_to_utf8($str) {
// map taken from http://de3.php.net/manual/de/function.utf8-encode.php#45226
"\xc2\x80" => "\xe2\x82\xac", /* EURO SIGN */
"\xc2\x82" => "\xe2\x80\x9a", /* SINGLE LOW-9 QUOTATION MARK */
"\xc2\x83" => "\xc6\x92", /* LATIN SMALL LETTER F WITH HOOK */
"\xc2\x84" => "\xe2\x80\x9e", /* DOUBLE LOW-9 QUOTATION MARK */
"\xc2\x85" => "\xe2\x80\xa6", /* HORIZONTAL ELLIPSIS */
"\xc2\x86" => "\xe2\x80\xa0", /* DAGGER */
"\xc2\x87" => "\xe2\x80\xa1", /* DOUBLE DAGGER */
"\xc2\x88" => "\xcb\x86", /* MODIFIER LETTER CIRCUMFLEX ACCENT */
"\xc2\x89" => "\xe2\x80\xb0", /* PER MILLE SIGN */
"\xc2\x8a" => "\xc5\xa0", /* LATIN CAPITAL LETTER S WITH CARON */
"\xc2\x8b" => "\xe2\x80\xb9", /* SINGLE LEFT-POINTING ANGLE QUOTATION */
"\xc2\x8c" => "\xc5\x92", /* LATIN CAPITAL LIGATURE OE */
"\xc2\x8e" => "\xc5\xbd", /* LATIN CAPITAL LETTER Z WITH CARON */
"\xc2\x91" => "\xe2\x80\x98", /* LEFT SINGLE QUOTATION MARK */
"\xc2\x92" => "\xe2\x80\x99", /* RIGHT SINGLE QUOTATION MARK */
"\xc2\x93" => "\xe2\x80\x9c", /* LEFT DOUBLE QUOTATION MARK */
"\xc2\x94" => "\xe2\x80\x9d", /* RIGHT DOUBLE QUOTATION MARK */
"\xc2\x95" => "\xe2\x80\xa2", /* BULLET */
"\xc2\x96" => "\xe2\x80\x93", /* EN DASH */
"\xc2\x97" => "\xe2\x80\x94", /* EM DASH */
"\xc2\x98" => "\xcb\x9c", /* SMALL TILDE */
"\xc2\x99" => "\xe2\x84\xa2", /* TRADE MARK SIGN */
"\xc2\x9a" => "\xc5\xa1", /* LATIN SMALL LETTER S WITH CARON */
"\xc2\x9b" => "\xe2\x80\xba", /* SINGLE RIGHT-POINTING ANGLE QUOTATION*/
"\xc2\x9c" => "\xc5\x93", /* LATIN SMALL LIGATURE OE */
"\xc2\x9e" => "\xc5\xbe", /* LATIN SMALL LETTER Z WITH CARON */
"\xc2\x9f" => "\xc5\xb8" /* LATIN CAPITAL LETTER Y WITH DIAERESIS*/
);
}
function cp1252_utf8_to_iso($str) { // the other way around...
#global $cp1252_map;
}
function raid_count($start_date, $end_date, $member_name)
{
global $db;
$raid_count = $db->query_first('SELECT count(*) FROM ' . RAIDS_TABLE . ' WHERE (raid_date BETWEEN ' . $start_date . ' AND ' . $end_date . ')');
$sql = 'SELECT count(*)
FROM ' . RAIDS_TABLE . ' r, ' . RAID_ATTENDEES_TABLE . " ra
WHERE (ra.raid_id = r.raid_id)
AND (ra.member_name='" . $member_name . "')
AND (r.raid_date BETWEEN " . $start_date . ' AND ' . $end_date . ')';
$individual_raid_count = $db->query_first($sql);
$percent_of_raids = ( $raid_count > 0
) ?
round(($individual_raid_count / $raid_count) * 100
) : 0;
$raid_count_stats = array(
'percent' => $percent_of_raids,
'total_count' => $raid_count,
'indiv_count' => $individual_raid_count);
return $raid_count_stats['percent']; // Only thing needed ATM
}
?>