public static function Initialize()
 {
     // Database
     Database::Initialize();
     Database::Query("SET NAMES UTF8");
     // Locales
     Locales::Initialize();
     // Acount
     self::$m_account = new Account();
     // Plugins
     self::$m_pluginmgr = new PluginMgr(PLUGIN_DIR);
 }
 public static function GetPage($a_id)
 {
     $id = Database::Escape($a_id);
     $result = Database::Query("SELECT * FROM `" . DB_TBL_PAGES . "` WHERE `id` = '" . $id . "'");
     if (!$result->HasData()) {
         die('Unknown page id');
     }
     self::$m_pagename = unserialize($result->GetValue('name'));
     $doc = unserialize($result->GetValue('compiled'));
     if (!$doc) {
         $compiler = new Compiler();
         $doc = $compiler->CompilePage($id);
     }
     // Plugin Hook
     $data_object = new stdClass();
     $data_object->doc = $doc;
     ObjMgr::GetPluginMgr()->ExecuteHook("On_PrepareTemplate", $data_object);
     // Title
     Content::AddTitle($doc, Locales::GetConstString("PAGE_TITLE", NULL, self::$m_pagename[Locales::$m_locale]));
     return $doc->getHtml();
 }
 public function Build($a_node)
 {
     // Get all elements
     $nodes = $a_node->getElementsByTag('*', TEMPLATE_SEARCHMODE_UNMATCHED_RECURSIVE);
     foreach ($nodes as $node) {
         // Plugin Hook
         $data_object = new stdClass();
         $data_object->node = $node;
         $data_object->moduleid = $this->m_moduleid;
         $data_object->ownerid = $this->m_ownerid;
         ObjMgr::GetPluginMgr()->ExecuteHook("On_Node_BuildTag_" . $node->tag(), $data_object);
     }
 }
 public static function GetModule($a_id)
 {
     $id = Database::Escape($a_id);
     $module = new Module($id);
     $doc = $module->Build();
     // Plugin Hook
     $data_object = new stdClass();
     $data_object->doc = $doc;
     ObjMgr::GetPluginMgr()->ExecuteHook("On_PrepareTemplate", $data_object);
     $data = array();
     $data['html'] = $doc->getHtml();
     $data['module_data'] = self::$m_data['module_data'];
     return json_encode($data);
 }
<?php

// Error reporting
error_reporting(E_ALL ^ E_NOTICE);
define("FAKE", 1);
include "_cms/includes/global.php";
ObjMgr::Initialize();
if (isset($_POST['username'])) {
    if (ObjMgr::GetAccount()->Login($_POST['username'], $_POST['password'], false)) {
        header('Location: index.php');
    }
} else {
    if (ObjMgr::GetAccount()->m_loggedin) {
        header('Location: index.php');
    }
}
print '<!DOCTYPE html>

<html>
<head>
<title>Admin Login</title>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
<style>

html, body
{
    height: 100%;
}

body
{
StopWatch::Start();
ObjMgr::Initialize();
$pageid = isset($_GET['page']) ? $_GET['page'] : Content::GetDefaultPageId();
if (isset($_GET['logout']) && ObjMgr::GetAccount()->m_loggedin) {
    ObjMgr::GetAccount()->Logout();
}
if (isset($_GET['locale'])) {
    Locales::SetUserLocale($_GET['locale']);
}
if (ObjMgr::GetAccount()->m_loggedin) {
    if (isset($_POST['action'])) {
        Compiler::$Mode = COMPILER_MODE_EDITOR;
        // Plugin Hook
        $data_object = new stdClass();
        $data_object->post = $_POST;
        ObjMgr::GetPluginMgr()->ExecuteHook("On_PostAction_" . $_POST['action'], $data_object);
        switch ($_POST['action']) {
            // Saves module data
            case 'module_update':
                Editor::SaveModule($_POST['module_data']);
                exit;
                // Returns module html
            // Returns module html
            case 'module_query':
                print Editor::GetModule($_POST['module_id']);
                exit;
                // Creates module template
            // Creates module template
            case 'module_create':
                print Editor::CreateModule($_POST['module_type'], $_POST['module_template'], $_POST['module_name']);
                exit;