Beispiel #1
0
function setStyles()
{
    global $Database;
    global $Config;
    // get styleHandler-object
    $StyleHandler = new ts_StyleHandler();
    // allow only, if logged in
    if (!isset($_SESSION['admin_auth']) or empty($_SESSION['admin_auth'])) {
        return false;
    }
    // get input
    $styles_activated = array();
    foreach ($_POST as $index => $value) {
        if (substr($index, 0, 7) != 'style__') {
            continue;
        }
        $styles_activated[] = substr($index, 7);
    }
    // get objects of all styles
    $styles_all = $StyleHandler->getStyles();
    // activate or deactivate modules
    foreach ($styles_all as $index => $Value) {
        $new_status = in_array($Value->getInfo('id__style'), $styles_activated) ? true : false;
        if (!$Value->activate($new_status)) {
            return false;
        }
    }
    // update installation progress
    if ($Config->get('installation') < 100) {
        $Config->setArray('installation_progress', 'setStyles', true);
    }
    $_SESSION['admin_info'] = 'INFO__SETSTYLES_SUCCESS';
    return true;
}
Beispiel #2
0
function parseAll()
{
    global $Database, $Config, $ModuleHandler, $Log;
    // allow only, if logged in
    if (!isset($_SESSION['admin_auth']) or empty($_SESSION['admin_auth'])) {
        return false;
    }
    // reset session var, if accessing page normally
    if (!isset($_GET['call'])) {
        unset($_SESSION['parseAll__call']);
    }
    // set global Objects
    global $FormatHandler, $SubcodeHandler, $Parser, $LanguageHandler, $AccessParser, $ConfigParser, $USERSYSTEM;
    // is first call or a consecutive one?
    if (isset($_SESSION['parseAll__call']) and !empty($_SESSION['parseAll__call'])) {
        // is consecutive call
        $call_num = $_SESSION['parseAll__call']['num'];
        $LanguageHandler = $_SESSION['parseAll__call']['LanguageHandler'];
        $FormatHandler = $_SESSION['parseAll__call']['FormatHandler'];
        $SubcodeHandler = $_SESSION['parseAll__call']['SubcodeHandler'];
        $AccessParser = $_SESSION['parseAll__call']['AccessParser'];
        $ConfigParser = $_SESSION['parseAll__call']['ConfigParser'];
        $USERSYSTEM = $_SESSION['parseAll__call']['USERSYSTEM'];
        $Parser = $_SESSION['parseAll__call']['Parser'];
        $modules_all = $_SESSION['parseAll__call']['modules_all'];
        $pre_system_online = $_SESSION['parseAll__call']['pre_system_online'];
    } else {
        // is first call
        $call_num = 0;
        $FormatHandler = new ts_FormatHandler();
        $SubcodeHandler = new ts_SubcodeHandler();
        $AccessParser = new ts_AccessParser();
        $ConfigParser = new ts_ConfigParser();
        $modules_all = $ModuleHandler->getModules(true);
        $Parser = new ts_Parser($Config->get('prefix'), $modules_all, $Config->get('debug_mode'));
        $USERSYSTEM = 0;
        $LanguageHandler = new ts_LanguageHandler();
        $pre_system_online = false;
    }
    if ($call_num == 0) {
        // log
        $Log->doLog(3, "Rendering: remove old files");
        // all directories and files that will be recreated
        $dir_runtime = $Config->get('dir_runtime');
        $rc_dirs = array($Config->get('dir_runtime') . '/classes', $Config->get('dir_runtime') . '/functions', $Config->get('dir_runtime') . '/templates', $Config->get('dir_runtime') . '/files', $Config->get('dir_runtime') . '/static', $Config->get('dir_runtime') . '/lang', $Config->get('dir_runtime') . '/javascript', $Config->get('dir_runtime') . '/xmlResponses', $Config->get('dir_runtime') . '/help');
        $rc_files = array($Config->get('dir_runtime') . '/index.php', $Config->get('dir_runtime') . '/ajax.php', $Config->get('dir_runtime') . '/init.php', $Config->get('dir_runtime') . '/offline.php', $Config->get('dir_runtime') . '/webdav.php', $Config->get('dir_runtime') . '/file.php');
        // set system as offline
        $pre_system_online = $Config->get('system_online');
        $Config->set('system_online', false);
        $Config->set('system_offline_since', date('m/d/y H:i:s'));
        // backup current runtime
        /*
        	if (!ts_BackupHandler::backupRuntime(true)) {
           $_SESSION['admin_error'] = 'ERROR__RENDER (backup runtime dir)';
           return false;
        	}
        */
        // delete all dirs and files which will be recreated
        foreach ($rc_dirs as $index => $value) {
            if (!ts_FileHandler::emptyFolder($value)) {
                $_SESSION['admin_error'] = 'ERROR__RENDER (empty runtime dirs)';
                return false;
            }
        }
        foreach ($rc_files as $index => $value) {
            if (file_exists($value)) {
                unlink($value);
            }
        }
    } elseif ($call_num > 0 and $call_num <= count($modules_all)) {
        // render all activated modules
        $call_counter = 0;
        $counter = 0;
        foreach ($modules_all as $index => $Value) {
            $counter++;
            // skip those, already parsed
            if ($counter < $call_num) {
                continue;
            }
            // parse module
            if (!$Value->parse()) {
                $_SESSION['admin_error'] = 'ERROR__RENDER (module: ' . $Value->getInfo('name') . ')';
                return false;
            }
            $call_counter++;
            // always parse 2 modules at a time
            if ($call_counter <= 1) {
                $call_num++;
                continue;
            }
            break;
        }
    } else {
        // log
        $Log->doLog(3, "Rendering: finish");
        // USERSYSTEM set?
        if (!$USERSYSTEM) {
            $_SESSION['admin_error'] = 'ERROR__RENDER (usersystem is missing!)';
            return false;
        }
        // render subcodes
        if (!$SubcodeHandler->parseAll()) {
            $_SESSION['admin_error'] = 'ERROR__RENDER (subfunction-parsing)';
            return false;
        }
        // render all activated styles
        $StyleHandler = new ts_StyleHandler();
        $styles_all = $StyleHandler->getStyles(true);
        $selected_default_style = $Config->get('default_style');
        $is_default_style = false;
        foreach ($styles_all as $index => $Value) {
            if ($selected_default_style and $Value->getInfo('id') == $selected_default_style) {
                $is_default_style = true;
            }
            if (!$Value->parse()) {
                $_SESSION['admin_error'] = 'ERROR__RENDER (style: ' . $Value->getInfo('name') . ')';
                return false;
            }
        }
        // set default style, if missing
        if (!$is_default_style) {
            $first_style = array_shift($styles_all);
            $Config->set('default_style', $first_style->getInfo('id'));
        }
        // make sure, a default-style is chosen
        $StyleHandler->validateDefault();
        // get format.css
        if ($format = $FormatHandler->writeFiles() === false) {
            $_SESSION['admin_error'] = 'ERROR__RENDER (format.css)';
            return false;
        }
        // render language-files
        if (!$LanguageHandler->writeFiles()) {
            $_SESSION['admin_error'] = 'ERROR__RENDER (language-files)';
            return false;
        }
        // parse Access
        if (!$AccessParser->parseAll($Config->get("prefix") . "mod{$USERSYSTEM}__")) {
            $_SESSION['admin_error'] = 'ERROR__RENDER (access-files)';
            return false;
        }
        // parse Config
        if (!$ConfigParser->parseAll($Config->get('prefix') . "mod{$USERSYSTEM}__config")) {
            $_SESSION['admin_error'] = 'ERROR__RENDER (config-files)';
            return false;
        }
        // move special files to runtime root
        $special_files = array('index.php', 'ajax.php', 'webdav.php', 'offline.php', 'init.php', 'file.php');
        foreach ($special_files as $index => $value) {
            if (file_exists($Config->get('dir_runtime') . "/static/{$value}") and !ts_FileHandler::moveFile($Config->get('dir_runtime') . "/static/{$value}", $Config->get('dir_runtime') . "/{$value}")) {
                $_SESSION['admin_error'] = 'ERROR__RENDER (copy special files "' . $value . '")';
                return false;
            }
        }
        // config
        $config = '<?php include "' . $Config->get('dir_data') . '/config.php"; ?>';
        if (!ts_FileHandler::writeFile($Config->get('dir_runtime') . '/config.php', $config, 1)) {
            $_SESSION['admin_error'] = 'ERROR__RENDER (write config)';
            return false;
        }
        // reset system_online
        $Config->set('system_online', $pre_system_online);
        // update installation-progress
        if ($Config->get('installation') < 100) {
            $Config->setArray('installation_progress', 'parseAll', true);
        }
        $_SESSION['admin_info'] = 'INFO__RENDER_SUCCESS';
    }
    // update call-progress
    if ($call_num > count($modules_all) + 2) {
        // finished
        unset($_SESSION['parseAll__call']);
    } else {
        // save vars
        if (!isset($_SESSION['parseAll__call']) or empty($_SESSION['parseAll__call'])) {
            $_SESSION['parseAll__call'] = array();
        }
        $_SESSION['parseAll__call']['num'] = $call_num + 1;
        $_SESSION['parseAll__call']['LanguageHandler'] = $LanguageHandler;
        $_SESSION['parseAll__call']['FormatHandler'] = $FormatHandler;
        $_SESSION['parseAll__call']['SubcodeHandler'] = $SubcodeHandler;
        $_SESSION['parseAll__call']['AccessParser'] = $AccessParser;
        $_SESSION['parseAll__call']['ConfigParser'] = $ConfigParser;
        $_SESSION['parseAll__call']['USERSYSTEM'] = $USERSYSTEM;
        $_SESSION['parseAll__call']['Parser'] = $Parser;
        $_SESSION['parseAll__call']['modules_all'] = $modules_all;
        $_SESSION['parseAll__call']['pre_system_online'] = $pre_system_online;
        // redirect to next
        header('Location:?event=parseAll&call=' . $call_num);
        exit;
    }
    return true;
}
Beispiel #3
0
     header('Location:?event=showModules');
     exit;
 case 'deleteModule':
     include_once 'functions/deleteModule.func.php';
     deleteModule();
     header('Location:?event=showModules');
     exit;
 case 'showStyles':
     // init database?
     include_once 'functions/initDatabase.func.php';
     if (!initDatabase()) {
         header('Location:?event=showInitDatabase');
     }
     // start StyleHandler
     global $StyleHandler;
     $StyleHandler = new ts_StyleHandler();
     $Styles = $StyleHandler->getStyles();
     $TemplateEngine->setData('html', array('title' => 'SHOWSTYLES__TITLE'));
     $TemplateEngine->activate('showStyles');
     break;
 case 'setStyles':
     // start StyleHandler
     global $StyleHandler;
     $StyleHandler = new ts_StyleHandler();
     include_once 'functions/setStyles.func.php';
     setStyles();
     header('Location:?event=showStyles');
     exit;
 case 'setDefaultStyle':
     include_once 'functions/setDefaultStyle.func.php';
     setDefaultStyle();