示例#1
0
    $_REQUEST['title'] = pieGetOption($_REQUEST['title']);
    $_REQUEST['comment'] = pieGetOption($_REQUEST['comment']);
} elseif (file_exists($preview)) {
    // Read source and meta data from temporary preview file.
    if (!($dump = file_get_contents($preview))) {
        pieError("SourceReadError");
    }
    $meta = pieExplodePage($dump);
    foreach (array('source', 'title', 'comment') as $i) {
        $_REQUEST[$i] = $meta[$i];
    }
    unset($meta);
} elseif ($page->exists($_REQUEST['page'])) {
    // The page already exists. Use and edit the existing source.
    $diff = new Increment();
    if (!($meta = $diff->readPage($_REQUEST['page'], $_REQUEST['stamp']))) {
        pieError("SourceVersionMissing");
    }
    $_REQUEST['source'] = $meta['source'];
    if ($_REQUEST['section'] > 0) {
        $section = new Section();
        // Extract the specified section.
        if (($_REQUEST['source'] = $section->extract($meta['source'], $_REQUEST['section'])) === false) {
            pieError('SectionNotFound');
        }
    }
    if ($meta['type'] == "alias") {
        // The existing page is an alias.
        if ($_REQUEST['overwrite']) {
            // Replace the alias by a new page.
            $_REQUEST['source'] = '';
示例#2
0
$_REQUEST['page'] = pieGetOption(@$_REQUEST['page']);
$_REQUEST['old'] = intval(@$_REQUEST['old']);
$_REQUEST['new'] = intval(@$_REQUEST['new']);
if (!@$_REQUEST['sort']) {
    $_REQUEST['sort'] = 'descending';
}
$page = new Page();
if (!$page->isValidName(@$_REQUEST['page'])) {
    pieError('PageNameInvalid');
}
if (!$page->exists(@$_REQUEST['page'])) {
    pieError('PageNotFound');
}
if (@$_REQUEST['old'] > 0 && @$_REQUEST['new'] > 0) {
    $diff = new Increment();
    if (!($old = $diff->readPage($_REQUEST['page'], $_REQUEST['old']))) {
        pieError('SourceVersionMissing');
    }
    if (!($new = $diff->readPage($_REQUEST['page'], $_REQUEST['new']))) {
        pieError('SourceVersionMissing');
    }
    $cache = new Cache();
    $cid = $cache->key('diff', array('old' => $_REQUEST['old'], 'new' => $_REQUEST['new']));
    if ($GLOBALS['pie']['query_caching'] && $cache->exists($cid)) {
        // Use existing cache.
        $data = file_get_contents($cache->file($cid));
        $cache->update($cid);
    } else {
        // Create diff from two versions.
        if (!($data = $diff->diff($old['source'], $new['source']))) {
            pieError('DiffError');