public function get_notice_id() { global $pmb_keyword_sep; $notice_id = 0; $this->data = array(); $this->data['tit1'] = $this->data['tit4'] = $this->data['authors'] = $this->data['co_authors'] = $this->data['code'] = $this->data['npages'] = $this->data['year'] = $this->data['index_l'] = $this->data['url'] = $this->data['thumbnail_content'] = $this->data['publisher'] = $this->data['n_resume'] = ""; if ($this->mimetype == "application/epub+zip") { //pour les ebook, on gère ca directement ici ! $this->data['tit1'] = $this->metas['title'][0]; $this->data['authors'] = $this->metas['creator']; $this->data['co_authors'] = $this->metas['contributor']; if ($this->metas['identifier']['isbn']) { $this->data['code'] = \formatISBN($this->metas['identifier']['isbn'], 13); } else { if ($this->metas['identifier']['ean']) { $this->data['code'] = \EANtoISBN($this->metas['identifier']['ean']); $this->data['code'] = \formatISBN($code, 13); } } if ($this->metas['identifier']['uri']) { $this->data['url'] = \clean_string($this->metas['identifier']['uri']); } $this->data['publisher'] = $this->metas['publisher'][0]; $this->data['year'] = $this->metas['date'][0]['value']; if (strlen($this->data['year']) && strlen($this->data['year']) != 4) { $this->data['year'] = \formatdate(detectFormatDate($this->data['year'])); } $this->data['lang'] = $this->metas['language']; $this->data['n_resume'] = implode("\n", $this->metas['description']); $this->data['keywords'] = implode($pmb_keyword_sep, $this->metas['subject']); $this->data['thumbnail_content'] = $this->metas['thumbnail_content']; } else { foreach ($this->map['meta'] as $map_field => $map) { foreach ($this->metas as $meta_field => $meta_value) { if ($map_field == $meta_field) { if (method_exists($this, $map['function'])) { $this->data[$map['field']] = $this->{$map}['function']($this->data[$map['field']], $meta_value, $map['params']); } else { $this->data[$map['field']] = $meta_value; } break; } } } } if (!$this->data['tit1']) { $this->data['tit1'] = $this->name; } $notice_id = $this->create_notice(); $notice_id = $this->dedoublonne($notice_id); return $notice_id; }
$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 if (!$isbn) { $code = str_replace("*", "%", $ex_query); } else {
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 ""; }
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; }
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; }
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 { // ce n'est rien de tout ça, on prend la saisie telle quelle $code = $cb;
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; } } }
$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 { // ce n'est rien de tout ca, on prend la saisie telle quelle $code = $f_cb;
} $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 if (!$isbn) { $code = str_replace("*", "%", $ref); } else {
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; }
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 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; }
// $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 $tab[] = formatISBN($code, 13); //format EAN
<?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;
public function get_notice_id($metas, $mimetype = "", $name = "") { global $pmb_keyword_sep; $this->metas = $metas; $this->mimetype = $mimetype; $this->name = $name; $notice_id = 0; $this->data = array(); $this->data['tit1'] = $this->data['tit4'] = $this->data['authors'] = $this->data['co_authors'] = $this->data['code'] = $this->data['npages'] = $this->data['year'] = $this->data['index_l'] = $this->data['url'] = $this->data['thumbnail_content'] = $this->data['publisher'] = $this->data['n_resume'] = ""; if ($this->mimetype == "application/epub+zip") { //pour les ebook, on gère ca directement ici ! $this->data['tit1'] = $this->metas['title'][0]; $this->data['authors'] = $this->metas['creator']; $this->data['co_authors'] = $this->metas['contributor']; if ($this->metas['identifier']['isbn']) { $this->data['code'] = \formatISBN($this->metas['identifier']['isbn'], 13); } else { if ($this->metas['identifier']['ean']) { $this->data['code'] = \EANtoISBN($this->metas['identifier']['ean']); $this->data['code'] = \formatISBN($code, 13); } } if ($this->metas['identifier']['uri']) { $this->data['url'] = \clean_string($this->metas['identifier']['uri']); } $this->data['publisher'] = $this->metas['publisher'][0]; $this->data['year'] = $this->metas['date'][0]['value']; if (strlen($this->data['year']) && strlen($this->data['year']) != 4) { $this->data['year'] = \formatdate(detectFormatDate($this->data['year'])); } $this->data['lang'] = $this->metas['language']; $this->data['n_resume'] = implode("\n", $this->metas['description']); $this->data['keywords'] = implode($pmb_keyword_sep, $this->metas['subject']); $this->data['thumbnail_content'] = $this->metas['thumbnail_content']; } else { $this->exec_map(); } if (!$this->data['tit1']) { $this->data['tit1'] = $this->name; } $notice_id = $this->create_notice(); $notice_id = $this->dedoublonne($notice_id); // Indexation \notice::majNoticesTotal($notice_id); return $notice_id; }
function get_notice_by_meta($name, $filename) { global $pmb_keyword_sep; global $pmb_type_audit; global $webdav_current_user_name, $webdav_current_user_id; \create_tableau_mimetype(); $mimetype = \trouve_mimetype($filename, extension_fichier($name)); $notice_id = 0; $title = $cplt = $code = $pages = $year = $keywords = $url = $thumbnail_content = ""; //on commence avec la gymnatisque des métas... if ($mimetype == "application/epub+zip") { //pour les ebook, on gère ca directement ici ! $epub = new \epubData(realpath($filename)); $title = $epub->metas['title'][0]; $authors = $epub->metas['creator']; $co_authors = $epub->metas['contributor']; if ($epub->metas['identifier']['isbn']) { $code = \formatISBN($epub->metas['identifier']['isbn'], 13); } else { if ($epub->metas['identifier']['ean']) { $code = \EANtoISBN($epub->metas['identifier']['ean']); $code = \formatISBN($code, 13); } } if ($epub->metas['identifier']['uri']) { $url = \clean_string($epub->metas['identifier']['uri']); } $publisher = $epub->metas['publisher'][0]; $year = $epub->metas['date'][0]['value']; if (strlen($year) && strlen($year) != 4) { $year = \formatdate(detectFormatDate($year)); } $lang = $epub->metas['language']; $resume = implode("\n", $epub->metas['description']); $keywords = implode($pmb_keyword_sep, $epub->metas['subject']); //jouons à et si on trouvait a vignette... $img = imagecreatefromstring($epub->getCoverContent()); $file = tempnam(sys_get_temp_dir(), "vign"); imagepng($img, $file); $thumbnail_content = file_get_contents($file); unlink($file); } else { $metas = \extract_metas(realpath($filename), $mimetype); if ($metas['Title'] && $metas['Author'] && $metas['Subject']) { $title = $metas['Title']; $author = $metas['Author']; $cplt = $metas['Subject']; } else { // métas non fiable, on regarde avec le titre... $title = $name; } //date de création... if ($metas["CreateDate"]) { $year = substr($metas["CreateDate"], 0, 4); } //pages if ($metas['PageCount']) { $pages = $metas['PageCount']; } //keywords if ($metas['Keywords']) { foreach ($metas['Keywords'] as $keyword) { if ($keywords != "") { $keywords .= $pmb_keyword_sep; } $keywords .= $keyword; } } } $query = "select notice_id from notices where tit1 = '" . addslashes($title) . "'"; $result = mysql_query($query); if (mysql_num_rows($result)) { $notice_id = mysql_result($result, 0, 0); } if (!$notice_id) { //en cas d'une leture moyenne des infos, on s'assure d'avoir au moins un titre.... if (!$title) { $title = $name; } if ($publisher) { $ed_1 = \editeur::import(array('name' => $publisher)); } else { $ed_1 = 0; } $ind_wew = $title . " " . $cplt; $ind_sew = \strip_empty_words($ind_wew); $query = "insert into notices set \n\t\t\t\ttit1 = '" . addslashes($title) . "'," . ($code ? "code='" . $code . "'," : "") . "ed1_id = '" . $ed_1 . "'," . ($cplt ? "tit4 = '" . addslashes($cplt) . "'," : "") . ($pages ? "npages = '" . addslashes($pages) . "'," : "") . ($keywords ? "index_l = '" . addslashes($keywords) . "'," : "") . "\n\t\t\t\tyear = '" . $year . "',\n\t\t\t\tniveau_biblio='m', \n\t\t\t\tniveau_hierar='0',\n\t\t\t\tstatut = '" . $this->config['default_statut'] . "',\n\t\t\t\tindex_wew = '" . $ind_wew . "',\n\t\t\t\tindex_sew = '" . $ind_sew . "',\n\t\t\t\tn_resume = '" . addslashes($resume) . "',\n\t\t\t\tlien = '" . addslashes($url) . "',\n\t\t\t\tindex_n_resume = '" . \strip_empty_words($resume) . "'," . ($thumbnail_content ? "thumbnail_url = 'data:image/png;base64," . base64_encode($thumbnail_content) . "'," : "") . "create_date = sysdate(), \n\t\t\t\tupdate_date = sysdate()"; mysql_query($query); $notice_id = mysql_insert_id(); $sign = new \notice_doublon(); mysql_query("update notices set signature = '" . $sign->gen_signature($notice_id) . "' where notice_id = " . $notice_id); //traitement audit if ($pmb_type_audit) { $query = "INSERT INTO audit SET "; $query .= "type_obj='1', "; $query .= "object_id='{$notice_id}', "; $query .= "user_id='{$webdav_current_user_id}', "; $query .= "user_name='{$webdav_current_user_name}', "; $query .= "type_modif=1 "; $result = @mysql_query($query); } if (count($authors)) { $i = 0; foreach ($authors as $author) { $aut = array(); if ($author['file-as']) { $infos = explode(",", $author['file-as']); $aut = array('name' => $infos[0], 'rejete' => $infos[1], 'type' => 70); } if (!$aut['name']) { $aut = array('name' => $author['value'], 'type' => 70); } $aut_id = \auteur::import($aut); if ($aut_id) { $query = "insert into responsability set \n\t\t\t\t\t\t\tresponsability_author = '" . $aut_id . "',\n\t\t\t\t\t\t\tresponsability_notice = '" . $notice_id . "',\n\t\t\t\t\t\t\tresponsability_type = '0'"; mysql_query($query); $i++; } } } if (count($co_authors)) { foreach ($co_authors as $author) { $aut = array(); if ($author['file-as']) { $infos = explode(",", $author['file-as']); $aut = array('name' => $infos[0], 'rejete' => $infos[1], 'type' => 70); } if (!$aut['name']) { $aut = array('name' => $author['value'], 'type' => 70); } $aut_id = \auteur::import($aut); if ($aut_id) { $query = "insert into responsability set \n\t\t\t\t\t\t\tresponsability_author = '" . $aut_id . "',\n\t\t\t\t\t\t\tresponsability_notice = '" . $notice_id . "',\n\t\t\t\t\t\t\tresponsability_type = '0',\n\t\t\t\t\t\t\trepsonsability_ordre = '" . $i . "'"; mysql_query($query); $i++; } } } } return $notice_id; }