diff options
author | petko <petko@524c5546-5005-0410-9a3e-e25e191bd360> | 2024-07-27 12:29:07 +0000 |
---|---|---|
committer | petko <petko@524c5546-5005-0410-9a3e-e25e191bd360> | 2024-07-27 12:29:07 +0000 |
commit | 72815ca332185edb8b513ea30b43829b42e92aa0 (patch) | |
tree | 34eebeb3752439d401c8407fcfdd58da842821c5 /pmwiki.php | |
parent | 48fce7d346f105596940cc11d77250fb21977de2 (diff) | |
download | pmwiki.svn-72815ca332185edb8b513ea30b43829b42e92aa0.tar.bz2 |
Add $TROEPatterns.
git-svn-id: svn://pmwiki.org/pmwiki/trunk@4745 524c5546-5005-0410-9a3e-e25e191bd360
Diffstat (limited to 'pmwiki.php')
-rw-r--r-- | pmwiki.php | 49 |
1 files changed, 26 insertions, 23 deletions
@@ -308,7 +308,7 @@ function CondExpr($pagename, $condname, $condparm) { $code = trim(preg_replace('/(^\\s*|(and|x?or|&&|\\|\\||!)\\s+)(?=and|x?or|&&|\\|\\|)/', '$1 0 ', trim(implode(' ', $terms)))); - if(!$code) return false; + if (!$code) return false; return @eval("return( $code );"); } $Conditions['expr'] = 'CondExpr($pagename, $condname, $condparm)'; @@ -404,7 +404,7 @@ function pm_servefile($basedir, $path, $cachecontrol='no-cache') { die('Forbidden'); } $filepath = "$basedir/$path"; - if(!file_exists($filepath)) { + if (!file_exists($filepath)) { http_response_code(404); die('File not found'); } @@ -562,7 +562,7 @@ function HandleDispatch($pagename, $action, $msg=NULL) { ## helper functions function stripmagic($x) { - if(is_null($x)) return ''; + if (is_null($x)) return ''; $fn = 'get_magic_quotes_gpc'; if (!function_exists($fn)) return $x; if (is_array($x)) { @@ -724,7 +724,7 @@ function PSFT($fmt, $stamp=null, $locale=null, $tz=null) { # strftime() replacem if (@$fmt == '') $fmt = $FTimeFmt; $stamp = is_numeric($stamp)? intval($stamp) : $Now; - if(preg_match('/(?<!%)(%L)/', $fmt)) { + if (preg_match('/(?<!%)(%L)/', $fmt)) { $gmt = PSFT('@%Y-%m-%dT%H:%M:%SZ', $stamp, null, 'GMT'); $fmt = preg_replace('/(?<!%)(%L)/', $gmt, $fmt); } @@ -922,8 +922,8 @@ function pmcrypt($str, $salt=null) { SDV($PmCryptAlgo, PASSWORD_DEFAULT); if ($salt && preg_match('/^(-?@|\\*$)/', $salt)) return false; if (!is_null($salt)) { - if(function_exists('password_verify')) { - if(password_verify($str, $salt)) return $salt; + if (function_exists('password_verify')) { + if (password_verify($str, $salt)) return $salt; # else retry with crypt() } return crypt($str, $salt); @@ -1806,7 +1806,7 @@ function ListPages($pat=NULL) { return $out; } -function RAPC($pagename, $level, $authprompt=false, $since=READPAGE_CURRENT) { +function RAPC($pagename, $level='read', $authprompt=false, $since=READPAGE_CURRENT) { # helper function, widely used return RetrieveAuthPage($pagename, $level, $authprompt, $since); } @@ -2595,25 +2595,28 @@ function UpdatePage(&$pagename, &$page, &$new, $fnlist = NULL) { # EditTemplate allows a site administrator to pre-populate new pages # with the contents of another page. function EditTemplate($pagename, &$page, &$new) { - global $EditTemplatesFmt; + global $EditTemplatesFmt, $ROEPatterns, $TROEPatterns; if (@$new['text'] > '') return; - if (@$_REQUEST['template'] && PageExists($_REQUEST['template'])) { - $p = RetrieveAuthPage($_REQUEST['template'], 'read', false, - READPAGE_CURRENT); - if ($p['text'] > '') $new['text'] = $p['text']; - return; + $rqt = @$_REQUEST['template']; + if ($rqt && PageExists($rqt)) { + $p = RAPC($rqt); + if (@$p['text'] > '') $new['text'] = $p['text']; } - foreach((array)$EditTemplatesFmt as $t) { - if (strpos($t, ' ')!==false) { - $args = ParseArgs($t); - if (@$args['name']) { - if (! MatchPageNames($pagename, FixGlob($args['name']))) continue; + else { + foreach((array)$EditTemplatesFmt as $t) { + if (strpos($t, ' ')!==false) { + $args = ParseArgs($t); + if (@$args['name']) { + if (! MatchPageNames($pagename, FixGlob($args['name']))) continue; + } + $t = $args[''][0]; } - $t = $args[''][0]; + $p = RAPC(FmtPageName($t,$pagename)); + if (@$p['text'] > '') { $new['text'] = $p['text']; break; } } - $p = RetrieveAuthPage(FmtPageName($t,$pagename), 'read', false, - READPAGE_CURRENT); - if (@$p['text'] > '') { $new['text'] = $p['text']; return; } + } + if (@$new['text']>'' && is_array($TROEPatterns)) { + $new['text'] = ProcessROESPatterns(@$new['text'], $TROEPatterns); } } @@ -2999,7 +3002,7 @@ function PmWikiAuth($pagename, $level, $authprompt=true, $since=0) { ## Split from PmWikiAuth to allow for recipes to call it function PrintAuthForm($pagename) { global $FmtV, $AuthPromptFmt, $PageStartFmt, $PageEndFmt, $AuthFormRespCode; - if(IsEnabled($AuthFormRespCode, 0)) http_response_code($AuthFormRespCode); + if (IsEnabled($AuthFormRespCode, 0)) http_response_code($AuthFormRespCode); $postvars = ''; foreach($_POST as $k=>$v) { if ($k == 'authpw' || $k == 'authid') continue; |