117 lines
3.7 KiB
PHP
117 lines
3.7 KiB
PHP
<!doctype html>
|
||
<html lang="en" class="no-js">
|
||
<head>
|
||
<meta charset="utf-8">
|
||
<meta http-equiv="refresh" content="915; url=index.php" />
|
||
<meta http-equiv="x-ua-compatible" content="ie=edge">
|
||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||
<title>Schreib auf die Erika</title>
|
||
<meta name="description" content="Simple Webseite, um auf Erika zu tippen.">
|
||
<link rel="stylesheet" href="style.css">
|
||
</head>
|
||
|
||
<body>
|
||
<header>
|
||
<div id="logo"><img src="logo.png">Erika-Tippmaschine</div>
|
||
<nav>
|
||
<ul>
|
||
<li><a href="./">Heim</a>
|
||
<!-- <li><a href="https://html-css-js.com/">HTML</a>
|
||
<li><a href="https://html-css-js.com/css/code/">CSS</a>
|
||
<li><a href="https://htmlcheatsheet.com/js/">JS</a> -->
|
||
</ul>
|
||
</nav>
|
||
</header>
|
||
<section>
|
||
<?php
|
||
include 'const.php';
|
||
|
||
// Letzten Timestamp lesen
|
||
$date = new DateTime();
|
||
$myfile=fopen(ZEITDATEI,'rt');
|
||
flock($myfile,LOCK_SH);
|
||
$letztesmal=file_get_contents(ZEITDATEI);
|
||
fclose($myfile);
|
||
|
||
$restzeit = intval($letztesmal)+(PAUSEZEIT_MS/1000) - $date->getTimestamp();
|
||
//echo "Letztesmal:".$letztesmal."----heute".($date->getTimestamp())."rest: ".$restzeit;
|
||
|
||
// timestamp vergleichen
|
||
if( $restzeit > 0)
|
||
{
|
||
?>
|
||
<strong>Leider ist die Zeit noch nicht reif für die nächste Aktion
|
||
mit der Schreibmaschine</strong> Versuche es später nochmal.
|
||
<?php
|
||
echo "Restzeit: ".$restzeit."s";
|
||
}
|
||
else
|
||
{
|
||
|
||
// Schreibe aktuellen Timestamp in eine Datei, die später ausgelesen wird
|
||
file_put_contents(ZEITDATEI, $date->getTimestamp(), LOCK_EX);
|
||
|
||
// textverarbeitung
|
||
$text = $_POST['texta'];
|
||
$len = strlen(utf8_decode($text));
|
||
if ( $len > TEXT_MAXLEN )
|
||
{
|
||
$meldung = "Text ist zu lang und wurde eingekürzt";
|
||
$text = substr($text, 0, TEXT_MAXLEN);
|
||
}
|
||
|
||
echo "Text: ".$len." von erlaubten ".TEXT_MAXLEN." Zeichen.";
|
||
|
||
$nlkorrekt = preg_replace('~\R~u', "\n", $text); // 2044 = /
|
||
//$suchmuster = '~[^-a-zA-Z0-9äüöÄÜÖß\s,;\.:()°%&²³µ€ç£èé=^_&$§"!+*#\?\t\n\r´`/]~m';
|
||
$suchmuster = REGEX_FILTER;
|
||
$ersetzung = '?';
|
||
$neuertext = preg_filter($suchmuster, $ersetzung, $nlkorrekt);
|
||
|
||
//Ersetze vier+mehr \n durch \n---\n
|
||
$newlinebereinigt = preg_replace('/(\R){3,}/mu', "\n---\n", $neuertext );
|
||
|
||
$umgebrochen = wordwrap($newlinebereinigt, TEXT_MAXLINE);
|
||
|
||
//echo "<pre>".$nlkorrekt."</pre>";
|
||
//echo "NT:<pre>".$neuertext."</pre>";
|
||
//echo "<br/>Der Text:<br/>";
|
||
//echo "<pre>".$newlinebereinigt."</pre>";
|
||
//echo "<br/>";
|
||
$arg = escapeshellarg($umgebrochen);
|
||
//echo "<br/> arg: ".$arg;
|
||
|
||
$res = system(ERIKA_CMD." ".$arg);
|
||
echo "<br/>";
|
||
echo "<strong>Befehl wurde ausgeführt: ".$res."</strong>. ";
|
||
?>
|
||
</section>
|
||
<section id="pageContent">
|
||
<main role="main">
|
||
<h1>Erika schreibt</h1>
|
||
<article>
|
||
<p>Wenn alles gut war, ist jetzt der Text zu sehen:
|
||
</p>
|
||
<br/>
|
||
<pre><?php echo $umgebrochen ?></pre>
|
||
</article>
|
||
<h1>Zurück</h1>
|
||
<article>
|
||
Hier geht's wieder <a href="./" >zurück</a>. Normalerweise aber automatisch.
|
||
</article>
|
||
|
||
</main>
|
||
</section>
|
||
<?php
|
||
}
|
||
?>
|
||
<footer>
|
||
<p>© Robert Köpferl für ChCh und Klub Solitär | Vorlage: <a href="https://html5-templates.com/" target="_blank" rel="nofollow">HTML5 Templates</a></p>
|
||
<address>
|
||
Kontakt: <a href="mailto:presse@klub-solitaer.de">E-Mail an Klub Solitär</a>
|
||
</address>
|
||
</footer>
|
||
</body>
|
||
|
||
</html>
|