* 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:
@ -53,6 +53,10 @@ Version 2.1 ()
|
|||||||
Version 2.0.2 ()
|
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.
|
* Allow serendipity_setCookie() function to set custom expiry.
|
||||||
|
|
||||||
* Adapt .htaccess profile of "mod_rewrite for 1&1 and problematic
|
* Adapt .htaccess profile of "mod_rewrite for 1&1 and problematic
|
||||||
|
@ -14,7 +14,7 @@ class serendipity_event_templatechooser extends serendipity_event
|
|||||||
$propbag->add('description', PLUGIN_EVENT_TEMPLATECHOOSER_DESC);
|
$propbag->add('description', PLUGIN_EVENT_TEMPLATECHOOSER_DESC);
|
||||||
$propbag->add('stackable', false);
|
$propbag->add('stackable', false);
|
||||||
$propbag->add('author', 'Evan Nemerson');
|
$propbag->add('author', 'Evan Nemerson');
|
||||||
$propbag->add('version', '1.4');
|
$propbag->add('version', '1.5');
|
||||||
$propbag->add('requirements', array(
|
$propbag->add('requirements', array(
|
||||||
'serendipity' => '0.8',
|
'serendipity' => '0.8',
|
||||||
'smarty' => '2.6.7',
|
'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())) ) {
|
if (isset($_REQUEST['user_template']) && (in_array($_REQUEST['user_template'], serendipity_fetchTemplates())) ) {
|
||||||
|
|
||||||
|
# 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'];
|
$_SESSION['serendipityUseTemplate'] = $_REQUEST['user_template'];
|
||||||
serendipity_setCookie('user_template', $_REQUEST['user_template'], false);
|
# 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,
|
// If the requested template is the same as the current default template,
|
||||||
|
Reference in New Issue
Block a user