Commit 826e313b by Aleksandar Hristov

install.php - creates a database named wiki.db with 3 tables:

- admin (contains username and password of users who can edit the wiki);

- page (contains id, title, text and sections that belong to the pages in the wiki);

- sections (contains id, id of the page the section belongs to, title and text that belong to the sections in the wiki).
1 parent c8fa5f05
...@@ -11,61 +11,18 @@ class MyDB extends SQLite3 ...@@ -11,61 +11,18 @@ class MyDB extends SQLite3
} }
$db = new MyDB(); $db = new MyDB();
$pass = md5('initpass');
$db->exec('CREATE TABLE admin (username varchar(255), password varchar(255))');
$db->exec('CREATE TABLE page (id INTEGER PRIMARY KEY AUTOINCREMENT, title varchar(250), text string, sections integer)');
$db->exec('CREATE TABLE section (id INTEGER PRIMARY KEY AUTOINCREMENT, page_id INTEGER, title varchar(250), text string, sections integers)');
$db->exec('CREATE TABLE subsection (id INTEGER PRIMARY KEY AUTOINCREMENT, page_id INTEGER, section_id INTEGER, title varchar(250), text string)');
$db->exec("INSERT INTO admin (username, password) VALUES ('admin', '$pass')");
$db->exec("INSERT INTO page (title, text, sections) VALUES ('example', 'example', 'example')");
$db->exec("INSERT INTO section (page_id, title, text, sections) VALUES (1, 'example', 'example', 'example')");
$db->exec("INSERT INTO subsection (page_id, section_id, title, text, sections) VALUES (1, 1, 'example', 'example')");
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<title>Create a new Wiki</title> if(!$db) echo $db->lastErrorMsg();
<!-- Bootstrap Core CSS --> $pass = md5('initpass');
<link href="static/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<!-- Custom CSS -->
<link href='http://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css'>
<!-- FontAwesome -->
<link rel="stylesheet" href="static/font-awesome/css/font-awesome.min.css">
<script src="static/bootstrap/js/jquery-1.11.0.js"></script>
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<div class="container-fluid text-center"> $query = $db->exec('CREATE TABLE admin (username varchar(255), password varchar(255))');
<h1>Wiki created!</h> if(!$query) echo $db->lastErrorMsg();
</div>
</div>
</body> $query = $db->exec('CREATE TABLE pages (id INTEGER PRIMARY KEY AUTOINCREMENT, title varchar(250), text string, sections integer)');
</html> if(!$query) echo $db->lastErrorMsg();
$query = $db->exec('CREATE TABLE sections (id INTEGER PRIMARY KEY AUTOINCREMENT, page_id INTEGER, title varchar(250), text string)');
if(!$query) echo $db->lastErrorMsg();
?>
\ No newline at end of file \ No newline at end of file
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!