]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - wiki_savepage.php3
Added a note about requiring PHP 3.0.9 or greater.
[SourceForge/phpwiki.git] / wiki_savepage.php3
1 <!-- $Id: wiki_savepage.php3,v 1.5 2000-06-07 11:10:46 ahollosi Exp $ -->
2 <?
3
4 /*
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
8    coding it.
9 */
10
11    function ConcurrentUpdates($pagename)
12    {
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>";
31       echo WikiFooter();
32       exit;
33    }
34
35    $pagename = rawurldecode($post);
36    $pagehash = RetrievePage($dbi, $pagename);
37
38    // if this page doesn't exist yet, now's the time!
39    if (! is_array($pagehash)) {
40       $pagehash = array();
41       $pagehash["version"] = 0;
42       $newpage = 1;
43    } else {
44       if(isset($editversion) && ($editversion != $pagehash["version"])) {
45          ConcurrentUpdates($pagename);
46       }
47       // archive it if it's a new author
48       if ($pagehash["author"] != $remoteuser) {
49          SaveCopyToArchive($pagename, $pagehash);
50       }
51       $newpage = 0;
52    }
53
54    $pagehash["date"] = GetCurrentDate();
55    $pagehash["version"]++;
56    $pagehash["author"] = $remoteuser;
57
58    // create page header
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";
64
65
66    if (! empty($text)) {
67       // patch from Grant Morgan <grant@ryuuguu.com> for
68       // magic_quotes_gpc
69       if(get_magic_quotes_gpc()) { $text = stripslashes($text); }
70
71       $pagehash["text"] = explode("\n", $text);
72
73       // convert spaces to tabs at user request
74       if ($convert) {
75          $pagehash["text"] = CookSpaces($pagehash["text"]);      
76       }
77    }
78
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};
83            else
84               echo "<P>Link [$i]: <B>unknown protocol</B>" .
85                    " - use one of $AllowedProtocols - link discarded.</P>\n";
86         }
87    }
88
89    InsertPage($dbi, $pagename, $pagehash);
90    UpdateRecentChanges($dbi, $pagename, $newpage);
91 ?>
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>
95
96 <?
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";
102    }
103    echo WikiFooter();
104 ?>