<?php
defined('PHP168_PATH') or die();

$IS_ADMIN or message('no_privilege');

if(REQUEST_METHOD == 'GET'){
	
	$db_version = $DB_master->version();
	$systems = $core->list_systems();
	if(isset($systems['cms'])){
		$cms = $core->load_system('cms');
		$item = $cms->load_module('item');
		$listdb=$DB_master->fetch_all("select * from ".$item->main_table." ORDER BY id DESC limit 9");
		
		foreach($listdb as $key => $val){
			$listdb[$key]['url']=$item->controller."-view-id-".$val['id'];
			$listdb[$key]['edit']=$core->admin_controller."/cms/item-update?id=$val[id]&model=$val[model]&verified=1";
			$listdb[$key]['delete']=$core->admin_controller."/cms/item-delete?id=$val[id]&model=$val[model]&verified=1";
		}
	}
	if(is_file(PHP168_PATH.'data/installcache.lock'))$cache = true;
	include template($core, 'main', 'admin');

}else if(REQUEST_METHOD == 'POST'){
	
	if(isset($_POST['detect_ssi'])){
		write_file(CACHE_PATH .'ssi.html', 'ssi');
		write_file(CACHE_PATH .'ssi.shtml', '<!--#include virtual="ssi.html"-->');
		
		$core->set_config(array('ssi' => file_get_contents('http://'. $_SERVER['HTTP_HOST'] .'/data/ssi.shtml') == 'ssi'));
	}
	
	message('done');
}