1 <!-- $Id: wiki_savepage.php3,v 1.10 2000-06-27 19:41:23 ahollosi Exp $ -->
5 All page saving events take place here.
6 All page info is also taken care of here.
7 This is klugey. But it works. There's probably a slicker way of
11 function ConcurrentUpdates($pagename)
13 $html = "<P>PhpWiki is unable to save your changes, because\n" .
14 "another user edited and saved the page while you\n" .
15 "were editing the page too. If saving proceeded now\n" .
16 "changes from the previous author would be lost.</P>\n" .
17 "<P>In order to recover from this situation follow these steps:\n" .
18 "<OL><LI>Use your browsers <B>Back</B> button to go back " .
19 "to the edit page.\n" .
20 "<LI>Copy your changes to the clipboard or to another temporary " .
21 "place (e.g. text editor).\n" .
22 "<LI><B>Reload</B> the page. You should now see the most current" .
23 " version of the page. Your changes are no longer there.\n" .
24 "<LI>Make changes to the file again. Paste your additions from " .
25 "the clipboard (or text editor).\n" .
26 "<LI>Press <B>Save</B> again.</OL>\n" .
27 "<P>Sorry for the inconvinience.</P>";
28 GeneratePage('MESSAGE', $html, "Problem while updating " .
29 htmlspecialchars($pagename), 0);
33 $pagename = rawurldecode($post);
34 $pagehash = RetrievePage($dbi, $pagename);
36 // if this page doesn't exist yet, now's the time!
37 if (! is_array($pagehash)) {
39 $pagehash["version"] = 0;
40 $pagehash["created"] = time();
41 $pagehash["flags"] = 0;
44 if(isset($editversion) && ($editversion != $pagehash["version"])) {
45 ConcurrentUpdates($pagename);
47 // archive it if it's a new author
48 if ($pagehash["author"] != $remoteuser) {
49 SaveCopyToArchive($pagename, $pagehash);
54 $pagehash["lastmodified"] = time();
55 $pagehash["version"]++;
56 $pagehash["author"] = $remoteuser;
59 $enc_url = rawurlencode($pagename);
60 $enc_name = htmlspecialchars($pagename);
61 $html = "Thank you for editing " .
62 "<a href=\"$ScriptUrl?$enc_url\">$enc_name</a><br>\n";
64 if (! empty($content)) {
65 // patch from Grant Morgan <grant@ryuuguu.com> for magic_quotes_gpc
66 if (get_magic_quotes_gpc())
67 $content = stripslashes($content);
69 $pagehash["content"] = explode("\n", $content);
71 // convert spaces to tabs at user request
73 $pagehash["content"] = CookSpaces($pagehash["content"]);
77 for ($i = 1; $i <= NUM_LINKS; $i++) {
78 if (! empty(${'r'.$i})) {
79 if (preg_match("#^($AllowedProtocols):#", ${'r'.$i}))
80 $pagehash['refs'][$i] = ${'r'.$i};
82 $html .= "<P>Link [$i]: <B>unknown protocol</B>" .
83 " - use one of $AllowedProtocols - link discarded.</P>\n";
87 InsertPage($dbi, $pagename, $pagehash);
88 UpdateRecentChanges($dbi, $pagename, $newpage);
90 $html .= "Your careful attention to detail is much appreciated.\n";
92 if ($WikiDataBase == "/tmp/wikidb") {
93 $html .= "<P><B>Warning: the Wiki DBM file still lives in the " .
94 "/tmp directory. Please read the INSTALL file and move " .
95 "the DBM file to a permanent location or risk losing " .
96 "all the pages!</B>\n";
99 $html .= "<P><img src=\"$SignatureImg\"></P><hr noshade><P>";
100 include("wiki_transform.php3");
102 GeneratePage('BROWSE', $html, $pagename, $pagehash);