Saved install from being lost started reworking codebase

This commit is contained in:
genuineparts 2025-06-22 14:16:52 +02:00
parent ebb4d5b72f
commit 76cafe30b3
60 changed files with 2752 additions and 36 deletions

View file

@ -1,6 +1,6 @@
<?php
<?php global $basepath, $config;
/**
* Project: astat - simple site engine
* Project: BeCast WebEngine - simple site engine
* File: init_core.inc.php
*
* This library is free software; you can redistribute it and/or
@ -17,27 +17,27 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* @link http://www.astat.org SVN: $URL: http://svn.becast.at/astat/trunk/core/init_core.inc.php $
* @copyright 2009 becast.at
* @link http://www.becast.at
* @copyright 2009-2025 becast.at
* @author Bernhard Jaud <bernhard at becast dot at>
* @package astat core
* @package BcWe core
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
* @version $Id: init_core.inc.php 148 2012-03-27 19:48:30Z genuineparts $
*/
* @version $Id$
*/
define('in_astat', true);
const in_astat = true;
function getTime() {
function getTime(): string
{
$timer = explode( ' ', microtime() );
$timer = $timer[1] + $timer[0];
return $timer;
return $timer[1] . $timer[0];
}
$start = getTime();
/**
* Configuration
*/
require dirname(dirname(__FILE__)).'/inc/config.inc.php';
require dirname(__FILE__, 2) .'/inc/config.inc.php';
/**
* Smarty
@ -53,42 +53,42 @@ require $basepath.'database/'.$config['db_class'].'.class.php';
/**
* Functions
*/
include dirname(dirname(__FILE__)).'/inc/functions.class.php';
include dirname(__FILE__, 2) .'/inc/functions.class.php';
/**
* Logger
*/
require dirname(dirname(__FILE__)).'/inc/logger.class.php';
require dirname(__FILE__, 2) .'/inc/logger.class.php';
/**
* Logger
*/
require dirname(dirname(__FILE__)).'/inc/datacache.class.php';
require dirname(__FILE__, 2) .'/inc/datacache.class.php';
/**
* Cache
*/
require dirname(dirname(__FILE__)).'/inc/cache.class.php';
require dirname(__FILE__, 2) .'/inc/cache.class.php';
/**
* Errors
*/
include dirname(dirname(__FILE__)).'/inc/error.class.php';
include dirname(__FILE__, 2) .'/inc/error.class.php';
/**
* Plugins
*/
include dirname(dirname(__FILE__)).'/inc/plugin.class.php';
include dirname(__FILE__, 2) .'/inc/plugin.class.php';
/**
* Mail
*/
include dirname(dirname(__FILE__)).'/inc/mail.class.php';
include dirname(__FILE__, 2) .'/inc/mail.class.php';
/**
* Captcha
*/
include dirname(dirname(__FILE__)).'/inc/captcha.class.php';
include dirname(__FILE__, 2) .'/inc/captcha.class.php';
$plugin=new plugins();
$db= new db($config['host'], $config['user'], $config['pass'], $config['db'],'utf8', true);
@ -97,7 +97,7 @@ $db= new db($config['host'], $config['user'], $config['pass'], $config['db'],'ut
* Select $config vars form Database
*
*/
$result = $db->query("SELECT `name`, `value` FROM " . $config['prefix'] . "config");
$result = $db->query("SELECT `name`, `value` FROM `" . $config['prefix'] . "config`");
while ($row = $db->fetch_array($result)){
$config[$row['name']] = $row['value'];
}
@ -130,7 +130,7 @@ if(!isset($config['path'])){
$last = array_pop($path);
$path = str_replace('/' . $last, '', $_SERVER['SCRIPT_NAME']);
$config['path'] = $path;
$db->query("INSERT INTO " . $config['prefix'] . "config (`name`, `value`, `title`, `description`, `option`, `category`) VALUES
$db->query("INSERT INTO `" . $config['prefix'] . "config` (`name`, `value`, `title`, `description`, `option`, `category`) VALUES
( 'path', '".$path."', 'Pfad', 'Der Pfad auf ihrem Webserver z.b. /cms', 'text', 1)");
}else{
$path=$config['path'];
@ -140,7 +140,7 @@ if(!isset($config['path'])){
* Start Logger
*
*/
$log=new logger($config['logtype'],dirname(dirname(__FILE__)).'/logs/'.$config['logfile'],$config['loglevel']);
$log=new logger($config['logtype'], dirname(__FILE__, 2) .'/logs/'.$config['logfile'],$config['loglevel']);
$tpl = new Smarty();
$error = new errorhandler();
$functions = new functions();
@ -150,7 +150,7 @@ $root = $_SERVER['DOCUMENT_ROOT'] . $config['path'];
* Start Language
*
*/
require dirname(dirname(__FILE__)).'/inc/lang.class.php';
require dirname(__FILE__, 2) .'/inc/lang.class.php';
$lang=new lang();
@ -171,8 +171,12 @@ if(isset($config['theme']) && $config['theme']!='' && is_dir($root . '/themes/'.
$tpl->setCompileDir($root . '/core/template/templates_c');
$tpl->setCacheDir($root . '/core/template/cache');
$tpl->setConfigDir($root . '/core/template/config');
$tpl->loadFilter(\Smarty\Smarty::FILTER_OUTPUT,'trimwhitespace');
$tpl->registerFilter("output", "lang");
try {
$tpl->registerFilter(\Smarty\Smarty::FILTER_OUTPUT, 'trimwhitespace');
$tpl->registerFilter(\Smarty\Smarty::FILTER_OUTPUT, "lang");
} catch (\Smarty\Exception $e) {
$log->write("Smarty Register Filter error", $e->getMessage());
}
//var_dump($tpl -> getAutoloadFilters());
/**
* Well... This should vanish with Thememanagement
@ -186,7 +190,7 @@ $addnav['left'] = TRUE;
* Start Sessions
*
*/
require dirname(dirname(__FILE__)).'/inc/sessions.class.php';
require dirname(__FILE__, 2) .'/inc/sessions.class.php';
$session=new session();
@ -194,12 +198,13 @@ $session=new session();
* Initiate Core Class
*
*/
require dirname(dirname(__FILE__)).'/inc/core.class.php';
require dirname(__FILE__, 2) .'/inc/core.class.php';
$core=new core($db, $log, $tpl);
if(defined('INSTALLED')){
if(is_dir(dirname(dirname(__FILE__)).'/install')){
return $core->message($lang->_('DELINSTALLDIR'), $lang->_('DELINSTALLDIRTEXT'),FALSE);
if(is_dir(dirname(__FILE__, 2) .'/install')){
$core->message($lang->_('DELINSTALLDIR'), $lang->_('DELINSTALLDIRTEXT'),FALSE);
return;
}
}else{
header("Location: install/install.php");
@ -211,7 +216,7 @@ $captcha = new captcha();
* OpenID
*/
if($config['use_openid']==1){
include dirname(dirname(__FILE__)).'/inc/SimpleOpenID.class.php';
include dirname(__FILE__, 2) .'/inc/SimpleOpenID.class.php';
}
/**
* Get all *.plugin.php files from the Modules and register the Pluginhooks
@ -250,13 +255,11 @@ function langstr($treffer)
* Its useful but "undocumented".
*
*/
$moduledir = dirname(dirname(__FILE__)).'/core/modules';
$moduledir = dirname(__FILE__, 2) .'/core/modules';
$modules = opendir($moduledir);
while ($mods = readdir($modules)) {
if (preg_match('/^.*?\.class.php$/', $mods)) {
require_once($moduledir.'/'.$mods);
}
}
@closedir($modules);
?>
@closedir($modules);