Esempio n. 1
0
function IncludeText($pagename, $inclspec)
{
    global $MaxIncludes, $IncludeOpt, $InclCount;
    SDV($MaxIncludes, 50);
    SDVA($IncludeOpt, array('self' => 1));
    $npat = '[[:alpha:]][-\\w]*';
    if ($InclCount++ >= $MaxIncludes) {
        return Keep($inclspec);
    }
    $args = array_merge($IncludeOpt, ParseArgs($inclspec));
    while (count($args['#']) > 0) {
        $k = array_shift($args['#']);
        $v = array_shift($args['#']);
        if ($k == '') {
            if ($v[0] != '#') {
                if (isset($itext)) {
                    continue;
                }
                $iname = MakePageName($pagename, $v);
                if (!$args['self'] && $iname == $pagename) {
                    continue;
                }
                $ipage = RetrieveAuthPage($iname, 'read', false, READPAGE_CURRENT);
                $itext = @$ipage['text'];
            }
            $itext = TextSection($itext, $v, array('anchors' => 1));
            continue;
        }
        if (preg_match('/^(?:line|para)s?$/', $k)) {
            preg_match('/^(\\d*)(\\.\\.(\\d*))?$/', $v, $match);
            @(list($x, $a, $dots, $b) = $match);
            $upat = $k[0] == 'p' ? ".*?(\n\\s*\n|\$)" : "[^\n]*(?:\n|\$)";
            if (!$dots) {
                $b = $a;
                $a = 0;
            }
            if ($a > 0) {
                $a--;
            }
            $itext = preg_replace("/^(({$upat}){0,{$b}}).*\$/s", '$1', $itext, 1);
            $itext = preg_replace("/^({$upat}){0,{$a}}/s", '', $itext, 1);
            continue;
        }
    }
    $basepage = isset($args['basepage']) ? MakePageName($pagename, $args['basepage']) : $iname;
    if ($basepage) {
        $itext = Qualify(@$basepage, @$itext);
    }
    return FmtTemplateVars(PVSE($itext), $args);
}
Esempio n. 2
0
function IncludeText($pagename, $inclspec) {
  global $MaxIncludes, $IncludeOpt, $InclCount, $PCache;
  SDV($MaxIncludes,50);
  SDVA($IncludeOpt, array('self'=>1));
  if ($InclCount++>=$MaxIncludes) return Keep($inclspec);
  $args = array_merge($IncludeOpt, ParseArgs($inclspec));
  while (count($args['#'])>0) {
    $k = array_shift($args['#']); $v = array_shift($args['#']);
    if ($k=='') {
      if ($v{0} != '#') {
        if (isset($itext)) continue;
        $iname = MakePageName($pagename, $v);
        if (!$args['self'] && $iname == $pagename) continue;
        $ipage = RetrieveAuthPage($iname, 'read', false, READPAGE_CURRENT);
        $itext = IsEnabled($PCache[$iname]['=preview'], @$ipage['text']);
      }
      $itext = TextSection($itext, $v, array('anchors' => 1));
      continue;
    }
    if (preg_match('/^(?:line|para)s?$/', $k)) {
      preg_match('/^(\\d*)(\\.\\.(\\d*))?$/', $v, $match);
      @list($x, $a, $dots, $b) = $match;
      $upat = ($k{0} == 'p') ? ".*?(\n\\s*\n|$)" : "[^\n]*(?:\n|$)";
      if (!$dots) { $b=$a; $a=0; }
      if ($a>0) $a--;
      $itext=preg_replace("/^(($upat){0,$b}).*$/s",'$1',$itext,1);
      $itext=preg_replace("/^($upat){0,$a}/s",'',$itext,1);
      continue;
    }
  }
  $basepage = isset($args['basepage']) 
              ? MakePageName($pagename, $args['basepage'])
              : $iname;
  if ($basepage) $itext = Qualify(@$basepage, @$itext);
  return FmtTemplateVars(PVSE($itext), $args);
}
function PmFormMail($pagename, $msgtmpl, $opt, $safe_opt)
{
    global $PmFormMailHeaders, $PmFormMailParameters;
    SDV($PmFormMailHeaders, '');
    SDV($PmFormMailParameters, '');
    if (!preg_match('/\\S/', $msgtmpl)) {
        $msgtmpl = '{$$text}';
    }
    $msgtext = FmtTemplateVars($msgtmpl, $opt, $pagename);
    $mailto = preg_split('/\\s*,\\s*/', @$safe_opt['mailto'], -1, PREG_SPLIT_NO_EMPTY);
    $mailto = implode(', ', $mailto);
    $from = $opt['from'];
    $subject = $opt['subject'];
    $header = $PmFormMailHeaders;
    if ($from) {
        $header = "From: {$from}\r\n{$header}";
    }
    $header = preg_replace("/[\r\n]*\$/", '', $header);
    if ($PmFormMailParameters) {
        $tf = mail($mailto, $subject, $msgtext, $header, $MailFormParameters);
    } else {
        $tf = mail($mailto, $subject, $msgtext, $header);
    }
    if (!$tf) {
        return '$[An error has occurred]';
    }
    return NULL;
}