Beispiel #1
0
 function makeAlias($original)
 {
     if (file_exists($this->_filePath($this->name))) {
         // A file (i. e. page or alias) with this name exists.
         if (!($info = $this->_current($this->name))) {
             return false;
         }
         // We cannot create an alias whose name is already
         // taken by a page.
         if ($info['type'] != 'alias') {
             return false;
         }
     }
     // Prepare all necessary meta data, complementing the
     // customized entries.
     if (!$this->meta['stamp']) {
         $this->meta['stamp'] = time();
     }
     $this->meta['type'] = 'alias';
     $this->meta['original'] = pieBeautifyName($original);
     if (!($f = fopen($this->_filePath($this->name), 'w'))) {
         return false;
     }
     fwrite($f, pieImplodePage($this->meta, ''));
     fclose($f);
     return true;
 }
Beispiel #2
0
$preview = pieTempName("_preview");
if (!$page->isValidName($page->name)) {
    pieError("PageNameInvalid");
}
if (!$page->lock($GLOBALS['pie']['user'])) {
    pieError("PageLockError");
}
// Retrieve the source:
if (@$_REQUEST['source']) {
    // Save the provided data to a temporary file.
    $_REQUEST['source'] = pieCleanString($_REQUEST['source']);
    $data = array('title' => pieGetOption($_REQUEST['title']), 'section' => intval($_REQUEST['section']), 'comment' => pieGetOption($_REQUEST['comment']));
    if (!($f = fopen($preview, "w"))) {
        pieError("SourceWriteError");
    }
    if (fwrite($f, pieImplodePage($data, $_REQUEST['source'])) === false) {
        pieError('SourceWriteError');
    }
    fclose($f);
} elseif (file_exists($preview)) {
    // Read the data from the temporary preview file.
    if (!($dump = file_get_contents($preview))) {
        pieError("SourceReadError");
    }
    $meta = pieExplodePage($dump);
    $_REQUEST['source'] = trim($meta['source']);
} else {
    // No source available.
    pieError("SourceReadError");
}
// Handle partial updates.