Login  |  Register
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome, Guest. Please login or register.
Did you miss your activation email?

May 29, 2020, 04:50:56 PM

Login with username, password and session length
Members
Stats
  • Total Posts: 190011
  • Total Topics: 20832
  • Online Today: 288
  • Online Ever: 917
  • (January 21, 2020, 09:02:26 AM)
Users Online
Users: 0
Guests: 93
Total: 93

Author Topic: Anyway to password protect articles?  (Read 12921 times)

0 Members and 1 Guest are viewing this topic.

dry3210

  • Guest
Anyway to password protect articles?
« on: December 17, 2007, 09:22:19 PM »
Anyway to password protect articles?

Offline IchBin™

  • Developer
  • *
  • Posts: 16228
    • My Website
Re: Anyway to password protect articles?
« Reply #1 on: December 17, 2007, 09:25:19 PM »
You could add your own custom PHP code to articles. If you google search it I bet you can find something.

lebisol

  • Guest
Re: Anyway to password protect articles?
« Reply #2 on: December 18, 2007, 10:27:36 AM »
Consider htaccess
http://www.htmlgoodies.com/tutorials/getting_started/article.php/3479531
or as Ich said enter a small php code (you would have convert all articles to php) to check "if user member group =x Then echo ....article ...Else "sorry"

Offline TimUSA

  • Full Member
  • ***
  • Posts: 211
Re: Anyway to password protect articles?
« Reply #3 on: December 18, 2007, 11:49:31 AM »
why not restrict it to a member group?

lebisol

  • Guest
Re: Anyway to password protect articles?
« Reply #4 on: December 18, 2007, 12:42:58 PM »
unlike forum baords articles are public...ACls only apply to edit/add/submit no 'view'.
I think he is looking for just a password protection to articles for guests and memebers...suppose the author will say more...
All the best!

Offline TimUSA

  • Full Member
  • ***
  • Posts: 211
Re: Anyway to password protect articles?
« Reply #5 on: December 18, 2007, 12:56:12 PM »
true, what i was suggesting is something like:
Code: [Select]
global $user_info;

if (count(array_intersect(array(1,9,10,11,12,13), $user_info['groups'])))
{
echo '***Your HTML here***';
}

This will show your article only to the selected member groups. So instead of a password, you would change their member group.
« Last Edit: December 18, 2007, 01:00:01 PM by TimUSA »

dry3210

  • Guest
Re: Anyway to password protect articles?
« Reply #6 on: January 05, 2008, 06:49:06 PM »
true, what i was suggesting is something like:
Code: [Select]
global $user_info;

if (count(array_intersect(array(1,9,10,11,12,13), $user_info['groups'])))
{
echo '***Your HTML here***';
}

This will show your article only to the selected member groups. So instead of a password, you would change their member group.

That should work then! 

Yeah basically I wanted it so some articles are viewable by all..and others are restricted some how membergroup or password

evilicy

  • Guest
Re: Anyway to password protect articles?
« Reply #7 on: January 17, 2008, 06:46:54 PM »
I know this was already resolved but wanted to share this code anyways and figure might as well post it here since it is related.

Remember the old Javascript "the gate keeper"? that pw protected pages I used to get a kick out of it. Well here it is again with the same fun novelty but in php for php articles.

DEMO
Password is: password

Code: [Select]
// Define your password

$password = "password";



if ($_POST['txtPassword'] != $password) {

echo '<img src="http://darkvoid.org/images/keeper.gif">

<form name="form" method="post" action="'; $_SERVER['PHP_SELF']; echo '">

<p><label for="txtpassword">Password:</label>

    <br /><input type="password" title="Enter your password" name="txtPassword" /></p>

<p><input type="submit" name="Submit" value="Enter Password" /></p>

</form>';

}

else {

echo "<p>This is the protected page. Your private content goes here.</p>";

}

PS

I didn't write the original gate keeper script or the php code provided. I simply googled the code and added the novelty of the Gate keeper to it :P
« Last Edit: January 17, 2008, 06:49:44 PM by evilicy »

Innocenzia

  • Guest
Re: Anyway to password protect articles?
« Reply #8 on: January 20, 2008, 12:33:54 PM »
Is there a way to make the information in an article viewable only for nonmembers, let say i want it to say: "please join.  blaha, blaha.." then i wouldn't want the members to see it, in stead i want the members to see: "Hi Member. blaha, blaha.." so the same article, but different text for members and nonmembers?

Offline IchBin™

  • Developer
  • *
  • Posts: 16228
    • My Website
Re: Anyway to password protect articles?
« Reply #9 on: January 20, 2008, 12:36:26 PM »
Code: [Select]
if ($context['user']['is_guest'])
    echo 'The code here for a guest that you want';

if ($context['user']['is_logged'])
    echo 'The code here for logged in users';