<?php
ob_start();
session_start();
require 'connect.php';
include_once("fckeditor/fckeditor.php") ;
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Administration GRDR</title>
<link href="style/style_admin.css" rel="stylesheet" type="text/css" />
<link rel="shortcut icon" href="images/favicon.ico" type="image/x-icon" />
<script type="text/javascript">
<!--
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}
function supprimer(page) {
	document.getElementById('suppr').innerHTML = '&Ecirc;tes vous sur de vouloir supprimer la page ? <a href="?page='+page+'&suppr" class="suppr">oui</a>&nbsp;&nbsp;&nbsp;<a href="#" onClick="annule_suppr();return false;" class="suppr">non</a>';
}
function annule_suppr() {
	document.getElementById('suppr').innerHTML = '<a href="#" class="suppr" onClick="supprimer();return false;">Supprimer</a>';
}
//-->
</script>
</head>
<body>
<?php
// Verification que l'admin est identifié
$login='root';
$pass='4Grdr';
if (isset($_SESSION['login']) && isset($_SESSION['pass'])) {
	if ($_SESSION['login']!=$login || $_SESSION['pass']!=$pass) header("location:identification.php");
} else  header("location:identification.php");
if (isset($_GET['deconnect'])) {
	session_destroy();
	header("location:identification.php");
}
?>	
<div id="header">
	<a href="?deconnect">Déconnexion</a>
    	<form name="form" id="form">
    		
            <table class="bienvenue">
            	<tr><td><img src="images/grdr.jpg" /></td>
                	<td>
                        <p>
                            Bienvenue dans l'interface de gestion du site GRDR<br />Choisissez une page à modifier : 
                            <?php
							if (isset($_GET['modif_ok'])) $_GET['page']=$_GET['modif_ok'];
							if (!isset($_GET['page'])) echo '<select name="jumpMenu" id="jumpMenu" onchange="MM_jumpMenu(\'parent\',this,0)"><option></option><option value="?page=texte accueil.php">texte accueil</option><option value="?page=petit texte accueil1.php">petit texte accueil1</option><option value="?page=petit texte accueil2.php">petit texte accueil2</option><option value="?page=petit texte accueil3.php">petit texte accueil3</option><option value="?page=axe1.php">axe1</option><option value="?page=axe2.php">axe2</option><option value="?page=axe3.php">axe3</option><option value="?page=axe4.php">axe4</option><option value="?page=axe5.php">axe5</option><option value="?page=outils.php">outils</option><option value="?page=mentions.php">mentions</option><option value="?page=mali.php">mali</option><option value="?page=mauritanie.php">mauritanie</option><option value="?page=senegal.php">s&eacute;n&eacute;gal</option></select>';
							else {
								if ($_GET['page']=='mali.php' || $_GET['page']=='mauritanie.php' || $_GET['page']=='senegal.php') {
									$ext= ".";
  									$position_ext = strpos($_GET['page'], $ext);
									$nom = substr($_GET['page'], 0, $position_ext);
									echo '<select name="jumpMenu" id="jumpMenu" onchange="MM_jumpMenu(\'parent\',this,0)"><option value="?page='.$_GET['page'].'">'.$nom.'</option><option value="?page=texte accueil.php">texte accueil</option><option value="?page=petit texte accueil1.php">petit texte accueil1</option><option value="?page=petit texte accueil2.php">petit texte accueil2</option><option value="?page=petit texte accueil3.php">petit texte accueil3</option><option value="?page=axe1.php">axe1</option><option value="?page=axe2.php">axe2</option><option value="?page=axe3.php">axe3</option><option value="?page=axe4.php">axe4</option><option value="?page=axe5.php">axe5</option><option value="?page=outils.php">outils</option><option value="?page=mentions.php">mentions</option><option value="?page=mali.php">mali</option><option value="?page=mauritanie.php">mauritanie</option><option value="?page=senegal.php">s&eacute;n&eacute;gal</option></select>';
									echo ' / ';
									echo '<select name="jumpMenu" id="jumpMenu" onchange="MM_jumpMenu(\'parent\',this,0)"><option></option>';
									$sql="SELECT id FROM content WHERE page='".$_GET['page']."'";
									$result = mysql_query($sql, $link);
									$ligne = mysql_fetch_array($result, MYSQL_ASSOC);
									$id_parent=$ligne['id'];
									$sql="SELECT id, nom FROM regions WHERE id_parent='$id_parent' ORDER BY nom ASC";
									$result = mysql_query($sql, $link);
									while ($ligne = mysql_fetch_array($result, MYSQL_ASSOC)) {
										$nom=$ligne['nom'];
										$id=$ligne['id'];
										echo '<option value="?page='.$id.'">'.$nom.'</option>';
									}
									echo '</select>';
								
								} else if (is_numeric($_GET['page'])) {
									$sql="SELECT id_parent FROM regions WHERE id='".$_GET['page']."'";
									$result = mysql_query($sql, $link);
									$ligne = mysql_fetch_array($result, MYSQL_ASSOC);
									$id_parent=$ligne['id_parent'];
									$sql="SELECT id_page FROM regions WHERE id_page='".$id_parent."'";
									$result = mysql_query($sql, $link);
									if (mysql_num_rows($result)==0) {
										// C'est une région
										$sql="SELECT page FROM content WHERE id='".$id_parent."'";
										$result = mysql_query($sql, $link);
										$ligne = mysql_fetch_array($result, MYSQL_ASSOC);
										$page=$ligne['page'];
										$ext=$trouvemoi = ".";
  										$position_ext = strpos($page, $ext);
										$page = substr($page, 0, $position_ext);
										echo '<select name="jumpMenu" id="jumpMenu" onchange="MM_jumpMenu(\'parent\',this,0)"><option value="?page='.$page.'">'.$page.'</option><option value="?page=texte accueil.php">texte accueil</option><option value="?page=petit texte accueil1.php">petit texte accueil1</option><option value="?page=petit texte accueil2.php">petit texte accueil2</option><option value="?page=petit texte accueil3.php">petit texte accueil3</option><option value="?page=axe1.php">axe1</option><option value="?page=axe2.php">axe2</option><option value="?page=axe3.php">axe3</option><option value="?page=axe4.php">axe4</option><option value="?page=axe5.php">axe5</option><option value="?page=outils.php">outils</option><option value="?page=mentions.php">mentions</option><option value="?page=mali.php">mali</option><option value="?page=mauritanie.php">mauritanie</option><option value="?page=senegal.php">s&eacute;n&eacute;gal</option></select>';
										echo ' / ';
										echo '<select name="jumpMenu" id="jumpMenu" onchange="MM_jumpMenu(\'parent\',this,0)">';
										$sql="SELECT nom FROM regions WHERE id='".$_GET['page']."'";
										$result = mysql_query($sql, $link);
										$ligne = mysql_fetch_array($result, MYSQL_ASSOC);
										$nom=$ligne['nom'];
										echo '<option value="?page='.$nom.'">'.$nom.'</option>';
										$sql="SELECT id, nom FROM regions WHERE id_parent='$id_parent' ORDER BY nom ASC";
										$result = mysql_query($sql, $link);
										while ($ligne = mysql_fetch_array($result, MYSQL_ASSOC)) {
											$nom=$ligne['nom'];
											$id=$ligne['id'];
											echo '<option value="?page='.$id.'">'.$nom.'</option>';
										}
										echo '</select>';
										echo ' / ';
										echo '<select name="jumpMenu" id="jumpMenu" onchange="MM_jumpMenu(\'parent\',this,0)"><option></option>';
										$sql="SELECT nom,id_page FROM regions WHERE id='".$_GET['page']."'";
										$result = mysql_query($sql, $link);
										$ligne = mysql_fetch_array($result, MYSQL_ASSOC);
										$nom=$ligne['nom'];
										$id_page=$ligne['id_page'];
										$sql="SELECT id, nom FROM regions WHERE id_parent='$id_page' ORDER BY nom ASC";
										$result = mysql_query($sql, $link);
										while ($ligne = mysql_fetch_array($result, MYSQL_ASSOC)) {
											$nom=$ligne['nom'];
											$id=$ligne['id'];
											echo '<option value="?page='.$id.'">'.$nom.'</option>';
										}
										echo '</select>';
									} else {
										// C'est une commune
										$sql="SELECT id_parent FROM regions WHERE id='".$_GET['page']."'";
										$result = mysql_query($sql, $link);
										$ligne = mysql_fetch_array($result, MYSQL_ASSOC);
										$id_parent=$ligne['id_parent'];
										$sql="SELECT id_parent FROM regions WHERE id_page='".$id_parent."'";
										$result = mysql_query($sql, $link);
										$ligne = mysql_fetch_array($result, MYSQL_ASSOC);
										$id_parent2=$ligne['id_parent'];
										$sql="SELECT page FROM content WHERE id='".$id_parent2."'";
										$result = mysql_query($sql, $link);
										$ligne = mysql_fetch_array($result, MYSQL_ASSOC);
										$page=$ligne['page'];
										$ext=$trouvemoi = ".";
  										$position_ext = strpos($page, $ext);
										$page = substr($page, 0, $position_ext);
										echo '<select name="jumpMenu" id="jumpMenu" onchange="MM_jumpMenu(\'parent\',this,0)"><option value="?page='.$page.'">'.$page.'</option><option value="?page=texte accueil.php">texte accueil</option><option value="?page=petit texte accueil1.php">petit texte accueil1</option><option value="?page=petit texte accueil2.php">petit texte accueil2</option><option value="?page=petit texte accueil3.php">petit texte accueil3</option><option value="?page=axe1.php">axe1</option><option value="?page=axe2.php">axe2</option><option value="?page=axe3.php">axe3</option><option value="?page=axe4.php">axe4</option><option value="?page=axe5.php">axe5</option><option value="?page=outils.php">outils</option><option value="?page=mentions.php">mentions</option><option value="?page=mali.php">mali</option><option value="?page=mauritanie.php">mauritanie</option><option value="?page=senegal.php">s&eacute;n&eacute;gal</option></select>';
										echo ' / ';
										echo '<select name="jumpMenu" id="jumpMenu" onchange="MM_jumpMenu(\'parent\',this,0)">';
										$sql="SELECT nom FROM regions WHERE id_page='".$id_parent."'";
										$result = mysql_query($sql, $link);
										$ligne = mysql_fetch_array($result, MYSQL_ASSOC);
										$nom=$ligne['nom'];
										echo '<option value="?page='.$nom.'">'.$nom.'</option>';
										$sql="SELECT id, nom FROM regions WHERE id_parent='$id_parent2' ORDER BY nom ASC";
										$result = mysql_query($sql, $link);
										while ($ligne = mysql_fetch_array($result, MYSQL_ASSOC)) {
											$nom=$ligne['nom'];
											$id=$ligne['id'];
											echo '<option value="?page='.$id.'">'.$nom.'</option>';
										}
										echo '</select>';
										echo ' / ';
										echo '<select name="jumpMenu" id="jumpMenu" onchange="MM_jumpMenu(\'parent\',this,0)">';
										$sql="SELECT nom FROM regions WHERE id='".$_GET['page']."'";
										$result = mysql_query($sql, $link);
										$ligne = mysql_fetch_array($result, MYSQL_ASSOC);
										$nom=$ligne['nom'];
										echo '<option value="?page='.$nom.'">'.$nom.'</option>';
										$sql="SELECT id, nom FROM regions WHERE id_parent='$id_parent' ORDER BY nom ASC";
										$result = mysql_query($sql, $link);
										while ($ligne = mysql_fetch_array($result, MYSQL_ASSOC)) {
											$nom=$ligne['nom'];
											$id=$ligne['id'];
											echo '<option value="?page='.$id.'">'.$nom.'</option>';
										}
										echo '</select>';
									}
									
								} else {
									$ext = ".";
  									$position_ext = strpos($_GET['page'], $ext);
									$nom = substr($_GET['page'], 0, $position_ext);
									echo '<select name="jumpMenu" id="jumpMenu" onchange="MM_jumpMenu(\'parent\',this,0)"><option value="?page='.$_GET['page'].'">'.$nom.'</option><option value="?page=texte accueil.php">texte accueil</option><option value="?page=petit texte accueil1.php">petit texte accueil1</option><option value="?page=petit texte accueil2.php">petit texte accueil2</option><option value="?page=petit texte accueil3.php">petit texte accueil3</option><option value="?page=axe1.php">axe1</option><option value="?page=axe2.php">axe2</option><option value="?page=axe3.php">axe3</option><option value="?page=axe4.php">axe4</option><option value="?page=axe5.php">axe5</option><option value="?page=outils.php">outils</option><option value="?page=mentions.php">mentions</option><option value="?page=mali.php">mali</option><option value="?page=mauritanie.php">mauritanie</option><option value="?page=senegal.php">s&eacute;n&eacute;gal</option></select>';
								}
								
							}
                            if (isset($_GET['suppr'])) echo '<br /><br />&nbsp;<span class="petit_rouge" style="border:1px solid #FFF;padding:5px;background:red;color:#FFF;width:500px;font-weight:bolder;font-size:12px;padding-left:20px;padding-right:20px;">La page a été supprimée</span>';
                            ?>
                        </p>
            		</td>
                 </tr>
             </table>
        </form>
</div>	
<?php
if (isset($_GET['page'])) {
	if (is_numeric($_GET['page'])) {
		$sql="SELECT nom FROM regions WHERE id='".$_GET['page']."'";
		$result = mysql_query($sql, $link);
		$ligne = mysql_fetch_array($result, MYSQL_ASSOC);
		$nom=$ligne['nom'];
	} else $nom=$_GET['page'];
	if (is_numeric($_GET['page'])) echo '<div id="content"><div id="titre_page"><table style="margin:auto;"><tr><td><p>Modification de la page '.$nom.'</td><td id="suppr"><a href="#" class="suppr" onClick="supprimer('.$_GET['page'].');return false;">Supprimer</a></td></tr></table></span></p></div>';
	else echo '<div id="content"><div id="titre_page"><p>Modification de la page '.$nom.'</p></div>';
	
	
	if (isset($_GET['suppr'])) {
		$sql="SELECT id_parent,id_page FROM regions WHERE id='".$_GET['page']."'";
		$result = mysql_query($sql, $link);
		$ligne = mysql_fetch_array($result, MYSQL_ASSOC);
		$id_parent=$ligne['id_parent'];
		$id_page=$ligne['id_page'];
		$sql="SELECT id_page FROM regions WHERE id_page='".$id_parent."'";
		$result = mysql_query($sql, $link);
		if (mysql_num_rows($result)>0) {
			// C'est une commune
			$sql="DELETE FROM regions WHERE id='".$_GET['page']."'";
			$result = mysql_query($sql, $link);
		} else {
			// C'est une région
			$sql="DELETE FROM regions WHERE id='".$_GET['page']."'";
			$result = mysql_query($sql, $link);
			
			$sql="SELECT id_page FROM regions WHERE id_parent='".$id_page."'";
			$result = mysql_query($sql, $link);
			while ($ligne = mysql_fetch_array($result, MYSQL_ASSOC)) {
				$id_page_enfant=$ligne['id_page'];
				$sql2="DELETE FROM content WHERE id='".$id_page_enfant."'";
				$result2 = mysql_query($sql2, $link);
				
			}
			$sql="DELETE FROM regions WHERE id_parent='".$id_page."'";
			$result = mysql_query($sql, $link);
			$sql="DELETE FROM content WHERE id='".$id_page."'";
			$result = mysql_query($sql, $link);
		}
		header("location:?suppr=".$_GET['page']);
	} else if (isset($_POST['new_region'])) {
		$new_region=$_POST['new_region'];
		$sql="SELECT id FROM content WHERE page='".$_GET['page']."'";
		$result = mysql_query($sql, $link);
		$ligne = mysql_fetch_array($result, MYSQL_ASSOC);
		$id_parent=$ligne['id'];
		$sql="INSERT INTO content VALUES ('','','','')";
		$result = mysql_query($sql, $link);
		$id_page =  mysql_insert_id();
		$sql="INSERT INTO regions VALUES ('','$id_parent','$id_page','$new_region')";
		$result = mysql_query($sql, $link);
		header("location:?page=".$_GET['page']."&new_region=".$new_region);
	} else if (isset($_POST['new_commune'])) {
		$new_commune=$_POST['new_commune'];
		$sql="SELECT id_page FROM regions WHERE id='".$_GET['page']."'";
		$result = mysql_query($sql, $link);
		$ligne = mysql_fetch_array($result, MYSQL_ASSOC);
		$id_parent=$ligne['id_page'];
		$sql="INSERT INTO content VALUES ('','','','')";
		$result = mysql_query($sql, $link);
		$id_page =  mysql_insert_id();
		$sql="INSERT INTO regions VALUES ('','$id_parent','$id_page','$new_commune')";
		$result = mysql_query($sql, $link);
		header("location:?page=".$_GET['page']."&new_commune=".$new_commune);
	} else if (isset($_POST['text'])) {
		$text = stripslashes( $_POST['text']);
		if (isset($_POST['pieces'])) $pieces = stripslashes( $_POST['pieces']);
		else $pieces='';
		if (isset($_GET['sauv'])) {
			if (!is_numeric($_GET['page'])) {
				$sql="UPDATE content SET text='".mysql_real_escape_string(stripslashes(trim(stripslashes($text))))."', pieces='".mysql_real_escape_string(stripslashes(trim(stripslashes($pieces))))."' WHERE page='".$_GET['page']."'";
				$result = mysql_query($sql, $link);
			} else {
				$sql="SELECT id_page FROM regions WHERE id='".$_GET['page']."'";
				$result = mysql_query($sql, $link);
				$ligne = mysql_fetch_array($result, MYSQL_ASSOC);
				$id_page=$ligne['id_page'];
				$sql="UPDATE content SET text='".mysql_real_escape_string(stripslashes(trim(stripslashes($text))))."', pieces='".mysql_real_escape_string(stripslashes(trim(stripslashes($pieces))))."' WHERE id='".$id_page."'";
				$result = mysql_query($sql, $link);
			}
			header("location:?modif_ok=".$_GET['page']);
		} else if (isset($_GET['modif'])) {
				echo '<table><tr><td><form action="?page='.$_GET['page'].'" method="post">';
				$oFCKeditor = new FCKeditor('text') ;
				$oFCKeditor->BasePath = 'fckeditor/' ;
				$oFCKeditor->Config['EnterMode'] = 'br';
				$oFCKeditor->Value = stripslashes($text) ;
				$oFCKeditor->Width = '600' ;
				$oFCKeditor->Height = '600' ;
				$oFCKeditor->Create() ;
				echo '<br /><input type="submit" value="Prévisualisation" /></td>';
				if (isset($_POST['pieces'])) {
					echo '<td id="prev"><p id="prev">Pi&egrave;ces disponibles<br />en téléchargement :</p>';
					$oFCKeditor = new FCKeditor('pieces') ;
					$oFCKeditor->BasePath = 'fckeditor2/' ;
					$oFCKeditor->Config['EnterMode'] = 'br';
					$oFCKeditor->Value = stripslashes($pieces) ;
					$oFCKeditor->Width = '760' ;
					$oFCKeditor->Height = '300' ;
					$oFCKeditor->Create() ;
					echo '</td>';
				}
				$sql="SELECT id_parent FROM regions WHERE id='".$_GET['page']."'";
				$result = mysql_query($sql, $link);
				$ligne = mysql_fetch_array($result, MYSQL_ASSOC);
				$id_parent=$ligne['id_parent'];
				$sql="SELECT id_page FROM regions WHERE id_page='".$id_parent."'";
				$result = mysql_query($sql, $link);
				if (mysql_num_rows($result)==0 && $_GET['page']!='axe1.php' && $_GET['page']!='axe2.php' && $_GET['page']!='axe3.php' && $_GET['page']!='axe4.php' && $_GET['page']!='axe5.php' && $_GET['page']!='texte accueil.php' && $_GET['page']!='petit texte accueil1.php' &&$_GET['page']!='petit texte accueil2.php' &&$_GET['page']!='petit texte accueil3.php') {
					// C'est une région
					echo '</form><form action="?page='.$_GET['page'].'" method="post"><td id="prev"><p id="prev2">Selectionnez une r&eacute;gion pour la modifier :<br /><select name="jumpMenu" id="jumpMenu" onchange="MM_jumpMenu(\'parent\',this,0)"><option></option>';
					$sql="SELECT id FROM content WHERE page='".$_GET['page']."'";
					$result = mysql_query($sql, $link);
					$ligne = mysql_fetch_array($result, MYSQL_ASSOC);
					$id_parent=$ligne['id'];
					$sql="SELECT id, nom FROM regions WHERE id_parent='$id_parent' ORDER BY nom ASC";
					$result = mysql_query($sql, $link);
					while ($ligne = mysql_fetch_array($result, MYSQL_ASSOC)) {
						$nom=$ligne['nom'];
						$id=$ligne['id'];
						echo '<option value="?page='.$id.'">'.$nom.'</option>';
					}
					echo '</select></p><p id="prev2">+ Ajouter une région +</p> <table id="ajout_region"><tr><td><input type="text" class="input_region" name="new_region" /></td><td><input type="submit" class="input_region2" value="Ajouter" />';
					echo '</td></tr>';
					if (isset($_GET['new_region'])) echo '<tr><td><span class="petit_rouge">&nbsp;La nouvelle r&eacute;gion a &eacute;t&eacute; cr&eacute;&eacute;e</span></td>';
				}
				echo '</tr></table></form>';
				
		} else {
			echo '<table>
						<tr>
							<td>
								<div id="prev_text">
									'.$text.'
								</div>
								<div>
									<form action="?page='.$_GET['page'].'&modif" method="post">
										<input type="submit" value="Modifier" class="" />
										<input type="hidden" name="text" value="'.htmlspecialchars($_POST['text']).'" />';
										if (isset($_POST['pieces'])) echo '<input type="hidden" name="pieces" value="'.htmlspecialchars($_POST['pieces']).'" /><br />';
										echo '</form>
									<form action="?page='.$_GET['page'].'&sauv" method="post">
										<input type="submit" value="Sauvegarder les changements" />
										<input type="hidden" name="text" value="'.htmlspecialchars($_POST['text']).'" />';
										if (isset($_POST['pieces'])) echo '<input type="hidden" name="pieces" value="'.htmlspecialchars($_POST['pieces']).'" />
									</form>
								</div>
							</td>';
							if (isset($_POST['pieces'])) echo '<td id="prev">
								<p id="prev">Pi&egrave;ces disponibles<br />en téléchargement :</p>
								<div id="prev_pieces">
									'.$pieces.'
								</div>
							</td>';
						echo '</tr>
					</table>';
		}
	} else {
		if (!is_numeric($_GET['page'])) {
			$sql="SELECT text,pieces FROM content WHERE page='".$_GET['page']."'";
			$result = mysql_query($sql, $link);
			if (mysql_num_rows($result)==0) {
				$sql="INSERT INTO content VALUES ('','".$_GET['page']."','','')";
				$result = mysql_query($sql, $link);
				$text='';
				$pieces='';
			} else {
				$ligne = mysql_fetch_array($result, MYSQL_ASSOC);
				$text=$ligne['text'];
				$pieces=$ligne['pieces'];
			}
		} else {
			$sql="SELECT id_page FROM regions WHERE id='".$_GET['page']."'";
			$result = mysql_query($sql, $link);
			$ligne = mysql_fetch_array($result, MYSQL_ASSOC);
			$id_page=$ligne['id_page'];
			$sql="SELECT text,pieces FROM content WHERE id='".$id_page."'";
			$result = mysql_query($sql, $link);
			$ligne = mysql_fetch_array($result, MYSQL_ASSOC);
			$text=$ligne['text'];
			$pieces=$ligne['pieces'];
		}
		echo '<table><tr><td><form action="?page='.$_GET['page'].'" method="post">';
		$oFCKeditor = new FCKeditor('text') ;
		$oFCKeditor->BasePath = 'fckeditor/' ;
		$oFCKeditor->Config['EnterMode'] = 'br';
		$oFCKeditor->Value = $text ;
		$oFCKeditor->Width = '600' ;
		$oFCKeditor->Height = '600' ;
		$oFCKeditor->Create() ;
		if ($_GET['page']=='mali.php' || $_GET['page']=='mauritanie.php' || $_GET['page']=='senegal.php') {
			echo '<br /><input type="submit" value="Prévisualisation" /></form><form action="?page='.$_GET['page'].'" method="post"></td><td id="prev"><p id="prev2">Selectionnez une r&eacute;gion pour la modifier :<br /><select name="jumpMenu" id="jumpMenu" onchange="MM_jumpMenu(\'parent\',this,0)"><option></option>';
			$sql="SELECT id FROM content WHERE page='".$_GET['page']."'";
			$result = mysql_query($sql, $link);
			$ligne = mysql_fetch_array($result, MYSQL_ASSOC);
			$id_parent=$ligne['id'];
			$sql="SELECT id, nom FROM regions WHERE id_parent='$id_parent' ORDER BY nom ASC";
			$result = mysql_query($sql, $link);
			while ($ligne = mysql_fetch_array($result, MYSQL_ASSOC)) {
				$nom=$ligne['nom'];
				$id=$ligne['id'];
				echo '<option value="?page='.$id.'">'.$nom.'</option>';
			}
			echo '</select></p><p id="prev2">+ Ajouter une région +</p> <table id="ajout_region"><tr><td><input type="text" class="input_region" name="new_region" /></td><td><input type="submit" class="input_region2" value="Ajouter" />';
			echo '</td></tr>';
			echo '</table></form>';
		} else if ($_GET['page']=='mentions.php') {
			echo '<br /><input type="submit" value="Prévisualisation" /></form><form action="?page='.$_GET['page'].'" method="post"></td></tr>';
			echo '</table></form>';
		} else if (is_numeric($_GET['page'])) {
			echo '<br /><input type="submit" value="Prévisualisation" />';
			$sql="SELECT id_parent FROM regions WHERE id='".$_GET['page']."'";
			$result = mysql_query($sql, $link);
			$ligne = mysql_fetch_array($result, MYSQL_ASSOC);
			$id_parent=$ligne['id_parent'];
			$sql="SELECT id_page FROM regions WHERE id_page='".$id_parent."'";
			$result = mysql_query($sql, $link);
			if (mysql_num_rows($result)>0) {
				// C'est une commune
				echo '</td><td id="prev"><p id="prev">Pi&egrave;ces disponibles<br />en téléchargement :</p>';
				$oFCKeditor = new FCKeditor('pieces') ;
				$oFCKeditor->BasePath = 'fckeditor2/' ;
				$oFCKeditor->Config['EnterMode'] = 'br';
				$oFCKeditor->Value = $pieces ;
				$oFCKeditor->Width = '760' ;
				$oFCKeditor->Height = '300' ;
				$oFCKeditor->Create() ;
				echo '</td></tr></table></form>';
			} else {
				echo '</form><form action="?page='.$_GET['page'].'" method="post"></td><td id="prev"><p id="prev2">Selectionnez une commune pour la modifier :<br /><select name="jumpMenu" id="jumpMenu" onchange="MM_jumpMenu(\'parent\',this,0)"><option></option>';
				$sql="SELECT id_page FROM regions WHERE id='".$_GET['page']."'";
				$result = mysql_query($sql, $link);
				$ligne = mysql_fetch_array($result, MYSQL_ASSOC);
				$id_parent=$ligne['id_page'];
				$sql="SELECT id, nom FROM regions WHERE id_parent='$id_parent' ORDER BY nom ASC";
				$result = mysql_query($sql, $link);
				while ($ligne = mysql_fetch_array($result, MYSQL_ASSOC)) {
					$nom=$ligne['nom'];
					$id=$ligne['id'];
					echo '<option value="?page='.$id.'">'.$nom.'</option>';
				}
				echo '</select></p><p id="prev2">+ Ajouter une commune +</p> <table id="ajout_region"><tr><td><input type="text" class="input_region" name="new_commune" /></td><td><input type="submit" class="input_region2" value="Ajouter" />';
				echo '</td></tr>';
				echo '</table></form>';
			}
		} else if ($_GET['page']=='petit texte accueil3.php' || $_GET['page']=='texte accueil.php' || $_GET['page']=='petit texte accueil1.php' || $_GET['page']=='petit texte accueil2.php') {
			echo '<br /><input type="submit" value="Prévisualisation" /></td></tr></table></form>';
		
		} else {
			echo '<br /><input type="submit" value="Prévisualisation" /></td><td id="prev"><p id="prev">Pi&egrave;ces disponibles<br />en téléchargement :</p>';
			$oFCKeditor = new FCKeditor('pieces') ;
			$oFCKeditor->BasePath = 'fckeditor2/' ;
			$oFCKeditor->Config['EnterMode'] = 'br';
			$oFCKeditor->Value = $pieces ;
			$oFCKeditor->Width = '760' ;
			$oFCKeditor->Height = '300' ;
			$oFCKeditor->Create() ;
			echo '</td></tr></table></form>';
		}
	}
	if (isset($_GET['modif_ok'])) {
		if (is_numeric($_GET['modif_ok'])) {
			$sql="SELECT nom FROM regions WHERE id='".$_GET['modif_ok']."'";
			$result = mysql_query($sql, $link);
			$ligne = mysql_fetch_array($result, MYSQL_ASSOC);
			$nom=$ligne['nom'];
		} else $nom=$_GET['modif_ok'];
        echo '<br /><br />&nbsp;<span class="petit_rouge" style="border:2px solid #FFF;padding:5px;background:red;color:#FFF;width:500px;font-weight:bolder;font-size:12px;padding-left:20px;padding-right:20px;">La page \''.$nom.'\' a été modifiée et publiée</span>';
    }
	if (isset($_GET['new_commune'])) echo '<br /><br />&nbsp;<span class="petit_rouge" style="border:2px solid #FFF;padding:5px;background:red;color:#FFF;width:500px;font-weight:bolder;font-size:12px;padding-left:20px;padding-right:20px;">La commune \''.$_GET['new_commune'].'\' a été créée</span>';
	if (isset($_GET['new_region'])) echo '<br /><br />&nbsp;<span class="petit_rouge" style="border:1px solid #FFF;padding:5px;background:red;color:#FFF;width:500px;font-weight:bolder;font-size:12px;padding-left:20px;padding-right:20px;">La région \''.$_GET['new_region'].'\' a été créée</span>';
	echo '</div>';
}	
?>
</body>
</html>
<?php
	ob_end_flush();
?>