| 439 | 
           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
  | 
        
        
           | 954 | 
           florian | 
           91 | 
           	if (!isset($_POST["previous"])) $previous = $this->page["id"];
  | 
        
        
            | 
            | 
           92 | 
           	else $previous = $_POST["previous"];
  | 
        
        
            | 
            | 
           93 | 
           	if (!isset($_POST["body"])) $body = $this->page["body"];
  | 
        
        
            | 
            | 
           94 | 
           	else $body = $_POST["body"];
  | 
        
        
           | 439 | 
           ddelon | 
           95 | 
              | 
        
        
           | 954 | 
           florian | 
           96 | 
              | 
        
        
           | 439 | 
           ddelon | 
           97 | 
           	// preview?
  | 
        
        
           | 954 | 
           florian | 
           98 | 
           	if (!isset($_POST["submit"])) $_POST["submit"] = "";
  | 
        
        
           | 439 | 
           ddelon | 
           99 | 
           	if ($_POST["submit"] == "Aperçu")
  | 
        
        
            | 
            | 
           100 | 
           	{
  | 
        
        
            | 
            | 
           101 | 
           		$output .=
  | 
        
        
            | 
            | 
           102 | 
           			"<div class=\"prev_alert\"><strong>Aperçu</strong></div>\n".
  | 
        
        
            | 
            | 
           103 | 
           			$this->Format($body)."\n\n".
  | 
        
        
            | 
            | 
           104 | 
           			$this->FormOpen("edit").
  | 
        
        
            | 
            | 
           105 | 
           			"<input type=\"hidden\" name=\"previous\" value=\"".$previous."\" />\n".
  | 
        
        
            | 
            | 
           106 | 
           			"<input type=\"hidden\" name=\"body\" value=\"".htmlentities($body)."\" />\n".
  | 
        
        
            | 
            | 
           107 | 
           			"<br />\n".
  | 
        
        
            | 
            | 
           108 | 
           			"<input name=\"submit\" type=\"submit\" value=\"Sauver\" accesskey=\"s\" />\n".
  | 
        
        
            | 
            | 
           109 | 
           			"<input name=\"submit\" type=\"submit\" value=\"Rééditer \" accesskey=\"p\" />\n".
  | 
        
        
            | 
            | 
           110 | 
           			"<input type=\"button\" value=\"Annulation\" onclick=\"document.location='".$this->href("")."';\" />\n".
  | 
        
        
            | 
            | 
           111 | 
           			$this->FormClose()."\n";
  | 
        
        
            | 
            | 
           112 | 
           	}
  | 
        
        
            | 
            | 
           113 | 
           	else
  | 
        
        
            | 
            | 
           114 | 
           	{
  | 
        
        
            | 
            | 
           115 | 
           		// display form
  | 
        
        
           | 954 | 
           florian | 
           116 | 
           		if (isset($error))
  | 
        
        
           | 439 | 
           ddelon | 
           117 | 
           		{
  | 
        
        
           | 954 | 
           florian | 
           118 | 
           			if (!isset($output)) $output = '';
  | 
        
        
           | 439 | 
           ddelon | 
           119 | 
           			$output .= "<div class=\"error\">$error</div>\n";
  | 
        
        
            | 
            | 
           120 | 
           		}
  | 
        
        
            | 
            | 
           121 | 
              | 
        
        
            | 
            | 
           122 | 
           		// append a comment?
  | 
        
        
           | 954 | 
           florian | 
           123 | 
           		if (isset($_REQUEST["appendcomment"]))
  | 
        
        
           | 439 | 
           ddelon | 
           124 | 
           		{
  | 
        
        
            | 
            | 
           125 | 
           			$body = trim($body)."\n\n----\n\n--".$this->UserName()." (".strftime("%c").")";
  | 
        
        
            | 
            | 
           126 | 
           		}
  | 
        
        
           | 954 | 
           florian | 
           127 | 
              | 
        
        
            | 
            | 
           128 | 
           		if (!isset($output)) $output = '';
  | 
        
        
           | 439 | 
           ddelon | 
           129 | 
           		$output .=
  | 
        
        
            | 
            | 
           130 | 
           			$this->FormOpen("edit").
  | 
        
        
           | 954 | 
           florian | 
           131 | 
           			"<input type=\"hidden\" name=\"previous\" value=\"".$previous."\" />\n".
  | 
        
        
           | 439 | 
           ddelon | 
           132 | 
           			"<textarea onkeydown=\"fKeyDown()\" name=\"body\" cols=\"60\" rows=\"40\" wrap=\"soft\" class=\"edit\">\n".
  | 
        
        
            | 
            | 
           133 | 
           			htmlspecialchars($body).
  | 
        
        
            | 
            | 
           134 | 
           			"\n</textarea><br />\n".
  | 
        
        
            | 
            | 
           135 | 
           			($this->config["preview_before_save"] ? "" : "<input name=\"submit\" type=\"submit\" value=\"Sauver\" accesskey=\"s\" />\n").
  | 
        
        
            | 
            | 
           136 | 
           			"<input name=\"submit\" type=\"submit\" value=\"Aperçu\" accesskey=\"p\" />\n".
  | 
        
        
            | 
            | 
           137 | 
           			"<input type=\"button\" value=\"Annulation\" onclick=\"document.location='".$this->href("")."';\" />\n".
  | 
        
        
            | 
            | 
           138 | 
           			$this->FormClose();
  | 
        
        
            | 
            | 
           139 | 
           	}
  | 
        
        
            | 
            | 
           140 | 
              | 
        
        
            | 
            | 
           141 | 
           	echo $output;
  | 
        
        
            | 
            | 
           142 | 
           }
  | 
        
        
            | 
            | 
           143 | 
           else
  | 
        
        
            | 
            | 
           144 | 
           {
  | 
        
        
            | 
            | 
           145 | 
           	echo "<i>Vous n'avez pas accès en écriture à cette page !</i>\n";
  | 
        
        
            | 
            | 
           146 | 
           }
  | 
        
        
            | 
            | 
           147 | 
           ?>
  | 
        
        
            | 
            | 
           148 | 
           <hr class="hr_clear" />
  | 
        
        
            | 
            | 
           149 | 
           </div>
  | 
        
        
            | 
            | 
           150 | 
           <?php echo $this->Footer(); ?>
  |