Fixed passing edited content with tinymce to php

This commit is contained in:
kolaente 2016-10-22 17:13:35 +02:00
parent 740cdc500c
commit 75b6f587cf
3 changed files with 20 additions and 77 deletions

View File

@ -20,77 +20,6 @@ if (hasPerm('manage_pages'))
$content = strip_tags($content);
}
/*if (!$confirmationRequierd)
{
$time = time();
$seite = str_replace('-', ' ', $seite);
$seite = str_replace('ä', 'ä', $seite);
$seite = str_replace('ö', 'ö', $seite);
$seite = str_replace('ü', 'ü', $seite);
//echo $seite;
$stmt = $DBH->prepare("UPDATE " . $MCONF['db_prefix'] . "seiten SET inhalt=:inhalt, datel=:datel, userl=:userl WHERE name=:seite");
$stmt->bindParam(':inhalt', $content);
$stmt->bindParam(':datel', $time);
$stmt->bindParam(':userl', $_SESSION['user']);
$stmt->bindParam(':seite', $seite);
if ($stmt->execute())
{
echo msg('succes', 'Die Seite "' . $seite . '" wurde erfolgreich ge&auml;ndert. <a href="management.php">Zurück</a>');
} else
{
echo msg('fail');
}
} else
{
$bnutzrid = $_SESSION['user'];
//echo $seite;
$seite = str_replace('-', ' ', $seite);
$seite = str_replace('ä', '&auml;', $seite);
$seite = str_replace('ö', '&ouml;', $seite);
$seite = str_replace('ü', '&uuml;', $seite);
//echo $seite;
if ($_SESSION['user'] === $confirmationUser)
{
$time = time();
$STH = $DBH->prepare("UPDATE " . $MCONF['db_prefix'] . "seiten SET inhalt=:inhalt, datel=:datel, userl=:userl WHERE name=:seite");
$STH->bindParam(':inhalt', $content);
$STH->bindParam(':datel', $time);
$STH->bindParam(':userl', $_SESSION['user']);
$STH->bindParam(':seite', $seite);
if ($STH->execute())
{
$STH2 = $DBH->prepare("DELETE FROM " . $MCONF['db_prefix'] . "seitenneu WHERE name=:name");
$STH2->bindParam(':name', $seite);
if ($STH2->execute())
{
echo msg('succes', 'Die Seite "' . $seite . '" wurde erfolgreich ge&auml;ndert. <a href="management.php">Zurück</a>');
} else
{
echo msg('fail');
}
} else
{
echo msg('fail');
}
} else
{
$time = time();
$stmt2 = $DBH->prepare("INSERT INTO " . $MCONF['db_prefix'] . "seitenneu (name, inhalt, geaendertby, datum) VALUES (:name, :inhalt, :geaendertby, :datum)");
$stmt2->bindParam(':name', $seite);
$stmt2->bindParam(':inhalt', $content);
$stmt2->bindParam(':geaendertby', $bnutzrid);
$stmt2->bindParam(':datum', $time);
if ($stmt2->execute() and freischaltemail($seite))
{
echo msg('succes', 'Die Seite ' . $seite . ' wurde erfolgreich ge&auml;ndert. Diese &Auml;nderungen werden &ouml;ffentlich, sobald ' . $confirmationUser . ' sie Freigegeben hat. <a href="management.php">Zurück</a>');
} else
{
echo msg('fail');
}
}*/
//
$db->clear();
//If a confirmation by user is requiered, insert it in another table and send an email
@ -146,6 +75,8 @@ if (hasPerm('manage_pages'))
$db->data['lastedit'] = time();
if(isset($_GET['new'])) $db->data['created'] = time();
//print_r($_POST);
//$db->update(['id' => $_GET['id']]);
$id = 0;
if (isset($_GET['new']))

View File

@ -46,11 +46,14 @@ $MCONF['update_uri'] = $config['Versioning']['update_uri'];
//Mailer
$MCONF['smtp'] = $config['Mail']['smtp'];
$MCONF['smtp_host'] = $config['Mail']['host'];
$MCONF['smtp_user'] = $config['Mail']['username'];
$MCONF['smtp_pass'] = $config['Mail']['password'];
$MCONF['smtp_secure'] = $config['Mail']['secure'];
$MCONF['smtp_port'] = $config['Mail']['port'];
if($MCONF['smtp'] === true)
{
$MCONF['smtp_host'] = $config['Mail']['host'];
$MCONF['smtp_user'] = $config['Mail']['username'];
$MCONF['smtp_pass'] = $config['Mail']['password'];
$MCONF['smtp_secure'] = $config['Mail']['secure'];
$MCONF['smtp_port'] = $config['Mail']['port'];
}
require_once 'libs/lang.class.php';

View File

@ -70,10 +70,19 @@ if (!isset($_GET['direct']))
var isAjax = false;
var requestData = 'direct=true';
var editorname = '';
if (typeof(tinyMCE) != "undefined") {editorname = $('#' + tinyMCE.activeEditor.id).attr("name");}//Get the new Content, not the old
for (var key in ctx.body) {
if (!ctx.body.hasOwnProperty(key)) continue;
requestData += '&' + key + '=' + ctx.body[key];
//If we have content edited with tinymce, we want the new content to be passed with the POST-Request
if(key == editorname) {
console.log(tinyMCE.activeEditor.getContent());
requestData += '&' + key + '=' + tinyMCE.activeEditor.getContent();
} else {
requestData += '&' + key + '=' + ctx.body[key];
}
if(key == 'ajax') isAjax = true;
}