Commit 9d552e7d by Aleksandar Hristov

Added templates, changes in install.php

1 parent 37a44999
<?php
/**
* Created by PhpStorm.
* User: aleksandarhristov
* Date: 29.01.15
* Time: 09:54
*/
//function that returns all the pages in the database in an array
function get_pages()
{
global $db;
$pages = $db->query("SELECT * FROM pages");
$db_page_title=array();
$i=0;
while ($row=$pages->fetchArray())
{
$db_page_title[$i] = $row[1];
$i++;
}
return $db_page_title;
}
//function that returns the current page as string; needed in the admin sidebar wrapper template to give the active class and color the active page <li>
function current_page()
{
global $current_page;
if(strpos($current_page, "create") !== false)
{
$current_page = "create";
}
else if(strpos($current_page, "edit") !== false)
{
$current_page = "edit";
}
else
{
$current_page = "remove";
}
return $current_page;
}
\ No newline at end of file \ No newline at end of file
<?php
class MyDB extends SQLite3
{
function __construct()
{
$this->open('wiki.db');
}
}
$db = new MyDB();
if(!$db) echo $db->lastErrorMsg();
$query = $db->exec('CREATE TABLE admin (username varchar(255), password VARCHAR (255))');
if(!$query) echo $db->lastErrorMsg();
$query = $db->exec('CREATE TABLE pages (id INTEGER PRIMARY KEY AUTOINCREMENT, title varchar(250) NULL, text STRING NULL)');
if(!$query) echo $db->lastErrorMsg();
$query = $db->exec('CREATE TABLE sections (id INTEGER PRIMARY KEY AUTOINCREMENT, page_id INTEGER NULL, title VARCHAR (250) NULL, text STRING NULL )');
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!