function PYATableMAJ($DB,$table,$typedit,$tbKeys=array()) { // construction du set, necessite uniquement le nom du champ .. $rq1=db_query("SELECT * from DESC_TABLES where NM_TABLE='$table' AND NM_CHAMP!='TABLE0COMM' AND (TYPEAFF!='HID' OR ( TT_PDTMAJ!='' AND TT_PDTMAJ!= NULL)) ORDER BY ORDAFF, LIBELLE"); $key = implode("_",$tbKeys)."_"; $tbset = array(); $tbWhK = array(); while ($res1 = db_fetch_array($rq1)) { $PYAoMAJ=new PYAobj(); // recréée l'objet pour RAZ ses propriétés !!! $PYAoMAJ->NmBase=$DB; $PYAoMAJ->NmTable=$table; $PYAoMAJ->TypEdit=$typedit; if (MaxFileSize>0) $PYAoMAJ->MaxFSize=MaxFileSize; $NOMC = $res1['NM_CHAMP']; // nom variable=nom du champ $PYAoMAJ->NmChamp = $NOMC; $PYAoMAJ->InitPO($_REQUEST[$NOMC],$res1); // init l'objet, sa valeur, lui passe le tableau d'infos du champ pr éviter une requete suppl. if (array_key_exists($NOMC,$tbKeys)) { $tbWhK = array_merge($tbWhK,$PYAoMAJ->RetSet($key."_",true)); } $PYAoMAJ->ValChp=$_REQUEST[$NOMC]; // sinon en new ca bugue if ($PYAoMAJ->TypeAff=="FICFOT") { if ($_FILES[$NOMC]['name']!="" && $_FILES[$NOMC]['error']!="0") { $error=$_FILES[$NOMC]['error']; $err_lbl="Erreur sur le champ $NOMC de type http"; } $PYAoMAJ->ValChp=($_FILES[$NOMC]['tmp_name']!="" ? $_FILES[$NOMC]['tmp_name'] : $PYAoMAJ->ValChp); $PYAoMAJ->Fok=$_REQUEST["Fok".$NOMC]; $PYAoMAJ->Fname=$_FILES[$NOMC]['name']; $PYAoMAJ->Fsize=$_FILES[$NOMC]['size']; $PYAoMAJ->OFN=$_REQUEST["Old".$NOMC]; // recup infos pour les pj dans le mail $size=($PYAoMAJ->Fsize >0 ? " (".round($PYAoMAJ->Fsize / 1000)."Ko) " : ""); $chemfich="http://".$_SERVER["SERVER_NAME"].str_replace(basename($_SERVER['SCRIPT_NAME']),"",$_SERVER['SCRIPT_NAME']).$PYAoMAJ->Valeurs; $fich=($PYAoMAJ->Fname != "" ? $key."_".$PYAoMAJ->Fname : $PYAoMAJ->ValChp); } $tbset=array_merge($tbset,$PYAoMAJ->RetSet($key."_",true)); // key sert �la gestion des fichiers li� if ($PYAoMAJ->error) { $error=true; $err_lbl="Erreur sur le champ $NOMC genree par pya :".$PYAoMAJ->error; $PYAoMAJ->error=""; } } // fin boucle sur les champs if (count($tbWhK)>0) { foreach ($tbWhK as $chp=>$val) $lchp[]=$chp."=$val"; $where= " where ".implode(" AND ",$lchp); } // GROS BUG $where=" where ".$key.($where_sup=="" ? "" : " and $where_sup"); //echovar("_REQUEST['typeditrcr']"); if ($typedit=="M") { // UPDATE $strqaj="UPDATE $table SET ".tbset2set($tbset)." $where"; } elseif ($typedit==-1) { // SUPPRESSION $strqaj="DELETE FROM $table $where"; } elseif ($typedit=="N") { //INSERTION $strqaj="INSERT INTO $table ".tbset2insert($tbset)." ON DUPLICATE KEY UPDATE ".tbset2set($tbset); } // echo "requete sql: $strqaj"; db_query($strqaj); if ($typedit == "N") return(mysql_insert_id()); }
$PYAoMAJ->Fname = $rwncs[0]; } } $tbset = array_merge($tbset, $PYAoMAJ->RetSet($keycopy, true)); // key copy sert à la gestion des fichiers liés // la gestion des fichiers est faite aussi là-dedans } // fin boucle sur les champs //echovar("tbset"); $key = stripslashes($key); if ($debug) { echo "Clé: {$key} <BR>"; } // GROS BUG $where=" where ".$key.($where_sup=="" ? "" : " and $where_sup"); $where = " where " . $key; if ($modif == 1) { $strqaj = "UPDATE " . $_REQUEST['NM_TABLE'] . " SET " . tbset2set($tbset) . " {$where}"; } else { if ($modif == -1) { $strqaj = "DELETE FROM " . $_REQUEST['NM_TABLE'] . " {$where}"; } else { // Ajout dans la table Mysql $strqaj = "INSERT INTO " . $_REQUEST['NM_TABLE'] . " " . tbset2insert($tbset); } } if ($debug) { echo "requete sql: {$strqaj}"; } msq($strqaj); header("location:" . $_REQUEST['adrr_majt']); //
if ($_REQUEST['modif'] == -1) { // suppression de l'enregistrement $rqncs = msq("select " . $PYAoMAJ->NmChamp . " from " . $PYAoMAJ->NmTable . " where " . stripslashes($_REQUEST['key'])); $rwncs = db_fetch_row($rqncs); $PYAoMAJ->Fname = $rwncs[0]; } } $tbset = array_merge($tbset, $PYAoMAJ->RetSet($keycopy, true)); // key copy sert �la gestion des fichiers li� // la gestion des fichiers est faite aussi l�dedans } // fin boucle sur les champs //echovar("tbset"); $_REQUEST['key'] = stripslashes($_REQUEST['key']); //echo "Cl� $_REQUEST['key'] <BR>"; // GROS BUG $where=" where ".$_REQUEST['key'].($where_sup=="" ? "" : " and $where_sup"); $where = " where " . $_REQUEST['key']; if ($_REQUEST['modif'] == 1) { $strqaj = "UPDATE {$CSpIC}{$NM_TABLE}{$CSpIC} SET " . tbset2set($tbset) . " {$where}"; } else { if ($_REQUEST['modif'] == -1) { $strqaj = "DELETE FROM {$CSpIC}{$NM_TABLE}{$CSpIC} {$where}"; } else { // Ajout dans la table Mysql $strqaj = "INSERT INTO {$CSpIC}{$NM_TABLE}{$CSpIC} " . tbset2insert($tbset); } } //echo "requete sql: $strqaj"; db_query($strqaj); header("location:" . ($lc_adrramact ? $lc_adrramact : ret_adrr("edit_table.php") . "?cfp=amact")); // lc_adrramact=sp�ial e-toil*/
// lc_NM_TABLE='+table+'&lc_NM_VTB2C= // $TBDname $NmChDT' if (strstr($_REQUEST['lc_NM_VTB2C'],$id_vtb)) { // verifie que le nom entré contient bien l'id de table virtuelle if ($_REQUEST['lc_NM_TABLE'] != "newvtable") { $rw=db_qr_comprass("SELECT * FROM $TBDname WHERE NM_TABLE='".$_REQUEST['lc_NM_TABLE']."'"); foreach($rw as $enr) { $enr['NM_TABLE'] = $_REQUEST['lc_NM_VTB2C']; if ($enr['NM_CHAMP']==$NmChDT) { $enr['LIBELLE'].=" ! Alias de la table : ".$_REQUEST['lc_NM_TABLE']; } else { $enr['VALEURS'] .= "\n".'$physTable='.$_REQUEST['lc_NM_TABLE']; $enr['VALEURS'] .= "\n".'$locFKeys='.$enr['NM_CHAMP']; } foreach ($enr as $chp=>$val) $enr[$chp]="'".addslashes($val)."'"; db_query("INSERT INTO $TBDname ".tbset2insert($enr)); } } else { // nvlle table virtuelle db_query("INSERT INTO $TBDname (NM_TABLE,NM_CHAMP,LIBELLE,TYPAFF_L) VALUES ('".$_REQUEST['lc_NM_VTB2C']."','TABLE0COMM','Nouvelle table virtuelle','AUT')"); } } else echo "<H1>".trad("LT_err_cvtb").$id_vtb."</H1>"; } // effacement if (isset($_REQUEST['lc_NM_VTB2D'])) { db_query("DELETE FROM $TBDname where NM_TABLE='".$_REQUEST['lc_NM_VTB2D']."'"); } ?> <? if ($admadm=="1") { // affiche les liens en orange pour bien diff�encier ?> <STYLE>