[pmwiki-users] Should register first before can read material indexed in side bar

Peter Bowers pbowers at pobox.com
Mon Mar 14 15:52:05 CDT 2011

On Mon, Mar 14, 2011 at 8:44 PM, Al Louis Ripskis <ripskis at sprynet.com> wrote:
> For newcomers to my homepage who would like to access and read the material indexed
> in the left side bar, I would like them to register first, providing their user name and password.
> And I would like to authenticate their IP address if possible.

If you don't want them to see the side bar on the home page you can
always surround some of the content with (:if authid:)...(:ifend:).

Can you be more clear about what type of authentication you want to do
on their IP address?  Are you wanting only people within a certain
range to be able to access the site or something?  If so you could
look at http://www.pmwiki.org/wiki/Cookbook/ConditionalMarkupSamples
and create your own conditional:

(:if ip 192.168.1.*:)for example(:ifend:)

I would probably base it off of the "matchstring" example.  Note the
very handy GlobToPCRE() function in pmwiki.php and preg_match() as
well as $_SERVER['remote_addr'] (which I believe can be fairly easily
faked).  It would probably look something like this:

# add (:if ip 192.168.1.* :) conditional
$Conditions['ip'] = 'MatchIp($condparm) == 1';
function MatchIp($arg)
  $arg = GlobToPCRE(trim($arg));
  return preg_match($arg, $_SERVER['remote_addr']);

Caveat: This is email-ware, completely untested even for syntax errors.


More information about the pmwiki-users mailing list