calendar.php
来自「sabreipb 2.1.6 utf-8中文版本!」· PHP 代码 · 共 1,905 行 · 第 1/5 页
PHP
1,905 行
<?php/*+--------------------------------------------------------------------------| Invision Power Board v2.1.6| =============================================| by Matthew Mecham| (c) 2001 - 2005 Invision Power Services, Inc.| http://www.invisionpower.com| =============================================| Web: http://www.invisionboard.com| Time: Thu, 04 May 2006 17:39:49 GMT| Release: b415613eeb952a2741ff6d53e0266428| Licence Info: http://www.invisionboard.com/?license+---------------------------------------------------------------------------| > $Date: 2006-02-28 14:25:39 +0000 (Tue, 28 Feb 2006) $| > $Revision: 149 $| > $Author: bfarber $+---------------------------------------------------------------------------|| > Calendar functions library| > Module written by Matt Mecham| > Date started: 12th June 2002|| > Module Version Number: 1.0.0| > DBA Checked: Wed 19 May 2004| > Quality Checked: Wed 15 Sept. 2004+--------------------------------------------------------------------------*/if ( ! defined( 'IN_IPB' ) ){ print "<h1>Incorrect access</h1>You cannot access this file directly. If you have recently upgraded, make sure you upgraded all the relevant files."; exit();}class calendar{ # Classes var $ipsclass; var $post; # Others var $output = ""; var $base_url = ""; var $html = ""; var $page_title = ""; var $nav; var $chosen_month = ""; var $chosen_year = ""; var $now_date = ""; var $our_datestamp = ""; var $offset = ""; var $start_date = ""; var $first_day_array = ""; var $month_words = array(); var $day_words = array(); var $query_month_cache = array(); var $query_bday_cache = array(); var $calendar_id = 1; var $calendar = array(); var $calendar_jump = ""; var $calenar_cache = array(); # Permissions var $can_read = 0; var $can_post = 0; var $can_avoid_queue = 0; var $can_moderate = 0; /*-------------------------------------------------------------------------*/ // AUTO-RUN /*-------------------------------------------------------------------------*/ function auto_run() { //----------------------------------------- // Load post class //----------------------------------------- require_once( ROOT_PATH.'sources/classes/post/class_post.php' ); $this->post = new class_post(); $this->post->ipsclass =& $this->ipsclass; $this->post->load_classes(); //----------------------------------------- // Get topic lib //----------------------------------------- require_once( ROOT_PATH . 'sources/action_public/topics.php' ); $this->topiclib = new topics(); $this->topiclib->ipsclass =& $this->ipsclass; $this->topiclib->topic_init(); //----------------------------------------- // Load lang and templs //----------------------------------------- $this->ipsclass->load_language('lang_calendar'); $this->ipsclass->load_template('skin_calendar'); $this->ipsclass->vars['bday_show_cal_max'] = 5; //----------------------------------------- // Get "this" calendar details //----------------------------------------- if ( $this->ipsclass->input['cal_id'] OR $this->ipsclass->input['calender_id'] ) { $this->calendar_id = intval($this->ipsclass->input['cal_id']) ? intval($this->ipsclass->input['cal_id']) : intval($this->ipsclass->input['calender_id']); } else { $this->calendar_id = 1; } //----------------------------------------- // Sneaky cheaty //----------------------------------------- $this->ipsclass->input['_cal_id'] =& $this->calendar_id; //----------------------------------------- // Get all calendar details //----------------------------------------- $this->ipsclass->DB->build_query( array( 'select' => '*', 'from' => 'cal_calendars', 'order' => 'cal_position ASC' ) ); $this->ipsclass->DB->exec_query(); while( $cal = $this->ipsclass->DB->fetch_row() ) { $selected = ""; $perms = unserialize( $cal['cal_permissions'] ); if ( $cal['cal_id'] == $this->calendar_id ) { $this->calendar = array_merge( $cal, $perms); $selected = " selected='selected'"; } $this->calendar_cache[ $cal['cal_id'] ] = array_merge( $cal, $perms); //----------------------------------------- // Got a perm? //----------------------------------------- if ( $this->ipsclass->check_perms( $perms['perm_read'] ) != TRUE ) { continue; } $this->calendar_jump .= "<option value='{$cal['cal_id']}'{$selected}>{$cal['cal_title']}</option>\n"; } if( ! $this->calendar ) { if( count( $this->calendar_cache ) ) { $tmp_resort = $this->calendar_cache; ksort($tmp_resort); reset($tmp_resort); $default_calid = key( $tmp_resort ); $this->calendar_id = $default_calid; $this->calendar = $tmp_resort[ $default_calid ]; unset( $tmp_resort ); } } //----------------------------------------- // Got viewing perms? //----------------------------------------- $this->build_permissions(); if ( ! $this->can_read ) { $this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'cal_no_perm') ); } //----------------------------------------- // Prep our chosen dates //----------------------------------------- // There is something whacky with getdate and GMT // This handrolled method seems to take into account // DST where getdate refuses. $a = explode( ',', gmdate( 'Y,n,j,G,i,s', time() + $this->ipsclass->get_time_offset() ) ); $this->now_date = array( 'year' => $a[0], 'mon' => $a[1], 'mday' => $a[2], 'hours' => $a[3], 'minutes' => $a[4], 'seconds' => $a[5] ); if ( $this->ipsclass->input['year'] ) { $this->ipsclass->input['y'] = $this->ipsclass->input['year']; } $this->chosen_month = ( ! intval($this->ipsclass->input['m']) ) ? $this->now_date['mon'] : intval($this->ipsclass->input['m']); $this->chosen_year = ( ! intval($this->ipsclass->input['y']) ) ? $this->now_date['year'] : intval($this->ipsclass->input['y']); //----------------------------------------- // Make sure the date is in range. //----------------------------------------- if ( ! checkdate( $this->chosen_month, 1 , $this->chosen_year ) ) { $this->chosen_month = $this->now_date['mon']; $this->chosen_year = $this->now_date['year']; } //----------------------------------------- // Get the timestamp for our chosen date //----------------------------------------- $this->our_datestamp = mktime( 0,0,1, $this->chosen_month, 1, $this->chosen_year); $this->first_day_array = $this->ipsclass->date_getgmdate($this->our_datestamp); //----------------------------------------- // Finally, build up the lang arrays //----------------------------------------- $this->month_words = array( $this->ipsclass->lang['M_1'] , $this->ipsclass->lang['M_2'] , $this->ipsclass->lang['M_3'] , $this->ipsclass->lang['M_4'] , $this->ipsclass->lang['M_5'] , $this->ipsclass->lang['M_6'] , $this->ipsclass->lang['M_7'] , $this->ipsclass->lang['M_8'] , $this->ipsclass->lang['M_9'] , $this->ipsclass->lang['M_10'], $this->ipsclass->lang['M_11'], $this->ipsclass->lang['M_12'] ); $this->day_words = array( $this->ipsclass->lang['D_0'], $this->ipsclass->lang['D_1'], $this->ipsclass->lang['D_2'], $this->ipsclass->lang['D_3'], $this->ipsclass->lang['D_4'], $this->ipsclass->lang['D_5'], $this->ipsclass->lang['D_6'] ); switch( $this->ipsclass->input['code'] ) { case 'newevent': $this->cal_event_form('add'); break; case 'addnewevent': $this->cal_event_save('add'); break; case 'edit': $this->cal_event_form('edit'); break; case 'doedit': $this->cal_event_save('edit'); break; case 'event_approve': $this->event_approve(); break; case 'showday': $this->show_day(); break; case 'showevent': $this->show_event(); break; case 'birthdays': $this->show_birthdays(); break; case 'showweek': $this->show_week(); break; case 'delete': $this->cal_delete(); break; case 'find': $this->find_date(); break; default: $this->show_month(); break; } if ($this->page_title == "") { $this->page_title = $this->ipsclass->vars['board_name']." ".$this->ipsclass->lang['page_title']; } if (! is_array($this->nav) ) { $this->nav[] = "<a href='{$this->ipsclass->base_url}act=calendar'>{$this->ipsclass->lang['page_title']}</a>"; } $this->ipsclass->print->add_output("$this->output"); $this->ipsclass->print->do_output( array( 'TITLE' => $this->page_title, 'JS' => 0, NAV => $this->nav ) ); } /*-------------------------------------------------------------------------*/ // Event Approve /*-------------------------------------------------------------------------*/ function cal_delete() { //----------------------------------------- // INIT //----------------------------------------- $cal_id = intval( $this->ipsclass->input['cal_id'] ); $event_id = intval( $this->ipsclass->input['event_id'] ); $md5check = trim( $this->ipsclass->input['md5check'] ); //----------------------------------------- // Get permissions //----------------------------------------- $this->build_permissions( $cal_id ); //----------------------------------------- // Check //----------------------------------------- $this->ipsclass->DB->build_query( array( 'select' => '*', 'from' => 'cal_events', 'where' => "event_id=$event_id AND event_calendar_id=$cal_id" ) ); $this->ipsclass->DB->exec_query(); $memcheck = $this->ipsclass->DB->fetch_row(); if ( ! $cal_id OR ! $event_id ) { $this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'no_permission') ); } if ( ! $this->can_moderate && ( $this->ipsclass->member['id'] > 0 && $this->ipsclass->member['id'] <> $memcheck['event_member_id'] ) ) { $this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'no_permission') ); } //----------------------------------------- // Check MD5 //----------------------------------------- if ( $md5check != $this->ipsclass->md5_check ) { $this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'no_permission') ); } //----------------------------------------- // Delete... //----------------------------------------- $this->ipsclass->DB->build_and_exec_query( array( 'delete' => 'cal_events', 'where' => "event_id=$event_id AND event_calendar_id=$cal_id" ) ); //----------------------------------------- // Recache... //----------------------------------------- $this->_call_recache(); //----------------------------------------- // Boing... //----------------------------------------- $this->ipsclass->print->redirect_screen( $this->ipsclass->lang['cal_event_delete'] , "&act=calendar&cal_id={$cal_id}" ); } /*-------------------------------------------------------------------------*/ // Event Approve /*-------------------------------------------------------------------------*/ function event_approve() { //----------------------------------------- // INIT //----------------------------------------- $cal_id = intval( $this->ipsclass->input['cal_id'] ); $event_id = intval( $this->ipsclass->input['event_id'] ); $approve = intval( $this->ipsclass->input['approve'] ); $modfilter = trim( $this->ipsclass->input['modfilter'] );
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?