Subversion Repositories Applications.papyrus

Rev

Rev 556 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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