Ejemplo n.º 1
0
function FmtPageList($fmt, $pagename, $opt)
{
    global $GroupPattern, $FmtV, $FPLFunctions;
    # if (isset($_REQUEST['q']) && $_REQUEST['q']=='') $_REQUEST['q']="''";
    $rq = htmlspecialchars(stripmagic(@$_REQUEST['q']), ENT_NOQUOTES);
    $FmtV['$Needle'] = $opt['o'] . ' ' . $rq;
    if (preg_match("!^({$GroupPattern}(\\|{$GroupPattern})*)?/!i", $rq, $match)) {
        $opt['group'] = @$match[1];
        $rq = substr($rq, strlen(@$match[1]) + 1);
    }
    $opt = array_merge($opt, ParseArgs($opt['o'] . ' ' . $rq), @$_REQUEST);
    if (@($opt['req'] && !$opt['-'] && !$opt[''] && !$opt['+'] && !$opt['q'])) {
        return;
    }
    $matches = array();
    $fmtfn = @$FPLFunctions[$opt['fmt']];
    if (!function_exists($fmtfn)) {
        $fmtfn = 'FPLByGroup';
    }
    $out = $fmtfn($pagename, $matches, $opt);
    $FmtV['$MatchCount'] = count($matches);
    $GLOBALS['SearchIncl'] = array_merge((array) @$opt[''], (array) @$opt['+']);
    $GLOBALS['SearchExcl'] = array_merge((array) $opt['-']);
    $GLOBALS['SearchGroup'] = @$opt['group'];
    if ($fmt != '$MatchList') {
        $FmtV['$MatchList'] = $out;
        $out = FmtPageName($fmt, $pagename);
    }
    if ($out[0] == '<') {
        return '<div>' . Keep($out) . '</div>';
    }
    PRR();
    return $out;
}
Ejemplo n.º 2
0
function SearchBox($pagename, $opt)
{
    global $SearchBoxFmt, $SearchBoxOpt, $SearchQuery, $EnablePathInfo;
    if (isset($SearchBoxFmt)) {
        return Keep(FmtPageName($SearchBoxFmt, $pagename));
    }
    SDVA($SearchBoxOpt, array('size' => '40', 'label' => FmtPageName('$[Search]', $pagename), 'value' => str_replace("'", "&#039;", $SearchQuery)));
    $opt = array_merge((array) $SearchBoxOpt, @$_GET, (array) $opt);
    $opt['action'] = 'search';
    $target = $opt['target'] ? MakePageName($pagename, $opt['target']) : $pagename;
    $out = FmtPageName(" class='wikisearch' action='\$PageUrl' method='get'>", $target);
    $opt['n'] = IsEnabled($EnablePathInfo, 0) ? '' : $target;
    $out .= "<input type='text' name='q' value='{$opt['value']}' \n    class='inputbox searchbox' size='{$opt['size']}' /><input type='submit' \n    class='inputbutton searchbutton' value='{$opt['label']}' />";
    foreach ($opt as $k => $v) {
        if ($v == '') {
            continue;
        }
        if ($k == 'q' || $k == 'label' || $k == 'value' || $k == 'size') {
            continue;
        }
        $k = str_replace("'", "&#039;", $k);
        $v = str_replace("'", "&#039;", $v);
        $out .= "<input type='hidden' name='{$k}' value='{$v}' />";
    }
    return '<form ' . Keep($out) . '</form>';
}
Ejemplo n.º 3
0
function InputMarkup($pagename, $type, $args)
{
    global $InputTags, $InputAttrs, $InputValues, $FmtV;
    if (!@$InputTags[$type]) {
        return "(:input {$type} {$args}:)";
    }
    $opt = array_merge($InputTags[$type], ParseArgs($args));
    $args = @$opt[':args'];
    if (!$args) {
        $args = array('name', 'value');
    }
    while (count(@$opt['']) > 0 && count($args) > 0) {
        $opt[array_shift($args)] = array_shift($opt['']);
    }
    foreach ((array) @$opt[''] as $a) {
        if (!isset($opt[$a])) {
            $opt[$a] = $a;
        }
    }
    if (!isset($opt['value']) && isset($InputValues[@$opt['name']])) {
        $opt['value'] = $InputValues[$opt['name']];
    }
    $attr = array();
    foreach ($InputAttrs as $a) {
        if (!isset($opt[$a])) {
            continue;
        }
        $attr[] = "{$a}='" . str_replace("'", '&#39;', $opt[$a]) . "'";
    }
    $FmtV['$InputFormArgs'] = implode(' ', $attr);
    $out = FmtPageName($opt[':html'], $pagename);
    return Keep($out);
}
function BDropdownMenu($inp)
{
    $defaults = array('title' => 'Dropdown');
    $args = array_merge($defaults, ParseArgs($inp));
    $inline_code_begin = "<li class='dropdown'><a href='#' class='dropdown-toggle' data-toggle='dropdown'>" . $args['title'] . "<b class='caret'></b></a><ul class='dropdown-menu'>";
    $inline_code_end = "</ul></li>";
    // if we're using MakePageList, we have to pass ALL the opts along...
    // in this case, named $args
    $group_list = BGetWikiPages($args);
    $formatted_list = BBuildGroupList($group_list);
    return Keep($inline_code_begin . $formatted_list . $inline_code_end);
}
Ejemplo n.º 5
0
function HandyTocProcessMarkup($pagename, $argstr)
{
    global $HandyTocEndAt, $HandyTocStartAt, $HandyTocIgnoreSoleH1;
    global $HTMLFooterFmt;
    $args = ParseArgs($argstr);
    $title = $args[''] ? implode(' ', $args['']) : '';
    $start = $args['start'] ? $args['start'] : $HandyTocStartAt;
    $end = $args['end'] ? $args['end'] : $HandyTocEndAt;
    $ignoreh1 = $args['ignoreh1'] ? $args['ignoreh1'] : $HandyTocIgnoreSoleH1;
    $class = $args['class'] ? ' class="' . $args['class'] . '" ' : '';
    $HTMLFooterFmt['handytoc'] = " \n  <script language='javascript' type='text/javascript'\n     src='\$HandyTocPubDirUrl/handytoc.js'></script>\n  <script language='javascript' type='text/javascript'>TOC.set_args({start:{$start}, end:{$end}, ignoreh1:{$ignoreh1}});</script>\n";
    if ($title) {
        return Keep("<div {$class}id='htoc'><h3>{$title}</h3></div>");
    } else {
        return Keep("<div {$class}id='htoc'></div>");
    }
}
Ejemplo n.º 6
0
function drawing($str)
{
    global $EnableUpload;
    $output = "";
    if ($EnableUpload != 1) {
        // Helpful hint to make sure people turn on uploads!
        $output .= "<b>Please note your administrator *NEEDS* to enable uploads before you can save your drawings.</b><br/>";
    }
    $drawing = $str;
    $pos = strrpos($drawing, '.');
    $filenameExtension = $pos == false ? '' : strtolower(substr($drawing, $pos + 1));
    if (in_array($filenameExtension, array('', 'draw'))) {
        $output .= drawing_draw($str);
    } else {
        $output .= drawing_any($str);
    }
    return Keep($output);
}
Ejemplo n.º 7
0
function SearchBox($pagename, $opt)
{
    global $SearchBoxFmt, $SearchBoxOpt, $SearchQuery, $EnablePathInfo;
    if (isset($SearchBoxFmt)) {
        return FmtPageName($SearchBoxFmt, $pagename);
    }
    SDVA($SearchBoxOpt, array('size' => '40', 'label' => FmtPageName('$[Search]', $pagename), 'group' => @$_REQUEST['group'], 'value' => str_replace("'", "&#039;", $SearchQuery)));
    $opt = array_merge((array) $SearchBoxOpt, (array) $opt);
    $group = $opt['group'];
    $out = FmtPageName("\n    class='wikisearch' action='\$PageUrl' method='get'><input\n    type='hidden' name='action' value='search' />", $pagename);
    if (!IsEnabled($EnablePathInfo, 0)) {
        $out .= "<input type='hidden' name='n' value='{$pagename}' />";
    }
    if ($group) {
        $out .= "<input type='hidden' name='group' value='{$group}' />";
    }
    $out .= "<input type='text' name='q' value='{$opt['value']}' \n    size='{$opt['size']}' /><input class='wikisearchbutton' \n    type='submit' value='{$opt['label']}' /></form>";
    return "<form " . Keep($out);
}
Ejemplo n.º 8
0
function InputActionForm($pagename, $type, $args) {
  global $InputAttrs;
  $args = ParseArgs($args);
  if (@$args['pagename']) $pagename = $args['pagename'];
  $opt = NULL;
  $html = InputToHTML($pagename, $type, $args, $opt);
  foreach(preg_grep('/^[\\w$]/', array_keys($args)) as $k) {
    if (is_array($args[$k]) || in_array($k, $InputAttrs)) continue;
    if ($k == 'n' || $k == 'pagename') continue;
    $html .= "<input type='hidden' name='$k' value='{$args[$k]}' />";
  }
  return Keep($html);
}
Ejemplo n.º 9
0
function MarkupExpression($pagename, $expr)
{
    global $KeepToken, $KPV, $MarkupExpr;
    $rpat = "/{$KeepToken}(\\d+P){$KeepToken}/e";
    $rrep = '$KPV[\'$1\']';
    $expr = preg_replace('/([\'"])(.*?)\\1/e', "Keep(PSS('\$2'),'P')", $expr);
    $expr = preg_replace('/\\(\\W/e', "Keep(PSS('\$2'),'P')", $expr);
    while (preg_match('/\\((\\w+)(\\s[^()]*)?\\)/', $expr, $match)) {
        list($repl, $func, $params) = $match;
        $code = @$MarkupExpr[$func];
        ##  if not a valid function, save this string as-is and exit
        if (!$code) {
            break;
        }
        ##  if the code uses '$params', we just evaluate directly
        if (strpos($code, '$params') !== false) {
            $out = eval("return ({$code});");
            if ($expr == $repl) {
                $expr = $out;
                break;
            }
            $expr = str_replace($repl, $out, $expr);
            continue;
        }
        ##  otherwise, we parse arguments into $args before evaluating
        $argp = ParseArgs($params);
        $x = $argp['#'];
        $args = array();
        while ($x) {
            list($k, $v) = array_splice($x, 0, 2);
            if ($k == '' || $k == '+' || $k == '-') {
                $args[] = $k . preg_replace($rpat, $rrep, $v);
            }
        }
        ##  fix any quoted arguments
        foreach ($argp as $k => $v) {
            if (!is_array($v)) {
                $argp[$k] = preg_replace($rpat, $rrep, $v);
            }
        }
        $out = eval("return ({$code});");
        if ($expr == $repl) {
            $expr = $out;
            break;
        }
        $expr = str_replace($repl, Keep($out, 'P'), $expr);
    }
    return preg_replace($rpat, $rrep, $expr);
}
Ejemplo n.º 10
0
function MarkupMarkup($pagename, $text, $opt = '') {
  global $MarkupWordwrapFunction;
  SDV($MarkupWordwrapFunction, 'wordwrap');
  $MarkupMarkupOpt = array('class' => 'vert');
  $opt = array_merge($MarkupMarkupOpt, ParseArgs($opt));
  $html = MarkupToHTML($pagename, $text, array('escape' => 0));
  if (@$opt['caption']) 
    $caption = str_replace("'", '&#039;', 
                           "<caption>{$opt['caption']}</caption>");
  $class = preg_replace('/[^-\\s\\w]+/', ' ', @$opt['class']);
  if (strpos($class, 'horiz') !== false) 
    { $sep = ''; $pretext = $MarkupWordwrapFunction($text, 40); } 
  else 
    { $sep = '</tr><tr>'; $pretext = $MarkupWordwrapFunction($text, 75); }
  return Keep(@"<table class='markup $class' align='center'>$caption
      <tr><td class='markup1' valign='top'><pre>$pretext</pre></td>$sep<td 
        class='markup2' valign='top'>$html</td></tr></table>");
}
Ejemplo n.º 11
0
function GroupDropdownMenu($inp)
{
    $defaults = array('title' => 'Dropdown');
    $args = array_merge($defaults, ParseArgs($inp));
    $inline_code_begin = "<li class='dropdown'><a href='#' class='dropdown-toggle' data-toggle='dropdown'>" . $args['title'] . "<b class='caret'></b></a><ul class='dropdown-menu'>";
    $inline_code_end = "</ul></li>";
    // NOTE: if pattern not present, will default to ALL pages in wiki
    // hrm. "pattern" should probably change to "include"....
    $pattern = $args['pattern'];
    $exclude = $args['exclude'];
    // initial implementation is a naive string-check
    // TODO: improve exclude pattern
    // look at http://www.pmwiki.org/wiki/PmWiki/PageLists
    $group_list = GetWikiPages($pattern, $exclude);
    $formatted_list = BuildGroupList($group_list);
    return Keep($inline_code_begin . $formatted_list . $inline_code_end);
}
Ejemplo n.º 12
0
function MarkupMarkup($pagename, $text)
{
    return "(:divend:)" . Keep("<table class='markup' align='center'><tr><td class='markup1'><pre>" . wordwrap($text, 70) . "</pre></td></tr><tr><td class='markup2'>") . "\n{$text}\n(:divend:)</td></tr></table>\n";
}
Ejemplo n.º 13
0
function FmtPageList($outfmt, $pagename, $opt)
{
    global $GroupPattern, $FmtV, $PageListArgPattern, $FPLFormatOpt, $FPLFunctions;
    # get any form or url-submitted request
    $rq = PHSC(stripmagic(@$_REQUEST['q']), ENT_NOQUOTES);
    # build the search string
    $FmtV['$Needle'] = $opt['o'] . ' ' . $rq;
    # Handle "group/" at the beginning of the form-submitted request
    if (preg_match("!^({$GroupPattern}(\\|{$GroupPattern})*)?/!i", $rq, $match)) {
        $opt['group'] = @$match[1];
        $rq = substr($rq, strlen(@$match[1]) + 1);
    }
    $opt = array_merge($opt, ParseArgs($opt['o'], $PageListArgPattern));
    # merge markup options with form and url
    if (@$opt['request'] && @$_REQUEST) {
        $rkeys = preg_grep('/^=/', array_keys($_REQUEST), PREG_GREP_INVERT);
        if ($opt['request'] != '1') {
            list($incl, $excl) = GlobToPCRE($opt['request']);
            if ($excl) {
                $rkeys = array_diff($rkeys, preg_grep("/{$excl}/", $rkeys));
            }
            if ($incl) {
                $rkeys = preg_grep("/{$incl}/", $rkeys);
            }
        }
        $cleanrequest = array();
        foreach ($rkeys as $k) {
            $cleanrequest[$k] = stripmagic($_REQUEST[$k]);
        }
        $opt = array_merge($opt, ParseArgs($rq, $PageListArgPattern), $cleanrequest);
    }
    # non-posted blank search requests return nothing
    if (@($opt['req'] && !$opt['-'] && !$opt[''] && !$opt['+'] && !$opt['q'])) {
        return '';
    }
    # terms and group to be included and excluded
    $GLOBALS['SearchIncl'] = array_merge((array) @$opt[''], (array) @$opt['+']);
    $GLOBALS['SearchExcl'] = (array) @$opt['-'];
    $GLOBALS['SearchGroup'] = @$opt['group'];
    $fmt = @$opt['fmt'];
    if (!$fmt) {
        $fmt = 'default';
    }
    $fmtopt = @$FPLFormatOpt[$fmt];
    if (!is_array($fmtopt)) {
        if ($fmtopt) {
            $fmtopt = array('fn' => $fmtopt);
        } elseif (@$FPLFunctions[$fmt]) {
            $fmtopt = array('fn' => $FPLFunctions[$fmt]);
        } else {
            $fmtopt = $FPLFormatOpt['default'];
        }
    }
    $fmtfn = @$fmtopt['fn'];
    if (!is_callable($fmtfn)) {
        $fmtfn = $FPLFormatOpt['default']['fn'];
    }
    $matches = array();
    $opt = array_merge($fmtopt, $opt);
    $out = $fmtfn($pagename, $matches, $opt);
    $FmtV['$MatchCount'] = count($matches);
    if ($outfmt != '$MatchList') {
        $FmtV['$MatchList'] = $out;
        $out = FmtPageName($outfmt, $pagename);
    }
    if ($out[0] == '<') {
        $out = Keep($out);
    }
    return PRR($out);
}
function doYouTube ($pagename, $attrstr) {
	$attribs = new Attributes($attrstr);
	$attr = $attribs->getAttribs('html');
	if (isset($attr['id'])) {
		$attr['id'] = preg_replace('/\W/', '', $attr['id']);
		$w = isset($attr['width']) ? $attr['width'] : 425;
		$h = isset($attr['height']) ? $attr['height'] : 350;
		$ret = "<object width='$w' height='$h'>\n";
		$ret.= "<param name='movie' value='http://www.youtube.com/v/$attr[id]'/>\n";
	  	$ret.= "<param name='wmode' value='transparent'/>\n";
		$ret.= "<embed src='http://www.youtube.com/v/$attr[id]' type='application/x-shockwave-flash' wmode='transparent' width='$w' height='$h'/>\n";
		$ret.= "</object>";
		return Keep($ret);
	}
	return '';
}
Ejemplo n.º 15
0
function MakeLink($pagename, $tgt, $txt = NULL, $suffix = NULL, $fmt = NULL)
{
    global $LinkPattern, $LinkFunctions, $UrlExcludeChars, $ImgExtPattern, $ImgTagFmt;
    $t = preg_replace('/[()]/', '', trim($tgt));
    $t = preg_replace('/<[^>]*>/', '', $t);
    preg_match("/^({$LinkPattern})?(.+?)(\"(.*)\")?\$/", $t, $m);
    if (!$m[1]) {
        $m[1] = '<:page>';
    }
    if (preg_match("/(({$LinkPattern})([^{$UrlExcludeChars}]+{$ImgExtPattern}))(\"(.*)\")?\$/", $txt, $tm)) {
        $txt = $LinkFunctions[$tm[2]]($pagename, $tm[2], $tm[3], @$tm[5], $tm[1], $ImgTagFmt);
    } else {
        if (is_null($txt)) {
            $txt = preg_replace('/\\([^)]*\\)/', '', $tgt);
            if ($m[1] == '<:page>') {
                $txt = preg_replace('!^.*[^<]/!', '', $txt);
            }
            $txt = Keep($txt);
        }
        $txt .= $suffix;
    }
    $out = $LinkFunctions[$m[1]]($pagename, $m[1], $m[2], @$m[4], $txt, $fmt);
    return $out;
}
Ejemplo n.º 16
0
function RedirectMarkup($pagename, $opt)
{
    $k = Keep("(:redirect {$opt}:)");
    global $MarkupFrame, $EnableRedirectQuiet;
    if (!@$MarkupFrame[0]['redirect']) {
        return $k;
    }
    $opt = ParseArgs($opt);
    $to = @$opt['to'];
    if (!$to) {
        $to = @$opt[''][0];
    }
    if (!$to) {
        return $k;
    }
    if (preg_match('/^([^#]+)(#[A-Za-z][-\\w]*)$/', $to, $match)) {
        $to = $match[1];
        $anchor = @$match[2];
    }
    $to = MakePageName($pagename, $to);
    if (!PageExists($to)) {
        return $k;
    }
    if ($to == $pagename) {
        return '';
    }
    if (@$opt['from'] && !MatchPageNames($pagename, FixGlob($opt['from'], '$1*.$2'))) {
        return '';
    }
    if (preg_match('/^30[1237]$/', @$opt['status'])) {
        header("HTTP/1.1 {$opt['status']}");
    }
    Redirect($to, "{\$PageUrl}" . (IsEnabled($EnableRedirectQuiet, 0) && IsEnabled($opt['quiet'], 0) ? '' : "?from={$pagename}") . $anchor);
    exit;
}
Ejemplo n.º 17
0
function MarkupMarkup($pagename, $text)
{
    $html = MarkupToHTML($pagename, $text, false);
    return Keep("<table class='markup' align='center'><tr><td class='markup1'><pre>" . wordwrap($text, 70) . "</pre></td></tr><tr><td class='markup2'>\n      {$html}</td></tr></table>");
}
Ejemplo n.º 18
0
function InputSelect($pagename, $type, $markup)
{
    global $InputTags, $InputAttrs, $FmtV;
    preg_match_all('/\\(:input\\s+\\S+\\s+(.*?):\\)/', $markup, $match);
    $selectopt = (array) $InputTags[$type];
    $opt = $selectopt;
    $optionshtml = '';
    $optiontype = isset($InputTags["{$type}-option"]) ? "{$type}-option" : "select-option";
    foreach ($match[1] as $args) {
        $optionshtml .= InputToHTML($pagename, $optiontype, $args, $oo);
        $opt = array_merge($opt, $oo);
    }
    $attrlist = array_diff($InputAttrs, array('value'));
    foreach ($attrlist as $a) {
        if (!isset($opt[$a]) || $opt[$a] === false) {
            continue;
        }
        $attr[] = "{$a}='" . str_replace("'", '&#39;', $opt[$a]) . "'";
    }
    $FmtV['$InputSelectArgs'] = implode(' ', $attr);
    $FmtV['$InputSelectOptions'] = $optionshtml;
    return Keep(FmtPageName($selectopt[':html'], $pagename));
}
Ejemplo n.º 19
0
function m2mButtons ($pagename) {
	global $M2MUrl;
	$url = FmtPageName('$PageUrl', $pagename) . "?action=m2m-publish";
	$ret = '';
	$ret = <<<content
		<script language='JavaScript'>
			function selectFormat() {
				format = document.m2mform.targetformat.value;
				document.m2mform.options.disabled = (format == 'zip');
				setCookie('m2m-format', format);
			}

			function getCookie (name) {  
				var arg = name + "=";  
				var alen = arg.length;  
				var clen = document.cookie.length;  
				var i = 0;  
				while (i < clen) {
					var j = i + alen;    
					if (document.cookie.substring(i, j) == arg)      
						return getCookieVal (j);    
					i = document.cookie.indexOf(" ", i) + 1;    
					if (i == 0) break;   
				}  
				return null;
			}
			
			function setCookie (name, value) {  
				var argv = setCookie.arguments;  
				var argc = setCookie.arguments.length;  
				var expires = (argc > 2) ? argv[2] : null;  
				var path = (argc > 3) ? argv[3] : null;  
				var domain = (argc > 4) ? argv[4] : null;  
				var secure = (argc > 5) ? argv[5] : false;  
				document.cookie = name + "=" + escape (value) + 
					((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + 
					((path == null) ? "" : ("; path=" + path)) +  
					((domain == null) ? "" : ("; domain=" + domain)) +    
					((secure == true) ? "; secure" : "");
			}
		</script>
		<form class='publish' name='m2mform' target='_blank' action='$url' method='post'>
content;

	$formats = WikiConverterFactory::availableTargetFormats();
	if (count($formats) > 1) {
		$ret.= '$[Target Format]:'; 
		$ret.= "<select name='targetformat' class='inputbox' onChange='selectFormat()'>";
		foreach ($formats as $f=>$d) {		
			$ret .= "<option value='$f'";		
			if ($f == $_COOKIE['m2m-format'])
				$ret .= " selected='selected'";
			$ret .= ">$d</option>";
		}
		$ret .= "</select>\n";
	}
	else {
		$keys = array_keys($formats);
		$ret .= "<input type='hidden' name='targetformat' value='$keys[0]'/>";
	}
	$ret .= <<<content
		<input type='hidden' value='$pagename' name='pagename'>
		<input type='submit' value='$[Options]' name='m2m-options' class='inputbutton'/>
		<input type='submit' value='$[Publish Page]' name='publishpage' class='inputbutton'/>
content;
	$pagetype = pagetype($pagename);
	if ($pagetype == 'trail' || $pagetype == 'collection') {
		$typestr = strtoupper($pagetype{0}).substr($pagetype, 1);
		$ret.= " <input type='submit' value='$[Publish $typestr]' name='publish$pagetype' class='inputbutton'/> ";
	}
	$ret.= "</form>";
	return Keep(FmtPageName($ret, $pagename));
}
Ejemplo n.º 20
0
function eProtectDecode($CompressedEmailAddress, $AlternateText)
{
    //----------------------------------------------------------------------
    $email = $CompressedEmailAddress;
    $html = "\n<!--eProtect-->\n";
    if ($AlternateText == '') {
        $html .= "<script type='text/JavaScript'>\n<!--\nNix.decode" . "(\"<n pynff='heyyvax' uers='znvygb:{$email}'>{$email}</n>\");" . "\n//-->\n</script>";
    } else {
        $html .= "<script type='text/JavaScript'>\n<!--\nNix.decode" . "(\"<n pynff='heyyvax' uers='znvygb:{$email}'>\");" . "\n//-->\n</script>" . $AlternateText . "<script\r\n      type='text/JavaScript'><!--\nNix.decode" . "(\"</n>\");" . "\n//-->\n</script>";
    }
    $html .= "\n<!--/eProtect-->\n";
    return Keep($html);
}
Ejemplo n.º 21
0
function MarkupMarkup($pagename, $text, $opt = '')
{
    $MarkupMarkupOpt = array('class' => 'vert');
    $opt = array_merge($MarkupMarkupOpt, ParseArgs($opt));
    $html = MarkupToHTML($pagename, $text, array('escape' => 0));
    if (@$opt['caption']) {
        $caption = str_replace("'", '&#039;', "<caption>{$opt['caption']}</caption>");
    }
    $class = preg_replace('/[^-\\s\\w]+/', ' ', @$opt['class']);
    if (strpos($class, 'horiz') !== false) {
        $sep = '';
        $pretext = wordwrap($text, 40);
    } else {
        $sep = '</tr><tr>';
        $pretext = wordwrap($text, 75);
    }
    return Keep("<table class='markup {$class}' align='center'>{$caption}\n      <tr><td class='markup1' valign='top'><pre>{$pretext}</pre></td>{$sep}<td \n        class='markup2' valign='top'>{$html}</td></tr></table>");
}
function FPLSimpleText($pagename, &$matches, $opt)
{
    $matches = MakePageList($pagename, $opt, 0);
    ##  extract page subset according to 'count=' parameter
    if (@$opt['count']) {
        list($r0, $r1) = CalcRange($opt['count'], count($matches));
        if ($r1 < $r0) {
            $matches = array_reverse(array_slice($matches, $r1 - 1, $r0 - $r1 + 1));
        } else {
            $matches = array_slice($matches, $r0 - 1, $r1 - $r0 + 1);
        }
    }
    $opt['sep'] = @$opt['sep'] ? $opt['sep'] : ",";
    $opt['sep'] = str_replace('\\n', "\n", $opt['sep']);
    if ($opt['sep'] == 'LF') {
        $opt['sep'] = "\n";
    }
    return Keep(implode($opt['sep'], $matches), 'P');
}
Ejemplo n.º 23
0
function FmtPageList($outfmt, $pagename, $opt) {
  global $GroupPattern, $FmtV, $PageListArgPattern, 
    $FPLFormatOpt, $FPLFunctions;
  # get any form or url-submitted request
  $rq = htmlspecialchars(stripmagic(@$_REQUEST['q']), ENT_NOQUOTES);
  # build the search string
  $FmtV['$Needle'] = $opt['o'] . ' ' . $rq;
  # Handle "group/" at the beginning of the form-submitted request
  if (preg_match("!^($GroupPattern(\\|$GroupPattern)*)?/!i", $rq, $match)) {
    $opt['group'] = @$match[1];
    $rq = substr($rq, strlen(@$match[1])+1);
  }
  $opt = array_merge($opt, ParseArgs($opt['o'], $PageListArgPattern));
  # merge markup options with form and url
  if (@$opt['request']) 
    $opt = array_merge($opt, ParseArgs($rq, $PageListArgPattern), @$_REQUEST);
  # non-posted blank search requests return nothing
  if (@($opt['req'] && !$opt['-'] && !$opt[''] && !$opt['+'] && !$opt['q']))
    return '';
  # terms and group to be included and excluded
  $GLOBALS['SearchIncl'] = array_merge((array)@$opt[''], (array)@$opt['+']);
  $GLOBALS['SearchExcl'] = (array)@$opt['-'];
  $GLOBALS['SearchGroup'] = @$opt['group'];
  $fmt = @$opt['fmt']; if (!$fmt) $fmt = 'default';
  $fmtopt = @$FPLFormatOpt[$fmt];
  if (!is_array($fmtopt)) {
    if ($fmtopt) $fmtopt = array('fn' => $fmtopt);
    elseif (@$FPLFunctions[$fmt]) 
      $fmtopt = array('fn' => $FPLFunctions[$fmt]);
    else $fmtopt = $FPLFormatOpt['default'];
  }
  $fmtfn = @$fmtopt['fn'];
  if (!is_callable($fmtfn)) $fmtfn = $FPLFormatOpt['default']['fn'];
  $matches = array();
  $opt = array_merge($fmtopt, $opt);
  $out = $fmtfn($pagename, $matches, $opt);
  $FmtV['$MatchCount'] = count($matches);
  if ($outfmt != '$MatchList') 
    { $FmtV['$MatchList'] = $out; $out = FmtPageName($outfmt, $pagename); }
  if ($out[0] == '<') $out = Keep($out);
  return PRR($out);
}
function doYouTube ($pagename, $attrstr) {
	$attr = new Attributes($attrstr, array('print'=>'fo'));
	$attr = $attr->getAttribs('fo');
	unset($attr['id']);
	if (isset($attr['file'])) {
		$embed = new Embed($pagename, $attrstr);
		return Keep($embed->getWikiXML());
	}
	return '';
}
Ejemplo n.º 25
0
function IncludeText($pagename, $inclspec)
{
    global $MaxIncludes, $InclCount;
    SDV($MaxIncludes, 50);
    $npat = '[[:alpha:]][-\\w]*';
    if ($InclCount++ >= $MaxIncludes) {
        return Keep($inclspec);
    }
    $args = ParseArgs($inclspec);
    while (count($args['#']) > 0) {
        $k = array_shift($args['#']);
        $v = array_shift($args['#']);
        if ($k == '') {
            preg_match('/^([^#\\s]*)(.*)$/', $v, $match);
            if ($match[1]) {
                # include a page
                if (isset($itext)) {
                    continue;
                }
                $iname = MakePageName($pagename, $match[1]);
                if (!PageExists($iname)) {
                    continue;
                }
                $ipage = RetrieveAuthPage($iname, 'read', false, READPAGE_CURRENT);
                $itext = @$ipage['text'];
            }
            if (preg_match("/^#({$npat})?(\\.\\.)?(#({$npat})?)?\$/", $match[2], $m)) {
                @(list($x, $aa, $dots, $b, $bb) = $m);
                if (!$dots && !$b) {
                    $bb = $npat;
                }
                if ($aa) {
                    $itext = preg_replace("/^.*?([^\n]*\\[\\[#{$aa}\\]\\])/s", '$1', $itext, 1);
                }
                if ($bb) {
                    $itext = preg_replace("/(.)[^\n]*\\[\\[#{$bb}\\]\\].*\$/s", '$1', $itext, 1);
                }
            }
            continue;
        }
        if (in_array($k, array('line', 'lines', 'para', 'paras'))) {
            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;
        }
    }
    return PVS(htmlspecialchars(@$itext, ENT_NOQUOTES));
}
Ejemplo n.º 26
0
function TEFormMarkup($pagename, $arg)
{
    global $ExtractFormOpt, $InputValues;
    $opt = ParseArgs($arg);
    $PageUrl = PageVar($pagename, '$PageUrl');
    $opt = array_merge($ExtractFormOpt, $opt);
    $opt['action'] = 'search';
    $opt['fmt'] = 'extract';
    foreach ($opt as $key => $val) {
        if (!is_array($val)) {
            if (!isset($InputValues[$key])) {
                $InputValues[$key] = $opt[$val];
            }
        }
    }
    $req = array_merge($_GET, $_POST);
    foreach ($req as $k => $v) {
        if (!isset($InputValues[$k])) {
            $InputValues[$k] = htmlspecialchars(stripmagic($v), ENT_NOQUOTES);
        }
    }
    if (!$InputValues['q']) {
        $InputValues['q'] = $opt['pattern'];
    }
    if (!$InputValues['page']) {
        $InputValues['page'] = $opt['defaultpage'];
    }
    $checkword = $InputValues['word'] ? "checked=1" : '';
    $checkcase = $InputValues['case'] ? "checked=1" : '';
    $checkregex = $InputValues['regex'] ? "checked=1" : '';
    //form
    $out = "<form class='wikisearch' action='{$PageUrl}' method='post' >";
    $out .= "\n<table>";
    if ($opt['pattern']) {
        $out .= "<input type='hidden' name='q' value='{$InputValues['q']}' /> \n";
    } else {
        $out .= "<tr><td>{$opt['searchlabel']} </td><td><input type='{$type1}' name='q' value='{$InputValues['q']}' class='inputbox searchbox' size='{$opt['size']}' /> </td></tr> \n";
    }
    if ($opt['page']) {
        $out .= "<input type='hidden' name='page' value='{$InputValues['page']}' /> \n";
    } else {
        $out .= "<tr><td>{$opt['pageslabel']} </td><td><input type='text' name='page' value='{$InputValues['page']}' class='inputbox searchbox' size='{$opt['size']}' /> </td></tr> \n";
    }
    if (!$opt['pattern']) {
        $out .= "<tr><td></td><td><input type='checkbox' name='word' value='1' {$checkword}/> {$opt['wordlabel']}</td></tr>";
        $out .= "<tr><td></td><td><input type='checkbox' name='case' value='1' {$checkcase}/> {$opt['caselabel']}</td></tr>";
    }
    if ($opt['regex']) {
        $out .= "<tr><td></td><td><input type='checkbox' name='regex' value='1' {$checkregex}/> {$opt['regexlabel']}</td></tr>";
    }
    $out .= "<tr><td></td><td>&nbsp;&nbsp;&nbsp;&nbsp;<input type='submit' class='inputbutton searchbutton' value='{$opt['button']}' /></td></tr></table> \n";
    foreach ($opt as $k => $v) {
        if ($v == '' || is_array($v)) {
            continue;
        }
        if (in_array($k, array('pattern', 'page', 'defaultpage', 'q', 'label', 'value', 'size', 'searchlabel', 'pageslabel', 'wordlabel', 'caselabel', 'regexlabel', 'regex'))) {
            continue;
        }
        $k = str_replace("'", "&#039;", $k);
        $v = str_replace("'", "&#039;", $v);
        $out .= "\n<input type='hidden' name='" . $k . "' value='" . $v . "' />";
    }
    $out .= "</form>";
    return Keep($out);
}
Ejemplo n.º 27
0
function IncludeText($pagename, $inclspec)
{
    global $MaxIncludes, $IncludeBadAnchorFmt, $InclCount, $FmtV;
    SDV($MaxIncludes, 10);
    SDV($IncludeBadAnchorFmt, "include:\$FullName - #\$BadAnchor \$[not found]\n");
    $npat = '[[:alpha:]][-\\w]*';
    if ($InclCount++ >= $MaxIncludes) {
        return Keep($inclspec);
    }
    if (preg_match("/^include\\s+([^#\\s]+)(.*)\$/", $inclspec, $match)) {
        @(list($inclstr, $inclname, $opts) = $match);
        $inclname = MakePageName($pagename, $inclname);
        if ($inclname == $pagename) {
            return '';
        }
        $inclpage = RetrieveAuthPage($inclname, 'read', false);
        $itext = @$inclpage['text'];
        foreach (preg_split('/\\s+/', $opts) as $o) {
            if (preg_match("/^#({$npat})?(\\.\\.)?(#({$npat})?)?\$/", $o, $match)) {
                @(list($x, $aa, $dots, $b, $bb) = $match);
                if (!$dots && !$b) {
                    $bb = $npat;
                }
                if ($b == '#') {
                    $bb = $npat;
                }
                if ($aa) {
                    $itext = preg_replace("/^.*?([^\n]*\\[\\[#{$aa}\\]\\])/s", '$1', $itext, 1);
                }
                if ($bb) {
                    $itext = preg_replace("/(.)[^\n]*\\[\\[#{$bb}\\]\\].*\$/s", '$1', $itext, 1);
                }
                continue;
            }
            if (preg_match('/^(lines?|paras?)=(\\d*)(\\.\\.(\\d*))?$/', $o, $match)) {
                @(list($x, $unit, $a, $dots, $b) = $match);
                $upat = substr($unit, 0, 1) == '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;
            }
        }
        return htmlspecialchars($itext, ENT_NOQUOTES);
    }
    return Keep($inclspec);
}
Ejemplo n.º 28
0
 function include_file($pagename, $argstr)
 {
     global $UploadFileFmt, $UploadUrlFmt, $UploadPrefixFmt;
     global $IncludeUploadTextToHtmlCmd;
     global $IncludeUploadToHtmlCmd;
     global $UrlScheme, $IncludeUploadUrlFopenEnabled;
     global $HandleAuth, $AuthFunction;
     $args = ParseArgs($argstr);
     $path = $args[''] ? implode('', $args['']) : '';
     $class = $args['class'] ? $args['class'] : $this->class;
     $abs_url = '';
     # figure out the file path
     if (preg_match("/^\\s*\\//", $path)) {
         # a path was given, give it a http: path
         # so that this will honour Apache permissions
         # However, this will only work if allow_url_fopen is enabled.
         if ($IncludeUploadUrlFopenEnabled) {
             $http = $UrlScheme ? $UrlScheme : 'http';
             $filepath = $http . '://' . $_SERVER['HTTP_HOST'] . $path;
         } else {
             $filepath = $_SERVER['DOCUMENT_ROOT'] . $path;
         }
         // make the abs_url from the part of the URL minus the file
         $bits = explode("/", $filepath);
         array_pop($bits);
         $abs_url = implode('/', $bits);
         $abs_url .= '/';
     } else {
         if (preg_match('!^(.*)/([^/]+)$!', $path, $match)) {
             $pagename = MakePageName($pagename, $match[1]);
             $path = $match[2];
         }
         // permission check for accessing files from given page
         if (!$AuthFunction($pagename, $HandleAuth['includeupload'], false)) {
             return Keep("(:includeupload {$path}:) failed: access denied to include files from {$pagename}<br>\n");
         }
         $upname = MakeUploadName($pagename, $path);
         $filepath = FmtPageName("{$UploadFileFmt}/{$upname}", $pagename);
         $abs_url = PUE(FmtPageName("{$UploadUrlFmt}{$UploadPrefixFmt}", $pagename));
     }
     // read the file; if there was failure, the content is empty
     $filetext = $this->read_file($filepath);
     if ($filetext) {
         $ext = '';
         if (preg_match('!\\.(\\w+)$!', $filepath, $match)) {
             $ext = $match[1];
         }
         $filetype = $args['type'] ? $args['type'] : $ext;
         if ($IncludeUploadToHtmlCmd[$filetype]) {
             $command = $IncludeUploadToHtmlCmd[$filetype];
             $tempfile = $this->put_file($filetext);
             $fcont = `{$command} {$tempfile}`;
             $fcont = $this->extract_body($fcont);
             $fcont = $this->absolute_url($fcont, $abs_url);
             @unlink($tempfile);
             return Keep(($class ? "<div class='{$class}'>" : '<div>') . $fcont . '</div>');
         } else {
             if (preg_match('/htm.?/', $ext)) {
                 $fcont = $this->extract_body($filetext);
                 $fcont = $this->absolute_url($fcont, $abs_url);
                 return Keep(($class ? "<div class='{$class}'>" : '<div>') . $fcont . '</div>');
             } else {
                 // by default, treat as text and escape HTML chars
                 return Keep(($class ? "<pre class='{$class}'>" : '<pre>') . "filetype={$filetype}\n" . htmlspecialchars($filetext) . '</pre>');
             }
         }
     }
     # fall through
     return Keep("(:includeupload {$path}:) failed: Could not open {$filepath}<br>\n");
 }
Ejemplo n.º 29
0
function RedirectMarkup($pagename, $opt) {
  $k = Keep("(:redirect $opt:)");
  global $MarkupFrame;
  if (!@$MarkupFrame[0]['redirect']) return $k;
  $opt = ParseArgs($opt);
  $to = @$opt['to']; if (!$to) $to = @$opt[''][0];
  if (!$to) return $k;
  if (preg_match('/^([^#]+)(#[A-Za-z][-\\w]*)$/', $to, $match)) 
    { $to = $match[1]; $anchor = $match[2]; }
  $to = MakePageName($pagename, $to);
  if (!PageExists($to)) return $k;
  if ($to == $pagename) return '';
  if (@$opt['from'] 
      && !MatchPageNames($pagename, FixGlob($opt['from'], '$1*.$2')))
    return '';
  if (preg_match('/^30[1237]$/', @$opt['status'])) 
     header("HTTP/1.1 {$opt['status']}");
  Redirect($to, "{\$PageUrl}?from=$pagename$anchor");
  exit();
}
Ejemplo n.º 30
0
function MagpieRSS($regex)
{
    global $action;
    global $FarmD;
    global $MAGPIE_ERROR, $MagpieDebug;
    global $MagpieDefaultItems;
    global $MagpieDefaultShowHeader, $MagpieDefaultShowContent, $MagpieDefaultShowDate;
    if (!IsEnabled($MagpieDebug)) {
        $OriginalError_reportingLevel = error_reporting();
        error_reporting(0);
    }
    # If you make a call to your own site
    # and you have any kind of WritePage action ( Lock(2) ) for example
    # because you do some kind of logging in a wiki-page.
    # the whole thing will deadlock, so remove any locks.
    # ReadPage will request a lock again when needed
    Lock(-1);
    $line = "";
    if ($regex == '') {
        $line .= "Empty parameter in RSS ";
    } else {
        $tokens = preg_split("/\\s+/", $regex);
        $url = html_entity_decode($tokens[0]);
        $what = $MagpieDefaultShowContent;
        $num_items = $MagpieDefaultItems;
        $showheader = $MagpieDefaultShowHeader;
        $showdate = $MagpieDefaultShowDate;
        foreach ($tokens as $t) {
            if ($t == 'long') {
                $what = true;
            }
            if ($t == 'short') {
                $what = false;
            }
            if ($t == 'header') {
                $showheader = true;
            }
            if ($t == 'noheader') {
                $showheader = false;
            }
            if ($t == 'date') {
                $showdate = true;
            }
            if ($t == 'nodate') {
                $showdate = false;
            }
            if (is_numeric($t)) {
                $num_items = intval($t);
            }
        }
        if ($action && $action != 'browse') {
            # this is important
            #pmwiki processes DoubleBrackets in the rss module
            #recursion untill the server blows
            $line .= "RSS Feed : {$url}";
        } else {
            MagpieRssPhpInclude();
            $rss = fetch_rss($url);
            if ($rss) {
                $title = $rss->channel['title'];
                $link = $rss->channel['link'];
                if ($showheader) {
                    $line .= "<h2 class='rss'>RSS feed: <a href='{$link}'>{$title}</a></h2>\n";
                }
                if ($num_items >= 0) {
                    $items = array_slice($rss->items, 0, $num_items);
                } else {
                    $items = $rss->items;
                }
                foreach ($items as $item) {
                    #print_r ($item);
                    $href = $item['link'];
                    $title = $item['title'];
                    $description = "-- empty -- ";
                    if (isset($item['description'])) {
                        $description = $item['description'];
                    }
                    if (isset($item['atom_content'])) {
                        $description = $item['atom_content'];
                    }
                    $link = "<a class='urllink' href='{$href}'>{$title}</a>";
                    $line .= "<h3 class='magpie-title'>{$link}</h3>\n";
                    if ($showdate) {
                        $date = MagpieRSSDate($item);
                        $line .= "{$date} \n";
                    }
                    if ($what) {
                        $line .= "<div class=\"magpie-desc\">{$description}</div>\n";
                    }
                    //if
                }
                //foreach
            } else {
                $line .= "<tt>{$MAGPIE_ERROR}</tt>";
            }
        }
        //else
    }
    if (!IsEnabled($MagpieDebug)) {
        error_reporting($OriginalError_reportingLevel);
    }
    $line = "<div class='magpie-rss'>{$line}</div>";
    $rss_link = "\n%right% [[{$url}|RSS]]\n";
    return Keep($line) . $rss_link;
}