index.php 1.17 KB
<?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");