From 5064da12cea319522125359b4a847e9215c8567c Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Thu, 11 May 2006 04:15:01 +0000 Subject: [PATCH] r819: Adding update_history.php to migrate old history data to the new format --- docs/update_history.php | 44 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 docs/update_history.php diff --git a/docs/update_history.php b/docs/update_history.php new file mode 100644 index 0000000..3636599 --- /dev/null +++ b/docs/update_history.php @@ -0,0 +1,44 @@ +query("SELECT * FROM " . TABLE_PREFIX . "history"); +while ($log = $db->fetch_array($history)) +{ + $matches = array(); + if (preg_match('#custom_field([0-9]+?)#i', $log['field'], $matches)) + { + $db->query("UPDATE " . TABLE_PREFIX . "history SET field = 'custom.field{$matches[1]}' WHERE historyid = $log[historyid]"); + } + else if (preg_match('#comment ([0-9]+?) (hidden|text)#i', $log['field'], $matches)) + { + $db->query("UPDATE " . TABLE_PREFIX . "history SET field = 'comment.{$matches[2]}', commentid = {$matches[1]} WHERE historyid = $log[historyid]"); + } + else if ($log['attachmentid'] != 0) + { + $db->query("UPDATE " . TABLE_PREFIX . "history SET field = 'attachment.{$log['field']}' WHERE historyid = $log[historyid]"); + } + else if (!preg_match('#^(comment|attachment)?\.#', $log['field'])) + { + foreach (array('original', 'changed') AS $array) + { + if (preg_match('# \(id: ([0-9]+?)\)$#i', $log["$array"], $matches)) + { + $db->query("UPDATE " . TABLE_PREFIX . "history SET $array = {$matches[1]} WHERE historyid = $log[historyid]"); + } + else if (preg_match('#user ?id:? ([0-9]+?)#i', $log["$array"], $matches)) + { + $db->query("UPDATE " . TABLE_PREFIX . "history SET $array = {$matches[1]} WHERE historyid = $log[historyid]"); + } + } + } +} + +?> \ No newline at end of file -- 2.43.5