calendar.php

来自「sabreipb 2.1.6 utf-8中文版本!」· PHP 代码 · 共 1,905 行 · 第 1/5 页

PHP
1,905 行
字号
		$end_day      = "";		$end_month    = "";		$end_year     = "";		$end_date     = "";		$event_ranged = 0;		$event_repeat = 0;		$can_edit     = 0;				$form_type         = $this->ipsclass->input['formtype'];		$event_id          = intval($this->ipsclass->input['event_id']);    	$calendar_id       = intval( $this->ipsclass->input['calendar_id'] );    	$allow_emoticons   = $this->ipsclass->input['enableemo'] == 'yes'     ? 1 : 0;		$private_event     = $this->ipsclass->input['e_type']    == 'private' ? 1 : 0;		$event_title       = trim($this->ipsclass->input['event_title']);		$day               = intval($this->ipsclass->input['e_day']);		$month             = intval($this->ipsclass->input['e_month']);		$year              = intval($this->ipsclass->input['e_year']);		$end_day           = intval($this->ipsclass->input['end_day']);		$end_month         = intval($this->ipsclass->input['end_month']);		$end_year          = intval($this->ipsclass->input['end_year']);		$recur_unit        = intval($this->ipsclass->input['recur_unit']);		$event_tz          = intval($this->ipsclass->input['event_tz']);		$offset            = 0; 		$event_calendar_id = intval($this->ipsclass->input['event_calendar_id']);		$set_time		   = intval($this->ipsclass->input['set_times']);		$hour_min		   = array();		if( $set_time )		{			$hour_min	   = strstr($this->ipsclass->input['event_timestart'], ":") ? explode(":", $this->ipsclass->input['event_timestart']) : 0;			if( intval($hour_min[0]) < 0 || intval($hour_min[0]) > 23 )			{				$hour_min[0] = 0;			}						if( intval($hour_min[1]) < 0 || intval($hour_min[1]) > 59 )			{				$hour_min[1] = 0;			}						if( $hour_min[0] || $hour_min[1] )			{				$offset	= $event_tz * 3600;			}			else			{				$hour_min 	= array();				$offset		= 0;			}		}				$this->ipsclass->vars['max_post_length'] = $this->ipsclass->vars['max_post_length'] ? $this->ipsclass->vars['max_post_length'] : 2140000;		    	//-----------------------------------------    	// CHECK    	//-----------------------------------------    	    	if ( $this->ipsclass->member['g_calendar_post'] != 1)		{			$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'no_permission') );		}				if ( ! $this->ipsclass->member['id'])		{			$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'no_permission') );		}				//-----------------------------------------		// Got permission to post to this calendar?		//-----------------------------------------				$this->build_permissions( $event_calendar_id );				if ( ! $this->can_post )		{			$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'no_permission') );		}				//-----------------------------------------		// WHTDOWEDO?		//-----------------------------------------				if ( $type == 'add' )		{				}		else		{			if ( ! $event_id )			{				$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'no_post') );			}						//-----------------------------------------			// Get the event			//-----------------------------------------						$this->ipsclass->DB->simple_construct( array( 'select' => '*', 'from' => 'cal_events', 'where' => "event_id=$event_id" ) );			$this->ipsclass->DB->simple_exec();						if ( ! $event = $this->ipsclass->DB->fetch_row() )			{				$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'cal_no_events') );			}						//-----------------------------------------			// Do we have permission to edit this event?			//-----------------------------------------						if ( $this->ipsclass->member['id'] == $event['event_member_id'] )			{				$can_edit = 1;			}			else if ( $this->ipsclass->member['g_is_supmod'] == 1 )			{				$can_edit = 1;			}						if ( $can_edit != 1 )			{ 				$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'cal_no_events') );			}		}				//-----------------------------------------		// Do we have a valid post?		//-----------------------------------------				if (strlen( trim($_POST['Post']) ) < 1)		{			$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'no_post') );		}				if (strlen( $_POST['Post'] ) > ($this->ipsclass->vars['max_post_length']*1024))		{			$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'post_too_long') );		}				//-----------------------------------------		// Fix up the Event Title		//-----------------------------------------				if ( (strlen($event_title) < 2) or (!$event_title)  )		{			$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'cal_title_none') );		}				if ( strlen($event_title) > 64 )		{			$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'cal_title_long') );		}				//-----------------------------------------		// Are we an admin, and have we set w/groups		// can see?		//-----------------------------------------				if ( $this->ipsclass->member['mgroup'] == $this->ipsclass->vars['admin_group'] )		{			if ( is_array( $_POST['e_groups'] ) )			{				$read_perms = implode( ",", $_POST['e_groups'] );				$read_perms .= ",".$this->ipsclass->vars['admin_group'];			}						if ($read_perms == "")			{				$read_perms = '*';			}		}				//-----------------------------------------		// Check dates: Range		//-----------------------------------------				if ( $form_type == 'range' )		{				if ( $end_year < $year )			{				$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'cal_range_wrong') );			}						if ( $end_year == $year )			{				if ( $end_month < $month )				{					$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'cal_range_wrong') );				}								if ( $end_month == $month AND $end_day <= $day )				{					$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'cal_range_wrong') );				}			}						$_final_unix_from = gmmktime(0 , 0, 0  , $month    , $day    , $year    ) + $offset;// + $offset; # Midday			$_final_unix_to   = gmmktime(23, 59, 59, $end_month, $end_day, $end_year) + $offset;// + $offset; # End of the day						$event_ranged = 1;			$set_time 	  = 0;			$hour_min 	  = array();		}				//-----------------------------------------		// Check dates: Recur		//-----------------------------------------				elseif ( $form_type == 'recur' )		{			if ( $this->ipsclass->input['recur_unit'] )			{				$event_repeat = 1;			}						if ( $end_year < $year )			{				$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'cal_range_wrong') );			}						if ( $end_year == $year )			{				if ( $end_month < $month )				{					$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'cal_range_wrong') );				}								if ( $end_month == $month AND $end_day <= $day )				{					$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'cal_range_wrong') );				}			}						$hour = 0;			$min  = 0;			if( $set_time )			{				if( is_array( $hour_min ) )				{					$hour = $hour_min[0];					$min  = $hour_min[1];				}			}						$_final_unix_from = gmmktime($hour , $min , 0 , $month    , $day    , $year    ) + $offset;// + $offset;			$_final_unix_to   = gmmktime($hour, $min, 0, $end_month, $end_day, $end_year) + $offset;// + $offset; # End of the day			$event_recur      = 1;		}				//-----------------------------------------		// Check dates: Single		//-----------------------------------------				else		{			$hour = 0;			$min  = 0;			if( $set_time )			{				if( is_array( $hour_min ) )				{					$hour = $hour_min[0];					$min  = $hour_min[1];				}			}						$_final_unix_from = gmmktime($hour, $min, 0, $month, $day, $year) + $offset;// + $offset;			$_final_unix_to   = 0;		}				//-----------------------------------------		// Do we have a sensible date?		//-----------------------------------------				if ( ! checkdate( $month, $day , $year ) )        {			$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'cal_date_oor') );		}				//-----------------------------------------		// Post process the editor		// Now we have safe HTML and bbcode		//-----------------------------------------		 		$this->ipsclass->input['Post'] = $this->post->han_editor->process_raw_post( 'Post' ); 		 		//----------------------------------------- 		// Event approved? 		//----------------------------------------- 		 		$event_approved = $this->can_avoid_queue ? 1 : ( $this->calendar_cache[ $event_calendar_id ]['cal_moderate'] ? 0 : 1 ); 		 		if( $private_event == 1 ) 		{	 		$event_approved = 1; 		} 		 		if ( $type == 'add' ) 		{			//-----------------------------------------			// Add it to the DB			//-----------------------------------------						$this->ipsclass->DB->do_insert( 'cal_events', array (																 'event_calendar_id' => $event_calendar_id,																 'event_member_id'   => $this->ipsclass->member['id'],																 'event_content'     => $this->ipsclass->input['Post'],																 'event_title'       => $event_title,																 'event_smilies'     => $allow_emoticons,																 'event_perms'       => $read_perms,																 'event_private'     => $private_event,																 'event_approved'    => $event_approved,																 'event_unixstamp'   => time(),																 'event_recurring'   => $recur_unit,																 'event_tz'          => $event_tz,																 'event_timeset'	 => count($hour_min) > 0 ? intval($hour_min[0]).":".intval($hour_min[1]) : 0,																 'event_unix_from'   => $_final_unix_from,																 'event_unix_to'     => $_final_unix_to ) );																		$this->_call_recache();						if ( $event_approved )			{				$this->ipsclass->print->redirect_screen( $this->ipsclass->lang['new_event_redirect'] , "&act=calendar&cal_id={$event_calendar_id}" );			}			else			{				$this->ipsclass->print->redirect_screen( $this->ipsclass->lang['new_event_mod'] , "&act=calendar&cal_id={$event_calendar_id}" );			}		}		else		{			//-----------------------------------------			// Add it to the DB			//-----------------------------------------						$this->ipsclass->DB->do_update( 'cal_events', array (																 'event_calendar_id' => $event_calendar_id,																 'event_content'     => $this->ipsclass->input['Post'],																 'event_title'       => $event_title,																 'event_smilies'     => $allow_emoticons,																 'event_perms'       => $read_perms,																 'event_private'     => $private_event,																 'event_approved'    => $event_approved,																 'event_unixstamp'   => time(),																 'event_recurring'   => $recur_unit,																 'event_tz'          => $event_tz,																 'event_timeset'	 => count($hour_min) > 0 ? intval($hour_min[0]).":".intval($hour_min[1]) : 0,																 																 'event_unix_from'   => $_final_unix_from,																 'event_unix_to'     => $_final_unix_to ), 'event_id='.$event_id );																		$this->_call_recache();						if ( $event_approved )			{				$this->ipsclass->print->redirect_screen( $this->ipsclass->lang['edit_event_redirect'] , "&act=calendar&cal_id={$event_calendar_id}&code=showevent&event_id=$event_id" );			}			else			{				$this->ipsclass->print->redirect_screen( $this->ipsclass->lang['new_event_mod'] , "&act=calendar&cal_id={$event_calendar_id}" );			}		}	}			/*-------------------------------------------------------------------------*/    // SHOW DAYS EVENTS    /*-------------------------------------------------------------------------*/        function show_day()    {        $day       = intval($this->ipsclass->input['d']);		$month     = intval($this->ipsclass->input['m']);		$year      = intval($this->ipsclass->input['y']);		$seen_ids  = array();		$timenow   = gmmktime( 0,0,0, $month, $day, $year);		$day_array = $this->ipsclass->date_getgmdate( $timenow  );				$printed = 0;		 		//-----------------------------------------		// Do we have a sensible date?

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?