Advertisement
Guest User

calendar index.php

a guest
Nov 8th, 2011
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 39.27 KB | None | 0 0
  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. if (!defined("INDEX_CHECK"))
  11. {
  12.     die ("<div style=\"text-align: center;\">You cannot open this page directly</div>");
  13. }
  14.  
  15. global $language, $user;
  16. translate("modules/Calendar/lang/" . $language . ".lang.php");
  17.  
  18. if (!$user)
  19. {
  20.     $visiteur = 0;
  21. }
  22. else
  23. {
  24.     $visiteur = $user[1];
  25. }
  26. $ModName = basename(dirname(__FILE__));
  27. $level_access = nivo_mod($ModName);
  28. if ($visiteur >= $level_access && $level_access > -1)
  29. {
  30.     compteur("Calendar");
  31.  
  32.     function index()
  33.     {
  34.         global $bgcolor1, $bgcolor2, $bgcolor3, $bgcolor4, $user;
  35.  
  36.         $SECONDS_PER_DAY = 60 * 60 * 24;
  37.  
  38.         function is_in_array($value , $array)
  39.         {
  40.             for ($i = 0 ; $i < sizeof($array) ; $i++)
  41.             {
  42.                 if (!strcmp($value , $array[$i]))
  43.                 {
  44.                     return 1;
  45.                 }
  46.             }
  47.             return 0;
  48.         }
  49.  
  50.         function cl_trim ($s)
  51.         {
  52.             $ret = preg_replace ("`^[[:space:]]+|[[:space:]]+$`i", "", $s);
  53.             return $ret;
  54.         }
  55.  
  56.         function js_popup($w = 800, $h = 600)
  57.         {
  58.             echo "<script type=\"text/javascript\">\n"
  59.             . "<!--\n"
  60.             . "function openWin(type,id,d,m,y){\n"
  61.             . "w = window.open('index.php?file=Calendar&nuked_nude=index&op=show_event&eid='+id+'&type='+type+'&d='+d+'&m='+m+'&y='+y,'event'+id,'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=" . $w . ",height=" . $h . ",top=30,left=0');\n"
  62.             . "}\n"
  63.             . "// -->\n"
  64.             . "</script>";
  65.         }
  66.  
  67.         class month
  68.         {
  69.             var $months_hash = array("01" => _JAN, "02" => _FEB, "03" => _MAR, "04" => _APR, "05" => _MAY, "06" => _JUN, "07" => _JUL, "08" => _AUG, "09" => _SEP, "10" => _OCT, "11" => _NOV, "12" => _DEC);
  70.             var $month_name;
  71.             var $month_number;
  72.             var $year;
  73.             var $month_data;
  74.             var $nextmonth;
  75.             var $nextyear;
  76.             var $prevmonth;
  77.             var $prevyear;
  78.  
  79.             function month($thismonth = "" , $thisyear = "")
  80.             {
  81.                 global $nuked;
  82.  
  83.                 if (!$thismonth)
  84.                 {
  85.                     $thismonth = date("m");
  86.                 }
  87.  
  88.                 if (!$thisyear)
  89.                 {
  90.                     $thisyear = date("Y");
  91.                 }
  92.  
  93.                 $this->month_name = $this->months_hash[$thismonth];
  94.                 $this->month_number = $thismonth;
  95.                 $this->year = $thisyear;
  96.  
  97.                 $this->nextmonth = sprintf("%02d", $this->month_number + 1);
  98.                 $this->prevmonth = sprintf("%02d", $this->month_number-1);
  99.                 $this->nextyear = $this->prevyear = $thisyear;
  100.  
  101.                 if ($this->month_number == "12")
  102.                 {
  103.                     $this->nextmonth = "01";
  104.                     $this->nextyear = $thisyear + 1;
  105.                 }
  106.                 if ($this->month_number == "01")
  107.                 {
  108.                     $this->prevmonth = "12";
  109.                     $this->prevyear = $thisyear - 1;
  110.                 }
  111.  
  112.                 $query = "SELECT warid, date_jour, adversaire FROM " . WARS_TABLE . " WHERE date_mois = '" . $this->month_number . "' AND date_an = '" . $this->year . "' ORDER BY date_jour";
  113.                 $result = mysql_query($query);
  114.  
  115.                 if (!$result)
  116.                 {
  117.                     echo mysql_error() . ": " . mysql_errno();
  118.                 }
  119.  
  120.                 while ($tmp = mysql_fetch_array($result))
  121.                 {
  122.                     if (strcmp($tmp['adversaire'] , "") != 0)
  123.                     {
  124.                         $tmp['adversaire'] = htmlentities($tmp['adversaire']);
  125.                         $this->month_data[$tmp['date_jour']]['id'][] = $tmp["warid"];
  126.                         $this->month_data[$tmp['date_jour']]['event_title'][] = "<span title=\"" . _MATCH . "&nbsp;" . _VS . "&nbsp;" . $tmp['adversaire'] . "\">" . _MATCH . "</span>";
  127.                         $this->month_data[$tmp['date_jour']]['event_type'][] = "match";
  128.                     }
  129.                 }
  130.  
  131.                 $query2 = "SELECT id, date_jour, titre FROM " . CALENDAR_TABLE . " WHERE date_mois = '" . $this->month_number . "' AND date_an = '" . $this->year . "'  ORDER BY date_jour";
  132.                 $data2 = mysql_query($query2);
  133.  
  134.                 if (!$data2)
  135.                 {
  136.                     echo mysql_error() . ": " . mysql_errno();
  137.                 }
  138.  
  139.                 while ($cmp = mysql_fetch_array($data2))
  140.                 {
  141.                     if (strcmp($cmp['titre'] , "") != 0)
  142.                     {
  143.                         $cmp['titre'] = htmlentities($cmp['titre']);
  144.                         $this->month_data[$cmp['date_jour']]['id'][] = $cmp['id'];
  145.                         $this->month_data[$cmp['date_jour']]['event_title'][] = "<span title=\"" . $cmp['titre'] . "\">" . _EVENT . "</span>";
  146.                         $this->month_data[$cmp['date_jour']]['event_type'][] = "divers";
  147.                     }
  148.                 }
  149.  
  150.                 if ($nuked['birthday'] != 'off')
  151.                 {
  152.                     if ($nuked['birthday'] == "team")
  153.                     {
  154.             $where = "WHERE team > 0";
  155.                     }
  156.                     else if ($nuked['birthday'] == "admin")
  157.                     {
  158.             $where = "WHERE niveau > 1";
  159.                     }
  160.                     else
  161.                     {
  162.             $where = "";
  163.                     }
  164.  
  165.                     $query3 = "SELECT user_id, age, pseudo FROM " . USER_DETAIL_TABLE . " INNER JOIN " . USER_TABLE . " ON user_id = id " . $where;
  166.                     $data3 = mysql_query($query3);
  167.  
  168.                     if (!$data3)
  169.                     {
  170.                         echo mysql_error() . ": " . mysql_errno();
  171.                     }
  172.  
  173.                     while ($amp = mysql_fetch_array($data3))
  174.                     {
  175.                         if ($amp['age'] != "")
  176.                         {
  177.                             list ($jour, $mois, $an) = explode ('/', $amp['age']);
  178.  
  179.                             if ($mois == $thismonth)
  180.                             {
  181.                                 $this->month_data[$jour]['id'][] = $amp['user_id'];
  182.                                 $this->month_data[$jour]['event_title'][] = "<span title=\"" . _BIRTHDAY . "&nbsp;" . $pseudo . "\">" ._BIRTHDAY . "</span>";
  183.                                 $this->month_data[$jour]['event_type'][] = "birthday";
  184.                             }
  185.                         }
  186.                     }
  187.                 }
  188.             }
  189.  
  190.             function print_month_name()
  191.             {
  192.                 echo $this->month_name;
  193.             }
  194.  
  195.             function print_year()
  196.             {
  197.                 echo $this->year;
  198.             }
  199.  
  200.             function print_datestring()
  201.             {
  202.                 echo $this->month_name . ", " . $this->year;
  203.             }
  204.  
  205.             function days_in_month($month, $year)
  206.             {
  207.                 if ($month == "01")
  208.                 {
  209.                     $days_in_month = 31;
  210.                 }
  211.                 if ($month == "02" && $year % 4 == 0 && ($year % 100 != 0 || $year % 1000 == 0))
  212.                 {
  213.                     $days_in_month = 29;
  214.                 }
  215.                 else if ($month == "02")
  216.                 {
  217.                     $days_in_month = 28;
  218.                 }
  219.  
  220.                 if ($month == "03")
  221.                 {
  222.                     $days_in_month = 31;
  223.                 }
  224.                 if ($month == "04")
  225.                 {
  226.                     $days_in_month = 30;
  227.                 }
  228.                 if ($month == "05")
  229.                 {
  230.                     $days_in_month = 31;
  231.                 }
  232.                 if ($month == "06")
  233.                 {
  234.                     $days_in_month = 30;
  235.                 }
  236.                 if ($month == "07")
  237.                 {
  238.                     $days_in_month = 31;
  239.                 }
  240.                 if ($month == "08")
  241.                 {
  242.                     $days_in_month = 31;
  243.                 }
  244.                 if ($month == "09")
  245.                 {
  246.                     $days_in_month = 30;
  247.                 }
  248.                 if ($month == "10")
  249.                 {
  250.                     $days_in_month = 31;
  251.                 }
  252.                 if ($month == "11")
  253.                 {
  254.                     $days_in_month = 30;
  255.                 }
  256.                 if ($month == "12")
  257.                 {
  258.                     $days_in_month = 31;
  259.                 }
  260.                 return $days_in_month;
  261.             }
  262.  
  263.             function _get_date_by_counter($i, $month, $year)
  264.             {
  265.                 $first_day = date("w" , mktime(0, 0, 0, $month, 1, $year));
  266.                 if ($month == "01")
  267.                 {
  268.                     $days_in_month = 31;
  269.                 }
  270.                 if ($month == "02" && $year % 4 == 0 && ($year % 100 != 0 || $year % 1000 == 0))
  271.                 {
  272.                     $days_in_month = 29;
  273.                 }
  274.                 else if ($month == "02")
  275.                 {
  276.                     $days_in_month = 28;
  277.                 }
  278.                 if ($month == "03")
  279.                 {
  280.                     $days_in_month = 31;
  281.                 }
  282.                 if ($month == "04")
  283.                 {
  284.                     $days_in_month = 30;
  285.                 }
  286.                 if ($month == "05")
  287.                 {
  288.                     $days_in_month = 31;
  289.                 }
  290.                 if ($month == "06")
  291.                 {
  292.                     $days_in_month = 30;
  293.                 }
  294.                 if ($month == "07")
  295.                 {
  296.                     $days_in_month = 31;
  297.                 }
  298.                 if ($month == "08")
  299.                 {
  300.                     $days_in_month = 31;
  301.                 }
  302.                 if ($month == "09")
  303.                 {
  304.                     $days_in_month = 30;
  305.                 }
  306.                 if ($month == "10")
  307.                 {
  308.                     $days_in_month = 31;
  309.                 }
  310.                 if ($month == "11")
  311.                 {
  312.                     $days_in_month = 30;
  313.                 }
  314.                 if ($month == "12")
  315.                 {
  316.                     $days_in_month = 31;
  317.                 }
  318.  
  319.                 if ($i < $first_day)
  320.                 {
  321.                     return "&nbsp;";
  322.                 }
  323.                 if ($i >= $days_in_month + $first_day)
  324.                 {
  325.                     return "&nbsp;";
  326.                 }
  327.  
  328.                 return ($i + 1 - $first_day);
  329.             }
  330.  
  331.             function draw($draw_array = "")
  332.             {
  333.                 global $bgcolor3, $bgcolor4, $bgcolor2, $bgcolor1;
  334.  
  335.                 if (!$draw_array['bgcolor'])
  336.                 {
  337.                     $bgcolor = $bgcolor3;
  338.                 }
  339.                 else
  340.                 {
  341.                     $bgcolor = $draw_array['bgcolor'];
  342.                 }
  343.  
  344.                 if (!$draw_array['table_width'])
  345.                 {
  346.                     $table_width = "100%";
  347.                 }
  348.                 else
  349.                 {
  350.                     $table_width = $draw_array['table_width'];
  351.                 }
  352.  
  353.                 if (!$draw_array["table_height"])
  354.                 {
  355.                     $table_height = 100;
  356.                 }
  357.                 else
  358.                 {
  359.                     $table_height = $draw_array['table_height'];
  360.                 }
  361.  
  362.                 if (!$draw_array['cellpadding'])
  363.                 {
  364.                     $cellpadding = 0;
  365.                 }
  366.                 else
  367.                 {
  368.                     $cellpadding = $draw_array['cellpadding'];
  369.                 }
  370.  
  371.                 if (!$draw_array['cellspacing'])
  372.                 {
  373.                     $cellspacing = 0;
  374.                 }
  375.                 else
  376.                 {
  377.                     $cellspacing = $draw_array['cellspacing'];
  378.                 }
  379.  
  380.                 if (!$draw_array['table_border'])
  381.                 {
  382.                     $table_border = 0;
  383.                 }
  384.                 else
  385.                 {
  386.                     $table_border = $draw_array['table_border'];
  387.                 }
  388.  
  389.                 if (!$draw_array['top_row_align'])
  390.                 {
  391.                     $table_top_row_align = "left";
  392.                 }
  393.                 else
  394.                 {
  395.                     $table_top_row_align = $draw_array['top_row_align'];
  396.                 }
  397.  
  398.                 if (!$draw_array['top_row_valign'])
  399.                 {
  400.                     $table_top_row_valign = "top";
  401.                 }
  402.                 else
  403.                 {
  404.                     $table_top_row_valign = $draw_array['top_row_valign'];
  405.                 }
  406.  
  407.                 if (!$draw_array['row_align'])
  408.                 {
  409.                     $table_row_align = "left";
  410.                 }
  411.                 else
  412.                 {
  413.                     $table_row_align = $draw_array['row_align'];
  414.                 }
  415.  
  416.                 if (!$draw_array['row_valign'])
  417.                 {
  418.                     $table_row_valign = "top";
  419.                 }
  420.                 else
  421.                 {
  422.                     $table_row_valign = $draw_array['row_valign'];
  423.                 }
  424.  
  425.                 if (!$draw_array['top_row_cell_height'])
  426.                 {
  427.                     $table_top_row_cell_height = "";
  428.                 }
  429.                 else
  430.                 {
  431.                     $table_top_row_cell_height = $draw_array['top_row_cell_height'];
  432.                 }
  433.  
  434.                 if (preg_match("`px`i", $table_width))
  435.                 {
  436.                     $table_width = (int) $table_width;
  437.                 }
  438.                 else if ($table_width)
  439.                 {
  440.                     $table_width = $table_width . "%";
  441.                 }
  442.  
  443.                 $table_height = (int) $table_height;
  444.                 if ( $table_height == 0 )
  445.                 {
  446.                     $table_height = 250;
  447.                 }
  448.  
  449.                 if ($this->days_in_month($this->month_number, $this->year) == 28 && date("w" , mktime(0, 0, 0, 2, 1, $this->year)) == 0)
  450.                 {
  451.                     $num_of_rows = 4;
  452.                 }
  453.                 else if ($this->days_in_month($this->month_number, $this->year) == 30 && date("w" , mktime(0, 0, 0, $this->month_number, 1, $this->year)) > 5)
  454.                 {
  455.                     $num_of_rows = 6;
  456.                 }
  457.                 else if ($this->days_in_month($this->month_number, $this->year) == 31 && date("w" , mktime(0, 0, 0, $this->month_number, 1, $this->year)) > 4)
  458.                 {
  459.                     $num_of_rows = 6;
  460.                 }
  461.                 else
  462.                 {
  463.                     $num_of_rows = 5;
  464.                 }
  465.  
  466.                 echo "<table style=\"height: " . $table_height . "px;\" cellspacing=\"" . $cellspacing . "\" cellpadding=\"0\" width=\"" . $table_width . "\" border=\"" . $table_border . "\">\n";
  467.  
  468.                 $dates_cell_height = ceil(($table_height - $table_top_row_cell_height) / $num_of_rows);
  469.  
  470.                 if (strpos("%" , $table_width))
  471.                 {
  472.                     $dates_cell_width = sprintf("%.3f" , (int) $table_width / 7) . "%";
  473.                 }
  474.                 else
  475.                 {
  476.                     $dates_cell_width = ceil($table_width / 7);
  477.                 }
  478.  
  479.                 echo "<tr style=\"background: " . $bgcolor3 . ";\">\n"
  480.                 . "<td style=\"width: " . $dates_cell_width . ";\" align=\"" . $table_top_row_align . "\" valign=\"" . $table_top_row_valign . "\"><big><b>" . _SUNDAY . "</b></big></td>\n"
  481.                 . "<td style=\"width: " . $dates_cell_width . ";\" align=\"" . $table_top_row_align . "\" valign=\"" . $table_top_row_valign . "\"><big><b>" . _MONDAY . "</b></big></td>\n"
  482.                 . "<td style=\"width: " . $dates_cell_width . ";\" align=\"" . $table_top_row_align . "\" valign=\"" . $table_top_row_valign . "\"><big><b>" . _TUESDAY . "</b></big></td>\n"
  483.                 . "<td style=\"width: " . $dates_cell_width . ";\" align=\"" . $table_top_row_align . "\" valign=\"" . $table_top_row_valign . "\"><big><b>" . _WENESDAY . "</b></big></td>\n"
  484.                 . "<td style=\"width: " . $dates_cell_width . ";\" align=\"" . $table_top_row_align . "\" valign=\"" . $table_top_row_valign . "\"><big><b>" . _THRUSDAY . "</b></big></td>\n"
  485.                 . "<td style=\"width: " . $dates_cell_width . ";\" align=\"" . $table_top_row_align . "\" valign=\"" . $table_top_row_valign . "\"><big><b>" . _FRIDAY . "</b></big></td>\n"
  486.                 . "<td style=\"width: " . $dates_cell_width . ";\" align=\"" . $table_top_row_align . "\" valign=\"" . $table_top_row_valign . "\"><big><b>" . _SATURDAY . "</b></big></td></tr>\n";
  487.  
  488.                 for($i = 0 ; $i < $num_of_rows * 7 ; $i++)
  489.                 {
  490.                     /* start first row */
  491.                     if ($i == 0)
  492.                     {
  493.                         echo "<tr>";
  494.                     }
  495.  
  496.                     if ($i % 7 == 0 && $i != 0)
  497.                     {
  498.                         echo "</tr><tr>";
  499.                     }
  500.  
  501.                     $theday = $this->_get_date_by_counter($i, $this->month_number, $this->year);
  502.  
  503.                     if ($this->month_data[$theday]['event_title'][0])
  504.                     {
  505.                         for($j = 0 ; $j < count($this->month_data[$theday]['event_title']) ; $j++)
  506.                         {
  507.                             $color1 = $bgcolor;
  508.                             $theevent .= "&nbsp;<b><big>·</big></b>&nbsp;<a href=\"javascript:openWin('" . $this->month_data[$theday]['event_type'][$j] . "', '" . $this->month_data[$theday]['id'][$j] . "', '" . $theday . "', '" . $_REQUEST['m'] . "', '" . $_REQUEST['y'] . "')\">" . $this->month_data[$theday]['event_title'][$j] . "</a><br />";
  509.                         }
  510.                     }
  511.                     else
  512.                     {
  513.                         $theevent = "";
  514.                         $color1 = $bgcolor;
  515.                     }
  516.  
  517.                     if (is_numeric($theday))
  518.                     {
  519.             $dd=date(d);
  520.             $mm=date(m);
  521.             $yyyy=date(Y);
  522.             if ($theday == $dd && $this->month_number == $mm && $this->year == $yyyy) $border = "border: 1px solid red;";
  523.             else if ($theevent) $border = "border: 1px solid red;" . $bgcolor3 . ";";
  524.             else $border = "";
  525.  
  526.             echo "<td style=\"background: " . $color1 . ";width: " . $dates_cell_width . ";height: " . $dates_cell_height. "px;" . $border . "\"  align=\"$table_row_align\" valign=\"$table_row_valign\">\n"
  527.             . "<table width=\"100%\" cellspacing=\"0\" cellpadding=\"" . $cellpadding . "\" border=\"0\">\n"
  528.             . "<tr><td style=\"background: " . $bgcolor1 . ";\">" . $theday . "</td></tr>\n"
  529.             . "<tr><td style=\"background: " . $bgcolor2 . ";\">" . $theevent . "</td></tr></table></td>";
  530.                     }
  531.                     else
  532.                     {
  533.             echo "<td style=\"background: " . $bgcolor3 . ";width: " . $dates_cell_width . ";height: " . $dates_cell_height. "px;\" align=\"$table_row_align\" valign=\"$table_row_valign\"></td>";
  534.                     }
  535.  
  536.                     $theevent = "";
  537.  
  538.                     if ($i == $num_of_rows * 7-1)
  539.                     {
  540.                         echo "</tr>\n";
  541.                     }
  542.                 }
  543.                 echo "</table>\n";
  544.             }
  545.         }
  546.  
  547.         js_popup();
  548.  
  549.         opentable();
  550.  
  551.         if (!$_REQUEST['y']) $_REQUEST['y'] = date("Y");
  552.         if (!$_REQUEST['m']) $_REQUEST['m'] = date("m");
  553.  
  554.         if ($_REQUEST['y'] < 1971) $_REQUEST['y'] = 1971;
  555.         if ($_REQUEST['y'] > 2038) $_REQUEST['y'] = 2038;
  556.  
  557.         $mymonth = new month($_REQUEST['m'], $_REQUEST['y']);
  558.  
  559.         echo "<br /><div style=\"text-align: center;\"><big><b>" . _CALENDARFOR . " : " . $mymonth->month_name . "&nbsp;" . $mymonth->year . "</b></big><br /><br /><small><i>" . _CLICKON . "</i></small></div><br />\n";
  560.  
  561.     echo "<form method=\"post\" action=\"index.php?file=Calendar\"><div style=\"text-align: center;\"><select name=\"m\">\n";
  562.  
  563.         $omonth = 1;
  564.             while ($omonth < 13)
  565.             {
  566.             if ($omonth < 10)
  567.             {
  568.             $omonth0 = "0" . $omonth;
  569.             }
  570.             else
  571.             {
  572.             $omonth0 = $omonth;
  573.             }
  574.  
  575.             if ($omonth0 == $_REQUEST['m'])
  576.                         {
  577.                             $selected = "selected=\"selected\"";
  578.                         }
  579.                         else
  580.                         {
  581.                             $selected = "";
  582.                         }
  583.                         echo "<option value=\"" . $omonth0 . "\" " . $selected . ">" . $omonth0 . "</option>\n";
  584.                 $omonth++;
  585.                     }
  586.                     echo "</select> / <select name=\"y\">\n";
  587.  
  588.         $oyear = $_REQUEST['y'] -10;
  589.         $maxyear = $_REQUEST['y'] + 10;
  590.                 while ($oyear < $maxyear)
  591.                 {
  592.                     if ($oyear == $_REQUEST['y'])
  593.                     {
  594.                         $selected = "selected=\"selected\"";
  595.                     }
  596.                     else
  597.                     {
  598.                         $selected = "";
  599.                     }
  600.                     echo "<option value=\"" . $oyear . "\" " . $selected . ">" . $oyear . "</option>\n";
  601.                     $oyear++;
  602.                 }
  603.                 echo "</select>&nbsp;&nbsp;<input type=\"submit\" value=\"" . _SUBMIT . "\" /></div></form>\n";
  604.  
  605.         echo "<table style=\"margin-left: auto;margin-right: auto;text-align: left;border: 1px solid" . $bgcolor3 . ";\" width=\"95%\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\">\n"
  606.     . "<tr><td><table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tr><td style=\"background: #FFFFFF;\">\n";
  607.  
  608.         $mymonth->draw(array("cellspacing" => "1" , "cellpadding" => "2" , "top_row_align" => "center" , "table_height" => "400px" , "top_row_cell_height" => 20 , "bgcolor" => "$bgcolor2" , "row_align" => "left" , "row_valign" => "top" , "font_size" => "-1"));
  609.  
  610.         echo "</td></tr></table></td></tr></table><div style=\"text-align: center;\"><br />\n"
  611.     . "<input type=\"button\" onclick=\"document.location='index.php?file=Calendar&amp;m=" . $mymonth->prevmonth . "&amp;y=" . $mymonth->prevyear . "'\" value=\"" . _PREVMONTH . "\" />&nbsp;"
  612.         . "<input type=\"button\" onclick=\"document.location='index.php?file=Calendar&amp;m=" . $mymonth->nextmonth . "&amp;y=" . $mymonth->nextyear . "'\" value=\"" . _NEXTMONTH . "\" /></div><br />\n";
  613.  
  614.         closetable();
  615.     }
  616.  
  617.     function show_event()
  618.     {
  619.         global $bgcolor2, $user, $nuked, $theme, $language;
  620.  
  621.         if ($_REQUEST['type'] == "birthday" && preg_match("`[a-zA-Z0-9]+$`", $_REQUEST['eid']))
  622.         {
  623.             $sql = mysql_query("SELECT pseudo FROM " . USER_TABLE . " WHERE id = '" . $_REQUEST['eid'] . "'");
  624.             list($pseudo) = mysql_fetch_array($sql);
  625.  
  626.             $sql2 = mysql_query("SELECT prenom, age FROM " . USER_DETAIL_TABLE . " WHERE user_id = '" . $_REQUEST['eid'] . "'");
  627.             list($prenom, $birthday) = mysql_fetch_array($sql2);
  628.  
  629.             list ($jour, $mois, $an) = explode ('/', $birthday);
  630.             $age = $_REQUEST['y'] - $an;
  631.             if ($_REQUEST['m'] < $mois)
  632.             {
  633.                 $age = $age - 1;
  634.             }
  635.             if ($_REQUEST['d'] < $jour && $_REQUEST['m'] == $mois)
  636.             {
  637.                 $age = $age-1;
  638.             }
  639.  
  640.             if ($prenom != "")
  641.             {
  642.                 $nom = $prenom;
  643.             }
  644.             else
  645.             {
  646.                 $nom = $pseudo;
  647.             }
  648.  
  649.             echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n"
  650.             . "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"fr\">\n"
  651.             . "<head><title>" . _BIRTHDAY . " : " . $pseudo . "</title>\n"
  652.             . "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\" />\n"
  653.             . "<meta http-equiv=\"content-style-type\" content=\"text/css\" />\n"
  654.             . "<link title=\"style\" type=\"text/css\" rel=\"stylesheet\" href=\"themes/" . $theme . "/style.css\" /></head>\n"
  655.             . "<body style=\"background: " . $bgcolor2 . ";\">\n"
  656.             . "<table width=\"100%\" cellpadding=\"3\" cellspacing=\"1\">\n"
  657.             . "<tr><td align=\"center\"><big><b>" . _BIRTHDAY . " : " . $pseudo . "</b></big></td></tr><tr><td>&nbsp;</td></tr>\n"
  658.             . "<tr><td align=\"center\">" . _BIRTHDAYTEXT . " <b>" . $nom . "</b> " . _BIRTHDAYTEXTSUITE . " <b>" . $age . "</b> " . _YEARSOLD . "</td></tr>\n"
  659.             . "<tr><td>&nbsp;</td></tr><tr><td align=\"center\"><b><a href=\"#\" onclick=\"self.close()\">" . _CLOSEWINDOW . "</a></b></td></tr></table></body></html>";
  660.         }
  661.         else if ($_REQUEST['type'] == "match" && is_numeric($_REQUEST['eid']))
  662.         {
  663.             $sql = mysql_query("SELECT warid, etat, team, adversaire, type, date_jour, date_mois, date_an, heure, style, tscore_team, tscore_adv, report FROM " . WARS_TABLE . " WHERE warid = '" . $_REQUEST['eid'] . "'");
  664.             $nb_match = mysql_num_rows($sql);
  665.             list($warid, $etat, $team, $adv_name, $type_match, $jour, $mois, $an, $heure, $style, $score_team, $score_adv, $report) = mysql_fetch_array($sql);
  666.            
  667.             $adv_name = htmlentities($adv_name);
  668.  
  669.             if ($team > 0)
  670.             {
  671.                 $sql2 = mysql_query("SELECT titre FROM " . TEAM_TABLE . " WHERE cid = '" . $team . "'");
  672.                 list($team_name) = mysql_fetch_array($sql2);
  673.             }
  674.             else
  675.             {
  676.                 $team_name = $nuked['name'];
  677.             }
  678.  
  679.             if ($score_team > $score_adv)
  680.             {
  681.                 $color = "#009900";
  682.             }
  683.             else if ($score_team < $score_adv)
  684.             {
  685.                 $color = "#990000";
  686.             }
  687.             else
  688.             {
  689.                 $color = "#3333FF";
  690.             }
  691.  
  692.             if ($language == "french")
  693.             {
  694.                 $date = $jour . "/" . $mois . "/" . $an;
  695.             }
  696.             else
  697.             {
  698.                 $date = $mois . "/" . $jour . "/" . $an;
  699.             }
  700.  
  701.             echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n"
  702.             . "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"fr\">\n"
  703.             . "<head><title>" . $team_name . "&nbsp;" . _VS . "&nbsp;" . $adv_name . "</title>\n"
  704.             . "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\" />\n"
  705.             . "<meta http-equiv=\"content-style-type\" content=\"text/css\" />\n"
  706.             . "<link title=\"style\" type=\"text/css\" rel=\"stylesheet\" href=\"themes/" . $theme . "/style.css\" /></head>\n"
  707.             . "<body style=\"background: " . $bgcolor2 . ";\">\n"
  708.             . "<table width=\"100%\" cellpadding=\"1\" cellspacing=\"0\">\n"
  709.             . "<tr><td align=\"center\"><big><b>" . $team_name . "&nbsp;" . _VS . "&nbsp;" . $adv_name . "</b></big></td></tr><tr><td>&nbsp;</td></tr>\n"
  710.             . "<tr><td><b>" . _DATE . " :</b> " . $date . " " . $heure . "</td></tr>\n"
  711.             . "<tr><td><b>" . _TYPE . " :</b> " . $type_match . "</td></tr>\n"
  712.             . "<tr><td><b>" . _STYLE . " :</b> " . $style . "</td></tr>\n";
  713.            
  714.  
  715.             if ($etat > 0)
  716.             {
  717.                 echo "</td></tr><tr><td><b>" . _RESULT . " : </b>";
  718.  
  719.                 if ($score_team < $score_adv)
  720.                 {
  721.                     echo "&nbsp;<span style=\"color: #990000;\"><b>" . $score_team . "</b></span> - <span style=\"color: #009900\"><b>" . $score_adv . "</b></span>";
  722.                 }
  723.                 else if ($score_team > $score_adv)
  724.                 {
  725.                     echo "&nbsp;<span style=\"color: #009900\"><b>" . $score_team . "</b></span> - <span style=\"color: #990000\"><b>" . $score_adv . "</b></span>";
  726.                 }
  727.                 else
  728.                 {
  729.                     echo "&nbsp;<b>" . $score_team . " -  " . $score_adv . "</b>";
  730.                 }
  731.             }
  732.  
  733.             if ($report != "")
  734.             {
  735.                 echo "</td></tr><tr><td>&nbsp;</td></tr><tr><td><b>" . _COMMENT . " : </b><br />" . $report;
  736.             }
  737.  
  738.             echo "</td></tr><tr><td>&nbsp;</td></tr>\n";
  739.  
  740.             $sql2 = mysql_query("SELECT pseudo FROM " . USER_TABLE . " WHERE id = '" . $pseudos[$i] . "'");
  741.  
  742.             if ($user)
  743.             {
  744.                 $sql_dispo = mysql_query("SELECT team FROM " . USER_TABLE . " WHERE id = '" . $user[0] . "'");
  745.                 list($user_team) = mysql_fetch_array($sql_dispo);
  746.  
  747.                 if ($user_team > 0 || $user[1] > 1)
  748.                 {
  749.                     dispo($warid, $_REQUEST['type']);
  750.                 }
  751.             }
  752.  
  753.             echo "</table><div style=\"text-align: center;\"><a href=\"#\" onclick=\"self.close()\"><b>" . _CLOSEWINDOW . "</b></a></div></body></html>";
  754.         }
  755.         else if (is_numeric($_REQUEST['eid']))
  756.         {
  757.             $sql = mysql_query("SELECT titre, description, date_jour, date_mois, date_an, heure, auteur FROM " . CALENDAR_TABLE . " WHERE id = '" . $_REQUEST['eid'] . "'");
  758.             list($titre, $description, $jour, $mois, $an, $heure, $auteur) = mysql_fetch_array($sql);
  759.  
  760.             $description = icon($description);
  761.  
  762.             if ($language == "french")
  763.             {
  764.                 $date = $jour . "/" . $mois . "/" . $an;
  765.             }
  766.             else
  767.             {
  768.                 $date = $mois . "/" . $jour . "/" . $an;
  769.             }
  770.  
  771.             echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n"
  772.             . "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"fr\">\n"
  773.             . "<head><title>" . $titre. "&nbsp;" . _THE . "&nbsp;" . $date . "&nbsp;" . $heure . "</title>\n"
  774.             . "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\" />\n"
  775.             . "<meta http-equiv=\"content-style-type\" content=\"text/css\" />\n"
  776.             . "<link title=\"style\" type=\"text/css\" rel=\"stylesheet\" href=\"themes/" . $theme . "/style.css\" /></head>\n"
  777.             . "<body style=\"background: " . $bgcolor2 . ";\">\n"
  778.             . "<table width=\"100%\" cellpadding=\"1\" cellspacing=\"0\">\n"
  779.             . "<tr><td align=\"center\"><big><b>" . $titre . "&nbsp;" . _THE . "&nbsp;" . $jour . "/" . $mois . "/" . $an;
  780.  
  781.             if ($heure != "")
  782.             {
  783.                 echo"&nbsp;" . _AT . "&nbsp;" . $heure;
  784.             }
  785.  
  786.             echo "</b></big><br />" . _ADDEDBY . " <b>" . $auteur . "</b></td></tr><tr><td>&nbsp;</td></tr>\n"
  787.             . "<tr><td><b>" . _DESCR . " : </b>" . $description . "</td></tr></table>\n"
  788.             . "<div style=\"text-align: center;\"><br /><a href=\"#\" onclick=\"self.close()\"><b>" . _CLOSEWINDOW . "</b></a><br /></div></body></html>";
  789.         }
  790.     }
  791.  
  792.     function dispo($warid, $type)
  793.     {
  794.         global $user, $nuked;
  795.  
  796.         $sql1 = mysql_query("SELECT dispo, pas_dispo FROM " . WARS_TABLE . " WHERE warid = '" . $warid . "'");
  797.         list($actual_dispo, $not_dipso) = mysql_fetch_array($sql1);
  798.  
  799.         echo "<tr><td><b>" . _LINEUP . " :</b><br /><small>" . _FREE . " : <br>";
  800.  
  801.         $nb_dispo = (strlen($actual_dispo) / 21);
  802.         $pseudos = explode('|', $actual_dispo);
  803.      echo "<div align=center><table border=\"1\">" ;
  804.         for($i = 0;$i <= $nb_dispo;$i++)
  805.         {
  806.             if ($pseudos[$i] == $user[0])
  807.             {
  808.                 $selected = 1;
  809.             }
  810.             $sql2 = mysql_query("SELECT pseudo FROM " . USER_TABLE . " WHERE id = '" . $pseudos[$i] . "'");
  811.             $sqlpref = mysql_query("SELECT pref_2, pref_3, pref_4, pref_5 FROM " . USER_DETAIL_TABLE . " WHERE user_id = '" . $pseudos[$i] . "'");
  812.             list($pseudo) = mysql_fetch_array($sql2);
  813.             list($pref_2, $pref_3, $pref_4, $pref_5) = mysql_fetch_array($sqlpref);
  814.            
  815.            
  816.             echo "<tr><td align=center><b>" . $pseudo . "</b /></td /><td align=center>". $pref_2 .  "</td /><td align=center>" . $pref_3 .  "</td /><td align=center>" . $pref_4 .  "</td /><td align=center>" . $pref_5 .  "</td /></tr>";
  817.        
  818.         }
  819.         echo "</table></div>" ;
  820.  
  821.         echo "<br />" . _NOTFREE . " : ";
  822.  
  823.         $nb_no_dispo = (strlen($not_dipso) / 21);
  824.         $pseudos2 = explode('|', $not_dipso);
  825.         for($l = 0;$l <= $nb_no_dispo;$l++)
  826.         {
  827.             if ($pseudos2[$l] == $user[0])
  828.             {
  829.                 $selected = 1;
  830.             }
  831.             $sql3 = mysql_query("SELECT pseudo FROM " . USER_TABLE . " WHERE id = '" . $pseudos2[$l] . "'");
  832.             list($pseudo2) = mysql_fetch_array($sql3);
  833.             if ($l > 0) echo ", ";
  834.             echo "<b>" . $pseudo2 . "</b>";
  835.         }
  836.  
  837.         if ($selected != "1" && $user[0] != "")
  838.         {
  839.             echo "</small><form method=\"post\" action=\"index.php?file=Calendar&amp;nuked_nude=index&amp;op=add_dispo&amp;warid=" . $warid . "\">\n"
  840.             . "<div style=\"text-align: center;\"><select name=\"dispo\">\n"
  841.             . "<option value=\"1\">" . _IPLAY . "</option>\n"
  842.             . "<option value=\"2\">" . _ICANT . "</option></select>\n"
  843.             . "<input type=\"hidden\" name=\"type\" value=\"" . $type . "\" />\n"
  844.             . "&nbsp;<input type=\"submit\" name=\"submit\" value=\"" . _VALID . "\" /><br /></div></form>\n";
  845.         }
  846.  
  847.         else
  848.         {
  849.             echo "</small><br /><div style=\"text-align: center;\"><br />[ <a href=\"index.php?file=Calendar&amp;nuked_nude=index&amp;op=del_dispo&amp;warid=" . $warid . "&amp;type=" . $type . "\">" . _DELAVAILLABLE . "</a> ]</div><br />\n";
  850.         }
  851.  
  852.     echo "</td></tr>\n";
  853.     }
  854.  
  855.     function add_dispo($dispo)
  856.     {
  857.         global $user, $nuked, $bgcolor2, $theme;
  858.  
  859.         $sql = "SELECT dispo, pas_dispo FROM " . WARS_TABLE . " WHERE warid = '" . $_REQUEST['warid'] . "'";
  860.         $req = mysql_query($sql);
  861.         $data = mysql_fetch_assoc($req);
  862.  
  863.         if ($data['dispo'] != "") $sep1 = "|";
  864.         if ($data['pas_dispo'] != "") $sep2 = "|";
  865.  
  866.         $new_dispo = $data['dispo'] . $sep1 . $user[0];
  867.         $new_pas_dispo = $data['pas_dispo'] . $sep2 . $user[0];
  868.  
  869.         if ($dispo == 1) $sql = "UPDATE " . WARS_TABLE . " SET dispo = '" . $new_dispo . "' WHERE warid = '" . $_REQUEST['warid'] . "'";
  870.         else if ($dispo == 2) $sql = "UPDATE " . WARS_TABLE . " SET pas_dispo = '" . $new_pas_dispo . "' WHERE warid = '" . $_REQUEST['warid'] ."'";
  871.  
  872.         mysql_query($sql);
  873.  
  874.         echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n"
  875.     . "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"fr\">\n"
  876.     . "<head><title>" . _MATCH . "</title>\n"
  877.     . "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\" />\n"
  878.     . "<meta http-equiv=\"content-style-type\" content=\"text/css\" />\n"
  879.     . "<link title=\"style\" type=\"text/css\" rel=\"stylesheet\" href=\"themes/" . $theme . "/style.css\" /></head>\n"
  880.     . "<body style=\"background: " . $bgcolor2 . ";\">\n"
  881.     . "<div style=\"text-align: center;\"><br /><br /><b>" . _UPDATEAVAILLABLE . "</b><br /><br /></div></body></html>";
  882.  
  883.     $url_redirect = "index.php?file=Calendar&nuked_nude=index&op=show_event&eid=" . $_REQUEST['warid'] . "&type=" . $_REQUEST['type'];
  884.         redirect($url_redirect, 2);
  885.     }
  886.  
  887.     function del_dispo()
  888.     {
  889.         global $user, $nuked, $bgcolor2, $theme;
  890.  
  891.         $sql = "SELECT * FROM " . WARS_TABLE . " WHERE warid = '" . $_REQUEST['warid'] . "'";
  892.         $req = mysql_query($sql);
  893.         $data = mysql_fetch_array($req);
  894.  
  895.         $list = explode("|", $data['dispo']);
  896.         $new_dispo = cleanList($user[0], $list);
  897.  
  898.         $list = explode("|", $data['pas_dispo']);
  899.         $new_pas_dispo = cleanList($user[0], $list);
  900.  
  901.         $sql = "UPDATE " . WARS_TABLE . " SET dispo = '" . $new_dispo . "', pas_dispo = '" . $new_pas_dispo . "' WHERE warid = '" . $_REQUEST['warid'] . "'";
  902.         mysql_query($sql);
  903.  
  904.         echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n"
  905.     . "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"fr\">\n"
  906.     . "<head><title>" . _MATCH . "</title>\n"
  907.     . "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\" />\n"
  908.     . "<meta http-equiv=\"content-style-type\" content=\"text/css\" />\n"
  909.     . "<link title=\"style\" type=\"text/css\" rel=\"stylesheet\" href=\"themes/" . $theme . "/style.css\" /></head>\n"
  910.     . "<body style=\"background: " . $bgcolor2 . ";\">\n"
  911.     . "<div style=\"text-align: center;\"><br /><br /><b>" . _UPDATEAVAILLABLE . "</b><br /><br /></div></body></html>";
  912.  
  913.     $url_redirect = "index.php?file=Calendar&nuked_nude=index&op=show_event&eid=" . $_REQUEST['warid'] . "&type=" . $_REQUEST['type'];
  914.         redirect($url_redirect, 2);
  915.     }
  916.  
  917.     function cleanList($val, $list)
  918.     {
  919.         for($i = 0; $i <= count($list)-1;$i++)
  920.         {
  921.             if ($i == 0 || ($i == 1 && $list[0] == $val))
  922.             {
  923.                 $sep = "";
  924.             }
  925.             else
  926.             {
  927.                 $sep = "|";
  928.             }
  929.             if ($list[$i] != $val)
  930.             {
  931.                 $cnt .= $sep . $list[$i];
  932.             }
  933.         }
  934.         return $cnt;
  935.     }
  936.  
  937.  
  938.     switch ($_REQUEST['op'])
  939.     {
  940.         case "show_event":
  941.             show_event();
  942.             break;
  943.  
  944.         case"iminent":
  945.             iminent($_REQUEST['eid']);
  946.             break;
  947.  
  948.         case"add_dispo":
  949.             add_dispo($_REQUEST['dispo'], $_REQUEST['war_id']);
  950.             break;
  951.  
  952.         case"del_dispo":
  953.             del_dispo();
  954.             break;
  955.  
  956.         default:
  957.             index();
  958.             break;
  959.     }
  960.  
  961. }
  962. else if ($level_access == -1)
  963. {
  964.     opentable();
  965.     echo "<br /><br /><div style=\"text-align: center;\">" . _MODULEOFF . "<br /><br /><a href=\"javascript:history.back()\"><b>" . _BACK . "</b></a><br /><br /></div>";
  966.     closetable();
  967. }
  968. else if ($level_access == 1 && $visiteur == 0)
  969. {
  970.     opentable();
  971.     echo "<br /><br /><div style=\"text-align: center;\">" . _USERENTRANCE . "<br /><br /><b><a href=\"index.php?file=User&amp;op=login_screen\">" . _LOGINUSER . "</a> | <a href=\"index.php?file=User&amp;op=reg_screen\">" . _REGISTERUSER . "</a></b><br /><br /></div>";
  972.     closetable();
  973. }
  974. else
  975. {
  976.     opentable();
  977.     echo "<br /><br /><div style=\"text-align: center;\">" . _NOENTRANCE . "<br /><br /><a href=\"javascript:history.back()\"><b>" . _BACK . "</b></a><br /><br /></div>";
  978.     closetable();
  979. }
  980.  
  981. ?>
  982.  
  983.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement