当前位置: 首页>>代码示例>>PHP>>正文


PHP ewiki_db::WRITE方法代码示例

本文整理汇总了PHP中ewiki_db::WRITE方法的典型用法代码示例。如果您正苦于以下问题:PHP ewiki_db::WRITE方法的具体用法?PHP ewiki_db::WRITE怎么用?PHP ewiki_db::WRITE使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ewiki_db的用法示例。


在下文中一共展示了ewiki_db::WRITE方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: 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;
}
开发者ID:gpuenteallott,项目名称:rox,代码行数:32,代码来源:addnewpage.php

示例2: ewiki_mpi_survey

function ewiki_mpi_survey($action, &$args, &$iii, &$s)
{
    global $ewiki_id, $ewiki_plugins;
    $o = "";
    #-- load data page
    if (!($df = $args["data"])) {
        return;
    }
    unset($args["data"]);
    unset($args["_"]);
    unset($args[""]);
    $data = ewiki_db::GET($df);
    if (!$data["version"]) {
        $data = ewiki_new_data($df, EWIKI_DB_F_BINARY);
        $data["version"]--;
    }
    if ($data["flags"] != EWIKI_DB_F_BINARY) {
        return;
    }
    $survey = unserialize($data["content"]);
    #-- operation
    $vote = @$_REQUEST[EWIKI_UP_SURVEY];
    if ($vote == "\$") {
        $action = "show";
    }
    if ($action == "html") {
        #-- show entries
        if (!$vote) {
            $o = "\n" . '<form action="' . $_SERVER["REQUEST_URI"] . '" method="POST" enctype="multipart/form-data">' . '<input type="hidden" name="id" value="' . htmlentities($ewiki_id) . '">' . "\n";
            foreach ($args as $name => $text) {
                if (!$name || !$text || $name == "data") {
                    continue;
                }
                $o .= '<input type="radio" name="' . EWIKI_UP_SURVEY . '" value="' . htmlentities($name) . '"> ' . $text . "<br />\n";
            }
            $o .= '<input type="submit" value="vote">';
            $o .= "\n</form>\n<br /><br />\n";
            $o .= '<a href="' . ewiki_script("", $ewiki_id, array(EWIKI_UP_SURVEY => "\$")) . '">show results</a><br />';
        }
        #-- store an entry
        if ($vote) {
            $survey[$vote]++;
            $data["content"] = serialize($survey);
            $data["version"]++;
            $data["lastmodified"] = time();
            $data["author"] = ewiki_author();
            ewiki_db::WRITE($data);
            #-- show it
            $action = "show";
        }
    }
    if ($action == "show") {
        $o .= $ewiki_plugins["view_stat"][0]($survey, $args);
    }
    return $o;
}
开发者ID:gpuenteallott,项目名称:rox,代码行数:56,代码来源:mpi_survey.php

示例3: ewiki_add_thread

function ewiki_add_thread($id, $data, $action)
{
    global $ewiki_plugins;
    $id = $id . EWIKI_THREAD_SEPARATOR . $_REQUEST['threadname'];
    $save = array("id" => $id, "version" => 1, "flags" => '', "content" => "   ", "author" => ewiki_author(), "lastmodified" => time(), "created" => time(), "meta" => array('isThread' => '1'), "hits" => 0, "refs" => "");
    if (!ewiki_db::WRITE($save)) {
        return ewiki_t("ERRORSAVING");
    }
    return ewiki_add_post($id, array(), 'addpost');
}
开发者ID:gpuenteallott,项目名称:rox,代码行数:10,代码来源:threads.php

示例4: ewiki_pingback_rpc

function ewiki_pingback_rpc($source_url, $target_url)
{
    global $ewiki_config;
    #-- does the target URL refer to a known WikiPage ?
    $id = ewiki_url2id($target_url);
    if (!$id) {
        xmlrpc_send_response(xmlrpc_error(0x21, "Could not determine PageName for the given target URL."));
    }
    if (!($data = ewiki_db::GET($id))) {
        xmlrpc_send_response(xmlrpc_error(0x20, "The given target page does not exist."));
    }
    #-- check if the caller really has a link as he claims
    ini_set("user_agent", $ewiki_config["ua"]);
    if (strpos($source_url, "http://") === 0 && ($test = ewiki_http_asis($source_url, 96256))) {
        $test = strtolower($test);
        $test_url = strtolower($target_url);
        if (!strpos($test, $test_url) and !strpos($test, htmlentities($test_url))) {
            return xmlrpc_error(0x11, "Sorry, but couldn't find a link to '{$target_url}' on your given '{$source_url}' page.");
        }
    } else {
        return xmlrpc_error(0x10, "Your given source URL does not exist, could not be retrieved.");
    }
    #-- reject other frivolous links
    if (preg_match('#^http://[^/]+/?$#', $source_url)) {
        return xmlrpc_error(0x11, "Rejected '{$source_url}' as frivolous.");
    }
    #-- check write permissions
    if (EWIKI_DB_F_TEXT != $data["flags"] & EWIKI_DB_F_TYPE or $data["flags"] & EWIKI_DB_F_READONLY) {
        return xmlrpc_error(0x31, "Sorry, but this page is write-protected or not a system page.");
    }
    #-- already on page
    if (strpos($data["content"], $source_url)) {
        return xmlrpc_error(0x30, "The given link does already exist on this page.");
    }
    #-- other go-away cases
    if (function_exists("ewiki_banned_url") && ewiki_banned_url($source_url) || function_exists("ewiki_blocked_url") && ewiki_blocked_url($source_url)) {
        return xmlrpc_error(0x100, "Your link is unwanted here (registered on BlockedLinks or BannedLinks).");
    }
    #-- else update page
    $data["content"] = rtrim($data["content"]) . "\n* {$source_url} (PingBack)\n";
    ewiki_db::UPDATE($data);
    $data["version"]++;
    $ok = ewiki_db::WRITE($data);
    #-- fin response
    if ($ok) {
        return "Link to '{$source_url}' was added to page '{$id}'.";
    } else {
        return xmlrpc_error(0x101, "Seems like a database/writing error occoured.");
    }
}
开发者ID:gpuenteallott,项目名称:rox,代码行数:50,代码来源:pingback.php

示例5: ewiki_mpi_registerspam

function ewiki_mpi_registerspam($action, &$args, &$iii, &$s)
{
    global $ewiki_id;
    if (!$_POST["regspam"]) {
        return <<<END
<form action="{$_SERVER['REQUEST_URI']}" method="POST" enctype="multipart/form-data">
<textarea name="add_spam" cols="50" rows="3"></textarea><br/>
<input type="submit" name="regspam" value="add listed urls" />
</form>
END;
    } else {
        #-- scan for links
        $text = $_REQUEST["add_spam"];
        ewiki_scan_wikiwords($text, $uu);
        $ls = array();
        foreach ($uu as $href => $uu) {
            if ($l = strpos($href, "://")) {
                // filter out redundant pattern parts
                $href = substr($href, $l + 3);
                if (strpos($href, "www.") === 0) {
                    $href = substr($href, 4);
                }
                $href = trim($href, "/");
                $ls[] = strtok($href, " ");
            }
        }
        #-- reduce
        $ls = array_unique($ls);
        $data = ewiki_db::GET($ewiki_id);
        foreach (explode("\n", trim($data["refs"])) as $href) {
            if (in_array($href, $ls)) {
                unset($ls[array_search($href, $ls)]);
            }
        }
        #-- add to current page
        if ($ls) {
            $inj = "* [" . implode("], [", $ls) . "]\n";
            $data["content"] = preg_replace("/(^[-*#])/m", "{$inj}\$1", $data["content"], 1);
            ewiki_db::UPDATE($data);
            $data["version"]++;
            ewiki_db::WRITE($data);
            return "\n<div class=\"system-message ok\">new links added as patterns here (please go back and reload page to see it)</div>\n";
        } else {
            return "\n<div class=\"system-message failure\">no new links found, please add the patterns by hand then</div>\n";
        }
    }
}
开发者ID:gpuenteallott,项目名称:rox,代码行数:47,代码来源:mpi_registerspam.php

示例6: ewiki_sync_local

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:
    }
}
开发者ID:gpuenteallott,项目名称:rox,代码行数:17,代码来源:sync.php

示例7: ewiki_action_image_append

function ewiki_action_image_append($id, $data, $action)
{
    #-- invalid $id value
    if (empty($data) || !$data["version"] || EWIKI_DB_F_TEXT != ($data["flags"] & EWIKI_DB_F_TYPE)) {
        $o = ewiki_t("CANNOTCHANGEPAGE");
    } elseif ($fa = $_FILES["imagefile"]) {
        #-- guess HTTP meta data
        $meta = array("X-Content-Type" => $fa["type"]);
        if ($s = $fa["name"]) {
            $meta["Content-Location"] = $s;
            $p = 0 or $p = strrpos($s, "/") and $p++ or $p = strrpos($s, '\\') and $p++;
            $meta["Content-Disposition"] = 'inline; filename="' . urlencode(substr($s, $p)) . '"';
        }
        #-- proceed an image (reject binary, resize if too large)
        $result = ewiki_binary_save_image($fa["tmp_name"], "", "RETURN", $meta, 0, 1);
        #-- database rejected file
        if (!$result) {
            $o = ewiki_t("BIN_NOIMG");
        } else {
            $loop = 3;
            while ($loop--) {
                $data = ewiki_db::GET($id);
                $data["version"]++;
                $data["content"] = rtrim($data["content"], "\n") . "\n\n" . "[\"AppendedPicture\"{$result}]\n\n\n";
                $result = ewiki_db::WRITE($data);
                if ($result) {
                    break;
                }
            }
            if ($result) {
                $o = ewiki_page("view/{$id}");
                ewiki_log("image appended to '{$id}'");
            } else {
                $o .= ewiki_t("NO_IMAGEAPPEND");
            }
        }
    } else {
        $o .= ewiki_t("BIN_NOIMG");
        #"You did not select an image, or something went really wrong during tansmission. Plase go back to the previous page.";
    }
    return $o;
}
开发者ID:gpuenteallott,项目名称:rox,代码行数:42,代码来源:imgappend.php

示例8: ewiki_mpi_bugreportstate

function ewiki_mpi_bugreportstate($action, $args, &$iii, &$s)
{
    global $ewiki_id;
    #-- possible states
    $values = array("open", "closed", "done", "frozen", "answered");
    foreach ($args as $i => $name) {
        if (is_int($i)) {
            if (preg_match("/^\\w+\$/", $name) && !in_array($name, $values)) {
                $values[] = $name;
            }
        }
    }
    $rxvals = implode("|", $values);
    #-- if button pressed
    if (($new = $_REQUEST["brs_change"]) && in_array($new, $values)) {
        $pages = ewiki_get_backlinks($ewiki_id);
        $pages[] = $ewiki_id;
        #-- change assoc pages
        foreach ($pages as $id) {
            $data = ewiki_db::GET($id);
            if (preg_match("/\n\\|.*stat(e|us).*\\|.*({$rxvals})/", $data["content"]) or preg_match("/\n\\|.*({$rxvals}).*\\|.*{$ewiki_id}/", $data["content"])) {
                $data["content"] = preg_replace("/(\n\\|.*stat(?:e|us).*\\|.*?)[_*]*(?:{$rxvals})[_*]*/", "\$1{$new}", $data["content"]);
                $data["content"] = preg_replace("/(\n\\|.*?)[_*]*(?:{$rxvals})[_*]*(.*?\\|.*{$ewiki_id})/", "\$1{$new}\$2", $data["content"]);
                ewiki_db::UPDATE($data);
                $data["version"]++;
                ewiki_db::WRITE($data);
            }
        }
        $o = "<p>(status changed)</p>";
        $iii[0][0] = preg_replace("/({$rxvals})/", "{$new}", $iii[0][0]);
    } else {
        $url = ewiki_script("", $ewiki_id);
        $o .= <<<EOT
<form action="{$url}#added" method="POST" enctype="multipart/form-data">
<input type="submit" name="brs_change" value="open">
<input type="submit" name="brs_change" value="closed">
<input type="submit" name="brs_change" value="frozen">
</form>
EOT;
    }
    return $o;
}
开发者ID:gpuenteallott,项目名称:rox,代码行数:42,代码来源:mpi_bugreportstate.php

示例9: ewiki_mpi_addlink

function ewiki_mpi_addlink($action, $args, &$iii, &$s)
{
    global $ewiki_id, $ewiki_action;
    $o = "";
    #-- add URL
    if ($_REQUEST["link_save"]) {
        #-- check parameters
        $url = trim($_REQUEST["link_url"]);
        $text = "";
        $title = $desc = "";
        if (!strpos($url, "example.com") && strlen($url) > 12 && preg_match('#^https?://#', $url)) {
            $text = implode("", file($url));
            if ($text) {
                preg_match('#<title[^>]*>([^<]+)</title>#ims', $text, $uu) and $title = $uu[1] or preg_match('#//([^/]+)#', $url, $uu) and $title = $uu[1];
                preg_match('#<meta[^>]+name=["\']description["\'][^>]+content=["\']([^"\']+)["\']#ims', $text, $uu) and $desc = $uu[1] or preg_match('#<body[^>]+>(.+?)</body#ims', $text, $uu) and $desc = strip_tags($uu[1]);
                $desc = substr(preg_replace('/\\s+/', " ", $desc), 0, 300);
            }
            $add = ":{$title}:\n   {$url} %%%\n   {$desc}\n";
        }
        #-- store bugreport
        if ($text) {
            $data = ewiki_db::GET($ewiki_id);
            $data["content"] = rtrim($data["content"]) . "\n" . $add;
            ewiki_data_update($data);
            $data["version"]++;
            ewiki_db::WRITE($data);
            #-- append to page output
            $iii[] = array($add, 0xffff, "core");
        }
    } else {
        $url = ewiki_script("", $ewiki_id);
        $o .= <<<EOT
<form style="border:2px #333370 solid; background:#7770B0; padding:5px;"class="BugReport" action="{$url}" method="POST" enctype="multipart/form-data">
<input type="hidden" name="id" value="{$ewiki_action}/{$ewiki_id}">
Link <input type="text" name="link_url" value="http://www.example.com/" size="50">
<input type="submit" name="link_save" value="hinzufügen">
</form>
EOT;
    }
    return $o;
}
开发者ID:gpuenteallott,项目名称:rox,代码行数:41,代码来源:mpi_addlink.php

示例10: ewiki_editable_intermap

function ewiki_editable_intermap($id, $data, $action)
{
    global $ewiki_config;
    $o = "";
    if (($url = $_REQUEST["add_url"]) && ($moni = $_REQUEST["add_moniker"])) {
        if (!preg_match('#^http[sz]?://(\\w{2,}\\.)+\\w{2,}(:\\d+)?[^\\[\\]\\"\\s]+$#', $url) || strpos($url, "example")) {
            $o .= "URL was rejected.";
        } elseif (!preg_match('#^([' . EWIKI_CHARS_U . ']+[' . EWIKI_CHARS_L . ']+){2,}[' . EWIKI_CHARS . ']+$#', $moni) || $moni == "WikiName") {
            $o .= "Choosen InterWiki moniker not acceptable.";
        } else {
            if ($ewiki_config["interwiki"][$moni]) {
                $o .= "(Note: eventually overriding earlier entry.)<br />";
            }
            $data["content"] = "\n" . trim($data["content"]) . "\n" . ":{$moni}:{$url}" . "\n";
            ewiki_data_update($data);
            $data["version"]++;
            if (ewiki_db::WRITE($data)) {
                $o .= "Map was updated.";
            } else {
                $o .= "Error occoured when saving your changes.";
            }
        }
        $o .= "<br />";
    }
    $o .= ewiki_make_title($id, $id, 2);
    $o .= ewiki_page_view($id, $data, $action, 0);
    $o .= ewiki_t(<<<EOT
    <form class="intermap-append" action="{$_SERVER['REQUEST_URI']}" method="POST" enctype="multipart/form-data">
      <hr>
      <input type="hidden" name="id" value="{$id}">
      :<input name="add_moniker" value="WikiName" size="16">:<input name="add_url" value="http://www.example.com/..." size="42">
      <br />
      <input type="submit" value="_{add}">
    </form>
EOT
);
    return $o;
}
开发者ID:gpuenteallott,项目名称:rox,代码行数:38,代码来源:editable.php

示例11: ewiki_cache_url

function ewiki_cache_url($url, $cache_min = 1200)
{
    global $ewiki_cache_ctype;
    #-- check if fresh enough in cache (20min)
    $data = ewiki_db::GET($url);
    if (time() <= $data["lastmodified"] + $cache_min) {
        $ewiki_cache_ctype = $data["Content-Type"];
        return $data["content"];
    }
    #-- retrieve
    $req = new http_request("GET", $url);
    $req->header["Accept"] = "application/atom+xml, application/rss+xml, text/rss, xml/*, */*rss*";
    if ($data["meta"]["Last-Modified"]) {
        $req->headers["If-Modified-Since"] = $data["meta"]["Last-Modified"];
    }
    if ($data["meta"]["Etag"]) {
        $req->headers["If-None-Match"] = $data["meta"]["Etag"];
    }
    $result = $req->go();
    #-- create/overwrite cache entry
    if ($result->status == 200) {
        $data = ewiki_db::CREATE($url, 0x0, "ewiki_cache_url");
        $data["flags"] = 0x0;
        $data["content"] = $result->body;
        foreach ($result->headers as $i => $v) {
            $data["meta"][$i] = $v;
        }
        $data["meta"]["class"] = "temp";
        $data["meta"]["kill-after"] = time() + $cache_min;
        if ($t = $data["meta"]["Last-Modified"]) {
            //    $data["lastmodified"] = ewiki_decode_datetime($t);
        }
        ewiki_db::WRITE($data, "_OVERWRITE=1");
    }
    $ewiki_cache_ctype = $data["Content-Type"];
    return $data["content"];
}
开发者ID:gpuenteallott,项目名称:rox,代码行数:37,代码来源:http_cache.php

示例12: ewiki_cache_generated_pages

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;
}
开发者ID:gpuenteallott,项目名称:rox,代码行数:36,代码来源:page_searchcache.php

示例13: time

    if ($_REQUEST["update"]["lastmodified"]) {
        $data["lastmodified"] = time();
    }
    // {refs}
    if ($_REQUEST["update"]["refs"]) {
        ewiki_scan_wikiwords($data["content"], $links, "_STRIP_EMAIL=1");
        $data["refs"] = "\n\n" . implode("\n", array_keys($links)) . "\n\n";
    } else {
        $data["refs"] = "\n\n" . trim(trim($data["refs"], "\n"), "\r") . "\n\n";
    }
    // {content}
    if ($data["flags"] & EWIKI_DB_F_TEXT) {
        $data["content"] = preg_replace("/\r*(\n)\r?/", "\$1", $data["content"]);
    }
    #-- ok, throw into DB
    if (ewiki_db::WRITE($data, $overwrite = 1)) {
        echo "<div class=\"msg\">page written into database</div>\n\n";
    } else {
        echo "<div class=\"msg\">error writing entry to db</div>\n\n";
    }
}
#-- fill with inital data
if ($_REQUEST["create"] && !$data) {
    $data = ewiki_db::CREATE($id);
}
#-- start output
echo '<form action="edit.php" method="POST" enctype="multipart/form-data">';
echo '<input type="hidden" name="id" value="' . htmlentities($id) . '">';
#-- {id}
print_field($data, "id", 32);
#-- {version}
开发者ID:gpuenteallott,项目名称:rox,代码行数:31,代码来源:edit.php

示例14: cmd_touch

function cmd_touch($ls)
{
    foreach ($ls as $id) {
        if ($data = ewiki_db::GET($id)) {
            echo "{$data['id']}<br>\n";
            $data["lastmodified"] = time();
            ewiki_db::WRITE($data, $overwrite = 1);
        } else {
            echo "'{$id}' does not exist<br>\n";
        }
    }
}
开发者ID:gpuenteallott,项目名称:rox,代码行数:12,代码来源:action.php

示例15: ewiki_action_control_page

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.";
//.........这里部分代码省略.........
开发者ID:gpuenteallott,项目名称:rox,代码行数:101,代码来源:control.php


注:本文中的ewiki_db::WRITE方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。