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 

filter functions help

 
Post new topic   Reply to topic    boardom Forum Index -> How to ?
View previous topic :: View next topic  
Author Message
yuch



Joined: 27 Feb 2003
Posts: 13
Location: Singapore

PostPosted: Thu Mar 20, 2003 9:18 am    Post subject: filter functions help Reply with quote

I am currently trying to make some of my posts private. I read the thread on filter functions here.

http://tidakada.com/board/viewtopic.php?t=1560&highlight=level+0+cannot+view

And I implemented the exact same code below. I put this code in my index.php, on line 2, before the "include ("blog.header.php");" line.

Code:

<?php /* Don't remove this line, it calls the b2 function files ! */ $blog=1; include ("blog.header.php"); ?>
<?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');

?>


When I make private posts, I do this from my b2edit.
Quote:
<private />TESTING. Private post.</private>


However, when I enter the password on my site, it does not display the private post. It simply refreshes and gives me the same page with the password form dialogue again.

I am using the "proper page refresh for MSIE" hack (the one michel posted on the main cafelog page...could this be the problem?), and b2 version 0.6.1. What exactly does preg_replace do? The </private> tag was automatically added in for me, I didn't type it in my post.

Can someone tell me what is wrong?? Sorry, but I am absolutely clueless abt PHP...
If it helps, my site is at [url]yuch.ionichost.com[/url]
_________________
yuch ^^
Back to top
View user's profile Send private message Send e-mail
GamerZ



Joined: 15 May 2002
Posts: 537
Location: Singapore

PostPosted: Thu Mar 20, 2003 1:19 pm    Post subject: Reply with quote

hmm maybe you can try $HTTP_POST_VARS['b2_password'] instead of $_POST['b2_password']
_________________

++ GamerZ.Per.Sg - Complex Simplicity
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger
yuch



Joined: 27 Feb 2003
Posts: 13
Location: Singapore

PostPosted: Thu Mar 20, 2003 8:17 pm    Post subject: Reply with quote

nope...still doesn't work...
_________________
yuch ^^
Back to top
View user's profile Send private message Send e-mail
yuch



Joined: 27 Feb 2003
Posts: 13
Location: Singapore

PostPosted: Thu Mar 20, 2003 9:25 pm    Post subject: Reply with quote

i think there's something wrong with the form input...
but still can't get it to work... ...frustrating...
_________________
yuch ^^
Back to top
View user's profile Send private message Send e-mail
Gadget Girl



Joined: 25 Jan 2002
Posts: 305
Location: Virginia

PostPosted: Tue Apr 08, 2003 12:44 pm    Post subject: Reply with quote

Hi,

I just tested this and only put <private /> once in the entry. Worked for me.

Smile Sara
Back to top
View user's profile Send private message
yuch



Joined: 27 Feb 2003
Posts: 13
Location: Singapore

PostPosted: Tue Apr 08, 2003 1:09 pm    Post subject: Reply with quote

oh, i solved it finally...i put the HTTP_POST thing as a global variable (i guess that's bad coding but if it works, it works Razz) and it worked...
_________________
yuch ^^
Back to top
View user's profile Send private message Send e-mail
Gadget Girl



Joined: 25 Jan 2002
Posts: 305
Location: Virginia

PostPosted: Tue Apr 08, 2003 1:41 pm    Post subject: Reply with quote

Glad to hear it! Smile
Back to top
View user's profile Send private message
Gadget Girl



Joined: 25 Jan 2002
Posts: 305
Location: Virginia

PostPosted: Sat Apr 12, 2003 4:26 pm    Post subject: Reply with quote

Hi,

Can anyone please help me? I want to use the private entries mod, but, I can't figure out the .RSS and how to hide the title.

I apologize if there is a thread with this in it already, I did search. Please point me in the right direction, thanks!

Sara Smile
Back to top
View user's profile Send private message
Mister44



Joined: 31 Oct 2002
Posts: 237
Location: Philadelphia, PA, USA

PostPosted: Sat Apr 12, 2003 4:59 pm    Post subject: Reply with quote

I've implemented it but it's not hackable... the code is too complex. See http://frcooper.com/devblog/
Back to top
View user's profile Send private message Visit poster's website
Gadget Girl



Joined: 25 Jan 2002
Posts: 305
Location: Virginia

PostPosted: Sat Apr 12, 2003 5:05 pm    Post subject: Reply with quote

I appreciate the link, but, did you have code on there I missed? Your blog entries go across the blog and under the sidebar.

You may want to fix that by declaring a width in your blog entries .CSS.

I was actually looking for the code to hide the private entries in .RSS and the title in .RSS and on the blog. You can still see your title on your .RSS feed, did you know that?

Smile Sara
Back to top
View user's profile Send private message
Mister44



Joined: 31 Oct 2002
Posts: 237
Location: Philadelphia, PA, USA

PostPosted: Sat Apr 12, 2003 5:30 pm    Post subject: Reply with quote

The code is in the cvs.

IE has the bug, not the CSS.
Back to top
View user's profile Send private message Visit poster's website
Gadget Girl



Joined: 25 Jan 2002
Posts: 305
Location: Virginia

PostPosted: Sat Apr 12, 2003 6:05 pm    Post subject: Reply with quote

I looked in the CVS and found it for the .RSS feed and .rss2, but the entire entry is still showing.

Thanks anyhow. Smile

Sara
Back to top
View user's profile Send private message
Mister44



Joined: 31 Oct 2002
Posts: 237
Location: Philadelphia, PA, USA

PostPosted: Sat Apr 12, 2003 8:08 pm    Post subject: Reply with quote

See all the commits marked "added support for protected entries"? Those are all the files needed to fix it everywhere...
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    boardom Forum Index -> How to ? All times are GMT + 1 Hour
Page 1 of 1

 
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