function main() { // Get top page $this->PageSubtitle = "Documentation"; //$sq="SELECT pagename FROM docpageshier WHERE pagehier=1"; //$pageroot=SQL_OneValue('pagename',$sq); $pageroot = 'Data Dictionary'; $pn = gp('gppn'); $pn = $pn == '' ? $pageroot : $pn; $sq = "SELECT * from docpages \n WHERE pagename = " . sql_format('char', $pn); $row = SQL_oneRow($sq); if ($row === false) { echo "Page does not exist: " . $pn; return; } // Get one parent. We used to get all of them, but now // we only want one $hmenu = ''; $attop = false; $parents = array(); $peers = array(); $kids = array(); $pparent = $pprev = $pnext = ''; $plast = $pn; while ($plast != $pageroot) { $sq = "SELECT pagename_par FROM docpages \n WHERE pagename = '{$plast}'"; $rownew = SQL_AllRows($sq); $plast = $rownew[0]['pagename_par']; $parents[] = $plast; //if ($rownew[0]['pagename_par'] == $pageroot) { // break; //} } if (count($parents) > 0) { $parents = array_reverse($parents); //$hmenu=adocs_makemenu($parents,'Parent Topics'); // Grab this page's peers $pparent = $parents[count($parents) - 1]; $sq = "SELECT pagename FROM docpages \n WHERE pagename_par = '{$pparent}'\n ORDER BY sequence"; $rs = SQL($sq); while ($rowx = SQL_Fetch_Array($rs)) { $peers[] = $rowx['pagename']; } $peersr = array_flip($peers); $pprev = $peersr[$pn] == 0 ? '' : $peers[$peersr[$pn] - 1]; $pnext = $peersr[$pn] == count($peers) - 1 ? '' : $peers[$peersr[$pn] + 1]; } // Now pull out the kids $sq = "SELECT pagename FROM docpages \n WHERE pagename_par = '{$pn}'\n ORDER BY sequence"; $rs = SQL($sq); while ($rowx = SQL_Fetch_Array($rs)) { $kids[] = $rowx['pagename']; } // Make and save a menu out of what we've discovered adocs_makemenu($pageroot, $pn, $parents, $peers); // Now format the page and save it. No caching for now. $html = $row['pagetext']; $html = $this->WikiProcess($html); /* // Remove carriage returns, makes things much easier $html=str_replace("\r",'',$html); // Convert newlines to double br's, but first don't do doubles // after headings $html=str_replace("=\n\n","=\n",$html); $html=preg_replace("/\n\s*\n/","\n<br><br>\n",$html); // Convert bold & italitcs $html=preg_replace( "/'{4,}(.*)'{4,}/xmsU" ,'<b><i>$1</i></b>' ,$html); $html=preg_replace( "/'{3}(.*)'{3}/xmsU" ,'<i>$1</i>' ,$html); $html=preg_replace( "/\'{2}(.*)\'{2}/xmsU" ,'<b>$1</b>' ,$html); // Convert 6 levels of title $html=preg_replace( "/={6}(.*)={6}/xsU" ,'<head6>$1</head6>' ,$html); $html=preg_replace( "/={5}(.*)={5}/xsU" ,'<head5>$1</head5>' ,$html); $html=preg_replace( "/={4}(.*)={4}/xsU" ,'<head4>$1</head4>' ,$html); $html=preg_replace( "/={3}(.*)={3}/xsU" ,'<head3>$1</head3>' ,$html); $html=preg_replace( "/={2}(.*)={2}/xsU" ,'<head2>$1</head2>' ,$html); $html=preg_replace( '/^=(.*)=$/U' ,'<head1>$1</head1>' ,$html); // convert hyperlinks and images $matches=array(); while(preg_match('/\[{2,}(.*)\]{2,}/xmsU',$html,$matches)>0) { $search=$matches[1]; $asearch=explode(':',$search); if(count($asearch)==2) { $type=$asearch[0]; $match=$asearch[1]; } else { $type='ilink'; $match=$search; } switch(strtolower($type)) { case 'ilink': $this->Linkilink($html,$match); break; case 'image': $this->LinkImage($html,$match,$type); break; } $matches=array(); } */ // Prepare a list of parents if (count($parents) == 0) { $apars = array($pn); } else { $apars = $parents; $apars[] = $pn; } $hpars = ''; foreach ($apars as $apar) { $hpars .= ($hpars == '' ? '' : ' > ') . '<a href="?gp_page=x_docview&gppn=' . urlencode($apar) . '">' . $apar . '</a>'; } // Prepare the prev, next stuff $hpn = ''; if ($pprev . $pnext != '') { $hp = $pprev == '' ? '' : '<a href="?gp_page=x_docview&gppn=' . urlencode($pprev) . '">PREV: ' . $pprev . '</a>'; $hn = $pnext == '' ? '' : '<a href="?gp_page=x_docview&gppn=' . urlencode($pnext) . '">NEXT: ' . $pnext . '</a>'; $hpn = "\n\t\t\t<div class=\"row\">\n\t\t\t<div class=\"span9\">\n\t\t\t\t<div class=\"pull-left\">{$hp}</div>\n\t\t\t\t<div class=\"pull-right\">{$hn}</div>\n\t\t\t</div>\n\t\t\t</div>"; } // Pull out and assemble the see-also groups $hsa = ''; /* $hsa=''; $sq='SELECT DISTINCT seealso FROM seealsoxpages ' ." WHERE pagename='$pn'"; $sas=SQL_AllRows($sq); foreach($sas as $sa) { $hsa.="<hr>"; $seealso=$sa['seealso']; $hsa.="<hr><h2>See Also ($seealso):</h2><p>"; $sq="SELECT pagename FROM seealsoxpages " ." WHERE seealso = '$seealso' " ." AND pagename <> '$pn'" ." ORDER By pagename "; $sarows=SQL_AllRows($sq); foreach($sarows as $index=>$sarow) { $hsa.=($index==0 ? '' : ', ') .'<a href="?gppn='.urlencode($sarow['pagename']).'">' .$sarow['pagename'].'</a>'; } $sarows.='</p>'; } */ // Now the actual output and formatting // $this->PageSubtitle = $pn; echo "<div class=\"hero-unit\">Database Specification</div>"; echo $hpars . "<br><br>"; echo $hpn; echo "\n<hr>"; echo "\n<h2>" . $pn . "</h2>\n"; echo $html; if (count($kids) > 0 && $pn == 'Data Dictionary') { echo "\n<hr>"; echo "\n<head2>Child Topics</head2>"; foreach ($kids as $kid) { echo "\n<div><a href=\"?gp_page=x_docview&gppn=" . urlencode($kid) . "\">{$kid}</a></div>"; } } echo $hsa; echo "<hr>"; echo $hpn; ?> <hr> Page last modified <?php echo date('r', dEnsureTS($row['ts_upd'])); ?> by <?php echo $row['uid_upd']; ?> <br><br> <?php }
//------------------------------------------------------------------------------ SUIVI /*--------------------------------------------------*/ /*ici ajouter la GESTION DES MODIFICATIONS ET SUIVI*/ /*-------------------------------------------------*/ } else { // ADD //------------------------------------------------------------------------------ Valeurs numériques if ($_POST['etape'] == "") { $_POST['etape'] = 2; } //------------------------------------------------------------------------------ /*Paramètre à ajouter*/ $in["cd_ref"] = sql_format_num($_POST["cd_ref"]); $in["famille"] = sql_format_quote($_POST["famille"], 'do'); $in["nom_sci"] = sql_format_quote($_POST["nom_sci"], 'do'); $in["cd_rang"] = sql_format($_POST["cd_rang"]); $in["nom_verna"] = sql_format_quote($_POST["nom_verna"], 'do'); $in["hybride"] = sql_format_bool($_POST["hybride"], 'do'); $rub[$id_page] = 'true'; $uid = add_taxon($in, $rub); add_suivi2($_POST["etape"], $id_user, $uid, "taxons", "nom", null, sql_format_num($_POST["nom_sci"]), 'applications', 'manuel', 'ajout'); add_suivi2($_POST["etape"], $id_user, $uid, "taxons", "uid", null, $uid, 'applications', 'manuel', 'ajout'); } /* if (!DEBUG) { echo ("<script language=\"javascript\" type=\"text/javascript\">"); echo ("window.location.replace ( \"index.php\")"); echo ("</script>"); } */ pg_close($db);
$code = ""; } $query = "UPDATE " . SQL_schema_app . ".utilisateur SET \n\tid_cbn=" . sql_format_num($_POST["id_cbn"]) . ",\n\tnom=" . sql_format($_POST["nom"]) . ",\n\tprenom=" . sql_format($_POST["prenom"]) . ",\n\t" . $code . "\n\ttel_bur=" . sql_format($_POST["tel_bur"]) . ",\n\ttel_port=" . sql_format($_POST["tel_port"]) . ",\n\ttel_int=" . sql_format($_POST["tel_int"]) . ",\n\temail=" . sql_format($_POST["email"]) . ",\n\tweb=" . sql_format($_POST["web"]) . ",\n\t" . $query_niveau . "\n\t" . $query_ref . "\n\tdescr=" . sql_format($_POST["descr"]) . " \n\tWHERE id_user='******';"; echo $query; $result = pg_query($db, $query) or die("Erreur pgSQL : " . pg_result_error($result)); add_log("log", 4, $id_user, getenv("REMOTE_ADDR"), "Admin. edit user", $id, "utilisateur"); } else { //------------------------------------------------------------------------------ ADD foreach ($rubrique as $key => $val) { if (empty($_POST["niveau_" . $key])) { $_POST["niveau_" . $key] = 0; } $val_niveau .= sql_format_num($_POST["niveau_" . $key]) . ","; $key_niveau .= "niveau_" . $key . ","; if (empty($_POST["ref_" . $key])) { $_POST["ref_" . $key] = 0; } $val_ref .= sql_format_bool($_POST["ref_" . $key]) . ","; $key_ref .= "ref_" . $key . ","; } $id = strtoupper(substr(stripAccents($_POST['prenom']), 0, 2) . substr(stripAccents($_POST['nom']), 0, 2)) . mt_rand(1, 9); $query = "INSERT INTO " . SQL_schema_app . ".utilisateur (id_user, id_cbn,nom,prenom,login,pw,tel_bur,tel_port,tel_int,email,web,\n\t{$key_niveau}\n\t{$key_ref}\n\tdescr)\n\tVALUES (\n\t\t'" . $id . "',\n\t\t" . sql_format_num($_POST["id_cbn"]) . ",\n\t\t" . sql_format($_POST["nom"]) . ",\n\t\t" . sql_format($_POST["prenom"]) . ",\n\t\t" . sql_format($_POST["login"]) . ",\n\t\t" . sql_format($_POST["pw"]) . ",\n\t\t" . sql_format($_POST["tel_bur"]) . ",\n\t\t" . sql_format($_POST["tel_port"]) . ",\n\t\t" . sql_format($_POST["tel_int"]) . ",\n\t\t" . sql_format($_POST["email"]) . ",\n\t\t" . sql_format($_POST["web"]) . ",\n\t\t{$val_niveau} {$val_ref}\n\t\t" . sql_format($_POST["descr"]) . ");"; echo $query; $result = pg_query($db, $query) or die("Erreur pgSQL : " . pg_result_error($result)); add_log("log", 4, $id_user, getenv("REMOTE_ADDR"), "Admin. ajout user", $id, "utilisateur"); } //------------------------------------------------------------------------------ FONCTIONS function stripAccents($string) { return strtr($string, 'àáâãäçèéêëìíîïñòóôõöùúûüýÿÀÁÂÃÄÇÈÉÊËÌÍÎÏÑÒÓÔÕÖÙÚÛÜÝ', 'aaaaaceeeeiiiinooooouuuuyyAAAAACEEEEIIIINOOOOOUUUUY'); }
}); </script> <?php //------------------------------------------------------------------------------ MAIN if (isset($_POST['submit'])) { // MaJ table /* //A faire dans la base de données? alter table syntaxa.st_cortege_floristique add column code_referentiel text; alter table syntaxa.st_cortege_floristique add column version_referentiel text; alter table syntaxa.st_cortege_floristique add column cd_ref text; alter table syntaxa.st_cortege_floristique add column nom_complet text; alter table syntaxa.st_cortege_floristique add column "rqTaxon" text; */ //echo "commentaire:".$_POST['COMM']."<br>"; //echo "commentaire utf8:".utf8_encode($_POST['COMM'])."<br>"; $query = "INSERT INTO " . $table . " (\"codeEnregistrementSyntaxon\",code_referentiel,version_referentiel,\"idRattachementReferentiel\",cd_ref,nom_complet,\"rqTaxon\") VALUES ('" . $idsyntaxon . "','TAXREF','7','" . $idrattachement . "'," . $CD_REF . ",'" . utf8_encode($taxon) . "'," . utf8_encode(sql_format($COMM)) . ");"; $query .= "INSERT INTO applications.suivi (etape,id_user, tables,champ,valeur_1,valeur_2,datetime,rubrique,methode,type_modif,libelle_1,libelle_2,uid) VALUES ('2','" . $iduser . "','st_cortege_floristique','idRattachementReferentiel','','" . $idrattachement . "',NOW(),'syntaxa','manuel','ajout','','" . $taxon . "','" . $idsyntaxon . "');"; // $query="INSERT INTO ".$table." (\"codeEnregistrementSyntaxon\",code_referentiel,version_referentiel,cd_ref,nom_complet,\"rqTaxon\") VALUES ('".$idsyntaxon."','TAXREF','7',".$CD_REF.",'".$taxon."',".sql_format($COMM).");"; echo "idrattachement:" . $idrattachement . "<br>"; echo $query . "<br>"; $result = pg_query($db, $query) or fatal_error("Erreur pgSQL : " . pg_result_error($result), false); } $query = "SELECT * FROM " . $table . " WHERE \"codeEnregistrementSyntaxon\"='" . $idsyntaxon . "';"; // Affiche la liste //echo $query; $result = pg_query($db, $query) or fatal_error("Erreur pgSQL : " . pg_result_error($result), false); echo "<table border=1 class=\"list\" >"; if (pg_num_rows($result) > 0) { while ($row = pg_fetch_array($result)) { //<td valign="middle" width="100%">'.utf8_encode($row['nom_complet']).' '.utf8_encode($row['rqTaxon']).'</td> echo '<tr class=\\"list\\" ><form id="form" action="taxon_delete.php?id=' . $row['idCortegeFloristique'] . '" method="post">
if ($action == "photo") { add_log("log", 1, "", getenv("REMOTE_ADDR"), "Photothèque", "", ""); echo "<script language=\"javascript\" type=\"text/javascript\">"; echo "window.open ( \"../../phototheque/index.php\")"; echo "</script>"; } break; case "valid": $user_login = $_POST['user_login']; $user_pw = $_POST['user_pw']; if (!empty($user_login) && !empty($user_pw)) { foreach ($rubrique as $key => $val) { $sql_niveau .= 'niveau_' . $val . ','; $sql_ref .= 'ref_' . $val . ','; } $query = "SELECT {$sql_niveau} {$sql_ref} id_user\n\t\t\tFROM applications.utilisateur \n\t\t\tWHERE login="******" AND pw=" . sql_format($user_pw) . ";"; $result = pg_query($db, $query) or fatal_error("Erreur pgSQL : " . pg_result_error($result), false); if (pg_num_rows($result)) { $_SESSION['EVAL_FLORE'] = "ok"; /*niveau de droit et référents*/ $_SESSION['niveau'] = 0; foreach ($rubrique as $key => $val) { $_SESSION['niveau_' . $val] = pg_result($result, 0, "niveau_" . $val); $_SESSION['niveau'] = max($_SESSION['niveau'], $_SESSION['niveau_' . $val]); $_SESSION['ref_' . $val] = pg_result($result, 0, "ref_" . $val); $_SESSION['ref'] = $_SESSION['ref'] = 't' or $_SESSION['ref_' . $val] = 't' ? 't' : 'f'; } $_SESSION['id_user'] = pg_result($result, 0, "id_user"); add_log("log", 3, pg_result($result, 0, "id_user"), getenv("REMOTE_ADDR"), "Login", $user_login, ""); die("<meta HTTP-equiv=\"refresh\" content=0;url=index.php />"); } else {
function add_suivi($etape, $id_user, $id, $table, $champ, $valeur_1, $valeur_2) { global $db; $query = "INSERT INTO applications.suivi (etape,id_user,uid,tables,champ,valeur_1,valeur_2,datetime) VALUES \n (" . $etape . ",'" . $id_user . "'," . $id . ",'" . $table . "','" . $champ . "'," . sql_format($valeur_1) . "," . sql_format($valeur_2) . ",NOW());"; // echo "<br>".$query; $result = pg_query($db, $query) or die("Erreur pgSQL : " . pg_result_error($result)); }
// Version 1.10 10/08/14 - MaJ pgSQL // //------------------------------------------------------------------------------// //----------------------------------------------------------------------------- INIT. include "../../_INCLUDE/config_sql.inc.php"; include "../../_INCLUDE/fonctions.inc.php"; //------------------------------------------------------------------------------ PARMS. $id = $_POST['id']; //------------------------------------------------------------------------------ VAR. //------------------------------------------------------------------------------ CONNEXION SERVEUR PostgreSQL $db = sql_connect(SQL_base); if (!$db) { fatal_error("Impossible de se connecter au serveur PostgreSQL.", false); } //------------------------------------------------------------------------------ MAIN if (!empty($id)) { $query = "UPDATE " . SQL_schema_app . ".bug SET "; foreach ($_POST as $field => $val) { if ($field == "descr") { $query .= $field . "=" . sql_format_quote($val, 'do') . ","; } elseif ($field == "statut_descr") { $query .= $field . "=" . sql_format_quote($val, 'do') . ","; } elseif ($field != "id") { $query .= $field . "=" . sql_format($val) . ","; } } $query = rtrim($query, ","); $query .= " WHERE id_bug=" . $id; $result = pg_query($db, $query) or die("Erreur pgSQL : " . pg_result_error($result)); } //------------------------------------------------------------------------------ FONCTIONS pg_close();
$in["famille"] = sql_format_quote($_POST["famille"], 'do'); $in["fr"] = sql_format($_POST["fr"]); $in["gf"] = sql_format($_POST["gf"]); $in["mar"] = sql_format($_POST["mar"]); $in["gua"] = sql_format($_POST["gua"]); $in["sm"] = sql_format($_POST["sm"]); $in["sb"] = sql_format($_POST["sb"]); $in["spm"] = sql_format($_POST["spm"]); $in["may"] = sql_format($_POST["may"]); $in["epa"] = sql_format($_POST["epa"]); $in["reu"] = sql_format($_POST["reu"]); $in["taaf"] = sql_format($_POST["taaf"]); $in["pf"] = sql_format($_POST["pf"]); $in["nc"] = sql_format($_POST["nc"]); $in["wf"] = sql_format($_POST["wf"]); $in["cli"] = sql_format($_POST["cli"]); $in["habitat"] = sql_format_num($_POST["habitat"], 'do'); $in["catnat"] = sql_format_bool($_POST["catnat"]); $in["lr"] = sql_format_bool($_POST["lr"]); $in["eee"] = sql_format_bool($_POST["eee"]); $in["hybride"] = sql_format_bool($_POST["hybride"], 'do'); // var_dump($in); //------------------------------------------------------------------------------ EDIT if (!empty($id)) { if ($niveau >= 128) { /*SUIVI DES MODIFICATIONS ET UPDATE*/ if (!isset($_POST["etape"])) { $etape = 1; } else { $etape = $_POST["etape"]; }
if (isset($_POST['i']) & !empty($_POST['i'])) { $pk = stripslashes($_POST['i']); } //l'identifiant correspond à l'id export-TXT-query-id de type hidden qui se retrouve dans index.php (qui appelle une query de commun.inc.php) //------------------------------------------------------------------------------ CONNEXION SERVEUR PostgreSQL $db = sql_connect(SQL_base); if (!$db) { fatal_error("Impossible de se connecter au serveur PostgreSQL.", false); } //------------------------------------------------------------------------------ MAIN $_POST['select'] = str_replace('%5B%5D', '', $_POST['select']); //permet de supprimer des caractères spéciaux générés pour le xml (ajaxSubmit) if (strlen($_POST['select']) > 0) { // Sélection ? $sWhere = "( "; $pairs = explode("&", $_POST['select']); foreach ($pairs as $key => $value) { $sWhere .= $pk . "=" . sql_format(ltrim($value, "id=")) . " OR "; } $sWhere = rtrim($sWhere, "OR "); $sWhere .= " ) "; $query2 = "{$query} AND {$sWhere}"; // echo "export_TXT > sWhere=".$sWhere; } else { // Liste totale $query2 = $query; } echo "export_TXT > sql=" . $query2 . "<br>"; export_txt($nom_fichier, $query2); //fonction contenue dans functions.inc.php //------------------------------------------------------------------------------ FONCTIONS
function add_log($table, $id_type, $id_user, $ip, $descr1, $descr2, $tables) { global $db; $query = "INSERT INTO " . SQL_schema_app . "." . $table . " (event,id_user,ip,descr1,descr2,tables,datetime_event) VALUES (" . $id_type . ",'" . $id_user . "','" . $ip . "'," . sql_format($descr1) . "," . sql_format($descr2) . "," . sql_format($tables) . ",NOW());"; $result = pg_query($db, $query) or fatal_error("Erreur pgSQL : " . pg_result_error($result), false); }
/** * Mark domain as deleted * * Possible options: * * - did (int) - REQUIRED - id of domain which will be deleted * (default: null) * - undelete (bool) - undelete domain, setting this to true will * undelete only domain names and domain attrs. Not * URIs and credentials within the domain * (default: false) * * @param array $opt associative array of options * @return bool TRUE on success, FALSE on failure */ function mark_domain_deleted($opt) { global $config; $errors = array(); if (!$this->connect_to_db($errors)) { ErrorHandler::add_error($errors); return false; } /* table's name */ $td_name =& $config->data_sql->domain->table_name; $ta_name =& $config->data_sql->domain_attrs->table_name; $tu_name =& $config->data_sql->uri->table_name; $tc_name =& $config->data_sql->credentials->table_name; /* col names */ $cd =& $config->data_sql->domain->cols; $ca =& $config->data_sql->domain_attrs->cols; $cu =& $config->data_sql->uri->cols; $cc =& $config->data_sql->credentials->cols; /* flags */ $fd =& $config->data_sql->domain->flag_values; $fa =& $config->data_sql->domain_attrs->flag_values; $fu =& $config->data_sql->uri->flag_values; $fc =& $config->data_sql->credentials->flag_values; $an =& $config->attr_names; $o_did = isset($opt['did']) ? $opt['did'] : null; $o_undelete = isset($opt['undelete']) ? (bool) $opt['undelete'] : false; if (is_null($o_did)) { ErrorHandler::log_errors(PEAR::raiseError('domain for mark as deleted is not specified')); return false; } /* if 'did' column in credentials table is not used, make list of all realms matching this domain */ if (!$config->auth['use_did']) { $dh =& Domains::singleton(); if (false === ($dom_names = $dh->get_domain_names($o_did))) { return false; } $da =& Domain_Attrs::singleton($o_did); if (false === ($realm = $da->get_attribute($config->attr_names['digest_realm']))) { return false; } $realms_w = array(); if (!is_null($realm)) { $realms_w[] = $cc->realm . " = " . $this->sql_format($realm, "s"); } foreach ($dom_names as $v) { $realms_w[] = $cc->realm . " = " . $this->sql_format($v, "s"); } } if (false === $this->transaction_start()) { return false; } $domain_attrs =& Domain_Attrs::singleton($o_did); if ($o_undelete) { if (false === $domain_attrs->unset_attribute($an['deleted_ts'])) { $this->transaction_rollback(); return false; } } else { if (false === $domain_attrs->set_attribute($an['deleted_ts'], time())) { $this->transaction_rollback(); return false; } } $q = "update " . $td_name . " set "; if ($o_undelete) { $q .= $cd->flags . " = " . $cd->flags . " & ~" . $fd['DB_DELETED']; } else { $q .= $cd->flags . " = " . $cd->flags . " | " . $fd['DB_DELETED']; } $q .= " where " . $cd->did . " = " . $this->sql_format($o_did, "s"); $res = $this->db->query($q); if (DB::isError($res)) { ErrorHandler::log_errors($res); $this->transaction_rollback(); return false; } $q = "update " . $ta_name . " set "; if ($o_undelete) { $q .= $ca->flags . " = " . $ca->flags . " & ~" . $fa['DB_DELETED']; } else { $q .= $ca->flags . " = " . $ca->flags . " | " . $fa['DB_DELETED']; } $q .= " where " . $ca->did . " = " . $this->sql_format($o_did, "s"); $res = $this->db->query($q); if (DB::isError($res)) { ErrorHandler::log_errors($res); $this->transaction_rollback(); return false; } if (!$o_undelete) { $q = "update " . $tu_name . " set "; $q .= $cu->flags . " = " . $cu->flags . " | " . $fu['DB_DELETED']; $q .= " where " . $cu->did . " = " . $this->sql_format($o_did, "s"); $res = $this->db->query($q); if (DB::isError($res)) { ErrorHandler::log_errors($res); $this->transaction_rollback(); return false; } $q = "update " . $tc_name . " set "; $q .= $cc->flags . " = " . $cc->flags . " | " . $fc['DB_DELETED']; if ($config->auth['use_did']) { $q .= " where " . $cc->did . " = " . $this->sql_format($o_did, "s"); } else { if (!$realms_w) { $q .= " where " . $this - sql_format(false, "b"); } else { $q .= " where " . implode($realms_w, " or "); } } $res = $this->db->query($q); if (DB::isError($res)) { ErrorHandler::log_errors($res); $this->transaction_rollback(); return false; } } if (false === $this->transaction_commit()) { return false; } return true; }
$query = "INSERT INTO catnat.statut_reg (uid, id_reg, nom_reg, type_statut, id_statut, nom_statut) VALUES ({$id}, {$id_reg}, " . frt('nom_reg', $region) . ", '{$type_stt}', '{$new_val}', '{$lib_stt}');"; if (DEBUG) { echo "<BR>{$query}"; } $result = pg_query($db, $query) or die("Erreur pgSQL : " . $query); add_suivi2($etape, $id_user, $id, "statut_reg", "statut_" . $type_stt, $old_val, $new_val, 'catnat', 'manuel', 'ajout'); } elseif ($new_val == null) { $query = "DELETE FROM catnat.statut_reg WHERE uid = {$id} AND id_statut = '{$old_val}' AND id_reg = '{$id_reg}'"; if (DEBUG) { echo "<BR>{$query}"; } $result = pg_query($db, $query) or die("Erreur pgSQL : " . $query); add_suivi2($etape, $id_user, $id, "statut_reg", "statut_" . $type_stt, $old_val, $new_val, 'catnat', 'manuel', 'suppr'); } else { /*Autres cas = modif*/ $valeur = sql_format($_POST[$val_st]); $query = "UPDATE catnat.statut_reg SET (id_statut, nom_statut) = ('{$new_val}', '{$lib_stt}') WHERE uid = {$id} AND id_statut = '{$old_val}' AND id_reg = '{$id_reg}' and type_statut = '{$type_stt}'"; if (DEBUG) { echo "<BR>{$query}"; } $result = pg_query($db, $query) or die("Erreur pgSQL : " . $query); add_suivi2($etape, $id_user, $id, "statut_reg", "statut_" . $type_stt, $old_val, $new_val, 'catnat', 'manuel', 'modif'); } } } } /*statut_nat*/ $coor_stt = array("indi" => "INDI", "lr" => "LR", "rarete" => "RAR", "endemisme" => "END", "presence" => "PRES"); $query = "SELECT indi, lr, rarete, endemisme, presence FROM catnat.statut_nat\tWHERE uid={$id};"; if (DEBUG) { echo "<br>" . $query;
/** * Get array of uids which URIs and credentials asociated ONLY with * the domain. And not with any other domain. * * Possible options: * - none * * @param string $did Domain ID * @param array $opt array of options * @return array FALSE on error */ function get_uid_of_domain($did, $opt) { global $config; $errors = array(); if (!$this->connect_to_db($errors)) { ErrorHandler::add_error($errors); return false; } /* table's name */ $tu_name =& $config->data_sql->uri->table_name; $tc_name =& $config->data_sql->credentials->table_name; /* col names */ $cu =& $config->data_sql->uri->cols; $cc =& $config->data_sql->credentials->cols; /* flags */ $fu =& $config->data_sql->uri->flag_values; $fc =& $config->data_sql->credentials->flag_values; /* if 'did' column in credentials table is not used, make list of all realms matching this domain */ if (!$config->auth['use_did']) { $dh =& Domains::singleton(); if (false === ($dom_names = $dh->get_domain_names($did))) { return false; } $da =& Domain_Attrs::singleton($did); if (false === ($realm = $da->get_attribute($config->attr_names['digest_realm']))) { return false; } $realms_w1 = array(); $realms_w2 = array(); if (!is_null($realm)) { $realms_w1[] = $cc->realm . " = " . $this->sql_format($realm, "s"); $realms_w2[] = $cc->realm . " != " . $this->sql_format($realm, "s"); } foreach ($dom_names as $v) { $realms_w1[] = $cc->realm . " = " . $this->sql_format($v, "s"); $realms_w2[] = $cc->realm . " != " . $this->sql_format($v, "s"); } } $uids = array(); /* get list of UIDs which have URI asociated with the domain */ $q = "select distinct " . $cu->uid . " as uid\n from " . $tu_name . "\n where " . $cu->did . " = " . $this->sql_format($did, "s") . " and \n (" . $cu->flags . " & " . $fu['DB_DISABLED'] . ") = 0"; $res = $this->db->query($q); if (DB::isError($res)) { ErrorHandler::log_errors($res); return false; } /* add the list to UIDs array */ while ($row = $res->fetchRow(DB_FETCHMODE_ASSOC)) { $uids[$row['uid']] = true; } /* get list of UIDs which have credentials asociated with the domain */ if ($config->auth['use_did']) { $q = "select distinct " . $cc->uid . " as uid\n from " . $tc_name . "\n where " . $cc->did . " = " . $this->sql_format($did, "s") . " and \n (" . $cc->flags . " & " . $fc['DB_DISABLED'] . ") = 0"; } else { if (!$realms_w1) { $realms_w1 = array($this - sql_format(false, "b")); } $q = "select distinct " . $cc->uid . " as uid\n from " . $tc_name . "\n where (" . implode($realms_w1, " or ") . ") and \n (" . $cc->flags . " & " . $fc['DB_DISABLED'] . ") = 0"; } $res = $this->db->query($q); if (DB::isError($res)) { ErrorHandler::log_errors($res); return false; } /* add the list to UIDs array */ while ($row = $res->fetchRow(DB_FETCHMODE_ASSOC)) { $uids[$row['uid']] = true; } /* get list of UIDs which have URI asociated with other domains */ $q = "select distinct " . $cu->uid . " as uid\n from " . $tu_name . "\n where " . $cu->did . " != " . $this->sql_format($did, "s") . " and \n (" . $cu->flags . " & " . $fu['DB_DISABLED'] . ") = 0"; $res = $this->db->query($q); if (DB::isError($res)) { ErrorHandler::log_errors($res); return false; } /* and remove them from UIDs array */ while ($row = $res->fetchRow(DB_FETCHMODE_ASSOC)) { if (isset($uids[$row['uid']])) { unset($uids[$row['uid']]); } } /* get list of UIDs which have credentials asociated with other domains */ if ($config->auth['use_did']) { $q = "select distinct " . $cc->uid . " as uid\n from " . $tc_name . "\n where " . $cc->did . " != " . $this->sql_format($did, "s") . " and \n (" . $cc->flags . " & " . $fc['DB_DISABLED'] . ") = 0"; } else { if (!$realms_w2) { $realms_w1 = array($this - sql_format(true, "b")); } $q = "select distinct " . $cc->uid . " as uid\n from " . $tc_name . "\n where (" . implode($realms_w2, " and ") . ") and \n (" . $cc->flags . " & " . $fc['DB_DISABLED'] . ") = 0"; } $res = $this->db->query($q); if (DB::isError($res)) { ErrorHandler::log_errors($res); return false; } /* and remove them from UIDs array */ while ($row = $res->fetchRow(DB_FETCHMODE_ASSOC)) { if (isset($uids[$row['uid']])) { unset($uids[$row['uid']]); } } return array_keys($uids); }
switch ($action) { default: break; case "add": $query = "INSERT INTO " . SQL_schema_app . ".bug ("; foreach ($_POST as $field => $val) { if ($field != "action") { $query .= $field . ","; } } $query .= "date_bug) VALUES ("; foreach ($_POST as $field => $val) { if ($field == "descr") { $query .= sql_format_quote($val, 'do') . ","; } elseif ($field != "action") { $query .= sql_format($val) . ","; } } $query .= "NOW())"; // echo $query; $result = pg_query($db, $query) or fatal_error("Erreur pgSQL : " . pg_result_error($result), false); break; } $id_page = "bug-encours"; echo "<div id=\"" . $id_page . "-dialog\"></div>"; aff_table($id_page . "-liste", true, false); echo "</div>"; //------------------------------------------------------------------------------ #Traités echo "<div id=\"tab-ok\" style=\"margin:0;padding:5;min-height:700px;\">"; $id_page = "bug-ok"; echo "<div id=\"" . $id_page . "-dialog\"></div>";