Recent Changes - Search:

Cookbook

PmWiki

pmwiki.org

MakingPasswordRequestsExplicit

Summary: How can we tell which password is requested?
Version: 1.0
Prerequisites: PmWiki 2.0
Status:
Maintainer:
Categories: Security Layout

PmWiki version tested: 2.0.beta36

Question

How can we tell which password is requested?

Answer

Place the following in local/config.php:

For version pmwiki 2.0.beta29 to 2.0.beta36:

 $AuthPromptFmt=array(&$PageStartFmt,
 "<p><b>A password is required to ".
    ($_GET['action']=='upload'?" reach file uploads":
     ($_GET['action']=='attr'?"administer":
      ($_GET['action']==edit?"edit":
       "read"))." this page")."</b></p>
      <form name='authform' action='{$_SERVER['REQUEST_URI']}' method='post'>
        Password: <input tabindex='1' type='password' name='authpw' value='' />
        <input type='submit' value='OK' />$postvars</form>
        If you forgot your password, please contact ...
        <script language='javascript'><!--
          document.authform.authpw.focus() //--></script>", &$PageEndFmt);

For pmwiki version ... up to 2.0.beta28

 $SessionAuthFmt=array(&$HTMLStartFmt,
    "<p><b>Password required to ".
    ($_GET['action']=='upload'?"upload a file":
     ($_GET['action']=='attr'?"administer":
      ($_GET['action']==edit?"edit":
       "read"))." this page")."</b></p>
      <form name='authform' action='{$_SERVER['REQUEST_URI']}' method='post'>
        Password: <input tabindex='1' type='password' name='authpw' value='' />
        <input type='submit' value='OK' />$postvars</form>
        If you forgot your password, please contact ...
       <script language='javascript'><!--
          document.authform.authpw.focus() //--></script>", &$HTMLEndFmt);

Notes and Comments

It's up to you to provide a contact, in place of the elipses to:

  • an email address <a href='mailto:Admin@here'>Admin</a> or
  • a profile page <a href='$ScriptURL/Profiles/AdminFolk'>AdminFolk</a>.

It may be a hack and there may be more elegant ways to do it

The conditional below can be used to override any $fooDoThisFmt string (either in local/config or in skins/SkinName/skin.php) to include the current mode (read, edit, administer - and one can easily add upload if needed):

 ($_GET['action']=='attr'?"administer":($_GET['action']==edit?"edit":"read"))

Neat! This also gives an opportunity to i8n the password dialog along the way. And you can put in extra lines for conditions coming out of other cookbook recipes (RenamePage for one). DirkBlaas

Optional image-link - use this:

 "<p><a href='http://www.pmwiki.org/wiki/PmWiki/PmWiki'><img 
 src='http://www.pmwiki.org/pmwiki/pub/skins/pmwiki/pmwiki-32.gif' alt='Back to HomePage'
 title='Back to HomePage' /></a>
   <p><b>A password is required to ".

in place of this:

 "<p><b>A password is required to ".  

-- TeganDowling

See Also

For including a similar conditional text in a page or template, see AuthenticatedAsConditional

History

  • Added link to request password - Radu May 19, 2005, at 09:36 AM
  • Added upload, fixed parentheses - Radu March 16, 2005, at 02:28 PM

Contributors

User notes? : If you use, used or reviewed this recipe, you can add your name. These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki.

Edit - History - Print - Recent Changes - Search
Page last modified on September 10, 2011, at 11:42 AM