Minor Fixes to the router

This commit is contained in:
kolaente 2016-08-07 11:37:19 +02:00
parent 6ddb3c6629
commit 46b12fbecd
18 changed files with 637 additions and 433 deletions

View File

@ -55,7 +55,7 @@ if (hasPerm('manage_system'))
?>
<div class="main">
<h1><?php echo $lang->get('action_construction_message_edit');?></h1>
<form action="" method="post">
<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>

View File

@ -0,0 +1,144 @@
;(function() {
// bind forms
function pageBodyParser() {
window.removeEventListener('click', bodyParser, false);
window.removeEventListener('keypress', bodyParser, false);
window.addEventListener('click', bodyParser, false);
window.addEventListener('keypress', bodyParser, false);
}
// handle forms in a manner similar to body-parser
function bodyParser(e) {
var el = e.target,
form = el,
nodeName = el.nodeName,
keycode = (e.keyCode ? e.keyCode : e.which),
link,
proto,
path,
orig,
body = {},
submitAdded,
i,
l,
control;
if (e.type === 'keypress') {
if (keycode === 13) {
if (nodeName !== 'INPUT') {
return; // enter key only valid when a form is focused
}
}
else {
return; // ignore other keypresses
}
}
else {
if (nodeName !== 'INPUT' && nodeName !== 'BUTTON') {
return; // something other than a submit button was clicked
}
else if (nodeName === 'INPUT' && el.type !== 'submit') {
return; // input was clicked that is not a submit button
}
}
// find parent form
while (form && 'FORM' !== form.nodeName) {
form = form.parentNode;
}
// no parent form
if (!form) {
return;
}
link = form.action;
// strip protocol
proto = link.split('://');
if (proto) {
if (proto[1]) {
link = proto[1];
form.pathname = link = proto[1].replace(location.host, '');
}
}
// normalize hash / search
if (!form.hash) {
form.hash = '';
}
if (!form.search) {
form.search = '';
}
// ensure non-hash for the same path
if (form.pathname === location.pathname && (form.hash || '#' === link)) return;
// x-origin
if (!page.sameOrigin(form.action)) return;
// rebuild path
path = form.pathname + form.search + (form.hash || '');
// same page
orig = path + form.hash;
function addToBody(el, val) {
if (el.name) {
body[el.name] = val;
}
else if (el.id) {
body[el.id] = val;
}
}
// build req.body
l = form.elements.length;
addToBody(el, el.value);
if ((el.name || el.id) && el.type === 'submit') {
submitAdded = true;
}
for (i = 0; i < l; i++) {
control = form.elements[i];
if (control.type === 'checkbox') {
addToBody(control, control.checked);
}
else if (control.type === 'submit') {
if (!submitAdded) {
addToBody(control, control.value);
submitAdded = true;
}
}
else if (control.nodeName !== 'BUTTON') {
if (control.type !== 'radio' || control.checked) {
addToBody(control, control.value);
}
}
}
e.preventDefault();
page.show(orig, {body: body});
}
var Context = page.Context;
// overload page.js show method to add support for body parser
page.show = function(path, state, dispatch) {
var ctx = new Context(path, state);
page.current = ctx.path;
if (state && state.body) ctx.body = state.body; // new
if (false !== dispatch) page.dispatch(ctx);
if (false !== ctx.handled) ctx.pushState();
return ctx;
};
// expose pageBodyParser
if ('undefined' == typeof module) {
window.pageBodyParser = pageBodyParser;
}
else {
module.exports = pageBodyParser;
}
})();

View File

@ -285,7 +285,7 @@ else
?>
<div class="install-container">
<form action="" 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">

10
admin/lang.php Normal file
View File

@ -0,0 +1,10 @@
<?php
session_name('adminsession');
session_start();
require_once '../inc/config.php';
if(isset($_GET['set']))
{
$_SESSION['lang'] = $_GET['set'];
echo '1';
}

View File

@ -32,7 +32,7 @@ if (isset($_GET['to']))
<div class="main">
<h1><?php printf($lang->get('mail_write_to'), $_GET['to']); ?></h1>
<div class="form">
<form action="" method="post">
<form action="<?php echo $_SERVER['REQUEST_URI']?>" method="post">
<p><span><?php echo $lang->get('admins_username'); ?>:</span>
<input type="text" value="<?php echo $_SESSION['user']; ?>" name="from"/>
</p>

View File

@ -48,7 +48,7 @@ if (hasPerm('manage_admins'))
?>
<div class="main">
<div class="form">
<form action="" method="POST">
<form action="<?php echo $_SERVER['REQUEST_URI']?>" method="POST">
<p><span><?php echo $lang->get('admins_cn_username'); ?>:</span><input type="text" name="userN"/>
</p>
<p><span><?php echo $lang->get('admins_cn_password'); ?>:</span><input type="password" name="pw1"/>

View File

@ -34,7 +34,7 @@ if (hasPerm('edit_permissions'))
}
} else
{
echo '<div class="main"><form action="" method="post">';
echo '<div class="main"><form action="'.$_SERVER['REQUEST_URI'].'" method="post">';
//Admin Groups
$db->get();
$role_names = [];

View File

@ -39,7 +39,7 @@ if (hasPerm('manage_groups'))
{
?>
<div class="main" style="text-align: center">
<form action="" method="post">
<form action="<?php echo $_SERVER['REQUEST_URI']?>" method="post">
<p><?php echo $lang->get('admins_roles_delete_confirm');?></p>
<input type="submit" name="del" value="<?php echo $lang->get('general_yes');?>"/>
<a href="roles.php?members=<?php echo $_GET['members']; ?>" class="button btn_del"><?php echo $lang->get('general_no');?></a>
@ -65,7 +65,7 @@ if (hasPerm('manage_groups'))
{
?>
<div class="main" style="text-align: center">
<form action="" method="post">
<form action="<?php echo $_SERVER['REQUEST_URI']?>" method="post">
<p><?php echo $lang->get('admins_roles_user_delete_confirm');?></p>
<input type="submit" name="del" value="<?php echo $lang->get('general_yes');?>"/>
<a href="roles.php?members=<?php echo $_GET['members']; ?>" class="button btn_del"><?php echo $lang->get('general_no');?></a>
@ -129,7 +129,7 @@ if (hasPerm('manage_groups'))
} else
{
?>
<form action="" method="post">
<form action="<?php echo $_SERVER['REQUEST_URI']?>" method="post">
<?php echo $lang->get('admins_roles_add_user');?>:
<select name="user">
<?php
@ -168,7 +168,7 @@ if (hasPerm('manage_groups'))
?>
<div class="main">
<h2><?php echo $lang->get('admins_roles_create_group');?></h2>
<form action="" method="post">
<form action="<?php echo $_SERVER['REQUEST_URI']?>" method="post">
<input type="text" name="group_name" placeholder="<?php echo $lang->get('admins_roles_group_name');?>"/><br/>
<input type="submit" name="submit" value="<?php echo $lang->get('admins_roles_create_group');?>"/>
</form>

View File

@ -41,7 +41,7 @@ if (hasPerm('manage_admins') || $uid == $_SESSION['userid'])
{
?>
<div class="main">
<form action="?pw_new" method="post">
<form action="<?php echo $_SERVER['REQUEST_URI']?>" method="post">
<input type="password" name="pw_new"
placeholder="<?php echo $lang->get('user_settings_new_pass'); ?>" autofocus/><br/>
<input type="password" name="pw_new2"
@ -67,7 +67,7 @@ if (hasPerm('manage_admins') || $uid == $_SESSION['userid'])
{
echo '<div class="main"><p>' . $lang->get('user_settings_new_pass') . '</p>';
?>
<form action="?pw_new" method="post">
<form action="<?php echo parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);?>?pw_new" method="post">
<input type="password" name="pw_new"
placeholder="<?php echo $lang->get('user_settings_new_pass'); ?>" autofocus/><br/>
<input type="password" name="pw_new2"
@ -85,7 +85,7 @@ if (hasPerm('manage_admins') || $uid == $_SESSION['userid'])
{
?>
<div class="main">
<form action="" method="post">
<form action="<?php echo $_SERVER['REQUEST_URI']?>" method="post">
<input type="password" name="pw" autofocus
placeholder="<?php echo $lang->get('user_settings_enter_current_pass'); ?>"/><br/>
<input type="submit" value="<?php echo $lang->get('confirm'); ?>"/>
@ -121,7 +121,7 @@ if (hasPerm('manage_admins') || $uid == $_SESSION['userid'])
echo '</table>';
?>
<form action="" method="post"><input type="submit" name="smbt"
<form action="<?php echo $_SERVER['REQUEST_URI']?>" method="post"><input type="submit" name="smbt"
value="<?php echo $lang->get('user_settings_current_sessions_logout_all'); ?>"/>
</form></div>
<?php
@ -157,7 +157,7 @@ if (hasPerm('manage_admins') || $uid == $_SESSION['userid'])
?>
<p><?php echo $lang->get('user_settings_2fa_deactivate_confirm'); ?></p>
<p>
<form action="" method="post" style="text-align: center;">
<form action="<?php echo $_SERVER['REQUEST_URI']?>" method="post" style="text-align: center;">
<input type="submit" name="confirm" value="<?php echo $lang->get('general_yes'); ?>"/>
<a onclick="history.back();" class="button btn_del"><?php echo $lang->get('general_no'); ?></a>
</form>
@ -197,7 +197,7 @@ if (hasPerm('manage_admins') || $uid == $_SESSION['userid'])
echo '<img src="https://api.qrserver.com/v1/create-qr-code/?size=200x200&format=svg&data=' . $qrCodeUrl . '" alt=""/></p>';
?>
<p><?php echo $lang->get('user_settings_2fa_confirm_code'); ?>:</p>
<form action="" method="post">
<form action="<?php echo $_SERVER['REQUEST_URI']?>" method="post">
<p><input type="text" placeholder="<?php echo $lang->get('user_settings_2fa_enter_code'); ?>"
name="2fatest" autocomplete="off"/>
<input type="hidden" name="secret" value="<?php echo $secret; ?>"/>
@ -231,7 +231,7 @@ if (hasPerm('manage_admins') || $uid == $_SESSION['userid'])
{
?>
<div class="main">
<form action="" class="form" method="post">
<form action="<?php echo $_SERVER['REQUEST_URI']?>" class="form" method="post">
<p><span><?php echo $lang->get('username'); ?>:</span><input name="username"
value="<?php echo $db->data[0]['username'] ?>"/>
</p>

View File

@ -5,5 +5,5 @@ $GLOBALS['lang']->set('Manage Files', 'files_title', 'en');
$_CONF['mod_name'] = 'Files';
$_CONF['mod_desc'] = 'Ein Modul zum Anzeigen & Uploaden von Dateien';
$_CONF['menu_top'] = '<i class="icon-folder2"></i> '.$GLOBALS['lang']->get('files_title');
$_CONF['menu'] = ['menu_top' => 'index.php'];
$_CONF['menu'] = ['menu_top' => 'index.php" rel="external'];
$_CONF['type'] = 'none';

View File

@ -302,366 +302,391 @@ if (isset($_SESSION['user']))
<script>
var webUri = '<?php echo $MCONF['web_uri'];?>';
</script>
<script src="<?php echo $MCONF['web_uri']; ?>apps/Files/js/jquery.history.js"></script>
<!--<script src="<?php echo $MCONF['web_uri']; ?>apps/Files/js/jquery.history.js"></script>-->
<script src="<?php echo $MCONF['web_uri']; ?>apps/Files/js/jquery.tablesorter.min.js"></script>
<script src="<?php echo $MCONF['web_uri']; ?>apps/Files/js/jquery.tablesorter.staticrow.js"></script>
<!--<script src="<?php echo $MCONF['web_uri']; ?>apps/Files/js/files.js"></script>-->
<script>
function getFiles(folder) {
var filesContent = '';
console.log(folder);
$.ajax({
url: webUri + 'apps/Files/index.php?json&folder=' + folder,
dataType: 'json',
success: function (data) {
msgDo('&nbsp;');
if (folder == '') folder = 'Files';
if (data.displayUrl == 'Files/') {
$('#delFolder').hide();
}
else {
$('#delFolder').show();
//History
var title = $(document).find("title").text();
historyc(webUri + 'apps/Files/index.php?folder_view=' + data.displayUrl, title);
}
$('#files').html('<h3 id="displayUrl">' + data.displayUrl + '</h3><table id="filesList" width="100%"><thead><tr><th><?php echo $lang->get('files_filename'); ?></th><th><?php echo $lang->get('files_last_modified'); ?></th><th><?php echo $lang->get('files_filetype'); ?></th><th><?php echo $lang->get('files_filesize'); ?></th></tr></thead><tbody id="filesContent"></tbody></table><div id="extra"></div>');
$.each(data.files, function () {
if (this.name == '..') {
var name = '<a onclick="openFile(\'..\', \'' + this.icon + '\', \'' + webUri + data.displayUrl + this.name + '\');"><i class="icon-' + this.icon + '"></i> ' + this.name;
} else {
var name = '<a onclick="openFile(\'' + this.name + '\', \'' + this.icon + '\', \'' + webUri + data.displayUrl + this.name + '\');"><i class="icon-' + this.icon + '"></i> ' + this.name;
}
var static_folder = '';
if (this.icon == 'folder2') {
static_folder = ' class="static"';
}
//$('#filesContent').append('<tr><td>' + name + '</td><td>' + this.date + '</td><td>' + this.type + '</td><td>' + this.size + '</td></tr>');
filesContent += '<tr' + static_folder + '><td>' + name + '</td><td>' + this.date + '</td><td>' + this.type + '</td><td>' + this.size + '</td></tr>';
});
},
timeout: 5000,
error: function (jqXHR, status, errorThrown) {
console.log(errorThrown, status);
var extra_info = status;
if (errorThrown == 'Not Found') extra_info = '<?php echo $lang->get('files_folder_not_found'); ?>';
showMsg('<?php echo $lang->get('files_error'); ?> (' + extra_info + ') <?php echo $lang->get('files_reload'); ?> ');
page('apps/Files/:var', function (ctx, next) {
console.log(ctx);
/*if(!ctx.init) {
next();
//window.location.replace('<?php echo $MCONF['home_uri']; ?>apps/Files/index.php#folder=');
//location.reload();
}*/
//else {*/
if (!window.location.hash) {
var url = '';
} else {
var url = window.location.hash.replace('#folder=', '').replace(folder_curr, '');
}
var folder_curr = $('#displayUrl').html();
getFiles(url);
window.onbeforeunload = function() { return "Your work will be lost."; };
//}
});
//getFiles('');
function getFiles(folder) {
var filesContent = '';
//console.log(folder);
$.ajax({
url: webUri + 'apps/Files/index.php?ajax&json&folder=' + folder,
dataType: 'json',
success: function (data) {
msgDo('&nbsp;');
if (folder == '') folder = 'Files';
if (data.displayUrl == 'Files/') {
$('#delFolder').hide();
}
else {
$('#delFolder').show();
//History
var title = $(document).find("title").text();
//historyc(webUri + 'apps/Files/index.php#folder_view=' + data.displayUrl, title);
}
$('#files').html('<h3 id="displayUrl">' + data.displayUrl + '</h3><table id="filesList" width="100%"><thead><tr><th><?php echo $lang->get('files_filename'); ?></th><th><?php echo $lang->get('files_last_modified'); ?></th><th><?php echo $lang->get('files_filetype'); ?></th><th><?php echo $lang->get('files_filesize'); ?></th></tr></thead><tbody id="filesContent"></tbody></table><div id="extra"></div>');
$.each(data.files, function () {
if(this.type == 'Ordner') {
var name = '<a href="#folder=' + data.displayUrl + this.name + '"><i class="icon-' + this.icon + '"></i> ' + this.name;
} else// onclick="openFile(\'' + this.name + '\', \'' + this.icon + '\', \'' + webUri + data.displayUrl + this.name + '\');"
if (this.name == '..') {
var name = '<a onclick="openFile(\'..\', \'' + this.icon + '\', \'' + webUri + data.displayUrl + this.name + '\');"><i class="icon-' + this.icon + '"></i> ' + this.name;
} else {
var name = '<a onclick="openFile(\'' + this.name + '\', \'' + this.icon + '\', \'' + webUri + data.displayUrl + this.name + '\');"><i class="icon-' + this.icon + '"></i> ' + this.name;
}
var static_folder = '';
if (this.icon == 'folder2') {
static_folder = ' class="static"';
}
//$('#filesContent').append('<tr><td>' + name + '</td><td>' + this.date + '</td><td>' + this.type + '</td><td>' + this.size + '</td></tr>');
filesContent += '<tr' + static_folder + '><td>' + name + '</td><td>' + this.date + '</td><td>' + this.type + '</td><td>' + this.size + '</td></tr>';
});
},
timeout: 5000,
error: function (jqXHR, status, errorThrown) {
console.log(errorThrown, status);
var extra_info = status;
if (errorThrown == 'Not Found') extra_info = '<?php echo $lang->get('files_folder_not_found'); ?>';
showMsg('<?php echo $lang->get('files_error'); ?> (' + extra_info + ') <?php echo $lang->get('files_reload'); ?> ');
}
});
//Tabelle Sortieren
setTimeout(function () {
$('#filesContent').html(filesContent);
$("table").tablesorter({
widgets: ['staticRow']
});
$("table").trigger("sorton", [[[0, 0]]]);
$('#msgDoContainer').hide();
}, 300);
}
//getFiles('');
function openFile(file, type, url) {
//console.log(file, type);
if (type == 'folder2') {
var folder_curr = $('#displayUrl').html();
getFiles(folder_curr + file);
}
else {
$('#extra').html('<div class="overlay" style="display:none;"><div class="window"><div class="head">' + file + '<a onclick="closeW();" class="closeMsg"><i class="icon-close"></i></a></div><div id="content"></div></div></div>');
if (type == 'file-audio-o') {//Audio
$('#content').html('<audio controls src="' + url + '" autoplay></audio>');
}
else if (type == 'file-movie-o') {//Video
$('#content').html('<video controls src="' + url + '" autoplay></video>');
//$('#content').html('<video class="video-js vjs-default-skin" width="640px" height="360px" controls preload="true" data-setup=\'{ "aspectRatio":"640:360" }\' src="' + url + '"></video>');
}
else if (type == 'file-picture-o') {//Bild oder Bild, alles was in einen iFrame passt
$('#content').html('<div class="imgContaienr"><img src="' + url + '" alt="" id="imgZoom"/></div>');
$('#content').css('margin-top', '32px');
//Bild Zoom
var img = document.getElementById('imgZoom');
console.log()
if (img.naturalHeight > 500 || img.naturalWidth > 984) {
$('#imgZoom').click(function () {
$('#imgZoom').toggleClass('zoomedin');
});
}
else {
$('#imgZoom').css('cursor', 'default');
}
}
else if (type == 'file-pdf-o') {//Bild oder pdf, alles was in einen iFrame passt
$('#content').html('<iframe src="' + url + '" width="102%" height="500" style="margin: 0px -10px;"></iframe>');
$('#content').css('margin-top', '32px');
}
else if (type == 'file-archive-o' || type == 'file-powerpoint-o' || type == 'file-word-o' || type == 'file-excel-o') {//Nix, weil die Datei nicht angezeigt werden kann -> Archive, Word, pp
}
else {//Sonst text -> Wenn Sonst oder code
$('#content').html('<div><textarea id="text"></textarea></div>');
$('#text').load(url);
}
$('#content').append('<p><?php echo $lang->get('files_url'); ?>:<input type="text" class="select" value="' + url + '" onClick="this.select();"/></p><p><a href="' + webUri + 'apps/Files/index.php?dl=' + url + '" class="button" download="download"><i class="icon-download"></i> <?php echo $lang->get('files_download'); ?></a> <a onclick="deleteFile(\'' + $('#displayUrl').html() + file + '\');" class="button btn_del"><i class="icon-trash-o"></i> <?php echo $lang->get('files_delete'); ?></a></p>');
//uuund einbelnden
$(".overlay").fadeIn(250);
//Rumschieben
//$('.window').drags();
}
}
function closeW() {
$(".overlay").fadeOut(200);
setTimeout(function () {
$('#extra').html('');
}, 300);
}
function uploadFileBtn() {
$("#upbutton").click();
}
//Neuen ordner
function newFolder() {
$('#extra').html('<div class="overlay" style="display:none;"><div class="window"><div class="head"><?php echo $lang->get('files_create_dir'); ?><a onclick="closeW();" class="closeMsg"><i class="icon-close"></i></a></div><div id="content"></div></div></div>');
$('#content').append('<p><form onsubmit="newFolderSub();return false;"><input type="text" class="select" placeholder="<?php echo $lang->get('files_enter_name'); ?>" id="folderName" autofocus/><input type="submit" value="<?php echo $lang->get('files_create_dir'); ?>"/></form></p>');
$('#folderName').focus();
//uuund einbelnden
$(".overlay").fadeIn(250);
}
function newFolderSub() {
closeW();
msgDo('<?php echo $lang->get('files_creating_new_folder'); ?>');
var folder = $('#displayUrl').html();
$.ajax({
type: 'POST',
url: webUri + 'apps/Files/index.php?newFolder',
data: 'ajax&name=' + $('#folderName').val() + '&dir=' + folder,
success: function (msg) {
console.log(msg);
if (msg == 'success') {
showMsg('<?php echo $lang->get('files_create_dir_success'); ?>');
getFiles(folder);
$('#msgDoContainer').hide();
}
else {
showMsg('<?php echo $lang->get('files_create_dir_fail'); ?>');
$('#msgDoContainer').hide();
}
}
});
return false;
}
//Ordner löschen
function delFolder() {
var file = $('#displayUrl').html();
$('#extra').html('<div class="overlay" style="display:none;"><div class="window window-confirm"><div class="head">"' + file + '" <?php echo $lang->get('files_delete_file'); ?><a onclick="closeW();" class="closeMsg"><i class="icon-close"></i></a></div><div id="content"><p><?php echo $lang->get('files_delete_dir_confirm'); ?></p><p><a onclick="confirmDeleteFile(\'' + file + '\', true);" class="button btn_del"><i class="icon-trash-o"></i>&nbsp;&nbsp;<?php echo $lang->get('files_delete'); ?></a><a onclick="closeW();" class="button"><?php echo $lang->get('files_abort'); ?></a></p></div></div></div>');
//uuund einbelnden
$(".overlay").fadeIn(250);
}
//Datei Löschen
function deleteFile(file) {
$('#extra').html('<div class="overlay" style="display:none;"><div class="window window-confirm"><div class="head">"' + file + '" <?php echo $lang->get('files_delete_file'); ?><a onclick="closeW();" class="closeMsg"><i class="icon-close"></i></a></div><div id="content"><p><?php echo $lang->get('files_delete_file_confirm'); ?></b></p><p><a onclick="confirmDeleteFile(\'' + file + '\', false);" class="button btn_del"><i class="icon-trash-o"></i>&nbsp;&nbsp;<?php echo $lang->get('files_delete'); ?></a><a onclick="closeW();" class="button"><?php echo $lang->get('files_abort'); ?></a></p></div></div></div>');
//uuund einbelnden
$(".overlay").fadeIn(250);
}
function confirmDeleteFile(file, isdir) {
closeW();
if (isdir) {
msgDo('<?php echo $lang->get('files_deleting_folder'); ?>');
}
else {
msgDo('<?php echo $lang->get('files_deleting_file'); ?>');
}
$.ajax({
type: 'POST',
url: webUri + 'apps/Files/index.php?del',
data: 'file=' + file,
success: function (msg) {
console.log(msg);
if (msg == 'success') {
if (isdir) {
showMsg('<?php echo $lang->get('files_delete_dir_success'); ?>');
getFiles('');
}
else {
showMsg('<?php echo $lang->get('files_delete_file_success'); ?>');
getFiles($('#displayUrl').html());
}
$('#msgDoContainer').hide();
}
else {
showMsg('<?php echo $lang->get('files_delete_error'); ?>');
$('#msgDoContainer').hide();
}
}
});
}
//Upload
//Dropupload
var obj = $(document);
obj.on('dragenter', function (e) {
e.stopPropagation();
e.preventDefault();
//$(this).css('border', '2px solid #0B85A1');
console.log('dragenter');
$('#dropFileArea').show();
});
//Tabelle Sortieren
setTimeout(function () {
$('#filesContent').html(filesContent);
$("table").tablesorter({
widgets: ['staticRow']
});
$("table").trigger("sorton", [[[0, 0]]]);
$('#msgDoContainer').hide();
}, 300);
}
obj.on('dragover', function (e) {
e.stopPropagation();
e.preventDefault();
//console.log('dragover');
//$('#dropFileArea').show();
});
getFiles('');
obj.on('drop', function (e) {
$('#dropFileArea').hide();
e.preventDefault();
var files = e.originalEvent.dataTransfer.files;
function openFile(file, type, url) {
console.log(file, type);
if (type == 'folder2') {
var folder_curr = $('#displayUrl').html();
getFiles(folder_curr + file);
//We need to send dropped files to Server
handleFileUpload(files);
});
$('#upbutton').change(function () {
var file = this.files[0];
var formData = new FormData($('form')[0]);
fileUpload(formData, file);
});
function handleFileUpload(files) {
for (var i = 0; i < files.length; i++) {
var fd = new FormData();
fd.append('file', files[i]);
fileUpload(fd, files[i]);
}
}
else {
$('#extra').html('<div class="overlay" style="display:none;"><div class="window"><div class="head">' + file + '<a onclick="closeW();" class="closeMsg"><i class="icon-close"></i></a></div><div id="content"></div></div></div>');
if (type == 'file-audio-o') {//Audio
$('#content').html('<audio controls src="' + url + '" autoplay></audio>');
}
else if (type == 'file-movie-o') {//Video
$('#content').html('<video controls src="' + url + '" autoplay></video>');
//$('#content').html('<video class="video-js vjs-default-skin" width="640px" height="360px" controls preload="true" data-setup=\'{ "aspectRatio":"640:360" }\' src="' + url + '"></video>');
}
else if (type == 'file-picture-o') {//Bild oder Bild, alles was in einen iFrame passt
$('#content').html('<div class="imgContaienr"><img src="' + url + '" alt="" id="imgZoom"/></div>');
$('#content').css('margin-top', '32px');
//Bild Zoom
var img = document.getElementById('imgZoom');
console.log()
if (img.naturalHeight > 500 || img.naturalWidth > 984) {
$('#imgZoom').click(function () {
$('#imgZoom').toggleClass('zoomedin');
function fileUpload(formData, file) {
console.log(formData, file);
//max filesize
$.get(webUri + 'apps/Files/index.php?max_file_size', function (data) {
if (file.size <= data) {
var folder = $('#displayUrl').html();
$.ajax({
url: webUri + 'apps/Files/index.php?upload=' + folder, //Server script to process data
type: 'POST',
xhr: function () { // Custom XMLHttpRequest
var myXhr = $.ajaxSettings.xhr();
if (myXhr.upload) { // Check if upload property exists
myXhr.upload.addEventListener('progress', progressHandlingFunction, false); // For handling the progress of the upload
}
return myXhr;
},
//Ajax events
beforeSend: beforeSendHandler,
success: completeHandler,
error: errorHandler,
// Form data
data: formData,
//Options to tell jQuery not to process data or worry about content-type.
cache: false,
contentType: false,
processData: false
});
}
else {
$('#imgZoom').css('cursor', 'default');
showMsg('<?php echo $lang->get('files_too_large_file'); ?>');
}
}
else if (type == 'file-pdf-o') {//Bild oder pdf, alles was in einen iFrame passt
$('#content').html('<iframe src="' + url + '" width="102%" height="500" style="margin: 0px -10px;"></iframe>');
$('#content').css('margin-top', '32px');
}
else if (type == 'file-archive-o' || type == 'file-powerpoint-o' || type == 'file-word-o' || type == 'file-excel-o') {//Nix, weil die Datei nicht angezeigt werden kann -> Archive, Word, pp
}
else {//Sonst text -> Wenn Sonst oder code
$('#content').html('<div><textarea id="text"></textarea></div>');
$('#text').load(url);
}
$('#content').append('<p><?php echo $lang->get('files_url'); ?>:<input type="text" class="select" value="' + url + '" onClick="this.select();"/></p><p><a href="' + webUri + 'apps/Files/index.php?dl=' + url + '" class="button" download="download"><i class="icon-download"></i> <?php echo $lang->get('files_download'); ?></a> <a onclick="deleteFile(\'' + $('#displayUrl').html() + file + '\');" class="button btn_del"><i class="icon-trash-o"></i> <?php echo $lang->get('files_delete'); ?></a></p>');
//uuund einbelnden
$(".overlay").fadeIn(250);
//Rumschieben
//$('.window').drags();
}
}
function closeW() {
$(".overlay").fadeOut(200);
setTimeout(function () {
$('#extra').html('');
}, 300);
}
function uploadFileBtn() {
$("#upbutton").click();
}
//Neuen ordner
function newFolder() {
$('#extra').html('<div class="overlay" style="display:none;"><div class="window"><div class="head"><?php echo $lang->get('files_create_dir'); ?><a onclick="closeW();" class="closeMsg"><i class="icon-close"></i></a></div><div id="content"></div></div></div>');
$('#content').append('<p><form action="" onsubmit="newFolderSub();return false;"><input type="text" class="select" placeholder="<?php echo $lang->get('files_enter_name'); ?>" id="folderName" autofocus/><input type="submit" value="<?php echo $lang->get('files_create_dir'); ?>"/></form></p>');
$('#folderName').focus();
//uuund einbelnden
$(".overlay").fadeIn(250);
}
function newFolderSub() {
closeW();
msgDo('<?php echo $lang->get('files_creating_new_folder'); ?>');
var folder = $('#displayUrl').html();
$.ajax({
type: 'POST',
url: webUri + 'apps/Files/index.php?newFolder',
data: 'name=' + $('#folderName').val() + '&dir=' + folder,
success: function (msg) {
console.log(msg);
if (msg == 'success') {
showMsg('<?php echo $lang->get('files_create_dir_success'); ?>');
getFiles(folder);
$('#msgDoContainer').hide();
}
else {
showMsg('<?php echo $lang->get('files_create_dir_fail'); ?>');
$('#msgDoContainer').hide();
}
}
});
return false;
}
//Ordner löschen
function delFolder() {
var file = $('#displayUrl').html();
$('#extra').html('<div class="overlay" style="display:none;"><div class="window window-confirm"><div class="head">"' + file + '" <?php echo $lang->get('files_delete_file'); ?><a onclick="closeW();" class="closeMsg"><i class="icon-close"></i></a></div><div id="content"><p><?php echo $lang->get('files_delete_dir_confirm'); ?></p><p><a onclick="confirmDeleteFile(\'' + file + '\', true);" class="button btn_del"><i class="icon-trash-o"></i>&nbsp;&nbsp;<?php echo $lang->get('files_delete'); ?></a><a onclick="closeW();" class="button"><?php echo $lang->get('files_abort'); ?></a></p></div></div></div>');
//uuund einbelnden
$(".overlay").fadeIn(250);
}
//Datei Löschen
function deleteFile(file) {
$('#extra').html('<div class="overlay" style="display:none;"><div class="window window-confirm"><div class="head">"' + file + '" <?php echo $lang->get('files_delete_file'); ?><a onclick="closeW();" class="closeMsg"><i class="icon-close"></i></a></div><div id="content"><p><?php echo $lang->get('files_delete_file_confirm'); ?></b></p><p><a onclick="confirmDeleteFile(\'' + file + '\', false);" class="button btn_del"><i class="icon-trash-o"></i>&nbsp;&nbsp;<?php echo $lang->get('files_delete'); ?></a><a onclick="closeW();" class="button"><?php echo $lang->get('files_abort'); ?></a></p></div></div></div>');
//uuund einbelnden
$(".overlay").fadeIn(250);
}
function confirmDeleteFile(file, isdir) {
closeW();
if (isdir) {
msgDo('<?php echo $lang->get('files_deleting_folder'); ?>');
}
else {
msgDo('<?php echo $lang->get('files_deleting_file'); ?>');
});
}
$.ajax({
type: 'POST',
url: webUri + 'apps/Files/index.php?del',
data: 'file=' + file,
success: function (msg) {
console.log(msg);
if (msg == 'success') {
if (isdir) {
showMsg('<?php echo $lang->get('files_delete_dir_success'); ?>');
getFiles('');
}
else {
showMsg('<?php echo $lang->get('files_delete_file_success'); ?>');
getFiles($('#displayUrl').html());
}
$('#msgDoContainer').hide();
}
else {
showMsg('<?php echo $lang->get('files_delete_error'); ?>');
$('#msgDoContainer').hide();
function progressHandlingFunction(e) {
if (e.lengthComputable) {
var prozent = (e.loaded / e.total) * 100;
msgDo('Datei wird Hochgeladen... [' + Math.round(prozent * 100) / 100 + '%]<div class="progbar_btm"></div>');
$('.progbar_btm').css('width', prozent + '%');
$('#msgDo').css('width', '250px');
if (prozent == 100) {
$('#msgDo').css('width', '232px');
$('#msgDo').html('<?php echo $lang->get('files_processing'); ?>');
}
}
});
}
//Upload
//Dropupload
var obj = $(document);
obj.on('dragenter', function (e) {
e.stopPropagation();
e.preventDefault();
//$(this).css('border', '2px solid #0B85A1');
console.log('dragenter');
$('#dropFileArea').show();
});
obj.on('dragover', function (e) {
e.stopPropagation();
e.preventDefault();
//console.log('dragover');
//$('#dropFileArea').show();
});
obj.on('drop', function (e) {
$('#dropFileArea').hide();
e.preventDefault();
var files = e.originalEvent.dataTransfer.files;
//We need to send dropped files to Server
handleFileUpload(files);
});
$('#upbutton').change(function () {
var file = this.files[0];
var formData = new FormData($('form')[0]);
fileUpload(formData, file);
});
function handleFileUpload(files) {
for (var i = 0; i < files.length; i++) {
var fd = new FormData();
fd.append('file', files[i]);
fileUpload(fd, files[i]);
}
}
function fileUpload(formData, file) {
console.log(formData, file);
//max filesize
$.get(webUri + 'apps/Files/index.php?max_file_size', function (data) {
if (file.size <= data) {
function beforeSendHandler() {
console.log('ready');
$('#upButton').prop("disabled", true);
}
function completeHandler(msg) {
$('#msgDoContainer').hide();
$('#upButton').prop("disabled", false);
if (msg == 'success') {
showMsg('<?php echo $lang->get('files_upload_finished'); ?>');
var folder = $('#displayUrl').html();
$.ajax({
url: webUri + 'apps/Files/index.php?upload=' + folder, //Server script to process data
type: 'POST',
xhr: function () { // Custom XMLHttpRequest
var myXhr = $.ajaxSettings.xhr();
if (myXhr.upload) { // Check if upload property exists
myXhr.upload.addEventListener('progress', progressHandlingFunction, false); // For handling the progress of the upload
}
return myXhr;
},
//Ajax events
beforeSend: beforeSendHandler,
success: completeHandler,
error: errorHandler,
// Form data
data: formData,
//Options to tell jQuery not to process data or worry about content-type.
cache: false,
contentType: false,
processData: false
});
getFiles(folder);
}
else {
showMsg('<?php echo $lang->get('files_too_large_file'); ?>');
}
});
}
function progressHandlingFunction(e) {
if (e.lengthComputable) {
var prozent = (e.loaded / e.total) * 100;
msgDo('Datei wird Hochgeladen... [' + Math.round(prozent * 100) / 100 + '%]<div class="progbar_btm"></div>');
$('.progbar_btm').css('width', prozent + '%');
$('#msgDo').css('width', '250px');
if (prozent == 100) {
$('#msgDo').css('width', '232px');
$('#msgDo').html('<?php echo $lang->get('files_processing'); ?>');
showMsg('<?php echo $lang->get('files_upload_failed'); ?>');
}
}
}
function beforeSendHandler() {
console.log('ready');
$('#upButton').prop("disabled", true);
}
function completeHandler(msg) {
$('#msgDoContainer').hide();
$('#upButton').prop("disabled", false);
if (msg == 'success') {
showMsg('<?php echo $lang->get('files_upload_finished'); ?>');
var folder = $('#displayUrl').html();
getFiles(folder);
}
else {
function errorHandler() {
$('#progressbox').hide();
$('#msgDoContainer').hide();
$('#upButton').prop("disabled", false);
showMsg('<?php echo $lang->get('files_upload_failed'); ?>');
}
}
function errorHandler() {
$('#progressbox').hide();
$('#msgDoContainer').hide();
$('#upButton').prop("disabled", false);
showMsg('<?php echo $lang->get('files_upload_failed'); ?>');
}
//MsgDOO
function msgDo(msg) {
$('#msgDoContainer').css('display', 'inline-block');
$('#msgDo').html(msg);
}
//history
function historyc(url, title) {
//Histroy state
var State = History.getState(), $log = $('#log');
History.Adapter.bind(window, 'statechange', function () {
var State = History.getState();
});
History.pushState({state: 1, rand: Math.random()}, title, url);
}
//Wenn zurücktaste gedrückt
window.addEventListener('popstate', function (event) {
//Histroy state
var State = History.getState(), $log = $('#log');
History.Adapter.bind(window, 'statechange', function () {
var State = History.getState();
});
var title = State.title;
//Seite wieder zusammenbauen
var curr = $('#displayUrl').html();
if (curr == 'Files/') {
History.pushState({state: 1, rand: Math.random()}, title, webUri + 'apps/Files/index.php');
getFiles('');
//MsgDOO
function msgDo(msg) {
$('#msgDoContainer').css('display', 'inline-block');
$('#msgDo').html(msg);
}
else {
History.pushState({
state: 1,
rand: Math.random()
}, title, webUri + 'apps/Files/index.php?folder_view=' + curr);
getFiles(curr + '..');
}
});
//history
/*function historyc(url, title) {
//Histroy state
var State = History.getState(), $log = $('#log');
History.Adapter.bind(window, 'statechange', function () {
var State = History.getState();
});
History.pushState({state: 1, rand: Math.random()}, title, url);
}
//Wenn zurücktaste gedrückt
window.addEventListener('popstate', function (event) {
//Histroy state
var State = History.getState(), $log = $('#log');
History.Adapter.bind(window, 'statechange', function () {
var State = History.getState();
});
var title = State.title;
//Seite wieder zusammenbauen
var curr = $('#displayUrl').html();
if (curr == 'Files/') {
History.pushState({state: 1, rand: Math.random()}, title, webUri + 'apps/Files/index.php');
getFiles('');
}
else {
History.pushState({
state: 1,
rand: Math.random()
}, title, webUri + 'apps/Files/index.php#folder_view=' + curr);
getFiles(curr + '..');
}
});*/
</script>
<!--<script src='<?php echo $MCONF['web_uri']; ?>js/video.js'></script>-->
<?php

View File

@ -93,7 +93,7 @@ if (isset($_GET['page']))
$data_display['lastedit'] = $data_new['lastedit'];
//echo '<pre>'.print_r($data_old, true).'</pre>';
echo '<form action="" method="post"><input type="hidden" name="contentToUpdate" value=\'' . json_encode($data_display) . '\'/><input type="submit" name="confirm" value="'.$lang->get('sp_confirm_confirm').'"/><input type="submit" name="delete" value="'.$lang->get('sp_confirm_delete').'" class="btn_del"/></form>';
echo '<form action="<?php echo $_SERVER['REQUEST_URI']?>" method="post"><input type="hidden" name="contentToUpdate" value=\'' . json_encode($data_display) . '\'/><input type="submit" name="confirm" value="'.$lang->get('sp_confirm_confirm').'"/><input type="submit" name="delete" value="'.$lang->get('sp_confirm_delete').'" class="btn_del"/></form>';
echo '</div>';
}
else

View File

@ -275,7 +275,7 @@ if (hasPerm('manage_pages'))
?>
<span id="response"></span>
<form id="edit" method="post" action="" class="form">
<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"

View File

@ -89,7 +89,7 @@ if (hasPerm('grant_permissions'))
echo '</td>';
?>
<td>
<form action="" method="post" style="padding:0;margin:0;">
<form action="<?php echo $_SERVER['REQUEST_URI']?>" method="post" style="padding:0;margin:0;">
<input type="hidden" name="page" value="<?php echo $data['id']; ?>"/>
<select name="user" style="margin:0;">
<?php

View File

@ -4,7 +4,7 @@ session_start();
require_once '../inc/config.php';
//Language
$lang = new lang();
//$lang = new lang();
$lang->setLangFolder('lang/');
require_once '../inc/libs/functions.php';

View File

@ -1,11 +1,13 @@
<?php
if(!isset($_GET['direct']))
if (!isset($_GET['direct']))
{
?>
</div>
<div id="showMsg"></div>
<script src="<?php echo $MCONF['web_uri']?>admin/assets/js/page.js"></script>
<!--<script src="<?php echo $MCONF['web_uri'] ?>admin/assets/js/page.js"></script>
<script src="<?php echo $MCONF['web_uri'] ?>admin/assets/js/page.bodyparser.js"></script>-->
<script>
//Msg
function showMsg(msg) {
$('#showMsg').html('<div class="snackbar"><a onclick="closeMsg();" class="closeMsg"><i class="icon-close"></i> </a><p>' + msg + '</p></div>');
}
@ -25,104 +27,121 @@ if(!isset($_GET['direct']))
$('.toploading').animate({height: "0"}, 150);
}
$(document).ready(function() {
//Form
// pre-submit callback
function showLoader(formData, jqForm, options) {
//Change current Language
function changeLang(lang) {
showTopLoader();
console.log('Form');
return true;
$.get('<?php echo $MCONF['home_uri'];?>admin/lang.php?set=' + lang, function (data) {
console.log(data);
if(data == 1){
location.reload();
} else {
showMsg('Error.');
}
})
}
// post-submit callback
function showResponse(responseText, statusText, xhr, $form) {
//return false;
hideTopLoader();
console.log(statusText);
}
//Error
function showError(e) {
console.log(e);
}
var options = {
target: '#loader',
beforeSubmit: showLoader,
success: showResponse,
error: showError,
resetForm: false,
data: {direct: ''}
};
$('form').ajaxForm(options);
$(document).ready(function () {
//Router
$('#topnav').addClass('no-transition');
page.base('<?php echo $MCONF['home_uri'];?>');
///page.base('<?php echo $MCONF['home_uri'];?>');
page('*', findPage);
page();
pageBodyParser();
function findPage(ctx, next) {
//console.log(ctx);
if(!ctx.init) {
//if('<?php echo str_replace($MCONF['home_uri'], '', $MCONF['web_uri']);?>' + ctx.canonicalPath != window.location.href) {
if (ctx.body) { //If POST-Request, send Post via ajax
showTopLoader();
//Load Title
var title = '';
var query = '';
if (ctx.querystring != '') {
query += '&' + ctx.querystring;
}
$.get(ctx.pathname + '?title' + query, function (data) {
title = data;
}).fail(function (e) {
if(e.status == 404){
showMsg('<?php echo $lang->get('404_not_found');?> (' + e.statusText + ')');
} else {
showMsg('Error.');
var isAjax = false;
var requestData = 'direct=true';
for (var key in ctx.body) {
if (!ctx.body.hasOwnProperty(key)) continue;
requestData += '&' + key + '=' + ctx.body[key];
if(key == 'ajax') isAjax = true;
}
});
//Load Content
$.get(ctx.pathname + '?direct' + query, function (data) {
hideTopLoader();
if (data == 'Login First.') {
location.reload();
} else {
$("#loader").html(data);
//Set Title
$("#title").html(title);
document.title = title + ' | <?php echo $lang->get('admin_title') . ' | ' . $MCONF['title']?>';
//Update Menu
$('li').each(function (index) {
$(this).removeClass('active');
if(!isAjax) {
$.ajax({
url: ctx.canonicalPath,
type: 'POST',
cache: false,
data: requestData,
beforeSend: function () {
showTopLoader();
},
complete: function () {
hideTopLoader();
},
success: function (result) {
$("#loader").html(result);
},
error: function (xhr, status, error) {
console.log(status, error);
}
});
}
} else {//Otherwise display Contents
//Find Class & Parent for menu
var menuitem = 'mw-menu-' + ctx.path.replace(/\//g, '-').replace('.php', '').replace('?', '').replace('&', '').replace('=', '');
//console.log(menuitem);
$('#' + menuitem).addClass('active');
//Find Top item
var topitems = menuitem.split('-');
//console.log(topitems);
$('#' + 'mw-menu-' + topitems[2] + '-' + topitems[3] + '-top').addClass('active');
if (topitems[3] == 'roles' || topitems[3] == 'users' || topitems[3] == 'permissions' || topitems[3] == 'new_user') {
$('#' + 'mw-menu-admin-users-top').addClass('active');
showTopLoader();
//Load Title
var title = '';
var query = '';
if (ctx.querystring != '') {
query += '&' + ctx.querystring;
}
$.get(ctx.pathname + '?title' + query, function (data) {
title = data;
}).fail(function (e) {
if (e.status == 404) {
showMsg('<?php echo $lang->get('404_not_found');?> (' + e.statusText + ')');
} else {
showMsg('Error.');
}
}
}).fail(function (e) {
if(e.status == 404){
showMsg('<?php echo $lang->get('404_not_found');?> (' + e.statusText + ')');
} else {
showMsg('Error.');
}
});
// }
});
//Load Content
$.get(ctx.pathname + '?direct' + query, function (data) {
hideTopLoader();
if (data == 'Login First.') {
location.reload();
} else {
$("#loader").html(data);
//Set Title
$("#title").html(title);
document.title = title + ' | <?php echo $lang->get('admin_title') . ' | ' . $MCONF['title']?>';
//Update Menu
$('li').each(function (index) {
$(this).removeClass('active');
});
//Find Class & Parent for menu
var menuitem = 'mw-menu-' + ctx.path.replace(/\//g, '-').replace('.php', '').replace('?', '').replace('&', '').replace('=', '');
//console.log(menuitem);
$('#' + menuitem).addClass('active');
//Find Top item
var topitems = menuitem.split('-');
//console.log(topitems);
$('#' + 'mw-menu-' + topitems[2] + '-' + topitems[3] + '-top').addClass('active');
if (topitems[3] == 'roles' || topitems[3] == 'users' || topitems[3] == 'permissions' || topitems[3] == 'new_user') {
$('#' + 'mw-menu-admin-users-top').addClass('active');
}
}
}).fail(function (e) {
if (e.status == 404) {
showMsg('<?php echo $lang->get('404_not_found');?> (' + e.statusText + ')');
} else {
showMsg('Error.');
}
});
}
}
}
});

View File

@ -229,7 +229,12 @@ function printHeader($title)
<link rel="stylesheet" href="' . $GLOBALS['MCONF']['web_uri'] . 'admin/assets/admin.css" type="text/css"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no" />
<script src="' . $GLOBALS['MCONF']['web_uri'] . 'admin/assets/js/jquery.min.js"></script>
<script src="' . $GLOBALS['MCONF']['web_uri'] . 'admin/assets/js/jquery.form.min.js"></script>
<script src="' . $GLOBALS['MCONF']['web_uri'] . 'admin/assets/js/page.js"></script>
<script src="' . $GLOBALS['MCONF']['web_uri'] . 'admin/assets/js/page.bodyparser.js"></script>
<script>
page.base(\'' . $GLOBALS['MCONF']['home_uri'] . '\');
</script>
</head>
<body>';
if (is_loggedin())

View File

@ -11,6 +11,7 @@ class lang
{
$this->default = $default;
$this->lang = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
if(isset($_SESSION['lang'])) $this->lang = $_SESSION['lang'];
$this->langfiles = [];
}