<?php

session_start();
error_reporting(0);

include("adminheader.php");

//dictionnaire specifique au module
  include("../langages/$SESSION_LANGSKIN/admin_rss.php");

// donnees titre et liens modules
//-------------------------------
$imgmodule="rss.gif";
$titremodule="$LG_MODUSYNDIC";
$descriptionmodule="$LG_MODUSYNDICDES";


/*****************************************************************************************
                          Artiphp Velocity 3 - la base
               copyright : Ronald Guérin - webmaster@artiloo.com
                            http://www.artiloo.com
                      Dernière mise à jour : 20 octobre 2004
******************************************************************************************/

/*****************************************************************************************
 Artiphp, portail CMS pour la création de sites dynamiques

 Copyright (C) 2003 Ronald Guérin - webmaster@artiloo.com

 Ce programme est un logiciel libre ; vous pouvez le redistribuer et/ou le modifier
 conformément aux dispositions de la Licence Publique Générale GNU, telle que publiée
 par la Free Software Foundation ; version 2 de la licence, ou encore (à votre choix)
 toute version ultérieure.

 Ce programme est distribué dans l'espoir qu'il sera utile, mais SANS AUCUNE GARANTIE ;
 sans même la garantie implicite de COMMERCIALISATION ou D'ADAPTATION A UN OBJET PARTICULIER.
 Pour plus de détail, voir la Licence Publique Générale GNU .

 Vous devez avoir reçu un exemplaire de la Licence Publique Générale GNU en même temps que
 ce programme ; si ce n'est pas le cas, écrivez à la Free Software Foundation Inc.,
 675 Mass Ave, Cambridge, MA 02139, Etats-Unis.

 Pour plus d'informations sur Artiphp :
 http://www.artiloo.com - webmaster@artiloo.com
******************************************************************************************/

//autorisation d'ouverture de cette page uniquement aux status autorisés
//----------------------------------------------------------------------

   if ($_SESSION['SESSION_STATUT']!="artadmin") {
     header("Location: ../outils/erreur.php?ec=2");
     exit();
   }


//affichage des fichiers de syndication pour traitement ulterieur
//--------------------------------------------------

  $style[0]="class=\"entete2\"";
  $style[1]="class=\"entete\"";
  $i=1;

  $requete="select * from ".$extension."syndic";
  $result=mysql_query($requete, $link);

  $listesindic="";
  while ($sind=mysql_fetch_object($result)) {
    $listesindic .= "<tr ".$style[$i++%2]."><td>".$sind->urlsyndic."</td>\n";
    $listesindic .= "<td align=\"center\"> <a href=\"rssindex.php?suppid=$sind->id_syndic\" onClick=\"return confirm('$LG_SUPPRESCONF');\"><img src=\"imgadmin/bbsupp.gif\" border=\"0\" alt=\"$LG_SUPPRES\" align=\"absmiddle\"></a> </td>\n";
    $listesindic .= "</tr>\n";
  }



//----------------------------
//Supprimer un site
//----------------------------

if ($_GET['suppid']) {
  $suppid = intval($_GET['suppid']);

      $requete="delete from ".$extension."syndic where id_syndic='$suppid'";
      $result2=mysql_query($requete, $link);
      header ("Location:rssindex.php");
}

// ouverture FTP et changement de chmod du repertoire bibliotheque
   if ($_FILES['image']['type']){
	if($ftp=='1') {
	 $ftpcon = ftp_connect($ftp_host) or die('Erreur');
	 $loginresult = ftp_login($ftpcon, $ftp_login, $ftp_mdp);

	 $repertoire="".$ftp_repertoire."images";

	 //emplacement du fichier que vous voulez modifier
	 ftp_chdir($ftpcon, $repertoire) or die('Erreur dossier');

	 //changement de chmod via FTP
	 $chmod_cmd="CHMOD 0777 rss"; 
	 ftp_site($ftpcon, $chmod_cmd);
	}
    }
//----------------------------------------------------------------

//upload de la photo
//------------------

   if ($_FILES['image']['type']){
   $img=$_FILES['image']['type'];
   $nomimage=$_FILES['image']['name'];
   $tmp_file = $_FILES['image']['tmp_name'];

    if( !is_uploaded_file($tmp_file) ) {
       $meserreur2 ="<br><font color=red>$LG_UPNOFILE</font><br><br>";
    }

     $tabTypeImage = split ("/", $img);
     $typeImage = $tabTypeImage[1];

     if ($typeImage != "pjpeg" && $typeImage != "x-jpeg" && $typeImage != "jpeg" && $typeImage != "gif" && $typeImage != "x-png") {
         $meserreur2 ="<br><font color=red>$LG_UPNOFORM</font><br><br>";
     } else {

         $destination = "../images/rss/".$nomimage."";

         if (! move_uploaded_file ($tmp_file, $destination)) {
            $meserreur2 ="<br><font color=red>$LG_UPNOTRANS</font><br><br>";
            $insertimage=="";
         } else {
            $insertimage=", imagerss='$nomimage' ";
         }
     }

   }

//-------------------------
// Fermeture et remise du chmod FTP
   if ($_FILES['image']['type']){
	if($ftp=='1') {
	  $chmod_cmd="CHMOD 0755 rss"; 
	  ftp_site($ftpcon, $chmod_cmd);
	  ftp_close($ftpcon);
	}
   }
//----------------------------------


//--------------------
//formulaire de saisie
//--------------------

 /*si un champ n'est pas renseigné, message d'erreur*/

  if (! $_POST['nom'] || ! $_POST['urlsite'] || ! $_POST['nomsite']) {
   $nom = $_POST['nom'];
   $urlsite = $_POST['urlsite'];
   $nomsite = $_POST['nomsite'];
   $meserreur="<font style=\"color:red\"> $LG_FORMERROR</font>";

 /*sinon, c'est un ajout*/

  } else {

   $nom = $_POST['nom'];
   $urlsite = $_POST['urlsite'];
   $nomsite = $_POST['nomsite'];

   $requete="INSERT into ".$extension."syndic set urlsyndic='$nom', urlsiterss='$urlsite', titrerss='$nomsite'$insertimage";
   $result=mysql_query($requete, $link);

   header ("Location:rssindex.php");
   exit();

  }


mysql_free_result($result);
//-------------------------


//presentation
//-------------------

 include("header.php");
 include("menumod.php");

?>

<?php echo $LG_RSSTXT1; ?> <br>
<?php echo $LG_RSSTXT2; ?>
<img src="../backend/xml.gif"></p>



<div align="center">
<table border="0" cellpadding="5" cellspacing="1" width="97%">
<tr><td>
<p><strong><?php echo $LG_RSSAJOUT; ?></strong><?php echo $meserreur; ?>
</td></tr><tr>
<form method="POST" action="rssindex.php" enctype="multipart/form-data">
<td bgcolor="#CCCCFF" style="BORDER:#000000 1px dashed">

<b><?php echo $LG_RSSURL; ?></b> * <br>
<input type="text" name="nom" size="50" value="<?php echo $nom; ?>"></p><p>

<b><?php echo $LG_RSSURLSITE; ?></b> * <br>
<input type="text" name="urlsite" size="50" value="<?php echo $urlsite; ?>"></p><p>

<b><?php echo $LG_RSSNOMSITE; ?></b> * <br>
<input type="text" name="nomsite" size="50" value="<?php echo $nomsite; ?>"></p><p>

<b><?php echo $LG_RSSIMG; ?></b> <br>
<input name="image" type="file" size="50" value=""><br>
<input type="hidden" name="MAX_FILE_SIZE" value="15000">


<input type="submit" value="<?php echo $LG_ENVOI; ?>" name="B1"></p>
</td></form></tr></table></div>

<p>

<div align="center">
<table border="0" cellpadding="5" cellspacing="1" width="97%">
<tr><td>
<p><strong><?php echo $LG_RSSSUPP; ?></strong>
</td></tr>

<?php echo $listesindic; ?><p>

</table></div>

<p>

<div align="center">
<table border="0" cellpadding="5" cellspacing="1" width="97%">
<tr><td>
<p><strong><?php echo $LG_RSSAFF; ?></strong>
</td></tr>
<tr><td bgcolor="#CCCCFF" style="BORDER:#000000 1px dashed">

<img src="imgadmin/fleche.gif" align="absMiddle"> <b><?php echo $LG_RSSAFFCOD1; ?> </b>
<br>
<textarea rows="1" name="S1" cols="60"><a href=\"../backend/index.php\">Fils d'info</a></textarea>


<br><br>
<img src="imgadmin/fleche.gif" align="absMiddle"> <b><?php echo $LG_RSSAFFCOD2; ?> </b>
<br>
<?php echo $LG_RSSAFFCODTX; ?><br>

<textarea rows="3" name="S1" cols="60">&lt;?php $urlsy=&quot;http://www.artiloo.com/backend/dossiers.xml&quot;; include (&quot;../backend/tradentrant.php&quot;); ?&gt;</textarea>
<p><?php echo $LG_RSSAFFCODTX2; ?> $urlsy <br>

</td></tr></table></div><p>

<?php
 include("menumod2.php");
 include("footer.php");
 mysql_close();
