%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /home/alliance/domains/sedl.alnetis.fr/public_html/
Upload File :
Create Path :
Current File : /home/alliance/domains/sedl.alnetis.fr/public_html/a-ajouter_collectivite.php

<?php
include_once("inc/config.php");
include_once("inc/functions.php");
include_once("inc/session.php");
include_once("inc/init.php");

verif_co();

$ske=false;




if(isset($_POST['post']) && $_POST['post'] == 1)
{
	
	$erreur1="ok";
	$erreur2="ok";
	if (verif_lang(1)) {
		$erreur1 = $db->verif($_POST['titre_fr'], "Le titre ");
		if($this_section['profil']!=3){
			if($erreur1 == "ok") $erreur1 = $db->verif($_POST['population'], $admtext->getText("population",$_SESSION['lang']), false, false, $_SESSION['lang']);
			//if($erreur1 == "ok") $erreur1 = verifie_num($_POST['population'],$admtext->getText("population",$_SESSION['lang']), false, false, $_SESSION['lang']);
		}
	}
	if (verif_lang(2)) {
		$erreur2 = $db->verif($_POST['titre_en'], "Title");
		if($this_section['profil']!=3){
			if($erreur2 == "ok") $erreur2 = $db->verif($_POST['population'], $admtext->getText("population",$_SESSION['lang']), false, false, $_SESSION['lang']);
			//if($erreur2 == "ok") $erreur2 = verifie_num($_POST['population'],$admtext->getText("population",$_SESSION['lang']), false, false, $_SESSION['lang']);
		}
	}
	
	if($_FILES['file_1']['name']!=""){
		$extensions_ok = array('jpg', 'jpeg', 'png', 'gif');
		$typeimages_ok = array(1,2,3);
		if(!$getimagesize = getimagesize($_FILES['file_1']['tmp_name'])) {
			$erreur2= $trad->getText("The file is not a valid image");
		}
		
		// on vérifie le type de l'image
		if( (!in_array( get_extension($_FILES['file_1']['name']), $extensions_ok ))
		   or (!in_array($getimagesize[2], $typeimages_ok )))
		{
			foreach($extensions_ok as $text) { $extensions_string .= $text.', '; }
			$erreur= $trad->getText('Please select a file with this type ').substr($extensions_string, 0, -2).' !';
		}
	}
	if($_FILES['file_2']['name']!=""){
		$extensions_ok = array('jpg', 'jpeg', 'png', 'gif');
		$typeimages_ok = array(1,2,3);
		if(!$getimagesize = getimagesize($_FILES['file_2']['tmp_name'])) {
			$erreur2= $trad->getText("The file is not a valid image");
		}
		
		// on vérifie le type de l'image
		if( (!in_array( get_extension($_FILES['file_2']['name']), $extensions_ok ))
		   or (!in_array($getimagesize[2], $typeimages_ok )))
		{
			foreach($extensions_ok as $text) { $extensions_string .= $text.', '; }
			$erreur= $trad->getText('Please select a file with this type ').substr($extensions_string, 0, -2).' !';
		}
	}
	if($_FILES['file_3']['name']!=""){
		$extensions_ok = array('jpg', 'jpeg', 'png', 'gif');
		$typeimages_ok = array(1,2,3);
		if(!$getimagesize = getimagesize($_FILES['file_3']['tmp_name'])) {
			$erreur2= $trad->getText("The file is not a valid image");
		}
		
		// on vérifie le type de l'image
		if( (!in_array( get_extension($_FILES['file_3']['name']), $extensions_ok ))
		   or (!in_array($getimagesize[2], $typeimages_ok )))
		{
			foreach($extensions_ok as $text) { $extensions_string .= $text.', '; }
			$erreur= $trad->getText('Please select a file with this type ').substr($extensions_string, 0, -2).' !';
		}
	}
	if($_FILES['file_4']['name']!=""){
		$extensions_ok = array('jpg', 'jpeg', 'png', 'gif');
		$typeimages_ok = array(1,2,3);
		if(!$getimagesize = getimagesize($_FILES['file_4']['tmp_name'])) {
			$erreur2= $trad->getText("The file is not a valid image");
		}
		
		// on vérifie le type de l'image
		if( (!in_array( get_extension($_FILES['file_4']['name']), $extensions_ok ))
		   or (!in_array($getimagesize[2], $typeimages_ok )))
		{
			foreach($extensions_ok as $text) { $extensions_string .= $text.', '; }
			$erreur= $trad->getText('Please select a file with this type ').substr($extensions_string, 0, -2).' !';
		}
	}
			
	if($erreur1 == "ok" && $erreur2 == "ok")
	{
		//Photos
		
		/*if($_POST['photo1'] != null) { if($_POST['photo1'] != $this_section['photo1']) {
				$section->suppr_photo($this_section['id'], 1);
				$_POST['photo1'] = photo_move($_POST['photo1']); } }
		if($_POST['photo2'] != null) { if($_POST['photo2'] != $this_section['photo2']) {
				$section->suppr_photo($this_section['id'], 2);
				$_POST['photo2'] = photo_move($_POST['photo2']); } }
		if($_POST['photo3'] != null) { if($_POST['photo3'] != $this_section['photo3']) {
				$section->suppr_photo($this_section['id'], 3);
				$_POST['photo3'] = photo_move($_POST['photo3']); } }
		if($_POST['photo4'] != null) { if($_POST['photo4'] != $this_section['photo4']) {
				$section->suppr_photo($this_section['id'], 4);
				$_POST['photo4'] = photo_move($_POST['photo4']); } }
			
		if($_POST['photo1'] == null) { $_POST['photo1'] = $this_section['photo1']; }
		if($_POST['photo2'] == null) { $_POST['photo2'] = $this_section['photo2']; }
		if($_POST['photo3'] == null) { $_POST['photo3'] = $this_section['photo3']; }
		if($_POST['photo4'] == null) { $_POST['photo4'] = $this_section['photo4']; }
		*/
		
		if(isset($_FILES['file_1']['name']) && $_FILES['file_1']['name'] != null){
			$_POST['photo1'] = file_move("",$_FILES['file_1']['name'],$_FILES['file_1']['tmp_name']);	
		}
		if(isset($_FILES['file_2']['name']) && $_FILES['file_2']['name'] != null){
			$_POST['photo2'] = file_move("",$_FILES['file_2']['name'],$_FILES['file_2']['tmp_name']);	
		}
		if(isset($_FILES['file_3']['name']) && $_FILES['file_3']['name'] != null){
			$_POST['photo3'] = file_move("",$_FILES['file_3']['name'],$_FILES['file_3']['tmp_name']);	
		}
		if(isset($_FILES['file_4']['name']) && $_FILES['file_4']['name'] != null){
			$_POST['photo4'] = file_move("",$_FILES['file_4']['name'],$_FILES['file_4']['tmp_name']);	
		}
		if(isset($_POST['supp1']) && $_POST['supp1']) {
			photo_supp($this_section['photo1']);
			$_POST['photo1'] = null; }
		if(isset($_POST['supp2']) && $_POST['supp2']) {
			photo_supp($this_section['photo2']);
			$_POST['photo2'] = null; }
		if(isset($_POST['supp3']) && $_POST['supp3']) {
			photo_supp($this_section['photo3']);
			$_POST['photo3'] = null; }
		if(isset($_POST['supp4']) && $_POST['supp4']) {
			photo_supp($this_section['photo4']);
			$_POST['photo4'] = null; }
		
		$desc_ok=1;
		if(strip_tags($data_fr["texte"]!=strip_tags($_POST['texte_fr'])) || strip_tags($data_en["texte"]!=strip_tags($_POST['texte_en']))){
			if(!estadmin()){
				$desc_ok=0;
			}
		}
				
		
		$where = "id = ".$_GET['id'];
		$where2 = "section = ".$_GET['id'];
		// page
		$values = array(
			"population"=> $_POST['population'],
			"adresse"=> $_POST['adresse'],
			"codepostal"=> $_POST['codepostal'],
			"ville"=> $_POST['ville'],
			"site"=> $_POST['site'],
			"site2"=> $_POST['site2'],
			"site3"=> $_POST['site3'],
			"photo1" => $_POST['photo1'],
			"photo2" => $_POST['photo2'],
			"photo3" => $_POST['photo3'],
			"photo4" => $_POST['photo4'],
			"section_lang"=> $_POST['section_lang'],
			"desc_ok"=> $desc_ok
			);
		$db->update("section", $values, $where);
		
		if (estadmin()){
			$values = array (
				"pays" => $_POST['country'] );
			$db->update("section", $values, $where);
		}
		
		if (verif_lang(1)) {
			//page_fr
			$values = array (
				"titre" => $_POST['titre_fr'],
				"texte" => strip_tags($_POST['texte_fr']),
				"partenaire"=> $_POST['partenaire_fr'],
				"permalien" => cleanUrl($_POST['titre_fr']) );
			$db->update("section_lang", $values, $where2." AND lang = 1");
		}
		
		if (verif_lang(2)) {		
			//page_en
			$values = array (
				"titre" => $_POST['titre_en'],
				"texte" => strip_tags($_POST['texte_en']),
				"partenaire"=> $_POST['partenaire_en'],
				"permalien" => cleanUrl($_POST['titre_en']) );
			$db->update("section_lang", $values, $where2." AND lang = 2");
		}
		
		
		
		$yes = true;
		header("Location:editer_section.php?id=".$_GET['id']."&msg=yes");
	}
	else {
		$err = true;
	}
}




//affichage du html
include("theme/html.php");
//affichage des metas
include("theme/meta.php");
echo "\n<title>".$admtext->getText("edit_collectivity",$_SESSION['lang'])." - ".$info_titresite."</title>\n";
//affichage du header
$pagesection=true;
$sectionid=$_GET['id'];
if(estadmin()) include("theme/header_admin.php");
else include("theme/header_redacteur.php");


$this_edition=$edition->getCurrentEdition($aff="ins",$_SESSION['lang']);


?>

<div class="text_admin">
<h2><?=$admtext->getText("edit_collectivity",$_SESSION['lang'])?></h2>

<div id="test"></div>

<?php
if(isset($_GET['msg']) && $_GET['msg']=="yes") {
	echo "<p class=\"infobloc\">Opération effectuée</p>";
}

?>



<?php
if(isset($err) && $err) {
	if (verif_lang(1)) {
		echo "<p class=\"erreurbloc\">".$erreur1."</p>";
	}
	else {
		echo "<p class=\"erreurbloc\">".$erreur2."</p>";
	}
}
if(isset($yes) && $yes) {
	echo "<p class=\"infobloc\">Opération effectuée</p>";
}
?>


<div class="tablepourcent">

<form action="admin/modifier_collectivite.php?id=<?php echo $_GET['id']; ?>" enctype="multipart/form-data" method="post" class="form">
	<table>
		<?if (estadmin() || $_SESSION['type']==3) : ?>
		<? $query="SELECT * FROM user WHERE section=".$_GET['id'];
				
		$contacts=$db->select_arrays($query);
		foreach($contacts as $uncontact):?>
			<h3>Personne de contact :</h3>
			<?=$uncontact['prenom']?> <?=$uncontact['nom']?><br/>
			Email : <a href="mailto:<?=$uncontact['email']?>"><?=$uncontact['email']?></a><br/>
			Fonction : <?=$uncontact['fonction']?><br/>
			Tel  : <?=$uncontact['telephone']?><br/>
			Service chargé des activités : <?=$uncontact['service']?><br/>
			<a href="admin/modifier_user.php?id=<?=$uncontact['id']; ?>">Editer</a>
		<? endforeach; ?>
		
		<tr>
			<td class="label"></td>
			<td class="field head">Français</td>
			<td class="field head">Anglais</td>
		</tr>
		<? endif; ?>
		<tr>
			<td class="label"><?=$admtext->getText("community_name",$_SESSION['lang'])?> <span class="etoile">*</span></td>
			<?if(verif_lang(1)):?><td class="field"><input type="text" name="titre_fr" value="<?php echo $_POST['titre_fr']; ?>" /></td><?endif;?>
			<?if(verif_lang(2)):?><td class="field"><input type="text" name="titre_en" value="<?php echo $_POST['titre_en']; ?>" /></td><?endif;?>
		</tr>
		<tr>
			<td class="label"></td>
			<td class="field" colspan="2">
				<div id="toolbar"></div>
			</td>
		</tr>
		<tr>
			<td class="label top"><?=$admtext->getText("description",$_SESSION['lang'])?> <span class="etoile">*</span></td>
			<?if(verif_lang(1)):?><td class="field top texte_fr"><textarea name="texte_fr"><?=strip_tags(html_entity_decode($_POST['texte_fr']))?></textarea>
			<!--<p><span class="res_fr"></span> restants</p>--></td><? endif; ?>
			
			<?if(verif_lang(2)):?><td class="field top texte_en"><textarea name="texte_en"><?=strip_tags(html_entity_decode($_POST['texte_en']))?></textarea>
			<!--<p><span class="res_en"></span> restants</p>--></td><? endif; ?>
			<script type="text/javascript">
				// $('.texte_fr textarea').keypress(function(e) {
					// var tval = $('.texte_fr textarea').val(),
						// tlength = tval.length,
						// set = 900,
						// remain = parseInt(set - tlength);
					// $('.res_fr').text(remain);
					// if (remain <= 0 && e.which !== 0 && e.charCode !== 0) {
						// $('.texte_fr textarea').val((tval).substring(0, tlength - 1));
					// }
				// });
				// $('.texte_fr textarea').change(function(e) {
					// var tval = $('.texte_fr textarea').val(),
						// tlength = tval.length,
						// set = 900,
						// remain = parseInt(set - tlength);
					// if (remain <= 0) {
						// $('.texte_fr textarea').val((tval).substring(0, set));
						// remain = 0;
					// }
					// $('.res_fr').text(remain);
				// });
				// $('.res_fr').text(parseInt(900 - $('.texte_fr textarea').val().length));
				
				// $('.texte_en textarea').keypress(function(e) {
					// var tval = $('.texte_en textarea').val(),
						// tlength = tval.length,
						// set = 900,
						// remain = parseInt(set - tlength);
					// $('.res_en').text(remain);
					// if (remain <= 0 && e.which !== 0 && e.charCode !== 0) {
						// $('.texte_en textarea').val((tval).substring(0, tlength - 1));
					// }
				// });
				// $('.texte_en textarea').change(function(e) {
					// var tval = $('.texte_en textarea').val(),
						// tlength = tval.length,
						// set = 900,
						// remain = parseInt(set - tlength);
					// if (remain <= 0) {
						// $('.texte_en textarea').val((tval).substring(0, set));
						// remain = 0;
					// }
					// $('.res_en').text(remain);
				// });
				// $('.res_en').text(parseInt(900 - $('.texte_en textarea').val().length));
				<?php if (!estadmin()) { ?>
				// $(".form").submit(function(e){
					// if(parseInt(900 - $('.texte_en textarea').val().length)<=0 || parseInt(900 - $('.texte_fr textarea').val().length)<=0){
						// alert("La description est trop longue");
						// e.preventDefault();
						// return false;
					// }
					// return true;
					
				// });
				<?php } ?>
			</script>
		</tr>
		<?if (estadmin()): ?>
			<tr>
				<td class="label">Pays </td>
				<td class="field">
					<select name="country">
						<?=$pays->getCountry($lang->getlangid(),$_POST['country'])?>
					</select>
				</td>
			</tr>
			<tr>
				<td class="label">Langue  </td>
				<td class="field">
					<select name="section_lang">
						<option value="0">Non définie</option>
						<? $query="SELECT * FROM lang ORDER BY nom";
						$langues=$db->select_arrays($query);
						foreach ($langues as $unelangue):?>
							<option <?=($unelangue["id"]==$_POST['section_lang']?'selected="selected"':"")?> value="<?=$unelangue["id"]?>"><?=$unelangue["nom"]?></option>
						<? endforeach;?>
					</select>
					(langue locale de la collectivité pour contenu supplémentaire dans cette langue, ne pas remplir si anglais ou français)
				</td>
			</tr>
		<? endif; ?>
		<tr>
			<td class="label"><?=$admtext->getText("address",$_SESSION['lang'])?> </td>
			<td class="field"><input type="text" name="adresse" value="<?php echo $_POST['adresse']; ?>" /></td>		
		</tr>
		<tr>
			<td class="label"><?=$admtext->getText("codepostal",$_SESSION['lang'])?> </td>
			<td class="field"><input type="text" name="codepostal" value="<?php echo $_POST['codepostal']; ?>" /></td>		
		</tr>
		<tr>
			<td class="label"><?=$admtext->getText("ville",$_SESSION['lang'])?> </td>
			<td class="field"><input type="text" name="ville" value="<?php echo $_POST['ville']; ?>" /></td>		
		</tr>
		<?if($this_section['profil']!=3): ?>
			<tr>
				<td class="label"><?=$admtext->getText("population",$_SESSION['lang'])?> </td>
				<td class="field"><input type="text" name="population" value="<?php echo $_POST['population']; ?>" /></td>		
			</tr>
		<? endif; ?>
		<tr>
			<td colspan="3" class="label"><?=$admtext->getText("question_colpartner",$_SESSION['lang'])?> </td>
		</tr>
		
		<tr>
			<td></td>
			<?if(verif_lang(1)):?><td class="field"><input type="text" name="partenaire_fr" value="<?php echo $_POST['partenaire_fr']; ?>" /></td><?endif;?>
			<?if(verif_lang(2)):?><td class="field"><input type="text" name="partenaire_en" value="<?php echo $_POST['partenaire_en']; ?>" /></td><?endif;?>			
		</tr>
		<tr>
			<td class="label"><?=$admtext->getText("website",$_SESSION['lang'])?></td>
			<td class="field"><input type="text" name="site" value="<?php echo $_POST['site']; ?>" /></td>		
		</tr>
		<tr>
			<td class="label"><?=$admtext->getText("website",$_SESSION['lang'])?> 2</td>
			<td class="field"><input type="text" name="site2" value="<?php echo $_POST['site2']; ?>" /></td>		
		</tr>
		<tr>
			<td class="label"><?=$admtext->getText("website",$_SESSION['lang'])?> 3</td>
			<td class="field"><input type="text" name="site3" value="<?php echo $_POST['site3']; ?>" /></td>		
		</tr>
		
		<tr class="news">
			<td class="label top"><?=$admtext->getText("main_picture",$_SESSION['lang'])?></td>
			<td class="field"><input type="file" name="file_1" id="file_1" /><?php if($_POST['photo1']) echo '<div class="uploadifyQueueItem completed"><div class="cancel"><input type="checkbox" class="radio supphoto" name="supp1" id="supp1"> <label for="supp1">Supprimer</label></div><a href="uploads/'.$_POST['photo1'].'" class="zoom">'.$_POST['photo1'].'</a></div> '; ?></td>
			<td class="field"><input type="hidden" name="photo1" id="photo1" value="<?php echo $_POST['photo1']; ?>" /></td>
		</tr>
		<tr class="news">
			<td class="label top"><?=$admtext->getText("picture",$_SESSION['lang'])?> n°2</td>
			<td class="field"><input type="file" name="file_2" id="file_2" /><?php if($_POST['photo2']) echo '<div class="uploadifyQueueItem completed"><div class="cancel"><input type="checkbox" class="radio supphoto" name="supp2" id="supp2"> <label for="supp2">Supprimer</label></div><a href="uploads/'.$_POST['photo2'].'" class="zoom">'.$_POST['photo2'].'</a></div> '; ?></td>
			<td class="field"><input type="hidden" name="photo2" id="photo2" value="<?php echo $_POST['photo2']; ?>" /></td>
		</tr>
		<tr class="news">
			<td class="label top"><?=$admtext->getText("picture",$_SESSION['lang'])?> n°3</td>
			<td class="field"><input type="file" name="file_3" id="file_3" /><?php if($_POST['photo3']) echo '<div class="uploadifyQueueItem completed"><div class="cancel"><input type="checkbox" class="radio supphoto" name="supp3" id="supp3"> <label for="supp3">Supprimer</label></div><a href="uploads/'.$_POST['photo3'].'" class="zoom">'.$_POST['photo3'].'</a></div> '; ?></td>
			<td class="field"><input type="hidden" name="photo3" id="photo3" value="<?php echo $_POST['photo3']; ?>" /></td>
		</tr>
		<tr class="news">
			<td class="label top"><?=$admtext->getText("picture",$_SESSION['lang'])?> n°4</td>
			<td class="field"><input type="file" name="file_4" id="file_4" /><?php if($_POST['photo4']) echo '<div class="uploadifyQueueItem completed"><div class="cancel"><input type="checkbox" class="radio supphoto" name="supp4" id="supp4"> <label for="supp4">Supprimer</label></div><a href="uploads/'.$_POST['photo4'].'" class="zoom">'.$_POST['photo4'].'</a></div> '; ?></td>
			<td class="field"><input type="hidden" name="photo4" id="photo4" value="<?php echo $_POST['photo4']; ?>" /></td>
		</tr>
		<tr>
			<td class="label top"> </td>
			<td class="field" colspan="2"><?=$admtext->getText("avert_responsable",$_SESSION['lang'])?></td>
		</tr>

	</table>
	<div class="form_bouton">
		<input type="hidden" name="post" value="1" />
		<input type="submit" class="bouton" id="maj_bouton" value="<?=$admtext->getText("edit_collectivity",$_SESSION['lang'])?>" />
		<?if (estadmin() && !$section->isValid($_GET['id'],$this_edition['id'])) : ?>
			<a href="admin/valider_section.php?id=<?php echo $_GET['id']; ?>&edition=<?=$this_edition['id']?>" class="bouton" />Valider la collectivité</a>
		<? endif;?>
		
		<?if (estadmin() && $this_section['desc_ok']==0) : ?>
			<a href="admin/valider_desc.php?id=<?php echo $_GET['id']; ?>&edition=<?=$this_edition['id']?>" class="bouton" />Valider la description</a>
		<? endif;?>
		
	</div>
</form>
</div>

<?

//affichage du footer
include("theme/footer.php");

?>

Zerion Mini Shell 1.0