PageRenderTime 51ms CodeModel.GetById 25ms RepoModel.GetById 0ms app.codeStats 0ms

/Includes/blocks/block_event.php

https://gitlab.com/donaldinou/nuked-gamer
PHP | 298 lines | 240 code | 50 blank | 8 comment | 84 complexity | fcc3edddae4d932690e06c958b255ff0 MD5 | raw file
Possible License(s): GPL-2.0, GPL-3.0, MPL-2.0-no-copyleft-exception, BSD-3-Clause
  1. <?php
  2. // -------------------------------------------------------------------------//
  3. // Nuked-KlaN - PHP Portal //
  4. // http://www.nuked-klan.org //
  5. // -------------------------------------------------------------------------//
  6. // This program is free software. you can redistribute it and/or modify //
  7. // it under the terms of the GNU General Public License as published by //
  8. // the Free Software Foundation; either version 2 of the License. //
  9. // -------------------------------------------------------------------------//
  10. defined("INDEX_CHECK") or die ('You can\'t run this file alone.');
  11. global $nuked, $language;
  12. translate('modules/Calendar/lang/' . $language . '.lang.php');
  13. function affich_block_event($blok){
  14. global $nuked, $bgcolor1, $bgcolor2, $bgcolor3, $file;
  15. define ('ADAY', (61 * 60 * 24));
  16. $datearray = getdate();
  17. if (empty($_REQUEST['mo']) && empty($_REQUEST['ye'])){
  18. $month = $datearray['mon'];
  19. $year = $datearray['year'];
  20. $nextmonth = $month + 1;
  21. $prevmonth = $month-1;
  22. if ($nextmonth > 12){
  23. $nextmonth = 1;
  24. $nextyear = $year + 1;
  25. }
  26. else $nextyear = $year;
  27. if ($prevmonth < 1){
  28. $prevmonth = 12;
  29. $prevyear = $year-1;
  30. }
  31. else $prevyear = $year;
  32. }
  33. else{
  34. $month = $_REQUEST['mo'];
  35. $year = $_REQUEST['ye'];
  36. $nextmonth = $_REQUEST['mo'] + 1;
  37. $prevmonth = $_REQUEST['mo']-1;
  38. if ($nextmonth > 12){
  39. $nextmonth = 1;
  40. $nextyear = $year + 1;
  41. }
  42. else $nextyear = $year;
  43. if ($prevmonth < 1){
  44. $prevmonth = 12;
  45. $prevyear = $year - 1;
  46. }
  47. else $prevyear = $year;
  48. }
  49. $start = mktime(0, 0, 0, $month, 1, $year);
  50. $firstdayarray = getdate($start);
  51. $months = Array(_JAN, _FEB, _MAR, _APR, _MAY, _JUN, _JUL, _AUG, _SEP, _OCT, _NOV, _DEC);
  52. $this_month = $month - 1;
  53. $days = Array(_SUN, _MON, _TUE, _WEN, _THR, _FRI, _SAT);
  54. $blok['content'] .= '<table style="margin:0 auto;text-align:left" cellpadding="0" cellspacing="0"><tr><td>'."\n"
  55. . '<a href="index.php?file='.$file.'&amp;mo=' . $prevmonth . '&amp;ye='.$prevyear.'" title="'._PREVMONTH.'"><small>&lt;&lt;</small></a>&nbsp;<b>'.$months[$this_month].'&nbsp;'.$year.'</b>&nbsp;'."\n"
  56. . '<a href="index.php?file='.$file.'&amp;mo='.$nextmonth.'&amp;ye='.$nextyear.'" title="'._NEXTMONTH.'"><small>&gt;&gt;</small></a></td></tr></table>'."\n"
  57. . '<table style="margin:0 auto;text-align:left" cellpadding="2" cellspacing="1"><tr>'."\n";
  58. $size = count($days);
  59. for($i=0; $i<$size; $i++){
  60. $blok['content'] .= '<td style="text-align:center"><b>' . $days[$i] . '</b></td>';
  61. }
  62. for($count = 0;$count < (6 * 7);$count++){
  63. $dayarray = getdate($start);
  64. if ((($count) % 7) == 0){
  65. $blok['content'] .= '</tr><tr>';
  66. }
  67. if ($count < $firstdayarray['wday'] || $dayarray['mon'] != $month){
  68. $blok['content'] .= '<td>&nbsp;</td>';
  69. }
  70. else{
  71. if ($dayarray['mday'] == $datearray['mday'] && $dayarray['mon'] == $datearray['mon']){
  72. $bd = '<b>';
  73. $bf = '</b>';
  74. }
  75. else{
  76. $bd = '';
  77. $bf = '';
  78. }
  79. $event_date = $dayarray['mday'];
  80. $txt = '';
  81. $heure2 = '';
  82. $sql1 = mysql_query('SELECT titre, date_jour, date_mois, date_an, heure, auteur FROM ' . CALENDAR_TABLE . ' WHERE date_an = \'' . $year . '\' AND date_mois = \'' . $month . '\' AND date_jour = \'' . $event_date . '\' ORDER BY heure');
  83. $nb_event = mysql_num_rows($sql1);
  84. if (defined("WARS_TABLE")){
  85. $sql2 = mysql_query('SELECT * FROM ' . WARS_TABLE . ' WHERE date_an = \'' . $year . '\' AND date_mois = \'' . $month . '\' AND date_jour = \'' . $event_date . '\' ');
  86. $nb_match = mysql_num_rows($sql2);
  87. }
  88. else{
  89. $nb_match = 0;
  90. }
  91. $nb_birthday = 0;
  92. if ($nuked['birthday'] != 'off'){
  93. $sql3 = mysql_query('SELECT user_id, age FROM ' . USER_DETAIL_TABLE);
  94. while (list($tuid, $tage) = mysql_fetch_array($sql3)){
  95. list ($tjour, $tmois, $tan) = explode ('/', $tage);
  96. if ($nuked['birthday'] == 'team'){
  97. $and = 'AND team > 0';
  98. }
  99. else if ($nuked['birthday'] == 'admin'){
  100. $and = 'AND niveau > 1';
  101. }
  102. else{
  103. $and = '';
  104. }
  105. $sql_test = mysql_query('SELECT pseudo FROM ' . USER_TABLE . ' WHERE id = \'' . $tuid . '\' '. $and);
  106. $test = mysql_num_rows($sql_test);
  107. if ($tmois == $month && $tjour == $event_date && $test > 0){
  108. $nb_birthday++;
  109. }
  110. }
  111. }
  112. if ($nb_match > 0 || $nb_event > 0 || $nb_birthday > 0){
  113. while (list($titre1, $jour1, $mois1, $an1, $heure1, $auteur1) = mysql_fetch_array($sql1)){
  114. $titre1 = printSecuTags($titre1);
  115. if (defined("WARS_TABLE")){
  116. $sql = mysql_query('SELECT etat, adversaire, type, date_jour, date_mois, date_an, heure, style, tscore_team, tscore_adv FROM ' . WARS_TABLE . ' WHERE date_an = \'' . $year . '\' AND date_mois = \''. $month . '\' AND date_jour = \'' . $event_date . '\' AND heure >= \'' . $heure2 . '\' AND heure < \'' . $heure1 . '\' ORDER BY heure');
  117. while (list($etat, $adv_name, $type_match, $jour, $mois, $an, $heure, $style, $score_team, $score_adv) = mysql_fetch_array($sql)){
  118. if ($etat == 1){
  119. if ($score_team < $score_adv){
  120. $scores = _RESULT . ' : <span style="color: #900"><b>' . $score_team . ' - ' . $score_adv . '</b></span>';
  121. }
  122. else if ($score_team > $score_adv){
  123. $scores = _RESULT . ' : <span style="color: #090"><b>' . $score_team . ' - ' . $score_adv . '</b></span>';
  124. }
  125. else{
  126. $scores = _RESULT . ' : <span style="color: #009"><b>' . $score_team . ' - ' . $score_adv . '</b></span>';
  127. }
  128. }
  129. else{
  130. $scores = "";
  131. }
  132. if ($heure) $txt .= '<b>' . $heure . '</b><br />';
  133. $txt .= _MATCH . '&nbsp:' . $type_match;
  134. if ($adv_name) $txt .= _VS . '&nbsp;' . $adv_name;
  135. if ($scores)$txt .= '<br />' . $scores;
  136. $txt .= '<br />';
  137. }
  138. }
  139. if ($heure1) $txt .= '<b>' . $heure1 . '</b><br />';
  140. $txt .= $titre1;
  141. $txt .= '<br />';
  142. $heure2 = $heure1;
  143. }
  144. if (defined("WARS_TABLE")){
  145. $sql = mysql_query('SELECT etat, adversaire, type, date_jour, date_mois, date_an, heure, style, tscore_team, tscore_adv FROM ' . WARS_TABLE . ' WHERE date_an = \'' . $year . '\' AND date_mois = \'' . $month . '\' AND date_jour = \'' . $event_date . '\' AND heure >= \'' . $heure2 . '\' ORDER BY heure');
  146. while (list($etat, $adv_name, $type_match, $jour, $mois, $an, $heure, $style, $score_team, $score_adv) = mysql_fetch_array($sql)){
  147. if ($etat == 1 && $score_team != "" && $score_adv != ""){
  148. if ($score_team < $score_adv){
  149. $scores = _RESULT . ' : <span style="color: #900;"><b>' . $score_team . ' - ' . $score_adv . '</b></span>';
  150. }
  151. else if ($score_team > $score_adv){
  152. $scores = _RESULT . ' : <span style="color: #090;"><b>' . $score_team . ' - ' . $score_adv . '</b></span>';
  153. }
  154. else{
  155. $scores = _RESULT . " : <span style='color: #000099;'><b>" . $score_team . "&nbsp;-&nbsp;" . $score_adv . "</b></span>";
  156. }
  157. }
  158. else{
  159. $scores = '';
  160. }
  161. if ($heure) $txt .= '<b>' . $heure . '</b><br />';
  162. $txt .= _MATCH . '&nbsp;' . $type_match;
  163. if ($adv_name) $txt .= '&nbsp;' . _VS . '&nbsp;' . $adv_name;
  164. if ($scores)$txt .= '<br />' . $scores;
  165. $txt .= '<br /><br />';
  166. }
  167. }
  168. if ($nb_birthday > 0){
  169. $sql4 = mysql_query('SELECT user_id, prenom, age FROM ' . USER_DETAIL_TABLE);
  170. while (list($id_user, $prenom, $birthday) = mysql_fetch_array($sql4)){
  171. if ($birthday != ""){
  172. list ($ajour, $amois, $aan) = explode ('/', $birthday);
  173. if ($amois == $month && $ajour == $event_date){
  174. $age = $year - $aan;
  175. if ($month < $amois){
  176. $age = $age - 1;
  177. }
  178. if ($event_date < $ajour && $month == $amois){
  179. $age = $age-1;
  180. }
  181. $sql5 = mysql_query('SELECT pseudo FROM ' . USER_TABLE . ' WHERE id = \'' . $id_user . '\' ' . $and);
  182. list($pseudo) = mysql_fetch_array($sql5);
  183. if ($prenom != ""){
  184. $nom = $prenom;
  185. }
  186. else{
  187. $nom = $pseudo;
  188. }
  189. $txt .= '<b>' . _BIRTHDAY . ' : ' . $pseudo . '</b><br />' . _BIRTHDAYTEXT . '&nbsp;<b>' . $nom . '</b>&nbsp;' . _BIRTHDAYTEXTSUITE . '&nbsp;<b>' . $age . '</b>&nbsp;' . _YEARSOLD . '<br /><br />';
  190. }
  191. }
  192. }
  193. }
  194. $blok['content'] .= '<td style="background: ' . $bgcolor1 . ';border: 1px solid ' . $bgcolor3 . ';text-align:center;" onmouseover="AffBulle(\'&nbsp;&nbsp;&nbsp;&nbsp;' . $event_date . '&nbsp;' . $months[$this_month] . '&nbsp;' . $year . '\', \'' . htmlentities(mysql_real_escape_string($txt), ENT_NOQUOTES, 'ISO-8859-1') . '\', 200)" onmouseout="HideBulle()">'."\n"
  195. . '<a href="index.php?file=Calendar&amp;m=' . $month . '&amp;y=' . $year . '">'. $bd . $dayarray['mday'] . $bf . '</a></td>'."\n";
  196. }
  197. else{
  198. $blok['content'] .= '<td align="center"><span style="text-align: center;">' . $bd . $dayarray[mday] . $bf . '</span></td>'."\n";
  199. }
  200. $start += ADAY;
  201. }
  202. }
  203. $blok['content'] .= '</tr></table>'."\n";
  204. return $blok;
  205. }
  206. function edit_block_event($bid){
  207. global $nuked, $language;
  208. $sql = mysql_query('SELECT active, position, titre, module, content, type, nivo, page FROM ' . BLOCK_TABLE . ' WHERE bid = \'' . $bid . '\' ');
  209. list($active, $position, $titre, $modul, $content, $type, $nivo, $pages) = mysql_fetch_array($sql);
  210. $titre = printSecuTags($titre);
  211. if ($active == 1) $checked1 = 'selected="selected"';
  212. else if ($active == 2) $checked2 = 'selected="selected"';
  213. else $checked0 = 'selected="selected"';
  214. echo '<div class="content-box">'."\n" //<!-- Start Content Box -->
  215. . '<div class="content-box-header"><h3>'._BLOCKADMIN.'</h3>'."\n"
  216. . '<a href="help/'.$language.'/block.html" rel="modal">'."\n"
  217. . '<img style="border: 0;" src="help/help.gif" alt="" title="'._HELP.'" /></a>'."\n"
  218. . '</div>'."\n"
  219. . '<div class="tab-content" id="tab2"><form method="post" action="index.php?file=Admin&amp;page=block&amp;op=modif_block">'."\n"
  220. . '<table style="margin:0 auto;text-align: left;" cellspacing="0" cellpadding="2" border="0">'."\n"
  221. . '<tr><td><b>'._TITLE.'</b></td><td><b>'._BLOCK.'</b></td><td><b>'._POSITION.'</b></td><td><b>'._LEVEL.'</b></td></tr>'."\n"
  222. . '<tr><td style="text-align:center;" ><input type="text" name="titre" size="40" value="'.$titre.'" /></td>'."\n"
  223. . '<td style="text-align:center;"><select name="active">'."\n"
  224. . '<option value="1" '.$checked1.'>'._LEFT.'</option>'."\n"
  225. . '<option value="2" '.$checked2.'>'._RIGHT.'</option>'."\n"
  226. . '<option value="0" '.$checked0.'>'._OFF.'</option></select></td>'."\n"
  227. . '<td style="text-align:center;" ><input type="text" name="position" size="2" value="'.$position.'" /></td>'."\n"
  228. . '<td style="text-align:center;" ><select name="nivo"><option>'.$nivo.'</option>'."\n"
  229. . '<option>0</option>'."\n"
  230. . '<option>1</option>'."\n"
  231. . '<option>2</option>'."\n"
  232. . '<option>3</option>'."\n"
  233. . '<option>4</option>'."\n"
  234. . '<option>5</option>'."\n"
  235. . '<option>6</option>'."\n"
  236. . '<option>7</option>'."\n"
  237. . '<option>8</option>'."\n"
  238. . '<option>9</option></select></td></tr><tr><td colspan="4">&nbsp;</td></tr><tr><td colspan="4" style="text-align:center;" ><b>'._PAGESELECT.' :</b></td></tr><tr><td colspan="4">&nbsp;</td></tr>'."\n"
  239. . '<tr><td colspan="4" align="center"><select name="pages[]" size="8" multiple="multiple">'."\n";
  240. select_mod2($pages);
  241. echo '</select></td></tr><tr><td colspan="4" style="text-align:center;" ><br />'."\n"
  242. . '<input type="hidden" name="type" value="'.$type.'" />'."\n"
  243. . '<input type="hidden" name="bid" value="'.$bid.'" />'."\n"
  244. . '<input type="submit" name="send" value="'._MODIFBLOCK.'" />'."\n"
  245. . '</td></tr></table>'
  246. . '<div style="text-align: center;"><br />[ <a href="index.php?file=Admin&amp;page=block"><b>'._BACK.'</b></a> ]</div></form><br /></div></div>'."\n";
  247. }
  248. ?>