Firefox PHP

Hack to display last posts in another document

Posted by Rene 
For some reason, i've not been able to post the attachment - sorry!
(Is it Mozilla 0.9.7, Squid or Phorum?)

So I've put it on my Webserver:
[www.buchzik.de]

If you "accidently" surf over my homepage: It's in german, I appologize!
And please don't feel disturbed about the ugly Forum software (WBB 1.1.1 - full of bugs!!!!) installed: I've installed Phorum yesterday the first time and had absolutely no idea before, how nice it is! WBB will be replaced with Phorum in near future ;)

Greetings from Bayreuth - Germany,

Michael
UPDATE: v0.2 of this Hack will now also show parental folder names!

Demo: [www.buchzik.de] (sorry, german language only!)
Download: [www.buchzik.de]
Questions: [www.buchzik.de] (english or german please)

Michael
Display a forum ERROR
May 18, 2002 08:57PM
When trying to show a forums header on another page, I keep geting the following error message:

Warning: Cannot add header information - headers already sent by (output started at /home/noshorn/public_html/nya/index.php:15) in /home/noshorn/public_html/nya/forum/common.php on line 348


Now, I'm wondering... Why!? It would be grat if someone could help me... And, one more thing, I'm really a newbie... just starting to lurn a little what php is... So, pleas explain careful for little me... :)
Re: Hack to display last posts in another document
July 26, 2002 06:48AM
OK, I've tried different hacks for this before, couldn't get them working. All I want is the last three thread subjects (no date, author etc.) to show on my home page. Links would be great.

I tried Diana's hack above. I put her entire file into a file named quickforum.php. All I changed was:

$baseurl = "[barntowire.com];;
if (empty($limit)) {
$limit = 3; # default max number of threads to list
}

Then I included quickforum.php into the appropriate spot on the home page.

What I end up with is this:
[www.barntowire.com]

It is listing all posts, with the letters new after each link. About half way through it also starts adding authors.

It is picking up the "3" in the echo, but do I need to add that somewhere else as well?

I'm using Phorum 3.3.2a.

Thanks for any help!
Janine
hi, i succeded when i installed the hack which allows us to see the last 5 posts (for example) but now i want, if the title of the subject is to long (like hellohello hello hello hello), the title to be short, i mean like "hellohello..."

i know there is already a script (here, on the same page) but i can get it works! the only result of the script is to show "..." after each word!

so, do u have a solutions guys?
Hi!

I'm using Rene´s modified hack and tried to incorporate the 15-letter limit.
Rene´s hack works great, but the 15-letter limit doesn't work, that is, nothing happens, not even any error msg.

the code is as follows:

<?
// Original hack by Rene displays last 5 postings in forum 1.
//This hack will show the last 3 posted headlines in each forum sectioned by folders if any
chdir("../phorum/"); //again, don't forget to change this to suit your phorum dir.
include_once("./common.php");
$curr_par = "";
$par = "";
$number=3; // number of messages to show.

//omit or change the forum name for your test forums.
// we select active forums tables that are not folders
$sSQL="Select id, name, table_name, parent from ".$pho_main." where active=1 and folder='0' and name!='Test' order by parent";
$q->query($DB, $sSQL);
$rec=$q->getrow();
if(is_array($rec)){
  while(is_array($rec)){
    //get folder name
    if ($rec[parent]>0) {
      $pSQL="Select name from ".$pho_main." where id=$rec[parent]";
      $pq = new query($DB, $pSQL);
      $prec=$pq->getrow();
      $par = $prec[name];
    }
    $SQL="select id, thread, author, subject, datestamp from $rec[table_name] order by datestamp desc limit $number";
    $nq = new query($DB, $SQL);
    $nrec=$nq->getrow();
    if(is_array($nrec)) {
      if ($curr_par != $par) echo "<br><b>$par</b>";
      $curr_par = $par;
      echo "<br><b><i>$rec[name]</i></b><br>\n";
      while(is_array($nrec)){
$subject = explode (" ", $rec[subject]);
$i = 0;
while($subject[$i]) {
if(strlen($subject[$i]) >= 15){ $subject[$i] = substr ($subject[$i], 0, 15)."..."; }
$i++;
}
$subject = implode (" ", $subject);
echo "$nrec[author] - <a href=\"$forum_url/$read_page.$ext?f=$rec[id]&i=$nrec[id]&t=$nrec[thread]\" target=\"_blank\"> $nrec[subject]</a><br>\n";
        $nrec=$nq->getrow();
      }
    }
  $rec=$q->getrow();
  }
}
?>



Anyone here with two good php-eyes who could tell me what's wrong?

TIA
kbking
The solution:

$url = "$forum_url/$read_page.$ext?f=$rec[id]&i=$nrec[id]&t=$nrec[thread]";
if (strlen($nrec['subject']) > 20) {
   $subject = substr($nrec['subject'], 0, 20).'...';
} else {
   $subject = $nrec['subject'];
}
echo "$nrec[author] - <a href=\"$url\"> $subject</a><br>\n";
include('connections/dbconnect.php');
$query = "SELECT * FROM `forum_messages` ORDER BY `modifystamp` DESC LIMIT 0,5";
$result = mysql_query($query);
include('connections/dbclose.php');

while($recent = mysql_fetch_assoc($result)){
$author=$recent['author'];
$datetime=$recent['datestamp'];
$id=$recent['forum_id'];
$thread=$recent['thread'];
$title = $recent['subject'];
if (strlen($title) > 28) {
$title = substr($title, 0, 28).'...';
}
echo'<tr>
<td><img src="images/icon.gif">&nbsp;<a href="./forums/read.php?'.$id.','.$thread.'">'.$title.'</a></td>
</tr>
';
}
Could anyone post the above code by kbking with 15 letter limit and the overall last 5 posts from ALL forums together, not seperately?
jetpeach
Re: Hack to display last posts in another document
November 30, 2004 08:54PM
I'm lost, none of these are working for me, are they compatible with phorum 5.013?
Sorry, you do not have permission to post/reply in this forum.