fixed some more bugs

parent 03ca7f77
<?php
/**
* @author Tino Goratsch
* @package ACP3
* @subpackage Core
*/
namespace ACP3;
class CMS {
/**
* Pimple Dependency Injector
*
......@@ -17,8 +20,7 @@ class CMS {
/**
* Führt alle nötigen Schritte aus, um die Seite anzuzeigen
*/
public static function run()
{
public static function run() {
self::defineDirConstants();
self::startupChecks();
self::includeAutoLoader();
......@@ -29,8 +31,7 @@ class CMS {
/**
* Überprüft, ob die config.php existiert
*/
public static function startupChecks()
{
public static function startupChecks() {
// Standardzeitzone festlegen
date_default_timezone_set('UTC');
......@@ -38,7 +39,7 @@ class CMS {
$path = ACP3_DIR . 'config.php';
if (is_file($path) === false || filesize($path) === 0) {
exit('The ACP3 is not correctly installed. Please navigate to the <a href="' . ROOT_DIR . 'installation/">installation wizard</a> and follow its instructions.');
// Wenn alles okay ist, config.php einbinden und error_reporting setzen
// Wenn alles okay ist, config.php einbinden und error_reporting setzen
} else {
require_once ACP3_DIR . 'config.php';
......@@ -50,8 +51,7 @@ class CMS {
/**
* Einige Pfadkonstanten definieren
*/
public static function defineDirConstants()
{
public static function defineDirConstants() {
define('PHP_SELF', htmlentities($_SERVER['SCRIPT_NAME']));
$php_self = dirname(PHP_SELF);
define('ROOT_DIR', $php_self !== '/' ? $php_self . '/' : '/');
......@@ -66,8 +66,7 @@ class CMS {
/**
* Klassen Autoloader inkludieren
*/
public static function includeAutoLoader()
{
public static function includeAutoLoader() {
require_once LIBRARIES_DIR . 'Doctrine/Common/ClassLoader.php';
$clACP3 = new \Doctrine\Common\ClassLoader('ACP3', ACP3_ROOT_DIR);
......@@ -80,10 +79,9 @@ class CMS {
/**
* Überprüfen, ob der Wartungsmodus aktiv ist
*/
public static function checkForMaintenanceMode()
{
public static function checkForMaintenanceMode() {
if ((bool) CONFIG_MAINTENANCE_MODE === true &&
(defined('IN_ADM') === false && strpos(self::$injector['URI']->query,'users/login/') !== 0)) {
(defined('IN_ADM') === false && strpos(self::$injector['URI']->query, 'users/login/') !== 0)) {
self::$injector['View']->assign('PAGE_TITLE', CONFIG_SEO_TITLE);
self::$injector['View']->assign('CONTENT', CONFIG_MAINTENANCE_MESSAGE);
self::$injector['View']->displayTemplate('system/maintenance.tpl');
......@@ -94,12 +92,10 @@ class CMS {
/**
* Initialisieren der anderen Klassen
*/
public static function initializeClasses()
{
public static function initializeClasses() {
// DI
self::$injector = new Core\Pimple();
// DoctrineDBAL instanziieren
$config = new \Doctrine\DBAL\Configuration();
$connectionParams = array(
'dbname' => CONFIG_DB_NAME,
......@@ -123,14 +119,8 @@ class CMS {
$classes = array('View', 'URI', 'Session', 'Auth', 'Lang', 'Date', 'Breadcrumb');
foreach ($classes as $class) {
if ($class === 'URI') {
self::$injector['URI'] = self::$injector->share(function($c) {
return new Core\URI();
});
} else {
$className = "\\ACP3\\Core\\" . $class;
self::$injector[$class] = new $className();
}
$className = "\\ACP3\\Core\\" . $class;
self::$injector[$class] = new $className();
}
Core\View::factory('Smarty');
Core\ACL::initialize(self::$injector['Auth']->getUserId());
......@@ -179,4 +169,5 @@ class CMS {
self::$injector['URI']->redirect('errors/404');
}
}
}
\ No newline at end of file
......@@ -21,7 +21,7 @@ class CaptchaFunctions {
* Anzahl der Zeichen, welche das Captcha haben soll
* @return string
*/
public static function captcha($captcha_length = 5)
public static function captcha($captcha_length = 5, $id = 'captcha')
{
// Wenn man als User angemeldet ist, Captcha nicht anzeigen
if (\ACP3\CMS::$injector['Auth']->isUser() === false) {
......@@ -29,6 +29,7 @@ class CaptchaFunctions {
$captcha = array();
$captcha['width'] = $captcha_length * 25;
$captcha['id'] = $id;
$captcha['height'] = 30;
\ACP3\CMS::$injector['View']->assign('captcha', $captcha);
return \ACP3\CMS::$injector['View']->fetchTemplate('captcha/captcha.tpl');
......
<div class="control-group">
<label for="captcha" class="control-label">{lang t="captcha|captcha"}</label>
<label for="{$captcha.id}" class="control-label">{lang t="captcha|captcha"}</label>
<div class="controls">
<img src="{uri args="captcha/image"}" width="{$captcha.width}" height="{$captcha.height}" alt=""><br>
<input type="text" name="captcha" id="captcha" value="" required>
<input type="text" name="captcha" id="{$captcha.id}" value="" required>
</div>
</div>
\ No newline at end of file
......@@ -98,8 +98,6 @@ class CategoriesAdmin extends Core\ModuleController {
$marked_entries = implode('|', $entries);
$this->injector['View']->setContent(Core\Functions::confirmBox($this->injector['Lang']->t('system', 'confirm_delete'), $this->injector['URI']->route('acp/categories/delete/entries_' . $marked_entries . '/action_confirmed/'), $this->injector['URI']->route('acp/categories')));
} elseif ($this->injector['URI']->action === 'confirmed') {
require_once MODULES_DIR . 'categories/functions.php';
$marked_entries = explode('|', $entries);
$bool = false;
$in_use = false;
......
......@@ -48,7 +48,7 @@ class EmoticonsAdmin extends Core\ModuleController {
);
$bool = $this->injector['Db']->insert(DB_PRE . 'emoticons', $insert_values);
setEmoticonsCache();
EmoticonsFunctions::setEmoticonsCache();
$this->injector['Session']->unsetFormToken();
......@@ -74,8 +74,6 @@ class EmoticonsAdmin extends Core\ModuleController {
$marked_entries = implode('|', $entries);
$this->injector['View']->setContent(Core\Functions::confirmBox($this->injector['Lang']->t('system', 'confirm_delete'), $this->injector['URI']->route('acp/emoticons/delete/entries_' . $marked_entries . '/action_confirmed/'), $this->injector['URI']->route('acp/emoticons')));
} elseif ($this->injector['URI']->action === 'confirmed') {
require_once MODULES_DIR . 'emoticons/functions.php';
$marked_entries = explode('|', $entries);
$bool = false;
foreach ($marked_entries as $entry) {
......@@ -87,7 +85,7 @@ class EmoticonsAdmin extends Core\ModuleController {
}
}
setEmoticonsCache();
EmoticonsFunctions::setEmoticonsCache();
Core\Functions::setRedirectMessage($bool, $this->injector['Lang']->t('system', $bool !== false ? 'delete_success' : 'delete_error'), 'acp/emoticons');
} else {
......@@ -98,8 +96,6 @@ class EmoticonsAdmin extends Core\ModuleController {
public function actionEdit() {
if (Core\Validate::isNumber($this->injector['URI']->id) === true &&
$this->injector['Db']->fetchColumn('SELECT COUNT(*) FROM ' . DB_PRE . 'emoticons WHERE id = ?', array($this->injector['URI']->id)) == 1) {
require_once MODULES_DIR . 'emoticons/functions.php';
if (isset($_POST['submit']) === true) {
if (!empty($_FILES['picture']['tmp_name'])) {
$file['tmp_name'] = $_FILES['picture']['tmp_name'];
......@@ -140,7 +136,7 @@ class EmoticonsAdmin extends Core\ModuleController {
}
$bool = $this->injector['Db']->update(DB_PRE . 'emoticons', $update_values, array('id' => $this->injector['URI']->id));
setEmoticonsCache();
EmoticonsFunctions::setEmoticonsCache();
$this->injector['Session']->unsetFormToken();
......
......@@ -152,9 +152,7 @@ class MenusAdmin extends Core\ModuleController {
$lang_display = array($this->injector['Lang']->t('system', 'yes'), $this->injector['Lang']->t('system', 'no'));
$this->injector['View']->assign('display', Core\Functions::selectGenerator('display', array(1, 0), $lang_display, 1, 'checked'));
if (Core\Modules::check('articles', 'functions') === true) {
require_once MODULES_DIR . 'articles/functions.php';
if (Core\Modules::isActive('articles') === true) {
$this->injector['View']->assign('articles', \ACP3\Modules\Articles\ArticlesFunctions::articlesList());
}
......@@ -392,9 +390,7 @@ class MenusAdmin extends Core\ModuleController {
$lang_display = array($this->injector['Lang']->t('system', 'yes'), $this->injector['Lang']->t('system', 'no'));
$this->injector['View']->assign('display', Core\Functions::selectGenerator('display', array(1, 0), $lang_display, $page['display'], 'checked'));
if (Core\Modules::check('articles', 'functions') === true) {
require_once MODULES_DIR . 'articles/functions.php';
if (Core\Modules::isActive('articles') === true) {
$matches = array();
if (!isset($_POST['submit']) && $page['mode'] == 4) {
preg_match_all('/^(articles\/details\/id_([0-9]+)\/)$/', $page['uri'], $matches);
......
......@@ -19,19 +19,17 @@ class UsersAdmin extends Core\ModuleController {
public function actionCreate()
{
if (isset($_POST['submit']) === true) {
require_once MODULES_DIR . 'users/functions.php';
if (empty($_POST['nickname']))
$errors['nickname'] = $this->injector['Lang']->t('system', 'name_to_short');
if (Core\Validate::gender($_POST['gender']) === false)
$errors['gender'] = $this->injector['Lang']->t('users', 'select_gender');
if (!empty($_POST['birthday']) && Core\Validate::birthday($_POST['birthday']) === false)
$errors[] = $this->injector['Lang']->t('users', 'invalid_birthday');
if (userNameExists($_POST['nickname']) === true)
if (UsersFunctions::userNameExists($_POST['nickname']) === true)
$errors['nickname'] = $this->injector['Lang']->t('users', 'user_name_already_exists');
if (Core\Validate::email($_POST['mail']) === false)
$errors['mail'] = $this->injector['Lang']->t('system', 'wrong_email_format');
if (userEmailExists($_POST['mail']) === true)
if (UsersFunctions::userEmailExists($_POST['mail']) === true)
$errors['mail'] = $this->injector['Lang']->t('users', 'user_email_already_exists');
if (empty($_POST['roles']) || is_array($_POST['roles']) === false || Core\Validate::aclRolesExist($_POST['roles']) === false)
$errors['roles'] = $this->injector['Lang']->t('users', 'select_access_level');
......@@ -273,19 +271,17 @@ class UsersAdmin extends Core\ModuleController {
$user = $this->injector['Auth']->getUserInfo($this->injector['URI']->id);
if (isset($_POST['submit']) === true) {
require_once MODULES_DIR . 'users/functions.php';
if (empty($_POST['nickname']))
$errors['nickname'] = $this->injector['Lang']->t('system', 'name_to_short');
if (Core\Validate::gender($_POST['gender']) === false)
$errors['gender'] = $this->injector['Lang']->t('users', 'select_gender');
if (!empty($_POST['birthday']) && Core\Validate::birthday($_POST['birthday']) === false)
$errors[] = $this->injector['Lang']->t('users', 'invalid_birthday');
if (userNameExists($_POST['nickname'], $this->injector['URI']->id))
if (UsersFunctions::userNameExists($_POST['nickname'], $this->injector['URI']->id))
$errors['nickname'] = $this->injector['Lang']->t('users', 'user_name_already_exists');
if (Core\Validate::email($_POST['mail']) === false)
$errors['mail'] = $this->injector['Lang']->t('system', 'wrong_email_format');
if (userEmailExists($_POST['mail'], $this->injector['URI']->id))
if (UsersFunctions::userEmailExists($_POST['mail'], $this->injector['URI']->id))
$errors['mail'] = $this->injector['Lang']->t('users', 'user_email_already_exists');
if (empty($_POST['roles']) || is_array($_POST['roles']) === false || Core\Validate::aclRolesExist($_POST['roles']) === false)
$errors['roles'] = $this->injector['Lang']->t('users', 'select_access_level');
......
......@@ -250,7 +250,7 @@ class UsersFrontend extends Core\ModuleController {
->append($this->injector['Lang']->t('users', 'users'), $this->injector['URI']->route('users'))
->append($this->injector['Lang']->t('users', 'forgot_pwd'));
$captchaAccess = Core\Modules::check('captcha', 'functions');
$captchaAccess = Core\Modules::isActive('captcha');
if (isset($_POST['submit']) === true) {
if (empty($_POST['nick_mail']))
......@@ -305,8 +305,7 @@ class UsersFrontend extends Core\ModuleController {
$this->injector['View']->assign('form', isset($_POST['submit']) ? $_POST : $defaults);
if ($captchaAccess === true) {
require_once MODULES_DIR . 'captcha/functions.php';
$this->injector['View']->assign('captcha', captcha());
$this->injector['View']->assign('captcha', \ACP3\Modules\Captcha\CaptchaFunctions::captcha());
}
$this->injector['Session']->generateFormToken();
......@@ -400,7 +399,7 @@ class UsersFrontend extends Core\ModuleController {
->append($this->injector['Lang']->t('users', 'users'), $this->injector['URI']->route('users'))
->append($this->injector['Lang']->t('users', 'register'));
$captchaAccess = Core\Modules::check('captcha', 'functions');
$captchaAccess = Core\Modules::isActive('captcha');
if (isset($_POST['submit']) === true) {
if (empty($_POST['nickname']))
......@@ -465,8 +464,7 @@ class UsersFrontend extends Core\ModuleController {
$this->injector['View']->assign('form', isset($_POST['submit']) ? $_POST : $defaults);
if ($captchaAccess === true) {
require_once MODULES_DIR . 'captcha/functions.php';
$this->injector['View']->assign('captcha', captcha());
$this->injector['View']->assign('captcha', \ACP3\Modules\Captcha\CaptchaFunctions::captcha());
}
$this->injector['Session']->generateFormToken();
......
......@@ -5,7 +5,7 @@
<div class="control-group">
<label for="nick-mail" class="control-label">{lang t="users|nickname_or_email"}</label>
<div class="controls">
<input type="text" name="nick_mail" id="nick-mail" value="{$form.nick_mail}" maxlength="120">
<input type="text" name="nick_mail" id="nick-mail" value="{$form.nick_mail}" maxlength="120" required>
<p class="help-block">{lang t="users|forgot_pwd_description"}</p>
</div>
</div>
......
......@@ -4,11 +4,11 @@
<form action="{$REQUEST_URI}" method="post" accept-charset="UTF-8" class="form-horizontal">
<div class="control-group">
<label for="nickname" class="control-label">{lang t="users|nickname"}</label>
<div class="controls"><input type="text" name="nickname" id="nickname" maxlength="30"></div>
<div class="controls"><input type="text" name="nickname" id="nickname" maxlength="30" required></div>
</div>
<div class="control-group">
<label for="pwd" class="control-label">{lang t="users|pwd"}</label>
<div class="controls"><input type="password" name="pwd" id="pwd"></div>
<div class="controls"><input type="password" name="pwd" id="pwd" required></div>
</div>
<div class="control-group">
<div class="controls">
......
......@@ -11,21 +11,21 @@
<div id="tab-1" class="tab-pane active">
<div class="control-group">
<label for="nickname" class="control-label">{lang t="users|nickname"}</label>
<div class="controls"><input type="text" name="nickname" id="nickname" value="{$form.nickname}" maxlength="30"></div>
<div class="controls"><input type="text" name="nickname" id="nickname" value="{$form.nickname}" maxlength="30" required></div>
</div>
<div class="control-group">
<label for="mail" class="control-label">{lang t="system|email_address"}</label>
<div class="controls"><input type="email" name="mail" id="mail" value="{$form.mail}" maxlength="120"></div>
<div class="controls"><input type="email" name="mail" id="mail" value="{$form.mail}" maxlength="120" required></div>
</div>
</div>
<div id="tab-2" class="tab-pane">
<div class="control-group">
<label for="pwd" class="control-label">{lang t="users|pwd"}</label>
<div class="controls"><input type="password" name="pwd" id="pwd" value=""></div>
<div class="controls"><input type="password" name="pwd" id="pwd" value="" required></div>
</div>
<div class="control-group">
<label for="pwd-repeat" class="control-label">{lang t="users|pwd_repeat"}</label>
<div class="controls"><input type="password" name="pwd_repeat" id="pwd-repeat" value=""></div>
<div class="controls"><input type="password" name="pwd_repeat" id="pwd-repeat" value="" required></div>
</div>
</div>
</div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment