Subversion Repositories Applications.papyrus

Rev

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

Rev 1696 Rev 1833
1
<?php
1
<?php
2
/*vim: set expandtab tabstop=4 shiftwidth=4: */
2
/*vim: set expandtab tabstop=4 shiftwidth=4: */
3
// +------------------------------------------------------------------------------------------------------+
3
// +------------------------------------------------------------------------------------------------------+
4
// | PHP version 4.1                                                                                      |
4
// | PHP version 4.1                                                                                      |
5
// +------------------------------------------------------------------------------------------------------+
5
// +------------------------------------------------------------------------------------------------------+
6
// | Copyright (C) 2005 Tela Botanica (accueil@tela-botanica.org)                                         |
6
// | Copyright (C) 2005 Tela Botanica (accueil@tela-botanica.org)                                         |
7
// +------------------------------------------------------------------------------------------------------+
7
// +------------------------------------------------------------------------------------------------------+
8
// | This file is part of Integrateur Wikini.                                                             |
8
// | This file is part of Integrateur Wikini.                                                             |
9
// |                                                                                                      |
9
// |                                                                                                      |
10
// | Foobar is free software; you can redistribute it and/or modify                                       |
10
// | Foobar is free software; you can redistribute it and/or modify                                       |
11
// | it under the terms of the GNU General Public License as published by                                 |
11
// | it under the terms of the GNU General Public License as published by                                 |
12
// | the Free Software Foundation; either version 2 of the License, or                                    |
12
// | the Free Software Foundation; either version 2 of the License, or                                    |
13
// | (at your option) any later version.                                                                  |
13
// | (at your option) any later version.                                                                  |
14
// |                                                                                                      |
14
// |                                                                                                      |
15
// | Foobar is distributed in the hope that it will be useful,                                            |
15
// | Foobar is distributed in the hope that it will be useful,                                            |
16
// | but WITHOUT ANY WARRANTY; without even the implied warranty of                                       |
16
// | but WITHOUT ANY WARRANTY; without even the implied warranty of                                       |
17
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                        |
17
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                        |
18
// | GNU General Public License for more details.                                                         |
18
// | GNU General Public License for more details.                                                         |
19
// |                                                                                                      |
19
// |                                                                                                      |
20
// | You should have received a copy of the GNU General Public License                                    |
20
// | You should have received a copy of the GNU General Public License                                    |
21
// | along with Foobar; if not, write to the Free Software                                                |
21
// | along with Foobar; if not, write to the Free Software                                                |
22
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                            |
22
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                            |
23
// +------------------------------------------------------------------------------------------------------+
23
// +------------------------------------------------------------------------------------------------------+
24
// CVS : $Id: iw_integrateur.fonct.php,v 1.19.6.1 2007-11-19 10:05:22 ddelon Exp $
24
// CVS : $Id: iw_integrateur.fonct.php,v 1.19.6.2 2008-04-25 07:59:25 jp_milcent Exp $
25
/**
25
/**
26
* Fonctions de l'integrateur de page Wikini
26
* Fonctions de l'integrateur de page Wikini
27
*
27
*
28
* Application permettant d'intégrer des pages wikini dans Papyrus.
28
* Application permettant d'intégrer des pages wikini dans Papyrus.
29
*
29
*
30
*@package IntegrateurWikini
30
*@package IntegrateurWikini
31
//Auteur original :
31
//Auteur original :
32
*@author        David Delon <david.delon@clapas.net>
32
*@author        David Delon <david.delon@clapas.net>
33
//Autres auteurs :
33
//Autres auteurs :
34
*@author        Aucun
34
*@author        Aucun
35
*@copyright     Tela-Botanica 2000-2004
35
*@copyright     Tela-Botanica 2000-2004
36
*@version       $Revision: 1.19.6.1 $ $Date: 2007-11-19 10:05:22 $
36
*@version       $Revision: 1.19.6.2 $ $Date: 2008-04-25 07:59:25 $
37
*
37
*
38
// +------------------------------------------------------------------------------------------------------+
38
// +------------------------------------------------------------------------------------------------------+
39
// |                                            ENTETE du PROGRAMME                                       |
39
// |                                            ENTETE du PROGRAMME                                       |
40
// +------------------------------------------------------------------------------------------------------+
40
// +------------------------------------------------------------------------------------------------------+
41
 
41
 
42
 
42
 
43
 
43
 
44
 
44
 
45
/** Inclusion de la classe PEAR de gestion des URL. */
45
/** Inclusion de la classe PEAR de gestion des URL. */
46
 
46
 
47
$GLOBALS['_PAPYRUS_']['erreur']->setActive(0);
47
$GLOBALS['_PAPYRUS_']['erreur']->setActive(0);
-
 
48
 
48
 
49
if (!class_exists('Net_URL')) {
49
require_once PAP_CHEMIN_API_PEAR.'Net/URL.php';
50
	require_once PAP_CHEMIN_API_PEAR.'Net/URL.php';
50
 
51
}
51
// TODO : un seul fichier de configuration ?
52
// TODO : un seul fichier de configuration ?
52
/** Inclusion du fichier de configuration de cette application.*/
53
/** Inclusion du fichier de configuration de cette application.*/
53
require_once 'client/integrateur_wikini/configuration/adwi_configuration.inc.php';
54
require_once 'client/integrateur_wikini/configuration/adwi_configuration.inc.php';
54
 
55
 
55
require_once ADWI_CHEMIN_BIBLIOTHEQUE.'adwi_wikini.fonct.php';
56
require_once ADWI_CHEMIN_BIBLIOTHEQUE.'adwi_wikini.fonct.php';
56
 
57
 
57
/** Inclusion du fichier de configuration général de IntegrateurWikini.*/
58
/** Inclusion du fichier de configuration général de IntegrateurWikini.*/
58
require_once 'client'.GEN_SEP.'integrateur_wikini'.GEN_SEP.'configuration'.GEN_SEP.'iw_config.inc.php';
59
require_once 'client'.GEN_SEP.'integrateur_wikini'.GEN_SEP.'configuration'.GEN_SEP.'iw_config.inc.php';
59
 
60
 
60
/** Inclusion du fichier permettant d'encoder du texte mais pas les balises XHTML.*/
61
/** Inclusion du fichier permettant d'encoder du texte mais pas les balises XHTML.*/
61
require_once IW_CHEMIN_BIBLIO.'iw_encodage.fonct.php';
62
require_once IW_CHEMIN_BIBLIO.'iw_encodage.fonct.php';
62
/** Inclusion du fichier permettant d'inclure les données dans du XHTML.*/
63
/** Inclusion du fichier permettant d'inclure les données dans du XHTML.*/
63
require_once IW_CHEMIN_BIBLIO.'iw_affichage_xhtml.fonct.php';
64
require_once IW_CHEMIN_BIBLIO.'iw_affichage_xhtml.fonct.php';
64
 
65
 
65
global $wikini_config_defaut;
66
global $wikini_config_defaut;
66
global $wiki;
67
global $wiki;
67
global $wiki_p;
68
global $wiki_p;
68
 
69
 
69
// $_REQUEST['wiki'] est obligatoire, car wakka.php envoie un redirect si non detecté, avec perte de tout l'environnement !
70
// $_REQUEST['wiki'] est obligatoire, car wakka.php envoie un redirect si non detecté, avec perte de tout l'environnement !
70
 
71
 
71
if ( ! isset( $_REQUEST['wiki'] ) ) {
72
if ( ! isset( $_REQUEST['wiki'] ) ) {
72
	    $_REQUEST['wiki'] = $wikini_config_defaut['root_page'];
73
	    $_REQUEST['wiki'] = $wikini_config_defaut['root_page'];
73
}
74
}
74
 
75
 
75
$server=$_SERVER['PHP_SELF'];
76
$server=$_SERVER['PHP_SELF'];
76
$_SERVER['PHP_SELF']="wakka.php";
77
$_SERVER['PHP_SELF']="wakka.php";
77
 
78
 
78
// Utilise le wakkaconfig de la racine ...
79
// Utilise le wakkaconfig de la racine ...
79
// TODO : un wiki par défaut pour chaque papyrus à l'installation de Papyrus
80
// TODO : un wiki par défaut pour chaque papyrus à l'installation de Papyrus
80
// TODO : verifier bon dimensionnement des champs et clef de la table papyrus_wiki
81
// TODO : verifier bon dimensionnement des champs et clef de la table papyrus_wiki
81
// TODO : creation des tables par defaut à l'installation d'un wikini
82
// TODO : creation des tables par defaut à l'installation d'un wikini
82
// TODO : Fusion des fichiers de configuration ?
83
// TODO : Fusion des fichiers de configuration ?
83
 
84
 
84
//echo IW_CHEMIN_WIKINI_COURANT.'wakka.php';
85
//echo IW_CHEMIN_WIKINI_COURANT.'wakka.php';
85
if (!file_exists(IW_CHEMIN_WIKINI_COURANT.'wakka.php')) {
86
if (!file_exists(IW_CHEMIN_WIKINI_COURANT.'wakka.php')) {
86
	if (GEN_DEBOGAGE) {
87
	if (GEN_DEBOGAGE) {
87
            $GLOBALS['_GEN_commun']['debogage_info'] .=
88
            $GLOBALS['_GEN_commun']['debogage_info'] .=
88
                'ERREUR Papyrus : le fichier '.IW_CHEMIN_WIKINI_COURANT.'wakka.php n\'existe pas.<br />'.
89
                'ERREUR Papyrus : le fichier '.IW_CHEMIN_WIKINI_COURANT.'wakka.php n\'existe pas.<br />'.
89
                'Identifiant : '. $id_fichier .'<br />'.
90
                'Identifiant : '. $id_fichier .'<br />'.
90
                'Ligne n° : '. __LINE__ .'<br />'.
91
                'Ligne n° : '. __LINE__ .'<br />'.
91
                'Fichier : '. __FILE__;
92
                'Fichier : '. __FILE__;
92
    }
93
    }
93
    return  ;
94
    return  ;
94
}
95
}
95
ob_start();
96
ob_start();
96
include_once IW_CHEMIN_WIKINI_COURANT.'wakka.php';
97
include_once IW_CHEMIN_WIKINI_COURANT.'wakka.php';
97
include_once(IW_CHEMIN_WIKINI_COURANT."/formatters/tableaux.php");
98
include_once(IW_CHEMIN_WIKINI_COURANT."/formatters/tableaux.php");
98
include_once(IW_CHEMIN_WIKINI_COURANT."/actions/attach.class.php");
99
include_once(IW_CHEMIN_WIKINI_COURANT."/actions/attach.class.php");
99
 
100
 
100
ob_end_clean();
101
ob_end_clean();
101
$_SERVER['PHP_SELF']=$server;
102
$_SERVER['PHP_SELF']=$server;
102
 
103
 
103
 
104
 
104
// On surcharge la classe Wiki pour en faire ce qu'on en veut
105
// On surcharge la classe Wiki pour en faire ce qu'on en veut
105
Class Wiki_Papyrus extends Wiki {
106
Class Wiki_Papyrus extends Wiki {
106
 
107
 
107
 
108
 
108
	function Header() {
109
	function Header() {
109
 
110
 
110
		return;
111
		return;
111
	}
112
	}
112
 
113
 
113
 	function Footer() {
114
 	function Footer() {
114
 		echo  "<div class=\"footer\">";
115
 		echo  "<div class=\"footer\">";
115
		echo  $this->HasAccess("write") ? "<a href=\"".$this->href("edit")."\" title=\"Cliquez pour modifier cette page.\">Modifier cette page</a> ::\n" : "";
116
		echo  $this->HasAccess("write") ? "<a href=\"".$this->href("edit")."\" title=\"Cliquez pour modifier cette page.\">Modifier cette page</a> ::\n" : "";
116
		echo  $this->GetPageTime() ? "<a href=\"".$this->href("revisions")."\" title=\"Cliquez pour voir les derni&egrave;res modifications sur cette page.\">".$this->GetPageTime()."</a> ::\n" : "";
117
		echo  $this->GetPageTime() ? "<a href=\"".$this->href("revisions")."\" title=\"Cliquez pour voir les derni&egrave;res modifications sur cette page.\">".$this->GetPageTime()."</a> ::\n" : "";
117
		// 	if this page exists
118
		// 	if this page exists
118
		if ($this->page)
119
		if ($this->page)
119
		{
120
		{
120
		// if owner is current user
121
		// if owner is current user
121
			if ($this->UserIsOwner())
122
			if ($this->UserIsOwner())
122
			{
123
			{
123
				echo
124
				echo
124
				"Propri&eacute;taire&nbsp;: vous :: \n",
125
				"Propri&eacute;taire&nbsp;: vous :: \n",
125
				"<a href=\"",$this->href("acls")."\" title=\"Cliquez pour modifer les permissions de cette page.\">&Eacute;diter permissions</a> :: \n",
126
				"<a href=\"",$this->href("acls")."\" title=\"Cliquez pour modifer les permissions de cette page.\">&Eacute;diter permissions</a> :: \n",
126
				"<a href=\"",$this->href("deletepage")."\">Supprimer</a> :: \n";
127
				"<a href=\"",$this->href("deletepage")."\">Supprimer</a> :: \n";
127
			}
128
			}
128
			else
129
			else
129
			{
130
			{
130
				if ($owner = $this->GetPageOwner())
131
				if ($owner = $this->GetPageOwner())
131
				{
132
				{
132
					echo "Propri&eacute;taire : ",$this->Format($owner);
133
					echo "Propri&eacute;taire : ",$this->Format($owner);
133
				}
134
				}
134
				else
135
				else
135
				{
136
				{
136
					echo "Pas de propri&eacute;taire ";
137
					echo "Pas de propri&eacute;taire ";
137
					echo ($this->GetUser() ? "(<a href=\"".$this->href("claim")."\">Appropriation</a>)" : "");
138
					echo ($this->GetUser() ? "(<a href=\"".$this->href("claim")."\">Appropriation</a>)" : "");
138
				}
139
				}
139
				echo " :: \n";
140
				echo " :: \n";
140
			}
141
			}
141
		}
142
		}
142
		echo "Vous &ecirc;tes ";
143
		echo "Vous &ecirc;tes ";
143
		echo $this->Format($this->GetUserName());
144
		echo $this->Format($this->GetUserName());
144
		echo "</div>";
145
		echo "</div>";
145
 
146
 
146
 	}
147
 	}
147
 
148
 
148
	function FormOpen($method = "", $tag = "", $formMethod = "post") {
149
	function FormOpen($method = "", $tag = "", $formMethod = "post") {
149
 
150
 
150
	// Le diff ne fonctionne pas avec la methode get dans papyrus. On surcharge avec du post.
151
	// Le diff ne fonctionne pas avec la methode get dans papyrus. On surcharge avec du post.
151
 
152
 
152
		if (($method=="diff") && $formMethod=="get") {
153
		if (($method=="diff") && $formMethod=="get") {
153
			$formMethod="post";
154
			$formMethod="post";
154
		}
155
		}
155
 
156
 
156
		if ($method=="edit") {
157
		if ($method=="edit") {
157
            $result = "<form id=\"ACEditor\" name=\"ACEditor\" action=\"".$this->href($method, $tag)."\" method=\"".$formMethod."\">\n";
158
            $result = "<form id=\"ACEditor\" name=\"ACEditor\" action=\"".$this->href($method, $tag)."\" method=\"".$formMethod."\">\n";
158
            return $result;
159
            return $result;
159
		}
160
		}
160
 
161
 
161
		return parent::FormOpen($method,$tag, $formMethod);
162
		return parent::FormOpen($method,$tag, $formMethod);
162
 
163
 
163
	}
164
	}
164
	// Detournement des handlers : comme ca on peut faire ce que l'on veut ....
165
	// Detournement des handlers : comme ca on peut faire ce que l'on veut ....
165
	function Method($method) {
166
	function Method($method) {
166
 
167
 
167
		if ($method=="xml") {
168
		if ($method=="xml") {
168
			header("Content-type: text/xml");
169
			header("Content-type: text/xml");
169
			if ($pages = $this->LoadRecentlyChanged(50)) {
170
			if ($pages = $this->LoadRecentlyChanged(50)) {
170
		
171
		
171
				$link=ereg_replace('&','&amp;',$this->Href());	            
172
				$link=ereg_replace('&','&amp;',$this->Href());	            
172
			    $output = "<?xml version=\"1.0\" encoding=\"iso-8859-1\" ?>\n";
173
			    $output = "<?xml version=\"1.0\" encoding=\"iso-8859-1\" ?>\n";
173
			    $output .= '<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">' . "\n";
174
			    $output .= '<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">' . "\n";
174
			    $output .= "<channel>\n";
175
			    $output .= "<channel>\n";
175
			    $output .= "<title> Derniers changements sur ". $this->config["wakka_name"]  . "</title>\n";
176
			    $output .= "<title> Derniers changements sur ". $this->config["wakka_name"]  . "</title>\n";
176
			    $output .= "<link>" .  $link . "</link>\n";
177
			    $output .= "<link>" .  $link . "</link>\n";
177
			    $output .= "<description> Derniers changements sur " . $this->config["wakka_name"] . " </description>\n";
178
			    $output .= "<description> Derniers changements sur " . $this->config["wakka_name"] . " </description>\n";
178
			    $output .= "<language>fr</language>\n";
179
			    $output .= "<language>fr</language>\n";
179
			    $output .= '<generator>WikiNi ' . WIKINI_VERSION . "</generator>\n";
180
			    $output .= '<generator>WikiNi ' . WIKINI_VERSION . "</generator>\n";
180
			    foreach ($pages as $i => $page)
181
			    foreach ($pages as $i => $page)
181
			    {
182
			    {
182
			        $output .= "<item>\n";
183
			        $output .= "<item>\n";
183
			        $output .= "<title>" . $page["tag"] . "</title>\n";
184
			        $output .= "<title>" . $page["tag"] . "</title>\n";
184
			        $output .= '<dc:creator>' . $page["user"] . "</dc:creator>\n";
185
			        $output .= '<dc:creator>' . $page["user"] . "</dc:creator>\n";
185
			        $output .= '<pubDate>' . date("r", strtotime($page['time'])) . "</pubDate>\n";
186
			        $output .= '<pubDate>' . date("r", strtotime($page['time'])) . "</pubDate>\n";
186
			        $output .= "<description> Modification de " . $page["tag"] . " --- par " .$page["user"] /* . " le " . $day ." - ". $hh .":". $mm */ . "</description>\n";
187
			        $output .= "<description> Modification de " . $page["tag"] . " --- par " .$page["user"] /* . " le " . $day ." - ". $hh .":". $mm */ . "</description>\n";
187
			        $link=ereg_replace('&','&amp;',$this->Href("",$page["tag"]));
188
			        $link=ereg_replace('&','&amp;',$this->Href("",$page["tag"]));
188
			        $output .= "<link>" . $link . "&amp;time=" . rawurlencode($page["time"]) . "</link>\n";
189
			        $output .= "<link>" . $link . "&amp;time=" . rawurlencode($page["time"]) . "</link>\n";
189
			        $output .= "</item>\n";
190
			        $output .= "</item>\n";
190
			    }
191
			    }
191
			    $output .= "</channel>\n";
192
			    $output .= "</channel>\n";
192
			    $output .= "</rss>\n";
193
			    $output .= "</rss>\n";
193
			    echo $output ;
194
			    echo $output ;
194
 
195
 
195
			}
196
			}
196
			exit;
197
			exit;
197
			return;
198
			return;
198
		}
199
		}
199
 
200
 
200
		if ($method=="edit") {
201
		if ($method=="edit") {
201
			
202
			
202
			if ($this->HasAccess("write") && $this->HasAccess("read")) {
203
			if ($this->HasAccess("write") && $this->HasAccess("read")) {
203
		
204
		
204
				$result='';
205
				$result='';
205
		
206
		
206
				if ($_POST) {
207
				if ($_POST) {
207
					if ($_POST["submit"] == "Sauver")	{
208
					if ($_POST["submit"] == "Sauver")	{
208
						
209
						
209
					require_once(ADWI_CHEMIN_BIBLIOTHEQUE.'/hashcash/secret/wp-hashcash.lib');
210
					require_once(ADWI_CHEMIN_BIBLIOTHEQUE.'/hashcash/secret/wp-hashcash.lib');
210
					if($_POST["hashcash_value"] != hashcash_field_value()) {
211
					if($_POST["hashcash_value"] != hashcash_field_value()) {
211
						$this->SetMessage("Cette page n\'a pas &eacute;t&eacute; enregistr&eacute;e car ce wiki pense que vous etes un robot !");
212
						$this->SetMessage("Cette page n\'a pas &eacute;t&eacute; enregistr&eacute;e car ce wiki pense que vous etes un robot !");
212
						$this->Redirect($this->href());
213
						$this->Redirect($this->href());
213
					}
214
					}
214
	
215
	
215
					// check for overwriting
216
					// check for overwriting
216
						if ($this->page) {
217
						if ($this->page) {
217
							if ($this->page["id"] != $_POST["previous"]) {
218
							if ($this->page["id"] != $_POST["previous"]) {
218
								$error = "ALERTE : ".
219
								$error = "ALERTE : ".
219
								"Cette page a &eacute;t&eacute; modifi&eacute;e par quelqu'un d'autre pendant que vous l'&eacute;ditiez.<br />\n".
220
								"Cette page a &eacute;t&eacute; modifi&eacute;e par quelqu'un d'autre pendant que vous l'&eacute;ditiez.<br />\n".
220
								"Veuillez copier vos changements et r&eacute;&eacute;diter cette page.\n";
221
								"Veuillez copier vos changements et r&eacute;&eacute;diter cette page.\n";
221
							}
222
							}
222
						}
223
						}
223
						// store
224
						// store
224
						if (!$error) {
225
						if (!$error) {
225
							$body = str_replace("\r", "", $_POST["body"]);
226
							$body = str_replace("\r", "", $_POST["body"]);
226
							// test si la nouvelle page est differente de la précédente
227
							// test si la nouvelle page est differente de la précédente
227
							if(rtrim($body)==rtrim($this->page["body"])) {
228
							if(rtrim($body)==rtrim($this->page["body"])) {
228
								$this->SetMessage("Cette page n\'a pas &eacute;t&eacute; enregistr&eacute;e car elle n\'a subi aucune modification.");
229
								$this->SetMessage("Cette page n\'a pas &eacute;t&eacute; enregistr&eacute;e car elle n\'a subi aucune modification.");
229
								$this->Redirect($this->href());
230
								$this->Redirect($this->href());
230
							}
231
							}
231
		
232
		
232
							// add page (revisions)
233
							// add page (revisions)
233
							$this->SavePage($this->tag, $body);
234
							$this->SavePage($this->tag, $body);
234
		
235
		
235
							// now we render it internally so we can write the updated link table.
236
							// now we render it internally so we can write the updated link table.
236
							$this->ClearLinkTable();
237
							$this->ClearLinkTable();
237
							$this->StartLinkTracking();
238
							$this->StartLinkTracking();
238
							$dummy = $this->Header();
239
							$dummy = $this->Header();
239
							$dummy .= $this->Format($body);
240
							$dummy .= $this->Format($body);
240
							$dummy .= $this->Footer();
241
							$dummy .= $this->Footer();
241
							$this->StopLinkTracking();
242
							$this->StopLinkTracking();
242
							$this->WriteLinkTable();
243
							$this->WriteLinkTable();
243
							$this->ClearLinkTable();
244
							$this->ClearLinkTable();
244
		
245
		
245
							// forward
246
							// forward
246
							$this->Redirect($this->href());
247
							$this->Redirect($this->href());
247
						}
248
						}
248
					}
249
					}
249
				}
250
				}
250
		
251
		
251
				// fetch fields
252
				// fetch fields
252
				if (!$previous = $_POST["previous"]) $previous = $this->page["id"];
253
				if (!$previous = $_POST["previous"]) $previous = $this->page["id"];
253
				if (!$body = $_POST["body"]) $body = $this->page["body"];
254
				if (!$body = $_POST["body"]) $body = $this->page["body"];
254
		
255
		
255
				// preview?
256
				// preview?
256
				if ($_POST["submit"] == "Aperçu")
257
				if ($_POST["submit"] == "Aperçu")
257
				{
258
				{
258
					$result .=
259
					$result .=
259
						"<div class=\"prev_alert\"><strong>Aper&ccedil;u</strong></div>\n".
260
						"<div class=\"prev_alert\"><strong>Aper&ccedil;u</strong></div>\n".
260
						$this->Format($body)."\n\n".
261
						$this->Format($body)."\n\n".
261
						$this->FormOpen("edit").
262
						$this->FormOpen("edit").
262
						"<input type=\"hidden\" name=\"previous\" value=\"".$previous."\" />\n".
263
						"<input type=\"hidden\" name=\"previous\" value=\"".$previous."\" />\n".
263
						"<input type=\"hidden\" name=\"body\" value=\"".htmlentities($body)."\" />\n".
264
						"<input type=\"hidden\" name=\"body\" value=\"".htmlentities($body)."\" />\n".
264
						"<br />\n".
265
						"<br />\n".
265
						"<input name=\"submit\" type=\"submit\" value=\"Sauver\" accesskey=\"s\" />\n".
266
						"<input name=\"submit\" type=\"submit\" value=\"Sauver\" accesskey=\"s\" />\n".
266
						"<input name=\"submit\" type=\"submit\" value=\"R&eacute;&eacute;diter \" accesskey=\"p\" />\n".
267
						"<input name=\"submit\" type=\"submit\" value=\"R&eacute;&eacute;diter \" accesskey=\"p\" />\n".
267
						"<input type=\"button\" value=\"Annulation\" onclick=\"document.location='".$this->href("")."';\" />\n".
268
						"<input type=\"button\" value=\"Annulation\" onclick=\"document.location='".$this->href("")."';\" />\n".
268
						$this->FormClose()."\n";
269
						$this->FormClose()."\n";
269
					return $result;
270
					return $result;
270
				}
271
				}
271
				else
272
				else
272
				{
273
				{
273
					
274
					
274
					// Edition 
275
					// Edition 
275
		
276
		
276
					require_once(ADWI_CHEMIN_BIBLIOTHEQUE.'/hashcash/secret/wp-hashcash.lib');
277
					require_once(ADWI_CHEMIN_BIBLIOTHEQUE.'/hashcash/secret/wp-hashcash.lib');
277
            
278
            
278
            		// UPDATE RANDOM SECRET
279
            		// UPDATE RANDOM SECRET
279
            		$curr = @file_get_contents(HASHCASH_SECRET_FILE);
280
            		$curr = @file_get_contents(HASHCASH_SECRET_FILE);
280
            		if(empty($curr) || (time() - @filemtime(HASHCASH_SECRET_FILE)) > HASHCASH_REFRESH){
281
            		if(empty($curr) || (time() - @filemtime(HASHCASH_SECRET_FILE)) > HASHCASH_REFRESH){
281
            	
282
            	
282
            			// update our secret
283
            			// update our secret
283
            			$fp = fopen(HASHCASH_SECRET_FILE, 'w');
284
            			$fp = fopen(HASHCASH_SECRET_FILE, 'w');
284
            
285
            
285
            			if(@flock($fp, LOCK_EX)){
286
            			if(@flock($fp, LOCK_EX)){
286
            				fwrite($fp, rand(21474836, 2126008810));
287
            				fwrite($fp, rand(21474836, 2126008810));
287
            				@flock($fp, LOCK_UN);
288
            				@flock($fp, LOCK_UN);
288
            			}
289
            			}
289
            
290
            
290
            			fclose($fp);
291
            			fclose($fp);
291
            	
292
            	
292
            		}
293
            		}
293
            		
294
            		
294
            		if (isset($GLOBALS['_GEN_commun']['url_sauvegarde']) && ($GLOBALS['_GEN_commun']['url_sauvegarde']!='')) {
295
            		if (isset($GLOBALS['_GEN_commun']['url_sauvegarde']) && ($GLOBALS['_GEN_commun']['url_sauvegarde']!='')) {
295
	                  $a=parse_url(str_replace('&amp;', '&', $GLOBALS['_GEN_commun']['url_sauvegarde']->getUrl()));
296
	                  $a=parse_url(str_replace('&amp;', '&', $GLOBALS['_GEN_commun']['url_sauvegarde']->getUrl()));
296
					}
297
					}
297
 
298
 
298
					else {
299
					else {
299
                        $a = parse_url($this->config['base_url']);
300
                        $a = parse_url($this->config['base_url']);
300
					}
301
					}
301
            		
302
            		
302
                    $siteurl = ($a['scheme'].'://'.$a['host'].dirname($a['path']));
303
                    $siteurl = ($a['scheme'].'://'.$a['host'].dirname($a['path']));
303
            
304
            
304
            
305
            
305
            		$ChampsHashcash = 
306
            		$ChampsHashcash = 
306
            		 '<link rel="powered" title="Elliott Back\'s Antispam" href="http://elliottback.com" />'.
307
            		 '<link rel="powered" title="Elliott Back\'s Antispam" href="http://elliottback.com" />'.
307
            		 '<script type="text/javascript" src="' . $siteurl . '/client/integrateur_wikini/bibliotheque/hashcash/wp-hashcash-js.php?siteurl='.$siteurl.'"></script>';
308
            		 '<script type="text/javascript" src="' . $siteurl . '/client/integrateur_wikini/bibliotheque/hashcash/wp-hashcash-js.php?siteurl='.$siteurl.'"></script>';
308
            	 
309
            	 
309
					$ACbuttonsBar='';
310
					$ACbuttonsBar='';
310
				    require_once(IW_CHEMIN_BIBLIO_ACEDITOR."ACeditor.buttonsBar.php");
311
				    require_once(IW_CHEMIN_BIBLIO_ACEDITOR."ACeditor.buttonsBar.php");
311
		
312
		
312
					$result .=
313
					$result .=
313
					$this->FormOpen("edit").
314
					$this->FormOpen("edit").
314
					"<input type=\"hidden\" name=\"previous\" value=\"".$previous."\" />\n".$ACbuttonsBar.
315
					"<input type=\"hidden\" name=\"previous\" value=\"".$previous."\" />\n".$ACbuttonsBar.
315
					"<textarea onkeydown=\"fKeyDown()\" name=\"body\" cols=\"60\" rows=\"40\" wrap=\"soft\" class=\"edit\">\n".
316
					"<textarea onkeydown=\"fKeyDown()\" name=\"body\" cols=\"60\" rows=\"40\" wrap=\"soft\" class=\"edit\">\n".
316
					htmlspecialchars($body).
317
					htmlspecialchars($body).
317
					"\n</textarea><br />\n".'<div class="boutons_wiki">'.
318
					"\n</textarea><br />\n".'<div class="boutons_wiki">'.
318
					($this->config["preview_before_save"] ? "" : $ChampsHashcash."<input name=\"submit\" type=\"submit\" value=\"Sauver\" accesskey=\"s\" />\n").
319
					($this->config["preview_before_save"] ? "" : $ChampsHashcash."<input name=\"submit\" type=\"submit\" value=\"Sauver\" accesskey=\"s\" />\n").
319
					"<input name=\"submit\" type=\"submit\" value=\"Aper&ccedil;u\" accesskey=\"p\" />\n".
320
					"<input name=\"submit\" type=\"submit\" value=\"Aper&ccedil;u\" accesskey=\"p\" />\n".
320
					"<input type=\"button\" value=\"Annulation\" onclick=\"document.location='".$this->href("")."';\" /></div>\n".
321
					"<input type=\"button\" value=\"Annulation\" onclick=\"document.location='".$this->href("")."';\" /></div>\n".
321
					$this->FormClose();
322
					$this->FormClose();
322
		
323
		
323
					return $result;
324
					return $result;
324
				}
325
				}
325
		
326
		
326
			}
327
			}
327
			else {
328
			else {
328
				echo "<i>Vous n'avez pas acc&egrave;s en &eacute;criture &agrave; cette page !</i>\n";
329
				echo "<i>Vous n'avez pas acc&egrave;s en &eacute;criture &agrave; cette page !</i>\n";
329
				
330
				
330
			}
331
			}
331
		}
332
		}
332
		else {
333
		else {
333
			return parent::Method($method);
334
			return parent::Method($method);
334
		}
335
		}
335
	}
336
	}
336
 
337
 
337
 
338
 
338
	// Surcharge Format a cause probleme de chemin.
339
	// Surcharge Format a cause probleme de chemin.
339
 
340
 
340
	function Format($text, $formatter = "wakka") {
341
	function Format($text, $formatter = "wakka") {
341
		return $this->IncludeBuffered(IW_CHEMIN_WIKINI_COURANT_FORMATTER.$formatter.".php", "<i>Impossible de trouver le formateur \"$formatter\"</i>", compact("text"));
342
		return $this->IncludeBuffered(IW_CHEMIN_WIKINI_COURANT_FORMATTER.$formatter.".php", "<i>Impossible de trouver le formateur \"$formatter\"</i>", compact("text"));
342
	}
343
	}
343
 
344
 
344
 
345
 
345
	// Identification
346
	// Identification
346
 
347
 
347
	function SetUser($user, $remember) {
348
	function SetUser($user, $remember) {
348
			// Appel à partir de Papyrus
349
			// Appel à partir de Papyrus
349
				if ($user=='initwiki') {
350
				if ($user=='initwiki') {
350
					$remember=1;
351
					$remember=1;
351
					$wiki_prenom=$this->versChatMot($GLOBALS['_GEN_commun']['pear_auth']->getAuthData($GLOBALS['_GEN_commun']['info_auth_bdd']->chp_personne_prenom));
352
					$wiki_prenom=$this->versChatMot($GLOBALS['_GEN_commun']['pear_auth']->getAuthData($GLOBALS['_GEN_commun']['info_auth_bdd']->chp_personne_prenom));
352
					$wiki_nom=$this->versChatMot($GLOBALS['_GEN_commun']['pear_auth']->getAuthData($GLOBALS['_GEN_commun']['info_auth_bdd']->chp_personne_nom));
353
					$wiki_nom=$this->versChatMot($GLOBALS['_GEN_commun']['pear_auth']->getAuthData($GLOBALS['_GEN_commun']['info_auth_bdd']->chp_personne_nom));
353
					$_SESSION["user"]=array("name"=>$wiki_prenom.$wiki_nom,"password"=>"wikini","changescount"=> 100);
354
					$_SESSION["user"]=array("name"=>$wiki_prenom.$wiki_nom,"password"=>"wikini","changescount"=> 100);
354
					$this->SetPersistentCookie("name", $user["name"], $remember);
355
					$this->SetPersistentCookie("name", $user["name"], $remember);
355
					$this->SetPersistentCookie("password", $user["password"], $remember);
356
					$this->SetPersistentCookie("password", $user["password"], $remember);
356
					$this->SetPersistentCookie("remember", $remember, $remember);
357
					$this->SetPersistentCookie("remember", $remember, $remember);
357
				}
358
				}
358
				else {
359
				else {
359
					parent::Setuser($user,$remember);
360
					parent::Setuser($user,$remember);
360
				}
361
				}
361
 
362
 
362
	}
363
	}
363
 
364
 
364
	function LoadUser($name, $password = 0) {
365
	function LoadUser($name, $password = 0) {
365
		 return true; 
366
		 return true; 
366
	}
367
	}
367
 
368
 
368
	function LogoutUser() {
369
	function LogoutUser() {
369
		$_SESSION["user"]="";
370
		$_SESSION["user"]="";
370
		$this->DeleteCookie("remember");
371
		$this->DeleteCookie("remember");
371
		parent::LogoutUser();
372
		parent::LogoutUser();
372
	}
373
	}
373
	
374
	
374
	
375
	
375
 
376
 
376
	function versChatMot($entree) {
377
	function versChatMot($entree) {
377
		$sortie = strtolower(trim(strtr($entree, "àâéêèëîïôöùûüç-", "aaeeeeiioouuuc ")));
378
		$sortie = strtolower(trim(strtr($entree, "àâéêèëîïôöùûüç-", "aaeeeeiioouuuc ")));
378
		$sortie = ucwords($sortie);
379
		$sortie = ucwords($sortie);
379
		$sortie = str_replace(" ", "",$sortie);
380
		$sortie = str_replace(" ", "",$sortie);
380
		return $sortie;
381
		return $sortie;
381
	}
382
	}
382
 
383
 
383
}
384
}
384
 
385
 
385
 
386
 
386
 
387
 
387
// Appel du fichier de traduction des textes de l'application Integrateur Wikini
388
// Appel du fichier de traduction des textes de l'application Integrateur Wikini
388
if (file_exists(IW_CHEMIN_LANGUES.'iw_langue_'.IW_I18N.'.inc.php')) {
389
if (file_exists(IW_CHEMIN_LANGUES.'iw_langue_'.IW_I18N.'.inc.php')) {
389
    /** Inclusion du fichier de traduction de l'application Integrateur Wikini. */
390
    /** Inclusion du fichier de traduction de l'application Integrateur Wikini. */
390
    include_once IW_CHEMIN_LANGUES.'iw_langue_'.IW_I18N.'.inc.php';
391
    include_once IW_CHEMIN_LANGUES.'iw_langue_'.IW_I18N.'.inc.php';
391
} else {
392
} else {
392
    /** Inclusion du fichier de traduction fr par défaut. */
393
    /** Inclusion du fichier de traduction fr par défaut. */
393
    include_once IW_CHEMIN_LANGUES.'iw_langue_fr.inc.php';
394
    include_once IW_CHEMIN_LANGUES.'iw_langue_fr.inc.php';
394
}
395
}
395
 
396
 
396
$GLOBALS['_PAPYRUS_']['erreur']->setActive(1);
397
$GLOBALS['_PAPYRUS_']['erreur']->setActive(1);
397
/**
398
/**
398
 *
399
 *
399
 * Fonction afficherPageMenuWikini()
400
 * Fonction afficherPageMenuWikini()
400
 *
401
 *
401
 * Renvoie le contenu de la page Menu de Wikini
402
 * Renvoie le contenu de la page Menu de Wikini
402
 *
403
 *
403
 * @return string
404
 * @return string
404
 * @access public
405
 * @access public
405
 */
406
 */
406
 
407
 
407
function afficherPageMenuWikini()
408
function afficherPageMenuWikini()
408
{
409
{
409
 
410
 
410
	$GLOBALS['_PAPYRUS_']['erreur']->setActive(0);
411
	$GLOBALS['_PAPYRUS_']['erreur']->setActive(0);
411
 
412
 
412
	global $wiki;
413
	global $wiki;
413
	global $wikini_config_defaut;
414
	global $wikini_config_defaut;
414
	$sortie='';
415
	$sortie='';
415
    $wakkaConfig = $GLOBALS['wikini_config_defaut'];
416
    $wakkaConfig = $GLOBALS['wikini_config_defaut'];
416
    if (!class_exists('Wiki_Papyrus')) return ;
417
    if (!class_exists('Wiki_Papyrus')) return ;
417
    $wiki  = new Wiki_Papyrus($wakkaConfig);
418
    $wiki  = new Wiki_Papyrus($wakkaConfig);
418
 
419
 
419
    // Suppression des slash.
420
    // Suppression des slash.
420
    $_REQUEST['wiki'] = preg_replace("/^\//", '',  $_REQUEST['wiki']);
421
    $_REQUEST['wiki'] = preg_replace("/^\//", '',  $_REQUEST['wiki']);
421
 
422
 
422
    // split into page/method
423
    // split into page/method
423
    $matches='';
424
    $matches='';
424
    if ( preg_match( "#^(.+?)/(.*)$#",  $_REQUEST['wiki'], $matches ) ) {
425
    if ( preg_match( "#^(.+?)/(.*)$#",  $_REQUEST['wiki'], $matches ) ) {
425
        list(, $page, $method) = $matches;
426
        list(, $page, $method) = $matches;
426
    } else if ( preg_match( "#^(.*)$#",  $_REQUEST['wiki'], $matches ) ) {
427
    } else if ( preg_match( "#^(.*)$#",  $_REQUEST['wiki'], $matches ) ) {
427
        list(, $page) = $matches;
428
        list(, $page) = $matches;
428
    }
429
    }
429
 
430
 
430
    $server=$_SERVER['PHP_SELF'];
431
    $server=$_SERVER['PHP_SELF'];
431
	$_SERVER['PHP_SELF']="wakka.php";
432
	$_SERVER['PHP_SELF']="wakka.php";
432
 
433
 
433
    $contenu=$wiki->LoadPage("PageMenu");
434
    $contenu=$wiki->LoadPage("PageMenu");
434
 
435
 
435
    $sortie.="<div id=\"menu_wikini\">";
436
    $sortie.="<div id=\"menu_wikini\">";
436
	$sortie.=$wiki->Format($contenu['body']);
437
	$sortie.=$wiki->Format($contenu['body']);
437
	$sortie.="</div>";
438
	$sortie.="</div>";
438
 
439
 
439
	$_SERVER['PHP_SELF']=$server;
440
	$_SERVER['PHP_SELF']=$server;
440
 
441
 
441
	$GLOBALS['_PAPYRUS_']['erreur']->setActive(1);
442
	$GLOBALS['_PAPYRUS_']['erreur']->setActive(1);
442
 
443
 
443
	return $sortie;
444
	return $sortie;
444
 
445
 
445
}
446
}
446
 
447
 
447
 
448
 
448
// +------------------------------------------------------------------------------------------------------+
449
// +------------------------------------------------------------------------------------------------------+
449
// |                                            CORPS du PROGRAMME                                        |
450
// |                                            CORPS du PROGRAMME                                        |
450
// +------------------------------------------------------------------------------------------------------+
451
// +------------------------------------------------------------------------------------------------------+
451
/** Fonction afficherPageWikini() - Fonction appelé par le gestionnaire Papyrus.
452
/** Fonction afficherPageWikini() - Fonction appelé par le gestionnaire Papyrus.
452
*
453
*
453
* Elle retourne le contenu de l'application.
454
* Elle retourne le contenu de l'application.
454
*
455
*
455
* @return  string  du code XHTML correspondant au contenu renvoyé par l'application.
456
* @return  string  du code XHTML correspondant au contenu renvoyé par l'application.
456
*/
457
*/
457
function afficherPageWikini()
458
function afficherPageWikini()
458
{
459
{
459
	
460
	
460
 
461
 
461
	$GLOBALS['_PAPYRUS_']['erreur']->setActive(0);
462
	$GLOBALS['_PAPYRUS_']['erreur']->setActive(0);
462
 
463
 
463
	// Ajout d'une feuille de style externe
464
	// Ajout d'une feuille de style externe
464
	GEN_stockerStyleExterne ('wikini', 'client/integrateur_wikini/presentations/styles/wikini.css') ;
465
	GEN_stockerStyleExterne ('wikini', 'client/integrateur_wikini/presentations/styles/wikini.css') ;
465
 
466
 
466
	global $wiki;
467
	global $wiki;
467
	global $wikini_config_defaut;
468
	global $wikini_config_defaut;
468
	$sortie='';
469
	$sortie='';
469
    $wakkaConfig = $GLOBALS['wikini_config_defaut'];
470
    $wakkaConfig = $GLOBALS['wikini_config_defaut'];
470
    if (!class_exists ('Wiki_Papyrus')) return ; 
471
    if (!class_exists ('Wiki_Papyrus')) return ; 
471
    $wiki  = new Wiki_Papyrus($wakkaConfig);
472
    $wiki  = new Wiki_Papyrus($wakkaConfig);
472
 
473
 
473
	if  ($GLOBALS['_GEN_commun']['pear_auth']->checkAuth()) {
474
	if  ($GLOBALS['_GEN_commun']['pear_auth']->checkAuth()) {
474
	//	if (!isset($_SESSION["user"]) || ($_SESSION["user"]=="")) {
475
	//	if (!isset($_SESSION["user"]) || ($_SESSION["user"]=="")) {
475
			$wiki->SetUser('initwiki');
476
			$wiki->SetUser('initwiki');
476
	//	}
477
	//	}
477
	}
478
	}
478
	else {
479
	else {
479
		$wiki->LogoutUser();
480
		$wiki->LogoutUser();
480
	}
481
	}
481
 
482
 
482
	// Gestion de la variable de session "linktracking"
483
	// Gestion de la variable de session "linktracking"
483
    if ( ! isset( $_SESSION['linktracking'] ) ) {
484
    if ( ! isset( $_SESSION['linktracking'] ) ) {
484
        $_SESSION['linktracking'] = 1;
485
        $_SESSION['linktracking'] = 1;
485
    }
486
    }
486
 
487
 
487
    // Suppression des slash.
488
    // Suppression des slash.
488
    $_REQUEST['wiki'] = preg_replace("/^\//", '',  $_REQUEST['wiki']);
489
    $_REQUEST['wiki'] = preg_replace("/^\//", '',  $_REQUEST['wiki']);
489
 
490
 
490
    // split into page/method
491
    // split into page/method
491
    $matches='';
492
    $matches='';
492
    if ( preg_match( "#^(.+?)/(.*)$#",  $_REQUEST['wiki'], $matches ) ) {
493
    if ( preg_match( "#^(.+?)/(.*)$#",  $_REQUEST['wiki'], $matches ) ) {
493
        list(, $page, $method) = $matches;
494
        list(, $page, $method) = $matches;
494
    } else if ( preg_match( "#^(.*)$#",  $_REQUEST['wiki'], $matches ) ) {
495
    } else if ( preg_match( "#^(.*)$#",  $_REQUEST['wiki'], $matches ) ) {
495
        list(, $page) = $matches;
496
        list(, $page) = $matches;
496
    }
497
    }
497
 
498
 
498
    // Vérification de la méthode d'affichage employée!
499
    // Vérification de la méthode d'affichage employée!
499
    if ( ! isset( $method ) ) {
500
    if ( ! isset( $method ) ) {
500
        $method = '';
501
        $method = '';
501
    }
502
    }
502
 
503
 
503
    //Récupération du contenu de la page Wikini
504
    //Récupération du contenu de la page Wikini
504
 
505
 
505
    ob_start();
506
    ob_start();
506
 
507
 
507
    $server=$_SERVER['PHP_SELF'];
508
    $server=$_SERVER['PHP_SELF'];
508
	$_SERVER['PHP_SELF']="wakka.php";
509
	$_SERVER['PHP_SELF']="wakka.php";
509
 
510
 
510
	$wiki->Run($page, $method);
511
	$wiki->Run($page, $method);
511
 
512
 
512
    $_SERVER['PHP_SELF']=$server;
513
    $_SERVER['PHP_SELF']=$server;
513
 
514
 
514
    $sortie.= ob_get_contents();
515
    $sortie.= ob_get_contents();
515
    ob_end_clean();
516
    ob_end_clean();
516
 
517
 
517
	$GLOBALS['_PAPYRUS_']['erreur']->setActive(1);
518
	$GLOBALS['_PAPYRUS_']['erreur']->setActive(1);
518
 
519
 
519
	if ($method!="edit") {
520
	if ($method!="edit") {
520
		return remplacerEntiteHTLM("<script type=\"text/javascript\" src=\"".IW_CHEMIN_BIBLIO_ACEDITOR."ACeditor.js\"></script><div id=\"wikini_page\"  ondblclick=\"document.location='".$wiki->href("edit")."';"."\">"."\n".$sortie.'</div>'."\n");
521
		return remplacerEntiteHTLM("<script type=\"text/javascript\" src=\"".IW_CHEMIN_BIBLIO_ACEDITOR."ACeditor.js\"></script><div id=\"wikini_page\"  ondblclick=\"document.location='".$wiki->href("edit")."';"."\">"."\n".$sortie.'</div>'."\n");
521
	}
522
	}
522
	else {
523
	else {
523
		return remplacerEntiteHTLM("<script type=\"text/javascript\" src=\"".IW_CHEMIN_BIBLIO_ACEDITOR."ACeditor.js\"></script><div id=\"wikini_page\">"."\n".$sortie.'</div>'."\n");
524
		return remplacerEntiteHTLM("<script type=\"text/javascript\" src=\"".IW_CHEMIN_BIBLIO_ACEDITOR."ACeditor.js\"></script><div id=\"wikini_page\">"."\n".$sortie.'</div>'."\n");
524
	}
525
	}
525
	
526
	
526
	
527
	
527
}
528
}
528
 
529
 
529
?>
530
?>