1 <!-- $Id: wiki_savepage.php3,v 1.8 2000-06-18 15:12:13 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;
42 if(isset($editversion) && ($editversion != $pagehash["version"])) {
43 ConcurrentUpdates($pagename);
45 // archive it if it's a new author
46 if ($pagehash["author"] != $remoteuser) {
47 SaveCopyToArchive($pagename, $pagehash);
52 $pagehash["date"] = GetCurrentDate();
53 $pagehash["version"]++;
54 $pagehash["author"] = $remoteuser;
57 $enc_url = rawurlencode($pagename);
58 $enc_name = htmlspecialchars($pagename);
59 $html = "Thank you for editing " .
60 "<a href=\"$ScriptUrl?$enc_url\">$enc_name</a><br>\n";
62 if (! empty($content)) {
63 // patch from Grant Morgan <grant@ryuuguu.com> for magic_quotes_gpc
64 if (get_magic_quotes_gpc())
65 $content = stripslashes($content);
67 $pagehash["content"] = explode("\n", $content);
69 // convert spaces to tabs at user request
71 $pagehash["content"] = CookSpaces($pagehash["content"]);
75 for ($i = 1; $i <= NUM_LINKS; $i++) {
76 if (! empty(${'r'.$i})) {
77 if (preg_match("#^($AllowedProtocols):#", ${'r'.$i}))
78 $pagehash['r'.$i] = ${'r'.$i};
80 $html .= "<P>Link [$i]: <B>unknown protocol</B>" .
81 " - use one of $AllowedProtocols - link discarded.</P>\n";
85 InsertPage($dbi, $pagename, $pagehash);
86 UpdateRecentChanges($dbi, $pagename, $newpage);
88 $html .= "Your careful attention to detail is much appreciated.\n";
90 if ($WikiDataBase == "/tmp/wikidb") {
91 $html .= "<P><B>Warning: the Wiki DBM file still lives in the " .
92 "/tmp directory. Please read the INSTALL file and move " .
93 "the DBM file to a permanent location or risk losing " .
94 "all the pages!</B>\n";
97 $html .= "<P><img src=\"$SignatureImg\"></P><hr noshade><P>";
98 include("wiki_transform.php3");
100 GeneratePage('BROWSE', $html, $pagename, $pagehash);