function critere_isbn($val1)
{
    $val = $val1;
    if (isEAN($val1)) {
        // la saisie est un EAN -> on tente de le formater en ISBN
        $val1 = z_EANtoISBN($val1);
        // si échec, on prend l'EAN comme il vient
        if (!$val1) {
            $val1 = $val;
        }
    } else {
        if (isISBN($val1)) {
            // si la saisie est un ISBN
            $val1 = z_formatISBN($val1, 13);
            // si échec, ISBN erroné on le prend sous cette forme
            if (!$val1) {
                $val1 = $val;
            }
        } else {
            // ce n'est rien de tout ça, on prend la saisie telle quelle
            $val1 = $val;
        }
    }
    return $val1;
}
示例#2
0
 function make_search($prefixe = "")
 {
     global $search;
     global $dbh;
     global $msg;
     global $include_path;
     global $pmb_multi_search_operator;
     global $pmb_search_stemming_active;
     $this->error_message = "";
     $last_table = "";
     $field_keyName = $this->keyName;
     //Pour chaque champ
     for ($i = 0; $i < count($search); $i++) {
         //construction de la requete
         $s = explode("_", $search[$i]);
         //Recuperation de l'operateur
         $op = "op_" . $i . "_" . $search[$i];
         //Recuperation du contenu de la recherche
         $field_ = "field_" . $i . "_" . $search[$i];
         global ${$field_};
         $field = ${$field_};
         //Recuperation de l'operateur inter-champ
         $inter = "inter_" . $i . "_" . $search[$i];
         global ${$inter};
         global ${$op};
         //Recuperation des variables auxiliaires
         $fieldvar_ = "fieldvar_" . $i . "_" . $search[$i];
         global ${$fieldvar_};
         $fieldvar = ${$fieldvar_};
         //Si c'est un champ fixe
         if ($s[0] == "f") {
             $ff = $this->fixedfields[$s[1]];
             //Choix du moteur
             if ($this->memory_engine_allowed && !$ff['MEMORYENGINEFORBIDDEN']) {
                 $this->current_engine = 'MEMORY';
             } else {
                 $this->current_engine = 'MyISAM';
             }
             //Calcul des variables
             $var_table = array();
             for ($j = 0; $j < count($ff["VAR"]); $j++) {
                 switch ($ff["VAR"][$j]["TYPE"]) {
                     case "input":
                         $var_table[$ff["VAR"][$j]["NAME"]] = @implode(",", $fieldvar[$ff["VAR"][$j]["NAME"]]);
                         break;
                     case "global":
                         $global_name = $ff["VAR"][$j]["NAME"];
                         global ${$global_name};
                         $var_table[$ff["VAR"][$j]["NAME"]] = ${$global_name};
                         break;
                     case "calculated":
                         $calc = $ff["VAR"][$j]["OPTIONS"]["CALC"][0];
                         switch ($calc["TYPE"]) {
                             case "value_from_query":
                                 $query_calc = $calc["QUERY"][0]["value"];
                                 @reset($var_table);
                                 while (list($var_name, $var_value) = @each($var_table)) {
                                     $query_calc = str_replace("!!" . $var_name . "!!", $var_value, $query_calc);
                                 }
                                 $r_calc = pmb_mysql_query($query_calc);
                                 $var_table[$ff["VAR"][$j]["NAME"]] = @pmb_mysql_result($r_calc, 0, 0);
                                 break;
                         }
                         break;
                 }
             }
             $q_index = $ff["QUERIES_INDEX"];
             //Recuperation de la requete associee au champ et a l'operateur
             $q = $ff["QUERIES"][$q_index[${$op}]];
             //Si c'est une requete conditionnelle, on sélectionne la bonne requete et on supprime les autres
             if ($q[0]["CONDITIONAL"]) {
                 $k_default = 0;
                 $q_temp = array();
                 $q_temp["OPERATOR"] = $q["OPERATOR"];
                 for ($k = 0; $k < count($q) - 1; $k++) {
                     if ($var_table[$q[$k]["CONDITIONAL"]["name"]] == $q[$k]["CONDITIONAL"]["value"]) {
                         break;
                     }
                     if ($q[$k]["CONDITIONAL"]["value"] == "default") {
                         $k_default = $k;
                     }
                 }
                 if ($k == count($q) - 1) {
                     $k = $k_default;
                 }
                 $q_temp[0] = $q[$k];
                 $q = $q_temp;
             }
             //Remplacement par les variables eventuelles pour chaque requete
             for ($k = 0; $k < count($q) - 1; $k++) {
                 reset($var_table);
                 while (list($var_name, $var_value) = each($var_table)) {
                     $q[$k]["MAIN"] = str_replace("!!" . $var_name . "!!", $var_value, $q[$k]["MAIN"]);
                     $q[$k]["MULTIPLE_TERM"] = str_replace("!!" . $var_name . "!!", $var_value, $q[$k]["MULTIPLE_TERM"]);
                 }
             }
             $last_main_table = "";
             // pour les listes, si un opérateur permet une valeur vide, il en faut une...
             if ($this->op_empty[${$op}] && !is_array($field)) {
                 $field = array();
                 $field[0] = "";
             }
             // si sélection d'autorité et champ vide : on ne doit pas le prendre en compte
             if (${$op} == 'AUTHORITY') {
                 $suppr = false;
                 foreach ($field as $k => $v) {
                     if ($v == 0) {
                         unset($field[$k]);
                         $suppr = true;
                     }
                 }
                 if ($suppr) {
                     $field = array_values($field);
                 }
             }
             //Pour chaque valeur du champ
             for ($j = 0; $j < count($field); $j++) {
                 //Pour chaque requete
                 $field_origine = $field[$j];
                 for ($z = 0; $z < count($q) - 1; $z++) {
                     //Pour chaque valeur du cha
                     //Si le nettoyage de la saisie est demande
                     if ($q[$z]["KEEP_EMPTYWORD"]) {
                         $field[$j] = strip_empty_chars($field_origine);
                     } elseif ($q[$z]["REGDIACRIT"]) {
                         $field[$j] = strip_empty_words($field_origine);
                     } elseif ($q[$z]["DETECTDATE"]) {
                         $field[$j] = detectFormatDate($field_origine, $q[$z]["DETECTDATE"]);
                     }
                     $main = $q[$z]["MAIN"];
                     //Si il y a plusieurs termes possibles on construit la requete avec le terme !!multiple_term!!
                     if ($q[$z]["MULTIPLE_WORDS"]) {
                         $terms = explode(" ", $field[$j]);
                         //Pour chaque terme,
                         $multiple_terms = array();
                         for ($k = 0; $k < count($terms); $k++) {
                             $multiple_terms[] = str_replace("!!p!!", $terms[$k], $q[$z]["MULTIPLE_TERM"]);
                         }
                         $final_term = implode(" " . $q[$z]["MULTIPLE_OPERATOR"] . " ", $multiple_terms);
                         $main = str_replace("!!multiple_term!!", $final_term, $main);
                         //Si la saisie est un ISBN
                     } else {
                         if ($q[$z]["ISBN"]) {
                             //Code brut
                             $terms[0] = $field[$j];
                             //EAN ?
                             if (isEAN($field[$j])) {
                                 //C'est un isbn ?
                                 if (isISBN($field[$j])) {
                                     $rawisbn = preg_replace('/-|\\.| /', '', $field[$j]);
                                     //On envoi tout ce qu'on sait faire en matiere d'ISBN, en raw et en formatte, en 10 et en 13
                                     $terms[1] = formatISBN($rawisbn, 10);
                                     $terms[2] = formatISBN($rawisbn, 13);
                                     $terms[3] = preg_replace('/-|\\.| /', '', $terms[1]);
                                     $terms[4] = preg_replace('/-|\\.| /', '', $terms[2]);
                                 }
                             } else {
                                 if (isISBN($field[$j])) {
                                     $rawisbn = preg_replace('/-|\\.| /', '', $field[$j]);
                                     //On envoi tout ce qu'on sait faire en matiere d'ISBN, en raw et en formatte, en 10 et en 13
                                     $terms[1] = formatISBN($rawisbn, 10);
                                     $terms[2] = formatISBN($rawisbn, 13);
                                     $terms[3] = preg_replace('/-|\\.| /', '', $terms[1]);
                                     $terms[4] = preg_replace('/-|\\.| /', '', $terms[2]);
                                 }
                             }
                             //Pour chaque terme,
                             $multiple_terms = array();
                             for ($k = 0; $k < count($terms); $k++) {
                                 $multiple_terms[] = str_replace("!!p!!", $terms[$k], $q[$z]["MULTIPLE_TERM"]);
                             }
                             $final_term = implode(" " . $q[$z]["MULTIPLE_OPERATOR"] . " ", $multiple_terms);
                             $main = str_replace("!!multiple_term!!", $final_term, $main);
                         } else {
                             if ($q[$z]["BOOLEAN"]) {
                                 if ($q[$z]['STEMMING']) {
                                     $stemming = $pmb_search_stemming_active;
                                 } else {
                                     $stemming = 0;
                                 }
                                 $aq = new analyse_query($field[$j], 0, 0, 1, 0, $stemming);
                                 $aq1 = new analyse_query($field[$j], 0, 0, 1, 1, $stemming);
                                 if ($q[$z]["KEEP_EMPTY_WORDS_FOR_CHECK"]) {
                                     $err = $aq1->error;
                                 } else {
                                     $err = $aq->error;
                                 }
                                 if (!$err) {
                                     if (is_array($q[$z]["TABLE"])) {
                                         for ($z1 = 0; $z1 < count($q[$z]["TABLE"]); $z1++) {
                                             $is_fulltext = false;
                                             if ($q[$z]["FULLTEXT"][$z1]) {
                                                 $is_fulltext = true;
                                             }
                                             if (!$q[$z]["KEEP_EMPTY_WORDS"][$z1]) {
                                                 $members = $aq->get_query_members($q[$z]["TABLE"][$z1], $q[$z]["INDEX_L"][$z1], $q[$z]["INDEX_I"][$z1], $q[$z]["ID_FIELD"][$z1], $q[$z]["RESTRICT"][$z1], 0, 0, $is_fulltext);
                                             } else {
                                                 $members = $aq1->get_query_members($q[$z]["TABLE"][$z1], $q[$z]["INDEX_L"][$z1], $q[$z]["INDEX_I"][$z1], $q[$z]["ID_FIELD"][$z1], $q[$z]["RESTRICT"][$z1], 0, 0, $is_fulltext);
                                             }
                                             $main = str_replace("!!pert_term_" . ($z1 + 1) . "!!", $members["select"], $main);
                                             $main = str_replace("!!where_term_" . ($z1 + 1) . "!!", $members["where"], $main);
                                         }
                                     } else {
                                         $is_fulltext = false;
                                         if ($q[$z]["FULLTEXT"]) {
                                             $is_fulltext = true;
                                         }
                                         if ($q[$z]["KEEP_EMPTY_WORDS"]) {
                                             $members = $aq1->get_query_members($q[$z]["TABLE"], $q[$z]["INDEX_L"], $q[$z]["INDEX_I"], $q[$z]["ID_FIELD"], $q[$z]["RESTRICT"], 0, 0, $is_fulltext);
                                         } else {
                                             $members = $aq->get_query_members($q[$z]["TABLE"], $q[$z]["INDEX_L"], $q[$z]["INDEX_I"], $q[$z]["ID_FIELD"], $q[$z]["RESTRICT"], 0, 0, $is_fulltext);
                                         }
                                         $main = str_replace("!!pert_term!!", $members["select"], $main);
                                         $main = str_replace("!!where_term!!", $members["where"], $main);
                                     }
                                 } else {
                                     $main = "select notice_id from notices where notice_id=0";
                                     $this->error_message = sprintf($msg["searcher_syntax_error_desc"], $aq->current_car, $aq->input_html, $aq->error_message);
                                 }
                             } else {
                                 if ($q[$z]["WORD"]) {
                                     if ($q[$z]['CLASS'] == "searcher_all_fields") {
                                         //Pour savoir si la recherche tous champs inclut les docnum ou pas
                                         global $mutli_crit_indexation_docnum_allfields;
                                         if ($var_table["is_num"]) {
                                             $mutli_crit_indexation_docnum_allfields = 1;
                                         } else {
                                             $mutli_crit_indexation_docnum_allfields = -1;
                                         }
                                     }
                                     //recherche par terme...
                                     if ($q[$z]["FIELDS"]) {
                                         $searcher = new $q[$z]['CLASS']($field[$j], $q[$z]["FIELDS"]);
                                     } else {
                                         $searcher = new $q[$z]['CLASS']($field[$j]);
                                     }
                                     $main = $searcher->get_full_query();
                                     //   							print "<br><br>".$main;
                                 } else {
                                     $main = str_replace("!!p!!", addslashes($field[$j]), $main);
                                 }
                             }
                         }
                     }
                     //Y-a-t-il une close repeat ?
                     if ($q[$z]["REPEAT"]) {
                         //Si oui, on repete !!
                         $onvals = $q[$z]["REPEAT"]["ON"];
                         global ${$onvals};
                         $onvalst = explode($q[$z]["REPEAT"]["SEPARATOR"], ${$onvals});
                         $mains = array();
                         for ($ir = 0; $ir < count($onvalst); $ir++) {
                             $mains[] = str_replace("!!" . $q[$z]["REPEAT"]["NAME"] . "!!", $onvalst[$ir], $main);
                         }
                         $main = implode(" " . $q[$z]["REPEAT"]["OPERATOR"] . " ", $mains);
                         $main = "select * from (" . $main . ") as sbquery" . ($q[$z]["REPEAT"]["ORDERTERM"] ? " order by " . $q[$z]["REPEAT"]["ORDERTERM"] : "");
                     }
                     if ($z < count($q) - 2) {
                         pmb_mysql_query($main);
                     }
                 }
                 if ($fieldvar["operator_between_multiple_authorities"]) {
                     $operator = $fieldvar["operator_between_multiple_authorities"][0];
                 } elseif ($q["DEFAULT_OPERATOR"]) {
                     $operator = $q["DEFAULT_OPERATOR"];
                 } else {
                     $operator = $pmb_multi_search_operator ? $pmb_multi_search_operator : "or";
                 }
                 if (count($field) > 1) {
                     if ($operator == "or") {
                         //Ou logique si plusieurs valeurs
                         if ($prefixe) {
                             $requete = "create temporary table " . $prefixe . "mf_" . $j . " ENGINE=" . $this->current_engine . " " . $main;
                             @pmb_mysql_query($requete, $dbh);
                             $requete = "alter table " . $prefixe . "mf_" . $j . " add idiot int(1)";
                             @pmb_mysql_query($requete);
                             $requete = "alter table " . $prefixe . "mf_" . $j . " add unique({$field_keyName})";
                             @pmb_mysql_query($requete);
                         } else {
                             $requete = "create temporary table mf_" . $j . " ENGINE=" . $this->current_engine . " " . $main;
                             @pmb_mysql_query($requete, $dbh);
                             $requete = "alter table mf_" . $j . " add idiot int(1)";
                             @pmb_mysql_query($requete);
                             $requete = "alter table mf_" . $j . " add unique({$field_keyName})";
                             @pmb_mysql_query($requete);
                         }
                         if ($last_main_table) {
                             if ($prefixe) {
                                 $requete = "insert ignore into " . $prefixe . "mf_" . $j . " select " . $last_main_table . ".* from " . $last_main_table;
                             } else {
                                 $requete = "insert ignore into mf_" . $j . " select " . $last_main_table . ".* from " . $last_main_table;
                             }
                             pmb_mysql_query($requete, $dbh);
                             //pmb_mysql_query("drop table mf_".$j,$dbh);
                             pmb_mysql_query("drop table " . $last_main_table, $dbh);
                         }
                         //else pmb_mysql_query("drop table mf_".$j,$dbh);
                         if ($prefixe) {
                             $last_main_table = $prefixe . "mf_" . $j;
                         } else {
                             $last_main_table = "mf_" . $j;
                         }
                     } elseif ($operator == "and") {
                         //ET logique si plusieurs valeurs
                         if ($prefixe) {
                             $requete = "create temporary table " . $prefixe . "mf_" . $j . " ENGINE=" . $this->current_engine . " " . $main;
                             @pmb_mysql_query($requete, $dbh);
                             $requete = "alter table " . $prefixe . "mf_" . $j . " add idiot int(1)";
                             @pmb_mysql_query($requete);
                             $requete = "alter table " . $prefixe . "mf_" . $j . " add unique({$field_keyName})";
                             @pmb_mysql_query($requete);
                         } else {
                             $requete = "create temporary table mf_" . $j . " ENGINE=" . $this->current_engine . " " . $main;
                             @pmb_mysql_query($requete, $dbh);
                             $requete = "alter table mf_" . $j . " add idiot int(1)";
                             @pmb_mysql_query($requete);
                             $requete = "alter table mf_" . $j . " add unique({$field_keyName})";
                             @pmb_mysql_query($requete);
                         }
                         if ($last_main_table) {
                             if ($prefixe) {
                                 $requete = "create temporary table " . $prefixe . "and_result_" . $j . " ENGINE=" . $this->current_engine . " select " . $last_tables . ".* from " . $last_tables . " where exists ( select " . $prefixe . "mf_" . $j . ".* from " . $prefixe . "mf_" . $j . " where " . $last_tables . ".notice_id=" . $prefixe . "mf_" . $j . ".notice_id)";
                             } else {
                                 $requete = "create temporary table and_result_" . $j . " ENGINE=" . $this->current_engine . " select " . $last_tables . ".* from " . $last_tables . " where exists ( select mf_" . $j . ".* from mf_" . $j . " where " . $last_tables . ".notice_id=mf_" . $j . ".notice_id)";
                             }
                             pmb_mysql_query($requete, $dbh);
                             pmb_mysql_query("drop table " . $last_tables, $dbh);
                         }
                         if ($prefixe) {
                             $last_tables = $prefixe . "mf_" . $j;
                         } else {
                             $last_tables = "mf_" . $j;
                         }
                         if ($prefixe) {
                             $last_main_table = $prefixe . "and_result_" . $j;
                         } else {
                             $last_main_table = "and_result_" . $j;
                         }
                     }
                 }
                 //else print $main;
             }
             if ($last_main_table) {
                 $main = "select * from " . $last_main_table;
             }
         } elseif (array_key_exists($s[0], $this->pp)) {
             $datatype = $this->pp[$s[0]]->t_fields[$s[1]]["DATATYPE"];
             $df = $this->dynamicfields[$s[0]]["FIELD"][$this->get_id_from_datatype($datatype, $s[0])];
             $q_index = $df["QUERIES_INDEX"];
             $q = $df["QUERIES"][$q_index[${$op}]];
             //Choix du moteur
             if ($this->memory_engine_allowed && !$df['MEMORYENGINEFORBIDDEN']) {
                 $this->current_engine = 'MEMORY';
             } else {
                 $this->current_engine = 'MyISAM';
             }
             //Pour chaque valeur du champ
             $last_main_table = "";
             if (count($field) == 0) {
                 $field[0] = "";
             }
             for ($j = 0; $j < count($field); $j++) {
                 if ($q["KEEP_EMPTYWORD"]) {
                     $field[$j] = strip_empty_chars($field[$j]);
                 } elseif ($q["REGDIACRIT"]) {
                     $field[$j] = strip_empty_words($field[$j]);
                 }
                 $main = $q["MAIN"];
                 //Si il y a plusieurs termes possibles
                 if ($q["MULTIPLE_WORDS"]) {
                     $terms = explode(" ", $field[$j]);
                     //Pour chaque terme
                     $multiple_terms = array();
                     for ($k = 0; $k < count($terms); $k++) {
                         $mt = str_replace("!!p!!", addslashes($terms[$k]), $q["MULTIPLE_TERM"]);
                         $mt = str_replace("!!field!!", $s[1], $mt);
                         $multiple_terms[] = $mt;
                     }
                     $final_term = implode(" " . $q["MULTIPLE_OPERATOR"] . " ", $multiple_terms);
                     $main = str_replace("!!multiple_term!!", $final_term, $main);
                 } else {
                     $main = str_replace("!!p!!", addslashes($field[$j]), $main);
                 }
                 $main = str_replace("!!field!!", $s[1], $main);
                 if ($q["WORD"]) {
                     //recherche par terme...
                     $searcher = new $q['CLASS']($field[$j], $s[1]);
                     $main = $searcher->get_full_query();
                 }
                 //Choix de l'operateur dans la liste
                 if ($q["DEFAULT_OPERATOR"]) {
                     $operator = $q["DEFAULT_OPERATOR"];
                 } else {
                     $operator = $pmb_multi_search_operator ? $pmb_multi_search_operator : "or";
                 }
                 if (count($field) > 1) {
                     if ($operator == "or") {
                         //Ou logique si plusieurs valeurs
                         if ($prefixe) {
                             $requete = "create temporary table " . $prefixe . "mf_" . $j . " ENGINE=" . $this->current_engine . " " . $main;
                             @pmb_mysql_query($requete, $dbh);
                             $requete = "alter table " . $prefixe . "mf_" . $j . " add idiot int(1)";
                             @pmb_mysql_query($requete);
                             $requete = "alter table " . $prefixe . "mf_" . $j . " add unique({$field_keyName})";
                             @pmb_mysql_query($requete);
                         } else {
                             $requete = "create temporary table mf_" . $j . " ENGINE=" . $this->current_engine . " " . $main;
                             @pmb_mysql_query($requete, $dbh);
                             $requete = "alter table mf_" . $j . " add idiot int(1)";
                             @pmb_mysql_query($requete);
                             $requete = "alter table mf_" . $j . " add unique({$field_keyName})";
                             @pmb_mysql_query($requete);
                         }
                         if ($last_main_table) {
                             if ($prefixe) {
                                 $requete = "insert ignore into " . $prefixe . "mf_" . $j . " select " . $last_main_table . ".* from " . $last_main_table;
                             } else {
                                 $requete = "insert ignore into mf_" . $j . " select " . $last_main_table . ".* from " . $last_main_table;
                             }
                             pmb_mysql_query($requete, $dbh);
                             //pmb_mysql_query("drop table mf_".$j,$dbh);
                             pmb_mysql_query("drop table " . $last_main_table, $dbh);
                         }
                         //else pmb_mysql_query("drop table mf_".$j,$dbh);
                         if ($prefixe) {
                             $last_main_table = $prefixe . "mf_" . $j;
                         } else {
                             $last_main_table = "mf_" . $j;
                         }
                     } elseif ($operator == "and") {
                         //ET logique si plusieurs valeurs
                         if ($prefixe) {
                             $requete = "create temporary table " . $prefixe . "mf_" . $j . " ENGINE=" . $this->current_engine . " " . $main;
                             @pmb_mysql_query($requete, $dbh);
                             $requete = "alter table " . $prefixe . "mf_" . $j . " add idiot int(1)";
                             @pmb_mysql_query($requete);
                             $requete = "alter table " . $prefixe . "mf_" . $j . " add unique({$field_keyName})";
                             @pmb_mysql_query($requete);
                         } else {
                             $requete = "create temporary table mf_" . $j . " ENGINE=" . $this->current_engine . " " . $main;
                             @pmb_mysql_query($requete, $dbh);
                             $requete = "alter table mf_" . $j . " add idiot int(1)";
                             @pmb_mysql_query($requete);
                             $requete = "alter table mf_" . $j . " add unique({$field_keyName})";
                             @pmb_mysql_query($requete);
                         }
                         if ($last_main_table) {
                             if ($prefixe) {
                                 $requete = "create temporary table " . $prefixe . "and_result_" . $j . " ENGINE=" . $this->current_engine . " select " . $last_tables . ".* from " . $last_tables . " where exists ( select " . $prefixe . "mf_" . $j . ".* from " . $prefixe . "mf_" . $j . " where " . $last_tables . ".notice_id=" . $prefixe . "mf_" . $j . ".notice_id)";
                             } else {
                                 $requete = "create temporary table and_result_" . $j . " ENGINE=" . $this->current_engine . " select " . $last_tables . ".* from " . $last_tables . " where exists ( select mf_" . $j . ".* from mf_" . $j . " where " . $last_tables . ".notice_id=mf_" . $j . ".notice_id)";
                             }
                             pmb_mysql_query($requete, $dbh);
                             pmb_mysql_query("drop table " . $last_tables, $dbh);
                         }
                         if ($prefixe) {
                             $last_tables = $prefixe . "mf_" . $j;
                         } else {
                             $last_tables = "mf_" . $j;
                         }
                         if ($prefixe) {
                             $last_main_table = $prefixe . "and_result_" . $j;
                         } else {
                             $last_main_table = "and_result_" . $j;
                         }
                     }
                 }
                 //else print $main;
             }
             if ($last_main_table) {
                 $main = "select * from " . $last_main_table;
             }
         } elseif ($s[0] == "s") {
             //instancier la classe de traitement du champ special
             $type = $this->specialfields[$s[1]]["TYPE"];
             for ($is = 0; $is < count($this->tableau_speciaux["TYPE"]); $is++) {
                 if ($this->tableau_speciaux["TYPE"][$is]["NAME"] == $type) {
                     $sf = $this->specialfields[$s[1]];
                     require_once $include_path . "/search_queries/specials/" . $this->tableau_speciaux["TYPE"][$is]["PATH"] . "/search.class.php";
                     $specialclass = new $this->tableau_speciaux["TYPE"][$is]["CLASS"]($s[1], $i, $sf, $this);
                     $last_main_table = $specialclass->make_search();
                     break;
                 }
             }
             if ($last_main_table) {
                 $main = "select * from " . $last_main_table;
             }
         } elseif ($s[0] == "authperso") {
             $aq = new analyse_query($field[0], 0, 0, 1, 1, $opac_stemming_active);
             $members = $aq->get_query_members("authperso_authorities", "authperso_infos_global", "authperso_index_infos_global", "id_authperso_authority");
             $clause = "where " . $members["where"] . " and notice_id=notice_authperso_notice_num and notice_authperso_authority_num=id_authperso_authority and authperso_authority_authperso_num=" . $s[1];
             $main = "select distinct notice_id FROM notices,notices_authperso,authperso_authorities {$clause} ";
             if ($last_main_table) {
                 $main = "select * from " . $last_main_table;
             }
         }
         if ($prefixe) {
             $table = $prefixe . "t_" . $i . "_" . $search[$i];
             $requete = "create temporary table " . $prefixe . "t_" . $i . "_" . $search[$i] . " ENGINE=" . $this->current_engine . " " . $main;
             pmb_mysql_query($requete, $dbh);
             $requete = "alter table " . $prefixe . "t_" . $i . "_" . $search[$i] . " add idiot int(1)";
             @pmb_mysql_query($requete);
             $requete = "alter table " . $prefixe . "t_" . $i . "_" . $search[$i] . " add unique({$field_keyName})";
             pmb_mysql_query($requete);
         } else {
             $table = "t_" . $i . "_" . $search[$i];
             $requete = "create temporary table t_" . $i . "_" . $search[$i] . " ENGINE=" . $this->current_engine . " " . $main;
             pmb_mysql_query($requete, $dbh);
             $requete = "alter table t_" . $i . "_" . $search[$i] . " add idiot int(1)";
             @pmb_mysql_query($requete);
             $requete = "alter table t_" . $i . "_" . $search[$i] . " add unique({$field_keyName})";
             pmb_mysql_query($requete);
         }
         if ($last_main_table) {
             $requete = "drop table " . $last_main_table;
             pmb_mysql_query($requete);
         }
         if ($prefixe) {
             $requete = "create temporary table " . $prefixe . "t" . $i . " ENGINE=" . $this->current_engine . " ";
         } else {
             $requete = "create temporary table t" . $i . " ENGINE=" . $this->current_engine . " ";
         }
         $isfirst_criteria = false;
         switch (${$inter}) {
             case "and":
                 $requete .= "select " . $table . ".* from {$last_table},{$table} where " . $table . ".{$field_keyName}=" . $last_table . ".{$field_keyName} and {$table}.idiot is null and {$last_table}.idiot is null";
                 @pmb_mysql_query($requete, $dbh);
                 break;
             case "or":
                 //Si la table précédente est vide, c'est comme au premier jour !
                 $requete_c = "select count(*) from " . $last_table;
                 if (!@pmb_mysql_result(pmb_mysql_query($requete_c), 0, 0)) {
                     $isfirst_criteria = true;
                 } else {
                     $requete .= "select * from " . $table;
                     @pmb_mysql_query($requete, $dbh);
                     if ($prefixe) {
                         $requete = "alter table " . $prefixe . "t" . $i . " add idiot int(1)";
                         @pmb_mysql_query($requete);
                         $requete = "alter table " . $prefixe . "t" . $i . " add unique({$field_keyName})";
                         @pmb_mysql_query($requete);
                     } else {
                         $requete = "alter table t" . $i . " add idiot int(1)";
                         @pmb_mysql_query($requete);
                         $requete = "alter table t" . $i . " add unique({$field_keyName})";
                         @pmb_mysql_query($requete);
                     }
                     if ($prefixe) {
                         $requete = "insert into " . $prefixe . "t" . $i . " ({$field_keyName},idiot) select distinct " . $last_table . "." . $field_keyName . "," . $last_table . ".idiot from " . $last_table . " left join " . $table . " on " . $last_table . ".{$field_keyName}=" . $table . ".{$field_keyName} where " . $table . ".{$field_keyName} is null";
                     } else {
                         $requete = "insert into t" . $i . " ({$field_keyName},idiot) select distinct " . $last_table . "." . $field_keyName . "," . $last_table . ".idiot from " . $last_table . " left join " . $table . " on " . $last_table . ".{$field_keyName}=" . $table . ".{$field_keyName} where " . $table . ".{$field_keyName} is null";
                         //print $requete;
                     }
                     @pmb_mysql_query($requete, $dbh);
                 }
                 break;
             case "ex":
                 //$requete_not="create temporary table ".$table."_b select notices.notice_id from notices left join ".$table." on notices.notice_id=".$table.".notice_id where ".$table.".notice_id is null";
                 //@pmb_mysql_query($requete_not);
                 //$requete_not="alter table ".$table."_b add idiot int(1), add unique(notice_id)";
                 //@pmb_mysql_query($requete_not);
                 $requete .= "select " . $last_table . ".* from {$last_table} left join " . $table . " on " . $table . ".{$field_keyName}=" . $last_table . ".{$field_keyName} where " . $table . ".{$field_keyName} is null";
                 @pmb_mysql_query($requete);
                 //$requete="drop table ".$table."_b";
                 //@pmb_mysql_query($requete);
                 if ($prefixe) {
                     $requete = "alter table " . $prefixe . "t" . $i . " add idiot int(1)";
                     @pmb_mysql_query($requete);
                     $requete = "alter table " . $prefixe . "t" . $i . " add unique({$field_keyName})";
                     @pmb_mysql_query($requete);
                 } else {
                     $requete = "alter table t" . $i . " add idiot int(1)";
                     @pmb_mysql_query($requete);
                     $requete = "alter table t" . $i . " add unique({$field_keyName})";
                     @pmb_mysql_query($requete);
                 }
                 break;
             default:
                 $isfirst_criteria = true;
                 @pmb_mysql_query($requete, $dbh);
                 $requete = "alter table {$table} add idiot int(1)";
                 @pmb_mysql_query($requete);
                 $requete = "alter table {$table} add unique({$field_keyName})";
                 @pmb_mysql_query($requete);
                 break;
         }
         if (!$isfirst_criteria) {
             pmb_mysql_query("drop table if exists {$last_table}", $dbh);
             pmb_mysql_query("drop table if exists {$table}", $dbh);
             if ($prefixe) {
                 $last_table = $prefixe . "t" . $i;
             } else {
                 $last_table = "t" . $i;
             }
         } else {
             pmb_mysql_query("drop table if exists {$last_table}", $dbh);
             $last_table = $table;
         }
     }
     return $last_table;
 }
 function process_isbn($isbn)
 {
     /* We've got everything, let's have a look if ISBN already exists in notices table */
     $isbn_nettoye = preg_replace('/-|\\.| |\\(|\\)|\\[|\\]|\\:|\\;|[A-WY-Z]/i', '', $isbn);
     $isbn_nettoye_13 = substr($isbn_nettoye, 0, 13);
     $isbn_nettoye_10 = substr($isbn_nettoye, 0, 10);
     $isbn_OK = "";
     if (isEAN($isbn_nettoye_13)) {
         /* it's an EAN -> convert it to ISBN */
         $isbn_OK = EANtoISBN($isbn_nettoye_13);
     }
     if (!$isbn_OK) {
         if (isISBN($isbn_nettoye_10)) {
             $isbn_OK = formatISBN($isbn_nettoye_10);
         }
     }
     if (!$isbn_OK) {
         $isbn_OK = clean_string($isbn);
     }
     return $isbn_OK;
 }
 static function listSuggestions($id_bibli = 0, $statut = '-1', $num_categ = '-1', $mask, $debut = 0, $nb_per_page = 0, $aq = 0, $order = '', $location = 0, $user_input = '', $source = 0, $user_id = 0, $user_statut = '-1')
 {
     if ($source) {
         $filtre_src = " sugg_source = '" . $source . "' ";
     } else {
         $filtre_src = " 1 ";
     }
     if (!$statut) {
         $statut = '-1';
     }
     if ($statut == '-1') {
         $filtre1 = '1';
     } elseif ($statut == $mask) {
         $filtre1 = "(statut & '" . $mask . "') = '" . $mask . "' ";
     } else {
         $filtre1 = "(statut & '" . $mask . "') = 0 and (statut & " . $statut . ") = '" . $statut . "' ";
     }
     if ($num_categ == '-1') {
         $filtre2 = '1';
     } else {
         $filtre2 = "num_categ = '" . $num_categ . "' ";
     }
     if (!$id_bibli) {
         $filtre3 = '1';
     } else {
         $filtre3 .= "num_entite = '" . $id_bibli . "' ";
     }
     if ($location == 0) {
         $filtre4 = '1';
     } else {
         $filtre4 = "sugg_location = '" . $location . "' ";
     }
     $filtre_empr = '';
     $tab_empr = array();
     $filtre_user = '';
     $tab_user = array();
     if (is_array($user_id) && count($user_id) && is_array($user_statut) && count($user_statut)) {
         foreach ($user_id as $k => $id) {
             if ($user_statut[$k] == "0") {
                 $tab_user[] = $id;
             }
             if ($user_statut[$k] == "1") {
                 $tab_empr[] = $id;
             }
         }
     }
     if (is_array($tab_empr) && count($tab_empr)) {
         $filtre_empr = "suggestions_origine.origine in ('" . implode("','", $tab_empr) . "') and type_origine='1' ";
     }
     if (is_array($tab_user) && count($tab_user)) {
         $filtre_user = "******" . implode("','", $tab_user) . "') and type_origine='0' ";
     }
     if ($filtre_empr != "" || $filtre_user != "") {
         $table_origine = ", suggestions_origine ";
         $join_origine = "  id_suggestion=num_suggestion  ";
         if ($filtre_empr && $filtre_user) {
             $clause_origine = " and ( (" . $filtre_empr . ") or (" . $filtre_user . ") ) and ";
         } elseif ($filtre_empr) {
             $clause_origine = " and (" . $filtre_empr . ") and ";
         } elseif ($filtre_user) {
             $clause_origine = " and (" . $filtre_user . ") and ";
         }
     }
     if (!$aq) {
         $q = "select * from suggestions {$table_origine}";
         $q .= "where {$join_origine} {$clause_origine} " . $filtre1 . " and " . $filtre2 . " and " . $filtre3 . " and " . $filtre4 . " and " . $filtre_src;
         if (!$order) {
             $q .= "order by statut, date_creation desc ";
         } else {
             $q .= "order by" . $order . " ";
         }
     } else {
         $isbn = '';
         $t_codes = array();
         if ($user_input !== '') {
             if (isEAN($user_input)) {
                 // la saisie est un EAN -> on tente de le formater en ISBN
                 $isbn = EANtoISBN($user_input);
                 if ($isbn) {
                     $t_codes[] = $isbn;
                     $t_codes[] = formatISBN($isbn, 10);
                 }
             } elseif (isISBN($user_input)) {
                 // si la saisie est un ISBN
                 $isbn = formatISBN($user_input);
                 if ($isbn) {
                     $t_codes[] = $isbn;
                     $t_codes[] = formatISBN($isbn, 13);
                 }
             }
         }
         if (count($t_codes)) {
             $q = "select * from suggestions {$table_origine}";
             $q .= "where {$join_origine} {$clause_origine} (" . $filtre1 . " and " . $filtre2 . " and " . $filtre3 . " and " . $filtre4 . " and " . $filtre_src;
             $q .= ") ";
             $q .= "and ('0' ";
             foreach ($t_codes as $v) {
                 $q .= "or code like '%" . $v . "%' ";
             }
             $q .= ") ";
             if (!$order) {
                 $q .= "order by statut, date_creation desc ";
             } else {
                 $q .= "order by" . $order . " ";
             }
         } else {
             $members = $aq->get_query_members("suggestions", "concat(titre,' ',editeur,' ',auteur,' ',commentaires)", "index_suggestion", "id_suggestion");
             $q = $q = "select *, " . $members["select"] . " as pert from suggestions {$table_origine} ";
             $q .= "where {$join_origine} {$clause_origine} (" . $filtre1 . " and " . $filtre2 . " and " . $filtre3 . " and " . $filtre4 . " and " . $filtre_src;
             $q .= ") ";
             $q .= "and (" . $members["where"] . " ";
             foreach ($t_codes as $v) {
                 $q .= "or index_suggestion like ('%" . $v . "%') ";
             }
             $q .= ") ";
             if (!$order) {
                 $q .= "order by pert desc ";
             } else {
                 $q .= "order by " . $order . ", pert desc ";
             }
         }
     }
     if (!$debut && $nb_per_page) {
         $q .= "limit " . $nb_per_page;
     }
     if ($debut && $nb_per_page) {
         $q .= "limit " . $debut . "," . $nb_per_page;
     }
     return $q;
 }
示例#5
0
//Limite la taille de l'image à 1 Mo
if ($notice_id && $pmb_notice_img_folder_id) {
    $req = "select repertoire_path from upload_repertoire where repertoire_id ='" . $pmb_notice_img_folder_id . "'";
    $res = mysql_query($req, $dbh);
    if (mysql_num_rows($res)) {
        $rep = mysql_fetch_object($res);
        $img = $rep->repertoire_path . "img_" . $notice_id;
        header('Content-Type: image/png');
        $fp = @fopen($img, "rb");
        fpassthru($fp);
        fclose($fp);
        exit;
    }
}
if ($noticecode) {
    if (isEAN($noticecode)) {
        if (isISBN($noticecode)) {
            if (isISBN10($noticecode)) {
                $url_image10 = str_replace("!!isbn!!", str_replace("-", "", $noticecode), $_GET['url_image']);
                $url_image13 = str_replace("!!isbn!!", str_replace("-", "", formatISBN($noticecode, "13")), $_GET['url_image']);
            } else {
                $url_image10 = str_replace("!!isbn!!", str_replace("-", "", EANtoISBN10($noticecode)), $_GET['url_image']);
                $url_image13 = str_replace("!!isbn!!", str_replace("-", "", $noticecode), $_GET['url_image']);
            }
        } else {
            $url_imageEAN = str_replace("!!isbn!!", str_replace("-", "", $noticecode), $_GET['url_image']);
        }
    }
    $url_image = str_replace("!!isbn!!", $noticecode, $_GET['url_image']);
} else {
    $url_image = rawurldecode(stripslashes($_GET['url_image']));
示例#6
0
require "{$include_path}/templates/common.tpl.php";
header("Content-Type: text/html; charset=" . $charset);
print "\n<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN'\n 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'>\n<html xmlns='http://www.w3.org/1999/xhtml' lang='{$msg['1002']}' charset='" . $charset . "'>\n\t<meta http-equiv='Pragma' content='no-cache'>\n\t\t<meta http-equiv='Cache-Control' content='no-cache'>";
print link_styles($stylesheet);
print "\t<title>{$msg['4014']}</title></head><body>";
if (!$formulaire_appelant) {
    $formulaire_appelant = "notice";
}
if (!$objet_appelant) {
    $objet_appelant = "f_cb";
}
// traitement de la soumission
if ($suite) {
    // un CB a été soumis
    if ($cb) {
        if (isEAN($cb)) {
            // la saisie est un EAN -> on tente de le formater en ISBN
            $code = EANtoISBN($cb);
            // si échec, on prend l'EAN comme il vient
            if (!$code) {
                $code = $cb;
            }
        } else {
            if (isISBN($cb)) {
                // si la saisie est un ISBN
                $code = formatISBN($cb, 13);
                // si échec, ISBN erroné on le prend sous cette forme
                if (!$code) {
                    $code = $cb;
                }
            } else {
示例#7
0
 // auteurs secondaires
 for ($i = 0; $i < $max_aut2; $i++) {
     $var_autid = "f_aut2_id{$i}";
     $var_autfonc = "f_f2_code{$i}";
     $f_aut[] = array('id' => ${$var_autid}, 'fonction' => ${$var_autfonc}, 'type' => '2', 'ordre' => $i);
 }
 $f_ed1 ? $t_notice['ed1_id'] = $f_ed1_id : ($t_notice['ed1_id'] = 0);
 $f_ed2 ? $t_notice['ed2_id'] = $f_ed2_id : ($t_notice['ed2_id'] = 0);
 $f_coll && $t_notice['ed1_id'] ? $t_notice['coll_id'] = $f_coll_id : ($t_notice['coll_id'] = 0);
 $f_subcoll && $t_notice['coll_id'] ? $t_notice['subcoll_id'] = $f_subcoll_id : ($t_notice['subcoll_id'] = 0);
 $t_notice['year'] = trim($f_year);
 $f_nocoll && $t_notice['coll_id'] ? $t_notice['nocoll'] = trim($f_nocoll) : ($t_notice['nocoll'] = '');
 $t_notice['mention_edition'] = trim($f_mention_edition);
 if ($f_cb) {
     // ce controle redondant est la pour le cas ou l'utilisateur aurait change le code
     if (isEAN($f_cb)) {
         // la saisie est un EAN -> on tente de le formater en ISBN
         $code = EANtoISBN($f_cb);
         // si echec, on prend l'EAN comme il vient
         if (!$code) {
             $code = $f_cb;
         }
     } else {
         if (isISBN($f_cb)) {
             // si la saisie est un ISBN
             $code = formatISBN($f_cb, 13);
             // si echec, ISBN errone on le prend sous cette forme
             if (!$code) {
                 $code = $f_cb;
             }
         } else {
示例#8
0
// � 2002-2004 PMB Services / www.sigb.net pmb@sigb.net et contributeurs (voir www.sigb.net)
// +-------------------------------------------------+
// $Id: isbn.inc.php,v 1.1 2011-06-06 08:04:28 dbellamy Exp $
if (stristr($_SERVER['REQUEST_URI'], ".inc.php")) {
    die("no access");
}
require_once "{$include_path}/isbn.inc.php";
if (isset($code)) {
    switch ($fname) {
        case 'getPatterns':
            $tab = array();
            $code = preg_replace('/-|\\.| /', '', $code);
            $code = str_replace('x', 'X', $code);
            //format expurge
            $tab[] = $code;
            if (isEAN($code)) {
                $EAN = $code;
                $isbn = EANtoISBN($code);
                if ($isbn) {
                    //formatISBN10
                    $tab[] = formatISBN($code, 10);
                    //formatISBN13
                    $tab[] = formatISBN($code, 13);
                }
            }
            if (isISBN($code)) {
                $isbn = formatISBN($code);
                if ($isbn) {
                    //formatISBN10
                    $tab[] = formatISBN($code, 10);
                    //formatISBN13
 function import_basic($notices, $params = array(), $with_expl = false)
 {
     global $base_path, $class_path, $include_path, $dbh, $msg, $charset;
     global $deflt_integration_notice_statut, $deflt_lenders, $deflt_docs_statut, $deflt_docs_location;
     $log = array();
     //On contrôle tous les paramètres obligatoires
     if (!$params["func_import"]) {
         $params["func_import"] = "func_bdp.inc.php";
         //Function d'import à utiliser
     }
     if (file_exists($base_path . "/admin/import/" . $params["func_import"])) {
         require_once $base_path . "/admin/import/" . $params["func_import"];
     } else {
         require_once $base_path . "/admin/import/func_bdp.inc.php";
     }
     //Notices
     if (!isset($params["isbn_mandatory"])) {
         $params["isbn_mandatory"] = "0";
     }
     //ISBN obligatoire ?
     if (!isset($params["isbn_dedoublonnage"])) {
         $params["isbn_dedoublonnage"] = "1";
     }
     //Dédoublonnage sur ISBN ?
     if (!isset($params["isbn_only"])) {
         $params["isbn_only"] = "0";
     }
     //Que les ISBN
     if (!isset($params["statutnot"])) {
         $params["statutnot"] = $deflt_integration_notice_statut;
     }
     //Statut des notices importées  -> On met la valeur du paramètre utilisateur "Statut de notice par défaut en intégration de notice"
     if (!isset($params["link_generate"])) {
         $params["link_generate"] = "0";
     }
     //Générer les liens entre notices ?
     if (!isset($params["authorities_notices"])) {
         $params["authorities_notices"] = "0";
     }
     //Tenir compte des notices d'autorités
     if (!isset($params["authorities_default_origin"])) {
         $params["authorities_default_origin"] = "";
     }
     //Origine par défaut des autorités si non précisé dans les notices
     //Exemplaires
     if ($with_expl) {
         if (!isset($params["book_lender_id"])) {
             $params["book_lender_id"] = $deflt_lenders;
         }
         //Propriétaire  -> On met la valeur du paramètre utilisateur "Propriétaire par défaut en création d'exemplaire"
         if (!isset($params["book_statut_id"])) {
             $params["book_statut_id"] = $deflt_docs_statut;
         }
         //Statut  -> On met la valeur du paramètre utilisateur "Statut de document par défaut en création d'exemplaire"
         if (!isset($params["book_location_id"])) {
             $params["book_location_id"] = $deflt_docs_location;
         }
         //Localisation  -> On met la valeur du paramètre utilisateur "Localisation du document par défaut en création d'exemplaire"
         if (!isset($params["cote_mandatory"])) {
             $params["cote_mandatory"] = "0";
         }
         //Cote obligatoire ?
         if (!isset($params["tdoc_codage"])) {
             $params["tdoc_codage"] = "0";
         }
         //Types de document Codage du propriétaire ?
         if (!isset($params["statisdoc_codage"])) {
             $params["statisdoc_codage"] = "0";
         }
         //Codes statistiques Codage du propriétaire ?
         if (!isset($params["sdoc_codage"])) {
             $params["sdoc_codage"] = "0";
         }
         //Sections Codage du propriétaire ?
     }
     //Find de contrôle des paramètres obligatoires
     //On rend global tous les paramètres passés (et pas forcément que les obligatoires) pour la suite
     foreach ($params as $key => $value) {
         global ${$key};
         ${$key} = $value;
     }
     if (count($notices)) {
         ob_start();
         //On temporise toutes les sorties (dans le cas ou dans la fonction d'import on fait des sorties écrans directement)
         $nbtot_notice = count($notices);
         $notice_deja_presente = 0;
         $notice_rejetee = 0;
         global $notices_crees, $notices_a_creer, $bulletins_crees, $bulletins_a_creer;
         $notices_crees = $notices_a_creer = $bulletins_crees = $bulletins_a_creer = array();
         if ($with_expl) {
             global $section_995, $typdoc_995, $codstatdoc_995, $nb_expl_ignores;
             $section_995_ = new marc_list("section_995");
             $section_995 = $section_995_->table;
             $typdoc_995_ = new marc_list("typdoc_995");
             $typdoc_995 = $typdoc_995_->table;
             $codstatdoc_995_ = new marc_list("codstatdoc_995");
             $codstatdoc_995 = $codstatdoc_995_->table;
             $nb_expl_ignores = 0;
         }
         foreach ($notices as $notice) {
             $notice = utf8_decode($notice);
             $res_lecture = recup_noticeunimarc($notice);
             if ($params["link_generate"]) {
                 recup_noticeunimarc_link($notice);
             }
             global $tit_200a;
             if (!$res_lecture || !$tit_200a[0]) {
                 $res_lecture = 0;
                 $fp = fopen($base_path . "/temp/err_import.unimarc", "a+");
                 fwrite($fp, $notice);
                 fclose($fp);
                 $notice_rejetee++;
             } else {
                 recup_noticeunimarc_suite($notice);
                 global $isbn, $EAN, $issn_011, $collection_225, $collection_410, $code, $code10, $isbn_OK, $notice_id;
                 if ($isbn[0] == "NULL") {
                     $isbn[0] = "";
                 }
                 // si isbn vide, on va tenter de prendre l'EAN stocké en 345$b
                 if ($isbn[0] == "") {
                     $isbn[0] = $EAN[0];
                 }
                 // si isbn vide, on va tenter de prendre le serial en 011
                 if ($isbn[0] == "") {
                     $isbn[0] = $issn_011[0];
                 }
                 // si ISBN obligatoire et isbn toujours vide :
                 if ($params["isbn_mandatory"] == 1 && $isbn[0] == "") {
                     // on va tenter de prendre l'ISSN stocké en 225$x
                     $isbn[0] = $collection_225[0]['x'];
                     // si isbn toujours vide, on va tenter de prendre l'ISSN stocké en 410$x
                     if ($isbn[0] == "") {
                         $isbn[0] = $collection_410[0]['x'];
                     }
                 }
                 // on commence par voir ce que le code est (basé sur la recherche par code du module catalogage
                 $ex_query = clean_string($isbn[0]);
                 $EAN = '';
                 $isbn = '';
                 $code = '';
                 $code10 = '';
                 if (isEAN($ex_query)) {
                     // la saisie est un EAN -> on tente de le formater en ISBN
                     $EAN = $ex_query;
                     $isbn = EANtoISBN($ex_query);
                     // si échec, on prend l'EAN comme il vient
                     if (!$isbn) {
                         $code = str_replace("*", "%", $ex_query);
                     } else {
                         $code = $isbn;
                         $code10 = formatISBN($code, 10);
                     }
                 } else {
                     if (isISBN($ex_query)) {
                         // si la saisie est un ISBN
                         $isbn = formatISBN($ex_query);
                         // si échec, ISBN erroné on le prend sous cette forme
                         if (!$isbn) {
                             $code = str_replace("*", "%", $ex_query);
                         } else {
                             $code10 = $isbn;
                             $code = formatISBN($code10, 13);
                         }
                     } else {
                         // ce n'est rien de tout ça, on prend la saisie telle quelle
                         $code = str_replace("*", "%", $ex_query);
                     }
                 }
                 $isbn_OK = $code;
                 $new_notice = 0;
                 $notice_id = 0;
                 // le paramétrage est-il : dédoublonnage sur code ? / Ne dédoublonner que sur code ISBN (ignorer les ISSN) ?
                 if ($params["isbn_dedoublonnage"] && !$params["isbn_only"] || $params["isbn_dedoublonnage"] && $params["isbn_only"] && isISBN($isbn)) {
                     $trouvees = 0;
                     if ($EAN && $isbn) {
                         // cas des EAN purs : constitution de la requête
                         $requete = "SELECT distinct notice_id FROM notices ";
                         $requete .= " WHERE notices.code in ('{$code}','{$EAN}'" . ($code10 ? ",'{$code10}'" : "") . ") limit 1";
                         $myQuery = mysql_query($requete, $dbh);
                         $trouvees = mysql_num_rows($myQuery);
                     } elseif ($isbn) {
                         // recherche d'un isbn
                         $requete = "SELECT distinct notice_id FROM notices ";
                         $requete .= " WHERE notices.code in ('{$code}'" . ($code10 ? ",'{$code10}'" : "") . ") limit 1";
                         $myQuery = mysql_query($requete, $dbh);
                         $trouvees = mysql_num_rows($myQuery);
                     } elseif ($code) {
                         // note : le code est recherché dans le champ code des notices
                         // (cas des code-barres disques qui échappent à l'EAN)
                         //
                         $requete = "SELECT notice_id FROM notices ";
                         $requete .= " WHERE notices.code like '{$code}' limit 10";
                         $myQuery = mysql_query($requete, $dbh);
                         $trouvees = mysql_num_rows($myQuery);
                     }
                     // dédoublonnage sur isbn
                     if ($EAN || $isbn || $code) {
                         if ($trouvees == 0) {
                             $new_notice = 1;
                         } else {
                             $new_notice = 0;
                             $notice_id = mysql_result($myQuery, 0, "notice_id");
                             $sql_log = mysql_query("insert into error_log (error_origin, error_text) values ('import_expl_" . addslashes(SESSid) . ".inc', '" . $msg[542] . " {$EAN}  || {$isbn} || {$code} " . addslashes($tit_200a[0]) . "') ");
                         }
                     } else {
                         if ($params["isbn_mandatory"] == 1) {
                             $sql_log = mysql_query("insert into error_log (error_origin, error_text) values ('import_" . addslashes(SESSid) . ".inc', '" . $msg[543] . "') ");
                         } else {
                             $new_notice = 1;
                             $sql_log = mysql_query("insert into error_log (error_origin, error_text) values ('import_" . addslashes(SESSid) . ".inc', '" . $msg[565] . "') ");
                         }
                     }
                 } else {
                     // pas de dédoublonnage
                     if ($params["isbn_mandatory"] == 1 && $isbn_OK == "") {
                         $sql_log = mysql_query("insert into error_log (error_origin, error_text) values ('import_" . addslashes(SESSid) . ".inc', '" . $msg[543] . "') ");
                     } elseif ($isbn_OK) {
                         $new_notice = 1;
                     } else {
                         $new_notice = 1;
                         $sql_log = mysql_query("insert into error_log (error_origin, error_text) values ('import_" . addslashes(SESSid) . ".inc', '" . $msg[565] . "') ");
                     }
                 }
                 /* the notice is new, we are going to import it... */
                 if ($new_notice == 1) {
                     import_new_notice();
                     if ($params["link_generate"]) {
                         import_notice_link();
                     }
                     import_new_notice_suite();
                     // Mise à jour de la table "notices_global_index"
                     notice::majNoticesGlobalIndex($notice_id);
                     // Mise à jour de la table "notices_mots_global_index"
                     notice::majNoticesMotsGlobalIndex($notice_id);
                 } else {
                     $notice_deja_presente++;
                     //TRAITEMENT DES DOCS NUMERIQUES SUR NOTICE EXISTANTE
                     global $add_explnum;
                     //Fonction d'import func_ensai_ensae.inc.php
                     if ($add_explnum === TRUE && function_exists("ajoute_explnum")) {
                         ajoute_explnum();
                     }
                 }
                 // TRAITEMENT DES EXEMPLAIRES ICI
                 if ($with_expl) {
                     traite_exemplaires();
                 }
             }
         }
         //Fin du traitement des notices
         //Gestion des logs
         $formulaire = "";
         $script = "";
         $log["notice_deja_presente"] = $notice_deja_presente;
         $log["notice_rejetee"] = $notice_rejetee;
         $log["nbtot_notice"] = $nbtot_notice;
         $log["stdout"] = ob_get_contents();
         if ($charset != "utf-8") {
             $log["stdout"] = utf8_encode($log["stdout"]);
         }
         ob_end_clean();
         $gen_liste_log = "";
         $resultat_liste = mysql_query("SELECT error_origin, error_text, count(*) as nb_error FROM error_log where error_origin in ('expl_" . addslashes(SESSid) . ".class','import_expl_" . addslashes(SESSid) . ".inc','iimport_expl_" . addslashes(SESSid) . ".inc','import_" . addslashes(SESSid) . ".inc.php', 'import_" . addslashes(SESSid) . ".inc','import_func_" . addslashes(SESSid) . ".inc.php') group by error_origin, error_text", $dbh);
         $nb_liste = mysql_num_rows($resultat_liste);
         if ($nb_liste > 0) {
             $i_log = 0;
             while ($i_log < $nb_liste) {
                 $tmp = array();
                 $tmp["error_origin"] = mysql_result($resultat_liste, $i_log, "error_origin");
                 if ($charset != "utf-8") {
                     $tmp["error_origin"] = utf8_encode($tmp["error_origin"]);
                 }
                 $tmp["error_text"] = mysql_result($resultat_liste, $i_log, "error_text");
                 if ($charset != "utf-8") {
                     $tmp["error_text"] = utf8_encode($tmp["error_text"]);
                 }
                 $tmp["nb_error"] = mysql_result($resultat_liste, $i_log, "nb_error");
                 $log["error_log"][] = $tmp;
                 $i_log++;
             }
             mysql_query("DELETE FROM error_log WHERE error_origin  in ('expl_" . addslashes(SESSid) . ".class','import_expl_" . addslashes(SESSid) . ".inc','iimport_expl_" . addslashes(SESSid) . ".inc','import_" . addslashes(SESSid) . ".inc.php', 'import_" . addslashes(SESSid) . ".inc','import_func_" . addslashes(SESSid) . ".inc.php')", $dbh);
         } else {
             $log["result"] = $this->msg["import_basic_msg_ok"];
             if ($charset != "utf-8") {
                 $log["result"] = utf8_encode($log["result"]);
             }
         }
     } else {
         $log["result"] = $this->msg["import_basic_msg_ko"];
         if ($charset != "utf-8") {
             $log["result"] = utf8_encode($log["result"]);
         }
     }
     return $log;
 }
// $Id: notice_display.inc.php,v 1.80 2015-04-03 11:16:16 jpermanne Exp $
if (stristr($_SERVER['REQUEST_URI'], ".inc.php")) {
    die("no access");
}
$libelle = $msg[270];
require_once $base_path . '/includes/templates/notice_display.tpl.php';
require_once $base_path . '/includes/explnum.inc.php';
require_once $base_path . '/classes/notice_affichage.class.php';
require_once $base_path . '/includes/bul_list_func.inc.php';
require_once $base_path . '/classes/upload_folder.class.php';
print $notice_display_header;
if ($ref) {
    $EAN = '';
    $isbn = '';
    $code = '';
    if (isEAN($ref)) {
        // la saisie est un EAN -> on tente de le formater en ISBN
        $EAN = $ref;
        $isbn = EANtoISBN($ref);
        // si échec, on prend l'EAN comme il vient
        if (!$isbn) {
            $code = str_replace("*", "%", $ref);
        } else {
            $code = $isbn;
            $code10 = formatISBN($code, 10);
        }
    } else {
        if (isISBN($ref)) {
            // si la saisie est un ISBN
            $isbn = formatISBN($ref);
            // si échec, ISBN erroné on le prend sous cette forme
示例#11
0
 static function getNbActes($id_bibli, $type_acte, $statut = '-1', $aq = 0, $user_input = '')
 {
     global $dbh;
     if ($statut == '-1') {
         $filtre = '';
     } elseif ($statut == 32) {
         $filtre = "and ((actes.statut & 32) = 32) ";
     } else {
         $filtre = "and ((actes.statut & 32) = 0) and ((actes.statut & " . $statut . ") = '" . $statut . "') ";
     }
     if (!$aq) {
         $q = "select count(1) from actes where num_entite = '" . $id_bibli . "' ";
         $q .= "and type_acte = '" . $type_acte . "' " . $filtre . " ";
     } else {
         $isbn = '';
         $t_codes = array();
         if ($user_input !== '') {
             if (isEAN($user_input)) {
                 // la saisie est un EAN -> on tente de le formater en ISBN
                 $isbn = EANtoISBN($user_input);
                 if ($isbn) {
                     $t_codes[] = $isbn;
                     $t_codes[] = formatISBN($isbn, 10);
                 }
             } elseif (isISBN($user_input)) {
                 // si la saisie est un ISBN
                 $isbn = formatISBN($user_input);
                 if ($isbn) {
                     $t_codes[] = $isbn;
                     $t_codes[] = formatISBN($isbn, 13);
                 }
             }
         }
         if (count($t_codes)) {
             $q = "select count(distinct(id_acte)) from actes left join lignes_actes on num_acte=id_acte ";
             $q .= "where ( num_entite='" . $id_bibli . "' and type_acte='" . $type_acte . "' " . $filtre . " ) ";
             $q .= "and ('0' ";
             foreach ($t_codes as $v) {
                 $q .= "or code like '%" . $v . "%' ";
             }
             $q .= ") ";
         } else {
             $members_actes = $aq->get_query_members("actes", "numero", "index_acte", "id_acte");
             $members_lignes = $aq->get_query_members("lignes_actes", "code", "index_ligne", "id_ligne");
             $q = "select count(distinct(id_acte)) from actes left join lignes_actes on num_acte=id_acte ";
             $q .= "where ( num_entite='" . $id_bibli . "' and type_acte='" . $type_acte . "' " . $filtre . " ) ";
             $q .= "and (" . $members_actes["where"] . " or " . $members_lignes["where"] . ") ";
         }
     }
     $r = mysql_query($q, $dbh);
     return mysql_result($r, 0, 0);
 }
 function get_form_sel()
 {
     global $harvest_notice_tpl, $harvest_notice_tpl_error;
     //Je regarde si la notice à un isbn
     $req = "SELECT code FROM notices WHERE notice_id='" . $this->id . "'";
     $res = pmb_mysql_query($req);
     if (pmb_mysql_num_rows($res) && (isISBN(pmb_mysql_result($res, 0, 0)) || isEAN(pmb_mysql_result($res, 0, 0)))) {
         $tpl = $harvest_notice_tpl;
         $harvests = new harvests();
         $tpl = str_replace('!!sel_harvest!!', $harvests->get_sel('harvest_id', 0), $tpl);
         $h = new harvest_profil_imports();
         $tpl = str_replace('!!sel_profil!!', $h->get_sel('profil_id', 0), $tpl);
         $tpl = str_replace('!!notice_id!!', $this->id, $tpl);
     } else {
         $tpl = $harvest_notice_tpl_error;
     }
     return $tpl;
 }
示例#13
0
 function getEnrichment($notice_id, $source_id, $type = "", $enrich_params = array(), $page = 1)
 {
     $params = $this->get_source_params($source_id);
     if ($params["PARAMETERS"]) {
         //Affichage du formulaire avec $params["PARAMETERS"]
         $vars = unserialize($params["PARAMETERS"]);
         foreach ($vars as $key => $val) {
             global ${$key};
             ${$key} = $val;
         }
     }
     $enrichment = array();
     //on renvoi ce qui est demandé... si on demande rien, on renvoi tout..
     switch ($type) {
         case "books":
         default:
             $rqt = "select code from notices where notice_id = '{$notice_id}'";
             $res = pmb_mysql_query($rqt);
             if (pmb_mysql_num_rows($res)) {
                 $ref = pmb_mysql_result($res, 0, 0);
                 //google change son API, on s'assure d'avoir un ISBN13 formaté !
                 if (isEAN(${$ref})) {
                     // la saisie est un EAN -> on tente de le formater en ISBN
                     $EAN = $ref;
                     $isbn = EANtoISBN($ref);
                     // si échec, on prend l'EAN comme il vient
                     if (!$isbn) {
                         $code = str_replace("*", "%", $ref);
                     } else {
                         $code = $isbn;
                         $code10 = formatISBN($code, 10);
                     }
                 } else {
                     if (isISBN($ref)) {
                         // si la saisie est un ISBN
                         $isbn = formatISBN($ref);
                         // si échec, ISBN erroné on le prend sous cette forme
                         if (!$isbn) {
                             $code = str_replace("*", "%", $ref);
                         } else {
                             $code10 = $isbn;
                             $code = formatISBN($code10, 13);
                         }
                     } else {
                         // ce n'est rien de tout ça, on prend la saisie telle quelle
                         $code = str_replace("*", "%", $ref);
                     }
                 }
                 //plutot que de faire une requete pour lancer que si ca marche, on ajoute un callback en cas d'échec
                 if ($code) {
                     $enrichment['books']['content'] = "\n\t\t\t\t\t\t<div id='gbook{$notice_id}' style='width: " . $width . "px; height: " . $height . "px;margin-bottom:0.5em;'></div>";
                     $enrichment['books']['callback'] = "\n\t\t\t\t\t\t\tvar viewer = new google.books.DefaultViewer(document.getElementById('gbook" . $notice_id . "'));\n\t\t\t\t\t\t\tvar gbook" . $notice_id . "_failed = function(){\n\t\t\t\t\t\t\t\tvar content = document.getElementById('gbook" . $notice_id . "');\n\t\t\t\t\t\t\t\tvar span = document.createElement('span');\n\t\t\t\t\t\t\t\tvar txt = document.createTextNode('" . $this->msg["gbook_no_preview"] . "');\n\t\t\t\t\t\t\t\tspan.appendChild(txt);\n\t\t\t\t\t\t\t\tcontent.appendChild(span);\n\t\t\t\t\t\t\t\tcontent.style.height='auto';\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tviewer.load('ISBN:" . str_replace("-", "", $code) . "',gbook" . $notice_id . "_failed);\t\n\t\t\t\t\t\t";
                 } else {
                     $enrichment['books']['content'] = "<span>" . $this->msg["gbook_no_preview"] . "</span>";
                 }
             }
             break;
     }
     $enrichment['source_label'] = $this->msg['gbooks_enrichment_source'];
     return $enrichment;
 }
示例#14
0
function traite_code_isbn($saisieISBN = "")
{
    if ($saisieISBN) {
        if (isEAN($saisieISBN)) {
            // la saisie est un EAN -> on tente de le formater en ISBN
            $code = EANtoISBN($saisieISBN);
            // si échec, on prend l'EAN comme il vient
            if (!$code) {
                $code = $saisieISBN;
            }
        } else {
            if (isISBN($saisieISBN)) {
                // si la saisie est un ISBN
                $code = formatISBN($saisieISBN);
                // si échec, ISBN erroné on le prend sous cette forme
                if (!$code) {
                    $code = $saisieISBN;
                }
            } else {
                // ce n'est rien de tout ça, on prend la saisie telle quelle
                $code = $saisieISBN;
            }
        }
        return $code;
    }
    return "";
}
示例#15
0
function test_cb()
{
    global $cb;
    global $barcode;
    $isbn = '';
    $barcode = '';
    // on commence par voir ce que la saisie utilisateur est ($cb)
    $cb = clean_string($cb);
    if (isEAN($cb)) {
        // la saisie est un EAN -> on tente de le formater en ISBN
        $isbn = EANtoISBN($cb);
        // si échec, on prend l'EAN comme il vient
        if (!$isbn) {
            $barcode = $cb;
        } else {
            $barcode = $isbn;
        }
    } else {
        if (isISBN($cb)) {
            // si la saisie est un ISBN
            $isbn = formatISBN($cb);
            // si échec, ISBN erroné on le prend sous cette forme
            if (!$isbn) {
                $barcode = $cb;
            } else {
                $barcode = $isbn;
            }
        } else {
            // ce n'est rien de tout ça, on prend la saisie telle quelle
            $barcode = $cb;
        }
    }
}
示例#16
0
    }
} else {
    //droits d'acces lecture notice
    $acces_j = '';
    if ($gestion_acces_active == 1 && $gestion_acces_user_notice == 1) {
        require_once "{$class_path}/acces.class.php";
        $ac = new acces();
        $dom_1 = $ac->setDomain(1);
        $acces_j = $dom_1->getJoin($PMBuserid, 4, 'notice_id');
    }
    // on commence par voir ce que la saisie utilisateur est ($ex_query)
    $ex_query = clean_string($ex_query);
    $EAN = '';
    $isbn = '';
    $code = '';
    if (isEAN($ex_query)) {
        // la saisie est un EAN -> on tente de le formater en ISBN
        $EAN = $ex_query;
        $isbn = EANtoISBN($ex_query);
        // si échec, on prend l'EAN comme il vient
        if (!$isbn) {
            $code = str_replace("*", "%", $ex_query);
        } else {
            $code = $isbn;
            $code10 = formatISBN($code, 10);
        }
    } else {
        if (isISBN($ex_query)) {
            // si la saisie est un ISBN
            $isbn = formatISBN($ex_query);
            // si échec, ISBN erroné on le prend sous cette forme
示例#17
0
<?php

// +-------------------------------------------------+
// © 2002-2004 PMB Services / www.sigb.net pmb@sigb.net et contributeurs (voir www.sigb.net)
// +-------------------------------------------------+
// $Id: create_form.inc.php,v 1.13 2015-04-03 11:16:24 jpermanne Exp $
if (stristr($_SERVER['REQUEST_URI'], ".inc.php")) {
    die("no access");
}
// page de création d'une notice
// affichage du form de création/modification d'une notice
// dédoublonnage par le code-barre ou l'ISBN
if ($saisieISBN) {
    if (isEAN($saisieISBN)) {
        // la saisie est un EAN -> on tente de le formater en ISBN
        $code = EANtoISBN($saisieISBN);
        // si échec, on prend l'EAN comme il vient
        if (!$code) {
            $code = $saisieISBN;
        } else {
            //On calcule l'ISBN 10
            $code10 = EANtoISBN10($saisieISBN);
        }
    } else {
        //C'est un ISBN 10 !!
        if (isISBN($saisieISBN)) {
            // si la saisie est un ISBN
            $code10 = formatISBN($saisieISBN);
            // si échec, ISBN erroné on le prend sous cette forme
            if (!$code10) {
                $code = $saisieISBN;