=IFNULL(lv.lv_markall,0) AND tv.tid IS NULL "; else $sqldata=" AND p__time>=IFNULL(lv.lv_time2,0) AND p_uid<>".$GLOBALS['inuserid']." "; if (getvar("fs")) $forumlimit=" AND (f_id=\"".getvar("fs")."\" OR f_parent=\"".getvar("fs")."\") "; $time=getvar("time"); if (!isset($_GET['time'])) $time=$GLOBALS['inuser']['u_timelimit']; else $timelimit=$GLOBALS['curtime']-$time*24*60*60; $sql = "SELECT f_title, f_id, f_link, f_lread, ua_level, lv_time2 AS lvtime ". "FROM ".$GLOBALS['DBprefix']."Category, ".$GLOBALS['DBprefix']."Forum ". "LEFT JOIN ".$GLOBALS['DBprefix']."LastVisit lv ON (lv.fid=f_id AND lv.uid=".$GLOBALS['inuserid'].") ". "LEFT JOIN ".$GLOBALS['DBprefix']."UserAccess ua ON (ua.fid=f_id AND ua.uid=".$GLOBALS['inuserid'].") ". "WHERE f_ctid=ct_id ".$forumlimit." ORDER BY ct_sortfield, f_sortfield"; $res=db_query($sql,$link); $forums = array(); $fids=array(); while ($tmp=db_fetch_array($res)) { if (($tmp['ua_level']!=NULL && $tmp['f_lread']<=$tmp['ua_level']) || $tmp['f_lread']<=$GLOBALS['inuserbasic']) { $forums[]=$tmp; $fids[]=$tmp['f_id']; } } if (count($fids)) $flist=' AND t_fid IN ('.join(',',$fids).')'; if ($timelimit>0) $timelimit=' AND p__time>'.$timelimit; $sql = "SELECT p_uname,p_uid,p__time,t_title,t_link,t_id,t_fid, SUBSTRING(p_text,1,".(intval($GLOBALS['opt_hinttext'])+1).") AS hint FROM ". $GLOBALS['DBprefix']."Post, ".$GLOBALS['DBprefix']."Topic ". "LEFT JOIN ".$GLOBALS['DBprefix']."TopicView tv ON (tv.tid=t_id AND tv.uid=".$GLOBALS['inuserid'].") ". "LEFT JOIN ".$GLOBALS['DBprefix']."LastVisit lv ON (lv.fid=t_fid AND lv.uid=".$GLOBALS['inuserid'].") ". "WHERE t__pcount>0 $timelimit AND t__lastpostid=p_id ".$flist.' '. $sqldata." ORDER BY t__lastpostid DESC"; $res = db_query($sql,$link); new_start($time,MSG_newposts); $oldforum=0; $newtopics=array(); while ($newdata=db_fetch_array($res)) { $newtopics[]=$newdata; } db_free_result($res); $fcount=count($forums); for ($i=0;$i<$fcount; $i++) { $f=0; $tcount=count($newtopics); for ($j=0;$j<$tcount; $j++) { if ($newtopics[$j]['t_fid']==$forums[$i]['f_id']) { if ($f==0) { new_forum($forums[$i]); $f=1; } new_entry(array_merge($newtopics[$j],$forums[$i])); } } } if (count($newtopics)==0) new_noentries(); new_end(); } function view_unanswered() { global $link; if (getvar("fs")) $forumlimit=" AND (f_id=\"".getvar("fs")."\" OR f_parent=\"".getvar("fs")."\") "; $time=getvar("time"); if (!isset($_GET['time'])) $time=$GLOBALS['inuser']['u_timelimit']; if ($time>0) $timelimit=' AND p__time>'.($GLOBALS['curtime']-$time*24*60*60); $sql = "SELECT f_title, f_id, f_link, f_lread, ua_level, lv_time2 AS lvtime ". "FROM ".$GLOBALS['DBprefix']."Category, ".$GLOBALS['DBprefix']."Forum ". "LEFT JOIN ".$GLOBALS['DBprefix']."LastVisit lv ON (lv.fid=f_id AND lv.uid=".$GLOBALS['inuserid'].") ". "LEFT JOIN ".$GLOBALS['DBprefix']."UserAccess ua ON (ua.fid=f_id AND ua.uid=".$GLOBALS['inuserid'].") ". "WHERE f_ctid=ct_id ".$forumlimit." ORDER BY ct_sortfield, f_sortfield"; $res=db_query($sql,$link); $forums = array(); $fids=array(); while ($tmp=db_fetch_array($res)) { if (($tmp['ua_level']!=NULL && $tmp['f_lread']<=$tmp['ua_level']) || $tmp['f_lread']<=$GLOBALS['inuserbasic']) { $forums[]=$tmp; $fids[]=$tmp['f_id']; } } if (count($fids)) $flist=' AND t_fid IN ('.join(',',$fids).')'; $sql = "SELECT p_uname,p_uid,p__time,t_title,t_link,t_id,t_fid, SUBSTRING(p_text,1,".(intval($GLOBALS['opt_hinttext'])+1).") AS hint FROM ". $GLOBALS['DBprefix']."Post, ".$GLOBALS['DBprefix']."Topic ". "LEFT JOIN ".$GLOBALS['DBprefix']."TopicView tv ON (tv.tid=t_id AND tv.uid=".$GLOBALS['inuserid'].") ". "LEFT JOIN ".$GLOBALS['DBprefix']."LastVisit lv ON (lv.fid=t_fid AND lv.uid=".$GLOBALS['inuserid'].") ". "WHERE t__lastpostid=p_id ".$flist.' '. " AND t__pcount=1 $timelimit ORDER BY t__lastpostid DESC"; $res = db_query($sql,$link); new_start($time,MSG_t_unanswered); $oldforum=0; $newtopics=array(); while ($newdata=db_fetch_array($res)) { $newtopics[]=$newdata; } db_free_result($res); $fcount=count($forums); for ($i=0;$i<$fcount; $i++) { $f=0; $tcount=count($newtopics); for ($j=0;$j<$tcount; $j++) { if ($newtopics[$j]['t_fid']==$forums[$i]['f_id']) { if ($f==0) { new_forum($forums[$i]); $f=1; } new_entry(array_merge($newtopics[$j],$forums[$i])); } } } if (count($newtopics)==0) new_noentries(); new_end(); } function do_mark_read() { global $link; $forum =getvar("fs"); if ($GLOBALS['inuserid']<=3) error(MSG_e_new_noguest); if ($GLOBALS['opt_fixviews']==1) { if ($forum) { $sql = "SELECT t_id FROM ".$GLOBALS['DBprefix']."Topic WHERE t_fid=\"$forum\""; $res = db_query($sql,$link); while ($tmp=db_fetch_row($res)) { if ($forumlimit) $forumlimit.=" OR "; $forumlimit.="tid=".$tmp[0]; } db_free_result($res); $forumlimit="AND ($forumlimit)"; } $sql = "DELETE FROM ".$GLOBALS['DBprefix']."TopicView WHERE uid=".$GLOBALS['inuserid']." $forumlimit"; $res = db_query($sql,$link); } if ($forum) { $forumlimit=" AND fid=\"$forum\""; $forumlimit2=" WHERE f_id=\"$forum\""; } $sql = "DELETE FROM ".$GLOBALS['DBprefix']."LastVisit WHERE uid=".$GLOBALS['inuserid'].$forumlimit; $res = db_query($sql,$link); $sql = "INSERT INTO ".$GLOBALS['DBprefix']."LastVisit (uid,fid,lv_time1,lv_time2,lv_markall,lv_markcount) ". "SELECT ".$GLOBALS['inuserid'].",f_id,".$GLOBALS['curtime'].",".$GLOBALS['curtime'].",".$GLOBALS['curtime'].", f__tcount FROM ".$GLOBALS['DBprefix']."Forum ".$forumlimit2; $res = db_query($sql,$link); message(MSG_f_marked,1); } function view_updated() { global $link; if (getvar("fs")) $forumlimit=" AND (f_id=\"".getvar("fs")."\" OR f_parent=\"".getvar("fs")."\") "; $time=getvar("time"); if (!isset($_GET['time'])) $time=$GLOBALS['inuser']['u_timelimit']; if (!$GLOBALS['opt_updated_time']) $GLOBALS['opt_updated_time']=30; if (!$time) $time=$GLOBALS['opt_updated_time']; $timelimit=$GLOBALS['curtime']-$time*24*60*60; $sql = "SELECT COUNT(*) FROM ".$GLOBALS['DBprefix']."Post, ". "".$GLOBALS['DBprefix']."Topic ". "LEFT JOIN ".$GLOBALS['DBprefix']."LastVisit lv ON (lv.fid=t_fid AND lv.uid=".$GLOBALS['inuserid'].") ". "WHERE p__time>$timelimit AND ".check_access('t_fid')." AND p__premoderate=0 AND t__lastpostid=p_id ". $sqldata.$forumlimit; $res=db_query($sql,$link); list($count)=db_fetch_row($res); db_free_result($res); $start=getvar('st'); $perpage=$GLOBALS['inuser']['u_tperpage']; $pages=build_pages($count,$start,$perpage,"index.php?m=newpost&a=view_updated&time=$time&fs=$forum"); if ($start!="all") $limit="LIMIT ".intval($start).",$perpage"; $sql = "SELECT t.*, f_id, f_title, f_link, p1.p_uid, p1.p_uname, p1.p__time AS fp__time, p2.p_uname AS lp_uname, ". "p2.p__html, p2.p__bcode, p2.p__smiles, lv_markall, ". "p2.p_uid AS lp_uid, p2.p__time AS lp__time, t.t__ratingsum/NULLIF(t__ratingcount,0) AS trating, ". "tv.tid AS visited, t__pcount AS tl_count, SUBSTRING(p2.p_text,1,".(intval($GLOBALS['opt_hinttext'])+20).") AS hint ". "FROM ".$GLOBALS['DBprefix']."Post p1, ".$GLOBALS['DBprefix']."Post p2, ".$GLOBALS['DBprefix']."Topic t ". "LEFT JOIN ".$GLOBALS['DBprefix']."Forum ON (t_fid=f_id) ". "LEFT JOIN ".$GLOBALS['DBprefix']."TopicView tv ON (tv.uid=".$GLOBALS['inuserid']." AND tv.tid=t_id) ". "LEFT JOIN ".$GLOBALS['DBprefix']."LastVisit lv ON (lv.fid=t_fid AND lv.uid=".$GLOBALS['inuserid'].") ". "WHERE p1.p_id=t__startpostid AND p2.p_id=t__lastpostid AND ". "p2.p__time>$timelimit AND ".check_access('t_fid')." AND t__pcount>0 ". $sqldata.$forumlimit. "ORDER BY p2.p__time DESC $limit"; $res = db_query($sql,$link); upd_start($time,$pages); while ($newdata=db_fetch_array($res)) { $tpages = build_pages_hurl($newdata['t__pcount'],-1,$GLOBALS['inuser']['u_mperpage'],$newdata,""); upd_entry($newdata,$tpages); } if (db_num_rows($res)==0) upd_noentries(); db_free_result($res); upd_end($pages); } function do_unmark_read() { global $link; $tid = intval(getvar('ts')); $sql = 'DELETE FROM '.$GLOBALS['DBprefix'].'TopicView WHERE tid='.$tid.' AND uid='.$GLOBALS['inuserid']; $res=db_query($sql,$link); $GLOBALS['refpage']=build_url($GLOBALS['inforum']); message(MSG_t_unmarked,1); } function locations(&$locations) { if ($GLOBALS['forum']) { push_parents($locations,$GLOBALS['inforum']['f_parent']); array_push($locations,"".$GLOBALS['inforum']['f_title'].""); } if ($GLOBALS['action']=="view") $GLOBALS['rss_link']="rss.php?a=last_topics"; if ($GLOBALS['action']=="view_updated") $GLOBALS['rss_link']="rss.php?a=allnew&days=3"; if ($GLOBALS['action']=="view") array_push($locations,MSG_f_newposts); elseif ($GLOBALS['action']=="view_unanswered") array_push($locations,MSG_t_unanswered); elseif ($GLOBALS['action']=="view_updated") array_push($locations,MSG_t_updated); return $locations; }