3 // can load/export all of our common data bits
7 require_once('./includes/init.php');
9 // ###################################################################
10 // list of things to export/import: array(displayname => array('table' => db table, 'rebuild' => rebuild function)
13 'usergroups' => array(
14 'table' => 'usergroup',
15 'rebuild' => 'build_usergroups'
20 'rebuild' => 'build_statuses'
24 'table' => 'severity',
25 'rebuild' => 'build_severities'
28 'priorities' => array(
29 'table' => 'priority',
30 'rebuild' => 'build_priorities'
33 'resolutions' => array(
34 'table' => 'resolution',
35 'rebuild' => 'build_resolutions'
39 'table' => 'fieldhelp',
40 'rebuild' => 'build_user_help',
49 Here you can either export
or import the standard data tables
for Bugdar
. These
include things such
as usergroups
, priorities
, etc
.
51 <h3
>[<strong
><a href
="datatools.php?do=export">Export
</a
></strong
>] [<strong
><a href
="datatools.php?do=import">Import
</a
></strong
>] [<strong
><a href
="datatools.php?do=view">View
</a
></strong
>] [<strong
><a href
="datatools.php?do=settings">Dump Settings
</a
></strong
>]</h3
>
59 // ###################################################################
61 if ($_REQUEST['do'] == 'export')
63 foreach ($THELIST AS $display => $data)
65 $fetch = $db->query("SELECT * FROM " . TABLE_PREFIX
. "$data[table]" . (!$data['orderfree'] ?
" ORDER BY {$data[table]}id ASC" : ""));
66 while ($fitem = $db->fetch_array($fetch))
68 $exportlist["$display"][] = $fitem;
70 $db->free_result($fetch);
72 echo "Exported $display\n";
75 $phpfile = '<?' . 'php
77 // stores exported data data
80 $DATASTORE = "' . addslashes(serialize($exportlist)) . '";
84 if ($handle = fopen('./docs/datatools_store.php', 'w'))
86 if (fwrite($handle, $phpfile))
92 echo 'Could not write the file';
98 echo 'Could not open the file with mode "w"';
102 echo "Wrote the file\n";
105 // ###################################################################
107 if ($_REQUEST['do'] == 'import')
109 require('./docs/datatools_store.php');
110 $DATASTORE = unserialize(stripslashes($DATASTORE));
112 foreach ($THELIST AS $display => $data)
114 $db->query("TRUNCATE TABLE " . TABLE_PREFIX
. "$data[table]");
118 foreach ($DATASTORE["$display"] AS $mainarray)
120 $fields = $values = array();
121 foreach ($mainarray AS $field => $value)
124 $values[] = "'" . $bugsys->escape($value) . "'";
126 $query = "INSERT INTO " . TABLE_PREFIX
. "$data[table] (" . implode(', ', $fields) . ") VALUES (" . implode(', ', $values) . ")";
127 echo str_replace(array('>', '<'), array('>', '<'), $query) . "\n";
132 echo "Rebuilding $data[table]\n\n";
136 // ###################################################################
138 if ($_REQUEST['do'] == 'view')
140 require_once('./docs/datatools_store.php');
141 $DATASTORE = unserialize(stripslashes($DATASTORE));
143 $build = '$data = array(';
145 foreach ($THELIST AS $display => $data)
147 $build .= "\n\t'$data[table]' => array(";
148 foreach ($DATASTORE["$display"] AS $mainarray)
150 $build .= "\n\t\tarray(";
151 foreach ($mainarray AS $field => $value)
153 $build .= "\n\t\t\t'" . addslashes($field) . "' => '" . addslashes($value) . "',";
155 $build = substr($build, 0, strlen($build) - 1);
156 $build .= "\n\t\t),";
158 $build = substr($build, 0, strlen($build) - 1);
161 $build = substr($build, 0, strlen($build) - 1);
165 echo '<textarea style="height: 500px; width: 100%">' . htmlspecialchars($build) . '</textarea>';
168 // ###################################################################
170 if ($_REQUEST['do'] == 'settings')
174 /*=====================================================================*\
175 || ###################################################################
176 || # Bugdar [#]version[#]
177 || # Copyright ©2002-[#]year[#] Blue Static
179 || # This program is free software; you can redistribute it and/or modify
180 || # it under the terms of the GNU General Public License as published by
181 || # the Free Software Foundation; version [#]gpl[#] of the License.
183 || # This program is distributed in the hope that it will be useful, but
184 || # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
185 || # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
188 || # You should have received a copy of the GNU General Public License along
189 || # with this program; if not, write to the Free Software Foundation, Inc.,
190 || # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
191 || ###################################################################
192 \*=====================================================================*/
194 // this stores all the settings for a new installation
199 $settings = $db->query("SELECT * FROM " . TABLE_PREFIX
. "setting");
200 while ($setting = $db->fetch_array($settings))
202 $fout .= "\n\t'$setting[varname]' => '" . str_replace("'", "\'", $setting['value']) . "',";
209 /*=====================================================================*\
210 || ###################################################################
213 || ###################################################################
214 \*=====================================================================*/
218 file_put_contents('install/settings.php', $fout);
220 echo 'Dumping current settings into install/settings.php';