Go Back   vb.org Archive > Community Discussions > Modification Requests/Questions (Unpaid)
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 04-14-2003, 01:37 PM
remal remal is offline
 
Join Date: Apr 2003
Posts: 6
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default latest threads from $forumXX

hello, iam searching for a hack or just a small php script that list the latest post or threads from a specific forum..

i found a few scripts thats list the latest threads, but you cant specifi a particular forum, they list the lasx XX threads from all of the forum.

if there is a script to do that it will be terrific, if not, what is the SQL query i need to do in order to get the last XX post or threads from a forumID...
Reply With Quote
  #2  
Old 04-14-2003, 02:21 PM
The_Cyberdemon The_Cyberdemon is offline
 
Join Date: Mar 2003
Location: VA
Posts: 132
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Umm, do something like this on your index.php file:
Code:
$numbersthreads=$DB_site->query_first('SELECT COUNT(*) AS threads,MAX(threadid) AS maxthread FROM thread WHERE forumid=1');
$numberthreads=number_format($numbersthreads['threads']);
$getnewestthreadforum=$DB_site->query_first("SELECT threadid,title FROM thread WHERE threadid=$numbersthreads[maxthread]");
$newthread=$getnewestthreadforum['title'];
$newthreadid=$getnewestthreadforum['threadid'];
Replace 1 with the forumid of your choice.
Then, in the FORUMHOME template, put this wherever you want it:
Code:
Newest Thread in Forum forum name:
<a href="showthread.php?s=$session[sessionhash]&threadid=$newthreadid">$newthread</a>
That should work. If you get an invalid URL, try:
<a href=\"showthread.php?s=$session[sessionhash]&threadid=$newthreadid\">$newthread</a>
Instead of:
<a href="showthread.php?s=$session[sessionhash]&threadid=$newthreadid">$newthread</a>

Hope that helps.
Reply With Quote
  #3  
Old 04-14-2003, 02:43 PM
remal remal is offline
 
Join Date: Apr 2003
Posts: 6
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

not working :disappointed:

PHP Code:

<?

$DB = mysql_connect("localhost", "SQLU_SER", "SQL_PASS");
mysql_select_db("SQL_DATABASE", $DB);

$numbersthreads= mysql_query("SELECT count(*) AS threads,max(threadid) AS maxthread FROM thread WHERE forumid=7 LIMIT 5");
$numberthreads= number_format($numbersthreads['threads']);
$getnewestthreadforum= mysql_query("SELECT threadid,title FROM thread WHERE threadid=$numbersthreads[maxthread] LIMIT 5");
$newthread=$getnewestthreadforum['title'];

mysql_close($DB);

echo "<a href=showthread.php?s=$session[sessionhash]&threadid=$newthreadid>$newthread</a>";
?>
it give me this output:
Code:
<a href=showthread.php?s=&threadid=></a>
Reply With Quote
  #4  
Old 04-14-2003, 04:37 PM
The_Cyberdemon The_Cyberdemon is offline
 
Join Date: Mar 2003
Location: VA
Posts: 132
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

A: Make sure it's on the main page
B: Make sure you edited the *ForumRoot*/index.php page
C: Try putting \ in front of each quote

Oh, you messed up. Put the <a href... blah blah blah thing in your FORUMHOME template, not in the php file.

And do this: <a href=\"showthread.php?s=$session[sessionhash]&threadid=$newthreadid\">$newthread</a>
Reply With Quote
  #5  
Old 04-14-2003, 05:07 PM
remal remal is offline
 
Join Date: Apr 2003
Posts: 6
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default



but i dont want to put the results on the index.php

what im trying to do is creating a api.php script so other sites can get the latest threads from a the forum that they want:

ex: <? include "http://mysite.com/forum/api.php?forum=7&show=5"; ?>

which will show them the last 5 threads from forum 7
Reply With Quote
  #6  
Old 04-18-2003, 07:14 PM
Highlander Highlander is offline
 
Join Date: Apr 2002
Posts: 188
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

thats exactly what i searching for month
Reply With Quote
  #7  
Old 04-18-2003, 07:52 PM
remal remal is offline
 
Join Date: Apr 2003
Posts: 6
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

here its


api.php
PHP Code:
<?
/// ex: [url]http://www.you.com/api.php?fid=7[/url]
/// fid is the forum ID
/////////////// CONFIG ///////////////
// 
$url = "http://www.you.com"; // URL to your board - NO TRAILING SLASH!
$urlimg = "http://www.you.com/images"; // URL to your board's images - NO TRAILING SLASH!
$maxthreads = "5"; // max threads to show. will show less if $last24 or $last7 limits it to less results than this number
$ob = "lastpost"; // set to one of the following: replycount , views , lastposter , title , lastpost (lastpost is most popular. it's the thread most recently replied to, then the second-to-last most recent, etc.)
$obdir = "desc"; // which direction to sort? "desc" goes from bottom to top (9 to 1, z to a, etc.). "asc" goes top to bottom (1 to 9, a to z, etc.). if you use lastpost for $ob, leave this set to desc or it will not work correctly!
$last24 = "0"; // 1 = last 24 hours; 0 = all (must set this to 0 if $last7 is set to 1)
$last7 = "0"; // 1 = last 7 days; 0 = all (must set this to 0 if $last24 is set to 1)
$bc1 = "#d8d8e9"; // first alt color
$bc2 = "#f0f0f7"; // second alt color
$hc = "#FFFFFF"; // head background color
$lc = "#000080"; // link color
$tc = "#FFFFFF"; // text color
$f = "tahoma"; // font face
$fs = "8"; // font size in points - 8 is normal, 6 is on the small side, 10 on the large side. play around with it. :)
$lastposter = "0"; // show last poster? 1 = yes; 0 = no
$views = "0"; // show view count? 1 = yes; 0 = no
$replies = "0"; // show reply count? 1 = yes; 0 = no
$lastpostdate = "0"; // show last post date and time? 1 = yes; 0 = no
$len = 35; // maximum number of characters of the title to show. e.g. if the title is 60 characters and this is set to 25, only the first 25 characters of the title will be shown (followed by ...)
$excludeforums = ""; // if you want to exclude a forum, put it's ID here. more than one, seperate them with commas, NO SPACES! e.g. 1,2,3,4
$includeforums = "$fid"; // if you only want to include certain forums, put their ids here. separate more than one with commas, NO SPACES! e.g. 1,2,3,4
$showmessages = "0"; // show the text of the last post too? 1 = yes; 0 = no
$lplen = "300"; // character length of last post text (if $showmessages is set to 0 this won't do anything).
$tw = ""; // width of the table that shows the info, in either a percent ( e.g. 95% ) or in pixels ( e.g. 300 ). leave blank if you want the table to be sized naturally
$showdate = "0"; // show the date, as well as the time? if the posts that show up in the list are likely to all be from today (or you set $last24 to "1"), you can set this to 0. if the posts are spread over multiple days, you probably want this set to 1.
$cs = "0"; // this is the cellspacing. 1 makes a thin line around the cells. 0 makes no line.
$showicon = "0"; // shows the posts' icon next to the post
$showforumtitle = "0"; // shows the forum title (linked to that forum) next to the thread title
$nb = "0"; // do you want breaks in text to appear as such? this may cause problems if there are large breaks in the text
//
///////////// END CONFIG /////////////


require("/full/path/to/admin/config.php");
$db=mysql_connect($servername,$dbusername,$dbpassword) or die("Can't open connection to MySQL");
mysql_select_db($dbname) or die("Can't select database");

$hfs = $fs+2;
$fs .= "pt";
$hfs .= "pt";
if ($tw == "") {
    $twt = "";
} else {
    $twt = "width=\"$tw\"";
}
if ($cs == "") {
    $cs = 0;
}

$wheresql = "WHERE thread.lastposter=user.username AND thread.open!='10'";

// we can't have both the last 24 hours *and* the last 7 days, so error out if needed
if ($last24 == "1" && $last7 == "1") {
    print("Error: \$last24 and \$last7 are both set to 1. Please change one of them to 0.");
    exit;
}
// otherwise we're gonna find out which one it is
// last 24
if ($last24 == "1") {
    $time = time()-86400;
    $wheresql .= " AND thread.lastpost>'$time'";
}
// last 7
if ($last7 == "1") {
    $time = time()-604800;
    $wheresql .= " AND thread.lastpost>'$time'";
}
// are we trying to exclude *and* include forums? if so, error out
if ($excludeforums != "" && $includeforums != "") {
    print("Error: \$includeforums and \$excludeforums are both set with numbers. Please remove the numbers from <b>one</b> of these two to proceed.");
    exit;
}
// otherwise figure out which one we're using
// include forums
if ($includeforums == "" or $includeforums <= "0") {
    $quarter = "no";
} else {
    $incfid = explode(",",$includeforums); $i = 0; $a = count($incfid);
    if ($a > 1) {
        $wheresql .= " AND (thread.forumid='$incfid[0]'";
        ++$i;
        while ($i < $a) {
            $wheresql .= " OR thread.forumid='$incfid[$i]'"; ++$i;
        }
        $wheresql .= ")";
    } else {
        $wheresql .= " AND thread.forumid='$incfid[$i]'";
    }
}
// or exclude forums
if ($excludeforums == "" or $excludeforums <= "0") {
    $quarter = "no";
} else {
    $excfid = explode(",",$excludeforums); $i = 0; $a = count($excfid);
    while ($i < $a) {
        $wheresql .= " AND thread.forumid!='$excfid[$i]'";    ++$i;
    }
}
if ($showforumtitle == "1") {
    $ftitle = ",forum";
    $fsel = ",forum.title AS ftitle";
    $wheresql .= " AND thread.forumid=forum.forumid";
}
// ooh a query!
$query = "SELECT thread.lastpost,thread.title,thread.lastposter,thread.replycount,thread.views,user.userid,thread.threadid,thread.forumid$fsel,thread.iconid FROM thread,user$ftitle $wheresql ORDER BY thread.$ob $obdir LIMIT $maxthreads";
// let's get the info
$tr = mysql_query($query) or die("MySQL reported this error while trying to retreive the info: ".mysql_error());
$dtf = mysql_query("SELECT value FROM setting WHERE varname='dateformat' OR varname='timeformat' OR varname='timeoffset' ORDER BY varname");
$df = mysql_result($dtf,0,0);
$tf = mysql_result($dtf,1,0);
$tof = mysql_result($dtf,2,0);
if ($showdate == "1") {
    $fdt = "$df $tf";
} else {
    $fdt = "$tf";
}
$cols = 1;
// let's display the info
while ($threads = mysql_fetch_array($tr)) {    
    // are we going to show the message too?
    if ($showmessages == "1") {
        $query0 = "SELECT pagetext,postid,dateline,iconid FROM post WHERE threadid='$threads[threadid]' ORDER BY dateline DESC LIMIT 1";
        $lastpost = mysql_query($query0) or die("MySQL reported this error while trying to retrieve the last post info: ".mysql_error());
        while ($lastpost1 = mysql_fetch_array($lastpost)) {
            $lastpostshort = $lastpost1[pagetext];
            $postii = $lastpost1[iconid];
        }
        if (strlen($lastpostshort) > $lplen) {
            $lastpostshort = substr($lastpostshort,0,$lplen);
            $lastpostshort .= "...";
        }
        $smilies = mysql_query("SELECT smilietext,smiliepath FROM smilie");
        while ($smiles = mysql_fetch_array($smilies)) {
            $lastpostshort = str_replace($smiles[smilietext],"<img src=\"".$url."/".$smiles[smiliepath]."\" border=0>",$lastpostshort);
        }
        if ($nb == "1") {
            $lastpostshort = nl2br($lastpostshort);
        }
        $lastpostshort = str_replace("[i]","<i>",$lastpostshort);
        $lastpostshort = str_replace("[/i]","</i>",$lastpostshort);
        $lastpostshort = str_replace("[u]","<u>",$lastpostshort);
        $lastpostshort = str_replace("[/u]","</u>",$lastpostshort);
        $lastpostshort = str_replace("[b]","<b>",$lastpostshort);
        $lastpostshort = str_replace("[/b]","</b>",$lastpostshort);
        $lastpostshort = str_replace("[quote]","<br>quote:<br><hr> ",$lastpostshort);
        $lastpostshort = str_replace("[/quote]"," <hr><br>\n",$lastpostshort);
        $lastpostshort = str_replace("[I]","<i>",$lastpostshort);
        $lastpostshort = str_replace("[/I]","</i>",$lastpostshort);
        $lastpostshort = str_replace("[U]","<u>",$lastpostshort);
        $lastpostshort = str_replace("[/U]","</u>",$lastpostshort);
        $lastpostshort = str_replace("[B]","<b>",$lastpostshort);
        $lastpostshort = str_replace("[/B]","</b>",$lastpostshort);
        $lastpostshort = str_replace("[QUOTE]","<br>quote:<br><hr> ",$lastpostshort);
        $lastpostshort = str_replace("[/QUOTE]"," <hr><br>\n",$lastpostshort);
        $lastpostshort = str_replace("[CODE]","<br>code:<br><hr> ",$lastpostshort);
        $lastpostshort = str_replace("[/CODE]"," <hr><br>\n",$lastpostshort);
        $lastpostshort = str_replace("[code]","<br>code:<br><hr> ",$lastpostshort);
        $lastpostshort = str_replace("[/code]"," <hr><br>\n",$lastpostshort);
        $lastpostshort = str_replace("[img]https://vborg.vbsupport.ru/[/img]","",$lastpostshort);
        $lastpostshort = str_replace("[img]https://vborg.vbsupport.ru/[/img]","",$lastpostshort);
        $lastpostshort = str_replace("[url]","",$lastpostshort);
        $lastpostshort = str_replace("[/url]","",$lastpostshort);
        $lastpostshort = str_replace("[URL]","",$lastpostshort);
        $lastpostshort = str_replace("[/URL]","",$lastpostshort);
    }
    // thanks to kier for this idea to do the alternating row colors
    if (($counter++ % 2) != 0) {
        $bc=$bc1;
    } else {
        $bc=$bc2;
    }
    // if the title is more than $len characters, we need to cut it off and add ... to the end
    if (strlen($threads[title]) > $len) { 
        $title = substr($threads[title],0,$len);
        $title .= "...";
    } else { 
        $title = $threads[title];
    }
    // convert the date to a format readable by non-unix geeks :)
    $fd = date($fdt,$threads[lastpost]);

    echo("$title - $url/showthread.php?threadid=$threads[threadid]&ref=arabar.com\n");
    // last poster column?



    $fd = "";
}
?>
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 12:28 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.12351 seconds
  • Memory Usage 2,274KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (3)bbcode_code
  • (2)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (7)post_thanks_box
  • (7)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (7)post_thanks_postbit_info
  • (7)postbit
  • (7)postbit_onlinestatus
  • (7)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete