Advertisement
Guest User

whoisonline.php

a guest
Sep 15th, 2012
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.26 KB | None | 0 0
  1. <?php
  2. $cache_sec = 60;
  3. $info = array(
  4. 0 => array('Europe', '28th Januari 2011, 18.00 CET')
  5. );
  6.  
  7. $id=0;
  8. if(isset($_POST['world'])) {
  9. $f = null;
  10. foreach($config['site']['worlds'] as $k => $v)
  11. if($v == $_POST['world']) {
  12. $f = true;
  13. $id = $k;
  14. break;
  15. }
  16. if(!$f)
  17. $_POST['world'] = $config['site']['worlds'][0];
  18. } else $_POST['world'] = $config['site']['worlds'][0];
  19.  
  20. $order = 'name_asc';
  21. if(isset($_REQUEST['order']) && in_array($_REQUEST['order'], array('name_desc', 'level_asc','level_desc','vocation_asc','vocation_desc')))
  22. $order = $_REQUEST['order'];
  23.  
  24. if(count($config['site']['worlds']) > 1) {
  25. $main_content =
  26. '<form action="?subtopic=whoisonline" method="post">
  27. <div class="TableContainer">
  28. <table class="Table1" cellpadding="0" cellspacing="0">
  29. <div class="CaptionContainer">
  30. <div class="CaptionInnerContainer">
  31. <span class="CaptionEdgeLeftTop" style="background-image:url('.$layout_name.'/images/content/box-frame-edge.gif)"></span>
  32. <span class="CaptionEdgeRightTop" style="background-image:url('.$layout_name.'/images/content/box-frame-edge.gif)"></span>
  33. <span class="CaptionBorderTop" style="background-image:url('.$layout_name.'/images/content/table-headline-border.gif)"></span>
  34. <span class="CaptionVerticalLeft" style="background-image:url('.$layout_name.'/images/content/box-frame-vertical.gif)"></span>
  35. <div class="Text">World Selection</div>
  36. <span class="CaptionVerticalRight" style="background-image:url('.$layout_name.'/images/content/box-frame-vertical.gif)"></span>
  37. <span class="CaptionBorderBottom" style="background-image:url('.$layout_name.'/images/content/table-headline-border.gif)"></span>
  38. <span class="CaptionEdgeLeftBottom" style="background-image:url('.$layout_name.'/images/content/box-frame-edge.gif)"></span>
  39. <span class="CaptionEdgeRightBottom" style="background-image:url('.$layout_name.'/images/content/box-frame-edge.gif)"></span>
  40. </div>
  41. </div>
  42. <tr>
  43. <td>
  44. <div class="InnerTableContainer">
  45. <table width="100%">
  46. <tr>
  47. <td style="vertical-align:middle" class="LabelV150">World Name:</td>
  48. <td style="width:170px">
  49. <select size="1" name="world" style="width:165px">';
  50. foreach($config['site']['worlds'] as $v)
  51. $main_content .= '<option value="'.$v.'"'.($v == $_POST['world'] ? ' selected="selected"' : '').'>'.$v.'</option>';
  52. $main_content .= '
  53. </select>
  54. </td>
  55. <td style="text-align:left">
  56. <div class="BigButton" style="background-image:url('.$layout_name.'/images/buttons/sbutton.gif)">
  57. <div onmouseover="MouseOverBigButton(this)" onmouseout="MouseOutBigButton(this)"><div class="BigButtonOver" style="background-image:url('.$layout_name.'/images/buttons/sbutton_over.gif)"></div>
  58. <input class="ButtonText" type="image" name="Submit" alt="Submit" src="'.$layout_name.'/images/buttons/_sbutton_submit.gif"/>
  59. </div>
  60. </div>
  61. </td>
  62. </tr>
  63. </table>
  64. </div>
  65. </td>
  66. </tr>
  67. </table>
  68. </div>
  69. </form><br/>
  70. ';
  71. }
  72. $main_content .=
  73. '<div class="TableContainer">
  74. <table class="Table1" cellpadding="0" cellspacing="0">
  75. <div class="CaptionContainer">
  76. <div class="CaptionInnerContainer">
  77. <span class="CaptionEdgeLeftTop" style="background-image:url('.$layout_name.'/images/content/box-frame-edge.gif)"></span>
  78. <span class="CaptionEdgeRightTop" style="background-image:url('.$layout_name.'/images/content/box-frame-edge.gif)"></span>
  79. <span class="CaptionBorderTop" style="background-image:url('.$layout_name.'/images/content/table-headline-border.gif)"></span>
  80. <span class="CaptionVerticalLeft" style="background-image:url('.$layout_name.'/images/content/box-frame-vertical.gif)"></span>
  81. <div class="Text">World Information</div>
  82. <span class="CaptionVerticalRight" style="background-image:url('.$layout_name.'/images/content/box-frame-vertical.gif)"></span>
  83. <span class="CaptionBorderBottom" style="background-image:url('.$layout_name.'/images/content/table-headline-border.gif)"></span>
  84. <span class="CaptionEdgeLeftBottom" style="background-image:url('.$layout_name.'/images/content/box-frame-edge.gif)"></span>
  85. <span class="CaptionEdgeRightBottom" style="background-image:url('.$layout_name.'/images/content/box-frame-edge.gif)"></span>
  86. </div>
  87. </div>
  88. <tr>
  89. <td>
  90. <div class="InnerTableContainer">
  91. <table width="100%">
  92. <tr>
  93. <td class="LabelV150">Status:</td>
  94. <td>'.($config['status']['serverStatus_online'] == 1 ? '<font color="green">online</font>' : '<font color="red">offline</font>').'</td>
  95. </tr>
  96. <tr>
  97. <td class="LabelV150">Players Online:</td>
  98. <td>';
  99. $f = 'cache/whoisonline-'.$_POST['world'].'-'.$order.'.tmp';
  100. $ff = 'cache/whoisonline-'.$_POST['world'].'-record.tmp';
  101. if(file_exists($f) && filemtime($f) > (time() - $cache_sec)) {
  102. $cp = file_get_contents($f);
  103. $cached = null;
  104. if(file_exists($f) && filemtime($f) > (time() - $cache_sec)) {
  105. $e = explode('|', file_get_contents($ff));
  106. $n = $e[0];
  107. $c = $e[1];
  108. $cached = true;
  109. }
  110. }
  111. else {
  112. $cp = '';
  113. $n = 0;
  114. $q = 'SELECT name,level,vocation,promotion,looktype,lookaddons,lookhead,lookbody,looklegs,lookfeet FROM players WHERE world_id='.$id.' AND online=1';
  115. if(in_array($order, array('name_asc','name_desc','level_asc','level_desc')))
  116. $q .= ' ORDER BY '.str_replace('_', ' ', $order);
  117.  
  118. $outfit = "outfitter.php";
  119.  
  120. if(in_array($order, array('vocation_asc','vocation_desc'))) {
  121. $a = array();
  122. foreach($SQL->query($q)->fetchAll() as $p)
  123. $a[] = array($p['name'], $p['level'], $vocation_name[$id][$p['promotion']][$p['vocation']], array($p['looktype'], $p['lookaddons'], $p['lookhead'], $p['lookbody'], $p['looklegs'], $p['lookfeet']));
  124. function cmp($a, $b) {
  125. $r = strcmp($a[2], $b[2]);
  126. $r = $GLOBALS['order'] == 'vocation_desc' ? ($r == 1 ? -1 : ($r == -1 ? 1 : 0)) : $r;
  127. return ($r == 0 && $a[1] < $b[1]) ? 1 : $r;
  128. }
  129. usort($a, 'cmp');
  130. foreach($a as $p) {
  131. $n++;
  132. $cp .= '<tr class="'.(is_int($n/2)?'Even':'Odd').'" style="text-align:right"><td><div style="position: relative; width: 32px; height: 32px;"><div style="background-image: url(\''.$outfit.'?id='.$p[3][0].'&addons='.$p[3][1].'&head='.$p[3][2].'&body='.$p[3][3].'&legs='.$p[3][4].'&feet='.$p[3][5].'\'); position: absolute; width: 64px; height: 80px; background-position: bottom right; background-repeat: no-repeat; right: 0px; bottom: 0px;"></div></div></td><td style="width:70%;text-align:left"><a href="?subtopic=characters&name='.urlencode($p[0]).'">'.$p[0].'</a></td><td style="width:10%;text-align:center;">'.$p[1].'</td><td style="width:40%;">'.str_replace(' ',' ',$p[2]).'</td></tr>';
  133. }
  134. }
  135. else {
  136. $l = array();
  137. foreach($SQL->query($q)->fetchAll() as $p) {
  138. $n++;
  139. $cp .= '<tr class="'.(is_int($n/2)?'Even':'Odd').'" style="text-align:right"><td><div style="position: relative; width: 32px; height: 32px;"><div style="background-image: url(\''.$outfit.'?id='.$p['looktype'].'&addons='.$p['lookaddons'].'&head='.$p['lookhead'].'&body='.$p['lookbody'].'&legs='.$p['looklegs'].'&feet='.$p['lookfeet'].'\'); position: absolute; width: 64px; height: 80px; background-position: bottom right; background-repeat: no-repeat; right: 0px; bottom: 0px;"></div></div></td>';
  140. if($order == 'name_asc') {
  141. $tmp = strtoupper($p['name'][0]);
  142. if(!in_array($tmp, $l)) {
  143. $l[] = $tmp;
  144. $cp .= '<a name="'.$tmp.'"></a>';
  145. }
  146. }
  147. $cp .= '<td style="width:70%;text-align:left"><a href="?subtopic=characters&name='.urlencode($p['name']).'">'.$p['name'].'</a></td><td style="width:10%;text-align:center;">'.$p['level'].'</td><td style="width:40%;">'.str_replace(' ',' ',$vocation_name[$id][$p['promotion']][$p['vocation']]).'</td></tr>';
  148. }
  149. }
  150. file_put_contents($f, $cp);
  151. }
  152. if(!$cached) {
  153. $r=$SQL->query('SELECT MAX(record) as r,MAX(timestamp) as t FROM server_record WHERE world_id='.$id)->fetch();
  154. $c = $r['r'].' players (on '.date('M d Y, H:i:s T', $r['t']).')';
  155. file_put_contents($ff, $n.'|'.$c);
  156. }
  157. $main_content .= $n.'</td>
  158. </tr>
  159. <tr>
  160. <td class="LabelV150">Online Record:</td>
  161. <td>'.$c.'</td>
  162. </tr>
  163. <tr>
  164. <td class="LabelV150">Creation Date:</td>
  165. <td>'.$info[$id][1].'</td>
  166. </tr>
  167. <tr>
  168. <td class="LabelV150">Location:</td>
  169. <td>'.$info[$id][0].'</td>
  170. </tr>
  171. <tr>
  172. <td class="LabelV150">PvP Type:</td>
  173. <td>';
  174. $w=strtolower($config['server']['worldType']);
  175. if(in_array($w, array('pvp','2','normal','open','openpvp')))
  176. $main_content .= 'Open PvP';
  177. elseif(in_array($w, array('no-pvp','nopvp','non-pvp','nonpvp','1','safe','optional','optionalpvp')))
  178. $main_content .= 'Optional PvP';
  179. elseif(in_array($w, array('pvp-enforced','pvpenforced','pvp-enfo','pvpenfo','pvpe','enforced','enfo','3','war','hardcore','hardcorepvp')))
  180. $main_content .= 'Hardcore PvP';
  181. $main_content .= '</td>
  182. </tr>
  183. </table>
  184. </div>
  185. </td>
  186. </tr>
  187. </table>
  188. </div><br/>
  189. <div class="TableContainer">
  190. <table class="Table2" cellpadding="0" cellspacing="0"> <div class="CaptionContainer"> <div class="CaptionInnerContainer"> <span class="CaptionEdgeLeftTop" style="background-image:url('.$layout_name.'/images/content/box-frame-edge.gif)"></span> <span class="CaptionEdgeRightTop" style="background-image:url('.$layout_name.'/images/content/box-frame-edge.gif)"></span> <span class="CaptionBorderTop" style="background-image:url('.$layout_name.'/images/content/table-headline-border.gif)"></span> <span class="CaptionVerticalLeft" style="background-image:url('.$layout_name.'/images/content/box-frame-vertical.gif)"></span> <div class="Text">Players Online';
  191. if($order == 'name_asc')
  192. $main_content .= '<span class="tableheadlinenavigation"> [ <a href="#A">A</a> <a href="#B">B</a> <a href="#C">C</a> <a href="#D">D</a> <a href="#E">E</a> <a href="#F">F</a> <a href="#G">G</a> <a href="#H">H</a> <a href="#I">I</a> <a href="#J">J</a> <a href="#K">K</a> <a href="#L">L</a> <a href="#M">M</a> <a href="#N">N</a> <a href="#O">O</a> <a href="#P">P</a> <a href="#Q">Q</a> <a href="#R">R</a> <a href="#S">S</a> <a href="#T">T</a> <a href="#U">U</a> <a href="#V">V</a> <a href="#W">W</a> <a href="#X">X</a> <a href="#Y">Y</a> <a href="#Z">Z</a> ]</span>';
  193. $main_content .= '</div> <span class="CaptionVerticalRight" style="background-image:url('.$layout_name.'/images/content/box-frame-vertical.gif)"></span> <span class="CaptionBorderBottom" style="background-image:url('.$layout_name.'/images/content/table-headline-border.gif)"></span> <span class="CaptionEdgeLeftBottom" style="background-image:url('.$layout_name.'/images/content/box-frame-edge.gif)"></span> <span class="CaptionEdgeRightBottom" style="background-image:url('.$layout_name.'/images/content/box-frame-edge.gif)"></span> </div> </div> <tr> <td> <div class="InnerTableContainer"> <table width="100%"><tr class="LabelH"><td style="text-align:center;width:5%">&#160;&#160;Outfit&#160;&#160;</td><td style="text-align:left;width:70%">Name<small style="font-weight:normal">[<a href="?subtopic=whoisonline&world='.$_POST['world'].'&order=name_'.($order == 'name_asc' ? 'desc' : 'asc').'">sort</a>]</small> <img class="sortarrow" src="'.$layout_name.'/images/'.($order == 'name_asc' ? 'content/order_desc' : ($order == 'name_desc' ? 'content/order_asc' : 'news/blank')).'.gif"/></td><td>Level<small style="font-weight:normal">[<a href="?subtopic=whoisonline&world='.$_POST['world'].'&order=level_'.($order == 'level_asc' ? 'desc' : 'asc').'">sort</a>]</small> <img class="sortarrow" src="'.$layout_name.'/images/'.($order == 'level_asc' ? 'content/order_desc' : ($order == 'level_desc' ? 'content/order_asc' : 'news/blank')).'.gif"/></td><td style="text-align:right">Vocation<small style="font-weight:normal">[<a href="?subtopic=whoisonline&world='.$_POST['world'].'&order=vocation_'.($order == 'vocation_asc' ? 'desc' : 'asc').'">sort</a>]</small> <img class="sortarrow" src="'.$layout_name.'/images/'.($order == 'vocation_asc' ? 'content/order_desc' : ($order == 'vocation_desc' ? 'content/order_asc' : 'news/blank')).'.gif"/></td></tr>'.$cp.' </table> </div> </table></div></td></tr><br/><form action="?subtopic=characters" method="post"><div class="TableContainer"> <table class="Table1" cellpadding="0" cellspacing="0"> <div class="CaptionContainer"> <div class="CaptionInnerContainer"> <span class="CaptionEdgeLeftTop" style="background-image:url('.$layout_name.'/images/content/box-frame-edge.gif)"></span> <span class="CaptionEdgeRightTop" style="background-image:url('.$layout_name.'/images/content/box-frame-edge.gif)"></span> <span class="CaptionBorderTop" style="background-image:url('.$layout_name.'/images/content/table-headline-border.gif)"></span> <span class="CaptionVerticalLeft" style="background-image:url('.$layout_name.'/images/content/box-frame-vertical.gif)"></span> <div class="Text">Search Character</div> <span class="CaptionVerticalRight" style="background-image:url('.$layout_name.'/images/content/box-frame-vertical.gif)"></span> <span class="CaptionBorderBottom" style="background-image:url('.$layout_name.'/images/content/table-headline-border.gif)"></span> <span class="CaptionEdgeLeftBottom" style="background-image:url('.$layout_name.'/images/content/box-frame-edge.gif)"></span> <span class="CaptionEdgeRightBottom" style="background-image:url('.$layout_name.'/images/content/box-frame-edge.gif)"></span> </div> </div> <tr> <td> <div class="InnerTableContainer"> <table width="100%"><tr><td style="vertical-align:middle" class="LabelV150">Character Name:</td><td style="width:170px"><input style="width:165px" name="name" value="" size="29" maxlength="29"/></td><td><div class="BigButton" style="background-image:url('.$layout_name.'/images/buttons/sbutton.gif)"><div onmouseover="MouseOverBigButton(this)" onmouseout="MouseOutBigButton(this)"><div class="BigButtonOver" style="background-image:url('.$layout_name.'/images/buttons/sbutton_over.gif)"></div><input class="ButtonText" type="image" name="Submit" alt="Submit" src="'.$layout_name.'/images/buttons/_sbutton_submit.gif"></div></div></td></tr> </table> </div> </table></div></td></tr></form></center>';
  194. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement