944,123 Members | Top Members by Rank

Ad:
Jan 16th, 2007
0

Dani Webs Code?

Expand Post »
This site shows (x) users veiwing each forum on the main index, Id love to know how its done? can it be done with javascript?
Similar Threads
Reputation Points: 11
Solved Threads: 6
Posting Whiz in Training
Inny is offline Offline
293 posts
since Oct 2005
Jan 16th, 2007
0

Re: Dani Webs Code?

i think its a php script maybe
i know nothing about web design though so take that with a pinch of salt
Last edited by jbennet; Jan 16th, 2007 at 3:22 am.
Moderator
Featured Poster
Reputation Points: 1800
Solved Threads: 575
Moderator
jbennet is offline Offline
16,534 posts
since Apr 2005
Jan 16th, 2007
0

Re: Dani Webs Code?

Well thankyou for replying at all, Appreciated!
Reputation Points: 11
Solved Threads: 6
Posting Whiz in Training
Inny is offline Offline
293 posts
since Oct 2005
Jan 16th, 2007
0

Re: Dani Webs Code?

This forum uses PHP and the code is embedded into the software.

I do not know if it can be done with javascript.
Team Colleague
Reputation Points: 92
Solved Threads: 21
Posting Pro in Training
FC Jamison is offline Offline
436 posts
since Jun 2004
Jan 16th, 2007
0

Re: Dani Webs Code?

It's not possible to do this with JavaScript because you would need some sort of database to keep track of how many visitors there are, which can only be done with a server-side programming language.

We do it with PHP and MySQL. Each time a page is accessed, a record in a MySQL table is updated with the user's IP address and the timestamp. Records with timestamps older than 20 minutes are deleted. The number of IP addresses is the number of people currently visiting the site.
Last edited by cscgal; Jan 16th, 2007 at 4:24 am. Reason: Typo
Administrator
Staff Writer
Reputation Points: 1422
Solved Threads: 163
The Queen of DaniWeb
cscgal is offline Offline
13,646 posts
since Feb 2002
Jan 16th, 2007
0

Re: Dani Webs Code?

ok Thanks again. I found a similar code that may need slight tweaking to work for me. I dont have a 'veiws' cell on my main index though.
could I rewrite this to add to cell 'Forum'? which list the forum name?

P.s Im aware of the advertising ban so I wont link you my site to see.

JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. <script type="text/javascript">
  2. <!--
  3. /*
  4. Users Viewing In Main Page
  5. */
  6. var addrequest;
  7. var viewadds = new Array();
  8. var curnum = 0;
  9. var td = document.getElementsByTagName('td');
  10. for(t=0;t<td.length;t++){
  11. if(td[t].getElementsByTagName('a')[0] && td[t].getElementsByTagName('a')[0].href.match(/showforum=\d+/)){
  12. viewadds.push(td[t]);
  13. }}
  14. checkBViews();
  15. function checkBViews(){
  16. if(window.ActiveXObject){
  17. addrequest = new ActiveXObject("Microsoft.XMLHTTP");
  18. } else {
  19. addrequest = new XMLHttpRequest();
  20. }
  21. var opener = viewadds[curnum].getElementsByTagName('a')[0].href;
  22. addrequest.onreadystatechange = function(){
  23. addBViews();
  24. }
  25. addrequest.open("GET",opener,true);
  26. addrequest.send('');
  27. }
  28. function addBViews(){
  29. if(addrequest.readyState == 4 && addrequest.status == 200){
  30. var resptext = addrequest.responseText;
  31. var addiv = document.createElement('div');
  32. addiv.innerHTML = resptext;
  33. var hdiv = addiv.getElementsByTagName('div');
  34. var views = 0;
  35. for(a=0;a<hdiv.length;a++){
  36. if(hdiv[a].className == "darkrow2" && hdiv[a].innerHTML.match(/^(\d+) User\(s\) are browsing this forum/)){
  37. views = parseInt(RegExp.$1) - 1;
  38. }}
  39. if(views < 0){
  40. views = 0;
  41. }
  42. if(views != 0){
  43. var viewstext = document.createTextNode( ' ('+views+' viewing'+')');
  44. viewadds[curnum].insertBefore(viewstext,viewadds[curnum].getElementsByTagName('br')[0]);
  45. }
  46. curnum++;
  47. if(curnum != viewadds.length){
  48. checkBViews();
  49. } else {
  50. termViews();
  51. }}}
  52. function termViews(){
  53. if(window.ActiveXObject){
  54. addrequest = new ActiveXObject("Microsoft.XMLHTTP");
  55. } else {
  56. addrequest = new XMLHttpRequest();
  57. }
  58. addrequest.open("GET",location.href,true);
  59. addrequest.send('');
  60. }
  61. //-->
  62. </script>


p.s My templet for board index forum row. Where I have 'New topic' link is where I want Users Browsing

JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1.  
  2. <tr>
  3. <td class="row4" align="center">{$info['img_new_post']}</td>
  4. <td class="row4"><a href="{ibf.script_url}showforum={$info['id'] }"onMouseover="ddrivetip('Open This Forum!','yellow', 150)";
  5. onMouseout="hideddrivetip()"><b>{$info['name']}</b></a><br /><br><a href="{ibf.script_url}act=Post&CODE=00&f={$info['id']}"onMouseover="ddrivetip('Start A new Topic In this Forum!','yellow', 150)";
  6. onMouseout="hideddrivetip()"><FONT COLOR="#FF0000"><b>New Topic</b></font></a><br /><br><span class='desc'>{$info['description']}<br />
  7.  
  8.  
  9.  
  10.  
  11.  
  12.  
  13.  
  14.  
  15.  
  16. </span></td>
  17.  
  18. <td class="row2" align="center">{$info['topics']}</td>
  19. <td class="row2" align="center">{$info['posts']}</td>
  20.  
  21. <td class="row2" nowrap="nowrap">{$info['last_post']}<br />{ibf.lang.in}:&nbsp;{$info['last_unread']}{$info['last_topic']}
  22.  
  23. <br />{ibf.lang.by}: {$info['last_poster']}
  24.  
  25. </td>
  26. </tr>

p.s users browsing [forum/topic] is written in php my board
Last edited by Inny; Jan 16th, 2007 at 4:33 am.
Reputation Points: 11
Solved Threads: 6
Posting Whiz in Training
Inny is offline Offline
293 posts
since Oct 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in JavaScript / DHTML / AJAX Forum Timeline: IE problem - Something's wrong with this JS
Next Thread in JavaScript / DHTML / AJAX Forum Timeline: dynamically filling dropdown from another dropdown





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC