aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/functions.php
diff options
context:
space:
mode:
authorPaul S. Owen <psotfx@users.sourceforge.net>2003-06-19 16:19:59 +0000
committerPaul S. Owen <psotfx@users.sourceforge.net>2003-06-19 16:19:59 +0000
commitc0a013053a127270a1b9498d847b63ae3a6a25c9 (patch)
tree7619d776a02ada3c4b99c4c4deec9e9e7688a72a /phpBB/includes/functions.php
parenteb6c2c54dfaafa5705d11fce82a70859684fb2f2 (diff)
downloadforums-c0a013053a127270a1b9498d847b63ae3a6a25c9.tar
forums-c0a013053a127270a1b9498d847b63ae3a6a25c9.tar.gz
forums-c0a013053a127270a1b9498d847b63ae3a6a25c9.tar.bz2
forums-c0a013053a127270a1b9498d847b63ae3a6a25c9.tar.xz
forums-c0a013053a127270a1b9498d847b63ae3a6a25c9.zip
Yet more updates, topic marking works again ... still intend (optional) checking of "forum read" status on return to index (rather than just the current fudge of visiting the forum), obtain_ranks as a function (used in at least three scripts), removed jabber method that was needed, oops
git-svn-id: file:///svn/phpbb/trunk@4147 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB/includes/functions.php')
-rw-r--r--phpBB/includes/functions.php87
1 files changed, 74 insertions, 13 deletions
diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php
index d293157bd7..9a0dbd94b0 100644
--- a/phpBB/includes/functions.php
+++ b/phpBB/includes/functions.php
@@ -505,13 +505,12 @@ function markread($mode, $forum_id = 0, $topic_id = 0, $marktime = false)
}
else
{
- $tracking = (isset($_COOKIE[$config['cookie_name'] . '_f'])) ? unserialize(stripslashes($_COOKIE[$config['cookie_name'] . '_f'])) : array();
- if (empty($tracking[$forum_id]) || $tracking[$forum_id] < $current_time)
- {
- $tracking[$forum_id] = $current_time;
- }
+ $tracking = (isset($_COOKIE[$config['cookie_name'] . '_track'])) ? unserialize(stripslashes($_COOKIE[$config['cookie_name'] . '_track'])) : array();
+
+ unset($tracking[$forum_id]);
+ $tracking[$forum_id][0] = base_convert($current_time - $config['board_startdate'], 10, 36);
- setcookie($config['cookie_name'] . '_f', serialize($tracking), time() + 31536000, $config['cookie_path'], $config['cookie_domain'], $config['cookie_secure']);
+ setcookie($config['cookie_name'] . '_track', serialize($tracking), time() + 31536000, $config['cookie_path'], $config['cookie_domain'], $config['cookie_secure']);
unset($tracking);
}
break;
@@ -578,9 +577,9 @@ function markread($mode, $forum_id = 0, $topic_id = 0, $marktime = false)
$db->sql_query($sql);
}
}
- else if (empty($tracking[$row['forum_id']]) || $tracking[$row['forum_id']] < $current_time)
+ else
{
- $tracking[$row['forum_id']] = $current_time;
+ $tracking[$row['forum_id']][0] = base_convert($current_time - $config['board_startdate'], 10, 36);
}
}
while ($row = $db->sql_fetchrow($result));
@@ -590,7 +589,7 @@ function markread($mode, $forum_id = 0, $topic_id = 0, $marktime = false)
if (!$config['load_db_lastread'])
{
- setcookie($config['cookie_name'] . '_f', serialize($tracking), time() + 31536000, $config['cookie_path'], $config['cookie_domain'], $config['cookie_secure']);
+ setcookie($config['cookie_name'] . '_track', serialize($tracking), time() + 31536000, $config['cookie_path'], $config['cookie_domain'], $config['cookie_secure']);
unset($tracking);
}
}
@@ -619,13 +618,34 @@ function markread($mode, $forum_id = 0, $topic_id = 0, $marktime = false)
if (!$config['load_db_lastread'])
{
- $tracking = (isset($_COOKIE[$config['cookie_name'] . '_t'])) ? unserialize(stripslashes($_COOKIE[$config['cookie_name'] . '_t'])) : array();
- if (empty($tracking[$topic_id]) || $tracking[$topic_id] < $current_time)
+ $tracking = array();
+ if (isset($_COOKIE[$config['cookie_name'] . '_track']))
{
- $tracking[$topic_id] = $current_time;
+ $tracking = unserialize(stripslashes($_COOKIE[$config['cookie_name'] . '_track']));
+
+ // If the cookie grows larger than 3000 characters we will remove
+ // the smallest value
+ if (strlen($_COOKIE[$config['cookie_name'] . '_track']) > 3000)
+ {
+ foreach ($tracking as $f => $t_ary)
+ {
+ if (!isset($m_value) || min($t_ary) < $m_value)
+ {
+ $m_value = min($t_ary);
+ $m_tkey = array_search($m_value, $t_ary);
+ $m_fkey = $f;
+ }
+ }
+ unset($tracking[$m_fkey][$m_tkey]);
+ }
}
- setcookie($config['cookie_name'] . '_t', serialize($tracking), time() + 31536000, $config['cookie_path'], $config['cookie_domain'], $config['cookie_secure']);
+ if (base_convert($tracking[$forum_id][0], 36, 10) < $current_time)
+ {
+ $tracking[$forum_id][base_convert($topic_id, 10, 36)] = base_convert($current_time - $config['board_startdate'], 10, 36);
+
+ setcookie($config['cookie_name'] . '_track', serialize($tracking), time() + 31536000, $config['cookie_path'], $config['cookie_domain'], $config['cookie_secure']);
+ }
unset($tracking);
}
break;
@@ -768,6 +788,47 @@ function obtain_icons(&$icons)
return;
}
+// Obtain ranks
+function obtain_ranks(&$ranks)
+{
+ global $db, $cache;
+
+ if ($cache->exists('ranks'))
+ {
+ $ranks = $cache->get('ranks');
+ }
+ else
+ {
+ $sql = 'SELECT *
+ FROM ' . RANKS_TABLE . '
+ ORDER BY rank_min DESC';
+ $result = $db->sql_query($sql);
+
+ $ranks = array();
+ while ($row = $db->sql_fetchrow($result))
+ {
+ if ($row['rank_special'])
+ {
+ $ranks['special'][$row['rank_id']] = array(
+ 'rank_title' => $row['rank_title'],
+ 'rank_image' => $row['rank_image']
+ );
+ }
+ else
+ {
+ $ranks['normal'][] = array(
+ 'rank_title' => $row['rank_title'],
+ 'rank_min' => $row['rank_min'],
+ 'rank_image' => $row['rank_image']
+ );
+ }
+ }
+ $db->sql_freeresult($result);
+
+ $cache->put('ranks', $ranks);
+ }
+}
+
// Obtain allowed extensions
function obtain_attach_extensions(&$extensions)
{