Advertisement
Guest User

latestnews.php

a guest
Dec 29th, 2014
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 17.62 KB | None | 0 0
  1. <?PHP
  2. //######################## SHOW TICKERS AND NEWS #######################
  3. $time = time();
  4. $query = $SQL->query("SELECT * FROM `players` ORDER BY `experience` DESC")->fetch();
  5. $query2 = $SQL->query('SELECT `id`, `name` FROM `players` ORDER BY `id` DESC LIMIT 1;')->fetch();
  6. $housesfree = $SQL->query('SELECT COUNT(*) FROM `houses` WHERE `owner`=0;')->fetch();
  7. $housesrented = $SQL->query('SELECT COUNT(*) FROM `houses` WHERE `owner`=1;')->fetch();
  8. $players = $SQL->query('SELECT COUNT(*) FROM `players` WHERE `id`>0;')->fetch();
  9. $accounts = $SQL->query('SELECT COUNT(*) FROM `accounts` WHERE `id`>0;')->fetch();
  10. //$banned = $SQL->query('SELECT COUNT(*) FROM `account_ban_history` WHERE `id`>0;')->fetch();
  11. $guilds = $SQL->query('SELECT COUNT(*) FROM `guilds` WHERE `id`>0;')->fetch();
  12. ///End Queries ///
  13. // top kills - guilds
  14. $main_content .= '<div class="NewsHeadline">
  15. <div class="NewsHeadlineBackground" style="background-image:url(' . $layout_name . '/images/news/newsheadline_background.gif)">
  16. <table border="0">
  17. <tr>
  18. <td style="text-align: center; font-weight: bold;">
  19. <font color="white">Most powerfull guilds</font>
  20. </td>
  21. </tr>
  22. </table>
  23. </div>
  24. </div>
  25. <table border="0" cellspacing="3" cellpadding="4" width="100%"><tr>';
  26.  
  27. foreach($SQL->query('SELECT `g`.`id` AS `id`, `g`.`name` AS `name`, COUNT(`g`.`name`) as `frags` FROM `players` p LEFT JOIN `player_deaths` pd ON `pd`.`killed_by` = `p`.`name` LEFT JOIN `guild_membership` gm ON `p`.`id` = `gm`.`player_id` LEFT JOIN `guilds` g ON `gm`.`guild_id` = `g`.`id` WHERE `g`.`id` > 0 AND `pd`.`unjustified` = 1 GROUP BY `name` ORDER BY `frags` DESC, `name` ASC LIMIT 4;') as $guild)
  28. $main_content .= '<td style="width: 25%; text-align: center;"><a href="?subtopic=guilds&action=show&guild=' . $guild['id'] . '"><img src="guild_image.php?id=' . $guild['id'] . '" width="64" height="64" border="0"/> <br />' . $guild['name'] . '</a><br />' . $guild['frags'] . ' kills
  29. </td>';
  30. $main_content .= '</tr></table>';
  31.  
  32.  
  33.  
  34. $main_content .= '<table bgcolor='.$config['site']['darkborder'].' border=0 cellpadding=4 cellspacing=1 width=100%>
  35. <tr bgcolor='. $config['site']['vdarkborder'] .'><td align="center" class=white colspan=1><b>Welcome to '.$config['server']['serverName'].'</b></td></tr>
  36. <tr><td><table border=0 cellpadding=1 cellspacing=1 width=100%>
  37.  
  38. <tr bgcolor='. $config['site']['lightborder'] .'><td><center>Last joined us: <a href="?subtopic=characters&name='.urlencode($query2['name']).'">'.$query2['name'].'</a>, player number '.$query2['id'].'. Welcome and wish you a nice game!</center></td></tr>
  39. <tr bgcolor='. $config['site']['lightborder'] .'><td><center>Currently, the best player on the server is: <a href="index.php?subtopic=characters&name='.urlencode($query['name']).'"> '.$query['name'].'</a> ('.urlencode($query['level']).'). Congratulations!</center></td></tr>
  40. <table border=0 cellpadding=0 cellspacing=1 width=100%>
  41. <tr bgcolor='. $config['site']['lightborder'] .'><td><center><b>Free Houses:</b> '.$housesfree[0].'</center></td>
  42. <td><center><b>Rented Houses:</b> '.$housesrented[0].'</center></td></tr>
  43. <tr bgcolor='. $config['site']['lightborder'] .'><td><center><b>Accounts</b> in database: '.$accounts[0].'</center></td>
  44. <td><center><b>Players</b> in database: '.$players[0].'</center></td></tr>
  45. <tr bgcolor='. $config['site']['lightborder'] .'><td><center><b>Banned</b> accounts: '.$banned[0].'</center></td>
  46. <td><center><b>Guilds</b> in databese: '.$guilds[0].'</center></td></tr>
  47.  
  48. </table></td></tr></table>';
  49. if($action == "") {
  50.  
  51. //show tickers if any in database or not blocked (tickers limit = 0)
  52. $tickers = $SQL->query('SELECT * FROM `z_news_tickers` WHERE hide_ticker != 1 ORDER BY date DESC LIMIT 4;');
  53. $number_of_tickers = 0;
  54. if(is_object($tickers)) {
  55. foreach($tickers as $ticker) {
  56. if(is_int($number_of_tickers / 2))
  57. $color = "Odd";
  58. else
  59. $color = "Even";
  60. $tickers_to_add .= '<div id="TickerEntry-'.$number_of_tickers.'" class="Row" onclick=\'TickerAction("TickerEntry-'.$number_of_tickers.'")\'>
  61. <div class="'.$color.'">
  62. <div class="NewsTickerIcon" style="background-image: url('.$layout_name.'/images/news/icon_'.$ticker['image_id'].'.gif);"></div>
  63. <div id="TickerEntry-'.$number_of_tickers.'-Button" class="NewsTickerExtend" style="background-image: url('.$layout_name.'/images/general/plus.gif);"></div>
  64. <div class="NewsTickerText">
  65. <span class="NewsTickerDate">'.date("j M Y", $ticker['date']).' -</span>
  66. <div id="TickerEntry-'.$number_of_tickers.'-ShortText" class="NewsTickerShortText">';
  67. //if admin show button to delete (hide) ticker
  68. if($group_id_of_acc_logged >= $config['site']['access_admin_panel']) {
  69. $tickers_to_add .= '<a href="?subtopic=latestnews&action=deleteticker&id='.$ticker['date'].'"><img src="'.$layout_name.'/images/news/delete.png" border="0"></a>';
  70. }
  71. $tickers_to_add .= short_text($ticker['text'], 60).'</div>
  72. <div id="TickerEntry-'.$number_of_tickers.'-FullText" class="NewsTickerFullText">';
  73. //if admin show button to delete (hide) ticker
  74. if($group_id_of_acc_logged >= $config['site']['access_admin_panel']) {
  75. $tickers_to_add .= '<a href="?subtopic=latestnews&action=deleteticker&id='.$ticker['date'].'"><img src="'.$layout_name.'/images/news/delete.png" border="0"></a>';
  76. }
  77. $tickers_to_add .= $ticker['text'].'</div>
  78. </div>
  79. </div>
  80. </div>';
  81. $number_of_tickers++;
  82. }
  83. }
  84.  
  85. if(!empty($tickers_to_add)) {
  86. //show table with tickers
  87. $news_content .= '<div id="newsticker" class="Box">
  88. <div class="Corner-tl" style="background-image: url('.$layout_name.'/images/content/corner-tl.gif);"></div>
  89. <div class="Corner-tr" style="background-image: url('.$layout_name.'/images/content/corner-tr.gif);"></div>
  90. <div class="Border_1" style="background-image: url('.$layout_name.'/images/content/border-1.gif);"></div>
  91. <div class="BorderTitleText" style="background-image: url('.$layout_name.'/images/content/title-background-green.gif);"></div>
  92. <img class="Title" src="'.$layout_name.'/images/header/headline-newsticker.gif" alt="Contentbox headline">
  93. <div class="Border_2">
  94. <div class="Border_3">
  95. <div class="BoxContent" style="background-image: url('.$layout_name.'/images/content/scroll.gif);">';
  96. if($group_id_of_acc_logged >= $config['site']['access_admin_panel'])
  97. $news_content .= '<script type="text/javascript">
  98. var showednewticker_state = "0";
  99. function showNewTickerForm()
  100. {
  101. if(showednewticker_state == "0") {
  102. document.getElementById("newtickerform").innerHTML = \'<form action="?subtopic=latestnews&action=newticker" method="post" ><table border="0"><tr><td bgcolor="D4C0A1" align="center"><b>Select icon:</b></td><td><table border="0" bgcolor="F1E0C6"><tr><td><img src="images/news/icon_0.gif" width="20"></td><td><img src="images/news/icon_1.gif" width="20"></td><td><img src="images/news/icon_2.gif" width="20"></td><td><img src="images/news/icon_3.gif" width="20"></td><td><img src="images/news/icon_4.gif" width="20"></td></tr><tr><td><input type="radio" name="icon_id" value="0" checked="checked"></td><td><input type="radio" name="icon_id" value="1"></td><td><input type="radio" name="icon_id" value="2"></td><td><input type="radio" name="icon_id" value="3"></td><td><input type="radio" name="icon_id" value="4"></td></tr></table></td></tr><tr><td align="center" bgcolor="D4C0A1"><b>New<br>ticker<br>text:</b></td><td bgcolor="F1E0C6"><textarea name="new_ticker" rows="3" cols="45"></textarea></td></tr><tr><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></form><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><img class="ButtonText" id="AddTicker" src="'.$layout_name.'/images/buttons/_sbutton_cancel.gif" onClick="showNewTickerForm()" alt="AddTicker" /></div></div></td></tr></table>\';
  103. document.getElementById("jajo").innerHTML = \'\';
  104. showednewticker_state = "1";
  105. }
  106. else {
  107. document.getElementById("newtickerform").innerHTML = \'\';
  108. document.getElementById("jajo").innerHTML = \'<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><img class="ButtonText" id="AddTicker" src="'.$layout_name.'/images/buttons/addticker.gif" onClick="showNewTickerForm()" alt="AddTicker" /></div></div>\';
  109. showednewticker_state = "0";
  110. }
  111. }
  112. </script><div id="newtickerform"></div><div id="jajo"><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><img class="ButtonText" id="AddTicker" src="'.$layout_name.'/images/buttons/addticker.gif" onClick="showNewTickerForm()" alt="AddTicker" /></div></div></div><hr/>';
  113. //add tickers list
  114. $news_content .= $tickers_to_add;
  115. //koniec
  116. $news_content .= '</div>
  117. </div>
  118. </div>
  119. <div class="Border_1" style="background-image: url('.$layout_name.'/images/content/border-1.gif);"></div>
  120. <div class="CornerWrapper-b"><div class="Corner-bl" style="background-image: url('.$layout_name.'/images/content/corner-bl.gif);"></div></div>
  121. <div class="CornerWrapper-b"><div class="Corner-br" style="background-image: url('.$layout_name.'/images/content/corner-br.gif);"></div></div>
  122. </div>';
  123. }
  124. }
  125. //##################### ADD NEW TICKER #####################
  126. if($action == "newticker") {
  127. if($group_id_of_acc_logged >= $config['site']['access_tickers']) {
  128. $ticker_text = stripslashes(trim($_POST['new_ticker']));
  129. $ticker_icon = (int) $_POST['icon_id'];
  130. if(empty($ticker_text)) {
  131. $main_content .= 'You can\'t add empty ticker.';
  132. }
  133. else
  134. {
  135. if(empty($ticker_icon)) {
  136. $ticker_icon = 0;
  137. }
  138. $SQL->query('INSERT INTO '.$SQL->tableName('z_news_tickers').' (date, author, image_id, text, hide_ticker) VALUES ('.$SQL->quote($time).', '.$account_logged->getId().', '.$ticker_icon.', '.$SQL->quote($ticker_text).', 0)');
  139. $main_content .= '<center><h2><font color="red">Added new ticker:</font></h2></center><hr/><div id="newsticker" class="Box"><div id="TickerEntry-1" class="Row" onclick=\'TickerAction("TickerEntry-1")\'>
  140. <div class="Odd">
  141. <div class="NewsTickerIcon" style="background-image: url('.$layout_name.'/images/news/icon_'.$ticker['image_id'].'.gif);"></div>
  142. <div id="TickerEntry-1-Button" class="NewsTickerExtend" style="background-image: url('.$layout_name.'/images/general/plus.gif);"></div>
  143. <div class="NewsTickerText">
  144. <span class="NewsTickerDate">'.date("j M Y", $time).' -</span>
  145. <div id="TickerEntry-1-ShortText" class="NewsTickerShortText">';
  146. $main_content .= '<a href="?subtopic=latestnews&action=deleteticker&id='.$time.'"><img src="'.$layout_name.'/images/news/delete.png" border="0"></a>';
  147. $main_content .= short_text($ticker_text, 60).'</div>
  148. <div id="TickerEntry-1-FullText" class="NewsTickerFullText">';
  149. $main_content .= '<a href="?subtopic=latestnews&action=deleteticker&id='.$time.'"><img src="'.$layout_name.'/images/news/delete.png" border="0"></a>';
  150. $main_content .= $ticker_text.'</div>
  151. </div>
  152. </div>
  153. </div></div><hr/>';
  154. }
  155. }
  156. else
  157. {
  158. $main_content .= 'You don\'t have admin rights. You can\'t add new ticker.';
  159. }
  160. $main_content .= '<form action="?subtopic=latestnews" METHOD=post><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="Back" alt="Back" src="'.$layout_name.'/images/buttons/_sbutton_back.gif" ></div></div></form>';
  161. }
  162. //#################### DELETE (HIDE only!) TICKER ############################
  163. if($action == "deleteticker") {
  164. if($group_id_of_acc_logged >= $config['site']['access_tickers']) {
  165. header("Location: ");
  166. $date = (int) $_REQUEST['id'];
  167. $SQL->query('UPDATE '.$SQL->tableName('z_news_tickers').' SET hide_ticker = 1 WHERE '.$SQL->fieldName('date').' = '.$date.';');
  168. $main_content .= '<center>News tickets with <b>date '.date("j F Y, g:i a", $date).'</b> has been deleted.<form action="?subtopic=latestnews" METHOD=post><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="Back" alt="Back" src="'.$layout_name.'/images/buttons/_sbutton_back.gif" ></div></div></form></center>';
  169. }
  170. else
  171. {
  172. $main_content .= '<center>You don\'t have admin rights. You can\'t delete tickers.<form action="?subtopic=latestnews" METHOD=post><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="Back" alt="Back" src="'.$layout_name.'/images/buttons/_sbutton_back.gif" ></div></div></form></center>';
  173. }
  174. }
  175. if($group_id_of_acc_logged >= $config['site']['access_admin_panel']){$main_content .= '<a href="?subtopic=forum&action=new_topic&section_id=1">Add new news</a>';}
  176. $zapytanie = $SQL->query("SELECT `z_forum`.`post_topic`, `z_forum`.`author_guid`, `z_forum`.`post_date`, `z_forum`.`post_text`, `z_forum`.`id`, `z_forum`.`replies`, `players`.`name` FROM `z_forum`, `players` WHERE `section` = '1' AND `z_forum`.`id` = `first_post` AND `players`.`id` = `z_forum`.`author_guid` ORDER BY `post_date` DESC LIMIT 6;")->fetchAll();
  177. foreach ($zapytanie as $row)
  178. {
  179. $BB = array(
  180. '/\[b\](.*?)\[\/b\]/is' => '<strong>$1</strong>',
  181. '/\[quote\](.*?)\[\/quote\]/is' => '<table cellpadding="0" style="background-color: #c4c4c4; width: 480px; border-style: dotted; border-color: #007900; border-width: 2px"><tr><td>$1</td></tr></table>',
  182. '/\[u\](.*?)\[\/u\]/is' => '<u>$1</u>',
  183. '/\[i\](.*?)\[\/i\]/is' => '<i>$1</i>',
  184. '/\[url](.*?)\[\/url\]/is' => '<a href=$1>$1</a>',
  185. '/\[img\](.*?)\[\/img\]/is' => '<img src=$1 alt=$1 />',
  186. '/\[player\](.*?)\[\/player\]/is' => '<a href='.$server['ip'].'?subtopic=characters&amp;name=$1>$1</a>',
  187. '/\[code\](.*?)\[\/code\]/is' => '<div dir="ltr" style="margin: 0px;padding: 2px;border: 1px inset;width: 500px;height: 290px;text-align: left;overflow: auto"><code style="white-space:nowrap">$1</code></div>'
  188. );
  189. $message = preg_replace(array_keys($BB), array_values($BB), nl2br($row['post_text']));
  190. $main_content .= '<div class=\'NewsHeadline\'>
  191. <div class=\'NewsHeadlineBackground\' style=\'background-image:url('.$layout_name.'/images/news/newsheadline_background.gif)\'>
  192. <table border=0><tr><td><img src="'.$layout_name.'/images/news/icon_1.gif" class=\'NewsHeadlineIcon\' alt=\'\' />
  193. </td><td><font color="'.$layout_ini['news_title_color'].'">'.date('d.m.y H:i:s', $row['post_date']).' - <b>'.$row['post_topic'].'</b></font></td></tr></table>
  194. </div>
  195. </div>
  196. <table style=\'clear:both\' border=0 cellpadding=0 cellspacing=0 width=\'100%\'><tr>
  197. <td><img src="'.$layout_name.'/images/global/general/blank.gif" width=10 height=1 border=0 alt=\'\' /></td>';
  198. if($group_id_of_acc_logged >= $config['site']['access_admin_panel'])
  199. {
  200. $main_content .='<td width="100%">'.$message.'<br><h6><i>Posted by </i><font color="green">'.$row['name'].'</font></h6><p align="right"><a href="?subtopic=forum&action=remove_post&id='.$row['id'].'"><font color="red">[Delete this news]</font></a> <a href="?subtopic=forum&action=edit_post&id='.$row['id'].'"><font color="green">[Edit this news]</font></a> <a href="?subtopic=forum&action=show_thread&id='.$row['id'].'">Comments: '.$row['replies'].'</a></p>';
  201. }
  202. else
  203. {
  204. $main_content .='<td width="100%">'.$message.'<br><h6><i>Posted by </i><font color="green">'.$row['name'].'</font></h6><p align="right"><a href="?subtopic=forum&action=show_thread&id='.$row['id'].'">Comments: '.$row['replies'].'</a></p>';
  205. }
  206. $main_content .= '</td>
  207. <td><img src="'.$layout_name.'/images/global/general/blank.gif" width=10 height=1 border=0 alt=\'\' /></td>
  208. </tr></table>';
  209. }
  210.  
  211. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement