function ewiki_page_since_updates($id = 0, $data = 0) { $orderby = "lastmodified"; $asc = -1; $print = "%02dT %02dH %02dM %02dS"; $title = "Aktualisierung seit"; $sorted = array(); $result = ewiki_db::GETALL(array($orderby, "flags", "version")); while ($row = $result->get()) { if (EWIKI_DB_F_TEXT == ($row["flags"] & EWIKI_DB_F_TYPE)) { $sorted[$row["id"]] = $row[$orderby]; } } if ($asc != 0) { arsort($sorted); } else { asort($sorted); } foreach ($sorted as $name => $value) { $x = time() - $value; $dy = (int) ($x / 86400); $hr = (int) ($x % 86400 / 3600); $mn = (int) ($x % 86400 % 3600 / 60); $se = $x % 86400 % 3600 % 60; $sorted[$name] = sprintf($print, $dy, $hr, $mn, $se); } $o .= ewiki_list_pages($sorted); return $o; }
function PROPFIND($path, $props) { #-- page name, prep $id = $this->id($path); $files = array(); #-- list pages if (!strlen($id) || $id == "/") { $oldest_time = 2 * UNIX_MILLENNIUM; $result = ewiki_db::GETALL(array()); while ($data = $result->get(1, 0x137f)) { if ($this->depth >= WEBDAV_DIR_DEPTH) { $files[] = $this->fileinfo($data); } $oldest_time = min($oldest_time, $data["created"]); } #-- add entry for virtual root directory $data = array("id" => "/", "created" => $oldest_time); $files[] = $this->dirinfo($data); } else { $version = NULL; $data = ewiki_db::GET($id, $version); if ($data) { $files[] = $this->fileinfo($data); } } #-- fin return $files; }
function ewiki_page_wiki_mini_tarball_dump($id, $data, $action) { global $ewiki_config, $ewiki_plugins; #-- get all pages / binary files $result = ewiki_db::GETALL(array("id", "version", "flags")); if ($result) { #-- HTTP headers header("Content-Type: application/x-tar"); header("Content-Disposition: attachment; filename=\"InitPages.tar.gz\""); #-- start tar file $tarball = new ewiki_virtual_tarball(); $tarball->open(0); #-- convert all pages while ($row = $result->get(0, 0x1037)) { $id = $row["id"]; $row = ewiki_db::GET($id); $content =& $row["content"]; $fn = $id; if (!$row || !$row["id"] || !$row["content"]) { continue; } #-- for tarball $perms = array("mtime" => $row["lastmodified"], "uname" => "ewiki", "mode" => 0664 | ($row["flags"] & EWIKI_DB_F_WRITEABLE ? 02 : 00)); #-- add file $tarball->add($fn, $content, $perms); } #-- end output $tarball->close(); } #-- fin die; }
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_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_valid_pages($bool_allowimages = 0, $virtual_pages = 0) { //$time=getmicrotime(); global $ewiki_plugins; $result = ewiki_db::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; } if (($row["flags"] & EWIKI_DB_F_TYPE) == EWIKI_DB_F_TEXT || ($bool_allowimages ? $row["meta"]["class"] == "image" : 0)) { $temp_refs = explode("\n", $row["refs"]); foreach ($temp_refs as $key => $value) { if (empty($value)) { unset($temp_refs[$key]); } } if ($row["meta"]["class"] == "image") { $a_validpages[$row["id"]] = $temp_array = array("refs" => $temp_refs, "type" => "image", "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; }
function ewiki_action_rss($id, &$data, $action) { $list = array(); #-- recentchanges as rss if (strtoupper($id) == "RSS") { $res = ewiki_db::GETALL(array("id", "flags", "version", "lastmodified")); $sort = array(); while ($data = $res->get(0, 0x137, EWIKI_DB_F_TEXT)) { $sort[$data["id"]] = $data["lastmodified"]; } arsort($sort); $limit = 100; foreach ($sort as $id => $uu) { $list[] = ewiki_db::GET($id); if ($limit-- < 0) { break; } } } else { $list[] = $data; for ($v = $data["version"] - 1; $v >= 1; $v--) { $d = ewiki_db::GET($id, $v); $list[] = $d; } } ewiki_feed($list); }
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_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_view_append_linktree($id, $data, $action) { global $ewiki_config; $refs = ewiki_db::GETALL(array("refs")); $refs = ewiki_f_parent_refs($refs); #-- $dest if (empty($ewiki_config["root_page"])) { if (defined("EWIKI_LINKTREE_DEST")) { $ewiki_config["root_page"] = EWIKI_LINKTREE_DEST; } else { $ewiki_config["root_page"] = EWIKI_PAGE_INDEX; } } $dest =& $ewiki_config["root_page"]; $depth = 0; $paths = array($id => $id); $current = $id; /* * $paths["Current"] = "Current"; * $paths["WorldWideWeb\nWikiWikiWeb\nErfurtWiki"] = "ErfurtWiki"; */ #-- retry until at least one $path is found while (!in_array($dest, $paths) && $depth <= 15 && count($paths) <= 100000) { $depth++; #-- expand every last path entry foreach ($paths as $pathkey => $uu) { #-- mk subkey from pathkey if ($p = strrpos($pathkey, "\n")) { $lkey = substr($pathkey, $p + 1); } else { $lkey = $pathkey; } #-- append tree leafs if ($walk = $refs[$lkey]) { foreach ($walk as $add => $uu) { $paths[$pathkey . "\n" . $add] = $add; } unset($refs[$lkey]); } } } #-- print results foreach ($paths as $key => $name) { $tree = array_reverse(explode("\n", $key)); $GLOBALS["ewiki_page_sections"] = array(); if ($name == $dest && count($tree) >= 2) { $GLOBALS["ewiki_page_sections"][] = $tree[1]; if (EWIKI_LINKTREE_UL) { $o .= ewiki_f_tree($tree, 0); } else { $o .= ewiki_f_tree2($tree, 0); } } } $o && ($o = "<div class=\"link-tree\">{$o}</div>\n"); return $o; }
function wikiapi_getRecentChanges($since = UNIX_MILLENNIUM) { $r = array(); $result = ewiki_db::GETALL(array("flags", "lastmodified")); while ($row = $result->get(0, 0x20)) { if (EWIKI_DB_F_TEXT == ($row["flags"] & EWIKI_DB_F_TYPE)) { if (!isset($since)) { $r[] = $row["id"]; } elseif ($row["lastmodified"] >= $since) { $r[] = wikiapi_pageinfo($data); } } } return $r; }
function cmd_ls($ls) { if (count($ls) == 1 && $ls[0] == "-l") { cmd_ll(NULL); } else { $rx = preg_glob($ls); $all = ewiki_db::GETALL(array("id")); while ($row = $all->get()) { if ($rx && !preg_match($rx, $row["id"])) { continue; } echo $row["id"] . "\n"; } } }
function ewiki_mpi_phpwiki_allusers($action, &$args, &$iii, &$s) { $authors = array(); $result = ewiki_db::GETALL(array("author")); while ($row = $result->get()) { if ($uu = strtok($row["author"], "(")) { $authors[trim($uu)] = 1; } } $authors = array_keys($authors); natcasesort($authors); foreach ($authors as $a) { $o .= "· " . ewiki_link_regex_callback(array($a)) . "<br />\n"; } 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_sync_local($func, $args = NULL) { switch (strtoupper(trim($func, ":"))) { case "GET": return ewiki_db::GET($args[0], $args[1]); case "WRITE": return ewiki_db::WRITE($args); case "LIST": $all = ewiki_db::GETALL(array("id", "version")); $r = array(); while ($row = $all->get()) { $r[$row["id"]] = $row["version"]; } return $r; default: } }
function ewiki_page_scandisk($id, $data, $action) { $o .= "<h2>{$id}</h2>\n"; $s_fv = 0; $s_files = 0; $s_n_txt = 0; $s_n_bin = 0; $s_n_txt_r = 0; $s_n_bin_r = 0; $s_n_dis = 0; $s_n_err = 0; $s_n_htm = 0; $s_n_ro = 0; $s_n_wr = 0; $s_holes = 0; $result = ewiki_db::GETALL(array("flags", "meta", "created", "version")); $s_files = $result->count(); while ($row = $result->get()) { $flags = $row["flags"]; $s_n_txt += $flags & EWIKI_DB_F_TEXT ? 1 : 0; $s_n_bin += $flags & EWIKI_DB_F_BINARY ? 1 : 0; $s_n_txt_r += ($flags & EWIKI_DB_F_TYPE) == EWIKI_DB_F_TEXT ? 1 : 0; $s_n_bin_r += ($flags & EWIKI_DB_F_TYPE) == EWIKI_DB_F_BINARY ? 1 : 0; $s_n_dis += $flags & EWIKI_DB_F_DISABLED ? 1 : 0; $s_n_err += ($flags & EWIKI_DB_F_TYPE) == 0 ? 1 : 0; $s_n_htm += $flags & EWIKI_DB_F_HTML ? 1 : 0; $s_n_ro += $flags & EWIKI_DB_F_READONLY ? 1 : 0; $s_n_wr += $flags & EWIKI_DB_F_WRITEABLE ? 1 : 0; $s_fv += $row["version"]; $id = $row["id"]; for ($v = 1; $v <= $row["version"]; $v++) { $r = ewiki_db::GET($id, $v); if (empty($r["created"]) || empty($r["content"])) { $s_holes += 1; } } } $s_frag = $s_fv ? (int) (100 * $s_holes / $s_fv) / 100 . "%" : "N/A"; $o .= '<table border="0" cellpadding="2" cellspacing="1">' . "<tr><td align=\"right\" bgcolor=\"#ccccee\">number of wikipages</td><td bgcolor=\"#eeeecc\">{$s_files}</td></tr>\n" . "<tr><td align=\"right\" bgcolor=\"#ccccee\">text<br />binary<br />disabled pages<br />errors</td><td bgcolor=\"#eeeecc\">{$s_n_txt} <small>({$s_n_txt_r})</small><br />{$s_n_bin} <small>({$s_n_bin_r})</small><br />{$s_n_dis}<br />{$s_n_err}</td></tr>\n" . "<tr><td align=\"right\" bgcolor=\"#ccccee\">flagged read-only<br />explicit writable<br />html enabled pages</td><td bgcolor=\"#eeeecc\">{$s_n_ro}<br />{$s_n_wr}<br />{$s_n_htm}</td></tr>\n" . "<tr><td align=\"right\" bgcolor=\"#ccccee\">absolute page number<br />version holes<br />database fragmentation</td><td bgcolor=\"#eeeecc\">{$s_fv}<br />{$s_holes}<br />{$s_frag}</td></tr>\n" . "</table>\n"; return $o; }
function ewiki_page_orphanedpages($id, $data, $action) { global $ewiki_links; $o = ewiki_make_title($id, $id, 2); $pages = array(); $refs = array(); $orphaned = array(); #-- 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 $o .= ewiki_list_pages($orphaned, 0); return $o; }
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; }
#-- config define("EWIKI_TRANSFER_IDF", "EWBF00000025"); // file magic #-- downloading if ($type = $_REQUEST["fetch"]) { $gzip = $type == "dat.gz"; $date = strftime("%Y-%m-%d", time()); $title = EWIKI_NAME; header("Content-Type: application/octet-stream"); header("Content-Disposition: attachment; filename=\"ewiki_transfer.{$title}.{$date}.{$type}\""); if ($gzip) { ob_start("ob_gzhandler"); } echo EWIKI_TRANSFER_IDF; $n = 0; $result = ewiki_db::GETALL(array("id", "version", "flags")); while ($row = $result->get()) { $n++; $id = $row["id"]; for ($v = $row["version"]; $v > 0; $v--) { $row = ewiki_db::GET($id, $v); if ($_REQUEST["textonly"] && EWIKI_DB_F_TEXT != ($row["flags"] & EWIKI_DB_F_TYPE)) { continue; } if ($row && ($row = serialize($row))) { echo "\n" . strlen($row) . "\n" . $row; } } if ($gzip && !($n % 15)) { ob_flush(); }
$regex = preg_quote($filter); $regex = str_replace("\\*", ".*", $regex); echo "<div class=\"msg\">filter regex /^{$regex}\$/i</div>\n"; $regex = ":^{$regex}\$:i"; } ?> <table border="0" cellpadding="2" cellspacing="0"> <colgroup cols="3"><col width="70%"><col width="10%"><col width="20%"></colgroup> <tr> <th>Name</th> <th>Flags</th> <th>MTime</th> </tr> <?php #-- list all files $all = ewiki_db::GETALL(array("id", "version", "flags", "lastmodified")); while ($row = $all->GET()) { #-- prep $id = $row["id"]; $url_id = urlencode($id); $title = htmlentities(substr($id, 0, 32)); #-- filter? if ($regex && !preg_match($regex, $id)) { continue; } #-- out echo "<tr onClick=\"parent.select_id(event, this, '" . htmlentities($id) . "')\">" . '<td class="fn">' . "<a target=\"page\" href=\"edit.php?id={$url_id}\"" . " onClick=\"return parent.click_magic(event)\">{$title}</a></td>" . '<td align="right">' . flag_text($row["flags"]) . '</td>' . '<td>' . strftime("%Y-%m-%d", $row["lastmodified"]) . '</td>' . "</tr>\n"; } ?> </table> </body>
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_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 all used words inside WikiPageNames and shows a list of them (similar to PageIndex) - but it redirects the words to PowerSearch, which also needs to be installed therefore! */ global $ewiki_plugins; echo ewiki_make_title($id, $id, 2); $result = ewiki_db::GETALL(array("flags")); $src = ""; while ($row = $result->get(0, 0x37, 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]; echo ewiki_list_pages($sorted, $limit = 0, $vat = 1, $pf_list_pages);
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; }
<?php define("N_PAGE_VERSIONS", 1); if (empty($_REQUEST["range"])) { echo ' This tool can be used to remove old page versions from the database, if they just slow down your wiki. For a db_flat_files/db_fast_files powered ewiki you could just delete the files from the database directory. <br><br> Please note, that the right number is always treated as count from the last existing version. So "2..-10" would delete anything from the 2nd to the "LAST minus 10"-th version. <br><br> <form action="t_holes.php" method="POST"> <table class="list" border="0" cellpadding="2" cellspacing="3"> '; $result = ewiki_db::GETALL(array()); while ($row = $result->get()) { if (($n = $row["version"]) >= N_PAGE_VERSIONS) { $id = $row["id"]; echo '<tr>'; echo "<td>" . htmlentities($id) . " (#{$n})</td>"; $n2 = $n - 10; echo '<td> <input type="checkbox" name="id[' . rawurlencode($id) . ']" value="1">' . ' delete versions ' . '<input name="range[' . rawurlencode($id) . ']" value="2..' . $n2 . '" size="7"> </td>'; echo "</tr>\n"; } } echo ' </table> <br><input type="submit" value="strip page versions"><br> </form> <br>
function ewiki_linkdatabase($id, &$data, $action) { if ($_REQUEST["action"] == "links" && $id == "action=links" && empty($_REQUEST["id"])) { $o = array("editlink" => 0, "empty" => 0, "names" => 1, "unique" => 1, "sort" => 1, "exists" => 2, "url" => 0, "inter" => 0, "search" => ""); $o = array_merge($o, $_REQUEST); #-- first read in all pages $res = ewiki_db::GETALL(array("flags", "version", "refs")); $all = array(); while ($row = $res->get()) { if (($row["version"] & EWIKI_DB_F_TYPE) == EWIKI_DB_F_TEXT) { $refs = trim($row["refs"]); if (!$o["empty"] && empty($refs)) { continue; } $all[$row["id"]] = $refs; } } #-- sort ksort($all); #-- output $out = ""; foreach ($all as $i => $refs) { $refs = explode("\n", $refs); if ($refs) { $refs = ewiki_db::FIND($refs); } foreach ($refs as $ri => $rv) { if ($o["exists"] != 2) { if ($rv != $o["exists"]) { unset($refs[$ri]); } } if ($o["url"] != 1) { if ($o["url"] xor strpos($ri, "://")) { unset($refs[$ri]); } } if ($o["inter"] != 1) { if ($o["inter"] xor strpos($ri, ":") && !strpos($ri, "://")) { unset($refs[$ri]); } } if ($o["search"] && strpos($ri, $o["search"]) === false) { unset($refs[$ri]); } } if (!$o["empty"] && empty($refs)) { continue; } if ($o["sort"]) { asort($refs); } $out .= "<a href=\"" . ewiki_script("", $i) . "\">{$i}</a> "; foreach ($refs as $i => $rv) { $title = $o[names] ? $i : " "; if ($rv) { $out .= " <a href=\"" . ewiki_script("", $i) . "\">{$title}</a>"; } else { $out .= " {$title}"; if ($o["editlink"]) { $out .= "<a href=\"" . ewiki_script("", $i) . "\">?</a>"; } } } $out .= "\n"; } return "\n<pre>\n\n\n\n{$out}</pre>\n"; } elseif ($id == "LinkDatabase") { $url = "url:?"; # $url = "ErfurtWiki:"; return ewiki_format(<<<EOT !!! LinkDatabase The LinkDatabase provides a list of all internal pages together with the links outgoing from each. * [{$url}action=links] list pages and links, using default options * [{$url}action=links&editlink=1] add the "?" link for not existent pages * [{$url}action=links&empty=1] allowes listing of pages without forward links * [{$url}action=links&names=0] no link title, just the <a href="..."> * [{$url}action=links&sort=0] order pages and their links * [{$url}action=links&exists=0] only links to not existing pages * [{$url}action=links&exists=1] only existing page links * [{$url}action=links&url=1] add URLs * [{$url}action=links&url=2] __only__ URLs * [{$url}action=links&inter=1] add ~InterWiki:Links * [{$url}action=links&inter=2] __only__ ~InterWiki:Links * [{$url}action=links&search=google] apply search pattern to page links handy combinations * [{$url}action=links&inter=1&editlink=1&empty=1&url=1&sort=0&names=1] show all links * [{$url}action=links&search=sourceforge&url=2] only URL links to sourceforge * [{$url}action=links&sort=0&exists=0] unsorted missing pages Only [{$url}action=links&unique=0] has not been implemented. EOT ); } }
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; }
action are: - "deleted" (or "DeletedPage") - "DeletePage" or "delete" - simply "trash" or a link to "TrashCan" - "RemovePage", "remove" - "RemovedPage", "removed" This feature is also known as MeatBall:KeptPages. */ // define("DELETEPAGES", 1); #-- proceed if (defined("DELETEPAGES") && DELETEPAGES && $keptpages) { echo "[{$cron}]: Scanning for pages to kill...\n"; $triggers = array("delete", "deleted", "del", "remove", "removed", "kill", "unlink", "unlink()", "unlink();", "trash", "rm", "rm -f", "DeletePage", "DeletedPage", "RemovePage", "KillPage", "UnlinkPage", "TrashCan"); #-- list all $all = ewiki_db::GETALL("id", "version", "lastmodified"); while ($row = $all->get()) { #-- check that it wasn't modified lately if (time() >= $row["lastmodified"] + $keptpages) { #-- check page content for trigger words $id = $row["id"]; $row = ewiki_db::GET($id); $text = strtolower(trim($row["content"])); $refs = trim($row["refs"]); if (in_array($text, $triggers) or ewiki_in_array($refs, $triggers)) { #-- purge it, no mercy!!!!! echo " {$id}"; for ($v = $row["version"]; $v >= 1; $v--) { if (ewiki_db::GET($id, $v)) { echo " [{$v}]"; ewiki_db::DELETE($id, $v);
<?php /* page list, ordered by count of backlinks */ echo ewiki_make_title($id, $id, 2); #-- fetch all pages $exist = array() + ewiki_array($ewiki_plugins["page"]); $refs = array(); $result = ewiki_db::GETALL(array("refs")); while ($r = $result->get(0, 0x137, EWIKI_DB_F_TEXT)) { $id = $r["id"]; $exist[strtolower($id)] = 1; foreach (explode("\n", trim($r["refs"])) as $i) { $refs[$i]++; } } unset($refs[0]); #-- beatify list if (isset($_REQUEST["desc"])) { asort($refs); } else { arsort($refs); } #-- output foreach ($refs as $id => $num) { echo "· " . "(<a href=\"" . ewiki_script("links", $id) . "\">{$num}</a>) " . ($exist[strtolower($id)] ? "<a href=\"" . ewiki_script("", $id) . "\">{$id}</a>" : "{$id}") . "<br>\n"; }
<?php include "t_config.php"; ?> <html> <head> <title>delete ewiki pages</title> <link rel="stylesheet" type="text/css" href="t_config.css"> </head> <body bgcolor="#ffffff" text="#000000"> <h1>delete pages from DB</h1> <?php if (empty($_REQUEST["remove"])) { echo "\n\tNote that only <b>unreferenced pages</b> will be listed here. And\n\tbecause the ewiki engine itself does only limited testing if a page is\n\treferenced it may miss some of them here.<br>\n If you however empty a page first, it will get listed here too.\n Various other database diagnostics are made as well.<br><br>\n"; $result = ewiki_db::GETALL(array("version")); $selected = array(); if (@$_REQUEST["listall"]) { while ($row = $result->get()) { $selected[$row["id"]] = "listall <br>"; } } else { while ($page = $result->get()) { $id = $page["id"]; if (!strlen($id)) { continue; } $page = ewiki_db::GET($id); $flags = $page["flags"]; if (!strlen(trim($page["content"]))) { @($selected[$id] .= "EMPTY <br>"); }