[feladat @ 7]
- Fixed last major part of translation.
<?php
// +--------------------------------------------------------------------+
// | PowerAdmin |
// +--------------------------------------------------------------------+
// | Copyright (c) 1997-2002 The PowerAdmin Team |
// +--------------------------------------------------------------------+
// | This source file is subject to the license carried by the overal |
// | program PowerAdmin as found on http://poweradmin.sf.net |
// | The PowerAdmin program falls under the QPL License: |
// | http://www.trolltech.com/developer/licensing/qpl.html |
// +--------------------------------------------------------------------+
// | Authors: Roeland Nieuwenhuis <trancer <AT> trancer <DOT> nl> |
// | Sjeemz <sjeemz <AT> sjeemz <DOT> nl> |
// +--------------------------------------------------------------------+
//
// File: migrator.php
// Description: Migrates PowerAdmin 1.1.2 to the new 1.2 format
if(!@include_once("inc/config.inc.php"))
{
error("You have to create a config.inc.php!");
}
require_once("inc/database.inc.php");
PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, 'error');
function error($msg)
{
// General function for printing critical errors.
include_once("inc/header.inc.php");
?>
<P><TABLE CLASS="error"><TR><TD CLASS="error"><H2>Oops! An error occured!</H2>
<BR>
<FONT STYLE="font-weight: Bold">
<?
if(is_object($msg))
{
switch($msg->code)
{
case -19:
echo "<P>It seems you already have your PowerAdmin migrated because the tables cant be
altered. Another problem can be that you dont ALTER right on your database,
check this if you think your database doesnt have the proper format yet!</P>";
break;
case -18:
echo "<P>One of the tables required doesnt exist, please run
test_setup.php.</P>PEAR::DB Error: " . $msg->getDebugInfo();
break;
default:
echo "Unknown error, sorry: PEAR::DB Returned: " . $msg->getDebugInfo();
break;
}
}
else
{
echo $msg;
}
?>
<BR><BR><a href="javascript:history.go(-1)"><< back</a></FONT><BR></TD></TR></TABLE></P>
<?
include_once("inc/footer.inc.php");
die();
}
function message($msg)
{
include_once("inc/header.inc.php");
?>
<P><TABLE CLASS="messagetable"><TR><TD CLASS="message"><H2>Success!</H2>
<BR>
<FONT STYLE="font-weight: Bold">
<P>
<?
if($msg)
{
echo nl2br($msg);
}
else
{
echo "Successful!";
}
?>
</P>
<BR>
<P>
<a href="javascript:history.go(-1)"><< back</a></FONT>
</P>
</TD></TR></TABLE></P>
<?
include_once("inc/footer.inc.php");
}
$zoneresult = $db->getCol("select id from zones");
foreach($zoneresult as $zr)
{
// Look up the domain_id
$zonename = $db->getOne("select name from zones where zones.id=" . $zr);
// do a count, if the record already exists in the domains table, dont insert it
$dom_count = $db->query("select id from domains where name='$zonename'");
if($dom_count->numRows() == 0)
{
$dom_id = $db->nextID("domains");
$db->query("INSERT INTO domains(id, name, type) VALUES('$dom_id', '$zonename', 'NATIVE')");
$db->query("UPDATE records SET domain_id=$dom_id where domain_id=$zr");
$db->query("UPDATE zones SET name=$dom_id where id=$zr");
}
else
{
$row = $dom_count->fetchRow();
$db->query('UPDATE records SET domain_id=' . $row["id"] . " where domain_id=$zr");
$db->query('UPDATE zones SET name=' . $row['id'] . " where id=$zr");
}
}
if(!DB::isError($zoneresult))
{
$db->query("ALTER TABLE zones CHANGE name domain_id INT(11) NOT NULL");
message("Done updating your tables, enjoy your new PowerAdmin!
Please remove this file from your webdirectory!");
}
else
{
error("You seem to have no information in the table zones");
}
?>