[READ-ONLY] Mirror of https://github.com/probablykasper/website-template. My PHP website template
0

Configure Feed

Select the types of activity you want to include in your feed.

Added what's already there

author
KH
date (May 17, 2017, 4:40 PM +0200) commit dde1897e
+280
+19
.htaccess
··· 1 + RewriteEngine On 2 + 3 + # Skip existing files or directories 4 + RewriteCond %{REQUEST_FILENAME} !-f 5 + RewriteCond %{REQUEST_FILENAME} !-d 6 + 7 + # Everything else goes to index.php 8 + # RewriteRule ^ index.php [L] 9 + RewriteRule ^(.*)$ /index.php?path=$1 [NC,L,QSA] 10 + 11 + # Redirects 12 + RedirectMatch 301 /includes(.*) / 13 + RedirectMatch 301 /.sass-cache(.*) / 14 + 15 + AddType video/mp4 mp4 m4v 16 + AddType audio/mp4 m4a 17 + AddType video/ogg ogv 18 + AddType video/ogg ogg oga 19 + AddType video/webm webm
+31
css/global.css
··· 1 + html body { background-color: white; margin: 0px; font-family: 'Roboto', Arial, sans-serif; color: black; } 2 + 3 + html p, html h1, html h2, html h3, html h4, html h5, html h6 { margin: 0px; font-weight: normal; } 4 + 5 + html .metadata { display: none; } 6 + 7 + html h1 { font-size: 50px; } 8 + 9 + html h2 { font-size: 35px; } 10 + 11 + html h3 { font-size: 30px; } 12 + 13 + html h4 { font-size: 25px; } 14 + 15 + html h5 { font-size: 20px; } 16 + 17 + html a, html a:link, html a:visited, html a:link:active, html a:visited:active { text-decoration: none; outline: none; color: white; } 18 + 19 + html img { display: block; } 20 + 21 + html input:focus, html button:focus, html textarea:focus, html div, html p { outline: none; } 22 + 23 + html input, html textarea, html button { font-family: 'Roboto', Arial, sans-serif; border: none; font-size: 16px; } 24 + 25 + html input[type="range"] { display: none; } 26 + 27 + html .flex-row { display: flex; justify-content: center; flex-direction: row; width: 100%; } 28 + 29 + html .flex-col { display: flex; justify-content: center; flex-direction: column; height: 100%; } 30 + 31 + html .invisible { visibility: none; }
+49
css/global.sass
··· 1 + @import "variables.sass" 2 + // defaults 3 + html 4 + body 5 + background-color: white 6 + margin: 0px 7 + font-family: 'Roboto', Arial, sans-serif 8 + color: $c-text 9 + p, h1, h2, h3, h4, h5, h6 10 + margin: 0px 11 + font-weight: normal 12 + .metadata 13 + display: none 14 + h1 15 + font-size: 50px 16 + h2 17 + font-size: 35px 18 + h3 19 + font-size: 30px 20 + h4 21 + font-size: 25px 22 + h5 23 + font-size: 20px 24 + a, a:link, a:visited, a:link:active, a:visited:active 25 + text-decoration: none 26 + outline: none 27 + color: white 28 + img 29 + display: block 30 + input:focus, button:focus, textarea:focus, div, p 31 + outline: none 32 + input, textarea, button 33 + font-family: 'Roboto', Arial, sans-serif 34 + border: none 35 + font-size: 16px 36 + input[type="range"] 37 + display: none 38 + .flex-row 39 + display: flex 40 + justify-content: center 41 + flex-direction: row 42 + width: 100% 43 + .flex-col 44 + display: flex 45 + justify-content: center 46 + flex-direction: column 47 + height: 100% 48 + .invisible 49 + visibility: none
css/variables.css

This is a binary file and will not be displayed.

+1
css/variables.sass
··· 1 + $c-text: black
+122
includes/functions.php
··· 1 + <? 2 + 3 + // $css_paths = [ 4 + // "/" => "home.css", 5 + // "/contact" => "contact.css" 6 + // ]; 7 + // $titles = [ 8 + // "/" => "Sitename", 9 + // "/contact" => "Contact" 10 + // ]; 11 + // $js_paths = [ 12 + // "/" => "home.js", 13 + // "/contact" => "contact.js" 14 + // ]; 15 + 16 + // ---------------------------------------------------------------------------- 17 + // GET THINGS 18 + // ---------------------------------------------------------------------------- 19 + 20 + function get_slug() { 21 + $slug = $_SERVER["REQUEST_URI"]; 22 + $slug = explode("?", $slug, 2); 23 + $slug = $slug[0]; 24 + $slug = strtolower($slug); 25 + if (preg_match("[/$]", $slug) && $slug != "/") { 26 + $slug = rtrim($slug, "/"); 27 + } 28 + return $slug; 29 + } 30 + 31 + function get_css($slug, $path_only = false) { 32 + global $css_paths; 33 + $css = ""; 34 + // Find out if slug is one from $css_paths 35 + foreach ($css_paths as $possible_slug => $css_path) { 36 + if ($possible_slug == $slug) { 37 + $css = "/css/$css_path?r=" . rand(0,999); 38 + if (!$path_only) { 39 + $css = '<link class="page-css" rel="stylesheet" type="text/css" href="'.$css.'"/>'; 40 + } 41 + } 42 + } 43 + return $css; 44 + } 45 + 46 + function get_js($slug, $path_only = false) { 47 + global $js_paths; 48 + $js = ""; 49 + // Find out if slug is one from $js_paths 50 + foreach ($js_paths as $possible_slug => $js_path) { 51 + if ($possible_slug == $slug) { 52 + $js = "/js/$js_path?r=" . rand(0,999); 53 + if (!$path_only) { 54 + $js = '<script class="page-js" src="'.$js.'"></script>'; 55 + } 56 + } 57 + } 58 + return $js; 59 + } 60 + 61 + function get_title($slug) { 62 + global $titles; 63 + $title = ""; 64 + // Find out if slug is one from $titles 65 + foreach ($titles as $possible_slug => $current_title) { 66 + if ($possible_slug == "/") { 67 + $title = $current_title; 68 + } elseif ($possible_slug == $slug) { 69 + $title = $current_title." - Nelation"; 70 + } 71 + } 72 + return $title; 73 + } 74 + 75 + // ---------------------------------------------------------------------------- 76 + // DATABASE 77 + // ---------------------------------------------------------------------------- 78 + 79 + function db_connect() { 80 + global $db_connection; 81 + $host = "localhost"; 82 + $username = "web"; 83 + $password = "BdW2XyeWaSVmFNcn"; 84 + $db_name = "nelation"; 85 + $db_connection = mysqli_connect($host, $username, $password, $db_name); 86 + } 87 + 88 + function db_disconnect() { 89 + // 5. Disconnect from db 90 + global $db_connection; 91 + mysqli_close($db_connection); 92 + } 93 + 94 + function db_query($query) { 95 + global $db_connection; 96 + $query = mysqli_real_escape_string($db_connection, $query); 97 + $result = mysqli_query($db_connection, $query); 98 + if (!$result) { 99 + echo "Bad, bad, bad error that we don't like: ".mysqli_error($db_connection); 100 + die(); 101 + } 102 + return $result; 103 + } 104 + 105 + // ---------------------------------------------------------------------------- 106 + // MISC 107 + // ---------------------------------------------------------------------------- 108 + 109 + function urlify($string) { 110 + $string = strtolower($string); 111 + $string = str_replace([" "], "-", $string); 112 + $string = preg_replace("/[^\w+-]/", "", $string); 113 + $string = preg_replace("[-+]", "-", $string); 114 + return $string; 115 + } 116 + 117 + function starts_with($haystack, $needle) { 118 + $length = strlen($needle); 119 + return (substr($haystack, 0, $length) === $needle); 120 + } 121 + 122 + ?>
+57
index.php
··· 1 + <? 2 + include("includes/functions.php"); 3 + $slug = get_slug(); 4 + $skip_document = false; 5 + $thatsa404 = false; 6 + // db_connect(); 7 + 8 + 9 + 10 + function slug_to_path($slug) { 11 + if ($slug == "/") { 12 + return "pages/home.php"; 13 + } elseif (file_exists("pages$slug/index.php")) { 14 + return "pages$slug/index.php"; 15 + } elseif (file_exists("pages$slug.php")) { 16 + return "pages$slug.php"; 17 + } else { 18 + global $thatsa404; 19 + $thatsa404 = true; 20 + return "pages/404.php"; 21 + } 22 + } 23 + $include_path = slug_to_path($slug); 24 + 25 + if (!$skip_document) { 26 + session_start(); 27 + ?> 28 + <!DOCTYPE html> 29 + <html> 30 + <head> 31 + <meta charset="utf-8"> 32 + <!-- <title><? 33 + if ($thatsa404) { 34 + echo "404 sitename"; 35 + } else { 36 + echo get_title($slug); 37 + } 38 + ?></title> --> 39 + <!--Roboto--> <link href="https://fonts.googleapis.com/css?family=Roboto:400,500" rel="stylesheet"> 40 + <!--Favicon: http://realfavicongenerator.net --> 41 + <link rel="stylesheet" type="text/css" href="/css/global.css?r=<?=rand(0,999)?>"> 42 + <?= get_css($slug); ?> 43 + </head> 44 + 45 + <body> 46 + <section id="body" class="body"> 47 + <? include("$include_path"); ?> 48 + </section> 49 + <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> 50 + <script src="/js/js.cookie-2.1.3.min.js"></script> 51 + <script src="/js/rangeSlider.js"></script> 52 + </body> 53 + </html> 54 + <? 55 + } 56 + db_disconnect(); 57 + ?>
+1
pages/home.php
··· 1 + home page