session_start();
$text = file_get_contents("data/text.yml");
$textArr = explode("\n",$text);
$_SESSION["text"] = [];
foreach($textArr as $textRow) {
$textRowArr = explode("\t",$textRow);
$textRowKey = str_replace(":","",$textRowArr[0]);
$_SESSION["text"]["$textRowKey"] = str_replace("\n","",str_replace("\r","",$textRowArr[count($textRowArr)-1]));
}
function string2sql($string) {
return utf8_decode((str_replace("'",'"',$string)));
}
function text($key) {
if(isset($_SESSION["text"]["$key"])) {
return $_SESSION["text"]["$key"];
} else {
return $key;
}
}
function randomQuiz() {
/*$array = array();
if ($handle = opendir('data/questions/')) {
while (false !== ($entry = readdir($handle))) {
if ($entry != "." && $entry != "..") {
$array[] = $entry;
}
}
closedir($handle);
}
shuffle($array);
return $array[0];*/
return "fragen.csv";
}
?>
Gewinnspiel
require_once 'class/mobile/Mobile_Detect.php';
$detect = new Mobile_Detect;
$deviceType = ($detect->isMobile() ? ($detect->isTablet() ? 'tablet' : 'phone') : 'computer');
if($deviceType=="phone") {
$content = file_get_contents("count/phone.txt");
$file = fopen("count/phone.txt","w");
fwrite($file,$content.".");
fclose($file);
?>
} else if($deviceType=="tablet") {
$content = file_get_contents("count/tablet.txt");
$file = fopen("count/tablet.txt","w");
fwrite($file,$content.".");
fclose($file);
?>
} else {
$content = file_get_contents("count/computer.txt");
$file = fopen("count/computer.txt","w");
fwrite($file,$content.".");
fclose($file);
}
?>
if(isset($_GET["game"])) {
/*$turnus = explode("|",file_get_contents("data/turnus"));
if(file_exists("data/log/".date("d.m.Y").".log")) {
$csv = file_get_contents("data/questions/".file_get_contents("data/log/".date("d.m.Y").".log"));
$title = file_get_contents("data/log/".date("d.m.Y").".log");
} else {
if($turnus[0]=="1") {
if(date("N")==$turnus[1]||!file_exists("data/log/turnus.log")) {
$file = fopen("data/log/turnus.log","w");
fwrite($file,randomQuiz());
fclose($file);
}
$title = file_get_contents("data/log/turnus.log");
} else {
if(!file_exists("data/log/".date("d.m.Y").".log")) {
$file = fopen("data/log/".date("d.m.Y").".log","w");
fwrite($file,randomQuiz());
fclose($file);
}
$title = file_get_contents("data/log/".date("d.m.Y").".log");
}
$csv = file_get_contents("data/questions/".$title);
}*/
function isWeekend($date) {
return (date('N', strtotime($date)) >= 6);
}
if(isWeekend(date("Y-m-d"))===true) {
if(!file_exists("data/log/".date("d.m.Y").".log")) {
$file = fopen("data/log/".date("d.m.Y").".log","w");
fwrite($file,"");
fclose($file);
$file = fopen("data/questions/fragen.csv","w");
fwrite($file,file_get_contents("data/questions/fragen.neu.csv"));
fclose($file);
}
}
$csv = utf8_encode(file_get_contents("data/questions/fragen.csv"));
?>