Replaced every loop through 'app' with a call to the app class

This commit is contained in:
kolaente 2016-10-20 17:04:34 +02:00
parent b6a4ecbe1e
commit 5911138b65
10 changed files with 367 additions and 360 deletions

View File

@ -16,8 +16,7 @@ if (isset($_GET['dbbackup']) && is_loggedin() && hasPerm('db_dump'))
if ($backup['error'])
{
echo msg('fail', $lang->get('action_backup_fail'));
}
else
} else
{
header("Cache-Control: public");
header("content-Description: File Transfer");
@ -27,137 +26,136 @@ if (isset($_GET['dbbackup']) && is_loggedin() && hasPerm('db_dump'))
echo $backup['msg'];
exit;
}
}
else
} else
{
printHeader($lang->get('action_edit_content'));
}
if (hasPerm('manage_system'))
{
//construction
if (isset($_GET['construction']))
if (isset($_GET['construction']))
{
if (isset($_GET['constr_message']))
{
if (isset($_GET['constr_message']))
if (isset($_POST['constr_message']))
{
if (isset($_POST['constr_message']))
if (file_put_contents('../inc/System/construction2.txt', $_POST['constr_message']))
{
if (file_put_contents('../inc/System/construction2.txt', $_POST['constr_message']))
{
copy('../inc/System/construction2.txt', '../inc/System/construction.txt');
echo msg('succes', $lang->get('action_construction_message_success').' <a href="general_config.php">'.$lang->get('back').'</a>');
} else
{
echo msg('fail', $lang->get('action_try_again_later').' <a href="general_config.php">'.$lang->get('back').'</a>');
}
copy('../inc/System/construction2.txt', '../inc/System/construction.txt');
echo msg('succes', $lang->get('action_construction_message_success') . ' <a href="general_config.php">' . $lang->get('back') . '</a>');
} else
{
tinymce();
?>
<div class="main">
<h1><?php echo $lang->get('action_construction_message_edit');?></h1>
<form action="<?php echo $_SERVER['REQUEST_URI']?>" method="post">
<textarea id="editor" name="constr_message"><?php require('../inc/System/construction2.txt'); ?></textarea>
<input type="submit" value="<?php echo $lang->get('general_save_changes');?>"/>
</form>
</div>
<?php
echo msg('fail', $lang->get('action_try_again_later') . ' <a href="general_config.php">' . $lang->get('back') . '</a>');
}
} else
{
if(hasPerm('construction'))
tinymce();
?>
<div class="main">
<h1><?php echo $lang->get('action_construction_message_edit'); ?></h1>
<form action="<?php echo $_SERVER['REQUEST_URI'] ?>" method="post">
<textarea id="editor"
name="constr_message"><?php require('../inc/System/construction2.txt'); ?></textarea>
<input type="submit" value="<?php echo $lang->get('general_save_changes'); ?>"/>
</form>
</div>
<?php
}
} else
{
if (hasPerm('construction'))
{
if (!file_exists('../inc/System/construction.txt'))
{
if (!file_exists('../inc/System/construction.txt'))
if (isset($_GET['confirm']))
{
if (isset($_GET['confirm']))
if (copy('../inc/System/construction2.txt', '../inc/System/construction.txt'))
{
if (copy('../inc/System/construction2.txt', '../inc/System/construction.txt'))
{
echo msg('succes', $lang->get('action_construction_success').' <a href="general_config.php">'.$lang->get('back').'</a>');
} else
{
echo msg('fail', $lang->get('action_try_again_later').' <a href="general_config.php">'.$lang->get('back').'</a>');
}
echo msg('succes', $lang->get('action_construction_success') . ' <a href="general_config.php">' . $lang->get('back') . '</a>');
} else
{
?>
<div class="main">
<p style="text-align: center;">
<?php echo $lang->get('action_construction_confirm');?><br/>
<a href="action.php?construction&confirm" class="button"><?php echo $lang->get('general_yes');?></a>
<a href="general_config.php" class="button btn_del"><?php echo $lang->get('general_no');?></a>
</p>
</div>
<?php
echo msg('fail', $lang->get('action_try_again_later') . ' <a href="general_config.php">' . $lang->get('back') . '</a>');
}
} else
{
if (isset($_GET['confirm']))
{
if (unlink('../inc/System/construction.txt'))
{
echo msg('succes', $lang->get('action_construction_removed_success').' <a href="general_config.php">'.$lang->get('back').'</a>');
} else
{
echo msg('fail', $lang->get('action_try_again_later').' <a href="general_config.php">'.$lang->get('back').'</a>');
}
} else
{
?>
<div class="main">
?>
<div class="main">
<p style="text-align: center;">
<?php echo $lang->get('action_construction_remove');?><br/>
<a href="action.php?construction&confirm" class="button"><?php echo $lang->get('general_yes');?></a>
<a href="general_config.php" class="button btn_del"><?php echo $lang->get('general_no');?></a>
<?php echo $lang->get('action_construction_confirm'); ?><br/>
<a href="action.php?construction&confirm"
class="button"><?php echo $lang->get('general_yes'); ?></a>
<a href="general_config.php"
class="button btn_del"><?php echo $lang->get('general_no'); ?></a>
</p>
</div>
<?php
}
</div>
<?php
}
}
}
}
//Generelle Änderungen
if (isset($_GET['general']))
{
//Header
if(hasPerm('edit_title'))
{
$titel = $_POST['titel'];
if (file_put_contents('../inc/System/page_title.txt', $titel))
{
echo msg('succes', $lang->get('action_change_page_title_success'));
} else
{
echo msg('fail', $lang->get('action_try_again_later'));
}
}
$moduluri = '../apps/';
if ($handle = opendir($moduluri))
{
while (false !== ($mod = readdir($handle)))
{
if ($mod != "." && $mod != ".." && is_dir($moduluri . $mod))
if (isset($_GET['confirm']))
{
require $moduluri . $mod . '/config.php';
if (isset($_CONF['general_conf']) && $_CONF['general_conf'] != '' && file_exists($moduluri . $mod . '/' . $_CONF['general_conf']))
if (unlink('../inc/System/construction.txt'))
{
//echo '<li class="divider"></li>';
require $moduluri . $mod . '/' . $_CONF['general_conf'];
echo msg('succes', $lang->get('action_construction_removed_success') . ' <a href="general_config.php">' . $lang->get('back') . '</a>');
} else
{
echo msg('fail', $lang->get('action_try_again_later') . ' <a href="general_config.php">' . $lang->get('back') . '</a>');
}
} else
{
?>
<div class="main">
<p style="text-align: center;">
<?php echo $lang->get('action_construction_remove'); ?><br/>
<a href="action.php?construction&confirm"
class="button"><?php echo $lang->get('general_yes'); ?></a>
<a href="general_config.php"
class="button btn_del"><?php echo $lang->get('general_no'); ?></a>
</p>
</div>
<?php
}
}
closedir($handle);
}
}
//Update
if(isset($_GET['update']))
}
//Generelle Änderungen
if (isset($_GET['general']))
{
if(hasPerm('update'))
//Header
if (hasPerm('edit_title'))
{
$version_remote = json_decode(file_get_contents($MCONF['update_uri'].'version.json'));
$titel = $_POST['titel'];
if (file_put_contents('../inc/System/page_title.txt', $titel))
{
echo msg('succes', $lang->get('action_change_page_title_success'));
} else
{
echo msg('fail', $lang->get('action_try_again_later'));
}
}
$apps = new apps();
$appUri = '../apps/';
foreach ($apps->getApps() as $app => $appconf)
{
require $appUri . $app . '/config.php';
if (isset($_CONF['general_conf']) && $_CONF['general_conf'] != '' && file_exists($appUri . $app . '/' . $_CONF['general_conf']))
{
//echo '<li class="divider"></li>';
require $appUri . $app . '/' . $_CONF['general_conf'];
}
}
}
//Update
if (isset($_GET['update']))
{
if (hasPerm('update'))
{
$version_remote = json_decode(file_get_contents($MCONF['update_uri'] . 'version.json'));
if ($version_remote->versionNum > $MCONF['version_num'])
{
if (copy($MCONF['update_uri'].'update.v' . $version_remote->versionNum . '.incremental.zip', 'update.zip'))
if (copy($MCONF['update_uri'] . 'update.v' . $version_remote->versionNum . '.incremental.zip', 'update.zip'))
{
if (md5_file('update.zip') == $version_remote->md5)
{
@ -193,10 +191,10 @@ if (hasPerm('manage_system'))
//Jetzt altes update entfernen
if (rrmdir('updateNeu') && $isUp && unlink('update.zip'))
{
echo msg('succes', $lang->get('action_update_success').' <a href="general_config.php">'.$lang->get('back').'</a>');
echo msg('succes', $lang->get('action_update_success') . ' <a href="general_config.php">' . $lang->get('back') . '</a>');
} else
{
echo msg('fail', $lang->get('action_update_fail').' <a href="general_config.php">'.$lang->get('back').'</a>');
echo msg('fail', $lang->get('action_update_fail') . ' <a href="general_config.php">' . $lang->get('back') . '</a>');
}
} else
{
@ -216,8 +214,7 @@ if (hasPerm('manage_system'))
}
}
}
}
else
} else
{
echo msg('info', $lang->get('missing_permission'));
}

View File

@ -2,15 +2,15 @@
require_once '../inc/autoload_adm.php';
printHeader($lang->get('general_config'));
tinymce();
?>
<div class="main">
?>
<div class="main">
<form method="POST" action="action.php?general">
<div class="form">
<?php
if(hasPerm('edit_title'))
if (hasPerm('edit_title'))
{
?>
<p><span><?php echo $lang->get('general_website_title');?></span>
<p><span><?php echo $lang->get('general_website_title'); ?></span>
<input type="text" name="titel" value="<?php
echo $MCONF['title'];
?>"/>
@ -18,86 +18,85 @@ tinymce();
<?php
}
if(hasPerm('construction'))
if (hasPerm('construction'))
{
?>
<p><span><?php echo $lang->get('general_construction_mode');?></span>
<p><span><?php echo $lang->get('general_construction_mode'); ?></span>
<?php
if (file_exists('../inc/System/construction.txt'))
{
echo '<a href="action.php?construction" class="button">'.$lang->get('general_end_construction_mode').'</a>';
echo '<a href="action.php?construction" class="button">' . $lang->get('general_end_construction_mode') . '</a>';
} else
{
echo '<a href="action.php?construction" class="button">'.$lang->get('general_start_construction_mode').'</a>';
echo '<a href="action.php?construction" class="button">' . $lang->get('general_start_construction_mode') . '</a>';
}
?> <a href="action.php?construction&constr_message" class="button"><?php echo $lang->get('general_edit_message');?></a>
?> <a href="action.php?construction&constr_message"
class="button"><?php echo $lang->get('general_edit_message'); ?></a>
</p>
<?php
}
if(hasPerm('update'))
{
?>
<i class="divider"></i>
<h1><?php echo $lang->get('general_version');?></h1>
<p><?php echo $lang->get('general_version_current');?>:
<?php
echo $MCONF['version'];
?>
</p>
<p>
<?php
$version_remote = json_decode(file_get_contents($MCONF['update_uri'].'version.json'));
if ($version_remote->versionNum > $MCONF['version_num'])
{
echo $lang->get('general_new_version').' <b>' . $version_remote->version . '</b> <a href="action.php?update" class="button">'.$lang->get('general_update').'</a>';
}
else
{
echo $lang->get('general_version_current_new');
}
?>
</p>
<?php
}
if(hasPerm('db_dump'))
if (hasPerm('update'))
{
?>
<i class="divider"></i>
<h1><?php echo $lang->get('general_database');?></h1>
<h1><?php echo $lang->get('general_version'); ?></h1>
<p><?php echo $lang->get('general_version_current'); ?>:
<?php
echo $MCONF['version'];
?>
</p>
<p>
<a href="action.php?dbbackup" class="button" download="download"><i class="fa fa-database"></i> <?php echo $lang->get('general_create_backup');?>
</a>
<a href="<?php
echo $MCONF['phpmyadmin'];
?>" class="button" target="_blank"><?php echo $lang->get('general_go_phpmyadmin');?> <i class="fa fa-external-link"></i></a>
<?php
$version_remote = json_decode(file_get_contents($MCONF['update_uri'] . 'version.json'));
if ($version_remote->versionNum > $MCONF['version_num'])
{
echo $lang->get('general_new_version') . ' <b>' . $version_remote->version . '</b> <a href="action.php?update" class="button">' . $lang->get('general_update') . '</a>';
} else
{
echo $lang->get('general_version_current_new');
}
?>
</p>
<?php
}
$moduluri = '../apps/';
if ($handle = opendir($moduluri))
if (hasPerm('db_dump'))
{
while (false !== ($mod = readdir($handle)))
?>
<i class="divider"></i>
<h1><?php echo $lang->get('general_database'); ?></h1>
<p>
<a href="action.php?dbbackup" class="button" download="download"><i
class="fa fa-database"></i> <?php echo $lang->get('general_create_backup'); ?>
</a>
<a href="<?php
echo $MCONF['phpmyadmin'];
?>" class="button" target="_blank"><?php echo $lang->get('general_go_phpmyadmin'); ?> <i
class="fa fa-external-link"></i></a>
</p>
<?php
}
$apps = new apps();
$appUri = '../apps/';
foreach ($apps->getApps() as $app => $appconf)
{
require $appUri . $app . '/config.php';
if (isset($_CONF['general_conf']) && $_CONF['general_conf'] != '' && file_exists($appUri . $app . '/' . $_CONF['general_conf']))
{
if ($mod != "." && $mod != ".." && is_dir($moduluri.$mod))
{
require $moduluri.$mod.'/config.php';
if(isset($_CONF['general_conf']) && $_CONF['general_conf']!='' && file_exists($moduluri.$mod.'/'.$_CONF['general_conf']))
{
echo '<i class="divider"></i>';
require $moduluri.$mod.'/'.$_CONF['general_conf'];
}
}
echo '<i class="divider"></i>';
require $appUri . $app . '/' . $_CONF['general_conf'];
}
closedir($handle);
}
?>
<i class="divider"></i>
<input type="submit" class="speichern" value="<?php echo $lang->get('general_save_changes');?>" style="width: auto;" />
<input type="submit" class="speichern" value="<?php echo $lang->get('general_save_changes'); ?>"
style="width: auto;"/>
</form>
<?php
<?php
echo '</div>';
require_once '../inc/footer.php';
?>

View File

@ -13,47 +13,48 @@ if (file_exists('install.php'))
if (hasPerm('view_dashboard'))
{
echo '<div class="cardsContainer cardsContainer-main"><div class="card-yellow" title="' . php_uname() . '"><span>' . substr(php_uname(), 0, strpos(php_uname(), ' ')) . '</span>'.$lang->get('os').'</div>';
echo '<div class="card-green" title="' . $_SERVER['SERVER_SOFTWARE'] . '"><span>' . $_SERVER['SERVER_SOFTWARE'] . '</span>'.$lang->get('server_software').'</div>';
echo '<div class="card-indigo" title="' . PHP_VERSION . '"><span>' . str_replace(substr(PHP_VERSION, strpos(PHP_VERSION, '-')), '', PHP_VERSION) . '</span>'.$lang->get('php_version').'</div>';
echo '<div class="card-orange" title="' . $db->version() . '"><span>' . str_replace(substr($db->version(), strpos($db->version(), '-')), '', $db->version()) . '</span>'.$lang->get('mysql_version').'</div></div><div class="cardsContainer cardsContainer-main">';
echo '<div class="card-purple"><span>' . date('H:i:s') . '</span>'.$lang->get('system_time').'</div>';
echo '<div class="cardsContainer cardsContainer-main"><div class="card-yellow" title="' . php_uname() . '"><span>' . substr(php_uname(), 0, strpos(php_uname(), ' ')) . '</span>' . $lang->get('os') . '</div>';
echo '<div class="card-green" title="' . $_SERVER['SERVER_SOFTWARE'] . '"><span>' . $_SERVER['SERVER_SOFTWARE'] . '</span>' . $lang->get('server_software') . '</div>';
echo '<div class="card-indigo" title="' . PHP_VERSION . '"><span>' . str_replace(substr(PHP_VERSION, strpos(PHP_VERSION, '-')), '', PHP_VERSION) . '</span>' . $lang->get('php_version') . '</div>';
echo '<div class="card-orange" title="' . $db->version() . '"><span>' . str_replace(substr($db->version(), strpos($db->version(), '-')), '', $db->version()) . '</span>' . $lang->get('mysql_version') . '</div></div><div class="cardsContainer cardsContainer-main">';
echo '<div class="card-purple"><span>' . date('H:i:s') . '</span>' . $lang->get('system_time') . '</div>';
?>
<a href="general_config.php" class="card-blue"><span><i class="fa fa-cog"></i></span><br/>
<?php echo $lang->get('general_config');?></a>
<a href=".<?php echo $GLOBALS['MCONF']['home_uri']; ?>apps/logfiles/index.php" class="card-lime"><span><i class="fa fa-list"></i></span><br/><?php echo $lang->get('logfiles');?></a>
<?php echo $lang->get('general_config'); ?></a>
<a href=".<?php echo $GLOBALS['MCONF']['home_uri']; ?>apps/logfiles/index.php" class="card-lime"><span><i
class="fa fa-list"></i></span><br/><?php echo $lang->get('logfiles'); ?></a>
</div>
<div class="cardsContainer cardsContainer-main">
<a href="<?php echo $GLOBALS['MCONF']['home_uri']; ?>apps/SimplePages/backend/management.php" class="card-red"><span><i class="fa fa-list"></i></span><br/><?php echo $lang->get('manage_pages');?></a>
<a href="<?php echo $GLOBALS['MCONF']['home_uri']; ?>apps/SimplePages/backend/permissions.php" class="card-pink"><span><i class="fa fa-lock"></i></span><br/><?php echo $lang->get('manage_contents');?></a>
<a href="<?php echo $GLOBALS['MCONF']['home_uri']; ?>apps/SimplePages/backend/management.php"
class="card-red"><span><i class="fa fa-list"></i></span><br/><?php echo $lang->get('manage_pages'); ?></a>
<a href="<?php echo $GLOBALS['MCONF']['home_uri']; ?>apps/SimplePages/backend/permissions.php"
class="card-pink"><span><i class="fa fa-lock"></i></span><br/><?php echo $lang->get('manage_contents'); ?>
</a>
<a href="<?php echo $GLOBALS['MCONF']['home_uri']; ?>apps/Files/index.php" class="card-amber"><span>
<i class="fa fa-file"></i></span><br/><?php echo $lang->get('manage_files');?></a>
<i class="fa fa-file"></i></span><br/><?php echo $lang->get('manage_files'); ?></a>
</div>
<?php
}
echo '<div class="main container">';
//Find Dashboard files
$moduluri = '../apps/';
if ($handle = opendir($moduluri))
$apps = new apps();
$appUri = '../apps/';
foreach ($apps->getApps() as $app => $appconf)
{
while (false !== ($mod = readdir($handle)))
require $appUri . $app . '/config.php';
if (isset($_CONF['dashboard']) && $_CONF['dashboard'] != '')
{
if ($mod != "." && $mod != ".." && is_dir($moduluri . $mod))
if (file_exists($appUri . $app . '/' . $_CONF['dashboard']))
{
require $moduluri . $mod . '/config.php';
if(isset($_CONF['dashboard']) && $_CONF['dashboard'] != '')
{
if (file_exists($moduluri . $mod . '/' . $_CONF['dashboard']))
{
echo '<div class="box">';
require $moduluri . $mod . '/' . $_CONF['dashboard'];
echo '</div>';
}
}
$_CONF['dashboard'] = '';
echo '<div class="box">';
require $appUri . $app . '/' . $_CONF['dashboard'];
echo '</div>';
}
}
closedir($handle);
$_CONF['dashboard'] = '';
}
echo '</div>';
require_once '../inc/footer.php';

View File

@ -11,38 +11,39 @@ require_once '../inc/libs/lang.class.php';
require_once '../inc/libs/db-mysql.php';
require_once '../inc/libs/YAML/autoload.php';
use Symfony\Component\Yaml\Yaml;
$lang = new lang();
$lang->setLangFolder('lang/');
?>
<html>
<head>
<title>Installation</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<link rel="stylesheet" href="assets/admin.css" type="text/css">
</head>
<body style="background: url('assets/bglogin.jpg') no-repeat center fixed;">
<img src="http://server/SelfCMS/Version2/admin/assets/Logo.svg" alt="Mowie" class="install-logo"/>
<h1 style="text-align: center; color: #E8E8E8;">Installation</h1>
<?php
if(isset($_POST['submit']))
if (isset($_POST['submit']))
{
if(
$_POST['lang'] !=='' &&
$_POST['db_host'] !=='' &&
$_POST['db_name'] !=='' &&
$_POST['db_user'] !=='' &&
$_POST['db_pw1'] !=='' &&
$_POST['db_pw2'] !=='' &&
$_POST['general_webUrl'] !=='' &&
$_POST['general_home_url'] !=='' &&
$_POST['general_pma'] !=='' &&
$_POST['general_page_title'] !=='' &&
$_POST['general_editor_css'] !=='' &&
$_POST['general_template'] !=='' &&
$_POST['admin_name'] !=='' &&
$_POST['admin_mail'] !=='' &&
$_POST['admin_pw1'] !=='' &&
$_POST['admin_pw2'] !==''
if (
$_POST['lang'] !== '' &&
$_POST['db_host'] !== '' &&
$_POST['db_name'] !== '' &&
$_POST['db_user'] !== '' &&
$_POST['db_pw1'] !== '' &&
$_POST['db_pw2'] !== '' &&
$_POST['general_webUrl'] !== '' &&
$_POST['general_home_url'] !== '' &&
$_POST['general_pma'] !== '' &&
$_POST['general_page_title'] !== '' &&
$_POST['general_editor_css'] !== '' &&
$_POST['general_template'] !== '' &&
$_POST['admin_name'] !== '' &&
$_POST['admin_mail'] !== '' &&
$_POST['admin_pw1'] !== '' &&
$_POST['admin_pw2'] !== ''
)
{
$CONFIG = [];
@ -67,9 +68,9 @@ if(isset($_POST['submit']))
$CONFIG['Mail']['smtp'] = false;
//Mail Settings
if(isset($_POST['mail_smtp']))
if (isset($_POST['mail_smtp']))
{
if($_POST['mail_host'] != '' && $_POST['mail_user'] != '' && $_POST['mail_pass'] != '' && $_POST['mail_secure'] != '' && $_POST['mail_port'] != '')
if ($_POST['mail_host'] != '' && $_POST['mail_user'] != '' && $_POST['mail_pass'] != '' && $_POST['mail_secure'] != '' && $_POST['mail_port'] != '')
{
$CONFIG['Mail']['smtp'] = true;
$config['Mail']['host'] = $_POST['mail_host'];
@ -77,8 +78,7 @@ if(isset($_POST['submit']))
$config['Mail']['password'] = $_POST['mail_pass'];
$config['Mail']['secure'] = $_POST['mail_secure'];
$config['Mail']['port'] = $_POST['mail_port'];
}
else
} else
{
echo msg('fail', 'Please provide all SMTP-Informations.');
exit;
@ -86,12 +86,12 @@ if(isset($_POST['submit']))
}
//Test Passwords
if($_POST['db_pw1']!==$_POST['db_pw2'])
if ($_POST['db_pw1'] !== $_POST['db_pw2'])
{
echo msg('fail', 'Mysqlpasswords don\'t match.');
exit;
}
if($_POST['admin_pw1']!==$_POST['admin_pw2'])
if ($_POST['admin_pw1'] !== $_POST['admin_pw2'])
{
echo msg('fail', 'Adminpasswords don\'t match');
exit;
@ -101,19 +101,19 @@ if(isset($_POST['submit']))
$db = new db($_POST['db_host'], $_POST['db_name'], $_POST['db_user'], $_POST['db_pw1'], $_POST['db_prefix']);
//Create Tables
if($db->query('SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
if ($db->query('SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
CREATE TABLE `'.$_POST['db_prefix'].'meta_meta` (
CREATE TABLE `' . $_POST['db_prefix'] . 'meta_meta` (
`name` text NOT NULL,
`content` text NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `'.$_POST['db_prefix'].'sidebar_sidebar` (
CREATE TABLE `' . $_POST['db_prefix'] . 'sidebar_sidebar` (
`active` tinyint(1) NOT NULL,
`content` text NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
INSERT INTO `'.$_POST['db_prefix'].'sidebar_sidebar` (`active`, `content`) VALUES
INSERT INTO `' . $_POST['db_prefix'] . 'sidebar_sidebar` (`active`, `content`) VALUES
(0, \'\');
CREATE TABLE `'.$_POST['db_prefix'].'simplePages_pages` (
CREATE TABLE `' . $_POST['db_prefix'] . 'simplePages_pages` (
`id` int(11) NOT NULL,
`title` text CHARACTER SET utf8 NOT NULL,
`alias` longtext CHARACTER SET utf8 NOT NULL,
@ -125,7 +125,7 @@ CREATE TABLE `'.$_POST['db_prefix'].'simplePages_pages` (
`created` int(11) NOT NULL,
`lastedit` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `'.$_POST['db_prefix'].'simplePages_pages_confirm` (
CREATE TABLE `' . $_POST['db_prefix'] . 'simplePages_pages_confirm` (
`id` int(11) NOT NULL,
`page_id` int(11) NOT NULL,
`title` text CHARACTER SET utf8 NOT NULL,
@ -138,13 +138,13 @@ CREATE TABLE `'.$_POST['db_prefix'].'simplePages_pages_confirm` (
`created` int(11) NOT NULL,
`lastedit` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `'.$_POST['db_prefix'].'simplePages_permissions` (
CREATE TABLE `' . $_POST['db_prefix'] . 'simplePages_permissions` (
`id` int(11) NOT NULL,
`page` int(11) NOT NULL,
`user` int(11) NOT NULL,
`lastedit` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
CREATE TABLE `'.$_POST['db_prefix'].'system_admins` (
CREATE TABLE `' . $_POST['db_prefix'] . 'system_admins` (
`id` int(11) NOT NULL,
`username` text NOT NULL,
`pass` text NOT NULL,
@ -152,7 +152,7 @@ CREATE TABLE `'.$_POST['db_prefix'].'system_admins` (
`mail` text NOT NULL,
`secret` text NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `'.$_POST['db_prefix'].'system_loggedin` (
CREATE TABLE `' . $_POST['db_prefix'] . 'system_loggedin` (
`id` int(11) NOT NULL,
`user` int(11) NOT NULL,
`user_agent` longtext NOT NULL,
@ -160,42 +160,42 @@ CREATE TABLE `'.$_POST['db_prefix'].'system_loggedin` (
`time` int(11) NOT NULL,
`token` text NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `'.$_POST['db_prefix'].'system_roles` (
CREATE TABLE `' . $_POST['db_prefix'] . 'system_roles` (
`id` int(11) NOT NULL,
`name` text COLLATE utf8_unicode_ci NOT NULL,
`permissions` longtext COLLATE utf8_unicode_ci NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
ALTER TABLE `'.$_POST['db_prefix'].'simplePages_pages`
ALTER TABLE `' . $_POST['db_prefix'] . 'simplePages_pages`
ADD PRIMARY KEY (`id`);
ALTER TABLE `'.$_POST['db_prefix'].'simplePages_pages_confirm`
ALTER TABLE `' . $_POST['db_prefix'] . 'simplePages_pages_confirm`
ADD PRIMARY KEY (`id`);
ALTER TABLE `'.$_POST['db_prefix'].'simplePages_permissions`
ALTER TABLE `' . $_POST['db_prefix'] . 'simplePages_permissions`
ADD PRIMARY KEY (`id`);
ALTER TABLE `'.$_POST['db_prefix'].'system_admins`
ALTER TABLE `' . $_POST['db_prefix'] . 'system_admins`
ADD PRIMARY KEY (`id`);
ALTER TABLE `'.$_POST['db_prefix'].'system_loggedin`
ALTER TABLE `' . $_POST['db_prefix'] . 'system_loggedin`
ADD PRIMARY KEY (`id`);
ALTER TABLE `'.$_POST['db_prefix'].'system_roles`
ALTER TABLE `' . $_POST['db_prefix'] . 'system_roles`
ADD PRIMARY KEY (`id`);
ALTER TABLE `'.$_POST['db_prefix'].'simplePages_pages`
ALTER TABLE `' . $_POST['db_prefix'] . 'simplePages_pages`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=1;
ALTER TABLE `'.$_POST['db_prefix'].'simplePages_pages_confirm`
ALTER TABLE `' . $_POST['db_prefix'] . 'simplePages_pages_confirm`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
ALTER TABLE `'.$_POST['db_prefix'].'simplePages_permissions`
ALTER TABLE `' . $_POST['db_prefix'] . 'simplePages_permissions`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=1;
ALTER TABLE `'.$_POST['db_prefix'].'system_admins`
ALTER TABLE `' . $_POST['db_prefix'] . 'system_admins`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=1;
ALTER TABLE `'.$_POST['db_prefix'].'system_loggedin`
ALTER TABLE `' . $_POST['db_prefix'] . 'system_loggedin`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=1;
ALTER TABLE `'.$_POST['db_prefix'].'system_roles`
ALTER TABLE `' . $_POST['db_prefix'] . 'system_roles`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=1;
'))
')
)
{
echo msg('success', 'Created Tables successfully.');
}
else
} else
{
echo msg('fail', 'Failed Creating Tables');
exit;
@ -203,11 +203,10 @@ ALTER TABLE `'.$_POST['db_prefix'].'system_roles`
//Admin group
$db->setCol('system_roles');
$db->data['name'] = 'Admins';
if($db->insert())
if ($db->insert())
{
echo msg('success', 'Successfully created admin group.');
}
else
} else
{
echo msg('fail', 'Error creating admin group.');
exit;
@ -218,94 +217,82 @@ ALTER TABLE `'.$_POST['db_prefix'].'system_roles`
$db->data['pass'] = password_hash($_POST['admin_pw1'], PASSWORD_DEFAULT);
$db->data['lvl'] = 1;
$db->data['mail'] = $_POST['admin_mail'];
if($db->insert())
if ($db->insert())
{
echo msg('success', 'Successfully created admin user.');
}
else
} else
{
echo msg('fail', 'Error creating admin user.');
exit;
}
//Page title
if(file_put_contents('../inc/System/page_title.txt', $_POST['general_page_title']))
if (file_put_contents('../inc/System/page_title.txt', $_POST['general_page_title']))
{
echo msg('succes', 'Page Title was successfully set.<br/>');
}
else
} else
{
echo msg('fail', 'Error setting page title.');
exit;
}
//htacces
$htacces = 'ErrorDocument 404 '.$_POST['general_home_url'].'index.php
$htacces = 'ErrorDocument 404 ' . $_POST['general_home_url'] . 'index.php
<Ifapps mod_rewrite.c>
<Ifapps mod_env.c>
SetEnv gp_rewrite U9sL2S2
</Ifapps>
RewriteEngine On
RewriteBase "'.$_POST['general_home_url'].'"
RewriteBase "' . $_POST['general_home_url'] . '"
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
<Ifapps mod_cache.c>
RewriteRule /?(.*) "'.$_POST['general_home_url'].'index.php?$1" [qsa,L]
RewriteRule /?(.*) "' . $_POST['general_home_url'] . 'index.php?$1" [qsa,L]
</Ifapps>
<Ifapps !mod_cache.c>
RewriteRule . "'.$_POST['general_home_url'].'index.php" [L]
RewriteRule . "' . $_POST['general_home_url'] . 'index.php" [L]
</Ifapps>
</Ifapps>';
if(file_put_contents('../.htaccess', $htacces))
if (file_put_contents('../.htaccess', $htacces))
{
echo msg('succes', '.htaccess was successfully set.<br/>');
}
else
} else
{
echo msg('fail', 'Error setting up .htaccess.<br/>');
exit;
}
//Apps
$modulurl = '../apps/';
if ($handle = opendir($modulurl))
$apps = new apps();
$appUri = '../apps/';
foreach ($apps->getApps() as $app => $appconf)
{
while (false !== ($mod = readdir($handle)))
require $appUri . $app . '/config.php';
if (isset($_CONF['install']) && $_CONF['install'] != '' && file_exists($appUri . $app . '/' . $_CONF['install']))
{
if ($mod != "." && $mod != ".." && is_dir($modulurl.$mod))
{
require $modulurl.$mod.'/config.php';
if(isset($_CONF['install']) && $_CONF['install']!='' && file_exists($modulurl.$mod.'/'.$_CONF['install']))
{
require $modulurl.$mod.'/'.$_CONF['install'];
}
}
require $appUri . $app . '/' . $_CONF['install'];
}
closedir($handle);
}
//Write Config
$configfile = Yaml::dump($CONFIG);
if(file_put_contents('../inc/config.yml', $configfile))
if (file_put_contents('../inc/config.yml', $configfile))
{
echo msg('succes', 'Configfile was successfully created.');
}
else
} else
{
echo msg('fail', 'Error creating configfile.');
exit;
}
echo msg('info', 'Installation successfully completed. <a href="'.$_POST['general_webUrl'].'admin">Login</a>');
}
else
echo msg('info', 'Installation successfully completed. <a href="' . $_POST['general_webUrl'] . 'admin">Login</a>');
} else
{
echo msg('info', 'Please fill in all fields!');
}
}
else
} else
{
?>
<div class="install-container">
<form action="<?php echo $_SERVER['REQUEST_URI']?>" method="post" class="form">
<form action="<?php echo $_SERVER['REQUEST_URI'] ?>" method="post" class="form">
<h2>Language</h2>
<span>Select your language:</span>
<select name="lang">
@ -313,7 +300,7 @@ else
$langs = $lang->getAll();
foreach ($langs as $lang_code => $lang_detail)
{
echo '<option value="'.$lang_code.'">'.$lang_detail['Lang'].'</option>';
echo '<option value="' . $lang_code . '">' . $lang_detail['Lang'] . '</option>';
}
?>
</select><br/><br/>
@ -327,15 +314,19 @@ else
<span>Table prefix</span><input type="text" placeholder="Table prefix" name="db_prefix"/><br/><br/>
<h2>Website</h2>
<span>Website Url</span><input type="text" placeholder="Website Url" name="general_webUrl" value="http://<?php echo $_SERVER['SERVER_NAME'].str_replace('admin/install.php', '', $_SERVER['REQUEST_URI']);?>"/><br/>
<span>Home Url</span><input type="text" placeholder="Home Url" name="general_home_url" value="<?php echo str_replace('admin/install.php', '', $_SERVER['REQUEST_URI']);?>"/><br/>
<span>Website Url</span><input type="text" placeholder="Website Url" name="general_webUrl"
value="http://<?php echo $_SERVER['SERVER_NAME'] . str_replace('admin/install.php', '', $_SERVER['REQUEST_URI']); ?>"/><br/>
<span>Home Url</span><input type="text" placeholder="Home Url" name="general_home_url"
value="<?php echo str_replace('admin/install.php', '', $_SERVER['REQUEST_URI']); ?>"/><br/>
<span>Phpmyadmin Url</span><input type="text" placeholder="Phpmyadmin Url" name="general_pma"/><br/>
<span>Page Title</span><input type="text" placeholder="Page Title" name="general_page_title"/><br/>
<span>Editor CSS</span><input type="text" placeholder="Editor CSS" name="general_editor_css"/><br/>
<span>Template</span><input type="text" placeholder="Template" name="general_template" value="content/template.tpl"/><br/>
<span>Template</span><input type="text" placeholder="Template" name="general_template"
value="content/template.tpl"/><br/>
<h2>Mail</h2>
<span>Use SMTP</span><input type="checkbox" name="mail_smtp" id="mail_smtp"/><label for="mail_smtp"><i></i> Use SMTP</label> <br/>
<span>Use SMTP</span><input type="checkbox" name="mail_smtp" id="mail_smtp"/><label for="mail_smtp"><i></i>
Use SMTP</label> <br/>
<span>SMTP-Host</span><input type="text" placeholder="SMTP-Host" name="mail_host"/><br/>
<span>SMTP-Username</span><input type="text" placeholder="SMTP-Username" name="mail_user"/><br/>
<span>SMTP-Password</span><input type="text" placeholder="SMTP-Password" name="mail_pass"/><br/>
@ -351,22 +342,16 @@ else
<span>Password</span><input type="password" placeholder="Password" name="admin_pw1"/><br/>
<span>Confirm Password</span><input type="password" placeholder="Confirm Password" name="admin_pw2"/><br/>
<?php
$modulurl = '../apps/';
if ($handle = opendir($modulurl))
//Apps
$apps = new apps();
$appUri = '../apps/';
foreach ($apps->getApps() as $app => $appconf)
{
while (false !== ($mod = readdir($handle)))
require $appUri . $app . '/config.php';
if (isset($_CONF['install']) && $_CONF['install'] != '' && file_exists($appUri . $app . '/' . $_CONF['install']))
{
if ($mod != "." && $mod != ".." && is_dir($modulurl . $mod))
{
//echo $mod;
require $modulurl . $mod . '/config.php';
if (isset($_CONF['install']) && $_CONF['install'] != '' && file_exists($modulurl . $mod . '/' . $_CONF['install']))
{
require $modulurl . $mod . '/' . $_CONF['install'];
}
}
require $appUri . $app . '/' . $_CONF['install'];
}
closedir($handle);
}
?>
<p style="text-align: center"><input type="submit" value="Install" name="submit"/></p>

View File

@ -66,22 +66,17 @@ if (hasPerm('edit_permissions'))
$permsTotal = [];
$permsTotal['System'] = json_decode(file_get_contents('permissions.json'), true);
$permsTotal['System'] = $permsTotal['System']['permissions'];
$moduluri = '../apps/';
if ($handle = opendir($moduluri))
$apps = new apps();
$appUri = '../apps/';
foreach ($apps->getApps() as $app => $appconf)
{
while (false !== ($mod = readdir($handle)))
if (file_exists($appUri . '/' . $app . '/permissions.json'))
{
if ($mod != "." && $mod != ".." && is_dir($moduluri . $mod))
{
if (file_exists($moduluri . '/' . $mod . '/permissions.json'))
{
require $moduluri . '/' . $mod . '/config.php';
$permsTotal[$_CONF['mod_name']] = json_decode(file_get_contents($moduluri . '/' . $mod . '/permissions.json'), true);
$permsTotal[$_CONF['mod_name']] = $permsTotal[$_CONF['mod_name']]['permissions'];
}
}
require $appUri . '/' . $app . '/config.php';
$permsTotal[$_CONF['mod_name']] = json_decode(file_get_contents($appUri . '/' . $app . '/permissions.json'), true);
$permsTotal[$_CONF['mod_name']] = $permsTotal[$_CONF['mod_name']]['permissions'];
}
closedir($handle);
}
//print_r($permsTotal);

View File

@ -1,6 +1,9 @@
<?php
require_once '../../../inc/autoload.php';
printHeader($lang->get('sp_confirm'));
require_once 'confirmConfig.php';
if (isset($_GET['page']))
{
if ($_SESSION['userid'] == $confirmationUser)

View File

@ -0,0 +1,16 @@
<?php
$confirmationRequierd = false;
$iniFile = 'confirm.ini';
if(strpos($_SERVER['SCRIPT_FILENAME'], '/apps/') === false)
{
$iniFile = '../SimplePages/backend/confirm.ini';
}
if(file_exists($iniFile))
{
$config = parse_ini_file($iniFile);
//print_r($config);exit;
$confirmationRequierd = $config['confirmationRequierd'];
$confirmationUserMail = $config['confirmationUserMail'];
$confirmationUser = $config['confirmationUser'];
}

View File

@ -1,6 +1,9 @@
<?php
require_once '../../../inc/autoload.php';
printHeader($lang->get('sp_edit'));
require_once 'confirmConfig.php';
if (hasPerm('manage_pages'))
{
tinymce();
@ -130,8 +133,13 @@ if (hasPerm('manage_pages'))
if(!isset($status))
{
$status = 0;
if (isset($_POST['status'])) $status = $_POST['status'];
if (isset($_POST['status']))
{
$status = $_POST['status'];
if($_POST['status'] == 'true') $status = 1;
}
}
$db->data['status'] = $status;
$db->data['meta_description'] = $_POST['meta_description'];
$db->data['meta_keywords'] = $_POST['meta_keywords'];
@ -294,7 +302,7 @@ if (hasPerm('manage_pages'))
<form id="edit" method="post" action="<?php echo $_SERVER['REQUEST_URI']?>" class="form">
<p><span><?php echo $lang->get('sp_edit_title');?>:</span><input type="text" name="title" value="<?php echo $data[0]['title']; ?>"/>
</p>
<p><span><?php echo $lang->get('sp_edit_alias');?>:</span><input type="text" name="alias"
<p><span data-toggle="tooltip" title="Die URL der Seite, ohne '/' am Anfang."><?php echo $lang->get('sp_edit_alias');?>:</span><input type="text" name="alias"
value="<?php echo $data[0]['alias']; ?>" autocomplete="off"/>
</p>
<p><span><?php echo $lang->get('sp_edit_public');?>:</span><input type="checkbox" name="status" id="status" value="1"<?php

View File

@ -12,9 +12,19 @@ class apps
public function __construct()
{
//Find the app directory
$i = 1;
$appdir = 'apps/';
$rel = explode('/', str_replace($GLOBALS['MCONF']['home_uri'], '', $_SERVER['SCRIPT_NAME']));
if($GLOBALS['MCONF']['home_uri'] == '/')
{
$rel = explode('/', $_SERVER['SCRIPT_NAME']);
$i++;
}
else
{
$rel = explode('/', str_replace($GLOBALS['MCONF']['home_uri'], '', $_SERVER['SCRIPT_NAME']));
}
$count = count($rel);
//print_r($rel);exit;
//if (strpos($_SERVER['REQUEST_URI'], '/apps/') !== false && $count !== 1) $count = $count - 1; $appdir = '';
$i = 1;

107
index.php
View File

@ -3,32 +3,31 @@
//Check if installed
if (file_exists('inc/config.yml'))
{
//Require Libs
require_once 'inc/libs/Smarty/Smarty.class.php';
//Require Libs
require_once 'inc/libs/Smarty/Smarty.class.php';
require_once 'inc/config.php';
require_once 'inc/libs/functions.php';
require_once 'inc/page.php';
require_once 'inc/apps.php';
//Under Construction?
//Under Construction?
if (file_exists('inc/System/construction.txt'))
{
echo file_get_contents('inc/System/construction.txt');
}
else
} else
{
//Page
$page = new page();
$page->caching = false;
$page->error_reporting = E_ALL & ~E_NOTICE;
$page->caching = false;
$page->error_reporting = E_ALL & ~E_NOTICE;
//Set Url
//Set Url
$page->setUrl(str_replace($MCONF['home_uri'], '', $_SERVER['REQUEST_URI']));
$base = explode('/', str_replace($MCONF['home_uri'], '', $_SERVER['REQUEST_URI']));
$page->setBaseUrl('/');
if(count($base)>1)
if (count($base) > 1)
{
$page->setBaseUrl($base[0].'/');
$page->setBaseUrl($base[0] . '/');
}
$page->setResponseCode(404);
@ -36,84 +35,78 @@ if (file_exists('inc/config.yml'))
//Search apps and execute them if necessary
foreach ($apps->getApps() as $app => $appconf)
{
$appUri = 'apps/'.$app.'/';
$appUri = 'apps/' . $app . '/';
//If the App should run from one domain only
if((isset($appconf['domain']) && $page->getDomain() == $appconf['domain']) || !isset($appconf['domain']) || (isset($appconf['domain']) && $appconf['domain'] === ''))
if ((isset($appconf['domain']) && $page->getDomain() == $appconf['domain']) || !isset($appconf['domain']) || (isset($appconf['domain']) && $appconf['domain'] === ''))
{
//If we have an alias which equals the current url, execute it
if(isset($appconf['alias']))
{
if(array_key_exists($page->getUrl(), $appconf['alias']))
//If we have an alias which equals the current url, execute it
if (isset($appconf['alias']))
{
require $appUri. $appconf['alias'][$page->getUrl()];
}
}
//If we have a type
if(isset($appconf['type']))
{
//Page for (more or less) dynamic content
if($appconf['type'] == 'page')
{
//If we have a base_url_file and the current url equals base_url, execute base_url_file
if(isset($appconf['base_url_file']))
if (array_key_exists($page->getUrl(), $appconf['alias']))
{
if($appconf['base_url'] == $page->getUrl())
{
require $appUri . $appconf['base_url_file'];
}
}
//if we have a base_url and a base_file which exists and the current baseUrl equals base_url, execute base_file
if(isset($appconf['base_url']) && file_exists($appUri.'/' . $appconf['base_file']))
{
if($appconf['base_url'] == $page->getBaseUrl())
{
require $appUri. $appconf['base_file'];
}
require $appUri . $appconf['alias'][$page->getUrl()];
}
}
//Static
if($appconf['type'] == 'static' && isset($appconf['base_file']) && file_exists($appUri.'/'.$appconf['base_file']))
//If we have a type
if (isset($appconf['type']))
{
require $appUri.$appconf['base_file'];
}
}
//Page for (more or less) dynamic content
if ($appconf['type'] == 'page')
{
//If we have a base_url_file and the current url equals base_url, execute base_url_file
if (isset($appconf['base_url_file']))
{
if ($appconf['base_url'] == $page->getUrl())
{
require $appUri . $appconf['base_url_file'];
}
}
//If the App should run from one domain only
/*if(isset($appconf['domain']) && $page->getDomain() == $appconf['domain'])
{
echo 'ff';*/
//if we have a base_url and a base_file which exists and the current baseUrl equals base_url, execute base_file
if (isset($appconf['base_url']) && file_exists($appUri . '/' . $appconf['base_file']))
{
if ($appconf['base_url'] == $page->getBaseUrl())
{
require $appUri . $appconf['base_file'];
}
}
}
//Static
if ($appconf['type'] == 'static' && isset($appconf['base_file']) && file_exists($appUri . '/' . $appconf['base_file']))
{
require $appUri . $appconf['base_file'];
}
}
}
$appconf = [];
}
if($page->getResponseCode() == 404)
if ($page->getResponseCode() == 404)
{
$page->setTitle('404');
$page->setContent(file_get_contents('inc/System/404.txt'));
}
//Copyright bauen
$founded = date('Y', filemtime('inc/config.php'));
$founded = date('Y', filemtime('inc/config.yml'));
$copy = $founded;
if($founded != date('Y'))
if ($founded != date('Y'))
{
$copy = $founded.' - '.date('Y');
$copy = $founded . ' - ' . date('Y');
}
$page->assign('copyright', $copy);
// dat ganze ausgeben
http_response_code($page->getResponseCode());
$page->assign($MCONF['tpl_title'], $page->getTitle(). ' | ' . $MCONF['title']);
$page->assign($MCONF['tpl_title'], $page->getTitle() . ' | ' . $MCONF['title']);
$page->assign($MCONF['tpl_content'], $page->getContent());
$page->assign($MCONF['tpl_webUri'], $MCONF['web_uri']);
$page->display($MCONF['template']);
}
}
else
} else
{
header('Location: admin/install.php');
}