pastebin - collaborative debugging

pastebin is a collaborative debugging tool allowing you to share and modify code snippets while chatting on IRC, IM or a message board.

This site is developed to XHTML and CSS2 W3C standards. If you see this paragraph, your browser does not support those standards and you need to upgrade. Visit WaSP for a variety of options.

PHP pastebin - collaborative debugging tool View Help


Posted by ddumont on Wed 12 Nov 02:23
report abuse | download | new post

  1. <?php
  2. /******************************
  3.  * GetDKP Plus
  4.  *
  5.  * © Corgan @ Server Antonidas PvE German -> www.seniorenraid.de
  6.  * ------------------
  7.  * getdkp.php
  8.  *
  9.  * Version 2.4
  10.  * 06/25/06
  11.  * 06/29/07 - Specialchar support
  12.  * 06/18/11 - multidkp support
  13.  * 07/03/01 - new item iterration
  14.  * Support English / German -> http://www.seniorenraid.de/forum/forumdisplay.php?f=13
  15.  * 07/05/13 support for dkp.exe 5.0
  16.  ******************************/
  17.  
  18.  
  19. ############# you dont have to change anything below !!!!  ######################################
  20. #################################################################################################
  21.  
  22. $version = "2.6";
  23. $total_players = 0;
  24. $total_items = 0;
  25. $total_points = 0;
  26. $eqdkp_version = "1.3.x";
  27. $date_created = date("d.m.y G:i:s");
  28. $startString = "--[START]\n";
  29. $endString = "\n--[END]";
  30.  
  31. define(TAB, "\t");
  32. define(CRLF, "\r\n");
  33.  
  34.  
  35. define('EQDKP_INC', true);
  36. $eqdkp_root_path = './';
  37. include_once($eqdkp_root_path . 'common.php');
  38. echo "function SDKP_DATA_INIT()".CRLF;
  39. echo TAB."SDKPDATA = {}".CRLF;
  40. echo TAB."SDKPPLAYER = {}".CRLF;
  41. echo TAB."SDKP_SYSTEMS = {}".CRLF;
  42. echo TAB."local tmp = nil;".CRLF;
  43.  
  44. if($conf_plus['pk_multidkp'] == 1)
  45.         {
  46.         $sql = 'SELECT multidkp_name, multidkp_disc, multidkp_id
  47.            FROM ' . MULTIDKP_TABLE . '
  48.            WHERE multidkp_name IS NOT NULL'
  49.             ;
  50.  
  51.         $total_multi = $db->query_first('SELECT count(*) FROM ' . MULTIDKP_TABLE . ' WHERE multidkp_name IS NOT NULL');
  52.  
  53.                 if ( !($multi_result = $db->query($sql)) ) {
  54.                     message_die('Could not obtain MultiDKP information', '', __FILE__, __LINE__, $sql);
  55.                 }
  56.  
  57.                 while ( $multi = $db->fetch_record($multi_result) )     {
  58.                         $system = strto_wowutf($multi['multidkp_name']);
  59.                         $tableoutput .= TAB.'SDKPDATA["' . $system . '"] = {};'.CRLF;
  60.                         $tableoutput .= TAB.'SDKP_SYSTEMS["'.$system.'"] = "'. $system .'";'.CRLF;
  61.                 }
  62.                 echo $tableoutput ;
  63. }
  64.  
  65.  
  66.  
  67. ########################
  68. # Multi DKP / Normal DKP
  69. ########################
  70. $sql = "SELECT *,
  71.                 m.member_name,
  72.        c.class_name as member_class,
  73.                 m.member_earned + m.member_adjustment - m.member_spent as current_dkp
  74.         FROM
  75.                 ".$table_prefix."members m, ".$table_prefix."classes c
  76.         WHERE
  77.                 m.member_class_id = c.class_id
  78.         GROUP BY
  79.                 m.member_name
  80.         ORDER BY
  81. member_name ASC";
  82.  
  83.  
  84. if ( !($result = mysql_query($sql)) ) {
  85.         print $sql ;
  86.         message_die('Could not obtain member DKP information', '', __FILE__, __LINE__, $sql);
  87. }
  88.  
  89.  
  90. if($conf_plus['pk_multidkp'] == 1) {
  91.         $format_record =   TAB.'SDKP_DATA["%s"][%s] = {};'.CRLF;
  92.         $format_name =     TAB.'SDKP_DATA["%s"][%s].name = "%s";'.CRLF;
  93.         $format_dkp_e =    TAB.'SDKP_DATA["%s"][%s].earned = %s;'.CRLF;
  94.         $format_dkp_s =    TAB.'SDKP_DATA["%s"][%s].spent = %s;'.CRLF;
  95.         $format_dkp_a =    TAB.'SDKP_DATA["%s"][%s].adj = %s;'.CRLF;
  96.         $format_class =    TAB.'SDKP_DATA["%s"][%s].class = "%s";'.CRLF;
  97.         $format_rankid =   TAB.'SDKP_DATA["%s"][%s].rankid = %s;'.CRLF;
  98.         $format_rank =     TAB.'SDKP_DATA["%s"][%s].rank = "%s";'.CRLF;
  99.         $format_att =    TAB.'SDKP_DATA["%s"][%s].%s = %s;'.CRLF;
  100.  
  101.  
  102.         if(mysql_num_rows($result) >= 1)
  103.         {
  104.                 $html = new htmlPlus(); // plus html class
  105.                 $member_num = 1;
  106.                 while ($row = $db->fetch_record($result)) # member row
  107.                 {
  108.  
  109.                         $sql = 'SELECT member_id, member_name, member_earned, member_spent, member_adjustment, (member_earned-member_spent+member_adjustment) AS member_current,
  110.                                   member_firstraid, member_lastraid, member_class_id, member_race_id, member_rank_id, r.rank_name, r.rank_id
  111.                                 FROM ' . MEMBERS_TABLE . ", " . MEMBER_RANKS_TABLE . " r
  112.                                 WHERE (member_name='".$row['member_name']."') AND (member_rank_id = r.rank_id)";
  113.  
  114.                         if ( !($member_result = $db->query($sql)) )
  115.                         {
  116.                                 message_die('Could not obtain member information', '', __FILE__, __LINE__, $sql);
  117.                         }
  118.  
  119.                         // Make sure they provided a valid member name
  120.                         if ( !$member = $db->fetch_record($member_result) )
  121.                         {
  122.                                 message_die($user->lang['error_invalid_name_provided']);
  123.                         }
  124.  
  125.                         // Find the percent of raids they've attended in the last 30, 60 and 90 days
  126.                         $percent_of_raids_30 = raid_count(mktime(0, 0, 0, date('m'), date('d')-30, date('Y')), time(), $member['member_name']);
  127.                         $percent_of_raids_60 = raid_count(mktime(0, 0, 0, date('m'), date('d')-60, date('Y')), time(), $member['member_name']);
  128.                         $percent_of_raids_90 = raid_count(mktime(0, 0, 0, date('m'), date('d')-90, date('Y')), time(), $member['member_name']);
  129.  
  130.                         $member_multidkp = $html-> multiDkpMemberArray($row['member_name']) ; // create the multiDKP Table
  131.                         if(!empty($member_multidkp[$row['member_name']])) {
  132.                                 $playername = '"'.strtolower(strto_wowutf($row['member_name'])).'"';
  133.                                 echo TAB."SDKPPLAYER[$playername] = $member_num;".CRLF;
  134.  
  135.                                 foreach ($member_multidkp[$row['member_name']] as $key) {
  136.  
  137.                                         echo TAB.'SDKPDATA["' . $key['name'] . '"][' . $member_num . '] = { '.CRLF;
  138.                                         echo TAB.TAB.'["cols"] = { '.CRLF;
  139.                                         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;
  140.                                         echo TAB.TAB.TAB.'{ ["value"] = "", },'.CRLF;
  141.                                         echo TAB.TAB.TAB.'{ ["value"] = ' . $percent_of_raids_30 . ', ["color"] = sdkp.FUNC_COLOR_BRACKET, },'.CRLF;
  142.                                         echo TAB.TAB.TAB.'{ ["value"] = ' . $percent_of_raids_60 . ', ["color"] = sdkp.FUNC_COLOR_BRACKET, },'.CRLF;
  143.                                         echo TAB.TAB.TAB.'{ ["value"] = ' . $percent_of_raids_90 . ', ["color"] = sdkp.FUNC_COLOR_BRACKET, },'.CRLF;
  144.                                         echo TAB.TAB.TAB.'{ ["value"] = sdkp.FUNC_PLAYER_BID, ["color"] = sdkp.FUNC_COLOR_BRACKET, },'.CRLF;
  145.                                         echo TAB.TAB.TAB.'{ ["value"] = sdkp.FUNC_DKP_TOTAL,  ["color"] = sdkp.FUNC_COLOR_BRACKET, },'.CRLF;
  146.                                         echo TAB.TAB.'},'.CRLF;
  147.                                         echo TAB.'};'.CRLF;
  148.                                         echo TAB.'tmp = SDKPDATA["' . $key['name'] . '"][' . $member_num . '].cols;'.CRLF;
  149.  
  150.                                         echo TAB.'for i = 3, 7 do'.CRLF;
  151.                                         echo TAB.TAB.'tmp[i]["colorargs"] = tmp;'.CRLF;
  152.                                         echo TAB.'end'.CRLF;
  153.                                         echo TAB.'tmp[6]["args"] = tmp;'.CRLF;
  154.                                         echo TAB.'tmp[7]["args"] = { tmp, ' . ($key['earned'] + $key['adjust'] - $key['spend']) . ',};'.CRLF;
  155.                                 }
  156.                         }
  157.                         $member_num += 1;
  158.                 }
  159.         }
  160. }
  161.  
  162. $db->free_result($result);
  163. echo "end".CRLF;
  164.  
  165.  
  166. function strto_wowutf($str)
  167. {
  168.         $find[] = 'à';
  169.         $find[] = 'á';
  170.         $find[] = 'â';
  171.         $find[] = 'ã';
  172.         $find[] = 'ä';
  173.         $find[] = 'æ';
  174.         $find[] = 'ç';
  175.         $find[] = 'Ä';
  176.         $find[] = 'Ö';
  177.         $find[] = 'Ü';
  178.         $find[] = 'ß';
  179.         $find[] = 'è';
  180.         $find[] = 'é';
  181.         $find[] = 'ê';
  182.         $find[] = 'ë';
  183.         $find[] = 'ì';
  184.         $find[] = 'í';
  185.         $find[] = 'î';
  186.         $find[] = 'ï';
  187.         $find[] = 'ñ';
  188.         $find[] = 'ò';
  189.         $find[] = 'ó';
  190.         $find[] = 'ô';
  191.         $find[] = 'õ';
  192.         $find[] = 'ö';
  193.         $find[] = 'ø';
  194.         $find[] = 'ù';
  195.         $find[] = 'ú';
  196.         $find[] = 'û';
  197.         $find[] = 'ü';
  198.         $find[] = 'Æ';
  199.  
  200.         $replace[]                      = '\195\160';
  201.         $replace[]                      = '\195\161';
  202.         $replace[]                      = '\195\162';
  203.         $replace[]                      = '\195\163';
  204.         $replace[]                      = '\195\164';
  205.         $replace[]                      = '\195\166';
  206.         $replace[]                      = '\195\167';
  207.         $replace[]                      = '\195\132';
  208.         $replace[]                      = '\195\150';
  209.         $replace[]                      = '\195\156';
  210.         $replace[]                      = '\195\159';
  211.         $replace[]                      = '\195\168';
  212.         $replace[]                      = '\195\169';
  213.         $replace[]                      = '\195\170';
  214.         $replace[]                      = '\195\171';
  215.         $replace[]                      = '\195\172';
  216.         $replace[]                      = '\195\173';
  217.         $replace[]                      = '\195\174';
  218.         $replace[]                      = '\195\175';
  219.         $replace[]                      = '\195\177';
  220.         $replace[]                      = '\195\178';
  221.         $replace[]                      = '\195\179';
  222.         $replace[]                      = '\195\180';
  223.         $replace[]                      = '\195\181';
  224.         $replace[]                      = '\195\182';
  225.         $replace[]                      = '\195\184';
  226.         $replace[]                      = '\195\185';
  227.         $replace[]                      = '\195\186';
  228.         $replace[]                      = '\195\187';
  229.         $replace[]                      = '\195\188';
  230.         $replace[]                      = '\195\134';
  231.  
  232.  
  233.         $str_encoded = str_replace($find, $replace , $str);
  234.  
  235.         return $str_encoded;
  236. }
  237.  
  238. function strto_wowutfItem($str)
  239. {
  240.         $str_encoded = utf8_encode($str);
  241.         return $str_encoded;
  242. }
  243.  
  244. // I find this name a little misleading because the result won't be valid UTF8 data
  245. function cp1252_to_utf8($str) {
  246. // map taken from http://de3.php.net/manual/de/function.utf8-encode.php#45226
  247. $cp1252_map = array(
  248.    "\xc2\x80" => "\xe2\x82\xac", /* EURO SIGN */
  249.    "\xc2\x82" => "\xe2\x80\x9a", /* SINGLE LOW-9 QUOTATION MARK */
  250.    "\xc2\x83" => "\xc6\x92",    /* LATIN SMALL LETTER F WITH HOOK */
  251.    "\xc2\x84" => "\xe2\x80\x9e", /* DOUBLE LOW-9 QUOTATION MARK */
  252.    "\xc2\x85" => "\xe2\x80\xa6", /* HORIZONTAL ELLIPSIS */
  253.    "\xc2\x86" => "\xe2\x80\xa0", /* DAGGER */
  254.    "\xc2\x87" => "\xe2\x80\xa1", /* DOUBLE DAGGER */
  255.    "\xc2\x88" => "\xcb\x86",    /* MODIFIER LETTER CIRCUMFLEX ACCENT */
  256.    "\xc2\x89" => "\xe2\x80\xb0", /* PER MILLE SIGN */
  257.    "\xc2\x8a" => "\xc5\xa0",    /* LATIN CAPITAL LETTER S WITH CARON */
  258.    "\xc2\x8b" => "\xe2\x80\xb9", /* SINGLE LEFT-POINTING ANGLE QUOTATION */
  259.    "\xc2\x8c" => "\xc5\x92",    /* LATIN CAPITAL LIGATURE OE */
  260.    "\xc2\x8e" => "\xc5\xbd",    /* LATIN CAPITAL LETTER Z WITH CARON */
  261.    "\xc2\x91" => "\xe2\x80\x98", /* LEFT SINGLE QUOTATION MARK */
  262.    "\xc2\x92" => "\xe2\x80\x99", /* RIGHT SINGLE QUOTATION MARK */
  263.    "\xc2\x93" => "\xe2\x80\x9c", /* LEFT DOUBLE QUOTATION MARK */
  264.    "\xc2\x94" => "\xe2\x80\x9d", /* RIGHT DOUBLE QUOTATION MARK */
  265.    "\xc2\x95" => "\xe2\x80\xa2", /* BULLET */
  266.    "\xc2\x96" => "\xe2\x80\x93", /* EN DASH */
  267.    "\xc2\x97" => "\xe2\x80\x94", /* EM DASH */
  268.  
  269.    "\xc2\x98" => "\xcb\x9c",    /* SMALL TILDE */
  270.    "\xc2\x99" => "\xe2\x84\xa2", /* TRADE MARK SIGN */
  271.    "\xc2\x9a" => "\xc5\xa1",    /* LATIN SMALL LETTER S WITH CARON */
  272.    "\xc2\x9b" => "\xe2\x80\xba", /* SINGLE RIGHT-POINTING ANGLE QUOTATION*/
  273.    "\xc2\x9c" => "\xc5\x93",    /* LATIN SMALL LIGATURE OE */
  274.    "\xc2\x9e" => "\xc5\xbe",    /* LATIN SMALL LETTER Z WITH CARON */
  275.    "\xc2\x9f" => "\xc5\xb8"      /* LATIN CAPITAL LETTER Y WITH DIAERESIS*/
  276. );
  277.  
  278.    return  strtr(utf8_encode($str), $cp1252_map);
  279. }
  280.  
  281. function cp1252_utf8_to_iso($str) { // the other way around...
  282.   #global $cp1252_map;
  283.   return  utf8_decode( strtr($str, array_flip($cp1252_map)) );
  284. }
  285.  
  286. function raid_count($start_date, $end_date, $member_name)
  287. {
  288.     global $db;
  289.  
  290.     $raid_count = $db->query_first('SELECT count(*) FROM ' . RAIDS_TABLE . ' WHERE (raid_date BETWEEN ' . $start_date . ' AND ' . $end_date . ')');
  291.  
  292.     $sql = 'SELECT count(*)
  293.            FROM ' . RAIDS_TABLE . ' r, ' . RAID_ATTENDEES_TABLE . " ra
  294.            WHERE (ra.raid_id = r.raid_id)
  295.            AND (ra.member_name='" . $member_name . "')
  296.            AND (r.raid_date BETWEEN " . $start_date . ' AND ' . $end_date . ')';
  297.     $individual_raid_count = $db->query_first($sql);
  298.  
  299.     $percent_of_raids = ( $raid_count > 0 ) ? round(($individual_raid_count / $raid_count) * 100) : 0;
  300.  
  301.     $raid_count_stats = array(
  302.         'percent'     => $percent_of_raids,
  303.         'total_count' => $raid_count,
  304.         'indiv_count' => $individual_raid_count);
  305.  
  306.     return $raid_count_stats['percent']; // Only thing needed ATM
  307. }
  308.  
  309. ?>

Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:

To highlight particular lines, prefix each line with @@


Remember me so that I can delete my post