Work on import routines.
@@ -59,20 +59,24 @@ $import_class_comment = array(); // Descriptive comment
|
|||||||
$import_class_support = array(); // Array of data types supported
|
$import_class_support = array(); // Array of data types supported
|
||||||
|
|
||||||
// Definitions of available areas to import
|
// Definitions of available areas to import
|
||||||
$db_import_blocks = array('users' => array('message' => LAN_CONVERT_25, 'classfile' => 'import_user_class.php', 'classname' => 'user_import'),
|
$db_import_blocks = array(
|
||||||
'news' => array('message' => LAN_CONVERT_28),
|
'users' => array('message' => LAN_CONVERT_25, 'classfile' => 'import_user_class.php', 'classname' => 'user_import'),
|
||||||
'forumdefs' => array('message' => LAN_CONVERT_26),
|
'news' => array('message' => LAN_CONVERT_28, 'classfile' => 'import_news_class.php', 'classname' => 'news_import'),
|
||||||
'forumposts' => array('message' => LAN_CONVERT_48),
|
'page' => array('message' => "Pages", 'classfile' => 'import_page_class.php', 'classname' => 'page_import'),
|
||||||
'polls' => array('message' => LAN_CONVERT_27)
|
'links' => array('message' => "Links", 'classfile' => 'import_links_class.php', 'classname' => 'links_import'),
|
||||||
|
'media' => array('message' => "Media", 'classfile' => 'import_media_class.php', 'classname' => 'media_import'),
|
||||||
);
|
'comments' => array('message'=> "Comments"),
|
||||||
|
// 'forumdefs' => array('message' => LAN_CONVERT_26),
|
||||||
|
// 'forumposts' => array('message' => LAN_CONVERT_48),
|
||||||
|
// 'polls' => array('message' => LAN_CONVERT_27)
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
// See what DB-based imports are available (don't really want it here, but gets it into the header script)
|
// See what DB-based imports are available (don't really want it here, but gets it into the header script)
|
||||||
require_once(e_HANDLER.'file_class.php');
|
require_once(e_HANDLER.'file_class.php');
|
||||||
|
|
||||||
$fl = new e_file;
|
$fl = new e_file;
|
||||||
$importClassList = $fl->get_files(e_PLUGIN.'import', "^.+?_import_class\.php$", "standard", 1);
|
$importClassList = $fl->get_files(e_PLUGIN.'import/providers', "^.+?_import_class\.php$", "standard", 1);
|
||||||
foreach($importClassList as $file)
|
foreach($importClassList as $file)
|
||||||
{
|
{
|
||||||
$tag = str_replace('_class.php','',$file['fname']);
|
$tag = str_replace('_class.php','',$file['fname']);
|
||||||
@@ -98,6 +102,7 @@ if(varset($_POST['import_source']))
|
|||||||
|
|
||||||
$current_db_type = varset($_POST['db_import_type'],key($import_class_names));
|
$current_db_type = varset($_POST['db_import_type'],key($import_class_names));
|
||||||
}
|
}
|
||||||
|
|
||||||
$db_blocks_to_import = array();
|
$db_blocks_to_import = array();
|
||||||
|
|
||||||
|
|
||||||
@@ -169,13 +174,17 @@ $msg = '';
|
|||||||
if(isset($_POST['do_conversion']))
|
if(isset($_POST['do_conversion']))
|
||||||
{
|
{
|
||||||
$abandon = TRUE;
|
$abandon = TRUE;
|
||||||
|
|
||||||
switch ($import_source)
|
switch ($import_source)
|
||||||
{
|
{
|
||||||
case 'csv' :
|
case 'csv' :
|
||||||
if (!isset($csv_formats[$current_csv])) $msg = "CSV File format error<br /><br />";
|
if (!isset($csv_formats[$current_csv])) $msg = "CSV File format error<br /><br />";
|
||||||
if (!is_readable($csv_data_file)) $msg = LAN_CONVERT_31;
|
if (!is_readable($csv_data_file)) $msg = LAN_CONVERT_31;
|
||||||
if (!isset($csv_options[$current_csv])) $msg = LAN_CONVERT_37.' '.$current_csv;
|
if (!isset($csv_options[$current_csv])) $msg = LAN_CONVERT_37.' '.$current_csv;
|
||||||
if (!isset($csv_option_settings[$csv_options[$current_csv]])) $msg = LAN_CONVERT_37.' '.$csv_options[$current_csv];
|
if (!isset($csv_option_settings[$csv_options[$current_csv]]))
|
||||||
|
{
|
||||||
|
$msg = LAN_CONVERT_37.' '.$csv_options[$current_csv];
|
||||||
|
}
|
||||||
|
|
||||||
if (!$msg)
|
if (!$msg)
|
||||||
{
|
{
|
||||||
@@ -233,6 +242,7 @@ if(isset($_POST['do_conversion']))
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($msg) $msg .= "<br />";
|
if ($msg) $msg .= "<br />";
|
||||||
if ($import_delete_existing_data) $msg .= LAN_CONVERT_40.'<br />';
|
if ($import_delete_existing_data) $msg .= LAN_CONVERT_40.'<br />';
|
||||||
$msg .= str_replace(array('--LINES--','--USERS--', '--ERRORS--'),array($line_counter,$write_counter,$error_counter),LAN_CONVERT_35);
|
$msg .= str_replace(array('--LINES--','--USERS--', '--ERRORS--'),array($line_counter,$write_counter,$error_counter),LAN_CONVERT_35);
|
||||||
@@ -240,93 +250,17 @@ if(isset($_POST['do_conversion']))
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'db' :
|
case 'db' :
|
||||||
|
if(dbImport() == false)
|
||||||
if (IMPORT_DEBUG) echo "Importing: {$current_db_type}<br />";
|
|
||||||
if (!isset($_POST['dbParamHost']) || !isset($_POST['dbParamUsername']) || !isset($_POST['dbParamPassword']) || !isset($_POST['dbParamDatabase']))
|
|
||||||
{
|
{
|
||||||
$msg = LAN_CONVERT_41;
|
$abandon = true;
|
||||||
}
|
};
|
||||||
if (!$msg)
|
|
||||||
{
|
|
||||||
if (class_exists($current_db_type))
|
|
||||||
{
|
|
||||||
$converter = new $current_db_type;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$msg = LAN_CONVERT_42;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!$msg)
|
|
||||||
{
|
|
||||||
|
|
||||||
$result = $converter->db_Connect($_POST['dbParamHost'], $_POST['dbParamUsername'], $_POST['dbParamPassword'], $_POST['dbParamDatabase'], $_POST['dbParamPrefix']);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if ($result !== TRUE)
|
|
||||||
{
|
|
||||||
$msg = LAN_CONVERT_43.": ".$result; // db connect failed
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!$msg)
|
|
||||||
{
|
|
||||||
foreach ($db_import_blocks as $k => $v)
|
|
||||||
{
|
|
||||||
if (isset($db_blocks_to_import[$k]))
|
|
||||||
{
|
|
||||||
$loopCounter = 0;
|
|
||||||
$errorCounter = 0;
|
|
||||||
if (is_readable($v['classfile']))
|
|
||||||
{
|
|
||||||
require_once($v['classfile']);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$msg = LAN_CONVERT_45.': '.$v['classfile']; // can't read class file.
|
|
||||||
}
|
|
||||||
if (!$msg && (varset($_POST["import_block_{$k}"],0) == 1))
|
|
||||||
{
|
|
||||||
if (IMPORT_DEBUG) echo "Importing: {$k}<br />";
|
|
||||||
$result = $converter->setupQuery($k,!$import_delete_existing_data);
|
|
||||||
if ($result !== TRUE)
|
|
||||||
{
|
|
||||||
$msg = LAN_CONVERT_44.' '.$k;
|
|
||||||
// $msg .= "Prefix = ".$converter->DBPrefix;
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
$exporter = new $v['classname']; // Writes the output data
|
case 'rss' :
|
||||||
// Do any type-specific default setting
|
if(rssImport() == false)
|
||||||
switch ($k)
|
|
||||||
{
|
{
|
||||||
case 'users' :
|
$abandon = true;
|
||||||
$exporter->overrideDefault('user_class',$checked_class_list);
|
};
|
||||||
break;
|
|
||||||
}
|
|
||||||
if ($import_delete_existing_data) $exporter->emptyTargetDB(); // Clean output DB - reasonably safe now
|
|
||||||
while ($row = $converter->getNext($exporter->getDefaults()))
|
|
||||||
{
|
|
||||||
$loopCounter++;
|
|
||||||
$result = $exporter->saveData($row);
|
|
||||||
if ($result !== TRUE)
|
|
||||||
{
|
|
||||||
$errorCounter++;
|
|
||||||
$line_error = $exporter->getErrorText($result);
|
|
||||||
if ($msg) $msg .= "<br />";
|
|
||||||
$msg .= str_replace(array('--ERRNUM--','--DB--'),array($line_error,$k),LAN_CONVERT_46).$loopCounter;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$converter->endQuery;
|
|
||||||
unset($exporter);
|
|
||||||
if ($msg) $msg .= "<br />";
|
|
||||||
$msg .= str_replace(array('--LINES--','--USERS--', '--ERRORS--','--BLOCK--'),
|
|
||||||
array($loopCounter,$loopCounter-$errorCounter,$errorCounter, $k),LAN_CONVERT_47);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// $msg = LAN_CONVERT_29;
|
|
||||||
$abandon = FALSE;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -338,7 +272,7 @@ if(isset($_POST['do_conversion']))
|
|||||||
|
|
||||||
if ($abandon)
|
if ($abandon)
|
||||||
{
|
{
|
||||||
// unset($_POST['do_conversion']);
|
// unset($_POST['do_conversion']);
|
||||||
$text = "
|
$text = "
|
||||||
<form method='post' action='".e_SELF."'>
|
<form method='post' action='".e_SELF."'>
|
||||||
<table style='width: 98%;' class='fborder'>
|
<table style='width: 98%;' class='fborder'>
|
||||||
@@ -347,13 +281,136 @@ if(isset($_POST['do_conversion']))
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table></form>";
|
</table></form>";
|
||||||
$ns -> tablerender(LAN_CONVERT_30, $text);
|
$ns -> tablerender(LAN_CONVERT_30,$emessage->render(). $text);
|
||||||
require_once(e_ADMIN."footer.php");
|
require_once(e_ADMIN."footer.php");
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function rssImport()
|
||||||
|
{
|
||||||
|
global $current_db_type, $db_import_blocks, $import_delete_existing_data,$db_blocks_to_import;
|
||||||
|
|
||||||
|
$mes = e107::getMessage();
|
||||||
|
$mes->addDebug("Loading: RSS");
|
||||||
|
$mes->addWarning("Under Construction");
|
||||||
|
return dbImport('xml');
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function dbImport($mode='db')
|
||||||
|
{
|
||||||
|
global $current_db_type, $db_import_blocks, $import_delete_existing_data,$db_blocks_to_import;
|
||||||
|
|
||||||
|
$mes = e107::getMessage();
|
||||||
|
|
||||||
|
// if (IMPORT_DEBUG) echo "Importing: {$current_db_type}<br />";
|
||||||
|
$mes->addDebug("Loading: ".$current_db_type);
|
||||||
|
|
||||||
|
if (class_exists($current_db_type))
|
||||||
|
{
|
||||||
|
$mes->addDebug("Class Available: ".$current_db_type);
|
||||||
|
$converter = new $current_db_type;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$mes->addError(LAN_CONVERT_42);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if($mode == 'db') // Don't do DB check on RSS/XML
|
||||||
|
{
|
||||||
|
if (!isset($_POST['dbParamHost']) || !isset($_POST['dbParamUsername']) || !isset($_POST['dbParamPassword']) || !isset($_POST['dbParamDatabase']))
|
||||||
|
{
|
||||||
|
$mes->addError(LAN_CONVERT_41);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$result = $converter->db_Connect($_POST['dbParamHost'], $_POST['dbParamUsername'], $_POST['dbParamPassword'], $_POST['dbParamDatabase'], $_POST['dbParamPrefix']);
|
||||||
|
if ($result !== TRUE)
|
||||||
|
{
|
||||||
|
$mes->addError(LAN_CONVERT_43.": ".$result); // db connect failed
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
foreach ($db_import_blocks as $k => $v)
|
||||||
|
{
|
||||||
|
if (isset($db_blocks_to_import[$k]))
|
||||||
|
{
|
||||||
|
$loopCounter = 0;
|
||||||
|
$errorCounter = 0;
|
||||||
|
|
||||||
|
if (is_readable($v['classfile']))
|
||||||
|
{
|
||||||
|
require_once($v['classfile']);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$mes->addError(LAN_CONVERT_45.': '.$v['classfile']); // can't read class file.
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (varset($_POST["import_block_{$k}"],0) == 1)
|
||||||
|
{
|
||||||
|
//if (IMPORT_DEBUG) echo "Importing: {$k}<br />";
|
||||||
|
$mes->addDebug("Importing: ".$k);
|
||||||
|
|
||||||
|
$result = $converter->setupQuery($k,!$import_delete_existing_data);
|
||||||
|
|
||||||
|
if ($result !== TRUE)
|
||||||
|
{
|
||||||
|
$mes->addError(LAN_CONVERT_44.' '.$k); // couldn't set query
|
||||||
|
// $msg .= "Prefix = ".$converter->DBPrefix;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
$exporter = new $v['classname']; // Writes the output data
|
||||||
|
|
||||||
|
switch ($k) // Do any type-specific default setting
|
||||||
|
{
|
||||||
|
case 'users' :
|
||||||
|
$exporter->overrideDefault('user_class',$checked_class_list);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($import_delete_existing_data)
|
||||||
|
{
|
||||||
|
$exporter->emptyTargetDB(); // Clean output DB - reasonably safe now
|
||||||
|
}
|
||||||
|
|
||||||
|
while ($row = $converter->getNext($exporter->getDefaults(),$mode))
|
||||||
|
{
|
||||||
|
$loopCounter++;
|
||||||
|
$result = $exporter->saveData($row);
|
||||||
|
if ($result !== TRUE)
|
||||||
|
{
|
||||||
|
$errorCounter++;
|
||||||
|
$line_error = $exporter->getErrorText($result);
|
||||||
|
// if ($msg) $msg .= "<br />";
|
||||||
|
$msg = str_replace(array('--ERRNUM--','--DB--'),array($line_error,$k),LAN_CONVERT_46).$loopCounter;
|
||||||
|
$mes->addError($msg); // couldn't set query
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$converter->endQuery();
|
||||||
|
|
||||||
|
unset($exporter);
|
||||||
|
|
||||||
|
|
||||||
|
$msg = str_replace(array('--LINES--','--USERS--', '--ERRORS--','--BLOCK--'),
|
||||||
|
array($loopCounter,$loopCounter-$errorCounter,$errorCounter, $k),LAN_CONVERT_47);
|
||||||
|
$mes->addSuccess($msg); // couldn't set query
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// $msg = LAN_CONVERT_29;
|
||||||
|
return true;
|
||||||
|
// $abandon = FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
//======================================================
|
//======================================================
|
||||||
// Display front page
|
// Display front page
|
||||||
@@ -411,19 +468,25 @@ function showStartPage()
|
|||||||
<tbody>
|
<tbody>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td>CSV</td>
|
<td><img src='".e_PLUGIN."import/images/csv.png' alt='' style='float:left;height:32px;width:32px;margin-right:4px'>CSV</td>
|
||||||
<td class='center'>".ADMIN_TRUE_ICON."</td>
|
<td class='center'>".ADMIN_TRUE_ICON."</td>";
|
||||||
<td> </td>
|
|
||||||
<td> </td>
|
for ($i=0; $i < count($db_import_blocks)-1; $i++)
|
||||||
<td> </td>
|
{
|
||||||
<td> </td>
|
$text .= "<td> </td>";
|
||||||
<td class='center middle'>".$frm->radio('import_type', 'csv')."</td></tr>";
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$text .= "<td class='center middle'>".$frm->radio('import_type', 'csv')."</td></tr>";
|
||||||
|
|
||||||
|
|
||||||
foreach ($import_class_names as $k => $title)
|
foreach ($import_class_names as $k => $title)
|
||||||
{
|
{
|
||||||
|
$iconFile = e_PLUGIN."import/images/".str_replace("_import","",strtolower($k)).".png";
|
||||||
|
$icon = (file_exists($iconFile)) ? "<img src='{$iconFile}' alt='' style='float:left;height:32px;width:32px;margin-right:4px'>" : "";
|
||||||
|
|
||||||
$text .= "<!-- $title -->
|
$text .= "<!-- $title -->
|
||||||
<tr><td>".$title."<div class='smalltext'>".$import_class_comment[$k]."</div></td>\n";
|
<tr><td>".$icon.$title."<div class='smalltext'>".$import_class_comment[$k]."</div></td>\n";
|
||||||
|
|
||||||
foreach($db_import_blocks as $key=>$val)
|
foreach($db_import_blocks as $key=>$val)
|
||||||
{
|
{
|
||||||
@@ -500,6 +563,15 @@ function showImportOptions($mode='csv')
|
|||||||
";
|
";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
elseif($mode == 'rss_import')
|
||||||
|
{
|
||||||
|
$text .= "<tr>
|
||||||
|
<td>Feed URL</td>
|
||||||
|
<td><input class='tbox' type='text' name='rss_feed' size='80' value='{$_POST['rss_feed']}' maxlength='250' />
|
||||||
|
<input type='hidden' name='import_source' value='rss' />
|
||||||
|
</td>
|
||||||
|
</tr>";
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$importType = $import_class_names[$mode];
|
$importType = $import_class_names[$mode];
|
||||||
@@ -526,7 +598,13 @@ function showImportOptions($mode='csv')
|
|||||||
<td ><input class='tbox' type='text' name='dbParamPrefix' size='30' value='".(varset($_POST['dbParamPrefix']) ? $_POST['dbParamPrefix'] : $import_default_prefix[$mode])."' maxlength='100' />
|
<td ><input class='tbox' type='text' name='dbParamPrefix' size='30' value='".(varset($_POST['dbParamPrefix']) ? $_POST['dbParamPrefix'] : $import_default_prefix[$mode])."' maxlength='100' />
|
||||||
<input type='hidden' name='import_source' value='db' />
|
<input type='hidden' name='import_source' value='db' />
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if($mode != 'csv')
|
||||||
|
{
|
||||||
|
$text .= "
|
||||||
<tr>
|
<tr>
|
||||||
<td >$importType ".LAN_CONVERT_24."</td>
|
<td >$importType ".LAN_CONVERT_24."</td>
|
||||||
<td >";
|
<td >";
|
||||||
@@ -543,6 +621,7 @@ function showImportOptions($mode='csv')
|
|||||||
$text .= "</td></tr>";
|
$text .= "</td></tr>";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$text .= "<tr><td>".LAN_CONVERT_38."</td>
|
$text .= "<tr><td>".LAN_CONVERT_38."</td>
|
||||||
<td><input type='checkbox' name='import_delete_existing_data' value='1'".($import_delete_existing_data ? " checked='checked'" : '')."/>
|
<td><input type='checkbox' name='import_delete_existing_data' value='1'".($import_delete_existing_data ? " checked='checked'" : '')."/>
|
||||||
<span class='smallblacktext'>".LAN_CONVERT_39."</span></td>
|
<span class='smallblacktext'>".LAN_CONVERT_39."</span></td>
|
||||||
|
BIN
e107_plugins/import/images/coppermine.png
Normal file
After Width: | Height: | Size: 1.8 KiB |
BIN
e107_plugins/import/images/drupal.png
Normal file
After Width: | Height: | Size: 1.7 KiB |
BIN
e107_plugins/import/images/e107.png
Normal file
After Width: | Height: | Size: 2.8 KiB |
BIN
e107_plugins/import/images/ikonboard.png
Normal file
After Width: | Height: | Size: 1.5 KiB |
BIN
e107_plugins/import/images/joomla.png
Normal file
After Width: | Height: | Size: 2.2 KiB |
BIN
e107_plugins/import/images/mambo.png
Normal file
After Width: | Height: | Size: 2.9 KiB |
BIN
e107_plugins/import/images/phpbb2.png
Normal file
After Width: | Height: | Size: 2.1 KiB |
BIN
e107_plugins/import/images/phpnuke.png
Normal file
After Width: | Height: | Size: 2.5 KiB |
BIN
e107_plugins/import/images/smf.png
Normal file
After Width: | Height: | Size: 1.5 KiB |
BIN
e107_plugins/import/images/wordpress.png
Normal file
After Width: | Height: | Size: 2.7 KiB |
@@ -24,9 +24,11 @@ class base_import_class
|
|||||||
var $DBPrefix = '';
|
var $DBPrefix = '';
|
||||||
var $currentTask = '';
|
var $currentTask = '';
|
||||||
var $copyUserInfo = TRUE;
|
var $copyUserInfo = TRUE;
|
||||||
|
var $arrayData = array();
|
||||||
|
|
||||||
|
/**
|
||||||
// Connect to the external DB if not already connected
|
* Connect to the external DB if not already connected
|
||||||
|
*/
|
||||||
function db_Connect($server, $user, $password, $database, $prefix)
|
function db_Connect($server, $user, $password, $database, $prefix)
|
||||||
{
|
{
|
||||||
if ($this->ourDB == NULL)
|
if ($this->ourDB == NULL)
|
||||||
@@ -39,12 +41,14 @@ class base_import_class
|
|||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
// Set up a query for the specified task. If $blank_user is TRUE, user ID Data in source data is ignored
|
* Set up a query for the specified task. If $blank_user is TRUE, user ID Data in source data is ignored
|
||||||
// Returns TRUE on success. FALSE on error
|
* @return boolean TRUE on success. FALSE on error
|
||||||
|
*/
|
||||||
function setupQuery($task, $blank_user=FALSE)
|
function setupQuery($task, $blank_user=FALSE)
|
||||||
{
|
{
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@@ -58,17 +62,35 @@ class base_import_class
|
|||||||
case 'users' :
|
case 'users' :
|
||||||
return $this->saveUserData($dataRecord);
|
return $this->saveUserData($dataRecord);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'news' :
|
||||||
|
return $this->saveNewsData($dataRecord);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'page' :
|
||||||
|
return $this->savePageData($dataRecord);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'links' :
|
||||||
|
return $this->saveLinksData($dataRecord);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'media' :
|
||||||
|
return $this->saveMediaData($dataRecord);
|
||||||
|
break;
|
||||||
|
|
||||||
case 'forumdefs' :
|
case 'forumdefs' :
|
||||||
return $this->saveForumData($dataRecord);
|
return $this->saveForumData($dataRecord);
|
||||||
return FALSE;
|
break;
|
||||||
|
|
||||||
case 'forumposts' :
|
case 'forumposts' :
|
||||||
return $this->savePostData($dataRecord);
|
return $this->savePostData($dataRecord);
|
||||||
return FALSE;
|
break;
|
||||||
|
|
||||||
case 'polls' :
|
case 'polls' :
|
||||||
return FALSE;
|
break;
|
||||||
case 'news' :
|
|
||||||
return FALSE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -76,24 +98,54 @@ class base_import_class
|
|||||||
// Return the next record as an array. All data has been converted to the appropriate E107 formats
|
// Return the next record as an array. All data has been converted to the appropriate E107 formats
|
||||||
// Return FALSE if no more data
|
// Return FALSE if no more data
|
||||||
// Its passed a record initialised with the default values
|
// Its passed a record initialised with the default values
|
||||||
function getNext($initial)
|
function getNext($initial,$mode='db')
|
||||||
|
{
|
||||||
|
if($mode == 'db')
|
||||||
{
|
{
|
||||||
$result = $this->ourDB->db_Fetch();
|
$result = $this->ourDB->db_Fetch();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$result = current($this->arrayData);
|
||||||
|
next($this->arrayData);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!$result) return FALSE;
|
if (!$result) return FALSE;
|
||||||
switch($this->currentTask)
|
switch($this->currentTask)
|
||||||
{
|
{
|
||||||
case 'users' :
|
case 'users' :
|
||||||
return $this->copyUserData($initial, $result);
|
return $this->copyUserData($initial, $result);
|
||||||
break;
|
break;
|
||||||
case 'forumdefs' :
|
|
||||||
return FALSE;
|
|
||||||
case 'forumposts' :
|
|
||||||
return FALSE;
|
|
||||||
case 'polls' :
|
|
||||||
return FALSE;
|
|
||||||
case 'news' :
|
case 'news' :
|
||||||
return FALSE;
|
return $this->copyNewsData($initial, $result);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'page' :
|
||||||
|
return $this->copyPageData($initial, $result);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'links' :
|
||||||
|
return $this->copyLinksData($initial, $result);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'media' :
|
||||||
|
return $this->copyMediaData($initial, $result);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'forumdefs' :
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'forumposts' :
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'polls' :
|
||||||
|
break;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -105,11 +157,32 @@ class base_import_class
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Empty function which descendants can inherit from
|
// Empty functions which descendants can inherit from
|
||||||
|
|
||||||
function copyUserData(&$target, &$source)
|
function copyUserData(&$target, &$source)
|
||||||
{
|
{
|
||||||
return $target;
|
return $target;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function copyNewsData(&$target, &$source)
|
||||||
|
{
|
||||||
|
return $target;
|
||||||
|
}
|
||||||
|
|
||||||
|
function copyPageData(&$target, &$source)
|
||||||
|
{
|
||||||
|
return $target;
|
||||||
|
}
|
||||||
|
|
||||||
|
function copyLinksData(&$target, &$source)
|
||||||
|
{
|
||||||
|
return $target;
|
||||||
|
}
|
||||||
|
|
||||||
|
function copyMediaData(&$target, &$source)
|
||||||
|
{
|
||||||
|
return $target;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -73,5 +73,5 @@ define('LAN_CONVERT_43','Error connecting to source database');
|
|||||||
define('LAN_CONVERT_44','Query setup error for ');
|
define('LAN_CONVERT_44','Query setup error for ');
|
||||||
define('LAN_CONVERT_45','Cannot read import code file');
|
define('LAN_CONVERT_45','Cannot read import code file');
|
||||||
define('LAN_CONVERT_46','Error: --ERRNUM-- while writing to --DB-- database, line ');
|
define('LAN_CONVERT_46','Error: --ERRNUM-- while writing to --DB-- database, line ');
|
||||||
define('LAN_CONVERT_47','Block --BLOCK-- import completed. --LINES-- read, --USERS-- added, --ERRORS-- errors');
|
define('LAN_CONVERT_47','Batch --BLOCK-- import completed. --LINES-- read, --USERS-- added, --ERRORS-- errors');
|
||||||
define('LAN_CONVERT_48','Forum posts');
|
define('LAN_CONVERT_48','Forum posts');
|
||||||
|
83
e107_plugins/import/providers/joomla_import_class.php
Normal file
@@ -0,0 +1,83 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
* e107 website system
|
||||||
|
*
|
||||||
|
* Copyright (C) 2008-2009 e107 Inc (e107.org)
|
||||||
|
* Released under the terms and conditions of the
|
||||||
|
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* $Source: /cvs_backup/e107_0.8/e107_plugins/import/mambo_import_class.php,v $
|
||||||
|
* $Revision: 11315 $
|
||||||
|
* $Date: 2010-02-10 10:18:01 -0800 (Wed, 10 Feb 2010) $
|
||||||
|
* $Author: secretr $
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Each import file has an identifier which must be the same for:
|
||||||
|
// a) This file name - add '_class.php' to get the file name
|
||||||
|
// b) The array index of certain variables
|
||||||
|
// Array element key defines the function prefix and the class name; value is displayed in drop-down selection box
|
||||||
|
$import_class_names['joomla_import'] = 'Joomla';
|
||||||
|
$import_class_comment['joomla_import'] = 'Untested - need feedback from users ';
|
||||||
|
$import_class_support['joomla_import'] = array('users');
|
||||||
|
$import_default_prefix['joomla_import'] = 'jos_';
|
||||||
|
|
||||||
|
// Mambo and joomla have the same DB format apart from the default prefix - 'jos_' for Joomla
|
||||||
|
|
||||||
|
require_once('import_classes.php');
|
||||||
|
|
||||||
|
class joomla_import extends base_import_class
|
||||||
|
{
|
||||||
|
// Set up a query for the specified task.
|
||||||
|
// Returns TRUE on success. FALSE on error
|
||||||
|
function setupQuery($task, $blank_user=FALSE)
|
||||||
|
{
|
||||||
|
if ($this->ourDB == NULL) return FALSE;
|
||||||
|
switch ($task)
|
||||||
|
{
|
||||||
|
case 'users' :
|
||||||
|
$result = $this->ourDB->db_Select_gen("SELECT * FROM {$this->DBPrefix}users");
|
||||||
|
if ($result === FALSE) return FALSE;
|
||||||
|
break;
|
||||||
|
default :
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
$this->copyUserInfo = !$blank_user;
|
||||||
|
$this->currentTask = $task;
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//------------------------------------
|
||||||
|
// Internal functions below here
|
||||||
|
//------------------------------------
|
||||||
|
|
||||||
|
// Copy data read from the DB into the record to be returned.
|
||||||
|
function copyUserData(&$target, &$source)
|
||||||
|
{
|
||||||
|
if ($this->copyUserInfo) $target['user_id'] = $source['id'];
|
||||||
|
$target['user_name'] = $source['name'];
|
||||||
|
$target['user_loginname'] = $source['username'];
|
||||||
|
$target['user_password'] = $source['password'];
|
||||||
|
$target['user_email'] = $source['email'];
|
||||||
|
// $target['user_hideemail'] = $source['user_viewemail'];
|
||||||
|
$target['user_join'] = $source['registerDate'];
|
||||||
|
$target['user_admin'] = ($source['usertype'] == 'superadministrator') ? 1 : 0;
|
||||||
|
|
||||||
|
if ($target['user_admin'] != 0)
|
||||||
|
{
|
||||||
|
$target['user_perms'] = '0.';
|
||||||
|
}
|
||||||
|
|
||||||
|
$target['user_lastvisit'] = $source['lastvisitDate'];
|
||||||
|
$target['user_login'] = $source['name'];
|
||||||
|
$target['user_ban'] = ($source['block'] ? 2 : 0);
|
||||||
|
|
||||||
|
return $target;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
?>
|
294
e107_plugins/import/providers/rss_import_class.php
Normal file
@@ -0,0 +1,294 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
* e107 website system
|
||||||
|
*
|
||||||
|
* Copyright (C) 2008-2009 e107 Inc (e107.org)
|
||||||
|
* Released under the terms and conditions of the
|
||||||
|
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* $Source: /cvs_backup/e107_0.8/e107_plugins/import/wordpress_import_class.php,v $
|
||||||
|
* $Revision: 11315 $
|
||||||
|
* $Date: 2010-02-10 10:18:01 -0800 (Wed, 10 Feb 2010) $
|
||||||
|
* $Author: secretr $
|
||||||
|
*/
|
||||||
|
|
||||||
|
// This must be an incredibly pointless file! But it does allow testing of the basic plugin structure.
|
||||||
|
|
||||||
|
// Each import file has an identifier which must be the same for:
|
||||||
|
// a) This file name - add '_class.php' to get the file name
|
||||||
|
// b) The array index of certain variables
|
||||||
|
// Array element key defines the function prefix and the class name; value is displayed in drop-down selection box
|
||||||
|
|
||||||
|
$import_class_names['rss_import'] = 'RSS';
|
||||||
|
$import_class_comment['rss_import'] = '(work in progress)';
|
||||||
|
$import_class_support['rss_import'] = array('news','page','links');
|
||||||
|
$import_default_prefix['rss_import'] = '';
|
||||||
|
|
||||||
|
require_once('import_classes.php');
|
||||||
|
|
||||||
|
class rss_import extends base_import_class
|
||||||
|
{
|
||||||
|
// Set up a query for the specified task.
|
||||||
|
// Returns TRUE on success. FALSE on error
|
||||||
|
function setupQuery($task, $blank_user=FALSE)
|
||||||
|
{
|
||||||
|
|
||||||
|
$xml = e107::getXml();
|
||||||
|
require_once(e_HANDLER."magpie_rss.php");
|
||||||
|
|
||||||
|
// $file = "http://www.e107.org/releases.php"; //pluginfeed.php or similar.
|
||||||
|
// $file = "http://localhost:8080/e107_0.8/e107_plugins/release/release.php"; // temporary testing
|
||||||
|
$file = "http://raelianews.org/rss";
|
||||||
|
|
||||||
|
$xml->setOptArrayTags('plugin'); // make sure 'plugin' tag always returns an array
|
||||||
|
|
||||||
|
|
||||||
|
switch ($task)
|
||||||
|
{
|
||||||
|
case 'users' :
|
||||||
|
//$query = "SELECT * FROM {$this->DBPrefix}users WHERE `user_id` != 1";
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'news' :
|
||||||
|
// $result = $xml->loadXMLfile($file,true);
|
||||||
|
// $rawData = $xml->getRemoteFile($file);
|
||||||
|
// $rss = new MagpieRSS( $rawData );
|
||||||
|
// $array = $xml->xml2array($rss);
|
||||||
|
|
||||||
|
$xml->setOptArrayTags('item'); // make sure 'plugin' tag always returns an array
|
||||||
|
$array = $xml->loadXMLfile($file,'advanced');
|
||||||
|
$this->arrayData = $array['channel']['item'];
|
||||||
|
|
||||||
|
if ($result === FALSE) return FALSE;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'page' :
|
||||||
|
|
||||||
|
if ($result === FALSE) return FALSE;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'media' :
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'links':
|
||||||
|
|
||||||
|
if ($result === FALSE) return FALSE;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default :
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->copyUserInfo = !$blank_user;
|
||||||
|
$this->currentTask = $task;
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//------------------------------------
|
||||||
|
// Internal functions below here
|
||||||
|
//------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Align source data to e107 User Table
|
||||||
|
* @param $target array - default e107 target values for e107_user table.
|
||||||
|
* @param $source array - WordPress table data
|
||||||
|
*/
|
||||||
|
function copyUserData(&$target, &$source)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Align source data to e107 News Table
|
||||||
|
* @param $target array - default e107 target values for e107_news table.
|
||||||
|
* @param $source array - WordPress table data
|
||||||
|
*/
|
||||||
|
function copyNewsData(&$target, &$source)
|
||||||
|
{
|
||||||
|
/* Example:
|
||||||
|
[ID] => 88
|
||||||
|
[post_author] => 1
|
||||||
|
[post_date] => 2012-01-25 04:11:22
|
||||||
|
[post_date_gmt] => 2012-01-25 09:11:22
|
||||||
|
[post_content] => [gallery itemtag="div" icontag="span" captiontag="p" link="file"]
|
||||||
|
[post_title] => Media Gallery
|
||||||
|
[post_excerpt] =>
|
||||||
|
[post_status] => inherit
|
||||||
|
[comment_status] => open
|
||||||
|
[ping_status] => open
|
||||||
|
[post_password] =>
|
||||||
|
[post_name] => 10-revision-6
|
||||||
|
[to_ping] =>
|
||||||
|
[pinged] =>
|
||||||
|
[post_modified] => 2012-01-25 04:11:22
|
||||||
|
[post_modified_gmt] => 2012-01-25 09:11:22
|
||||||
|
[post_content_filtered] =>
|
||||||
|
[post_parent] => 10
|
||||||
|
[guid] => http://siteurl.com/2012/01/25/10-revision-6/
|
||||||
|
[menu_order] => 0
|
||||||
|
[post_type] => post
|
||||||
|
[post_mime_type] =>
|
||||||
|
[comment_count] => 0
|
||||||
|
*/
|
||||||
|
|
||||||
|
// $target['news_id'] = $source['ID'];
|
||||||
|
$target['news_title'] = $source['post_title'];
|
||||||
|
$target['news_sef'] = $source['post_name'];
|
||||||
|
$target['news_body'] = $source['post_content'];
|
||||||
|
// $target['news_extended'] = '';
|
||||||
|
// $target['news_meta_keywords'] = '';
|
||||||
|
// $target['news_meta_description'] = '';
|
||||||
|
$target['news_datestamp'] = strtotime($source['post_date']);
|
||||||
|
$target['news_author'] = $source['post_author'];
|
||||||
|
// $target['news_category'] = '';
|
||||||
|
$target['news_allow_comments'] = ($source['comment_status']=='open') ? 1 : 0;
|
||||||
|
$target['news_start'] = '';
|
||||||
|
$target['news_end'] = '';
|
||||||
|
$target['news_class'] = '';
|
||||||
|
$target['news_render_type'] = '';
|
||||||
|
$target['news_comment_total'] = $source['comment_count'];
|
||||||
|
$target['news_summary'] = $source['post_excerpt'];
|
||||||
|
$target['news_thumbnail'] = '';
|
||||||
|
$target['news_sticky'] = '';
|
||||||
|
|
||||||
|
// return $target; // comment out to debug
|
||||||
|
|
||||||
|
// DEBUG INFO BELOW.
|
||||||
|
$this->renderDebug($source,$target);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Align source data to e107 Page Table
|
||||||
|
* @param $target array - default e107 target values for e107_page table.
|
||||||
|
* @param $source array - WordPress table data
|
||||||
|
*/
|
||||||
|
function copyPageData(&$target, &$source)
|
||||||
|
{
|
||||||
|
$tp = e107::getParser();
|
||||||
|
/* post_status:
|
||||||
|
publish - A published post or page
|
||||||
|
inherit - a revision
|
||||||
|
pending - post is pending review
|
||||||
|
private - a private post
|
||||||
|
future - a post to publish in the future
|
||||||
|
draft - a post in draft status
|
||||||
|
trash - post is in trashbin (available with 2.9)
|
||||||
|
*/
|
||||||
|
|
||||||
|
if($source['post_status']=='private' || $source['post_status']=='future' || $source['post_status'] == 'draft')
|
||||||
|
{
|
||||||
|
$target['page_class'] = e_UC_ADMIN;
|
||||||
|
}
|
||||||
|
|
||||||
|
// $target['page_id'] = $source['ID']; // auto increment
|
||||||
|
$target['page_title'] = $source['post_title'];
|
||||||
|
$target['page_sef'] = $source['post_name'];
|
||||||
|
$target['page_text'] = "[html]".$source['post_content']."[/html]";
|
||||||
|
$target['page_metakeys'] = '';
|
||||||
|
$target['page_metadscr'] = '';
|
||||||
|
$target['page_datestamp'] = strtotime($source['post_date']);
|
||||||
|
$target['page_author'] = $source['post_author'];
|
||||||
|
// $target['page_category'] = '',
|
||||||
|
$target['page_comment_flag'] = ($source['comment_status']=='open') ? 1 : 0;
|
||||||
|
$target['page_password'] = $source['post_password'];
|
||||||
|
|
||||||
|
return $target; // comment out to debug
|
||||||
|
|
||||||
|
// DEBUG INFO BELOW.
|
||||||
|
$this->renderDebug($source,$target);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Align source data to e107 Links Table
|
||||||
|
* @param $target array - default e107 target values for e107_links table.
|
||||||
|
* @param $source array - WordPress table data
|
||||||
|
*/
|
||||||
|
function copyLinksData(&$target, &$source)
|
||||||
|
{
|
||||||
|
$tp = e107::getParser();
|
||||||
|
/* WP
|
||||||
|
link_id
|
||||||
|
link_url
|
||||||
|
link_name
|
||||||
|
link_image
|
||||||
|
link_target
|
||||||
|
link_description
|
||||||
|
link_visible
|
||||||
|
link_owner
|
||||||
|
link_rating
|
||||||
|
link_updated
|
||||||
|
link_rel
|
||||||
|
link_notes
|
||||||
|
link_rss
|
||||||
|
*
|
||||||
|
* e107
|
||||||
|
* link_id
|
||||||
|
link_name
|
||||||
|
link_url
|
||||||
|
link_description
|
||||||
|
link_button
|
||||||
|
link_category
|
||||||
|
link_order
|
||||||
|
link_parent
|
||||||
|
link_open
|
||||||
|
link_class
|
||||||
|
link_function
|
||||||
|
link_sefurl
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
// $target['page_id'] = $source['ID']; // auto increment
|
||||||
|
$target['link_name'] = $source['post_title'];
|
||||||
|
$target['link_url'] = $source['post_name'];
|
||||||
|
$target['link_description'] = "[html]".$source['post_content']."[/html]";
|
||||||
|
$target['link_button'] = '';
|
||||||
|
$target['link_category'] = '';
|
||||||
|
$target['link_order'] = strtotime($source['post_date']);
|
||||||
|
$target['link_parent'] = $source['post_author'];
|
||||||
|
$target['link_open'] = '';
|
||||||
|
$target['link_class'] = '';
|
||||||
|
$target['link_sefurl'] = $source['post_password'];
|
||||||
|
|
||||||
|
// return $target; // comment out to debug
|
||||||
|
|
||||||
|
// DEBUG INFO BELOW.
|
||||||
|
$this->renderDebug($source,$target);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function renderDebug($source,$target)
|
||||||
|
{
|
||||||
|
echo "
|
||||||
|
<div style='width:1000px'>
|
||||||
|
<table style='width:100%'>
|
||||||
|
<tr>
|
||||||
|
<td style='width:500px;padding:10px'>".print_a($source,TRUE)."</td>
|
||||||
|
<td style='border-left:1px solid black;padding:10px'>".print_a($target,TRUE)."</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</div>";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
?>
|
354
e107_plugins/import/providers/wordpress_import_class.php
Normal file
@@ -0,0 +1,354 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
* e107 website system
|
||||||
|
*
|
||||||
|
* Copyright (C) 2008-2009 e107 Inc (e107.org)
|
||||||
|
* Released under the terms and conditions of the
|
||||||
|
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* $Source: /cvs_backup/e107_0.8/e107_plugins/import/wordpress_import_class.php,v $
|
||||||
|
* $Revision$
|
||||||
|
* $Date$
|
||||||
|
* $Author$
|
||||||
|
*/
|
||||||
|
|
||||||
|
// This must be an incredibly pointless file! But it does allow testing of the basic plugin structure.
|
||||||
|
|
||||||
|
// Each import file has an identifier which must be the same for:
|
||||||
|
// a) This file name - add '_class.php' to get the file name
|
||||||
|
// b) The array index of certain variables
|
||||||
|
// Array element key defines the function prefix and the class name; value is displayed in drop-down selection box
|
||||||
|
|
||||||
|
$import_class_names['wordpress_import'] = 'Wordpress';
|
||||||
|
$import_class_comment['wordpress_import'] = 'Tested with version 2.8.x (salted passwords)';
|
||||||
|
$import_class_support['wordpress_import'] = array('users','news','page','links');
|
||||||
|
$import_default_prefix['wordpress_import'] = 'wp_';
|
||||||
|
|
||||||
|
require_once('import_classes.php');
|
||||||
|
|
||||||
|
class wordpress_import extends base_import_class
|
||||||
|
{
|
||||||
|
// Set up a query for the specified task.
|
||||||
|
// Returns TRUE on success. FALSE on error
|
||||||
|
function setupQuery($task, $blank_user=FALSE)
|
||||||
|
{
|
||||||
|
if ($this->ourDB == NULL) return FALSE;
|
||||||
|
|
||||||
|
switch ($task)
|
||||||
|
{
|
||||||
|
case 'users' :
|
||||||
|
//$query = "SELECT * FROM {$this->DBPrefix}users WHERE `user_id` != 1";
|
||||||
|
|
||||||
|
$query = "SELECT u.*,
|
||||||
|
w.meta_value AS admin,
|
||||||
|
f.meta_value as firstname,
|
||||||
|
l.meta_value as lastname
|
||||||
|
FROM {$this->DBPrefix}users AS u
|
||||||
|
LEFT JOIN {$this->DBPrefix}usermeta AS w ON (u.ID = w.user_id AND w.meta_key = 'wp_capabilities')
|
||||||
|
LEFT JOIN {$this->DBPrefix}usermeta AS f ON (u.ID = f.user_id AND f.meta_key = 'first_name')
|
||||||
|
LEFT JOIN {$this->DBPrefix}usermeta AS l ON (u.ID = l.user_id AND l.meta_key = 'last_name')
|
||||||
|
GROUP BY u.ID";
|
||||||
|
|
||||||
|
// $this->ourDB -> db_Select_gen($query);
|
||||||
|
|
||||||
|
$result = $this->ourDB->db_Select_gen($query);
|
||||||
|
|
||||||
|
if ($result === FALSE) return FALSE;
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'userclass' :
|
||||||
|
/* For reference: (stored in usermeta -> wp_capabilities
|
||||||
|
* Administrator - Somebody who has access to all the administration features
|
||||||
|
* Editor - Somebody who can publish posts, manage posts as well as manage other people's posts, etc.
|
||||||
|
* Author - Somebody who can publish and manage their own posts
|
||||||
|
* Contributor - Somebody who can write and manage their posts but not publish posts
|
||||||
|
* Subscriber - Somebody who can read comments/comment/receive news letters, etc.
|
||||||
|
*/
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'news' :
|
||||||
|
$query = "SELECT * FROM {$this->DBPrefix}posts WHERE post_type = 'post' AND post_status !='trash' ORDER BY ID";
|
||||||
|
$result = $this->ourDB->db_Select_gen($query);
|
||||||
|
if ($result === FALSE) return FALSE;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'page' :
|
||||||
|
$query = "SELECT * FROM {$this->DBPrefix}posts WHERE post_type = 'page' AND post_status !='trash' ORDER BY ID";
|
||||||
|
$result = $this->ourDB->db_Select_gen($query);
|
||||||
|
if ($result === FALSE) return FALSE;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'media' :
|
||||||
|
$query = "SELECT * FROM {$this->DBPrefix}posts WHERE post_type = 'attachment' AND post_status !='trash' ORDER BY ID";
|
||||||
|
$result = $this->ourDB->db_Select_gen($query);
|
||||||
|
if ($result === FALSE) return FALSE;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'links':
|
||||||
|
$query = "SELECT * FROM {$this->DBPrefix}links WHERE link_id !='' ORDER BY link_id";
|
||||||
|
$result = $this->ourDB->db_Select_gen($query);
|
||||||
|
if ($result === FALSE) return FALSE;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default :
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->copyUserInfo = !$blank_user;
|
||||||
|
$this->currentTask = $task;
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//------------------------------------
|
||||||
|
// Internal functions below here
|
||||||
|
//------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Align source data to e107 User Table
|
||||||
|
* @param $target array - default e107 target values for e107_user table.
|
||||||
|
* @param $source array - WordPress table data
|
||||||
|
*/
|
||||||
|
function copyUserData(&$target, &$source)
|
||||||
|
{
|
||||||
|
$user_meta = unserialize($source['admin']);
|
||||||
|
|
||||||
|
if ($this->copyUserInfo)
|
||||||
|
{
|
||||||
|
$target['user_id'] = $source['ID'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$target['user_name'] = $source['user_nicename'];
|
||||||
|
$target['user_loginname'] = $source['user_login'];
|
||||||
|
$target['user_password'] = $source['user_pass']; // needs to be salted!!!!
|
||||||
|
$target['user_email'] = $source['user_email'];
|
||||||
|
$target['user_hideemail'] = $source['user_hideemail'];
|
||||||
|
$target['user_join'] = strtotime($source['user_registered']);
|
||||||
|
$target['user_admin'] = ($user_meta['administrator'] == 1) ? 1 : 0;
|
||||||
|
$target['user_lastvisit'] = $source['user_lastvisit'];
|
||||||
|
$target['user_login'] = $source['firstname']." ".$source['lastname'];
|
||||||
|
$target['user_ban'] = $source['user_ban'];
|
||||||
|
$target['user_customtitle'] = $source['display_name'];
|
||||||
|
$target['user_sess'] = $source['user_sess']; // Photo
|
||||||
|
$target['user_signature'] = $source['user_signature'];
|
||||||
|
$target['user_image'] = $source['user_image']; // Avatar
|
||||||
|
$target['user_currentvisit'] = $source['user_currentvisit'];
|
||||||
|
$target['user_lastpost'] = $source['user_lastpost'];
|
||||||
|
$target['user_chats'] = $source['user_chats'];
|
||||||
|
$target['user_comments'] = $source['user_comments'];
|
||||||
|
|
||||||
|
$target['user_ip'] = $source['user_ip'];
|
||||||
|
$target['user_prefs'] = $source['user_prefs'];
|
||||||
|
$target['user_visits'] = $source['user_visits'];
|
||||||
|
$target['user_class'] = $source['user_class'];
|
||||||
|
$target['user_perms'] = $source['user_perms'];
|
||||||
|
$target['user_xup'] = $source['user_xup'];
|
||||||
|
$target['user_language'] = $source['user_language'];
|
||||||
|
$target['user_country'] = $source['user_country'];
|
||||||
|
$target['user_location'] = $source['user_location'];
|
||||||
|
$target['user_aim'] = $source['user_aim'];
|
||||||
|
$target['user_icq'] = $source['user_icq'];
|
||||||
|
$target['user_yahoo'] = $source['user_yahoo'];
|
||||||
|
$target['user_msn'] = $source['user_msn'];
|
||||||
|
$target['user_homepage'] = $source['user_url'];
|
||||||
|
$target['user_birthday'] = $source['user_birthday'];
|
||||||
|
$target['user_timezone'] = $source['user_timezone'];
|
||||||
|
|
||||||
|
$this->renderDebug($source,$target);
|
||||||
|
|
||||||
|
//return $target;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Align source data to e107 News Table
|
||||||
|
* @param $target array - default e107 target values for e107_news table.
|
||||||
|
* @param $source array - WordPress table data
|
||||||
|
*/
|
||||||
|
function copyNewsData(&$target, &$source)
|
||||||
|
{
|
||||||
|
/* Example:
|
||||||
|
[ID] => 88
|
||||||
|
[post_author] => 1
|
||||||
|
[post_date] => 2012-01-25 04:11:22
|
||||||
|
[post_date_gmt] => 2012-01-25 09:11:22
|
||||||
|
[post_content] => [gallery itemtag="div" icontag="span" captiontag="p" link="file"]
|
||||||
|
[post_title] => Media Gallery
|
||||||
|
[post_excerpt] =>
|
||||||
|
[post_status] => inherit
|
||||||
|
[comment_status] => open
|
||||||
|
[ping_status] => open
|
||||||
|
[post_password] =>
|
||||||
|
[post_name] => 10-revision-6
|
||||||
|
[to_ping] =>
|
||||||
|
[pinged] =>
|
||||||
|
[post_modified] => 2012-01-25 04:11:22
|
||||||
|
[post_modified_gmt] => 2012-01-25 09:11:22
|
||||||
|
[post_content_filtered] =>
|
||||||
|
[post_parent] => 10
|
||||||
|
[guid] => http://siteurl.com/2012/01/25/10-revision-6/
|
||||||
|
[menu_order] => 0
|
||||||
|
[post_type] => post
|
||||||
|
[post_mime_type] =>
|
||||||
|
[comment_count] => 0
|
||||||
|
*/
|
||||||
|
|
||||||
|
// $target['news_id'] = $source['ID'];
|
||||||
|
$target['news_title'] = $source['post_title'];
|
||||||
|
$target['news_sef'] = $source['post_name'];
|
||||||
|
$target['news_body'] = $source['post_content'];
|
||||||
|
// $target['news_extended'] = '';
|
||||||
|
// $target['news_meta_keywords'] = '';
|
||||||
|
// $target['news_meta_description'] = '';
|
||||||
|
$target['news_datestamp'] = strtotime($source['post_date']);
|
||||||
|
$target['news_author'] = $source['post_author'];
|
||||||
|
// $target['news_category'] = '';
|
||||||
|
$target['news_allow_comments'] = ($source['comment_status']=='open') ? 1 : 0;
|
||||||
|
$target['news_start'] = '';
|
||||||
|
$target['news_end'] = '';
|
||||||
|
$target['news_class'] = '';
|
||||||
|
$target['news_render_type'] = '';
|
||||||
|
$target['news_comment_total'] = $source['comment_count'];
|
||||||
|
$target['news_summary'] = $source['post_excerpt'];
|
||||||
|
$target['news_thumbnail'] = '';
|
||||||
|
$target['news_sticky'] = '';
|
||||||
|
|
||||||
|
return $target; // comment out to debug
|
||||||
|
|
||||||
|
// DEBUG INFO BELOW.
|
||||||
|
$this->renderDebug($source,$target);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Align source data to e107 Page Table
|
||||||
|
* @param $target array - default e107 target values for e107_page table.
|
||||||
|
* @param $source array - WordPress table data
|
||||||
|
*/
|
||||||
|
function copyPageData(&$target, &$source)
|
||||||
|
{
|
||||||
|
$tp = e107::getParser();
|
||||||
|
/* post_status:
|
||||||
|
publish - A published post or page
|
||||||
|
inherit - a revision
|
||||||
|
pending - post is pending review
|
||||||
|
private - a private post
|
||||||
|
future - a post to publish in the future
|
||||||
|
draft - a post in draft status
|
||||||
|
trash - post is in trashbin (available with 2.9)
|
||||||
|
*/
|
||||||
|
|
||||||
|
if($source['post_status']=='private' || $source['post_status']=='future' || $source['post_status'] == 'draft')
|
||||||
|
{
|
||||||
|
$target['page_class'] = e_UC_ADMIN;
|
||||||
|
}
|
||||||
|
|
||||||
|
// $target['page_id'] = $source['ID']; // auto increment
|
||||||
|
$target['page_title'] = $source['post_title'];
|
||||||
|
$target['page_sef'] = $source['post_name'];
|
||||||
|
$target['page_text'] = "[html]".$source['post_content']."[/html]";
|
||||||
|
$target['page_metakeys'] = '';
|
||||||
|
$target['page_metadscr'] = '';
|
||||||
|
$target['page_datestamp'] = strtotime($source['post_date']);
|
||||||
|
$target['page_author'] = $source['post_author'];
|
||||||
|
// $target['page_category'] = '',
|
||||||
|
$target['page_comment_flag'] = ($source['comment_status']=='open') ? 1 : 0;
|
||||||
|
$target['page_password'] = $source['post_password'];
|
||||||
|
|
||||||
|
return $target; // comment out to debug
|
||||||
|
|
||||||
|
// DEBUG INFO BELOW.
|
||||||
|
$this->renderDebug($source,$target);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Align source data to e107 Links Table
|
||||||
|
* @param $target array - default e107 target values for e107_links table.
|
||||||
|
* @param $source array - WordPress table data
|
||||||
|
*/
|
||||||
|
function copyLinksData(&$target, &$source)
|
||||||
|
{
|
||||||
|
$tp = e107::getParser();
|
||||||
|
/* WP
|
||||||
|
link_id
|
||||||
|
link_url
|
||||||
|
link_name
|
||||||
|
link_image
|
||||||
|
link_target
|
||||||
|
link_description
|
||||||
|
link_visible
|
||||||
|
link_owner
|
||||||
|
link_rating
|
||||||
|
link_updated
|
||||||
|
link_rel
|
||||||
|
link_notes
|
||||||
|
link_rss
|
||||||
|
*
|
||||||
|
* e107
|
||||||
|
* link_id
|
||||||
|
link_name
|
||||||
|
link_url
|
||||||
|
link_description
|
||||||
|
link_button
|
||||||
|
link_category
|
||||||
|
link_order
|
||||||
|
link_parent
|
||||||
|
link_open
|
||||||
|
link_class
|
||||||
|
link_function
|
||||||
|
link_sefurl
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
// $target['page_id'] = $source['ID']; // auto increment
|
||||||
|
$target['link_name'] = $source['post_title'];
|
||||||
|
$target['link_url'] = $source['post_name'];
|
||||||
|
$target['link_description'] = "[html]".$source['post_content']."[/html]";
|
||||||
|
$target['link_button'] = '';
|
||||||
|
$target['link_category'] = '';
|
||||||
|
$target['link_order'] = strtotime($source['post_date']);
|
||||||
|
$target['link_parent'] = $source['post_author'];
|
||||||
|
$target['link_open'] = '';
|
||||||
|
$target['link_class'] = '';
|
||||||
|
$target['link_sefurl'] = $source['post_password'];
|
||||||
|
|
||||||
|
// return $target; // comment out to debug
|
||||||
|
|
||||||
|
// DEBUG INFO BELOW.
|
||||||
|
$this->renderDebug($source,$target);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function renderDebug($source,$target)
|
||||||
|
{
|
||||||
|
echo "
|
||||||
|
<div style='width:1000px'>
|
||||||
|
<table style='width:100%'>
|
||||||
|
<tr>
|
||||||
|
<td style='width:500px;padding:10px'>".print_a($source,TRUE)."</td>
|
||||||
|
<td style='border-left:1px solid black;padding:10px'>".print_a($target,TRUE)."</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</div>";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
?>
|
@@ -1,141 +0,0 @@
|
|||||||
<?php
|
|
||||||
/*
|
|
||||||
* e107 website system
|
|
||||||
*
|
|
||||||
* Copyright (C) 2008-2009 e107 Inc (e107.org)
|
|
||||||
* Released under the terms and conditions of the
|
|
||||||
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* $Source: /cvs_backup/e107_0.8/e107_plugins/import/wordpress_import_class.php,v $
|
|
||||||
* $Revision$
|
|
||||||
* $Date$
|
|
||||||
* $Author$
|
|
||||||
*/
|
|
||||||
|
|
||||||
// This must be an incredibly pointless file! But it does allow testing of the basic plugin structure.
|
|
||||||
|
|
||||||
// Each import file has an identifier which must be the same for:
|
|
||||||
// a) This file name - add '_class.php' to get the file name
|
|
||||||
// b) The array index of certain variables
|
|
||||||
// Array element key defines the function prefix and the class name; value is displayed in drop-down selection box
|
|
||||||
$import_class_names['wordpress_import'] = 'Wordpress';
|
|
||||||
$import_class_comment['wordpress_import'] = 'Tested with version 2.8.x (salted passwords)';
|
|
||||||
$import_class_support['wordpress_import'] = array('users');
|
|
||||||
$import_default_prefix['wordpress_import'] = 'wp_';
|
|
||||||
|
|
||||||
|
|
||||||
require_once('import_classes.php');
|
|
||||||
|
|
||||||
class wordpress_import extends base_import_class
|
|
||||||
{
|
|
||||||
// Set up a query for the specified task.
|
|
||||||
// Returns TRUE on success. FALSE on error
|
|
||||||
function setupQuery($task, $blank_user=FALSE)
|
|
||||||
{
|
|
||||||
if ($this->ourDB == NULL) return FALSE;
|
|
||||||
switch ($task)
|
|
||||||
{
|
|
||||||
case 'users' :
|
|
||||||
$query = "SELECT * FROM {$this->DBPrefix}users WHERE `user_id` != 1";
|
|
||||||
|
|
||||||
$query = "SELECT u.*,
|
|
||||||
w.meta_value AS admin,
|
|
||||||
f.meta_value as firstname,
|
|
||||||
l.meta_value as lastname
|
|
||||||
FROM {$this->DBPrefix}users AS u
|
|
||||||
LEFT JOIN {$this->DBPrefix}usermeta AS w ON (u.ID = w.user_id AND w.meta_key = 'wp_capabilities')
|
|
||||||
LEFT JOIN {$this->DBPrefix}usermeta AS f ON (u.ID = f.user_id AND f.meta_key = 'first_name')
|
|
||||||
LEFT JOIN {$this->DBPrefix}usermeta AS l ON (u.ID = l.user_id AND l.meta_key = 'last_name')
|
|
||||||
GROUP BY u.ID";
|
|
||||||
|
|
||||||
$this->ourDB -> db_Select_gen($query);
|
|
||||||
|
|
||||||
$result = $this->ourDB->db_Select_gen($query);
|
|
||||||
|
|
||||||
if ($result === FALSE) return FALSE;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'userclass' :
|
|
||||||
|
|
||||||
/* For reference: (stored in usermeta -> wp_capabilities
|
|
||||||
* Administrator - Somebody who has access to all the administration features
|
|
||||||
* Editor - Somebody who can publish posts, manage posts as well as manage other people's posts, etc.
|
|
||||||
* Author - Somebody who can publish and manage their own posts
|
|
||||||
* Contributor - Somebody who can write and manage their posts but not publish posts
|
|
||||||
* Subscriber - Somebody who can read comments/comment/receive news letters, etc.
|
|
||||||
*/
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
default :
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
$this->copyUserInfo = !$blank_user;
|
|
||||||
$this->currentTask = $task;
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//------------------------------------
|
|
||||||
// Internal functions below here
|
|
||||||
//------------------------------------
|
|
||||||
|
|
||||||
// Copy data read from the DB into the record to be returned.
|
|
||||||
function copyUserData(&$target, &$source)
|
|
||||||
{
|
|
||||||
$user_meta = unserialize($source['admin']);
|
|
||||||
|
|
||||||
if ($this->copyUserInfo)
|
|
||||||
{
|
|
||||||
$target['user_id'] = $source['ID'];
|
|
||||||
}
|
|
||||||
$target['user_name'] = $source['user_nicename'];
|
|
||||||
$target['user_loginname'] = $source['user_login'];
|
|
||||||
$target['user_password'] = $source['user_pass']; // needs to be salted!!!!
|
|
||||||
$target['user_email'] = $source['user_email'];
|
|
||||||
$target['user_hideemail'] = $source['user_hideemail'];
|
|
||||||
$target['user_join'] = strtotime($source['user_registered']);
|
|
||||||
$target['user_admin'] = ($user_meta['administrator'] == 1) ? 1 : 0;
|
|
||||||
$target['user_lastvisit'] = $source['user_lastvisit'];
|
|
||||||
$target['user_login'] = $source['firstname']." ".$source['lastname'];
|
|
||||||
$target['user_ban'] = $source['user_ban'];
|
|
||||||
$target['user_customtitle'] = $source['display_name'];
|
|
||||||
$target['user_sess'] = $source['user_sess']; // Photo
|
|
||||||
$target['user_signature'] = $source['user_signature'];
|
|
||||||
$target['user_image'] = $source['user_image']; // Avatar
|
|
||||||
$target['user_currentvisit'] = $source['user_currentvisit'];
|
|
||||||
$target['user_lastpost'] = $source['user_lastpost'];
|
|
||||||
$target['user_chats'] = $source['user_chats'];
|
|
||||||
$target['user_comments'] = $source['user_comments'];
|
|
||||||
|
|
||||||
$target['user_ip'] = $source['user_ip'];
|
|
||||||
$target['user_prefs'] = $source['user_prefs'];
|
|
||||||
$target['user_visits'] = $source['user_visits'];
|
|
||||||
$target['user_class'] = $source['user_class'];
|
|
||||||
$target['user_perms'] = $source['user_perms'];
|
|
||||||
$target['user_xup'] = $source['user_xup'];
|
|
||||||
$target['user_language'] = $source['user_language'];
|
|
||||||
$target['user_country'] = $source['user_country'];
|
|
||||||
$target['user_location'] = $source['user_location'];
|
|
||||||
$target['user_aim'] = $source['user_aim'];
|
|
||||||
$target['user_icq'] = $source['user_icq'];
|
|
||||||
$target['user_yahoo'] = $source['user_yahoo'];
|
|
||||||
$target['user_msn'] = $source['user_msn'];
|
|
||||||
$target['user_homepage'] = $source['user_url'];
|
|
||||||
$target['user_birthday'] = $source['user_birthday'];
|
|
||||||
$target['user_timezone'] = $source['user_timezone'];
|
|
||||||
|
|
||||||
|
|
||||||
// user_pass user_nicename user_email user_url user_registered user_activation_key user_status display_name
|
|
||||||
|
|
||||||
return $target;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
?>
|
|