示例#1
0
 /**
 Retourne un tableau de saveurs correspondant aux champs du tableau en argument.
 @param $args
 */
 function Saveurs_chercher($args)
 {
     $count = 0;
     $tab_result = array();
     if (isset($args['count'])) {
         $sql = " SELECT count(*) nb_enregistrements \n\t\t\t\t\tFROM " . $GLOBALS['prefix'] . "saveur\n\t\t\t\t\tWHERE 1";
     } else {
         $sql = " SELECT * \n\t\t\t\t\tFROM " . $GLOBALS['prefix'] . "saveur\n\t\t\t\t\tWHERE 1";
     }
     if (!isset($args['id_saveur']) && !isset($args['pourcent_eth0_dans_arome_pur_1']) && !isset($args['pourcent_eth0_dans_arome_pur_2']) && !isset($args['pourcent_eth0_dans_arome_pur_3']) && !isset($args['pourcent_eth0_dans_arome_pur_4']) && !isset($args['pourcent_eth0_dans_arome_pur_5']) && !isset($args['pourcent_eth0_dans_arome_pur_6']) && !isset($args['pourcent_arome_pur_dans_arome_prod_1']) && !isset($args['pourcent_arome_pur_dans_arome_prod_2']) && !isset($args['pourcent_arome_pur_dans_arome_prod_3']) && !isset($args['pourcent_arome_pur_dans_arome_prod_4']) && !isset($args['pourcent_arome_pur_dans_arome_prod_5']) && !isset($args['pourcent_arome_pur_dans_arome_prod_6']) && !isset($args['pourcent_alcool_prod_dans_arome_prod']) && !isset($args['pourcent_eau_dans_arome_prod']) && !isset($args['pourcent_arome_prod_dans_e_liquide_1']) && !isset($args['pourcent_arome_prod_dans_e_liquide_2']) && !isset($args['pourcent_arome_prod_dans_e_liquide_3']) && !isset($args['etat']) && !isset($args['order_by']) && !isset($args['etat']) && !isset($args['tab_ids_saveurs'])) {
         return $tab_result;
     }
     $condition = "";
     if (isset($args['id_saveur']) && $args['id_saveur'] != "*") {
         $condition .= " AND id_saveur = '" . $args['id_saveur'] . "' ";
     }
     if (isset($args['pourcent_eth0_dans_arome_pur_1']) && $args['pourcent_eth0_dans_arome_pur_1'] != "*") {
         $condition .= " AND pourcent_eth0_dans_arome_pur_1 = '" . strtr($this->pourcent_eth0_dans_arome_pur_1, ",", ".") . "' ";
     }
     if (isset($args['pourcent_eth0_dans_arome_pur_2']) && $args['pourcent_eth0_dans_arome_pur_2'] != "*") {
         $condition .= " AND pourcent_eth0_dans_arome_pur_2 = '" . strtr($this->pourcent_eth0_dans_arome_pur_2, ",", ".") . "' ";
     }
     if (isset($args['pourcent_eth0_dans_arome_pur_3']) && $args['pourcent_eth0_dans_arome_pur_3'] != "*") {
         $condition .= " AND pourcent_eth0_dans_arome_pur_3 = '" . strtr($this->pourcent_eth0_dans_arome_pur_3, ",", ".") . "' ";
     }
     if (isset($args['pourcent_eth0_dans_arome_pur_4']) && $args['pourcent_eth0_dans_arome_pur_4'] != "*") {
         $condition .= " AND pourcent_eth0_dans_arome_pur_4 = '" . strtr($this->pourcent_eth0_dans_arome_pur_4, ",", ".") . "' ";
     }
     if (isset($args['pourcent_eth0_dans_arome_pur_5']) && $args['pourcent_eth0_dans_arome_pur_5'] != "*") {
         $condition .= " AND pourcent_eth0_dans_arome_pur_5 = '" . strtr($this->pourcent_eth0_dans_arome_pur_5, ",", ".") . "' ";
     }
     if (isset($args['pourcent_eth0_dans_arome_pur_6']) && $args['pourcent_eth0_dans_arome_pur_6'] != "*") {
         $condition .= " AND pourcent_eth0_dans_arome_pur_6 = '" . strtr($this->pourcent_eth0_dans_arome_pur_6, ",", ".") . "' ";
     }
     if (isset($args['pourcent_arome_pur_dans_arome_prod_1']) && $args['pourcent_arome_pur_dans_arome_prod_1'] != "*") {
         $condition .= " AND pourcent_arome_pur_dans_arome_prod_1 = '" . strtr($this->pourcent_arome_pur_dans_arome_prod_1, ",", ".") . "' ";
     }
     if (isset($args['pourcent_arome_pur_dans_arome_prod_2']) && $args['pourcent_arome_pur_dans_arome_prod_2'] != "*") {
         $condition .= " AND pourcent_arome_pur_dans_arome_prod_2 = '" . strtr($this->pourcent_arome_pur_dans_arome_prod_2, ",", ".") . "' ";
     }
     if (isset($args['pourcent_arome_pur_dans_arome_prod_3']) && $args['pourcent_arome_pur_dans_arome_prod_3'] != "*") {
         $condition .= " AND pourcent_arome_pur_dans_arome_prod_3 = '" . strtr($this->pourcent_arome_pur_dans_arome_prod_3, ",", ".") . "' ";
     }
     if (isset($args['pourcent_arome_pur_dans_arome_prod_4']) && $args['pourcent_arome_pur_dans_arome_prod_4'] != "*") {
         $condition .= " AND pourcent_arome_pur_dans_arome_prod_4 = '" . strtr($this->pourcent_arome_pur_dans_arome_prod_4, ",", ".") . "' ";
     }
     if (isset($args['pourcent_arome_pur_dans_arome_prod_5']) && $args['pourcent_arome_pur_dans_arome_prod_5'] != "*") {
         $condition .= " AND pourcent_arome_pur_dans_arome_prod_5 = '" . strtr($this->pourcent_arome_pur_dans_arome_prod_5, ",", ".") . "' ";
     }
     if (isset($args['pourcent_arome_pur_dans_arome_prod_6']) && $args['pourcent_arome_pur_dans_arome_prod_6'] != "*") {
         $condition .= " AND pourcent_arome_pur_dans_arome_prod_6 = '" . strtr($this->pourcent_arome_pur_dans_arome_prod_6, ",", ".") . "' ";
     }
     if (isset($args['pourcent_alcool_prod_dans_arome_prod']) && $args['pourcent_alcool_prod_dans_arome_prod'] != "*") {
         $condition .= " AND pourcent_alcool_prod_dans_arome_prod = '" . strtr($this->pourcent_alcool_prod_dans_arome_prod, ",", ".") . "' ";
     }
     if (isset($args['pourcent_eau_dans_arome_prod']) && $args['pourcent_eau_dans_arome_prod'] != "*") {
         $condition .= " AND pourcent_eau_dans_arome_prod = '" . strtr($this->pourcent_eau_dans_arome_prod, ",", ".") . "' ";
     }
     if (isset($args['pourcent_arome_prod_dans_e_liquide_1']) && $args['pourcent_arome_prod_dans_e_liquide_1'] != "*") {
         $condition .= " AND pourcent_arome_prod_dans_e_liquide_1 = '" . strtr($this->pourcent_arome_prod_dans_e_liquide_1, ",", ".") . "' ";
     }
     if (isset($args['pourcent_arome_prod_dans_e_liquide_2']) && $args['pourcent_arome_prod_dans_e_liquide_2'] != "*") {
         $condition .= " AND pourcent_arome_prod_dans_e_liquide_2 = '" . strtr($this->pourcent_arome_prod_dans_e_liquide_2, ",", ".") . "' ";
     }
     if (isset($args['pourcent_arome_prod_dans_e_liquide_3']) && $args['pourcent_arome_prod_dans_e_liquide_3'] != "*") {
         $condition .= " AND pourcent_arome_prod_dans_e_liquide_3 = '" . strtr($this->pourcent_arome_prod_dans_e_liquide_3, ",", ".") . "' ";
     }
     if (isset($args['etat']) && $args['etat'] != "*") {
         $condition .= " AND etat = '" . $args['etat'] . "' ";
     }
     if (isset($args['tab_ids_saveurs']) && $args['tab_ids_saveurs'] != "*") {
         $ids = implode(",", $args['tab_ids_saveurs']);
         $condition .= " AND id_saveur IN (0" . $ids . ") ";
     }
     if (!isset($args['etat'])) {
         $condition .= " AND etat != 'supprime' ";
     }
     $sql .= $condition;
     if (isset($args['order_by']) && !isset($args['asc_desc'])) {
         $sql .= " ORDER BY " . $args['order_by'] . " ASC";
     }
     if (isset($args['order_by']) && isset($args['asc_desc'])) {
         $sql .= " ORDER BY " . $args['order_by'] . " " . $args['asc_desc'];
     }
     if (isset($args['limit']) && !isset($args['start'])) {
         $sql .= " LIMIT " . $args['limit'];
     }
     if (isset($args['limit']) && isset($args['start'])) {
         $sql .= " LIMIT " . $args['start'] . "," . $args['limit'];
     }
     /*=============*/
     Lib_myLog("SQL: {$sql}");
     $result = Sql_query($sql);
     if (isset($args['count'])) {
         if ($result && Sql_errorCode($result) === "00000") {
             $row = Sql_fetch($result);
             $count = $row['nb_enregistrements'];
         }
         return $count;
     } else {
         if ($result && Sql_errorCode($result) === "00000") {
             while ($row = Sql_fetch($result)) {
                 $id = $row['id_saveur'];
                 $tab_result[$id]["id_saveur"] = $id;
                 $tab_result[$id]["pourcent_eth0_dans_arome_pur_1"] = $row['pourcent_eth0_dans_arome_pur_1'];
                 $tab_result[$id]["pourcent_eth0_dans_arome_pur_2"] = $row['pourcent_eth0_dans_arome_pur_2'];
                 $tab_result[$id]["pourcent_eth0_dans_arome_pur_3"] = $row['pourcent_eth0_dans_arome_pur_3'];
                 $tab_result[$id]["pourcent_eth0_dans_arome_pur_4"] = $row['pourcent_eth0_dans_arome_pur_4'];
                 $tab_result[$id]["pourcent_eth0_dans_arome_pur_5"] = $row['pourcent_eth0_dans_arome_pur_5'];
                 $tab_result[$id]["pourcent_eth0_dans_arome_pur_6"] = $row['pourcent_eth0_dans_arome_pur_6'];
                 $tab_result[$id]["pourcent_arome_pur_dans_arome_prod_1"] = $row['pourcent_arome_pur_dans_arome_prod_1'];
                 $tab_result[$id]["pourcent_arome_pur_dans_arome_prod_2"] = $row['pourcent_arome_pur_dans_arome_prod_2'];
                 $tab_result[$id]["pourcent_arome_pur_dans_arome_prod_3"] = $row['pourcent_arome_pur_dans_arome_prod_3'];
                 $tab_result[$id]["pourcent_arome_pur_dans_arome_prod_4"] = $row['pourcent_arome_pur_dans_arome_prod_4'];
                 $tab_result[$id]["pourcent_arome_pur_dans_arome_prod_5"] = $row['pourcent_arome_pur_dans_arome_prod_5'];
                 $tab_result[$id]["pourcent_arome_pur_dans_arome_prod_6"] = $row['pourcent_arome_pur_dans_arome_prod_6'];
                 $tab_result[$id]["pourcent_alcool_prod_dans_arome_prod"] = $row['pourcent_alcool_prod_dans_arome_prod'];
                 $tab_result[$id]["pourcent_eau_dans_arome_prod"] = $row['pourcent_eau_dans_arome_prod'];
                 $tab_result[$id]["pourcent_arome_prod_dans_e_liquide_1"] = $row['pourcent_arome_prod_dans_e_liquide_1'];
                 $tab_result[$id]["pourcent_arome_prod_dans_e_liquide_2"] = $row['pourcent_arome_prod_dans_e_liquide_2'];
                 $tab_result[$id]["pourcent_arome_prod_dans_e_liquide_3"] = $row['pourcent_arome_prod_dans_e_liquide_3'];
                 $tab_result[$id]["etat"] = $row['etat'];
                 $tab_result[$id]["date_add"] = $row['date_add'];
                 $tab_result[$id]["date_upd"] = $row['date_upd'];
                 $tab_result[$id]["info_saveur"] = Sql_prepareTexteAffichage($row['info_saveur']);
             }
         }
         if (count($tab_result) == 1 && ($args['id_saveur'] != '' && $args['id_saveur'] != '*')) {
             $tab_result = array_pop($tab_result);
         }
     }
     return $tab_result;
 }
示例#2
0
 /**
  Renvoie le nom et l'identifiant des groupes ayant les données passées en argument sous forme d'un tableau
  @param nom_groupe
  ...
 */
 function Groupes_chercher($nom_groupe = '')
 {
     $tab_result = array();
     $sql = " SELECT *\n          FROM " . $GLOBALS['prefix'] . "sys_groupes\n          WHERE modifiable = '1'";
     if ($nom_groupe == "") {
         return $tab_result;
     }
     $condition = "";
     if ($nom_groupe != "" && $nom_groupe != "*") {
         $condition .= " AND nom_groupe = '{$nom_groupe}' ";
     }
     $condition .= " ORDER by id_groupe ASC";
     $sql .= $condition;
     $result = Sql_query($sql);
     if ($result && Sql_errorCode($result) === "00000") {
         while ($row = Sql_fetch($result)) {
             $tab_result[$row['id_groupe']]['id_groupe'] = $row['id_groupe'];
             $tab_result[$row['id_groupe']]['nom_groupe'] = $row['nom_groupe'];
             $tab_result[$row['id_groupe']]['nb_connect_defaut'] = $row['nb_connect_defaut'];
             $tab_result[$row['id_groupe']]['effacable'] = $row['effacable'];
             $tab_result[$row['id_groupe']]['modifiable'] = $row['modifiable'];
             $tab_result[$row['id_groupe']]['modules'] = array();
             $tab_result[$row['id_groupe']]['droits'] = array();
             // On récupère ensuite les données de la table modules
             $sql2 = "SELECT *\n                 FROM " . $GLOBALS['prefix'] . "sys_groupes_modules\n                 WHERE nom_groupe = '{$row->nom_groupe}'";
             $result2 = Sql_query($sql2);
             if ($result2) {
                 while ($row2 = Sql_fetch($result2)) {
                     $tab_result[$row['id_groupe']]['modules'][] = $row2['module'];
                 }
             }
             // On récupère ensuite les données de la table des droits
             $sql3 = "SELECT *\n                 FROM " . $GLOBALS['prefix'] . "sys_groupes_droits\n                 WHERE nom_groupe = '{$row->nom_groupe}'";
             $result3 = Sql_query($sql3);
             if ($result3) {
                 while ($row3 = Sql_fetch($result3)) {
                     $tab_result[$row['id_groupe']]['droits'][$row3->champ] = $row3['droits'];
                 }
             }
         }
     }
     if (count($tab_result) == 1 && ($nom_groupe != '' && $nom_groupe != '*')) {
         $tab_result = array_pop($tab_result);
     }
     return $tab_result;
 }
示例#3
0
 function Fiches_count($args)
 {
     $count = 0;
     $sql = " SELECT count(*) nb_enregistrements\n\t\t\t\tFROM " . $GLOBALS['prefix'] . "fiche\n\t\t\t\tWHERE 1";
     if (!isset($args['id_fiche']) && !isset($args['id_type_fiche']) && !isset($args['fic_prenom']) && !isset($args['fic_nom']) && !isset($args['fic_email']) && !isset($args['order_by']) && !isset($args['tab_ids_fiches'])) {
         return $count;
     }
     $condition = "";
     if (isset($args['id_fiche']) && $args['id_fiche'] != "*") {
         $condition .= " AND id_fiche = '" . $args['id_fiche'] . "' ";
     }
     if (isset($args['id_type_fiche']) && $args['id_type_fiche'] != "*") {
         $condition .= " AND id_type_fiche = '" . $args['id_type_fiche'] . "' ";
     }
     if (isset($args['fic_prenom']) && $args['fic_prenom'] != "*") {
         $condition .= " AND fic_prenom LIKE '" . Sql_prepareTexteStockage($args['fic_prenom']) . "' ";
     }
     if (isset($args['fic_nom']) && $args['fic_nom'] != "*") {
         $condition .= " AND fic_nom LIKE '" . Sql_prepareTexteStockage($args['fic_nom']) . "' ";
     }
     if (isset($args['fic_email']) && $args['fic_email'] != "*") {
         $condition .= " AND fic_email LIKE '" . Sql_prepareTexteStockage($args['fic_email']) . "' ";
     }
     if (isset($args['tab_ids_fiches']) && $args['tab_ids_fiches'] != "*") {
         $ids = implode(",", $args['tab_ids_fiches']);
         $condition .= " AND id_fiche IN (0" . $ids . ") ";
     }
     $sql .= $condition;
     /*=============*/
     Lib_myLog("SQL: {$sql}");
     $result = Sql_query($sql);
     if ($result && Sql_errorCode($result) === "00000") {
         $row = Sql_fetch($result);
         $count = $row['nb_enregistrements'];
     }
     return $count;
 }
 /**
 Retourne un tableau de post_auteurs correspondant aux champs du tableau en argument.
 @param $args
 */
 function Post_auteurs_chercher($args)
 {
     $count = 0;
     $tab_result = array();
     if (isset($args['count'])) {
         $sql = " SELECT count(*) nb_enregistrements \n\t\t\t\t\tFROM " . $GLOBALS['prefix'] . "post_auteur\n\t\t\t\t\tWHERE 1";
     } else {
         $sql = " SELECT * \n\t\t\t\t\tFROM " . $GLOBALS['prefix'] . "post_auteur\n\t\t\t\t\tWHERE 1";
     }
     if (!isset($args['id_post_auteur']) && !isset($args['etat']) && !isset($args['order_by']) && !isset($args['etat']) && !isset($args['tab_ids_post_auteurs'])) {
         return $tab_result;
     }
     $condition = "";
     if (isset($args['id_post_auteur']) && $args['id_post_auteur'] != "*") {
         $condition .= " AND id_post_auteur = '" . $args['id_post_auteur'] . "' ";
     }
     if (isset($args['etat']) && $args['etat'] != "*") {
         $condition .= " AND etat = '" . $args['etat'] . "' ";
     }
     if (isset($args['tab_ids_post_auteurs']) && $args['tab_ids_post_auteurs'] != "*") {
         $ids = implode(",", $args['tab_ids_post_auteurs']);
         $condition .= " AND id_post_auteur IN (0" . $ids . ") ";
     }
     if (!isset($args['etat'])) {
         $condition .= " AND etat != 'supprime' ";
     }
     $sql .= $condition;
     if (isset($args['order_by']) && !isset($args['asc_desc'])) {
         $sql .= " ORDER BY " . $args['order_by'] . " ASC";
     }
     if (isset($args['order_by']) && isset($args['asc_desc'])) {
         $sql .= " ORDER BY " . $args['order_by'] . " " . $args['asc_desc'];
     }
     if (isset($args['limit']) && !isset($args['start'])) {
         $sql .= " LIMIT " . $args['limit'];
     }
     if (isset($args['limit']) && isset($args['start'])) {
         $sql .= " LIMIT " . $args['start'] . "," . $args['limit'];
     }
     /*=============*/
     Lib_myLog("SQL: {$sql}");
     $result = Sql_query($sql);
     if (isset($args['count'])) {
         if ($result && Sql_errorCode($result) === "00000") {
             $row = Sql_fetch($result);
             $count = $row['nb_enregistrements'];
         }
         return $count;
     } else {
         if ($result && Sql_errorCode($result) === "00000") {
             while ($row = Sql_fetch($result)) {
                 $id = $row['id_post_auteur'];
                 $tab_result[$id]["id_post_auteur"] = $id;
                 $tab_result[$id]["post_auteur_nom"] = Sql_prepareTexteAffichage($row['post_auteur_nom']);
                 $tab_result[$id]["post_auteur_prenom"] = Sql_prepareTexteAffichage($row['post_auteur_prenom']);
                 $tab_result[$id]["post_auteur_pseudo"] = Sql_prepareTexteAffichage($row['post_auteur_pseudo']);
                 $tab_result[$id]["post_auteur_avatar"] = Sql_prepareTexteAffichage($row['post_auteur_avatar']);
                 $tab_result[$id]["etat"] = $row['etat'];
                 $tab_result[$id]["date_add"] = $row['date_add'];
                 $tab_result[$id]["date_upd"] = $row['date_upd'];
                 $tab_result[$id]["info_post_auteur"] = Sql_prepareTexteAffichage($row['info_post_auteur']);
             }
         }
         if (count($tab_result) == 1 && ($args['id_post_auteur'] != '' && $args['id_post_auteur'] != '*')) {
             $tab_result = array_pop($tab_result);
         }
     }
     return $tab_result;
 }
示例#5
0
 /**
  Renvoie le nom, le prénom et l'identifiant des personnes ayant les données passées en argument sous forme d'un tableau
  @param IdForm
  @param NomPersonne
  @param PrenomPersonne
  ...
 */
 function Forms_chercher($id_form = '', $form0 = '')
 {
     $tab_result = array();
     $sql = " SELECT * \n\t\t\tFROM " . $GLOBALS['prefix'] . "forms\n\t\t\tWHERE 1";
     if ("{$id_form}" == "" && $form0 == "") {
         return $tab_result;
     }
     $condition = "";
     if ($id_form != "" && $id_form != "*") {
         $condition .= " AND id_form = {$id_form} ";
     }
     if ($form0 != "" && $form0 != "*") {
         $condition .= " AND form0 = '{$form0}' ";
     }
     $sql .= $condition;
     Lib_myLog("SQL: {$sql}");
     $result = Sql_query($sql);
     if ($result && Sql_errorCode($result) === "00000") {
         while ($row = Sql_fetch($result)) {
             $id = $row['id_form'];
             $tab_result[$id]["id_form"] = $id;
             $tab_result[$id]["nom"] = Sql_prepareTexteAffichage($row['nom']);
             $tab_result[$id]["prenom"] = Sql_prepareTexteAffichage($row['prenom']);
             $tab_result[$id]["date_add"] = $row['date_add'];
             for ($i = 0; $i <= 30; $i++) {
                 $tab_result[$id]['form' . $i] = Sql_prepareTexteAffichage($row['form' . $i]);
             }
         }
     }
     if (count($tab_result) == 1 && ("{$id_form}" != '' && "{$id_form}" != '*')) {
         $tab_result = array_pop($tab_result);
     }
     return $tab_result;
 }
 /**
 Retourne un tableau de commandes correspondant aux champs du tableau en argument.
 @param $args
 */
 function Commandes_chercher($args)
 {
     $count = 0;
     $tab_result = array();
     if (isset($args['count'])) {
         $sql = " SELECT count(*) nb_enregistrements \n\t\t\t\t\tFROM " . $GLOBALS['prefix'] . "commande\n\t\t\t\t\tWHERE 1";
     } else {
         $sql = " SELECT * \n\t\t\t\t\tFROM " . $GLOBALS['prefix'] . "commande\n\t\t\t\t\tWHERE 1";
     }
     if (!isset($args['id_commande']) && !isset($args['id_utilisateur']) && !isset($args['id_customer']) && !isset($args['id_pg_vg']) && !isset($args['date_commande']) && !isset($args['etat']) && !isset($args['order_by']) && !isset($args['etat']) && !isset($args['tab_ids_commandes'])) {
         return $tab_result;
     }
     $condition = "";
     if (isset($args['id_commande']) && $args['id_commande'] != "*") {
         $condition .= " AND id_commande = '" . $args['id_commande'] . "' ";
     }
     if (isset($args['id_utilisateur']) && $args['id_utilisateur'] != "*") {
         $condition .= " AND id_utilisateur = '" . $args['id_utilisateur'] . "' ";
     }
     if (isset($args['id_customer']) && $args['id_customer'] != "*") {
         $condition .= " AND id_customer = '" . $args['id_customer'] . "' ";
     }
     if (isset($args['id_pg_vg']) && $args['id_pg_vg'] != "*") {
         $condition .= " AND id_pg_vg = '" . $args['id_pg_vg'] . "' ";
     }
     if (isset($args['date_commande']) && $args['date_commande'] != "*") {
         $condition .= " AND date_commande = '" . Lib_frToEn($args['date_commande']) . "' ";
     }
     if (isset($args['etat']) && $args['etat'] != "*") {
         $condition .= " AND etat = '" . $args['etat'] . "' ";
     }
     if (isset($args['tab_ids_commandes']) && $args['tab_ids_commandes'] != "*") {
         $ids = implode(",", $args['tab_ids_commandes']);
         $condition .= " AND id_commande IN (0" . $ids . ") ";
     }
     if (!isset($args['etat'])) {
         $condition .= " AND etat != 'supprime' ";
     }
     $sql .= $condition;
     if (isset($args['order_by']) && !isset($args['asc_desc'])) {
         $sql .= " ORDER BY " . $args['order_by'] . " ASC";
     }
     if (isset($args['order_by']) && isset($args['asc_desc'])) {
         $sql .= " ORDER BY " . $args['order_by'] . " " . $args['asc_desc'];
     }
     if (isset($args['limit']) && !isset($args['start'])) {
         $sql .= " LIMIT " . $args['limit'];
     }
     if (isset($args['limit']) && isset($args['start'])) {
         $sql .= " LIMIT " . $args['start'] . "," . $args['limit'];
     }
     /*=============*/
     Lib_myLog("SQL: {$sql}");
     $result = Sql_query($sql);
     if (isset($args['count'])) {
         if ($result && Sql_errorCode($result) === "00000") {
             $row = Sql_fetch($result);
             $count = $row['nb_enregistrements'];
         }
         return $count;
     } else {
         if ($result && Sql_errorCode($result) === "00000") {
             while ($row = Sql_fetch($result)) {
                 $id = $row['id_commande'];
                 $tab_result[$id]["id_commande"] = $id;
                 $tab_result[$id]["id_utilisateur"] = $row['id_utilisateur'];
                 $tab_result[$id]["id_customer"] = $row['id_customer'];
                 $tab_result[$id]["id_pg_vg"] = $row['id_pg_vg'];
                 $tab_result[$id]["date_commande"] = Lib_enToFr($row['date_commande']);
                 $tab_result[$id]["nb_imp"] = $row['nb_imp'];
                 $tab_result[$id]["num_lot"] = Sql_prepareTexteAffichage($row['num_lot']);
                 $tab_result[$id]["etat"] = $row['etat'];
                 $tab_result[$id]["date_add"] = $row['date_add'];
                 $tab_result[$id]["date_upd"] = $row['date_upd'];
                 $tab_result[$id]["info_commande"] = Sql_prepareTexteAffichage($row['info_commande']);
             }
         }
         if (count($tab_result) == 1 && ($args['id_commande'] != '' && $args['id_commande'] != '*')) {
             $tab_result = array_pop($tab_result);
         }
     }
     return $tab_result;
 }
 function Article_precedent($code_news, $position, $lang)
 {
     $id_precedent = 0;
     $sql = " SELECT *\n\t\t\t\tFROM " . $GLOBALS['prefix'] . "articles\n\t\t\t\tWHERE code_news = '{$code_news}'\n\t\t\t\tAND lang = '{$lang}'\n\t\t\t\tAND position < {$position}\n\t\t\t\tAND etat != 'supprime' " . $cond_concours . "\n\t\t\t\tORDER BY position ASC\n\t\t\t\tLIMIT 0, 1";
     if ($result && Sql_errorCode($result) === "00000") {
         $row = Sql_fetch($result);
         return $row['id_article'];
     }
     return $id_precedent;
 }
 /**
  Renvoie la liste des autorisations ayant les données passées en argument sous forme d'un tableau
  @param id_groupe
  @param adresse_ip
  ...
 */
 function Autorisation_chercher($id_groupe = '', $adresse_ip = '')
 {
     $RESULT = array();
     $sql = " SELECT SA.id_groupe, SA.adresse_ip, SA.effacable, SG.nom_groupe\n\t\t\t\tFROM " . $GLOBALS['prefix'] . "sys_ip_autorisations SA, " . $GLOBALS['prefix'] . "sys_groupes SG\n\t\t\t\tWHERE SA.id_groupe = SG.id_groupe";
     if ($id_groupe == "" && $adresse_ip == "") {
         return $RESULT;
     }
     $condition = "";
     if ($id_groupe != "" && $id_groupe != "*") {
         $condition .= " AND id_groupe = {$id_groupe} ";
     }
     if ($adresse_ip != "" && $adresse_ip != "*") {
         $condition .= " AND adresse_ip LIKE '%{$adresse_ip}%' ";
     }
     $sql .= $condition;
     $result = Sql_query($sql);
     if ($result && Sql_errorCode($result) === "00000") {
         $indice = 0;
         while ($row = Sql_fetch($result)) {
             $RESULT[$indice]["id_groupe"] = $row['id_groupe'];
             $RESULT[$indice]["nom_groupe"] = $row['nom_groupe'];
             $RESULT[$indice]["adresse_ip"] = $row['adresse_ip'];
             $RESULT[$indice]["effacable"] = $row['effacable'];
             $indice++;
         }
     }
     return $RESULT;
 }
 /**
 Retourne un tableau de adherents correspondant aux champs du tableau en argument.
 @param $args
 */
 function Adherents_chercher($args)
 {
     $tab_result = array();
     $sql = " SELECT A.*, U.nom_utilisateur, U.password\n\t\t\t\tFROM " . $GLOBALS['prefix'] . "adherent A, " . $GLOBALS['prefix'] . "sys_utilisateurs U\n\t\t\t\tWHERE A.id_utilisateur = U.id_utilisateur";
     if (!isset($args['id_adherent']) && !isset($args['id_interne']) && !isset($args['id_utilisateur']) && !isset($args['nom']) && !isset($agrs['prenom']) && !isset($args['enseigne']) && !isset($args['email']) && !isset($args['not_email']) && !isset($args['raison_sociale']) && !isset($args['cp']) && !isset($args['ville']) && !isset($args['not_latitude']) && !isset($args['categorie']) && !isset($args['nature_lien']) && !isset($args['categorie1']) && !isset($args['categorie2']) && !isset($args['categorie3']) && !isset($args['categorie4']) && !isset($args['categorie5']) && !isset($args['categorie6']) && !isset($args['categorie7']) && !isset($args['categorie8']) && !isset($args['categorie9']) && !isset($args['categorie10']) && !isset($args['tab_categorie1']) && !isset($args['tab_categorie2']) && !isset($args['tab_categorie3']) && !isset($args['pays']) && !isset($args['etat']) && !isset($args['order_by']) && !isset($args['etat']) && !isset($args['entreprise_qualifiee']) && !isset($args['tab_ids_adherents']) && !isset($args['tab_cps'])) {
         return $tab_result;
     }
     $condition = "";
     if (isset($args['id_adherent']) && $args['id_adherent'] != "*") {
         $condition .= " AND id_adherent = '" . $args['id_adherent'] . "' ";
     }
     if (isset($args['id_interne'])) {
         $condition .= " AND id_interne = '" . $args['id_interne'] . "' ";
     }
     if (isset($args['id_utilisateur'])) {
         $condition .= " AND A.id_utilisateur = '" . $args['id_utilisateur'] . "' ";
     }
     if (isset($args['nom'])) {
         $condition .= " AND nom LIKE '" . Sql_prepareTexteStockage($args['nom']) . "' ";
     }
     if (isset($args['prenom'])) {
         $condition .= " AND prenom LIKE '" . Sql_prepareTexteStockage($args['prenom']) . "' ";
     }
     if (isset($args['enseigne'])) {
         $condition .= " AND enseigne LIKE '" . Sql_prepareTexteStockage($args['enseigne']) . "' ";
     }
     if (isset($args['email'])) {
         $condition .= " AND email LIKE '" . $args['email'] . "' ";
     }
     if (isset($args['not_email'])) {
         $condition .= " AND email NOT LIKE '" . $args['not_email'] . "' ";
     }
     if (isset($args['raison_sociale'])) {
         $condition .= " AND raison_sociale LIKE '" . Sql_prepareTexteStockage($args['raison_sociale']) . "' ";
     }
     if (isset($args['cp'])) {
         $condition .= " AND cp LIKE '" . Sql_prepareTexteStockage($args['cp']) . "' ";
     }
     if (isset($args['ville'])) {
         $condition .= " AND ville LIKE '" . Sql_prepareTexteStockage($args['ville']) . "' ";
     }
     if (isset($args['pays'])) {
         $condition .= " AND pays LIKE '" . Sql_prepareTexteStockage($args['pays']) . "' ";
     }
     if (isset($args['not_latitude'])) {
         $condition .= " AND latitude NOT LIKE '" . $args['not_latitude'] . "' ";
     }
     if (isset($args['entreprise_qualifiee'])) {
         $condition .= " AND entreprise_qualifiee = " . $args['entreprise_qualifiee'] . " ";
     }
     if (isset($args['categorie'])) {
         $condition .= " AND categorie LIKE '" . $args['categorie'] . "' ";
     }
     if (isset($args['nature_lien'])) {
         $condition .= " AND nature_lien LIKE '" . $args['nature_lien'] . "' ";
     }
     if (isset($args['categorie1'])) {
         $condition .= " AND categorie1 LIKE '" . $args['categorie1'] . "' ";
     }
     if (isset($args['categorie2'])) {
         $condition .= " AND categorie2 LIKE '" . $args['categorie2'] . "' ";
     }
     if (isset($args['categorie3'])) {
         $condition .= " AND categorie3 LIKE '" . $args['categorie3'] . "' ";
     }
     if (isset($args['categorie4'])) {
         $condition .= " AND categorie4 LIKE '" . $args['categorie4'] . "' ";
     }
     if (isset($args['categorie5'])) {
         $condition .= " AND categorie5 LIKE '" . $args['categorie5'] . "' ";
     }
     if (isset($args['categorie6'])) {
         $condition .= " AND categorie6 LIKE '" . $args['categorie6'] . "' ";
     }
     if (isset($args['categorie7'])) {
         $condition .= " AND categorie7 LIKE '" . $args['categorie7'] . "' ";
     }
     if (isset($args['categorie8'])) {
         $condition .= " AND categorie8 LIKE '" . $args['categorie8'] . "' ";
     }
     if (isset($args['categorie9'])) {
         $condition .= " AND categorie9 LIKE '" . $args['categorie9'] . "' ";
     }
     if (isset($args['categorie10'])) {
         $condition .= " AND categorie10 LIKE '" . $args['categorie10'] . "' ";
     }
     if (isset($args['etat']) && $args['etat'] != "*") {
         $condition .= " AND A.etat = '" . $args['etat'] . "' ";
     }
     if (isset($args['tab_ids_adherents']) && $args['tab_ids_adherents'] != "*") {
         $ids = implode(",", $args['tab_ids_adherents']);
         $condition .= " AND id_adherent IN (0" . $ids . ") ";
     }
     if (isset($args['tab_cps'])) {
         $condition .= " AND ( ";
         $nb = count($args['tab_cps']);
         for ($i = 1; $i <= $nb; $i++) {
             $cp = array_pop($args['tab_cps']);
             $condition .= " cp LIKE '" . $cp . "%' ";
             if ($i < $nb) {
                 $condition .= " OR ";
             }
         }
         $condition .= " ) ";
     }
     if (isset($args['tab_categorie'])) {
         $condition .= " AND (";
         for ($i = 0; count($args['tab_categorie']); $i++) {
             $id = array_pop($args['tab_categorie']);
             $condition .= " categorie LIKE '%{$id}%' ";
             if (count($args['tab_categorie'])) {
                 $condition .= " OR ";
             }
         }
         $condition .= ")";
     }
     if (isset($args['tab_categorie1'])) {
         $condition .= " AND (";
         for ($i = 0; count($args['tab_categorie1']); $i++) {
             $id = array_pop($args['tab_categorie1']);
             $condition .= " categorie1 LIKE '%|{$id}|%' ";
             if (count($args['tab_categorie1'])) {
                 $condition .= " OR ";
             }
         }
         $condition .= ")";
     }
     if (isset($args['tab_categorie2'])) {
         $condition .= " AND (";
         for ($i = 0; count($args['tab_categorie2']); $i++) {
             $id = array_pop($args['tab_categorie2']);
             $condition .= " categorie2 LIKE '%|{$id}|%' ";
             if (count($args['tab_categorie2'])) {
                 $condition .= " OR ";
             }
         }
         $condition .= ")";
     }
     if (isset($args['tab_categorie3'])) {
         $condition .= " AND (";
         for ($i = 0; count($args['tab_categorie3']); $i++) {
             $id = array_pop($args['tab_categorie3']);
             $condition .= " categorie3 LIKE '%|{$id}|%' ";
             if (count($args['tab_categorie3'])) {
                 $condition .= " OR ";
             }
         }
         $condition .= ")";
     }
     if (!isset($args['etat'])) {
         $condition .= " AND A.etat != 'supprime' ";
     }
     $sql .= $condition;
     if (isset($args['order_by']) && !isset($args['asc_desc'])) {
         $sql .= " ORDER BY " . $args['order_by'] . " ASC";
     }
     if (isset($args['order_by']) && isset($args['asc_desc'])) {
         $sql .= " ORDER BY " . $args['order_by'] . " " . $args['asc_desc'];
     }
     if (isset($args['limit']) && !isset($args['start'])) {
         $sql .= " LIMIT " . $args['limit'];
     }
     if (isset($args['limit']) && isset($args['start'])) {
         $sql .= " LIMIT " . $args['start'] . "," . $args['limit'];
     }
     /*=============*/
     Lib_myLog("SQL: {$sql}");
     $result = Sql_query($sql);
     if ($result && Sql_errorCode($result) === "00000") {
         while ($row = Sql_fetch($result)) {
             $id = $row['id_adherent'];
             $tab_result[$id]["id_adherent"] = $id;
             $tab_result[$id]["id_utilisateur"] = $row['id_utilisateur'];
             $tab_result[$id]["id_interne"] = $row['id_interne'];
             $tab_result[$id]["nom"] = Sql_prepareTexteAffichage($row['nom']);
             $tab_result[$id]["prenom"] = Sql_prepareTexteAffichage($row['prenom']);
             $tab_result[$id]["enseigne"] = Sql_prepareTexteAffichage($row['enseigne']);
             $tab_result[$id]["raison_sociale"] = Sql_prepareTexteAffichage($row['raison_sociale']);
             $tab_result[$id]["adresse1"] = Sql_prepareTexteAffichage($row['adresse1']);
             $tab_result[$id]["adresse2"] = Sql_prepareTexteAffichage($row['adresse2']);
             $tab_result[$id]["cp"] = Sql_prepareTexteAffichage($row['cp']);
             $tab_result[$id]["ville"] = Sql_prepareTexteAffichage($row['ville']);
             $tab_result[$id]["pays"] = Sql_prepareTexteAffichage($row['pays']);
             $tab_result[$id]["telephone"] = Sql_prepareTexteAffichage($row['telephone']);
             $tab_result[$id]["fax"] = Sql_prepareTexteAffichage($row['fax']);
             $tab_result[$id]["email"] = $row['email'];
             $tab_result[$id]["site_internet"] = $row['site_internet'];
             $tab_result[$id]["entreprise_qualifiee"] = $row['entreprise_qualifiee'];
             $tab_result[$id]["logo"] = $row['logo'];
             $tab_result[$id]["categorie"] = Sql_prepareTexteAffichage($row['categorie']);
             $tab_result[$id]["nature_lien"] = Sql_prepareTexteAffichage($row['nature_lien']);
             $tab_result[$id]["info_publique"] = Sql_prepareTexteAffichage($row['info_publique']);
             $tab_result[$id]["categorie1"] = $row['categorie1'];
             $tab_result[$id]["categorie2"] = $row['categorie2'];
             $tab_result[$id]["categorie3"] = $row['categorie3'];
             $tab_result[$id]["categorie4"] = $row['categorie4'];
             $tab_result[$id]["categorie5"] = $row['categorie5'];
             $tab_result[$id]["categorie6"] = $row['categorie6'];
             $tab_result[$id]["categorie7"] = $row['categorie7'];
             $tab_result[$id]["categorie8"] = $row['categorie8'];
             $tab_result[$id]["categorie9"] = $row['categorie9'];
             $tab_result[$id]["categorie10"] = $row['categorie10'];
             $tab_result[$id]["latitude"] = $row['latitude'];
             $tab_result[$id]["longitude"] = $row['longitude'];
             $tab_result[$id]["etat"] = $row['etat'];
             $tab_result[$id]["date_add"] = $row['date_add'];
             $tab_result[$id]["date_upd"] = $row['date_upd'];
             $tab_result[$id]["info_adherent"] = $row['info_adherent'];
             $tab_result[$id]["nom_utilisateur"] = $row['nom_utilisateur'];
             $tab_result[$id]["password"] = $row['password'];
         }
     }
     if (count($tab_result) == 1 && !isset($args['tab']) && ($args['id_adherent'] != '' && $args['id_adherent'] != '*')) {
         $tab_result = array_pop($tab_result);
     }
     if (count($tab_result) == 1 && !isset($args['tab']) && ($args['id_utilisateur'] != '' && $args['id_utilisateur'] != '*')) {
         $tab_result = array_pop($tab_result);
     }
     return $tab_result;
 }
示例#10
0
 function News_precedent($code_news, $position, $lang, $concours, $data)
 {
     $suivant = array();
     $suivants = array();
     $liste_news = $data;
     foreach ($liste_news as $new) {
         if ($new['code_news'] != $code_news) {
             continue;
         }
         if ($new['lang'] != $lang) {
             continue;
         }
         if ($new['position'] <= $position) {
             continue;
         }
         if ($new['code'] == 999999999) {
             continue;
         }
         if ($new['etat'] == 'supprime') {
             continue;
         }
         if (isset($concours) && $concours != '') {
             if ($new['titre_data2'] != $concours) {
                 continue;
             }
         }
         $suivants[$new['position']] = $new;
         asort($suivants);
     }
     /*=============*/
     Lib_myLog("Suivants:", $suivants);
     $suivant = array_shift($suivants);
     //SQL
     if (isset($concours) && $concours != '') {
         $cond_concours = "AND titre_data2 = '{$concours}' ";
     }
     $sql = " SELECT *\n\t\t\t\tFROM " . $GLOBALS['prefix'] . "new\n\t\t\t\tWHERE code_news = '{$code_news}'\n\t\t\t\tAND lang = '{$lang}'\n\t\t\t\tAND position > {$position}\n\t\t\t\tAND etat != 'supprime' " . $cond_concours . "\n\t\t\t\tORDER BY position ASC\n\t\t\t\tLIMIT 0, 1";
     if ($result && Sql_errorCode($result) === "00000") {
         $row = Sql_fetch($result);
         $suivant["id_new"] = $row['id_new'];
         $suivant["titre_data1"] = Sql_prepareTexteAffichage($row['titre_data1']);
         $suivant["data1"] = Sql_prepareTexteAffichage($row['data1']);
         $suivant["titre_data2"] = Sql_prepareTexteAffichage($row['titre_data2']);
         $suivant["data2"] = Sql_prepareTexteAffichage($row['data2']);
         $suivant["titre_data3"] = Sql_prepareTexteAffichage($row['titre_data3']);
         $suivant["data3"] = Sql_prepareTexteAffichage($row['data3']);
         $suivant["titre_data4"] = Sql_prepareTexteAffichage($row['titre_data4']);
         $suivant["data4"] = Sql_prepareTexteAffichage($row['data4']);
         $suivant["titre_data5"] = Sql_prepareTexteAffichage($row['titre_data5']);
         $suivant["data5"] = Sql_prepareTexteAffichage($row['data5']);
         $suivant["titre_data6"] = Sql_prepareTexteAffichage($row['titre_data6']);
         $suivant["data6"] = Sql_prepareTexteAffichage($row['data6']);
         $suivant["code_news"] = Sql_prepareTexteAffichage($row['code_news']);
         $suivant["code"] = $row['code'];
         $suivant["lang"] = Sql_prepareTexteAffichage($row['lang']);
         $suivant["etat"] = Sql_prepareTexteAffichage($row['etat']);
         $suivant["position"] = $row['position'];
         $suivant["titre"] = Sql_prepareTexteAffichage($row['titre']);
         $suivant["contenu"] = Sql_prepareTexteAffichage($row['contenu']);
         $suivant["texte_intro"] = Sql_prepareTexteAffichage($row['texte_intro']);
         $suivant["image_intro"] = Sql_prepareTexteAffichage($row['image_intro']);
         $suivant["date"] = Sql_prepareTexteAffichage($row['date']);
         $suivant["url_image"] = Sql_prepareTexteAffichage($row['url_image']);
         $suivant["url_image2"] = Sql_prepareTexteAffichage($row['url_image2']);
         $suivant["date_add"] = Sql_prepareTexteAffichage($row['date_add']);
         $suivant["date_upd"] = Sql_prepareTexteAffichage($row['date_upd']);
         $suivant["info_new"] = Sql_prepareTexteAffichage($row['info_new']);
     }
     return $suivant;
 }
示例#11
0
 /**
  Renvoie le position, le préposition et l'identifiant des personnes ayant les données passées en argument sous forme d'un tableau
  @param id_mobilier_image
  @param positionPersonne
  @param url_gde_imagePersonne
  ...
 */
 function Galeries_chercher($args)
 {
     $tab_result = array();
     $sql = " SELECT * \n\t\t\t FROM " . $GLOBALS['prefix'] . "galeries\n\t\t\t WHERE 1";
     if (!isset($args['id_galerie']) && !isset($args['id_pere']) && !isset($args['type_pere']) && !isset($args['position']) && !isset($args['order_by']) && !isset($args['code_pere'])) {
         return $tab_result;
     }
     $condition = "";
     if (isset($args['id_galerie']) && $args['id_galerie'] != "*") {
         $condition .= " AND id_galerie = " . $args['id_galerie'] . " ";
     }
     if (isset($args['id_pere']) && $args['id_pere'] != "*") {
         $condition .= " AND id_pere = '" . $args['id_pere'] . "' ";
     }
     if (isset($args['code_pere']) && $args['code_pere'] != "*") {
         $condition .= " AND code_pere LIKE '" . $args['code_pere'] . "' ";
     }
     if (isset($args['type_pere']) && $args['type_pere'] != "*") {
         $condition .= " AND type_pere LIKE '" . $args['type_pere'] . "' ";
     }
     if (isset($args['position']) && $args['position'] != "*") {
         $condition .= " AND position = '" . $args['position'] . "' ";
     }
     $condition .= " ORDER BY position ASC ";
     $sql .= $condition;
     /*=============*/
     Lib_myLog("SQL: {$sql}");
     $result = Sql_query($sql);
     if ($result && Sql_errorCode($result) === "00000") {
         while ($row = Sql_fetch($result)) {
             $id = $row['id_galerie'];
             $tab_result[$id]["id_galerie"] = $row['id_galerie'];
             $tab_result[$id]["id_pere"] = $row['id_pere'];
             $tab_result[$id]["code_pere"] = $row['code_pere'];
             $tab_result[$id]["type_pere"] = $row['type_pere'];
             $tab_result[$id]["position"] = $row['position'];
             $tab_result[$id]["url_vignette"] = $row['url_vignette'];
             $tab_result[$id]["largeur_vignette"] = $row['largeur_vignette'];
             $tab_result[$id]["hauteur_vignette"] = $row['hauteur_vignette'];
             $tab_result[$id]["url_gde_image"] = $row['url_gde_image'];
             $tab_result[$id]["info_galerie"] = $row['info_galerie'];
             // On récupère ensuite les données de la table modules
             $sql2 = "SELECT *\n\t\t\t\t\t  FROM " . $GLOBALS['prefix'] . "galeries_lang\n\t\t\t\t\t  WHERE id_galerie = {$id}";
             $result2 = Sql_query($sql2);
             $tab_result[$id]['versions'][$row2['lang']] = array();
             if ($result2) {
                 while ($row2 = Sql_fetch($result2)) {
                     $tab_result[$id]['versions'][$row2['lang']]['legende'] = Sql_prepareTexteAffichage($row2['legende']);
                     $tab_result[$id]['versions'][$row2['lang']]['data1'] = Sql_prepareTexteAffichage($row2['data1']);
                     $tab_result[$id]['versions'][$row2['lang']]['data2'] = Sql_prepareTexteAffichage($row2['data2']);
                     $tab_result[$id]['versions'][$row2['lang']]['data3'] = Sql_prepareTexteAffichage($row2['data3']);
                     $tab_result[$id]['versions'][$row2['lang']]['data4'] = Sql_prepareTexteAffichage($row2['data4']);
                     $tab_result[$id]['versions'][$row2['lang']]['data5'] = Sql_prepareTexteAffichage($row2['data5']);
                 }
             }
         }
     }
     return $tab_result;
 }
 /**
  Renvoie le nom et l'identifiant des utilisateurs ayant les données passées en argument sous forme d'un tableau
  @param IdUtilisateur
  @param NomUtilisateur
  ...
 */
 function Utilisateurs_chercher($nom_utilisateur = '', $id_utilisateur = '', $id_personne = '', $etat = '', $code_utilisateur = '', $tab_ids = '')
 {
     $tab_result = array();
     $sql = " SELECT *\n\t\t\tFROM " . $GLOBALS['prefix'] . "sys_utilisateurs\n\t\t\tWHERE modifiable = '1'";
     if ($nom_utilisateur == "" && "{$id_utilisateur}" == "" && "{$id_personne}" == "" && $etat == "" && $code_utilisateur == "" && $tab_ids == "") {
         return $tab_result;
     }
     $condition = "";
     if ("{$id_utilisateur}" != "" && "{$id_utilisateur}" != "*") {
         $condition .= " AND id_utilisateur = {$id_utilisateur} ";
     }
     if ($nom_utilisateur != "" && $nom_utilisateur != "*") {
         $condition .= " AND nom_utilisateur = '{$nom_utilisateur}' ";
     }
     if ($etat != "" && $etat != "*") {
         $condition .= " AND etat = '{$etat}' ";
     }
     if ($code_utilisateur != "" && $code_utilisateur != "*") {
         $condition .= " AND code_utilisateur = '{$code_utilisateur}' ";
     }
     if ($tab_ids != "") {
         $ids = implode(",", $tab_ids);
         $condition .= " AND id_utilisateur IN (0" . $ids . ") ";
     }
     $condition .= " ORDER by id_utilisateur ASC";
     $sql .= $condition;
     /*=============*/
     Lib_myLog("SQL: {$sql}");
     $result = Sql_query($sql);
     if ($result && Sql_errorCode($result) === "00000") {
         while ($row = Sql_fetch($result)) {
             $id = $row['id_utilisateur'];
             $tab_result[$id]["id_utilisateur"] = $id;
             $tab_result[$id]["code_utilisateur"] = $row['code_utilisateur'];
             $tab_result[$id]["nom_groupe"] = $row['nom_groupe'];
             $tab_result[$id]["nom_utilisateur"] = $row['nom_utilisateur'];
             $tab_result[$id]["password"] = $row['password'];
             $tab_result[$id]["nb_connect"] = $row['nb_connect'];
             $tab_result[$id]["etat"] = $row['etat'];
             $tab_result[$id]["lang"] = $row['lang'];
             $tab_result[$id]["info_utilisateur"] = $row['info_utilisateur'];
             $tab_result[$id]["modifiable"] = $row['modifiable'];
             $tab_result[$id]["effacable"] = $row['effacable'];
             $tab_result[$id]["type"] = 'utilisateurs';
             // On récupère ensuite les données de la table des droits
             $sql3 = "SELECT *\n\t\t\t\t\tFROM " . $GLOBALS['prefix'] . "sys_utilisateurs_droits\n\t\t\t\t\tWHERE id_utilisateur = {$id}";
             $result3 = Sql_query($sql3);
             if ($result3) {
                 while ($row3 = Sql_fetch($result3)) {
                     $tab_result[$id]['droits'][$row3['champ']] = $row3['droits'];
                 }
             }
         }
     }
     if (count($tab_result) == 1 && ($nom_utilisateur != '' && $nom_utilisateur != '*') || "{$id_utilisateur}" != '' && "{$id_utilisateur}" != '*' || $code_utilisateur != '' && $code_utilisateur != '*') {
         $tab_result = array_pop($tab_result);
     }
     return $tab_result;
 }
 /**
 Retourne un tableau de fiche_memos correspondant aux champs du tableau en argument.
 @param $args
 */
 function FicheMemos_chercher($args)
 {
     $tab_result = array();
     $sql = " SELECT * \n\t\t\t\tFROM " . $GLOBALS['prefix'] . "fiche_memos\n\t\t\t\tWHERE 1";
     if (!isset($args['id_memo']) && !isset($args['id_fiche']) && !isset($args['order_by']) && !isset($args['tab_ids_memos']) && !isset($args['tab_ids_fiches'])) {
         return $tab_result;
     }
     $condition = "";
     if (isset($args['id_memo']) && $args['id_memo'] != "*") {
         $condition .= " AND id_memo = " . $args['id_memo'] . " ";
     }
     if (isset($args['id_fiche']) && $args['id_fiche'] != "*") {
         $condition .= " AND id_fiche = " . $args['id_fiche'] . " ";
     }
     if (isset($args['date_memo_min'])) {
         $condition .= " AND date_memo >= " . $args['date_memo_min'] . " ";
     }
     if (isset($args['date_memo_max'])) {
         $condition .= " AND date_memo <= " . $args['date_memo_max'] . " ";
     }
     if (isset($args['tab_ids_memos']) && $args['tab_ids_memos'] != "*") {
         $ids = implode(",", $args['tab_ids_memos']);
         $condition .= " AND id_memo IN (0" . $ids . ") ";
     }
     if (isset($args['tab_ids_fiches']) && $args['tab_ids_fiches'] != "*") {
         $ids = implode(",", $args['tab_ids_fiches']);
         $condition .= " AND id_fiche IN (0" . $ids . ") ";
     }
     $sql .= $condition;
     if (isset($args['order_by']) && !isset($args['asc_desc'])) {
         $sql .= " ORDER BY " . $args['order_by'] . " ASC";
     }
     if (isset($args['order_by']) && isset($args['asc_desc'])) {
         $sql .= " ORDER BY " . $args['order_by'] . " " . $args['asc_desc'];
     }
     if (isset($args['limit']) && !isset($args['start'])) {
         $sql .= " LIMIT " . $args['limit'];
     }
     if (isset($args['limit']) && isset($args['start'])) {
         $sql .= " LIMIT " . $args['start'] . "," . $args['limit'];
     }
     /*=============*/
     Lib_myLog("SQL: {$sql}");
     $result = Sql_query($sql);
     if ($result && Sql_errorCode($result) === "00000") {
         while ($row = Sql_fetch($result)) {
             $id = $row['id_memo'];
             $tab_result[$id]["id_memo"] = $id;
             $tab_result[$id]["id_fiche"] = $row['id_fiche'];
             $tab_result[$id]["date_memo"] = $row['date_memo'];
             $tab_result[$id]["memo"] = Sql_prepareTexteAffichage($row['memo']);
             $tab_result[$id]["date_add"] = $row['date_add'];
             $tab_result[$id]["date_upd"] = $row['date_upd'];
             $tab_result[$id]["info_memo"] = Sql_prepareTexteAffichage($row['info_memo']);
         }
     }
     if (count($tab_result) == 1 && ($args['id_memo'] != '' && $args['id_memo'] != '*')) {
         $tab_result = array_pop($tab_result);
     }
     return $tab_result;
 }
 /**
     Récupère tous les identifiants verifiant le etat fourni
     /param etat
     /param type_parametre
 */
 function Parametres_chercher($id_utilisateur = '', $code_parametre = '', $type_parametre = '', $designation = '', $etat = '')
 {
     $tab_result = array();
     $sql = " SELECT distinct(code_parametre), type_parametre, designation, etat, info_parametre\n            FROM " . $GLOBALS['prefix'] . "sys_parametres\n            WHERE 1";
     if ("{$id_utilisateur}" == "" && $code_parametre == "" && $etat == "" && $type_parametre == "" && $designation == "") {
         return $tab_result;
     }
     $condition = "";
     if ($id_utilisateur != "" && $id_utilisateur != "*") {
         $condition .= " AND id_utilisateur = {$id_utilisateur} ";
     }
     if ($code_parametre != "" && $code_parametre != "*") {
         $condition .= " AND code_parametre = '{$code_parametre}' ";
     }
     if ($etat != "" && $etat != "*") {
         $condition .= " AND etat = '{$etat}' ";
     }
     if ($type_parametre != "" && $type_parametre != "*") {
         $condition .= " AND type_parametre = '{$type_parametre}' ";
     }
     if ($designation != "" && $designation != "*") {
         $condition .= " AND designation LIKE '%{$designation}%' ";
     }
     $sql .= $condition;
     $result = Sql_query($sql);
     if ($result && Sql_errorCode($result) === "00000") {
         $i = 0;
         while ($row = Sql_fetch($result)) {
             $tab_result[$i]["id_utilisateur"] = $row['id_utilisateur'];
             $tab_result[$i]["code_parametre"] = $row['code_parametre'];
             $tab_result[$i]["type_parametre"] = $row['type_parametre'];
             $tab_result[$i]["designation"] = $row['designation'];
             $tab_result[$i]["etat"] = $row['etat'];
             $tab_result[$i]["info_parametre"] = Sql_prepareTexteAffichage($row['info_parametre']);
             $i++;
         }
     }
     if (count($tab_result) == 1 && ($code_parametre != '' && "{$id_utilisateur}" != '*')) {
         $tab_result = array_pop($tab_result);
     }
     return $tab_result;
 }
 /**
  Renvoie la liste des interdictions ayant les données passées en argument sous forme d'un tableau
  @param id_groupe
  @param adresse_ip
  ...
 */
 function Interdictions_chercher($adresse_ip = '')
 {
     $RESULT = array();
     $sql = " SELECT *\n\t\t\t\tFROM " . $GLOBALS['prefix'] . "sys_ip_interdictions\n\t\t\t\tWHERE 1";
     if ($id_groupe == "" && $adresse_ip == "") {
         return $RESULT;
     }
     $condition = "";
     if ($adresse_ip != "" && $adresse_ip != "*") {
         $condition .= " AND adresse_ip LIKE '%{$adresse_ip}%' ";
     }
     $sql .= $condition;
     $result = Sql_query($sql);
     if ($result && Sql_errorCode($result) === "00000") {
         $indice = 0;
         while ($row = Sql_fetch($result)) {
             $RESULT[$indice]["nom_utilisateur"] = $row['nom_utilisateur'];
             $RESULT[$indice]["adresse_ip"] = $row['adresse_ip'];
             $RESULT[$indice]["nb_tentatives"] = $row['nb_tentatives'];
             $RESULT[$indice]["date_add"] = $row['date_add'];
             $RESULT[$indice]["date_upd"] = $row['date_upd'];
             $indice++;
         }
     }
     return $RESULT;
 }
示例#16
0
 /**
 * Creation d'un fichier temporaire de sauvegarde contenant les instructions SQL
 *
 * @param out_file Fichier cible pour stockage des instructions SQL
 */
 function Sql_buildSqlFile($out_file, $sql = '')
 {
     $crlf = Lib_endOfLine();
     $out_handle = fopen($out_file, "w");
     fputs($out_handle, "# BdD: " . $GLOBALS['db'] . "{$crlf}");
     //===========================================================================
     // auth_tables[] vient du .conf et contient la liste des tables a sauvegarder
     //===========================================================================
     foreach ($GLOBALS['AUTH_TABLES'] as $table) {
         fputs($out_handle, $crlf);
         fputs($out_handle, "# --------------------------------------------------------{$crlf}");
         fputs($out_handle, "# DumpingData '" . $GLOBALS['prefix'] . "{$table}'{$crlf}");
         fputs($out_handle, "# --------------------------------------------------------{$crlf}");
         fputs($out_handle, $crlf);
         fputs($out_handle, "DELETE from " . $GLOBALS['prefix'] . "{$table};{$crlf}");
         fputs($out_handle, $crlf);
         if ($sql != "") {
             $sql = ereg_replace(';', ' ', $sql);
         } else {
             $sql = "SELECT * FROM " . $GLOBALS['db'] . "." . $GLOBALS['prefix'] . $table;
         }
         $result = Sql_query($sql);
         $sql = "";
         if (!$result) {
             echo $MSG[$lang]['ProblemeSql'];
             echo $MSG['fr']['MessageBase'] . Sql_errorCode($result) . " : " . Sql_errorInfo($result) . "<BR>";
             break;
         }
         $first_line = Sql_fetch($result);
         //============================================================================
         // Si la table n'a pas de lignes, on continue avec la table suivante
         //============================================================================
         if (count($first_line) <= 1) {
             continue;
         }
         //============================================================================
         // On construit la liste des champs pour eviter d'avoir des problemes d'INSERT
         //============================================================================
         $fields = "(";
         foreach ($first_line as $index => $val) {
             $fields .= $index . ",";
         }
         $fields .= ")";
         //       $fields = "(";
         //       $list_fields = mysql_list_fields($GLOBALS['db'], $GLOBALS['prefix'].$table);
         //       $columns = mysql_num_fields($list_fields);
         //       for ($i = 0; $i < $columns; $i++)
         //           $fields .= (strcmp($fields,"(") == 0) ? mysql_field_name($list_fields, $i) : ",".mysql_field_name($list_fields, $i);
         //       $fields .= ")";
         $insert_table = "INSERT INTO " . $GLOBALS['prefix'] . "{$table} {$fields} VALUES";
         $insert_table = trim($insert_table);
         while ($row = Sql_fetch($result)) {
             fputs($out_handle, "{$insert_table} {$crlf}");
             $k = 0;
             //=============================================================
             // $lines_max represente le nombre de lignes maximum par INSERT
             // defini dans le conf.php
             //=============================================================
             while ($k < $GLOBALS['lines_max']) {
                 $schema_insert = "(";
                 @set_time_limit(60);
                 $table_list = "(";
                 for ($j = 0; $j < mysql_num_fields($result); $j++) {
                     $table_list .= mysql_field_name($result, $j) . ", ";
                 }
                 $table_list = substr($table_list, 0, -2);
                 $table_list .= ")";
                 for ($j = 0; $j < mysql_num_fields($result); $j++) {
                     if (!isset($row[$j])) {
                         $schema_insert .= " NULL,";
                     } elseif ($row[$j] != "") {
                         $dummy = "";
                         $srcstr = $row[$j];
                         for ($xx = 0; $xx < strlen($srcstr); $xx++) {
                             $yy = strlen($dummy);
                             if ($srcstr[$xx] == "\\") {
                                 $dummy .= "\\\\";
                             }
                             if ($srcstr[$xx] == "'") {
                                 $dummy .= "\\'";
                             }
                             if ($srcstr[$xx] == "\"") {
                                 $dummy .= "\\\"";
                             }
                             if ($srcstr[$xx] == "") {
                                 $dummy .= "\\0";
                             }
                             if ($srcstr[$xx] == "\n") {
                                 $dummy .= "\\n";
                             }
                             if ($srcstr[$xx] == "\r") {
                                 $dummy .= "\\r";
                             }
                             if ($srcstr[$xx] == "") {
                                 $dummy .= "\\b";
                             }
                             if ($srcstr[$xx] == "\t") {
                                 $dummy .= "\\t";
                             }
                             if ($srcstr[$xx] == "") {
                                 $dummy .= "\\Z";
                             }
                             if (strlen($dummy) == $yy) {
                                 $dummy .= $srcstr[$xx];
                             }
                         }
                         $schema_insert .= " '" . $dummy . "',";
                     } else {
                         $schema_insert .= " '',";
                     }
                 }
                 $schema_insert = ereg_replace(",\$", "", $schema_insert);
                 $schema_insert .= ")";
                 $schema_insert = trim($schema_insert);
                 //============================================================================
                 // On ecrit dans le fichier temporaire
                 //============================================================================
                 if ($k == $GLOBALS['lines_max'] - 1 || $i == $nb_lines - 1) {
                     fputs($out_handle, "{$schema_insert};{$crlf}");
                 } else {
                     fputs($out_handle, "{$schema_insert},{$crlf}");
                 }
                 $k++;
                 $i++;
                 if ($i == $nb_lines) {
                     break;
                 }
             }
         }
     }
     fclose($out_handle);
 }
示例#17
0
 function Arbo_construire($code_arbo = '', $type = 'article')
 {
     /*=============*/
     Lib_myLog("Recuperation de l'arbo a partir de la BDD");
     if ($type == 'tache') {
         // On récupère tous les taches de la base
         $args_taches['id_tache'] = '*';
         $liste_taches = Taches_chercher($args_taches);
         $tab_intitules = array();
         foreach ($liste_taches as $tache) {
             $tab_intitules[$tache['id_tache']] = $tache['titre'];
             $tab_etats[$tache['id_tache']] = $tache['etat'];
             $tab_priorites[$tache['id_tache']] = $tache['data1'];
         }
     }
     if ($type == 'article') {
         // On récupère tous les articles de la base
         $args_articles['id_article'] = '*';
         $liste_articles = Articles_chercher($args_articles);
         $tab_intitules = array();
         $tab_urls = array();
         foreach ($liste_articles as $article) {
             $tab_intitules[$article['id_article']] = $article['titre'];
             $tab_etats[$article['id_article']] = $article['etat'];
             $tab_urls[$article['id_article']] = $article['meta_url'];
         }
     }
     $sql = " SELECT * \n\t\t\tFROM " . $GLOBALS['prefix'] . "arbo\n\t\t\tWHERE code_arbo = '{$code_arbo}'\n\t\t\tORDER BY famille ASC, ordre ASC";
     $result = Sql_query($sql);
     $tab_sql = array();
     if ($result && Sql_errorCode($result) === "00000") {
         while ($row = Sql_fetch($result)) {
             $id = $row['id_arbo'];
             $id_pere = $row['id_pere'];
             $type_pere = $row['type_pere'];
             $tab_sql[$id]["id_arbo"] = $id;
             $tab_sql[$id]["id_arbo_pere"] = $row['id_arbo_pere'];
             $tab_sql[$id]["code_arbo"] = $row['code_arbo'];
             $tab_sql[$id]["famille"] = $row['famille'];
             $tab_sql[$id]["id_pere"] = $id_pere;
             if ($type == 'tache') {
                 $tab_sql[$id]["tache"] = $liste_taches[$id_pere];
             }
             if ($type == 'article') {
                 $tab_sql[$id]["article"] = $liste_articles[$id_pere];
             }
             $tab_sql[$id]["type_pere"] = $type_pere;
             $tab_sql[$id]["ordre"] = $row['ordre'];
             $tab_sql[$id]["couleur"] = $row['couleur'];
             $tab_sql[$id]["etat"] = ($type_pere == 'article' || $type_pere == 'tache') && isset($tab_etats[$id_pere]) && $tab_etats[$id_pere] != '' ? $tab_etats[$id_pere] : $row['etat'];
             $tab_sql[$id]["intitule"] = ($type_pere == 'article' || $type_pere == 'tache') && isset($tab_intitules[$id_pere]) && $tab_intitules[$id_pere] != '' ? $tab_intitules[$id_pere] : Sql_prepareTexteAffichage($row['intitule']);
             $tab_sql[$id]["intitule_canonize"] = $row['intitule_canonize'];
             $tab_sql[$id]["priorite"] = $type_pere == 'tache' && isset($tab_priorites[$id_pere]) && $tab_priorites[$id_pere] != '' ? $tab_priorites[$id_pere] : '';
             if ($type_pere == 'tache' && isset($tab_etats[$id_pere]) && $tab_etats[$id_pere] == 'inactif') {
                 if ($row['famille'] != '' && $row['id_arbo_pere'] == 0) {
                     $tab_famille = explode('-', $row['famille']);
                     $index_pere = count($tab_famille) - 2;
                     $tab_sql[$tab_famille[$index_pere]]['nb_taches_a_faire']++;
                     if (!empty($tab_famille[$index_pere - 1])) {
                         $tab_sql[$tab_famille[$index_pere - 1]]['nb_taches_a_faire']++;
                     }
                 } else {
                     $tab_sql[$id]['nb_taches_a_faire'] = 0;
                 }
             }
             if ($type_pere == 'tache' && isset($tab_etats[$id_pere]) && $tab_etats[$id_pere] == 'actif') {
                 if ($row['famille'] != '' && $row['id_arbo_pere'] == 0) {
                     $tab_famille = explode('-', $row['famille']);
                     $index_pere = count($tab_famille) - 2;
                     $tab_sql[$tab_famille[$index_pere]]['nb_taches_terminees']++;
                     if (!empty($tab_famille[$index_pere - 1])) {
                         $tab_sql[$tab_famille[$index_pere - 1]]['nb_taches_terminees']++;
                     }
                 } else {
                     $tab_sql[$id]['nb_taches_terminees'] = 0;
                 }
             }
             // On détermine le niveau de profondeur dans l'arborescence
             $tab_sql[$id]["niveau"] = substr_count($row['famille'], "-");
         }
     }
     /*=============*/
     Lib_myLog("Tab sql:", $tab_sql);
     /*=============*/
     Lib_myLog("Construction de l'arbo");
     $tab_result = Arbo_getTab($tab_sql, 0, '');
     return $tab_result;
 }
 /**
  Renvoie la liste des événements vérifiant les conditions passées en argument sous forme d'un tableau
  @param $id_evenement Identifiant de l'evenement a chercher
  ...
 */
 function Evenements_chercher($id_utilisateur = '', $type_pere = '', $id_pere = '', $date_evenement = '', $type_evenement = '', $info_evenement = '')
 {
     $tab_result = array();
     $sql = " SELECT distinct(id_evenement), id_utilisateur, date_evenement, type_pere, id_pere, type_evenement, info_evenement\n          FROM " . $GLOBALS['prefix'] . "sys_evenements\n          WHERE 1";
     if ("{$id_utilisateur}" == "" && $type_pere == "" && "{$id_pere}" == "" && "{$date_evenement}" == "" && $type_evenement == "" && $type_evenement == "" && $info_evenement == "") {
         return $tab_result;
     }
     $condition = "";
     if ("{$id_utilisateur}" != "" && "{$id_utilisateur}" != "*") {
         $condition .= " AND id_utilisateur = {$id_utilisateur} ";
     }
     if ($type_pere != "" && $type_pere != "*") {
         $condition .= " AND type_pere = '{$type_pere}' ";
     }
     if ("{$id_pere}" != "" && "{$id_pere}" != "*") {
         $condition .= " AND id_pere = {$id_pere} ";
     }
     if ("{$date_evenement}" != "" && "{$date_evenement}" != "*") {
         $condition .= " AND date_evenement = {$date_evenement} ";
     }
     if ($type_evenement != "" && $type_evenement != "*") {
         $condition .= " AND type_evenement = '{$type_evenement}' ";
     }
     if ($info_evenement != "" && $info_evenement != "*") {
         $condition .= " AND info_evenement = '{$info_evenement}' ";
     }
     $condition .= " ORDER by date_evenement ASC";
     $sql .= $condition;
     $result = Sql_query($sql);
     if ($result && Sql_errorCode($result) === "00000") {
         while ($row = Sql_fetch($result)) {
             $tab_result[$row->id_evenement]["id_utilisateur"] = $row['id_utilisateur'];
             $tab_result[$row->id_evenement]["type_pere"] = $row['type_pere'];
             $tab_result[$row->id_evenement]["id_pere"] = $row['id_pere'];
             $tab_result[$row->id_evenement]["id_evenement"] = $row['id_evenement'];
             $tab_result[$row->id_evenement]["date_evenement"] = $row['date_evenement'];
             $tab_result[$row->id_evenement]["type_evenement"] = Sql_prepareTexteAffichage($row['type_evenement']);
             $tab_result[$row->id_evenement]["info_evenement"] = Sql_prepareTexteAffichage($row['info_evenement']);
         }
     }
     if (count($tab_result) == 1 && ($type_pere != '' && '$id_pere' != '' && $type_evenement != '' && $info_evenement != '')) {
         $tab_result = array_pop($tab_result);
     }
     return $tab_result;
 }