Commit
This commit is contained in:
parent
28d451c0d4
commit
c4fcaee34d
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
/app/config.php
|
14
app/config.example.php
Normal file
14
app/config.example.php
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
<?php
|
||||||
|
return [
|
||||||
|
'root_url' => '/public',
|
||||||
|
'database' => [
|
||||||
|
'name' => 'mysql',
|
||||||
|
'args' => [
|
||||||
|
'host' => 'localhost',
|
||||||
|
'database' => 'test',
|
||||||
|
'user' => 'root',
|
||||||
|
'password' => '',
|
||||||
|
'charset' => 'utf8mb4',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
];
|
@ -3,11 +3,11 @@
|
|||||||
// Encapsulates a single connection to a database
|
// Encapsulates a single connection to a database
|
||||||
class DBHandle
|
class DBHandle
|
||||||
{
|
{
|
||||||
private string $host = '127.0.0.1';
|
private string $host = CONFIG['database']['args']['host'];
|
||||||
private string $db = 'test';
|
private string $db = CONFIG['database']['args']['database'];
|
||||||
private string $user = 'root';
|
private string $user = CONFIG['database']['args']['user'];
|
||||||
private string $pass = '';
|
private string $pass = CONFIG['database']['args']['password'];
|
||||||
private string $charset = 'utf8mb4';
|
private string $charset = CONFIG['database']['args']['charset'];
|
||||||
|
|
||||||
public object $dbh;
|
public object $dbh;
|
||||||
|
|
||||||
|
@ -12,6 +12,12 @@
|
|||||||
Tread carefully
|
Tread carefully
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// Autoloader
|
||||||
spl_autoload_register(function ($class_name) {
|
spl_autoload_register(function ($class_name) {
|
||||||
require __DIR__ . '/core/' . $class_name . '.php';
|
require __DIR__ . '/core/' . $class_name . '.php';
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Define global CONFIG constant.
|
||||||
|
define("CONFIG",
|
||||||
|
require __DIR__ . '/config.php'
|
||||||
|
);
|
@ -6,7 +6,7 @@
|
|||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title><?=htmlspecialchars($title);?> – Stafett for livet</title>
|
<title><?=htmlspecialchars($title);?> – Stafett for livet</title>
|
||||||
|
|
||||||
<link rel="stylesheet" href="static/style/main.css">
|
<link rel="stylesheet" href="<?=CONFIG['root_url']?>/static/style/main.css">
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<div id="header">
|
<div id="header">
|
||||||
@ -18,7 +18,7 @@
|
|||||||
<div id="menu">
|
<div id="menu">
|
||||||
<small>
|
<small>
|
||||||
<span>Ikke pålogget</span>
|
<span>Ikke pålogget</span>
|
||||||
<a href="">Logg inn</a>
|
<a href="<?=CONFIG['root_url']?>/login.php">Logg inn</a>
|
||||||
</small>
|
</small>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -28,9 +28,9 @@
|
|||||||
|
|
||||||
<div id="nav">
|
<div id="nav">
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="">Forside</a></li>
|
<li><a href="<?=CONFIG['root_url']?>/index.php">Forside</a></li>
|
||||||
<li><a href="">Logg inn</a></li>
|
<li><a href="<?=CONFIG['root_url']?>/login.php">Logg inn</a></li>
|
||||||
<li><a href="">Eksempel</a></li>
|
<li><a href="<?=CONFIG['root_url']?>">Eksempel</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user