1
flyingkick
disallow anonymous search
  • 2008/6/9 13:49

  • flyingkick

  • Just popping in

  • Posts: 11

  • Since: 2008/5/19


Hi,
I've installed XOOPS 2.0.18.1 with newBBex as a forum on my website. I want anonymous users to be able to view the forum topics, but I don't want them to be able to use the search function. Only registered users should be able to do so.

I've disabled access for anonymous users in admin->groups->anonymous users->Block Access rights. I thought that would do the trick, but when I type http://www.mywebpage.com/search.php in my browser, without logging in, I am still able to use the search function. Also, the NewBBex module does not seem to have a setting to disable search permission for anonymous users. So I gather that is regulated in the XOOPS group settings, right?

I did a search here for setting search permissions, but couldn't find what I am looking for. Is what I've described possible in xoops? Have I missed something in the configuration settings? Any help is greatly appreciated.
Cheers.

2
trabis
Re: disallow anonymous search
  • 2008/6/9 13:59

  • trabis

  • Core Developer

  • Posts: 2269

  • Since: 2006/9/1 1


You have to edit newbbex/xoops_version.php

$modversion['hasSearch'] = 0;

3
frankblack
Re: disallow anonymous search
  • 2008/6/9 14:03

  • frankblack

  • Just can't stay away

  • Posts: 830

  • Since: 2005/6/13


hasSearch = 0 removes newbbex from being searched. flyingkick instead wants to disallow search for guests.

Edit search.php and insert after include 'mainfile.php'; this line:
if (!is_object($xoopsUser)) redirect_header('index.php',2,_NOPERM);


This should do the trick?

4
zyspec
Re: disallow anonymous search
  • 2008/6/9 14:06

  • zyspec

  • Module Developer

  • Posts: 1095

  • Since: 2004/9/21


You're right. Currently ./search.php will not prevent anonymous users from being able to search the modules where they have the view rights.

I believe the only option to acccomplish what you want is to "hack" ./search.php

Here's a "suggestion" - although I haven't actually tried this:

replace line 92 in search.php
$groups is_object($xoopsUser) ? $xoopsUser -> getGroups() : XOOPS_GROUP_ANONYMOUS;

with:
if (is_object($xoopsUser) {
    
$groups $xoopsUser -> getGroups();
}else{
    
redirect_header(XOOPS_URL."/",3,_NOPERM);
    exit();
}


Edited: To fix stupid coding error in example... (thanks frankblack )

5
frankblack
Re: disallow anonymous search
  • 2008/6/9 14:12

  • frankblack

  • Just can't stay away

  • Posts: 830

  • Since: 2005/6/13


something missing in your code?

if (is_object($xoopsUser) {
    
$groups $xoopsUser -> getGroups();
}else{
        
redirect_header(XOOPS_URL."/",3,_NOPERM);
    exit();
}

6
flyingkick
Re: disallow anonymous search
  • 2008/6/9 17:44

  • flyingkick

  • Just popping in

  • Posts: 11

  • Since: 2008/5/19


WOW! That was quick. Thanks a million guys

7
flyingkick
Re: disallow anonymous search
  • 2008/6/10 19:02

  • flyingkick

  • Just popping in

  • Posts: 11

  • Since: 2008/5/19


Ok, just to let you guys know I've put the line of code suggested by frankblack in the search.php, and it works like a charm. One thing though. NewBBex has its own search.php file. I used frankblack's hack because it also works on the /NewBBex/search.php file.

I haven't tried the code suggested by zyspec because there was no need after confirming the first one works, but I'm curious, what's the difference in both codes? Is one more secure than the other? Thanks again guys.

8
trabis
Re: disallow anonymous search
  • 2008/6/10 19:08

  • trabis

  • Core Developer

  • Posts: 2269

  • Since: 2006/9/1 1


No diference, it just saves some bytes and looks more professional. The result is the same regarding to safety.

9
flyingkick
Re: disallow anonymous search
  • 2008/6/11 18:30

  • flyingkick

  • Just popping in

  • Posts: 11

  • Since: 2008/5/19


Thanks for the headsup! This is a great forum.

Login

Who's Online

262 user(s) are online (152 user(s) are browsing Support Forums)


Members: 0


Guests: 262


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits