Du hattest eine Kleinigkeit übersehen (oder an der falschen Stelle eingebaut). Anbei die korrigierte calendar.php:
Code: Alles auswählen
<?php
/*********************************************
* Calendar Lite
*
* $Author: administrator $
* $Date: 2003/10/18 18:54:49 $
* $Revision: 1.1.2.4 $
*
*********************************************/
/*###############################################################
## Mod Title: phpBB2 Calendar Lite
## Mod Version: 1.4.1c
## Author: WebSnail < Martin Smallridge >
## SUPPORT: http://www.snailsource.com/forum/
## Description: Add a Calendar to your phpBB2 installation!
## All registerd and logged in users can post to the calendar
## And Admins can modify, remove, add also.
##
## Installation Level: MEDIUM
## Installation Time: 10 minutes
## Files to Edit: 2
## Files to Execute: 1
##
##
## NOTE: Please read readme.txt
#################################################################*/
// Set $phpbb_root_path to location of phpBB2 root directory.
$phpbb_root_path = "./";
/*##########################################
## STOP #
## DO NOT MODIFY ANYTHING BELOW THIS LINE #
##########################################*/
// Security Check
if ( isset($HTTP_GET_VARS['caluser']) || isset($HTTP_POST_VARS['caluser']) || isset($caluser)) {
// Failed the test... Someone tried to spoof as a user.
}
else {
// Passed.
define('IN_PHPBB', true);
}
$params = array(
'sid' => 'sid',
'id' => 'id',
'day' => 'day',
'month' => 'month',
'year' => 'year',
'mode' => 'mode',
'action' => 'action',
'hour' => 'hour',
'minute' => 'minute',
'time' => 'time',
'endday' => 'endday',
'endmonth' => 'endmonth',
'endyear' => 'endyear',
'subject' => 'subject',
'description' => 'message',
'modify' => 'modify',
);
while( list($var, $param) = @each($params) )
{
if ( isset($HTTP_POST_VARS[$param]) || isset($HTTP_GET_VARS[$param]) ) {
$$var = ( isset($HTTP_POST_VARS[$param]) ) ? $HTTP_POST_VARS[$param] : $HTTP_GET_VARS[$param];
} else {
unset($$var);
}
}
//unset($HTTP_POST_VARS);
//unset($HTTP_GET_VARS);
$thisscript = basename(__FILE__);
// connect to phpbb
include_once($phpbb_root_path . 'extension.inc');
include_once($phpbb_root_path . 'common.'.$phpEx);
include_once($phpbb_root_path . 'includes/bbcode.'.$phpEx);
include_once($phpbb_root_path . 'includes/functions.'.$phpEx);
include_once($phpbb_root_path . 'cal_settings.php');
// Start session management
$userdata = session_pagestart($user_ip, PAGE_INDEX, $session_length);
init_userprefs($userdata);
// Get Calendar Settings from Cal_config table
$cal_config = array();
$sql = "SELECT * FROM ". CAL_CONFIG;
if(!$result = $db->sql_query($sql))
{
message_die(GENERAL_ERROR, "Couldn't query calendar config table", "", __LINE__, __FILE__, $sql);
}
else
{
while( $row = $db->sql_fetchrow($result) )
{
$cal_config[$row['config_name']] = $row['config_value'];
}
}
// End of Calendar settings
// Interim days id to help with transfer to $lang['datetime'] format.
// DO NOT CHANGE THESE!!!!!!!!!!!!!!!!
$langdays[0] = $lang['datetime']['Sunday'];
$langdays[1] = $lang['datetime']['Monday'];
$langdays[2] = $lang['datetime']['Tuesday'];
$langdays[3] = $lang['datetime']['Wednesday'];
$langdays[4] = $lang['datetime']['Thursday'];
$langdays[5] = $lang['datetime']['Friday'];
$langdays[6] = $lang['datetime']['Saturday'];
$langdays[7] = $lang['datetime']['Sunday']; // Repeated to cover a Monday start
// Set Users permissions.
if ($userdata['user_level'] == 1) {
$caluser = 5;
}
else {
$test = $userdata['user_id'];
$caluser = calendarperm($test); // Set the user level for the user.
}
if ( $userdata['session_logged_in'] ) {
$lvd = sprintf($lang['You_last_visit'], create_date($board_config['default_dateformat'], $userdata['user_lastvisit'], $board_config['board_timezone']));
}
else {
$lvd = "Not Logged In";
}
include ($phpbb_root_path . "includes/page_header.php");
// Set Calendar Home URL (used in all templates)
$homeurl = append_sid($thisscript);
if ($cal_config['show_headers'] == 1) {
$ct = sprintf($lang['Current_time'], create_date($board_config['default_dateformat'], time(), $board_config['board_timezone']));
if ( $userdata['session_logged_in'] ) {
$lvd = sprintf($lang['You_last_visit'], create_date($board_config['default_dateformat'], $userdata['user_lastvisit'], $board_config['board_timezone']));
}
else {
$lvd = "Not Logged In";
}
$phpbbheaders = '<span class=gensmall>'. $lvd ."<br>\n";
$phpbbheaders .= $ct.'<br></span>';
}
else {
$phpbbheaders = '';
}
// Public Access check
if ($cal_config['allow_anon'] != '1' && ($userdata['user_id'] == '-1' || $caluser == 0 || !$userdata)) {
$er_msg = $lang['Cal_not_enough_access']."<br />\n";
$er_msg .= $lang['Cal_must_member'];
message_die(GENERAL_MESSAGE, $er_msg);
}
// Default date
if ($userdata && $userdata['user_id'] != '-1') {
if (!$day) { $day = create_date("j", time(), $userdata['user_timezone']); }
if (!$month) { $month = create_date("m", time(), $userdata['user_timezone']); }
if (!$year) { $year = create_date("Y", time(), $userdata['user_timezone']); }
}
else {
if (!$day) { $day = create_date("j", time(), $userdata[board_timezone]); }
if (!$month) { $month = create_date("m", time(), $userdata[board_timezone]); }
if (!$year) { $year = create_date("Y", time(), $userdata[board_timezone]); }
}
$lastday = 1;
while (checkdate($month,$lastday,$year))
{
$lastday++;
}
if ($mode == 'validate' && $caluser >=5) { validate(); }
elseif ($mode == 'display') { display(); }
elseif ($action == 'Delete_marked' && $caluser >= 4 ) { delete_marked(); }
elseif ($action == 'Modify_marked' && $caluser >= 4 ) { modify_marked(); }
elseif ($action == 'Cal_add_event' && $caluser >= 2 ) { cal_add_event(); }
elseif ($action == 'Addsucker') { addsucker($modify); }
else { defaultview($todaycolor); }
include_once($phpbb_root_path . 'includes/page_tail.php');
exit;
function validate()
{
// Start of MOD function (validate untrusted events)
global $thisscript, $phpbb_root_path, $phpEx, $db, $action, $template,
$id, $day, $month, $year, $userdata, $lang, $config_footer, $footer, $caluser,
$endday, $endmonth, $endyear, $homeurl, $board_config, $cal_config, $phpbbheaders;
if ($caluser >= 5)
{
switch ($action)
{
case "validevent":
// Validate the selected events.
if (!$id)
{
message_die(GENERAL_MESSAGE, $lang['Cal_must_sel_event'], '', __LINE__, __FILE__, '');
}
// $id is an array where checkboxes
while (list($thisid,$value) = each($id)) {
$sql = '';
if ($value=='yes') {
$sql = "UPDATE ".CAL_TABLE." SET valid = 'yes' WHERE id = '$thisid'";
}
elseif ($value=='del') {
$sql = "DELETE FROM ".CAL_TABLE." WHERE id = '$thisid'";
}
if($sql) {
if ( !($query = $db->sql_query($sql)) ) {
message_die(GENERAL_ERROR, 'Could not validate events', '', __LINE__, __FILE__, $sql);
}
}
}
$message = $lang['Cal_event_validated'];
$url = append_sid($thisscript."?month=".$month."&year=".$year);
$message .= "</br></br><a href='".$url."'>".$lang['Cal_back2cal']."</a>";
message_die(GENERAL_MESSAGE, $message, '', __LINE__, __FILE__, '');
// end of case
break;
case "getlist":
// Get the list of events waiting to be validated and display them for selection
$sql = "SELECT * FROM ".CAL_TABLE." WHERE valid='no' ORDER BY stamp";
if ( !($query = $db->sql_query($sql)) ) {
message_die(GENERAL_ERROR, 'Could not get events list to validate', '', __LINE__, __FILE__, $sql);
}
$url = append_sid($thisscript."?month=".$month."&year=".$year);
$template->set_filenames(array(
'body' => 'cal_validate_events_lite.tpl')
);
$template->assign_vars(array(
'VALIDATE' => $lang['Validate'],
'SELECT' => $lang['Select'],
'SUBJECT' => $lang['Subject'],
'DATE' => $lang['Date'],
'END_DATE' => $lang['End_day'],
'AUTHOR' => $lang['Username'],
'BUTTON_HOME' => button_main($url, $lang['Cal_back2cal'], 'center'))
);
if ($max_query < 5) $max_query = 5;
$max_height = $max_query * 12;
$template->assign_vars(array(
'PHPBBHEADER' => $phpbbheaders,
'S_POST_ACTION' => $thisscript,
'CAL_VERSION' => 'Ver: '.$cal_version,
'TODAY' => append_sid("calendar.$phpEx"),
'L_TODAY' => $lang['Today'],
'CALENDAR' => $lang['Calendar'],
'L_CAL_NEW' => $lang['Cal_add_event'],
'U_INDEX' => append_sid("index.$phpEx"),
'L_INDEX' => sprintf($lang['Forum_Index'], $board_config['sitename']),
'U_CAL_HOME' => $homeurl,
'MAX_HEIGHT' => 'height=' . $max_height . 'px')
);
$i = 0;
while ($row = $db->sql_fetchrow($query))
{
$options = "<select name=id[".$row['id']."]>
<option value='hold' SELECTED>Hold</option>
<option value='yes'>Accept</option>
<option value='del'>Deny</option>
</select>";
$zdesc = stripslashes($row['description']);
$bbcode_uid = $row['bbcode_uid'];
if( $board_config['allow_bbcode'] ) {
$zdesc = ( $board_config['allow_bbcode'] ) ? bbencode_second_pass($zdesc, $bbcode_uid) : preg_replace("/\:[0-9a-z\:]+\]/si", "]", $zdesc);
}
if ( $board_config['allow_smilies'] )
{
$zdesc = smilies_pass($zdesc);
}
$zsujet = stripslashes($row['subject']);
$template->assign_block_vars('event_row', array(
'SELECT' => $options,
'SUBJECT' => $zsujet,
'DATE' => mydateformat($row['stamp'], $userdata['user_dateformat']),
'END_DATE' => mydateformat($row['eventspan'], $userdata['user_dateformat'], 1),
'AUTHOR' => stripslashes($row['username']),
'DESC' => $zdesc)
);
$i++;
}
if($i == 0)
{
$template->assign_block_vars('no_events', array(
'NO_EVENTS' => $lang['No records'])
);
$submit_button = '';
}
else {
$submit_button = "<input type='submit' accesskey='s' tabindex='6' name='post' class='mainoption' value='".$lang['Submit']."' />";
}
$template->assign_vars(array(
'SUBMIT' => $submit_button)
);
$template->pparse('body');
break;
}
}
else
{
message_die(GENERAL_MESSAGE, $lang['Cal_delete_event'], '', __LINE__, __FILE__, '');
}
return;
}
function delete_marked()
{
global $thisscript, $phpbb_root_path, $phpEx, $action,
$id, $day, $month, $year, $userdata, $lang, $config_footer, $footer, $caluser,
$endday, $endmonth, $endyear, $homeurl, $db;
if ($caluser >= 4)
{
if (!$id)
{
message_die(GENERAL_ERROR, $lang['Cal_must_sel_event'], '', __LINE__, __FILE__, $sql);
}
$sql = "SELECT id, user_id FROM ".CAL_TABLE." WHERE id = '$id'";
if ($caluser < 5) {
$sql .= " AND user_id = '".$userdata['user_id']."'";
}
if ( !($query = $db->sql_query($sql)) ) {
message_die(GENERAL_ERROR, 'Could not select event to delete from Table', '', __LINE__, __FILE__, $sql);
}
$row = $db->sql_fetchrow($query);
if ($row['id'] != '') {
$sql = "DELETE FROM ".CAL_TABLE." WHERE id = '$id'";
if ( !($query = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could Not delete event from Table', '', __LINE__, __FILE__, $sql);
}
else {
$url = append_sid($thisscript);
$message = $lang['Cal_event_delete']. "<br><br><a href='".$url."'>".$lang['Cal_back2cal']."</a>";
message_die(GENERAL_MESSAGE, $message, '', __LINE__, __FILE__, $sql);
}
}
else
{
// Failed
message_die(GENERAL_ERROR, $lang['Cal_delete_event'], '', __LINE__, __FILE__, $sql);
}
}
else
{
// Failed
message_die(GENERAL_ERROR, $lang['Cal_delete_event'], '', __LINE__, __FILE__, $sql);
}
return;
}
function modify_marked()
{
global $html_entities_match, $html_entities_replace;
global $thisscript, $board_config, $phpbb_root_path, $phpEx, $action, $lastday, $phpbbheaders,
$id, $day, $month, $year, $userdata, $lang, $config_footer, $footer, $caluser, $cal_config,
$endday, $endmonth, $endyear, $bbcode_uid, $homeurl, $db, $template;
include_once($phpbb_root_path . 'includes/functions_post.'.$phpEx);
if ($caluser >= 4)
{
if (!$id)
{
message_die(GENERAL_ERROR, $lang['Cal_must_sel_event'], '', __LINE__, __FILE__, '');
}
$sql = "SELECT *, SUBSTRING(stamp FROM 12 FOR 5) AS thetime,
SUBSTRING(stamp FROM 9 FOR 2) AS theday,
SUBSTRING(eventspan FROM 9 FOR 2) AS theendday,
SUBSTRING(stamp FROM 6 FOR 2) AS themonth,
SUBSTRING(eventspan FROM 6 FOR 2) AS theendmonth,
SUBSTRING(stamp FROM 1 FOR 4) AS theyear,
SUBSTRING(eventspan FROM 1 FOR 4) AS theendyear
FROM ".CAL_TABLE." WHERE id = '$id'";
if ( !($query = $db->sql_query($sql)) )
{
// CHECK echo "<B>".mysql_error()."</B><BR><BR>"; exit;
message_die(GENERAL_ERROR, 'Could not select event to modify from Table', '', __LINE__, __FILE__, $sql);
}
$row = $db->sql_fetchrow($query);
if ($caluser == 5 || $userdata['user_id'] == $row['user_id'])
{
$bbcode_uid = $row['bbcode_uid'];
$zdesc = ereg_replace("<br />", "", $row['description']);
$zdesc = preg_replace("/\:(([a-z0-9]:)?)" . $bbcode_uid . "/si", "", $zdesc);
$hidden_form_fields = "<input type=hidden name=id value='".$row['id']."'>
<input type=hidden name=bbcode_uid value='".$row['bbcode_uid']."'>
<input type=hidden name=modify value='Modify'>";
generate_smilies('inline', PAGE_POSTING);
$template->set_filenames(array(
'body' => 'cal_posting_body_lite.tpl')
);
$template->assign_vars(array(
'PHPBBHEADER' => $phpbbheaders,
'CAL_VERSION' => 'Ver: '.$cal_config['version'],
'CALENDAR' => $lang['Calendar'],
'L_CAL_NEW' => $lang['Cal_mod_marked'],
'U_INDEX' => append_sid("index.$phpEx"),
'L_INDEX' => sprintf($lang['Forum_Index'], $board_config['sitename']),
'U_CAL_HOME' => $homeurl)
);
$template->assign_vars(array(
'SUBJECT' => $row['subject'],
'MESSAGE' => stripslashes($zdesc),
'L_SUBJECT' => $lang['Subject'],
'L_MESSAGE_BODY' => $lang['Cal_description'],
'L_SUBMIT' => $lang['Cal_mod_only'],
'L_CANCEL' => $lang['Cancel'],
'L_BBCODE_B_HELP' => $lang['bbcode_b_help'],
'L_BBCODE_I_HELP' => $lang['bbcode_i_help'],
'L_BBCODE_U_HELP' => $lang['bbcode_u_help'],
'L_BBCODE_Q_HELP' => $lang['bbcode_q_help'],
'L_BBCODE_C_HELP' => $lang['bbcode_c_help'],
'L_BBCODE_L_HELP' => $lang['bbcode_l_help'],
'L_BBCODE_O_HELP' => $lang['bbcode_o_help'],
'L_BBCODE_P_HELP' => $lang['bbcode_p_help'],
'L_BBCODE_W_HELP' => $lang['bbcode_w_help'],
'L_BBCODE_A_HELP' => $lang['bbcode_a_help'],
'L_BBCODE_S_HELP' => $lang['bbcode_s_help'],
'L_BBCODE_F_HELP' => $lang['bbcode_f_help'],
'L_EMPTY_MESSAGE' => $lang['Empty_message'],
'L_FONT_COLOR' => $lang['Font_color'],
'L_COLOR_DEFAULT' => $lang['color_default'],
'L_COLOR_DARK_RED' => $lang['color_dark_red'],
'L_COLOR_RED' => $lang['color_red'],
'L_COLOR_ORANGE' => $lang['color_orange'],
'L_COLOR_BROWN' => $lang['color_brown'],
'L_COLOR_YELLOW' => $lang['color_yellow'],
'L_COLOR_GREEN' => $lang['color_green'],
'L_COLOR_OLIVE' => $lang['color_olive'],
'L_COLOR_CYAN' => $lang['color_cyan'],
'L_COLOR_BLUE' => $lang['color_blue'],
'L_COLOR_DARK_BLUE' => $lang['color_dark_blue'],
'L_COLOR_INDIGO' => $lang['color_indigo'],
'L_COLOR_VIOLET' => $lang['color_violet'],
'L_COLOR_WHITE' => $lang['color_white'],
'L_COLOR_BLACK' => $lang['color_black'],
'L_FONT_SIZE' => $lang['Font_size'],
'L_FONT_TINY' => $lang['font_tiny'],
'L_FONT_SMALL' => $lang['font_small'],
'L_FONT_NORMAL' => $lang['font_normal'],
'L_FONT_LARGE' => $lang['font_large'],
'L_FONT_HUGE' => $lang['font_huge'],
'L_BBCODE_CLOSE_TAGS' => $lang['Close_Tags'],
'L_STYLES_TIP' => $lang['Styles_tip'],
'S_POST_ACTION' => append_sid($thisscript."?action=Addsucker"),
'S_HIDDEN_FORM_FIELDS' => $hidden_form_fields)
);
// Day field
$this_day = create_day_drop($row['theday'], 31);
// Month field
$this_month = create_month_drop($row['themonth'], $row['theyear']);
// Year field
$this_year = create_year_drop($row['theyear']);
// End Day field
$end_day = create_day_drop($row['theendday'], 31);
// End Month field
$end_month = create_month_drop($row['theendmonth'], $row['theendyear']);
// End Year field
$end_year = create_year_drop($row['theendyear']);
$currentmonth = create_date("m", time(), $userdata['user_timezone']);
$the_time = ($row['thetime'] != '00:00') ? $row['thetime'] : '';
// Set the rest of the Calendar fields
$template->assign_vars(array(
'L_CAL_DATE' => $lang['Cal_day'],
'L_CAL_TIME' => $lang['Cal_hour'],
'L_CAL_END_DATE' => $lang['End_day'],
'THIS_DAY' => $this_day,
'THIS_MONTH' => $this_month,
'THIS_YEAR' => $this_year,
'TIME' => $the_time,
'END_DAY' => $end_day,
'END_MONTH' => $end_month,
'END_YEAR' => $end_year,
'L_CAL_HOME' => $lang['Cal_back2cal'])
);
$template->pparse('body');
return;
}
else
{
message_die(GENERAL_ERROR, $lang['Cal_edit_own_event'], '', __LINE__, __FILE__, $sql);
}
}
else
{
message_die(GENERAL_ERROR, $lang['Cal_not_enough_access'], '', __LINE__, __FILE__, $sql);
}
return;
}
function cal_add_event()
{
global $thisscript, $phpbb_root_path, $phpEx, $board_config, $action, $cal_config,
$id, $day, $month, $year, $userdata, $lang, $caluser, $lastday, $phpbbheaders,
$endday, $endmonth, $endyear, $bbcode_uid, $db, $template, $homeurl;
if ($caluser >= 2) {
$currentday = create_date("j", time(), $userdata['user_timezone']);
if ($day) { $currentday = $day; }
include_once($phpbb_root_path . 'includes/functions_post.'.$phpEx);
generate_smilies('inline', PAGE_POSTING);
$template->set_filenames(array(
'body' => 'cal_posting_body_lite.tpl')
);
$template->assign_vars(array(
'PHPBBHEADER' => $phpbbheaders,
'CAL_VERSION' => 'Ver: '.$cal_config['version'],
'CALENDAR' => $lang['Calendar'],
'L_CAL_NEW' => $lang['Cal_add_event'],
'U_INDEX' => append_sid("index.$phpEx"),
'L_INDEX' => sprintf($lang['Forum_Index'], $board_config['sitename']),
'U_CAL_HOME' => $homeurl)
);
$template->assign_vars(array(
'SUBJECT' => $subject,
'MESSAGE' => $message,
'L_SUBJECT' => $lang['Subject'],
'L_MESSAGE_BODY' => $lang['Cal_description'],
'L_SUBMIT' => $lang['Submit'],
'L_CANCEL' => $lang['Cancel'],
'L_BBCODE_B_HELP' => $lang['bbcode_b_help'],
'L_BBCODE_I_HELP' => $lang['bbcode_i_help'],
'L_BBCODE_U_HELP' => $lang['bbcode_u_help'],
'L_BBCODE_Q_HELP' => $lang['bbcode_q_help'],
'L_BBCODE_C_HELP' => $lang['bbcode_c_help'],
'L_BBCODE_L_HELP' => $lang['bbcode_l_help'],
'L_BBCODE_O_HELP' => $lang['bbcode_o_help'],
'L_BBCODE_P_HELP' => $lang['bbcode_p_help'],
'L_BBCODE_W_HELP' => $lang['bbcode_w_help'],
'L_BBCODE_A_HELP' => $lang['bbcode_a_help'],
'L_BBCODE_S_HELP' => $lang['bbcode_s_help'],
'L_BBCODE_F_HELP' => $lang['bbcode_f_help'],
'L_EMPTY_MESSAGE' => $lang['Empty_message'],
'L_FONT_COLOR' => $lang['Font_color'],
'L_COLOR_DEFAULT' => $lang['color_default'],
'L_COLOR_DARK_RED' => $lang['color_dark_red'],
'L_COLOR_RED' => $lang['color_red'],
'L_COLOR_ORANGE' => $lang['color_orange'],
'L_COLOR_BROWN' => $lang['color_brown'],
'L_COLOR_YELLOW' => $lang['color_yellow'],
'L_COLOR_GREEN' => $lang['color_green'],
'L_COLOR_OLIVE' => $lang['color_olive'],
'L_COLOR_CYAN' => $lang['color_cyan'],
'L_COLOR_BLUE' => $lang['color_blue'],
'L_COLOR_DARK_BLUE' => $lang['color_dark_blue'],
'L_COLOR_INDIGO' => $lang['color_indigo'],
'L_COLOR_VIOLET' => $lang['color_violet'],
'L_COLOR_WHITE' => $lang['color_white'],
'L_COLOR_BLACK' => $lang['color_black'],
'L_FONT_SIZE' => $lang['Font_size'],
'L_FONT_TINY' => $lang['font_tiny'],
'L_FONT_SMALL' => $lang['font_small'],
'L_FONT_NORMAL' => $lang['font_normal'],
'L_FONT_LARGE' => $lang['font_large'],
'L_FONT_HUGE' => $lang['font_huge'],
'L_BBCODE_CLOSE_TAGS' => $lang['Close_Tags'],
'L_STYLES_TIP' => $lang['Styles_tip'],
'S_POST_ACTION' => append_sid($thisscript."?action=Addsucker"),
'S_HIDDEN_FORM_FIELDS' => '')
);
// Day field
$this_day = create_day_drop($currentday, 31);
// Month field
$this_month = create_month_drop($month, $year);
// Year field
$this_year = create_year_drop($year);
// End Day field
$end_day = create_day_drop($currentday, 31);
// End Month field
$end_month = create_month_drop($month, $year);
// End Year field
$end_year = create_year_drop($year);
$currentmonth = create_date("m", time(), $userdata['user_timezone']);
// Set the rest of the Calendar fields
$template->assign_vars(array(
'L_CAL_DATE' => $lang['Cal_day'],
'L_CAL_TIME' => $lang['Cal_hour'],
'L_CAL_END_DATE' => $lang['End_day'],
'THIS_DAY' => $this_day,
'THIS_MONTH' => $this_month,
'THIS_YEAR' => $this_year,
'END_DAY' => $end_day,
'END_MONTH' => $end_month,
'END_YEAR' => $end_year,
'L_CAL_HOME' => $lang['Cal_back2cal'])
);
$template->pparse('body');
return;
}
else
{
message_die(GENERAL_ERROR, $lang['Cal_not_enough_access'], '', __LINE__, __FILE__, '');
}
}
function addsucker( $modify='')
{
global $html_entities_match, $html_entities_replace;
global $thisscript, $phpbb_root_path, $phpEx, $db, $template, $action, $phpbbheaders,
$board_config, $cal_config, $id, $day, $month, $year, $time, $userdata, $modify, $lang, $description, $subject, $caluser,
$endday, $endmonth, $endyear, $bbcode_uid, $homeurl;
if (($subject =='') || ($description ==''))
{
// Nothing in the subject line: Reject it.
message_die(GENERAL_ERROR, $lang['No information'], '', __LINE__, __FILE__, '');
}
$currentdate = time();
// Valid Start Date?
if (!checkdate($month,$day,$year)) {
message_die(GENERAL_ERROR, $lang['Invalid date']);
}
// Valid End Date?
if (!checkdate($endmonth,$endday,$endyear)) {
message_die(GENERAL_ERROR, $lang['Invalid date']);
}
// Valid Time?
$hour = substr($time, 0,2);
$symbol = substr($time,2,1);
$minute = substr($time,3,2);
if (!empty($time)) {
if(!is_numeric($hour) || $hour < 0 || $hour > 23) {
$err_time = true;
}
elseif(!is_numeric($minute) || $minute < 0 || $minute > 59) {
$err_time = true;
}
else {
unset($err_time);
}
if(isset($err_time)) {
message_die(GENERAL_ERROR, ("Invalid ". $lang['Cal_hour']));
}
}
// Check that date info has been set.
if ($month != '' && $day != '' && $year != '' && $endmonth != '' && $endday != '' && $endyear != '') {
$submitdate = mktime (23,59,59,$month,$day,$year);
$submitenddate = mktime (23,59,59,$endmonth,$endday,$endyear);
}
else {
message_die(GENERAL_ERROR, $lang['No date']);
}
if (($currentdate > $submitdate) && !$cal_config['allow_old'])
{
// Nothing in the subject line: Reject it.
message_die(GENERAL_ERROR, $lang['Date before today'], '', __LINE__, __FILE__, '');
}
if ($submitdate > $submitenddate)
{
message_die(GENERAL_ERROR, $lang['Date before start'], '', __LINE__, __FILE__, '');
}
include_once($phpbb_root_path . 'includes/functions_post.'.$phpEx);
if (!$bbcode_uid) { $bbcode_uid = make_bbcode_uid(); }
// PREPARE MESSAGE
$description = prepare_message($description,
$board_config['allow_html'],
$board_config['allow_bbcode'],
$board_config['allow_smilies'],
$bbcode_uid);
$description = nl2br($description);
$description = addslashes($description);
// Get rid of any commas in your subject field (causes untold problems with the HTML form)
$subject = ereg_replace("[\"]", "", $subject);
$subject = addslashes($subject);
$valid = 'no';
if ($caluser >= 3) {
$valid = 'yes';
}
if ($modify)
{
ereg_replace("<br />", "", $description);
$sql = "UPDATE ".CAL_TABLE." SET stamp='$year-$month-$day $time', subject='$subject', description='$description', eventspan='$endyear-$endmonth-$endday', bbcode_uid='$bbcode_uid' WHERE id = '$id'";
}
else
{
$sql = "INSERT INTO ".CAL_TABLE." (username, stamp, subject, description, user_id, valid, eventspan, bbcode_uid) VALUES ('".addslashes($userdata[username])."', '$year-$month-$day $time', '$subject', '$description', '".$userdata['user_id']."', '$valid', '$endyear-$endmonth-$endday', '$bbcode_uid')";
}
if ( !($query = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, $lang['Cal_event_not_add'], '', __LINE__, __FILE__, $sql);
}
else
{
// Success the event is now pending or actually added.
// Temp measure until the language files all get updated.
$lang['Cal_add4valid'] = (!empty($lang['Cal_add4valid'])) ? $lang['Cal_add4valid'] : 'Event submitted for validation by an Administrator';
$l_add = ($valid != 'no') ? $lang['Cal_event_add'] : $lang['Cal_add4valid'];
$url = append_sid($thisscript);
$message = $l_add. "</br></br><a href='".$url."'>".$lang['Cal_back2cal']."</a>";
message_die(GENERAL_MESSAGE, $message, '', __LINE__, __FILE__, $sql);
}
}
function display()
{
global $thisscript, $phpbb_root_path, $phpEx, $action, $homeurl, $images, $phpbbheaders,
$id, $day, $month, $year, $userdata, $lang, $config_footer, $footer, $caluser,
$endday, $endmonth, $endyear, $board_config, $bbcode_uid, $template, $db, $cal_config;
$currentmonth = create_date("m", time(), $userdata['user_timezone']);
$template->set_filenames(array(
'body' => 'cal_day_events_lite.tpl')
);
$lastseconds = mktime(0,0,0,$month,$day,$year)-(24*60*60);
$lastday = date('j', $lastseconds);
$lastmonth = date('m', $lastseconds);
$lastyear = date('Y', $lastseconds);
$nextseconds = mktime(0,0,0,$month,$day,$year)+(24*60*60);
$nextday = date('j', $nextseconds);
$nextmonth = date('m', $nextseconds);
$nextyear = date('Y', $nextseconds);
$sql = "SELECT * FROM ".CAL_TABLE." WHERE valid = 'yes' AND ";
if ($id) {
$sql .= "id = '$id'";
}
else {
$sql .= "eventspan >= \"$year-$month-$day 00:00:00\" AND stamp <= \"$year-$month-$day 23:59:59\" ORDER BY stamp";
}
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not select Event data', '', __LINE__, __FILE__, $sql);
}
$check=0;
while ($row = $db->sql_fetchrow($result))
{
$subject=stripslashes($row['subject']);
$zdesc=stripslashes($row['description']);
$bbcode_uid = $row['bbcode_uid'];
if( $board_config['allow_bbcode'] ) {
$zdesc = ( $board_config['allow_bbcode'] ) ? bbencode_second_pass($zdesc, $bbcode_uid) : preg_replace("/\:[0-9a-z\:]+\]/si", "]", $zdesc);
}
if ( $board_config['allow_smilies'] )
{
$zdesc = smilies_pass($zdesc);
}
if ((($caluser >=4) && ($userdata['user_id']==$row['user_id'])) || ($caluser >=5)) {
// Edit icon
if (strtotime($row['stamp']) >= time() || $cal_config['allow_old']) {
$edit_img = '<a href="'. append_sid($thisscript .'?action=Modify_marked&id='.$row['id']) .'"><img src="' . $images['icon_edit'] . '" alt="' . $lang['Edit_delete_post'] . '" title="' . $lang['Edit_delete_post'] . '" border="0" /></a>';
}
// Delete icon
$delpost_img = '<a href="' . append_sid($thisscript .'?action=Delete_marked&id='.$row['id']).'"><img src="' . $images['icon_delpost'] . '" alt="' . $lang['Delete_post'] . '" title="' . $lang['Delete_post'] . '" border="0" /></a>';
}
else {
$edit_img = '';
$delpost_img = '';
}
$zdesc = make_clickable($zdesc);
$start_date = mydateformat($row['stamp'], $userdata['user_dateformat']);
$end_date = mydateformat($row['eventspan'], $userdata['user_dateformat'], 1);
$template->assign_block_vars('event_row', array(
'SUBJECT' => $subject,
'DATE' => $start_date,
'END_DATE' => $end_date,
'AUTHOR' => stripslashes($row['username']),
'DESC' => $zdesc,
'BUTTON_DEL' => $delpost_img,
'BUTTON_MOD' => $edit_img)
);
$check++;
//echo $row['stamp']; exit;
}
if($check == 0)
{
$template->assign_block_vars('no_events', array(
'NO_EVENTS' => $lang["No events"])
);
}
// Previous Month button
$url = append_sid($thisscript."?day=".$lastday."&month=".$lastmonth."&year=".$lastyear."&mode=display");
$button_prev = button_prev($url);
// Viewed month link
$monthname = $lang['datetime'][date("F", mktime(0,0,0,$month,1,$year))];
$select_month_url = append_sid($thisscript."?month=".$month."&year=".$year);
// Home Button
$curmonthname = $lang['datetime'][date("F", mktime(0,0,0,$currentmonth,1,$year))];
$url = append_sid($thisscript."?month=".$currentmonth."&year=".$year);
$button_home = button_main($url, $lang['Cal_back2cal'], 'center');
// Next Month button.
$url = append_sid($thisscript."?day=".$nextday."&month=".$nextmonth."&year=".$nextyear."&mode=display");
$button_next = button_next($url);
if ($caluser >= 2) {
// Add button
$url = append_sid($thisscript."?day=".$day."&month=".$month."&year=".$year."&action=Cal_add_event");
$button_add = button_add($url);
// Validate button
$url = append_sid($thisscript."?mode=validate&action=getlist");
$button_val = button_validate($url);
}
$template->assign_vars(array(
'PHPBBHEADER' => $phpbbheaders,
'CAL_VERSION' => 'Ver: '.$cal_config['version'],
'CALENDAR' => $lang['Calendar'],
'L_CAL_NEW' => $lang['Cal_add_event'],
'U_INDEX' => append_sid("index.$phpEx"),
'L_INDEX' => sprintf($lang['Forum_Index'], $board_config['sitename']),
'U_CAL_HOME' => $homeurl)
);
$template->assign_vars(array(
'CAL_MONTH' => " <a href='$select_month_url' class='topictitle'> $monthname </a>",
'CAL_YEAR' => $year,
'CAL_DAY' => $day,
'SUBJECT' => $lang['Subject'],
'DATE' => $lang['Date'],
'END_DATE' => $lang['End_day'],
'AUTHOR' => $lang['Author'],
'BUTTON_PREV' => $button_prev,
'BUTTON_NEXT' => $button_next,
'BUTTON_HOME' => $button_home,
'BUTTON_ADD' => $button_add,
'BUTTON_VAL' => $button_val)
);
$template->pparse('body');
return;
}
// End Display
// End Display
// The default display (ie: The main calendar screen)
function defaultview()
{
global $thisscript, $phpbb_root_path, $phpEx, $action, $phpbbheaders,
$board_config, $cal_config, $id, $day, $month, $year, $userdata, $lang, $description, $subject, $caluser,
$endday, $endmonth, $endyear, $langdays, $template, $db, $homeurl;
if ($userdata && $userdata['user_id'] != '-1')
{
$currentday = create_date("j", time(), $userdata['user_timezone']);
$currentmonth = create_date("m", time(), $userdata['user_timezone']);
$currentyear = create_date("Y", time(), $userdata['user_timezone']);
}
else
{
$currentday = create_date("j", time(), $board_config['board_timezone']);
$currentmonth = create_date("m", time(), $board_config['board_timezone']);
$currentyear = create_date("Y", time(), $board_config['board_timezone']);
}
if ($cal_config['show_birthdays'] == 1)
{
$username = array();
$user_id = array();
$birthday = array();
$birthmonth = array();
$useryear = array();
$ii = 0;
$sql = "SELECT username, user_id, user_birthday
FROM " . USERS_TABLE . "
WHERE user_birthday < '999999'
ORDER BY username";
if( ($result = $db->sql_query($sql)) )
{
while( $row = $db->sql_fetchrow($result))
{
$ii++;
$username[$ii] = $row['username'];
$user_id[$ii] = $row['user_id'];
$birthday[$ii] = realdate('j', $row['user_birthday']);
$birthmonth[$ii] = realdate('m', $row['user_birthday']);
$useryear[$ii] = realdate('Y', $row['user_birthday']);
}
}
}
$lastday = 1;
$pt = '*';
if (!$month) {
$month = $currentmonth;
$year = $currentyear;
}
else if($month < 10) {
$month = date('m', mktime(0,0,0,$month,1,$year));
}
$template->set_filenames(array(
'body' => 'cal_view_month_lite.tpl')
);
$firstday = (date('w', (mktime(0,0,0,$month,1,$year))) - $cal_config['week_start']) % 7;
$firstday = ($firstday < 0) ? ($firstday + 7) : $firstday;
$lastday = date('t', mktime(0,0,0,$month,1,$year));
$end_day = 7-(($firstday + $lastday) % 7);
$end_day = ($end_day == 7) ? 0 : $end_day; // day 7 same as day 0
$nextmonth = ($month < 12) ? ($month + 1) : 1;
$nextyear = ($month < 12) ? $year : ($year + 1);
$lastmonth = ($month > 1) ? ($month - 1) : 12;
$lastyear = ($month > 1) ? $year: ($year - 1);
$template->assign_vars(array(
'PHPBBHEADER' => $phpbbheaders,
'CAL_MONTH' => $lang['datetime'][date("F", mktime(0,0,0,$month,1,$year))],
'CAL_YEAR' => $year,
'DAY_HEAD_1' => $langdays[(0+$cal_config['week_start'])%7],
'DAY_HEAD_2' => $langdays[(1+$cal_config['week_start'])%7],
'DAY_HEAD_3' => $langdays[(2+$cal_config['week_start'])%7],
'DAY_HEAD_4' => $langdays[(3+$cal_config['week_start'])%7],
'DAY_HEAD_5' => $langdays[(4+$cal_config['week_start'])%7],
'DAY_HEAD_6' => $langdays[(5+$cal_config['week_start'])%7],
'DAY_HEAD_7' => $langdays[(6+$cal_config['week_start'])%7])
);
$rowrow = 1;
$lastday = date('t', mktime(0,0,0,$month,1,$year));
// New optimised SQL query
$sql = "SELECT * FROM ". CAL_TABLE ."
WHERE valid = 'yes' AND eventspan >= '$year-$month-1' AND stamp <= '$year-$month-$lastday 23:59:59'
ORDER BY stamp";
if ( !($query = $db->sql_query($sql)) ) {
echo "<BR>$sql<BR>".mysql_error(); exit;
message_die(GENERAL_ERROR, 'Could not get months data', '', __LINE__, __FILE__, $sql);
}
$dates = array();
while($get_row = $db->sql_fetchrow($query)) {
$dates[] = $get_row;
}
// Changed the range to do ALL the days not require duplicate code later.
$max_query = 0;
for ($i=1; $i <= ($firstday+$lastday+$end_day); $i++) {
if($i <= $firstday) {
$today_year = ($month <= 1) ? $year - 1 : $year;
$today_month = ($month <= 1) ? 12 : $month - 1;
$today_day = (gmdate('t', gmmktime(0,0,0,$today_month,1,$today_year)) - $firstday) + $i;
}
else if($i > ($firstday+$lastday)) {
$today_year = ($month >= 12) ? $year + 1 : $year;
$today_month = ($month >= 12) ? 1 : $month + 1;
$today_day = $i - ($firstday + $lastday);
}
else {
$today_year = $year;
$today_month = $month;
$today_day = $i - $firstday;
}
// calc todays date range
$today_start = date("Y-m-d", mktime(0,0,0,$month,$today_day,$year));
$today_end = date("Y-m-d H:i:s", mktime(23,59,59,$month,$today_day,$year));
//CHECK echo "TS: $today_start , TE: $today_end <BR>";
unset($this_date);
$this_date = array();
for($d_cnt=0; $d_cnt < count($dates); $d_cnt++) {
//CHECK echo "TS: ".$dates[$d_cnt]['stamp']." , TE: ".$dates[$d_cnt]['eventspan']." <BR>";
if( ($dates[$d_cnt]['eventspan'] >= $today_start) && ($dates[$d_cnt]['stamp'] <= $today_end) ) {
// Compile an array of all the events for today
$this_date[] = $dates[$d_cnt];
}
}
$this_date = array_qsort2 ($this_date, 'stamp', SORT_ASC, 0, $last= -2);
$thisday = $i - $firstday;
$event_list = '';
$correction = 0;
if ($cal_config['show_birthdays'] == 1)
{
$ii = 0;
for ($ii; $ii<=count($useryear); $ii++)
{
if ( $birthday[$ii] == $thisday AND $birthmonth[$ii] == $month)
{
$userage = $year - $useryear[$ii];
$correction++;
$event_list .= '<span class="gensmall">-> <a href="' . append_sid("profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . "=$user_id[$ii]") . '">' . $username[$ii] . ' (' . $userage .')</a></span><br />';
}
}
}
$query_num = count($this_date);
if (($query_num + $correction) > $max_query)
{
$max_query = $query_num + $correction;
}
for ($j = 0; $j < $query_num; $j++) {
$results = $this_date[$j];
$subject = stripslashes($results['subject']);
$full_subject = stripslashes($results['subject']);
$subjectnum = '';
// Specific UKRag.net function.
if ( strlen($subject) > $cal_config['subject_length']) {
if ((substr($subject,-3,1) == '(') && (substr($subject,-1,1) == ')')) {
// store the number of permits and tack them on the end of the shortened subject
$subjectnum = substr($subject,-2,1);
$subject = substr($subject, 0, -3);
}
$subject = substr($subject, 0, $cal_config['subject_length']);
$subject .= '..';
}
if ($subjectnum) {
$subject .= ' ('.$subjectnum.')';
}
// End UKRag.net function
$url = append_sid($thisscript.'?id='.$results['id'].'&mode=display&day='.$thisday.'&month='.$today_month.'&year='.$today_year, 1);
// Need to keep the size down
$event_list .= "<span class=gensmall><acronym title='".stripslashes($results['username']).": $full_subject'>
$pt <a href='$url' id='cal_id".$results['id']."' onMouseOver=\"swc('cal_id".$results['id']."',1)\" onMouseOut=\"swc('cal_id".$results['id']."',0)\">
$subject</a></acronym><br></span>\n";
}
// if (($query_num - $correction) < 4) {
// for ($j=0; $j<(4 - ($query_num-$correction)); $j++) {
// $event_list .= '<span class=gensmall>&<br></span>';
// }
// }
if ($i % 7 == 0) {
// we're at the end of a row
// got another week to run
$week_end = "\n</tr>\n<tr>\n";
}
else {
$week_end = '';
}
// Choose which format to use (ie: pre, during or after this month)
if ($i <= $firstday) {
$thisday = '';
$event_list = '';
$cellback = 'class=row1';
$cellhead = 'class=row1';
$cellbody = 'class=row1';
}
else if ($currentmonth == $today_month && $month == $currentmonth && $currentday == $thisday && $currentyear == $year) {
// TODAY
$cellback = 'class=row3';
$cellhead = 'class=rowpic';
$cellbody = 'class=row2';
}
else if ($i > ($firstday + $lastday)) {
// end of the month
$thisday = '';
$event_list = '';
$cellback = 'class=row1';
$cellhead = 'class=row1';
$cellbody = 'class=row1';
}
else {
$cellback = 'class=row3';
$cellhead = 'class=row3';
$cellbody = 'class=row1';
}
$url_day = !empty($thisday) ? append_sid($thisscript."?day=".$thisday."&month=".$month."&year=".$year."&mode=display") : '';
$template->assign_block_vars('daycell', array(
'S_CELL' => $cellback,
'U_DAY' => $url_day,
'NUM_DAY' => $thisday,
'DAY_EVENT_LIST' => $event_list,
'S_HEAD' => $cellhead,
'S_DETAILS' => $cellbody,
'WEEK_ROW' => $week_end)
);
if ($week_end) {
++$rowrow;
if ($rowrow == '3') {
$rowrow = '1';
}
}
}
if ($max_query < 5) $max_query = 5;
$max_height = $max_query * 12;
$template->assign_vars(array(
'CAL_VERSION' => 'Ver: '.$cal_version,
'TODAY' => append_sid("calendar.$phpEx"),
'L_TODAY' => $lang['Today'],
'CALENDAR' => $lang['Calendar'],
'L_CAL_NEW' => $lang['Cal_add_event'],
'U_INDEX' => append_sid("index.$phpEx"),
'L_INDEX' => sprintf($lang['Forum_Index'], $board_config['sitename']),
'U_CAL_HOME' => $homeurl,
'MAX_HEIGHT' => 'height=' . $max_height . 'px')
);
$ny = $nextyear + 1;
$ly = $lastyear - 1;
if ($caluser >= 2)
{
// Previous Year button
$url = append_sid($thisscript."?month=".$month."&year=".$ly);
$button_prev_year = button_prev_year($url);
// Previous Month button
$url = append_sid($thisscript."?month=".$lastmonth."&year=".$lastyear);
$button_prev = button_prev($url);
// Add Event button
$url = append_sid($thisscript."?month=".$month."&year=".$year."&action=Cal_add_event");
$button_add = button_add($url);
// Admin Validate button
$url = append_sid($thisscript."?mode=validate&action=getlist");
$button_validate = button_validate($url);
// Next Month button
$url = append_sid($thisscript."?month=".$nextmonth."&year=".$nextyear);
$button_next = button_next($url);
// Next Year button
$url = append_sid($thisscript."?month=".$month."&year=".$ny);
$button_next_year = button_next_year($url);
}
else
{
// Previous Year button
$url = append_sid($thisscript."?month=".$month."&year=".$ly);
$button_prev_year = button_prev_year($url);
// Previous Month button
$url = append_sid($thisscript."?month=".$lastmonth."&year=".$lastyear);
$button_prev = button_prev($url);
// Next Month button
$url = append_sid($thisscript."?month=".$nextmonth."&year=".$nextyear);
$button_next = button_next($url);
// Next Year button
$url = append_sid($thisscript."?month=".$month."&year=".$ny);
$button_next_year = button_next_year($url);
}
$template->assign_vars(array(
'BUTTON_PREV' => $button_prev,
'BUTTON_PREV_YEAR' => $button_prev_year,
'BUTTON_ADD' => $button_add,
'BUTTON_VALIDATE' => $button_validate,
'BUTTON_NEXT' => $button_next,
'BUTTON_NEXT_YEAR' => $button_next_year)
);
$template->pparse('body');
return;
}
function calendarperm($user_id)
{
global $db, $table_prefix, $cal_config;
// Get the user permissions first.
$sql = 'SELECT user_calendar_perm FROM ' . $table_prefix. 'users WHERE user_id = \''.$user_id.'\'';
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not select Calendar permission from user table', '', __LINE__, __FILE__, $sql);
}
$row = $db->sql_fetchrow($result);
// Get the group permissions second.
$sql2 = 'SELECT group_calendar_perm FROM ' . $table_prefix. 'user_group ug, ' . $table_prefix. "groups g
WHERE ug.user_id = '$user_id' AND g.group_id = ug.group_id";
if ( !($result2 = $db->sql_query($sql2)) )
{
message_die(GENERAL_ERROR, 'Could not select Calendar permission from user/usergroup table', '', __LINE__, __FILE__, $sql2);
}
$topgroup = 0;
while($rowg = $db->sql_fetchrow($result2)) {
if($topgroup < $rowg['group_calendar_perm']) {
$topgroup = $rowg['group_calendar_perm'];
}
}
// Use whichever value is highest.
if ($topgroup > $row['user_calendar_perm']) {
$cal_perm = $topgroup;
}
else {
$cal_perm = $row['user_calendar_perm'];
}
if($cal_config['allow_user_default'] > $cal_perm && $user_id != ANONYMOUS) {
$cal_perm = $cal_config['allow_user_default'];
}
return $cal_perm;
}
function mydateformat($thisdate, $dateformat='d M Y G:i', $span=0)
{
global $cal_config;
if ($cal_config['cal_dateformat']) {
$dateformat = $cal_config['cal_dateformat'];
}
// date comes in as the following:
$myr = substr($thisdate, 0, 4);
$mym = substr($thisdate, 5, 2);
$myd = substr($thisdate, 8, 2);
$myh = substr($thisdate, 11, 2);
$myn = substr($thisdate, 14, 2);
$mys = substr($thisdate, 17, 2);
if ($span || ($myh=='00' && $myn=='00' && $mys=='00')) {
// Need to strip out any TIME references so...
$timerefs = array ('a','A','B','g','G','h','H','i','I','s');
while (list(,$val) = each ($timerefs))
{
$dateformat = ereg_replace($val, "", $dateformat);
}
// strip out any characters used for time
$dateformat = ereg_replace('[:\.]', " ", $dateformat);
}
$returndate = date($dateformat, mktime ($myh,$myn,$mys,$mym,$myd,$myr));
return $returndate;
}
function create_day_drop($day, $lastday)
{
for ($i=1; $i<=$lastday; $i++) {
if ($i == $day) {
$day_drop .= "<option value=$i selected>$i</option>";
}
else {
$day_drop .= "<option value=$i>$i</option>";
}
}
return $day_drop;
}
function create_month_drop($month, $year)
{
global $lang;
for ($i=1; $i<13; $i++) {
$nm = $lang['datetime'][date("F", mktime(0,0,0,$i,1,$year))];
if ($i == $month) {
$mon_drop .= "<option value=$i selected>$nm</option>";
}
else {
$mon_drop .= "<option value=$i>$nm</option>";
}
}
return $mon_drop;
}
function create_year_drop($year)
{
for ($i=$year-2; $i<$year+5; $i++) {
if ($i == $year) {
$yr_drop .= "<option value=$i selected>$i</option>";
}
else {
$yr_drop .= "<option value=$i>$i</option>";
}
}
return $yr_drop;
}
// buttons
function button_main($url, $month, $align='center')
{
global $lang;
$button_main = "<form method=post action='$url'><td align='$align'>\n";
$button_main .= "<input type=submit value='$month' class=mainoption>\n";
$button_main .= "</td></form>";
return $button_main;
}
function button_validate($url)
{
global $lang, $caluser;
if ($caluser >= 5) {
// Validate button
//$url = append_sid($thisscript."?mode=validate&action=getlist");
$button_validate = "<form method=post action='$url'><td>";
$button_validate .= "<input type=submit value='" . $lang['Validate'] . "' class=mainoption>";
$button_validate .= "</td></form>";
}
else {
$button_validate = "";
}
return $button_validate;
}
function button_mod_del($url)
{
global $lang, $caluser;
if ($caluser >= 4) {
// Delete/Modify Button
//$url = append_sid($thisscript."?day=".$day."&month=".$month."&year=".$year."&mode=modify");
$button_mod_del = "<form method=post action=$url><td>";
$button_mod_del .= "<input type=submit value=\"";
if ($caluser >= 5) { $button_mod_del .= $lang['Cal_Del_mod']; }
else { $button_mod_del .= $lang['Cal_mod_only']; }
$button_mod_del .= "\" class=mainoption></td></form>";
}
else {
$button_mod_del = "";
}
return $button_mod_del;
}
function button_add($url)
{
global $lang, $caluser;
// Next Month
$button_add = "<form method=post action='$url'><td>";
$button_add .= "<input type=submit name=zaction value=\"" . $lang['Cal_add_event'] . "\" class=mainoption>";
$button_add .= "</td></form>";
return $button_add;
}
function button_prev($url)
{
// Previous Month
$button_prev = '<a href="'.$url.'"><img src="images/icon_left_arrow.gif" border="0"></a>';
return $button_prev;
}
function button_next($url)
{
// Next Month
$button_next = '<a href="'.$url.'"><img src="images/icon_right_arrow.gif" border="0"></a>';
return $button_next;
}
function button_prev_year($url)
{
// Previous Year
$button_prev = '<a href="'.$url.'"><img src="images/icon_double_left_arrow.gif" border="0"></a>';
return $button_prev;
}
function button_next_year($url)
{
// Next Year
$button_next = '<a href="'.$url.'"><img src="images/icon_double_right_arrow.gif" border="0"></a>';
return $button_next;
}
function array_qsort2 (&$array, $column=0, $order=SORT_ASC, $first=0, $last= -2) {
// $array - the array to be sorted
// $column - index (column) on which to sort
// can be a string if using an associative array
// $order - SORT_ASC (default) for ascending or SORT_DESC for descending
// $first - start index (row) for partial array sort
// $last - stop index (row) for partial array sort
if($last == -2) {
$last = count($array) - 1;
}
if($last > $first) {
$alpha = $first;
$omega = $last;
$guess = $array[$alpha][$column];
while($omega >= $alpha) {
if($order == SORT_ASC) {
while($array[$alpha][$column] < $guess) {
$alpha++;
}
while($array[$omega][$column] > $guess) {
$omega--;
}
} else {
while($array[$alpha][$column] > $guess) {
$alpha++;
}
while($array[$omega][$column] < $guess) {
$omega--;
}
}
if($alpha > $omega) {
break;
}
$temporary = $array[$alpha];
$array[$alpha++] = $array[$omega];
$array[$omega--] = $temporary;
}
array_qsort2 ($array, $column, $order, $first, $omega);
array_qsort2 ($array, $column, $order, $alpha, $last);
}
return $array;
}
?>