PDA

View Full Version : Help! Please review this code: Trying to get "latest topics" to show on front page.


Jyaki
03-09-2001, 07:28 PM
I have been trying to implement this hack, but since it's so scattered, I am having a hard time applying it.

If you can spare a moment, please tell me what I am doing wrong.

1. I've created "active.inc.php" file and uploaded into forum/admin.


<?php
// Set this to the max number of threads to display
$maxthreads = 5;

require("http://www.anesthesiaforums.com/forums/admin/config.php");
$db=mysql_connect($servername,$dbusername,$dbpassw ord);
mysql_select_db($dbname);
$query = "SELECT * FROM thread ORDER BY lastpost DESC LIMIT $maxthreads";
$resultlatest = mysql_query($query,$db);
while ($latest_array = mysql_fetch_array($resultlatest)) {
echo "<FONT SIZE=\"2\" FACE=\"Verdana, Arial, Helvetica, sans-serif\"> ?
<A HREF=\"http://www.anesthesiaforums.com/forums/showthread.php?threadid=$latest_array[threadid]\">$latest_array[title]</A></FONT><BR>";
}

?>


2. Now on my homepage, "default.htm", I've added:
<?php
include("http://www.anesthesiaforums.com/forums/admin/active.inc.php");
?>

Within the body tags where I would like the information to dispay.

The problem is, nothing is showing up.
Thanks
-Hideki

03-10-2001, 07:38 AM
"default.html" should be "default.php" if you want to parse it as php

03-10-2001, 02:04 PM
Menno, thanks for the reply,
I was under the impression that the entire purpose of this hack was to display vB elements on a non PHP page. Am I mistaken?

So, people who have latest threads, total number of members, etc. on their homepage/front page are actually using default.php instead of default.htm?

Thanks again.
-Hideki :)

03-10-2001, 02:10 PM
The purpose is to display vB elements on non-vB pages. On my site, all the pages are *.php, as I run scripts on various pages throughout it.

Hope this helps :)

03-10-2001, 02:10 PM
Hes saying that in order to do that as a php command you need a php file.. in order to do it as a SSI command you should change your extension to .shtml and use

<!--#include virtual="../forums/admin/active.inc.php"-->

I believe

03-10-2001, 02:11 PM
I don't know if that would work...calling a PHP file from a SSI. It might not parse the PHP...be interesting to try it and find out. ;)

03-10-2001, 02:14 PM
It will work fine, the only thing Im unsure of is if it should be called like that. I used the code in sidebars which were in a subdirectory thus the [ ../forum/blah/ ]

03-10-2001, 02:24 PM
Thanks guys,
I really appreciate your help. Hopefully it will work now.
Question, I'm not too familiar with the .shtml extension. Could you give me a bit more info on it?
Thanks
-Hideki

03-10-2001, 02:24 PM
Yeah that's the correct syntax, except remove the .. so it looks like
<!--#include virtual="/forums/admin/active.inc.php"-->
otherwise it will try to go up one directory before looking for the "forums" directory. Assuming the forums directory is right below the root, i.e.
root [aka yoursite.com/]
--> forums (subdirectory) [aka yoursite.com/forums/]
it will work just fine. :D

03-10-2001, 02:33 PM
The SHTML or SHTM extension is for files that are server-parsed for SSI (server side includes). Basically it allows you to include stuff like the contents of another file, various stuff about the current file, and even execute scripts (CGI, PHP, etc) as we're doing in this case.

You can find more info here (http://www.sales-support4u.com/manual/chpt18.html). ;)

03-10-2001, 03:20 PM
I have set it up that way, through SSI calls, and I can tell you it works just fine, as tubedogg said :)
I have been using this syntax without problems:
<!--#include virtual="/forums/active.inc.php"-->

03-10-2001, 03:29 PM
good job tubedog :p

03-10-2001, 03:32 PM
Thank you :D

I help where I can. ;)

03-10-2001, 03:33 PM
<seriously off-topic emotional outburst>
YES!!!!!!!! With that previous post I have become a Senior Member! YAY YAY YAY!
</seriously off-topic emotional outburst>

:D

03-10-2001, 03:38 PM
<seriously off-topic emotional outburst>
good job tubedogg
</seriously off-topic emotional outburst>

On another off topic note only 60+ more good job tubedoggs and I will also be a senior member :p

03-12-2001, 02:13 PM
Great! It finally worked.

Now, I've searched through the site, but could not find the codes for these. Does anybody know how to display polls and currently active users on non vb pages?
Thanks again

Evoir
08-17-2001, 02:22 AM
I got this beautiful little hack to work (not sure who to thank-but I thank whoever is responsible) :)

BUT, it seems to be showing even our private forums, including the moderators chat. NOT COOL. I had to take it down.

Is there some modification that will stop any private forum from showing on this non-vb page?

I know nothing about php, but I can follow good directions :D

Evoir
08-17-2001, 02:51 AM
ok. I still know nothing about php :D

but, it seems to me that it shouldn't be difficult to add usergroups to this little hack. Anyone have any idea how this would be done?

in other words: I'd like to be able to list the usergroups from whom this information is pulled.

Here is the hack code, how would I make it so it only shows posts of, say... usergroup: members?


<?php
// Set this to the max number of threads to display
$maxthreads = 5;

require("/path/to/my/admin/config.php");
$db=mysql_connect($servername,$dbusername,$dbpassw ord);
mysql_select_db($dbname);
$query = "SELECT * FROM thread ORDER BY lastpost DESC LIMIT $maxthreads";
$resultlatest = mysql_query($query,$db);
while ($latest_array = mysql_fetch_array($resultlatest)) {
echo "<FONT SIZE=\"2\" FACE=\"Verdana, Arial, Helvetica, sans-serif\"> ?
<A HREF=\"http://www.mysite.com/forum/showthread.php?threadid=$latest_array[threadid]\">$latest_array[title]</A></FONT><BR>";
}

?>

BDJ
08-17-2001, 08:59 AM
Well, here's some code to make it so it doesn't show threads private forums:
(I'm guessing this will work)


SELECT * FROM thread LEFT JOIN forumpermission ON (forumpermission.forumid=thread.forumid) WHERE forumpermission.canview=1 ORDER BY lastpost DESC LIMIT 0,$maxthreads


Try that..

Evoir
08-17-2001, 04:58 PM
Ok, what I did was replace the code in the hack that resembled your suggestion :)

Now, it ONLY shows the private forums. I tried switching the word ON to OFF and it showed nothing when I did that. here is the modified code:


<?php
// Set this to the max number of threads to display
$maxthreads = 5;

require("/path/to/my/admin/config.php");
$db=mysql_connect($servername,$dbusername,$dbpassw ord);
mysql_select_db($dbname);
$query = "SELECT * FROM thread LEFT JOIN forumpermission ON (forumpermission.forumid=thread.forumid) WHERE forumpermission.canview=1 ORDER BY lastpost DESC LIMIT 0,$maxthreads";
$resultlatest = mysql_query($query,$db);
while ($latest_array = mysql_fetch_array($resultlatest)) {
echo "<FONT SIZE=\"2\" FACE=\"Verdana, Arial, Helvetica, sans-serif\"> ?
<A HREF=\"http://www.domain.com/forum/showthread.php?threadid=$latest_array[threadid]\">$latest_array[title]</A></FONT><BR>";
}

?>


can anyone help me? I really would like to sue this, but I must have the private forums NOT listed in the output.

BDJ
08-17-2001, 09:29 PM
SELECT * FROM thread LEFT JOIN forumpermission ON (forumpermission.forumid=thread.forumid) WHERE forumpermission.canview=1 AND forumpermission.usergroupid=2 ORDER BY lastpost DESC LIMIT 0,$maxthreads


Maybe that
;)

Evoir
08-17-2001, 10:08 PM
I do appreciate your help, but, it isn't working still.

when I changed it with your last suggestion, I get no output. Still hoping to find an answer for this. I can't believe this hasn't come up for anyone else using this hack! comon and help me out. I promise to be nice :D

Evoir
08-18-2001, 12:13 AM
Ok, it took me this long to find it, but I did. My solution lies in tubedogg's fabulous last10 hack.

I wish I had known that yesterday! So, for those of you who don't know what I am talking about, tubedogg made this really cool, really customizable hack. here it is (http://www.vbulletin.com/forum/showthread.php?s=&threadid=12324&highlight=last10) .

Thanks tubedogg!

Evoir
08-18-2001, 03:33 PM
ok, even though I very much like tubedoggs last10 hack, it doesn't show html tags properly in a mac environment. I cant change the text color or size or type in Nescape, and in IE, I cant change the color of the text.

So, I am back to this hack. :(

This one I can controll the html tags really simply. So, is there anyone who can help me? I'd like to add a line that excludes whichever forums I list by number. That could make it simpler...no?

Evoir
08-18-2001, 06:47 PM
I really liek the simplicity of this particular version of this hack. (that is it a simple list of the last threads.) I must, however, protect my private forums.

I have come up with this:



<?php
// Set this to the max number of threads to display
$maxthreads = 5;

require("http://www.mysite.com/forum/admin/config.php");
$db=mysql_connect($servername,$dbusername,$dbpassw ord);
mysql_select_db($dbname);
$querylatest="select * from thread where forumid in ('113','120','97','98','112','114','117','122','93 ','95','107','110','101','102','103','104','105',' 111','100','96','99','94','116','108','115','118', '123','106') order by lastpost desc limit $num_active";

$resultlatest = mysql_query($query,$db);
while ($latest_array = mysql_fetch_array($resultlatest)) {
echo "<FONT SIZE=\"2\" FACE=\"Verdana, Arial, Helvetica, sans-serif\"> ?
<A HREF=\"http://www.mysite.com/forum/showthread.php?threadid=$latest_array[threadid]\">$latest_array[title]</A></FONT><BR>";
}

?>



This shows nothing on the page. The thing I changed was:


$query = "SELECT * FROM thread ORDER BY lastpost DESC LIMIT $maxthreads";


Which showed it perfectly (but also showed private forums)

to:


$querylatest="select * from thread where forumid in ('113','120','97','98','112','114','117','122','93 ','95','107','110','101','102','103','104','105',' 111','100','96','99','94','116','108','115','118', '123','106') order by lastpost desc limit $num_active";



based on what I could figure out from another thread on this topic.

I really like the output of this script (simple) but I must be able to control the private forums. Please help me?