From e48bece3283b0b3843e8da9e34b60d3859e3ee5a Mon Sep 17 00:00:00 2001 From: Tobias Hopp Date: Thu, 6 Aug 2020 04:33:48 +0200 Subject: [PATCH] Updating a lot of stuff Took 1 hour 48 minutes --- index.php | 12 ++++++-- lang/de_DE.ini | 14 +++++++++- lang/en_EN.ini | 14 +++++++++- vendor/css/default.css | 2 +- website.class.inc.php | 62 +++++++++++++++++++++++++++++++++++++++--- website.html | 8 +++--- website_score.html | 10 +++---- 7 files changed, 104 insertions(+), 18 deletions(-) diff --git a/index.php b/index.php index a02d158..3cbec78 100644 --- a/index.php +++ b/index.php @@ -18,8 +18,16 @@ try $website = new website(); - $content = $website->buildWebsite(); - //@ob_clean(); + + if( isset( $_POST['submit'] ) ) + { + $content = $website->showScore(); + } + else + { + $content = $website->buildWebsite(); + } + @ob_clean(); echo $content; } catch( Exception $e ) diff --git a/lang/de_DE.ini b/lang/de_DE.ini index 74f2dc3..2e1ad37 100644 --- a/lang/de_DE.ini +++ b/lang/de_DE.ini @@ -14,7 +14,19 @@ JOIN_DISCORD = "Tritt unserem Discord bei!" LANGUAGE_CHOOSE = "Wähle deine Sprache aus" CALCULATE = "Berechne meine Punkte!" +SCORE_TITLE = "Reinheits-Level" +SCORE_DESCRIPTION = "Hier kannst du sehen, wie Rein du bist.
Jeder hat eine Dunkle Seite!" +SCORE_SHARE = "Teilen" +SCORE_SAVE = "Speichern" + [questions] 1 = "Hast du schon mal einen Schwangerschaftstest benutzt?" 2 = "Hast du dich schon mal selbst befriedigt?" -3 = "" \ No newline at end of file +3 = "" +4 = "" +5 = "" +6 = "" +7 = "" +8 = "" +9 = "" +10 = "" \ No newline at end of file diff --git a/lang/en_EN.ini b/lang/en_EN.ini index 3f31b0e..c67ee30 100644 --- a/lang/en_EN.ini +++ b/lang/en_EN.ini @@ -14,7 +14,19 @@ JOIN_DISCORD = "Join our Discord!" LANGUAGE_CHOOSE = "Choose your langauge" CALCULATE = "Calculate my score!" +SCORE_TITLE = "Purity-Score" +SCORE_DESCRIPTION = "Here you can see how purity you are.
Everyone has a dark side!" +SCORE_SHARE = "Share it" +SCORE_SAVE = "Save it" + [questions] 1 = "Have you ever used a pregnancy test before?" 2 = "Did you ever masturbated?" -3 = "" \ No newline at end of file +3 = "" +4 = "" +5 = "" +6 = "" +7 = "" +8 = "" +9 = "" +10 = "" \ No newline at end of file diff --git a/vendor/css/default.css b/vendor/css/default.css index 676ba72..252fdbc 100644 --- a/vendor/css/default.css +++ b/vendor/css/default.css @@ -2,5 +2,5 @@ body { background-image: url('/vendor/images/background.png'); - + background-attachment: fixed; } \ No newline at end of file diff --git a/website.class.inc.php b/website.class.inc.php index accfc9a..dd1f742 100644 --- a/website.class.inc.php +++ b/website.class.inc.php @@ -14,9 +14,12 @@ class website try { $website = file_get_contents( __DIR__ . '/website_score.html' ); $website = $this->replaceDefaultThings( $website ); + + $website = $this->setScore( $website ); + return $website; } catch( Exception $e ) { - + throw new RuntimeException( 'Cannot load the score file', 201 ); } } @@ -93,9 +96,9 @@ HTML; foreach( language::$lang_file['questions'] as $number => $question ) { $questions .= << +
CHECKBOX; @@ -106,7 +109,7 @@ HTML; $submit = language::$lang_file[language::CALCULATE]; $form_end = << - @@ -119,4 +122,55 @@ HTML; return $website; } + + private function calculateScore() : int + { + $score = count( language::$lang_file['questions'] ); + foreach( language::$lang_file['questions'] as $number => $question ) + { + if( isset( $_POST["question_$number"] ) && $_POST["question_$number"] === 'checked' ) + { + $score--; + } + } + return $score; + } + + private function setScore ( string $a_website ): string + { + $score = $this->calculateScore(); + $html = << +
+
+
+ [SCORE_TITLE] +
+
+

[SCORE_DESCRIPTION]

+
+ + +
+ 52 +
+
+
+
+ +
+
+ + + +HTML; + + $html = str_replace( ['[SCORE_TITLE]', '[SCORE_DESCRIPTION]', '[SCORE_SHARE]', '[SCORE_SAVE]'], [language::$lang_file['SCORE_TITLE'], language::$lang_file['SCORE_DESCRIPTION'], language::$lang_file['SCORE_SHARE'], language::$lang_file['SCORE_SAVE']], $html ); + + $a_website = str_replace( '[CONTENT]', $html, $a_website ); + return $a_website; + } } \ No newline at end of file diff --git a/website.html b/website.html index d27f9c5..480ba9d 100644 --- a/website.html +++ b/website.html @@ -30,10 +30,10 @@
-
-
+
+
-

[MAIN_TITLE]

+

[MAIN_TITLE]

[DESCRIPTION]
@@ -50,7 +50,7 @@
-
+
[CONTENT]
diff --git a/website_score.html b/website_score.html index 5f5a52e..367d383 100644 --- a/website_score.html +++ b/website_score.html @@ -30,10 +30,10 @@
-
-
+
+
-

[MAIN_TITLE]

+

[MAIN_TITLE]

[DESCRIPTION]
@@ -50,10 +50,10 @@
-
+
[CONTENT] -
+