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");
// 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;
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.