Exemplo n.º 1
0
function ewiki_uservar_collect($id, $data, $action)
{
    global $ewiki_plugins, $ewiki_config;
    if (!isset($GLOBALS['ewiki_auth_user'])) {
        return;
    }
    //Authenticate on the UserInfo page that we will be submitting to.
    if (EWIKI_PROTECTED_MODE && EWIKI_PROTECTED_MODE_HIDING && !ewiki_auth('UserInfo', $uu, "view")) {
        return;
    }
    foreach ($ewiki_config["CollectedUserData"] as $checkVar => $uu) {
        if (strlen(ewiki_get_uservar($checkVar)) == 0) {
            $currVar = $checkVar;
            break;
        }
    }
    if (isset($currVar)) {
        $o = ewiki_make_title($id, "User data update", 2);
        $o .= "Our database does not include your {$currVar}, please enter it below:";
        $o .= '<p><form method="post" action="' . ewiki_script('UserInfo') . '"><table border="1" cellpadding="1">';
        $o .= '<tr><th>' . $currVar . '</th><td><input name="text_' . $currVar . '" type="text"></td></tr>';
        $o .= '<tr><td></td><td><input value="Submit Changes" type="submit" name="submit_changeaccount" /></td></tr>';
        $o .= '</table></form>';
        return $o;
    }
}
Exemplo n.º 2
0
function ewiki_edit_form_append_pageimgcntrl($id, $data, $action)
{
    global $ewiki_config;
    #-- fetch and asort images
    $sorted = array();
    $result = ewiki_db::GETALL(array("flags", "created", "meta"));
    while ($row = $result->get()) {
        if (($row["flags"] & EWIKI_DB_F_TYPE) == EWIKI_DB_F_BINARY && strpos($row['meta']['Content-Type'], 'image/') === 0) {
            if (isset($ewiki_config['image-galleries'][EWIKI_PAGE_LOGOCNTRL_GALLERY])) {
                foreach ($ewiki_config['image-galleries'][EWIKI_PAGE_LOGOCNTRL_GALLERY] as $field => $value) {
                    if ($row['meta'][$field] != $value) {
                        continue 2;
                    }
                }
            }
            if (!EWIKI_PROTECTED_MODE || EWIKI_PROTECTED_MODE_HIDING <= 0.5 || ewiki_auth($row["id"], $uu, "binary-get")) {
                $sorted[$row["id"]] = substr($row['meta']["Content-Location"] . ' (' . $row["id"] . ')', 0, 70);
                //echo("adding ".$row["id"].", ".$sorted[$row["id"]]."<br />");
            }
        }
    }
    arsort($sorted);
    #-- start selector
    $o = '
        <br /><label for="pageimagecntrl">Choose Page Image (<A href="' . ewiki_script(EWIKI_PAGE_LOGOCNTRL_GALLERY) . '">view thumbnails</A>):</label>
        <select id="pageimagecntrl" name="pageimagecntrl">' . '<option value="-1" ' . (!isset($data['meta']['pageimage']) || $data['meta']['pageimage'] == '' ? ' selected="selected"' : '') . '>None</option>';
    foreach ($sorted as $image => $name) {
        $o .= '<option value="' . htmlentities($image) . '"' . (isset($data['meta']['pageimage']) && $image == $data['meta']['pageimage'] ? ' selected="selected"' : '') . '>' . htmlentities($name) . '</option>';
    }
    $o .= "</select>\n";
    return $o;
}
Exemplo n.º 3
0
function ewiki_page_wikiuserlogin($id, $data, $action)
{
    $o .= "<h2>{$id}</h2>\n";
    if (empty($_GET["wikiauthor"])) {
        $o .= '
       <form action="' . ewiki_script("login", $id) . '" method="get">
          your WikiName <input type="text" name="wikiauthor" size="20">
          <br /><br />
          <input type="submit" value="log in">
          <input type="hidden" name="page" value="' . $id . '">
          <br /><br />
          <input type="checkbox" name="forever" value="1"> make cookie persistent forever
       </form>
       ';
    } else {
        $o .= '
       Your author name is now set to "' . $_GET["wikiauthor"] . '". Please go ahead and
       start editing pages.
       ';
        if ($_REQUEST["forever"]) {
            setcookie("wikiauthor", $_GET["wikiauthor"]);
        } else {
            setcookie("wikiauthor", $_GET["wikiauthor"], time() * 1.2);
        }
    }
    return $o;
}
Exemplo n.º 4
0
function ewiki_addpage($id, &$data, $version)
{
    $o = ewiki_make_title($id, $id, 2);
    #-- output page creation dialog
    if (empty($_REQUEST["new_id"])) {
        $o .= ewiki_t('<form action="' . ewiki_script("", $id) . '" method="POST" enctype="multipart/formdata"> ' . '_{name of the new page} <input type="text" name="new_id" size="26" value="">' . '<br />' . '<input type="submit" value="_{create}">' . '<br /><br />' . '<input type="checkbox" name="add_link_from" value="1" checked="checked">' . ' _{link it from} ' . '<input type="text" name="link_from" size="20" value="_{AddedPages}">' . '</form>');
    } else {
        $new_id = trim($_REQUEST["new_id"]);
        #-- add a link to new page
        if ($_REQUEST["add_link_from"] && ($from = $_REQUEST["link_from"])) {
            $row = ewiki_db::GET($from);
            if ($row && $row["version"]) {
                if (($row["flags"] & EWIKI_DB_F_TYPE) == EWIKI_DB_F_TEXT) {
                    $row["version"]++;
                    $row["content"] .= "\n* [{$new_id}]";
                    ewiki_scan_wikiwords($row["content"], $row["refs"], "_STRIP_EMAIL=1");
                    $row["refs"] = "\n\n" . implode("\n", array_keys($row["refs"])) . "\n\n";
                } else {
                    $row = false;
                }
            } else {
                $row = array("id" => $from, "version" => 1, "flags" => EWIKI_DB_F_TEXT, "created" => time(), "lastmodified" => time(), "hits" => 0, "meta" => "", "content" => "\n* [{$new_id}]", "refs" => "\n\n{$new_id}\n\n");
            }
            if ($row) {
                ewiki_db::WRITE($row);
            }
        }
        #-- call edit <form>
        $o = ewiki_page($new_id);
    }
    return $o;
}
Exemplo n.º 5
0
function ewiki_action_info_qdiff($id, &$data, $action)
{
    $CLK = "%c";
    $o = ewiki_make_title($id, "history of '{$id}'", 2);
    #-- walk through versions
    $prev = (array) $data;
    $ver = $data["version"] + 1;
    while (--$ver >= 2) {
        #-- get
        if ($d = ewiki_db::GET($id, $ver - 1)) {
            $curr = $prev;
            $prev = $d;
            $d = NULL;
        } else {
            continue;
        }
        #-- info header
        $o .= '<table border="1">' . "\n" . '<tr class="qdiff-header"><td>' . '<b><a href="' . ewiki_script("", $id, "version={$ver}") . "\">version {$ver}</a></b>" . '</td><td>' . ewiki_author_html($curr["author"]) . '</td><td>' . strftime($CLK, $curr["lastmodified"]) . "</td></tr>\n";
        #-- diff part
        $diff = ewiki_stupid_diff($curr["content"], $prev["content"], $show_unchanged = 0, $magic_notes = 1);
        $o .= '<td colspan="3">' . $diff;
        $o .= "\n</td></tr>\n</table>\n<br />\n";
    }
    // add initial version:
    $d = ewiki_db::GET($id, 1);
    $o .= '<table border="1">' . "\n" . '<tr class="qdiff-header"><td>' . '<b><a href="' . ewiki_script("", $id, "version=" . $d["version"]) . "\">version " . $d["version"] . "</a></b>" . '</td><td>' . ewiki_author_html($d["author"]) . '</td><td>' . strftime($CLK, $d["lastmodified"]) . "</td></tr>\n";
    #-- diff part
    $o .= '<td colspan="3">' . nl2br($d["content"]);
    $o .= "\n</td></tr>\n</table>\n<br />\n";
    return $o;
}
Exemplo n.º 6
0
function ewiki_view_append_attachments($id, $data, $action)
{
    $o = '<hr /><h4><a href="' . ewiki_script(EWIKI_ACTION_ATTACHMENTS, $id) . '">' . ewiki_t("ATTACHMENTS") . '</a></h4>';
    $scan = 's:7:"section";' . serialize($id);
    $result = ewiki_database("SEARCH", array("meta" => $scan));
    #### BEGIN MOODLE CHANGES - show attachments link only if there are attachments.
    ####                      - don't show the attachments on the content page.
    if (count($result->entries) <= 0) {
        $o = '';
    }
    //   $ord = array();
    //   while ($row = $result->get()) {
    //      $ord[$row["id"]] = $row["created"];
    //   }
    //   arsort($ord);
    //
    //    foreach ($ord as $id => $uu) {
    //        $row = ewiki_database("GET", array("id"=>$id));
    //        if (EWIKI_PROTECTED_MODE && EWIKI_PROTECTED_MODE_HIDING && !ewiki_auth($row["id"], $row, "view")) {
    //            continue;
    //        }
    //        $o .= ewiki_entry_downloads($row, "*");
    //    }
    #### END MOODLE CHANGES
    return $o;
}
Exemplo n.º 7
0
function ewiki_page_wiki_dump_tarball($id, $data, $action)
{
    #-- return legacy page
    if (empty($_REQUEST["download_tarball"])) {
        $url = ewiki_script("", $id);
        return ewiki_make_title($id, $id, 2) . ewiki_t(<<<END
_{WIKIDUMP}
<br /><br />
<form action="{$url}" method="POST" enctype="multipart/form-data">
<input type="hidden" name="id" value="{$id}">
<input type="submit" name="download_tarball" value="_{download tarball}">
<br /><br />
<input type="checkbox" name="dump_images" value="1"> _{with images}<br />
<input type="checkbox" name="dump_virtual" value="1"> _{include virtual pages}<br />
<input type="checkbox" name="dump_fullhtml" value="1" checked> _{complete .html files}<br />
&nbsp; &nbsp; &nbsp; <input type="checkbox" name="dump_linksto" value="1"> _{with backlink pages}<br />
</form>
END
);
    } else {
        $di = $_REQUEST["dump_images"];
        $fh = $_REQUEST["dump_fullhtml"];
        $bl = $_REQUEST["dump_linksto"];
        $vp = $_REQUEST["dump_virtual"];
        $_REQUEST = $_GET = $_POST = array();
        set_time_limit(180);
        ewiki_page_wiki_dump_send($di, $fh, $vp, $bl);
    }
}
Exemplo n.º 8
0
function ewiki_createpage($id, &$data, $version)
{
    $o = ewiki_make_title($id, $id, 2);
    #-- output page creation dialog
    $o .= ewiki_t('<form action="' . ewiki_script("", "") . '" method="POST" enctype="multipart/formdata"> ' . '_{name of the new page} <input type="text" name="id" size="26" value="">' . '<br />' . '<input type="submit" value="_{create}">' . '</form>');
    return $o;
}
Exemplo n.º 9
0
function ewiki_edit_form_append_updFormat($id, $data, $action)
{
    global $ewiki_ring;
    if (!ewiki_auth_perm_liveuser($id, $data, 'manage', $ewiki_ring, 0)) {
        return '';
    }
    return ' &nbsp; <a href="' . ewiki_script('updformatheader', $id) . '">' . ewiki_t("UPDHEADERFORMAT") . '</a>';
}
Exemplo n.º 10
0
function ewiki_page_aboutplugins($id, $data, $action)
{
    global $ewiki_plugins;
    $o = ewiki_make_title($id, $id, 2);
    #-- plugin types
    foreach (array("page", "action", "mpi") as $pclass) {
        $o .= "<u>{$pclass} plugins</u><br />\n";
        switch ($pclass) {
            case "page":
                $o .= "dynamically generated pages<br />\n";
                break;
            case "action":
                $o .= "can be activated on each (real) page<br />\n";
                break;
            case "mpi":
                $o .= "the markup plugins can be utilized to integrate dynamic content into pages<small> (loaded on demand, so rarely shown here)</small><br />\n";
                break;
            default:
        }
        if ($pf_a = $ewiki_plugins[$pclass]) {
            ksort($pf_a);
            if ($pclass == "action") {
                $pf_a = array_merge($pf_a, $ewiki_plugins["action_always"]);
            }
            foreach ($pf_a as $i => $pf) {
                switch ($pclass) {
                    case "page":
                        $i = '<a href="' . ewiki_script("", $i) . '">' . $i . '</a>';
                        break;
                    case "action":
                        $i = '<a href="' . ewiki_script($i, "Notepad") . '">' . $i . '</a>';
                        break;
                    case "mpi":
                        $i = '<a href="' . ewiki_script("mpi/{$i}") . '">&lt;?plugin ' . $i . '?&gt;</a>';
                        break;
                    default:
                }
                $o .= "· <b>{$i}</b> <small>via {$pf}</small><br />\n";
            }
        }
        $o .= "<br />\n";
    }
    #-- task plugins
    $o .= "<u>task plugins</u> (core stuff)<br />\n";
    $o .= "enhance the wiki engine internally, with widely varying functionality enhancements or changes<br />\n";
    foreach ($ewiki_plugins as $i => $a) {
        if (is_array($a)) {
            foreach ($a as $n => $pf) {
                if (is_int($n)) {
                    $o .= "· <b><tt>{$i}</tt></b> <small>via {$pf}</small><br />\n";
                }
            }
        }
    }
    $o .= "<br />\n";
    return $o;
}
Exemplo n.º 11
0
function ewiki_mpi_survey($action, &$args, &$iii, &$s)
{
    global $ewiki_id, $ewiki_plugins;
    $o = "";
    #-- load data page
    if (!($df = $args["data"])) {
        return;
    }
    unset($args["data"]);
    unset($args["_"]);
    unset($args[""]);
    $data = ewiki_db::GET($df);
    if (!$data["version"]) {
        $data = ewiki_new_data($df, EWIKI_DB_F_BINARY);
        $data["version"]--;
    }
    if ($data["flags"] != EWIKI_DB_F_BINARY) {
        return;
    }
    $survey = unserialize($data["content"]);
    #-- operation
    $vote = @$_REQUEST[EWIKI_UP_SURVEY];
    if ($vote == "\$") {
        $action = "show";
    }
    if ($action == "html") {
        #-- show entries
        if (!$vote) {
            $o = "\n" . '<form action="' . $_SERVER["REQUEST_URI"] . '" method="POST" enctype="multipart/form-data">' . '<input type="hidden" name="id" value="' . htmlentities($ewiki_id) . '">' . "\n";
            foreach ($args as $name => $text) {
                if (!$name || !$text || $name == "data") {
                    continue;
                }
                $o .= '<input type="radio" name="' . EWIKI_UP_SURVEY . '" value="' . htmlentities($name) . '"> ' . $text . "<br />\n";
            }
            $o .= '<input type="submit" value="vote">';
            $o .= "\n</form>\n<br /><br />\n";
            $o .= '<a href="' . ewiki_script("", $ewiki_id, array(EWIKI_UP_SURVEY => "\$")) . '">show results</a><br />';
        }
        #-- store an entry
        if ($vote) {
            $survey[$vote]++;
            $data["content"] = serialize($survey);
            $data["version"]++;
            $data["lastmodified"] = time();
            $data["author"] = ewiki_author();
            ewiki_db::WRITE($data);
            #-- show it
            $action = "show";
        }
    }
    if ($action == "show") {
        $o .= $ewiki_plugins["view_stat"][0]($survey, $args);
    }
    return $o;
}
Exemplo n.º 12
0
function ewiki_view_append_backlinks($id, $data, $action)
{
    $pages = ewiki_get_backlinks($id);
    $o = "";
    foreach ($pages as $id) {
        $o .= ' <a href="' . ewiki_script("", $id) . '">' . $id . '</a>';
    }
    $o && ($o = "<div class=\"wiki_backlinks\"><small>" . get_string('backlinks', 'wiki') . ":</small><br />{$o}</div>\n");
    return $o;
}
Exemplo n.º 13
0
function ewiki_tcn_view_final_add_variants(&$o, $id, &$data, &$action)
{
    global $ewiki_variants;
    if (count($ewiki_variants) >= 2) {
        $add = '<div class="language-variants">';
        foreach ($ewiki_variants as $v_id => $v_l) {
            $add .= " <a href=\"" . ewiki_script($action, $v_id, array(EWIKI_UP_FORCE_LANG => $v_l)) . "\" class=\"lang {$v_l}\" lang=\"{$v_l}\">{$v_l}</a> ";
        }
        $add .= '</div>' . "\n";
        $o = $add . $o;
    }
}
Exemplo n.º 14
0
function ewiki_page_sitemap($id = 0, $data = 0, $action = 0)
{
    global $ewiki_config;
    //**code hijacked from page_pageindex.php**
    //creates a list of all of the valid wiki pages in the site
    $str_null = NULL;
    $a_validpages = ewiki_valid_pages(0, 1);
    //**end of hijacked code**
    //$time_end=getmicrotime();
    //creates the title bar on top of page
    if ($id == EWIKI_PAGE_SITEMAP) {
        $o = ewiki_make_title($id, ewiki_t($id), 2);
        foreach ($ewiki_config["SiteMap"]["RootList"] as $root) {
            if (isset($a_validpages[$root])) {
                $valid_root = TRUE;
                $str_rootid = $root;
                break;
            }
        }
    } else {
        $o = ewiki_make_title($id, ewiki_t("SMFOR") . " " . $id, 2);
        if (isset($a_validpages[$id])) {
            $valid_root = TRUE;
            $str_rootid = $id;
        }
    }
    $o .= "<p>" . ewiki_t("VIEWSMFOR") . " ";
    foreach ($ewiki_config["SiteMap"]["RootList"] as $root) {
        if (isset($a_validpages[$root])) {
            $o .= '<a href="' . ewiki_script('sitemap/', $root) . '">' . $root . '</a> ';
        }
    }
    $o .= "</p>";
    //checks to see if the user is allowed to view the root page
    if (!isset($a_validpages[$str_rootid])) {
        $o .= ewiki_t("INVALIDROOT");
        return $o;
    }
    //$timesitemap=getmicrotime();
    $a_sitemap = ewiki_sitemap_create($str_rootid, $a_validpages, EWIKI_SITEMAP_DEPTH);
    $timer = array();
    $level = -1;
    $fordump = 0;
    $str_formatted = "<ul>\n<li><a href=\"" . EWIKI_SCRIPT . $str_rootid . "\">" . $str_rootid . "</a></li>";
    $fin_level = format_sitemap($a_sitemap, $str_rootid, $str_formatted, $level, $timer, $fordump);
    $str_formatted .= "</ul>" . str_pad("", $fin_level * 6, "</ul>\n");
    $o .= $str_formatted;
    //$timesitemap_end=getmicrotime();
    //$o.="GetAll: ".($time_end-$time)."\n";
    //$o.="SiteMap: ".($timesitemap_end-$timesitemap)."\n";
    //$o.="Total: ".($timesitemap_end-$time);
    return $o;
}
Exemplo n.º 15
0
function ewiki_view_append_blog($id, $data, $action)
{
    global $ewiki_config;
    if (!calendar_exists(false)) {
        return;
    }
    #-- conf
    ($n_num = $ewiki_config["wikinews_num"]) || ($n_num = 10);
    ($n_len = $ewiki_config["wikinews_len"]) || ($n_len = 512);
    $o = '<div class="text-blog">' . ewiki_wikinews_summary($n_num, $n_len, '/^' . $id . EWIKI_NAME_SEP . '\\d{8}$/') . '</div>';
    $o .= '<a href="' . ewiki_script("calendarlist", $id) . '">View all log entries.</a>';
    return $o;
}
Exemplo n.º 16
0
function ewiki_handler_jump(&$id, &$data, &$action)
{
    global $ewiki_config;
    static $redirect_count = 5;
    $jump_markup = array("jump", "goto", "redirect", "location");
    #-- we only care about "view" action
    if ($action != "view") {
        return;
    }
    #-- escape from loop
    if (isset($_REQUEST[EWIKI_UP_REDIRECT_COUNT])) {
        $redirect_count = $_REQUEST[EWIKI_UP_REDIRECT_COUNT];
    }
    if ($redirect_count-- <= 0) {
        return ewiki_t("REDIRECTION_LOOP", array("id" => $id));
    }
    #-- search for [jump:...]
    if ($links = explode("\n", trim($data["refs"]))) {
        foreach ($links as $link) {
            if (strlen($link) && strpos($link, ":") && in_array(strtolower(strtok($link, ":")), $jump_markup) && ($dest = trim(strtok("\n")))) {
                #-- URL
                $url = "";
                if (strpos($dest, "://")) {
                    $url = $dest;
                } else {
                    $url = ewiki_interwiki($dest, $uu, $uu2);
                }
                #-- Location:
                if (EWIKI_JUMP_HTTP && EWIKI_HTTP_HEADERS && !headers_sent()) {
                    #-- simple PageLink
                    if (empty($url)) {
                        $url = ewiki_script("", $dest, array(EWIKI_UP_REDIRECT_COUNT => $redirect_count), 0, 0, ewiki_script_url());
                        $url .= defined("SID") ? EWIKI_ADDPARAMDELIM . SID : "";
                    }
                    header("Location: {$url}");
                    die;
                } elseif ($url) {
                    return "";
                    # the rendering kernel will just show up the [jump:]!
                    # (without the jump: of course)
                } else {
                    #-- we'll just restart ewiki
                    $data = array();
                    $id = $dest;
                    return ewiki_page("view/" . $id);
                }
            }
        }
    }
    #-search
}
Exemplo n.º 17
0
function ewiki_page_wiki_dump_tarball($id = 0, $data = 0, $action = 0)
{
    #-- return legacy page
    if (empty($_REQUEST["download_tarball"])) {
        if ($action == "wikidump") {
            $url = ewiki_script("", "WikiDump");
            return ewiki_make_title($id, $id, 2) . ewiki_t(<<<END
_{WIKIDUMP}
<br /><br />
<form action="{$url}" method="POST" enctype="multipart/form-data">
<input type="hidden" name="dump_id" value="{$id}">
<input type="hidden" name="dump_depth" value=1>
<input type="submit" name="download_tarball" value= "_{DOWNLOAD_ARCHIVE}">
<br /><br />
<input type="checkbox" name="dump_images" value="1" checked> _{with images}<br />
<input type="hidden" name="dump_fullhtml" value="1">
<input type="hidden" name="dump_virtual" value="0"><br />
Archive Format:
<select NAME="dump_arctype">
  <option VALUE="ZIP">ZIP
  <option VALUE="TAR">TAR
</select>

</form>
END
);
        } else {
            return "";
        }
    } else {
        $di = $_REQUEST["dump_images"];
        $fh = $_REQUEST["dump_fullhtml"];
        $vp = $_REQUEST["dump_virtual"];
        $rp = $_REQUEST["dump_id"];
        #-- $_REQUEST["dump_depth"]==100 will give a complete dump
        if ($_REQUEST["dump_depth"] > EWIKI_WIKIDUMP_MAXLEVEL && $_REQUEST["dump_depth"] != 100) {
            $dd = EWIKI_WIKIDUMP_MAXLEVEL;
        } else {
            $dd = $_REQUEST["dump_depth"];
        }
        $at = $_REQUEST["dump_arctype"];
        $al = 9;
        #$_REQUEST["dump_arclevel"];
        $_REQUEST = $_GET = $_POST = array();
        if (!ewiki_auth($rp, $str_null, "view")) {
            return ewiki_make_title($id, $id, 2) . "<p>You either do not have permission to access the page {$rp} or it does not exist.</p>";
        }
        ewiki_page_wiki_dump_send($di, $fh, $vp, $rp, $dd, $at, $al);
    }
}
Exemplo n.º 18
0
function ewiki_add_action_link_for_translation($id, &$data, $action)
{
    global $language_comb, $language_service, $language_names, $ewiki_t, $ewiki_config;
    $o = "";
    $url = "";
    if ($data["version"]) {
        $lang_src = ewiki_guess_lang($data["content"]);
        #-- check if page is already in desired language
        if ($ewiki_t["languages"][0] == $lang_src) {
        } else {
            foreach ($ewiki_t["languages"] as $lang_dest) {
                $url = "";
                $comb = "{$lang_src}|{$lang_dest}";
                foreach ($language_service as $SERVICE => $params) {
                    if (in_array($comb, $language_comb[$SERVICE]) || $SERVICE == "intertran") {
                        if ($SERVICE == "babelfish") {
                            $lp = "&" . $params[1] . "=" . strtr($comb, "|", "_");
                        } elseif ($SERVICE == "google") {
                            $lp = "&" . $params[1] . "=" . $comb;
                        } else {
                            $from = $language_names[strtok($comb, "|")];
                            $to = $language_names[strtok("|")];
                            if (!$from || !$to) {
                                continue;
                            }
                            $lp = "&" . $params[1][0] . "=" . $from . "&" . $params[1][1] . "=" . $to;
                        }
                        $url = $params[0] . $lp . "&" . $params[2] . "=" . urlencode(ewiki_script($action, $id, "", 0, 0, ewiki_script_url()));
                        break;
                    }
                }
                #-- add translation link to page
                if ($url) {
                    $ewiki_config["action_links"]["view"][$url] = "TranslateInto" . $ewiki_t["C"][$lang_dest];
                    /*---
                         $o = "<br /><a class=\"tool-button\" href=\""
                         . $url . "\">"
                         . "TranslateInto" . $ewiki_t["C"][$lang_dest]
                         . "</a>\n";
                      ---*/
                    break;
                }
            }
        }
    }
    /*---
       return($o);
    ---*/
}
Exemplo n.º 19
0
function ewiki_mpi_brainfuck($action, $args, &$iii, &$s)
{
    global $ewiki_id;
    if ($action == "input") {
        return '<form action="' . ewiki_script("", $ewiki_id) . '">' . '<input name="i" type="text"> ' . '<input type="hidden" name="id" value="' . htmlentities($ewiki_id) . '">' . '<input type="submit"></form>';
    } else {
        $input = "";
        foreach ($_REQUEST as $i => $str) {
            if (strlen($i) == 1) {
                $input .= $str;
            }
        }
        return bf_exec($args["_"], $input);
    }
}
Exemplo n.º 20
0
function ewiki_aview_image_append($id, $data, $action)
{
    $URL = ewiki_script("imageappend", $id);
    $TXT = ewiki_t("IMAGEAPPEND_FORM0");
    $BTN1 = ewiki_t("UPLOAD_PICTURE_BUTTON");
    $accept = defined("EWIKI_IMAGE_ACCEPT") ? ' accept="' . EWIKI_IMAGE_ACCEPT . '">' : "";
    return <<<___
<div class="imageappend">
<form action="{$URL}" method="POST" enctype="multipart/form-data">
  {$TXT}
  <input type="file" name="imagefile" {$accept}><br />
  <input type="submit" value="{$BTN1}">
</form>
</div>
___;
}
Exemplo n.º 21
0
function ewiki_linking_titlefix(&$title, &$href, &$href2, &$type)
{
    global $ewiki_links;
    $href_mod = str_replace("  ", " ", $href);
    $href_mod = str_replace(' ', '_', $href);
    // Edit 'Nov09: replace spaces with underscores
    $find = ewiki_db::FIND(array($href_mod));
    if ($find[$href_mod]) {
        $str = '<a href="' . ewiki_script("", rawurlencode($href_mod)) . htmlentities($href2) . '">' . $title . '</a>';
        $type = array("wikipage", "title-swapped");
    } else {
        $str = '<span class="NotFound"><a href="' . ewiki_script("", rawurlencode($href_mod)) . htmlentities($href2) . '">' . $title . '</a></span>';
        $type = array("wikipage", "title-swapped");
    }
    return $str;
}
Exemplo n.º 22
0
function ewiki_mpi_call(&$str, &$in, &$iii, &$s)
{
    global $ewiki_plugins;
    #-- split out $mpi-action
    $str = trim($str);
    if ($str[0] == "-") {
        $mpi_action = substr(strtolower(strtok($str, " :\n\t\f\r")), 1);
        $str = ltrim(strtok(""));
    }
    switch ($mpi_action) {
        case "doc":
        case "desc":
        case "link":
            break;
        default:
            $mpi_action = "html";
    }
    #-- split mpi plugin name from arguments
    $mpi_name = trim(strtok($str, " \n\t\f\r"));
    $str = strtok("");
    #-- split args
    $mpi_args = array();
    $mpi_args["_"] = $str;
    ewiki_stripentities($mpi_args["_"]);
    if (preg_match_all('/(\\w+)="(.+)(?<![\\\\])"|(\\w+)=([^\\s]+)|([^\\s"=]+)/', $mpi_args["_"], $uu)) {
        $pos = 0;
        foreach ($uu[5] as $i => $d) {
            if (strlen($d)) {
                $mpi_args[$pos] = $d;
                $pos++;
            } elseif ($uu[$f = 1][$i] || $uu[$f = 3][$i]) {
                $mpi_args[$uu[$f][$i]] = stripslashes($uu[$f + 1][$i]);
            }
        }
        #-- std arg
        isset($mpi_args["id"]) or $mpi_args["id"] = $mpi_args[0] or $mpi_args["id"] = $mpi_args["page"];
    }
    #-- plugin-link
    if ($action == "link") {
        $str = '<a href="' . ewiki_script("mpi", $name, $args) . '">' . $name . '</a>';
        $iii[$in][1] = 0x10 | 0x20;
        # InlineBlock+ScanForWikiWords
    } else {
        $str = ewiki_mpi_exec($mpi_action, $mpi_name, $mpi_args, $iii, $s);
    }
}
Exemplo n.º 23
0
function ewiki_view_append_threads($id, $data, $action)
{
    if (isThread($id)) {
        return "";
    }
    $result = ewiki_db::SEARCH("id", $id . EWIKI_THREAD_SEPARATOR);
    while ($row = $result->get()) {
        if (!isPost($row["id"])) {
            $pages[$row["id"]] = "";
        }
    }
    if (0 != count($pages)) {
        $o = "<div class='wiki_threads'><small>" . ewiki_t('THREADS') . ":</small><br />";
        $o .= ewiki_list_pages($pages) . "</div>\n";
    }
    $o .= "<form action='" . ewiki_script('addthread', $id) . "' method='POST'>" . ewiki_t("NEWTHREAD") . ":  <input type='text' name='threadname'>" . "<input type='submit' value='Add Thread'>" . "</form>";
    return "<div class='wiki aview threads'>" . $o . '</div>';
}
Exemplo n.º 24
0
function ewiki_view_append_attachments($id, $data, $action)
{
    $o = '<hr><h4><a href="' . ewiki_script(EWIKI_ACTION_ATTACHMENTS, $id) . '">' . ewiki_t("ATTACHMENTS") . '</a></h4>';
    $scan = 's:7:"section";' . serialize($id);
    $result = ewiki_db::SEARCH("meta", $scan);
    $ord = array();
    while ($row = $result->get()) {
        $ord[$row["id"]] = $row["created"];
    }
    arsort($ord);
    foreach ($ord as $id => $uu) {
        $row = ewiki_db::GET($id);
        if (EWIKI_PROTECTED_MODE && EWIKI_PROTECTED_MODE_HIDING && !ewiki_auth($row["id"], $row, "view")) {
            continue;
        }
        $o .= ewiki_entry_downloads($row, "*");
    }
    return $o;
}
Exemplo n.º 25
0
function ewiki_mpi_bugreportstate($action, $args, &$iii, &$s)
{
    global $ewiki_id;
    #-- possible states
    $values = array("open", "closed", "done", "frozen", "answered");
    foreach ($args as $i => $name) {
        if (is_int($i)) {
            if (preg_match("/^\\w+\$/", $name) && !in_array($name, $values)) {
                $values[] = $name;
            }
        }
    }
    $rxvals = implode("|", $values);
    #-- if button pressed
    if (($new = $_REQUEST["brs_change"]) && in_array($new, $values)) {
        $pages = ewiki_get_backlinks($ewiki_id);
        $pages[] = $ewiki_id;
        #-- change assoc pages
        foreach ($pages as $id) {
            $data = ewiki_db::GET($id);
            if (preg_match("/\n\\|.*stat(e|us).*\\|.*({$rxvals})/", $data["content"]) or preg_match("/\n\\|.*({$rxvals}).*\\|.*{$ewiki_id}/", $data["content"])) {
                $data["content"] = preg_replace("/(\n\\|.*stat(?:e|us).*\\|.*?)[_*]*(?:{$rxvals})[_*]*/", "\$1{$new}", $data["content"]);
                $data["content"] = preg_replace("/(\n\\|.*?)[_*]*(?:{$rxvals})[_*]*(.*?\\|.*{$ewiki_id})/", "\$1{$new}\$2", $data["content"]);
                ewiki_db::UPDATE($data);
                $data["version"]++;
                ewiki_db::WRITE($data);
            }
        }
        $o = "<p>(status changed)</p>";
        $iii[0][0] = preg_replace("/({$rxvals})/", "{$new}", $iii[0][0]);
    } else {
        $url = ewiki_script("", $ewiki_id);
        $o .= <<<EOT
<form action="{$url}#added" method="POST" enctype="multipart/form-data">
<input type="submit" name="brs_change" value="open">
<input type="submit" name="brs_change" value="closed">
<input type="submit" name="brs_change" value="frozen">
</form>
EOT;
    }
    return $o;
}
Exemplo n.º 26
0
function ewiki_mpi_addlink($action, $args, &$iii, &$s)
{
    global $ewiki_id, $ewiki_action;
    $o = "";
    #-- add URL
    if ($_REQUEST["link_save"]) {
        #-- check parameters
        $url = trim($_REQUEST["link_url"]);
        $text = "";
        $title = $desc = "";
        if (!strpos($url, "example.com") && strlen($url) > 12 && preg_match('#^https?://#', $url)) {
            $text = implode("", file($url));
            if ($text) {
                preg_match('#<title[^>]*>([^<]+)</title>#ims', $text, $uu) and $title = $uu[1] or preg_match('#//([^/]+)#', $url, $uu) and $title = $uu[1];
                preg_match('#<meta[^>]+name=["\']description["\'][^>]+content=["\']([^"\']+)["\']#ims', $text, $uu) and $desc = $uu[1] or preg_match('#<body[^>]+>(.+?)</body#ims', $text, $uu) and $desc = strip_tags($uu[1]);
                $desc = substr(preg_replace('/\\s+/', " ", $desc), 0, 300);
            }
            $add = ":{$title}:\n   {$url} %%%\n   {$desc}\n";
        }
        #-- store bugreport
        if ($text) {
            $data = ewiki_db::GET($ewiki_id);
            $data["content"] = rtrim($data["content"]) . "\n" . $add;
            ewiki_data_update($data);
            $data["version"]++;
            ewiki_db::WRITE($data);
            #-- append to page output
            $iii[] = array($add, 0xffff, "core");
        }
    } else {
        $url = ewiki_script("", $ewiki_id);
        $o .= <<<EOT
<form style="border:2px #333370 solid; background:#7770B0; padding:5px;"class="BugReport" action="{$url}" method="POST" enctype="multipart/form-data">
<input type="hidden" name="id" value="{$ewiki_action}/{$ewiki_id}">
Link <input type="text" name="link_url" value="http://www.example.com/" size="50">
<input type="submit" name="link_save" value="hinzufügen">
</form>
EOT;
    }
    return $o;
}
Exemplo n.º 27
0
function ewiki_linking_findany($moniker, $page)
{
    global $ewiki_config;
    #-- lists
    $page_i = strtolower($page);
    $search = array_merge($ewiki_config["instant"], $ewiki_config["interwiki"]);
    foreach ($search as $pn => $url) {
        if (strtolower($pn) == $page_i) {
            return $url;
        }
    }
    #-- find a page
    $result = ewiki_db::SEARCH("id", $page_i);
    while ($row = $result->get()) {
        if (($row["flags"] & EWIKI_DB_F_TYPE) == EWIKI_DB_F_TEXT) {
            return ewiki_script("", $row["id"]);
        }
    }
    #-- Google saves the day!
    return "http://www.google.com/search?q=" . urlencode($page);
}
Exemplo n.º 28
0
function ewiki_page_hitcounter($id, $data, $action)
{
    #-- loop thur all pages, and mk sum
    $n = 0;
    $result = ewiki_db::GETALL(array("hits"));
    while ($r = $result->get()) {
        if ($r["flags"] & EWIKI_DB_F_TEXT) {
            $n += $r["hits"];
        }
    }
    #-- output
    $title = ewiki_make_title($id, $id, 2);
    $AllPages = '<a href="' . ewiki_script("", "PageIndex") . '">AllPages</a>';
    $o = <<<___
{$title}
The overall hit score of {$AllPages} is:
<div class="counter">
  {$n}
</div>
___;
    return $o;
}
Exemplo n.º 29
0
function ewiki_action_verdiff($id, $data, $action)
{
    global $ewiki_plugins, $ewiki_diff_versions;
    if (($v0 = (int) $_REQUEST["from"]) && ($v1 = (int) $_REQUEST["to"])) {
        $ewiki_diff_versions = array($v0, $v1);
        return $ewiki_plugins["action"]["diff"]($id, $data, $action);
    } else {
        $o = ewiki_make_title($id, "{$id} version differences");
        $o .= '<form action="' . ewiki_script($action, $id) . '" method="GET">';
        $o .= '<input type="submit" value="diff">';
        $o .= '<input type="hidden" name="id" value="' . $action . "/" . htmlentities($id) . '">';
        $o .= "\n" . '<table border="1" class="diff"><tr>' . "<th>from</th> <th>to</th> <th>version</th> <th>mtime</th> " . "<th>size</th> <th>author</th></tr>\n";
        for ($n = $data["version"]; $n >= 1; $n--) {
            $data = ewiki_db::GET($id, $n);
            if (EWIKI_DB_F_TEXT == ($data["flags"] & EWIKI_DB_F_TYPE)) {
                $o .= "<tr>" . '<td><input type="radio" name="from" value="' . $n . '"></td>' . '<td><input type="radio" name="to" value="' . $n . '"></td>' . "<td>#{$n}</td>" . "<td>" . strftime("%Y-%m-%d %H:%M", $data["last_modified"]) . "</td>" . "<td>" . strlen($data["content"]) . "</td>" . "<td>" . $data["author"] . "</td>" . "</tr>\n";
            }
        }
        $o .= "</table>\n";
        $o .= "</form>\n";
    }
    return $o;
}
Exemplo n.º 30
0
function ewiki_aedit_templates(&$html, $id, &$data, $action)
{
    if (!$data["content"]) {
        #-- search template pages
        $list = array();
        $result = ewiki_db::SEARCH("id", "Template");
        while ($row = $result->get(0, 0x21, EWIKI_DB_F_TEXT)) {
            if (preg_match('/Template$/', $row["id"])) {
                $list[] = $row["id"];
            }
        }
        #-- add list
        if ($list) {
            $o = '<form action="' . ewiki_script("", $id) . '" method="POST" entype="multipart/form-data">' . '<input type="hidden" name="id" value="' . $action . '/' . $id . '">' . '<input type="submit" value="load"> ' . '<select name="load_template">';
            foreach ($list as $i) {
                $o .= '<option value="' . $i . '">' . $i . '</option>';
            }
            $o .= '</select></form>';
            #-- output
            $html = $o . $html;
        }
    }
}