Commit cac4f84b authored by Henning Leutz's avatar Henning Leutz 🥋

feat: #571 - ADMIN ist true im Frontend

parent 9b5627da
<?php
/**
* PHP Ajax Schnittstelle
* QUIQQER Backend Ajax API
*/
define('QUIQQER_AJAX', true);
define('QUIQQER_SYSTEM', true);
define('QUIQQER_BACKEND', true);
require_once 'header.php';
// use QUI;
use QUI\Utils\Security\Orthos;
header("Content-Type: text/plain");
// expire date in the past
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");
header('Expires: ' . gmdate('D, d M Y H:i:s', time() - 60) . ' GMT');
$User = QUI::getUserBySession();
if (!isset($_REQUEST['_FRONTEND']) || $_REQUEST['_FRONTEND'] == 0) {
define('QUIQQER_BACKEND', true);
} else {
define('QUIQQER_FRONTEND', true);
}
// Falls Benutzer eingeloggt ist, dann seine Sprache nehmen
if ($User->getId() && $User->getLang()) {
QUI::getLocale()->setCurrent($User->getLang());
}
if (!isset($_REQUEST['_rf'])) {
exit;
}
$_rf_files = json_decode($_REQUEST['_rf'], true);
if (!is_array($_rf_files)) {
$_rf_files = array($_rf_files);
}
// generate global ajax
QUI::getAjax();
// ajax package loader
if (isset($_REQUEST['package'])) {
$package = $_REQUEST['package'];
$dir = OPT_DIR;
foreach ($_rf_files as $key => $file) {
$firstpart = 'package_' . str_replace('/', '_', $package);
$ending = str_replace($firstpart, '', $file);
$_rf_file = $dir . $package . str_replace('_', '/', $ending) . '.php';
$_rf_file = Orthos::clearPath($_rf_file);
$_rf_file = realpath($_rf_file);
if (strpos($_rf_file, $dir) !== false && file_exists($_rf_file)) {
require_once $_rf_file;
}
}
}
// admin ajax
foreach ($_rf_files as $key => $file) {
$_rf_file
= OPT_DIR . 'quiqqer/quiqqer/admin/' . str_replace('_', '/', $file) . '.php';
$_rf_file = Orthos::clearPath($_rf_file);
$_rf_file = realpath($_rf_file);
$dir = OPT_DIR . 'quiqqer/quiqqer/admin/';
if (strpos($_rf_file, $dir) !== false && file_exists($_rf_file)) {
require_once $_rf_file;
}
}
// ajax project loader
if (isset($_REQUEST['project'])) {
try {
$Project = QUI::getProjectManager()->decode($_REQUEST['project']);
} catch (QUI\Exception $Exception) {
try {
$Project = QUI::getProjectManager()->getProject(
$_REQUEST['project']
);
} catch (QUI\Exception $Exception) {
$Project = QUI::getProjectManager()->getStandard();
}
}
$projectDir = USR_DIR . $Project->getName();
$firstpart = 'project_' . $Project->getName() . '_';
foreach ($_rf_files as $key => $file) {
$file = str_replace($firstpart, '', $file);
$file = $projectDir . '/lib/' . str_replace('_', '/', $file) . '.php';
$file = Orthos::clearPath($file);
$file = realpath($file);
$dir = $projectDir . '/lib/';
if (strpos($file, $dir) !== false && file_exists($file)) {
require_once $file;
}
}
}
/**
* Ajax Ausgabe
*/
header('Expires: '.gmdate('D, d M Y H:i:s', time() - 60).' GMT');
echo QUI::getAjax()->call();
exit;
//require '../bootstrap.php';
require '../lib/ajax.php';
......@@ -4,8 +4,8 @@ define('QUIQQER_SYSTEM', true);
require 'header.php';
// qui path
$qui_path = URL_OPT_DIR . 'bin/qui/';
$qui_extend = URL_OPT_DIR . 'bin/qui/extend/';
$qui_path = URL_OPT_DIR.'bin/qui/';
$qui_extend = URL_OPT_DIR.'bin/qui/extend/';
$config = array();
$config['globals'] = QUI::conf('globals');
......@@ -153,6 +153,7 @@ try {
URL_PROJECT_CHARACTER: "<?php echo \QUI\Rewrite::URL_PROJECT_CHARACTER; ?>",
SUFFIX : "<?php echo \QUI\Rewrite::getDefaultSuffix(); ?>"
},
ajax : '<?php echo URL_SYS_DIR; ?>ajax.php',
inAdministration: true,
lu : "<?php echo QUI::getPackageManager()->getLastUpdateDate(); ?>",
......@@ -199,12 +200,12 @@ try {
$locales = array();
foreach ($files as $package => $file) {
$locales[] = $package . '/' . $User->getLang();
$locales[] = $package.'/'.$User->getLang();
}
echo '<script type="text/javascript">';
echo '/* <![CDATA[ */';
echo 'var QUIQQER_LOCALE = ' . json_encode($locales, true);
echo 'var QUIQQER_LOCALE = '.json_encode($locales, true);
echo '/* ]]> */';
echo '</script>';
......
<?php
/**
* QUIQQER Frontend Ajax API
*/
define('QUIQQER_AJAX', true);
define('QUIQQER_FRONTEND', true);
header("Content-Type: text/plain");
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");
header('Expires: '.gmdate('D, d M Y H:i:s', time() - 60).' GMT');
require 'bootstrap.php';
require 'lib/ajax.php';
......@@ -31,11 +31,17 @@ define('Ajax', [
], function (QUI, QUIAjax, Utils, Locale) {
"use strict";
return {
var apiPoint = '/ajax.php';
if (typeof QUIQQER !== 'undefined' &&
"ajax" in QUIQQER) {
apiPoint = QUIQQER.ajax;
}
return {
$globalJSF : {}, // global javascript callback functions
$onprogress: {},
$url : typeof URL_DIR === 'undefined' ? '' : URL_DIR + 'admin/ajax.php',
$url : apiPoint,
/**
* Send a Request async
......@@ -56,7 +62,7 @@ define('Ajax', [
method = method || 'post'; // is post, put, get or delete
callback = callback || function () {
};
};
params = Utils.combine(params, {
'_rf' : call,
......
......@@ -42,12 +42,12 @@ class Setup
SystemFile::mkdir(VAR_DIR);
// look at media trash
$mediaTrash = VAR_DIR . 'media/trash';
$mediaTrash = VAR_DIR.'media/trash';
if (!is_dir($mediaTrash)) {
SystemFile::mkdir($mediaTrash);
$folders = SystemFile::readDir(VAR_DIR . 'media');
$folders = SystemFile::readDir(VAR_DIR.'media');
foreach ($folders as $folder) {
if ($folder === 'trash') {
......@@ -55,8 +55,8 @@ class Setup
}
SystemFile::move(
VAR_DIR . 'media/' . $folder,
$mediaTrash . '/' . $folder
VAR_DIR.'media/'.$folder,
$mediaTrash.'/'.$folder
);
}
}
......@@ -94,18 +94,18 @@ class Setup
/**
* header dateien
*/
$str = "<?php require_once '" . CMS_DIR . "bootstrap.php'; ?>";
$str = "<?php require_once '".CMS_DIR."bootstrap.php'; ?>";
if (file_exists(USR_DIR . 'header.php')) {
unlink(USR_DIR . 'header.php');
if (file_exists(USR_DIR.'header.php')) {
unlink(USR_DIR.'header.php');
}
if (file_exists(OPT_DIR . 'header.php')) {
unlink(OPT_DIR . 'header.php');
if (file_exists(OPT_DIR.'header.php')) {
unlink(OPT_DIR.'header.php');
}
file_put_contents(USR_DIR . 'header.php', $str);
file_put_contents(OPT_DIR . 'header.php', $str);
file_put_contents(USR_DIR.'header.php', $str);
file_put_contents(OPT_DIR.'header.php', $str);
/**
* Project Setup
......@@ -139,14 +139,14 @@ class Setup
continue;
}
if (!is_dir(OPT_DIR . '/' . $package)) {
if (!is_dir(OPT_DIR.'/'.$package)) {
continue;
}
$list = SystemFile::readDir(OPT_DIR . '/' . $package);
$list = SystemFile::readDir(OPT_DIR.'/'.$package);
foreach ($list as $key => $sub) {
$packageName = $package . '/' . $sub;
$packageName = $package.'/'.$sub;
$PackageManager->setup($packageName);
}
}
......@@ -188,7 +188,7 @@ class Setup
* (____\/_)(_______)\_______/(____\/_)(____\/_)(_______/|/ \__/
*
* Generated File via QUIQQER
* Date: ' . date('Y-m-d H:i:s') . '
* Date: '.date('Y-m-d H:i:s').'
*
*/
......@@ -197,13 +197,14 @@ class Setup
$OPT_DIR = OPT_DIR;
$CMS_DIR = CMS_DIR;
$image = CMS_DIR . 'image.php';
$index = CMS_DIR . 'index.php';
$quiqqer = CMS_DIR . 'quiqqer.php';
$bootstrap = CMS_DIR . 'bootstrap.php';
$ajax = CMS_DIR.'ajax.php';
$image = CMS_DIR.'image.php';
$index = CMS_DIR.'index.php';
$quiqqer = CMS_DIR.'quiqqer.php';
$bootstrap = CMS_DIR.'bootstrap.php';
// bootstrap
$bootstrapContent = $fileHeader . "
$bootstrapContent = $fileHeader."
\$etc_dir = dirname(__FILE__).'/etc/';
if (!file_exists(\$etc_dir.'conf.ini.php')) {
......@@ -224,25 +225,32 @@ if (file_exists(\$boot)) {
file_put_contents($bootstrap, $bootstrapContent);
// ajax.php
$content = $fileHeader.
"define('QUIQQER_SYSTEM',true);".
"require '{$OPT_DIR}quiqqer/quiqqer/ajax.php';\n";
file_put_contents($ajax, $content);
// image.php
$content = $fileHeader .
"define('QUIQQER_SYSTEM',true);" .
"require dirname(__FILE__) .'/bootstrap.php';\n" .
$content = $fileHeader.
"define('QUIQQER_SYSTEM',true);".
"require dirname(__FILE__) .'/bootstrap.php';\n".
"require '{$OPT_DIR}quiqqer/quiqqer/image.php';\n";
file_put_contents($image, $content);
// index.php
$content = $fileHeader .
"define('QUIQQER_SYSTEM',true);" .
"require dirname(__FILE__) .'/bootstrap.php';\n" .
$content = $fileHeader.
"define('QUIQQER_SYSTEM',true);".
"require dirname(__FILE__) .'/bootstrap.php';\n".
"require '{$OPT_DIR}quiqqer/quiqqer/index.php';\n";
file_put_contents($index, $content);
// quiqqer.php
$content = $fileHeader .
"define('CMS_DIR', '{$CMS_DIR}');\n" .
$content = $fileHeader.
"define('CMS_DIR', '{$CMS_DIR}');\n".
"require '{$OPT_DIR}quiqqer/quiqqer/quiqqer.php';\n";
file_put_contents($quiqqer, $content);
......
<?php
/**
* Main Ajax Handling
* Is used in backend and frontend ajax
*/
if (!isset($_REQUEST['_rf'])) {
exit;
}
use QUI\Utils\Security\Orthos;
// if user is loged in, use his language
$User = QUI::getUserBySession();
if ($User->getId() && $User->getLang()) {
QUI::getLocale()->setCurrent($User->getLang());
}
// required ajax files
$_rf_files = json_decode($_REQUEST['_rf'], true);
if (!is_array($_rf_files)) {
$_rf_files = array($_rf_files);
}
QUI::getAjax();
// ajax package loader
if (isset($_REQUEST['package'])) {
$package = $_REQUEST['package'];
$dir = OPT_DIR;
foreach ($_rf_files as $key => $file) {
$firstPart = 'package_'.str_replace('/', '_', $package);
$ending = str_replace($firstPart, '', $file);
$_rf_file = $dir.$package.str_replace('_', '/', $ending).'.php';
$_rf_file = Orthos::clearPath($_rf_file);
$_rf_file = realpath($_rf_file);
if (strpos($_rf_file, $dir) !== false && file_exists($_rf_file)) {
require_once $_rf_file;
}
}
}
// admin ajax
foreach ($_rf_files as $key => $file) {
$_rf_file = OPT_DIR.'quiqqer/quiqqer/admin/'.str_replace('_', '/', $file).'.php';
$_rf_file = Orthos::clearPath($_rf_file);
$_rf_file = realpath($_rf_file);
$dir = OPT_DIR.'quiqqer/quiqqer/admin/';
if (strpos($_rf_file, $dir) !== false && file_exists($_rf_file)) {
require_once $_rf_file;
}
}
// ajax project loader
if (isset($_REQUEST['project'])) {
try {
$Project = QUI::getProjectManager()->decode($_REQUEST['project']);
} catch (QUI\Exception $Exception) {
try {
$Project = QUI::getProjectManager()->getProject(
$_REQUEST['project']
);
} catch (QUI\Exception $Exception) {
$Project = QUI::getProjectManager()->getStandard();
}
}
$projectDir = USR_DIR.$Project->getName();
$firstPart = 'project_'.$Project->getName().'_';
foreach ($_rf_files as $key => $file) {
$file = str_replace($firstPart, '', $file);
$file = $projectDir.'/lib/'.str_replace('_', '/', $file).'.php';
$file = Orthos::clearPath($file);
$file = realpath($file);
$dir = $projectDir.'/lib/';
if (strpos($file, $dir) !== false && file_exists($file)) {
require_once $file;
}
}
}
echo QUI::getAjax()->call();
exit;
......@@ -70,7 +70,8 @@
URL_TEMPLATE_DIR = '{$URL_OPT_DIR}{$Project->getAttribute('template')}/';
var QUIQQER = {
lu : "{$lastUpdate}"
lu : "{$lastUpdate}",
ajax: '/ajax.php'
};
{assign var=httpshost value=$Project->getVHost( true, true )}
......@@ -178,7 +179,7 @@
require(['Locale'].append(QUIQQER_LOCALE), function (QUILocale) {
QUILocale.setCurrent(QUIQQER_PROJECT.lang);
if (window.location.toString().indexOf('lang=false') !== -1) {
QUILocale.no_translation = true;
}
......
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