|
Joined: Sep 2001
Posts: 61
Member
|
Member
Joined: Sep 2001
Posts: 61 |
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?
|
|
|
|
Joined: Nov 2001
Posts: 745
Admin Emeritus
|
Admin Emeritus
Joined: Nov 2001
Posts: 745 |
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.
|
|
|
|
Joined: Sep 2001
Posts: 61
Member
|
Member
Joined: Sep 2001
Posts: 61 |
thanks... definitely way beyond my abilities!
|
|
|
|
Joined: Jan 2000
Posts: 5,834 Likes: 20
UBBDev Owner Time Lord
|
UBBDev Owner Time Lord
Joined: Jan 2000
Posts: 5,834 Likes: 20 |
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  ...
|
|
|
|
Joined: Nov 2001
Posts: 745
Admin Emeritus
|
Admin Emeritus
Joined: Nov 2001
Posts: 745 |
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....
|
|
|
|
Joined: Jan 2000
Posts: 5,834 Likes: 20
UBBDev Owner Time Lord
|
UBBDev Owner Time Lord
Joined: Jan 2000
Posts: 5,834 Likes: 20 |
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  ...
|
|
|
|
Joined: Nov 2001
Posts: 745
Admin Emeritus
|
Admin Emeritus
Joined: Nov 2001
Posts: 745 |
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...
|
|
|
|
Joined: Sep 2000
Posts: 221
Member
|
Member
Joined: Sep 2000
Posts: 221 |
Is this hack what's being used for the news at www.ubbdev.com?
This is the designed behavior.
|
|
|
|
Joined: Jan 2000
Posts: 5,834 Likes: 20
UBBDev Owner Time Lord
|
UBBDev Owner Time Lord
Joined: Jan 2000
Posts: 5,834 Likes: 20 |
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" 
|
|
|
|
Joined: Nov 2001
Posts: 745
Admin Emeritus
|
Admin Emeritus
Joined: Nov 2001
Posts: 745 |
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 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.
|
|
|
|
Joined: Jan 2000
Posts: 5,834 Likes: 20
UBBDev Owner Time Lord
|
UBBDev Owner Time Lord
Joined: Jan 2000
Posts: 5,834 Likes: 20 |
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.
|
|
|
|
Joined: Nov 2001
Posts: 745
Admin Emeritus
|
Admin Emeritus
Joined: Nov 2001
Posts: 745 |
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;
|
|
|
|
Joined: Jan 2000
Posts: 5,834 Likes: 20
UBBDev Owner Time Lord
|
UBBDev Owner Time Lord
Joined: Jan 2000
Posts: 5,834 Likes: 20 |
Interesting, I'll get it installed when i have some free time 
|
|
|
|
Joined: Jan 2000
Posts: 5,834 Likes: 20
UBBDev Owner Time Lord
|
UBBDev Owner Time Lord
Joined: Jan 2000
Posts: 5,834 Likes: 20 |
Well, that's done; works nicly, thanks  .
|
|
|
|
Joined: Sep 2001
Posts: 61
Member
|
Member
Joined: Sep 2001
Posts: 61 |
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?
|
|
|
|
Joined: Nov 2001
Posts: 745
Admin Emeritus
|
Admin Emeritus
Joined: Nov 2001
Posts: 745 |
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.
|
|
|
|
Joined: Jan 2003
Posts: 3,456 Likes: 2
Master Hacker
|
Master Hacker
Joined: Jan 2003
Posts: 3,456 Likes: 2 |
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 
|
|
|
|
Joined: Jan 2003
Posts: 3,456 Likes: 2
Master Hacker
|
Master Hacker
Joined: Jan 2003
Posts: 3,456 Likes: 2 |
for those who still use this, I've been rewriting my scripts and wrote this function up 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
|
|
|
|
Joined: Mar 2000
Posts: 21,079 Likes: 3
I type Like navaho
|
I type Like navaho
Joined: Mar 2000
Posts: 21,079 Likes: 3 |
grazi 
|
|
|
|
Joined: Jun 2002
Posts: 111
Member
|
Member
Joined: Jun 2002
Posts: 111 |
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: <? // 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("||", $newsdetail[0]); $zline = explode("||", $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++; } }
|
|
|
|
Joined: Nov 2001
Posts: 745
Admin Emeritus
|
Admin Emeritus
Joined: Nov 2001
Posts: 745 |
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.
|
|
|
|
Joined: Jun 2002
Posts: 111
Member
|
Member
Joined: Jun 2002
Posts: 111 |
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?
|
|
|
|
Joined: Jan 2000
Posts: 5,834 Likes: 20
UBBDev Owner Time Lord
|
UBBDev Owner Time Lord
Joined: Jan 2000
Posts: 5,834 Likes: 20 |
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 
|
|
|
|
Joined: Jan 2000
Posts: 5,834 Likes: 20
UBBDev Owner Time Lord
|
UBBDev Owner Time Lord
Joined: Jan 2000
Posts: 5,834 Likes: 20 |
Well, I found a bug... I'm running the latest version and for once I'm using the section: (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 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: if ($count > 1) echo " || "; And the "Tech News" section the first two stories mesh together instead of using: (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)...
|
|
|
|
Joined: Nov 2001
Posts: 745
Admin Emeritus
|
Admin Emeritus
Joined: Nov 2001
Posts: 745 |
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.
|
|
|
|
Joined: Jan 2000
Posts: 5,834 Likes: 20
UBBDev Owner Time Lord
|
UBBDev Owner Time Lord
Joined: Jan 2000
Posts: 5,834 Likes: 20 |
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
|
|
|
|
Joined: Nov 2001
Posts: 745
Admin Emeritus
|
Admin Emeritus
Joined: Nov 2001
Posts: 745 |
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.
|
|
|
|
Joined: Jan 2000
Posts: 5,834 Likes: 20
UBBDev Owner Time Lord
|
UBBDev Owner Time Lord
Joined: Jan 2000
Posts: 5,834 Likes: 20 |
Ahh, that's looking beautiful; thanks  ... Now to go terrorize more php code!
|
|
|
|
Joined: Nov 2001
Posts: 745
Admin Emeritus
|
Admin Emeritus
Joined: Nov 2001
Posts: 745 |
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  ) - 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.
|
|
|
|
Joined: Nov 2001
Posts: 745
Admin Emeritus
|
Admin Emeritus
Joined: Nov 2001
Posts: 745 |
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: $morepath = $CGIURL . "/ultimatebb.cgi/ubb/get_topic/f/" . $forum . "/t/" . $topicnum; //$morepath = $CGIURL . "/ultimatebb.cgi?ubb=get_topic;f=" . $forum . ";t=" . $topicnum; Example After: //$morepath = $CGIURL . "/ultimatebb.cgi/ubb/get_topic/f/" . $forum . "/t/" . $topicnum; $morepath = $CGIURL . "/ultimatebb.cgi?ubb=get_topic;f=" . $forum . ";t=" . $topicnum;
|
|
|
|
Joined: Jan 2000
Posts: 5,834 Likes: 20
UBBDev Owner Time Lord
|
UBBDev Owner Time Lord
Joined: Jan 2000
Posts: 5,834 Likes: 20 |
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  .
|
|
|
|
Joined: Nov 2001
Posts: 745
Admin Emeritus
|
Admin Emeritus
Joined: Nov 2001
Posts: 745 |
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 
|
|
|
|
Joined: Jan 2000
Posts: 5,834 Likes: 20
UBBDev Owner Time Lord
|
UBBDev Owner Time Lord
Joined: Jan 2000
Posts: 5,834 Likes: 20 |
Well the timezone for RSS has to be in an exact format; we have a discussion at ugn here on the subject though  ... 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.
|
|
|
|
Joined: Jan 2003
Posts: 3,456 Likes: 2
Master Hacker
|
Master Hacker
Joined: Jan 2003
Posts: 3,456 Likes: 2 |
http://www.ianspence.com/?page=rss First, use the following function 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 $date = date( "D, d M Y H:i:s T" , strtotime( convert_date( $day . ' ' . $hour ) ));
|
|
|
|
Joined: Jan 2000
Posts: 5,834 Likes: 20
UBBDev Owner Time Lord
|
UBBDev Owner Time Lord
Joined: Jan 2000
Posts: 5,834 Likes: 20 |
Ian, not bad, however it sets the time as "00:00:00" vs the time of the post 
|
|
|
|
Joined: Jan 2003
Posts: 3,456 Likes: 2
Master Hacker
|
Master Hacker
Joined: Jan 2003
Posts: 3,456 Likes: 2 |
are you entering the entire time. by $hour I meant "05:15 PM"
|
|
|
|
Joined: Jan 2000
Posts: 5,834 Likes: 20
UBBDev Owner Time Lord
|
UBBDev Owner Time Lord
Joined: Jan 2000
Posts: 5,834 Likes: 20 |
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: // Use ShortURLs? 1 = yes, 0 = no. $shorturls = "1"; Then add this before you define your layout: 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; }
|
|
|
|
Joined: Nov 2001
Posts: 745
Admin Emeritus
|
Admin Emeritus
Joined: Nov 2001
Posts: 745 |
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 
|
|
|
|
Joined: Nov 2001
Posts: 745
Admin Emeritus
|
Admin Emeritus
Joined: Nov 2001
Posts: 745 |
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.
|
|
|
|
Joined: Mar 2000
Posts: 21,079 Likes: 3
I type Like navaho
|
I type Like navaho
Joined: Mar 2000
Posts: 21,079 Likes: 3 |
Does this do rss 2.0 feeds? I saw someone at ubbcentral requesting the ability.
|
|
|
Donate to UBBDev today to help aid in Operational, Server and Script Maintenance, and Development costs.
Please also see our parent organization VNC Web Services if you're in the need of a new UBB.threads Install or Upgrade, Site/Server Migrations, or Security and Coding Services.
|
|
Posts: 69
Joined: January 2001
|
|
Forums63
Topics37,575
Posts293,931
Members13,824
|
Most Online6,139 Sep 21st, 2024
|
|
Currently Online
Topics Created
Posts Made
Users Online
Birthdays
|
|
|
|