4 * FusionForge Group Docman updater
6 * Copyright 2004 GForge, LLC
7 * Copyright 2011, IƱigo Martinez (inigoml)
8 * http://fusionforge.org/
10 * This file is part of FusionForge.
12 * FusionForge is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
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 this program; if not, write to the Free Software Foundation, Inc.,
24 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
27 require_once dirname(__FILE__).'/../www/env.inc.php';
28 require_once $gfwww.'include/squal_pre.php';
30 $res = db_query_params('SELECT docid,filesize FROM doc_data',
38 echo "Updating ".db_numrows($res)." documents\n";
40 for ($i=0; $i < db_numrows($res); $i++) {
42 $docid = db_result($res, $i, 'docid');
43 $base64_data_res = db_query_params('SELECT data FROM doc_data where docid='.$docid,array());
44 $base64_data = db_result($base64_data_res, 0, 'data');
45 $data = base64_decode($base64_data);
46 $size = strlen($data);
47 $res2 = db_query_params('UPDATE doc_data SET filesize=$1 WHERE docid=$2',
51 echo "Couldn't update document #".$docid.":".db_error()."\n";
55 echo "Updated document #".$docid." with size ".$size."\n";
63 // c-file-style: "bsd"