AN-net
07-19-2004, 02:51 AM
ok well im trying to it state how many people are viewing a journal just like vb's how many are viewing a forum that it lists on the forum index "(6 viewing)".
Well the problem here is that when one person views a journal it shows on the journal index that he/she is viewing all of them. I cant find a logical reason why it does this
here are bits of my code:
require_once('./includes/functions_bigthree.php');
$datecut = TIMENOW - $vboptions['cookietimeout'];
$browsers = '';
$comma = '';
// Don't put the inthread value in the WHERE clause as it might not be the newest location!
$journalusers = $DB_site->query("
SELECT user.username, user.usergroupid, user.membergroupids,
session.userid, session.inthread, session.injournal, session.location, session.lastactivity,
IF(user.displaygroupid = 0, user.usergroupid, user.displaygroupid) AS displaygroupid,
IF(user.options & $_USEROPTIONS[invisible], 1, 0) AS invisible
FROM " . TABLE_PREFIX . "session AS session
LEFT JOIN " . TABLE_PREFIX . "user AS user ON(user.userid = session.userid)
WHERE session.lastactivity > $datecut
ORDER BY " . iif($permissions['genericpermissions'] & CANSEEHIDDEN, 'invisible ASC, ') . "username ASC, lastactivity DESC
");
$numberguest = 0;
$numberregistered = 0;
$doneuser = array();
if ($bbuserinfo['userid']) // fakes the user being in this thread
{
$bbuserinfo['joingroupid'] = iif($bbuserinfo['displaygroupid'], $bbuserinfo['displaygroupid'], $bbuserinfo['usergroupid']);
$loggedin = array(
'userid' => $bbuserinfo['userid'],
'username' => $bbuserinfo['username'],
'invisible' => $bbuserinfo['invisible'],
'invisiblemark' => $bbuserinfo['invisiblemark'],
'inthread' => $threadinfo['threadid'],
'lastactivity' => TIMENOW,
'musername' => fetch_musername($bbuserinfo, 'joingroupid')
);
$numberregistered = 1;
$numbervisible = 1;
fetch_online_status($loggedin);
eval('$activeusers = "' . fetch_template('forumdisplay_loggedinuser') . '";');
$doneuser["$bbuserinfo[userid]"] = 1;
$comma = ', ';
}
//$injournal= array();
// this requires the query to have lastactivity ordered by DESC so that the latest location will be the first encountered.
while ($loggedin = $DB_site->fetch_array($journalusers))
{
if (empty($doneuser["$loggedin[userid]"]))
{
if ($loggedin['userid'] == 0) // Guest
{
if($loggedin['location']=="/journal.php" OR $loggedin['location']=="/journal.php?do=showindex")
{
$numberguest++;
}
}
else
{
if($loggedin['location']=="/journal.php" OR $loggedin['location']=="/journal.php?do=showindex")
{
$loggedin['musername'] = fetch_musername($loggedin);
$numberregistered++;
if (fetch_online_status($loggedin))
{
eval('$activeusers .= "' . $comma . fetch_template('forumdisplay_loggedinuser') . '";');
$comma = ', ';
}
}
}
if ($loggedin['userid'])
{
$doneuser["$loggedin[userid]"] = 1;
}
if(!empty($loggedin['injournal']))
{
$injournal['id']= $loggedin['injournal'];
$injournal[$loggedin['injournal']]++;
}
}
}
global $injournal;
$totalviewing = $numberregistered + $numberguest;
and here is another bit
while($journal= $DB_site->fetch_array($fjournals))
{
if(empty($journal['totalrating']) OR empty($journal['totalvotes']))
{
$rating= "0";
}
else
{
$calcrating= $journal['totalrating']/$journal['totalvotes'];
$rating= round($calcrating);
}
if($injournal['id']==$journal['journal_id'])
{
$viewing= $injournal[$injournal['id']];
}
if($journal['private']==1)
{
$show['privatelock']= true;
}
else
{
$show['privatelock']= false;
}
if($bbuserinfo['lastvisit']<$journal['lastentry_date'])
{
$show['newentryicon']= true;
}
$lastedate= vbdate($vboptions['dateformat'], $journal['lastentry_date'], 1);
$lastetime= vbdate($vboptions['timeformat'], $journal['lastentry_date']);
exec_switch_bg();
if(strlen($journal[journaldesc])>30)
{
$journal[journaldesc]= "".substr($journal[journaldesc],0,30)."...";
}
eval('$journalbits .= "' . fetch_template('journal_journalbits') . '";');
}
i set it up so if the injournal isnt empty it wont both making $injournal['id'] and start counting, in the while query for grabbing the actual journals i made an if statement so that if the $injournal['id'] equals the $journal['journal_id'] it wont display anything for views but for somereason it takes the id of just one journal and says it equal to all of them even though the injournal id from the sessions table is 7
i hope i make sense:(
anyways thanks in advance
Well the problem here is that when one person views a journal it shows on the journal index that he/she is viewing all of them. I cant find a logical reason why it does this
here are bits of my code:
require_once('./includes/functions_bigthree.php');
$datecut = TIMENOW - $vboptions['cookietimeout'];
$browsers = '';
$comma = '';
// Don't put the inthread value in the WHERE clause as it might not be the newest location!
$journalusers = $DB_site->query("
SELECT user.username, user.usergroupid, user.membergroupids,
session.userid, session.inthread, session.injournal, session.location, session.lastactivity,
IF(user.displaygroupid = 0, user.usergroupid, user.displaygroupid) AS displaygroupid,
IF(user.options & $_USEROPTIONS[invisible], 1, 0) AS invisible
FROM " . TABLE_PREFIX . "session AS session
LEFT JOIN " . TABLE_PREFIX . "user AS user ON(user.userid = session.userid)
WHERE session.lastactivity > $datecut
ORDER BY " . iif($permissions['genericpermissions'] & CANSEEHIDDEN, 'invisible ASC, ') . "username ASC, lastactivity DESC
");
$numberguest = 0;
$numberregistered = 0;
$doneuser = array();
if ($bbuserinfo['userid']) // fakes the user being in this thread
{
$bbuserinfo['joingroupid'] = iif($bbuserinfo['displaygroupid'], $bbuserinfo['displaygroupid'], $bbuserinfo['usergroupid']);
$loggedin = array(
'userid' => $bbuserinfo['userid'],
'username' => $bbuserinfo['username'],
'invisible' => $bbuserinfo['invisible'],
'invisiblemark' => $bbuserinfo['invisiblemark'],
'inthread' => $threadinfo['threadid'],
'lastactivity' => TIMENOW,
'musername' => fetch_musername($bbuserinfo, 'joingroupid')
);
$numberregistered = 1;
$numbervisible = 1;
fetch_online_status($loggedin);
eval('$activeusers = "' . fetch_template('forumdisplay_loggedinuser') . '";');
$doneuser["$bbuserinfo[userid]"] = 1;
$comma = ', ';
}
//$injournal= array();
// this requires the query to have lastactivity ordered by DESC so that the latest location will be the first encountered.
while ($loggedin = $DB_site->fetch_array($journalusers))
{
if (empty($doneuser["$loggedin[userid]"]))
{
if ($loggedin['userid'] == 0) // Guest
{
if($loggedin['location']=="/journal.php" OR $loggedin['location']=="/journal.php?do=showindex")
{
$numberguest++;
}
}
else
{
if($loggedin['location']=="/journal.php" OR $loggedin['location']=="/journal.php?do=showindex")
{
$loggedin['musername'] = fetch_musername($loggedin);
$numberregistered++;
if (fetch_online_status($loggedin))
{
eval('$activeusers .= "' . $comma . fetch_template('forumdisplay_loggedinuser') . '";');
$comma = ', ';
}
}
}
if ($loggedin['userid'])
{
$doneuser["$loggedin[userid]"] = 1;
}
if(!empty($loggedin['injournal']))
{
$injournal['id']= $loggedin['injournal'];
$injournal[$loggedin['injournal']]++;
}
}
}
global $injournal;
$totalviewing = $numberregistered + $numberguest;
and here is another bit
while($journal= $DB_site->fetch_array($fjournals))
{
if(empty($journal['totalrating']) OR empty($journal['totalvotes']))
{
$rating= "0";
}
else
{
$calcrating= $journal['totalrating']/$journal['totalvotes'];
$rating= round($calcrating);
}
if($injournal['id']==$journal['journal_id'])
{
$viewing= $injournal[$injournal['id']];
}
if($journal['private']==1)
{
$show['privatelock']= true;
}
else
{
$show['privatelock']= false;
}
if($bbuserinfo['lastvisit']<$journal['lastentry_date'])
{
$show['newentryicon']= true;
}
$lastedate= vbdate($vboptions['dateformat'], $journal['lastentry_date'], 1);
$lastetime= vbdate($vboptions['timeformat'], $journal['lastentry_date']);
exec_switch_bg();
if(strlen($journal[journaldesc])>30)
{
$journal[journaldesc]= "".substr($journal[journaldesc],0,30)."...";
}
eval('$journalbits .= "' . fetch_template('journal_journalbits') . '";');
}
i set it up so if the injournal isnt empty it wont both making $injournal['id'] and start counting, in the while query for grabbing the actual journals i made an if statement so that if the $injournal['id'] equals the $journal['journal_id'] it wont display anything for views but for somereason it takes the id of just one journal and says it equal to all of them even though the injournal id from the sessions table is 7
i hope i make sense:(
anyways thanks in advance