boardom Forum Index boardom
b2 message board
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

[Request] People Who Are Not Logged In See Nothing
Goto page 1, 2  Next
 
Post new topic   Reply to topic    boardom Forum Index -> Hacks
View previous topic :: View next topic  
Author Message
MiniSizeIt



Joined: 02 Nov 2002
Posts: 70

PostPosted: Tue Nov 05, 2002 4:52 am    Post subject: [Request] People Who Are Not Logged In See Nothing Reply with quote

Hello.

I use my weblog as a journal with my g/f, and we are the only two registered people and I have disabled new member registration. I would like a little something to redirect guests to say this weblog is private, please login. This is exactly what I need to have b2 the perfect script for me. Any help or workarounds would be greatly appreciated!

Thanks in advance.
Back to top
View user's profile Send private message
MiniSizeIt



Joined: 02 Nov 2002
Posts: 70

PostPosted: Tue Nov 05, 2002 5:22 am    Post subject: Reply with quote

I have been forced to shut down my b2 because people snooping the site and viewing entries that are private. I'll open it up once I get a workaround or when private entries is included in b2. If that's not soon, I might have to find a totally new service, so please help if you can
Back to top
View user's profile Send private message
jasonvelocity



Joined: 10 Feb 2002
Posts: 11
Location: colorado springs - co

PostPosted: Wed Nov 06, 2002 10:19 pm    Post subject: Reply with quote

I know you might have found a solution that might work using that .htaccess trick, but you might want to look at this as well

http://tidakada.com/board/viewtopic.php?t=1476
_________________
[img]jasonvelocity.com[/img]
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
michel v
Site Admin


Joined: 25 Jan 2002
Posts: 799
Location: Corsica

PostPosted: Thu Nov 07, 2002 3:08 am    Post subject: Reply with quote

Actually, it so happens that you can protect entries in b2 0.6.1, with this new feature: filter functions!

--
Short intro on filters (I mean to post that as its own thread sometime):

Basically, you can set functions to be run over some template tags before they're displayed, for example like this:
[php:1:b8bb6f2968]<?php
/* this will capitalise all the text displayed by the_content() */
add_filter('the_content', 'strtoupper');
?>[/php:1:b8bb6f2968]
Currently the functions you can use in filters must allow only one argument: a string. They must also return a string.

So what you can do is something like this in your template (after you included blog.header.php):
[php:1:b8bb6f2968]<?php

function b2_private_entry($string) {
$password = 'jesusatemyballs';
if (stristr($string, '<private />')) {
if (trim($_POST['b2_password']) != $password) {
$form = 'This is a private entry.<br />To view private entries on this website, please enter the password in the field below:<br /><form method="POST"><input type="password" name="b2_password" /><input type="submit" value="OK" /></form>';
return $form;
}
}
return preg_replace('#\<private \/\>#is', '', $string);
}

add_filter('the_content', 'b2_private_entry');

?>[/php:1:b8bb6f2968]
Then you'll only need to add the tag <private /> in an entry to make it private, and your visitor would have to enter the password in the form to see your private entries.
You can improve the password handling if you want, add a cookie for it to avoid the visitor to have to enter the password each time.
Note that this doesn't protect the_title() (make a similar filter for it), and the RSS files. For the RSS files you should edit them and add a similar filter (though without the form since aggregators couldn't do anything with it) that would just return 'this is a private entry'.

I hope this helps. I haven't tested it, but it should work. Smile


Update: I have tested it, in a modified manner (it would hide any entry's content that has 'CSS' in it) here: http://tidakada.com/indexjesus.php - password is 'jesusatemyballs' (without the quotes).
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger
MiniSizeIt



Joined: 02 Nov 2002
Posts: 70

PostPosted: Thu Nov 07, 2002 6:25 am    Post subject: Reply with quote

Thanks jason, I already saw that post and since we have numerous categories that need to be private, I'm not sure how easy that'd work out.

michel v, thanks for the great post. I've very new to PHP and don't really understand ways to further the coding you posted. However password protection for posts is a great feature. But I'm still looking for a way to password protect all posts by a certain user or to be able to choose who can view my posts. An option in each Member's Control Panel such as a friends list would be awesome. People I include in my list would have the ability to view my list while all others don't even see them. Plus you could have another option only members could see it, and not guests. And a feature to set it totally public.

Thanks! I appreciate you looking into it for me Razz
Back to top
View user's profile Send private message
michel v
Site Admin


Joined: 25 Jan 2002
Posts: 799
Location: Corsica

PostPosted: Thu Nov 07, 2002 3:02 pm    Post subject: Reply with quote

MiniSizeIt wrote:
But I'm still looking for a way to password protect all posts by a certain user or to be able to choose who can view my posts. An option in each Member's Control Panel such as a friends list would be awesome. People I include in my list would have the ability to view my list while all others don't even see them. Plus you could have another option only members could see it, and not guests. And a feature to set it totally public.

Errr, I may introduce that kind of feature in 1.0 but... from what you're describing you should just use LiveJournal!

Then again, if someone wants to further the above code, it should be pretty easy to make it password-protect each posts by author X.
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger
MiniSizeIt



Joined: 02 Nov 2002
Posts: 70

PostPosted: Thu Nov 07, 2002 9:45 pm    Post subject: Reply with quote

Yeah I looked into LiveJournal and it's not nearly as cool and as fun to play with compared to b2 Very Happy

I just wish I knew PHP well enough to edit and create new features. I'll try to learn PHP and MySQL in the coming months, and maybe even contribute by making hacks and such. But for now I'm just relying on new features in newer versions or hacks created by users.

If anyone can help me out, I'd love it.

Thanks!
Back to top
View user's profile Send private message
Reese



Joined: 07 Sep 2002
Posts: 60

PostPosted: Thu Feb 20, 2003 8:25 pm    Post subject: Reply with quote

Edit: I got it working, thanks to a lovely person.

However, I'm still curious to figure out how I could add in that cookie feature.


Last edited by Reese on Wed Feb 26, 2003 7:41 am; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website AIM Address
k9underdog



Joined: 25 Feb 2003
Posts: 1

PostPosted: Tue Feb 25, 2003 11:50 pm    Post subject: Reply with quote

Well... I've came with a much more simpller sollution.

First step: open your b2config.php file and just set
Code:
$users_can_register = 0;


Second step: edit blog.header.php and on line 2 add:
Code:
if(!isset($_COOKIE['cafeloguser']) || $_COOKIE['cafeloguser'] == '') {
    Header('Location: b2login.php');
}


Since this file is included in every file... it will check if you are logged in, and if you're not, it'll take you to the login page.

You can try mine @ http://www.badmodafocas.com/blog/ although I don't think you'll be able to see anything.

If there are any flaws or any way around this let me know. I just did this, so it's still in "testing" phase.

PS: I also needed it to serve the same purpose =P Good luck with your relationship
Back to top
View user's profile Send private message
Reese



Joined: 07 Sep 2002
Posts: 60

PostPosted: Wed Feb 26, 2003 12:45 am    Post subject: Reply with quote

That would be a good solution for MiniSizeIt...still waiting to figure out where I went wrong, though.
Back to top
View user's profile Send private message Visit poster's website AIM Address
nelg



Joined: 06 Mar 2003
Posts: 1

PostPosted: Thu Mar 06, 2003 9:18 am    Post subject: Thinking of building this functionality Reply with quote

Yeah, it would be really good if users could login and have a list of friends, or friends email addresses, that are allowed to view the blog (and it would automatically authenticate them when they create and account, and cookie it so they don't have to login all the time)

I am thinking of building this, if I can't find a solution for it, as I have private stuff on my blog as well, am thinking a checkbox, or group of users, that I can configure on a post by post basis would be good, as I do have some public posts, and some private.

Comments, and if anyone else is building this, I am happy to give them a hand rather than do it all myself, as I will have to get familular with B2 code.

Cheers
Glen
Back to top
View user's profile Send private message
livediary



Joined: 12 Jan 2003
Posts: 15
Location: Austin, TX

PostPosted: Sun Mar 16, 2003 8:51 pm    Post subject: cookie feature fixed? Reply with quote

So has anyone tried out the cookie feature that michel v mentioned---so that users wouldn't have to enter the password in the form every time?
_________________
www.live-diary.com
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger
Cyberian75



Joined: 26 Sep 2002
Posts: 1019
Location: Oregon

PostPosted: Mon Mar 17, 2003 4:33 am    Post subject: Re: cookie feature fixed? Reply with quote

livediary wrote:
So has anyone tried out the cookie feature that michel v mentioned---so that users wouldn't have to enter the password in the form every time?



Refer to http://www.php.net/manual/en/function.setcookie.php for setcookie function.
_________________
Michael P.
Back to top
View user's profile Send private message Visit poster's website AIM Address
livediary



Joined: 12 Jan 2003
Posts: 15
Location: Austin, TX

PostPosted: Mon Mar 17, 2003 4:37 am    Post subject: Reply with quote

Thanks, I'll have to check that out. Very Happy
_________________
www.live-diary.com
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger
Gadget Girl



Joined: 25 Jan 2002
Posts: 305
Location: Virginia

PostPosted: Tue Apr 08, 2003 1:41 pm    Post subject: .RSS and title Reply with quote

Thank you Michel for the modification for the entry, now, how do I and where do I place what for the .RSS and the title?

Thanks,

Sara
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    boardom Forum Index -> Hacks All times are GMT + 1 Hour
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB 2 © 2001, 2002 phpBB Group