[TUTORIAL] restricted access to SEARCH page

This mod will make it posible to specify permissions to all "special pages, like MEMBERLIST, PROFILE VIEW and so on.
The permissions support USERGROUP, making this tool very powerfull

Moderator: Moderators

Forum rules
The content in this forum is dated Dec. 21 2005 and can be used as Archive only. This Forum is LOCKED and READ ONLY !

[TUTORIAL] restricted access to SEARCH page

Postby pengrus on Wed 25. Jun, 2003 19:26

I tried to look at the code, but could not fully understand what I need to do with setting a new permission.

Here is what I like to achieve:

Restrict the Access to Search page to Registered members only. But the un-registered users should be able to see it and be prompted to login when they click on it.

If anyone could help me with the code change, I'd greatly appreciate it!

Thank you!
pengrus
Poster
Poster
 
Posts: 24
Joined: Mon 09. Jun, 2003 19:15

tutorial for search page

Postby Niels on Thu 04. Sep, 2003 12:32

the changes can also be seen in the pre-loaded pack.

you need to modify
page_header.php, overall_header.tpl and search.php
in your case you only need to modify search.php as you do not desire to hide the link showen at the top for any users.
anyway I will describe the complete solution.

in page_header.php
Code: Select all
[FIND]
$view_pages_ary = auth(AUTH_VIEW, AUTH_LIST_ALL, $userdata);

[AFTER, ADD]
if ($view_pages_ary[''.PAGE_SEARCH.'']['auth_view'])
{
   $template->assign_block_vars('switch_search_on', array());
}


in file overall_header.tpl
Code: Select all
[FIND]
<a href="{U_SEARCH}" class="mainmenu"><img src="templates/subSilver/images/icon_mini_search.gif" width="12" height="13" border="0" alt="{L_SEARCH}" hspace="3" />{L_SEARCH}</a>&nbsp; &nbsp;

[REPLACE WITH]
<!-- BEGIN switch_search_on -->
<a href="{U_SEARCH}" class="mainmenu"><img src="templates/subSilver/images/icon_mini_search.gif" width="12" height="13" border="0" alt="{L_SEARCH}" hspace="3" />{L_SEARCH}</a>&nbsp; &nbsp;
<!-- END switch_search_on -->


in file search.php
Code: Select all
[FIND]
// End session management
//
[AFTER ADD]
// Added for Extra permission MOD
// Start auth check
//
$is_auth = array();
$is_auth = auth(AUTH_ALL, PAGE_SEARCH, $userdata);

if( !$is_auth['auth_read'] )
{
   if ( !$userdata['session_logged_in'] )
   {
      $header_location = ( @preg_match("/Microsoft|WebSTAR|Xitami/", getenv("SERVER_SOFTWARE")) ) ? "Refresh: 0; URL=" : "Location: ";
      header($header_location . append_sid("login.$phpEx?redirect=search.$phpEx", true));
      exit;
   }
   $message = ( !$is_auth['auth_view'] ) ? $lang['Not_Authorised'] : sprintf ($lang['Sorry_no_auth'],$is_auth['auth_read_type']);
   message_die(GENERAL_MESSAGE, $message);
}
//
// End auth check
//


you also need to add a extra entry in your DB,
Code: Select all
'INSERT IGNORE INTO ' . FORUMS_TABLE . ' (forum_id ,cat_id, forum_name, forum_desc, forum_status )
VALUES ("'.PAGE_SEARCH.'", "0", "SEARCH PAGE", "Search Page Control", 1)',

modify the already included db_update.php to included this aswell.
(you may run the file again, it does not harm)

when this is done, you may look up the "special page forum" SEARCH, inside ACP->forum permission assign VIEW permission to users who may SEE the link to the page, assign READ permission to the users you would grant access to USE the page.

e.g.
VIEW = ALL
READ = REG
(if a how-to is EM ready, it will mostly be bullet prof, since a machine is more picky than a human. :D)
User avatar
Niels
Poster
Poster
 
Posts: 4390
Joined: Sat 27. Jul, 2002 15:46

Postby pengrus on Sun 14. Sep, 2003 18:47

Thank you very much for the detailed instruction. I made change to search.php and database, and it worked!!!

Feedback:

When I ran the following command alone in phpmyadmin, it gave me a syntax error:

Code: Select all
'INSERT IGNORE INTO ' . FORUMS_TABLE . ' (forum_id ,cat_id, forum_name, forum_desc, forum_status )
VALUES ("'.PAGE_SEARCH.'", "0", "SEARCH PAGE", "Search Page Control", 1)',


But it worked when I copied the above to the db_extra.php page and ran that file.

I have one more question:

Somehow, I added TWO SHOUTBOX PAGE to the ACP->forum permission , how can I remove one of them or both of them from the Forum Permission drop down menu?

Thank you for your help!
pengrus
Poster
Poster
 
Posts: 24
Joined: Mon 09. Jun, 2003 19:15

Postby Niels on Sun 14. Sep, 2003 21:32

to remove one of them, you need to go into phpmyadmin, and lok up your phpbb_froum table, and in here find and delete one of them
(if a how-to is EM ready, it will mostly be bullet prof, since a machine is more picky than a human. :D)
User avatar
Niels
Poster
Poster
 
Posts: 4390
Joined: Sat 27. Jul, 2002 15:46


Return to Extra permission [2.0.6/EM]

Who is online

Users browsing this forum: No registered users and 1 guest

cron