$explnum = pmb_mysql_query("SELECT count(1) FROM explnum", $dbh); $count = pmb_mysql_result($explnum, 0, 0); } print "<br /><br /><h2 align='center'>" . htmlentities($msg["docnum_reindexation"], ENT_QUOTES, $charset) . "</h2>"; $requete = "select explnum_id as id from explnum order by id LIMIT {$start}, {$lot}"; $res_explnum = pmb_mysql_query($requete, $dbh); if (pmb_mysql_num_rows($res_explnum)) { // définition de l'état de la jauge $state = floor($start / ($count / $jauge_size)); $state .= "px"; // mise à jour de l'affichage de la jauge print "<table border='0' align='center' width='{$jauge_size}' cellpadding='0'><tr><td class='jauge' width='100%'>"; print "<img src='../../images/jauge.png' width='{$state}' height='16px'></td></tr></table>"; // calcul pourcentage avancement $percent = floor($start / $count * 100); // affichage du % d'avancement et de l'état print "<div align='center'>{$percent}%</div>"; while ($explnum = pmb_mysql_fetch_object($res_explnum)) { $index = new indexation_docnum($explnum->id); $index->indexer(); } $next = $start + $lot; print "\n\t\t<form class='form-{$current_module}' name='current_state' action='./clean.php' method='post'>\n\t\t<input type='hidden' name='v_state' value=\"" . urlencode($v_state) . "\">\n\t\t<input type='hidden' name='spec' value=\"{$spec}\">\n\t\t<input type='hidden' name='start' value=\"{$next}\">\n\t\t<input type='hidden' name='count' value=\"{$count}\">\n\t\t</form>\n\t\t<script type=\"text/javascript\"><!-- \n\t\tsetTimeout(\"document.forms['current_state'].submit()\",1000); \n\t\t-->\n\t\t</script>"; } else { $spec = $spec - INDEX_DOCNUM; $not = pmb_mysql_query("SELECT count(1) FROM explnum", $dbh); $compte = pmb_mysql_result($not, 0, 0); $v_state .= "<br /><img src=../../images/d.gif hspace=3>" . htmlentities($msg['docnum_reindexation'], ENT_QUOTES, $charset) . " : "; $v_state .= $compte . " " . htmlentities($msg['docnum_reindex_expl'], ENT_QUOTES, $charset); print "\n\t\t<form class='form-{$current_module}' name='process_state' action='./clean.php' method='post'>\n\t\t<input type='hidden' name='v_state' value=\"" . urlencode($v_state) . "\">\n\t\t<input type='hidden' name='spec' value=\"{$spec}\">\n\t\t</form>\n\t\t<script type=\"text/javascript\"><!--\n\t\t\tdocument.forms['process_state'].submit();\n\t\t\t-->\n\t\t</script>"; }
function indexDocnum() { global $msg, $dbh, $charset, $PMBusername; if (SESSrights & ADMINISTRATION_AUTH) { $result .= "<h3>" . htmlentities($msg["docnum_reindexation"], ENT_QUOTES, $charset) . "</h3>"; $requete = "select explnum_id as id from explnum order by id"; $res_explnum = mysql_query($requete, $dbh); if (mysql_num_rows($res_explnum)) { while ($explnum = mysql_fetch_object($res_explnum)) { mysql_close($dbh); $dbh = connection_mysql(); $index = new indexation_docnum($explnum->id); $index->indexer(); } } $explnum = mysql_query("SELECT count(1) FROM explnum", $dbh); $count = mysql_result($explnum, 0, 0); $result .= $count . " " . htmlentities($msg['docnum_reindex_expl'], ENT_QUOTES, $charset); } else { $result .= sprintf($msg["planificateur_rights_bad_user_rights"], $PMBusername); } return $result; }
function get_doc_num($explnum, $upload_folder) { global $pmb_set_time_limit, $dbh; $report = array(); if (SESSrights & ADMINISTRATION_AUTH) { @set_time_limit($pmb_set_time_limit); if (is_array($explnum) && $upload_folder) { $idLien = ''; if ($explnum['explnum_bulletin']) { $query = "SELECT 1 FROM bulletins WHERE bulletin_id=" . $explnum['explnum_bulletin']; $result = pmb_mysql_query($query, $dbh); if (pmb_mysql_num_rows($result)) { $idLien = 'explnum_bulletin=' . $explnum['explnum_bulletin']; } } elseif ($explnum['explnum_notice']) { $query = "SELECT 1 FROM notices WHERE notice_id=" . $explnum['explnum_notice']; $result = pmb_mysql_query($query, $dbh); if (pmb_mysql_num_rows($result)) { $idLien = 'explnum_notice=' . $explnum['explnum_notice']; } } if ($idLien) { if (file_exists($upload_folder . $explnum['explnum_nomfichier'])) { if (!$explnum['explnum_nom']) { $explnum['explnum_nom'] = $explnum['explnum_nomfichier']; } if (!$explnum['explnum_repertoire']) { $explnum['explnum_repertoire'] = '1'; } if (!$explnum['explnum_statut']) { $explnum['explnum_statut'] = '0'; } if (!$explnum['explnum_path']) { $explnum['explnum_path'] = '/'; } if (!$explnum['explnum_extfichier']) { $match = array(); if (preg_match('/.+\\.(.+)$/', $explnum['explnum_nomfichier'], $match)) { $explnum['explnum_extfichier'] = $match[1]; } } if (!$explnum['explnum_mimetype']) { $explnum['explnum_mimetype'] = trouve_mimetype($upload_folder . $explnum['explnum_nomfichier'], $explnum['explnum_extfichier']); } if (!$explnum['explnum_vignette']) { $explnum['explnum_vignette'] = reduire_image($upload_folder . $explnum['explnum_nomfichier']); } $query = 'INSERT INTO explnum SET ' . $idLien . ', explnum_nom="' . addslashes($explnum['explnum_nom']) . '", explnum_mimetype="' . addslashes($explnum['explnum_mimetype']) . '", explnum_extfichier="' . addslashes($explnum['explnum_extfichier']) . '", explnum_nomfichier="' . addslashes($explnum['explnum_nomfichier']) . '", explnum_vignette="' . addslashes($explnum['explnum_vignette']) . '", explnum_path="' . addslashes($explnum['explnum_path']) . '", explnum_repertoire="' . addslashes($explnum['explnum_repertoire']) . '", explnum_statut="' . addslashes($explnum['explnum_statut']) . '"'; pmb_mysql_query($query, $dbh); $explnum['explnum_id'] = pmb_mysql_insert_id($dbh); if ($explnum['explnum_id']) { //on récup le répertoire dans lequel envoyer le fichier $upload_repertoire = new upload_folder($explnum['explnum_repertoire']); if (!is_dir($upload_repertoire->decoder_chaine($upload_repertoire->repertoire_path))) { $report['error'][] = $this->msg['get_doc_num_upload_repertoire_do_not_exist']; //On efface l'entrée $query = 'DELETE FROM explnum WHERE explnum_id=' . $explnum['explnum_id']; pmb_mysql_query($query, $dbh); } if (!rename($upload_folder . $explnum['explnum_nomfichier'], $upload_repertoire->decoder_chaine($upload_repertoire->repertoire_path) . $explnum['explnum_nomfichier'])) { $report['error'][] = $this->msg['get_doc_num_rename_error']; //On efface l'entrée $query = 'DELETE FROM explnum WHERE explnum_id=' . $explnum['explnum_id']; pmb_mysql_query($query, $dbh); } else { //Réussi ici, on réindex et on incrémente le résultat $obj_explnum = new explnum($explnum['explnum_id']); $index = new indexation_docnum($explnum['explnum_id']); $index->indexer(); $report['info'] = 1; } } else { //erreur de déplacement ou de création $report['error'][] = $this->msg['get_doc_num_cant_create_explnum']; } } else { $report['error'][] = $this->msg['get_doc_num_file_not_found']; //On efface l'entrée $query = 'DELETE FROM explnum WHERE explnum_id=' . $explnum['explnum_id']; pmb_mysql_query($query, $dbh); } } else { //doc num sans id notice ou bulletin $report['error'][] = $this->msg['get_doc_num_missing_link']; } } else { //il manque un param $report['error'][] = $this->msg['get_doc_num_missing_param']; } } return $report; }
function explnum_add_url($f_notice_id, $f_bulletin_id, $f_nom, $f_url, $overwrite = true, $f_statut = 0) { global $dbh; if ($f_bulletin_id) { $f_notice_id = 0; } else { if (!$f_bulletin_id && $f_notice_id) { $f_bulletin_id = 0; } } if (!$overwrite) { $sql_find = "SELECT count(*) FROM explnum WHERE explnum_notice = " . $f_notice_id . " AND explnum_nom = " . addslashes($f_nom); $res = pmb_mysql_query($sql_find, $dbh); $count = pmb_mysql_result($res, 0, 0); if ($count) { return; } } $sql_delete = "DELETE FROM explnum WHERE explnum_notice = " . $f_notice_id . " AND explnum_nom = " . addslashes($f_nom); pmb_mysql_query($sql_delete, $dbh); $original_filename = basename($f_url); $extension = strrchr($original_filename, '.'); $insert_sql = "INSERT INTO explnum (explnum_notice, explnum_bulletin, explnum_nom, explnum_nomfichier, explnum_url, explnum_mimetype, explnum_extfichier, explnum_docnum_statut) VALUES ("; $insert_sql .= $f_notice_id . ","; $insert_sql .= $f_bulletin_id . ","; $insert_sql .= "'" . addslashes($f_nom) . "',"; $insert_sql .= "'" . addslashes($original_filename) . "',"; $insert_sql .= "'" . addslashes($f_url) . "',"; $insert_sql .= "'" . "URL" . "',"; $insert_sql .= "'" . addslashes($extension) . "',"; $insert_sql .= $f_statut; $insert_sql .= ")"; if (pmb_mysql_query($insert_sql, $dbh)) { $docnum_id = pmb_mysql_insert_id($dbh); if ($docnum_id) { $index = new indexation_docnum($docnum_id); $index->indexer(); } } }
function indexer_docnum() { global $scanned_texte, $ck_index; if (!$this->explnum_id && $ck_index) { $id_explnum = $this->explnum_id; $indexation = new indexation_docnum($id_explnum, $scanned_texte); $indexation->indexer(); } elseif ($this->explnum_id && $ck_index) { $indexation = new indexation_docnum($this->explnum_id, $scanned_texte); $indexation->indexer(); } elseif ($this->explnum_id && !$ck_index && ($this->explnum_index_sew != '' || $this->explnum_index_wew != '')) { $indexation = new indexation_docnum($this->explnum_id); $indexation->desindexer(); } return $indexation->vignette; }