diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b72b7e5 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/vendor/images/background.xcf diff --git a/index.php b/index.php index 18e1fee..b9660b2 100644 --- a/index.php +++ b/index.php @@ -6,9 +6,20 @@ require_once 'main.inc.php'; try { + // Better Cache-Control + $etag = filesize( LANG_DIRECTORY . language::$lang . '.ini' ) + filesize( 'website.html' ) . filesize( 'website.class.inc.php' ); + header( 'Cache-Control: max-age=86400' ); + header( 'ETag: ' . $etag ); + if( isset( $_SERVER['HTTP_IF_NONE_MATCH'] ) && $_SERVER['HTTP_IF_NONE_MATCH'] === $etag ) + { + header( 'HTTP/1.1 304 Not Modified', true, 304 ); + exit(); + } + + $website = new website(); $content = $website->buildWebsite(); - @ob_clean(); + //@ob_clean(); echo $content; } catch( Exception $e ) @@ -16,7 +27,24 @@ try if( $e->getCode() === 201 ) { HTTPStatus( 503 ); - echo 'We encountered an critical error.
The system file cannot be loaded!'; + echo 'We encountered an critical error.
The website file cannot be loaded!'; return; } + + if ( $e->getCode() === 202 ) + { + HTTPStatus( 503 ); + echo 'We encountered a critical error.
The language file cannot be loaded!'; + return; + } + + if( $e->getCode() === 203 ) + { + HTTPStatus( 503 ); + echo 'We encountered a critical error
The questions cannot be loaded!'; + return; + } + + HTTPStatus( 500 ); + echo 'We encountered a critical error.
That\'s all what we known!'; } \ No newline at end of file diff --git a/lang/de_DE.ini b/lang/de_DE.ini index 018536f..437b122 100644 --- a/lang/de_DE.ini +++ b/lang/de_DE.ini @@ -1,4 +1,19 @@ ; Langauge file for ;GERMAN - de_DE -[language] +TITLE = "YourSecretsAreOurs" +MAIN_TITLE = "YourSecretsAreOurs" +DESCRIPTION = "Berechne jetzt, wie unschuldig du noch bist!" +EXPLANATION = "Wähle aus, welche Dinge du bereits getan hast.
Wenn du fertig bist, bestätige einfach mit dem Knopf unten!" +PROJECT_DESCRIPTION = "YourSecretsAreOurs ist ein kleines Projekt, welches von ein paar Schülern geleitet wird.
Es dient lediglich zur Belustigung und sollte nicht zu ernst genommen werden.
Aber.. wie unschuldig bist du? - Das ist doch eine gute Frage oder?
Versuche nicht alles durchzuführen!
Wenn du alles angekreuzt hast wird es im Tod enden." +HELP_US = "Hilf mit!" +REQUEST_MORE = "Beim erweitern der Fragen helfen" +SOCIAL_MEDIA = "Social Media" +JOIN_DISCORD = "Tritt unserem Discord bei!" +LANGUAGE_CHOOSE = "Wähle deine Sprache aus" +CALCULATE = "Berechne meine Punkte!" + +[questions] +1 = "Hast du schon mal einen Schwangerschaftstest benutzt?" +2 = "Hast du dich schon mal selbst befriedigt?" +3 = "" \ No newline at end of file diff --git a/lang/en_EN.ini b/lang/en_EN.ini index c6c4a44..e759fca 100644 --- a/lang/en_EN.ini +++ b/lang/en_EN.ini @@ -1,4 +1,18 @@ ; Langauge file for -;ENGLISH - en_en +;ENGLISH - en_EN -[language] +TITLE = "YourSecretsAreOurs" +MAIN_TITLE = "YourSecretsAreOurs" +DESCRIPTION = "Calculate how innocent you still are!" +EXPLANATION = "Choose which things you have already done.
When you are done, just confirm with the button below!" +PROJECT_DESCRIPTION = "YourSecretsAreOurs is a small project, which is managed by a few students.
It is just for fun and should not be taken too seriously.
But... how innocent are you? - That's a good question, isn't it?
Do not try to do everything!
If you check all the boxes it will result in death." +HELP_US = "Help us!" +REQUEST_MORE = "Request a question" +SOCIAL_MEDIA = "Social Media" +JOIN_DISCORD = "Join our Discord!" +LANGUAGE_CHOOSE = "Choose your langauge" +CALCULATE = "Calculate my score!" + +[questions] +1 = "Have you ever used a pregnancy test before?" +2 = "Did you ever masturbated?" \ No newline at end of file diff --git a/language.class.inc.php b/language.class.inc.php index 56d167e..73ca62f 100644 --- a/language.class.inc.php +++ b/language.class.inc.php @@ -19,11 +19,13 @@ class language TITLE = 'TITLE', MAIN_TITLE = 'MAIN_TITLE', DESCRIPTION = 'DESCRIPTION', + EXPLANATION = 'EXPLANATION', PROJECT_DESCRIPTION = 'PROJECT_DESCRIPTION', HELP_US = 'HELP_US', REQUEST_MORE = 'REQUEST_MORE', - SOCIAL_MEDIA = 'SOCIAL_MEDIA', - JOIN_DISCORD = 'JOIN_DISCORD' + JOIN_DISCORD = 'JOIN_DISCORD', + LANGUAGE_CHOOSE = 'LANGUAGE_CHOOSE', + CALCULATE = 'CALCULATE' ; public static $lang_file; @@ -38,9 +40,11 @@ class language // Check cookie if( isset( $_GET['lang'] ) ) { - if( isset( $languages[$_GET['lang']] ) ) + if( isset( self::$languages[$_GET['lang']] ) ) { + self::setLangauge( $_GET['lang'] ); + header( 'Location: ?' ); } else { @@ -57,13 +61,16 @@ class language } } - private static function setLangauge ( $a_language = 'en_en' ): void + private static function setLangauge ( $a_language = 'en_EN' ): void { self::$lang = $a_language; - setcookie( 'lang', $a_language, 0 ); + if( !isset( $_COOKIE['lang'] ) || $_COOKIE['lang'] !== $a_language ) + { + setcookie( 'lang', $a_language, 0 ); + } try { - self::$lang_file = parse_ini_file( LANG_DIRECTORY . $a_language . '.ini' ); + self::$lang_file = parse_ini_file( LANG_DIRECTORY . $a_language . '.ini', true ); } catch( Exception $e ) { diff --git a/metas/android-icon-144x144.png b/metas/android-icon-144x144.png new file mode 100644 index 0000000..918a667 Binary files /dev/null and b/metas/android-icon-144x144.png differ diff --git a/metas/android-icon-192x192.png b/metas/android-icon-192x192.png new file mode 100644 index 0000000..a6f69db Binary files /dev/null and b/metas/android-icon-192x192.png differ diff --git a/metas/android-icon-36x36.png b/metas/android-icon-36x36.png new file mode 100644 index 0000000..a32f6a2 Binary files /dev/null and b/metas/android-icon-36x36.png differ diff --git a/metas/android-icon-48x48.png b/metas/android-icon-48x48.png new file mode 100644 index 0000000..0ee0e19 Binary files /dev/null and b/metas/android-icon-48x48.png differ diff --git a/metas/android-icon-72x72.png b/metas/android-icon-72x72.png new file mode 100644 index 0000000..c037e57 Binary files /dev/null and b/metas/android-icon-72x72.png differ diff --git a/metas/android-icon-96x96.png b/metas/android-icon-96x96.png new file mode 100644 index 0000000..25fa0de Binary files /dev/null and b/metas/android-icon-96x96.png differ diff --git a/metas/apple-icon-114x114.png b/metas/apple-icon-114x114.png new file mode 100644 index 0000000..9944f10 Binary files /dev/null and b/metas/apple-icon-114x114.png differ diff --git a/metas/apple-icon-120x120.png b/metas/apple-icon-120x120.png new file mode 100644 index 0000000..e1396c4 Binary files /dev/null and b/metas/apple-icon-120x120.png differ diff --git a/metas/apple-icon-144x144.png b/metas/apple-icon-144x144.png new file mode 100644 index 0000000..918a667 Binary files /dev/null and b/metas/apple-icon-144x144.png differ diff --git a/metas/apple-icon-152x152.png b/metas/apple-icon-152x152.png new file mode 100644 index 0000000..afddcec Binary files /dev/null and b/metas/apple-icon-152x152.png differ diff --git a/metas/apple-icon-180x180.png b/metas/apple-icon-180x180.png new file mode 100644 index 0000000..b1dc964 Binary files /dev/null and b/metas/apple-icon-180x180.png differ diff --git a/metas/apple-icon-57x57.png b/metas/apple-icon-57x57.png new file mode 100644 index 0000000..c53e8c4 Binary files /dev/null and b/metas/apple-icon-57x57.png differ diff --git a/metas/apple-icon-60x60.png b/metas/apple-icon-60x60.png new file mode 100644 index 0000000..4d66c2d Binary files /dev/null and b/metas/apple-icon-60x60.png differ diff --git a/metas/apple-icon-72x72.png b/metas/apple-icon-72x72.png new file mode 100644 index 0000000..c037e57 Binary files /dev/null and b/metas/apple-icon-72x72.png differ diff --git a/metas/apple-icon-76x76.png b/metas/apple-icon-76x76.png new file mode 100644 index 0000000..0610a0f Binary files /dev/null and b/metas/apple-icon-76x76.png differ diff --git a/metas/apple-icon-precomposed.png b/metas/apple-icon-precomposed.png new file mode 100644 index 0000000..cea4d9e Binary files /dev/null and b/metas/apple-icon-precomposed.png differ diff --git a/metas/apple-icon.png b/metas/apple-icon.png new file mode 100644 index 0000000..cea4d9e Binary files /dev/null and b/metas/apple-icon.png differ diff --git a/metas/browserconfig.xml b/metas/browserconfig.xml new file mode 100644 index 0000000..c554148 --- /dev/null +++ b/metas/browserconfig.xml @@ -0,0 +1,2 @@ + +#ffffff \ No newline at end of file diff --git a/metas/favicon-16x16.png b/metas/favicon-16x16.png new file mode 100644 index 0000000..9758530 Binary files /dev/null and b/metas/favicon-16x16.png differ diff --git a/metas/favicon-32x32.png b/metas/favicon-32x32.png new file mode 100644 index 0000000..b8d9f4c Binary files /dev/null and b/metas/favicon-32x32.png differ diff --git a/metas/favicon-96x96.png b/metas/favicon-96x96.png new file mode 100644 index 0000000..25fa0de Binary files /dev/null and b/metas/favicon-96x96.png differ diff --git a/metas/favicon.ico b/metas/favicon.ico new file mode 100644 index 0000000..6ff35e2 Binary files /dev/null and b/metas/favicon.ico differ diff --git a/metas/manifest.json b/metas/manifest.json new file mode 100644 index 0000000..013d4a6 --- /dev/null +++ b/metas/manifest.json @@ -0,0 +1,41 @@ +{ + "name": "App", + "icons": [ + { + "src": "\/android-icon-36x36.png", + "sizes": "36x36", + "type": "image\/png", + "density": "0.75" + }, + { + "src": "\/android-icon-48x48.png", + "sizes": "48x48", + "type": "image\/png", + "density": "1.0" + }, + { + "src": "\/android-icon-72x72.png", + "sizes": "72x72", + "type": "image\/png", + "density": "1.5" + }, + { + "src": "\/android-icon-96x96.png", + "sizes": "96x96", + "type": "image\/png", + "density": "2.0" + }, + { + "src": "\/android-icon-144x144.png", + "sizes": "144x144", + "type": "image\/png", + "density": "3.0" + }, + { + "src": "\/android-icon-192x192.png", + "sizes": "192x192", + "type": "image\/png", + "density": "4.0" + } + ] +} \ No newline at end of file diff --git a/metas/ms-icon-144x144.png b/metas/ms-icon-144x144.png new file mode 100644 index 0000000..918a667 Binary files /dev/null and b/metas/ms-icon-144x144.png differ diff --git a/metas/ms-icon-150x150.png b/metas/ms-icon-150x150.png new file mode 100644 index 0000000..5a822d4 Binary files /dev/null and b/metas/ms-icon-150x150.png differ diff --git a/metas/ms-icon-310x310.png b/metas/ms-icon-310x310.png new file mode 100644 index 0000000..a90049d Binary files /dev/null and b/metas/ms-icon-310x310.png differ diff --git a/metas/ms-icon-70x70.png b/metas/ms-icon-70x70.png new file mode 100644 index 0000000..6294683 Binary files /dev/null and b/metas/ms-icon-70x70.png differ diff --git a/vendor/css/default.css b/vendor/css/default.css new file mode 100644 index 0000000..676ba72 --- /dev/null +++ b/vendor/css/default.css @@ -0,0 +1,6 @@ +/* Default CSS File for YourSecretsAreOurs */ + +body { + background-image: url('/vendor/images/background.png'); + +} \ No newline at end of file diff --git a/vendor/images/background.png b/vendor/images/background.png new file mode 100644 index 0000000..35ffb3b Binary files /dev/null and b/vendor/images/background.png differ diff --git a/website.class.inc.php b/website.class.inc.php index 32faa17..f331be1 100644 --- a/website.class.inc.php +++ b/website.class.inc.php @@ -21,31 +21,89 @@ class website } catch( Exception $e ) { + if( ( $code = $e->getCode() ) === 202 || $code === 203 ) + { + throw new RuntimeException( $e->getMessage(), $code ); + } throw new RuntimeException( 'Cannot load the website.html file', 201 ); } } private function replaceDefaultThings( $website ) { + if( !isset( language::$lang_file[language::TITLE], + language::$lang_file[language::MAIN_TITLE], + language::$lang_file[language::DESCRIPTION], + language::$lang_file[language::EXPLANATION], + language::$lang_file[language::PROJECT_DESCRIPTION], + language::$lang_file[language::HELP_US], + language::$lang_file[language::REQUEST_MORE], + language::$lang_file[language::LANGUAGE_CHOOSE], + language::$lang_file[language::JOIN_DISCORD] ) ) + { + throw new RuntimeException( 'Cannot load default langauge replacements', 202 ); + } $website = str_replace( array( - '[LANG]', '[TITLE]', '[MAIN_TITLE]', '[DESCRIPTION]', '[PROJECT_DESCRIPTION]', '[HELP_US]', '[REQUEST_MORE]','[SOCIAL_MEDIA]', '[JOIN_DISCORD]' ), + '[LANG]', '[TITLE]', '[MAIN_TITLE]', '[DESCRIPTION]', '[EXPLANATION]', '[PROJECT_DESCRIPTION]', '[HELP_US]', '[REQUEST_MORE]','[LANGUAGE_CHOOSE]', '[JOIN_DISCORD]' ), array( substr( language::$lang, 0, 2 ), language::$lang_file[language::TITLE], language::$lang_file[language::MAIN_TITLE], language::$lang_file[language::DESCRIPTION], + language::$lang_file[language::EXPLANATION], language::$lang_file[language::PROJECT_DESCRIPTION], language::$lang_file[language::HELP_US], language::$lang_file[language::REQUEST_MORE], - language::$lang_file[language::SOCIAL_MEDIA], + language::$lang_file[language::LANGUAGE_CHOOSE], language::$lang_file[language::JOIN_DISCORD] ), $website ); + $languages = ''; + foreach( language::$languages as $code => $language ) + { + $languages .= <<$language +HTML; + +} + $website = str_replace( '[LANGUAGES]', $languages, $website ); return $website; } private function setQuestions( $website ) : string { - return $website; // todo + if( !isset( language::$lang_file['questions'] ) ) + { + throw new RuntimeException( 'Error while reading the questions in langauge file', 203 ); + } + $questions = ''; + foreach( language::$lang_file['questions'] as $number => $question ) + { + $questions .= << + + $question +
+CHECKBOX; + + } + $form_start = << +HTML; + $submit = language::$lang_file[language::CALCULATE]; + $form_end = << + + +HTML; + + + $questions = $form_start . $questions . $form_end; + $website = str_replace( '[QUESTIONS]', $questions, $website ); + + + return $website; } } \ No newline at end of file diff --git a/website.html b/website.html index 403f7d2..4afac35 100644 --- a/website.html +++ b/website.html @@ -5,11 +5,31 @@ [TITLE] - + + + + + + + + + + + + + + + + + + + + +


@@ -17,18 +37,21 @@
[DESCRIPTION]
-

+
+
+
[EXPLANATION]
+
+
[QUESTIONS]
-
- [DONE] +


@@ -38,23 +61,24 @@
YourSecretsAreOurs
-

[PROJECT_DESCRIPTION].

+

[PROJECT_DESCRIPTION]

-
[SOCIAL_MEDIA]
+
[LANGUAGE_CHOOSE]
- +