<?php
// $Id$
die('Remove die notice!');
chdir('./../');
require_once('./global.php');
$total = $nodo = 0;
$history = $db->query("SELECT * FROM " . TABLE_PREFIX . "history");
foreach ($history as $log)
{
$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]");
}
$db->query("UPDATE " . TABLE_PREFIX . "history SET field = '.{$log['field']}' WHERE historyid = $log[historyid]");
}
}
}
?>