if($_GET['action']=="savewar") {
include("_mysql.php");
include("_settings.php");
include("_functions.php");
if(!isclanwaradmin($userID)) die('No access!');
$hour = $_POST['hour'];
$minute = $_POST['minute'];
$day = $_POST['day'];
$month = $_POST['month'];
$year = $_POST['year'];
$squad = $_POST['squad'];
$opponent = $_POST['opponent'];
$opptag = $_POST['opptag'];
$opphp = $_POST['opphp'];
$oppcountry = $_POST['oppcountry'];
$maps = $_POST['maps'];
$server = $_POST['server'];
$league = $_POST['league'];
$leaguehp = $_POST['leaguehp'];
$warinfo = $_POST['warinfo'];
$date=mktime($hour,$minute,0,$month,$day,$year);
safe_query("INSERT INTO ".PREFIX."upcoming ( date, type, squad, opponent, opptag, opphp, oppcountry, maps, server, league, leaguehp, warinfo )
values( '$date', 'c', '$squad', '$opponent', '$opptag', '$opphp', '$oppcountry', '$maps', '$server', '$league', '$leaguehp', '$warinfo' ) ");
if($chID) safe_query("DELETE FROM ".PREFIX."challenge WHERE chID='$chID'");
if($messages) {
$title='new upcoming war in calendar!';
$message='new upcoming clanwar on '.date("d.m.Y", $date).':[br][br]Opponent: [flag]'.$oppcountry.'[/flag] '.$opponent.' [br]League: '.$league.' [br]Info: '.$warinfo.'[br][br]link to calendar';
$ergebnis=safe_query("SELECT userID FROM ".PREFIX."squads_members WHERE squadID='$squad'");
while($ds=mysql_fetch_array($ergebnis)) {
$id=$ds[userID];
safe_query("INSERT INTO ".PREFIX."messenger (userID, date, fromuser, touser, title, message, viewed)
values('$id', '$date', '$userID', '$id', '$title', '$message', '0')"); // eintrag für empfänger
safe_query("UPDATE ".PREFIX."user SET pmsent=pmsent+1 WHERE userID='$userID'");
safe_query("UPDATE ".PREFIX."user SET pmgot=pmgot+1 WHERE userID='$id'");
}
}
header("Location: index.php?site=calendar&tag=$day&month=$month&year=$year");
}
elseif($_GET['action']=="delete") {
include("_mysql.php");
include("_settings.php");
include("_functions.php");
if(!isclanwaradmin($userID)) die('No access!');
$upID = $_GET['upID'];
safe_query("DELETE FROM ".PREFIX."upcoming WHERE upID='$upID'");
safe_query("DELETE FROM ".PREFIX."upcoming_announce WHERE upID='$upID'");
header("Location: index.php?site=calendar");
}
elseif($_GET['action']=="saveannounce") {
include("_mysql.php");
include("_settings.php");
include("_functions.php");
if(!isclanmember($userID)) die('No access!');
$tag = $_POST['tag'];
$month = $_POST['month'];
$year = $_POST['year'];
$ergebnis=safe_query("SELECT * FROM ".PREFIX."upcoming_announce WHERE upID='".$_POST['upID']."' AND userID='$userID'");
if(mysql_num_rows($ergebnis)) {
$ds=mysql_fetch_array($ergebnis);
safe_query("UPDATE ".PREFIX."upcoming_announce SET status='".$_POST['status']."' WHERE annID='$ds[annID]' ");
}
else safe_query("INSERT INTO ".PREFIX."upcoming_announce ( upID, userID, status ) values( '".$_POST['upID']."', '$userID', '".$_POST['status']."' ) ");
header("Location: index.php?site=calendar&tag=$tag&month=$month&year=$year");
}
elseif($_GET['action']=="saveeditdate") {
include("_mysql.php");
include("_settings.php");
include("_functions.php");
if(!isclanwaradmin($userID)) die('No access!');
$hour = $_POST['hour'];
$minute = $_POST['minute'];
$day = $_POST['day'];
$month = $_POST['month'];
$year = $_POST['year'];
$date=mktime($hour,$minute,0,$month,$day,$year);
$enddate=mktime($_POST['endhour'],$_POST['endminute'],0,$_POST['endmonth'],$_POST['endday'],$_POST['endyear']);
safe_query("UPDATE ".PREFIX."upcoming SET date='$date',
enddate='$enddate',
short='".$_POST['short']."',
title='".$_POST['title']."',
country='".$_POST['country']."',
location='".$_POST['location']."',
locationhp='".$_POST['locationhp']."',
dateinfo='".$_POST['dateinfo']."' WHERE upID='".$_POST['upID']."' ");
header("Location: index.php?site=calendar&tag=$day&month=$month&year=$year");
}
elseif($_GET['action']=="savedate") {
include("_mysql.php");
include("_settings.php");
include("_functions.php");
if(!isclanwaradmin($userID)) die('No access!');
$date=mktime($_POST['hour'],$_POST['minute'],0,$_POST['month'],$_POST['day'],$_POST['year']);
$enddate=mktime($_POST['endhour'],$_POST['endminute'],0,$_POST['endmonth'],$_POST['endday'],$_POST['endyear']);
if($date>$enddate) {
$temp=$date;
$date=$enddate;
$enddate=$temp;
unset($temp);
}
safe_query("INSERT INTO ".PREFIX."upcoming ( date, type, enddate, short, title, country, location, locationhp, dateinfo )
values( '$date', 'd', '".$enddate."', '".$_POST['short']."', '".$_POST['title']."', '".$_POST['country']."', '".$_POST['location']."', '".$_POST['locationhp']."', '".$_POST['dateinfo']."' ) ");
redirect("index.php?site=calendar&tag=".$_POST['day']."&month=".$_POST['month']."&year=".$_POST['year'],"",0);
}
elseif($_GET['action']=="saveeditwar") {
include("_mysql.php");
include("_settings.php");
include("_functions.php");
if(!isclanwaradmin($userID)) die('No access!');
$upID = $_POST['upID'];
$hour = $_POST['hour'];
$minute = $_POST['minute'];
$day = $_POST['day'];
$month = $_POST['month'];
$year = $_POST['year'];
$squad = $_POST['squad'];
$opponent = $_POST['opponent'];
$opptag = $_POST['opptag'];
$opphp = $_POST['opphp'];
$oppcountry = $_POST['oppcountry'];
$maps = $_POST['maps'];
$server = $_POST['server'];
$league = $_POST['league'];
$leaguehp = $_POST['laeguehp'];
$warinfo = $_POST['warinfo'];
$date=mktime($hour,$minute,0,$month,$day,$year);
safe_query("UPDATE ".PREFIX."upcoming SET date='$date',
type='c',
squad='$squad',
opponent='$opponent',
opptag='$opptag',
opphp='$opphp',
oppcountry='$oppcountry',
maps='$maps',
server='$server',
league='$league',
leaguehp='$leaguehp',
warinfo='$warinfo' WHERE upID='$upID' ");
header("Location: index.php?site=calendar&tag=$day&month=$month&year=$year");
}
$month = $_GET['month'];
$year = $_GET['year'];
$tag = $_GET['tag'];
eval ("\$title_calendar = \"".gettemplate("title_calendar_minicalendar")."\";");
echo $title_calendar;
if(isclanwaradmin($userID)) echo'<input type="button" class="button" onClick="MM_goToURL(\'parent\',\'index.php?site=calendar&action=addwar\');return document.MM_returnValue" value="Add Clanwar">
<input type="button" class="button" onClick="MM_goToURL(\'parent\',\'index.php?site=calendar&action=adddate\');return document.MM_returnValue" value="Add Event"><br><br>';
function print_calendar($mon,$year) {
global $dates, $first_day, $start_day;
$pagebg=PAGEBG;
$border=BORDER;
$bghead=BGHEAD;
$bgcat=BGCAT;
$first_day = mktime(0,0,0,$mon,1,$year);
$start_day = date("w",$first_day);
$res = getdate($first_day);
$month_name = $res["month"];
$no_days_in_month = date("t",$first_day);
//If month's first day does not start with first Sunday, fill table cell with a space
for ($i = 1; $i <= $start_day;$i++) $dates[1][$i] = " ";
$row = 1;
$col = $start_day+1;
$num = 1;
while($num<=31) {
if ($num > $no_days_in_month) break;
else {
$dates[$row][$col] = $num;
if (($col + 1) > 7) {
$row++;
$col = 1;
}
else $col++;
$num++;
}
}
$mon_num = date("n",$first_day);
$temp_yr = $next_yr = $prev_yr = $year;
$prev = $mon_num - 1;
if ($prev<10) $prev="0".$prev;
$next = $mon_num + 1;
if ($next<10) $next="0".$next;
//If January is currently displayed, month previous is December of previous year
if ($mon_num == 1){
$prev_yr = $year - 1;
$prev = 12;
}
//If December is currently displayed, month next is January of next year
if ($mon_num == 12) {
$next_yr = $year + 1;
$next = 1;
}
echo'
<table width="100%" cellspacing="1" cellpadding="2" bgcolor="#DCDCDC">
<tr>
<td class="title" align="center" colspan="2">'.date("F",$first_day).' '.$temp_yr.'</td>
</tr>
<tr>
<td colspan="7" bgcolor="'.PAGEBG.'"></td>
</tr>
<tr>
<td bgcolor="'.BGCAT.'" width="16%" align="center">Sun</td>
<td bgcolor="'.BGCAT.'" width="14%" align="center">Mon</td>
<td bgcolor="'.BGCAT.'" width="14%" align="center">Tue</td>
<td bgcolor="'.BGCAT.'" width="14%" align="center">Wed</td>
<td bgcolor="'.BGCAT.'" width="14%" align="center">Thu</td>
<td bgcolor="'.BGCAT.'" width="14%" align="center">Fri</td>
<td bgcolor="'.BGCAT.'" width="14%" align="center">Sat</td>
</tr>
<tr>
<td colspan="7" bgcolor="'.BG_1.'"></td>
</tr>';
$end = ($start_day > 4)? 6:5;
for ($row=1;$row<=$end;$row++) {
for ($col=1;$col<=7;$col++) {
if ($dates[$row][$col] == "") $dates[$row][$col] = " ";
if (!strcmp($dates[$row][$col]," ")) $count++;
$t = $dates[$row][$col];
if($t < 10) $tag = "0$t";
else $tag = $t;
// DATENBANK ABRUF
$start_date = mktime(0, 0, 0, $mon, $t, $year);
$end_date = mktime(23, 59, 59, $mon, $t, $year);
unset($termin);
$ergebnis = safe_query("SELECT * FROM ".PREFIX."upcoming");
$anz = mysql_num_rows($ergebnis);
if($anz) {
while ($ds = mysql_fetch_array($ergebnis)) {
if($ds[type]=="d") {
if(($start_date<=$ds[date] && $end_date>=$ds[date]) || ($start_date>=$ds[date] && $end_date<=$ds[enddate]) || ($start_date<=$ds[enddate] && $end_date>=$ds[enddate]))
$termin.='<a href="index.php?site=calendar&tag='.$t.'&month='.$mon.'&year='.$year.'"><br></a>';
}
else {
if($ds[date]>=$start_date && $ds[date]<=$end_date) {
$begin = date("H:i", $ds[date]);
$termin.='<a href="index.php?site=calendar&tag='.$t.'&month='.$mon.'&year='.$year.'">'.$begin.' '.$ds[opptag].'</a>';
}
}
}
}
else $termin="";
// DB ABRUF ENDE
//If date is today, highlight it
if (($t == date("j")) && ($mon == date("n")) && ($year == date("Y"))) echo'<td height="20" valign="top" bgcolor="'.BG_4.'"><b>'.$t.'</b><br>'.$termin.'</td>';
// If the date is absent ie after 31, print space
else {
if($t==' ') echo'<td height="20" valign="top" bgcolor="'.BG_1.'"> </td>';
else echo'<td height="20" valign="top" bgcolor="'.BG_2.'">'.$t.'<br>'.$termin.'</td>';
}
}
if (($row + 1) != ($end+1)) echo'</tr><tr>';
else echo'</tr>';
}
echo'<tr><td colspan="7" bgcolor="'.PAGEBG.'"></td></tr>
<tr>
<td bgcolor="'.BGCAT.'" colspan="7" align="center"><a class="category" href="index.php?site=calendar"><b>show today\'s events</b></a></td>
</tr>
</table><br><br>';
}