Add uebung8
This commit is contained in:
47
cgi-bin/uebung08/hangman_lib.php
Normal file
47
cgi-bin/uebung08/hangman_lib.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
// startet die Session und initialisiert das tasks-Array
|
||||
function startHangmanSession()
|
||||
{
|
||||
// Setze einen eindeutigen Session-Name: zdvlogin mit suffix todo
|
||||
// get_current_user() liefert den Benutzernamen
|
||||
session_name(get_current_user() . "hangman");
|
||||
session_start();
|
||||
|
||||
if (!isset($_SESSION['state'])) {
|
||||
resetTasks();
|
||||
}
|
||||
}
|
||||
|
||||
// Löscht alle Session Daten
|
||||
function resetTasks()
|
||||
{
|
||||
$_SESSION['state'] = [];
|
||||
}
|
||||
|
||||
//Bringt ein Wort in das richtige Format
|
||||
function transformWord($word) {
|
||||
$word = strtoupper($word);
|
||||
$word = str_replace("Ä", "AE", $word);
|
||||
$word = str_replace("Ö", "OE", $word);
|
||||
$word = str_replace("Ü", "UE", $word);
|
||||
$word = str_replace("ß", "SS", $word);
|
||||
|
||||
return $word;
|
||||
}
|
||||
|
||||
//Maskiert ein Wort mit _
|
||||
function maskWord($word) {
|
||||
$arr = array();
|
||||
for ($i = 0; i < strlen($word); $i++) {
|
||||
$arr[] = "_";
|
||||
}
|
||||
return $arr;
|
||||
}
|
||||
|
||||
function getAllWords() {
|
||||
return include("words-array.php");
|
||||
}
|
||||
|
||||
|
||||
?>
|
Reference in New Issue
Block a user