index.php
1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
/**
* Created by PhpStorm.
* User: aleksandarhristov
* Date: 02.02.15
* Time: 09:53
*/
//include the smarty class and the global functions
require "libs/Smarty.class.php";
require "global_functions.php";
//initialize smarty
$smarty = new Smarty;
//connect to the database
$db = new SQLite3('wiki.db');
$url=$_SERVER['REQUEST_URI'];
//gotta solve this, it's not certain that there's a page with id=1
if (strpos($url, '?') === false)
{
$current_page=$db->querySingle("SELECT MIN (id) FROM pages");
}
else
{
$current_page = explode ('?', $url);
$current_page=$current_page[1];
}
$smarty->assign("current_page", $current_page);
$smarty->assign("page_id", main_page("page_id", $current_page));
$smarty->assign("page_title", main_page("page_title", $current_page));
$smarty->assign("page_text", main_page("page_text", $current_page));
$smarty->assign("section_id", main_page("section_id", $current_page));
$smarty->assign("section_title", main_page("section_title", $current_page));
$smarty->assign("section_text", main_page("section_text", $current_page));
$smarty->assign("pages", get_pages());
$smarty->assign("pages_id", get_pages_id());
$smarty->display("tpl/index.tpl");