summaryrefslogtreecommitdiff
path: root/admin/plugins/filter_htmlpurifier.php
blob: 1a28aa6ca5eb5dbe504fb9a296d8314ae32f8560 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<?php
require_once '../../../kernel/includes/setup_inc.php';
include_once KERNEL_PKG_INCLUDE_PATH . 'simple_form_functions_lib.php';

$gBitSystem->verifyPermission( 'p_admin' );

$htmlPurifier = [
	'htmlpure_escape_bad'         => [
		'label'   => 'Escape invalid HTML',
		'note'    => ' Escapes invlid HTML as text. Otherwise invalid HTML is silently dropped. See <a href="http://htmlpurifier.org/live/configdoc/plain.html#Core.EscapeInvalidTags">this</a> and <a href="http://htmlpurifier.org/live/configdoc/plain.html#Core.EscapeInvalidChildren">this</a> for more information.',
		'default' => 'y',
	],
	'htmlpure_disable_extern'     => [
		'label'   => 'Disable External Links',
		'note'    => 'Disables links to external websites which is effective against spam. See <a href="http://htmlpurifier.org/live/configdoc/plain.html#URI.DisableExternal">this</a> for more information.',
		'default' => 'n',
	],
	'htmlpure_disable_extern_res' => [
		'label'   => 'Disable External Resounces',
		'note'    => 'Disables the embedding of external resource like images from other hosts. See <a href="http://htmlpurifier.org/live/configdoc/plain.html#URI.DisableExternalResources">this</a> for more information.',
		'default' => 'y',
	],
	'htmlpure_disable_res'        => [
		'label'   => 'Disable All Resources',
		'note'    => 'Disables the embedding of all resources preventing users from including pictures at all. See <a href="http://htmlpurifier.org/live/configdoc/plain.html#URI.DisableResources">this</a> for more information.',
		'default' => 'n',
	],
	'htmlpure_disable_uri'        => [
		'label'   => 'Disable all URIs',
		'note'    => 'Disables all URIs in all forms within submitted content. See <a href="http://htmlpurifier.org/live/configdoc/plain.html#URI.Disable">this</a> for more information.',
		'default' => 'n',
	],
	'htmlpure_use_redirect'       => [
		'label'   => 'Use Redirect',
		'note'    => 'Uses the redirect service in the Redirect URI. This can be handy to track clicks out and prevent leacks of PageRank. See <a href="http://htmlpurifier.org/live/configdoc/plain.html#URI.Munge">this</a> for more information.',
		'default' => 'n',
	],
	'htmlpure_strict_html'        => [
		'label'   => 'Force Strict',
		'note'    => 'Determines if the purification matches the Transitional or Strict rule sets. See <a href="http://htmlpurifier.org/live/configdoc/plain.html#HTML.Strict">this</a> for more information.',
		'default' => 'y',
	],
	'htmlpure_xhtml'              => [
		'label'   => 'Force XHTML',
		'note'    => 'Determine if purification forces only XHTML tags or if it allows standard HTML.',
		'default' => 'y',
	],
	// TODO: We should parse the plugins directory to generate these
	// so that new plugins just have to be dropped in the dir and turned on.
	'htmlpure_allow_youtube'      => [
		'label'   => 'Allow YouTube',
		'note'    => 'Allow YouTube videos to be passed through.',
		'default' => 'n',
	],
	'htmlpure_allow_cnbc'         => [
		'label'   => 'Allow CNBC',
		'note'    => 'Allow CNBC videos to be passed through.',
		'default' => 'n',
	],
	'htmlpure_force_nofollow'     => [
		'label'   => 'Force No Follow',
		'note'    => 'Force all anchor tags to have rel=nofollow in them. Many search engines respect this in order to give sites a way to try to avoid link spammers.',
		'default' => 'y',
	],
];
$gBitSmarty->assign( 'htmlPurifier', $htmlPurifier );

if( !empty( $_REQUEST['apply'] )) {
	$formFeatures = array_merge( $htmlPurifier );
	foreach( $formFeatures as $item => $data ) {
		simple_set_toggle( $item, LIBERTY_PKG_NAME );
	}
	$errors = [];
	if( !empty($_REQUEST['blacklisted_html_tags'] )) {
		$tags = preg_replace( '/\s/', '', $_REQUEST['blacklisted_html_tags'] );
		if( strlen( $tags ) > 250 ) {
			$tags = substr( $tags, 0, 250 );
			$errors['blacklist'] = 'The blacklisted tags list has been shortened. You can only have 250 characters for blacklisted tags.';
		}
		$gBitSystem->storeConfig('blacklisted_html_tags', $tags , LIBERTY_PKG_NAME );
	}
	$gBitSmarty->assign($errors);
}

$gBitSystem->display( 'bitpackage:liberty/plugins/filter_htmlpurifier_admin.tpl', 'HTML Purifier' , [ 'display_mode' => 'admin' ]);