📄 calendar.php
字号:
$this_day_events = "";
$cal_date = $day_array['mday'];
if ( isset( $events[$day_array['mday']] ) && is_array( $events[$day_array['mday']] ) && 0 < count( $events[$day_array['mday']] ) )
{
foreach ( $events[$day_array['mday']] as $idx => $data )
{
$this_day_events .= $this->html->cal_events_wrap( "code=showevent&eventid=".$data['eventid'], $data['title'] );
}
}
if ( isset( $birthdays[$day_array['mday']] ) && 0 < $birthdays[$day_array['mday']] )
{
$this_day_events .= $this->html->cal_events_wrap( "code=birthdays&y=".$this->chosen_year."&m=".$this->chosen_month."&d=".$day_array['mday'], sprintf( $ibforums->lang['entry_birthdays'], $birthdays[$day_array['mday']] ) );
}
if ( $this_day_events != "" )
{
$cal_date = "<a href='{$ibforums->base_url}&act=calendar&code=showday&y=".$this->chosen_year."&m=".$this->chosen_month."&d=".$day_array['mday']."'>{$day_array['mday']}</a>";
$this_day_events = $this->html->cal_events_start( ).$this_day_events.$this->html->cal_events_end( );
}
if ( $day_array['mday'] == $this->now_date['mday'] && $this->now_date['mon'] == $day_array['mon'] && $this->now_date['year'] == $day_array['year'] )
{
$cal_output .= $this->html->cal_date_cell_today( $cal_date, $this_day_events );
}
else
{
$cal_output .= $this->html->cal_date_cell( $cal_date, $this_day_events );
}
unset( $this_day_events );
}
}
}
$this->output = str_replace( "<!--IBF.DAYS_TITLE_ROW-->", $day_output, $this->output );
$this->output = str_replace( "<!--IBF.DAYS_CONTENT-->", $cal_output, $this->output );
$this->output = str_replace( "<!--IBF.MONTH_BOX-->", $this->get_month_dropdown( ), $this->output );
$this->output = str_replace( "<!--IBF.YEAR_BOX-->", $this->get_year_dropdown( ), $this->output );
$this->nav[] = "<a href='{$ibforums->base_url}&act=calendar'>{$ibforums->lang['page_title']}</a>";
$this->nav[] = $this->month_words[$this->chosen_month - 1]." ".$this->chosen_year;
}
function new_event( )
{
global $ibforums;
global $DB;
global $std;
global $print;
if ( $ibforums->member['g_calendar_post'] != 1 )
{
$std->error( array( "LEVEL" => 1, "MSG" => "no_permission" ) );
}
if ( !$ibforums->member['id'] )
{
$std->error( array( "LEVEL" => 1, "MSG" => "no_permission" ) );
}
$ibforums->lang['the_max_length'] = $ibforums->vars['max_post_length'] ? $ibforums->vars['max_post_length'] * 1024 : 2140000;
$this->nav[] = "<a href='{$ibforums->base_url}&act=calendar'>{$ibforums->lang['page_title']}</a>";
$this->nav[] = $ibforums->lang['post_new_event'];
$this->output .= $this->post_html->calendar_start_form( );
$this->output .= $this->post_html->table_top( $ibforums->lang['post_new_event'] );
$this->output .= $this->post_html->calendar_event_title( );
$this->output .= $this->post_html->calendar_choose_date( $this->get_day_dropdown( ), $this->get_month_dropdown( ), $this->get_year_dropdown( ) );
$this->output .= $this->post_html->calendar_event_type( );
if ( $ibforums->member['mgroup'] == $ibforums->vars['admin_group'] )
{
$group_choices = "";
$DB->query( "SELECT g_id, g_title FROM ibf_groups ORDER BY g_title" );
while ( $r = $DB->fetch_row( ) )
{
$group_choices .= "<option value='".$r['g_id']."'>".$r['g_title']."</option>\n";
}
$this->output .= $this->post_html->calendar_admin_group_box( $group_choices );
}
$this->output .= $this->post_html->postbox_buttons( "" );
$this->output .= $this->post_html->calendar_end_form( $ibforums->lang['calendar_submit'] );
$show_table = 0;
$count = 0;
$smilies = "<tr align='center'>\n";
$DB->query( "SELECT * FROM ibf_emoticons WHERE clickable='1'" );
while ( $elmo = $DB->fetch_row( ) )
{
++$show_table;
++$count;
if ( strstr( $elmo['typed'], "'" ) )
{
$in_delim = "\"";
$out_delim = "'";
}
else
{
$in_delim = "'";
$out_delim = "\"";
}
$smilies .= "<td><a href={$out_delim}javascript:emoticon({$in_delim}".$elmo['typed']."{$in_delim}){$out_delim}><img src=\"".$ibforums->vars['EMOTICONS_URL']."/".$elmo['image']."\" alt='smilie' border='0'></a> </td>\n";
if ( $count == $ibforums->vars['emo_per_row'] )
{
$smilies .= "</tr>\n\n<tr align='center'>";
$count = 0;
}
}
if ( $count != $ibforums->vars['emo_per_row'] )
{
$i = $count;
for ( ; $i < $ibforums->vars['emo_per_row']; ++$i )
{
$smilies .= "<td> </td>\n";
}
$smilies .= "</tr>";
}
$table = $this->post_html->smilie_table( );
if ( $show_table != 0 )
{
$table = preg_replace( "/<!--THE SMILIES-->/", $smilies, $table );
$this->output = preg_replace( "/<!--SMILIE TABLE-->/", $table, $this->output );
}
$this->output = preg_replace( "/<!--IBF\\.SIG_CLICK-->.+?<!--IBF\\.END_SIG_CLICK-->/s", "", $this->output );
}
function add_new_event( )
{
global $ibforums;
global $DB;
global $std;
global $print;
global $HTTP_POST_VARS;
if ( $ibforums->member['g_calendar_post'] != 1 )
{
$std->error( array( "LEVEL" => 1, "MSG" => "no_permission" ) );
}
if ( !$ibforums->member['id'] )
{
$std->error( array( "LEVEL" => 1, "MSG" => "no_permission" ) );
}
$ibforums->vars['max_post_length'] = $ibforums->vars['max_post_length'] ? $ibforums->vars['max_post_length'] : 2140000;
$allow_emoticons = $ibforums->input['enableemo'] == "yes" ? 1 : 0;
$private_event = $ibforums->input['e_type'] == "private" ? 1 : 0;
if ( strlen( trim( $HTTP_POST_VARS['Post'] ) ) < 1 )
{
$std->error( array( "LEVE" => 1, "MSG" => "no_post" ) );
}
if ( $ibforums->vars['max_post_length'] * 1024 < strlen( $HTTP_POST_VARS['Post'] ) )
{
$std->error( array( "LEVEL" => 1, "MSG" => "post_too_long" ) );
}
$ibforums->input['event_title'] = str_replace( "<br>", "", $ibforums->input['event_title'] );
$ibforums->input['event_title'] = trim( stripslashes( $ibforums->input['event_title'] ) );
if ( strlen( $ibforums->input['event_title'] ) < 2 || !$ibforums->input['event_title'] )
{
$std->error( array( "LEVEL" => 1, "MSG" => "cal_title_none" ) );
}
if ( 64 < strlen( $ibforums->input['event_title'] ) )
{
$std->error( array( "LEVEL" => 1, "MSG" => "cal_title_long" ) );
}
$read_perms = "*";
if ( $ibforums->member['mgroup'] == $ibforums->vars['admin_group'] )
{
if ( is_array( $HTTP_POST_VARS['e_groups'] ) )
{
$read_perms = implode( ",", $HTTP_POST_VARS['e_groups'] );
$read_perms .= ",".$ibforums->vars['admin_group'];
}
if ( $read_perms == "" )
{
$read_perms = "*";
}
}
$day = intval( $ibforums->input['e_day'] );
$month = intval( $ibforums->input['e_month'] );
$year = intval( $ibforums->input['e_year'] );
if ( !checkdate( $month, $day, $year ) )
{
$std->error( array( "LEVEL" => 1, "MSG" => "cal_date_oor" ) );
}
$db_string = $DB->compile_db_insert_string( array(
"userid" => $ibforums->member['id'],
"year" => $year,
"month" => $month,
"mday" => $day,
"title" => $ibforums->input['event_title'],
"event_text" => $ibforums->input['Post'],
"read_perms" => $read_perms,
"unix_stamp" => mktime( 23, 59, 59, $month, $day, $year ),
"priv_event" => $private_event,
"show_emoticons" => $allow_emoticons
) );
$DB->query( "INSERT INTO ibf_calendar_events (".$db_string['FIELD_NAMES'].") VALUES (".$db_string['FIELD_VALUES'].")" );
$print->redirect_screen( $ibforums->lang['new_event_redirect'], "&act=calendar" );
}
function show_day( )
{
global $ibforums;
global $DB;
global $std;
global $print;
$day = intval( $ibforums->input['d'] );
$month = intval( $ibforums->input['m'] );
$year = intval( $ibforums->input['y'] );
if ( !checkdate( $month, $day, $year ) )
{
$std->error( array( "LEVEL" => 1, "MSG" => "cal_date_oor" ) );
}
require( "./sources/lib/post_parser.php" );
$this->parser = new post_parser( );
$this->output .= $this->html->cal_page_events_start( );
$eq = $DB->query( "SELECT * FROM ibf_calendar_events WHERE month='{$month}' AND mday='{$day}' AND year='{$year}'" );
$printed = 0;
while ( $DB->get_num_rows( $eq ) && ( $event = $DB->fetch_row( $eq ) ) )
{
if ( $event['priv_event'] == 1 && $ibforums->member['id'] != $event['userid'] )
{
}
else
{
if ( $event['read_perms'] != "*" && !preg_match( "/(^|,)".$ibforums->member['mgroup']."(,|\$)/", $event['read_perms'] ) )
{
continue;
}
$this->output .= $this->make_event_html( $event );
++$printed;
}
}
if ( 0 < $printed )
{
$switch = 1;
}
else
{
$switch = 0;
}
$this->output .= $this->make_birthday_html( $month, $day, $switch );
$this->nav[] = "<a href='{$ibforums->base_url}&act=calendar'>{$ibforums->lang['page_title']}</a>";
$this->nav[] = $day." ".$this->month_words[$this->chosen_month - 1]." ".$this->chosen_year;
}
function show_event( )
{
global $ibforums;
global $DB;
global $std;
global $print;
$eventid = intval( $ibforums->input['eventid'] );
if ( $eventid == "" )
{
$std->error( array( "LEVEL" => 1, "MSG" => "cal_no_events" ) );
}
$DB->query( "SELECT * FROM ibf_calendar_events WHERE eventid='{$eventid}'" );
if ( !( $event = $DB->fetch_row( ) ) )
{
$std->error( array( "LEVEL" => 1, "MSG" => "cal_no_events" ) );
}
if ( $event['priv_event'] == 1 && $ibforums->member['id'] != $event['userid'] )
{
$std->error( array( "LEVEL" => 1, "MSG" => "cal_no_events" ) );
}
if ( $event['read_perms'] != "*" && !preg_match( "/(^|,)".$ibforums->member['mgroup']."(,|\$)/", $event['read_perms'] ) )
{
$std->error( array( "LEVEL" => 1, "MSG" => "cal_no_events" ) );
}
require( "./sources/lib/post_parser.php" );
$this->parser = new post_parser( );
$this->output .= $this->html->cal_page_events_start( ).$this->make_event_html( $event );
$this->nav[] = "<a href='{$ibforums->base_url}&act=calendar'>{$ibforums->lang['page_title']}</a>";
$this->nav[] = $event['title'];
}
function make_event_html( $event )
{
global $ibforums;
global $DB;
global $std;
global $print;
$event['event_text'] = $this->parser->convert( array(
"TEXT" => $event['event_text'],
"SMILIES" => $event['show_emoticons'],
"CODE" => 1,
"HTML" => 0
) );
$event_type = $ibforums->lang['public_event'];
if ( $event['priv_event'] == 1 )
{
$event_type = $ibforums->lang['private_event'];
}
else if ( $event['read_perms'] != "*" )
{
$event_type = $ibforums->lang['restricted_event'];
}
$edit_button = "";
if ( $ibforums->member['g_is_supmod'] == 1 )
{
$edit_button = $this->html->cal_edit_button( $event['eventid'] );
}
else if ( $ibforums->member['id'] == $event['userid'] )
{
$edit_button = $this->html->cal_edit_button( $event['eventid'] );
}
$DB->query( "SELECT m.id, m.name, m.mgroup, m.posts, m.joined, m.avatar, m.avatar_size, g.g_id, g.g_title FROM ibf_members m, ibf_groups g WHERE m.id='".$event['userid']."' AND g.g_id=m.mgroup" );
$member = $DB->fetch_row( );
$member['joined'] = $std->get_date( $member['joined'], "JOINED" );
$member['avatar'] = $std->get_avatar( $member['avatar'], $ibforums->member['view_avs'], $member['avatar_size'] );
$event['month_text'] = $this->month_words[$event['month'] - 1];
return $this->html->cal_show_event( $event, $member, $event_type, $edit_button );
}
function show_birthdays( )
{
global $ibforums;
global $DB;
global $std;
global $print;
$day = intval( $ibforums->input['d'] );
$month = intval( $ibforums->input['m'] );
$year = intval( $ibforums->input['y'] );
if ( !checkdate( $month, $day, $year ) )
{
$std->error( array( "LEVEL" => 1, "MSG" => "cal_date_oor" ) );
}
$this->output .= $this->html->cal_page_events_start( ).$this->make_birthday_html( $month, $day );
$this->nav[] = "<a href='{$ibforums->base_url}&act=calendar'>{$ibforums->lang['page_title']}</a>";
$this->nav[] = $ibforums->lang['cal_birthdays']." ".$this->month_words[$this->chosen_month - 1]." ".$this->chosen_year;
}
function make_birthday_html( $month, $day, $switch = 0 )
{
global $ibforums;
global $DB;
global $std;
global $print;
$birthdays = array( );
$output = "";
$DB->query( "SELECT id, name, bday_year from ibf_members WHERE bday_month='".$month."' and bday_day='{$day}'" );
if ( !$DB->get_num_rows( ) )
{
if ( $switch == 1 )
{
return;
}
else
{
$std->error( array( "LEVEL" => 1, "MSG" => "cal_no_events" ) );
}
}
else
{
$output .= $this->html->cal_birthday_start( );
while ( $r = $DB->fetch_row( ) )
{
$age = $this->chosen_year - $r['bday_year'];
$output .= $this->html->cal_birthday_entry( $r['id'], $r['name'], $age );
}
$output .= $this->html->cal_birthday_end( );
}
return $output;
}
function get_month_dropdown( $month = "" )
{
global $ibforums;
$return = "";
if ( $month == "" )
{
$month = $this->chosen_month;
}
$x = 1;
for ( ; $x <= 12; ++$x )
{
$return .= "\t<option value='{$x}'";
$return .= $x == $month ? " selected" : "";
$return .= ">".$this->month_words[$x - 1]."\n";
}
return $return;
}
function get_year_dropdown( $year = "" )
{
global $ibforums;
$return = "";
$ibforums->vars['start_year'] = isset( $ibforums->vars['start_year'] ) ? $ibforums->vars['start_year'] : 2001;
$ibforums->vars['year_limit'] = isset( $ibforums->vars['year_limit'] ) ? $ibforums->vars['year_limit'] : 5;
if ( $year == "" )
{
$year = $this->chosen_year;
}
$x = $ibforums->vars['start_year'];
for ( ; $x <= $this->now_date['year'] + $ibforums->vars['year_limit']; ++$x )
{
$return .= "\t<option value='{$x}'";
$return .= $x == $year ? " selected" : "";
$return .= ">".$x."\n";
}
return $return;
}
function get_day_dropdown( $day = "" )
{
global $ibforums;
if ( $day == "" )
{
$day = $this->now_date['mday'];
}
$return = "";
$x = 1;
for ( ; $x <= 31; ++$x )
{
$return .= "\t<option value='{$x}'";
$return .= $x == $day ? " selected" : "";
$return .= ">".$x."\n";
}
return $return;
}
}
calendar( );
$idx = new calendar( );
?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -