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">
<head>
<title>{$flatpress.title}{$pagetitle}</title>

View File

@ -1,10 +1,9 @@
<?php
// require_once('../init.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">
<head>
<title>FlatPress</title>

View File

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

View File

@ -16,7 +16,7 @@
/*
* function admin_plugin_adminheader() {
* $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
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');
class admin_widgets_default extends AdminPanelAction {
// 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) {
if (!isset($wlist [$wpos]))
return;
@ -22,11 +22,10 @@
$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;
if (isset($registered_w [$newid])) {
$thiswdg = $registered_w [$newid];
@ -43,7 +42,6 @@
* in the template
*
*/
} else {
global $lang;
@ -53,30 +51,22 @@
$errs = sprintf($lang ['admin'] ['widgets'] ['errors'] ['generic'], $newid);
$this->smarty->append('warnings', $errs);
}
}
if (!$widget_list [$wpos] && !$add_empties)
unset($widget_list [$wpos]);
}
function main() {
lang_load('admin.widgets');
# $this->smarty->assign('warnings', admin_widgets_checkall());
// $this->smarty->assign('warnings', admin_widgets_checkall());
global $fp_widgets;
$registered_w = get_registered_widgets();
$registered_ws = get_registered_widgetsets(null);
$this->smarty->assign('fp_registered_widgets', $registered_w);
$wlist = $fp_widgets->getList();
$widget_list = array();
@ -87,7 +77,6 @@
$this->get_widget_lists($wlist, $wpos, $widget_list, $registered_w, true);
unset($wlist [$wpos]);
}
$oldwidget_list = array();
@ -98,26 +87,20 @@
$this->smarty->assign('widgetlist', $widget_list);
$this->smarty->assign('oldwidgetlist', $oldwidget_list);
$conf = io_load_file(CONFIG_DIR . 'widgets.conf.php');
$this->smarty->assign('pluginconf', $conf);
return 0;
}
function onsave() {
$fp_widgets = isset($_POST ['widgets']) ? $_POST ['widgets'] : array();
$success = system_save(CONFIG_DIR . 'widgets.conf.php', compact('fp_widgets'));
$this->smarty->assign('success', ($success) ? 1 : -1);
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">
<head>
<title>{$flatpress.title}{$pagetitle}</title>

View File

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

View File

@ -780,7 +780,7 @@ function plugin_bbcode_toolbar() {
// $bblang = lang_load('plugin:bbcode');
// $_FP_SMARTY->assign('bblang', $bblang);
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 "<!-- end of bbcode plugin -->\n";
}

View File

@ -2,21 +2,47 @@
/**
* This is the administration panel for the plugin Flatpress Comment Center.
*/
if (!class_exists('plugin_commentcenter')) {
die('Don\'t try to hack us.');
}
class admin_entry_commentcenter extends AdminPanelAction {
# The language files
// The language files
var $langres = 'plugin:commentcenter';
# The commands
var $commands=array('configure', 'polup', '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');
// The commands
var $commands = array(
'configure',
'polup',
'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.
@ -28,21 +54,32 @@ class admin_entry_commentcenter extends AdminPanelAction {
$this->plugin = &$GLOBALS ['plugin_commentcenter'];
$smarty = &$this->smarty;
# The default TPL
// The default TPL
$smarty->assign('admin_resource', 'plugin:commentcenter/policies');
$smarty->assign('plugin_url', plugin_geturl('commentcenter'));
$smarty->register_modifier('idToSubject', array(&$this, '_idToTitle'));
add_filter('wp_title', array(&$this, '_title'), 15, 2);
add_action('wp_head', array(&$this, '_head'), 10);
$smarty->register_modifier('idToSubject', array(
&$this,
'_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.
* It sets the title.
*
* @param string $val: The current title
* @param string $sep: The separator
* @param string $val:
* The current title
* @param string $sep:
* The separator
* @return string: The title
*/
function _title($val, $sep) {
@ -59,19 +96,25 @@ class admin_entry_commentcenter extends AdminPanelAction {
}
$src1 = plugin_geturl('commentcenter') . 'res/ajax.js';
$src2 = BLOG_BASEURL . 'admin.php?jslang=commentcenter';
echo '<script type="text/javascript" src="'.$src1."\"></script>\n";
echo '<script type="text/javascript" src="'.$src2."\"></script>\n";
echo '<script src="' . $src1 . "\"></script>\n";
echo '<script src="' . $src2 . "\"></script>\n";
}
/**
* This function return the entry title from the id.
* It's made to be called from Smarty.
*
* @param string $id: The entry id
* @param string $id:
* The entry id
* @return string: The output
*/
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()) {
return false;
}
@ -82,9 +125,12 @@ class admin_entry_commentcenter extends AdminPanelAction {
/**
* This function is an advanced redirect option.
*
* @param string $cmd: The command
* @param mixed $cmdval: The value for the command
* @param boolean $nosuccess: Don't save the success?
* @param string $cmd:
* The command
* @param mixed $cmdval:
* The value for the command
* @param boolean $nosuccess:
* Don't save the success?
*/
function _redirect($cmd, $cmdval = 1, $nosuccess = false) {
global $panel;
@ -96,7 +142,7 @@ class admin_entry_commentcenter extends AdminPanelAction {
$url = html_entity_decode($url);
$url = substr($url, strlen(BLOG_BASEURL));
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']),
'akismet_check' => isset($_POST ['akismet_check']),
'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...
foreach ($save as $key => $value) {
plugin_addoption('commentcenter', $key, $value);
@ -160,7 +208,8 @@ class admin_entry_commentcenter extends AdminPanelAction {
/**
* 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
*/
function dopoledit($id) {
@ -177,7 +226,7 @@ class admin_entry_commentcenter extends AdminPanelAction {
if ($id != -1 && isset($plugin->policies [$id])) {
$smarty->assign('policy', $plugin->policies [$id]);
} elseif ($id != -1) {
# Inexistent policy
// Inexistent policy
$smarty->assign('errors', $plang ['errors'] ['pol_nonex']);
} else {
$smarty->assign('polnew', true);
@ -247,7 +296,7 @@ class admin_entry_commentcenter extends AdminPanelAction {
$policy ['is_all'] = false;
}
if (is_numeric($_POST ['older'])) {
# Save in seconds
// Save in seconds
$policy ['older'] = $_POST ['older'] * 86400;
$policy ['is_all'] = false;
}
@ -278,7 +327,8 @@ class admin_entry_commentcenter extends AdminPanelAction {
/**
* 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
*/
function dopoldelete($id) {
@ -289,7 +339,9 @@ class admin_entry_commentcenter extends AdminPanelAction {
$plugin->loadPolicies();
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);
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
*/
@ -367,7 +420,8 @@ class admin_entry_commentcenter extends AdminPanelAction {
/**
* 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
*/
function dopolup($id) {
@ -387,7 +441,8 @@ class admin_entry_commentcenter extends AdminPanelAction {
/**
* 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
*/
function dopoldown($id) {
@ -428,9 +483,12 @@ class admin_entry_commentcenter extends AdminPanelAction {
/**
* This function is the callback for the publishcomm command
*
* @param string $id: The comment id
* @param boolean $noredirect: If true, don't redirect
* @param boolean $noham: If it was blocked from Akismet, don't submit as ham
* @param string $id:
* The comment id
* @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
*/
function dopublishcomm($id, $noredirect = false, $noham = false) {
@ -466,14 +524,16 @@ class admin_entry_commentcenter extends AdminPanelAction {
}
$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;
$smarty->assign('success', $succ);
if ($succ == 5) {
@unlink($f);
}
}
if ($noredirect) {
@ -487,7 +547,8 @@ class admin_entry_commentcenter extends AdminPanelAction {
/**
* 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.
*/
function dopubnoham($id) {
@ -522,7 +583,8 @@ class admin_entry_commentcenter extends AdminPanelAction {
/**
* 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
*/
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
*/
@ -624,7 +687,8 @@ class admin_entry_commentcenter extends AdminPanelAction {
/**
* 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
*/
function domanage($entry) {
@ -678,7 +742,8 @@ class admin_entry_commentcenter extends AdminPanelAction {
/**
* 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
*/
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
*/
@ -781,7 +847,8 @@ class admin_entry_commentcenter extends AdminPanelAction {
/**
* 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
*/
function docommspam($id) {

View File

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

View File

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