Exemple #1
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;
}
Exemple #2
0
function ewiki_page_recentchanges($recentchanges, $data, $action)
{
    global $ewiki_plugins, $ewiki_links;
    #-- start output
    $ewiki_links = true;
    $o = "";
    $o .= ewiki_make_title($recentchanges, $recentchanges, 2);
    #-- options
    $minor_edits = $_GET["minor"] ? 1 : 0;
    #-- select timeframe
    if (($days = $_REQUEST["days"]) < 1) {
        $days = 7;
    }
    $timeframe = time() - $days * 24 * 3600;
    #-- fetch pages modified in given timeframe
    $result = ewiki_db::GETALL(array("meta", "lastmodified", "author"));
    $changes = array();
    $meta = array();
    while ($row = $result->get(0, 0x137, EWIKI_DB_F_TEXT)) {
        if ($row["lastmodified"] >= $timeframe) {
            #-- id->time array
            $id = $row["id"];
            $changes[$id] = $row["lastmodified"];
            #-- collect also info for previous changes of current page
            $meta[$id] = array();
            ewiki_page_rc_more($row, $meta[$id], $timeframe, $minor_edits);
        }
    }
    #-- sort results into date catalogue
    arsort($changes);
    $last_date = "";
    $datestr = ewiki_t("DAY");
    $e = array();
    foreach ($changes as $id => $date) {
        $date = strftime($datestr, $date);
        if ($date != $last_date) {
            $last_date = $date;
        }
        $e[$date][] = $id;
        unset($changes[$id]);
    }
    #-- mk output
    $o .= $ewiki_plugins["rc"][0]($e, $meta);
    #-- add an <form>
    if ($days == 7) {
        $days = 30;
    }
    $url = ewiki_script("", $recentchanges);
    $o .= ewiki_t(<<<EOT
   <br />
   <form action="{$url}" method="GET">
     <input type="hidden" name="id" value="{$recentchanges}">
     _{show last} <input type="text" name="days" value="{$days}" size="5">
     <input type="submit" value="_{days}">
   </form>
   <br />
EOT
);
    return $o;
}
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;
    }
}
Exemple #4
0
function ewiki_page_pluginstall($id, $data, $action)
{
    global $ewiki_config, $ewiki_plugins;
    $jpi_support = function_exists("js_compile") && function_exists("jsa_generate");
    $jpi_access = XPI_EVERYBODY_JPI && $jsi_support;
    #-- title
    $o .= ewiki_make_title($id, $id, 2);
    $o .= '<form action="' . $_SERVER["REQUEST_URI"] . '" method="POST" enctype="multipart/form-data">' . '<input type="hidden" name="id" value="' . htmlentities($id) . '">';
    #-- pw, access
    $access = 0;
    $o .= ewiki_xpi_password($access, $jpi_access);
    #-- upload & install
    if ($access || $jpi_access) {
        $o .= '<div class="xpi-upload"><h4>.xpi plugin upload</h4>';
        #-- if filename received => upload+install
        if ($xpi_install_fn = $_REQUEST["install_remote_xpi"] or $_REQUEST["install_xpi"] && ($xpi_install_fn = $_FILES["xpi_file"]["tmp_name"])) {
            $o .= ewiki_xpi_install($xpi_install_fn, $access, $jsi_access, $jsi_support);
        } else {
            $o .= ewiki_xpi_show_remote_repository();
            $o .= ewiki_xpi_upload_form();
        }
        $o .= '</div><br />';
    }
    #-- plugin control
    $o .= ewiki_xpi_plugin_control_centre();
    return $o;
}
Exemple #5
0
function ewiki_extract($id, $data, $action)
{
    global $ewiki_links, $ewiki_config, $ewiki_plugins, $ewiki_ring, $ewiki_title;
    $extracttypes = $ewiki_config["extracttypes"][$action];
    $o = ewiki_make_title($id, ewiki_t(strtoupper($action) . "FROM") . $ewiki_title, 2, $action, "", "_MAY_SPLIT=1");
    //ignore any number of list markup tags in front of an @@{todotype},
    //extract only the @@, the types, and their message
    //or
    //extract any header line
    //1 2         3  4-Class                      5     6
    preg_match_all("/^(([-;:#\\* ]*)(@@(" . implode("|", $extracttypes) . ")(.*))|(!+.*))\$/im", $data["content"], $matches);
    for ($index = 0; $index < sizeof($matches[0]); $index++) {
        //a line will be either header or todo, concatenate the two sub expressions
        $extractedContent .= $matches[3][$index] . $matches[6][$index] . "\n\n";
    }
    //Render extracted lines as a wiki page, this code extracted from ewiki_page
    #-- render requested wiki page  <-- goal !!!
    $o .= "<div class='ewiki_page_todolist'>" . $ewiki_plugins["render"][0]($extractedContent . ewiki_t(strtoupper($action) . "POSTSCRIPT"), 1, EWIKI_ALLOW_HTML || @$data["flags"] & EWIKI_DB_F_HTML) . "</div>";
    #-- control line + other per-page info stuff
    if ($pf_a = $ewiki_plugins["view_append"]) {
        ksort($pf_a);
        foreach ($pf_a as $n => $pf) {
            $o .= $pf($id, $data, $action);
        }
    }
    if ($pf_a = $ewiki_plugins["view_final"]) {
        ksort($pf_a);
        foreach ($pf_a as $n => $pf) {
            if (!preg_match('/_title/', $pf)) {
                $pf($o, $id, $data, $action);
            }
        }
    }
    return $o;
}
Exemple #6
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;
}
Exemple #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);
    }
}
Exemple #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;
}
Exemple #9
0
function ewiki_page_wordindex($id, $data, $action)
{
    global $ewiki_plugins;
    $o = ewiki_make_title($id, $id, 2);
    $src = "";
    $result = ewiki_db::GETALL(array("flags"));
    while ($row = $result->get()) {
        if (EWIKI_PROTECTED_MODE && EWIKI_PROTECTED_MODE_HIDING && !ewiki_auth($row["id"], $uu, "view")) {
            continue;
        }
        if (($row["flags"] & EWIKI_DB_F_TYPE) == EWIKI_DB_F_TEXT) {
            $src .= " " . $row["id"];
        }
    }
    $src = ewiki_split_title($src, "SPLIT", 0);
    $chars = strtr(EWIKI_CHARS_U . EWIKI_CHARS_L, "_", " ");
    $src = preg_replace("/[^{$chars}]/", " ", $src);
    $src = explode(" ", $src);
    $src = array_unique($src);
    //@ADD: word counting
    unset($src[""]);
    natcasesort($src);
    $sorted = array();
    foreach ($src as $i => $word) {
        if (strlen($word) >= 2) {
            $sorted[] = array(EWIKI_PAGE_POWERSEARCH, array("where" => "id", "q" => $word), $word, "");
        }
    }
    unset($src);
    $pf_list_pages = $ewiki_plugins["list_dict"][0];
    $o .= ewiki_list_pages($sorted, $limit = 0, $vat = 1, $pf_list_pages);
    return $o;
}
Exemple #10
0
/**
 * changes user preferences based on form input
 *
 * @param mixed id
 * @param mixed data
 * @return mixed
 */
function ewiki_page_liveuser_chprefs($id, $data)
{
    global $liveuser, $liveuserDB;
    // if form was submitted, write
    if (isset($_REQUEST['submit_prefs'])) {
        return ewiki_t('CHPWFORM');
    }
    ob_start();
    echo ewiki_make_title($id, $id, 2);
    $results = $liveuserDB->getAll('SELECT * FROM ' . LW_PREFIX . '_prefs_fields');
    foreach ($results as $result) {
        if (isset($_REQUEST[$result['field_name']])) {
            liveuser_pref_setPref($liveuser->getHandle(), $result['field_name'], $_REQUEST[$result['field_name']]);
        }
    }
    echo '<form action="" method="post"><table border="1">';
    foreach ($results as $result) {
        echo '<tr><td>';
        echo '<label for="' . $result['field_name'] . '">' . $result['field_name'] . '</label></td><td>';
        echo '<input id="' . $result['field_name'] . '" name="' . $result['field_name'] . '" type="text" ';
        echo ' value=' . liveuser_pref_getPref($liveuser->getHandle(), $result['field_name']) . '></td></tr>';
    }
    echo '<tr><td colspan="2"><input type="reset" text="Reset"><input type="submit"></td></tr></table></form>';
    $o = ob_get_contents();
    ob_end_clean();
    return $o;
}
Exemple #11
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;
}
function ewiki_page_gnu_diff_safemode($id, &$data, $action)
{
    #-- different operation modes of GNU diff:
    $OPTIONS = " -B -u -U 50 ";
    #   $OPTIONS = " -B ";
    #   $OPTIONS = " -c ";
    #   $OPTIONS = " --side-by-side ";
    #-- fetch old wiki source
    if (($old_ver = ($new_ver = $data["version"]) - 1) > 0) {
        $data0 = ewiki_db::GET($id, $old_ver);
    }
    $o = ewiki_make_title($id, "Differences between version {$new_ver} and {$old_ver} of »{$id}«");
    #-- create temporary files from wikipages
    $file0 = tempnam(EWIKI_TMP, "ewiki.diff.gnu.");
    $f = fopen($file0, "w");
    fwrite($f, $data0["content"]);
    fclose($f);
    $file1 = tempnam(EWIKI_TMP, "ewiki.diff.gnu.");
    $f = fopen($file1, "w");
    fwrite($f, $data["content"]);
    fclose($f);
    #-- parse thru GNU diff util
    $fn = addslashes($id);
    $OPTIONS .= " --label='{$fn} (version {$old_ver})' --label='{$fn} (version {$new_ver})' ";
    //following lines replace the original
    //$diff = shell_exec("diff $OPTIONS $file0 $file1");
    $dfd = popen("diff {$OPTIONS} {$file0} {$file1}", "r");
    $diff = "";
    while (!feof($dfd)) {
        $diff .= fread($dfd, 5000);
    }
    pclose($dfd);
    //end of moderation
    #-- remove temporary files
    unlink($file0);
    unlink($file1);
    #-- encolor diff output
    foreach (explode("\n", $diff) as $dl) {
        $str = substr($dl, 1);
        switch (substr($dl, 0, 1)) {
            case "<":
            case "-":
                $o .= "<b>-</b><font color=\"#990000\"> <tt>{$str}</tt></font><br />\n";
                break;
            case ">":
            case "+":
                $o .= "<b>+</b><font color=\"#009900\"> <tt>{$str}</tt></font><br />\n";
                break;
            case "*":
            case "-":
                break;
            default:
                $o .= "<small><tt>{$dl}</tt></small><br />";
        }
    }
    return $o;
}
Exemple #13
0
function ewiki_page_wikinews($newsid, $data, $action)
{
    global $ewiki_config;
    #-- conf
    ($n_num = $ewiki_config["wikinews_num"]) || ($n_num = 10);
    ($n_len = $ewiki_config["wikinews_len"]) || ($n_len = 512);
    ($c_regex = $ewiki_config["wikinews_regex"]) || ($c_regex = false);
    return ewiki_make_title($newsid, $newsid, 2) . ewiki_wikinews_summary($n_num, $n_len, $c_regex);
}
Exemple #14
0
function ewiki_password_status($id, &$data, $action)
{
    global $liveuser;
    $passwd_status = ewiki_get_uservar("passwdstatus", 'expired');
    if ($passwd_status != 'good' && $id != "Logout" && $id != "ChangePassword" && $liveuser->isLoggedIn()) {
        return ewiki_make_title($id, "Change Password:"******"<p>You password has expired</p>" . ewiki_t("CHPW_FORM");
    }
    return 0;
}
Exemple #15
0
function ewiki_page_ewikilog($id, $data, $action)
{
    ob_start();
    echo ewiki_make_title($id, $id, 2);
    echo '<pre>';
    readfile(EWIKI_LOGFILE);
    echo '</pre>';
    $o = ob_get_contents();
    ob_end_clean();
    return $o;
}
Exemple #16
0
function ewiki_page_interwikimap($id, $data, $action)
{
    global $ewiki_config;
    $o = ewiki_make_title($id, $id, 1);
    $o .= '<dl id="InterWikiMap">' . "\n";
    foreach ($ewiki_config["interwiki"] as $shortcut => $url) {
        $o .= "<dt>{$shortcut}:</dt>\n" . "   <dd><a href=\"{$url}\">{$url}</a></dd>\n";
    }
    $o .= "</dl>";
    return $o;
}
Exemple #17
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;
}
Exemple #18
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);
    }
}
Exemple #19
0
function ewiki_page_stupid_diff($id, $data, $action)
{
    if ($uu = $GLOBALS["ewiki_diff_versions"]) {
        list($new_ver, $old_ver) = $uu;
        $data = ewiki_db::GET($id, $new_ver);
    } else {
        $new_ver = $data["version"];
        $old_ver = $new_ver - 1;
    }
    if ($old_ver > 0) {
        $data0 = ewiki_db::GET($id, $old_ver);
    }
    $o = ewiki_make_title($id, "Differences between version {$new_ver} and {$old_ver} of »{$id}«");
    $o .= ewiki_stupid_diff($data["content"], $data0["content"]);
    return $o;
}
Exemple #20
0
function ewiki_page_like($id, $data, $action)
{
    preg_match_all("/([" . EWIKI_CHARS_U . "][" . EWIKI_CHARS_L . "]+)/", $id, $words);
    $pages = array();
    foreach ($words[1] as $find) {
        $result = ewiki_db::SEARCH("id", $find);
        while ($row = $result->get()) {
            if (EWIKI_PROTECTED_MODE && EWIKI_PROTECTED_MODE_HIDING && !ewiki_auth($row["id"], $row, "view")) {
                continue;
            }
            $pages[$row["id"]] = "";
        }
    }
    $o = ewiki_make_title($id, ewiki_t(strtoupper($action) . "_TITLE"), 3);
    $o .= ewiki_list_pages($pages, 0);
    return $o;
}
function ewiki_page_orphanedpages($id, $data, $action)
{
    global $ewiki_links;
    $o = ewiki_make_title($id, ewiki_t($id), 2);
    $pages = array();
    $refs = array();
    $orphaned = array();
    #-- read database
    $db = ewiki_database("GETALL", array("refs", "flags"));
    $n = 0;
    while ($row = $db->get()) {
        $p = $row["id"];
        #-- remove self-reference
        $row["refs"] = str_replace("\n{$p}\n", "\n", $row["refs"]);
        #-- add to list of referenced pages
        $rf = explode("\n", trim($row["refs"]));
        $refs = array_merge($refs, $rf);
        if ($n++ > 299) {
            $refs = array_unique($refs);
            $n = 0;
        }
        // (clean-up only every 300th loop)
        #-- add page name
        if (($row["flags"] & EWIKI_DB_F_TYPE) == EWIKI_DB_F_TEXT) {
            $pages[] = $row["id"];
        }
    }
    $refs = array_unique($refs);
    #-- check pages to be referenced from somewhere
    foreach ($pages as $p) {
        if (!ewiki_in_array($p, $refs)) {
            if (!EWIKI_PROTECTED_MODE || EWIKI_PROTECTED_MODE_HIDING || ewiki_auth($p, $uu, "view")) {
                $orphaned[] = $p;
            }
        }
    }
    #-- output
    $o .= ewiki_list_pages($orphaned, 0);
    return $o;
}
Exemple #22
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;
}
function ewiki_auth_query_form(&$data, $force_query = 0)
{
    global $ewiki_plugins, $ewiki_config, $ewiki_errmsg, $ewiki_id, $ewiki_action, $ewiki_author, $ewiki_ring;
    $o =& $ewiki_errmsg;
    #-- get user/pw from POST or COOKIE
    if ($_POST["login_user"]) {
        $_user = $_REQUEST["login_user"];
        $_pw = $_REQUEST["login_pw"];
    } elseif ($_COOKIE["ewiki_login"]) {
        list($_user, $_pw) = explode(":", base64_decode($_COOKIE["ewiki_login"]));
    }
    #-- check password
    $_success = 0;
    if (strlen($_user) && strlen($_pw)) {
        $_success = ewiki_auth_user($_user, $_pw);
    }
    #-- store login data as Cookie
    if ($_success && $_POST["login_user"]) {
        setcookie("ewiki_login", base64_encode("{$_user}:{$_pw}"), time() + 7 * 24 * 3600);
    }
    #-- login form
    if ($force_query && !$_success || $force_query >= 2) {
        #-- it's safe to call this plugin for interception of running submits
        $_REPOST = "";
        if (defined("EWIKI_AUTH_QUERY_SAFE")) {
            foreach ($_POST as $i => $v) {
                if ($i == "login_name" || $i == "login_pw") {
                    continue;
                }
                $_REPOST .= '<input type="hidden" name="' . $i . '" value="' . preg_replace('/([^\\w\\d\\260-\\377])/e', '"&#".ord("$1").";"', $v) . '">' . "\n";
            }
            $_REPOST = '<!-- $_REPOST -->' . "\n" . $_REPOST . '<!-- $_END -->' . "\n";
        }
        #-- print
        $o = '<div class="login-form auth-login">' . ewiki_make_title($ewiki_id, "Login", $_title_class = 4, $ewiki_action, $_go_action = "info") . ewiki_t("LOGIN_QUERY") . "\n<br /><br />\n" . '<form action="' . $_SERVER["REQUEST_URI"] . '" method="POST">' . "\n" . ewiki_t('_{user} <input type="text" size="14" name="login_user"><br />' . "\n" . '_{password} <input type="password" size="10" maxsize="12" name="login_pw"><br /><br />' . "\n" . '<input type="submit" value="_{login}"><br /><br />' . "\n") . $_REPOST . "</form><br /><br />\n" . ewiki_t("LOGIN_QUERY_2") . '</div>';
    }
    #-- end
    return $_success;
}
Exemple #24
0
function ewiki_page_index($id = 0, $data = 0, $action = 0, $args = array())
{
    global $ewiki_plugins;
    $o = ewiki_make_title($id, ewiki_t($id), 2);
    $sorted = array();
    $sorted = array_merge($sorted, array_keys($ewiki_plugins["page"]));
    $exclude = "\n" . implode("\n", preg_split("/\\s*[,;:\\|]\\s*/", $args["exclude"])) . "\n";
    $result = ewiki_database("GETALL", array("flags"));
    while ($row = $result->get()) {
        if (EWIKI_PROTECTED_MODE && EWIKI_PROTECTED_MODE_HIDING && !ewiki_auth($row["id"], $uu, "view")) {
            continue;
        }
        if (($row["flags"] & EWIKI_DB_F_TYPE) == EWIKI_DB_F_TEXT) {
            if (!stristr($exclude, "\n" . $row["id"] . "\n")) {
                $sorted[] = $row["id"];
            }
        }
    }
    natcasesort($sorted);
    $o .= ewiki_list_pages($sorted, 0, 0, $ewiki_plugins["list_dict"][0]);
    return $o;
}
Exemple #25
0
function ewiki_editable_intermap($id, $data, $action)
{
    global $ewiki_config;
    $o = "";
    if (($url = $_REQUEST["add_url"]) && ($moni = $_REQUEST["add_moniker"])) {
        if (!preg_match('#^http[sz]?://(\\w{2,}\\.)+\\w{2,}(:\\d+)?[^\\[\\]\\"\\s]+$#', $url) || strpos($url, "example")) {
            $o .= "URL was rejected.";
        } elseif (!preg_match('#^([' . EWIKI_CHARS_U . ']+[' . EWIKI_CHARS_L . ']+){2,}[' . EWIKI_CHARS . ']+$#', $moni) || $moni == "WikiName") {
            $o .= "Choosen InterWiki moniker not acceptable.";
        } else {
            if ($ewiki_config["interwiki"][$moni]) {
                $o .= "(Note: eventually overriding earlier entry.)<br />";
            }
            $data["content"] = "\n" . trim($data["content"]) . "\n" . ":{$moni}:{$url}" . "\n";
            ewiki_data_update($data);
            $data["version"]++;
            if (ewiki_db::WRITE($data)) {
                $o .= "Map was updated.";
            } else {
                $o .= "Error occoured when saving your changes.";
            }
        }
        $o .= "<br />";
    }
    $o .= ewiki_make_title($id, $id, 2);
    $o .= ewiki_page_view($id, $data, $action, 0);
    $o .= ewiki_t(<<<EOT
    <form class="intermap-append" action="{$_SERVER['REQUEST_URI']}" method="POST" enctype="multipart/form-data">
      <hr>
      <input type="hidden" name="id" value="{$id}">
      :<input name="add_moniker" value="WikiName" size="16">:<input name="add_url" value="http://www.example.com/..." size="42">
      <br />
      <input type="submit" value="_{add}">
    </form>
EOT
);
    return $o;
}
Exemple #26
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;
}
Exemple #27
0
function ewiki_page_powersearch($id, &$data, $action)
{
    $q = @$_REQUEST["q"];
    $where = preg_replace('/[^a-z]/', '', @$_REQUEST["where"]) or $where = "content";
    $o = ewiki_make_title($id, $id, 2);
    if (empty($q)) {
        $o .= '<div class="search-form">
        <form name="powersearch" action="' . ewiki_script("", $id) . '" method="GET">
        <input type="hidden" name="id" value="' . $id . '">
        <input type="text" id="q" name="q" size="30">
        in <select name="where"><option value="content">page texts</option><option value="id">titles</option><option value="author">author names</option></select>
        <br /><br />
        <input type="submit" value=" &nbsp; &nbsp; S E A R C H &nbsp; &nbsp; ">
        </form></div>
        <script type="text/javascript"><!--
        document.powersearch.q.focus();
        //--></script>';
        return $o;
    } else {
        $o .= ewiki_powersearch($q, $where);
        return $o;
    }
    return '';
}
function ewiki_cache_generated_pages($id, &$data, $action)
{
    global $ewiki_plugins, $ewiki_ring;
    $o = ewiki_make_title($id, $id, 1);
    if (empty($_REQUEST["generate_cache"])) {
        $o .= "Use this page plugin/tool to generate text database entries for\nall generated ('internal' or 'static') pages available, so those can later\nbe found using the search functions.<br /><br />";
        $o .= '<form action="' . ewiki_script("", $id) . '" method="POST" enctype="text/html">' . '<input type="hidden" name="id" value="' . $id . '">' . '<input type="submit" value="generate cache" name="generate_cache">' . '</form>';
    } elseif (!ewiki_auth($id, $data, $action, $ring = 0, "_FORCE_AUTH=1") || !isset($ewiki_ring) || $ewiki_ring > 0) {
        if (is_array($data)) {
            $data = "You'll need to be admin. See ewiki_auth() and _PROTECTED_MODE in the README.";
        }
        $o .= $data;
    } else {
        unset($_REQUEST["generate_cache"]);
        $o .= "generating cache versions from:<ul>\n";
        foreach ($ewiki_plugins["page"] as $pid => $pf) {
            #echo "$pid:";
            $d = ewiki_db::GET($pid);
            if (empty($d) || empty($d["content"])) {
                $d = array("id" => $pid, "version" => 1, "flags" => EWIKI_DB_F_TEXT, "created" => time(), "content" => "", "meta" => "", "hits" => 0, "refs" => "");
            }
            $d["last_modified"] = time();
            $d["hits"]++;
            $d["content"] = $pf($pid, $d, "view");
            //@ADD - transform <html> back to wikimarkup
            //       here?
            if (ewiki_db::WRITE($d, true)) {
                $o .= "<li>{$pid}</li>\n";
            }
            unset($d);
        }
        $o .= "</ul>";
        ewiki_log("page search cache was updated", 2);
    }
    return $o;
}
function moodle_ewiki_page_wiki_dump($id = 0, $data = 0, $action = 0)
{
    global $userid, $groupid, $cm, $wikipage, $wiki, $course, $CFG;
    #-- return legacy page
    $cont = true;
    if (!empty($_REQUEST["wikiexport"])) {
        $binaries = $_REQUEST["exportbinaries"];
        if (!$wiki->ewikiacceptbinary) {
            $binaries = 0;
        }
        $exportformats = $_REQUEST["exportformats"];
        if ($wiki->htmlmode == 2) {
            $exportformats = 1;
        }
        $cont = ewiki_page_wiki_dump_send($binaries, $exportformats, $_REQUEST["withvirtualpages"], $_REQUEST["exportdestinations"]);
    }
    if ($cont === false) {
        die;
    }
    $url = ewiki_script("", "WikiExport");
    $ret = ewiki_make_title($id, ewiki_t($id), 2);
    $ret .= $cont && $cont !== true ? $cont . "<br /><br />\n" : "";
    $ret .= get_string("wikiexportcomment", "wiki");
    // removing name="form" from the following form as it does not validate
    // and is not referenced. MDL-7861
    $ret .= "<br /><br />\n" . '<FORM method="post" action="view.php">' . "\n" . "<div class=\"wikiexportbox\">\n" . '<INPUT type="hidden" name="page" value="WikiExport" />' . "\n" . '<INPUT type="hidden" name="userid" value="' . $userid . '" />' . "\n" . '<INPUT type="hidden" name="groupid" value="' . $groupid . '" />' . "\n" . '<INPUT type="hidden" name="id" value="' . $cm->id . '" />' . "\n" . '<INPUT type="hidden" name="wikipage" value="' . $wikipage . '" />' . "\n";
    // Export binaries too ?
    if (!$wiki->ewikiacceptbinary) {
        $ret .= '<INPUT type="hidden" name="exportbinaries" value="0" />' . $exportdestinations[0] . "\n";
    } else {
        $ret .= '<INPUT type="hidden" name="exportbinaries" value="0" />' . "\n";
    }
    $ret .= "<TABLE cellpadding=\"5\">\n";
    if ($wiki->ewikiacceptbinary) {
        $ret .= "  <TR valign=\"top\">\n" . '    <TD align="right">' . get_string("withbinaries", "wiki") . ":</TD>\n" . "    <TD>\n" . '      <input type="checkbox" name="exportbinaries" value="1"' . ($_REQUEST["exportbinaries"] == 1 ? " checked" : "") . " />\n" . "    </TD>\n" . "  </TR>\n";
    }
    $ret .= "  <TR valign=\"top\">\n" . '    <TD align="right">' . get_string("withvirtualpages", "wiki") . ":</TD>\n" . "    <TD>\n" . '      <input type="checkbox" name="withvirtualpages" value="1"' . ($_REQUEST["withvirtualpages"] == 1 ? " checked" : "") . " />\n" . "    </TD>\n" . "  </TR>\n";
    $exportformats = array("0" => get_string("plaintext", "wiki"), "1" => get_string("html", "wiki"));
    /// Formats
    $ret .= "  <TR valign=\"top\">\n" . '    <TD align="right">' . get_string("exportformats", "wiki") . ":</TD>\n" . "    <TD>\n";
    if ($wiki->htmlmode != 2) {
        $ret .= choose_from_menu($exportformats, "exportformats", $_REQUEST["exportformats"], "", "", "", true) . "\n";
    } else {
        $ret .= '<INPUT type="hidden" name="exportformats" value="1" />' . get_string("html", "wiki");
    }
    $ret .= "    </TD>\n" . "  </TR>\n";
    /// Destination
    $exportdestinations = array("0" => get_string("downloadaszip", "wiki"));
    if (wiki_is_teacher($wiki)) {
        // Get Directory List
        $rawdirs = get_directory_list("{$CFG->dataroot}/{$course->id}", 'moddata', true, true, false);
        foreach ($rawdirs as $rawdir) {
            $exportdestinations[$rawdir] = get_string("moduledirectory", "wiki") . ": " . $rawdir;
        }
    }
    $ret .= "  <TR valign=\"top\">\n" . '    <TD align="right">' . get_string("exportto", "wiki") . ":</TD>\n" . "    <TD>\n";
    if (count($exportdestinations) == 1) {
        $ret .= '<INPUT type="hidden" name="exportdestinations" value="0" />' . $exportdestinations[0] . "\n";
    } else {
        $ret .= choose_from_menu($exportdestinations, "exportdestinations", $_REQUEST["exportdestinations"], "", "", "", true) . "\n";
    }
    $ret .= "    </TD>\n" . "  </TR>\n" . "</TABLE>\n" . '  <input type="submit" name="wikiexport" value= "' . get_string("export", "wiki") . '" />' . "\n" . "</div>\n";
    "</FORM>\n";
    return $ret;
}
/**
 * admin gui for modifying LiveUser perms
 *
 * @param string id
 * @param mixed data
 * @param string action
 * @return string page output response
 */
function ewiki_page_liveuser_admin_perms($id, $data, $action)
{
    global $liveuserDB, $liveuserPermAdmin, $liveuserBaseRings;
    ob_start();
    // flip livewebRings keys to values, vice versa
    $ringdefs = array_flip($liveuserBaseRings);
    // check if viewing read only
    $readonly = $id == 'AdminPermsReport';
    // preserve filters across forms
    $preservePageFilter = isset($_REQUEST['pagefilter']) ? $_REQUEST['pagefilter'] : '';
    $preserveClassFilter = isset($_POST['classfilter']) ? $_POST['classfilter'] : '';
    $preserveLetterFilter = isset($_REQUEST['letterfilter']) ? $_REQUEST['letterfilter'] : '';
    echo ewiki_make_title($id, $id, 2);
    $rights = $liveuserPermAdmin->getRights();
    if (!$readonly) {
        // Handle POSTed deletes or updates
        foreach ($_POST as $key => $value) {
            list($prefix, $id) = explode('_', $key, 2);
            if ($prefix == 'chk' && is_numeric($id) && $value == 'on' && isset($_POST['submit_changeperm'])) {
                if (liveuser_removePerm($id)) {
                    echo '<p>Permission ' . $id . ' was successfully deleted.</p>';
                } else {
                    echo '<p>Deletion of permission ' . $id . ' failed.</p>';
                }
            }
            if ($prefix == 'ring' && is_numeric($id) && $value != '-1' && isset($_POST['submit_changeperm'])) {
                if (liveuser_addPerm($id, $value)) {
                    echo '<p>Permission ' . $id . ' was successfully updated.</p>';
                } else {
                    echo '<p>Update of permission ' . $id . ' failed.</p>';
                }
            }
        }
        // Handle POSTed new rows
        if (!empty($_POST['pagename_text']) && !empty($_POST['right_list']) && isset($_POST['submit_addperm'])) {
            $livewebperm = liveuser_checkPerm($_POST['pagename_text'], $_POST['right_list']);
            if ($livewebperm === false) {
                $livewebperm = liveuser_addPerm($_POST['pagename_text'], $_POST['ring_list'], $_POST['right_list']);
                if ($livewebperm !== false) {
                    echo '<p>Permission for ' . $_POST['pagename_text'] . ' was successfully created.</p>';
                } else {
                    echo '<p>Creation of permission for ' . $_POST['pagename_text'] . ' failed.</p>';
                }
            } else {
                echo '<p>Permission for ' . $_POST['pagename_text'] . ' with class ' . $_POST['right_list'] . ' already exists.</p>';
            }
        }
        // Show Add a new row section
        ?>
	    <form method="post" action="">
	    <h3>Add a Page Permission</h3>
            <?php 
        echo empty($preservePageFilter) ? '' : '<input type="hidden" name="pagefilter" value="' . $preservePageFilter . '" />';
        ?>
            <?php 
        echo empty($preserveClassFilter) ? '' : '<input type="hidden" name="classfilter" value="' . $preserveClassFilter . '" />';
        ?>
            <?php 
        echo empty($preserveLetterFilter) ? '' : '<input type="hidden" name="letterfilter" value="' . $preserveLetterFilter . '" />';
        ?>
	    <label for="pagename_text">Page Name</label>
	    <input id="pagename_text" name="pagename_text" type="text" /><br />
	    <label for="ring_list">Permission Level</label>
	    <select id="ring_list" name="ring_list">
        <?php 
        foreach ($ringdefs as $key => $value) {
            echo '<option value="' . $key . '">' . $value . '</option>';
        }
        ?>
	    </select><br />
	    <label for="right_list">Classes</label>
	    <select id="right_list" name="right_list">
        <?php 
        foreach ($rights as $right) {
            echo '<option value="' . $right['right_id'] . '">' . $right['define_name'] . '</option>';
        }
        ?>
	    </select><br />
	    <input type="submit" name="submit_addperm" value="Create Permission" />
	    </form>
        <?php 
    }
    // Show filtering form
    ?>
        <form method="post" action="<?php 
    echo ewiki_script('', $data['id']);
    ?>
">
        <h3>Filter Permissions</h3>
        <table>
        <tr>
            <td>
                <label for="pagefilter">Page Name</label>
                <input id="pagefilter" name="pagefilter" type="text" /><br />
            </td>
            <td>
                <label for="classfilter">Class</label>
                <select id="classfilter" name="classfilter">
                <option value=""></option>
    <?php 
    foreach ($rights as $right) {
        echo '<option value="' . $right['right_id'] . '">' . $right['define_name'] . '</option>';
    }
    ?>
                </select>
            </td>
            <td><input type="submit" name="submit_filterperm" value="Filter" /></td>
        </tr><tr><td colspan="3"><label>First Letter</label>&nbsp;&nbsp;
    <?php 
    foreach (range('A', 'Z') as $letter) {
        echo '<a href="' . ewiki_script('', $data['id'], array('letterfilter' => $letter)) . '">' . $letter . '</a>&nbsp;';
    }
    ?>
	<a href="<?php 
    echo ewiki_script('', $data['id'], array('letterfilter' => '0-9'));
    ?>
">0-9</a>
	<a href="<?php 
    echo ewiki_script('', $data['id'], array('letterfilter' => 'other'));
    ?>
">Other</a>
	<a href="<?php 
    echo ewiki_script('', $data['id'], array('letterfilter' => 'all'));
    ?>
">All</a>
	</td></tr></table>
        </form>
    <?php 
    // Show current table listing of pages and permissions
    $query = '
        SELECT ' . LW_PREFIX . '_perms.id, ' . LW_PREFIX . '_perms.pagename, ' . LW_PREFIX . '_perms.ring, liveuser_rights.right_define_name 
        FROM ' . LW_PREFIX . '_perms, liveuser_rights
        WHERE ' . LW_PREFIX . '_perms.right_id = liveuser_rights.right_id';
    $filter = '';
    if (!empty($_REQUEST['pagefilter'])) {
        $filter .= ' AND UPPER(' . LW_PREFIX . '_perms.pagename) LIKE "%' . strtoupper($_REQUEST['pagefilter']) . '%"';
    }
    if (!empty($_POST['classfilter'])) {
        $filter .= ' AND ' . LW_PREFIX . '_perms.right_id = ' . $_POST['classfilter'];
    }
    if (!empty($_REQUEST['letterfilter'])) {
        if (strlen($_REQUEST['letterfilter']) == 1 && $_REQUEST['letterfilter'] >= 'A' && $_REQUEST['letterfilter'] <= 'Z') {
            $filter = ' AND UPPER(' . LW_PREFIX . '_perms.pagename) LIKE "' . $_REQUEST['letterfilter'] . '%"';
        }
        if ($_REQUEST['letterfilter'] == '0-9') {
            $filter = ' AND ' . LW_PREFIX . '_perms.pagename REGEXP "^[0-9]"';
        }
        if ($_REQUEST['letterfilter'] == 'other') {
            $filter = ' AND ' . LW_PREFIX . '_perms.pagename REGEXP "^[^0-9A-Za-z]"';
        }
    }
    $query .= $filter;
    $query .= ' ORDER BY ' . LW_PREFIX . '_perms.pagename ASC';
    if (isset($_REQUEST['pagefilter']) || isset($_POST['classfilter']) || isset($_REQUEST['letterfilter'])) {
        $perms = $liveuserDB->getAll($query);
        if (is_array($perms) && !empty($perms)) {
            if (!$readonly) {
                // Display regular AdminPerms page
                ?>
		    <form method="post" action="">
		    <?php 
                echo empty($preservePageFilter) ? '' : '<input type="hidden" name="pagefilter" value="' . $preservePageFilter . '" />';
                ?>
		    <?php 
                echo empty($preserveClassFilter) ? '' : '<input type="hidden" name="classfilter" value="' . $preserveClassFilter . '" />';
                ?>
		    <?php 
                echo empty($preserveLetterFilter) ? '' : '<input type="hidden" name="letterfilter" value="' . $preserveLetterFilter . '" />';
                ?>
                    <h3>Edit Permissions</h3>
		    <table border="1">
		    <tr><th>Delete</th><th>Page Name</th><th>Permission Level</th><th>Class</th></tr>
                <?php 
                foreach ($perms as $perm) {
                    ?>
			<tr>
                            <td><input name="chk_<?php 
                    echo $perm['id'];
                    ?>
" type="checkbox" /></td>
                            <td><a href="<?php 
                    echo ewiki_script($perm['pagename']);
                    ?>
"><?php 
                    echo $perm['pagename'];
                    ?>
</a></td>
                            <td><select name="ring_<?php 
                    echo $perm['id'];
                    ?>
">
                    <?php 
                    foreach ($ringdefs as $key => $value) {
                        if ($key == $perm['ring']) {
                            echo '<option value="-1" selected>' . $value . '</option>';
                        } else {
                            echo '<option value="' . $key . '">' . $value . '</option>';
                        }
                    }
                    ?>
                            </select></td>
                            <td><?php 
                    echo $perm['right_define_name'];
                    ?>
</td>
                        </tr>
                    <?php 
                }
                ?>
                    </table>
                    <input type="reset" value="Reset" />
                    <input name="submit_changeperm" type="submit" value="Submit Changes" />
                    </form>
                <?php 
            } else {
                // Display readonly AdminPermsReport page
                ?>
                    <h3>View Permissions</h3>
		    <table border="1">
		    <tr><th>Pagename</th><th>Perm Level</th><th>Class</th></tr>
                <?php 
                foreach ($perms as $perm) {
                    ?>
			<tr>
                            <td><a href ="<?php 
                    echo ewiki_script($perm['pagename']);
                    ?>
"><?php 
                    echo $perm['pagename'];
                    ?>
</a></td>
                            <td><?php 
                    echo $ringdefs[$perm['ring']];
                    ?>
</td>
                            <td><?php 
                    echo $perm['right_define_name'];
                    ?>
</td>
                        </tr>
                    <?php 
                }
                echo '</table>';
            }
        } else {
            ?>
                <h3><?php 
            echo $readonly ? 'View' : 'Edit';
            ?>
 Permissions</h3>
                <p>No permissions were found in the database.</p>
            <?php 
        }
    }
    $o = ob_get_contents();
    ob_end_clean();
    return $o;
}