Switch the 'modify' code of admin/field.php to use templates
[bugdar.git] / docs / update_history.php
1 <?php
2
3 // $Id$
4
5 die('Remove die notice!');
6
7 chdir('./../');
8 require_once('./global.php');
9
10 $total = $nodo = 0;
11
12 $history = $db->query("SELECT * FROM " . TABLE_PREFIX . "history");
13 foreach ($history as $log)
14 {
15 $matches = array();
16 if (preg_match('#custom_field([0-9]+?)#i', $log['field'], $matches))
17 {
18 $db->query("UPDATE " . TABLE_PREFIX . "history SET field = 'custom.field{$matches[1]}' WHERE historyid = $log[historyid]");
19 }
20 else if (preg_match('#comment ([0-9]+?) (hidden|text)#i', $log['field'], $matches))
21 {
22 $db->query("UPDATE " . TABLE_PREFIX . "history SET field = 'comment.{$matches[2]}', commentid = {$matches[1]} WHERE historyid = $log[historyid]");
23 }
24 else if ($log['attachmentid'] != 0)
25 {
26 $db->query("UPDATE " . TABLE_PREFIX . "history SET field = 'attachment.{$log['field']}' WHERE historyid = $log[historyid]");
27 }
28 else if (!preg_match('#^(comment|attachment)?\.#', $log['field']))
29 {
30 foreach (array('original', 'changed') AS $array)
31 {
32 if (preg_match('# \(id: ([0-9]+?)\)$#i', $log["$array"], $matches))
33 {
34 $db->query("UPDATE " . TABLE_PREFIX . "history SET $array = {$matches[1]} WHERE historyid = $log[historyid]");
35 }
36 else if (preg_match('#user ?id:? ([0-9]+?)#i', $log["$array"], $matches))
37 {
38 $db->query("UPDATE " . TABLE_PREFIX . "history SET $array = {$matches[1]} WHERE historyid = $log[historyid]");
39 }
40 $db->query("UPDATE " . TABLE_PREFIX . "history SET field = '.{$log['field']}' WHERE historyid = $log[historyid]");
41 }
42 }
43 }
44
45 ?>