Beispiel #1
0
function pieMakeLink($text, $urldata, $linkspec = array())
{
    $spec = "";
    if (count($linkspec)) {
        // Customizations of the link element.
        foreach ($linkspec as $k => $v) {
            $spec .= " {$k}=\"{$v}\"";
        }
    }
    // A link to a local page:
    if ((!$urldata['action'] || $urldata['action'] == 'page') && $urldata['page'] && !@$urldata['stamp']) {
        // Don't escape the short form.
        if (substr($GLOBALS['pie']['page_link'], -10) != '?[[$page]]') {
            $urldata['page'] = urlencode($urldata['page']);
        }
        return "<a{$spec} href=\"" . pieMakeString($GLOBALS['pie']['page_link'], $urldata) . "\">{$text}</a>";
    } elseif ($urldata['action'] == "download" && $urldata['file'] && !@$urldata['stamp']) {
        $urldata['file'] = urlencode($urldata['file']);
        return "<a{$spec} href=\"" . pieMakeString($GLOBALS['pie']['file_link'], $urldata) . "\">{$text}</a>";
    } elseif ($urldata['action'] == "dump" && $urldata['file'] && !@$urldata['stamp']) {
        $urldata['file'] = urlencode($urldata['file']);
        return "<a{$spec} href=\"" . pieMakeString($GLOBALS['pie']['media_link'], $urldata) . "\">{$text}</a>";
    } else {
        $param = array();
        foreach ($urldata as $k => $v) {
            $param[] = "{$k}=" . urlencode($v);
        }
        return "<a{$spec} href=\"" . pieMakeString($GLOBALS['pie']['base_link']) . implode("&amp;", $param) . "\">{$text}</a>";
    }
}
Beispiel #2
0
<?php

/*
 *	Switch the user environment to the specified mode.
 */
include_once "{$lib}/share/stdio.php";
if (is_array($_SESSION)) {
    switch (@$_REQUEST['context']) {
        case 'browse':
        case 'edit':
            $_SESSION['context'] = $_REQUEST['context'];
            break;
    }
}
if (@$_REQUEST['page']) {
    $_REQUEST['action'] = 'page';
    include "{$lib}/action/page.php";
} elseif (@$_REQUEST['file']) {
    $_REQUEST['action'] = 'fileinfo';
    include "{$lib}/action/fileinfo.php";
} elseif ($GLOBALS['pie']['auto_redirect']) {
    // Redirect to default page.
    include_once "{$lib}/share/string.php";
    header("Location: " . pieMakeString($GLOBALS['pie']['redirect_page_url'], array('page' => rawurlencode($GLOBALS['pie']['default_page']))));
} else {
    pieHead();
    pieError("AliasRedirect", array('page' => htmlspecialchars($GLOBALS['pie']['default_page'])));
}
Beispiel #3
0
                    $referers[$name]++;
                }
            }
        }
    }
    if (!count($referers)) {
        pieError("NoDeadLinks");
    }
    pieNotice("ListOfPages");
    pieNotice("RefererTableHead");
    arsort($referers);
    $n = 0;
    $hint_info = $GLOBALS['pie']['locale']->key("Info");
    $hint_show = $GLOBALS['pie']['locale']->key("Show");
    $hint_edit = $GLOBALS['pie']['locale']->key("Edit");
    $ip = pieMakeString('[[$^icon_link]]');
    foreach ($referers as $name => $i) {
        $n++;
        print '<tr class="' . ($n % 2 ? "oddRow" : "evenRow") . '">' . '<td>' . pieMakeLink(htmlspecialchars($name), array('page' => $name), array('class' => "itemLink")) . '</td>' . "<td style=\"text-align: right;\">{$i}</td>" . '<td>' . pieMakeLink("<img src=\"{$ip}/information.png\" />", array('action' => "pageinfo", 'page' => $name), array('title' => $hint_info)) . '</td>' . '<td>' . pieMakeLink("<img src=\"{$ip}/page_edit.png\" />", array('action' => "edit", 'page' => $name), array('title' => $hint_edit)) . '</td>' . "</tr>\n";
    }
    print "</table>\n";
} elseif (@$_REQUEST['mode'] == "links") {
    // Walk all pages and examine their links.
    // Collect a list of _links_, i. e. destinations of broken links.
    $page = new Page();
    $file = new File();
    $deadpages = array();
    $deadfiles = array();
    for ($name = $page->first(); $name; $name = $page->next()) {
        if (!$page->read($name, 0)) {
            pieError("SourceReadError");
Beispiel #4
0
$file = new File();
if (!$file->isValidName($_REQUEST['file'])) {
    pieErrorImage();
}
if (!$file->exists($_REQUEST['file'])) {
    pieErrorImage();
}
$_REQUEST['stamp'] = abs(intval(@$_REQUEST['stamp']));
$_REQUEST['size'] = abs(intval(@$_REQUEST['size']));
if (!$file->read($_REQUEST['file'], $_REQUEST['stamp'])) {
    pieErrorImage();
}
// Check for alias:
while ($file->meta['type'] == "alias") {
    if ($GLOBALS['pie']['auto_redirect']) {
        header("Location: " . pieMakeString($GLOBALS['pie']['redirect_media_url'], array('file' => rawurlencode($file->meta['original']))));
        exit;
    } else {
        // Try to resolve the alias myself.
        if (!$file->read($file->meta['original'], 0)) {
            pieErrorImage();
        }
    }
}
if (@$_REQUEST['size'] > 0) {
    $max = $_REQUEST['size'];
} elseif ($GLOBALS['pie']['max_image_size']) {
    $max = intval($GLOBALS['pie']['max_image_size']);
} else {
    $max = 256;
}
Beispiel #5
0
 function expandCommand($string)
 {
     // Split the components, i. e. the command and its argument(s)
     $string = trim($string);
     if (strpos($string, $GLOBALS['pie']['link_text_delimiter']) > 0) {
         list($cmd, $data) = explode($GLOBALS['pie']['link_text_delimiter'], $string, 2);
         $data = preg_split('/\\s+/', $data);
     } else {
         $cmd = preg_replace('/\\s+/', ' ', $string);
         $data = array();
     }
     if (!preg_match('/^(\\w+):(.+)$/', $cmd, $match)) {
         return $string;
     }
     $cmd = mb_strtolower($match[1]);
     $arg = $match[2];
     if (trim($data[0]) == '') {
         $data = array();
     }
     // Command multiplexer:
     switch ($cmd) {
         case 'page':
         case $this->commands['Page']:
             // Link placement via command:
             // [page:<PageName> ...]
             return $this->expandLink($arg . $GLOBALS['pie']['link_text_delimiter'] . implode(' ', $data));
             break;
         case 'link':
         case $this->commands['Link']:
             // Enforce link to external resource:
             $text = htmlspecialchars(implode(' ', $data));
             if (count($data)) {
                 return '<a href="' . htmlspecialchars($arg) . '" title="' . htmlspecialchars($arg) . '" target="_blank">' . htmlspecialchars(implode(' ', $data)) . '</a>';
             } else {
                 return '<a href="' . htmlspecialchars($arg) . '" target="_blank">' . htmlspecialchars($arg) . '</a>';
             }
             break;
         case 'mail':
         case 'mailto':
             // Link to an e-mail address:
             // [mail:<Address> ...]
             if (preg_match('/^[\\w\\.\\-_]+@' . HOST_PATTERN . '$/', $arg)) {
                 if (count($data)) {
                     $alt = htmlspecialchars(implode(' ', $data));
                 } else {
                     $alt = htmlspecialchars($arg);
                 }
                 return "<a href=\"mailto:{$arg}\" class=\"mailLink\">{$alt}</a>";
             } else {
                 $this->trapError('InvalidMailLink', $arg);
                 return '';
             }
             break;
         case 'file':
         case $this->commands['File']:
             // Link to a local file:
             // [file:<FileName> ...]
             if ($path = $this->expandGroupPath($GLOBALS['pie']['file_link_pattern'], $arg)) {
                 if (count($data) > 0) {
                     $text = implode(' ', $data);
                 } else {
                     if (preg_match('/^(.+)\\.[0-9A-Za-z]{1,5}$/', $path, $match)) {
                         $text = $match[1];
                     } else {
                         $text = $path;
                     }
                 }
                 $path = pieBeautifyName($path);
                 $this->files[$path]++;
                 return pieMakeLink(htmlspecialchars($text), array('action' => 'download', 'file' => $path), array('class' => 'fileLink', 'title' => htmlspecialchars($path)));
             } else {
                 $this->trapError('InvalidFileLink', $arg);
                 return '';
             }
             break;
         case 'image':
         case $this->commands['Image']:
             // Embeds a local file as an image:
             // [image:<ImageName> ...]
             if (preg_match('/^' . URL_PATTERN . '$/', $arg)) {
                 return $this->expandImage($arg, array_map('htmlspecialchars', $data));
             } elseif ($path = $this->expandGroupPath($GLOBALS['pie']['file_link_pattern'], $arg)) {
                 $path = pieBeautifyName($path);
                 $this->files[$path]++;
                 return $this->expandImage(pieMakeString($GLOBALS['pie']['media_link'], array('action' => 'image', 'file' => urlencode($path))), array_map('htmlspecialchars', $data));
             } else {
                 $this->trapError('InvalidImageLink', $arg);
                 return '';
             }
             break;
         case 'figure':
         case $this->commands['Figure']:
         case 'preview':
         case $this->commands['Preview']:
             // Embeds a thumbnail of an image that acts as a link
             // to the full-sized version.
             // [figure:<ImageName> ...]
             unset($caption);
             if (count($data)) {
                 $info = htmlspecialchars(implode(' ', $data));
             }
             $data = array('.figure', $this->locale->key('ShowFullSized'));
             $caption = $info ? "<p class=\"caption\">{$info}</p>\n" : '';
             if (preg_match('%^https?://%', $arg)) {
                 return "<div class=\"figure\">\n" . "<p><a href=\"{$arg}\" target=\"_blank\" title=\"" . $this->locale->key('ShowExternalResource') . "\"><img src=\"{$arg}\" alt=\"{$info}\" width=\"" . $GLOBALS['pie']['max_image_size'] . "\" /></a></p>\n" . "{$caption}</div>\n";
             } elseif ($path = $this->expandGroupPath($GLOBALS['pie']['file_link_pattern'], $arg)) {
                 $path = pieBeautifyName($path);
                 $this->files[$path]++;
                 $link = pieMakeString($GLOBALS['pie']['base_link'] . 'action=image&amp;file=' . urlencode($path));
                 $link = "<img src=\"{$link}\"  alt=\"" . $GLOBALS['pie']['media_alt_text'] . '" title="' . $this->locale->key('ShowFullSized') . '" />';
                 $link = pieMakeLink($link, array('action' => 'dump', 'file' => $path), array('class' => 'figure', 'target' => '_blank'));
                 return "<div class=\"figure\">\n<p>{$link}</p>\n{$caption}</div>\n";
             } else {
                 $this->trapError('InvalidImageLink', $arg);
                 return '';
             }
             break;
         case 'embed':
         case 'media':
         case $this->commands['Embed']:
         case $this->commands['Media']:
             // Embeds a local file as media:
             // [embed:<FileName> ...]
             $spec = '';
             if (preg_match('/^' . URL_PATTERN . '$/', $arg)) {
                 $path = htmlspecialchars($arg);
             } elseif ($path = $this->expandGroupPath($GLOBALS['pie']['file_link_pattern'], $arg)) {
                 $path = pieBeautifyName($path);
                 $this->files[$path]++;
                 $path = pieMakeString($GLOBALS['pie']['media_link'], array('action' => 'dump', 'file' => urlencode($path)));
             } else {
                 $this->trapError('InvalidEmbeddedObject', $arg);
                 return '';
             }
             foreach ($data as $i) {
                 if (preg_match('/^(\\w+)="?([^"]+)"?$/', $i, $match)) {
                     $spec .= " {$match['1']}=\"" . htmlspecialchars($match[2]) . '"';
                 }
             }
             return "<embed src=\"{$path}\" alt=\"" . $GLOBALS['pie']['media_alt_text'] . '"' . ($spec ? $spec : "") . "></embed>";
             break;
         case 'anchor':
         case $this->commands['Anchor']:
             // Local anchor
             // [anchor:<AnchorName>]
             return '<a name="' . htmlspecialchars($arg) . '"></a>';
             break;
         case 'class':
         case $this->commands['Class']:
         case 'style':
         case $this->commands['Style']:
             // Class definition for a local environment:
             // a span, if there are arguments to be applied to
             // or a customization for the next block.
             // [class:<ClassName> ...]
             if (count($data)) {
                 return "<span class=\"{$arg}\">" . htmlspecialchars(implode(" ", $data)) . "</span>";
             } elseif ($arg) {
                 $this->custom['class'] = htmlspecialchars($arg);
             }
             return '';
             break;
         case 'begin':
         case $this->commands['Begin']:
             // Begin of a customized environmental DIV.
             // [begin:<kind_of_environment> ...]
             if ($arg[0] == '.') {
                 // Named CSS class.
                 array_unshift($this->nest, 'div');
                 return '<div class="' . substr($arg, 1) . "\">\n";
             } elseif ($arg == 'figure' || $arg == $this->locale->key('Figure')) {
                 // Figure.
                 array_unshift($this->nest, 'div');
                 return "<div class=\"figure\">\n";
             } else {
                 // Unspecified or unknown block type.
                 array_unshift($this->nest, 'div');
                 return "<div>\n";
             }
             break;
         case 'end':
         case $this->commands['End']:
             // Close an customized environmental context block.
             // [end:block]
             if (count($this->nest)) {
                 array_shift($this->nest);
                 return $this->endEnvironment() . "</div>\n";
             } else {
                 $this->trapError('NestingNotWellFormed', $arg);
                 return '';
             }
             break;
         case 'footnote':
         case $this->commands['Footnote']:
             array_push($this->footnotes, $arg);
             $t = count($this->footnotes);
             if (count($data)) {
                 return "<a name=\"ref{$t}\"></a><a href=\"#footnote{$t}\" title=\"" . $this->locale->key("Footnote") . '">' . htmlspecialchars(implode(" ", $data)) . "</a>";
             } else {
                 return "<a name=\"ref{$t}\"></a><a href=\"#footnote{$t}\" title=\"" . $this->locale->key("Footnote") . "\">[{$t}]</a>";
             }
             break;
         case 'abbr':
         case $this->commands['Abbr']:
             return '<abbr title="' . htmlspecialchars(implode(' ', $data)) . '">' . htmlspecialchars($arg) . '</abbr>';
             break;
         default:
             $this->trapError('UnknownCommand', $cmd);
             return '';
             break;
     }
     $this->trapError('InvalidCommand', $cmd);
     return '';
 }
Beispiel #6
0
<?php

/*
 *	Alias for action 'page'.
 *	Kept for compatibility reasons.
 */
include_once "{$lib}/class/page.php";
include_once "{$lib}/class/cache.php";
include_once "{$lib}/share/string.php";
include_once "{$lib}/share/stdio.php";
header('Location: ' . pieMakeString($GLOBALS['pie']['redirect_base_url']) . '?action=page&page=' . rawurlencode(@$_REQUEST['page']));
Beispiel #7
0
    $data['type'] = $GLOBALS['pie']['locale']->key("BinaryFile");
}
if (preg_match('%^(\\w+)/.*$%', $file->meta['type'], $match)) {
    $data['kind'] = $GLOBALS['pie']['locale']->key(ucfirst($match[1]) . 'File');
}
if ($file->meta['comment']) {
    $data['comment'] = htmlspecialchars($file->meta['comment']);
} else {
    $data['comment'] = "&mdash;";
}
$history = $file->history($file->name);
$data['history_count'] = count($history);
$t = 0;
ksort($history);
$n = 0;
foreach ($history as $k => $v) {
    $n++;
    if ($stamp == $k) {
        break;
    }
}
$data['history_index'] = $n;
// Present results:
pieNotice("FileInfo", $data);
switch ($file->meta['type']) {
    case 'image/jpeg':
    case 'image/gif':
    case 'image/png':
        print '<p>' . $GLOBALS['pie']['locale']->key('ImagePreview') . ":</p>\n" . "<p>" . pieMakeLink("<img src=\"" . pieMakeString($GLOBALS['pie']['base_link'], array('action' => 'image', 'file' => urlencode($file->name))) . "action=image&amp;file=" . urlencode($file->name) . '" />', array('action' => 'dump', 'file' => $file->name), array('target' => '_blank', 'title' => $GLOBALS['pie']['locale']->key('ShowFullSized'))) . "</p>\n";
}
pieTail();
Beispiel #8
0
print '<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
	<channel>
';
if (file_exists($GLOBALS['pie']['custom_path'] . '/rss_head.xml')) {
    include $GLOBALS['pie']['custom_path'] . '/rss_head.xml';
} else {
    print '		<title>RSS Feed</title>
		<link>http://' . $_SERVER['SERVER_NAME'] . '/</link>
		<language>' . $GLOBALS['pie']['default_locale'] . '</language>
		<generator>pie</generator>
		<webMaster>' . $_SERVER['SERVER_ADMIN'] . '</webMaster>
';
}
list($stamp) = explode("\t", $data[0]);
print "\t\t<pubDate>" . date('r', $stamp) . "</pubDate>\n";
foreach ($data as $i) {
    list($stamp, $p) = explode("\t", $i, 2);
    if (!$page->read($p, 0)) {
        continue;
    }
    if ($page->meta['type'] == 'alias') {
        continue;
    }
    if (substr($GLOBALS['pie']['page_link'], -10) != '?[[$page]]') {
        $p = urlencode($p);
    }
    $link = 'http://' . $_SERVER['SERVER_NAME'] . ($GLOBALS['pie']['page_link'][0] == '/' ? '' : '/') . pieMakeString($GLOBALS['pie']['page_link'], array('page' => $p));
    print "\t\t<item>\n" . "\t\t\t<title>" . htmlspecialchars($page->meta['title']) . "</title>\n" . "\t\t\t<link>" . $link . "</link>\n" . "\t\t\t<description>" . ($page->meta['comment'] ? htmlspecialchars($page->meta['comment']) : '') . "</description>\n" . "\t\t\t<author>" . htmlspecialchars($page->meta['author']) . "</author>\n" . "\t\t\t<pubDate>" . date('r', $page->meta['stamp']) . "</pubDate>\n" . "\t\t\t<guid>{$link}</guid>\n" . "\t\t</item>\n";
}
print "\t</channel>\n</rss>\n";
Beispiel #9
0
 function string($string, $data)
 {
     while (preg_match('/^(.*)\\[\\[(\\w+)\\]\\](.*)$/s', $string, $match)) {
         $string = $match[1] . $this->key($match[2]) . $match[3];
     }
     return pieMakeString($string, $data);
 }
Beispiel #10
0
if (!$page->exists($_REQUEST['page'])) {
    // Requested page not available
    header("HTTP/1.0 404 Not Found");
    pieHead();
    pieError("PageNotFound");
}
if (!$page->read($_REQUEST['page'], 0)) {
    pieHead();
    pieError("SourceReadError");
}
// Handle aliases:
if ($page->meta['type'] == "alias") {
    $original = $page->meta['original'];
    if ($GLOBALS['pie']['auto_redirect']) {
        include_once "{$lib}/share/string.php";
        header("Location: " . pieMakeString($GLOBALS['pie']['redirect_base_url']) . "?action=page&page=" . rawurlencode($original) . "&referer=" . rawurlencode($_REQUEST['page']));
        exit;
    } else {
        pieHead();
        pieError("AliasRedirect", array('page' => htmlspecialchars($original), 'alias' => htmlspecialchars($_REQUEST['page'])));
    }
}
// Compile source:
pieHead();
include_once "{$lib}/compiler/html.php";
$compiler = new htmlCompiler();
$compiler->source = $page->source;
if ($GLOBALS['pie']['page_header'] || $GLOBALS['pie']['page_footer']) {
    // Header and footer require meta data.
    $compiler->meta = $page->meta;
}