UBB.Dev
Posted By: Ron M [6.4 - 6.5 - 6.6 - 6.7] [beta] UBBNews PHP Feed - 04/02/2003 6:53 AM
* Updated September 15, 2005
ubbnews.php
Modification and Redistribution of this code without perission is prohibited
The Official Code can be found at https://www.ubbdev.com/ubb/ultimatebb.php/topic/33/42.html

Reads the UBB for the latest topic in a forum, and displays a teaster of it on a page
Required Parameter -- forum=## where ## is the forum number requested
Optional Parameter -- threads=# where # is the number of threads to tease (5 limit)
Optional Parameter -- surl=1 will turn on Spider Friendly URLs (Requires 6.7.x)

Usage: just do an include with "http://yourdomain.com/path/ubbnews.php?forum=##&threads=X(&surl=1)" where ## is the number of the forum without any leading zeros and X is a number between 1 and 5. You will need to put your noncgi path in the script so it may read the vars_config.inc.php for your UBB paths.
Download: UBBDev
Requires: 6.4+

Features:
- Counts your comments and puts the count next to the Comments Link
- Comments Link will give them UBB Reply Screen
- Read More takes them to the entire topic
- Will display 1 topic of no threads=X is added to the URL
- Feed multiple forums by doing multiple includes of the ubbnews.php
- Will NOT feed private forums
- Will display a message if your forum_##.threads file is missing
- Author's name links to their profile
- Spider Friendly URLs

Known Issues:
- Doesn't process Gramelins This can be corrected by placing ubbnews.php in your noncgi directory
- Sometimes doesn't process URL's correctly (I've seen it on rare occasions, but bumping the Max Characters setting noted in the code should cure it)
- You will receive a missing .threads error message after an upgrade. Rebuild your Forum Metadata on that forum to correct this error.

This may/may not work on earlier versions, so use at your own risk.

I put a hard limit of 5 in the PHP code to prevent the code from trying to tease every topic in the forum (Could kill performance). You can change this by editing
Code
       if ($threads > 5)
$threads = 5;
just change the 5 in both lines to whatever you want to cap it at. I honestly don't see a need to be over 10.

Also, this may show a bit of lag if you have thousands of topic in the forums. I haven't tested this on large forums.

August 26, 2005 Notice
UBBFeed was an unauthorized modification of the UBBNews code and I will provide NO support for UBBFeed, or my code contained in it. Posting here for support of UBBFeed will result in an unpleasant response.
Any demo (of what you have so far)? This sounds very promising. If you can get it so that the user can determine how many "teasers" that are displayed (other than default "1") that would be cool. smile
demo: http://thegeeksinc.com/

nice work Ron laugh the graemlins shouldn't be too difficult, I believe we worked through them for ubbnews and for a threads mod smile
Quote
quote:
Originally posted by AllenAyres:
demo: http://thegeeksinc.com/
OOPS...I feel quite <-- thumbsup
Thanks guys smile

I only wanted to tease one thread (the latest) but it could probably be modified to do more. You can feed more than one forum by doing multiple includes of the .php
Quote
quote:
Originally posted by Sub Zero:
the vars_config.inc.php for your UBB paths.

Feel free to suggest any improvements to the code, as I'm still learning PHP smile This may/may not work on earlier versions, so use at your own risk.
vars_config.inc.php is different in 6.4, so i any one wants to use it on 6.4.x u have to change the link towards the the topic.
6.5 Zip File Updated with a bugfix - ultimatebb.cgi was not in the URL

Patch: Add /ultimatebb.cgi before ?ubb= on lines 52 and 56
changing the
to
would fix the xhtml-compliance smile

What do you see when you have graemlins in the post sz? some html?
The best way to check if it cuts any HTML command (including graemlins, images, etc) is to check the number of <'s in comparison to the number of >'s, and if there are more <'s just remove everything after the last <, including it.

For example if it is:
Quote
quote:
This is a sample sentence! Welcome to our board! ", so it removes everything after and including the last <, which is "
its not really working for me on 6.4, what do I do wrong confused

http://www.greek-forum.de/ubb/ubbnews.php?forum=46
Sorry for the slow reply. I checked it out. You are running 6.4.0.1, and I wrote this on a 6.5 board, so there might be some differences, but it should work.

Also, you really should get your host to upgrade your PHP as you are running 4.0.6. The exact problem is the way I get the query string (?forum=46) must not be recognized on the older version of PHP. Either way, I would recommend upgrading the PHP as there are some vulnerabilities fixed.
hmmm it's my own server so I have to upgrade it by my own, oh well, i will try this then wink tipsy
Sub, anyway to have it relay the last 5 or so stories?
Right now, it only teases one. When I figure out a sane way to parse the necessary files, I will expand it.
Ok, can't wait to see it smile ...
The Zip file has been updated with a new version that now allows a tease upto 5 topics.
yey! anyway to make it 15 :x
nm, i see it :x... thanks sub!
The limit is in there to prevent someone from trying to crash the server by doing threads=99999 smile
yeh, i see how to mod it to allow what i need, I love this mod, now I can begin to use it for my implimentation of taking over the world... err umm news posting...
I realize that this is for 6.5 and 6.6 but I figured 6.4 *might* work so I gave it a shot and I set it to forum 9 (announcement) and threads =5 and it comes up blank. If I put ubbnews.php?forum=9 then it gives me one thread and it seems to pull it up from last year. Any ideas?
if i had ftp access to my domain from here, and if my domain wasn't blocked from here i'd test it, but i'm not expecting my laptop back till next week smirk...
Quote
quote:
Originally posted by twslex:
quote:
[qb]Originally posted by Sub Zero:
the vars_config.inc.php for your UBB paths.

Feel free to suggest any improvements to the code, as I'm still learning PHP smile This may/may not work on earlier versions, so use at your own risk.
[/qb]
vars_config.inc.php is different in 6.4, so i any one wants to use it on 6.4.x u have to change the link towards the the topic.
Can we get a little more detail on how to get it to work with 6.4?
Ok... I haven't tested it with 6.4 but assuming the metadata formats haven't changed it should work.

Regarding pulling the old thread, rebuild the forum stat files for that particular forum and see if that cures it. If not, I'll have to figure a way to handle metadata being out of order. Maybe something of using the lastnumber and counting backwards and searching for existing files.

doing ubbnews.php?forum=9&threads=5 should pull 5 threads and tease them.
Thanks, I'll work on it. I appreciate the reply!!

edit: the stat rebuild didn't help and the threads=5 still just pulls one old thread up. Thread it pulls is consistent though. Here's the link I'm trying;

http://www.netwerkin.com/noncgi/ubbnews.php?forum=9&threads=5
Lemme dig up a 6.4 zip and I'll install it locally and see if I can't sort it out. I wrote this during 6.5, so I never got a chance to run it on 6.4.
You are the man, I hope I'm not causing too much trouble. I want to upgrade but I don't want to kill the look I have at Netwerkin right now and it's a pain to build.
I got the threads to show 5 but they are still old ones. I had made a mistake while editing the page.
Aye! The forum_XX.threads files in 6.4 aren't in sync like the 6.6 files(The ones on my 6.6 board are sorted in numeric order which makes for clean processing of the array). The way I wrote this, I take the .threads, pop the bottom rows off, then invert the array so I can process it in reverse order. It looks like with 6.4, I need to sort the array myself before processing it.

Let me see what I can cook up for porting this mod back to 6.4....

On a positive note, you helped me solve the graemlin processing problem. Drop ubbnews.php into the noncgi directory. I call mine out of the root because it is with the rest of the PHP scripts that power the main page on my site.
Fair warning: The fact that hashes are alpha-sorted in 6.6 is actually a bug. I meant to turn that off. 6.6.1+ corrects this. tipsy
Damn...It makes metadata much easier to examine.
Eh, it's not so bad. The fact that alpha-sorted forums will use a date-sorted .threads file in 6.7 will make up for it. (Meaning alpha-sorted forums will be able to be pruned, mass moved from, and have CIs stuck on them, in addition to your routines being able to work with them.)
ok, I've gotten as far as this

http://www.alforadmin.com/ubb/ubbnews.php?forum=10&threads=5

shocked How do I include it in a webpage?
just do a

Code
<? include("http://www.alforadmin.com/ubb/ubbnews.php?forum=10&threads=5"); ?>
Now to start rewriting the fetching engine so it can properly sort the .threads file smile
smile Thank you, I got it working here http://www.alforadmin.com/ubb/index.php
That has a nice look to it Al.
Updated the zip with a sorting bugfix which pulls old topics.

Randy, this should work with 6.4 now smile
Thank you SO much. I've been building a 6.6 upgrade kit for Netwerkin but it's weeks away and I've been dying to have a front page again. Netwerkin used to be rather large but I moved the tutorials etc. to www.randymcelroy.com (my personal site).
Between the news feeder and CIs, you should be able to build one in no time smile
I found an, odd, bug...

When you view the script here and compaire it to my forum #6 it pretty much pick and chooses which stories it wants to use...
Quote
quote:
Originally posted by Gizzy:
I found an, odd, bug...

When you view the script here and compaire it to my forum #6 it pretty much pick and chooses which stories it wants to use...
It's based on when the topic is made, not when it was last replied to.

Look at the links, it's t=290,291,292,etc
You know, i figured that AFTER i actually glanced through the posts lol...
I love how you did it so you can't tease private forums (not the most graceful way to do it, but works nonetheless)

http://www.undergroundnews.com/ubbnews.php?forum=16&threads=5
Yeah...I should probably add some error handling in it to quelch the ugly errors...

The nice thing is the .threads for private forums are tucked away in the private directory. Not to meniton it would require opening vars_forums.cgi, and doing an authentication check before displaying anything. Can get just plain ugly at that point.
Here's a patch to cure that and a missing .threads error

Before
Code
$thread_data = file($threadspath);
Add
Code
if (file_exists($threadspath)) {
and After
Code
$thr_array = $threads--;
Insert
Code
        } else {
$thr_array = 0;
echo "Unable to read .threads file. Either you are trying to access a private forum, or you need to Rebuild your forum stat files.";
}
I'll upload a patched zip shortly.
I have an error :x.. When users use
Code
[quote][/quote]
in a post, and it's set to trunicate the posts after so many characters it displays the rest as quoted since the ending of the quoted text was trunicated.

http://www.undergroundnews.com/ubbnews.php?forum=6&threads=5
I'll add it to the known issue list.
Found another:

When there is only one forum and the requested is 5, it errors out, granted that there is no data for it to retrieve...

Quote
quote:
Posted by
Posted:


Read More...

Comments (-1)


Warning: file(/var/www/html/ubb/Forum26/.cgi): failed to open stream: No such file or directory in /var/www/html/ubbnews.php on line 54
quick question, is it possible to have the username as a link to the users profile?
Regarding first report - I'll look into that one. I'm probably going to have to do some sort of array count to see how many topics.

The 2nd one. Well... The usernumber is already in the A line so it isn't hard to assemble the name as a URL and display. I suppose I could whip that up this evening. Doesn't look like that would be too difficult.
Zip File Updated with the member name now linking to their profile.

Still looking at the topic counting issue.
Zip File Updated patching the topic counting bug.
hummm, sub, can you post these fixes lol... i hate doing customization then having an update lol
Ok, I have a new one! How about filtering out the edited by statement...

[ September 29, 2003, 11:40 PM: Message edited by: Gizmo ]

for example...
Lemme look at the topic files and see how it is in the Z lines. I'm not sure if there will be a sane way to do it...

I'll rustle up the code changes and add those. It's only about 7 new lines that fix both of the above issues.
sweet, work on the quote issue, it'll make us all feel a lot better :x...
smile and lists... they mess up too
I'll get it on the bug list to look into/fix.
Quote
quote:
Originally posted by Weird Al:
smile and lists... they mess up too
the lists? lol...
http://www.alforadmin.com/ubb/index.php

Look at the top news... and the "Read more".. it's added to the [list]
hmmm...looks like I need to see if there are open list/quote tags and close them in the tease. This should be interesting.
Hey Sub, here's a quick beta of what i've done with your script (yeh i know it's still kinda lame/buggy) UGN Security Test Page
Quote
quote:
Originally posted by Gizzy:
Hey Sub, here's a quick beta of what i've done with your script (yeh i know it's still kinda lame/buggy) UGN Security Test Page
*cough* mine works with the Colorforums hack *cough*

http://www.alforadmin.com/ubb/index.php tipsy
I don't need color forums hack though, mines just for my main page's content...
Sub, i found another error :choff:...

before you say it's one of my mods to it a clean copy my modded copy .

My issue is this, it doens't always update and i'd hate to have to rebuild my forum statistics to get it to update all the time... We have like 20 posts from today and it's not showing any of them...
Did you do fetch the one with sort fix Gizzy? If not, I'll put the sort patch up here. If you did, then I'll need to look and see why it has gone insane.
sub, the clean.php is the one i just downloaded :x...
Aye Aye Aye....I'll have to see if I remembered the sort fix in the zip on my server. If I did...welllll..I've got a problem
lol, i can't wait to get it working frown ... spent a bit of time customizing it lol, it'll pull the site together a bit...
Doh!

I forgot to commit the sort fix to the released version. I had it on my production version.

I'll fix the zip.

Patch:

Find:
Code
        $thr_data = array_reverse($thread_data);
Replace with:
Code
$thr_data2 = array_reverse($thread_data);
array_pop($thr_data2);
sort($thr_data2);
$thr_data = array_reverse($thr_data2);
mmm, makes it work perfectly! Now to get the quotes fixed :x... thanks smile
i dont get confused

on my test forum it runs well:
http://www.greek-covers.de/ubbtest/ubbnews3.php?forum=1

(ubb 6.6.1 - apache server)

on my regular forum it just says
Quote
quote:
Unable to read .threads file. Either you are trying to access a private forum, or you need to Rebuild your forum stat files.
http://www.greek-forum.de/ubb/ubbnews2.php?forum=1

(ubb 6.6.1 - apache server)

it's the same software, the same script all the same but no work confused

why is that like this ?! frown
rebuild your forum stat files then try it, I had the same issue and it cleared it up quite quickly.
For anyone running this who wants to use smilies in their news, you can use the
Code
<BASE href="http://www.undergroundnews.com/ubb/">
to point to your ubb directory in your page that you're including from. Be sure however that in that document that you're linking directly to any images/pages/css that you have in the document since it'll look for them in your ubb directory. This is of coarse if you don't want to use a php implode to display your news and just want to use a common include.

Sub, as a sugguestion, perhaps have it so that the location of images loaded through your script is passed through the script and pointed back to the ubb directory?
The script already can see the NonCGI directory path via the UBB's config.inc.php (Line 7: include("$varspath/vars_config.inc.php");) so it shouldn't take much to get the path to the images. I've been swamped with other development so I haven't had a chance to look at the known issues lately. I have injected some code in my dev version to try to squash the list/code/quote problems but I haven't even touched that in a couple weeks.

Another alternative is to drop the ubbnews.php into your UBB's noncgi directory.
Sub, if you use a php include it doesn't matter where it's placed, it'll call the paths from that location.
:bump: any hope on an update sub?
For those of you wondering how to customize the script's output, check here
I think the quote/list/code issue is mostly squashed. Let me beat up on my beta version a bit more. I finally had a few days to do some development.
ya know you're really going through too much trouble. All I did was change the layout so that the Read More, etc links were in the next cell. blockquote, lists, etc don't pass through that. So essentially the only reason to update the script is for html compliance
yeh well, others that use stock quote woudln't wanna be thrown off by the page lookin like crap :x...

Sub, daddy tipsy , when you finish could you post a list of changes lol...
So, about the beating up of the beta version :x...

BTW, for the gramelins, could you have it just define a url when it sences a gramelin's usage? Say using noncgiurl/gramelins/gramelin.gif
I kind of got sidetracked on the ubbnews.php after a couple of major projects cropped up this past fall. I'm getting this back on my whiteboard to address/look into further.

A workaround for the graemlin problem is to drop ubbnews.php in the noncgi directory. I'll have to examine the Z lines a bit more to determine if I can do a replace on the graemlins, or somehow break it apart and insert in the noncgi url from the vars_config.inc.php.

Regarding the quote/code/list fix, I have a tempoary one, however, it doesn't handle multiple lists correctly. I'm going to rethink the code that I injected last fall into my beta version. I think I'm going need to do a string find and count, then compare the open and close counts and append the appropriate number of closing tags.

If you want, I can post my current temporary fix, but I'll need to do further testing on my boards after I write a more permenant fix. I have an idea about how to do a more permenant fix, I just need to code and test it on my boards before I release it. It's not going to break the UBB, I'd just rather break my beta directory than anyones live sites.
That's not a vaild workaround... If you use a php include to load the page into a document it'll load all data from that called position. Example:

http://www.undergroundnews.com/ if I use a PHP call to load from http://www.undergroundnews.com/ubb/news.php on the main page of http://www.undergroundnews.com/ it'll still look for the gramelins in http://www.undergroundnews.com/ and not http://www.undergroundnews.com/ubb/.

'eh I can wait till an official live version is available lol... I run it so much at my site, with some customizations it's used for site news/rants/tech news/main page/store news.

Just wanted to be sure you were alive :x...
I'm still alive.

I've been playing in Zend with the quote/code/list (Gotta love the Preview of the HTML and the ability to set breakpoints to examine varaible content). I did concept up a method of counting the open tags, and automatically closing the tags at the end of the teaser, regardless of where they are supposed to close. I'll probably be able to test that on a live board shortly.

The problem I'm running into on the gramelins is doing an outright replace on the img tags. If I append $NonCGIURL to all image tags, it would break any outside images in the feed. On the other hand, I cannot be guaranteed that I'm able to read /cgi-bin/vars_graemlins.cgi due to open_basedir restrictions. If I can be sure that I can read vars_graemlins, I can do some array work to "trim the fat" of the hash, and get it so I have just the graemlin image file names, and just do a search and replace on those file names. I could just include a base href, but would that break other parts of the page that it is feeding onto. That, I'm unsure of also.
perhaps have it compaire where the url is linking to? or if the url is linking to a directory named gramelins?

Yeh I'm using a base href, it's a pain in the butt... I had to recode parts of my entire news pages just to run this and have gramelins show lol...
Not all graemlins are in /noncgi/graemlins. Some are in /noncgi...

Oh, and here's some beta code for the quote bug:

Find:
Code
     $postdet = substr($postdet,0,strlen($postdet)-strpos(strrev($postdet),$aspace));
Add After:
Code
     $bot = substr_count($postdet, "<blockquote>");
$bct = substr_count($postdet, "</blockquote>");
if ($bot > $bct) {
while($bot > $bct) {
$postdet = $postdet . "</blockquote>";
$bct++;
}
$nodots = "TRUE";
}
$lot = substr_count($postdet, "<ul");
$lct = substr_count($postdet, "</ul>");
if ($lot > $lct) {
while($lot > $lct) {
$postdet = $postdet . "</ul>";
$lct++;
}
$nodots = "TRUE";
}
Quote
Originally posted by Sub Zero:

- Will NOT feed private forums
I require my users to login, but i guess that will work?

Another question:

$varspath = "/path/to/noncgi";

Is it an absolute path or relative to webserver root? IĀ“m running on Windows2000-server, could you give an example?

"/inetpub/wwwroot" or "c:inetpub..." or is it a webpath?
go into your CP and see what you have entered for your Non CGI Path.

Enter that
Eric,

1. You'll be able to use this, so long as your news forum is NOT a private forum (yes your board is closed, but a private forum is one that only restricted users such as admin/mod/ones you deem worthly can access).

2. It's a server path not web path. As Ian said, it'll be what's in your board configuration.
Tried, but running ubbnews.php only displays a blank page.
in ubbnews.php, try changing

Code
include("$varspath/vars_config.inc.php");
to

Code
include("vars_config.inc.php");
No luck, still blank!
Are you sending proper parameters??
http://mydomain.com/noncgi/ubbnews.php?forum=12
for example

gives me nothing;

Code
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=windows-1252"></HEAD>
<BODY></BODY></HTML>
Running Windows 2000.
odd, I don't think ubbnews is supposed to print any of that, as it's meant to be included in another page.

Have you modified any of the code?
You can call it directly for testing, however it is meant to be used in an include() in a PHP page.

http://thegeeksinc.com/ubbnews.php?forum=34&threads=3

Dumb question - Do you have the PHP Accelerator enabled???
No modification, only tried changing the path you suggested before.

Yes, I have the PHP accelerator enabled, and it is working.

Maybe something with the PHP installation? IĀ“ll have the guy that installed it to have a look at this issue. If you donĀ“t have any other clues?
I just don't see any reason why it's printing out the
Code
<html><body></body></html>
and nothing else. I can't find anywhere in the code where it tells it to print that out
Can you post a URL to your ubbnews.php like my one above? Also a URL to your forums would be helpful.

I'm not outputting any DOCTYPE, HEAD, or BODY tags with ubbnews.php because I do an inculde("$siteroot/ubbnews.php?forum=34&threads=2"); in my index.php to get the feed. ($siteroot is a variable from my index.php script I use to define my root directory path)

If I can't see anything wrong with those, I'll either write some diagnostic code or have you send me your configured ubbnews.php and your vars_config.inc.php
Sub, if you ever want to turn the times into a format that is adjusted via users preference, I wrote this js function that takes the normal 12-31-2004 08:42PM

and turns it into something workable.

Code
<script language="Javascript" type="text/javascript">
<!--
function formatTime(input) {
var tippy = input;
var tippy_array = tippy.split("-");
var month = parseInt(tippy_array[0]) - 1;
var day = parseInt(tippy_array[1]) + 0;

if(tippy_array[2] != null && tippy_array[2] != '') {
var new_array_tippy = tippy_array[2].split(" ");
var year = parseInt(new_array_tippy[0]);

var newer_array_tippy = new_array_tippy[1].split(':');

hour = parseFloat(newer_array_tippy[0]);

if(new_array_tippy[2] == 'PM'){ hour += 12; }
var minutes = parseInt(newer_array_tippy[1]);
document.write('<span class="time">');
document.write(timestamp(new Date(year,month,day,hour,minutes,0), dfrm, null, 0, 0, 0, 0), "at ");
document.write(timestamp(new Date(year,month,day,hour,minutes,0), null, tfrm, 0, 0, 0, 0), '</span>');
}
}
//-->

</script>
Sub Zero: Coming by PM!

Probably something with my php installation, which i didnĀ“t do myself. Will check that too, this week.

Thanks!
Quote
Originally posted by Ian Spence:

I just don't see any reason why it's printing out the
Code
<html><body></body></html>
and nothing else. I can't find anywhere in the code where it tells it to print that out
If there is no query string found, it bugs out and outputs nothing. It seems that IE/Moz like to invent tags when none exist.

I've PM'd Eric with a different (and less cluttered) method of fetching the query string to see if that cures the problem.
Zip file updated to include the following fixes:
- A fix for the quote/code/list problems
- Fix for the IIS Query String bug
:hopes for gramelins to be worked out: :hopes hopes hopes: heh...

I have an idea... Possibly have in the code and if/else statement, have it so that if it sees one of the core smilies stored in the noncgi dir it loads that path to it, else if it's not one of those and a path isn't presant it searches in the gramelins dir...
work at it this way.

IMG tags only allow full urls, and graemlins use relative paths.

Do something like

Code
$message = pregreplace("/src="Graemlins//", "src="$NonCGIURL/Graemlins/", $message);
That's untested, and should only work with custom graemlins. You could also try something like
Code
$message = pregreplace("/src="biggrin.gif/", "src="$NonCGIURL/biggrin.gif", $message);
for each of the built in graemlins.
I ran into a couple of things when looking at the graemlins:

1. the vars_graemlins.cgi looks difficult to parse via PHP
2. I cannot even be sure that I can read vars_graemlins.cgi due to open_basedir restrictions

So how do I determine what is a graemlin, and what is not without knowing what graemlins exist?
Quote
Originally posted by Sub Zero:

So how do I determine what is a graemlin, and what is not without knowing what graemlins exist?



Originally posted by Ian Spence:
[qb]
work at it this way.

IMG tags only allow full urls, and graemlins use relative paths.

Do something like

Code
$message = pregreplace("/src="Graemlins//", "src="$NonCGIURL/Graemlins/", $message);
That's untested, and should only work with custom graemlins. You could also try something like
Code
$message = pregreplace("/src="biggrin.gif/", "src="$NonCGIURL/biggrin.gif", $message);
for each of the built in graemlins.
[/qb]
ok, I'm trying to put together a page that includes this news feed. For some reason, if I have any includes or scripts (such as content islands) after the one that calls this one, they don't work. If they come before it, they work OK. Any idea why that might be and what I can do about it?
Can you post a Demo URL, and how you are doing the include?
ok, here's the URL...

http://www.alex.to/experiment/virtual.html

and here's the code:

Code
                       <!--#include virtual="/ubb/ubbnews.php?forum=1&threads=2"-->

<!--#include virtual="/ubb/ubbnews.php?forum=6&threads=3-->

<!--#include virtual="/ubb/ContentIslands/1/html.html" -->

<script src="http://www.alex.to/ubb/ContentIslands/1/html.js"
language="Javascript1.3" type="text/javascript"></script>
see what I mean? Nothing below the ubbnews lines shows up.
it's a PHP include, I don't think a virtual include will work... although I can't read anything on that page anyway
thanks, that was what I needed to figure it out!
ok, I got it to do what I wanted it to laugh

http://www.alex.to/doomlink
Not half bad wink
looks absolutely nothing like eve, not at all wink
thank you... i think... what is eve???
Been to infopop.com lately? lol...
no, I guess I hadn't eek Well any resemblance is purely coincidental, I was actually more inspired by this site. laugh
sooo... how hard would it be to modify UBBNews so that it takes the last post of any thread, rather than the first, and picks the topics by newest post, rather than newest original topic?
I haven't looked into that, as it was designed as more of a News function than an expanded content island. I'm pretty sure there is some metadata somewhere that stores that data. Then it would be a matter of parsing the metadata, looking up the topic file, fetching the appropriate Z line, and printing it.
thanks... definitely way beyond my abilities!
This is the best script to learn customization on; with a few tweaks you can have it post every line in the post :x... Then theres the customization of having it work with bookmarks (#postid) like I have at UGN Security ... The script is deffinately a time saver wink ...
I do have a new version of this as a PHP function which utilizes the spider friendly functions of the latest version of UBB, but it's acutally a function instead of an include (part of a bigger change I'm working on with my site). I could probably move the code into the .php and still use release it...

Jumping to the latest post in the topic. Now that's an idea....
Lol, here we're waiting on new releases and you've totally redone it :-x... Hey, so long as theres no bugs, it's smaller, and more efficient, can't hurt to release it wink ...
So far, the only real change besides converting it to a function in my UBB class file is the spider friendly. I may try to stick a "Hop to Last post" in it. I'm also looking at adding some Javascript for the times that was posted earlier in the thread. I'm also thinking about a couple of layout changes to it...
Is this hack what's being used for the news at www.ubbdev.com?
No, UBBDev is using something else for news (should be a perl news modification).

Sub, sounds good; I'd love to see a function for "hopping" to the story; see what I have at UGN Security ... As is I have this addon twice (news.php and header.php); be cool to "consolidate" wink
Hey Gizzy, would you mind shooting your code to me to peek at? I would like to see what kind of tweaks you have made to it. I might actually incorporate some of them if you don't mind wink

Also, you shouldn't have to have 2 separate instances of the PHP, you should just be able to include it twice on the page with different query strings. That is unless you are doing different layouts, then you would need to.
Well see the one (headlines.php) is just "jump down" links to the data displayed... But no problem; get it here .

I know it's all pretty dirty but still gets the job done...

Hit me up on AIM (lordmoguai) or IRC (irc.undergroundnews.com #undergroundnews) if you need me.
While I do some thinking, here's how you can spider friendly those links (assming you can use the short version safely):

Find:
$morepath = $CGIURL . "/ultimatebb.cgi?ubb=get_topic;f=" . $forum . ";t=" . $topicnum;

Replace with:
$morepath = $CGIURL . "/ultimatebb.cgi/ubb/get_topic/f/" . $forum . "/t/" . $topicnum;

Find:
$authorurl = $CGIURL . "/ultimatebb.cgi?ubb=get_profile;u=" . $authorid;

Replace with:
$authorurl = $CGIURL . "/ultimatebb.cgi/profile/" . $authorid;

Find:
$commentpath = $CGIURL . "/ultimatebb.cgi?ubb=reply;f=" . $forum . ";t=" . $topicnum;

Replace with:
$commentpath = $CGIURL . "/ultimatebb.cgi/ubb/reply/f/" . $forum . "/t/" . $topicnum;
Interesting, I'll get it installed when i have some free time wink
Well, that's done; works nicly, thanks smile .
just wondering... is there a way to create hidden forums that can contain topics that will show up in ubbnews, but will *not* show up in the "today's active topics" list?
With the stock behavior, no. That was a safety feature implemented to prevent people from farting around and trying to get private forums.

Reading private forums isn't hard to hack in. You would need to know the forum key, as you cannot count on always being able to read vars_forums., then it is a matter of assembling the path, and parsing the appropriate files.

Keep in mind, if anyone knew the URL to the page, your private forum topics would be compromised, hence the reason for the current behavior.
from my experience, if you set a forum as hidden, but not private, you should be able to use the feed for it. Although as Sub said, it's not a well hidden forum is we all know where it is wink
for those who still use this, I've been rewriting my scripts and wrote this function up

Code
function fix_smilies( $string )
{

$string = preg_replace('/src="graemlins//', 'src="/ubb/graemlins/', $string);
$string = preg_replace('/src="([^/]+?)"/', 'src="/ubb/$1"', $string);

return $string;
}
change the 'ubb' if your noncgi directory is named something else
grazi smile
OK,

been playing around with this one, now the latest threads do not come up, but the threads with the latest posts.

Code now looks like this, i have renamed it into ubbnews2.php:

Code
<?
// ubbnews2.php
// Reads the UBB for the latest topic in a forum, and displays a teaster of it on a page
// Required Paramater -- forum=## where ## is the forum number requested
// Optional Paramter -- threads=# where # is the number of threads to tease (5 limit)

$varspath = "<NonCGIPath>"; # Take this from the NonCGI Path setting in your cp.cgi
include("$varspath/vars_config.inc.php");

$forum = $_GET['forum'];
$threads = $_GET['threads'];
$threads = (isset($threads) && $threads) ? $threads : 1;

// If you dare, you can adjust the max number to tease by adjusting the number in the next 2 lines
// ******* WARNING - DO NOT REMOVE/COMMENT OUT THE CHECK! ********
if ($threads > 5)
$threads = 5;

if ($forum)
{
$ubbnewspath = $NonCGIPath . "/" . "Forum";
$threadspath = $ubbnewspath . $forum . "/" . "forum_" . $forum . ".threads";
if (file_exists($threadspath))
{
$thread_data = file($threadspath);
$thread_count = count($thread_data);
array_pop($thread_data);
array_pop($thread_data);
array_pop($thread_data);
array_pop($thread_data);
$thr_data2 = array_reverse($thread_data);
array_pop($thr_data2);
sort($thr_data2);
$thr_data = array_reverse($thr_data2);
$thr_start = 0;
$thr_array = $threads--;
$real_count = count($thr_data);
if ($real_count < $thr_array)
$thr_array = $real_count;
}
else
{
$thr_array = 0;
echo "Unable to read .threads file. Either you are trying to access a private forum, or you need to Rebuild your forum stat files.";
}
$count = 0;
$mereal_count = $real_count;

while($real_count)
{
$real_count--;
$extrame[$real_count] = "";
$extrameme = $extrame[$real_count];
$extrathisone = $thr_data[$real_count];
$extrameme= explode("!", $extrathisone);
$extrame[$real_count][0] = $extrameme[0];
$extrame[$real_count][1] = $extrameme[1];
$extrame[$real_count][2] = $extrameme[2];
$extrame[$real_count][3] = $extrameme[3];
$extrame[$real_count][4] = $extrameme[4];
}
while($real_count <= $mereal_count)
{
$extrame2[$real_count] = "!" . $extrame[$real_count][3] . "!" . " => " . "!" . $extrame[$real_count][1] . "!";
$real_count++;
}
rsort($extrame2);

$thr_data = $extrame2;

while ($count < $thr_array)
{
if ($count > 1)
echo "

";
$thisone = $thr_data[$thr_start];
$getme = explode("!", $thisone);
$getme2 = $getme[3];
$topicnum = trim($getme2);
$maxTextLenght=850;
$ubbnewspath = $NonCGIPath . "/" . "Forum";
$newsitem = $ubbnewspath . $forum . "/" . $topicnum . ".cgi";
$newsdetail = file($newsitem);
$num_lines = count ($newsdetail);
$comment_count = $num_lines - 2;
$aline = explode("&#0124;&#0124;", $newsdetail[0]);
$zline = explode("&#0124;&#0124;", $newsdetail[1]);
$author = $aline[8];
$authorid = $aline[9];
$authorurl = $NonCGIURL . "/ultimatebb.php?ubb=get_profile;u=" . $authorid;
$title = $aline[4];
$postdate = $zline[3];
$posttime = $zline[4];
$aspace=" ";
if(strlen($zline[6]) > $maxTextLenght )
{
$postdet = substr(trim($zline[6]),0,$maxTextLenght);
$postdet = substr($postdet,0,strlen($postdet)-strpos(strrev($postdet),$aspace));
$bot = strpos($postdet, "<blockquote>");
$bct = strpos($postdet, "</blockquote>");
if (($bot!==FALSE) and ($bct===FALSE))
{
$postdet = $postdet . "</blockquote>";
$nodots = "TRUE";
}
$lot = strpos($postdet, "<ul");
$lct = strpos($postdet, "</ul>");
if (($lot!==FALSE) and ($lct===FALSE))
{
$postdet = $postdet . "</ul>";
$nodots = "TRUE";
}
if ($nodots != "TRUE")
$postdet = $postdet . '...';
}
else
{
$postdet = $zline[6];
}
echo "<b>$title</b>
";
echo "<font size="1">";
print("Posted: $postdate $posttime by <a href="$authorurl">$author</a>");
echo "</font>
";
echo "
";
print($postdet);
$morepath = $NonCGIURL . "/ultimatebb.php?ubb=get_topic;f=" . $forum . ";t=" . $topicnum;
echo "   ";
echo "<a href="$morepath">Read More...</a>";
echo "
";
$commentpath = $NonCGIURL . "/ultimatebb.php?ubb=reply;f=" . $forum . ";t=" . $topicnum;
echo "<a href="$commentpath">Comments ($comment_count)</a>

";
$count++;
$thr_start++;
}
}
It looks pretty good, however, it is best to call ultimatebb.cgi and let the UBB decide when to call ultimatebb.php. I do have a more updated version of this, but I haven't released it.
Hiya,

Are u gonna add this to that one or the other way around?

Btw, have u got any clue on how to get this php code to run outside a browser but on a command line like this: php-cli ubbnews.php?forum=1

so that one can use cron?
Quote
Originally posted by Sub Zero:

It looks pretty good, however, it is best to call ultimatebb.cgi and let the UBB decide when to call ultimatebb.php. I do have a more updated version of this, but I haven't released it.

:sniff: i want lol... I'm usign the latest public version of this on one of my new sites that i'm planning on opening in sept wink
Well, I found a bug...

I'm running the latest version and for once I'm using the section:
Code
if ($count > 1)
echo "

";
(before I left it as "" and used something else, but now i'm going for a more professional look)

What I'm seeing on my dev site is that the first entry ignores
Code
if ($count > 1)
echo "

";
Which kind of sucks as I get parts that run together...

Any ideas? This is the only thing that's holding development back right now (well, the only thing i need to worry about anyway); I've been coding up a storm lately...

You can see examples of this error by looking at the "Headlines" section, the first two entries mesh together vs using:
Code
if ($count > 1)
echo " &#0124;&#0124; ";
And the "Tech News" section the first two stories mesh together instead of using:
Code
if ($count > 1)
echo "

";
(Note that the headlines are generated from a file named "headlines.php" and news from "news.php" so they aren't in the same file)...
You might want to verify your changes. The $count > 1 is that way so that it does the 2 line breaks after the 1st iteration of the script. My guess is that $count isn't being incremented during the 1st pass.
The only changes I made was to the formatting and the line which is responsible for the amount of stories allowed to pull... I'll get a copy uploaded for you shortly

files
Change $count > 1 to $count >= 1. The problem is $count = 0 at first, then gets incremented to 1 and the line break logic doesn't get called.
Ahh, that's looking beautiful; thanks smile ...

Now to go terrorize more php code!
Zip File Updated.

Fixes
======
- Fixed the Gizzy $count bug
- Changed the include to require for vars_config.inc.php (Why try to run if you cannot fetch the paths confused )
- Tweaked the internal code documentation
- Cleaned up the formatting of the code for easier reading (I should have done this sooner)
- Switched the URLs to Spider Friendly

I'm going to mark this as a Finished Modification since it does seem rather stable.
Zip File Updated again because I forgot to leave the old URL formats in for the 6.4 Users. If you do not want the short URLs or are unable to run with them, you may comment the lines with them and uncomment the lines with the standard URLs.

Example Before:
Code
		$morepath = $CGIURL . "/ultimatebb.cgi/ubb/get_topic/f/" . $forum . "/t/" . $topicnum;
//$morepath = $CGIURL . "/ultimatebb.cgi?ubb=get_topic;f=" . $forum . ";t=" . $topicnum;
Example After:
Code
		//$morepath = $CGIURL . "/ultimatebb.cgi/ubb/get_topic/f/" . $forum . "/t/" . $topicnum;
$morepath = $CGIURL . "/ultimatebb.cgi?ubb=get_topic;f=" . $forum . ";t=" . $topicnum;
Hey SubZero, I'm currently working on a rendition of the body of UBB.News that will provide a valid RSS2.0 feed; would it be allright if I can post the body segment here when completed?

The hardest task is to get a valid date lol, they want it one way whereas it's presented another ;/, too bad that for a valid feed we had to sit and code for a while to get it to output a differant way without modding existing ubb code :/; but we coded a fix for that one wink .
I could probably help you out with the date handling Gizzy. I do see that it is tricky. You are probably going to have to do some kludge to get the current server Time Zone and assume that the FudgedOffset is 0. Then again, you could do some math on FudgedOffset from vars_config.inc.php and figure out the new timezone.

Possibly at some point, the RSS 2.0 stuff could either be a "hack" to the code, or we might be able to make some arrangements and ship it as stock behavior. We should probably discuss what we want to do privately if that is something we want to consider smile
Well the timezone for RSS has to be in an exact format; we have a discussion at ugn here on the subject though wink ...

PM me later and i'll get you what i have right now; the only thing not rss2.0 compliant is the date which would be fixed via the forum thread we have going.
http://www.ianspence.com/?page=rss

smile

First, use the following function

Code
function convert_date($ubb_time)
{
return preg_replace("/(d{1,2})-(d{1,2})-(d{4})/", "\3-\1-\2", $ubb_time);
}
Pass in the normal UBB time you get (DATE blank space TIME)

Then
Code
$date = date( "D, d M Y H:i:s T" , strtotime( convert_date( $day . ' ' . $hour ) ));
Ian, not bad, however it sets the time as "00:00:00" vs the time of the post smirk
are you entering the entire time. by $hour I meant "05:15 PM"
I just dropped it in and called it as you said... BTW, "am/pm" isn't in the spec, it's 24 hour time I believe.

SubZero, a reccommendation, instead of commenting the shorturl capabilities why not just add a switch?

Add this to the top:
Code
// Use ShortURLs? 1 = yes, 0 = no.
$shorturls = "1";
Then add this before you define your layout:
Code
			if($shorturls == 1) {
$authorurl = $CGIURL . "/ultimatebb.cgi/profile/" . $authorid;
$morepath = $CGIURL . "/ultimatebb.cgi/ubb/get_topic/f/" . $forum . "/t/" . $topicnum;
$commentpath = $CGIURL . "/ultimatebb.cgi/ubb/reply/f/" . $forum . "/t/" . $topicnum;
} else {
$authorurl = $CGIURL . "/ultimatebb.cgi?ubb=get_profile;u=" . $authorid;
$morepath = $CGIURL . "/ultimatebb.cgi?ubb=get_topic;f=" . $forum . ";t=" . $topicnum;
$commentpath = $CGIURL . "/ultimatebb.cgi?ubb=reply;f=" . $forum . ";t=" . $topicnum;
}
I only did the comment method because it was a quick fix. I will look at adding it as a switch shortly. My schedule is kinda...crappy this week smile
Zip File Updated
- New optional Query String parameter - surl=1 will enable Short URLs (Requires UBB.classic 6.7.x)
- Fixed some typos in the comments
- Added a few additional comments
- Cleaned up some of the nodots logic

Reverting this back to a beta hack for the time being.
Does this do rss 2.0 feeds? I saw someone at ubbcentral requesting the ability.
really, all you'd need to do is

Code
header( "Content-type: text/xml" );
and edit the output part to produce valid rss2