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; } }
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; }
function ewiki_announcements($id, $data, $action) { global $ewiki_plugins, $ewiki_config; if (!isset($GLOBALS['ewiki_auth_user'])) { return; } $notifyDates = ewiki_get_uservar("NotifyDates", FALSE); if (!$notifyDates) { $notifyDates = $ewiki_config["DefaultNotify"]; } else { $notifyDates = unserialize($notifyDates); } foreach ($notifyDates as $pageName => $date) { $data = ewiki_db::GET($pageName); if (EWIKI_PROTECTED_MODE && EWIKI_PROTECTED_MODE_HIDING && !ewiki_auth($pageName, $data, "view")) { continue; } if ($data['lastmodified'] > $date) { $dispDate = $data['lastmodified']; $dispPage = $pageName; break; } } if (!isset($dispPage)) { return; } $notifyDates[$dispPage] = $dispDate; ewiki_set_uservar("NotifyDates", serialize($notifyDates)); $o = ewiki_page('view/' . $dispPage); //page_final plugins have been run, unset them unset($ewiki_plugins["page_final"]); return $o; }
function ewiki_powersearch($q, $where = 'content') { $q = ewiki_lowercase(preg_replace('/\\s*[\\000-\\040]+\\s*/', ' ', $q)); $found = array(); $scored = array(); #-- initial scan foreach (explode(" ", $q) as $search) { if (empty($search)) { continue; } $result = ewiki_db::SEARCH($where, $search); while ($row = $result->get()) { if (($row["flags"] & EWIKI_DB_F_TYPE) == EWIKI_DB_F_TEXT) { $id = $row["id"]; $content = strtolower($row[$where]); unset($row); #-- have a closer look $len1 = strlen($content) + 1; if (!isset($scored[$id])) { $scored[$id] = 1; } $scored[$id] += 800 * (strlen($search) / $len1); $scored[$id] += 65 * (count(explode($search, $content)) - 2); $p = -1; while (($p = strpos($content, $search, $p + 1)) !== false) { $scored[$id] += 80 * (1 - $p / $len1); } } #if-TXT } } #-- output results arsort($scored); $o = "<ol>\n"; $n = 0; foreach ($scored as $id => $score) { #-- refetch page for top 10 entries (still cached by OS or DB) $row = $n < 10 ? ewiki_db::GET($id) : NULL; #-- check access rights in protected mode if (EWIKI_PROTECTED_MODE && !ewiki_auth($id, $row, "view", $ring = false, $force = 0)) { if (EWIKI_PROTECTED_MODE_HIDING) { continue; } else { $row["content"] = ewiki_t("FORBIDDEN"); } } $o .= "<li>\n"; $o .= '<div class="search-result ' . ($oe ^= 1 ? "odd" : "even") . '">' . '<a href="' . ewiki_script("", $id) . '">' . $id . "</a> " . "\n"; #-- top 10 results are printed more verbosely if ($n++ < 10) { preg_match_all('/([_-\\w]+)/', $row["content"], $uu); $text = htmlentities(substr(implode(" ", $uu[1]), 0, 200)); $o .= "<br />\n<small>{$text}\n" . "<br />" . strftime(ewiki_t("LASTCHANGED"), $row["lastmodified"]) . "<br /><br /></small>\n"; } $o .= "</div>\n"; $o .= "</li>\n"; } $o .= "</ol>\n"; return $o; }
function ewiki_page_wantedpages($id, $data, $action) { #-- collect referenced pages $result = ewiki_db::GETALL(array("refs")); while ($row = $result->get()) { if (EWIKI_PROTECTED_MODE && EWIKI_PROTECTED_MODE_HIDING && !ewiki_auth($row["id"], $uu, "view")) { continue; } $refs .= $row["refs"]; } #-- build array $refs = array_unique(explode("\n", $refs)); #-- strip existing pages from array $refs = ewiki_db::FIND($refs); foreach ($refs as $id => $exists) { if (EWIKI_PROTECTED_MODE && EWIKI_PROTECTED_MODE_HIDING && !ewiki_auth($row["id"], $uu, "view")) { continue; } if (!$exists && !strstr($id, "://") && strlen(trim($id))) { $wanted[] = $id; } } #-- print out $o .= "<ul>\n"; foreach ($wanted as $page) { $o .= " <li>" . ewiki_link($page) . "</li>\n"; } $o .= "<ul>\n"; return $o; }
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; }
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); } }
function ewiki_subpage_list($id, $postfix = "") { $_hiding = EWIKI_PROTECTED_MODE && EWIKI_PROTECTED_MODE_HIDING; $result = ewiki_db::SEARCH("id", $id . $postfix); while ($row = $result->get()) { #-- retrieve and check rights if running in protected mode if ($_hiding) { if (!ewiki_auth($row["id"], $uu, 'view', $ring = false, $force = 0)) { continue; } } $pages[$row["id"]] = ""; } return $pages; }
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_random(&$id, &$data, $action) { global $ewiki_plugins; $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) { $pages[] = $row["id"]; } } $pages = array_merge($pages, $ewiki_plugins["page"]); $n = rand(0, count($pages)); $id = $pages[$n]; return ewiki_page($id); }
function ewiki_page_wantedpages($id, $data, $action) { $wanted = array(); #-- collect referenced pages $result = ewiki_database("GETALL", array("refs")); while ($row = $result->get()) { if (EWIKI_PROTECTED_MODE && EWIKI_PROTECTED_MODE_HIDING && !ewiki_auth($row["id"], $uu, "view")) { continue; } $refs .= $row["refs"]; } #-- build array $refs = array_unique(explode("\n", $refs)); #-- strip existing pages from array $refs = ewiki_database("FIND", $refs); foreach ($refs as $id => $exists) { if (EWIKI_PROTECTED_MODE && EWIKI_PROTECTED_MODE_HIDING && !ewiki_auth($row["id"], $uu, "view")) { continue; } if (!$exists && !strstr($id, "://") && strlen(trim($id))) { $wanted[] = $id; } } // to prevent empty <ul></ul> getting printed out, we have to interate twice. // once to make sure the <ul></ul> is needed at all. // MDL-7861, <ul></ul> does not validate. $printul = false; foreach ($wanted as $page) { $link = ewiki_link_regex_callback(array($page, $page)); if (strstr($link, "?</a>")) { $printul = true; } } #-- print out if ($printul) { $o .= "<ul>"; foreach ($wanted as $page) { $link = ewiki_link_regex_callback(array($page, $page)); if (strstr($link, "?</a>")) { $o .= "<li>" . $link . "</li>"; } } $o .= "</ul>"; } return $o; }
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; }
function mkLiveWebNavBar($navBarPage, $activePage) { #-- fetch from db $data = ewiki_db::GET($navBarPage); #-- Authenticate, return nothing if authentication fails if (!ewiki_auth($navBarPage, $data, EWIKI_NAVBAR_ACTION, $ring = 3, $force = 0)) { return ""; } #-- escape if navBarPage does not exist or was not retrieved. if (empty($data["content"])) { return ""; } //echo(":".$data["content"].":"); $o .= ewiki_navbar_format($data["content"], 1, urlencode($activePage)); //Apply class only if we have a bar at all if ($o) { return " <div class='wikiNavBar' >\n" . $o . "\n</div>\n"; } return ""; }
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; }
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; }
function ewiki_print_control_line_fancy2(&$html, $id, $data, $action) { global $ewiki_plugins, $ewiki_t, $ewiki_config; #-- produce control links $cl = ""; if (!empty($data["forced_version"])) { $cl = '<a href="' . ewiki_script("edit", $id, array("version" => $data["forced_version"], "edit" => "old")) . '">' . ewiki_t("OLDVERCOMEBACK") . "</a>"; } else { foreach ($ewiki_config["action_links"]["view"] as $action => $title) { if (!empty($ewiki_plugins["action"][$action])) { if (EWIKI_PROTECTED_MODE && EWIKI_PROTECTED_MODE_HIDING && !ewiki_auth($id, $data, $action)) { continue; } $cl .= $ins[1] . '<a href="' . (strpos($action, "://") ? $action : ewiki_script($action, $id, $version ? array("version" => $version) : NULL)) . '">[' . ewiki_t($title) . ']</a> ' . $ins[2]; } } } if ($data["lastmodified"] >= UNIX_MILLENNIUM) { $cl .= '<br />' . strftime(ewiki_t("LASTCHANGED"), @$data["lastmodified"]); } #-- output $html = '<div class="controlbox float_right small">' . "{$h2}\n" . '<div style="text-align:right">' . $cl . '</div>' . "</div>\n" . $html; }
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 ewiki2_binary_page_handler($id, &$data, $action) { global $ewiki_plugins, $ewiki_errmsg; //echo("running handler"); #-- however we do not handle _DISABLED or _SYSTEM entries if (empty($data["flags"]) || !($data["flags"] & EWIKI_DB_F_BINARY) || $data["flags"] & EWIKI_DB_F_SYSTEM || $data["flags"] & EWIKI_DB_F_DISABLED) { return ewiki_t("DISABLED"); } #-- _PROTECTED_MODE # (Andy: can we print a login <form> once we reached here???) if (!ewiki_auth($id, $data, $action, $ring = false, $force = EWIKI_AUTO_LOGIN)) { //echo("not authenticated id".$id." action ".$action); return $ewiki_errmsg; } //echo("authenticated id:".$id." action ".$action); #-- chain to one of the action_BINARY plugins if ($pf = $ewiki_plugins["action_binary"][$action]) { //echo("running ".$pf."()"); return $pf($id, $data, $action); } #-- else let ?binary= return the requested 'page' entry //Consider binary view here //ewiki_binary($id); }
function ewiki_valid_pages($bool_allowimages = 0, $virtual_pages = 0) { //$time=getmicrotime(); global $ewiki_plugins; $result = ewiki_database("GETALL", array("flags", "refs", "meta")); while ($row = $result->get()) { if (EWIKI_PROTECTED_MODE && EWIKI_PROTECTED_MODE_HIDING && !ewiki_auth($row["id"], $str_null, "view")) { continue; } $isbinary = $row["meta"]["class"] == "image" || $row["meta"]["class"] == "file" ? true : false; if (($row["flags"] & EWIKI_DB_F_TYPE) == EWIKI_DB_F_TEXT || ($bool_allowimages ? $isbinary : 0)) { $temp_refs = explode("\n", $row["refs"]); foreach ($temp_refs as $key => $value) { if (empty($value)) { unset($temp_refs[$key]); } } if ($isbinary) { $a_validpages[$row["id"]] = $temp_array = array("refs" => $temp_refs, "type" => $row["meta"]["class"], "touched" => FALSE); } else { $a_validpages[$row["id"]] = $temp_array = array("refs" => $temp_refs, "type" => "page", "touched" => FALSE); } unset($temp_refs); } } if ($virtual_pages) { #-- include virtual pages to the sitemap. $virtual = array_keys($ewiki_plugins["page"]); foreach ($virtual as $vp) { if (!EWIKI_PROTECTED_MODE || !EWIKI_PROTECTED_MODE_HIDING || ewiki_auth($vp, $str_null, "view")) { $a_validpages[$vp] = array("refs" => array(), "type" => "page", "touched" => FALSE); } } } return $a_validpages; }
#-- read database $db = ewiki_db::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 echo ewiki_list_pages($orphaned, 0);
#-- enable readonly:test play account? $test = $_SERVER["SERVER_NAME"] == "erfurtwiki.sourceforge.net" || $_SERVER["REMOTE_ADDR"] == "127.0.0.1" && !strpos($_SERVER["SERVER_NAME"], "."); if ($test && !$_REQUEST["test"]) { $passwords["readonly"] = "test"; } #-- simplest authentication: require "../fragments/funcs/auth.php"; if ($_a_user == "readonly") { define("EWIKI_DB_LOCK", 1); // disable write-access } #-- normalize cwd (stupid approach) if (!file_exists($LIB = "ewiki.php")) { chdir(".."); define("EWIKI_SCRIPT", "../?"); define("EWIKI_SCRIPT_BINARY", "../?binary="); } #-- open db connection, load 'lib' include "./config.php"; #-- PHP fixes include "plugins/lib/fix.php"; include "plugins/lib/upgrade.php"; } else { #-- this terminates ewiki from within the spages plugin if (!EWIKI_PROTECTED_MODE || !ewiki_auth($id, $data, $action, 0, 2) || $ewiki_ring > 0 || !isset($ewiki_ring)) { die("Only the administrator can use this function."); } #-- some tools/ must be excluded nevertheless (because they override security-related settings, like t_control.php does) define("CONCURRENT_INCLUDE", 1); // just don't ask for an explaination ;) }
function ewiki_page_filedownload($id, $data, $action, $def_sec = "") { global $ewiki_binary_icons, $ewiki_upload_sections; $o = ewiki_make_title($id, $id, 2); #<off># $o .= ewiki_t("DWNL_SEEUPL", '$scr'=>ewiki_script("", "")); #-- params (section, orderby) $orderby = $_REQUEST["orderby"] or $orderby = "created"; if ($def_sec) { $section = $def_sec; } else { $section = $_REQUEST["section"] or $section = ""; if (count($ewiki_upload_sections) > 1) { $oa = array(); $ewiki_upload_sections["*"] = "*"; if (empty($ewiki_plugins["action"][EWIKI_ACTION_ATTACHMENTS])) { $ewiki_upload_sections["**"] = "**"; } foreach ($ewiki_upload_sections as $sec => $title) { $oa[] = '<a href="' . ewiki_script("", $id, array("orderby" => $orderby, "section" => $sec)) . '">' . $title . "</a>"; } $o .= '<div align="center" class="darker">' . implode(" · ", $oa) . '</div><br />'; } } #-- collect entries $files = array(); $sorted = array(); $result = ewiki_db::GETALL(array("flags", "meta", "created", "hits")); while ($row = $result->get()) { if (($row["flags"] & EWIKI_DB_F_TYPE) == EWIKI_DB_F_BINARY) { $m =& $row["meta"]; if ($m["section"] != $section) { if ($section == "**") { } elseif ($section == "*" && !empty($ewiki_upload_sections[$m["section"]])) { } else { continue; } } if (EWIKI_PROTECTED_MODE && EWIKI_PROTECTED_MODE_HIDING && !ewiki_auth($row["id"], $uuu, "binary-get")) { continue; } $files[$row["id"]] = $row; $sorted[$row["id"]] = $row[$orderby]; } } #-- sort arsort($sorted); #-- slice $pnum = $_REQUEST[EWIKI_UP_PAGENUM] or $pnum = 0; if (count($sorted) > EWIKI_LIST_LIMIT) { $o_nl .= '<div class="lighter">>> '; for ($n = 0; $n < (int) (count($sorted) / EWIKI_LIST_LIMIT); $n++) { $o_nl .= '<a href="' . ewiki_script("", $id, array("orderby" => $orderby, "section" => $section, EWIKI_UP_PAGENUM => $n)) . '">[' . $n . "]</a> "; } $o_nl .= '</div><br />'; $o .= $o_nl; } $sorted = array_slice($sorted, $pnum * EWIKI_LIST_LIMIT, EWIKI_LIST_LIMIT); #-- output if (empty($sorted)) { $o .= ewiki_t("DWNL_NOFILES"); } else { foreach ($sorted as $id => $uu) { $row = $files[$id]; $o .= ewiki_entry_downloads($row, $section[0] == "*"); } } $o .= $o_nl; return $o; }
function ewiki_action_control_page($id, &$data, $action) { global $ewiki_ring, $ewiki_config, $ewiki_plugins; $a_flagnames = array("_TEXT", "_BINARY", "_DISABLED", "_HTML", "_READONLY", "_WRITEABLE", "_APPENDONLY", "_SYSTEM", "_PART", "_MINOR", "_HIDDEN", "_ARCHIVE", "_UU12", "_UU13", "_UU14", "_UU15", "_UU16", "_EXEC", "_UU18", "_UU19"); $o = ewiki_make_title($id, "control {$id}", 2); #-- admin requ. --------------------------------------------------------- if (!ewiki_auth($id, $data, $action, $ring = 0, "_FORCE_LOGIN=1") || !isset($ewiki_ring) || $ewiki_ring > 1) { if (is_array($data)) { $data = "You'll need to be admin. See ewiki_auth() and _PROTECTED_MODE in the README."; } $o .= $data; } elseif (@$_REQUEST["pgc_setflags"]) { #-- setted new flags $new_f = 0; foreach ($_REQUEST["sflag"] as $n => $b) { if ($b) { $new_f |= 1 << $n; } } #-- administrator may change all flags if ($ewiki_ring == 0) { $data["flags"] = $new_f; } else { $data["flags"] = $data["flags"] & ~EWIKI_DB_F_MODERATORFLAGS | $new_f & EWIKI_DB_F_MODERATORFLAGS; } $data["lastmodified"] = time(); $data["version"]++; if (ewiki_db::WRITE($data)) { $o .= "Page flags were updated correctly."; ewiki_log("page flags of '{$id}' were set to {$data['flags']}"); } else { $o .= "A database error occoured."; } } elseif (@$_REQUEST["pgc_rename"] && strlen($new_id = $_REQUEST["mv_to"])) { $old_id = $id; $report = ""; $preg_id = "/" . addcslashes($old_id, ".+*?|/\\()\$[]^#") . "/" . ($_REQUEST["mv_cr1"] ? "i" : ""); #-- check if new name does not already exist in database $exists = ewiki_db::GET($new_id); if ($exists || !empty($exists)) { return $o .= "Cannot overwrite an existing database entry."; } #-- copy from old name to new name $max_ver = $data["version"]; $data = array(); for ($v = 1; $v <= $max_ver; $v++) { $row = ewiki_db::GET($old_id, $v); $row["id"] = $new_id; $row["lastmodified"] = time(); $row["content"] = preg_replace($preg_id, $new_id, $row["content"]); ewiki_scan_wikiwords($row["content"], $links, "_STRIP_EMAIL=1"); $row["refs"] = "\n\n" . implode("\n", array_keys($links)) . "\n\n"; $row["author"] = ewiki_author("control/"); if (!ewiki_db::WRITE($row)) { $report .= "error while copying version {$v},<br />\n"; } } #-- proceed if previous actions error_free if (empty($report)) { #-- deleting old versions for ($v = 1; $v <= $max_ver; $v++) { ewiki_db::DELETE($old_id, $v); } #-- adjust links/references to old page name if ($_REQUEST["mv_cr0"]) { $result = ewiki_db::SEARCH("refs", $old_id); while ($result && ($row = $result->get())) { $row = ewiki_db::GET($row["id"]); if (preg_match($preg_id, $row["content"], $uu)) { $row["content"] = preg_replace($preg_id, $new_id, $row["content"]); $row["lastmodified"] = time(); $row["version"]++; ewiki_scan_wikiwords($row["content"], $links, "_STRIP_EMAIL=1"); $row["refs"] = "\n\n" . implode("\n", array_keys($links)) . "\n\n"; $row["author"] = ewiki_author("control/"); if (!ewiki_db::WRITE($row)) { $report .= "could not update references in " . $row['id'] . ",<br />\n"; } else { $report .= "updated references in " . $row['id'] . ",<br />\n"; } } } } $o .= "This page was correctly renamed from '{$old_id}' to '{$new_id}'.<br /><br />\n{$report}"; ewiki_log("page renamed from '{$old_id}' to '{$new_id}'", 2); } else { $o .= "Some problems occoured while processing your request, therefor the old page still exists:<br />\n" . $report; } } elseif (@$_REQUEST["pgc_setmeta"] && $ewiki_ring == 0 && ($set = explode("\n", $_REQUEST["pgc_meta"]))) { $new_meta = array(); foreach ($set as $line) { if (($line = trim($line)) && ($key = trim(strtok($line, ":"))) && ($value = trim(strtok("")))) { $new_meta[$key] = $value; } } $data["meta"] = $new_meta; $data["lastmodified"] = time(); $data["version"]++; if (ewiki_db::WRITE($data)) { $o .= "The {meta} field was updated."; } else { $o .= "A database error occoured."; } } elseif (@$_REQUEST["pgc_purge"] && $_REQUEST["pgc_purge1"]) { $loop = 3; do { $verZ = $data["version"]; while ($verZ > 0) { ewiki_db::DELETE($id, $verZ); $verZ--; } } while ($loop-- && ($data = ewiki_db::GET($id))); if (empty($data)) { $o .= "Page completely removed from database."; ewiki_log("page '{$id}' was deleted from db", 2); } else { $o .= "Page still here."; } } else { $o .= '<form action="' . ewiki_script("{$action}", $id) . '" method="POST" enctype="text/html">' . '<input type="hidden" name="id" value="' . "{$action}/{$id}" . '">'; #-- flags $o .= '<div class="flags">'; $o .= "<h4>page flags</h4>\n"; foreach ($a_flagnames as $n => $s) { $disabled = $ewiki_ring == 1 && !(1 << $n & EWIKI_DB_F_MODERATORFLAGS) ? ' disabled="disabled"' : ""; $checked = $data["flags"] & 1 << $n ? ' checked="checked"' : ""; $a[$n] = '<input type="checkbox" name="sflag[' . $n . ']" value="1"' . $checked . $disabled . '> ' . $s; } $o .= '<table border="0" class="list">' . "\n"; for ($n = 0; $n < count($a_flagnames); $n++) { $y = $n >> 2; $x = $n & 0x3; if ($x == 0) { $o .= "<tr>"; } $o .= "<td>" . $a[4 * $y + $x] . "</td>"; if ($x == 3) { $o .= "</tr>\n"; } } $o .= '</table>'; $o .= '<input type="submit" name="pgc_setflags" value="chmod">'; $o .= "\n<br /><br /><hr></div>\n"; #-- rename $o .= '<div class="rename">'; $o .= "<h4>rename page</h4>\n"; $o .= 'new page name: <input type="text" size="30" name="mv_to" value="' . htmlentities($id) . '">' . '<br />' . '<input type="checkbox" name="mv_cr0" value="1" checked> also try to change all references from other pages accordingly ' . '(<input type="checkbox" name="mv_cr1" value="1" checked> and act case-insensitive when doing so) '; $o .= '<br /><input type="submit" name="pgc_rename" value="mv">'; $o .= "\n<br /><br /><hr></div>\n"; #-- meta if (isset($ewiki_ring) && $ewiki_ring == 0) { $o .= '<div class="meta">'; $o .= "<h4>meta data</h4>\n"; $o .= '<textarea cols="40" rows="6" name="pgc_meta">'; if (($uu = @$data["meta"]) && is_array($uu)) { foreach ($uu as $key => $value) { if (is_array($value)) { $value = serialize($array); } $o .= htmlentities($key . ": " . trim($value)) . "\n"; } } $o .= "</textarea>\n"; $o .= '<br /><input type="submit" name="pgc_setmeta" value="set">'; $o .= "\n<br /><br /><hr></div>\n"; } #-- delete $o .= '<div class="delete">'; $o .= "<h4>delete page</h4>\n"; $o .= '<input type="checkbox" name="pgc_purge1" value="1"> I\'m sure'; $o .= '<br /><input type="submit" name="pgc_purge" value="rm">'; $o .= "\n<br /><br /><hr></div>\n"; $o .= '</form>'; } return $o; }
function ewiki_blog_list($n_num, $n_len, $b_sort, $b_sortrev, $b_hr, $b_more, $c_regex) { global $ewiki_plugins, $ewiki_config; #-- fetch all page entries from DB, for sorting on pagename or lastmodified if ($b_sort) { $result = ewiki_db::GETALL(array("pagename")); } else { $result = ewiki_db::GETALL(array("lastmodified")); } $sorted = array(); // get an array from the database while ($row = $result->get(0, 0x137, EWIKI_DB_F_TEXT)) { if ($c_regex && !preg_match($c_regex, $row["id"])) { continue; } if ($b_sort) { $sorted[$row["id"]] = $row["pagename"]; } else { $sorted[$row["id"]] = $row["lastmodified"]; } } #-- sort normal or reversed if ($b_sortrev) { asort($sorted); } else { // if we sort on lastmodified reverse sort arsort($sorted); } $displayed = 0; //$displayed will count pages successfully displayed #-- gen output $o = ""; foreach ($sorted as $id => $uu) { $row = ewiki_db::GET($id); #-- require auth if (EWIKI_PROTECTED_MODE && !ewiki_auth($id, $row, "view", $ring = false, $force = 0)) { if (EWIKI_PROTECTED_MODE_HIDING) { continue; } else { $row["content"] = ewiki_t("FORBIDDEN"); } } $text = "\n" . substr($row["content"], 0, $n_len); $text = str_replace("[internal://", "[ internal://", $text); #-- shore more link or not if ($b_more) { $text .= " [...[read more | {$id}]]\n"; } #-- title mangling (from ewiki.php) $title = $id; if ($ewiki_config["split_title"] && $may_split) { $title = ewiki_split_title($title, $ewiki_config["split_title"], 0 & $title != $ewiki_title); //Why 0&? } else { $title = htmlentities($title); } if ($pf_a = @$ewiki_plugins["title_transform"]) { foreach ($pf_a as $pf) { $pf($id, $title, $go_action); } } if ($ewiki_config["wm_publishing_headers"]) { $text = preg_replace("/^!([^!])/m", "!! \$1", $text); $o .= "\n" . "! [\"{$title}\"{$id}]"; } else { $text = preg_replace("/^!!!/m", "!!", $text); $o .= "\n" . "!!! [\"{$title}\"{$id}]"; } $o .= " µµ" . strftime(ewiki_t("LASTCHANGED"), $row["lastmodified"]) . "µµ\n"; $o .= " {$text}\n"; // add a horizontal line if wanted if ($b_hr) { $o .= "----\n"; } if (!$n_num--) { break; } } #-- render requested wiki page <-- goal !!! $render_args = array("scan_links" => 1, "html" => EWIKI_ALLOW_HTML || @$data["flags"] & EWIKI_DB_F_HTML); $o = $ewiki_plugins["render"][0]($o, $render_args); return $o; }
function ewiki_edit_save_unix_access_rights(&$save, &$old_data) { global $ewiki_auth_user, $ewiki_author, $ewiki_ring, $ewiki_errmsg; $user = $ewiki_auth_user or $user = $ewiki_author or $user = ""; #-- get current settings $new_owner = $p_owner = $save["meta"]["owner"]; $new_groups = $p_groups = $save["meta"]["groups"]; $p_rights = $save["meta"]["rights"] or $p_rights = 0777 ^ EWIKI_UNIX_PERM_UMAKS; $new_rights = $p_rights; #-- fetch entered settings if (true) { #-- access rights $set_rights = 0; foreach ($_POST["perm_unix_rights"] as $n => $is) { if ($is) { $set_rights = $set_rights | 1 << $n; } } #-- attempt to set new page owner? $set_owner = trim($_REQUEST["perm_unix_owner"]); if (!preg_match("/^[" . EWIKI_CHARS . "]+\$/", $set_owner) && ewiki_auth_user_exists($set_owner)) { $save = array(); $ewiki_errmsg = "broken username"; return; } #-- clean up list of group names $set_groups = array(); $uu = strtr($_REQUEST["perm_unix_groups"], EWIKI_USERDB_GROUPDELIMS, " "); foreach (explode(" ", $uu) as $grp) { if (strlen($grp) && preg_match("/^[" . EWIKI_CHARS . "]+\$/", $grp)) { $set_groups[] = $grp; } } $set_groups = implode(", ", $set_groups); } #-- check if changing settings is allowed $bad = 0; if (!$user || $user != $p_owner) { $bad = $bad || $p_owner != $set_owner && !(empty($p_owner) && EWIKI_PERM_USERSET_FREE || $set_owner == $user); # $bad = $bad || ($p_groups != $set_groups); # cannot reliably check this $bad = $bad || $p_rights != $set_rights; } if ($ewiki_ring == 0) { $bad = 0; } #$bad=0; #-- login_query, if something was changed if ($bad) { $uu = 0; ewiki_auth($uu, $uu, $uu, $uu, 2); $save = array(); $ewiki_errmsg = "You cannot change these settings without being logged in."; return; } #echo "pr=$p_rights,sr=$set_rights<br />\n"; #echo "po=$p_owner,so=$set_owner<br />\n"; #echo "bad=$bad<br />\n"; #die("passed"); #-- the owner may change anything if ($user == $p_owner || 0 == $ewiki_ring) { #-- new page owner $new_owner = $set_owner; #-- new access rights $new_rights = $set_rights; $new_rights |= 0400; // owner can always edit a page #-- restricted settings if ($ewiki_ring == 0) { // keep all bits } elseif ($ewiki_ring == 1) { $new_rights = $new_rights & 07777 | $p_rights & 070000; } else { $new_rights = $new_rights & 0777 | $p_rights & 077000; } #-- groups $new_groups = $set_groups; } /******** #-- groups can...(?) if (!EWIKI_PERM_UNIX_SHAREHOLDERS) { // no they can't. } elseif (ewiki_auth_user_in_groups_str($user, $p_groups) && ($new_rights=$save["meta"]["rights"])) { #-- this can effectively only remove bits $new_rights = (077700 & $new_rights) | (000077 & $new_rights & $set_rights); } *******/ #-- store any changes into database entry if ($user) { $save["meta"]["rights"] = $new_rights; $save["meta"]["owner"] = $new_owner; $save["meta"]["groups"] = $new_groups; } #print_r($save);die(); }
function ewiki_page_image_gallery($id, $data = 0, $action) { global $ewiki_config; $o = ewiki_make_title($id, $id, 2); $mwidth = 120; $mscale = 0.7; #-- fetch and asort images $sorted = array(); $pages = array(); $result = ewiki_db::GETALL(array("flags", "created", "meta", "refs")); 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'][$id])) { foreach ($ewiki_config['image-galleries'][$id] 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"]] = $row["created"]; $pages[$row["id"]] = $row; } } elseif (($row["flags"] & EWIKI_DB_F_TYPE) == EWIKI_DB_F_TEXT) { $page_refs[$row["id"]] = $row["refs"]; } } arsort($sorted); #-- start table $o .= '<table border="0" cellpadding="10" cellspacing="4">' . "\n"; $n = 0; $num_per_row = EWIKI_GALLERY_WIDTH; foreach ($sorted as $image => $uu) { $row = $pages[$image]; $meta = $row["meta"]; #-- height, width $x = $x0 = $meta["width"]; $y = $y0 = $meta["height"]; if (!($x && $y)) { $x = $mwidth; $y = (int) ($mwidth * $mscale); } $r = 1; if ($y > $mwidth * $mscale) { $r = $mwidth * $mscale / $y; } if ($r > $mwidth / $x) { $r = $mwidth / $x; } $x = (int) ($x * $r); $y = (int) ($y * $r); #-- get image references $ref = array(); foreach ($page_refs as $pageid => $pageref) { if (strstr($pageref, $image)) { if (EWIKI_PROTECTED_MODE && EWIKI_PROTECTED_MODE_HIDING && !ewiki_auth($pageid, $str_null, "view")) { continue; } $ref[] = '<a href=?page=' . $pageid . '>' . $pageid . '</a>'; } if (count($ref) >= 5) { break; } } $ref = implode(", ", $ref); #-- table lines $n % $num_per_row == 0 && ($o .= "<tr>\n"); #-- print a/img tag $o .= '<td class="lighter" align="center">' . '<a href="' . ewiki_script_binary("", $image) . '">' . '<img src="' . ewiki_script_binary("", $image) . '" alt="' . $image . '" border="0"' . ($x && $y ? ' width="' . $x . '" height="' . $y . '"' : '') . ' />' . str_replace('/', '/ ', urldecode($meta["Content-Location"])) . '</a><br />' . ($x0 && $y0 ? "{$x0}x{$y0}<br />" : "") . $ref . '<div class="action-links">' . ewiki_control_links_list($image, $uuu, $ewiki_config["action_links"]["gallery"]) . "</div>\n" . "</td>\n"; #-- table lines $n++; $n % $num_per_row == 0 && ($o .= "</tr>\n"); } #-- empty table cells if ($n % $num_per_row) { while ($n % $num_per_row && $n++) { $o .= "<td class=\"lighter\"> </td>\n"; } $o .= "</tr>\n"; } $o .= "</table>\n"; return $o; }
<?php /* lists pages which are referenced but not yet written (AKA "DanglingSymlinks") */ #-- title echo ewiki_make_title($id, $id, 2); #-- collect referenced pages $result = ewiki_db::GETALL(array("refs")); while ($row = $result->get()) { if (EWIKI_PROTECTED_MODE && EWIKI_PROTECTED_MODE_HIDING && !ewiki_auth($row["id"], $uu, "view")) { continue; } $refs .= $row["refs"]; } #-- build array $refs = array_unique(explode("\n", $refs)); #-- strip existing pages from array $refs = ewiki_db::FIND($refs); foreach ($refs as $id => $exists) { if (!$exists && !strstr($id, "://") && strlen(trim($id))) { $wanted[] = $id; } } #-- print out echo "<ul>\n"; foreach ($wanted as $page) { echo " <li>" . ewiki_link($page) . "</li>\n"; } echo "<ul>\n";
function ewiki_page_exall($id = 0, $data = 0, $action = 0) { global $ewiki_plugins, $ewiki_config; //$timestart=getmicrotime(); $action = str_replace("all", "", strtolower($id)); $invalid = false; $initials = ewiki_get_uservar("Initials"); $exinitials = ewiki_get_uservar("ExtractorInitials"); if (isset($_GET['q']) && $_GET['q'] != "") { if ($_GET['q'] != 'ALL') { $str_usr = str_replace(array("or", " ", "and"), array("|", "", "|"), $_GET['q']); //$str_usr=$_GET['q']; //initials were entered if (!(stristr($_GET['q'], "or") && stristr($_GET['q'], "and"))) { if (stristr($_GET['q'], "and")) { $operator = "and"; } $extractFor = $_GET['q']; } else { $invalid = true; } } } elseif (strlen($initials)) { $str_usr = $initials; $extractFor = $str_usr; } elseif (strlen($exinitials)) { $str_usr = $exinitials; $extractFor = $str_usr; } else { $str_usr = "******"; //no initials were entered $o = ewiki_make_title($id, ewiki_t(strtoupper($action) . "TITLE"), 2); } if (isset($extractFor)) { $o = ewiki_make_title($id, ewiki_t(strtoupper($action) . "FOR") . $extractFor, 2); if ($extractFor != $exinitials && $extractFor != $initials && strlen($extractFor) == 2) { ewiki_set_uservar("ExtractorInitials", $extractFor); } } else { $o = ewiki_make_title($id, ewiki_t(strtoupper($action) . "TITLE"), 2); } $o .= ewiki_t("EXALLCONTROLS", array("controlid" => $id)); //prints text, textbox, and button $o .= '<p>'; if (strlen($initials)) { $o .= '<a href="' . ewiki_script("", $id, array('q' => $initials)) . '">' . ewiki_t(strtoupper($action) . "FOR") . $initials . "</a> "; } if (strlen($exinitials) && $exinitials != $initials) { $o .= '<a href="' . ewiki_script("", $id, array('q' => $exinitials)) . '">' . ewiki_t(strtoupper($action) . "FOR") . $exinitials . "</a> "; } $o .= '<a href="' . ewiki_script("", $id, array('q' => 'ALL')) . '">' . ewiki_t(strtoupper($action) . "FORALL") . "</a> " . '</p>'; if ($invalid) { return $o . ewiki_t("EXALLERROR"); } //define types of todo/policy items $ext_types = $ewiki_config["extracttypes"][$action]; //get data from database $data = ewiki_db::GETALL(array("content", "pagename", "flags")); while ($content = $data->get()) { $str_null = NULL; if (($content["flags"] & EWIKI_DB_F_TYPE) == EWIKI_DB_F_TEXT) { //code hijacked from action_extracttodo and modified preg_match_all("/^([;:#\\*\\- ]*)((@@(" . implode("|", $ext_types) . ")) ((" . $str_usr . ")+.*)(:.*))\$/im", $content["content"], $matches); if (!empty($matches[0])) { $extractedContent = NULL; for ($index = 0; $index < sizeof($matches[0]); $index++) { //extract each todo/policy item if ($operator == "and") { $all = true; $a_users = explode("|", $str_usr); foreach ($a_users as $str_user) { if (!stristr($matches[5][$index], $str_user)) { $all = false; } } if (!$all) { continue; } } //security layer if (EWIKI_PROTECTED_MODE && EWIKI_PROTECTED_MODE_HIDING && !ewiki_auth($content["id"], $str_null, $action)) { continue; //skip rest of loop and start from beginning } $extractedContent .= "*" . $matches[2][$index] . "@@\n"; } if ($extractedContent != NULL) { $o .= $ewiki_plugins["render"][0]("!!!" . ewiki_t(strtoupper($action) . "FROM") . "[" . $content["id"] . "]"); $o .= "<div class='ewiki_page_todolist'>" . $ewiki_plugins["render"][0]($extractedContent, 1, EWIKI_ALLOW_HTML || @$content["flags"] & EWIKI_DB_F_HTML) . "</div>"; } } } } $o .= $ewiki_plugins["render"][0](ewiki_t(strtoupper($action) . "POSTSCRIPT")); /*$timeend=getmicrotime(); $o.="time: ".($timeend-$timestart);*/ return $o; }
function get($all = 0, $flags = 0x0) { $row = array(); $prot_hide = $flags & 0x20 && EWIKI_PROTECTED_MODE && EWIKI_PROTECTED_MODE_HIDING; do { if (count($this->entries)) { #-- fetch very first entry from $entries list $r = array_shift($this->entries); #-- finish if buffered entry if (is_array($r) && !$all) { $row = $r; } else { if (is_array($r)) { $r = $r["id"]; } $r = ewiki_database("GET", array("id" => $r)); if (!$all) { foreach ($this->keys as $key) { $row[$key] = $r[$key]; } } else { $row = $r; } } unset($r); } else { return NULL; // no more entries } #-- expand {meta} field if (is_array($row) && is_string(@$row["meta"])) { $row["meta"] = unserialize($row["meta"]); } #-- drop unwanted results if ($prot_hide && !ewiki_auth($row["id"], $row, $ewiki_action)) { $row = array(); } } while ($prot_hide && empty($row)); return $row; }
function ewiki_view_append_posts($id, $data, $action) { global $ewiki_plugins, $ewiki_config; ## Since this function calls ewiki_page_view it must disable itself when it is called ## I do this by having it set separate view_append and view final actions for posts ## but at a minimum it removes itself $std_view_append = $ewiki_plugins["view_append"]; $std_view_final = $ewiki_plugins["view_final"]; $std_action_links = $ewiki_config["action_links"]["view"]; $thread_page_title = $GLOBALS["ewiki_title"]; if (!isset($ewiki_config['posts_view_append'])) { unset($ewiki_plugins["view_append"]['view_append_posts']); } else { $ewiki_plugins["view_append"] = $ewiki_config['posts_view_append']; } if (isset($ewiki_config['posts_view_final'])) { $ewiki_plugins["view_final"] = $ewiki_config['posts_view_final']; } if (!isset($ewiki_config['posts_action_links'])) { unset($GLOBALS['ewiki_config']["action_links"]["view"]["addpost"]); } else { $ewiki_config["action_links"]["view"] = $ewiki_config['posts_action_links']; } unset($_REQUEST["thankyou"]); // Prevent thank you message from appearing in the menu // bar /** * Code for the new database layer */ $result = ewiki_db::SEARCH("id", $id . '_POST'); #sort by post number $ord = array(); while ($row = $result->get()) { if (preg_match('#_POST(\\d{3})#', $row["id"], $matches = array())) { $ord[$matches[1]] = $row['id']; } } asort($ord); foreach ($ord as $postNum => $id) { $GLOBALS["ewiki_title"] = ewiki_t('POST') . $postNum; $row = ewiki_db::GET($id); #-- require auth if (EWIKI_PROTECTED_MODE) { if (!ewiki_auth($id, $row, EWIKI_VIEWPOSTACTION, $ring = false, $force = 0)) { continue; } } $postOut = ewiki_page_view($id, $row, EWIKI_VIEWPOSTACTION); ewiki_page_css_container($postOut, $id, $row, $oo = EWIKI_VIEWPOSTACTION); $o .= $postOut; } ## Restore normal actions $ewiki_plugins["view_append"] = $std_view_append; $ewiki_plugins["view_final"] = $std_view_final; $ewiki_config["action_links"]["view"] = $std_action_links; $GLOBALS["ewiki_title"] = $thread_page_title; return "<div class='wiki aview posts'>" . $o . '</div>'; }