Advertisement:

Author Topic: Private forum. How to make a page visible to all users, including guests?  (Read 1576 times)

Offline Juanchoartes

  • Semi-Newbie
  • *
  • Posts: 28
Hello,

I've been researching the forum but I haven't found the way to do this.

I am creating a forum in which the administrator has to manually activate registered users. Guests cannot see anything, just only the login page.

I would want to put a link on the login page that opens a page with the cookie policy. I want this Cookie policy page to keep the same aspect of the forum. I have made the page made with php (using "template_header ();" and "template_footer ();"), but what I don't know is how to make this page visible for guests.

That is my question: how to make a page that guests could see without logging in and taking into account that the forum is completely private?

The way of making the page is not important to me. I mean that if I have to do it differently, without using php, I would do it, no problem. What I would like to know is some clue on how to make that page visible to all users, including guests.

Any help on this would be more than welcome. Thanks in advance.

I am using SMF 2.0.17 and the theme is Dash (from SMFTricks).

Cheers!

Offline m4z

  • 98.8% chimp
  • Localizer
  • Sophist Member
  • *
  • Posts: 1,183
  • /mɛs/
SSI is your friend. Maybe this badly searchable FAQ entry specifically.
"Faith is what you have in things that don't exist."
--Homer Simpson

<werbung>Meine Freundin hat ihr erstes Buch veröffentlicht!</werbung>

Offline Sir Osis of Liver

  • SMF Super Hero
  • *******
  • Posts: 10,447
  • We were all equal in the end.
You can also stick it in function template_kick_guest() in Login.template.php.
“There is nothing more frightful than ignorance in action.”  Goethe

Offline Juanchoartes

  • Semi-Newbie
  • *
  • Posts: 28
Hello,

SSI is your friend. Maybe this badly searchable FAQ entry specifically.

Thank you for your answer m4z.

Yes, I had already used SSI.php and the page looked good, it looked the same as the forum. The problem is that you have to login to see it, guests cannot see it.

When researching, I found in this forum how to make a page using SSI.php. I created a php file called cookies.php with this code inside:
Code: [Select]
<?php require("/home/.../SSI.php");
template_header(); 

   echo 
   
'Here goes the Cookie Policy';

template_footer(); ?>

I have the "Allow guests to browse the forum" option disabled (is a private forum). For that reason the guests cannot see anything. I don't know if having that option disabled, I can solve the problem using SSI ...

I don't want guests to see the forum but I do want them to see the cookie policy. That is what I would want, create a page that guests could see.


You can also stick it in function template_kick_guest() in Login.template.php.


Thank you very much Sir Osis of Liver. I will look into that.


Offline Illori

  • Project Manager
  • SMF Legend
  • *
  • Posts: 52,607
you need to wrap your code in

Code: [Select]
if ($context['user']['is_guest'])
 {
   echo '
<h5>Access Denied</h5>
   We are sorry guest, it seems you dont have permission to view these downloads.';
 }

put your code after the echo '

Offline Juanchoartes

  • Semi-Newbie
  • *
  • Posts: 28
Thanks Illori. Is the following code correct? (I have tested but unfortunately it loads the login page).

Code: [Select]
<?php require("/home/.../SSI.php");

template_header(); 
if (
$context['user']['is_guest'])
 {
   echo 
   
'COOKIES';
}
template_footer(); ?>

If I login, the content (the word "COOKIES") does not appear So it works. Because the content is not displayed for non-guests.

The problem is that the guests cannot see the cookie page, they are redirected to the login page (maybe because I have disabled the option "Allow guests to browse the forum").

Also, what I am trying to do is that everyone can see the page, guests and non-guests.

Offline Illori

  • Project Manager
  • SMF Legend
  • *
  • Posts: 52,607
Code: [Select]
<?php require("/home/.../SSI.php");

template_header(); 
global 
$context;
if (
$context['user']['is_guest'])
 {
   echo 
   
'COOKIES';
}
template_footer(); ?>



try that and see if it works. I cannot test it currently. if it works for guests then it can be modified for logged in users.

Offline Juanchoartes

  • Semi-Newbie
  • *
  • Posts: 28
Thanks Illori. But does not work. It redirects the guests to the login page.

Offline Illori

  • Project Manager
  • SMF Legend
  • *
  • Posts: 52,607
try this one.

Code: [Select]
<?php require("/home/.../SSI.php");

template_header(); 
global 
$modSettings;
if (
$modSettings['allow_guestAccess']=1)
 {
   echo 
   
'COOKIES';
}
template_footer(); ?>

Offline Juanchoartes

  • Semi-Newbie
  • *
  • Posts: 28
Same result. Redirects to login page.

Offline Sir Osis of Liver

  • SMF Super Hero
  • *******
  • Posts: 10,447
  • We were all equal in the end.
Re: Private forum. How to make a page visible to all users, including guests?
« Reply #10 on: January 21, 2020, 05:26:33 PM »
If the cookie policy isn't too wordy, you can just add it to the text header in the login window -

Login.template.php

Code: [Select]

// Show the message or default message.
echo '
<p class="information centertext">
', empty($context['kick_message']) ? $txt['only_members_can_access'] : $context['kick_message'], '<br />
', $txt['login_below'], ' <a href="', $scripturl, '?action=register">', $txt['register_an_account'], '</a> ', sprintf($txt['login_with_forum'], $context['forum_name_html_safe']), '
</p>';


Login.english.php

Code: [Select]

$txt['warning'] = 'Warning!';
$txt['only_members_can_access'] = 'Only registered members are allowed to access this section.';
$txt['login_below'] = 'Please login below or';
$txt['register_an_account'] = 'register an account';
$txt['login_with_forum'] = 'with %1$s.';

“There is nothing more frightful than ignorance in action.”  Goethe

Offline Juanchoartes

  • Semi-Newbie
  • *
  • Posts: 28
Re: Private forum. How to make a page visible to all users, including guests?
« Reply #11 on: January 21, 2020, 05:30:23 PM »
That would be an option, but the cookie policy text is really long. Thanks anyway.

Offline Sir Osis of Liver

  • SMF Super Hero
  • *******
  • Posts: 10,447
  • We were all equal in the end.
Re: Private forum. How to make a page visible to all users, including guests?
« Reply #12 on: January 21, 2020, 05:57:27 PM »
Do you want to display the login window on same page as cookie policy?
“There is nothing more frightful than ignorance in action.”  Goethe

Offline Juanchoartes

  • Semi-Newbie
  • *
  • Posts: 28
Re: Private forum. How to make a page visible to all users, including guests?
« Reply #13 on: January 21, 2020, 06:07:55 PM »
Do you want to display the login window on same page as cookie policy?


No, I want to display a link to the Cookie policy in the same page as login page. Under the login box.

Offline Sir Osis of Liver

  • SMF Super Hero
  • *******
  • Posts: 10,447
  • We were all equal in the end.
Re: Private forum. How to make a page visible to all users, including guests?
« Reply #14 on: January 21, 2020, 06:57:36 PM »
Interestingly (or not), anything you put under require("YOUR_PATH_TO_SSI.php"); loads guest login, including wiki examples for SSI, if guest browsing is disabled.  Only works if guests can browse forum.
“There is nothing more frightful than ignorance in action.”  Goethe

Offline Illori

  • Project Manager
  • SMF Legend
  • *
  • Posts: 52,607
Re: Private forum. How to make a page visible to all users, including guests?
« Reply #15 on: January 21, 2020, 07:25:11 PM »
the code i posted above worked for me in the forum with guests disabled. i did not test it directly with SSI though but it should work the same way.

Offline Sir Osis of Liver

  • SMF Super Hero
  • *******
  • Posts: 10,447
  • We were all equal in the end.
Re: Private forum. How to make a page visible to all users, including guests?
« Reply #16 on: January 22, 2020, 12:17:18 AM »
The SSI call seems to be the problem, it can't get anywhere but guest login regardless of what else is in the file.  Am linking directly to test file, maybe it doesn't work that way,
“There is nothing more frightful than ignorance in action.”  Goethe

Offline Juanchoartes

  • Semi-Newbie
  • *
  • Posts: 28
Re: Private forum. How to make a page visible to all users, including guests?
« Reply #17 on: January 22, 2020, 07:56:14 AM »
the code i posted above worked for me in the forum with guests disabled. i did not test it directly with SSI though but it should work the same way.

The SSI call seems to be the problem, it can't get anywhere but guest login regardless of what else is in the file.  Am linking directly to test file, maybe it doesn't work that way,

Thank you both for your answers.

I can't make it work using SSI.php...  Because it always takes me to the login page. :-\

The only option I see is to make a php file that shows the Cookie policy text but without the appearance or design of the forum, which is not what I want because it is very rare to show a blank page with the Cookie policy text without de theme layout and design.

Offline Sir Osis of Liver

  • SMF Super Hero
  • *******
  • Posts: 10,447
  • We were all equal in the end.
Re: Private forum. How to make a page visible to all users, including guests?
« Reply #18 on: January 22, 2020, 10:57:08 AM »
There are a couple of other options.  You can use a popup window to display the cookie policy over the login page, just have to match background, or you can add the cookie policy to Login.template.php so it's displayed on login page, just a matter of formatting it so it looks ok. 

You may also be able create a clickable or hoverable dropdown -

https://www.w3schools.com/howto/howto_js_dropdown.asp
https://www.w3schools.com/howto/howto_css_dropdown.asp
« Last Edit: January 22, 2020, 11:38:51 AM by Sir Osis of Liver »
“There is nothing more frightful than ignorance in action.”  Goethe

Offline Juanchoartes

  • Semi-Newbie
  • *
  • Posts: 28
Re: Private forum. How to make a page visible to all users, including guests?
« Reply #19 on: January 22, 2020, 12:13:33 PM »
Thank you Sir Osis of Liver. I will look into the popup window option. It is not what I wanted but maybe I could get something decent.

I discard the dropdown option because it is a very long text and it would not look good. Thanks anyway for the option.

Offline Sir Osis of Liver

  • SMF Super Hero
  • *******
  • Posts: 10,447
  • We were all equal in the end.
Re: Private forum. How to make a page visible to all users, including guests?
« Reply #20 on: January 23, 2020, 04:31:13 PM »
After dicking around with this for a (too long) while, here's something that works.  Basically involves creating a new action to display cookie policy.  Must be an easier way to do it, but I can't find it.  Here goes:

- Add new action to actions array and allow action to guests if guest browsing is disabled:

index.php

Code: [Select]

// If guest access is off, a guest can only do one of the very few following actions.
elseif (empty($modSettings['allow_guestAccess']) && $user_info['is_guest'] && (!isset($_REQUEST['action']) || !in_array($_REQUEST['action'], array('coppa', 'login', 'login2', 'register', 'register2', 'reminder', 'activate', 'help', 'smstats', 'mailq', 'verificationcode', 'openidreturn', 'cookies'))))



'collapse' => array('BoardIndex.php', 'CollapseCategory'),
'cookies' => array('Cookies.php', 'Cookies'),
'coppa' => array('Register.php', 'CoppaForm'),



- Add button to main menu in buttons array:

Subs.php

Code: [Select]

// Cookie Policy
'cookies' => array(
'title' => 'Cookie Policy',
'href' => $scripturl . '?action=cookies',
'show' => true,
'icon' => '',
),



- Create new source file:

Cookies.php

Code: [Select]

<?php

if (!defined('SMF'))
die('Hacking attempt...');

function 
Cookies()
{
// Load Cookies template
loadtemplate('Cookies');
}
?>




- Create new template file (using aggreement.txt as example):

Cookies.template.php

Code: [Select]

<?php

function template_main()
{
echo 
'

<div class="cat_bar">
<h3 class="catbg centertext">Cookie Policy</h3>
</div>
<div style="padding: 25px 50px; color: blue;">

You agree, through your use of this forum, that you will not post any material which is false, defamatory, inaccurate, abusive, vulgar, hateful, harassing, obscene, profane, sexually oriented, threatening, invasive of a person\'s privacy, adult material, or otherwise in violation of any International or United States Federal law. You also agree not to post any copyrighted material unless you own the copyright or you have written consent from the owner of the copyrighted material. Spam, flooding, advertisements, chain letters, pyramid schemes, and solicitations are also forbidden on this forum.
<br /><br />
Note that it is impossible for the staff or the owners of this forum to confirm the validity of posts. Please remember that we do not actively monitor the posted messages, and as such, are not responsible for the content contained within. We do not warrant the accuracy, completeness, or usefulness of any information presented. The posted messages express the views of the author, and not necessarily the views of this forum, its staff, its subsidiaries, or this forum\'s owner. Anyone who feels that a posted message is objectionable is encouraged to notify an administrator or moderator of this forum immediately. The staff and the owner of this forum reserve the right to remove objectionable content, within a reasonable time frame, if they determine that removal is necessary. This is a manual process, however, please realize that they may not be able to remove or edit particular messages immediately. This policy applies to member profile information as well.
<br /><br />
You remain solely responsible for the content of your posted messages. Furthermore, you agree to indemnify and hold harmless the owners of this forum, any related websites to this forum, its staff, and its subsidiaries. The owners of this forum also reserve the right to reveal your identity (or any other related information collected on this service) in the event of a formal complaint or legal action arising from any situation caused by your use of this forum.
<br /><br />
You have the ability, as you register, to choose your username. We advise that you keep the name appropriate. With this user account you are about to register, you agree to never give your password out to another person except an administrator, for your protection and for validity reasons. You also agree to NEVER use another person\'s account for any reason.  We also HIGHLY recommend you use a complex and unique password for your account, to prevent account theft.
<br /><br />
After you register and login to this forum, you will be able to fill out a detailed profile. It is your responsibility to present clean and accurate information. Any information the forum owner or staff determines to be inaccurate or vulgar in nature will be removed, with or without prior notice. Appropriate sanctions may be applicable.
<br /><br />
Please note that with each post, your IP address is recorded, in the event that you need to be banned from this forum or your ISP contacted. This will only happen in the event of a major violation of this agreement.
<br /><br />
Also note that the software places a cookie, a text file containing bits of information (such as your username and password), in your browser\'s cache. This is ONLY used to keep you logged in/out. The software does not collect or send any other form of information to your computer.
</div>'
;
}

?>




Quite the hack to do something so simple. :P
“There is nothing more frightful than ignorance in action.”  Goethe

Offline m4z

  • 98.8% chimp
  • Localizer
  • Sophist Member
  • *
  • Posts: 1,183
  • /mɛs/
Re: Private forum. How to make a page visible to all users, including guests?
« Reply #21 on: January 23, 2020, 05:52:27 PM »
Actually, this should also work:
Code: [Select]
<?php
        $ssi_guest_access 
true;
        require_once(
'SSI.php');
        
$context['page_title_html_safe'] = 'your title';

        
template_header();

        if (
$context['user']['is_guest'])
        {
                echo  
'your text';
        }
        
template_footer();
?>

"Faith is what you have in things that don't exist."
--Homer Simpson

<werbung>Meine Freundin hat ihr erstes Buch veröffentlicht!</werbung>

Offline Sir Osis of Liver

  • SMF Super Hero
  • *******
  • Posts: 10,447
  • We were all equal in the end.
Re: Private forum. How to make a page visible to all users, including guests?
« Reply #22 on: January 24, 2020, 12:25:25 PM »
Yes, it does work.   For reasons unknown, template_footer() is messed up, copyright is missing and there's a blank area below that shoudn't be there, but it gets around the guest access problem.  Will play with it tonight.
“There is nothing more frightful than ignorance in action.”  Goethe

Offline Juanchoartes

  • Semi-Newbie
  • *
  • Posts: 28
Re: Private forum. How to make a page visible to all users, including guests?
« Reply #23 on: January 24, 2020, 12:27:59 PM »
Well... Solved!! Thank you very much all of you for your help.

Actually, this should also work:
Code: [Select]
<?php
        $ssi_guest_access 
true;
        require_once(
'SSI.php');
        
$context['page_title_html_safe'] = 'your title';

        
template_header();

        if (
$context['user']['is_guest'])
        {
                echo  
'your text';
        }
        
template_footer();
?>


This code works perfect. Thank you very much m4z. I deleted this part:
Code: [Select]
" if ($context['user']['is_guest'])" because I wanted the cookie file to be accessible also by registered users.

Many thanks also to you, Sir Osis of Liver, because your code has been very useful to me to create the text code of the cookie file, the appearance, etc. and something else that I have to do in the forum. Thank you.

So thank you very much to both of you for your time and help.

Cheers!!  ;)


Offline Juanchoartes

  • Semi-Newbie
  • *
  • Posts: 28
Re: Private forum. How to make a page visible to all users, including guests?
« Reply #24 on: January 24, 2020, 12:35:03 PM »
Yes, it does work.   For reasons unknown, template_footer() is messed up, copyright is missing and there's a blank area below that shoudn't be there, but it gets around the guest access problem.  Will play with it tonight.

It also happens to me. The following copyright lines of SMF and Tinyportal have disappeared, but otherwise everything works fine:

SMF 2.0.17 | SMF © 2017, SIMPLE MACHINES
TINYPORTAL 1.6.4 © 2005-2019 | TERMS AND POLICIES