eve
Full Member
Posts: 773
inherit
136280
0
Dec 24, 2009 13:27:25 GMT -8
eve
773
January 2009
evefun
|
Post by eve on Feb 13, 2009 15:58:41 GMT -8
Forum URL: everythingaquatic.proboards104.com/index.cgiProblem: ok, what i'm wondering is what i can change in this code because it doesnt' matter when i log on, but i will always be shown over 500-700 reply's since last visit even that there should only be like 10 or up to 50 any help and ideas on what to change that would be very much appreciated the following is the code i have currently in the main footer <script type="text/Javascript"> // View Posts Since Last Visit by Chris // This script may not be redistributed outside of Studio Zero, ProBoards Support, SoCal, or ProVision
var imageUrl = "http://i208./bb53/evelynmarch26/buttons/button1up_menu204471-2.gif";
// Don't edit var pslv = { image: imageUrl, lastTime: 0, // Last login time genRand: function(){ return Math.floor(Math.random()*500)+500; }, genLink: function(){ var sstring = "?action=search2&search=&match=1&whattosearch=1&user="; sstring += "&maxresults="+this.genRand()+"&viewtype=1&subject=1&message=1"; // Check into search string // Check into match type // Add the date here var x = (new Date()).getTime()-this.lastTime; x = Math.ceil(((x/1000)/60)/60); // Milliseconds to seconds to minutes to hours sstring += "&hours="+x; // Load board data var f = document.getElementById("forumjump").options; for(a=6;a<f.length;a++){ if(f[a].value.match(/board=/i)){ sstring += "&board-"+f[a].value.split(/board=/i)[1]+"=1"; } } location.href = sstring; }, addInfo: function(){ var aTD = document.getElementsByTagName("td"); for(a=0;a<aTD.length;a++){ if(aTD[a].colSpan == 5 && aTD[a].getElementsByTagName("img")[0]){ var v = aTD[a].firstChild; v.appendChild(document.createTextNode(" ")); var ah = v.appendChild(document.createElement("a")); ah.href = "javascript:void(0);" ah.onclick = function(){ pslv.genLink(); }; ah.appendChild(new Image()).src = this.image; ah.firstChild.alt = ah.firstChild.title = "Posts Since Last Visit"; ah.firstChild.border = 0; break; } } }, init: function(){ if(pb_username == "Guest") return false; if(!(location.href.match(/action=home/i) || !location.href.match(/(action|board)=/i))) return false;
this.addInfo(); this.lastTime = this.c.get("session_visit") || this.c.get("last_visit") || 1; this.c.set("session_visit", this.lastTime); this.c.set("last_visit", (new Date()).getTime(), true); }, c: { get: function(n){ if(document.cookie.match(new RegExp("pslv_"+n+"=(.+?)(;|$)", "gi"))){ return RegExp.$1; } return 0; }, set: function(n, v, e){ document.cookie = "pslv_"+n+"="+v+";"+(e?"expires="+(new Date( )).toGMTString().replace(/\d{4}/, "2050"):""); } } };
pslv.init(); </script> cheers Eve
|
|
inherit
Official Code Helper
65613
0
1
Apr 15, 2024 17:01:41 GMT -8
Chris
"'Oops' is the sound we make when we improve"
8,870
December 2005
horace
|
Post by Chris on Feb 13, 2009 20:45:14 GMT -8
The code works by saving a cookie of the last time you visited to your computer. It then uses that cookie when you return to calculate how far back a search should be made for new posts (with an absolute max set at 500 I think).
This means the first time you use the code no cookie is available and the randomly generated max is returned, subsequent visits should prune those results quite a bit.
If your browser is however set to treat all cookies as session (i.e. delete all cookies everytime it closes) then you'll never have a cookie on return trips and it will be as if you're running the code for the first time.
You could of course change the absolute max in the code if it annoys you but that might mean someone who has been away for a while might miss posts believing the code returned all there was.
Best solution is to ensure your cookies are preserved between browser uses.
|
|
eve
Full Member
Posts: 773
inherit
136280
0
Dec 24, 2009 13:27:25 GMT -8
eve
773
January 2009
evefun
|
Post by eve on Feb 14, 2009 15:04:27 GMT -8
thanks for the response i tried to change the following in different numbers return Math.floor(Math.random()* 500)+ 500; however it still don't work if i leave it the way it is, it returns over 600 results if i turn it down to 300 and 100, the returning results are still anywhere between 100 and 300 results, it changs every time i click on the button i have cookies enabled for it i tried it on FF as well as on opera, same results any other ideas maybe?
|
|
inherit
Official Code Helper
65613
0
1
Apr 15, 2024 17:01:41 GMT -8
Chris
"'Oops' is the sound we make when we improve"
8,870
December 2005
horace
|
Post by Chris on Feb 14, 2009 17:47:43 GMT -8
For a tiny script that is a deceptively complex algorithm Chris . I misread it earlier, the max is 500 plus a randomly generated second value added ranging from 0 to 500 bringing total to between 500 and 1000. From my own experience the randomness in the search url is needed to avoid getting "no results found". Have you tried closing your browser completely (so your session cookie deletes) or are you like me and leave it running sometimes to avoid that 3 millisecond application startup? Also when you login are you actually going to the main page? If I'm reading the code correctly it will not record your visit unless you go to the main page after logging in. If for example you always use a bookmark that takes you to a sub-board where you can login then get directly routed to that board without ever seeing the main page then no cookies will ever get recorded. After you login what url do you immediately see in the address bar?
|
|
eve
Full Member
Posts: 773
inherit
136280
0
Dec 24, 2009 13:27:25 GMT -8
eve
773
January 2009
evefun
|
Post by eve on Feb 15, 2009 2:07:13 GMT -8
yes, it's a very long and complex code so let's see if i understood all that correctly originally i start the site from a bookmark i hardly every log in or out, i have it set to forever but to try to get this to work for me, i did logout, close the browser and reopen the browser my computer is never running forever, get's turned off every day (wasn't always that way ) so the session cookies should be cleared every time also just tried to access the board from the homepage still same result from here www.everything-aquatic.com/2008/09/fish-profiles.htmlok, i just looked over the code again (i'm not really familiar with all the coding as you for sure can tell), but is it possible that the red part needs editing? genLink: function(){ var sstring = "?action=search2&search=&match=1&whattosearch=1&user="; sstring += "&maxresults="+this.genRand()+"&viewtype=1&subject=1&message=1"; // Check into search string // Check into match type // Add the date herevar x = (new Date()).getTime()-this.lastTime; x = Math.ceil(((x/1000)/60)/60); // Milliseconds to seconds to minutes to hours sstring += "&hours="+x; // Load board data var f = document.getElementById("forumjump").options; for(a=6;a<f.length;a++){ if(f .value.match(/board=/i)){ sstring += "&board-"+f.value.split(/board=/i)[1]+"=1";
oh, and this is the url i see immediately after logging in
everythingaquatic.proboards104.com/index.cgi?and for the bookmark, i have it saved with the above url hope all that just made sense
|
|
inherit
Official Code Helper
65613
0
1
Apr 15, 2024 17:01:41 GMT -8
Chris
"'Oops' is the sound we make when we improve"
8,870
December 2005
horace
|
Post by Chris on Feb 16, 2009 7:09:09 GMT -8
Those red lines are merely comments put there for informational purposes and really have no effect on the execution of the code. The problem with diagnosing a code like this is it relies so heavily on the existence and values of cookies, which is something the user can't easily offer. The developer can always look at her own cookies through each stage to verify values are as they should be but that simply doesn't work when trying to debug remotely. I had the same problem with the alias code.
Here's a small script I'd like you to run from your addressbar several times from several different page loads of the forum to track the value changes of your cookies. Jot down the url then overwrite the url by pasting the script and hitting enter. Jot down the results you got for that url.
I'd like you to do it when first opening your browser and going to the main page of the forum. Then completely close the browser and reopen and go back to the main page and repeat the steps.
javascript:var a=/(pslv(\w+)=([^;]+))/gi, b=document.cookie.match(a), c=new Date(),d='',e=pb_username+'\n'; try{for(d=0;d<b.length;d++)e+=b[d]+' ('+new Date((c-b[d].split('=')[1]))+')\n'; alert(e);}catch(f){alert('no cookie')}; void(1)
|
|
eve
Full Member
Posts: 773
inherit
136280
0
Dec 24, 2009 13:27:25 GMT -8
eve
773
January 2009
evefun
|
Post by eve on Feb 16, 2009 20:54:45 GMT -8
wow ok First result from how I was logged in already when i just read your reply<everythingaquatic.proboards104.com> eve pslv_session_visit=1234837227110 (Wed Dec 31 1969 18:27:29 GMT-0800) pslv_last_visit=1234846068758 (Wed Dec 31 1969 16:00:07 GMT-0800) right after logut<everythingaquatic.proboards104.com> Guest pslv_session_visit=1234837227110 (Wed Dec 31 1969 18:29:58 GMT-0800) pslv_last_visit=1234846068758 (Wed Dec 31 1969 16:02:37 GMT-0800) right after browser restart, before login<everythingaquatic.proboards104.com> Guest pslv_last_visit=1234846068758 (Wed Dec 31 1969 16:04:19 GMT-0800) right after login<everythingaquatic.proboards104.com> eve pslv_session_visit=1234846068758 (Wed Dec 31 1969 16:05:21 GMT-0800) pslv_last_visit=1234846375900 (Wed Dec 31 1969 16:00:14 GMT-0800)
|
|
inherit
Official Code Helper
65613
0
1
Apr 15, 2024 17:01:41 GMT -8
Chris
"'Oops' is the sound we make when we improve"
8,870
December 2005
horace
|
Post by Chris on Feb 16, 2009 22:18:28 GMT -8
Looks like your cookies are working as expected. Did you try using the code after that last login, because that should return posts created in the past hour: (1234846375900-1234846068758 )/1000/60/60 = 0.08531722222222222 (rounded up to 1 hour) If you get a ton of returned results then copy the url from that result page and paste here so we can see if something is off in the generated url itself
|
|
eve
Full Member
Posts: 773
inherit
136280
0
Dec 24, 2009 13:27:25 GMT -8
eve
773
January 2009
evefun
|
Post by eve on Feb 16, 2009 22:26:29 GMT -8
thanks for helping me out with this one and your patience with me this is what i get when i click on the posts since last visit with the code above <everythingaquatic.proboards104.com> eve pslv_last_visit=1234851426863 (Wed Dec 31 1969 16:06:01 GMT-0800) i still get over 500 results and this is the url it goes to geeez, that's a long url http://everythingaquatic.proboards104.com/?action=search2&search=&match=1&whattosearch=1&user=&maxresults=741&viewtype=1&subject=1&message=1&hours=1&board-updates=1&board-general=1&board-articles=1&board-structuring=1&board-catagorizing=1&board-regrouping=1&board-discuss=1&board-questions=1&board-sickfish=1&board-filters=1&board-info=1&board-postings=1&board-identify=1&board-cleanup=1&board-characins=1&board-coldwater=1&board-pregnant=1&board-airbreathing=1&board-whoami=1&board-aggression=1&board-bigbadboys=1&board-harassers=1&board-allbymyself=1&board-china=1&board-breeding=1&board-creation=1&board-egglayer=1&board-posts=1&board-breedinglive=1&board-breedingmarine=1&board-chlorophyll=1&board-miscellaneous=1&board-jelly=1&board-swimmingpool=1&board-novice=1&board-greatwhite=1&board-nemo=1&board-nemo2=1&board-greatbarrierreef=1&board-shrimpy=1&board-caviar=1&board-tankblogs=1&board-talkhistoryanddiscussion=1&board-lookatthismom=1&board-jailhouse=1&board-wildkingdom=1&board-anythingandeverything=1&board-fungames=1&board-famandpets=1&board-expressinghappythings=1&board-buying=1&board-onlinebying=1&board-local=1&board-sellfish=1&board-information=1
|
|
inherit
Official Code Helper
65613
0
1
Apr 15, 2024 17:01:41 GMT -8
Chris
"'Oops' is the sound we make when we improve"
8,870
December 2005
horace
|
Post by Chris on Feb 16, 2009 23:13:48 GMT -8
The bad news is proboards must have broken its search during the last round of updates because it no longer pays attention to time filters and tries to return maxresults if the parameters are submitted through HTTP GET (included as part of the url) instead of HTTP POST (submited as form data).
I confirmed this by using the search menu button on your forum and setup the values exactly as the values specified in that url and got 36 results returned as opposed to 741 using the url ( input 741 in the max result field with hours=1 and days=0). I then generated an url for this support forum and got the same thing with posts older than one hour getting returned, while a form based search did filter by time.
If that is the case then this code might have become crippled since it relies on that time filter working to get the job done. You'll obviously be able to edit the lower fixed max and the upper random max to prune the results but time based GET searches looks to be broken on Proboards' end.
Forget what I said, I went back and double checked my comparison between the params sent by POST and the params sent by the script constructed URL and I noticed the omission of two params: checkall=on and days=0
I plugged the missing params into the url you posted and sure enough time based filtering started working again. The checkall didn't make a difference if removed but the days did. Proboards treats the search as a "x most recent posts" (where x=maxresults) if hours and/or days are missing.
Find this line in the code and add the red: location.href = sstring+'&days=0';
|
|
eve
Full Member
Posts: 773
inherit
136280
0
Dec 24, 2009 13:27:25 GMT -8
eve
773
January 2009
evefun
|
Post by eve on Feb 17, 2009 13:13:08 GMT -8
AWESOME that works like a charm thank you soooooo much for your time and patience somebody should update that on the original code though
|
|
#00AF33
14306
0
1
Sept 8, 2023 8:54:17 GMT -8
Jordan
What is truth?
11,838
October 2003
jab2
|
Post by Jordan on Feb 17, 2009 13:43:30 GMT -8
I've sent Chris a private message and updated the code here.
Appreciate it Eton.
|
|
inherit
Official Code Helper
65613
0
1
Apr 15, 2024 17:01:41 GMT -8
Chris
"'Oops' is the sound we make when we improve"
8,870
December 2005
horace
|
Post by Chris on Feb 18, 2009 0:23:05 GMT -8
no problem
|
|
inherit
142097
0
Jul 3, 2009 8:21:40 GMT -8
dhaholic
2
July 2009
dhaholic
|
Post by dhaholic on Jul 1, 2009 21:27:36 GMT -8
Hi everyone, I've been trying to use this code but I'm not managing. I've copied the code from Chris's topic and pasted it in the main footer. The words ' posts since last visit ' appears. But it isn't working for me - javascript:void(0); appears when I scroll the cursor over it. Totally new to this kind of coding, hope I don't annoy anyone
|
|
inherit
The Final Cylon
31521
0
Mar 3, 2015 14:39:33 GMT -8
Trublu
Maybe the duck is in the hat.
12,323
October 2004
trublusvufan
|
Post by Trublu on Jul 2, 2009 5:14:30 GMT -8
Hi everyone, I've been trying to use this code but I'm not managing. I've copied the code from Chris's topic and pasted it in the main footer. The words ' posts since last visit ' appears. But it isn't working for me - javascript:void(0); appears when I scroll the cursor over it. Totally new to this kind of coding, hope I don't annoy anyone Hi, Please create your own thread and include the URL to your forum.
|
|