4 * GForge Group Role Generator
6 * Copyright 2004 GForge, LLC
7 * http://fusionforge.org/
9 * This file is part of FusionForge.
11 * FusionForge is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * FusionForge is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License along
22 * with this program; if not, write to the Free Software Foundation, Inc.,
23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 require_once dirname(__FILE__).'/../common/include/env.inc.php';
27 require_once $gfcommon.'include/pre.php';
28 require_once $gfcommon.'tracker/ArtifactStorage.class.php';
30 ini_set('memory_limit', -1);
31 ini_set('max_execution_time', 0);
33 $res = db_query_params ('SELECT id FROM artifact_file WHERE bin_data !=$1', array('')) ;
35 echo 'UPGRADE ERROR: '.db_error();
39 $data = forge_get_config('data_path');
41 system("mkdir -p $data");
42 system("chown ".forge_get_config('apache_user').':'.forge_get_config('apache_group')." $data");
43 system("chmod 0700 $data");
46 $as = new ArtifactStorage();
47 $tmp = tempnam('/tmp', 'tracker');
49 while($row = db_fetch_array($res)) {
50 $res2 = db_query_params ('SELECT filesize, bin_data FROM artifact_file WHERE id=$1',
52 $row2 = db_fetch_array($res2);
53 $ret = file_put_contents($tmp, base64_decode($row2['bin_data']));
55 echo "UPGRADE ERROR: file_put_contents($tmp) error: returned false\n";
59 if ($ret != $row2['filesize']) {
60 echo "UPGRADE ERROR: file_put_contents($tmp): size error ($ret != ".$row2['filesize'].")\n";
64 $ret = $as->store($row['id'], $tmp);
66 echo "UPGRADE ERROR: $ret: ".$as->getErrorMessage()."\n";
74 db_query_params ('UPDATE artifact_file SET bin_data=$1', array(''));