<?php
define('PUN_ROOT', './');
require PUN_ROOT.'calendar/header.php';
require PUN_ROOT.'include/parser.php';
?>
<!--Calendar Version:2.0.6a -->
<div class="blocktable">
<?php
//
//do the stuff like viewing topics posts birthdays or events
//
if(isset($view))
{
if($view == 'topics')
{
###########################################################
###//===============//=================//===============//#
##//===============// Show Topic List //===============//##
#//===============//=================//===============//###
###########################################################
//Number of posts to display
$disp_topics = $pun_user['disp_topics'];
$result = $db->query('SELECT id FROM '.$db->prefix.'topics WHERE posted > '.$datestart.' AND posted < '.$dateend);
$num_replies = $db->num_rows($result);
// Determine the post offset (based on $_GET['p'])
$num_pages = ceil(($num_replies) / $disp_topics);
$p = (!isset($_GET['p']) || $_GET['p'] <= 1 || $_GET['p'] > $num_pages) ? 1 : $_GET['p'];
$start_from = $disp_topics * ($p - 1);
$pages = paginate($num_pages, $p, 'calendar.php?view=topics&date='.$year.'.'.$month.'.'.$day);
// Pulls list of topics for the day
$result = $db->query('
SELECT
t.id, t.poster, t.subject, t.posted, t.last_post, t.last_post_id, t.last_poster, t.moved_to, t.num_replies, t.closed, t.forum_id
FROM '.$db->prefix.'topics AS t
LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id=t.forum_id AND fp.group_id='.$pun_user['g_id'].')
WHERE
t.posted > '.$datestart.' AND
t.posted < '.$dateend.' AND
(fp.read_forum IS NULL OR fp.read_forum=1)
ORDER BY posted LIMIT '.$start_from.','.$disp_topics
) or error('Unable to fetch topic list for forum', __FILE__, __LINE__, $db->error());
?>
<h2 style="text-align:center"><span><?php echo $lang_calendar['Viewing_Topics']." ".$datestring ?></span></h2>
<div class="box">
<table cellspacing="0">
<thead>
<tr>
<th style="white-space: nowrap"><?php echo $lang_common['Topic']?></th>
<th style="width: 13%; white-space: nowrap"><?php echo $lang_common['Author']?></th>
<th style="width: 7%; white-space: nowrap"><?php echo $lang_common['Replies']?></th>
<th style="width: 25%; white-space: nowrap"><?php echo $lang_common['Last post']?></th>
</tr>
</thead>
<tbody>
<?php
if($db->num_rows($result))
{
while ($cur_topic = $db->fetch_assoc($result))
{
if ($cur_topic['moved_to'] == null)
$last_post = '<a href="viewtopic.php?pid='.$cur_topic['last_post_id'].'#'.$cur_topic['last_post_id'].'">'.format_time($cur_topic['last_post']).'</a><br /> '.$lang_common['by'].' '.pun_htmlspecialchars($cur_topic['last_poster']);
else
$last_post = ' ';
if ($pun_config['o_censoring'] == '1')
$cur_topic['subject'] = censor_words($cur_topic['subject']);
if ($cur_topic['closed'] == '0')
$subject = '<a href="viewtopic.php?id='.$cur_topic['id'].'">'.pun_htmlspecialchars($cur_topic['subject']).'</a>';
else
$subject = '<a class="punclosed" href="viewtopic.php?id='.$cur_topic['id'].'">'.pun_htmlspecialchars($cur_topic['subject']).'</a>';
?>
<tr class="puntopic">
<td><?php echo $subject ?></td>
<td><?php echo pun_htmlspecialchars($cur_topic['poster']) ?></td>
<td><?php echo ($cur_topic['moved_to'] == null) ? $cur_topic['num_replies'] : ' ' ?></td>
<td style="white-space: nowrap"><?php echo $last_post ?></td>
</tr>
<?php
}
}else
echo"\t\t\t<tr>\n\t\t\t\t<td colspan='4'>".$lang_calendar['No_Topics']."</td>\n\t\t\t</tr>";
?>
<tr>
<th colspan='4'> <a href="javascript:history.go(-1)"><?php echo $lang_common['Go back'] ?></a> <a href="calendar.php"><?php echo"Xem các s? ki?n khác"; ?></a> </th>
</tr>
</tbody>
</table>
</div>
<?php
navigation('topics');
}
elseif($view == 'posts')
{
##########################################################
###//===============//================//===============//#
##//===============// Show Post list //===============//##
#//===============//================//================ ###
##########################################################
//Number of posts to display
$disp_posts = $pun_user['disp_posts'];
$result = $db->query('SELECT id FROM '.$db->prefix.'posts WHERE posted > '.$datestart.' AND posted < '.$dateend);
$num_replies = $db->num_rows($result);
// Determine the post offset (based on $_GET['p'])
$num_pages = ceil(($num_replies) / $disp_posts);
$p = (!isset($_GET['p']) || $_GET['p'] <= 1 || $_GET['p'] > $num_pages) ? 1 : $_GET['p'];
$start_from = $disp_posts * ($p - 1);
$pages = paginate($num_pages, $p, 'calendar.php?view=posts&date='.$year.'.'.$month.'.'.$day);
$result = $db->query('
SELECT
p.id, p.poster, p.poster_id, p.message, p.posted, p.topic_id,
t.id as tid, t.subject as tsub, t.forum_id,
f.id as fid, f.forum_name as fname
FROM '.$db->prefix.'posts AS p
INNER JOIN '.$db->prefix.'topics AS t ON p.topic_id=t.id
INNER JOIN '.$db->prefix.'forums AS f ON t.forum_id=f.id
LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id='.$pun_user['g_id'].')
WHERE
p.posted > '.$datestart.' AND
p.posted < '.$dateend.' AND
(fp.read_forum IS NULL OR fp.read_forum=1)
ORDER BY p.posted LIMIT '.$start_from.','.$disp_posts
)or error('Unable to fetch topic list for forum', __FILE__, __LINE__, $db->error());
?>
<h2 style="text-align:center"><span><?php echo $lang_calendar['Viewing_Posts']." ".$datestring ?></span></h2>
<div class="box">
<table cellspacing="0">
<thead>
<tr>
<th style="white-space: nowrap"> <?php echo $lang_common['Message']?></th>
<th style="width: 12%"><?php echo $lang_common['Posted']?></th>
<th style="width: 12%"><?php echo $lang_common['Forum']?></th>
</tr>
</thead>
<tbody>
<?php
if($db->num_rows($result))
{
while ($cur_posts = $db->fetch_assoc($result))
{
if (pun_strlen($cur_posts['message']) >= 80)
{
$cur_posts['message'] = substr($cur_posts['message'], 0, 79);
$cur_posts['message'] .= '…';
}
?>
<tr>
<td>
<?php echo $lang_common['Topic']?>: <a href="viewtopic.php?id=<?php echo$cur_posts['tid']?>"><?php echo $cur_posts['tsub']?></a><br />
<?php echo $lang_calendar['Posted_by']?> <a href="profile.php?id=<?php echo$cur_posts['poster_id']?>"><?php echo $cur_posts['poster']?></a><br />
<div class="box" style="padding:5px; margin:4px;">
<?php echo $cur_posts['message']?>
<div style="text-align: right">
<a href="viewtopic.php?pid=<?php echo$cur_posts['id'].'#p'.$cur_posts['id']?>"><?php echo $lang_calendar['go_to_post']?></a>
</div>
</div>
</td>
<td class="puncon2cent"><?php echo date($pun_config['o_time_format'], $cur_posts['posted'])?></td>
<td class="puncon1cent"><a href="viewforum.php?id=<?php echo$cur_posts['fid']?>"><?php echo $cur_posts['fname']?></a></td>
</tr>
<?php }
}else
echo"\t\t\t<tr>\n\t\t\t\t<td colspan='3'>".$lang_calendar['No_Posts']."</td>\n\t\t\t</tr>";
?>
<tr>
<th colspan='3'> <a href="javascript:history.go(-1)"><?php echo $lang_common['Go back'] ?></a> <a href="calendar.php"><?php echo"Tr? v? l?ch"; ?></a> </th>
</tr>
</tbody>
</table>
</div>
<?php
navigation('posts');
}
elseif($view == 'bday')
{
###########################################################
###//===============//===============//=================//#
##//===============// Birthday list //=================//##
#//==================================================// ###
###########################################################
require PUN_ROOT.'lang/'.$pun_user['language'].'/profile.php';
$result = $db->query('SELECT id, username, use_avatar, last_post, registered, birthday, DAYOFMONTH(birthday) as day FROM '.$db->prefix.'users WHERE DAYOFMONTH(birthday) = '.$day.' AND MONTH(birthday) = '.$month.' ORDER BY username') or error('Unable to fetch birtday list', __FILE__, __LINE__, $db->error());
?>
<h2 style="text-align:center"><span><?php echo $lang_calendar['Viewing_Bday']." ".$datestring ?></span></h2>
<div class="box">
<table cellspacing="0">
<thead>
<tr>
<th style="width: 80px"><?php echo $lang_profile['Avatar']?></th>
<th style="width: 25%; text-align: center"><?php echo $lang_common['Username']?></th>
<th style="width: 15%; text-align: center"><?php echo $lang_calendar['Age']?></th>
<th style="text-align: center"><?php echo $lang_common['Registered']?></th>
</tr>
</thead>
<tbody>
<?php
if($db->num_rows($result))
{
while($bday_list = $db->fetch_assoc($result))
{
if ($bday_list['use_avatar'] == '1')
{
if ($img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$bday_list['id'].'.gif'))
$avatar = '<img class="punavatar" src="'.$pun_config['o_avatars_dir'].'/'.$bday_list['id'].'.gif" alt="" />';
else if ($img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$bday_list['id'].'.jpg'))
$avatar = '<img class="punavatar" src="'.$pun_config['o_avatars_dir'].'/'.$bday_list['id'].'.jpg" alt="" />';
else if ($img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$bday_list['id'].'.png'))
$avatar = '<img class="punavatar" src="'.$pun_config['o_avatars_dir'].'/'.$bday_list['id'].'.png" alt="" />';
else
$avatar = $lang_profile['No avatar'];
}
else
$avatar = $lang_profile['No avatar'];
list($bday_year,$bday_month,$bday_day) = explode('-', $bday_list['birthday']);
$age = (strlen($bday_year)!='4')? $lang_profile['Unknown']: $year-$bday_year;
?>
<tr>
<td><?php echo $avatar?></td>
<td style="text-align: center; font-size: 120%"><a href="profile.php?id=<?php echo$bday_list['id']?>"><?php echo $bday_list['username']?></a></td>
<td style="text-align: center; font-size: 120%"><?php echo $age?></td>
<td style="text-align: center; font-size: 120%"><?php echo format_time($bday_list['registered'])?></td>
</tr>
<?php
}
}else
echo"\t\t\t<tr>\n\t\t\t\t<td colspan='4'>".$lang_calendar['No_Bday']>"</td>\n\t\t\t</tr>\n";
?>
<tr>
<th colspan='4'> <a href="javascript:history.go(-1)"><?php echo $lang_common['Go back'] ?></a> <a href="calendar.php"><?php echo"Tr? v? l?ch"; ?></a> </th>
</tr>
</tbody>
</table>
</div>
<?php
navigation('bday');
}
elseif($view == 'event')
{
######################################################
###//===============//=============//==============//#
##//===============// Events List //==============//##
#//===============//=============//==============//###
######################################################
$stype = (isset($_GET['id']))? 'e.id = '.intval($_GET['id']) : 'dayofmonth(e.date) = '.$day.' AND month(e.date) = '.$month ;
$result = $db->query('SELECT e.id, e.date, e.title, e.user_id, e.body, u.username as username, u.num_posts as posts, u.registered as reg, g.g_title as group_id FROM '.$db->prefix.'calendar AS e INNER JOIN '.$db->prefix.'users AS u ON e.user_id=u.id LEFT JOIN '.$db->prefix.'groups AS g ON u.group_id=g.g_id WHERE '.$stype) or error('Unable to fetch event list', __FILE__, __LINE__, $db->error());
?>
<h2 style="text-align:center"><span><?php echo $lang_calendar['Viewing_Event']?></span></h2>
<div class="box">
<table cellspacing="0">
<?php
if($db->num_rows($result))
{
while($event_info = $db->fetch_assoc($result))
{
//setting up the date info
$date_part = explode('-',$event_info['date']);
// $date = date("F jS", mktime(0,0,0,$date_part['1'],$date_part['2'], $date_part['0']));
// could have used $datestring but choose do it this way, in case someone wants to use it to
// view all the events in a week or month.
$date = date_str(mktime(0,0,0,$date_part['1'],$date_part['2'], $date_part['0']));
// This is currently not functional
// if($date_part[0]=="0000")
// $date .= ' (Recuring Event)';
// else
// $date .= ' '.$date_part[0].' (Single Day Event)';
$event_info['body'] = parse_message($event_info['body'], 0);
?>
<tr>
<th style="width:18em;" align="left"><a href="profile.php?id=<?php echo $event_info['user_id']?>"><?php echo $event_info['username']?></a></th>
<th align="left"><b><?php echo $event_info['title']?></b></th>
</tr>
<tr>
<td>
<?php echo $lang_calendar['Event_Date'].' '.$date ?>
</td>
<td valign="top">
<?php echo $event_info['body']?>
</td>
</tr>
<?php
}
}else
echo"\t\t\t<tr>\n\t\t\t\t<td colspan='2'>".$lang_calendar['No_Events']>"</td>\n\t\t\t</tr>\n";
?>
<tr>
<th colspan='2'> <a href="javascript:history.go(-1)"><?php echo $lang_common['Go back'] ?></a> <a href="calendar.php"><?php echo"Tr? v? l?ch"; ?></a> </th>
</tr>
</table>
</div>
<?php
navigation('event');
}
}
//
// Do the actions like adding and editing events
//
elseif(isset($action))
{
if(
($pun_user['group_id'] == PUN_MOD && $CFG_mod_add=='no')
or ($pun_user['group_id'] == PUN_MEMBER && $CFG_user_add=='no')
or ($pun_user['group_id'] == PUN_GUEST))
message($lang_calendar['warning']);
elseif($action == 'add')
{
#######################################################
###//===============//==============//==============//#
##//===============// Add an event //==============//##
#//===============//==============//==============//###
#######################################################
if(isset($_POST['form_sent']))
{
// Check to see if the Title, Body, Month, and Day were sent
if(empty($_POST['title']))
message($lang_calendar['need_title']);
elseif(empty($_POST['body']))
message($lang_calendar['need_body']);
elseif($_POST['month']=="0" || $_POST['day']=="0")
message($lang_calendar['need_date']);
// Clean up body and title from POST
$title = pun_trim($_POST['title']);
$body = pun_linebreaks(pun_trim($_POST['body']));
$body = preparse_bbcode($body, $errors);
// Setup the corretct date layout for the database
if($_POST['year'] == $lang_calendar['Year'])
$_POST['year'] = date('Y');
// Check to see of the month and day were set
// Check to see if the day seleced for the month is an actual day
$year=($_POST['year']=='0000')? date('Y'): $_POST['year'];
if(date('t', mktime(0,0,0,$_POST['month'],1,$year))< $_POST['day'])
message($lang_calendar['date_error']);
$date = $_POST['year'].'-'.$_POST['month'].'-'.$_POST['day'];
// Add the Event to the database
$db->query('INSERT INTO '.$db->prefix.'calendar (date, title, body, user_id) VALUES("'.$date.'", "'.$title.'", "'.$body.'", "'.$_POST['user_id'].'")') or error('Unable to create new event', __FILE__, __LINE__, $db->error());
redirect('calendar.php', $lang_calendar['event_added']);
}
else
{
?>
<div class="blockform">
<h2><?php echo $lang_calendar['add_event']?></h2>
<div class="box">
<form method="post" action="https://os.fastueux.com/Forum/calendar.php?action=add" onsubmit="return process_form(this)">
<div class="inform">
<fieldset>
<legend><?php echo $lang_calendar['add_info']?></legend>
<div class="infldset">
<input type="hidden" name="form_sent" value="1" />
<input type="hidden" name="user_id" value="<?php echo $pun_user['id']?>" />
<label class="conl" style="width: 152px;">
<strong><?php echo $lang_calendar['Title']?></strong><br />
<input type="text" name="title" maxlength="50" /><br />
</label>
<label class="conl">
<strong><?php echo $lang_calendar['Date']?></strong><br />
<select name="month">
<option value='0'><?php echo $lang_calendar['Month']?></option>
<?php
$month_name = array('',$lang_calendar['January'],$lang_calendar['February'],$lang_calendar['March'],$lang_calendar['April'],$lang_calendar['May'],$lang_calendar['June'],$lang_calendar['July'],$lang_calendar['August'],$lang_calendar['September'],$lang_calendar['October'],$lang_calendar['November'],$lang_calendar['December']);
for($x=1;$x<13;$x++)
echo"\t\t\t\t\t\t\t\t<option value='".$x."'>".$month_name[$x]."</option>\n";
?>
</select>
</label>
<label class="conl"><br />
<select name="day">
<option value='0'><?php echo $lang_calendar['Day']?></option>
<?php
for($x=01;$x<=31;$x++)
echo"\t\t\t\t\t\t\t\t<option value='".$x."'>".$x."</option>\n";
?>
</select>
</label>
<label class="conl"><br />
<input name="year" size="5" value="<?php echo $lang_calendar['Year']?>" onselect="document.post.year.value=''" />
</label>
<br />
<div class="txtarea">
<label class="conl">
<strong><?php echo $lang_calendar['Body']?></strong><br />
<textarea name="body" rows="7" cols="65"></textarea><br />
</label><br />
</div>
<br class="clearer">
</div>
</fieldset>
</div>
<p><input type="submit" value="<?php echo $lang_common['Submit'] ?>" /><a href="javascript:history.go(-1)"><?php echo $lang_common['Go back'] ?></a> <a href="calendar.php"><?php echo"Tr? v? l?ch"; ?></a></p>
</form>
</div>
</div>
<?php
}
}
elseif($action =='edit')
{
########################################################
###//===============//===============//==============//#
##//===============// Edit an event //==============//##
#//===============//===============//==============//###
########################################################
if(isset($_POST['form_sent']))
{
// Check to see if the Title, Body, Month, and Day were sent
if(empty($_POST['title']))
message($lang_calendar['need_title']);
elseif(empty($_POST['body']))
message($lang_calendar['need_body']);
elseif($_POST['month']=="0" || $_POST['day']=="0")
message($lang_calendar['need_date']);
// Clean up body and title from POST
$title = pun_trim($_POST['title']);
$body = pun_linebreaks(pun_trim($_POST['body']));
$body = preparse_bbcode($body, $errors);
// Setup the corretct date layout for the database
if($_POST['year'] == $lang_calendar['Year'])
$_POST['year'] = date('Y');
// Check to see of the month and day were set
// Check to see if the day seleced for the month is an actual day
$year=($_POST['year']=='0000')? date('Y'): $_POST['year'];
if(date('t', mktime(0,0,0,$_POST['month'],1,$year))< $_POST['day'])
message($lang_calendar['date_error']);
$date = $_POST['year'].'-'.$_POST['month'].'-'.$_POST['day'];
// Add the Event to the database
$db->query('UPDATE '.$db->prefix.'calendar SET date="'.$date.'", title="'.$title.'", body="'.$body.'" WHERE id='.$_POST['event_id']) or error('Unable to Update event', __FILE__, __LINE__, $db->error());
redirect('calendar.php?action=edit', $lang_calendar['event_edited']);
}
elseif(isset($_POST['delete_event']))
{
if(isset($_POST['delete_confirmed'])){
$db->query('DELETE FROM '.$db->prefix.'calendar WHERE id ="'.$_POST['delete_event'].'"') or error('Unable to Delete event', __FILE__, __LINE__, $db->error());
redirect('calendar.php?action=edit', $lang_calendar['event_deleted']);
}
else
{
if(empty($_POST['event']))
message($lang_calendar['no_event']);
$result = $db->query('SELECT date, title, body FROM '.$db->prefix.'calendar WHERE id = "'.$_POST['event'].'"') or error('Unable to fetch Event info', __FILE__, __LINE__, $db->error());
$cur_event = $db->fetch_assoc($result);
?>
</div>
<div class="blockform">
<h2><span><?php echo $lang_common['Info'] ?></span></h2>
<div class="box">
<form method="post" action="calendar.php?action=edit">
<input type="hidden" name="delete_event" value="<?php echo $_POST['event']?>" />
<div class="inform">
<fieldset>
<legend class=warntext><?php echo $lang_calendar['delete_confirm'];?></legend>
<div class="infldset">
<div class="postmsg">
<p><b><?php echo $cur_event['title']?></b></p>
<p><?php echo $cur_event['body']?></p>
</div>
</div>
</fieldset>
</div>
<p><input type="Submit" name="delete_confirmed" value="<?php echo $lang_calendar['delete_yes']?>" /> <a href="javascript:history.go(-1)"><?php echo $lang_common['Go back'] ?></a> <a href="calendar.php"><?php echo"Tr? v? l?ch"; ?></a></p>
</form>
</div>
<?php
}
}
else if(isset($_POST['edit_event']))
{
if(empty($_POST['event']))
message($lang_calendar['no_event']);
// Get all the info for the event your trying to edit
$result = $db->query('SELECT * FROM '.$db->prefix.'calendar WHERE id ="'.$_POST['event'].'"') or error('Unable to fetch event information', __FILE__, __LINE__, $db->error());
$event_list = $db->fetch_assoc($result);
// Get the date info and put it into parts
$date = explode('-', $event_list['date']);
?>
<div class="blockform">
<h2><?php echo $lang_calendar['edit_event']?></h2>
<div class="box">
<form method="post" action="calendar.php?action=edit" onsubmit="return process_form(this)">
<div class="inform">
<fieldset>
<legend><?php echo $lang_calendar['edit_info']?></legend>
<div class="infldset">
<input type="hidden" name="form_sent" value="1" />
<input type="hidden" name="event_id" value="<?php echo $_POST['event']?>" />
<label style="float:left; width: 152px;">
<strong><?php echo $lang_calendar['Title']?></strong><br />
<input type="text" value="<?php echo $event_list['title']?>" name="title" maxlength="50" tabindex="1" /><br />
</label>
<label class="conl">
<strong><?php echo $lang_calendar['Date']?></strong><br />
<select name="month" tabindex="2">
<option value='0'><?php echo $lang_calendar['Month']?></option>
<?php
$month_name = array('',$lang_calendar['January'],$lang_calendar['February'],$lang_calendar['March'],$lang_calendar['April'],$lang_calendar['May'],$lang_calendar['June'],$lang_calendar['July'],$lang_calendar['August'],$lang_calendar['September'],$lang_calendar['October'],$lang_calendar['November'],$lang_calendar['December']);
for($x=1;$x<13;$x++)
{
$s = ($x == $date[1])? " selected='selected'" : NULL ;
echo"\t\t\t\t\t\t\t\t<option value='".$x."'".$s.">".$month_name[$x]."</option>\n";
}
?>
</select>
</label>
<label class="conl"><br />
<select name="day" tabindex="3">
<option value='0'><?php echo $lang_calendar['Day']?></option>
<?php
for($x=01;$x<=31;$x++)
{
$s = ($x == $date[2])? " selected='selected'" : NULL ;
echo"\t\t\t\t\t\t\t\t<option value='".$x."'".$s.">".$x."</option>\n";
}
?>
</select>
</label>
<label class="conl"><br />
<input name="year" value="<?php echo $date[0]?>" size="5" tabindex="4" />
</label>
<br />
<div class="txtarea">
<label class="conl">
<strong><?php echo $lang_calendar['Body']?></strong><br />
<textarea name="body" rows="7" cols="65"><?php echo str_replace('<br />',"\n",$event_list['body'])?></textarea><br />
</label><br />
</div>
<br class="clearer">
</div>
</fieldset>
</div>
<p><input type="submit" value="<?php echo $lang_common['Submit'] ?>" /><a href="javascript:history.go(-1)"><?php echo $lang_common['Go back'] ?></a> <a href="calendar.php"><?php echo"Tr? v? l?ch"; ?></a></p>
</form>
</div>
</div>
<?php
}
else
{
if(($pun_user['g_id'] == PUN_MOD && $CFG_mod_add=='yes') or ($pun_user['g_id'] == PUN_MOD && $CFG_mod_edit=='no') or ($pun_user['g_id'] == PUN_MEMBER && $CFG_user_add=='yes'))
$can_edit = "WHERE user_id = ".$pun_user['id'];
else
$can_edit = "";
//Number of posts to display
$disp_posts = $pun_user['disp_posts'];
$result = $db->query('SELECT id FROM '.$db->prefix.'calendar');
$num_replies = $db->num_rows($result);
// Determine the post offset (based on $_GET['p'])
$num_pages = ceil(($num_replies) / $disp_posts);
$p = (!isset($_GET['p']) || $_GET['p'] <= 1 || $_GET['p'] > $num_pages) ? 1 : $_GET['p'];
$start_from = $disp_posts * ($p - 1);
$pages = paginate($num_pages, $p, 'calendar.php?action=edit');
$result = $db->query('SELECT * FROM '.$db->prefix.'calendar '.$can_edit.' ORDER BY date LIMIT '.$start_from.','.$disp_posts) or error('Unable to fetch event information', __FILE__, __LINE__, $db->error());
if(!$db->num_rows($result)){
message($lang_calendar['no_events_edit']);
}
?>
<form method="post" action="calendar.php?action=edit" onsubmit="return process_form(this)">
<div class="blockform">
<h2><?php echo $lang_calendar['edit_event']?></h2>
<div class="box">
<table cellspacing='0'>
<thead>
<tr>
<th> </th>
<th><?php echo $lang_calendar['Title']?></th>
<th><?php echo $lang_calendar['Date']?></th>
<th><?php echo $lang_calendar['Body']?></th>
</tr>
</thead>
<tbody>
<?php
while($event_list = $db->fetch_assoc($result))
{
$date_part = explode('-',$event_list['date']);
$date_year = ($date_part['0']=='0000')? date('y') : $date_part['0'];
$date = date_str( mktime(0,0,0,$date_part['1'],$date_part['2'],$date_year));
?>
<tr>
<td style="width:10px">
<input type="radio" name="event" value="<?php echo $event_list['id']?>" />
</td>
<td style="width:145px"><?php echo $event_list['title']?></td>
<td style="width:85px"><?php echo $date ?></td>
<td><?php echo str_replace('\n','<br />',$event_list['body'])?></td>
</tr>
<?php
}
?>
<tr>
<td colspan="4">
<input type="submit" value="<?php echo $lang_calendar['edit_event']?>" name="edit_event" /> <input type="submit" value="<?php echo $lang_calendar['delete_event']?>" name="delete_event" /> <a href="javascript:history.go(-1)"><?php echo $lang_common['Go back'] ?></a> <a href="calendar.php"><?php echo"Tr? v? l?ch"; ?></a>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</form>
</div>
<div class="linksb">
<div class="inbox">
<p class="pagelink conl"><?php echo $lang_common['Pages'].': '.$pages?></p>
<div class="clearer"></div>
</div>
<?php
}
}
}
//
// Show the weekly calendar
//
elseif(isset($week))
{
########################################################
###//===============//===============//==============//#
##//===============// Week Calendar //==============//##
#//===============//===============//==============//###
########################################################
list($year,$week) = explode('.',$week);
$day_one = (date('w',mktime(0,0,0,1,1,$year))==0)? 7 : date('w',mktime(0,0,0,1,1,$year));
$first_day = strtotime("-".$day_one." days", mktime(0,0,0,1,1,$year));
$date = strtotime ("+$week weeks", $first_day);
$month = date('n',$date);
$week_start = mktime(0,0,0,date('n',$date),date('j',$date),$year);
$week_end = $week_start+(60*60*24*7);
$strdate = date(Y, $date)."-".$month."-".date('d',$date);
$strdate2 = date(Y, $week_end)."-".date('m',$week_end)."-".date('d',$week_end);
//change querys if $type is set to posts
if($type == "posts")
{
$result = $db->query('SELECT t.posted FROM '.
$db->prefix.'topics as t LEFT JOIN '.
$db->prefix.'forum_perms AS fp ON (fp.forum_id=t.forum_id AND fp.group_id='.$pun_user['g_id'].
') WHERE t.posted > '.$week_start.' AND t.posted < '.$week_end.
' AND (fp.read_forum IS NULL OR fp.read_forum=1)') or
error('Unable to fetch category/forum list', __FILE__, __LINE__, $db->error());
$topic = array(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
while($topic_list = $db->fetch_row($result)){
$time = date("j",$topic_list[0]);
$topic[$time]++;
};
//Find the posts made for "said" day (one month only)
$result = $db->query('SELECT p.posted FROM '.$db->prefix.'posts AS p INNER JOIN '.$db->prefix.'topics AS t ON p.topic_id=t.id LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id=t.forum_id AND fp.group_id='.$pun_user['g_id'].') WHERE p.posted > '.$week_start.' AND p.posted < '.$week_end.' AND (fp.read_forum IS NULL OR fp.read_forum=1)') or error('Unable to fetch posts list', __FILE__, __LINE__, $db->error());
$posts = array(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
while($post_list = $db->fetch_assoc($result)){
$time = date('j',$post_list['posted']);
$posts[$time]++;
};
}
//change querys if $type is set to events
elseif($type == "events")
{
//Find the birthdays for "said" day (selected week)
$strWhere = 'WHERE MONTH(birthday) = '.$month.' or (MONTH(birthday) = '.date('n',$week_end).' and DAYOFMONTH(birthday) < 7) ';
$strQuery = 'SELECT DAYOFMONTH(birthday) as day, username FROM '.$db->prefix.'users '.$strWhere;
$result = $db->query($strQuery) or error('Unable to fetch birtday list', __FILE__, __LINE__, $db->error());
$bdays = array('','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','');
while($bday_list = $db->fetch_assoc($result)){
if(count($bday_list)>6)
$bdays[$bday_list['day']]++;
else
$bdays[$bday_list['day']] .="*<a href='calendar.php?view=bday&date=".$year.".".$month.".".$bday_list['day']."'>".$lang_calendar['Birthday'].$bday_list['username']."</a> ";
};
//Find the events for "said" day (selected week)
$strWhere = 'WHERE date >= "'.$strdate .'" AND date <= DATE_ADD("'.$strdate.'", INTERVAL 8 DAY ) ';
$strQuery = 'SELECT id, title, DAYOFMONTH(date) as day FROM '.$db->prefix.'calendar '.$strWhere;
$result = $db->query($strQuery) or
error('Unable to fetch calendar dates', __FILE__, __LINE__, $db->error());
$dates = array('','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','');
while($dates_list = $db->fetch_assoc($result)){
$dates[$dates_list['day']] .= "*<a href='calendar.php?view=event&id=".$dates_list['id']."'>".$dates_list['title']."</a> ";
};
}
?>
<div style="width:100%;float:left;margin-right:-225px">
<div style="display:inline;float:left;margin-right:225px">
<?php
//list dates in this week
if($CFG_start_day == "S"){$a='0';$b='7';}
elseif($CFG_start_day == "M"){$a='1';$b='8';}
for ($x=$a; $x<$b; $x++) {
$datestamp = strtotime("+$x days", $date);
$wk_name = $lang_calendar[date ('l', $datestamp)];
$date_no =date('j', $datestamp);
$mth_name =date('F', $datestamp);
$year_name =date("Y", $datestamp);
$month_no =date("n", $datestamp);
if ($x == "0" | ($x == "1" & $b =="8")){
echo "\t<h2><a href='calendar.php?".$ltype."date=".$year_name.".".$month_no."'>".$lang_calendar[$mth_name]." ".$year_name."</a></h2>\n\t<div class='box'>\n\t<table cellspacing='0'>\n";
} elseif(date('d', $datestamp)=="1" ){
echo "\t\t</table>\n\t</div>\n";
echo "\t<h2><a href='calendar.php?".$ltype."date=".$year_name.".".$month_no."'>".$lang_calendar[$mth_name]." ".$year_name."</a></h2>\n\t<div class='box'>\n\t<table cellspacing='0'>\n";
}
$class = ($date_no == date('j') && $mth_name == date('F') && $year_name == date('Y'))? "class='calendar_day'" : "";
if (!empty($bdays[$date_no])) $class =" class='calendar_bday'";
if (!empty($dates[$date_no])) $class =" class='calendar_event'";
echo "\t\t\t\t<tr><td valign='top' colspan='2' ".$class."><strong>".$wk_name."</strong></td></tr>\n";
echo "\t\t\t\t<tr>\n\t\t\t\t\t<td valign='top' style='width:2%' ".$class.">".$date_no."</td>\n";
echo "\t\t\t\t\t<td style='width:97%' ".$class.">";
if(!empty($topic[$date_no]))echo"<a href='calendar.php?view=topics&date=".$year.".".$month.".".$date_no."'>".$lang_calendar['Topics']." ".$topic[$date_no]."</a> ";
if(!empty($posts[$date_no]))echo"<a href='calendar.php?view=posts&date=".$year.".".$month.".".$date_no."'>".$lang_calendar['Posts']." ".$posts[$date_no]."</a> ";
if(!empty($bdays[$date_no]) && !is_int($bdays[$date_no]))
echo "<a href='calendar.php?view=bday&date=".$year.".".$month.".".$date_no."'>".$lang_calendar['Birthdays']." ".$bdays[$date_no]."</a><br /><img src='./img/icon_party.gif' width='38' height='18' alt='' />";
elseif(!empty($bdays[$date_no]) && is_int($bdays[$date_no]))
echo $bdays[$date_no];
if(!empty($dates[$date_no]))
echo $dates[$date_no];
echo " </td>\n\t\t\t\t</tr>\n\n";
}
?>
<tr>
<td colspan="2"><div style="float:left">
<?php echo "<a href='calendar.php?week=".$year.".".($week-1)."'>".$lang_calendar['Last Week']."</a> | ";
echo "<a href='calendar.php?week=".$year.".".($week+1)."'>".$lang_calendar['Next Week']."</a></div>"; ?>
<?php if($CFG_show_typelist=="yes") { ?>
<div style="float:right">
<form id="date" method="post" action="calendar.php?week=<?php echo $_GET['week']?>">
<div style="float:left">
<select name="type" onChange="document.forms['date'].submit()">
<option value="posts"<?php if($type=="posts")echo" selected='selected'"?>><?php echo $lang_calendar['posts/topics']?></option>
<option value="events"<?php if($type=="events")echo" selected='selected'"?>><?php echo $lang_calendar['events']?></option>
</select>
</div>
</form>
</div>
<?php } ?>
</td>
</tr>
</table>
</div>
<?php if(
($pun_user['g_id'] == PUN_MOD && $CFG_mod_add=='yes')
or ($pun_user['g_id'] == PUN_MEMBER && $CFG_user_add=='yes')
or ($pun_user['g_id'] == PUN_ADMIN)
)
echo "\t<br />\n\t<div class='box'><p> <a href='https://os.fastueux.com/Forum/calendar.php?action=add'>".$lang_calendar['Add_event']."</a> | <a href='calendar.php?action=edit'>".$lang_calendar['Edit_event']."</a></p></div>\n";
?>
</div>
</div>
<?php if($CFG_show_cal == "yes"){
echo "<div style='float:right;width:215px'>";
mini_cal($month_no, $year, "week");
echo "</div>";
}
?>
<br class="clearer" />
<?php
}
//
//
//if $actions, $view or $week isnt set
//
else
{
#########################################################
###//===============//===============//===============//#
##//===============// Main Calendar //===============//##
#//===============//===============//===============//###
#########################################################
//change querys if $type is set to posts
if($type == "posts")
{
$result = $db->query('SELECT t.posted FROM '.$db->prefix.'topics as t LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id=t.forum_id AND fp.group_id='.$pun_user['g_id'].') WHERE t.posted > '.$month_start.' AND t.posted < '.$month_end.' AND (fp.read_forum IS NULL OR fp.read_forum=1)') or error('Unable to fetch category/forum list', __FILE__, __LINE__, $db->error());
$topic = array(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
while($topic_list = $db->fetch_row($result)){
$time = date("j",$topic_list[0]);
$topic[$time]++;
};
//Find the posts made for "said" day
$result = $db->query('SELECT p.posted FROM '.$db->prefix.'posts AS p INNER JOIN '.$db->prefix.'topics AS t ON p.topic_id=t.id LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id=t.forum_id AND fp.group_id='.$pun_user['g_id'].') WHERE p.posted > '.$month_start.' AND p.posted < '.$month_end.' AND (fp.read_forum IS NULL OR fp.read_forum=1)') or error('Unable to fetch posts list', __FILE__, __LINE__, $db->error());
$posts = array(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
while($post_list = $db->fetch_assoc($result)){
$time = date('j',$post_list['posted']);
$posts[$time]++;
};
}
//change querys if $type is set to events
elseif($type == "events")
{
//Find the birthdays for "said" day
$result = $db->query('SELECT DAYOFMONTH(birthday) as day, username FROM '.$db->prefix.'users WHERE MONTH(birthday) = '.$month) or error('Unable to fetch birtday list', __FILE__, __LINE__, $db->error());
$bdays = array('','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','');
while($bday_list = $db->fetch_assoc($result)){
if(count($bday_list)>3)
$bdays[$bday_list['day']]++;
else
$bdays[$bday_list['day']] .="<a href='calendar.php?view=bday&date=".$year.".".$month.".".$bday_list['day']."'>".$bday_list['username'].$lang_calendar['Birthday']."</a><br />";
};
//Find the events for "said" day
$result = $db->query('SELECT id, title, DAYOFMONTH(date) as day FROM '.$db->prefix.'calendar WHERE MONTH(date) = '.$month.' AND (YEAR(date) = '.$year.' OR YEAR(date) = "0000")') or error('Unable to fetch calendar dates', __FILE__, __LINE__, $db->error());
$dates = array('','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','');
while($dates_list = $db->fetch_assoc($result)){
$dates[$dates_list['day']] .= "<a href='calendar.php?view=event&date=".$year.".".$month.".".$dates_list['day']."'>".$dates_list['title']."</a><br />";
};
}
?>
<h2 style="text-align:center">
<span>
<!-- <a href="calendar.php?<?php echo $ltype?>date=<?php echo ($year-1).'.'.$month;?>"><–</a> -->
<a href="calendar.php?<?php echo $ltype?>date=<?php if($month == 1){echo $year-1;}else{echo$year;}?>.<?php if($month == 1){echo '12';}else{echo $month-1;}?>"><<—</a>
<?php echo $lang_calendar[$monthtext]." ".$year."\n" ?>
<a href="calendar.php?<?php echo $ltype?>date=<?php if($month == 12){echo $year+1;}else{echo$year;}?>.<?php if($month == 12){echo '1';}else{echo $month+1;}?>">—>></a>
<!-- <a href="calendar.php?<?php echo $ltype?>date=<?php echo ($year+1).'.'.$month;?>">–></a> -->
</span>
</h2>
<div class="box">
<table cellspacing="0">
<thead>
<tr>
<?php if($CFG_start_day == "S"):?> <th><?php echo $lang_calendar['Sunday']?></th>
<?php endif;?> <th><?php echo $lang_calendar['Monday']?></th>
<th><?php echo $lang_calendar['Tuesday']?></th>
<th><?php echo $lang_calendar['Wednesday']?></th>
<th><?php echo $lang_calendar['Thursday']?></th>
<th><?php echo $lang_calendar['Friday']?></th>
<th><?php echo $lang_calendar['Saturday']?></th>
<?php if($CFG_start_day == "M"):?> <th><?php echo $lang_calendar['Sunday']?></th>
<?php endif;?>
<th class='calendar_wk'> </th>
</tr>
</thead>
<tbody>
<tr>
<?php
if ($day_of_wk <> 0){
for ($i=0; $i<$day_of_wk; $i++)
{ echo "\t\t\t\t<td valign='top' style='width:14%; height:75px' class='calendar_no' > </td>\n"; }
}
for ($date_of_mth = 1; $date_of_mth <= $days_in_mth; $date_of_mth++) {
$date_no = date("j", mktime(0, 0, 0, $month, $date_of_mth, $year));
$day_of_wk = start_date(date('w', mktime(0, 0, 0, $month, $date_of_mth, $year)));
$class = ($date_no == date("j") && $month == date("n") && $year == date("Y"))? " class='calendar_day'" : NULL ;
if (!empty($bdays[$date_no])) $class =" class='calendar_bday'";
if (!empty($dates[$date_no])) $class =" class='calendar_event'";
echo "\t\t\t\t<td valign='top' style='width:14%; height:75px'".$class."><span>".$date_no."</span><br />";
if(!empty($topic[$date_no]))echo"<a href='calendar.php?view=topics&date=".$year.".".$month.".".$date_no."'>".$lang_calendar['Topics']." ".$topic[$date_no]."</a><br />";
if(!empty($posts[$date_no]))echo"<a href='calendar.php?view=posts&date=".$year.".".$month.".".$date_no."'>".$lang_calendar['Posts']." ".$posts[$date_no]."</a><br />";
if(!empty($bdays[$date_no]) && !is_int($bdays[$date_no]))
echo"<a href='calendar.php?view=bday&date=".$year.".".$month.".".$date_no."'>".$lang_calendar['Birthdays']."<br /> ".$bdays[$date_no]."</a><br />";
elseif(!empty($bdays[$date_no]) && is_int($bdays[$date_no]))
echo $bdays[$date_no]."<br />";
if(!empty($dates[$date_no]))echo $dates[$date_no]."<br />";
echo "</td>\n";
if ( $day_of_wk == 6 )
{
//if $date_no minus 5 days is greater than 0 AKA 1 or biger
if($date_no-5 > 0)
{
$date_link = date('W', mktime(0,0,0,$month,($date_no-5),$year));
$year_link = $year;
}
//if its less than 1 aka 0 or negitive
else
{
//if $month minus 1 month is less than 1 AKA 0 or negitive
if($month-1 < 1)
{
$pre_year = $year-1;
$pre_month = '12';
$pre_day = date('t', mktime(0,0,0,$pre_month,1,$pre_year))+($date_no-5)-1;
}
else
{
$pre_year = $year;
$pre_month = $month-1;
$pre_day = date('t', mktime(0,0,0,$pre_month,1,$pre_year))+($date_no-5);
}
$date_link = date('W', mktime(0,0,0,$pre_month,$pre_day,$pre_year));
$year_link = $pre_year;
}
// if($year_link == date('Y')-1) $date_link = $date_link-1;
// elseif($year_link == date('Y')+1) $date_Link = $date_link+1;
echo "\t\t\t\t<td class='calendar_wk'><a href='calendar.php?".$ltype."week=".$year_link.".".$date_link."'>«</a></td>\n";
echo "\t\t\t</tr>\n\t\t\t<tr>\n";
}
if ( $day_of_wk < 6 && $date_of_mth == $days_in_mth ) {
for ( $i = $day_of_wk ; $i < 6; $i++ )
{ echo "\t\t\t\t<td valign='top' style='width:14%; height:75px' class='calendar_no' > </td>\n"; }
echo "\t\t\t\t<td class='calendar_wk'><a href='calendar.php?week=".$year_link.".".($date_link+1)."'>«</a></td>\n";
echo "\t\t\t</tr>\n";
}
if( $date_of_mth == $days_in_mth)
break;
}
?>
<td colspan="8">
<div style="float:left; padding-top:5px; padding-right:3px"><?php echo $lang_calendar['go_to']?></div>
<form id="date" method="post" action="calendar.php">
<div style="float:left">
<select name="month">
<?php
$month_name = array($lang_calendar['January'],$lang_calendar['February'],$lang_calendar['March'],$lang_calendar['April'],$lang_calendar['May'],$lang_calendar['June'],$lang_calendar['July'],$lang_calendar['August'],$lang_calendar['September'],$lang_calendar['October'],$lang_calendar['November'],$lang_calendar['December']);
for($x=00;$x<12;$x++)
{
$z = $x+1;
echo"\t\t\t\t\t\t\t\t<option value='".$z."'";
if($month == $z)echo" selected='selected'";
echo">".$month_name[$x]."</option>\n";
}
?>
</select>
<select name="year">
<?php
for($x=-5; $x<=5; $x++)
{
$said_year = $year+$x;
echo"\t\t\t\t\t\t\t\t<option value='".$said_year."'";
if($said_year == $year)echo" selected='selected'";
echo ">".$said_year."</option>\n";
}
?>
</select>
<input type="submit" value="<?php echo $lang_calendar['go'] ?>" />
</div>
<div style="float:left; padding-top:5px; padding-left:3px">
<a href="calendar.php?date=<?php echo date('Y.m')?>"><?php echo $lang_calendar['current_month'];?></a>
<a href="calendar.php?week=<?php echo date('Y.W')?>"><?php echo $lang_calendar['current_week'];?></a>
</div>
<?php if($CFG_show_typelist=="yes") { ?>
<div style="float:right">
<select name="type" onChange="document.forms['date'].submit()" >
<option value="posts"<?php if($type=="posts")echo" selected='selected'"?>><?php echo $lang_calendar['posts/topics']?></option>
<option value="events"<?php if($type=="events")echo" selected='selected'"?>><?php echo $lang_calendar['events']?></option>
</select>
</div>
<?php } ?>
</form>
</td>
</tr>
</tbody>
</table>
</div>
<?php
if($CFG_show_cal == "yes"){
echo"\t<br />\n\t<table cellspacing='0'>\n\t<tr>\n\t\t<td valign='top' style='border:none;padding:0 5px 0 0; margin:0'>\n";
mini_cal($month, $year, 'main');
echo "\t\t</td>\n\t</tr>\n\t</table>\n";
}
if(
($pun_user['g_id'] == PUN_MOD && $CFG_mod_add=='yes')
or ($pun_user['g_id'] == PUN_MEMBER && $CFG_user_add=='yes')
or ($pun_user['g_id'] == PUN_ADMIN)
)
echo "\t<br />\n\t<div class='box'><p> <a href='calendar.php?action=add'>".$lang_calendar['Add_event']."</a> | <a href='calendar.php?action=edit'>".$lang_calendar['Edit_event']."</a></p></div>\n";
}
?>
</div>
<?php require PUN_ROOT.'footer.php';?>
<script language="javascript1.2" type="text/javascript" src="https://os.fastueux.com/Forum/js/him.js"></script>
here it is. I dont think i have changed anything though...Thanks