1
0

* Allow templatechooser plugin to read a custom "blacklist.txt"

within its directory, that can blacklist certain themes from
     being selected.
This commit is contained in:
Garvin Hicking
2015-03-16 14:12:43 +01:00
parent 98cd0e0541
commit 9278c9e40c
2 changed files with 30 additions and 3 deletions

View File

@ -53,6 +53,10 @@ Version 2.1 ()
Version 2.0.2 ()
------------------------------------------------------------------------
* Allow templatechooser plugin to read a custom "blacklist.txt"
within its directory, that can blacklist certain themes from
being selected.
* Allow serendipity_setCookie() function to set custom expiry.
* Adapt .htaccess profile of "mod_rewrite for 1&1 and problematic

View File

@ -14,7 +14,7 @@ class serendipity_event_templatechooser extends serendipity_event
$propbag->add('description', PLUGIN_EVENT_TEMPLATECHOOSER_DESC);
$propbag->add('stackable', false);
$propbag->add('author', 'Evan Nemerson');
$propbag->add('version', '1.4');
$propbag->add('version', '1.5');
$propbag->add('requirements', array(
'serendipity' => '0.8',
'smarty' => '2.6.7',
@ -47,8 +47,31 @@ class serendipity_event_templatechooser extends serendipity_event
}
if (isset($_REQUEST['user_template']) && (in_array($_REQUEST['user_template'], serendipity_fetchTemplates())) ) {
$_SESSION['serendipityUseTemplate'] = $_REQUEST['user_template'];
serendipity_setCookie('user_template', $_REQUEST['user_template'], false);
# Specific themes can be blacklisted for viewing. Enter the names of those, one per line.
$blacklisted = $has_blacklist = false;
if (file_exists(dirname(__FILE__) . '/blacklist.txt')) {
$_blacklist = explode("\n", file_get_contents(dirname(__FILE__) . '/blacklist.txt'));
$blacklist = array();
$has_blacklist = true;
foreach($_blacklist AS $idx => $blackline) {
$blackline = trim($blackline);
if (empty($blackline)) continue;
if ($blackline[0] == '#') continue;
$blacklist[$blackline] = true;
if (preg_match('/' . preg_quote($blackline) . '$/i', $_REQUEST['user_template'])) {
header('X-Theme-Blacklisted: ' . urlencode($blackline));
$blacklisted = true;
}
}
}
if (!$blacklisted) {
$_SESSION['serendipityUseTemplate'] = $_REQUEST['user_template'];
# When blacklisting occurs, the cookie to remember template selection will be removed by closing the browser.
serendipity_setCookie('user_template', $_REQUEST['user_template'], false, ($has_blacklist ? 0 : false));
}
}
// If the requested template is the same as the current default template,