1 <!-- $Id: wiki_savepage.php3,v 1.5 2000-06-07 11:10:46 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 echo WikiHeader("Problem while updating $pagename");
14 $pagename = htmlspecialchars($pagename);
15 echo "<h1>Problem while updating $pagename</h1>\n" .
16 "<P>PhpWiki is unable to save your changes, because\n" .
17 "another user edited and saved the page while you\n" .
18 "were editing the page too. If saving proceeded now\n" .
19 "changes from the previous author would be lost.</P>\n" .
20 "<P>In order to recover from this situation follow these steps:\n" .
21 "<OL><LI>Use your browsers <B>Back</B> button to go back " .
22 "to the edit page.\n" .
23 "<LI>Copy your changes to the clipboard or to another temporary " .
24 "place (e.g. text editor).\n" .
25 "<LI><B>Reload</B> the page. You should now see the most current" .
26 " version of the page. Your changes are no longer there.\n" .
27 "<LI>Make changes to the file again. Paste your additions from " .
28 "the clipboard (or text editor).\n" .
29 "<LI>Press <B>Save</B> again.</OL>\n" .
30 "<P>Sorry for the inconvinience.</P>";
35 $pagename = rawurldecode($post);
36 $pagehash = RetrievePage($dbi, $pagename);
38 // if this page doesn't exist yet, now's the time!
39 if (! is_array($pagehash)) {
41 $pagehash["version"] = 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["date"] = GetCurrentDate();
55 $pagehash["version"]++;
56 $pagehash["author"] = $remoteuser;
59 echo WikiHeader("Thanks for $pagename Edits");
60 $enc_url = rawurlencode($pagename);
61 $enc_name = htmlspecialchars($pagename);
62 echo "Thank you for editing " .
63 "<a href=\"$ScriptUrl?$enc_url\">$enc_name</a><br>\n";
67 // patch from Grant Morgan <grant@ryuuguu.com> for
69 if(get_magic_quotes_gpc()) { $text = stripslashes($text); }
71 $pagehash["text"] = explode("\n", $text);
73 // convert spaces to tabs at user request
75 $pagehash["text"] = CookSpaces($pagehash["text"]);
79 for ($i = 1; $i <= NUM_LINKS; $i++) {
80 if (! empty(${'r'.$i})) {
81 if (preg_match("#^($AllowedProtocols):#", ${'r'.$i}))
82 $pagehash['r'.$i] = ${'r'.$i};
84 echo "<P>Link [$i]: <B>unknown protocol</B>" .
85 " - use one of $AllowedProtocols - link discarded.</P>\n";
89 InsertPage($dbi, $pagename, $pagehash);
90 UpdateRecentChanges($dbi, $pagename, $newpage);
92 Your careful attention to detail is much appreciated.<br>
93 <img src="<? echo "$SignatureImg"; ?>"><br>
94 p.s. Be sure to <em>Reload</em> your old pages.<br>
97 if ($WikiDataBase == "/tmp/wikidb") {
98 echo "<h2>Warning: the Wiki DBM file still lives in the ";
99 echo "/tmp directory. Please read the INSTALL file and move ";
100 echo "the DBM file to a permanent location or risk losing ";
101 echo "all the pages!</h2>\n";