本文整理汇总了PHP中ewiki_db类的典型用法代码示例。如果您正苦于以下问题:PHP ewiki_db类的具体用法?PHP ewiki_db怎么用?PHP ewiki_db使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ewiki_db类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ewiki_valid_pages
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;
}
示例2: ewiki_anacron_checktime
function ewiki_anacron_checktime()
{
global $ewiki_plugins;
if ($d = ewiki_db::GET(EWIKI_ANACRON_ID) and $d = unserialize($d["content"]) and $d["last"] >= UNIX_MILLENNIUM and time() >= $d["last"] + EWIKI_ANACRON_INTERLEAVE) {
register_shutdown_function("ewiki_anacron_runparts");
}
}
示例3: ewiki_page_wordindex
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;
}
示例4: ewiki_powersearch
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;
}
示例5: ewiki_banned_link
function ewiki_banned_link($href)
{
global $ewiki_config;
#-- buffer list of banned urls
if (!isset($ewiki_config["banned"])) {
$data = ewiki_db::GET(EWIKI_PAGE_BANNED);
$ewiki_config["banned"] = trim(strtolower($data["refs"]));
}
#-- check for entry
if ($b =& $ewiki_config["banned"]) {
$href = strtolower(urldecode($href));
if (strpos($b, $href) !== false) {
return true;
}
foreach (explode("\n", $b) as $bad) {
if (strpos($href, $bad) !== false) {
return true;
}
}
}
#-- advanced
if ($pf_a = $ewiki_plugins["ban_lookup"]) {
foreach ($pf_a as $pf) {
if ($pf($href)) {
return true;
}
}
}
return false;
}
示例6: ewiki_action_rss
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);
}
示例7: ewiki_page_since_updates
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;
}
示例8: ewiki_edit_form_append_pageimgcntrl
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;
}
示例9: ewiki_page_wiki_mini_tarball_dump
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;
}
示例10: ewiki_blocked_link
function ewiki_blocked_link($href, $LinkPage = EWIKI_PAGE_BLOCKED)
{
global $ewiki_config, $ewiki_plugins;
if (!($href = trim(strtolower(urldecode($href))))) {
return;
}
#-- buffer list of banned urls
if (!isset($ewiki_config[$LinkPage])) {
$data = ewiki_db::GET($LinkPage);
$ewiki_config[$LinkPage] = trim(strtolower($data["refs"]));
}
#-- check for entry
if ($b =& $ewiki_config[$LinkPage]) {
if (strpos($b, $href) !== false) {
// quick string check
return true;
}
foreach (explode("\n", $b) as $bad) {
// use as patterns
if (strlen($bad) && strpos($href, $bad) !== false) {
return true;
}
}
}
#-- advanced
if ($pf_a = $ewiki_plugins["ban_lookup"]) {
foreach ($pf_a as $pf) {
if ($pf($href)) {
return true;
}
}
}
return false;
}
示例11: ewiki_addpage
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;
}
示例12: ewiki_announcements
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;
}
示例13: ewiki_page_wantedpages
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;
}
示例14: ewiki_edit_load_template
function ewiki_edit_load_template($id, &$data, $action)
{
if ($id = $_REQUEST["load_template"]) {
$d2 = ewiki_db::GET($id);
$data["content"] = $d2["content"];
}
}
示例15: ewiki_view_append_linktree
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;
}