<?php
error_reporting(E_ALL & ~E_NOTICE);
ob_start();
require_once ("config.php");
session_start();
   
    if(!isset($_SESSION['sys_id']) && strpos($_SERVER['REQUEST_URI'], "login.php")==NULL){
        header("Location: login.php");
        exit();
    }
		

$filename = "index";

if (isset($_GET['d'])) $filename = $_GET['d'];

$slashpos = stripos($filename, "/");
$count = substr_count($filename, "/");
if($count >1){
	$arr_file = explode('/',$filename);
	$uri_num = count($arr_file) -  1;
	$mfilename = "";
	$vfilename = "";
	$cfilename = "";
	for($f_n = 0; $f_n <=$uri_num; $f_n++){
		if($f_n==$uri_num){
			$mfilename .= "m_".$arr_file[$f_n]. ".php";
			$vfilename .= "v_".$arr_file[$f_n]. ".php";
			$cfilename .= "c_".$arr_file[$f_n]. ".php";
		}else{
			$mfilename .= $arr_file[$f_n]. "/";
			$vfilename .= $arr_file[$f_n]. "/";
			$cfilename .= $arr_file[$f_n]. "/";
		}
		
	}

}else{
	if ($slashpos != false){
		$mfilename = substr($filename, 0, $slashpos+1) . "m_" . substr($filename, $slashpos+1) . ".php";
		$vfilename = substr($filename, 0, $slashpos+1) . "v_" . substr($filename, $slashpos+1) . ".php";
		$cfilename = substr($filename, 0, $slashpos+1) . "c_" . substr($filename, $slashpos+1) . ".php";
	} else {
		$mfilename = "m_$filename.php";
		$vfilename = "v_$filename.php";
		$cfilename = "c_$filename.php";
	}
}
include_once("function/function.php");
if (file_exists($mfilename)) include($mfilename);
if (file_exists($cfilename)) include($cfilename);
