diff --git a/css/hidden-scrollbar-GUI.css b/css/hidden-scrollbar-GUI.css new file mode 100644 index 0000000..8898c09 --- /dev/null +++ b/css/hidden-scrollbar-GUI.css @@ -0,0 +1,6 @@ +html,body { + scrollbar-width: none; +} +::-webkit-scrollbar { + width: 0; +} \ No newline at end of file diff --git a/index.php b/index.php index d55bc1c..5470328 100644 --- a/index.php +++ b/index.php @@ -1,44 +1,60 @@ 'Previous', + $section_page_titles = [ + 0 => '', 1 => 'Home', 2 => 'About myself', 3 => 'What I\'ve done so far', 4 => 'Who I would like to be', - 5 => 'Contact me via webform' + 5 => 'Webform contact' ]; - if ( ! isset ( $_POST ['section'] ) || ! in_array ( $_POST ['section'], array_keys( $sections ) ) ) { - $section_title = 'Home'; + if ( ! isset ( $_POST ['section'] ) ) { + $requested_section_title = 'Home'; } else { - $section = $_POST ['section']; - if ( $section == 0 ) { + if ( ! in_array ( $_POST ['section'], array_keys( $section_page_titles ) ) ) { + $page_content_array = [ + 'status' => 400, + 'errorCode' => 'Bad Request', + 'errorText' => 'Requested section \'' . $_POST [ 'section' ] . '\' does not exist: do not attempt to compromise the website.', + ]; + $page_content_json = json_encode ( $page_content_array ); + header('Content-Type: application/json'); + echo $page_content_json; + exit; + } + $requested_section = $_POST ['section']; + if ( $requested_section == 0 ) { if ( isset ( $_SESSION [ 'section' ] ) ) { - $section = $_SESSION [ 'section' ]; + $requested_section = $_SESSION [ 'section' ]; } else { - $section = 1; + $requested_section = 1; } } - $_SESSION [ 'section' ] = $section; - $section_title = $sections [ $section ]; - $sections_content = [ - 1 => file_get_contents ( 'tmpl/home.phtml' ), - 2 => file_get_contents ( 'tmpl/description.phtml' ), - 3 => file_get_contents ( 'tmpl/projects.phtml' ), - 4 => file_get_contents ( 'tmpl/ideas.phtml' ), - 5 => file_get_contents ( 'tmpl/contact-form.phtml' ), + $_SESSION [ 'section' ] = $requested_section; + $requested_section_title = $section_page_titles [ $requested_section ]; + $section_templates = [ + 1 => file_get_contents ( 'templates/home.phtml' ), + 2 => file_get_contents ( 'templates/description.phtml' ), + 3 => file_get_contents ( 'templates/projects.phtml' ), + 4 => file_get_contents ( 'templates/ideas.phtml' ), + 5 => file_get_contents ( 'templates/contact-form.phtml' ), ]; - $arr_res = [ + $page_content_array = [ 'status' => 200, - 'pageTitle' => $section_title, - 'html' => $sections_content [ $section ] + 'pageTitle' => $requested_section_title, + 'html' => $section_templates [ $requested_section ] ]; - $res = json_encode($arr_res); + $page_content_json = json_encode($page_content_array); header('Content-Type: application/json'); - echo $res; + echo $page_content_json; exit; } ?> @@ -49,20 +65,13 @@ -