News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

Private forum. How to make a page visible to all users, including guests?

Started by Juanchoartes, January 20, 2020, 12:34:20 PM

Previous topic - Next topic

Sir Osis of Liver

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



// 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



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




- Create new source file:

Cookies.php



<?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



<?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
Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

m4z

Actually, this should also work:

<?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

Es gibt hier im Forum ein deutsches Support-Board!

Sir Osis of Liver

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.
Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

Juanchoartes

Well... Solved!! Thank you very much all of you for your help.

Quote from: m4z on January 23, 2020, 05:52:27 PM
Actually, this should also work:

<?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: " 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!!  ;)


Juanchoartes

Quote from: Sir Osis of Liver 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.

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

Advertisement: