本文整理汇总了PHP中ewiki_db::UPDATE方法的典型用法代码示例。如果您正苦于以下问题:PHP ewiki_db::UPDATE方法的具体用法?PHP ewiki_db::UPDATE怎么用?PHP ewiki_db::UPDATE使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ewiki_db
的用法示例。
在下文中一共展示了ewiki_db::UPDATE方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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.");
}
}
示例2: 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";
}
}
}
示例3: 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;
}
示例4: PUT
function PUT($path, $ct, $charset)
{
#-- let's call the auth routine once more??
$this->auth();
#-- get old page version
$id = $this->id($path);
$data = ewiki_db::GET($id) or $data = ewiki_db::CREATE($id);
#-- read from whereever
$data["content"] = $this->get_body();
#-- check content-type
if ($ct != "text/wiki" && $ct != "text/plain") {
return "422 Only WikiPages Accepted";
}
#-- save back to db
ewiki_db::UPDATE($data);
$data["version"] += 1;
$ok = ewiki_db::WRITE($data);
#-- handle response here
if ($ok) {
return "200 Written Successfully";
}
return "500 Couldn't Save";
}
示例5: ewiki_mpi_bugreport
function ewiki_mpi_bugreport($action, $args, &$iii, &$s)
{
global $ewiki_id;
$MAIN = $ewiki_id;
//"BugReports";
$ELSE = $args[0] or $ELSE = rtrim($MAIN, "s");
$o = "";
if ($_REQUEST["br_save"]) {
#-- check parameters
$content = $_REQUEST["content"];
$title = $_REQUEST["title"];
$author = $_REQUEST["author"];
if (strlen($content) < 50) {
return "<p><b>Insufficient information for a useful BugReport.</b></p>";
}
if (strstr($title, "???")) {
$title = substr($content, 0, 50);
}
#-- make page name for bug report
$new_id = ewiki_title_to_pagename($title, $ELSE);
#-- generate bug page text
$new = "This page is part of the {$MAIN} series. Please go there to submit a new bug or to see the list of all existing reports.\n";
if ($m = $_REQUEST["br_notify"]) {
$new .= "\n[notify:{$m}]\n";
}
$new .= "\n----\n\n" . "!! {$title}\n\n";
foreach ($_REQUEST["i"] as $i => $v) {
if ($v != "unknown") {
$new .= "| {$i} | {$v} |\n";
}
}
$new .= "| status | __open__ |\n <?plugin BugReportState ?" . "> \n";
$new .= "\n{$author}: {$content}\n\n";
#-- create new bug report page
$data = ewiki_db::CREATE($new_id);
$data["content"] = $new;
ewiki_db::UPDATE($data);
$data["version"] = 1;
$ok = ewiki_db::WRITE($data);
if (!$ok) {
return "<b>Error</b> while creating new bug report page. Please go back and change the title (at least two words required), so we can try again.";
}
#-- store bugreport entry on main page
$data = ewiki_db::GET($MAIN);
$list_e = "| __open__ | {$new_id} | {$title} |\n";
$data["content"] = preg_replace("/(\n\\|.+\\|.+\\|\\s*\n)/", "\$1{$list_e}", $data["content"], 1);
ewiki_db::UPDATE($data);
$data["version"]++;
ewiki_db::WRITE($data);
if ($notify = function_exists($pf = "ewiki_notify_edit_hook")) {
$pf($MAIN, $data, $uu);
}
#-- append to page output
$iii[] = array("\n\n| new bug report [#added \"added\"] as {$new_id} |\n\n", 0xffff, "core");
} else {
$url = ewiki_script("", $ewiki_id);
$ver = EWIKI_VERSION;
$current_vers = "<option>{$ver}";
for ($i = $ver[strlen($ver) - 1] - 1; $i > 0; $i--) {
$current_vers .= "<option>" . substr($ver, 0, strlen($ver) - 1) . $i;
}
$o .= <<<EOT
<form style="border:2px #444455 solid; background:#9999aa; padding:5px;"class="BugReport" action="{$url}#added" method="POST" enctype="multipart/form-data">
bug title: <input type="text" name="title" value="???" size="50">
<br/>
<br/>
YourName: <input type="text" name="author" value="anonymous" size="30">
<br/>
<br/>
your ewiki version: <select name="i[ewiki version]"><option>unknown<option>other{$current_vers}<option>CVS today<option>CVS yesterday<option>CVS last week<option>two weeks old<option>latest -dev<option>R1.02a<option>R1.01f<option>R1.01e<option>R1.01d<option>R1.01c<option>R1.01b<option>R1.01a</select>
plattform: <select name="i[operating system]"><option>unknown<option>other<option>Win4<option>NT (2K,XP)<option>Unix<option>Linux<option>OS X</select>
<br/>
database: <select name="i[database backend]"><option>unknown<option>mysql<option>db_flat_files<option>db_fast_files<option>anydb: other<option>anydb: pgsql<option>dzf2<option>dba/dbm<option>phpwiki13<option>zip<option>other<option>own</select>
php version: <select name="i[php version]"><option>unknown<option>4.0.x<option>4.1.x<option>4.2.x<option>4.3.x<option>4.4/4.5 (CVS)<option>5.0-beta/rc<option>5.0.x<option>CGI/suPHP<option>PHP/FastCGI<option>SafeMode 4.x</select>
<br>
problem category (vague): <select name="i[bug category]"><option>unknown<option>general<option>feature request<option>get running<option>markup<option>links<option>error message<option>plugin<option>page plugin<option>action plugin<option>auth plugin<option>aview plugin<option>edit plugin<option>feature extension<option>link tweak plugin<option>mpi plugin<option>spages<option>lib extension<option>module plugin<option>db plugin<option>configuration<option>documentation</select>
<br/>
<br/>
long error description:<br />
<textarea name="content" cols="75" rows="8">
</textarea>
<br/><br/>
<input type="submit" name="br_save" value="create bug page">
<br/>
<br/>
email notification <input type="text" name="br_notify" value="" size="16">
<br/><small>(opt., only enter if you want get notified on any responses)</small>
<br/>
</form>
EOT;
}
return $o;
}
示例6: serialize
<?php
/*
This part writes back the $anacron[] timestamps, so we can keep track
of when we run which parts in here.
*/
#-- update
if ($anacron && ANACRON_ID) {
echo "[{$cron}]: writing back anacron timestamps\n";
#-- get old
$data = ewiki_db::GET(ANACRON_ID) or $data = ewiki_db::CREATE(ANACRON_ID);
#-- vars
$data["flags"] = EWIKI_DB_F_SYSTEM;
ewiki_db::UPDATE($data);
$data["lastmodified"] = $anacron["last"] = EWIKI_CRON;
$data["content"] = serialize($anacron);
#-- overwrite
ewiki_db::WRITE($data, 1) or $data["version"]++ && ewiki_db::WRITE($data);
}