Forum overzetten
Geplaatst: 24 apr 2004, 18:30
Hoe kan ik mijn berichten overzetten (dus alleen mijn berichten) naar een ander forum???
Code: Selecteer alles
#!/usr/bin/php -q
<?php
define('IN_PHPBB', true);
$phpbb_root_path = './';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);
function read ($length='255')
{
if (!isset ($GLOBALS['StdinPointer']))
{
$GLOBALS['StdinPointer'] = fopen ("php://stdin","r");
}
$line = fgets ($GLOBALS['StdinPointer'],$length);
return trim ($line);
}
$dbhost_old = '********';
$dbname_old = '********';
$dbuser_old = '********';
$dbpasswd_old = '********';
$db_old = new sql_db($dbhost_old, $dbuser_old, $dbpasswd_old, $dbname_old, false);
if(!$db_old->db_connect_id)
{
message_die(CRITICAL_ERROR, "Could not connect to the old database");
}
$new_table_list = $db->sql_fetch_tables();
passthru(clear);
for($i=0;$i<count($new_table_list);$i++)
{
$fields = $db->sql_fetch_fields($new_table_list[$i]);
for($f=0;$f<count($fields);$f++)
{
$field_list .= ", ".$fields[$f];
}
$sql = "SELECT ".trim($field_list, ", ")." FROM $new_table_list[$i] WHERE 1 ORDER BY ".$fields[0];
echo "\n\nGet data from: " . $new_table_list[$i] . "\n";
echo "[yes / no] :";
$go_ahead = read();
if(strtolower($go_ahead) == "no" || strtolower($go_ahead) == "n")
{
unset($go_ahead);
unset($field_list, $insert_rows, $data, $fields);
continue;
} elseif ( strtolower($go_ahead) == "yes" || strtolower($go_ahead) == "y")
{
} else {
$go_ahead = read();
}
echo "\n\n";
echo $sql."\n";
echo "progres: ";
sleep(2);
$result = $db_old->sql_query($sql);
if(!($db_old->sql_query($sql)) )
{
$error = $db_old->sql_error();
echo "\n".$error['message']."\n\n";
}
$numrows = $db_old->sql_numrows($result);
while( $row = $db_old->sql_fetchrow($result) )
{
for($r=0;$r<count($numrows);$r++)
{
for($d=0;$d<count($fields);$d++)
{
$insert_data .= ", '".addslashes($row[$d])."'";
}
$sql_new_insert = "INSERT INTO ".$new_table_list[$i]." (".trim($field_list, ", ").") values (".trim($insert_data, ", ").")";
set_time_limit(60);
if(!($db->sql_query($sql_new_insert)) )
{
$error = $db->sql_error();
echo "\n".$error['message']."\n\n";
echo "@";
}else{
echo "*";
}
sleep(0.5);
unset($insert_data);
}
}
flush();
unset($field_list, $insert_rows, $data, $fields);
}
?>