4 * FusionForge document search engine
6 * Copyright 2005, Fabio Bertagnin
7 * Copyright 2009, Roland Mas
8 * Copyright 2010-2011, Franck Villaume - Capgemini
9 * Copyright 2012, Franck Villaume - TrivialDev
11 * This file is part of FusionForge. FusionForge is free software;
12 * you can redistribute it and/or modify it under the terms of the
13 * GNU General Public License as published by the Free Software
14 * Foundation; either version 2 of the Licence, or (at your option)
17 * FusionForge is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License along
23 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
24 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
27 require dirname(__FILE__).'/../www/env.inc.php';
28 require_once $gfcommon.'include/pre.php';
29 require_once $gfcommon.'docman/Parsedata.class.php';
30 require_once $gfcommon.'docman/Document.class.php';
31 require_once $gfcommon.'docman/DocumentFactory.class.php';
32 require_once $gfcommon.'docman/DocumentGroupFactory.class.php';
36 $timestarttrait = microtime_float();
39 $result = db_query_params('SELECT doc_data.docid, doc_data.group_id, doc_data.filename, doc_data.title, doc_data.description, doc_data.filetype from doc_data, groups where doc_data.group_id = groups.group_id and groups.force_docman_reindex = $1',
46 while ($arr = db_fetch_array($result)) {
53 foreach ($resarr as $item) {
55 $timestart = microtime_float();
56 $group = group_get_object($item['group_id']);
57 $d = new Document($group, $item['docid']);
58 $datafile = tempnam(forge_get_config('data_path'), 'tmp');
59 $fh = fopen($datafile, 'w');
60 fwrite($fh, $d->getFileData(false));
62 $lenin = $d->getFileSize();
63 $res = $p->get_parse_data($datafile, htmlspecialchars($item['title']), htmlspecialchars($item['description']), $item['filetype'], $item['filename']);
65 if (file_exists($datafile)) {
68 $resUp = db_query_params('UPDATE doc_data SET data_words=$1 WHERE docid=$2',
69 array ($res, $item['docid']));
71 die('unable to update data: '.db_error());
73 $timeend = microtime_float();
74 $timetrait = $timeend - $timestart;
75 echo "Analyzed $item[filename] : type=$item[filetype] octets in=$lenin octets out=$len time=$timetrait sec\n";
77 $timeendtrait = microtime_float();
78 $timetot = $timeendtrait - $timestarttrait;
79 db_query_params('UPDATE groups set force_docman_reindex = $1', array('0'));
80 //echo "End analyze : $compt files, $timetot secs.";
82 function microtime_float() {
83 list($usec, $sec) = explode(" ", microtime());
84 return ((float)$usec + (float)$sec);
89 // c-file-style: "bsd"