Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#196 2006-04-03 13:00:31
- igner
- Plugin Author

- Registered: 2004-06-03
- Posts: 337
Re: ign_password_protect
<quote>My current TP install is not located at the domain root, it is offset to a /journal/ directory. Anyway, a couple of questions:
1) Is it possible to display a log out link without displaying the user’s name? For instance modifying it such that “<txp:ign_logged_user text=“Log out” />” .
2) On a offset install (described above), clicking on the log out link takes you to the domain root, appending the URL with “?logout=1”. This however, does not log one out, as the logout URL should read journal/<section>?logout=1
</quote>
Both of these are possible by editing one section of the plugin. In the ign_logged_user function, find the lines that read:
<code>
if ( !$ign_err ) {
list($c_userid,$c_privs,$c_realname,$cookie_hash) = split(‘,’,$_COOKIE[‘ign_login’]);
$u_display = (strtolower($display) == ‘realname’) ? $c_realname : $c_userid;
$user= ($verbose) ?
graf(gTxt(‘logged_in_as’).’ ‘.$u_display.br.’<a href=”?logout=1” alt=”’.$alt.’” title=”’.$alt.’”>’.gTxt(‘logout’).’</a>’)
: ‘<a href=”?logout=1” alt=”’.$alt.’” title=”’.$alt.’”>’.$u_display.’</a>’;
return $user;
} else {
return graf($logged_msg);
}
</code>
and change to
<code>
if ( !$ign_err ) {
return “<a href=’”.$_SERVER[‘REQUEST_URI’].”?logout=1’>Log Out</a>”;
} else {
return graf($logged_msg);
}
</code>
(Caveat: it’s early, I haven’t had my coffee, and I didn’t test the above code. Nevertheless, it should do what you are looking for.)
<quote>
Great work with the plugin, it seems to be working brilliantly. Although I have only just skimmed over the possibilities, has anyone managed to password protect just one section? And are files uploaded to certain sections still ‘protected’ ?
</quote>
You can easily protect one section if it uses a unique page template by adding the tag to the page. As far as the files go – the plugin’s really designed to protect inline content only. It does not prevent content from being accessible in searches or RSS feeds.
And then my dog ate my badger, and the love was lost.
Offline
#197 2006-04-03 17:48:57
Re: ign_password_protect
Thanks for your response Igner. I am currently getting the following error based on the following code amendment:
<code>
//———————————————————————-
//displays logged-in user
function ign_logged_user($atts)
{
global $ign_user, $ign_err;
extract(lAtts(array( ‘logged_msg’ => IGN_NOT_LOGGED_IN, ‘display’ => ‘name’, ‘alt’ => IGN_LOGOUT_LINK, ‘verbose’ => false, ‘greeting’ => gtxt(‘logged_in_as’) ), $atts));
if ( !$ign_err ) {
return “<a href=’”.$_SERVER[‘REQUEST_URI’].”?logout=1’>Log Out</a>”;
} else {
return graf($logged_msg);
}
}
</code>
The error being returned (on most admin pages)
<code>
Parse error: syntax error, unexpected $end in /usr/local/psa/home/vhosts/thekhans.me.uk/httpdocs/journal/textpattern/lib/txplib_misc.php(459) : eval()’d code on line 1109
The above errors were caused by the plugin:ign_password_protect
</code>
Offline
#198 2006-04-03 18:34:59
- igner
- Plugin Author

- Registered: 2004-06-03
- Posts: 337
Re: ign_password_protect
Saj,
line 1109 is toward the bottom of the plugin, the lines you edited are toward the top.
I tested the code copied and pasted from your post, and it’s working fine for me. I’m betting there’s a stray character in there somewhere else. Try reverting back to an unmodified version, and re-applying the hack, and let me know if that doesn’t solve the problem.
And then my dog ate my badger, and the love was lost.
Offline
#199 2006-04-08 03:48:54
- Mary
- Sock Enthusiast
- Registered: 2004-06-27
- Posts: 6,236
Re: ign_password_protect
I can’t seem to be able to use login_type of anything but browser (which I don’t want because that doesn’t work if you’re not using mod_php). The help says the default is inline, and you can also set it directly to be inline. No matter what, I still get the browser prompt. Am I being daft or what?
Offline
#200 2006-04-08 04:58:38
- igner
- Plugin Author

- Registered: 2004-06-03
- Posts: 337
Re: ign_password_protect
Mary, are you really sure you’re qualified to be using plugins? Code samples help ;)
How are you using the tag? Are you using it in the self-closing form? <txp:ign_password_protect /> will ALWAYS trigger browser-based authentication.
Use <txp:ign_password_protect></txp:ign_password_protect> instead. (Or use <txp:ign_if_logged_in></txp:ign_if_logged_in> in conjunction with <txp:ign_show_login /> to separate the authentication form and the actual protected content)
And then my dog ate my badger, and the love was lost.
Offline
#201 2006-04-08 05:52:24
- Mary
- Sock Enthusiast
- Registered: 2004-06-27
- Posts: 6,236
Re: ign_password_protect
Mary, are you really sure you’re qualified to be using plugins? Code samples help ;)
Shaddap. ;p I’ve earned posting vague help requests. :D
Are you using it in the self-closing form?
Aha, yes that’d be the problem. Thanks muchly, now all is well. :)
Offline
#202 2006-05-05 14:34:39
Re: ign_password_protect
I have successfully used ign_password_protect version 0.4.2 on a site for a long time (and it works great!)
Today, I downloaded version 0.4.2c for another site. In an article form called “password” (natch!), I added this:
<code><txp:ign_password_protect login_msg=“Please login to view this page” remember=“true”>
<h2><txp:permlink><txp:title /></txp:permlink></h2>
<txp:body />
</txp:ign_password_protect></code>
and then set one of the articles to “override form” and use the form “password”.
Now, the whole site continues to work, but when I click on the link to read that article, I get this error:
Parse error: syntax error, unexpected T_STRING in <code>[server address stuff]/textpattern/publish.php(934)</code> : eval()’d code on line 203
What am I doing wrong?
Last edited by Mike Montgomery (2006-05-05 14:40:47)
Offline
#203 2006-05-05 16:41:25
- igner
- Plugin Author

- Registered: 2004-06-03
- Posts: 337
Re: ign_password_protect
Don’t look at me, I just wrote the thing. I have no idea how it works.
Seriously, though, I just tested using your code above1, and seems to work fine for me. If you want to shoot me link info offlist, I can take a look at it2.
1 copied from the source. To get code to show up in the forums, wrap the code in < code > tags, or use pastebin.
2 All support work is billed at USD$12,000/hr. with a 3-hour minimum. But all service comes with a money-back guarantee3, and I offer generous payment terms of Net 25,550 days.
3 I guarantee you’ll want your money back, not that you’ll actually get it.
And then my dog ate my badger, and the love was lost.
Offline
#204 2006-05-17 10:05:58
- Algaris
- Member
- From: England
- Registered: 2006-01-27
- Posts: 608
Re: ign_password_protect
Hi this seems like a really good plug-in, just what I need for me site. I’m having some trouble getting it to work though. I’m using the following code in a page template as a test:
<code>
<txp:ign_password_protect login_msg=“Please log in to view this resource”>
<h1>Password Protected Stuff</h1>
Hello world! Do you know where your towel is?
</txp:ign_password_protect>
</code>
When ever I visit the page (before logging in) it displays the following message: ‘Sorry, the username and/or password entered is not valid, or you do not have privileges to access this resource’ and displays the login form. Whenever I try to login with my username and password (which I setup in the Textpattern admin tab) it loops back around to the login form and displays the same error message again.
Am I doing something wrong? I’m trying different tags and options but keep getting the same results.
Thanks for any help.
Last edited by Algaris (2006-05-17 10:06:12)
Offline
#205 2006-05-17 13:13:46
- igner
- Plugin Author

- Registered: 2004-06-03
- Posts: 337
Re: ign_password_protect
I’ve heard this come up a couple times, but I’ve not been able to recreate it.
A couple questions:- What version of TXP are you running?
- What version of the plugin?
- Using the txp_users database or the alternate?
And then my dog ate my badger, and the love was lost.
Offline
#206 2006-05-17 21:07:49
- Algaris
- Member
- From: England
- Registered: 2006-01-27
- Posts: 608
Re: ign_password_protect
Hi igner thanks for the reply. In answer to your questions:
Textpattern version: 4.0.3 (r1188)
ign_password_protect 0.4.2c
txp_users
Offline
#207 2006-05-18 12:32:02
- igner
- Plugin Author

- Registered: 2004-06-03
- Posts: 337
Re: ign_password_protect
Strange. The only reason that you’d get the failed login message is if the ign_user cookie is set but doesn’t match the credentials in the system. Check if you have the cookie, and delete it if present.
And then my dog ate my badger, and the love was lost.
Offline
#208 2006-05-18 14:52:54
- Algaris
- Member
- From: England
- Registered: 2006-01-27
- Posts: 608
Re: ign_password_protect
Ha! I found out what the problem was.
Because this is a test area of my site I’ve been using a CGI script to password protect the whole directory.
It appears that the CGI script and ign_password_protect both conflict with each other. I removed the script from my .htaccess file and everything works as it should.
It is a shame that I won’t be able to lock the whole directory down as before, but I guess I can live with that.
Thank you for your help and replies.
Not that it matters now I guess, but in answer to your question there was no ign_user cookie set on my machine.
Last edited by Algaris (2006-05-18 15:12:39)
Offline
#209 2006-05-18 15:11:45
- igner
- Plugin Author

- Registered: 2004-06-03
- Posts: 337
Re: ign_password_protect
Yep, that makes sense – the plugin tests to see if credentials are being passed in either as POST variables or from the AUTH_USER and AUTH_PW variables (passed in from the browser authentication). And I assume that the password protection on the directory was using those values.
One thought to make it work in the short run is to use the same user name and password for both. (though if you have different permission levels in the plugin / on the site, you’ll have to test those with the directory protection turned off)
And then my dog ate my badger, and the love was lost.
Offline
#210 2006-05-18 15:14:50
- Algaris
- Member
- From: England
- Registered: 2006-01-27
- Posts: 608
Re: ign_password_protect
Thank you. I’ll give that a try.
Offline