How to protect pages of a website with Phorum (Easy way)
Posted by tonimad
How to protect pages of a website with Phorum (Easy way) August 13, 2008 09:14PM |
Registered: 16 years ago Posts: 4 |
Hello,
I'm installing Phorum on my server.
In my website, I have some pages that I want to protect, using the system of users Phorum's.
For example:
My website is located at the root of my server. Phorum is located in the subfolder called "Forum".
Ok. One person creates a user account's on the forum. So, the user have a username and password.
Perfect. Now, I have a page on my website (root server) that I want to protect. This page is only visible to users of the forum.
How can I protect this page?.
This is my idea:
- User "A" is not registered in the forum. The protected page displays a message like "To see this page, please, create a user account or login.".
- User "B" is registered in the forum. The user can view the contents of this page.
# Question:
- On page I want to protect, what code should I include to protect it?.
Please, I need some code like:
- If user is user Phorum, then shows content. If user is not user Phorum shows warning message.
Waiting your responses, thank you very much.
Toni .-
Edited 3 time(s). Last edit at 08/13/2008 09:16PM by tonimad.
I'm installing Phorum on my server.
In my website, I have some pages that I want to protect, using the system of users Phorum's.
For example:
My website is located at the root of my server. Phorum is located in the subfolder called "Forum".
Ok. One person creates a user account's on the forum. So, the user have a username and password.
Perfect. Now, I have a page on my website (root server) that I want to protect. This page is only visible to users of the forum.
How can I protect this page?.
This is my idea:
- User "A" is not registered in the forum. The protected page displays a message like "To see this page, please, create a user account or login.".
- User "B" is registered in the forum. The user can view the contents of this page.
# Question:
- On page I want to protect, what code should I include to protect it?.
Please, I need some code like:
- If user is user Phorum, then shows content. If user is not user Phorum shows warning message.
Waiting your responses, thank you very much.
Toni .-
Edited 3 time(s). Last edit at 08/13/2008 09:16PM by tonimad.
August 14, 2008 02:31AM |
Admin Registered: 20 years ago Posts: 8,532 |
You are looking for the quick authentication script.
See this thread.
Using that script, you can check outside Phorum if a user is logged in.
Remember to update the include() line that includes the include/db/config.php. It must load the Phorum database config.php file.
After including the quick authentication script in a PHP page, you can use code like this:
Maurice Makaay
Phorum Development Team
my blog
linkedin profile
secret sauce
See this thread.
Using that script, you can check outside Phorum if a user is logged in.
Remember to update the include() line that includes the include/db/config.php. It must load the Phorum database config.php file.
After including the quick authentication script in a PHP page, you can use code like this:
Language: PHP<?php if (!empty($GLOBALS[';USER';])) { ?> ... your protected page code ... ... goes here ... <?php } else { ?> ... your "register now" page ... ... goes here ... <?php } ?>
Maurice Makaay
Phorum Development Team



Re: How to protect pages of a website with Phorum (Easy way) August 14, 2008 04:31AM |
Registered: 16 years ago Posts: 4 |
August 14, 2008 07:30AM |
Admin Registered: 20 years ago Posts: 8,532 |
The most straight forward way is to use the RSS feature of Phorum for that. There are scripts (both in PHP and pure javascript) that can take an RSS feed and show the last items in a list. I am not using such script myself, but I know that others did.
Maurice Makaay
Phorum Development Team
my blog
linkedin profile
secret sauce
Maurice Makaay
Phorum Development Team



Re: How to protect pages of a website with Phorum (Easy way) August 14, 2008 08:00AM |
Registered: 16 years ago Posts: 4 |
Perfect.
And the last thing :)
I want to put the user options and anonymous user in the top of my php pages (outside folder "phorum"). Searching in header.tpl, I have this code:
------------------------------------------------------
{! Code for logged in users }
{IF LOGGEDIN}
{LANG->Welcome}, <b>{USER->username}</b> <br><br>
</td></tr><tr><td align="right">
<img src="../fx/iconomyprofile.png"> <a href="{URL->REGISTERPROFILE}">{LANG->MyProfile}</a>
{IF ENABLE_PM}
<img src="../fx/pm.png"> <a href="{URL->PM}">
{IF USER->new_private_messages}
<strong>{LANG->NewPrivateMessages}</strong>
{ELSE}
{LANG->PrivateMessages}
{/IF}
</a> <img src="../fx/exit.png"> <a href="{URL->LOGINOUT}">{LANG->LogOut}</a></td></tr></table>
{/IF}
{! Code for anonymous users }
{ELSE}
<img src="../fx/iconologin.png"> <a href="login.php">Login</a> | <img src="../fx/iconoregister.png"> <a href="register.php">Register</a></td></tr><tr><td align="right"><br><font color=#B8B8B8><b>Wellcome to my forum</font></td></tr></table>
{/IF}
-----------------------------------------------------
How to put this code in a php page without "tags" of tpl sources?
Ever, ever, ever.. thank you!
Toni .-
Edited 1 time(s). Last edit at 08/14/2008 08:03AM by tonimad.
And the last thing :)
I want to put the user options and anonymous user in the top of my php pages (outside folder "phorum"). Searching in header.tpl, I have this code:
------------------------------------------------------
{! Code for logged in users }
{IF LOGGEDIN}
{LANG->Welcome}, <b>{USER->username}</b> <br><br>
</td></tr><tr><td align="right">
<img src="../fx/iconomyprofile.png"> <a href="{URL->REGISTERPROFILE}">{LANG->MyProfile}</a>
{IF ENABLE_PM}
<img src="../fx/pm.png"> <a href="{URL->PM}">
{IF USER->new_private_messages}
<strong>{LANG->NewPrivateMessages}</strong>
{ELSE}
{LANG->PrivateMessages}
{/IF}
</a> <img src="../fx/exit.png"> <a href="{URL->LOGINOUT}">{LANG->LogOut}</a></td></tr></table>
{/IF}
{! Code for anonymous users }
{ELSE}
<img src="../fx/iconologin.png"> <a href="login.php">Login</a> | <img src="../fx/iconoregister.png"> <a href="register.php">Register</a></td></tr><tr><td align="right"><br><font color=#B8B8B8><b>Wellcome to my forum</font></td></tr></table>
{/IF}
-----------------------------------------------------
How to put this code in a php page without "tags" of tpl sources?
Ever, ever, ever.. thank you!
Toni .-
Edited 1 time(s). Last edit at 08/14/2008 08:03AM by tonimad.
August 14, 2008 08:17AM |
Admin Registered: 20 years ago Posts: 8,532 |
With the quick authentication script, your user's data is in $USER.
The template code will need to be translated to pure PHP code, using the data from $USER;
Some translations within this environment (untested, printing URLs is chopped up a bit to prevent BBcode form turning the URLs into clickable links):
When using all this, maybe the different solution angle from this thread is an easier approach to tackle your needs?
Maurice Makaay
Phorum Development Team
my blog
linkedin profile
secret sauce
The template code will need to be translated to pure PHP code, using the data from $USER;
Some translations within this environment (untested, printing URLs is chopped up a bit to prevent BBcode form turning the URLs into clickable links):
{IF LOGGEDIN} .... {/IF} if (!empty($USER)) { .... } ---------------------- {USER->username} print htmlspecialchars($USER['username']); ---------------------- {URL->REGISTERPROFILE} if (empty($USER)) { print "http" . "://www.yoursite.com/yourphorumdir/register.php"; } else { print "http" . "://www.yoursite.com/yourphorumdir/control.php"; } ---------------------- {URL->LOGINOUT} if (empty($USER)) { print "http" . "://www.yoursite.com/yourphorumdir/login.php"; } else { print "http" . "://www.yoursite.com/yourphorumdir/login.php?0,logout=1"; } ---------------------- {IF USER->new_private_messages} .... {ELSE} .... {/IF} $has_new_pm = phorum_db_pm_checknew($USER['user_id']); if ($has_new_pm) { .... } else { .... }
When using all this, maybe the different solution angle from this thread is an easier approach to tackle your needs?
Maurice Makaay
Phorum Development Team



Re: How to protect pages of a website with Phorum (Easy way) August 15, 2008 07:05PM |
Registered: 16 years ago Posts: 4 |
Hello Maurice!,
Following your advice, I have designed all the forum and all website with this method. All pages on my website have been converted to files .tpl
Now I use any function of Phorum (identification, registration, user names) and much more on my website. Is fantastic!
After evaluating many systems forums, I find that Phorum is the perfect solution for any website. And a perfect support!
Congratulations. I am recommending Phorum to all my friends and websites of Spain.
Again... ever, ever, thank you very much!
Regards,
Toni .-
Edited 2 time(s). Last edit at 08/15/2008 07:06PM by tonimad.
Following your advice, I have designed all the forum and all website with this method. All pages on my website have been converted to files .tpl
Now I use any function of Phorum (identification, registration, user names) and much more on my website. Is fantastic!
After evaluating many systems forums, I find that Phorum is the perfect solution for any website. And a perfect support!
Congratulations. I am recommending Phorum to all my friends and websites of Spain.
Again... ever, ever, thank you very much!
Regards,
Toni .-
Edited 2 time(s). Last edit at 08/15/2008 07:06PM by tonimad.
August 18, 2008 12:30PM |
Admin Registered: 20 years ago Posts: 8,532 |
Great! Enjoy the software, both you and your friends!
Maurice Makaay
Phorum Development Team
my blog
linkedin profile
secret sauce
Maurice Makaay
Phorum Development Team



Anonymous User
Re: How to protect pages of a website with Phorum (Easy way) July 22, 2009 08:05AM |
Quote
Maurice Makaay
There are scripts (both in PHP and pure javascript) that can take an RSS feed and show the last items in a list.
Is this possible to have more information on this ?
I'm looking for a way to use a XML file of the RSS feed into a third application, but how to obtain the XML file available into a specific folder ?
Re: How to protect pages of a website with Phorum (Easy way) July 22, 2009 08:11AM |
Admin Registered: 22 years ago Posts: 9,240 |
Quote
Is this possible to have more information on this ?
Use google to find the scripts you want ;-).
Quote
I'm looking for a way to use a XML file of the RSS feed into a third application, but how to obtain the XML file available into a specific folder ?
I'm not sure what you are asking for. Every recent Phorum has RSS-URLs to get the RSS-feed, you see them in the header and on index.
Thomas Seifert
Sorry, only registered users may post in this forum.