forked from leftypol/leftypol
Edit static pages commit
This commit is contained in:
parent
7911c374e8
commit
95b1e103cb
9 changed files with 328 additions and 6 deletions
|
@ -20,6 +20,7 @@ require_once 'inc/events.php';
|
|||
require_once 'inc/api.php';
|
||||
require_once 'inc/mod/auth.php';
|
||||
require_once 'inc/polyfill.php';
|
||||
//require_once 'inc/lib/parsedown/Parsedown.php'; // we don't need that right now, do we?
|
||||
|
||||
if (!extension_loaded('gettext')) {
|
||||
require_once 'inc/lib/gettext/gettext.inc';
|
||||
|
@ -2739,3 +2740,45 @@ function link_for($post, $page50 = false, $foreignlink = false, $thread = false)
|
|||
|
||||
return sprintf($tpl, $id, $slug);
|
||||
}
|
||||
|
||||
function prettify_textarea($s){
|
||||
return str_replace("\t", '	', str_replace("\n", ' ', htmlentities($s)));
|
||||
}
|
||||
|
||||
class HTMLPurifier_URIFilter_NoExternalImages extends HTMLPurifier_URIFilter {
|
||||
public $name = 'NoExternalImages';
|
||||
public function filter(&$uri, $c, $context) {
|
||||
global $config;
|
||||
$ct = $context->get('CurrentToken');
|
||||
|
||||
if (!$ct || $ct->name !== 'img') return true;
|
||||
|
||||
if (!isset($uri->host) && !isset($uri->scheme)) return true;
|
||||
|
||||
if (!in_array($uri->scheme . '://' . $uri->host . '/', $config['allowed_offsite_urls'])) {
|
||||
error('No off-site links in board announcement images.');
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
function purify_html($s) {
|
||||
global $config;
|
||||
|
||||
$c = HTMLPurifier_Config::createDefault();
|
||||
$c->set('HTML.Allowed', $config['allowed_html']);
|
||||
$uri = $c->getDefinition('URI');
|
||||
$uri->addFilter(new HTMLPurifier_URIFilter_NoExternalImages(), $c);
|
||||
$purifier = new HTMLPurifier($c);
|
||||
$clean_html = $purifier->purify($s);
|
||||
return $clean_html;
|
||||
}
|
||||
|
||||
function markdown($s) {
|
||||
$pd = new Parsedown();
|
||||
$pd->setMarkupEscaped(true);
|
||||
$pd->setimagesEnabled(false);
|
||||
|
||||
return $pd->text($s);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue