 |
 |
 |
 |
#199740 - 08/23/05 08:39 AM
Re: [6.4 - 6.5 - 6.6 - 6.7] [beta] UBBNews PHP Feed
|
Member
Registered: 06/13/02
Posts: 100
|
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++;
}
}
|
|
Top
|
|
|
|
 |
 |
 |
 |
|
|