Issue 106: Invalid HTML output fixed

This commit is contained in:
azett 2022-05-07 20:02:41 +02:00
parent 96934bf2aa
commit becd504aae
11 changed files with 454 additions and 405 deletions

View File

@ -1,4 +1,4 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-loose.dtd"> <!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"> <html xmlns="http://www.w3.org/1999/xhtml">
<head> <head>
<title>{$flatpress.title}{$pagetitle}</title> <title>{$flatpress.title}{$pagetitle}</title>

View File

@ -1,10 +1,9 @@
<?php <?php
// require_once('../init.php'); // require_once('../init.php');
// utils_redirect('../admin.php'); // utils_redirect('../admin.php');
?> ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"> <html xmlns="http://www.w3.org/1999/xhtml">
<head> <head>
<title>FlatPress</title> <title>FlatPress</title>

View File

@ -13,7 +13,7 @@
{html_form} {html_form}
<script type="text/javascript"> <script>
{literal} {literal}
function admin_entry_comment_delete() { return confirm({/literal}'{$plang.act_del_confirm}'{literal}); } function admin_entry_comment_delete() { return confirm({/literal}'{$plang.act_del_confirm}'{literal}); }

View File

@ -16,7 +16,7 @@
/* /*
* function admin_plugin_adminheader() { * function admin_plugin_adminheader() {
* $f = ADMIN_DIR . '/panels/plugin/admin.plugin.js'; * $f = ADMIN_DIR . '/panels/plugin/admin.plugin.js';
* echo '<script src="$f" type="text/javascript"></script> * echo '<script src="$f"></script>
* '; * ';
* *
* } * }

View File

@ -1,18 +1,18 @@
<?php <?php
function admin_widgets_head() { function admin_widgets_head() {
echo '<script type="text/javascript" src="'.BLOG_BASEURL.ADMIN_DIR.'panels/widgets/admin.widgets.js"></script>'; echo '<script src="' . BLOG_BASEURL . ADMIN_DIR . 'panels/widgets/admin.widgets.js"></script>';
} }
add_action('wp_footer', 'admin_widgets_head'); add_action('wp_footer', 'admin_widgets_head');
class admin_widgets_default extends AdminPanelAction { class admin_widgets_default extends AdminPanelAction {
// var $validators = array(array('content', 'content', 'notEmpty', false, false)); // var $validators = array(array('content', 'content', 'notEmpty', false, false));
var $events = array('save'); var $events = array(
'save'
);
function get_widget_lists($wlist, $wpos, &$widget_list, $registered_w, $add_empties) { function get_widget_lists($wlist, $wpos, &$widget_list, $registered_w, $add_empties) {
if (!isset($wlist [$wpos])) if (!isset($wlist [$wpos]))
return; return;
@ -22,11 +22,10 @@
$widget_list [$wpos] [$idx] = array(); $widget_list [$wpos] [$idx] = array();
$newid = $wdg; # @list($newid, $params) = explode(":", $wdg); $newid = $wdg; // @list($newid, $params) = explode(":", $wdg);
$widget_list [$wpos] [$idx] ['id'] = $newid; $widget_list [$wpos] [$idx] ['id'] = $newid;
if (isset($registered_w [$newid])) { if (isset($registered_w [$newid])) {
$thiswdg = $registered_w [$newid]; $thiswdg = $registered_w [$newid];
@ -43,7 +42,6 @@
* in the template * in the template
* *
*/ */
} else { } else {
global $lang; global $lang;
@ -53,30 +51,22 @@
$errs = sprintf($lang ['admin'] ['widgets'] ['errors'] ['generic'], $newid); $errs = sprintf($lang ['admin'] ['widgets'] ['errors'] ['generic'], $newid);
$this->smarty->append('warnings', $errs); $this->smarty->append('warnings', $errs);
} }
} }
if (!$widget_list [$wpos] && !$add_empties) if (!$widget_list [$wpos] && !$add_empties)
unset($widget_list [$wpos]); unset($widget_list [$wpos]);
} }
function main() { function main() {
lang_load('admin.widgets'); lang_load('admin.widgets');
# $this->smarty->assign('warnings', admin_widgets_checkall()); // $this->smarty->assign('warnings', admin_widgets_checkall());
global $fp_widgets; global $fp_widgets;
$registered_w = get_registered_widgets(); $registered_w = get_registered_widgets();
$registered_ws = get_registered_widgetsets(null); $registered_ws = get_registered_widgetsets(null);
$this->smarty->assign('fp_registered_widgets', $registered_w); $this->smarty->assign('fp_registered_widgets', $registered_w);
$wlist = $fp_widgets->getList(); $wlist = $fp_widgets->getList();
$widget_list = array(); $widget_list = array();
@ -87,7 +77,6 @@
$this->get_widget_lists($wlist, $wpos, $widget_list, $registered_w, true); $this->get_widget_lists($wlist, $wpos, $widget_list, $registered_w, true);
unset($wlist [$wpos]); unset($wlist [$wpos]);
} }
$oldwidget_list = array(); $oldwidget_list = array();
@ -98,26 +87,20 @@
$this->smarty->assign('widgetlist', $widget_list); $this->smarty->assign('widgetlist', $widget_list);
$this->smarty->assign('oldwidgetlist', $oldwidget_list); $this->smarty->assign('oldwidgetlist', $oldwidget_list);
$conf = io_load_file(CONFIG_DIR . 'widgets.conf.php'); $conf = io_load_file(CONFIG_DIR . 'widgets.conf.php');
$this->smarty->assign('pluginconf', $conf); $this->smarty->assign('pluginconf', $conf);
return 0; return 0;
} }
function onsave() { function onsave() {
$fp_widgets = isset($_POST ['widgets']) ? $_POST ['widgets'] : array(); $fp_widgets = isset($_POST ['widgets']) ? $_POST ['widgets'] : array();
$success = system_save(CONFIG_DIR . 'widgets.conf.php', compact('fp_widgets')); $success = system_save(CONFIG_DIR . 'widgets.conf.php', compact('fp_widgets'));
$this->smarty->assign('success', ($success) ? 1 : -1); $this->smarty->assign('success', ($success) ? 1 : -1);
return PANEL_REDIRECT_CURRENT; return PANEL_REDIRECT_CURRENT;
} }
} }

View File

@ -1,4 +1,4 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-loose.dtd"> <!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"> <html xmlns="http://www.w3.org/1999/xhtml">
<head> <head>
<title>{$flatpress.title}{$pagetitle}</title> <title>{$flatpress.title}{$pagetitle}</title>

View File

@ -12,9 +12,9 @@
</h3> </h3>
{include file=shared:entryadminctrls.tpl} {include file=shared:entryadminctrls.tpl}
<span itemprop="articleBody"> <div itemprop="articleBody">
{$content|tag:the_content} {$content|tag:the_content}
</span> </div>
<ul class="entry-footer"> <ul class="entry-footer">

View File

@ -780,7 +780,7 @@ function plugin_bbcode_toolbar() {
// $bblang = lang_load('plugin:bbcode'); // $bblang = lang_load('plugin:bbcode');
// $_FP_SMARTY->assign('bblang', $bblang); // $_FP_SMARTY->assign('bblang', $bblang);
echo "<!-- bbcode plugin -->\n"; echo "<!-- bbcode plugin -->\n";
echo '<script type="text/javascript" src="' . plugin_geturl('bbcode') . 'res/editor.js"></script>' . "\n"; echo '<script src="' . plugin_geturl('bbcode') . 'res/editor.js"></script>' . "\n";
echo $_FP_SMARTY->fetch('plugin:bbcode/toolbar'); echo $_FP_SMARTY->fetch('plugin:bbcode/toolbar');
echo "<!-- end of bbcode plugin -->\n"; echo "<!-- end of bbcode plugin -->\n";
} }

View File

@ -2,21 +2,47 @@
/** /**
* This is the administration panel for the plugin Flatpress Comment Center. * This is the administration panel for the plugin Flatpress Comment Center.
*/ */
if (!class_exists('plugin_commentcenter')) { if (!class_exists('plugin_commentcenter')) {
die('Don\'t try to hack us.'); die('Don\'t try to hack us.');
} }
class admin_entry_commentcenter extends AdminPanelAction { class admin_entry_commentcenter extends AdminPanelAction {
# The language files // The language files
var $langres = 'plugin:commentcenter'; var $langres = 'plugin:commentcenter';
# The commands
var $commands=array('configure', 'polup', 'poldown', 'poledit', 'poldelete', 'approve_list', // The commands
'publishcomm', 'pubnoham', 'deletecomm', 'manage', 'deletecomm2', 'commspam'); var $commands = array(
# The submits 'configure',
var $events=array('configure', 'edit_policy', 'delok', 'cancel', 'multidel', 'mpubcomm', 'mdelcomm', 'polup',
'commdelok', 'ccancel', 'entry_search', 'mdelcomm_2', 'commdelok_2', 'ccancel_2'); 'poldown',
'poledit',
'poldelete',
'approve_list',
'publishcomm',
'pubnoham',
'deletecomm',
'manage',
'deletecomm2',
'commspam'
);
// The submits
var $events = array(
'configure',
'edit_policy',
'delok',
'cancel',
'multidel',
'mpubcomm',
'mdelcomm',
'commdelok',
'ccancel',
'entry_search',
'mdelcomm_2',
'commdelok_2',
'ccancel_2'
);
/** /**
* This function is used as a callback when the panel is loaded. * This function is used as a callback when the panel is loaded.
@ -28,21 +54,32 @@ class admin_entry_commentcenter extends AdminPanelAction {
$this->plugin = &$GLOBALS ['plugin_commentcenter']; $this->plugin = &$GLOBALS ['plugin_commentcenter'];
$smarty = &$this->smarty; $smarty = &$this->smarty;
# The default TPL // The default TPL
$smarty->assign('admin_resource', 'plugin:commentcenter/policies'); $smarty->assign('admin_resource', 'plugin:commentcenter/policies');
$smarty->assign('plugin_url', plugin_geturl('commentcenter')); $smarty->assign('plugin_url', plugin_geturl('commentcenter'));
$smarty->register_modifier('idToSubject', array(&$this, '_idToTitle')); $smarty->register_modifier('idToSubject', array(
add_filter('wp_title', array(&$this, '_title'), 15, 2); &$this,
add_action('wp_head', array(&$this, '_head'), 10); '_idToTitle'
));
add_filter('wp_title', array(
&$this,
'_title'
), 15, 2);
add_action('wp_head', array(
&$this,
'_head'
), 10);
} }
/** /**
* This function is the callback for the hook system. * This function is the callback for the hook system.
* It sets the title. * It sets the title.
* *
* @param string $val: The current title * @param string $val:
* @param string $sep: The separator * The current title
* @param string $sep:
* The separator
* @return string: The title * @return string: The title
*/ */
function _title($val, $sep) { function _title($val, $sep) {
@ -59,19 +96,25 @@ class admin_entry_commentcenter extends AdminPanelAction {
} }
$src1 = plugin_geturl('commentcenter') . 'res/ajax.js'; $src1 = plugin_geturl('commentcenter') . 'res/ajax.js';
$src2 = BLOG_BASEURL . 'admin.php?jslang=commentcenter'; $src2 = BLOG_BASEURL . 'admin.php?jslang=commentcenter';
echo '<script type="text/javascript" src="'.$src1."\"></script>\n"; echo '<script src="' . $src1 . "\"></script>\n";
echo '<script type="text/javascript" src="'.$src2."\"></script>\n"; echo '<script src="' . $src2 . "\"></script>\n";
} }
/** /**
* This function return the entry title from the id. * This function return the entry title from the id.
* It's made to be called from Smarty. * It's made to be called from Smarty.
* *
* @param string $id: The entry id * @param string $id:
* The entry id
* @return string: The output * @return string: The output
*/ */
function _idToTitle($id) { function _idToTitle($id) {
$o=new FPDB_Query(array('start'=>0, 'count'=>1, 'fullparse'=>false, 'id'=>$id), null); $o = new FPDB_Query(array(
'start' => 0,
'count' => 1,
'fullparse' => false,
'id' => $id
), null);
if (!$o->hasMore()) { if (!$o->hasMore()) {
return false; return false;
} }
@ -82,9 +125,12 @@ class admin_entry_commentcenter extends AdminPanelAction {
/** /**
* This function is an advanced redirect option. * This function is an advanced redirect option.
* *
* @param string $cmd: The command * @param string $cmd:
* @param mixed $cmdval: The value for the command * The command
* @param boolean $nosuccess: Don't save the success? * @param mixed $cmdval:
* The value for the command
* @param boolean $nosuccess:
* Don't save the success?
*/ */
function _redirect($cmd, $cmdval = 1, $nosuccess = false) { function _redirect($cmd, $cmdval = 1, $nosuccess = false) {
global $panel; global $panel;
@ -96,7 +142,7 @@ class admin_entry_commentcenter extends AdminPanelAction {
$url = html_entity_decode($url); $url = html_entity_decode($url);
$url = substr($url, strlen(BLOG_BASEURL)); $url = substr($url, strlen(BLOG_BASEURL));
utils_redirect($url); utils_redirect($url);
die; die();
} }
/** /**
@ -142,11 +188,13 @@ class admin_entry_commentcenter extends AdminPanelAction {
} }
} }
$save=array('log_all'=>isset($_POST['log_all']), $save = array(
'log_all' => isset($_POST ['log_all']),
'email_alert' => isset($_POST ['email_alert']), 'email_alert' => isset($_POST ['email_alert']),
'akismet_check' => isset($_POST ['akismet_check']), 'akismet_check' => isset($_POST ['akismet_check']),
'akismet_key' => $_POST ['akismet_key'], 'akismet_key' => $_POST ['akismet_key'],
'akismet_url'=>$_POST['akismet_url']); 'akismet_url' => $_POST ['akismet_url']
);
// It doesn't make very sense: I could just use array_merge but... // It doesn't make very sense: I could just use array_merge but...
foreach ($save as $key => $value) { foreach ($save as $key => $value) {
plugin_addoption('commentcenter', $key, $value); plugin_addoption('commentcenter', $key, $value);
@ -160,7 +208,8 @@ class admin_entry_commentcenter extends AdminPanelAction {
/** /**
* The edit policy/new policy action callback. * The edit policy/new policy action callback.
* *
* @param integer $id: The policy id. -1 means a new one * @param integer $id:
* The policy id. -1 means a new one
* @return integer: The redirect option * @return integer: The redirect option
*/ */
function dopoledit($id) { function dopoledit($id) {
@ -177,7 +226,7 @@ class admin_entry_commentcenter extends AdminPanelAction {
if ($id != -1 && isset($plugin->policies [$id])) { if ($id != -1 && isset($plugin->policies [$id])) {
$smarty->assign('policy', $plugin->policies [$id]); $smarty->assign('policy', $plugin->policies [$id]);
} elseif ($id != -1) { } elseif ($id != -1) {
# Inexistent policy // Inexistent policy
$smarty->assign('errors', $plang ['errors'] ['pol_nonex']); $smarty->assign('errors', $plang ['errors'] ['pol_nonex']);
} else { } else {
$smarty->assign('polnew', true); $smarty->assign('polnew', true);
@ -247,7 +296,7 @@ class admin_entry_commentcenter extends AdminPanelAction {
$policy ['is_all'] = false; $policy ['is_all'] = false;
} }
if (is_numeric($_POST ['older'])) { if (is_numeric($_POST ['older'])) {
# Save in seconds // Save in seconds
$policy ['older'] = $_POST ['older'] * 86400; $policy ['older'] = $_POST ['older'] * 86400;
$policy ['is_all'] = false; $policy ['is_all'] = false;
} }
@ -278,7 +327,8 @@ class admin_entry_commentcenter extends AdminPanelAction {
/** /**
* This function is the callback for the poldelete action. * This function is the callback for the poldelete action.
* *
* @param integer $id: The id of policy you wish to delete * @param integer $id:
* The id of policy you wish to delete
* @return integer: Redirect option * @return integer: Redirect option
*/ */
function dopoldelete($id) { function dopoldelete($id) {
@ -289,7 +339,9 @@ class admin_entry_commentcenter extends AdminPanelAction {
$plugin->loadPolicies(); $plugin->loadPolicies();
if (isset($plugin->policies [$id])) { if (isset($plugin->policies [$id])) {
$smarty->assign('policies', array($id=>$plugin->policies[$id])); $smarty->assign('policies', array(
$id => $plugin->policies [$id]
));
} }
$smarty->assign('single', true); $smarty->assign('single', true);
return 0; return 0;
@ -356,7 +408,8 @@ class admin_entry_commentcenter extends AdminPanelAction {
} }
/** /**
* This is the cancel callback. It just makes the redirect. * This is the cancel callback.
* It just makes the redirect.
* *
* @return integer: The redirect option * @return integer: The redirect option
*/ */
@ -367,7 +420,8 @@ class admin_entry_commentcenter extends AdminPanelAction {
/** /**
* This function is the callback for the polup action. * This function is the callback for the polup action.
* *
* @param integer $id: The id of policy you wish to delete * @param integer $id:
* The id of policy you wish to delete
* @return integer: Redirect option * @return integer: Redirect option
*/ */
function dopolup($id) { function dopolup($id) {
@ -387,7 +441,8 @@ class admin_entry_commentcenter extends AdminPanelAction {
/** /**
* This function is the callback for the poldown action. * This function is the callback for the poldown action.
* *
* @param integer $id: The id of policy you wish to delete * @param integer $id:
* The id of policy you wish to delete
* @return integer: Redirect option * @return integer: Redirect option
*/ */
function dopoldown($id) { function dopoldown($id) {
@ -428,9 +483,12 @@ class admin_entry_commentcenter extends AdminPanelAction {
/** /**
* This function is the callback for the publishcomm command * This function is the callback for the publishcomm command
* *
* @param string $id: The comment id * @param string $id:
* @param boolean $noredirect: If true, don't redirect * The comment id
* @param boolean $noham: If it was blocked from Akismet, don't submit as ham * @param boolean $noredirect:
* If true, don't redirect
* @param boolean $noham:
* If it was blocked from Akismet, don't submit as ham
* @return integer: The redirect option * @return integer: The redirect option
*/ */
function dopublishcomm($id, $noredirect = false, $noham = false) { function dopublishcomm($id, $noredirect = false, $noham = false) {
@ -466,14 +524,16 @@ class admin_entry_commentcenter extends AdminPanelAction {
} }
$id = comment_save($entry, $comment); $id = comment_save($entry, $comment);
do_action('comment_post', $entry, array($id, $comment)); do_action('comment_post', $entry, array(
$id,
$comment
));
$succ = $id ? 5 : -5; $succ = $id ? 5 : -5;
$smarty->assign('success', $succ); $smarty->assign('success', $succ);
if ($succ == 5) { if ($succ == 5) {
@unlink($f); @unlink($f);
} }
} }
if ($noredirect) { if ($noredirect) {
@ -487,7 +547,8 @@ class admin_entry_commentcenter extends AdminPanelAction {
/** /**
* This is the callback for the action pubnoham. * This is the callback for the action pubnoham.
* *
* @param string $id: The comment id * @param string $id:
* The comment id
* @return integer: The redirect option. * @return integer: The redirect option.
*/ */
function dopubnoham($id) { function dopubnoham($id) {
@ -522,7 +583,8 @@ class admin_entry_commentcenter extends AdminPanelAction {
/** /**
* This function is the callback for the deletecomm action. * This function is the callback for the deletecomm action.
* *
* @param integer $id: The id of the comment you wish to delete * @param integer $id:
* The id of the comment you wish to delete
* @return integer: Redirect option * @return integer: Redirect option
*/ */
function dodeletecomm($id) { function dodeletecomm($id) {
@ -612,7 +674,8 @@ class admin_entry_commentcenter extends AdminPanelAction {
} }
/** /**
* This is the cancel callback. It just makes the redirect. * This is the cancel callback.
* It just makes the redirect.
* *
* @return integer: The redirect option * @return integer: The redirect option
*/ */
@ -624,7 +687,8 @@ class admin_entry_commentcenter extends AdminPanelAction {
/** /**
* This function is the callback for the action "manage". * This function is the callback for the action "manage".
* *
* @param string $entry: The entry id * @param string $entry:
* The entry id
* @return integer: The redirect option * @return integer: The redirect option
*/ */
function domanage($entry) { function domanage($entry) {
@ -678,7 +742,8 @@ class admin_entry_commentcenter extends AdminPanelAction {
/** /**
* This function is the callback for the deletecomm2 action. * This function is the callback for the deletecomm2 action.
* *
* @param integer $id: The id of the comment you wish to delete * @param integer $id:
* The id of the comment you wish to delete
* @return integer: Redirect option * @return integer: Redirect option
*/ */
function dodeletecomm2($id) { function dodeletecomm2($id) {
@ -769,7 +834,8 @@ class admin_entry_commentcenter extends AdminPanelAction {
} }
/** /**
* This is the cancel callback. It just makes the redirect. * This is the cancel callback.
* It just makes the redirect.
* *
* @return integer: The redirect option * @return integer: The redirect option
*/ */
@ -781,7 +847,8 @@ class admin_entry_commentcenter extends AdminPanelAction {
/** /**
* This function is the callback for the action commspam. * This function is the callback for the action commspam.
* *
* @param string $id: The comment id * @param string $id:
* The comment id
* @return integer: The redirect option * @return integer: The redirect option
*/ */
function docommspam($id) { function docommspam($id) {

View File

@ -13,8 +13,8 @@ function plugin_jquery_head() {
$pdir = plugin_geturl('jquery'); $pdir = plugin_geturl('jquery');
echo ' echo '
<!-- start of jsUtils --> <!-- start of jsUtils -->
<script type="text/javascript" src="' . $pdir . 'res/jquery/3.6/jquery-3.6.0.min.js"></script> <script src="' . $pdir . 'res/jquery/3.6/jquery-3.6.0.min.js"></script>
<script type="text/javascript" src="' . $pdir . 'res/jqueryui/1.13.0/jquery-ui.min.js"></script> <script src="' . $pdir . 'res/jqueryui/1.13.0/jquery-ui.min.js"></script>
<!-- end of jsUtils -->'; <!-- end of jsUtils -->';
} }

View File

@ -29,7 +29,7 @@ function plugin_lightbox2_footer() {
$pdir = plugin_geturl('lightbox2'); $pdir = plugin_geturl('lightbox2');
echo ' echo '
<!-- start of lightbox --> <!-- start of lightbox -->
<script type="text/javascript" src="' . $pdir . 'res/slimbox2.js"></script> <script src="' . $pdir . 'res/slimbox2.js"></script>
<!-- end of lightbox -->'; <!-- end of lightbox -->';
} }
add_action('wp_footer', 'plugin_lightbox2_footer'); add_action('wp_footer', 'plugin_lightbox2_footer');