⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 calendar-box.php3

📁 Event Calendar是一个在线事件日程
💻 PHP3
📖 第 1 页 / 共 2 页
字号:
<?php//  Simon's Rock Web Calendar//  Copyright (C) 1999-2000 Ryan Krebs and Simon's Rock College of Bard//  Please read the accompanying files "COPYING" and "COPYRIGHT"//  for more informationif( !isSet( $CALENDAR_BOX_INCLUDED ) ) {	$CALENDAR_BOX_INCLUDED = 1;	include( 'box.php3' );	include( 'error/error.php3' );	include( 'sql/sql.php3' );	include( 'event.php3' );	class SRCCalendarBox extends SRCBox{		function SRCCalendarBox( $new_action_url = "",				$new_session_var = "", $new_login_req = 0 ) {			$this->action_url = $new_action_url;			$this->login_required = $new_login_req;			$this->session_var = $new_session_var;			$this->uses_headers = 1;			$this->help_available = 1;			$this->help_topic = "The Month View";			$this->error = "";		}		function outputBox() {// For some reason the vars set in updateVars//   don't stick unless run from parseBox()			if( !isSet( $this->event_index ) )				$this->updateVars();			$this->outputCalendar();		}		function parseBox() {			if( isSet( $GLOBALS["view_unapproved"] ) ) {				if( $GLOBALS["view_unapproved"] != "no" ) {					setCookie( "SRCViewUnapproved", "1",						(mktime() + 31536000),						"/" );					$GLOBALS["SRCViewUnapproved"] = 1;				} else {					setCookie( "SRCViewUnapproved", "", "",						"/" );					unset( $GLOBALS["SRCViewUnapproved"] );				}			}			$this->updateVars();			if( $GLOBALS["text_only"] ) {				$this->outputResults();				exit;			}		}		function updateVars() {			$this->approved_only = !($GLOBALS["SRCViewUnapproved"]					&& !$GLOBALS["oc_remote_host"] );// If the timestamp isn't set, get the current time//  and add any additional time arguments			if (! $GLOBALS["timestamp"] ) {				$temp_stamp = mktime();				$temp_date = getDate( $temp_stamp );				if ( isSet( $GLOBALS["month"] ) )					$temp_date["mon"] = $GLOBALS["month"];				if ( isSet( $GLOBALS["date"] ) )					$temp_date["mday"] = $GLOBALS["date"];				if ( isSet( $GLOBALS["year"] ) )					$temp_date["year"] = $GLOBALS["year"];				$temp_stamp = mktime( $temp_date["hours"],					$temp_date["minutes"],					$temp_date["seconds"],					$temp_date["mon"],					$temp_date["mday"],					$temp_date["year"] );			} else {				$temp_stamp = $GLOBALS["timestamp"];			}// change the timestamp to the beginning of the month			$temp_stamp = mktime( 0, 0, 0, date("m", $temp_stamp),				1, date("Y", $temp_stamp ) );// get date array for the beginning of the month			$this->month_begin = $temp_stamp;// beginning of the last day of the month			$temp_stamp = mktime( 0, 0, 0, date("m", $temp_stamp)+1,				0, date("Y", $temp_stamp ) );			$this->month_end = $temp_stamp;			$this->event_index = $this->fetchIndex(				$this->month_begin, $this->month_end); 		}		function outputResults() {			switch( $GLOBALS["cal_view"] ) {				case "detail":					$this->outputDetailView(						$GLOBALS["event_id"], 1 );					break;				case "day":					$this->outputDayView( 1 );// Messy text-only view					if( !$GLOBALS["text_only"] )						$this->outputTextOnlyLink();					break;				case "week":					$this->outputDayView( 7 );					if( !$GLOBALS["text_only"] ) {						echo( "<HR>" );						$this->outputTextOnlyLink();					}					break;				case "weekday":					$this->outputWeekdayView( $GLOBALS["weekday"] );					break;				case "month":					$this->outputMonthView( $this->month_begin );					break;				default:					$this->outputDayView( 1 );					if( !$GLOBALS["text_only"] ) {						echo( "<HR>" );						$this->outputTextOnlyLink();					}			}		}// This just needs to spit out a link that sets the "text_only" var		function outputTextOnlyLink() {			echo( "View these events in a <A HREF=\"" .				$this->action_url .				"&amp;text_only=1" .				( isSet( $GLOBALS["timestamp"] ) ?					"&amp;timestamp=" . $GLOBALS["timestamp"]					: "" ) .				( isSet( $GLOBALS["cal_view"] ) &&					$GLOBALS["cal_view"] != "detail" ?					"&amp;cal_view=" . $GLOBALS["cal_view"]					: "" ) .				"\">text-only</A> format.<BR>\n"			);		}		function outputCalendar() {// today used to make today's header red			$today = mktime( 0,0,0 );			$temp_stamp = $this->month_begin;// get date array for the beginning of the month			$month_begin = getDate( $temp_stamp );// output some HTML// title and week headers first// week headers are links to the week view			echo( "<H2 ALIGN=\"center\"><A HREF=\"" .				$this->action_url . "&amp;timestamp=" .				$temp_stamp . "&amp;cal_view=month\">" .				$month_begin["month"] . "&nbsp;" .				$month_begin["year"] . "</A></H2>\n" );			echo( "<TABLE BORDER ALIGN=\"center\">\n<TR>\n<TD> </TD>\n" );			echo( "<TD ALIGN=\"center\">" .				"<A HREF=\"" . $this->action_url .				"&amp;timestamp=" . $temp_stamp .				"&amp;cal_view=weekday&amp;weekday=0\">" .				"S</A></TD>\n" );			echo( "<TD ALIGN=\"center\">" .				"<A HREF=\"" . $this->action_url .				"&amp;timestamp=" . $temp_stamp .				"&amp;cal_view=weekday&amp;weekday=1\">" .				"M</A></TD>\n" );			echo( "<TD ALIGN=\"center\">" .				"<A HREF=\"" . $this->action_url .				"&amp;timestamp=" . $temp_stamp .				"&amp;cal_view=weekday&amp;weekday=2\">" .				"T</A></TD>\n" );			echo( "<TD ALIGN=\"center\">" .				"<A HREF=\"" . $this->action_url .				"&amp;timestamp=" . $temp_stamp .				"&amp;cal_view=weekday&amp;weekday=3\">" .				"W</A></TD>\n" );			echo( "<TD ALIGN=\"center\">" .				"<A HREF=\"" . $this->action_url .				"&amp;timestamp=" . $temp_stamp .				"&amp;cal_view=weekday&amp;weekday=4\">" .				"Th</A></TD>\n" );			echo( "<TD ALIGN=\"center\">" .				"<A HREF=\"" . $this->action_url .				"&amp;timestamp=" . $temp_stamp .				"&amp;cal_view=weekday&amp;weekday=5\">" .				"F</A></TD>\n" );			echo( "<TD ALIGN=\"center\">" .				"<A HREF=\"" . $this->action_url .				"&amp;timestamp=" . $temp_stamp .				"&amp;cal_view=weekday&amp;weekday=6\">" .				"Sa</A></TD>\n" );			echo( "</TR>\n" );			$current_weekday = $month_begin["wday"];			$current_date = 1;			$current_week = 1;// display the "week #" link// there's an if here to keep the first "week #" from being// output twice when the month starts on sunday.			if ( $current_weekday ) {				echo( "<TR>\n<TD>" .				"<A HREF=\"$this->action_url&amp;cal_view=week&amp;timestamp="				. mktime( 0, 0, 0, $month_begin["mon"],				$current_date, $month_begin["year"] )				. "\">Week&nbsp;$current_week</A></TD>\n" );			}// blanks spaces up to the first day of the month			for ( $i = $current_weekday; $i > 0; $i-- ) {				echo( "<TD> </TD>\n" );			}// and we go through all the numbers until the date is invalid			while ( checkDate( $month_begin["mon"], $current_date,					$month_begin["year"] ) ) {				if ( ! $current_weekday ) {					echo( "<TR>\n<TD>" .					"<A HREF=\"$this->action_url&amp;cal_view=week&amp;timestamp="					. mktime( 0, 0, 0, $month_begin["mon"],					$current_date, $month_begin["year"] )					. "\">Week&nbsp;$current_week</A>"					. "</TD>\n" );				}				$curr_date = mktime( 0, 0, 0, $month_begin["mon"],					$current_date, $month_begin["year"] );				echo( "<TD ALIGN=\"center\">" );				echo( "<A HREF=\"$this->action_url&amp;cal_view=day&amp;timestamp=" .					$curr_date . "\" " .					($curr_date == $today ? " CLASS=red>"					: (isSet($this->event_index[$curr_date])						? " CLASS=green>" : ">"))					. "$current_date</A>" );				echo( "</TD>\n" );				$current_date++;				if ( ++$current_weekday >= 7 ) {					$current_weekday = 0;					$current_week++;					echo( "</TR>\n" );				}			}// some more stuff beneath the calendar// next month and previous month links			echo( "</TABLE>\n" );			echo( "<P ALIGN=\"center\">\n" );			echo( "<A HREF=\"$this->action_url&amp;cal_view=month&amp;timestamp=" .				mktime( 0,0,0, ($month_begin["mon"] - 1),1,				$month_begin["year"] ) .				"\">Previous month</A> | " );			echo( "<A HREF=\"$this->action_url&amp;cal_view=month&amp;timestamp=" .				mktime( 0,0,0, ($month_begin["mon"] + 1),1,				$month_begin["year"] ) . "\">Next month</A>\n" );// let people look at unapproved events if they're on campus			if( !$GLOBALS["oc_remote_host"] ) {				echo( "<BR><A HREF=\"" .					$this->action_url . "&amp;view_unapproved=" . 					( $GLOBALS["SRCViewUnapproved"] ?						"no" : "yes" ) .					( isSet( $GLOBALS["timestamp"] ) ?						"&amp;timestamp=" . $GLOBALS["timestamp"]						: "" ) .					( isSet( $GLOBALS["cal_view"] ) &&						$GLOBALS["cal_view"] != "detail" ?						"&amp;cal_view=" . $GLOBALS["cal_view"]						: "" ) .					"\">" .					( $GLOBALS["SRCViewUnapproved"] ?						"Hide" : "View" ) .					" unapproved events.</A>" );			}		}// Thanks to Bruce Tenison for he following function that searches for// events on the date of a timestamp, returning 1 for events present,// and 0 for no events.//// Modified heavily by me to check the index table and return a hash with//  event IDs for a range of dates.  The hash uses the timestamp as the//  key and an array of event IDs for the value.		function fetchIndex( $startstamp, $endstamp ) {			if ( ! $my_conn = connectROToCalendar() ) {				$during = "while connecting to the calendar database";				reportError( $php_errormsg, $during );				return;			}// See if we need to consult srcevent for approval or hide_oc			if( $this->approved_only || $GLOBALS["oc_remote_host"] )					$blah = 1;			else $blah = 0;			if( $blah )				$timename = "I.timestamp";			else				$timename = "timestamp";			$my_query = "SELECT " . ($blah ?				"I.event_id as event_id, I.timestamp as timestamp "				: " * ") . " FROM srcindex " .				( $blah ? "I, srcevent E WHERE " : "WHERE ");			$my_query .= ( $endstamp ?				"( " . $timename . " >= " . $startstamp .				" ) AND ( ". $timename . " <= " . $endstamp .				" ) " : $timename . " = " . $startstamp );			if ( $this->approved_only )				$my_query .= " AND E.approver_id notNull ";			if( $GLOBALS["oc_remote_host"] )				$my_query .= " AND E.hide_oc isNull ";			if( $blah )				$my_query .= " AND E.event_id = I.event_id";			$my_query .= " ORDER BY " . $timename . " ASC";			if(! $result_id = @pg_exec( $my_conn, $my_query ) ) {				$during = "while searching the event database";				$error = $php_errormsg . " -QUERY= " . $my_query;				reportError( $error, $during );				return;			}			$num_rows = pg_NumRows( $result_id );			$currentstamp = 0;

⌨️ 快捷键说明

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