1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138
|
$szCheminLib = "../commun/include/";
include($szCheminLib."commun.inc.php");
/***************************************************************************/
/* CONNEXION BASE DE DONNEES */
/***************************************************************************/
vInitData();
if(!bConnexionBDD())
vErreurBDDHTML();
$szIdZone='EC_IMAGE';
vAuth($szIdZone, isset($aNiveauAcces));
if(isset($_REQUEST['bAjout_PM']) && $_REQUEST['bAjout_PM']=='1')
$bDroit = $aNiveauAcces[2];
else
$bDroit = $aNiveauAcces[4];
if(!$bDroit)
{
echo "Vous n'avez pas accès à cette fonctionnalité";
exit;
}
vInitParamGeneral('scripts');
$nIdElement = intval($_REQUEST['nIdElement_PM']);
$aIdClassement = $_REQUEST['nIdClassement_PM'];
/* Modification des caractéristiques de l'image */
$szQueryUp = " UPDATE `ec_image` "
." SET `img_libelle`='".$_REQUEST['szLibelle_PM']."' , "
." `img_lien`='".$_REQUEST['szLien_PM']."' "
." WHERE `img_id` ='".$nIdElement."' ";
$rResultat = mysql_query($szQueryUp, $GLOBALS['rDataBaseLinkRP']);
mysql_free_result($rResultat);
$szQuery="SELECT imgt_type_id FROM ec_image_type WHERE imgt_img_id='".$nIdElement."'";
$rResult = mysql_query($szQuery, $GLOBALS['rDataBaseLinkRP']);
if ($rResult && mysql_num_rows($rResult))
{
while($aRow = mysql_fetch_array($rResult))
{
$aImgClassement[$aRow['imgt_type_id']] =1 ;
}
mysql_free_result($rResult);
}
echo print_r($aImgClassement);
/* Récupération des classements */
$szQueryData = '';
$szQuery = " SELECT typ_libelle as szClasse, typ_id"
." FROM ec_type";
$rResult = mysql_query($szQuery,$GLOBALS['rDataBaseLinkRP']);
if ($rResult && mysql_num_rows($rResult))
{
$aIdClassement;
/* Parcours le tableau des classements*/
foreach($aIdClassement as $valeur)
{
$nIdimgtype = $valeur;
if($szQueryData != '')
$szQueryData .= ',';
$szQueryData .= "('".$nIdimgtype."' , '".$nIdElement."')";
}
}
echo print_r($aIdClassement);
echo $szQueryData;
/* recupération de l'input type file*/
$szQuery = " SELECT img_id , img_libelle FROM ec_image";
$rResult = mysql_query($szQuery,$GLOBALS['rDataBaseLinkRP']);
if ($rResult && mysql_num_rows($rResult))
{
$szNomFichier='';
$szNomFichierOld='';
while($aRow = mysql_fetch_array($rResult))
{
if($aRow['img_id'] == intval($_REQUEST['nIdElement_PM']))
$szNomFichier=$aRow['img_libelle'];
elseif($aRow['img_id'] == intval($_REQUEST['nIdElement_PM']))
$szNomFichierOld=$aRow['img_libelle'];
}
$szNomOld='../../data/ec_image/photo-'.intval($_REQUEST['nIdElement_PM']).".jpg";
$szNom='../../data/ec_image/photo-'.intval($_REQUEST['nIdElement_PM']).".jpg";
rename($szNomOld, $szNom);
mysql_free_result($rResult);
}
/* Insertion des Classements choisis dans la base*/
if(isset($_REQUEST['bAjout_PM']) && $_REQUEST['bAjout_PM']=='1')
{
$szQuery = " INSERT INTO `ec_image_type` (`imgt_type_id` , `imgt_img_id`) "
." VALUES ".$szQueryData."; ";
}
else
{
if(isset($aImgClassement[$aRow['typ_id']]) && isset($aIdClassement[$aRow['typ_id']]))
{
}
elseif (is_null($aImgClassement[$aRow['typ_id']]) && isset($aIdClassement[$aRow['typ_id']]))
{
$szQuery = " INSERT INTO `ec_image_type` (`imgt_type_id` , `imgt_img_id`) "
." VALUES ".$szQueryData."; ";
}
elseif (isset($aImgClassement[$aRow['typ_id']]) && is_null($aIdClassement[$aRow['typ_id']]))
{
$szQuery = " DELETE FROM `ec_image_type` WHERE `imgt_img_id` = '0' OR `imgt_img_id` = '".intval($_REQUEST['nIdElement_PM'])."'";
}
}
if (!mysql_query($szQuery,$GLOBALS['rDataBaseLinkRP']))
echo "erreur";
else
// header("location:../ec_image.php");
vDeconnexionBDD(); |
Partager