vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   Member Archives (https://vborg.vbsupport.ru/forumdisplay.php?f=202)
-   -   Hide private forums from this MySQL query...very hard (https://vborg.vbsupport.ru/showthread.php?t=41941)

Jungleman 08-05-2002 05:30 PM

Hide private forums from this MySQL query...very hard
 
I am working on a hack which breaks down a users posts into forums they have posted in..

Example, if a user has 1000 posts, it shows 500 in Off Topic, 300 in Hardware Support, 150 in Software Support, 50 in Web Design, etc.

So far the hack works great, one little problem-- it shows names of private forums to people who aren't supposed to have access to them, and I want to avoid that.

Here is the query that I am using:

SELECT COUNT(p.postid) AS post_count, f.title, f.forumid FROM forum f, post p, thread t, user u WHERE f.forumid = t.forumid AND t.threadid = p.threadid AND p.userid = u.userid AND u.userid = $userid AND t.visible = 1 GROUP BY f.forumid ORDER BY post_count DESC

How can I eliminate forums NOT accessible to regular users?

BTW, if you wanna run that query on your forum to see how it works, replace $userid with the user ID of your choice.

filburt1 08-05-2002 05:46 PM

...WHERE forumid NOT IN(comma-delimited list of private forumids)

Beyond that, don't know :(

Jungleman 08-05-2002 05:52 PM

Yep...well, that'd work just for my forum, but I wanted to release this hack.

Just gotta finish this up...OK I can do it :)

Logician 08-05-2002 08:42 PM

You can ask the users to edit that part of the hack according to their forums so filburt1's solution is good.

But if you are determined to code your hack so that it will automaticly detect this, you can get the help of the function getpermissions like:

$getperms=getpermissions($forumid,-1,-1,$forum['parentlist']);

if (!$getperms['canview'] OR !$getperms['canviewothers'])
{
//user dont have permission for this forum skip it
}

Jungleman 08-05-2002 09:27 PM

Logician, what would be the usage of that code? Where should I put it?

Thanks :)

Logician 08-05-2002 10:39 PM

Did I get you wrong?

I thought you are trying to find out if forum X is closed for the user so that you can exclude it from your query. If this is correct the function I refered makes this check so you can call it before your query so that you can detect private forums for the board viewer.

I'm assuming you required global.php" in your script..

Jungleman 08-05-2002 11:51 PM

I put the require global.php in.

I put the block of code you told me to put right before my query and it did nothing, and I logged in as a test user that has no access to special forums to verify. It kept showing the hidden forums.

I think I'm doing something wrong. :confused:

Jungleman 08-12-2002 01:08 AM

Bump


All times are GMT. The time now is 12:35 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.01142 seconds
  • Memory Usage 1,717KB
  • 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
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (8)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
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete