function InsertPage($dbi, $pagename, $pagehash) { // update the wikilinks table $linklist = ExtractWikiPageLinks($pagehash['content']); SetWikiPageLinks($dbi, $pagename, $linklist); // prepare the content for storage if (!isset($pagehash["pagename"])) { $pagehash["pagename"] = $pagename; } if (!isset($pagehash["flags"])) { $pagehash["flags"] = 0; } $pagehash["author"] = addslashes($pagehash["author"]); $pagehash["content"] = implode("\n", $pagehash["content"]); $pagehash["content"] = addslashes($pagehash["content"]); $pagehash["pagename"] = addslashes($pagehash["pagename"]); $pagehash["refs"] = serialize($pagehash["refs"]); // Check for empty variables which can cause a sql error if (empty($pagehash["created"])) { $pagehash["created"] = time(); } if (empty($pagehash["version"])) { $pagehash["version"] = 1; } // record the time of modification $pagehash["lastmodified"] = time(); if (IsWikiPage($dbi, $pagename)) { $PAIRS = "author='{$pagehash['author']}'," . "content='{$pagehash['content']}'," . "created={$pagehash['created']}," . "flags={$pagehash['flags']}," . "lastmodified={$pagehash['lastmodified']}," . "pagename='{$pagehash['pagename']}'," . "refs='{$pagehash['refs']}'," . "version={$pagehash['version']}"; $query = "UPDATE {$dbi['table']} SET {$PAIRS} WHERE pagename='{$pagename}'"; } else { // do an insert // build up the column names and values for the query $COLUMNS = "author, content, created, flags, " . "lastmodified, pagename, refs, version"; $VALUES = "'{$pagehash['author']}', '{$pagehash['content']}', " . "{$pagehash['created']}, {$pagehash['flags']}, " . "{$pagehash['lastmodified']}, '{$pagehash['pagename']}', " . "'{$pagehash['refs']}', {$pagehash['version']}"; $query = "INSERT INTO {$dbi['table']} ({$COLUMNS}) VALUES({$VALUES})"; } // echo "<p>Query: $query<p>\n"; $retval = pg_exec($dbi['dbc'], $query); if ($retval == false) { echo "Insert/update failed: " . pg_errormessage($dbi['dbc']); } }
function InsertPage($dbi, $pagename, $pagehash, $pagestore = 'wiki') { if ($pagestore == 'wiki') { // a bit of a hack $linklist = ExtractWikiPageLinks($pagehash['content']); SetWikiPageLinks($dbi, $pagename, $linklist); } $pagedata = PadSerializedData(serialize($pagehash)); if (dbminsert($dbi[$pagestore], $pagename, $pagedata)) { if (dbmreplace($dbi[$pagestore], $pagename, $pagedata)) { ExitWiki("Error inserting page '{$pagename}'"); } } }
function InsertPage($dbi, $pagename, $pagehash) { global $WikiPageStore; // ugly hack if ($dbi['table'] == $WikiPageStore) { // HACK $linklist = ExtractWikiPageLinks($pagehash['content']); SetWikiPageLinks($dbi, $pagename, $linklist); } $pagehash = MakeDBHash($pagename, $pagehash); // record the time of modification $pagehash["lastmodified"] = time(); if (IsWikiPage($dbi, $pagename)) { $PAIRS = "author='{$pagehash['author']}'," . "content='{$pagehash['content']}'," . "created={$pagehash['created']}," . "flags={$pagehash['flags']}," . "lastmodified={$pagehash['lastmodified']}," . "pagename='{$pagehash['pagename']}'," . "refs='{$pagehash['refs']}'," . "version={$pagehash['version']}"; $query = "UPDATE {$dbi['table']} SET {$PAIRS} WHERE pagename='{$pagename}'"; } else { // do an insert // build up the column names and values for the query $COLUMNS = "author, content, created, flags, lastmodified, " . "pagename, refs, version"; $VALUES = "'{$pagehash['author']}', '{$pagehash['content']}', " . "{$pagehash['created']}, {$pagehash['flags']}, " . "{$pagehash['lastmodified']}, '{$pagehash['pagename']}', " . "'{$pagehash['refs']}', {$pagehash['version']}"; $query = "INSERT INTO {$dbi['table']} ({$COLUMNS}) VALUES({$VALUES})"; } //echo "<p>Insert/Update Query: $query<p>\n"; $retval = mssql_query($query); if ($retval == false) { printf(gettext("Insert/Update failed: %s <br>\n"), mssql_get_last_message()); } }
function InsertPage($dbi, $pagename, $pagehash) { global $WikiPageStore; // ugly hack if ($dbi['table'] == $WikiPageStore) { // HACK $linklist = ExtractWikiPageLinks($pagehash['content']); SetWikiPageLinks($dbi, $pagename, $linklist); } $pagehash = MakeDBHash($pagename, $pagehash); $COLUMNS = "author, content, created, flags, " . "lastmodified, pagename, refs, version"; $VALUES = "'{$pagehash['author']}', '{$pagehash['content']}', " . "{$pagehash['created']}, {$pagehash['flags']}, " . "{$pagehash['lastmodified']}, '{$pagehash['pagename']}', " . "'{$pagehash['refs']}', {$pagehash['version']}"; if (!mysql_query("replace into {$dbi['table']} ({$COLUMNS}) values ({$VALUES})", $dbi['dbc'])) { $msg = sprintf(gettext("Error writing page '%s'"), $pagename); $msg .= "<BR>"; $msg .= sprintf(gettext("MySQL error: %s"), mysql_error()); ExitWiki($msg); } }