$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")."\";");
echo $title_calendar;
if(isclanwaradmin($userID)) echo'
';
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'
';
echo'
« prev
'.date("F",$first_day).' '.$temp_yr.'
next »
Sun
Mon
Tue
Wed
Thu
Fri
Sat
';
$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.=''.$ds[short].' ';
}
else {
if($ds[date]>=$start_date && $ds[date]<=$end_date) {
$begin = date("H:i", $ds[date]);
$termin.=''.$begin.' '.$ds[opptag].' ';
}
}
}
}
else $termin=" ";
// DB ABRUF ENDE
//If date is today, highlight it
if (($t == date("j")) && ($mon == date("n")) && ($year == date("Y"))) echo''.$t.' '.$termin.' ';
// If the date is absent ie after 31, print space
else {
if($t==' ') echo' ';
else echo''.$t.' '.$termin.' ';
}
}
if (($row + 1) != ($end+1)) echo'';
else echo' ';
}
echo'
show today\'s events
';
}
function print_termine($tag,$month,$year) {
global $wincolor;
global $loosecolor;
global $drawcolor;
global $userID;
$pagebg=PAGEBG;
$border=BORDER;
$bghead=BGHEAD;
$bgcat=BGCAT;
$start_date = mktime(0, 0, 0, $month, $tag, $year);
$end_date = mktime(23, 59, 59, $month, $tag, $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]=="c") {
if($ds[date]>=$start_date && $ds[date]<=$end_date) {
$date = date("d.m.Y", $ds[date]);
$time = date("H:i", $ds[date]);
$squad=getsquadname($ds[squad]);
$oppcountry="[flag]".$ds[oppcountry]."[/flag]";
$oppcountry=flags($oppcountry);
$opponent=$oppcountry.' '.$ds[opptag].' / '.$ds[opponent].' ';
$maps=$ds[maps];
$server=$ds[server];
$league=''.$ds[league].' ';
if(isclanmember($userID)) $warinfo=cleartext($ds[warinfo]);
else $warinfo='You have to be a clanmmeber to see this.';
unset($players);
if(isclanmember($userID) or isanyadmin($userID)) {
$anmeldung=safe_query("SELECT * FROM ".PREFIX."upcoming_announce WHERE upID='".$ds[upID]."'");
if(mysql_num_rows($anmeldung)) {
$i=1;
while ($da = mysql_fetch_array($anmeldung)) {
if ($da[status] == "y") $fontcolor = $wincolor;
elseif ($da[status] == "n") $fontcolor = $loosecolor;
else $fontcolor = $drawcolor;
if($i>1) $players.=', '.getnickname($da[userID]).' ';
else $players.=''.getnickname($da[userID]).' ';
$i++;
}
}
else $players='no players announced';
if(issquadmember($userID, $ds[squad])) $announce='• announce here ';
if(isclanwaradmin($userID))
$adminaction='
';
} else $players = 'You have to be a clanmember to see this.';
$bg1=BG_1;
$bg2=BG_2;
$bg3=BG_3;
$bg4=BG_4;
eval ("\$upcoming_war_details = \"".gettemplate("upcoming_war_details")."\";");
echo $upcoming_war_details;
}
}
else {
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])) {
$date = date("d.m.Y", $ds[date]);
$time = date("H:i", $ds[date]);
$enddate = date("d.m.Y", $ds[enddate]);
$endtime = date("H:i", $ds[enddate]);
$title=$ds[title];
$location=''.$ds[location].' ';
$dateinfo=cleartext($ds[dateinfo]);
$dateinfo = toggle($dateinfo, $ds[upID]);
$country="[flag]".$ds[country]."[/flag]";
$country=flags($country);
unset($players);
if(isclanmember($userID)) {
$anmeldung=safe_query("SELECT * FROM ".PREFIX."upcoming_announce WHERE upID='$ds[upID]' ");
if(mysql_num_rows($anmeldung)) {
$i=1;
while ($da = mysql_fetch_array($anmeldung)) {
if ($da[status] == "y") $fontcolor = $wincolor;
elseif ($da[status] == "n") $fontcolor = $loosecolor;
else $fontcolor = $drawcolor;
if($i>1) $players.=', '.getnickname($da[userID]).' ';
else $players.=''.getnickname($da[userID]).' ';
$i++;
}
}
else $players='no players announced.';
$announce='• announce here ';
if(isclanwaradmin($userID))
$adminaction='
';
} else $players = 'You have to be a clanmember to see this.';
$bg1=BG_1;
$bg2=BG_2;
$bg3=BG_3;
$bg4=BG_4;
eval ("\$upcoming_date_details = \"".gettemplate("upcoming_date_details")."\";");
echo $upcoming_date_details;
}
}
}
}
else echo 'no entries for today';
}
if($_GET['action']=="addwar") {
if(isclanwaradmin($userID)) {
$chID=$_GET['chID'];
for($i=1; $i<32; $i++) {
if($i==date("d", time())) $day.=''.$i.' ';
else $day.=''.$i.' ';
}
for($i=1; $i<13; $i++) {
if($i==date("n", time())) $month.=''.date("M", time()).' ';
else $month.=''.date("M", mktime(0,0,0,$i,1,2000)).' ';
}
for($i=2000; $i<2010; $i++) {
if($i==date("Y", time())) $year.=''.date("Y", time()).' ';
else $year.=''.$i.' ';
}
$squads=getgamesquads();
$hours="20";
$minutes="00";
$opphp="http://";
if($chID) {
$ergebnis=safe_query("SELECT * FROM ".PREFIX."challenge WHERE chID='$chID'");
$ds=mysql_fetch_array($ergebnis);
$day=str_replace("", " ", $day);
$day=str_replace(" ".date("d", $ds[cwdate])." ", "".date("d", $ds[cwdate])." ", $day);
$month=str_replace(" selected", "", $month);
$month=str_replace(' value="'.date("n", $ds[cwdate]).'"', ' value="'.date("n", $ds[cwdate]).'" selected', $month);
$year=str_replace(" selected", "", $year);
$year=str_replace(' value="'.date("Y", $ds[cwdate]).'"', ' value="'.date("Y", $ds[cwdate]).'" selected', $year);
$hours=date("H", $ds[cwdate]);
$minutes=date("i", $ds[cwdate]);
$squads=str_replace(" selected", "", $squads);
$squads=str_replace('', ' ', $squads);
$countries=str_replace(" selected", "", $countries);
$countries=str_replace(' ', ' ', $countries);
$opphp=$ds[opphp];
}
$bg1=BG_1;
eval ("\$upcoming_war_new = \"".gettemplate("upcoming_war_new")."\";");
echo $upcoming_war_new;
}
else redirect('index.php?site=calendar', 'no access!');
}
elseif($_GET['action']=="editwar") {
if(isclanwaradmin($userID)) {
$upID = $_GET['upID'];
$ds=mysql_fetch_array(safe_query("SELECT * FROM ".PREFIX."upcoming WHERE upID='$upID'"));
for($i=1; $i<32; $i++) {
if($i==date("d", $ds[date])) $day.=' '.$i.' ';
else $day.=''.$i.' ';
}
for($i=1; $i<13; $i++) {
if($i==date("n", $ds[date])) $month.=''.date("M", $ds[date]).' ';
else $month.=''.date("M", mktime(0,0,0,$i,1,2000)).' ';
}
for($i=2000; $i<2010; $i++) {
if($i==date("Y", $ds[date])) $year.=''.$i.' ';
else $year.=''.$i.' ';
}
$squads=getgamesquads();
$squads=str_replace('value="'.$ds[squad].'"', 'value="'.$ds[squad].'" selected', $squads);
$league=$ds[league];
$leaguehp=$ds[leaguehp];
$opponent=$ds[opponent];
$opptag=$ds[opptag];
$opphp=$ds[opphp];
$maps=$ds[maps];
$server=$ds[server];
$warinfo=$ds[warinfo];
$countries=str_replace('value="at" selected', 'value="at"', $countries);
$countries=str_replace('value="'.$ds[oppcountry].'"', 'value="'.$ds[oppcountry].'" selected', $countries);
$hour=date("H", $ds[date]);
$minutes=date("i", $ds[date]);
$bg1=BG_1;
eval ("\$upcoming_war_edit = \"".gettemplate("upcoming_war_edit")."\";");
echo $upcoming_war_edit;
}
else redirect('index.php?site=calendar', 'no access!');
}
elseif($_GET['action']=="adddate") {
if(isclanwaradmin($userID)) {
for($i=1; $i<32; $i++) {
if($i==date("d", time())) $day.=''.$i.' ';
else $day.=''.$i.' ';
}
for($i=1; $i<13; $i++) {
if($i==date("n", time())) $month.=''.date("M", time()).' ';
else $month.=''.date("M", mktime(0,0,0,$i,1,2000)).' ';
}
for($i=2000; $i<2010; $i++) {
if($i==date("Y", time())) $year.=''.date("Y", time()).' ';
else $year.=''.$i.' ';
}
$squads=getgamesquads();
$bg1=BG_1;
eval ("\$upcoming_date_new = \"".gettemplate("upcoming_date_new")."\";");
echo $upcoming_date_new;
}
else redirect('index.php?site=calendar', 'no access!');
}
elseif($_GET['action']=="editdate") {
if(isclanwaradmin($userID)) {
$upID = $_GET['upID'];
$ds=mysql_fetch_array(safe_query("SELECT * FROM ".PREFIX."upcoming WHERE upID='$upID'"));
for($i=1; $i<32; $i++) {
if($i==date("d", $ds[date])) $day.=''.$i.' ';
else $day.=''.$i.' ';
}
for($i=1; $i<13; $i++) {
if($i==date("n", $ds[date])) $month.=''.date("M", $ds[date]).' ';
else $month.=''.date("M", mktime(0,0,0,$i,1,2000)).' ';
}
for($i=2000; $i<2010; $i++) {
if($i==date("Y", $ds[date])) $year.=''.$i.' ';
else $year.=''.$i.' ';
}
for($i=1; $i<32; $i++) {
if($i==date("d", $ds[enddate])) $endday.=''.$i.' ';
else $endday.=''.$i.' ';
}
for($i=1; $i<13; $i++) {
if($i==date("n", $ds[enddate])) $endmonth.=''.date("M", $ds[enddate]).' ';
else $endmonth.=''.date("M", mktime(0,0,0,$i,1,2000)).' ';
}
for($i=2000; $i<2010; $i++) {
if($i==date("Y", $ds[enddate])) $endyear.=''.$i.' ';
else $endyear.=''.$i.' ';
}
$countries=str_replace(' selected', '', $countries);
$countries=str_replace('value="'.$ds[country].'"', 'value="'.$ds[country].'" selected', $countries);
$hour=date("H", $ds[date]);
$endhour=date("H", $ds[enddate]);
$minute=date("i", $ds[date]);
$endminute=date("i", $ds[enddate]);
$short=$ds[short];
$title=$ds[title];
$location=$ds[location];
$locationhp=$ds[locationhp];
$dateinfo=cleartext($ds[dateinfo]);
$dateinfo = toggle($dateinfo, $upID);
$bg1=BG_1;
eval ("\$upcoming_date_edit = \"".gettemplate("upcoming_date_edit")."\";");
echo $upcoming_date_edit;
}
else redirect('index.php?site=calendar', 'no access!');
}
elseif($_GET['action']=="announce") {
echo'';
}
else {
// If $month is not present, set it to current month.
$month = $_GET['month'];
$month = (empty($month)) ? date("m") : $month;
// If $year is not present, set it to current year.
$year = $_GET['year'];
$year = (empty($year)) ? date("Y") : $year;
// If $year is not present, set it to current year.
$tag = $_GET['tag'];
$tag = (empty($tag)) ? date("d") : $tag;
print_calendar($month,$year);
print_termine($tag, $month, $year);
}
?>