Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions
  #1  
Old 03-02-2001, 04:18 AM
bombout bombout is offline
 
Join Date: Nov 2001
Posts: 4
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Is there a hack to show the most recent 5 threads on my main index.html (or shtml) page for my site, linking to the respective posts?

I have seen this on other forums such as UBB, but I have little knowledge in mySQL programming, so I don't know how to pull this info out.

Can anyone point me in the direction of a hack, or help with the programming?

Thanks In Advance.
Reply With Quote
  #2  
Old 03-02-2001, 05:55 AM
Guest
 
Posts: n/a
Default

i would like this too

thx
Reply With Quote
  #3  
Old 03-03-2001, 10:25 AM
Guest
 
Posts: n/a
Default

I'm taking it that no-one knows any way to do this?

Comments aappreciated.
Reply With Quote
  #4  
Old 03-03-2001, 10:39 PM
Guest
 
Posts: n/a
Default

You could use the query:

SELECT threadid, dateline, title FROM thread WHERE visible=1 AND open=1 AND dateline!=4294967295 ORDER BY dateline DESC LIMIT 5;

But you would probably want to do some permissions checking for each.

Here is something to get you started:

Visit http://www.php.net. Read through the manual (you can skip the parts for most of the modules, just be sure to read the MySQL one). If you have done any programming before it won't be bad. Then go to http://www.mysql.com and read the documentation there. Then just go look at the /forum/index.php and just see if you can figure out how it displays the forums. Then check out /forum/forumdisplay.php and see how it displays the threads. Some other files to look at would include /forum/global.php, /forum/admin/global.php and /forum/admin/functions.php. Then you should have a pretty good idea of how to accomplish this, its not that difficult.
Reply With Quote
  #5  
Old 03-04-2001, 06:31 AM
Guest
 
Posts: n/a
Default

I am going to give this a go, but I havent done any PHP/SQL before, so I might struggle.

If I manage to do this I will post it up here, if anyone else manages to complete a version of this, it would be appreciated too...
Reply With Quote
  #6  
Old 03-04-2001, 09:39 AM
Guest
 
Posts: n/a
Default

I tried using this code as a new file...

Code:
<?php
require("global.php");

$db_link = @mysql_pconnect("$dbservername", "$dbusername", "$dbpassword");
mysql_select_db ("$dbname", $db_link);

$query = mysql_query("SELECT threadid, dateline, title FROM thread WHERE visible=1 AND open=1 AND dateline!=4294967295 ORDER BY dateline DESC LIMIT 5");

while($row = mysql_fetch_array($query))
          {
          $username = $row["title"];

          print("$title");
          }

?>
But that gave me the error:

Warning: Supplied argument is not a valid MySQL-Link resource in /home/bombout/public_html/board/posts.php on line 5

.. when I ran posts.php (my new file name)

Anyone got any ideas?
Reply With Quote
  #7  
Old 03-04-2001, 12:06 PM
Guest
 
Posts: n/a
Default

I would much rather help someone that is at least trying to do it on their own then just write it for someone.

The problem you have here is that you are trying to connect to the MySQL db on your own, let the vB engine do that. If you look in admin/db_mysql.php there is already a class designed for this, (Plus if you look in any vB file you can see this being used). Whenever you load the global.php several things happen automatically. First as persistant connection is opened to the db server, so no need for that. Next variables are for who the person is and session stuff. When reading through the files be sure you also read through any included files. What I did when I began writing the hacks (granted I only started two weeks ago) I printed out all the common files, global.php, functions.php, session.php and then the index.php from the forum dir. Then I just started at the global.php and read through. If I came to a new function that wasn't a PHP function I found that function definition and parsed it in my mind. Doing this will just give you a general understanding of how it all works.

Now what you are trying to do would be changed to this.

PHP Code:
<?php

chdir
"./forum");
require( 
"./global.php");
chdir".." );

/* Note: anytime you include global.php you must include it at the beginning
 before any output it sent. The way around this would be to set output buffering
 in the php.ini file, however a better practice would be to just get in the habbit of
 including it before you send any PHP or HTML output. */

?>
<HTML>
<BODY>

<?php

$recentThreads 
$DB_site->query"
SELECT threadid, dateline, title
FROM thread
WHERE visible=1 AND open=1 AND dateline!=4294967295
ORDER BY dateline DESC LIMIT 5"
);

while ( 
$thread $DB_site->fetch_array$recentThreads ))
{
        
$output .= "<a href=\"/forum/showthread.php?s=$session[sessionhash]&threadid=$thread[threadid]\">$thread[title]</a><br>";
}

dooutput$output );

?>
</BODY>
</HTML>
Now this is still incomplete. You would want to add permissions checking to the thread, look at the forumdisplay.php and index.php files. You will want to first check the user has permission on the forum the thread is in (use the forumid element of the thread table) and then make sure the thread is visible ( visible element of the thread table).
Reply With Quote
  #8  
Old 03-04-2001, 12:22 PM
Guest
 
Posts: n/a
Default

Thank you.

I have modified it slightly to work along with my board, but it was basically getting the topics to be linked to the board which I was finding the trouble with in the end

Thank You Again, and I will continue to work with it
Reply With Quote
Reply

Thread Tools
Display Modes

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 07:45 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.05149 seconds
  • Memory Usage 2,219KB
  • Queries Executed 13 (?)
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
  • (1)bbcode_code
  • (1)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (8)post_thanks_box
  • (8)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (8)post_thanks_postbit_info
  • (8)postbit
  • (1)postbit_onlinestatus
  • (8)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_postinfo_query
  • fetch_postinfo
  • 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