View file iblog/index.php

File size: 1.39Kb
<?php
	session_start();
	include "lib/config.php";
	include "lib/functions_class.php";
	include "lib/function.php";

	if($conn->connect_error){
		header("Location: setup/database.php");		
		//echo 'Databse connection failed! Please contact support team';
	}
	
	//################################
	//########## Start Auto URL Engine
	$request  = $_SERVER['REQUEST_URI'];
	$root  = ROOT;
	#split the path by '/'
	if($root != "/" or $root == ""){
		$url = str_replace($root,"",$request);
	}else{
		$url = $request;
	}

	#split the path by '/'
	$params	= explode("/", $url);
	
	$count = count($params);
	
	if($root != "/" or $root == ""){
		$p1 = $count - 1;
		$p2 = $p1 + 1;
		if($p1 != ''){
			$p1 = $count - 2;
			$p2 = $count - 1;
		}
	}else{
		$p1 = 1;
		$p2 = 2;
	}
	
	$para1 = $params[$p1];
	$para2 = $params[$p2];
	//####### End Auto URL Engine
	//###########################
	
	
	$blog_page = blogpage_name($conn); //Get the blog Page name
	$page_name = getpage_name($conn,$para1); //Get the Page name
	$topic_name = gettopic_name($conn,$para2); //Get the Topic name
	$theme_dir = active_theme($conn); //Get Theme Directory
	//Include Page
	
	if($para1 == ''){
		include $theme_dir."/pages/home.php";
	}
	else if($para1 == $page_name and $para2 == ''){
		include $theme_dir."/pages/page.php";
	}
	else if($para2 == $topic_name){
		include $theme_dir."/pages/single_topic.php";
	}
	else{
		include "pages/404.php";
	}
?>