View Full Version : Active topics ? how did you do it tech talk ?
Okay i thought i'd start a new thread ... how did tech talk do the today's active topics code hack to include it on a non vb page..
i have added most of the includes that tech talk released on my test index page at
now all i am missing are
1. active topics includes
2. displaying total threads
3. displaying total posts
4. displaying total registered members
5. displaying most recent registered member
any help is appreciated :D
[Edited by eva2000 on 01-04-2001 at 12:43 PM]
[Edited by eva2000 on 01-04-2001 at 12:44 PM]
Ok ill try to help a little here. To show the newest registered member make a new file called "newestmember.inc.php" and place the code below into it.
See it in action here:
http://www.extremeforums.com/include/newestmember.inc.php
Here is the code:
<?php
require("/full/path/to/admin/config.php");
$db=mysql_connect($servername,$dbusername,$dbpassw ord);
mysql_select_db($dbname);
$query = "select * from user order by userid desc limit 1";
$resultlatest = mysql_query($query,$db);
$latest_array = mysql_fetch_array($resultlatest);
echo "<FONT FACE=\"Verdana, Arial, Helvetica, sans-serif\" SIZE=\"2\"><b>Greetings to our newest member, <a href=\"http://www.extremeforums.com/forums/member.php?action=getinfo&userid=$latest_array[userid]\" target=_blank>$latest_array[username]</a> !</b></font>";
?>
------------------------------------------------------------
For the total number of members make a file called "totalmembers.inc.php" and place the following code into it:
<?php
require("/full/path/to/admin/config.php");
$db=mysql_connect($servername,$dbusername,$dbpassw ord);
mysql_select_db($dbname);
$query = "select * from user";
$resultlatest = mysql_query($query,$db);
$num = mysql_num_rows($resultlatest);
echo "<FONT FACE=\"Verdana, Arial, Helvetica, sans-serif\" SIZE=\"2\">There are currently <b>$num</b> registered members.</font>";
?>
See this one in action here:
http://www.extremeforums.com/include/totalmembers.inc.php
------------------------------------------------------------
For the total posts make a new file called "totalposts.inc.php" and include the following:
<?php
require("/full/path/to/admin/config.php");
$db=mysql_connect($servername,$dbusername,$dbpassw ord);
mysql_select_db($dbname);
$query = "select * from post";
$resultlatest = mysql_query($query,$db);
$num = mysql_num_rows($resultlatest);
echo "<FONT FACE=\"Verdana, Arial, Helvetica, sans-serif\" SIZE=\"2\">There are currently <b>$num</b> posts on the forums.</font>";
?>
See an example here:
http://www.extremeforums.com/include/totalposts.inc.php
------------------------------------------------------------
For the total threads make a file called "totalthreads.inc.php" and include the following:
<?php
require("/full/path/to/admin/config.php");
$db=mysql_connect($servername,$dbusername,$dbpassw ord);
mysql_select_db($dbname);
$query = "select * from thread";
$resultlatest = mysql_query($query,$db);
$num = mysql_num_rows($resultlatest);
echo "<FONT FACE=\"Verdana, Arial, Helvetica, sans-serif\" SIZE=\"2\">There are currently <b>$num</b> threads on the forums.</font>";
?>
Here is the example:
http://www.extremeforums.com/include/totalthreads.inc.php
------------------------------------------------------------
Hope this helps ;)
If you have any questions just let me know
~Chris
Oh and BTW....your active topics looks nice ;) Mine will show you any threads that were posted to today. If you want it here is the code:
<?php
// Set this to the max number of threads you want to display
$maxthreads = 100;
require("/full/path/to/admin/config.php");
$db=mysql_connect($servername,$dbusername,$dbpassw ord);
mysql_select_db($dbname);
$query = "SELECT * FROM thread WHERE to_days(now())=to_days(from_unixtime(lastpost)) AND forumid <> 34 AND forumid <> 33 ORDER BY dateline DESC LIMIT $maxthreads";
$resultlatest = mysql_query($query,$db);
while ($latest_array = mysql_fetch_array($resultlatest)) {
echo "<img src=\"images/smalldoc.gif\" width=\"12\" height=\"12\" alt=\">\" border=\"0\" align=\"absmiddle\"><FONT SIZE=\"2\" FACE=\"Verdana, Arial, Helvetica, sans-serif\">
<A HREF=\"http://www.extremeforums.com/forums/showthread.php?threadid=$latest_array[threadid]\">$latest_array[title]</A></FONT><BR>";
}
?>
~Chris
thanks techtalk it works perfectly and can be seen at http://www.animeboards.net :D
the only thing i had to do was add the chdir before require command in each php file you had above
<?php
chdir("/home/usr1/www.animeboards.net/htdocs/forums");
require("/home/usr1/www.animeboards.net/htdocs/forums/admin/config.php");
Glad you got it working ;) Strange about the change dir thingy...I never had to do that before :confused:
~Chris
*** dances around *** thanks again tech talk... just amazing what you can do with vbulletin :D
whoops... forgot one slight addition... how do you display the Active users ?
just the top part which says
Currently there are x members and x guests on the forums.
nice hack, but i want to exclude the private forums (TechTalk's active hack).
is this possible?
that's what i did i excluded forums by not specifying them
i.e. for me
<?
require("/home/usr1/www.animeboards.net/htdocs/forums/admin/config.php");
$num_active = 10;
$num_chars = 90;
$db=mysql_connect($servername,$dbusername,$dbpassw ord);
mysql_select_db($dbname);
$querylatest="select * from thread where forumid='1' or forumid='2' or forumid='3' or forumid='4' or forumid='5' or forumid='6' or forumid='7' or forumid='8' or forumid='9' or forumid='10' or forumid='11' or forumid='12' or forumid='13' or forumid='14' or forumid='15' or forumid='16' or forumid='17' or forumid='18' or forumid='19' or forumid='20' or forumid='22' or forumid='23' or forumid='25' or forumid='26' or forumid='27' or forumid='28' or forumid='29' or forumid='30' or forumid='31' or forumid='32' or forumid='34' or forumid='35' or forumid='36' or forumid='37' or forumid='38' order by lastpost desc limit $num_active";
$resultlatest = mysql_query($querylatest,$db);
print("<center><table width=\"100%%\" cellspacing=\"0\" cellpadding=\"2\">");
while ($latest_array = mysql_fetch_array($resultlatest)) {
// Get Forum Infomation
$query_forum = "select * from forum where forumid='$latest_array[forumid]'";
$result_forum = mysql_query($query_forum,$db);
$forum_info_array = mysql_fetch_array($result_forum);
printf("<tr><td colspan=\"2\" bgcolor=\"#87A4C2\"><b><font color=\"#000000\" size=\"1\" face=\"Verdana, Arial, Helvetica, sans-serif\">%s: %s</font></b></td></tr>",$forum_info_array["title"],$latest_array["title"]);
// split the date up a bit
$datestr1 = substr($latest_array["dateline"],0,10);
$datetime = substr($latest_array["dateline"],11,8);
printf ("<tr valign=\"top\"><td width=\"15%%\" bgcolor=\"#B9B9B9\"><font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"1\"><b>%s</b><br>Updated: %s<br>Replies: %s</font></td>", $latest_array["postusername"], $datetime, $latest_array["replycount"]);
$querythread="select * from post where threadid='$latest_array[threadid]' order by dateline asc limit 1";
$result_thread_text= mysql_query($querythread,$db);
$result_thread_array = mysql_fetch_array($result_thread_text);
printf ("<td width=\"85%%\" bgcolor=\"#cccccc\"><font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"1\"><img src=\"/forums/images/icons/icon%s.gif\">?Last Post By: %s<hr>%s...<br><a href=\"/forums/showthread.php?threadid=%s\">Click here for more</font></td></tr>",$result_thread_array["iconid"],$latest_array["lastposter"],substr(strip_tags($result_thread_array["pagetext"]),0,$num_chars),$latest_array["threadid"]);
printf ("<tr><td colspan=\"2\" width=\"100%%\">?</td></tr>");
}
printf ("</table></center>");
?>
the part where is shows
forumid='1' or forumid='2' etc... it tells which forums to show... so leaving it out, hides the private forums :)
well you have to thank shri, tech talk and jimf :D
oh yeah 1 last thing is i need is the code to make the ctive users show up on a non vb page
something like
Currently there are x members and x guests on the forums.
Hi eva2000,
I tried your .txt examples but they were redirecting to your main forums page. I need Code help on the following stuff please?
1. Show Most Active Posters (number of active posters as variable)
example: Most Active Posters
POster 1 (number of posts)
Poster 2 (number of posts)
etc.
2. Show Last ($UNANSWERED TOPICS)
3. Show Forum Categories and Forums in Directory Tree Form
example:
Category 1
Forum 1 (number of posts)
Forum 2 (number of posts)
Forum 3 (number of posts)
Category 2
Forum 4 (number of posts)
Thanks and you guys rock!!!
okay here it is thanks to techtalk for these :D
1. http://animeboards.net/topposters.txt
2. http://animeboards.net/deadtopics.txt
3. don't know about that one but you could add the forum display one that techtalk did http://animeboards.net/forumlist.txt several times and select which forums you want each php include to display
in the above example
AND forumid != 21 AND forumid != 22 etc displays those forums...
you could do 2 includes for 2 categories and specify only the forums within that category
For the active Forums hack above you could change the SQL statement from
$querylatest="select * from thread where forumid='1' or
forumid='2' or forumid='3' or forumid='4' or forumid='5' or
forumid='6' or forumid='7' or forumid='8' or forumid='9' or
forumid='10' or forumid='11' or forumid='12' or
forumid='13' or forumid='14' or forumid='15' or
forumid='16' or forumid='17' or forumid='18' or
forumid='19' or forumid='20' or forumid='22' or
forumid='23' or forumid='25' or forumid='26' or
forumid='27' or forumid='28' or forumid='29' or
forumid='30' or forumid='31' or forumid='32' or
forumid='34' or forumid='35' or forumid='36' or forumid='37' or forumid='38'
order by lastpost desc limit
$num_active";
to
$querylatest="select * from thread where forumid in
('1','2','3','4','5','6','7','8','9','10','11','12 ','13','14'
,'15','16','17','18','19','20','22','23','25','26' ,'27','28'
,'29','30','31',32','34','35','36','37','38') order by
lastpost desc limit $num_active";
The second is shorter but both require you to change the code every time you add a new public forum. Now since you mark a forum as private or not then you can also use "where private='1'" in your SQL statement which shortens the whole SQL statement to:
$querylatest="select * from thread where select private != '1' from forum and thread.forumid=forum.forumid
order by lastpost desc limit $num_active";
Since I don't know that the forum table is called I just called it forum for simplicities sake.
Now I just have to learn PHP so I can understand what the rest of it does. :)
[Edited by wluke on 08-30-2000 at 01:04 AM]
Hi everyone.
This is my first post ever, and I'm very new to PHP and MySQL, though I'm good enough to be dangerous. That's why I need your help.
Let's say I have a forum in which only I post news items for my site. No postings by public allowed, though I don't know if that will make a difference to the hack.
I see the code you guys have been slinging around here, but cannot make enough progress in hacking it.
I want to take the very last item that's posted in my "private" forum for site news, and pull it into my homepage, with the headline and post time above it.
Possible? I know so. How, though?
Please help.
Originally posted by wluke
to
$querylatest="select * from thread where forumid in
('1','2','3','4','5','6','7','8','9','10','11','12 ','13','14'
,'15','16','17','18','19','20','22','23','25','26' ,'27','28'
,'29','30','31',32','34','35','36','37','38') order by
lastpost desc limit $num_active";
The second is shorter but both require you to change the code every time you add a new public forum. Now since you mark a forum as private or not then you can also use "where private='1'" in your SQL statement which shortens the whole SQL statement to:
$querylatest="select * from thread where select private != '1' from forum and thread.forumid=forum.forumid
order by lastpost desc limit $num_active";
note to those that asked about my frontpage at http://animeboards.net - i have yet to change the code to the above posted by wluke
so does the below
$querylatest="select * from thread where select private != '1' from forum and thread.forumid=forum.forumid
order by lastpost desc limit $num_active";
show all forums and hide all private forums (more than 1 private forum) ?
I need the active topics .txt for the 12 last active topics you have down the middle of your page Eva2000
Please. Thanks.
somehow all those links i did above are valid ? strange oh well
here's the last 12 active threads in the middle column
<?
$num_active = 12;
$num_chars = 95;
$db=mysql_connect($servername,$dbusername,$dbpassw ord);
mysql_select_db($dbname);
$querylatest="select * from thread where forumid='1' or forumid='2' or forumid='3' or forumid='4' or forumid='5' or forumid='6' or forumid='7' or forumid='8' or forumid='9' or forumid='10' or forumid='11' or forumid='12' or forumid='13' or forumid='14' or forumid='15' or forumid='16' or forumid='17' or forumid='18' or forumid='19' or forumid='20' or forumid='22' or forumid='23' or forumid='25' or forumid='26' or forumid='27' or forumid='28' or forumid='32' or forumid='34' or forumid='35' or forumid='36' or forumid='37' or forumid='38' order by lastpost desc limit $num_active";
$resultlatest = mysql_query($querylatest,$db);
print("<center><table width=\"100%%\" cellspacing=\"0\" cellpadding=\"2\">");
while ($latest_array = mysql_fetch_array($resultlatest)) {
// Get Forum Infomation
$query_forum = "select * from forum where forumid='$latest_array[forumid]'";
$result_forum = mysql_query($query_forum,$db);
$forum_info_array = mysql_fetch_array($result_forum);
printf("<tr><td colspan=\"2\" bgcolor=\"#87A4C2\"><b><font color=\"#000000\" size=\"1\" face=\"Verdana, Arial, Helvetica, sans-serif\">%s: %s</font></b></td></tr>",$forum_info_array["title"],$latest_array["title"]);
// split the date up a bit
$datestr1 = substr($latest_array["dateline"],0,10);
$datetime = substr($latest_array["dateline"],11,8);
printf ("<tr valign=\"top\"><td width=\"15%%\" bgcolor=\"#B9B9B9\"><font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"1\"><b>%s</b><br>Updated: %s<br>Replies: %s</font></td>", $latest_array["postusername"], $datetime, $latest_array["replycount"]);
$querythread="select * from post where threadid='$latest_array[threadid]' order by dateline asc limit 1";
$result_thread_text= mysql_query($querythread,$db);
$result_thread_array = mysql_fetch_array($result_thread_text);
printf ("<td width=\"85%%\" bgcolor=\"#cccccc\"><font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"1\"><img src=\"/forums/images/icons/icon%s.gif\">?Last Post By: %s<hr>%s...<br><a href=\"/forums/showthread.php?threadid=%s\">Click here for more</font></td></tr>",$result_thread_array["iconid"],$latest_array["lastposter"],substr(strip_tags($result_thread_array["pagetext"]),0,$num_chars),$latest_array["threadid"]);
printf ("<tr><td colspan=\"2\" width=\"100%%\">?</td></tr>");
}
printf ("</table></center>");
?>
i haven't tried replacing it with wluke's suggestion for the $querylatest= yet
$querylatest="select * from thread where select private != '1' from forum and thread.forumid=forum.forumid
order by lastpost desc limit $num_active";
I just want to add that I have not tested it yet and it is based entirely on my knowledge of SQL because I don't have any PHP knowledge yet but I am learning because I have a few hacks of my own in mind including integration with an PHP driven IRC chat client.
I will be willing to work with you though on making queries more efficient if you want.
I tried it and it did not work. I might have done it wrong though.
These additions seem to slow down MySQL a good amount. DO you find that to be the case?
http://www.paintballcity.com/index.php
[Edited by VirtueTech on 09-08-2000 at 11:27 AM]
Ok let me work on it some more and actually test it because there has to be a better way than listing every forum you want to show, which would require changing the hack if you expand.
Originally posted by VirtueTech
I tried it and it did not work. I might have done it wrong though.
These additions seem to slow down MySQL a good amount. DO you find that to be the case?
http://www.paintballcity.com/index.php
[Edited by VirtueTech on 09-08-2000 at 11:27 AM] do you mean wluke's alterations slow it down or just the last 12 active hacks as is, slows down mysql ?
i do notice my front page slows down with the hacks added to the front page...
Just all the add ons in general...that kind of sucks. Cause they look cool
Maybe there is a way to lower the calls to mysql
yeah it does look cool... i have been thinking of changing my frontpage again and maybe remove some of those hacks...
I think the slowness is related to MySQL.
If it supported stored procedures than most of these hacks could be run as native SQL code and that would decrease response time plus make upgrades easier.
Eva-
How did you tie all these pieces together to get to what you have on your front page? Did you put each section of code inside it's own .php file and include them into a frame set?
Thanks,
-Chris
yeah i put each hack into a php file and used a php include command to add them to the index page
Can someone help me create this hack and modify so that will list the top 25 posters that have visited within the last (XX) days? I have some very active posters that haven't visited in months, and I would like to have them not show up in this.
anybody knows how to make top posters in specific forum?
Originally posted by eva2000
yeah i put each hack into a php file and used a php include command to add them to the index page
I want to include these things on a portal page so that people visiting my site can see what the hot topics are going on at the moment.
Canb I include these hacks (and by the way, I need them :)) into an html page or do they have to be on a php page? if they have to be in a php page.
Any help would be great.
Yes they need to be in a PHP page, if your server doesn't parse .html for PHP code. Just copy any of the code snippets here that you need, and save them as something.php. Then your name your portal page index.php and inside there just use the include command to call something.php. It should look something like this:
<html>
<?php
include("something.php");
?>
</html>
Of course with all of your other html code for your main page in there as well.
-Chris
Originally posted by Chris Schreiber
Yes they need to be in a PHP page, if your server doesn't parse .html for PHP code. Just copy any of the code snippets here that you need, and save them as something.php. Then your name your portal page index.php and inside there just use the include command to call something.php. It should look something like this:
<html>
<?php
include("something.php");
?>
</html>
Of course with all of your other html code for your main page in there as well.
-Chris
Now I'm confused (I'm new at this) When people type in my url they will not get the .php index file, they get my .html index file. This is where I want to include this stuff. If there is a way that when people go to my url they will get the index.php file that would be great.
Another point where I'm lost is: I don't have a template in my list (from the admin control panel) for Index.php Should I be using the Forumhome.php file for this? Also, I copied the code for the topposts list that I want (one that I see on Eva2000's site and on Paintball.com) and created a template called Toppost. I then tried to insert the include command you gave me in the Forumhome file, but nothing showed up. I changed the "something.php" to toppost.php of course, but nothing, not even a bit of code showing through.
I really like the paintball home page, as it has everything I want to include in mine. But......
Thanks for your help.
I was thinking in totally the wrong terms. I started looking around my server at the php files and realized what I have to do. I was thinking I had to do this through the template files that are in the admin section. My bad. All straight now. :)
Originally posted by SoccerGazette.com
Thanks for your help.
I was thinking in totally the wrong terms. I started looking around my server at the php files and realized what I have to do. I was thinking I had to do this through the template files that are in the admin section. My bad. All straight now. :) sorry i missed the posts in here... glad to see it's working.
Any way to display members currently on the boards?
Hi! Can me anybody pleas send the "Active topics" File? Thank you!
Tho
Originally posted by eva2000
that's what i did i excluded forums by not specifying them
i.e. for me
<?
require("/home/usr1/www.animeboards.net/htdocs/forums/admin/config.php");
$num_active = 10;
$num_chars = 90;
$db=mysql_connect($servername,$dbusername,$dbpassw ord);
mysql_select_db($dbname);
$querylatest="select * from thread where forumid='1' or forumid='2' or forumid='3' or forumid='4' or forumid='5' or forumid='6' or forumid='7' or forumid='8' or forumid='9' or forumid='10' or forumid='11' or forumid='12' or forumid='13' or forumid='14' or forumid='15' or forumid='16' or forumid='17' or forumid='18' or forumid='19' or forumid='20' or forumid='22' or forumid='23' or forumid='25' or forumid='26' or forumid='27' or forumid='28' or forumid='29' or forumid='30' or forumid='31' or forumid='32' or forumid='34' or forumid='35' or forumid='36' or forumid='37' or forumid='38' order by lastpost desc limit $num_active";
$resultlatest = mysql_query($querylatest,$db);
print("<center><table width=\"100%%\" cellspacing=\"0\" cellpadding=\"2\">");
while ($latest_array = mysql_fetch_array($resultlatest)) {
// Get Forum Infomation
$query_forum = "select * from forum where forumid='$latest_array[forumid]'";
$result_forum = mysql_query($query_forum,$db);
$forum_info_array = mysql_fetch_array($result_forum);
printf("<tr><td colspan=\"2\" bgcolor=\"#87A4C2\"><b><font color=\"#000000\" size=\"1\" face=\"Verdana, Arial, Helvetica, sans-serif\">%s: %s</font></b></td></tr>",$forum_info_array["title"],$latest_array["title"]);
// split the date up a bit
$datestr1 = substr($latest_array["dateline"],0,10);
$datetime = substr($latest_array["dateline"],11,8);
printf ("<tr valign=\"top\"><td width=\"15%%\" bgcolor=\"#B9B9B9\"><font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"1\"><b>%s</b><br>Updated: %s<br>Replies: %s</font></td>", $latest_array["postusername"], $datetime, $latest_array["replycount"]);
$querythread="select * from post where threadid='$latest_array[threadid]' order by dateline asc limit 1";
$result_thread_text= mysql_query($querythread,$db);
$result_thread_array = mysql_fetch_array($result_thread_text);
printf ("<td width=\"85%%\" bgcolor=\"#cccccc\"><font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"1\"><img src=\"/forums/images/icons/icon%s.gif\">?Last Post By: %s<hr>%s...<br><a href=\"/forums/showthread.php?threadid=%s\">Click here for more</font></td></tr>",$result_thread_array["iconid"],$latest_array["lastposter"],substr(strip_tags($result_thread_array["pagetext"]),0,$num_chars),$latest_array["threadid"]);
printf ("<tr><td colspan=\"2\" width=\"100%%\">?</td></tr>");
}
printf ("</table></center>");
?>
the part where is shows
forumid='1' or forumid='2' etc... it tells which forums to show... so leaving it out, hides the private forums :)
If I run the above script I get this error
Warning: 0 is not a MySQL result index in /www/tuffsports/forum/test1.php3 on line 15
I keep will keep playing around but any guidence is appreciated.
Ok - dumb me
didnt have the require command in for some reason
Eva, I do not see your .txt file anywhere in these posts that show what you have here:
The Center Links Displaying Actual tables (http://animeboards.net/index4.php3)
I want to display the actual tables of last 5 posts like you did in
http://animeboards.net/index4.php3
Also forgot.. For y our top posters, I did what you have, but how can I put the number of posts next to it like in yours?
i.e. :
Top 25 Posters
? eva2000 (4571)
? Commander Atomic (3594)
? Oogami Ichirou (3076)
? Ko Hakaisha (2263)
? fireguy (2132)
? Wolfpac (2104)
thanks
I would really appreciate it if you can post the code for this.
Thanks A BUNCH!
note these were not written by me but techtalk, and others... you're need to include these into the non vb page i.e.
<?php
include("/path/to/activetopics.php");
?>
<?php
include("/path/topposters.php");
?>
last 5 active topics code:
<?
$num_active = 5;
$num_chars = 75;
$db=mysql_connect($servername,$dbusername,$dbpassw ord);
mysql_select_db($dbname);
$querylatest="select * from thread where forumid='1' or forumid='2' or forumid='3' or forumid='4' or forumid='5' or forumid='6' or forumid='7' or forumid='8' or forumid='10' or forumid='11' or forumid='12' or forumid='13' or forumid='14' or forumid='15' or forumid='16' or forumid='17' or forumid='18' or forumid='19' or forumid='20' or forumid='22' or forumid='23' or forumid='25' or forumid='26' or forumid='27' or forumid='28' or forumid='32' or forumid='34' or forumid='35' or forumid='36' or forumid='37' or forumid='38' or forumid='44' or forumid='45' or forumid='46' order by lastpost desc limit $num_active";
$resultlatest = mysql_query($querylatest,$db);
print("<center><table width=\"100%%\" cellspacing=\"0\" cellpadding=\"2\">");
while ($latest_array = mysql_fetch_array($resultlatest)) {
// Get Forum Infomation
$query_forum = "select * from forum where forumid='$latest_array[forumid]'";
$result_forum = mysql_query($query_forum,$db);
$forum_info_array = mysql_fetch_array($result_forum);
printf("<tr><td colspan=\"2\" bgcolor=\"#87A4C2\"><b><font color=\"#000000\" size=\"1\" face=\"Verdana, ArialHelveticasans-serif\">%s: %s</font></b></td></tr>",$forum_info_array["title"],$latest_array["title"]);
// split the date up a bit
$datestr1 = substr($latest_array["dateline"],0,10);
$datetime = substr($latest_array["dateline"],11,8);
printf ("<tr valign=\"top\"><td width=\"15%%\" bgcolor=\"#B9B9B9\"><font face=\"Verdana, ArialHelveticasans-serif\" size=\"1\"><b>%s</b><br>Updated: %s<br>Replies: %s</font></td>", $latest_array["postusername"], $datetime, $latest_array["replycount"]);
$querythread="select * from post where threadid='$latest_array[threadid]' order by dateline asc limit 1";
$result_thread_text= mysql_query($querythread,$db);
$result_thread_array = mysql_fetch_array($result_thread_text);
printf ("<td width=\"85%%\" bgcolor=\"#cccccc\"><font face=\"Verdana, ArialHelveticasans-serif\" size=\"1\"><img src=\"/forums/images/icons/icon%s.gif\">?Last Post By: %s<hr>%s...<br></font><a href=\"/forums/showthread.php?threadid=%s\"><font face=\"Verdana, ArialHelveticasans-serif\" size=\"1\">Click here for more</font></a></td></tr>",$result_thread_array["iconid"],$latest_array["lastposter"],substr(strip_tags($result_thread_array["pagetext"]),0,$num_chars),$latest_array["threadid"]);
printf ("<tr><td colspan=\"2\" width=\"100%%\">?</td></tr>");
}
printf ("</table>");
?>
top posters with post count:
<?php
// Set this to the max number top posters to display
$num = 25;
$db=mysql_connect($servername,$dbusername,$dbpassw ord);
mysql_select_db($dbname);
$query = "SELECT * FROM user ORDER BY posts DESC LIMIT $num";
$resultlatest = mysql_query($query,$db);
while ($latest_array = mysql_fetch_array($resultlatest)) {
echo "<FONT SIZE=\"1\" FACE=\"Verdana, Arial, Helvetica, sans-serif\">??
<A HREF=\"http://animeboards.net/forums/member.php?action=getinfo&userid=$latest_array[userid]\">$latest_array[username]</A>?($latest_array[posts])</FONT><BR>";
}
?>
Hi, Eva2000
Can I get http://animeboards.net/index3.php3 source?
I couldn't find this source.
The source link doesn't exist.
Please.... :)
Eva, I installed successfully the active topics hack, but I see that there is not the last time of update in each thread.
The same updated time in active topics is missing in http://www.animeboards.net
Thanks
[Edited by sinotto on 12-02-2000 at 02:22 PM]
I've sort of tidied it up a bit. And mine only displays the news (1st post of thread) from the news forum. If I wanted to do all forums, and mask off I would use forumid != whatever.
I've put the values in variables, which I then use in print(), rather than having to concatenate long strings and using printf() which I don't like.
Also a few additions: comment count, user email link.
So here goes:
<?
chdir("/home/ymuk/public_html/forum/");
include("global.php");
$num_active = 7;
$db=mysql_connect($servername,$dbusername,$dbpassw ord);
mysql_select_db($dbname);
$querylatest="SELECT * FROM thread WHERE forumid='2' ORDER BY dateline DESC LIMIT $num_active";
$resultlatest = mysql_query($querylatest,$db);
while ($latest_array = mysql_fetch_array($resultlatest)) {
// split the date up a bit
$datestr1 = substr($latest_array["dateline"],0,10);
$datetime = substr($latest_array["dateline"],11,8);
$querythread="SELECT * FROM post WHERE threadid='$latest_array[threadid]' ORDER BY dateline ASC LIMIT 1";
$result_thread_text= mysql_query($querythread,$db);
$result_thread_array = mysql_fetch_array($result_thread_text);
$newstitle = $latest_array["title"];
$newsposter = $latest_array["postusername"];
$newsposterid = $result_thread_array["userid"];
$newsdate = date("D j M Y", $latest_array["dateline"]);
$newstext = bbcodeparse($result_thread_array["pagetext"],2,1);
$newsthreadid = $latest_array["threadid"];
$newscomments = $latest_array["replycount"];
print("<font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"3\"><b>$newstitle</b></font><br>");
print("<font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"2\">Posted by
<a href=\"http://forum.ymuk.net/member.php?action=mailform&userid=$newsposterid\">$newsposter</a> on $newsdate
<br>$newstext<br><a href=\"http://forum.ymuk.net/showthread.php?threadid=$newsthreadid
\"><br>($newscomments comments...)</a></font></br></p>");
}
?>
I'm not sure, but there might be something wrong with the code in the Top Posters code above by eva2000. I keep getting this error message: Warning: Supplied argument is not a valid MySQL result resource in /home/jjr512/jjr512-www/bbs/topposters.php on line 10
I assume this is line 10, if the count starts at 0:
echo "<FONT SIZE=\"1\" FACE=\"Verdana, Arial, Helvetica, sans-serif\"> ?
Is that last character, the degree symbol, the problem? What is it supposed to be?
Actually, I've tried several of the scripts in here, and I get a similar error message each time.
Your problem is most probably something completely different, as I found out first-hand.
If you are including theses scripts in home.php for example, then right at the top of home.php, you need to do an include(/homes/whatever/public_html/forum/global.php);
if you don't do it, then your passing it a non-existing servername, so it doesn't return a handle, so everything breaks.
Please note that if you are using lots of these scriptlets (funny word :)) on one page, then you only need the one include at the top of the page that includes all the scriptlets.
Also, if you put the global include anywhere else in the file (ie. not top), you'll get a horrible header error.
That's my 2p's worth (UK Sterling you see!)
OK, thanks! It works now.
Now I have another question: When a user starts a post with no icon, this script tries to display icon0.gif, but because that file doesn't exist, I get a broken-image symbol. Can you write something to insert into the code, and show me what and where, that checks to see if the icon is icon0.gif, and if so, not try to display it? Thanks!
Did somebody find out how to get the current active users on a non-vB page hack yet?
With a little trial-and-error, I've answered my own question. I wrote a little if-else statement that tests if the iconid is 0, and if it is, returns an empty string to a new variable; if it is not 0, an image tag is returned to the new variable.
I also noticed that, at least in Saracen's version, it has a bit at the bottom that is a hyperlink to the thread. The link says "xx comments...", where xx is the number of comments. What I didn't like is that it always says "comments", even if the number is 1, so it would read "1 comments...". I could have changed it to "comment(s)", but I went for a more sophisticated approach. Again, I wrote a little if-else statement, that tests if the number of replies is 1, and if so, returns the text "reply" to a new variable. If it isn't 1, it returns the text "replies" to the new variable. (I changed the word "comment" or "comments" to "reply" or "replies", for my own personal preference.)
You can see how both these work below. Note that this has pretty much no formatting, but thanks to Saracen's use of defining variables and calling them in the generated HTML, it is much easier to add whatever formatting you want.
<?
include("/home/jjr512/jjr512-www/bbs/global.php");
$num_active = 7;
$num_chars = 125;
$db=mysql_connect($servername,$dbusername,$dbpassw ord);
mysql_select_db($dbname);
$querylatest="SELECT * FROM thread WHERE forumid='1' OR forumid='2' OR forumid='3' OR forumid='4' OR forumid='5' OR forumid='6' OR forumid='8' OR forumid='11' OR forumid='12' OR forumid='13' ORDER BY lastpost DESC LIMIT $num_active";
$resultlatest = mysql_query($querylatest,$db);
while ($latest_array = mysql_fetch_array($resultlatest)) {
// Get Forum Infomation
$query_forum = "select * from forum where forumid='$latest_array[forumid]'";
$result_forum = mysql_query($query_forum,$db);
$forum_info_array = mysql_fetch_array($result_forum);
// split the date up a bit
$datestr1 = substr($latest_array["dateline"],0,10);
$datetime = substr($latest_array["dateline"],11,8);
$querythread="SELECT * FROM post WHERE threadid='$latest_array[threadid]' ORDER BY dateline ASC LIMIT 1";
$result_thread_text= mysql_query($querythread,$db);
$result_thread_array = mysql_fetch_array($result_thread_text);
$newstitle = $latest_array["title"];
$newsposter = $latest_array["postusername"];
$newsposterid = $result_thread_array["userid"];
$newsdate = date("D j M Y", $latest_array["dateline"]);
$newstext = substr(strip_tags($result_thread_array["pagetext"]),0,$num_chars);
$newsthreadid = $latest_array["threadid"];
$newscomments = $latest_array["replycount"];
$threadforumid = $latest_array["forumid"];
$threadforum = $forum_info_array["title"];
$threadiconid = $latest_array["iconid"];
if ($threadiconid==0) {
$threadicon = "";
}
else {
$threadicon = "<img src=\"/bbs/images/icons/icon$threadiconid.gif\" alt=\"Thread icon\">?";
}
if ($newscomments==1) {
$commenttext = "reply ?";
}
else {
$commenttext = "replies ?";
}
print("<font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"3\"><b>$threadicon$newstitle</b></font><br>");
print("<font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"2\">Posted in <a href=\"http://www.jjr512.com/bbs/forumdisplay.php?forumid=$threadforumid\">$threadforum</a> by
<a href=\"http://www.jjr512.com/bbs/member.php?action=mailform&userid=$newsposterid\">$newsposter</a> on $newsdate:
<br>\"$newstext...\"<br><a href=\"http://www.jjr512.com/bbs/showthread.php?threadid=$newsthreadid
\">$newscomments $commenttext</a></font></br></p>");
}
?>
(Note that in the first if-else statement, the one about the icons, in the else section, between the end of the image tag and the "; where it look like there's a space, it was really the HTML non-breaking space command, but I guess it got interpreted for some reason, rather than displayed literally.)
This is my first real attempt at making such big changes to a hack for php/mysql. If anyone has any suggestions on improving what I did, I'd love to hear them! :)
[Edited by JJR512 on 12-15-2000 at 12:24 AM]
Well, although that runs fine when I run the file activetopics.php by itself, I seem to be having trouble including it. Sacremen, I stuck that include statement at the top of the main file, tried it various other places, tried it inside the activetopics.php file. I tried it with full absolute path, relative path, or URL to the file global.php. I always seem to get the "Warning: Supplied argument not a valid etc.".
If I put it anywhere inside the activetopics.php file, I get the msg "Warning: Cannot add header information - header already sent etc.".
I've also tried it both with the path in the include statement, or with the separate line with the chdir statement.
Obviously, I'm missing something. Can you explain it to me, please? Thanks!
Could somebody help me make 2 hacks like the one's TechTalk made earlier in this thread?
1 for showing the current active users (xx members online... xx guests online...)
& 1 for checking if the user has logged in or not, if logged in, then show the "welcome back _____", if not, then show the log in text boxes.
Please & thanks a lot ;)
LOL JJr...you tried too hard with that.....I just made a 1x1 pixel transparent gif and named it icon0.gif and uploaded it into the images/icons folder. :)
I considered that option, but decided against it. The reason was that, no matter what size you made the transparent icon, the size of the icon is defined in the image tag, so it gets stretched to full icon size. Well, you might say that doesn't matter, since it's transparent. True, but you do see an empty space. With the way I did it, if there is no icon, the text aligns to the edge of the table cell, rather than to the edge of an empty space. In my opinion, it just looks better.
But I'm still looking for help with the include global.php statement!
funny, it didn't on our page did it? http://www.friendswithoutfaces.com I don't see blank space where a posting icon would be. We're having trouble with the includes for top 25 posters, too. I can't seem to get it to work. But Kathy's already asked that question. <G>
:D
Just call me desparate. I want that TOP 25 POSTERS list on my main page. I think a little competition and reward is a good thing to help encourage posting.... maybe? :lol:
Someone help us out?
OK, I've gotten the results to show up. Now I have another question, about long text strings breaking the tables. Since I have this hack displaying in a table that is only 155 pixels wide, this can be a problem with even a simple URL. Is there a way to force it to split a line apart rather than let the table get wider?
Originally posted by Kathy
:D
Just call me desparate. I want that TOP 25 POSTERS list on my main page. I think a little competition and reward is a good thing to help encourage posting.... maybe? :lol:
Someone help us out?
I dont know the answer but sure hope you get one, I figured I asked enough questions so I wasnt going to ask - I just could not get teh dang thing to work.
But if I took the hack for most posts in the last 24 hours it worked fine, and you can change the time to go back a long times and giving you the same results as the top 25 hack - BUT in my case I cant use it because of a wierd glitch somewhere I had to prune a lot of messages and it will not count pruned messages in the persons post count.
OK, I've gotten it all worked out, with much help from Menno! This time, with the part that Menno added, if there is a URL that is so long that it would stretch the table, you don't have to worry. The part by Menno looks in the message text that would be displayed, and looks for the URL tags, and if it sees it, replaces the text of the hyperlink with the text (hyperlink). For an example, please look at my working test file, http://www.jjr512.com/newer.html
<?
$num_active = 6;
$num_chars = 75;
$db=mysql_connect($servername,$dbusername,$dbpassw ord);
mysql_select_db($dbname);
$querylatest="SELECT * FROM thread WHERE forumid='1' OR forumid='2' OR forumid='3' OR forumid='4' OR forumid='5' OR forumid='6' OR forumid='8' OR forumid='11' OR forumid='12' OR forumid='13' ORDER BY lastpost DESC LIMIT $num_active";
$resultlatest = mysql_query($querylatest,$db);
while ($latest_array = mysql_fetch_array($resultlatest)) {
// Get Forum Infomation
$query_forum = "select * from forum where forumid='$latest_array[forumid]'";
$result_forum = mysql_query($query_forum,$db);
$forum_info_array = mysql_fetch_array($result_forum);
// split the date up a bit
$datestr1 = substr($latest_array["dateline"],0,10);
$datetime = substr($latest_array["dateline"],11,8);
$querythread="SELECT * FROM post WHERE threadid='$latest_array[threadid]' ORDER BY dateline ASC LIMIT 1";
$result_thread_text= mysql_query($querythread,$db);
$result_thread_array = mysql_fetch_array($result_thread_text);
$newstitle = $latest_array["title"];
$newsposter = $latest_array["postusername"];
$newsposterid = $result_thread_array["userid"];
$newsdate = date("D j M Y", $latest_array["dateline"]);
$newstext = substr(strip_tags($result_thread_array["pagetext"]),0,$num_chars);
$newsthreadid = $latest_array["threadid"];
$newscomments = $latest_array["replycount"];
$threadforumid = $latest_array["forumid"];
$threadforum = $forum_info_array["title"];
$threadiconid = $latest_array["iconid"];
// split apart long URL strings
$newstext=eregi_replace("\\[url\\]www.([^\\[]*)\\[/url\\]","<a href=\"http://www.\\1\" target=_blank>\\1</a>",$newstext);
$newstext=eregi_replace("\\[url\\]([^\\[]*)\\[/url\\]","<a href=\"\\1\" target=_blank>(hyperlink)</a>",$text);
$newstext=eregi_replace("\\*)\"\\]([^\\[]*)\\[\\/url\\]","<a href=\"\\1\" target=_blank>\\2</a>",$newstext);
$newstext=eregi_replace("\\[url=([^\"]*)\\]([^\\[]*)\\[\\/url\\]","<a href=\"\\1\" target=_blank>(hyperlink)</a>",$newstext);
//special thank-you to Menno at vBulletin Community Forum for coming up with the above part!
if ($threadiconid==0) {
$threadicon = "";
}
else {
$threadicon = "<img src=\"/bbs/images/icons/icon$threadiconid.gif\" alt=\"Thread icon\"> ";
}
if ($newscomments==1) {
$commenttext = "reply ?";
}
else {
$commenttext = "replies ?";
}
print("
<table width=\"155\" cellpadding=\"2\">
<tr>
<td width=\"150\" bgcolor=\"#0066CC\" class=\"sidebar1\">
<b>$threadicon$newstitle</b><br>
</td>
</tr>
<tr>
<td width=\"150\" class=\"sidebar1\">
Posted in <a href=\"http://www.jjr512.com/bbs/forumdisplay.php?forumid=$threadforumid\" class=\"sidebar1\">$threadforum</a> by <a href=\"http://www.jjr512.com/bbs/member.php?action=mailform&userid=$newsposterid\" class=\"sidebar1\">$newsposter</a> on $newsdate:<br>
\"$newstext...\"<br><a href=\"http://www.jjr512.com/bbs/showthread.php?threadid=$newsthreadid\" class=\"sidebar1\">$newscomments $commenttext</a><br><p>
</td>
</tr>
</table>
");
}
?>
Here is a link to a text file containing the above, in case some part gets messed up: [url]http://www.jjr512.com/bbs/activetopics.txt (\"([^\")
Please note that because I could never get the global.php file to properly include, I just ended up replacing the four variables at the top for server, username, PW, and db name with the actual values. (Of course, I replaced them back before posting it here for you! ;))
This took a little figgerin' so I thought I'd post it so others wouldn't have to. This snippet is for non-VB pages, it will show the thread posted within the last 24 hours that has the most views.
If you change $daysback to something else, you can pull from the last week, etc.
require("/full/path/to/admin/config.php");
$db=mysql_connect($servername,$dbusername,$dbpassw ord);
mysql_select_db($dbname);
$daysback=1;
$datecut=time()-($daysback * 86400);
$query = "SELECT threadid,title,views,dateline FROM thread WHERE dateline > '".$datecut."' ORDER BY views DESC LIMIT 1";
$resultlatest = mysql_query($query,$db_connection);
$latest_array = mysql_fetch_array($resultlatest);
$mvtitle = $latest_array[title];
$mvid = $latest_array[threadid];
Then simply print out the $mvtitle and $mvid wherever you want to link to this active topic.
Oh yea.. I also run this piece of code on any thread title I pull-- if it's too long it will truncate it and add ...
if (strlen($latest_array["title"]) > 40) {
$mvtitle = substr($latest_array["title"],0,37) . "...";
}
Hi,
I'm sorry to bring this up now, but I need help. I want to display the ten latest topics on mymessage boards (http://scboards.cjb.net) automatically. I read many of the above posts and didn't find exactly what I'm looking for, that's why I'm posting here. I have little knowledge of PHP and MySQL, so don't confuse me too much. :) I want to exclude posts from a few boards and I just wanted to list them on my main page.
It is my assumption that if I use a PHP code, I can modify my .htaccess file to read the PHP on my main page and make it not require the .shtml extension to be changed to .php3. Any help would be appreciated.
Originally posted by M. James
It is my assumption that if I use a PHP code, I can modify my .htaccess file to read the PHP on my main page and make it not require the .shtml extension to be changed to .php3. Any help would be appreciated.
Add this to you .htaccess file
AddType application/x-httpd-php3 .shtml
Script for Active topics, anumber of people have worked on this including Dark_Wizard.
BTW... Has anyone added vB templates to this script, if so could you share or tell me how to do it.
<?
require("config.php");
// number of active topics to show
$num_active = 5;
// number of pagetext characters to show
$num_chars = 70;
$db=mysql_connect($servername,$dbusername,$dbpassw ord);
mysql_select_db($dbname);
// Remove the forums you don't want listed
$querylatest="select * from thread where forumid='1' or forumid='2' or forumid='3' or forumid='4' or forumid='5' or forumid='6' or forumid='7' or forumid='8' or forumid='10' or forumid='11' or forumid='12' or forumid='13' or forumid='14' or forumid='15' or forumid='16' or forumid='17' or forumid='18' or forumid='19' or forumid='20' or forumid='22' or forumid='23' or forumid='25' or forumid='26' or forumid='27' or forumid='28' or forumid='29' or forumid='30' or forumid='31' or forumid='32' or forumid='34' or forumid='35' or forumid='36' or forumid='37' or forumid='38' order by lastpost desc limit $num_active";
$resultlatest = mysql_query($querylatest,$db);
print("<center><table width=\"100%%\" cellspacing=\"0\" cellpadding=\"2\">");
while ($latest_array = mysql_fetch_array($resultlatest)) {
// Get Forum Infomation
$query_forum = "select * from forum where forumid='$latest_array[forumid]'";
$result_forum = mysql_query($query_forum,$db);
$forum_info_array = mysql_fetch_array($result_forum);
// split the date up a bit
$datestr1 = substr($latest_array["dateline"],0,10);
$datetime = substr($latest_array["dateline"],11,8);
printf("<tr><td align=\"left\"><b><font color=\"#FFFFCC\" size=\"1\" face=\"Verdana, Arial, Helvetica, sans-serif\">%s: %s</font></b></td></tr>",$forum_info_array["title"],$latest_array["title"]);
$querythread="select * from post where threadid='$latest_array[threadid]' order by dateline asc limit 1";
$result_thread_text= mysql_query($querythread,$db);
$result_thread_array = mysql_fetch_array($result_thread_text);
printf ("<td width=\"100%%\"><font color=\"#FFCC66\" face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"1\"><img src=\"images/icons/icon%s.gif\"> Started By: %s Last Post By: %s<br><font color=\"#FFFFFF\">%s...<a href=\"showthread.php?threadid=%s\"> (Click here for more)</font></a><hr color=\"#003366\"></td></tr>",$result_thread_array["iconid"],$latest_array["postusername"],$latest_array["lastposter"],substr(strip_tags($result_thread_array["pagetext"]),0,$num_chars),$latest_array["threadid"]);
printf ("<tr><td width=\"100%%\"> </td></tr>");
}
printf ("</table></center>");
?>
Evoir
08-18-2001, 04:46 PM
Is there a way to use an SSI to include this script? Does it have to be called with a php include?
jcroft
08-28-2001, 06:24 PM
Can anyone post the code for displaying currently logged on members in a non-vb page?
Thanks a lot,
Jeff Croft
newBeetle.org
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.