Dateien nach "/" hochladen

This commit is contained in:
gruinelli 2024-03-17 17:18:37 +00:00
parent 44a0800b48
commit 520a0425d4
5 changed files with 341 additions and 0 deletions

12
config.php Normal file
View File

@ -0,0 +1,12 @@
<?
// Name of the Church (Will be shown in the title)
define('NAME_OF_CHURCH', 'Kirche Neuwies');
// Set the URL to the calendar (ICS-file, eg. https://neuwies.churchtools.de/?q=churchcal/ical
define('URL_TO_CALENDAR', 'https://neuwies.churchtools.de/?q=churchcal/ical');
?>

BIN
favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 446 B

249
index.php Normal file
View File

@ -0,0 +1,249 @@
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Copyright 2017 by George Ruinelli <george@ruinelli.ch>
Licence: GPL
Last Change: 10.02.2022
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<?php
include('common.php');
// Add the GET-Parameter "debug" for additional output
if(isset($_GET['debug'])) {
define('DEBUG', 1);
}
?>
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="UTF-8">
<http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="shortcut icon" href="favicon.ico">
<title><? echo(NAME_OF_CHURCH); ?> Nächste Termine</title>
<link rel="stylesheet" href="style.css">
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<?
$textStyle = "font-family: Arial; font-size: 11pt;";
$textStyleLarger = "font-family: Arial; font-size: 14pt;";
$titleStyle = "font-family: Arial Black; font-size: 14pt;";
$titleStyleLarger = "font-family: Arial Black; font-size: 16pt;";
?>
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script src="javascript.js"></script>
</head>
<body style="background-color: #eee">
<div>
<h1>
<img src="logo_small.png" > &ndash; N&auml;chste Termine</h1>
<div style="margin: 20px">
<?
if(isset($_GET['date'])) {
$startDateForm = $_GET['date'];
}
else{
// http://php.net/manual/de/function.date.php
// select next sunday
// $startDateForm = $weekdays[date('N', strtotime('next sunday')) - 1] . date('. j. ', strtotime('next sunday')) . $monthNames[date('n', strtotime('next sunday')) - 1];
$startDateForm = date('d.m.Y', strtotime('next sunday'));
}
if(defined('DEBUG')) {
// echo("__" . date('n', strtotime('next sunday')) . "__");
// echo("__" . $monthNames[date('n', strtotime('next sunday')) - 1] . "__");
echo("<pre>startDateForm: $startDateForm</pre>\n");
}
$startDateCleaned = str_replace(" ", "", $startDateForm);
// $startDateCleaned = str_replace(".", " ", $startDateForm);
list($day, $month, $year) = explode(".", trim($startDateCleaned));
if(defined('DEBUG')) {
echo("<pre>startDateCleaned: $startDateCleaned</pre>\n");
echo("<pre>Day, Month, Year: $day, $month, $year</pre>\n");
}
if(isset($_GET['timeSpan'])) {
$timeSpan = $_GET['timeSpan'];
}
else{
$timeSpan = "1week";
}
if(defined('DEBUG')) {
echo("<pre>timeSpan: $timeSpan</pre>\n");
}
if($timeSpan == "1week"){
$timeSpanDays = 7;
$mode = "weeks";
}
elseif($timeSpan == "2weeks"){
$timeSpanDays = 14;
$mode = "weeks";
}
elseif($timeSpan == "3weeks"){
$timeSpanDays = 21;
$mode = "weeks";
}
elseif($timeSpan == "4weeks"){
$timeSpanDays = 28;
$mode = "weeks";
}
elseif($timeSpan == "16weeks"){
$timeSpanDays = 28*4;
$mode = "weeks";
}
elseif($timeSpan == "nextmonth" or $timeSpan == "afternextmonth"){
$mode = "months";
}
else{
die("Unbekannte Angabe für timeSpan!");
}
if(defined('DEBUG')) {
echo("<pre>mode: $mode</pre>\n");
}
if($mode == "weeks"){
$timeSpanSeconds = 3600 * 24 * $timeSpanDays;
// print_r($dateParts);
// echo("<br>" . $dateParts[1] . " " . $dateParts[2]);
// $startDate = strptime($dateParts[1] . " " . $dateParts[2], " %e. %m");
// $startDate = mktime(0, 0, 0, $monthDE[$dateParts[2]], $dateParts[1], date("Y"));
$startDate = mktime(0, 0, 0, $month, $day, $year);
// echo("<br>Start: $startDate<br>");
// echo("<br>Start: ". strftime("%c", $startDate) . "<br>");
$startDateIcs = strftime("%Y%m%dT000000Z", $startDate);
// echo("startDateIcs: ". $startDateIcs . "<br>");
$endDateIcs = strftime("%Y%m%dT235959Z", $startDate + $timeSpanSeconds);
// echo("endDateIcs: ". $endDateIcs . "<br><br>");
// $startDMY = strftime("%d.%m.%Y", $startDate);
$startDMY = strftime("%d. ", $startDate) . $monthNamesShort[(strftime("%m", $startDate)-1)*1] . strftime(". %Y", $startDate);
// $endDMY = strftime("%d.%m.%Y", $startDate + $timeSpanSeconds);
$endDMY = strftime("%d. ", $startDate + $timeSpanSeconds) . $monthNamesShort[(strftime("%m", $startDate + $timeSpanSeconds)-1)*1] . strftime(". %Y", $startDate + $timeSpanSeconds);
$startDayFormated = strftime("%e.", $startDate);
// $startMonthFormated = $monthNamesShort[(strftime("%m", $startDate)-1)*1] . ".";
$startMonthFormated = $monthNames[(strftime("%m", $startDate)-1)*1];
$startYearFormated = strftime("%Y", $startDate);
$endDayFormated = strftime("%e.", $startDate + $timeSpanSeconds);
// $endMonthFormated = $monthNamesShort[(strftime("%m", $startDate + $timeSpanSeconds)-1)*1] . ".";
$endMonthFormated = $monthNames[(strftime("%m", $startDate + $timeSpanSeconds)-1)*1];
$endYearFormated = strftime("%Y", $startDate + $timeSpanSeconds);
if ($startMonthFormated == $endMonthFormated) { # Start and end in same month
$formatedDateSpan = "$startDayFormated &ndash; $endDayFormated $endMonthFormated $endYearFormated";
}
else if (($startDayFormated != $endDayFormated) && ($startYearFormated == $endYearFormated)) { // Start and end not in same month but same year
$formatedDateSpan = "$startDayFormated $startMonthFormated &ndash; $endDayFormated $endMonthFormated $endYearFormated";
}
else { # Start and end not in same year
$formatedDateSpan = "$startDayFormated $startMonthFormated $startYearFormated &ndash; $endDayFormated $endMonthFormated $endYearFormated";
}
if(defined('DEBUG')) {
// echo("<pre>Month: -" . $dateParts[2] . "- => " . $monthDE[$dateParts[2]] . "</pre>\n");
echo("<pre>startDMY: $startDMY</pre>\n");
echo("<pre>mktime(0, 0, 0, $month, $day, $year);</pre>\n");
echo("<pre>endDMY: $endDMY</pre>\n");
}
}
else{ //months
$firstDayOfCurrentMonth = date("Y-m-01"); //2017-07-01
// $firstDayOfCurrentMonth = date("2016-12-1"); //test
// $firstDayOfCurrentMonth = date("2017-1-1"); //test
// $firstDayOfCurrentMonth = date("2017-2-1"); //test
if($timeSpan == "nextmonth"){
$firstOfMonth = strtotime ( '+1 month' , strtotime ( $firstDayOfCurrentMonth ) ) ;
}
else{ //after next month
$firstOfMonth = strtotime ( '+2 month' , strtotime ( $firstDayOfCurrentMonth ) ) ;
}
$lastDayOfMonth = strtotime ( '+1 month' , $firstOfMonth) - 1; //first day of next month minus 1 second
$startDateIcs = strftime("%Y%m%dT000000Z", $firstOfMonth);
$endDateIcs = strftime("%Y%m%dT235959Z", $lastDayOfMonth);
$monthNo = strftime("%m", $firstOfMonth);
$month = $monthNames[$monthNo-1];
$year = strftime("%Y", $firstOfMonth);
if(defined('DEBUG')) {
echo("<pre>startDateIcs: $startDateIcs ($firstOfMonth)</pre>");
echo("<pre>endDateIcs: $endDateIcs ($lastDayOfMonth)</pre>");
echo("<pre>firstOfMonth: $firstOfMonth ($monthNo)</pre>");
}
}
?>
<form action="index.php" method="get">
<input type=text class="date_input" name=date id=datepicker value="<? echo($startDateForm); ?>"
onchange="reloadPage(event.target.value, '<? echo($timeSpan); ?>');" size=10> <a href=".">Nächster Sonntag</a><br>
<label><input type="radio" name="timeSpan" value="1week" <? if($timeSpan == "1week"){ echo("checked=true"); } ?>
onclick="reloadPage('<? echo($startDateForm); ?>', '1week');">1 Woche</label><br>
<label><input type="radio" name="timeSpan" value="2weeks" <? if($timeSpan == "2weeks"){ echo("checked=true"); } ?>
onclick="reloadPage('<? echo($startDateForm); ?>', '2weeks');">2 Wochen</label><br>
<label><input type="radio" name="timeSpan" value="3weeks" <? if($timeSpan == "3weeks"){ echo("checked=true"); } ?>
onclick="reloadPage('<? echo($startDateForm); ?>', '3weeks');">3 Wochen</label><br>
<label><input type="radio" name="timeSpan" value="4weeks" <? if($timeSpan == "4weeks"){ echo("checked=true"); } ?>
onclick="reloadPage('<? echo($startDateForm); ?>', '4weeks');">4 Wochen</label><br>
<label><input type="radio" name="timeSpan" value="nextmonth" <? if($timeSpan == "nextmonth"){ echo("checked=true"); } ?>
onclick="reloadPage('<? echo($startDateForm); ?>', 'nextmonth');">Nächster Monat</label><br>
<label><input type="radio" name="timeSpan" value="afternextmonth" <? if($timeSpan == "afternextmonth"){ echo("checked=true"); } ?>
onclick="reloadPage('<? echo($startDateForm); ?>', 'afternextmonth');">Übernächster Monat</label>
<!-- <br> -->
<!-- <input type="submit" value="Lade Termine" style> -->
</form>
<hr>
<button style="width: 200px;" value="Program kopieren" onclick="selectElementContents( document.getElementById('Content') );">Programm kopieren</button>
<div id="Content" class="content">
<?
if($mode == "weeks"){
include('week.php');
}
else{ // months
include('month.php');
}
?>
</div>
<!-- <button style="width: 200px;" value="Program kopieren" onclick="selectElementContents( document.getElementById('Content') );">Programm kopieren</button> -->
<hr>
Quelle: <a href="<? echo(URL_TO_CALENDAR); ?>" target="_blank"><? echo(URL_TO_CALENDAR); ?></a><br>
Support: <a href="mailto:george[at]ruinelli.ch">george[at]ruinelli.ch</a>
</div>
</body>
</html>

1
info.txt Normal file
View File

@ -0,0 +1 @@
Bei Fragen bitte an George wenden.

79
javascript.js Normal file
View File

@ -0,0 +1,79 @@
/* -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Copyright 2017 by George Ruinelli <george@ruinelli.ch>
Licence: GPL
Last Change: 13.10.2017
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
$(function() {
$('#datepicker').datepicker({
prevText: '&#x3c;zurück', prevStatus: '',
prevJumpText: '&#x3c;&#x3c;', prevJumpStatus: '',
nextText: 'Vor&#x3e;', nextStatus: '',
nextJumpText: '&#x3e;&#x3e;', nextJumpStatus: '',
currentText: 'heute', currentStatus: '',
todayText: 'heute', todayStatus: '',
clearText: '-', clearStatus: '',
closeText: 'schließen', closeStatus: '',
// monthNames: ['Januar','Februar','März','April','Mai','Juni', 'Juli','August','September','Oktober','November','Dezember'],
// monthNamesShort: ['Jan','Feb','Mär','Apr','Mai','Jun', 'Jul','Aug','Sep','Okt','Nov','Dez'],
// dayNames: ['Sonntag','Montag','Dienstag','Mittwoch','Donnerstag','Freitag','Samstag'],
// dayNamesShort: ['So','Mo','Di','Mi','Do','Fr','Sa'],
// dayNamesMin: ['So','Mo','Di','Mi','Do','Fr','Sa'],
showMonthAfterYear: false,
firstDay: 1,
showOn: 'both',
// buttonImage: 'media/img/calendar.png',
// buttonImageOnly: true,
// http://keith-wood.name/datepick.HTML
// dateFormat:'D d. MM'
dateFormat:'dd.mm.yy'
}
);
});
function selectElementContents(el) {
var body = document.body, range, sel;
if (document.createRange && window.getSelection) {
range = document.createRange();
sel = window.getSelection();
sel.removeAllRanges();
try {
range.selectNodeContents(el);
sel.addRange(range);
} catch (e) {
range.selectNode(el);
sel.addRange(range);
}
} else if (body.createTextRange) {
range = body.createTextRange();
range.moveToElementText(el);
range.select();
}
// Use try & catch for unsupported browser
try {
// The important part (copy selected text)
var successful = document.execCommand('copy');
if(successful) alert('Inhalt kopiert!');
else alert('Kopieren nicht möglich!');
} catch (err) {
alert('Unsupported Browser!');
}
}
function reloadPage(date, timeSpan) {
url = "index.php?date=" + date + "&timeSpan=" + timeSpan;
console.log("Redirecting to " + url);
window.location.href=url;
}
$( function() {
$( ".date_input" ).datepicker();
} );