448 |
ddelon |
1 |
<?php
|
|
|
2 |
/*
|
|
|
3 |
edit.php
|
|
|
4 |
Copyright (c) 2002, Hendrik Mans <hendrik@mans.de>
|
|
|
5 |
Copyright 2002, 2003 David DELON
|
|
|
6 |
Copyright 2002, 2003 Charles NEPOTE
|
|
|
7 |
Copyright 2002, 2003 Patrick PAUL
|
|
|
8 |
Copyright 2003 Eric FELDSTEIN
|
|
|
9 |
All rights reserved.
|
|
|
10 |
Redistribution and use in source and binary forms, with or without
|
|
|
11 |
modification, are permitted provided that the following conditions
|
|
|
12 |
are met:
|
|
|
13 |
1. Redistributions of source code must retain the above copyright
|
|
|
14 |
notice, this list of conditions and the following disclaimer.
|
|
|
15 |
2. Redistributions in binary form must reproduce the above copyright
|
|
|
16 |
notice, this list of conditions and the following disclaimer in the
|
|
|
17 |
documentation and/or other materials provided with the distribution.
|
|
|
18 |
3. The name of the author may not be used to endorse or promote products
|
|
|
19 |
derived from this software without specific prior written permission.
|
|
|
20 |
|
|
|
21 |
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
|
22 |
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
23 |
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
24 |
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
25 |
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
26 |
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
27 |
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
28 |
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
29 |
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
|
30 |
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
31 |
*/
|
|
|
32 |
//vérification de sécurité
|
|
|
33 |
if (!eregi("wakka.php", $_SERVER['PHP_SELF'])) {
|
|
|
34 |
die ("accès direct interdit");
|
|
|
35 |
}
|
|
|
36 |
echo $this->Header();
|
|
|
37 |
?>
|
|
|
38 |
<div class="page">
|
|
|
39 |
<?php
|
|
|
40 |
if ($this->HasAccess("write") && $this->HasAccess("read"))
|
|
|
41 |
{
|
|
|
42 |
$output='';
|
|
|
43 |
if ($_POST)
|
|
|
44 |
{
|
|
|
45 |
// only if saving:
|
|
|
46 |
if ($_POST["submit"] == "Sauver")
|
|
|
47 |
{
|
|
|
48 |
// check for overwriting
|
|
|
49 |
if ($this->page)
|
|
|
50 |
{
|
|
|
51 |
if ($this->page["id"] != $_POST["previous"])
|
|
|
52 |
{
|
|
|
53 |
$error = "ALERTE : ".
|
|
|
54 |
"Cette page a été modifiée par quelqu'un d'autre pendant que vous l'éditiez.<br />\n".
|
|
|
55 |
"Veuillez copier vos changements et rééditer cette page.\n";
|
|
|
56 |
}
|
|
|
57 |
}
|
|
|
58 |
|
|
|
59 |
|
|
|
60 |
// store
|
|
|
61 |
if (!$error)
|
|
|
62 |
{
|
|
|
63 |
$body = str_replace("\r", "", $_POST["body"]);
|
|
|
64 |
|
|
|
65 |
// test si la nouvelle page est differente de la précédente
|
|
|
66 |
if(rtrim($body)==rtrim($this->page["body"])) {
|
|
|
67 |
$this->SetMessage("Cette page n\'a pas été enregistrée car elle n\'a subi aucune modification.");
|
|
|
68 |
$this->Redirect($this->href());
|
|
|
69 |
}
|
|
|
70 |
|
|
|
71 |
// add page (revisions)
|
|
|
72 |
$this->SavePage($this->tag, $body);
|
|
|
73 |
|
|
|
74 |
// now we render it internally so we can write the updated link table.
|
|
|
75 |
$this->ClearLinkTable();
|
|
|
76 |
$this->StartLinkTracking();
|
|
|
77 |
$dummy = $this->Header();
|
|
|
78 |
$dummy .= $this->Format($body);
|
|
|
79 |
$dummy .= $this->Footer();
|
|
|
80 |
$this->StopLinkTracking();
|
|
|
81 |
$this->WriteLinkTable();
|
|
|
82 |
$this->ClearLinkTable();
|
|
|
83 |
|
|
|
84 |
// forward
|
|
|
85 |
$this->Redirect($this->href());
|
|
|
86 |
}
|
|
|
87 |
}
|
|
|
88 |
}
|
|
|
89 |
|
|
|
90 |
// fetch fields
|
|
|
91 |
if (!$previous = $_POST["previous"]) $previous = $this->page["id"];
|
|
|
92 |
if (!$body = $_POST["body"]) $body = $this->page["body"];
|
|
|
93 |
|
|
|
94 |
// preview?
|
|
|
95 |
if ($_POST["submit"] == "Aperçu")
|
|
|
96 |
{
|
|
|
97 |
$output .=
|
|
|
98 |
"<div class=\"prev_alert\"><strong>Aperçu</strong></div>\n".
|
|
|
99 |
$this->Format($body)."\n\n".
|
|
|
100 |
$this->FormOpen("edit").
|
|
|
101 |
"<input type=\"hidden\" name=\"previous\" value=\"".$previous."\" />\n".
|
|
|
102 |
"<input type=\"hidden\" name=\"body\" value=\"".htmlentities($body)."\" />\n".
|
|
|
103 |
"<br />\n".
|
|
|
104 |
"<input name=\"submit\" type=\"submit\" value=\"Sauver\" accesskey=\"s\" />\n".
|
|
|
105 |
"<input name=\"submit\" type=\"submit\" value=\"Rééditer \" accesskey=\"p\" />\n".
|
|
|
106 |
"<input type=\"button\" value=\"Annulation\" onclick=\"document.location='".$this->href("")."';\" />\n".
|
|
|
107 |
$this->FormClose()."\n";
|
|
|
108 |
}
|
|
|
109 |
else
|
|
|
110 |
{
|
|
|
111 |
// display form
|
|
|
112 |
if ($error)
|
|
|
113 |
{
|
|
|
114 |
$output .= "<div class=\"error\">$error</div>\n";
|
|
|
115 |
}
|
|
|
116 |
|
|
|
117 |
// append a comment?
|
|
|
118 |
if ($_REQUEST["appendcomment"])
|
|
|
119 |
{
|
|
|
120 |
$body = trim($body)."\n\n----\n\n--".$this->UserName()." (".strftime("%c").")";
|
|
|
121 |
}
|
|
|
122 |
require_once("ACeditor.buttonsBar.php");
|
|
|
123 |
$output .=
|
|
|
124 |
$this->FormOpen("edit").
|
|
|
125 |
"<input type=\"hidden\" name=\"previous\" value=\"".$previous."\" />\n".$ACbuttonsBar.
|
|
|
126 |
"<textarea onkeydown=\"fKeyDown()\" name=\"body\" cols=\"60\" rows=\"40\" wrap=\"soft\" class=\"edit\">\n".
|
|
|
127 |
htmlspecialchars($body).
|
|
|
128 |
"\n</textarea><br />\n".
|
|
|
129 |
($this->config["preview_before_save"] ? "" : "<input name=\"submit\" type=\"submit\" value=\"Sauver\" accesskey=\"s\" />\n").
|
|
|
130 |
"<input name=\"submit\" type=\"submit\" value=\"Aperçu\" accesskey=\"p\" />\n".
|
|
|
131 |
"<input type=\"button\" value=\"Annulation\" onclick=\"document.location='".$this->href("")."';\" />\n".
|
|
|
132 |
$this->FormClose();
|
|
|
133 |
}
|
|
|
134 |
|
|
|
135 |
echo $output;
|
|
|
136 |
}
|
|
|
137 |
else
|
|
|
138 |
{
|
|
|
139 |
echo "<i>Vous n'avez pas accès en écriture à cette page !</i>\n";
|
|
|
140 |
}
|
|
|
141 |
?>
|
|
|
142 |
<hr class="hr_clear" />
|
|
|
143 |
</div>
|
|
|
144 |
<?php echo $this->Footer(); ?>
|