vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 2.x Full Releases (https://vborg.vbsupport.ru/forumdisplay.php?f=4)
-   -   Simple newsportal / thread overview to add to your board... (https://vborg.vbsupport.ru/showthread.php?t=38334)

KuraFire 05-05-2002 10:00 PM

Simple newsportal / thread overview to add to your board...
 
Okay, this isn't really a hack, since you don't have to modify any vb-files really, but I figured this was the best place to make it public anyhow. I found it rather useful myself, so I figured others might, too.

Last update: April 28th, 2003!
** Update summary: **
The bug that could occur due to MySQL stupidity has been fixed. Version 2 of the Newsportal script is now attached in this post, you can simply overwrite the newsportal.php on your site with the one from the attached zipfile to upgrade.
From now on, no more vB files need to be adjusted nor do you have to make any database changes. If you've already done all that due to the mysql-bug in a previous stage of this hack, you can just leave it like that, it won't do any harm. If you're intent on 'cleaning' your files again, let me know if you can't get it done yourself.


Q&A:
What does this 'hack' do?

http://www.kurafire.com/newsportal.php

That's a live example of the fully functional version of the Hack (version 2). I think it speaks for itself. :)

The amount of newsposts & threads on the right is set in a variable at the beginning.


Is this hack hard to install?
Absolutely not. You upload the newsportal.php, you add the new templates (see zipfile), and you place a link to newsportal.php wherever you want it on your site. That's it. :)
You don't have to modify any vB files, nor your database. :)


Does this hack include my style and everything?
Yes, the newsportal page will use your headinclude, header, footer and style-colors (pagebgcolor, tableouterwidth, linkcolor, etc.) and all these settings are easily configureable. You just edit the templates like you're (hopefully) used to with all the normal vB Templates.


Version 2:
The newsportal script now uses 2 queries to get the necessary information for your News posts. One for all thread info and the postid's of the starting posts, and one for the pagetext (ie. post contents) of all those postid's. You can use 2, 20 or 200 newsposts, that won't matter, it'll always be 2 queries (though I discourage using more than 20 newsposts :p). ^_^

That's it, you're all done. Have fun with the newsportal! ^_^

AnkisethGallant 05-06-2002 09:03 PM

You gotta screenshot KuraFire?

TECK 05-06-2002 09:04 PM

any pics? or a site in action? thanks. ;)

KuraFire 05-06-2002 09:04 PM

And an example of how it looks with the default configuration of the templates, and my own colors etc.

(I didn't display the header here, because I'm keeping it a secret till all goes online - this page isn't available to be viewed online at the moment, really, only on my work-in-progress board so far)

KuraFire 05-06-2002 09:05 PM

holy [better wash my mouth][better wash my mouth][better wash my car;)][better wash my mouth] you guys are fast... :p

edit: LOL @ censoring here! :lol:

AnkisethGallant 05-06-2002 09:05 PM

That actually looks pretty cool, I might just end up installing that. Nice work.

Floris 05-06-2002 09:07 PM

Way cool, way cool, way cool. :)

KuraFire 05-06-2002 09:15 PM

Note that this 'hack' does not (yet?) incorporate Permissions, so if you don't exclude your Admin/Moderator's forum (which I expect everyone has) normal users will be able to view those forum's threads' names (not able to read the threads 'mselves of course)

Floris 05-06-2002 09:36 PM

http://www.marietje.nl/vbb/newsportal.php?s=$session[sessionhash]

As you can see, works just fine!
Installation was so easy, I thought I forgot something :D

Great hack! Love it!


Found a little bug though. Sometimes its the second post or the last one from a news thread :/

KuraFire 05-06-2002 09:44 PM

dude: "$session[sessionhash] " <= this is for in your TEMPLATE, not for use on forums etc. :p:p:p

Anyhoo, yeah that bug is making me go crazy, I haven't found a pattern in it at all, and on my own system it has totally disappeared (for now, anyway). I REALLY don't know what's causing that, though... :(

Might be a problem with the Query, but then again, it shouldn't be malfunctioning (it worked for me in the past, in a different page setup)

zachb 05-07-2002 02:19 AM

/me likes the hack.

Xenon 05-07-2002 06:50 AM

this hack looks good.

funnyly i have written such a thing for myself two days ago :)

now im in the university, so i cannot download your hack, but when i'm at home, i will, and try to find the bug, because my hack doesn't have this bug, so i'd compare and perhaps find the bug

TECK 05-07-2002 07:18 AM

i wonder how many queries are pulled with this hack?
i didnt downloaded the hack yet.. let me know kura...

Floris 05-07-2002 07:28 AM

Xenon : fnx! Would be great :)
nakkid : check the code :) I do not see many queries

KuraFire 05-07-2002 07:57 AM

2 queries only :)

and xenon: thanks, that'd be great. :)
(I'm really baffled by the random appearance of this bug)

TECK 05-07-2002 07:58 AM

no, i reffer to the full page. do an explain=1 please and let me know if it goes higher then 40.

Floris 05-07-2002 08:03 AM

Due to security and a bug in 2.2.5, that has been unset. Sorry, I can not test it. I stick with 2 queries :)

KuraFire 05-07-2002 08:07 AM

"Page generated in 0.8501260 seconds (17.14% PHP / 82.86% MySQL) with 14 queries "

(seems that coincidentally, the percentages check out this time, lol!)

Note that if you don't run extra queries in your Header (like me) this number will be even lower :)

TECK 05-07-2002 08:08 AM

looks good then :)

Floris 05-07-2002 08:08 AM

I just put back the db_mysql.php for testing this, and only 4 queries could be related to the hack, the rest is obviously through global and default vB. I removed the hack and let the page load, and had 10 instead of 12. So I stick to only 2 queries. maybe a few more for replacements and/or smilies etc.

TECK 05-07-2002 08:16 AM

i looked at your code kura.. the way is set now will also show to everyone the posts made in a private forum (if you have a private forum). you need to add some perms in there... just a thought.

TECK 05-07-2002 08:18 AM

Quote:

Originally posted by xiphoid
I just put back the db_mysql.php for testing this, and only 4 queries could be related to the hack, the rest is obviously through global and default vB. I removed the hack and let the page load, and had 10 instead of 12. So I stick to only 2 queries. maybe a few more for replacements and/or smilies etc.
you cant have only 2 queries because for every thread it will do one. so if it shows 10 threads or posts, you will have 10 queries.. and so on...

KuraFire 05-07-2002 08:41 AM

That's nonsense.

It takes 1 query to extract the firstposts of X amount of different threads on the newsforum you specify, and 1 query to extract all the threads-overview info.

You can increase the amount of newsposts listed, but it won't affect the query count.

Nakkid, if you read post #8 in this thread, you'll see that I already commented on that. :)

(I'm not capable of adding permissions myself yet, still too much of a n00b for that, but I'm working on it :))

TECK 05-07-2002 08:50 AM

try this for perms:
https://vborg.vbsupport.ru/showthrea...threadid=38355

i didnt test it, i just put it togheter... let me know if it can help you out. :)
about the queries.. if i'm correct, for every thread,forum that is checked the script will perform a query. the more forums you have the more queries you will add, etc. goes the same way with the threads. i know element that have an impressive 108 queries on his page. over 40queries your server gets on its knees if it's a busy board..

KuraFire 05-07-2002 08:55 AM

Thanks, I'll have a look into it and see what I can work out. :)

:up:

KuraFire 05-07-2002 08:59 AM

Quote:

Originally posted by nakkid
about the queries.. if i'm correct, for every thread,forum that is checked the script will perform a query. the more forums you have the more queries you will add, etc. goes the same way with the threads. i know element that have an impressive 108 queries on his page. over 40queries your server gets on its knees if it's a busy board..
No, that's only the case if you run two queries per output, one to select the forum and thread, one to extract the post.

However, my query (in the newsportal.php file) uses a JOIN so that it can extract as many firstposts from a single (or multiple, if you want) forum, with only 1 single query. The JOIN worked perfectly fine in phpMyAdmin, but it seems to have a random bug when put in use through vB itself. It's still just 1 query though, trust me. :)

TECK 05-07-2002 09:01 AM

ok. thanks for the info. :)

Floris 05-07-2002 09:23 AM

Kura does it like we wish all of those type of scripts were made. Efficient. Nice example for vBportal etc.

KuraFire 05-07-2002 10:07 AM

Yeah I've seen a vbPortal site that had 199 queries run. :eek:

[high]* KuraFire goes dive into adding permissions to this script, now.. :)[/high]

FlyingDutchman 05-07-2002 10:44 AM

Quote:

Originally posted by KuraFire
Yeah I've seen a vbPortal site that had 199 queries run. :eek:
we all know that VbPortal sucks :)

I think your script is pretty nice man ;)
I like VbIndex a bit more (when you edit it well :D) because of it's menu...
oh, well, yours is cool too, if you don't have a high-end server ;)

KuraFire 05-07-2002 11:15 AM

I made this script basically just for my own needs, but figured others might appreciate it as well. :)

Man, this permissions thing is giving me a headache. Nakkid, I can't say exactly why that part of code of yours is adding 1 query for every thread, but it does suck and it's hell trying to get around it. :(

Xenon 05-07-2002 04:37 PM

well i'm not sure, why there is sometimes an error and sometimes not

i think you can solve this problem, with making an extra query for each message news, i have made it so an it works:

PHP Code:

$newsql $DB_site->query("SELECT thread.threadid as tid, thread.title as ttitle, thread.replycount as treply, thread.postusername as user, thread.postuserid as userid, thread.dateline as dateline FROM thread WHERE forumid=$newsforum GROUP BY thread.threadid ORDER BY thread.threadid DESC LIMIT $newslimit");
if (!
$newsql) {
  
// use this only to check whether it works on your board, 
  // after all tests turn successful you can remove it if you want (remove entire IF-statement of course)
  
echo "<p>Could not get news records.";
  exit;
}

while (
$news=$DB_site->fetch_array($newsql)) {
    
$newstext=$DB_site->query_first("SELECT post.pagetext FROM post    WHERE post.threadid='$news[tid]' ORDER BY postid LIMIT 1");
    
$pagetext=$newstext['pagetext']; 

instead of

PHP Code:

$newsql $DB_site->query("SELECT thread.threadid as tid, thread.title as ttitle, thread.replycount as treply, thread.postusername as user, thread.postuserid as userid, thread.dateline as dateline, post.pagetext as pagetext FROM thread LEFT JOIN post USING (threadid) WHERE forumid=$newsforum GROUP BY thread.threadid ORDER BY thread.threadid DESC LIMIT $newslimit");

if (!
$newsql) {
  
// use this only to check whether it works on your board, 
  // after all tests turn successful you can remove it if you want (remove entire IF-statement of course)
  
echo "<p>Could not get news records.";
  exit;
}

while (
$news=$DB_site->fetch_array($newsql)) { 

i think it should work, but i dont tested it, just compared with my files ;)

try it and say it to me if it works or not. If not, i will check it a more :)

KuraFire 05-07-2002 04:42 PM

That should work fine, from what I see, but it adds a query for each news item, and I'm trying to get rid of that since I _know_ this can be done using only 2 queries.

With your code, the default setup would add 8 queries to the 10~12 that global.php runs already. Seems to me as not very efficient. :(

Besides, that's how my _old_ script was run. One query for the newsforum, and one for each news item..... I was hoping to _advance_ :(

Thanks though. Well-appreciated :):up:

AndyTSJ 05-07-2002 05:33 PM

How can I pull news from more than one forum

Code:

$newsforum = 5;

Parker Clack 05-07-2002 05:43 PM

Kurafire:

To get the permissions issued addressed on my site I used

Code:

if (ismoderator($forumid) or $getperms['canopenclose'] or $getperms['candeletethread'] or $getperms['canmove']) {
$threadsql = $DB_site->query("SELECT lastposter, threadid, title, replycount FROM thread WHERE forumid ORDER BY lastpost DESC LIMIT $threadslimit");
} else {
$threadsql = $DB_site->query("SELECT lastposter, threadid, title, replycount FROM thread WHERE forumid $forumexclude ORDER BY lastpost DESC LIMIT $threadslimit");
}

in the threads section just above the array.

Parker

KuraFire 05-07-2002 05:53 PM

AndyTSJ:

try replacing that line with

PHP Code:

$newsforum "5 OR forumid=6"

where 5 and 6 are the id's of the two newsforums. I'm not sure if this really works, but it's worth a try. Let us know if it works, eh? :):up:

Parker: have you tried that out as a normal registered member?

come to think of it, would this piece of code work?

PHP Code:

if ( $getperms['canview']) {
 
$threadsql DB_site->query("SELECT lastposter, threadid, title, replycount FROM thread WHERE forumid ORDER BY lastpost DESC LIMIT $threadslimit");
} else {
$threadsql $DB_site->query("SELECT lastposter, threadid, title, replycount FROM thread WHERE forumid $forumexclude ORDER BY lastpost DESC LIMIT $threadslimit"); 


? I'll test this later on, but if someone else wants to test this right away, be my guest and let us know :)

(I'm off for some things so I can't test it myself right now :()

AndyTSJ 05-07-2002 05:57 PM

That works !!!!!!!!!!!!!!!!! COOL :) :)

Parker Clack 05-07-2002 06:50 PM

Kurafire:

I tried the $getperms['canview'] before I tried what I suggested above and that didn't work.

The code that I suggested works on my board just fine and it will only allow those admins, etc. that are allowed to view a private forum see the thread listed. If you are a regular member you will not see the ones that you set up in $forumexclude.

Parker

KuraFire 05-07-2002 07:59 PM

Parker: ah yes, I saw that already but the thing is, I'm one of those people who have more than the default usergroups. I have 1 category with 4 forums in it that is only accessible to users in a certain usergroup, and 1 forum elsewhere that is only accessible to users in yet Another special usergroup.
Using your code wouldn't help at all for my board, nor for people who have something similar.

However, it DOES indeed work on boards where there's only admins, S-mods and normal members, I guess. Thanks for that addition, therefore, because it will at least allow people with such board-setups to include permissions in this script already. :)

TECK 05-07-2002 08:24 PM

kura, PPN rewrote the perms code i had there in a much more elegant way. take a look and insert it also in your script:
https://vborg.vbsupport.ru/showthrea...924#post248924


All times are GMT. The time now is 06:41 AM.

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.01631 seconds
  • Memory Usage 1,840KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_code_printable
  • (4)bbcode_php_printable
  • (3)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (40)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete