Open Pass

For https://notes.ekvastra.in/ I have edited Site.AuthForm so that it will display the edit password. The code inserted is as follows:

(:if equal {$editpass} "site" :) 

Try entering EDIT in small letters as the password. This is an open password to prevent spamming by robots but still allow a human who can read the page and follow instructions to make edits.

(:ifend:)

I added corresponding code in config.php so that the prompt is only shown where it is applicable. For example it is not useful on pages that are locked by admin password and it will not be shown there.

function MyPasswdVar($pagename, $level)
{
  global $PCache;
  $page = $PCache[$pagename];
  if (!isset($page['=passwd'][$level])) {
    $page = RetrieveAuthPage($pagename, 'ALWAYS', false, READPAGE_CURRENT);
    if ($page) PCache($pagename, $page);
  }
  $pwsource = $page['=pwsource'][$level];
  if (strncmp($pwsource, 'cascade:', 8) == 0)
    return( substr($pwsource, 8));
  return ($pwsource);
}

if ($action == 'edit') {
   # $FmtPV is an array that is used for defining Page Variables.
   $FmtPV['$editpass'] = 'MyPasswdVar($pagename,"edit")';
}