Newer
Older
insanelyBlog / index.php
<?php

require_once 'core.php';

ob_start();
switch ($seo[0])
{
	case 'rss':
		include 'includes/rss.php';
		exit;
	break;

	case $_set['subEntry']:
		if (isset($_POST['read_entry_pin']) && is_numeric($_POST['read_entry_pin'])) set_pin($_POST['read_entry_pin']);
		include 'includes/main/entry.php';
	break;

	case $_set['subPage']:
		include 'includes/main/page.php';
	break;

	case $_set['subProfile']:
		if (!isset($seo[1])) redirect();
		include 'includes/main/profile.php';
	break;

	case 'tag':
		include 'includes/main/tag.php';
	break;

	case 'login':
		include 'includes/main/login.php';
	break;

	case 'admin':
		if (LOGGEDIN && $user['userLevel'] > 1)
			include 'includes/admin/main.php';
		else
			redirect();
	break;

	case 'p':
		include 'includes/main/entries.php';
	break;

	case 'filtrToken':
		if (isset($seo[1]))
			setcookie('filtr_token', $seo[1], time()+3600*24*31, '/');
		redirect();
	break;

	default:
		include 'includes/main/entries.php';
	break;


}

// COLLECT OUTPUT
$output = ob_get_contents();
ob_end_clean();

// PLUGINS
$pluginsQuery = $_sql->query("SELECT pluginLib, pluginStatus FROM plugins WHERE pluginStatus = 1");
while ($data = $pluginsQuery->fetch_assoc())
{
	$pinfo = 'plugins/'.$data['pluginLib'].'/info.json';
	$pexec = 'plugins/'.$data['pluginLib'].'/_plugin.php';
	if (file_exists($pinfo) && file_exists($pexec))
	{
		
		$pinfo = (array)json_decode(file_get_contents($pinfo));
		$paths = explode(',', $pinfo['paths']);

		foreach ($paths AS $index => $path)
			if (fnmatch($path, get_current_link()))
			{
				include $pexec;
				break;
			}
	}
	unset($pinfo);
	unset($pexec);
}

// LOAD THEME
if (get_theme())
	include get_theme();
else
	nice_error('The theme is not complete.');