Location: PHPKode > projects > SAPID > etc/startup.inc.php
<?PHP
// vim: set expandtab tabstop=4 shiftwidth=4:
// +----------------------------------------------------------------------+
// | SAPID: XML Sapiens Engine Demonstrator                               |
// +----------------------------------------------------------------------+
// | Author:  Max Baryshnikov aka Mephius <hide@address.com>,	          |
// | Dmitry Sheiko <hide@address.com>	                		  |
// | Copyright (c) 2004-2005 Max Baryshnikov                              |
// | http://sapid.sourceforge.net	                                      |
// +----------------------------------------------------------------------+
// | This source file is free software; you can redistribute it and/or    |
// | modify it under the terms of the GNU Lesser General Public           |
// | License as published by the Free Software Foundation; either         |
// | version 2.1 of the License, or (at your option) any later version.   |
// |                                                                      |
// | This source file is distributed in the hope that it will be useful,  |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of       |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU    |
// | Lesser General Public License for more details.                      |
// +----------------------------------------------------------------------+
// Release: 24.02.05 (dd/mm/yy)
// $Id: startup.inc.php,v 1.4 2006/02/20 08:27:31 sheiko Exp $

if (!defined("SAPID_STARTED")) die("Hacking attempt!");

$env["default_charset"]=$default_charset="UTF-8";

session_start();

include(ROOT_PATH . "mvc/basics.inc.php");

if (isset($_GET["logout"])) {
	session_destroy();
	unset($_SESSION["user"]);
	header("Location: ".$http_path);
}

// Definition of variables environment

if (isset($_ENV["argv"])) $argv=$_ENV["argv"];
if( !$SAPIDTHEME ) $SAPIDTHEME="default";
$env["rewritten_http_path"]  = $http_path.($MODREWRITE=="disabled"?"?vpath=/".$admin_path."/":$admin_path."/");

// Is request string valid
if(
preg_match("/^.?system/is", $_SERVER["REQUEST_URI"]) OR
preg_match("/^.?xml/is", $_SERVER["REQUEST_URI"]) OR
preg_match("/^.?content/is", $_SERVER["REQUEST_URI"])
) exit;

if($MODREWRITE == "MultiviewsMode") {
	$_SERVER["REQUEST_URI"] = preg_replace("/^\/index\.php\//is", "/", $_SERVER["REQUEST_URI"]);
	$http_path .= "index.php/";
}


// Is root path defined
//if(!ROOT_PATH) {
//	ROOT_PATH = preg_replace("/index\.php$/is", "", $_SERVER["SCRIPT_FILENAME"])."/";
//	ROOT_PATH = preg_replace("/\/\//is","/", ROOT_PATH);
//}

include(ROOT_PATH . "kernel/vdb.lib.php");
include(ROOT_PATH . "kernel/tree.lib.php");
include(ROOT_PATH . "kernel/kernel.lib.php");
include(ROOT_PATH . "kernel/dal/".DAL.".lib.php");
include(ROOT_PATH . "etc/case.inc.php");
include(ROOT_PATH . "usr/system/sapi_expressions.inc.php");
if(!$default_language) $default_language="ru";
if(!@include(ROOT_PATH.'lang/'.$default_language.'.inc.php') ) message_die("Can't include ".ROOT_PATH.'lang/'.$default_language.'.inc.php');

// Require MVC View
include(ROOT_PATH . "mvc/view/functions.inc.php");

// Require MVC Controller
include(ROOT_PATH . "mvc/controller/requesturi_analysis.inc.php");
include(ROOT_PATH . "mvc/controller/authorization_analysis.inc.php");

$tree = new tree(ROOT_PATH . "usr/xml/tree.xml");
include(ROOT_PATH . "mvc/controller/build_tree.inc.php");
// Require MVC Model
include(ROOT_PATH . "mvc/model/document_identification.inc.php");

// Require MVC Controller
include(ROOT_PATH . "mvc/controller/postmethod_analysis.inc.php");

// Get data file info
	if(@file_exists(ROOT_PATH."usr/xml/content/".$env["page"]["ID"].".xml"))
		$env["page"]["filemtime"] = @filemtime(ROOT_PATH."usr/xml/content/".$env["page"]["ID"].".xml");

// Get page data
$xmldata = getXMLdata(ROOT_PATH."usr/xml/content/".$env["page"]["ID"].".xml");
if($xmldata) {
	foreach($xmldata as $fetch) {
		if($fetch) {
			foreach($fetch as $key => $val) {
				$env["page.".$key] = $val;
				$env["page.".strtolower($key)] = $val;
			}
		}
	}
}


if($env["user"]["LOGIN"]) {
	$metatitle = "SAPID Admin Mode";
	option_switch();
}

?>
Return current item: SAPID