コード例 #1
0
ファイル: useredit.php プロジェクト: rafsoaken/piewiki
        $pref->write($user, 'realname', pieGetOption(@$_REQUEST['realname']));
    }
    if ($_REQUEST['mail']) {
        $pref->write($user, 'mail', pieGetOption(@$_REQUEST['mail']));
    }
    if ($_REQUEST['cols']) {
        $pref->write($user, 'cols', intval(@$_REQUEST['cols']));
    }
    if ($_REQUEST['rows']) {
        $pref->write($user, 'rows', intval(@$_REQUEST['rows']));
    }
    pieLog("user");
    pieNotice("UpdateSuccessful");
} else {
    // Display the form.
    $data = array('user' => htmlspecialchars($user), 'admin' => "—", 'registered' => 0, 'cols' => 80, 'rows' => 20);
    $map = new MapFile();
    $data['lastlogin'] = date($GLOBALS['pie']['time_format'], $map->read($GLOBALS['pie']['run_path'] . "/user/login.map", $user));
    $data['updated'] = date($GLOBALS['pie']['time_format'], $pref->read($user, 'stamp'));
    $data['registered'] = date($GLOBALS['pie']['time_format'], $pref->read($user, 'registered'));
    if (pieIsSuperuser($user)) {
        $data['admin'] = "√";
    }
    foreach (array('realname', 'mail', 'cols', 'rows') as $i) {
        if (($val = $pref->read($user, $i)) !== false) {
            $data[$i] = $val;
        }
    }
    pieNotice("PreferencesForm", $data);
}
pieTail();
コード例 #2
0
ファイル: deadlinks.php プロジェクト: rafsoaken/piewiki
    if (!count($deadpages) && !count($deadfiles)) {
        pieError("NoDeadLinks");
    }
    pieNotice("ListOfDeadLinks");
    if (count($deadpages)) {
        pieNotice("PageTableHead");
        arsort($deadpages);
        $n = 0;
        foreach ($deadpages as $name => $i) {
            $n++;
            print '<tr class="' . ($n % 2 ? "oddRow" : "evenRow") . '">' . '<td>' . pieMakeLink(htmlspecialchars($name), array('action' => "edit", 'page' => $name), array('class' => "itemLink")) . '</td>' . "<td style=\"text-align: right;\">{$i}</td></tr>\n";
        }
        print "</table>\n";
    }
    if (count($deadfiles)) {
        if (count($deadpages)) {
            print "<br />\n";
        }
        pieNotice("FileTableHead");
        arsort($deadfiles);
        $n = 0;
        foreach ($deadfiles as $name => $i) {
            $n++;
            print '<tr class="' . ($n % 2 ? "oddRow" : "evenRow") . '">' . '<td>' . pieMakeLink(htmlspecialchars($name), array('action' => "upload", 'file' => $name, 'create' => "true"), array('class' => "itemLink")) . '</td>' . "<td style=\"text-align: right;\">{$i}</td></tr>\n";
        }
        print "</table>\n";
    }
} else {
    pieNotice("SelectForm");
}
pieTail();
コード例 #3
0
ファイル: edit.php プロジェクト: rafsoaken/piewiki
        }
        if (!($dump = file_get_contents("{$path}/{$file}"))) {
            pieError("NoTemplates");
        }
        $meta = pieExplodePage($dump);
        $list[$file] = $meta['title'];
    }
    closedir($dh);
    asort($list);
    // Present available templates.
    $l = "";
    foreach ($list as $file => $info) {
        $l .= "<option value=\"{$file}\">" . htmlspecialchars($info) . "</option>\n";
    }
    pieError("TemplateList", array('templates' => $l));
} else {
    // Create a new, empty page.
    $_REQUEST['source'] = '';
}
// Initialize and print editing form.
if (empty($_REQUEST['source'])) {
    if ($GLOBALS['pie']['page_header']) {
        $_REQUEST['title'] = str_replace('_', ' ', $_REQUEST['page']);
    }
    $_REQUEST['comment'] = $GLOBALS['pie']['locale']->key('InitialVersion');
}
pieNotice("EditScript");
pieNotice("CharacterPanel");
pieNotice("EditPanel");
pieNotice("PageEdit");
pieTail("edit");
コード例 #4
0
ファイル: search.php プロジェクト: rafsoaken/piewiki
        }
        if ($page->meta['comment']) {
            if ($n = preg_match_all($pattern, $page->meta['comment'], $m)) {
                $result[$name] += 2 * $n * $val;
            }
        }
        if ($page->meta['type'] == "alias") {
            continue;
        }
        // Examine the source (of the page).
        if ($n = preg_match_all($pattern, $page->source, $m)) {
            $result[$name] += 2 * $n * $val;
        }
    }
    if (!count($result)) {
        pieError("NoMatches");
    }
    // Present the results:
    arsort($result);
    reset($result);
    list($n, $val) = each($result);
    pieNotice("TableHead");
    $i = 0;
    foreach ($result as $p => $n) {
        $i++;
        print '<tr class="' . ($i % 2 ? "oddRow" : "evenRow") . '">' . "<td>" . pieMakeLink(htmlspecialchars($p), array('page' => $p), array('class' => "itemLink")) . "</td>" . '<td><hr class="gauge" style="width: ' . sprintf("%.2f", $n * 10 / $val) . 'em;" /></td>' . "</tr>\n";
    }
    pieNotice("TableFooter");
} else {
}
pieTail();
コード例 #5
0
ファイル: edit_head.php プロジェクト: rafsoaken/piewiki
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr">
<head>
<title>Pie (Edit Mode)</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="Content-Language" content="en">
<link rel="stylesheet" type="text/css" href="css/common.css" />
<link rel="stylesheet" type="text/css" href="css/edit.css" media="screen" />
<link rel="stylesheet" type="text/css" href="css/print.css" media="print" />
</head>

<body>
<div id="control">
<ul>
<?php 
pieNotice("MenuRoot");
if (@$_REQUEST['page']) {
    pieNotice("MenuPage");
} elseif (@$_REQUEST['file']) {
    pieNotice("MenuFile");
}
pieNotice("MenuDirectory");
pieNotice("MenuUser");
?>
</ul>
</div>

<div id="content">
コード例 #6
0
ファイル: pageimport.php プロジェクト: rafsoaken/piewiki
        }
        $total++;
    }
    // Walk directory for the second time. This time, encountered
    // files (and pages contained therein) are imported for real.
    rewinddir($dh);
    while (($file = readdir($dh)) !== false) {
        if ($file == "." || $file == "..") {
            continue;
        }
        if (!importFile($_REQUEST['path'] . "/{$file}")) {
            pieError("ImportError", array('page' => htmlspecialchars($file)));
        }
        $count++;
    }
} elseif (is_readable($_REQUEST['path'])) {
    // Just one file is to be imported.
    if (!importFile($_REQUEST['path'])) {
        pieError("ImportError", array('page' => htmlspecialchars($_REQUEST['path'])));
    }
    $total = 1;
    $count = 1;
}
// Update the cache.
$cache = new Cache();
if ($cache->exists($cache->key('latest', array()))) {
    $cache->delete($cache->key('latest', array()));
}
pieLog("alter");
pieNotice("ImportSuccess", array('total' => $total, 'count' => $count));
pieTail();
コード例 #7
0
ファイル: filelist.php プロジェクト: rafsoaken/piewiki
    $n++;
}
// Print the files:
$hint_show = $GLOBALS['pie']['locale']->key("Show");
$hint_info = $GLOBALS['pie']['locale']->key("Info");
$hint_download = $GLOBALS['pie']['locale']->key("Download");
$hint_update = $GLOBALS['pie']['locale']->key("Update");
$ip = pieMakeString('[[$^icon_link]]');
pieNotice("TableHead", array('order' => $_REQUEST['order'] == "ascend" ? "descend" : "ascend"));
while (($item = each($data)) && $n < $_REQUEST['offset'] + $_REQUEST['limit']) {
    print '<tr class="' . ($n % 2 ? "oddRow" : "evenRow") . "\">\n" . "<td>" . pieMakeLink(htmlspecialchars($item[0]), array('action' => "fileinfo", 'file' => $item[0]), array('title' => $hint_info, 'class' => "itemLink")) . "</td>\n" . "<td>" . date($GLOBALS['pie']['time_format'], $item[1]) . "</td>\n" . "<td>" . pieMakeLink("<img src=\"{$ip}/information.png\" alt=\"" . $hint_info . '" />', array('file' => $item[0], 'action' => "fileinfo"), array('title' => $hint_info)) . "</td>\n" . "<td>" . pieMakeLink("<img src=\"{$ip}/eye.png\" alt=\"" . $hint_show . '" />', array('file' => $item[0], 'action' => "dump"), array('title' => $hint_show, 'target' => "_blank")) . "</td>\n" . "<td>" . pieMakeLink("<img src=\"{$ip}/download.png\" alt=\"" . $hint_download . '" />', array('file' => $item[0], 'action' => "download"), array('title' => $hint_download, 'target' => "_blank")) . "</td>\n" . "<td>" . pieMakeLink("<img src=\"{$ip}/upload.png\" alt=\"" . $hint_update . '" />', array('file' => $item[0], 'action' => "upload"), array('title' => $hint_update)) . "</td>\n" . "</tr>\n";
    $n++;
}
print "</table>\n";
// Navigation for long lists.
$data = array('prev' => 0, 'next' => 0);
if ($_REQUEST['offset'] > 0) {
    $data['prev'] = $_REQUEST['offset'] - $_REQUEST['limit'];
    $data['prev'] = max(0, $data['prev']);
} else {
    $data['no_prev'] = 'disabled="disabled"';
}
if ($n < $max) {
    $data['next'] = $n;
} else {
    $data['no_next'] = 'disabled="disabled"';
}
if (count($data) != 4) {
    pieNotice("BackAndForth", $data);
}
pieTail();
コード例 #8
0
ファイル: latest.php プロジェクト: rafsoaken/piewiki
$n = 1;
$hint_alias = $GLOBALS['pie']['locale']->key("Alias");
$hint_info = $GLOBALS['pie']['locale']->key("Details");
pieNotice("TableHead");
foreach ($data as $i) {
    list($stamp, $name) = explode("\t", $i);
    if (!$page->read($name, 0)) {
        pieError("SourceReadError");
    }
    $comment = $page->meta['comment'];
    if (strlen($comment) > 30) {
        $comment = wordwrap($comment, 30, "\n");
        list($comment) = explode("\n", $comment);
        $comment .= " ...";
    } elseif (!$comment) {
        $comment = '-';
    }
    print '<tr class="' . ($n % 2 ? "oddRow" : "evenRow") . "\">\n<td>";
    if ($page->meta['type'] == 'alias') {
        print pieMakeLink(htmlspecialchars($name) . " <span class=\"warning\">({$hint_alias})</span>", array('action' => 'alias', 'page' => $page->meta['original'], 'alias' => $name), array('class' => "itemLink", 'title' => $hint_info)) . "</td>\n";
    } else {
        print pieMakeLink(htmlspecialchars($name), array('page' => $name), array('class' => "itemLink")) . "</td>\n";
    }
    print "<td>" . date($GLOBALS['pie']['time_format'], $stamp) . "</td>\n" . "<td>" . pieMakeLink(htmlspecialchars($page->meta['author']), array('action' => 'userinfo', 'user' => $page->meta['author']), array('class' => "itemLink")) . "</td>\n" . "<td>" . htmlspecialchars($comment) . "</td>\n" . "</tr>\n";
    $n++;
    if ($n > $_REQUEST['limit']) {
        break;
    }
}
pieNotice("TableTail");
pieTail();
コード例 #9
0
ファイル: history.php プロジェクト: rafsoaken/piewiki
    pieError("PageNotFound");
}
// Display the history.
if (@$_REQUEST['order'] == "descend") {
    krsort($history);
    $n = count($history);
} else {
    ksort($history);
    $n = 1;
}
$hint_info = $GLOBALS['pie']['locale']->key("Info");
$hint_show = $GLOBALS['pie']['locale']->key("Show");
$hint_edit = $GLOBALS['pie']['locale']->key("RevertTo");
$ip = pieMakeString('[[$^icon_link]]');
// Present results:
pieNotice("TableHead");
foreach ($history as $stamp => $info) {
    $comment = $info['comment'];
    if (strlen($comment) > 30) {
        $comment = wordwrap($comment, 30, "\n");
        list($comment) = explode("\n", $comment);
        $comment .= " ...";
    }
    print '<tr class="' . ($n % 2 ? "oddRow" : "evenRow") . '">' . "<td style=\"text-align: right;\">{$n}</td>\n" . "<td>" . date($GLOBALS['pie']['time_format'], $stamp) . "</td>\n" . "<td>" . pieMakeLink(htmlspecialchars($info['author']), array('action' => "userinfo", 'user' => $info['author'])) . "</td>\n" . "<td>" . htmlspecialchars($comment) . "</td>\n" . "<td>" . pieMakeLink("<img src=\"{$ip}/information.png\" alt=\"{$hint_info}\" />", array($context => $_REQUEST[$context], 'action' => "{$context}info", 'stamp' => $info['stamp']), array('title' => $hint_info)) . "</td>\n" . "<td>" . pieMakeLink("<img src=\"{$ip}/eye.png\" alt=\"{$hint_show}\" />", array($context => $_REQUEST[$context], 'action' => "revert", 'stamp' => $info['stamp']), array('title' => $hint_show)) . "</td>\n";
    if ($context == 'page') {
        print "<td>" . pieMakeLink("<img src=\"{$ip}/page_edit.png\" alt=\"{$hint_edit}\" />", array($context => $_REQUEST[$context], 'action' => "edit", 'stamp' => $info['stamp']), array('title' => $hint_edit)) . "</td>\n";
    }
    print "</tr>\n";
    if ($_REQUEST['order'] == "descend") {
        $n--;
    } else {
コード例 #10
0
ファイル: logshow.php プロジェクト: rafsoaken/piewiki
<?php

/*
 *      Display the log file.
 */
include_once "{$lib}/class/session.php";
include_once "{$lib}/class/user.php";
include_once "{$lib}/share/auth.php";
include_once "{$lib}/share/stdio.php";
pieRequireSuperuser();
pieHead("edit");
if (!file_exists($GLOBALS['pie']['run_path'] . "/log/pie.log")) {
    pieError("NoLogFile");
}
if (!($f = fopen($GLOBALS['pie']['run_path'] . "/log/pie.log", "r"))) {
    pieError("NoLogFile");
}
pieNotice("LogHead");
while ($line = fgets($f, 4096)) {
    print $line;
}
pieNotice("LogTail");
pieTail();
コード例 #11
0
ファイル: source.php プロジェクト: rafsoaken/piewiki
    }
    return htmlspecialchars($string);
}
pieHead();
$_REQUEST['page'] = pieCleanString(@$_REQUEST['page']);
$page = new Page();
$page->name = $_REQUEST['page'];
if (!$page->isValidName($_REQUEST['page'])) {
    pieError("PageNameInvalid");
}
if (!$page->exists($_REQUEST['page'])) {
    pieError("PageNotFound");
}
if (!(($_REQUEST['stamp'] = intval($_REQUEST['stamp'])) > 0)) {
    $_REQUEST['stamp'] = 0;
}
if (!$page->read($_REQUEST['page'], $_REQUEST['stamp'])) {
    pieError("SourceReadError");
}
if ($page->meta['type'] == "alias") {
    pieError("AliasRedirect", array('page' => htmlspecialchars($page->meta['original']), 'alias' => htmlspecialchars($_REQUEST['page'])));
}
// Format and display the page source:
$source = $page->source;
$source = str_replace('\\[', chr(1), $source);
$source = str_replace('\\]', chr(2), $source);
$source = nl2br(hilightBrackets($source));
$source = str_replace(chr(1), '\\[', $source);
$source = str_replace(chr(2), '\\]', $source);
pieNotice("SourceOfPage", array('source' => $source));
pieTail();
コード例 #12
0
ファイル: alias.php プロジェクト: rafsoaken/piewiki
        if ($resource->meta['original'] != $original) {
            continue;
        }
        $aliases[] = $i;
    }
    if (!count($aliases)) {
        if (@$is_alias) {
            pieTail();
            exit;
        }
        pieError("NoAliases", array('context' => $context, 'original' => htmlspecialchars($original)));
    }
    sort($aliases);
    $hint_descend = $GLOBALS['pie']['locale']->key("Descend");
    $hint_info = $GLOBALS['pie']['locale']->key("Display");
    $hint_delete = $GLOBALS['pie']['locale']->key("Delete");
    $ip = pieMakeString('[[$^icon_link]]');
    $n = 0;
    pieNotice("TableHeader", array('original' => htmlspecialchars($original)));
    foreach ($aliases as $i) {
        $n++;
        print '<tr class="' . ($n % 2 ? "oddRow" : "evenRow") . '">' . "<td>" . pieMakeLink(htmlspecialchars($i), array('action' => "alias", $context => $i), array('title' => $hint_descend, 'class' => "itemLink")) . "</td>\n" . "<td>" . pieMakeLink("<img src=\"{$ip}/information.png\" alt=\"{$hint_info}\" />", array('action' => "alias", $context => $original, 'alias' => $i), array('title' => $hint_info)) . "</td>\n" . "<td>" . pieMakeLink("<img src=\"{$ip}/delete.png\" alt=\"{$hint_delete}\" />", array('action' => "delete", $context => $i), array('title' => $hint_delete)) . "</td>\n" . "</tr>\n";
    }
    pieNotice("TableFooter", array('original' => htmlspecialchars($original), 'context' => $context));
    if (!$is_alias) {
        pieNotice("CreateAlias", array('original' => htmlspecialchars($original), 'context' => $context));
    }
} else {
    pieError("ActionInvalid");
}
pieTail();
コード例 #13
0
ファイル: upload.php プロジェクト: rafsoaken/piewiki
}
// Prepare meta data of the file:
$file->name = $name;
$file->meta = array('stamp' => time(), 'author' => $GLOBALS['pie']['user']);
// .. file size
if ($_FILES['upload']['size']) {
    $file->meta['size'] = $_FILES['upload']['size'];
} else {
    $file->meta['size'] = filesize(pieTempName("_upload"));
}
// .. file type
if (preg_match('/^[a-z]+\\/[a-z]+[\\w\\-\\+\\.]*\\w+$/', $_FILES['upload']['type'])) {
    $file->meta['type'] = $_FILES['upload']['type'];
} elseif (preg_match('/\\.([0-9A-Za-z]{1,5})$/', $name, $match)) {
    // File type is determined by file name suffix.
    $map = new MapFile();
    if ($type = $map->read("{$lib}/share/suffix.map", strtolower($match[1]))) {
        $file->meta['type'] = $type;
    }
} elseif (function_exists("mime_content_type")) {
    $file->meta['type'] = mime_content_type(pieTempName("_upload"));
}
if (@$_REQUEST['comment']) {
    $file->meta['comment'] = pieGetOption($_REQUEST['comment']);
}
if (!$file->write(pieTempName("_upload"))) {
    pieError("FileWriteError");
}
pieLog("edit");
pieNotice("UploadComplete");
pieTail();
コード例 #14
0
ファイル: wipe.php プロジェクト: rafsoaken/piewiki
<?php

/*
 *	Purge ALL cache files from the Cache database.
 */
include_once "{$lib}/class/cache.php";
include_once "{$lib}/class/locale.php";
include_once "{$lib}/share/auth.php";
include_once "{$lib}/share/log.php";
include_once "{$lib}/share/stdio.php";
include_once "{$lib}/share/string.php";
$cache = new Cache();
pieLoadLocale();
pieRequireSuperuser();
pieHead();
if (@$_REQUEST['approve']) {
    // Initialize the cache database and purge all existing caches.
    if ($cache->initialize()) {
        pieNotice('InitializationSuccess');
    } else {
        pieError('InitializationError');
    }
} else {
    // Verify action.
    pieError('AskInitialization');
}
pieLog('edit');
pieTail();
コード例 #15
0
ファイル: upgrade.php プロジェクト: rafsoaken/piewiki
<?php

/*
 *      Enable system upgrade by the setup script.
 */
include_once "{$lib}/class/session.php";
include_once "{$lib}/class/user.php";
include_once "{$lib}/share/auth.php";
include_once "{$lib}/share/stdio.php";
pieLoadLocale();
pieRequireSuperuser();
pieHead();
if (@$_REQUEST['enable']) {
    if (!touch($GLOBALS['pie']['run_path'] . '/user/enable_setup')) {
        pieError('EnableError');
    }
    pieNotice('EnableSuccess');
} else {
    pieNotice('AskEnable');
}
pieTail();
コード例 #16
0
ファイル: stdio.php プロジェクト: rafsoaken/piewiki
function pieError($message, $data = array())
{
    pieNotice($message, $data);
    pieTail();
    exit;
}
コード例 #17
0
ファイル: version.php プロジェクト: rafsoaken/piewiki
<?php

/*
 *	Display version and copyright information.
 */
include_once "{$lib}/share/stdio.php";
pieHead();
pieNotice("SoftwareRelease");
pieTail();
コード例 #18
0
ファイル: userimport.php プロジェクト: rafsoaken/piewiki
    $user = new User();
    // Check all new users for existence.
    if (!($f = fopen($_REQUEST['userfile'], "r"))) {
        pieError("ImportError");
    }
    while ($line = fgets($f, 4096)) {
        list($name) = explode(":", $line);
        if ($user->exists($name)) {
            pieError("UserExists", array('user' => $name));
        }
    }
    // Now import users for real.
    if (!rewind($f)) {
        pieError("ImportError");
    }
    $n = 0;
    while ($line = fgets($f, 4096)) {
        list($name, $pass) = explode(":", $line, 2);
        $pass = trim($pass);
        if (!$user->write($name, $pass)) {
            pieError("ImportError");
        }
        $n++;
    }
    fclose($f);
    pieNotice("ImportComplete", array('count' => $n));
} else {
    // Print the form.
    pieNotice("UserImportForm");
}
pieTail();
コード例 #19
0
ファイル: revert.php プロジェクト: rafsoaken/piewiki
    pieError("PageNameInvalid");
}
if (!$page->exists(@$_REQUEST['page'])) {
    pieError("PageNotFound");
}
if (!($meta = $diff->readPage($_REQUEST['page'], $_REQUEST['stamp']))) {
    pieError("SourceVersionMissing");
}
if ($meta['type'] == "alias") {
    pieError("AliasRedirect", array('page' => htmlspecialchars($meta['original']), 'alias' => htmlspecialchars($_REQUEST['page'])));
}
// Compile and display source:
if ($meta['title']) {
    $_REQUEST['title'] = $meta['title'];
}
$compiler = new htmlCompiler();
$compiler->source = $meta['source'];
if ($GLOBALS['pie']['page_header'] || $GLOBALS['pie']['page_footer']) {
    // Header and footer require meta data.
    $compiler->meta = $meta;
}
if (!$compiler->compile()) {
    $data = array('error' => "");
    foreach ($compiler->error as $i) {
        $data['error'] .= "<li>{$i}</li>\n";
    }
    $data['error'] .= "</ul>\n";
    pieNotice("CompilerError", $data);
}
pieNotice("VersionHead", array('stamp' => date($GLOBALS['pie']['time_format'], $_REQUEST['stamp']), 'output' => $compiler->output));
pieTail();
コード例 #20
0
ファイル: fileinfo.php プロジェクト: rafsoaken/piewiki
    $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();
コード例 #21
0
ファイル: pageinfo.php プロジェクト: rafsoaken/piewiki
$data = array('page_count' => 0, 'file_count' => 0);
$data['date'] = date($GLOBALS['pie']['time_format'], $page->meta['stamp']);
$data['author'] = htmlspecialchars($page->meta['author']);
$data['comment'] = "&mdash;";
if ($page->meta['comment']) {
    $data['comment'] = htmlspecialchars($page->meta['comment']);
}
$history = $page->history($page->name);
$data['history_count'] = count($history);
$t = 0;
ksort($history);
foreach ($history as $k => $v) {
    $n++;
    if ($stamp == $k) {
        break;
    }
}
$data['history_index'] = $n;
$data['page_count'] = '&mdash;';
$data['file_count'] = '&mdash;';
if ($page->meta['pages']) {
    $t = explode(" ", $page->meta['pages']);
    $data['page_count'] = count($t);
}
if ($page->meta['files']) {
    $t = explode(" ", $page->meta['files']);
    $data['file_count'] = count($t);
}
// Present results:
pieNotice("PageInfo", $data);
pieTail();
コード例 #22
0
ファイル: register.php プロジェクト: rafsoaken/piewiki
pieHead("browse");
if ($GLOBALS['pie']['deny_register']) {
    pieError("NotPublic");
}
$user = new User();
if (@$_REQUEST['username'] && @$_REQUEST['password'] && @$_REQUEST['retype']) {
    if (!$user->isValidName($_REQUEST['username'])) {
        pieLog("error");
        pieError("InvalidUsername");
    }
    if ($user->exists($_REQUEST['username'])) {
        pieLog("error");
        pieError("UserExists");
    }
    if ($_REQUEST['password'] != $_REQUEST['retype']) {
        pieError("PasswordMismatch");
    }
    // Userdata acceptable. Create new user.
    if (!$user->write($_REQUEST['username'], $user->encrypt($_REQUEST['password']))) {
        pieError("FailureForm");
    }
    $pref = new UserPref();
    $pref->write($_REQUEST['username'], "registered", time());
    $GLOBALS['pie']['user'] = $_REQUEST['username'];
    pieLog("user");
    pieNotice("SuccessForm");
} else {
    // Print the registration form.
    pieNotice("RegisterForm");
}
pieTail();
コード例 #23
0
ファイル: cancel.php プロジェクト: rafsoaken/piewiki
<?php

/*
 *	Cancel editing a page.
 */
include_once "{$lib}/class/page.php";
include_once "{$lib}/class/session.php";
include_once "{$lib}/class/locale.php";
include_once "{$lib}/share/auth.php";
include_once "{$lib}/share/stdio.php";
include_once "{$lib}/share/storage.php";
pieRequireUser();
pieHead();
$_REQUEST['page'] = pieGetOption(@$_REQUEST['page']);
$preview = pieTempName("_preview");
// Check permission:
$page = new Page();
if (!$page->isValidName(@$_REQUEST['page'])) {
    pieError("PageNameInvalid");
}
$page->name = $_REQUEST['page'];
if (!$page->lock($GLOBALS['pie']['user'])) {
    pieError("PageLockError");
}
// Clean up what has been set up while editing:
if (file_exists($preview)) {
    unlink($preview);
}
$page->unlock($GLOBALS['pie']['user']);
pieNotice("Cancelation");
pieTail();
コード例 #24
0
ファイル: update.php プロジェクト: rafsoaken/piewiki
    $cid = $cache->key('page', array('page' => $_REQUEST['page']));
    if (!($f = fopen($cache->file($cid), 'w'))) {
        pieError("CacheWriteError");
    }
    if (!fwrite($f, $compiler->output)) {
        pieError("CacheWriteError");
    }
    fclose($f);
}
// Clean up.
if (file_exists($preview)) {
    unlink($preview);
}
if ($GLOBALS['pie']['edit_timeout']) {
    pieExpireDirectory($GLOBALS['pie']['run_path'] . "/temp", $GLOBALS['pie']['edit_timeout']);
}
$page->unlock($GLOBALS['pie']['user']);
// Purge list of latest changes.
if ($GLOBALS['pie']['query_caching']) {
    $cache = new Cache();
    $cache->delete($cache->key('latest', array()));
}
// Print output.
pieLog("edit");
pieNotice("PageUpdated");
if ($GLOBALS['pie']['context'] == 'edit') {
    print "<div class=\"output\">\n" . $compiler->output . "</div>\n";
} else {
    print "<hr />\n<br />\n" . $compiler->output;
}
pieTail();
コード例 #25
0
ファイル: useradd.php プロジェクト: rafsoaken/piewiki
include_once "{$lib}/share/stdio.php";
include_once "{$lib}/share/string.php";
include_once "{$lib}/share/log.php";
pieRequireSuperuser();
pieHead("edit");
if (@$_REQUEST['username'] && @$_REQUEST['password']) {
    // A user has been specified.
    $user = new User();
    if (!$user->isValidName($_REQUEST['username'])) {
        pieError("InvalidUsername");
    }
    if ($user->exists($_REQUEST['username'])) {
        pieError("UserExists");
    }
    if ($_REQUEST['password'] != $_REQUEST['retype']) {
        pieError("PasswordMismatch");
    }
    // Userdata acceptable. Create new user.
    if (!$user->write($_REQUEST['username'], $user->encrypt($_REQUEST['password']))) {
        pieError("FailureForm");
    }
    $pref = new UserPref();
    $pref->write($_REQUEST['username'], "registered", time());
    $GLOBALS['pie']['user'] = $_REQUEST['username'];
    pieLog("user");
    pieNotice("SuccessForm");
} else {
    // Print the form.
    pieNotice('RegisterForm');
}
pieTail();
コード例 #26
0
ファイル: purge.php プロジェクト: rafsoaken/piewiki
}
pieHead();
if (@$_REQUEST['page']) {
    // Purge the cache of a single page.
    $_REQUEST['page'] = pieGetOption($_REQUEST['page']);
    $_REQUEST['page'] = pieBeautifyName($_REQUEST['page']);
    if (!$page->isValidName($_REQUEST['page'])) {
        pieError('PageNameInvalid');
    }
    if (!$page->exists($_REQUEST['page'])) {
        pieError('PageNotFound');
    }
    $cid = $cache->key('page', array('page' => $_REQUEST['page']));
    if (!$cache->exists($cid)) {
        pieError('PurgeSuccess');
    }
    if ($cache->delete($cid)) {
        pieNotice('PurgeSuccess');
    } else {
        pieError('PurgeError');
    }
} else {
    // Purge the caches of all pages.
    if ($cache->expire('page', 0)) {
        pieNotice('ExpirationSuccess');
    } else {
        pieError('ExpirationError');
    }
}
pieLog('edit');
pieTail();
コード例 #27
0
ファイル: preview.php プロジェクト: rafsoaken/piewiki
    }
    // Determine the text that come before and after the edited section.
    $section = new Section();
    if (($p = $section->offset($page->source, $_REQUEST['section'])) === false) {
        pieError('SectionNotFound');
    }
    if (($old = $section->extract($page->source, $_REQUEST['section'])) === false) {
        pieError('SectionNotFound');
    }
    $_REQUEST['source'] = substr($page->source, 0, $p) . rtrim($_REQUEST['source']) . "\n\n" . substr($page->source, $p + strlen($old));
}
// Parse and compile the source.
$data = array();
$compiler = new htmlCompiler();
$compiler->source = pieCleanString($_REQUEST['source']);
if ($GLOBALS['pie']['page_header'] || $GLOBALS['pie']['page_footer']) {
    // Header and footer require meta data.
    $compiler->meta = array('title' => pieGetOption($_REQUEST['title']), 'author' => $GLOBALS['pie']['user'], 'stamp' => time());
}
if (!$compiler->compile()) {
    $data['error'] = "<ul>\n";
    foreach ($compiler->error as $i) {
        $data['error'] .= "<li class=\"warning\">{$i}</li>\n";
    }
    $data['error'] .= "</ul>\n";
    pieNotice("CompilerError", $data);
}
// Present the output:
$data['preview'] = $compiler->output;
pieNotice("ApprovePreview", $data);
pieTail();
コード例 #28
0
ファイル: systeminfo.php プロジェクト: rafsoaken/piewiki
<?php

/*
 *      Display system information.
 */
include_once "{$lib}/share/auth.php";
pieLoadLocale();
pieRequireSuperuser();
pieHead("edit");
pieNotice("SystemInfoHead");
foreach ($GLOBALS['pie'] as $k => $v) {
    if (!preg_match('/^[a-z]+(_[a-z]+)+$/', $k)) {
        continue;
    }
    print "<li>{$k} = <samp style=\"color: #666;\">" . ($v ? htmlspecialchars($v) : '<span class="warning">false</span>') . "</samp></li>\n";
}
pieNotice("SystemInfoTail");
pieTail();
コード例 #29
0
ファイル: userinfo.php プロジェクト: rafsoaken/piewiki
pieRequireUser();
pieHead("edit");
if (@$_REQUEST['user']) {
    // A user has been specified.
    $_REQUEST['user'] = pieGetOption($_REQUEST['user']);
    $user = new User();
    if (!$user->isValidName($_REQUEST['user'])) {
        pieError("BadUser");
    }
    if (!$user->exists($_REQUEST['user'])) {
        pieError("BadUser");
    }
} elseif ($_SESSION['user']) {
    // No user has been specified:
    // display information about myself.
    $_REQUEST['user'] = $_SESSION['user'];
}
if (!@$_REQUEST['user']) {
    pieError("NoUser");
}
$map = new MapFile();
$data = array('user' => htmlspecialchars($_REQUEST['user']), 'realname' => "&mdash;", 'lastlogin' => date($GLOBALS['pie']['time_format'], $map->read($GLOBALS['pie']['run_path'] . "/user/login.map", $_REQUEST['user'])));
$pref = new UserPref();
if (($val = $pref->read(@$_REQUEST['user'], 'realname')) !== false) {
    $data['realname'] = $val;
}
if (($val = $pref->read(@$_REQUEST['user'], 'registered')) !== false) {
    $data['registered'] = date($GLOBALS['pie']['time_format'], $val);
}
pieNotice("UserData", $data);
pieTail();
コード例 #30
0
ファイル: password.php プロジェクト: rafsoaken/piewiki
include_once "{$lib}/share/log.php";
include_once "{$lib}/share/stdio.php";
pieRequireUser();
pieHead("edit");
if (@$_REQUEST['old'] && @$_REQUEST['new'] && @$_REQUEST['retype']) {
    if ($_REQUEST['new'] != $_REQUEST['retype']) {
        pieError("PasswordMismatch");
    }
    $user = new User();
    $pw = $user->read($GLOBALS['pie']['user']);
    if ($pw != $user->encrypt($_REQUEST['old'])) {
        // The entered password differs from the registered password.
        // Try the crypt() command to handle old style passwords.
        $salt = substr($pw, 0, 2);
        if ($pw != crypt($_REQUEST['old'], $salt)) {
            // The entered password is just wrong.
            pieLog("failure");
            pieError("PasswordFailure");
        }
    }
    // The input is acceptable. Change the password.
    if (!$user->write($GLOBALS['pie']['user'], $user->encrypt($_REQUEST['new']))) {
        pieError("PasswordFailure");
    }
    pieLog("user");
    pieNotice("PasswordSuccess");
} else {
    // Print the form.
    pieNotice("PasswordForm", array('user' => $GLOBALS['pie']['user']));
}
pieTail();