1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-01 20:30:39 +02:00

Remove unused poll cookies. Thanks Fanat1k - bugtracker #4983

This commit is contained in:
nlstart
2010-07-19 09:23:25 +00:00
parent 87fce435f4
commit 13e810c457
2 changed files with 28 additions and 1 deletions

View File

@@ -27,6 +27,32 @@ class poll
var $pollRow;
var $pollmode;
/*
function remove_poll_cookies
Remove unused poll cookies. See: http://krijnhoetmer.nl/stuff/javascript/maximum-cookies/ Thanks Fanat1k - bugtracker #4983
no parameters
*/
function remove_poll_cookies()
{
$arr_polls_cookies = array();
foreach($_COOKIE as $cookie_name => $cookie_val)
{ // Collect poll cookies
list($str, $int) = explode('_', $cookie_name);
if (($str == 'poll') && is_numeric($int))
{ // Yes, its poll's cookie
$arr_polls_cookies[] = $int;
}
}
if (count($arr_polls_cookies) > 1)
{ // Remove all except first (assumption: there is always only one active poll)
rsort($arr_polls_cookies);
for($i = 1; $i < count($arr_polls_cookies); $i++)
{
cookie("poll_{$arr_polls_cookies[$i]}", "", (time() - 2592000));
}
}
}
/*
function delete_poll
parameter in: $existing - existing poll id to be deleted

View File

@@ -61,6 +61,7 @@ WHERE p.poll_type=1{$poll_to_show}
ORDER BY p.poll_datestamp DESC LIMIT 0,1
";
$poll->render_poll($query, $pollType, $pollMode);
$poll->remove_poll_cookies();
$poll->render_poll($query, $pollType, $pollMode);
?>