Home
>
Outdated forums
>
Phorum 3 forums (READ ONLY)
>
Finished Mods and Plug-ins (READ ONLY)
>
Topic
>
Page 2
Hack to display last posts in another document
Posted by Rene
act
Re: Hack to display last... on the index.php file June 11, 2001 03:35AM |
--------------------------------------------------------
$i = 0;
while($subject[$i]) {
if(strlen($subject[$i]) >= 15){ $subject[$i] = substr ($subject[$i], 0, 15)."..."; }
$i++;
}
--------------------------------------------------------
Hi, I also want to limit the lenght of subject at the original phorum,default set to 255 chatrecters but it mess my table..
I dont know where to put this code
Re: Hack to display last posts in another document August 12, 2001 10:22AM |
Re: Hack to display last posts in another document August 12, 2001 03:18PM |
You should count post on each database table of the forum, for example in two tables "table1" and "music:
$cvbn = @mysql_fetch_row(@mysql_query("select count(id) from table1"));
$cvbna = @mysql_fetch_row(@mysql_query("select count(id) from music"));
echo "In the Phorum".($cvbn[0]+$cvbna[0])."posts";
If you want display number of registered user, try use the follow:
$cusr = @mysql_fetch_row(@mysql_query("select count(id) from forums_auth"));
echo "Registered users $cusr";
$cvbn = @mysql_fetch_row(@mysql_query("select count(id) from table1"));
$cvbna = @mysql_fetch_row(@mysql_query("select count(id) from music"));
echo "In the Phorum".($cvbn[0]+$cvbna[0])."posts";
If you want display number of registered user, try use the follow:
$cusr = @mysql_fetch_row(@mysql_query("select count(id) from forums_auth"));
echo "Registered users $cusr";
Re: Hack to display last posts in another document August 12, 2001 04:27PM |
Re: Hack to display last posts in another document August 16, 2001 11:21AM |
I'm running into similar problems as those mentioned above. To be more specific, I'm getting no output in the browser. Absolutely nothing displays. I know this question has already been posted, but I didn't see a resolution throughout the thread.
I'm using the exact code (I've checked and rechecked many times) that Rene originally posted and the script is in the following location:
../phorum/
I've named the script get_posts.php. I'm a new PHP coder, so I wouldn't be surprised if I missing something very basic and I apologize if I am. Is this code supposed to be somewhere else?
Any help is very much appreciated!
I'm using the exact code (I've checked and rechecked many times) that Rene originally posted and the script is in the following location:
../phorum/
I've named the script get_posts.php. I'm a new PHP coder, so I wouldn't be surprised if I missing something very basic and I apologize if I am. Is this code supposed to be somewhere else?
Any help is very much appreciated!
Re: Hack to display last posts in another document August 16, 2001 11:49AM |
Well, I figured out my problem, other than the fact that I'm a newbie PHP coder.. :]
The reason why it wasn't displaying anything was because my query had a typo. The query I had was:
$SQL="select id, thread, author, subject, datestamp from $Forum TableName order by datestamp desc limit $number";
The problem was the fact that I had a space between "$Forum" and "TableName", which makes it an invalid query and thus the reason for nothing being displayed. Once I made the correction to "$ForumTableName", my browser displayed the last 5 posts.
That's what I get for typing the code in myself and not doing a copy/paste. Sorry for cluttering up the newsgroup, but I hope someone learned something from my idiotic mistake... :]
The reason why it wasn't displaying anything was because my query had a typo. The query I had was:
$SQL="select id, thread, author, subject, datestamp from $Forum TableName order by datestamp desc limit $number";
The problem was the fact that I had a space between "$Forum" and "TableName", which makes it an invalid query and thus the reason for nothing being displayed. Once I made the correction to "$ForumTableName", my browser displayed the last 5 posts.
That's what I get for typing the code in myself and not doing a copy/paste. Sorry for cluttering up the newsgroup, but I hope someone learned something from my idiotic mistake... :]
Re: Hack to display la.... for multiple forums. August 17, 2001 10:31PM |
I've been up for four hours or so trying to find way of doing this, without success. What I am trying to do is to have the five latest topics for four different forums on my main page as well as every other, including the forum pages. This can easily be achieved with an include.
My problem is that I can't come up with some code that displays topics for multiple forums, I have written tons of code that "should" work, in theory anyway....
The closest I came were multiple instances of the same forum's topics, and if I include it on a phorum page, it only displays the topics of the active forum.
Can someone please help me, I have a deadline in one month.
Best Regards
Lasse Jellum
My problem is that I can't come up with some code that displays topics for multiple forums, I have written tons of code that "should" work, in theory anyway....
The closest I came were multiple instances of the same forum's topics, and if I include it on a phorum page, it only displays the topics of the active forum.
Can someone please help me, I have a deadline in one month.
Best Regards
Lasse Jellum
Re: Hack to display last posts in another document August 17, 2001 10:34PM |
Re: Hack to display la.... for multiple forums. August 20, 2001 05:58AM |
Re: Hack to display la.... for multiple forums. August 20, 2001 10:49AM |
X
Re: Hack to display la.... for multiple forums. August 21, 2001 11:09PM |
Re: Hack to display la.... for multiple forums. August 29, 2001 06:12AM |
Is there a way to avoid using common.php? What would my code be to skip this file. I'm trying to include this code but since I already have a database opened I get all sorts of errors since it then tries to use my phorum db afterwards.
I want to include this code independent of the other phorum code. Is this possible, and if so, how?
- Ståle
I want to include this code independent of the other phorum code. Is this possible, and if so, how?
- Ståle
Re: Hack to display la.... for multiple forums. August 29, 2001 12:24PM |
meta-script that does all forums September 10, 2001 04:51PM |
Hi,
Attached is something called 'quickphorum.php' that we use at RPGnet to show "all the forums at a glance". It recursively uses the main index (set as $baseurl) and displays the 5 (or whatever you set $limit to) most recent posts. An example in use is:
[www.rpg.net]
The nice thing is it uses the main phorum index and which forums are active, ergo, you don't need to recode it for specific sites.
Cheers,
Sandy
sandy@rpg.net
(p.s. I'd submitted this way back when the phorum@ email list was up, I guess it never became semi-official).
Attached is something called 'quickphorum.php' that we use at RPGnet to show "all the forums at a glance". It recursively uses the main index (set as $baseurl) and displays the 5 (or whatever you set $limit to) most recent posts. An example in use is:
[www.rpg.net]
The nice thing is it uses the main phorum index and which forums are active, ergo, you don't need to recode it for specific sites.
Cheers,
Sandy
sandy@rpg.net
(p.s. I'd submitted this way back when the phorum@ email list was up, I guess it never became semi-official).
X
Re: meta-script that does all forums September 10, 2001 06:08PM |
Delirious
Re: meta-script that does all forums January 21, 2002 12:52PM |
Too dumb to understand basic instruction January 21, 2002 10:29PM |
I'm too stoopid and need someone to hold my hand. Here is the section of code...
if($DB->type=="postgresql"){
$limit="";
$q->query($DB, "set QUERY_LIMIT TO '$ForumDisplay'");
}
else{
$limit=" limit $ForumDisplay";
}
The file says:
# required phorum mode: add to list.php
# 'elseif (isset($limit)) {
# $limit=" limit $limit";'
# right before '$limit=" limit $ForumDisplay"'
does this then mean that the code should read..
if($DB->type=="postgresql"){
$limit="";
$q->query($DB, "set QUERY_LIMIT TO '$ForumDisplay'");
}
else{
elseif (isset($limit)) {
$limit=" limit $limit";'
$limit=" limit $ForumDisplay";
}
Thanx
if($DB->type=="postgresql"){
$limit="";
$q->query($DB, "set QUERY_LIMIT TO '$ForumDisplay'");
}
else{
$limit=" limit $ForumDisplay";
}
The file says:
# required phorum mode: add to list.php
# 'elseif (isset($limit)) {
# $limit=" limit $limit";'
# right before '$limit=" limit $ForumDisplay"'
does this then mean that the code should read..
if($DB->type=="postgresql"){
$limit="";
$q->query($DB, "set QUERY_LIMIT TO '$ForumDisplay'");
}
else{
elseif (isset($limit)) {
$limit=" limit $limit";'
$limit=" limit $ForumDisplay";
}
Thanx
No, I'm too dumb to write clearly :) January 22, 2002 11:25PM |
Hi,
It should read like this:
if($DB->type=="postgresql"){
$limit="";
$q->query($DB, "set QUERY_LIMIT TO '$ForumDisplay'");
}
elseif (isset($limit)) {
$limit=" limit $limit";
} else{
$limit=" limit $ForumDisplay";
}
Enjoy!
Sandy
sandy@rpg.net
It should read like this:
if($DB->type=="postgresql"){
$limit="";
$q->query($DB, "set QUERY_LIMIT TO '$ForumDisplay'");
}
elseif (isset($limit)) {
$limit=" limit $limit";
} else{
$limit=" limit $ForumDisplay";
}
Enjoy!
Sandy
sandy@rpg.net
Failed January 31, 2002 08:31PM |
following error:
Warning: file("[www.realm.com] &limit=5") - Success in /home/httpd/vhosts/realm.com/httpdocs/phorum/quickforum.php on line 28
Warning: Variable passed to each() is not an array or object in /home/httpd/vhosts/realm.com/httpdocs/phorum/quickphorum.php on line 30
:(
Warning: file("[www.realm.com] &limit=5") - Success in /home/httpd/vhosts/realm.com/httpdocs/phorum/quickforum.php on line 28
Warning: Variable passed to each() is not an array or object in /home/httpd/vhosts/realm.com/httpdocs/phorum/quickphorum.php on line 30
:(
Re: Hack to display la.... for multiple forums. February 04, 2002 11:59PM |
Hi All,
After all I've made a complete rewrite of Dianas Hack (there've been just the PHP Short Open Tags and the include-statement left ...).
My Script Lists now the latest $number Headers of all Forums, that are not "secured". There are two ways to use the Script:
With or without own Output.
Without Output? Yes!
If you put it into a secured Directory (or out of the Webservers accessible Path), so no external Websites can abuse your Phorums Messages, you will have to "include" it and build the "visual" Data on your own. I'll come back to this later ...
Configuration:
You will possibly want to edit the default Date format $dfmt into the one you prefer (reference: www.php.net/date).
The other Settings would be the default number $number of shown messages, the time format $tfmt, and the path chdir(...).
Usage:
1.) Access via http:
put
$lastpostings = "[$SERVER_NAME];;
[array] = file($lastpostings);
into the page you want it to be (the function readfile() would put it directly on the stdout -> www.php.net/readfile).
The parameter "number" is optional.
I've written two routines (show=1, show=2) to generate output:
they are not pretty, but demonstrate how it works.
show=1 generates for each message header a new line and show=2 generates a full Table.
2.) Include in your Script:
Here you have to use $number definition set in my script.
If the (your) calling script already includes other parts of Phorum, you will have to replace 'include("./common.php");' with 'include_once("./common.php")'.
After the include statement in Your Script, you can grab the data out of the array $sorted[$i]; $i=0 points to the most recent message.
Each element of this array is again an array! Here the keys and values:
$sorted[$i][name] // name of the forum where the message resides
$sorted[$i][timestamp] // unix timestamp of the message to use with date();
$sorted[$i][author] // the authors name
$sorted[$i][subject] // Subject of the message
$sorted[$i][ ]
After all I've made a complete rewrite of Dianas Hack (there've been just the PHP Short Open Tags and the include-statement left ...).
My Script Lists now the latest $number Headers of all Forums, that are not "secured". There are two ways to use the Script:
With or without own Output.
Without Output? Yes!
If you put it into a secured Directory (or out of the Webservers accessible Path), so no external Websites can abuse your Phorums Messages, you will have to "include" it and build the "visual" Data on your own. I'll come back to this later ...
Configuration:
You will possibly want to edit the default Date format $dfmt into the one you prefer (reference: www.php.net/date).
The other Settings would be the default number $number of shown messages, the time format $tfmt, and the path chdir(...).
Usage:
1.) Access via http:
put
$lastpostings = "[$SERVER_NAME];;
[array] = file($lastpostings);
into the page you want it to be (the function readfile() would put it directly on the stdout -> www.php.net/readfile).
The parameter "number" is optional.
I've written two routines (show=1, show=2) to generate output:
they are not pretty, but demonstrate how it works.
show=1 generates for each message header a new line and show=2 generates a full Table.
2.) Include in your Script:
Here you have to use $number definition set in my script.
If the (your) calling script already includes other parts of Phorum, you will have to replace 'include("./common.php");' with 'include_once("./common.php")'.
After the include statement in Your Script, you can grab the data out of the array $sorted[$i]; $i=0 points to the most recent message.
Each element of this array is again an array! Here the keys and values:
$sorted[$i][name] // name of the forum where the message resides
$sorted[$i][timestamp] // unix timestamp of the message to use with date();
$sorted[$i][author] // the authors name
$sorted[$i][subject] // Subject of the message
$sorted[$i][ ]
Sorry, you do not have permission to post/reply in this forum.