<?php //----------------------------------------------------------------------------- // German Event Calendar 2012 //----------------------------------------------------------------------------- define ("START_YEAR", "2012"); define ("END_YEAR", "2020"); define ("LOGIN_NAME", "demo"); define ("LOGIN_PASSWORD", "demo"); define ("MULTIPLE", 1); //auf 0 setzen, wenn Möglichkeit für wiederholte Einträge nicht gewünscht. define ("MAX_REPEATS", 20); //Max. Wiederholungen von Einträgen define ("MOUSE_OVER_EFFECT", 1); define ("ALLOW_HTML_CODE", 0); define ("DATA_DIR", ""); // hier können bis zu 10 Ereignisse eingetragen werden. Die farbliche Gestaltung findet im "priority.css" Dokument statt. $priority_array[0] = "früh."; $priority_array[1] = "spät."; $priority_array[2] = "frei."; $priority_array[3] = "Url."; $priority_array[4] = "Anne"; $priority_array[5] = "Bert"; $priority_array[6] = "Chris"; $priority_array[7] = "No.7"; $priority_array[8] = "No.8"; $priority_array[9] = "No.9"; if ($_POST['user'] == LOGIN_NAME && $_POST['password'] == LOGIN_PASSWORD) { setcookie('logged_in',1,time()+60*60*24*90 ); $_COOKIE['logged_in']=1; } if(isset($_GET['log_out'])) { setcookie('logged_in', 0,time() -600); unset ($_COOKIE['logged_in']); } { $Sun = "So"; $Mon = "Mo"; $Tue = "Di"; $Wed = "Mi"; $Thu = "Do"; $Fri = "Fr"; $Sat = "Sa"; $repeat_every = "Eintragen für jeden/jede"; $add_entry = "Anzahl Wiederholungen"; $times = "mal"; $no_repeat = "Keine Wiederholung"; $days_text = "Tag"; $weeks_text = "Woche"; $months_text = "Monat"; $calendar_view_text = "Kalenderansicht"; $previous_month_text = "vorheriger Monat"; $next_month_text = "nächster Monat"; $No_events_listed_for = "Keine Termine eingetragen"; $change_text = "Monat/Jahr aktualisieren"; $log_in_text = "Einloggen"; $name_text = "Name"; $password_text = "Passwort"; $month_event_view = "Monatsübersicht"; $login_text = "Einloggen"; $add_edit_text = "Hinzufügen/editieren"; $Calendar_Login = "Kalender"; $back_text = "zurück"; $log_out_text = "Ausloggen"; define("January", "Januar"); define("February" ,"Februar"); define("March", "März"); define("April", "April"); define("May", "Mai"); define("June", "Juni"); define("July", "July"); define("August", "August"); define("September", "September"); define("October","Oktober"); define("November", "November"); define("December", "Dezember"); } define ("DEBUG_ON", true); extract ($_GET); extract ($_POST); ?> <html> <head> <title>Event Kalender</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <STYLE> /* This is for Netscape 4.0+ broswsers so that the border will display. If you want to modify the background color this is where you would do it for NS4.0+. To modify the color for IE and NS6 do so in the style tag in the div below */ .ttip {border:1px solid black;font-size:12px;layer-background-color:lightyellow;background-color:lightyellow} </STYLE> <script> function showtip(current,e,num) { if (document.layers) // Netscape 4.0+ { theString="<DIV CLASS='ttip'>"+num+"</DIV>" document.tooltip.document.write(theString) document.tooltip.document.close() document.tooltip.left=e.pageX+14 document.tooltip.top=e.pageY+2 document.tooltip.visibility="show" } else { if(document.getElementById) // Netscape 6.0+ and Internet Explorer 5.0+ { elm=document.getElementById("tooltip") elml=current elm.innerHTML=num elm.style.height=elml.style.height elm.style.top=parseInt(elml.offsetTop+elml.offsetHeight) elm.style.left=parseInt(elml.offsetLeft+elml.offsetWidth+10) elm.style.visibility = "visible" } } } function hidetip(){ if (document.layers) // Netscape 4.0+ { document.tooltip.visibility="hidden" } else { if(document.getElementById) // Netscape 6.0+ and Internet Explorer 5.0+ { elm.style.visibility="hidden" } } } </script> <link href="priority.css" rel="stylesheet" type="text/css"> </head> <body> <div id="tooltip" style="position:absolute; visibility:hidden; border:1px solid black; font-size:11px; layer-background-color:lightyellow; background-color:lightyellow; padding:1px; width: 30%;"></div> <?php //---------------------------------------------------------------------------- //debugging function //---------------------------------------------------------------------------- function DebugDie ( $file ,$line, $msg = "") { if (DEBUG_ON) die ("Error file : $file, line : $line $msg<br>\n"); else die ("Failed to run script"); } //---------------------------------------------------------------------------- // Checks to see if the user is logged in and if he is not // authenticates the user. If the user fails to enter correct user name // and i.d then the log in form is shown. //---------------------------------------------------------------------------- function loginCheck () { if (isLoggedIn()) { return true; } else { show_login_form(); return false; } } ?> <?php //---------------------------------------------------------------------------- // displays form for log in // also re posts the year month and day data //---------------------------------------------------------------------------- function show_login_form() { global $select_priority; global $yearSelect, $monthSelect, $daySelect, $textEntry; global $select_repeat, $num_repeats, $select_time_block, $select_priority, $Calendar_Login; global $name_text, $password_text, $back_text, $log_in_text; echo "<form action = '$_SERVER[PHP_SELF]' method = 'post'>\n"; echo "<table align = center>\n"; echo " <tr>"; echo " <td align = 'center' colspan = '2'>"; echo "<b>$Calendar_Login</b>"; echo "</td></tr>\n"; echo "<tr>\n"; echo " <td>$name_text</td>\n"; echo " <td><input type ='text' name = 'user' value = '' maxlength='8'><br></td>\n"; echo " </tr>"; echo " <tr>"; echo " <td>$password_text</td>\n"; echo " <td><input type ='password' name = 'password' value = '' maxlength='8'></td>\n"; echo " </tr>"; echo " <tr>"; echo "<input type = 'hidden' name = 'yearSelect', value = '$yearSelect'>\n"; echo "<input type = 'hidden' name = 'monthSelect', value = '$monthSelect'>\n"; echo "<input type = 'hidden' name = 'daySelect', value = '$daySelect'>\n"; echo "<input type = 'hidden' name = 'dayClick', value = '1'>\n"; echo "<input type = 'hidden' name = 'login' value = '1'>\n"; echo "<input type = 'hidden' name = 'select_priority' value = '$select_priority'>\n"; echo " <td align = 'center' colspan = '2' ><input type ='submit' name='user_id' value ='$log_in_text'></td>\n"; echo " </tr>\n"; echo "</table>\n"; echo "</form>\n"; echo "<div align='center'><a href='$_SERVER[PHP_SELF]'>$back_text</a></center>\n"; } function isLoggedIn () { return $_COOKIE['logged_in']; } //---------------------------------------------------------------------------- class MyCalendar { var $daysInMonth = array (1=>31, 2=>28, 3=>31, 4=>30, 5=>31, 6=>30, 7=>31, 8=>31, 9=>30, 10=>31, 11=>30, 12=>31); var $monthName = array (1=>January, 2=>February, 3=>March, 4=>April, 5=>May, 6=>June, 7=>July, 8=>August, 9=>September, 10=>October, 11=>November, 12=>December); //---------------------------------------------------------------------------- // returns boolean result of test for leap year //---------------------------------------------------------------------------- function isLeap($yr) { return date("L", mktime(0,0,0,1,1,$yr)); } //---------------------------------------------------------------------------- // Shows the colour codes //---------------------------------------------------------------------------- function show_colour_codes () { global $priority_array; echo "<table align ='center' class='colorCodeTable'>\n"; echo "<tr>"; for($j = 0; $j <count ($priority_array); $j++) { if (strlen ($priority_array[$j])) { echo "<td class ='filledColor$j'>$priority_array[$j]</td>\n"; } } echo "</tr>\n"; echo "</table>\n"; } //---------------------------------------------------------------------------- // Given the month and year returns the number of days in the month //---------------------------------------------------------------------------- function getDaysInMonth ($yr, $mn) { $mn = intval ($mn); $yr = intval ($yr); if ($this->isLeap($yr) && $mn == 2) return 29; return $this->daysInMonth[$mn]; } //---------------------------------------------------------------------------- // Accepts values for month and year and returns // of 2 time stamps representing first and last day of month //---------------------------------------------------------------------------- /* function getDateRange ($mn, $yr, &$start, &$end) { $mn = intval ($mn); $yr = intval ($yr); $last = $this->getDaysInMonth ($yr, $mn); $start = mktime (0,0,0, $mn,1, $yr); $end = mktime (0,0,0, $mn,$last, $yr); $start = date ("Y-m-d", $start); $end = date ("Y-m-d", $end); } */ //---------------------------------------------------------------------------- // returns the first day of the month as integer //---------------------------------------------------------------------------- function getFirstDayInMonth ($yr, $mn) { $mn = intval ($mn); $yr = intval ($yr); return date("w", mktime(0,0,0,$mn,1,$yr)); } //---------------------------------------------------------------------------- // Returns the month name given the month as an integer //---------------------------------------------------------------------------- function getMonthName ($mn) { $mn = intval ($mn); return $this->monthName[$mn]; } //---------------------------------------------------------------------------- // returns current month as integer //---------------------------------------------------------------------------- function getCurrentMonth() { return intval(Date("m")); } //---------------------------------------------------------------------------- // returns current year as integer //---------------------------------------------------------------------------- function getCurrentYear () { return intval(Date("Y")); } //---------------------------------------------------------------------------- // lists all the events for the current month in a table //---------------------------------------------------------------------------- function month_events($yr, $mn) { global $No_events_listed_for; echo "<br>"; $f_array = array(); if (strlen ($mn) <2) { $mn = "0".$mn; } if ((!file_exists(DATA_DIR."todo$yr$mn.txt"))|| (!filesize (DATA_DIR."todo$yr$mn.txt"))) { echo "<center>$No_events_listed_for ".$this->getMonthName($mn)." $yr<br>\n"; return; } $f_array = file (DATA_DIR."todo$yr$mn.txt") or DebugDie (__FILE__, __LINE__, "Failed to open file for reading ".DATA_DIR."/todo$yr$mn.txt"); if (count($f_array) ==0 ) { echo "<center>No events listed for this month</center><br>\n"; return; } sort ($f_array); echo "<table align='center' class='monthEvents'>\n"; for ($row = 0; $row < count ($f_array); $row++) { $line = trim($f_array[$row]); $last_char_pos = strlen($line)-1; //get priority in last char $last_char = $line[$last_char_pos]; echo "<tr>\n"; echo "<td align='center' width='22%'>\n"; $mn_date = substr($f_array[$row], 0, 10); $mn_array = explode ("-", $mn_date); $mn_name = substr($this->getMonthName($mn_array[1]),0,3) ; $mn_date = "$mn_array[2] $mn_name $mn_array[0]"; echo "<font class='filledColor$last_char'>$mn_date</font>"; echo "</td>\n"; echo "<td>\n"; $retStr = substr ($f_array[$row], 11, strlen ($f_array[$row]) -13); echo $retStr; echo "</td>\n"; echo "</tr>\n"; } echo "</table>\n"; } //---------------------------------------------------------------------------- // gets the entries in the calendar for the given month and year // returns by ref an array of days that have entries in the calendar and array of priorities. //---------------------------------------------------------------------------- function getEntryArray($yr, $mn, &$day_array, &$priority_array) { if (strlen ($mn) <2) { $mn = "0".$mn; } $entryArray = array(); if ((!file_exists(DATA_DIR."todo$yr$mn.txt")) || (!filesize(DATA_DIR."todo$yr$mn.txt"))) { return $entryArray; } $fp = fopen (DATA_DIR."todo$yr$mn.txt", "r") or DebugDie (__FILE__, __LINE__); flock ($fp,LOCK_EX); while (!feof($fp)) { $str = fgets ($fp, 1024); if (strlen ($str) > 10) { $date_entry = substr($str, 0, 10); $day = explode ("-",$date_entry); $day_array[] = $day[2]; $temp = trim ($str); $priority_array[] = $temp[strlen($temp)-1]; } } flock ($fp, LOCK_UN); fclose ($fp); clearstatcache(); } //----------------------------------------------------------------------------- // gets event for particular day from the file //----------------------------------------------------------------------------- function showUserDayEvent($yr, $mn, $day, &$priority) { if (strlen ($mn) <2) { $mn = "0".$mn; } if (strlen ($day) <2) { $day = "0".$day; } if ( (!file_exists(DATA_DIR."todo$yr$mn.txt") )|| (!filesize (DATA_DIR."todo$yr$mn.txt"))) { $priority = 0; return ""; } $retStr = ""; $dtstr = $yr."-".$mn."-".$day; $fp = fopen (DATA_DIR."todo$yr$mn.txt", "r") or DebugDie (__FILE__, __LINE__,"Failed to open file for reading, ".DATA_DIR."/todo$yr$mn.txt");; flock ($fp,LOCK_EX); while (!feof($fp)) { $str = fgets ($fp, 1024); if (strlen ($str) > 10) { $date_entry = substr ($str, 0, 10); if (!strcmp ($date_entry, $dtstr)) { $end = strlen($str)-1; $end_ch = $str[$end]; $retStr = substr ($str, 11, strlen ($str) -13); $priority =$str[strlen ($str)-1]; } } } flock ($fp,LOCK_UN); fclose($fp); clearstatcache(); return str_replace("<br>", "\r\n", $retStr); } //--------------------------------------------------------------------------- // update entry by a particular user // put all entries in an array // if the date in the file == date of $txt then // replace entry otherwise add to array and rewrite array to file //--------------------------------------------------------------------------- function update_entry ($yr, $mn, $day, $txt, $select_priority) { // replace all linespaces and trim if (!isLoggedIn()) { return; } if (!ALLOW_HTML_CODE) { $txt = strip_tags ("$txt"); } $txt = stripslashes ("$txt"); $txt = trim ($txt); $txt = str_replace("\r\n", "<br>", $txt); $f_array = array(); if (strlen ($mn) <2) { $mn = "0".$mn; } if (strlen ($day) <2) { $day = "0".$day; } $dtstr = $yr."-".$mn."-".$day; //----------------------------------------------------------------------------- // if first entry need to create a new file but only if entry is not all spaces //----------------------------------------------------------------------------- if ((!file_exists(DATA_DIR."todo$yr$mn.txt"))|| (!filesize (DATA_DIR."todo$yr$mn.txt"))) { if (!strlen ($txt)) { return; } else { $fp = fopen (DATA_DIR."todo$yr$mn.txt", "wb"); flock ($fp,LOCK_EX); $temp = $dtstr." ".$txt.$select_priority; fputs ($fp, $temp."\n"); flock ($fp,LOCK_UN); fclose ($fp); clearstatcache(); return; } } // not new file so check if an entry already exists for that date // replace entry if found or add to end otherwise $f_array = file (DATA_DIR."todo$yr$mn.txt") or DebugDie (__FILE__, __LINE__, "Failed to open file for reading ".DATA_DIR."/todo$yr$mn.txt"); $found = false; for ($j = 0; $j< count ($f_array); $j++) { $date_entry = substr ($f_array[$j], 0, 10); if (!strcmp ( $date_entry , $dtstr)) { $found = true; if (strlen ($txt)) { $f_array[$j] = $dtstr." ".$txt.$select_priority; } else { $f_array[$j] = ""; } } } if (!$found && strlen ($txt)) { array_push ($f_array, $dtstr." ".$txt.$select_priority); } //rewrite array back to file $fp = fopen (DATA_DIR."todo$yr$mn.txt", "w") or DebugDie (__FILE__, __LINE__, "Failed to open file for writing"); flock ($fp,LOCK_EX); for ($line = 0; $line < count ($f_array); $line++) { $data = trim ($f_array[$line]); if (strlen ($data)) { fputs ($fp ,$data."\n"); } } flock ($fp,LOCK_UN); fclose ($fp); clearstatcache(); } //----------------------------------------------------------------------------- // Draws the calander table //----------------------------------------------------------------------------- function drawTable ($yr, $mn) { global $Sun,$Mon,$Tue,$Wed,$Thu,$Fri, $Sat; $entries = $this->getDaysInMonth ($yr, $mn); $firstSq = $this->getFirstDayInMonth ($yr, $mn); $arr_dates = array(); $arr_priority = array(); $this->getEntryArray($yr, $mn, $arr_dates, $arr_priority); echo "<table class='calendarTable' align='center'>\n"; echo "<tr class='calendarRow'>\n"; echo "<td class='weekheader'><b>$Sun</b></td>\n"; echo "<td class='weekheader'><b>$Mon</b></td>\n"; echo"<td class='weekheader'><b>$Tue</b></td>\n"; echo "<td class='weekheader'><b>$Wed</b></td>\n"; echo "<td class='weekheader'><b>$Thu</b></td>\n"; echo"<td class='weekheader'><b>$Fri</b></td>\n"; echo"<td class='weekheader'><b>$Sat</b></td>\n"; echo "</tr>\n"; // some of the first sqaures may be blank i.e if month doesn't // start on Sunday. so use $count to determine if square is blank $day_date= 0 - $firstSq ; for ($theRow=0; $theRow<6; $theRow++) { echo "<tr class='calendarRow'>\n"; for ($theCol=0; $theCol<7; $theCol++) { $textEntry = ""; $day_date++; if ($day_date< 1 || $day_date> $entries) { echo " <td class ='emptydate'><div align='center'>-</div></td>\n"; continue; } else { // see if there is an entry for this date and if there is // get the index of the array holding that date info $found = false; $found_index = 0; for ($j = 0; $j< count($arr_dates); $j++) { if (intval ($arr_dates[$j]) == $day_date) { $found = true; $found_index = $j; } } } $ind = 0; if (!$found) { echo "<td align='center' class ='emptydate'>\n"; } else { $ind = $arr_priority[$found_index]; echo "<td align='center' class='filledColor$ind'>\n"; if (MOUSE_OVER_EFFECT) { $textEntry = $this->showUserDayEvent($yr, $mn, $day_date, $pri); $textEntry = str_replace( "\"", """,$textEntry); $textEntry = str_replace( "'", "’",$textEntry); $textEntry = str_replace( "\r\n", " ",$textEntry); } } if (strlen($textEntry)) { echo "<a href = '$_SERVER[PHP_SELF]?dayClick=1&daySelect=$day_date&monthSelect=$mn&yearSelect=$yr&select_priority=$ind' onMouseover=\"showtip(this,event,'$textEntry')\" onMouseOut=\"hidetip()\">$day_date</a>"; } else { echo "<a href = '$_SERVER[PHP_SELF]?dayClick=1&daySelect=$day_date&monthSelect=$mn&yearSelect=$yr&select_priority=$ind'>$day_date</a>"; } echo "</td>\n"; } echo "</tr>\n"; } echo "</table>"; $this->show_colour_codes(); } //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- function display_cal () { global $monthSelect,$yearSelect; // if year and month not selected give default if (!$monthSelect) { $monthSelect=$this->getCurrentMonth(); } if (!$yearSelect) { $yearSelect=$this->getCurrentYear(); } $this->drawSelectionBox($yearSelect,$monthSelect); $this->drawTable ($yearSelect,$monthSelect); } //----------------------------------------------------------------------------- // draws the month and year selection boxes //----------------------------------------------------------------------------- function drawSelectionBox ($yearSelect,$monthSelect) { global $month_event_view, $change_text; // output the form to select month and year echo "<form method='post' action='$_SERVER[PHP_SELF]'>"; echo "<table class='selectionbox' align='center'>\n"; echo"<tr><td>\n"; // draw a select box for months. Set the default value shown to the one previously // selected e.g if user selects April then submits, the select box will // default to April for selected value echo "<select name='monthSelect'>"; for ($m = 1; $m<13; $m++) { $str = "<option value=$m"; if ($m == $monthSelect) { $str = $str." selected>".$this->getMonthName($m)."</option>"; } else { $str = $str.">".$this->getMonthName($m)."</option>"; } echo $str."\n"; } echo " </select>"; echo "</td>\n<td>\n"; // draw a select box for years. echo "<select name='yearSelect'>"; for ($yr = START_YEAR; $yr<END_YEAR; $yr++) { $str = "<option value=$yr"; if ($yr == $yearSelect) { $str = $str." selected>".$yr."</option>"; } else { $str = $str.">".$yr."</option>"; } echo $str."\n"; } echo "</select>"; echo "</td>\n<td>\n"; echo "<input type='submit' name='drawCal' value='$change_text'>"; echo"</td></tr>\n"; echo "</table>\n"; echo "</form>\n"; if (!defined('IN_MONTHS')) { echo "<center><a href = '$_SERVER[PHP_SELF]?month_events=1&yearSelect=$yearSelect&monthSelect=$monthSelect'>$month_event_view</a></center>\n"; } } //----------------------------------------------------------------------------- // Displays the edit form for a chosen day //----------------------------------------------------------------------------- function display_edit_form() { global $select_priority, $priority_array, $monthSelect, $yearSelect, $daySelect; global $dayClick, $login_text; global $repeat_every, $add_entry, $times, $no_repeat, $days_text, $weeks_text, $months_text; global $add_edit_text, $times_text; echo "<div align = 'center'>\n"; echo "<form action = '$_SERVER[PHP_SELF]' method = 'post'>\n"; echo "<table class='editForm'>\n"; //display selected date $mn_nm = $this->getMonthName ($monthSelect); echo "<tr><td>$daySelect $mn_nm $yearSelect</td></tr>\n"; $textEntry = ($this->showUserDayEvent($yearSelect, $monthSelect, $daySelect, $priority)); // check using priorities if (isLoggedIn()) { $found_pri =false; for ($j = 0; $j<count ($priority_array); $j++) { if (strlen ($priority_array[$j])) { $found_pri = true; } } if ($found_pri) { echo "<tr><td><select name='select_priority'>\n"; for ($j = 0; $j<count ($priority_array); $j++) { if (strlen ($priority_array[$j])) { if ($j==$select_priority) { echo "<option value='$j' selected>$priority_array[$j]</option>\n"; } else { echo "<option value='$j'>$priority_array[$j]</option>\n"; } } } echo "</select>\n"; } else { echo "<input type = 'hidden' name='select_priority' value='0'>\n"; } if (MULTIPLE == 1) { // repeat select box echo "<tr><td>$repeat_every <select name='select_repeat'>\n"; for ($j = 0; $j<=31; $j++) { if ($j == 0) { echo "<option value='$j'>$no_repeat</option>\n"; } else { echo "<option value='$j'>$j</option>\n"; } } echo "</select>\n"; // time block selection echo "<select name='select_time_block'>\n"; echo "<option value='days'>$days_text</option>\n"; echo "<option value='weeks'>$weeks_text</option>\n"; echo "<option value='months'>$months_text</option>\n"; echo "</select></td></tr>\n"; echo "<tr>\n"; echo "<td>$add_entry\n"; echo "<select name='num_repeats' size='1'>\n"; for ($op = 1; $op < MAX_REPEATS +1; $op++) { echo "<option value='$op'>$op</option>\n"; } echo "</select>$times</td>\n"; echo "</tr>\n"; } echo "<tr><td>"; echo "<textarea name='textEntry' cols='50' rows='5'>".str_replace("<br>","\n",(stripslashes($textEntry)))."</textarea></td></tr>\n"; echo "</td></tr>"; } else { echo "<tr><td>\n"; echo "<table width='440' border='0'>\n"; echo "<tr><td>".stripslashes($textEntry)."</td></tr>\n"; echo "</td></tr>"; echo "</table>"; echo "</td></tr>"; } echo "<input type = 'hidden' name = 'yearSelect', value = '$yearSelect'>\n"; echo "<input type = 'hidden' name = 'monthSelect', value = '$monthSelect'>\n"; echo "<input type = 'hidden' name = 'daySelect', value = '$daySelect'>\n"; if (isLoggedIn()) { echo "<tr><td><input type='submit' name='editEntry' value='$add_edit_text'></td></tr>\n"; } else { echo "<tr><td><input type = 'hidden' name='select_priority' value='$select_priority'>\n"; echo"<input type='submit' name='login' value='$login_text'></td></tr>\n"; } echo "</table>\n"; echo "</form>\n"; echo "</div>\n"; } }// end calendar class //----------------------------------------------------------------------------- if (!defined('IN_MONTHS')) { $c = new MyCalendar(); // if updating entry from entry form then check logged in and update entry if (isset($editEntry) ) { $c->update_entry($yearSelect, $monthSelect, $daySelect, $textEntry, $select_priority); if ($select_repeat) { if ( $select_time_block == 'days' || $select_time_block == 'weeks') { if ($select_time_block == 'weeks') { $select_repeat *=7; } for ($j = 0; $j < $num_repeats; $j++) { $ts = mktime (0,0,0, $monthSelect, $daySelect + $j * $select_repeat, $yearSelect); $date_arr = getdate ($ts); $yr_add = $date_arr['year']; $mn_add = $date_arr['mon']; $day_add = $date_arr['mday']; $c->update_entry( $yr_add, $mn_add, $day_add, $textEntry, $select_priority); } } else if ( $select_time_block == 'months') { for ($j = 0; $j < $num_repeats; $j++) { $prev_month = $monthSelect; $new_month = $monthSelect +j; $ts = mktime ( 0,0,0, $monthSelect + $j * $select_repeat, $daySelect, $yearSelect); $date_arr = getdate ($ts); $yr_add = $date_arr[year]; $mn_add = $date_arr[mon]; $day_add = $date_arr[mday]; // check that there are enough days in month e.g 31st if ($daySelect == $day_add) { $c->update_entry( $yr_add, $mn_add, $day_add, $textEntry, $select_priority); } } } } $c->display_cal (); $c->display_edit_form (); } elseif (isset ($login)) { if (loginCheck ()) { $c->display_cal (); $c->display_edit_form (); } } //they have just selected a day href elseif (isset($dayClick)) { $c->display_cal (); $c->display_edit_form (); } else if (isset ($month_events)) { echo "<div align='center'>\n"; echo "<a href=$_SERVER[PHP_SELF]?yearSelect=$yearSelect&monthSelect=$monthSelect>$calendar_view_text</a>\n"; echo "</div>\n"; $next_month= $monthSelect+1; $next_year = $yearSelect; if ($next_month >12) { $next_month = $next_month -12; $next_year ++; } $prev_month= $monthSelect-1; $prev_year = $yearSelect; if ($prev_month < 1) { $prev_month = $prev_month + 12; $prev_year --; } echo "<table align='center' cellpadding='5'>\n"; echo "<tr>\n"; echo "<td><a href=$_SERVER[PHP_SELF]?month_events=1&yearSelect=$prev_year&monthSelect=$prev_month>$previous_month_text</a>\n"; echo "</td>\n"; echo "<td><a href=$_SERVER[PHP_SELF]?month_events=1&yearSelect=$next_year&monthSelect=$next_month>$next_month_text</a>\n"; echo "</td>\n"; echo "</tr>\n"; echo "</table>\n"; $c->show_colour_codes(); $c->month_events($yearSelect, $monthSelect); } else { $c->display_cal (); } if (isLoggedIn()) { echo "<center><a href = '$_SERVER[PHP_SELF]?log_out=1'>$log_out_text</a></center>\n"; } } ?> </body> </html>
/* the main calendar table */ .calendarTable{ background-color: #FFFEE5; border: thin ridge; font-weight: bold; display: table; height: 200px; width: 450px; margin-left: auto; margin-right: auto; margin-top: 5; } /* Gesamttabelle*/ .calendarForm { margin: 0px; padding: 0px; border: thin ridge; } .calendarRow { } /*Farbe für freie Tage*/ .emptydate { background-color: #FFFFFF; text-align: center; border: thin ridge; } /*Farbe für erste Kategorie*/ .filledColor0 { background-color: #FFF1D1; text-align: center; border: thin ridge; } /*Farbe für zweite Kategorie*/ .filledColor1 { background-color: #E8D1B3; text-align: center; border: thin ridge; } /*Farbe für dritte Kategorie*/ .filledColor2 { background-color: #CCB598; text-align: center; border: thin ridge; } .filledColor3 { background-color: #B09B7E; text-align: center; border: thin ridge; } .filledColor4 { background-color: #CCB36A; text-align: center; border: thin ridge; } .filledColor5 { background-color: #BBCC6A; text-align: center; border: thin ridge; } .filledColor6 { background-color: #BBB3CC; text-align: center; border: thin ridge; } .filledColor7 { background-color: #FFB36A; text-align: center; border: thin ridge; } .filledColor8 { background-color: #BBFF8A; text-align: center; border: thin ridge; } .filledColor9 { background-color: #BBB6FF; text-align: center; border: thin ridge; } /* the sun mon tue header*/ .weekheaderTd { background-color: #CCCCCC; font-weight: bold; color: #FF0000; text-align: center; border: thin ridge; width: 20px; } /* Setup für das Eintragsfeld*/ .editForm { background-color: #FFFEE5; text-align: center; border: thin ridge; width: 450px; margin-left:auto; margin-right:auto; } .editFormTdTitle { font-weight: bold; } .editFormTd { } /* Tabellengröße für die einzelnen Katgorien*/ .colorCodeTable{ width: 450px; margin-left:auto; margin-right:auto; background-color: #FFFEE5; height: 10px; font-weight: bold; text-align: center; border: thin ridge; } /*Jahres- u. Monatsauswahl*/ .selectionboxTable{ background-color: #0066CC; font-weight: bold; width: 14%; } .selectionboxTd{ } /*Tabelle für monatl. Ereignisanzeige*/ .monthEvents{ background-color: #FFFEE5; border: thin ridge; width: 450px; } .monthViewLeft{ width: 0px; overflow: hidden; } .monthViewRight{ width: 0px; background-color: #EEFFFF; overflow: hidden; } .cal_link { } /* Nachrichtenanzeige wenn keine Ereignisse eingetragen*/ #noEvents { background-color: #FFFEE5; margin-left:auto; margin-right:auto; width: 450px; text-align: center; border: thin ridge; } .logInTable { width: 450px; margin-left:auto; margin-right:auto; } .logInTableTd { } .logInTableTdTwoSpan { }
<div class="marquee" id="mycrawler"> Mein Text-Crawler Text! Mein Text-Crawler Text! Mein Text-Crawler Text! Mein Text-Crawler Text! <img src="http://www.meineDomain.de/meinUnterverzeichnis/meinCrawlerBild1.jpg" /> <img src="meinCrawlerBild2.jpg" /> </div> <script type="text/javascript"> marqueeInit({ uniqueid: 'mycrawler', style: { 'padding': '0px', 'background': '#ffffff', 'width': '300px', 'height': '30px', 'color': '#000000', 'font-family': 'rockwell' }, inc: 5, //speed - pixel increment for each iteration of this marquee's movement mouse: 'cursor driven', //mouseover behavior ('pause' 'cursor driven' or false) moveatleast: 1, neutral: 20, savedirection: true }); </script>
/* Text and/or Image Crawler Script ©2009 John Davenport Scheuer as first seen in http://www.dynamicdrive.com/forums/ username: jscheuer1 - This Notice Must Remain for Legal Use */ ///////////////// DO NOT EDIT ///////////////// function marqueeInit(config){ if(!document.createElement) return; marqueeInit.ar.push(config); marqueeInit.run(config.uniqueid); } (function(){ if(!document.createElement) return; marqueeInit.ar = []; document.write('<style type="text/css">.marquee{white-space:nowrap;overflow:hidden;visibility:hidden;}' + '#marq_kill_marg_bord{border:none!important;margin:0!important;}<\/style>'); var c = 0, tTRE = [new RegExp('^\\s*$'), new RegExp('^\\s*'), new RegExp('\\s*$')], req1 = {'position': 'relative', 'overflow': 'hidden'}, defaultconfig = { style: { //default style object for marquee containers without configured style 'margin': '0 auto' }, direction: 'left', inc: 2, //default speed - pixel increment for each iteration of a marquee's movement mouse: 'pause' //default mouseover behavior ('pause' 'cursor driven' or false) }, dash, ie = false, oldie = 0, ie5 = false, iever = 0; /*@cc_on @*/ /*@if(@_jscript_version >= 5) ie = true; try{document.documentMode = 2000}catch(e){}; iever = Math.min(document.documentMode, navigator.appVersion.replace(/^.*MSIE (\d+\.\d+).*$/, '$1')); if(iever < 6) oldie = 1; if(iever < 5.5){ Array.prototype.push = function(el){this[this.length] = el;}; ie5 = true; dash = new RegExp('(-(.))'); String.prototype.encamel = function(s, m){ s = this; while((m = s.match(dash))) s = s.replace(m[1], m[2].toUpperCase()); return s; }; } @end @*/ if(!ie5){ dash = new RegExp('-(.)', 'g'); function toHump(a, b){return b.toUpperCase();}; String.prototype.encamel = function(){return this.replace(dash, toHump);}; } if(ie && iever < 8){ marqueeInit.table = []; window.attachEvent('onload', function(){ marqueeInit.OK = true; for(var i = 0; i < marqueeInit.table.length; ++i) marqueeInit.run(marqueeInit.table[i]); }); } function intable(el){ while((el = el.parentNode)) if(el.tagName && el.tagName.toLowerCase() === 'table') return true; return false; }; marqueeInit.run = function(id){ if(ie && !marqueeInit.OK && iever < 8 && intable(document.getElementById(id))){ marqueeInit.table.push(id); return; } if(!document.getElementById(id)) setTimeout(function(){marqueeInit.run(id);}, 300); else new Marq(c++, document.getElementById(id)); } function trimTags(tag){ var r = [], i = 0, e; while((e = tag.firstChild) && e.nodeType == 3 && tTRE[0].test(e.nodeValue)) tag.removeChild(e); while((e = tag.lastChild) && e.nodeType == 3 && tTRE[0].test(e.nodeValue)) tag.removeChild(e); if((e = tag.firstChild) && e.nodeType == 3) e.nodeValue = e.nodeValue.replace(tTRE[1], ''); if((e = tag.lastChild) && e.nodeType == 3) e.nodeValue = e.nodeValue.replace(tTRE[2], ''); while((e = tag.firstChild)) r[i++] = tag.removeChild(e); return r; } function Marq(c, tag){ var p, u, s, a, ims, ic, i, marqContent, cObj = this; this.mq = marqueeInit.ar[c]; for (p in defaultconfig) if((this.mq.hasOwnProperty && !this.mq.hasOwnProperty(p)) || (!this.mq.hasOwnProperty && !this.mq[p])) this.mq[p] = defaultconfig[p]; this.mq.style.width = !this.mq.style.width || isNaN(parseInt(this.mq.style.width))? '100%' : this.mq.style.width; if(!tag.getElementsByTagName('img')[0]) this.mq.style.height = !this.mq.style.height || isNaN(parseInt(this.mq.style.height))? tag.offsetHeight + 3 + 'px' : this.mq.style.height; else this.mq.style.height = !this.mq.style.height || isNaN(parseInt(this.mq.style.height))? 'auto' : this.mq.style.height; u = this.mq.style.width.split(/\d/); this.cw = this.mq.style.width? [parseInt(this.mq.style.width), u[u.length - 1]] : ['a']; marqContent = trimTags(tag); tag.className = tag.id = ''; tag.removeAttribute('class', 0); tag.removeAttribute('id', 0); if(ie) tag.removeAttribute('className', 0); tag.appendChild(tag.cloneNode(false)); tag.className = ['marquee', c].join(''); tag.style.overflow = 'hidden'; this.c = tag.firstChild; this.c.appendChild(this.c.cloneNode(false)); this.c.style.visibility = 'hidden'; a = [[req1, this.c.style], [this.mq.style, this.c.style]]; for (i = a.length - 1; i > -1; --i) for (p in a[i][0]) if((a[i][0].hasOwnProperty && a[i][0].hasOwnProperty(p)) || (!a[i][0].hasOwnProperty)) a[i][1][p.encamel()] = a[i][0][p]; this.m = this.c.firstChild; if(this.mq.mouse == 'pause'){ this.c.onmouseover = function(){cObj.mq.stopped = true;}; this.c.onmouseout = function(){cObj.mq.stopped = false;}; } this.m.style.position = 'absolute'; this.m.style.left = '-10000000px'; this.m.style.whiteSpace = 'nowrap'; if(ie5) this.c.firstChild.appendChild((this.m = document.createElement('nobr'))); if(!this.mq.noAddedSpace) this.m.appendChild(document.createTextNode('\xa0')); for(i = 0; marqContent[i]; ++i) this.m.appendChild(marqContent[i]); if(ie5) this.m = this.c.firstChild; ims = this.m.getElementsByTagName('img'); if(ims.length){ for(ic = 0, i = 0; i < ims.length; ++i){ ims[i].style.display = 'inline'; ims[i].style.verticalAlign = ims[i].style.verticalAlign || 'top'; if(typeof ims[i].complete == 'boolean' && ims[i].complete && !window.opera) ic++; else { ims[i].onload = function(){ if(++ic == ims.length) cObj.setup(); }; } if(ic == ims.length) this.setup(); } } else this.setup() } Marq.prototype.setup = function(){ if(this.mq.setup) return; this.mq.setup = this; var s, cObj = this; if(this.c.style.height === 'auto') this.c.style.height = this.m.offsetHeight + 4 + 'px'; this.c.appendChild(this.m.cloneNode(true)); this.m = [this.m, this.m.nextSibling]; if(this.mq.mouse == 'cursor driven'){ this.r = this.mq.neutral || 16; this.sinc = this.mq.inc; this.c.onmousemove = function(e){cObj.mq.stopped = false; cObj.directspeed(e)}; if(this.mq.moveatleast){ this.mq.inc = this.mq.moveatleast; if(this.mq.savedirection){ if(this.mq.savedirection == 'reverse'){ this.c.onmouseout = function(e){ if(cObj.contains(e)) return; cObj.mq.inc = cObj.mq.moveatleast; cObj.mq.direction = cObj.mq.direction == 'right'? 'left' : 'right';}; } else { this.mq.savedirection = this.mq.direction; this.c.onmouseout = function(e){ if(cObj.contains(e)) return; cObj.mq.inc = cObj.mq.moveatleast; cObj.mq.direction = cObj.mq.savedirection;}; } } else this.c.onmouseout = function(e){if(!cObj.contains(e)) cObj.mq.inc = cObj.mq.moveatleast;}; } else this.c.onmouseout = function(e){if(!cObj.contains(e)) cObj.slowdeath();}; } this.w = this.m[0].offsetWidth; this.m[0].style.left = 0; this.c.id = 'marq_kill_marg_bord'; this.m[0].style.top = this.m[1].style.top = Math.floor((this.c.offsetHeight - this.m[0].offsetHeight) / 2 - oldie) + 'px'; this.c.id = ''; this.c.removeAttribute('id', 0); this.m[1].style.left = this.w + 'px'; s = this.mq.moveatleast? Math.max(this.mq.moveatleast, this.sinc) : (this.sinc || this.mq.inc); while(this.c.offsetWidth > this.w - s) this.c.style.width = isNaN(this.cw[0])? this.w - s + 'px' : --this.cw[0] + this.cw[1]; this.c.style.visibility = 'visible'; this.runit(); } Marq.prototype.slowdeath = function(){ var cObj = this; if(this.mq.inc){ this.mq.inc -= 1; this.timer = setTimeout(function(){cObj.slowdeath();}, 100); } } Marq.prototype.runit = function(){ var cObj = this, d = this.mq.direction == 'right'? 1 : -1; if(this.mq.stopped || this.mq.stopMarquee){ setTimeout(function(){cObj.runit();}, 300); return; } if(this.mq.mouse != 'cursor driven') this.mq.inc = Math.max(1, this.mq.inc); if(d * parseInt(this.m[0].style.left) >= this.w) this.m[0].style.left = parseInt(this.m[1].style.left) - d * this.w + 'px'; if(d * parseInt(this.m[1].style.left) >= this.w) this.m[1].style.left = parseInt(this.m[0].style.left) - d * this.w + 'px'; this.m[0].style.left = parseInt(this.m[0].style.left) + d * this.mq.inc + 'px'; this.m[1].style.left = parseInt(this.m[1].style.left) + d * this.mq.inc + 'px'; setTimeout(function(){cObj.runit();}, 30 + (this.mq.addDelay || 0)); } Marq.prototype.directspeed = function(e){ e = e || window.event; if(this.timer) clearTimeout(this.timer); var c = this.c, w = c.offsetWidth, l = c.offsetLeft, mp = (typeof e.pageX == 'number'? e.pageX : e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft) - l, lb = (w - this.r) / 2, rb = (w + this.r) / 2; while((c = c.offsetParent)) mp -= c.offsetLeft; this.mq.direction = mp > rb? 'left' : 'right'; this.mq.inc = Math.round((mp > rb? (mp - rb) : mp < lb? (lb - mp) : 0) / lb * this.sinc); } Marq.prototype.contains = function(e){ if(e && e.relatedTarget){var c = e.relatedTarget; if(c == this.c) return true; while ((c = c.parentNode)) if(c == this.c) return true;} return false; } function resize(){ for(var s, m, i = 0; i < marqueeInit.ar.length; ++i){ if(marqueeInit.ar[i] && marqueeInit.ar[i].setup){ m = marqueeInit.ar[i].setup; s = m.mq.moveatleast? Math.max(m.mq.moveatleast, m.sinc) : (m.sinc || m.mq.inc); m.c.style.width = m.mq.style.width; m.cw[0] = m.cw.length > 1? parseInt(m.mq.style.width) : 'a'; while(m.c.offsetWidth > m.w - s) m.c.style.width = isNaN(m.cw[0])? m.w - s + 'px' : --m.cw[0] + m.cw[1]; } } } if (window.addEventListener) window.addEventListener('resize', resize, false); else if (window.attachEvent) window.attachEvent('onresize', resize); })();
<script type="text/javascript"> new pausescroller(pausecontent, "pscroller1", "someclass", 3000) </script>
<style type="text/css"> #pscroller1{ width: 300px; height: 40px; border: 0px solid black; padding: 2px; background-color: #aaaaaa; font-family:Rockwell; font-size:14px; font-weight:bold; color:#ffffff; } </style> <script type="text/javascript"> /*Hier Beispielangaben für Websites, Text und Bilder - jede pausecontent-Zeile muss OHNE Zeilenumbruch eingegeben werden.*/ var pausecontent=new Array() pausecontent[0]='<a href="http://www.ichrr.de" target="_blank">RRs</a><br />Private Website, nur so zum Spaß.' pausecontent[1]='Textzeile, für einfache Mitteilungen. ' pausecontent[2]='<img src="http://www.ichrr.de/favicon.ico" alt="Bookmark von ichrr" border="1"/><br>Text zum Bild, wenn nötig.' </script> <script type="text/javascript"> /*********************************************** * Pausing up-down scroller- © Dynamic Drive (www.dynamicdrive.com) * This notice MUST stay intact for legal use * Visit http://www.dynamicdrive.com/ for this script and 100s more. ***********************************************/ function pausescroller(content, divId, divClass, delay){ this.content=content //message array content this.tickerid=divId //ID of ticker div to display information this.delay=delay //Delay between msg change, in miliseconds. this.mouseoverBol=0 //Boolean to indicate whether mouse is currently over scroller (and pause it if it is) this.hiddendivpointer=1 //index of message array for hidden div document.write('<div id="'+divId+'" class="'+divClass+'" style="position: relative; overflow: hidden"><div class="innerDiv" style="position: absolute; width: 100%" id="'+divId+'1">'+content[0]+'</div><div class="innerDiv" style="position: absolute; width: 100%; visibility: hidden" id="'+divId+'2">'+content[1]+'</div></div>') var scrollerinstance=this if (window.addEventListener) //run onload in DOM2 browsers window.addEventListener("load", function(){scrollerinstance.initialize()}, false) else if (window.attachEvent) //run onload in IE5.5+ window.attachEvent("onload", function(){scrollerinstance.initialize()}) else if (document.getElementById) //if legacy DOM browsers, just start scroller after 0.5 sec setTimeout(function(){scrollerinstance.initialize()}, 500) } // ------------------------------------------------------------------- // initialize()- Initialize scroller method. // -Get div objects, set initial positions, start up down animation // ------------------------------------------------------------------- pausescroller.prototype.initialize=function(){ this.tickerdiv=document.getElementById(this.tickerid) this.visiblediv=document.getElementById(this.tickerid+"1") this.hiddendiv=document.getElementById(this.tickerid+"2") this.visibledivtop=parseInt(pausescroller.getCSSpadding(this.tickerdiv)) //set width of inner DIVs to outer DIV's width minus padding (padding assumed to be top padding x 2) this.visiblediv.style.width=this.hiddendiv.style.width=this.tickerdiv.offsetWidth-(this.visibledivtop*2)+"px" this.getinline(this.visiblediv, this.hiddendiv) this.hiddendiv.style.visibility="visible" var scrollerinstance=this document.getElementById(this.tickerid).onmouseover=function(){scrollerinstance.mouseoverBol=1} document.getElementById(this.tickerid).onmouseout=function(){scrollerinstance.mouseoverBol=0} if (window.attachEvent) //Clean up loose references in IE window.attachEvent("onunload", function(){scrollerinstance.tickerdiv.onmouseover=scrollerinstance.tickerdiv.onmouseout=null}) setTimeout(function(){scrollerinstance.animateup()}, this.delay) } // ------------------------------------------------------------------- // animateup()- Move the two inner divs of the scroller up and in sync // ------------------------------------------------------------------- pausescroller.prototype.animateup=function(){ var scrollerinstance=this if (parseInt(this.hiddendiv.style.top)>(this.visibledivtop+5)){ this.visiblediv.style.top=parseInt(this.visiblediv.style.top)-5+"px" this.hiddendiv.style.top=parseInt(this.hiddendiv.style.top)-5+"px" setTimeout(function(){scrollerinstance.animateup()}, 50) } else{ this.getinline(this.hiddendiv, this.visiblediv) this.swapdivs() setTimeout(function(){scrollerinstance.setmessage()}, this.delay) } } // ------------------------------------------------------------------- // swapdivs()- Swap between which is the visible and which is the hidden div // ------------------------------------------------------------------- pausescroller.prototype.swapdivs=function(){ var tempcontainer=this.visiblediv this.visiblediv=this.hiddendiv this.hiddendiv=tempcontainer } pausescroller.prototype.getinline=function(div1, div2){ div1.style.top=this.visibledivtop+"px" div2.style.top=Math.max(div1.parentNode.offsetHeight, div1.offsetHeight)+"px" } // ------------------------------------------------------------------- // setmessage()- Populate the hidden div with the next message before it's visible // ------------------------------------------------------------------- pausescroller.prototype.setmessage=function(){ var scrollerinstance=this if (this.mouseoverBol==1) //if mouse is currently over scoller, do nothing (pause it) setTimeout(function(){scrollerinstance.setmessage()}, 100) else{ var i=this.hiddendivpointer var ceiling=this.content.length this.hiddendivpointer=(i+1>ceiling-1)? 0 : i+1 this.hiddendiv.innerHTML=this.content[this.hiddendivpointer] this.animateup() } } pausescroller.getCSSpadding=function(tickerobj){ //get CSS padding value, if any if (tickerobj.currentStyle) return tickerobj.currentStyle["paddingTop"] else if (window.getComputedStyle) //if DOM2 return window.getComputedStyle(tickerobj, "").getPropertyValue("padding-top") else return 0 } </script>