• OzzModz is no longer taking registrations. All registrations are being redirected to Snog's Site
    All addons and support is available there now.

Forum Icon Issues

HM666

New member
I had posted about this on vbulletin.org some time ago but never got a response that worked. I have a client that has a strange forum icon problem. They are running vBulletin 4.2.2, PHP 5.4.33, & MySQL 5.5.42.

Here is the problem:

When you are viewing the forum from the FORUMHOME all the icons will appear as marked read when they are not. Even if there are new threads in a forum area the icons still show as read unless:

1. You are not logged in or viewing as a guest.
2. You have cleared your browser cache (and then this only lasts until you click on a forum area to read the new threads or posts once you do that and go back to the FORUMHOME all the icons are marked read again.)
3. I clear the site cache (and again the same thing happens as in number 2 above)
4. You logout and then login again. (again after clicking a forum link it goes back to read)

Things I've tried so far:

1. Disabled all mods globally.
2. Cleared the cache numerous times.
3. Disabled the mods & then cleared the cache.
4. Adding the optimization for the htaccess file from this site.
5. Had the host upgrade from PHP 5.3 to PHP 5.4.

Through the months I've tried other things but I cannot remember them right off, but they did not work. Any help would be great.
 
The mark_forums_read() function in includes/functions_misc.php will mark all threads read if no forumid arguments are given and is what appears to be happening here. These are the only locations I can find that are calling the function.

Code:
ajax.php:686:   $mark_read_result = mark_forums_read($foruminfo['forumid']);
forumdisplay.php:127:   $mark_read_result = mark_forums_read($foruminfo['forumid']);
forumrunner/include/misc.php:49:    mark_forums_read($foruminfo['forumid']);
and the function is located at
Code:
includes/functions_misc.php:441:function mark_forums_read($forumid = false)

It may be possible that something in the login script is firing the function in the ajax.php. I'm thinking maybe putting a couple debug statements in these locations with some tell-tale notes/var_dumps may show where this function is being called from. You can try commentting out the ajax.php function and see if the behaviour stops, then trace from there.
 
Ok I can try commenting that out but as far as creating PHP code to do other things I'm not a programmer and do not code PHP. So that would not work for me to do. So is this a PHP issue possibly? If so I can direct my client to hire a programmer possibly.
 
I dont think it's a php issue because it seems to be working as designed. It's probably a js file calling the php when it shouldn't.
 
Hmmmmmmm ok I can check the js files and see if one is causing this issue. I have in mind what file it maybe. I'll post the code here when I take a look at it.
 
Just out of curiosity, what is the session timeout set to? When the "Thread/Forum Read Marking Type" setting is set to "Inactivity/Cookie Based", the forums are marked read after session timeout.
 
Just out of curiosity, what is the session timeout set to? When the "Thread/Forum Read Marking Type" setting is set to "Inactivity/Cookie Based", the forums are marked read after session timeout.

No its set to Database (automatic forum marking).
 
Ok so the two possible js files that maybe causing this issue are a menu file and a world clock file.

The menu file:

Code:
/*********************
//* jQuery Multi Level CSS Menu (horizontal)- By Dynamic Drive DHTML code library: http://www.dynamicdrive.com
//* Menu instructions page: http://www.dynamicdrive.com/dynamicindex1/ddlevelsmenu/
//* Last modified: Sept 6th, 08'. Usage Terms: http://www.dynamicdrive.com/style/csslibrary/tos/
*********************/

//Specify full URL to down and right arrow images (25 is padding-right to add to top level LIs with drop downs):
var arrowimages={down:['downarrowclass', 'http://www.merchant-navy.net/forum/arrow-down.gif', 25], right:['rightarrowclass', 'http://www.merchant-navy.net/forum/arrow-right.gif']}

var jquerycssmenu={

fadesettings: {overduration: 350, outduration: 100}, //duration of fade in/ out animation, in milliseconds

buildmenu:function(menuid, arrowsvar){
	jQuery(document).ready(function($){
		var $mainmenu=$("#"+menuid+">ul")
		var $headers=$mainmenu.find("ul").parent()
		$headers.each(function(i){
			var $curobj=$(this)
			var $subul=$(this).find('ul:eq(0)')
			this._dimensions={w:this.offsetWidth, h:this.offsetHeight, subulw:$subul.outerWidth(), subulh:$subul.outerHeight()}
			this.istopheader=$curobj.parents("ul").length==1? true : false
			$subul.css({top:this.istopheader? this._dimensions.h+"px" : 0})
			$curobj.children("a:eq(0)").css(this.istopheader? {paddingRight: arrowsvar.down[2]} : {}).append(
				'<img src="'+ (this.istopheader? arrowsvar.down[1] : arrowsvar.right[1])
				+'" class="' + (this.istopheader? arrowsvar.down[0] : arrowsvar.right[0])
				+ '" style="border:0;" />'
			)
			$curobj.hover(
				function(e){
					var $targetul=$(this).children("ul:eq(0)")
					this._offsets={left:$(this).offset().left, top:$(this).offset().top}
					var menuleft=this.istopheader? 0 : this._dimensions.w
					menuleft=(this._offsets.left+menuleft+this._dimensions.subulw>$(window).width())? (this.istopheader? -this._dimensions.subulw+this._dimensions.w : -this._dimensions.w) : menuleft
					$targetul.css({left:menuleft+"px"}).fadeIn(jquerycssmenu.fadesettings.overduration)
				},
				function(e){
					$(this).children("ul:eq(0)").fadeOut(jquerycssmenu.fadesettings.outduration)
				}
			) //end hover
		}) //end $headers.each()
		$mainmenu.find("ul").css({display:'none', visibility:'visible'})
	}) //end document.ready
}
}

//build menu with ID="myjquerymenu" on page:
jquerycssmenu.buildmenu("myjquerymenu", arrowimages)

And the World Clock js:

Code:
function worldClock(zone, region){
var dst = 0
var time = new Date()
var gmtMS = time.getTime() + (time.getTimezoneOffset() * 60000)
var gmtTime = new Date(gmtMS)
var day = gmtTime.getDate()
var month = gmtTime.getMonth()
var year = gmtTime.getYear()
if(year < 1000){
year += 1900
}
var monthArray = new Array("January", "February", "March", "April", "May", "June", "July", "August", 
				"September", "October", "November", "December")
var monthDays = new Array("31", "28", "31", "30", "31", "30", "31", "31", "30", "31", "30", "31")
if (year%4 == 0){
monthDays = new Array("31", "29", "31", "30", "31", "30", "31", "31", "30", "31", "30", "31")
}
if(year%100 == 0 && year%400 != 0){
monthDays = new Array("31", "28", "31", "30", "31", "30", "31", "31", "30", "31", "30", "31")
}

var hr = gmtTime.getHours() + zone
var min = gmtTime.getMinutes()
var sec = gmtTime.getSeconds()

if (hr >= 24){
hr = hr-24
day -= -1
}
if (hr < 0){
hr -= -24
day -= 1
}
if (hr < 10){
hr = " " + hr
}
if (min < 10){
min = "0" + min
}
if (sec < 10){
sec = "0" + sec
}
if (day <= 0){
if (month == 0){
	month = 11
	year -= 1
	}
	else{
	month = month -1
	}
day = monthDays[month]
}
if(day > monthDays[month]){
	day = 1
	if(month == 11){
	month = 0
	year -= -1
	}
	else{
	month -= -1
	}
}
if (region == "NAmerica"){
	var startDST = new Date()
	var endDST = new Date()
	startDST.setMonth(3)
	startDST.setHours(2)
	startDST.setDate(1)
	var dayDST = startDST.getDay()
	if (dayDST != 0){
		startDST.setDate(8-dayDST)
		}
		else{
		startDST.setDate(1)
		}
	endDST.setMonth(9)
	endDST.setHours(1)
	endDST.setDate(31)
	dayDST = endDST.getDay()
	endDST.setDate(31-dayDST)
	var currentTime = new Date()
	currentTime.setMonth(month)
	currentTime.setYear(year)
	currentTime.setDate(day)
	currentTime.setHours(hr)
	if(currentTime >= startDST && currentTime < endDST){
		dst = 1
		}
}
if (region == "Europe"){
	var startDST = new Date()
	var endDST = new Date()
	startDST.setMonth(2)
	startDST.setHours(1)
	startDST.setDate(31)
	var dayDST = startDST.getDay()
	startDST.setDate(31-dayDST)
	endDST.setMonth(9)
	endDST.setHours(0)
	endDST.setDate(31)
	dayDST = endDST.getDay()
	endDST.setDate(31-dayDST)
	var currentTime = new Date()
	currentTime.setMonth(month)
	currentTime.setYear(year)
	currentTime.setDate(day)
	currentTime.setHours(hr)
	if(currentTime >= startDST && currentTime < endDST){
		dst = 1
		}
}
if (region == "SAmerica"){
	var startDST = new Date()
	var endDST = new Date()
	startDST.setMonth(9)
	startDST.setHours(0)
	startDST.setDate(1)
	var dayDST = startDST.getDay()
	if (dayDST != 0){
		startDST.setDate(22-dayDST)
		}
		else{
		startDST.setDate(15)
		}
	endDST.setMonth(1)
	endDST.setHours(11)
	endDST.setDate(1)
	dayDST = endDST.getDay()
	if (dayDST != 0){
		endDST.setDate(21-dayDST)
		}
		else{
		endDST.setDate(14)
		}
	var currentTime = new Date()
	currentTime.setMonth(month)
	currentTime.setYear(year)
	currentTime.setDate(day)
	currentTime.setHours(hr)
	if(currentTime >= startDST || currentTime < endDST){
		dst = 1
		}
}
if (region == "Cairo"){
	var startDST = new Date()
	var endDST = new Date()
	startDST.setMonth(3)
	startDST.setHours(0)
	startDST.setDate(30)
	var dayDST = startDST.getDay()
	if (dayDST < 5){
		startDST.setDate(28-dayDST)
		}
		else {
		startDST.setDate(35-dayDST)
		}
	endDST.setMonth(8)
	endDST.setHours(11)
	endDST.setDate(30)
	dayDST = endDST.getDay()
	if (dayDST < 4){
		endDST.setDate(27-dayDST)
		}
		else{
		endDST.setDate(34-dayDST)
		}
	var currentTime = new Date()
	currentTime.setMonth(month)
	currentTime.setYear(year)
	currentTime.setDate(day)
	currentTime.setHours(hr)
	if(currentTime >= startDST && currentTime < endDST){
		dst = 1
		}
}
if (region == "Israel"){
	var startDST = new Date()
	var endDST = new Date()
	startDST.setMonth(3)
	startDST.setHours(2)
	startDST.setDate(1)
	endDST.setMonth(8)
	endDST.setHours(2)
	endDST.setDate(25)
	dayDST = endDST.getDay()
	if (dayDST != 0){
	endDST.setDate(32-dayDST)
	}
	else{
	endDST.setDate(1)
	endDST.setMonth(9)
	}
	var currentTime = new Date()
	currentTime.setMonth(month)
	currentTime.setYear(year)
	currentTime.setDate(day)
	currentTime.setHours(hr)
	if(currentTime >= startDST && currentTime < endDST){
		dst = 1
		}
}
if (region == "Beirut"){
	var startDST = new Date()
	var endDST = new Date()
	startDST.setMonth(2)
	startDST.setHours(0)
	startDST.setDate(31)
	var dayDST = startDST.getDay()
	startDST.setDate(31-dayDST)
	endDST.setMonth(9)
	endDST.setHours(11)
	endDST.setDate(31)
	dayDST = endDST.getDay()
	endDST.setDate(30-dayDST)
	var currentTime = new Date()
	currentTime.setMonth(month)
	currentTime.setYear(year)
	currentTime.setDate(day)
	currentTime.setHours(hr)
	if(currentTime >= startDST && currentTime < endDST){
		dst = 1
		}
}
if (region == "Baghdad"){
	var startDST = new Date()
	var endDST = new Date()
	startDST.setMonth(3)
	startDST.setHours(3)
	startDST.setDate(1)
	endDST.setMonth(9)
	endDST.setHours(3)
	endDST.setDate(1)
	dayDST = endDST.getDay()
		var currentTime = new Date()
	currentTime.setMonth(month)
	currentTime.setYear(year)
	currentTime.setDate(day)
	currentTime.setHours(hr)
	if(currentTime >= startDST && currentTime < endDST){
		dst = 1
		}
}
if (region == "Australia"){
	var startDST = new Date()
	var endDST = new Date()
	startDST.setMonth(10)
	startDST.setHours(2)
	startDST.setDate(4)
	var dayDST = startDST.getDay()
	startDST.setDate(31-dayDST)
	endDST.setMonth(2)
	endDST.setHours(2)
	endDST.setDate(31)
	dayDST = endDST.getDay()
	endDST.setDate(31-dayDST)
	var currentTime = new Date()
	currentTime.setMonth(month)
	currentTime.setYear(year)
	currentTime.setDate(day)
	currentTime.setHours(hr)
	if(currentTime >= startDST && currentTime < endDST){
		dst = 0
		}
}
	
if (dst == 1){
	hr -= -1
	if (hr >= 24){
	hr = hr-24
	day -= -1
	}
	if (hr < 10){
	hr = " " + hr
	}
	if(day > monthDays[month]){
	day = 1
	if(month == 11){
	month = 0
	year -= -1
	}
	else{
	month -= -1
	}
	}
return hr + ":" + min + ":" + sec + " DST"
}
else{
return hr + ":" + min + ":" + sec
}
}

function worldClockZone(){

document.getElementById("London").innerHTML = worldClock(0, "Europe")
document.getElementById("Sydney").innerHTML = worldClock(11, "Australia")
document.getElementById("Wellington").innerHTML = worldClock(13, "Wellington")
document.getElementById("Capetown").innerHTML = worldClock(2, "Capetown")
document.getElementById("NewYork").innerHTML = worldClock(-5, "NAmerica")
document.getElementById("Vancouver").innerHTML = worldClock(-8, "NAmerica")

setTimeout("worldClockZone()", 1000)
}
//window.onload=worldClockZone;

//-->

Do you see anything that might cause this issue in those two files?
 
Nothing pops out me. This is definitely an interesting issue for sure. Have you tried a unmodified default style to see if the behavior is consistent?
 
Yeah at one time I think I had tried that, but I'll give that a go again and see if it works or not.
 
Nope changing to a default skin does not seem to help.:(

Also commenting out that line in ajax.php did nothing different. :( Is it possible this is hosting/server related?
 
Last edited:
I can't think of anything the server could be doing to make it happen. You could try switching to cookie based marking and see if the behaviour is consistent. Other than that, I'm at a loss as to what may be causing it. Unfortunately, I no longer have any free time for the next few months to investigate due to a few large jobs falling into my lap that will require my presence onsite. Looks like play time is over. ;(
 
Thanks for your help. I've tried changing the cookie settings and its the same no matter what I do with them.
 
I'm a bit late to this thread, but I can say I've experienced a very similar thing in the past. New posts were not flagging the forum as unread without first doing a hard refresh of the page (ctrl+shift+R). I don't know what the exact cause was, but it was most certainly the hosting service/server. The problem vanished after moving to a VPS. The only thing I know that is 100% different between the shared service it was on before, and the VPS I am on now is my VPS does not use litespeed web server, where as the shared hosting did use it.

The only thing I can really suggest is to upload a copy of the website to another server, point your hosts file to it, and see how it performs.
 
Back
Top