/*
Written in 11-07-2006.
Document-type: PHP source
Just put it on the web server where the mysql server is and execute it.
*/
// Connecting, selecting database
$link = mysql_connect('HOST', 'USER', 'PASSWORD')
or die("Could not connect: " . mysql_error() . "\n");
mysql_select_db('horde') or die("Could not select database\n");
// Performing SQL query
$query = 'SELECT * FROM turba_objects';
$result = mysql_query($query) or die('Query failed: ' . mysql_error() . "\n");
/*
// Printing results in HTML
echo "
\n";
while ($line = mysql_fetch_array($result, MYSQL_NUM)) {
echo "\t\n";
foreach ($line as $col_value) {
// for ($num = 1; $num <= 16; $num++) {
// $num++;
// $line[$num]=$col_value;
echo "\t\t$col_value | \n";
}
echo "\t
\n";
}
echo "
\n";
*/
while ($line = mysql_fetch_array($result, MYSQL_NUM)) {
for ($num = 0; $num < 16; $num++) {
// here you can comment this out to match your case
// I consider that the new horde must have the usernames as
// user and NOT as user@domain anymore
if ($num != 1)
$new[$num] = str_replace("'","\'",$line[$num]);
else
list($new[$num],$domain) = split("@",$line[$num]);
}
// $nomes = str_replace("'","\'",$new[4]);
//echo "\n$nomes\n";
echo "INSERT INTO turba_objects VALUES ('$new[0]','$new[1]','$new[14]',NULL,'$new[15]','$new[2]','$new[3]','$new[4]','$new[5]','$new[6]','$new[7]','$new[8]','$new[9]','$new[10]','$new[11]','$new[12]','$new[13]',NULL,NULL,NULL);\n";
}
// Free resultset
mysql_free_result($result);
// Closing connection
mysql_close($link);
?>