Example #1
0
function kona3_action_new()
{
    global $kona3conf;
    $page = $kona3conf["page"];
    $action = kona3getPageURL($page, "new");
    $am = kona3param('a_mode', '');
    $key = kona3param('a_key', '');
    $res = "";
    if ($am == "new") {
        $url = kona3getPageURL($key, "edit");
        header("Location: {$url}");
        exit;
    }
    $key_ = kona3text2html($key);
    // show form
    $form = <<<EOS
<div>
  <form method="post" action="{$action}">
    <input type="hidden" name="a_mode" value="new">
    <input type="text" name="a_key" value="{$key_}">
    <input type="submit" value="New">
  </form>
</div>
<div>
{$res}
</div>
EOS;
    // show
    kona3template('message', array("page_title" => kona3text2html($page), "page_body" => $form));
}
Example #2
0
function kona3_action_edit()
{
    global $kona3conf, $page;
    $page = $kona3conf["page"];
    $action = kona3getPageURL($page, "edit");
    $a_mode = kona3param('a_mode', '');
    $i_mode = kona3param('i_mode', 'form');
    // or ajax
    // check permission
    if (!kona3isLogin()) {
        $url = kona3getPageURL($page, 'login');
        kona3_edit_err("<a href='{$url}'>Please login</a>", $i_mode);
        exit;
    }
    // load body
    $txt = "";
    $fname = kona3getWikiFile($page);
    if (file_exists($fname)) {
        $txt = @file_get_contents($fname);
    }
    $a_hash = hash('sha256', $txt);
    if ($a_mode == "trywrite") {
        $msg = kona3_trywrite($txt, $a_hash, $i_mode);
    } else {
        $msg = "";
    }
    // show
    kona3template('edit', array("action" => $action, "a_hash" => $a_hash, "page_title" => kona3text2html($page), "page_body" => kona3text2html($txt), "msg" => $msg));
}
Example #3
0
function kona3plugins_beta_execute($args)
{
    $text = array_shift($args);
    //
    $html = kona3text2html($text, ENT_QUOTES, "UTF-8");
    $html = str_replace("\n", "<br>", $html);
    return "<div class='filecode'><div class='beta'>{$html}</div></div>";
}
Example #4
0
function _cell($cell, $type)
{
    if ($type == 'wiki') {
        $cell = konawiki_parser_convert($cell, FALSE);
        return $cell;
    }
    $cell = kona3text2html($cell);
    return $cell;
}
Example #5
0
function kona3plugins_count_execute($args)
{
    $text = array_shift($args);
    $len = strlen($text);
    $mlen = mb_strlen($text);
    $html = kona3text2html($text, ENT_QUOTES, "utf-8");
    $s = "{$len}B";
    if ($mlen != $len) {
        $s .= ",{$mlen}хнЧ";
    }
    return "<span>{$html}<span class='memo'>({$s})</span></span>";
}
Example #6
0
function kona3plugins_file_execute($args)
{
    global $kona3conf;
    $name = array_shift($args);
    $fname = kona3getWikiFile($name, false);
    if (!file_exists($fname)) {
        return "<div class='error'>Not Exists:" . kona3text2html($name) . "</div>";
    }
    $txt = file_get_contents($fname);
    $htm = konawiki_parser_convert($txt);
    return "<div>" . $htm . "</div>";
}
Example #7
0
function kona3plugins_code_execute($args)
{
    $lang = array_shift($args);
    $text = array_shift($args);
    // #code (NULL) 対策
    if ($lang == "") {
        $text = $lang;
    }
    //
    $html = kona3text2html($text, ENT_QUOTES, "UTF-8");
    return "<div><pre class='code'>{$html}</pre></div>";
}
Example #8
0
function kona3plugins_ref_execute($args)
{
    global $kona3conf;
    // get args
    $size = "";
    $caption = "";
    $link = "";
    $url = array_shift($args);
    while ($args) {
        $arg = array_shift($args);
        $arg = trim($arg);
        $c = substr($arg, 0, 1);
        if ($c == "*") {
            $caption = substr($arg, 1);
            continue;
        }
        if ($c == "@") {
            $link = substr($arg, 1);
            continue;
        }
        if (preg_match("#(\\d+)x(\\d+)#", $arg, $m)) {
            $size = " width='{$m[1]}' height='{$m[2]}'";
            continue;
        }
    }
    // make link
    if (!preg_match("#^http#", $url)) {
        // attach
        $f = $kona3conf["path.attach"] . "/" . urlencode($url);
        if (file_exists($f)) {
            $url = $kona3conf["url.attach"] . "/" . urlencode($url);
        }
        // data
        $f = kona3getWikiFile($url, false);
        if (file_exists($f)) {
            $url = kona3getWikiUrl($url);
        }
    }
    // Is image?
    if (preg_match('/\\.(png|jpg|jpeg|gif|bmp|ico|svg)$/', $url)) {
        $caph = "<div class='memo'>" . kona3text2html($caption) . "</div>";
        $code = "<div>" . "<div><a href='{$url}'><img src='{$url}'{$size}></a></div>" . ($caption != "" ? $caph : "") . "</div>";
    } else {
        if ($caption == "") {
            $caption = $url;
        }
        $code = "<div><a href='{$url}'>{$caption}</a></div>";
    }
    return $code;
}
Example #9
0
function kona3_action_login()
{
    global $kona3conf;
    $page = $kona3conf["page"];
    $action = kona3getPageURL($page, "login");
    $am = kona3param('a_mode', '');
    $user = kona3param('a_user', '');
    $pw = kona3param('a_pw', '');
    $msg = '';
    // check user
    if ($am == "trylogin") {
        $users = $kona3conf['users'];
        if (isset($users[$user]) && $users[$user] == $pw) {
            // ok
            $editLink = kona3getPageURL($page, 'edit');
            $msg = "<a href='{$editLink}'>Success to login.</a>";
            kona3login();
            kona3showMessage($page, $msg);
            exit;
        } else {
            // ng
            $msg = '<div class="error">Invalid User or Password.</div>';
        }
    }
    // show form
    $form = <<<EOS
<div id="loginform">
  {$msg}
  <form method="post" action="{$action}">
  <input type="hidden" name="a_mode" value="trylogin">
  <p>
    <label for="user">User:</label><br>
    <input id="user" type="text" name="a_user">
  </p>
  <p>
    <label for="pass">Password:</label><br>
    <input id="pass" type="password" name="a_pw">
  </p>
  <p><input type="submit" value="Login"></p>
  </form>
</div>
EOS;
    // show
    kona3template('message', array("page_title" => kona3text2html($page), "page_body" => $form));
}
Example #10
0
function kona3plugins_tsv_execute($args)
{
    $html = "";
    $text = trim(array_shift($args));
    $lines = explode("\n", $text);
    foreach ($lines as $line) {
        $line = trim($line);
        if ($line == "") {
            continue;
        }
        $cells = explode("\t", $line);
        $html .= "<tr>";
        foreach ($cells as $cell) {
            $html .= "<td>" . kona3text2html($cell) . "</td>";
        }
        $html .= "</tr>";
    }
    return "<table>" . $html . "</table>";
}
Example #11
0
function kona3_action_search()
{
    global $kona3conf;
    $page = $kona3conf["page"];
    $action = kona3getPageURL($page, "search");
    $am = kona3param('a_mode', '');
    $key = kona3param('a_key', '');
    $res = '';
    if ($am == "search") {
        $result = array();
        $path_data = $kona3conf["path.data"];
        kona3search($key, $result, $path_data);
        foreach ($result as $f) {
            $path = str_replace("{$path_data}/", "", $f);
            $path = preg_replace('/\\.(txt|md)$/', '', $path);
            $enc = urlencode($path);
            $res .= "<li><a href='index.php?{$enc}'>{$path}</li>";
        }
    }
    if ($res != "") {
        $res = "<ul>{$res}</ul>\n";
    }
    $key_ = kona3text2html($key);
    // show form
    $form = <<<EOS
<div>
  <form method="post" action="{$action}">
    <input type="hidden" name="a_mode" value="search">
    <input type="text" name="a_key" value="{$key_}">
    <input type="submit" value="Search">
  </form>
</div>
<div>
{$res}
</div>
EOS;
    // show
    kona3template('message', array("page_title" => kona3text2html($page), "page_body" => $form));
}
Example #12
0
function kona3plugins_filecode_execute($args)
{
    global $kona3conf;
    $name = array_shift($args);
    $fname = kona3getWikiFile($name, false);
    if (!file_exists($fname)) {
        return "<div class='error'>Not Exists:" . kona3text2html($name) . "</div>";
    }
    $url = kona3getWikiUrl($name);
    $txt = @file_get_contents($fname);
    if (preg_match('#\\.php$#', $fname)) {
        $txt = trim($txt);
        $htm = highlight_string($txt, true);
        // <pre>するので不必要な改行を削除
        $htm = preg_replace('#[\\r\\n]#', '', $htm);
    } else {
        $htm = kona3text2html(trim($txt));
    }
    $name_ = htmlspecialchars($name, ENT_QUOTES);
    $code = "<div class='filecode'>" . "  <div class='filename'>" . "    <a href='{$url}'>file: {$name_}</a>" . "  </div>" . "  <pre class='code'>{$htm}</pre>" . "</div>";
    return $code;
}
Example #13
0
<?php

/** frame template */
global $kona3conf;
// Parameters
if (empty($page_title)) {
    $page_title = "?";
}
if (empty($page_body)) {
    $page_body = "page_body is empty";
}
$wiki_title_ = kona3text2html($kona3conf['title']);
$page_title_ = Kona3text2html($page_title);
$logo_href = kona3getPageURL(KONA3_WIKI_FRONTPAGE);
$page_href = kona3getPageURL($page_title);
// Is FrontPage?
if ($page_title == KONA3_WIKI_FRONTPAGE) {
    // FrontPage
    $head_title = "{$wiki_title_}";
} else {
    // Normal page
    $head_title = "{$page_title}-{$wiki_title_}";
}
//
$logo_title_ = "<a href='{$logo_href}'>{$wiki_title_}</a>";
$page_name_ = "<a href='{$page_href}'>{$page_title_}</a>";
// js & css & header tags
$js = "";
if (isset($kona3conf['js'])) {
    $jslist = $kona3conf['js'];
    $jslist = array_unique($jslist);
Example #14
0
function kona3plugins_rem_execute($args)
{
    $text = array_shift($args);
    $html = kona3text2html($text);
    return "<!-- {$html} -->";
}
Example #15
0
function konawiki_parser_render_plugin($value)
{
    $pname = $value['text'];
    $params = $value['params'];
    $info = konawiki_parser_getPlugin($pname);
    $func = $info['func'];
    $res = "[Plugin Error:" . kona3text2html($pname) . "({$func})]";
    // check
    if ($info['disallow']) {
        $res = "[Plugin Error:" . kona3text2html($pname) . "]";
        return $res;
    }
    // execute
    if (is_callable($func)) {
        $res = @call_user_func($func, $params);
    }
    return $res;
}
Example #16
0
function kona3showMessage($title, $msg)
{
    $body = "<div class='message'>{$msg}</div>";
    kona3template("message", array('page_title' => kona3text2html($title), 'page_body' => $body));
    exit;
}
Example #17
0
function kona3_action_show()
{
    global $kona3conf;
    $page = $kona3conf["page"];
    $page_h = htmlspecialchars($page);
    // check login
    if ($kona3conf["wiki.private"]) {
        if (!kona3isLogin()) {
            $url = kona3getPageURL($page, "login");
            kona3error($page, "Private mode. <a href='{$url}'>Please login.</a>");
            exit;
        }
    }
    // wiki file (text)
    $fname = kona3getWikiFile($page);
    // wiki file eixsits?
    $ext = "txt";
    $wiki_live = file_exists($fname);
    if (!$wiki_live) {
        // mark down
        $fname = kona3getWikiFile($page, TRUE, '.md');
        $wiki_live = file_exists($fname);
        if ($wiki_live) {
            $ext = "md";
        } else {
            $fname = kona3getWikiFile($page, FALSE);
            $wiki_live = file_exists($fname);
            if (preg_match('#\\.([a-z]+)$#', $fname, $m)) {
                $ext = $m[1];
            }
        }
    }
    // body
    if ($wiki_live) {
        $txt = @file_get_contents($fname);
    } else {
        $updir = dirname($page);
        $txt = "*** {$page}\n\n" . "Not Found\n\n" . "#ls()\n";
    }
    // convert
    $cnt_txt = mb_strlen($txt);
    if ($ext == "txt") {
        $page_body = konawiki_parser_convert($txt);
    } else {
        if ($ext == "md") {
            $page_body = _markdown_convert($txt);
        } else {
            kona3error($page, "Sorry, System Error.");
            exit;
        }
    }
    // every page
    if (!empty($kona3conf['allpage.footer'])) {
        $footer = konawiki_parser_convert($kona3conf['allpage.footer']);
        $page_body .= "<hr>" . $footer;
    }
    // menu
    $menufile = kona3getWikiFile("MenuBar");
    if (file_exists($menufile)) {
        $menu = @file_get_contents($menufile);
        $menuhtml = konawiki_parser_convert($menu);
    } else {
        $menuhtml = "";
    }
    // show
    kona3template('show', array("page_title" => kona3text2html($page), "page_body" => $page_body, "cnt_txt" => $cnt_txt, "wiki_menu" => $menuhtml));
}