My thought was that if I deliver a serialized php object, then the other side can do whatever they want with it.
Export script. You just need to edit the first couple lines to point to the appropriate directory, and which blogId you want to export.
- Code: Select all
<?php
define( "PLOG_CLASS_PATH", "/home/....../www");
$blogId = 8;
include_once( PLOG_CLASS_PATH."class/bootstrap.php" );
lt_include( PLOG_CLASS_PATH."class/file/file.class.php" );
lt_include( PLOG_CLASS_PATH."class/dao/userinfo.class.php" );
lt_include( PLOG_CLASS_PATH."class/dao/bloginfo.class.php" );
lt_include( PLOG_CLASS_PATH."class/data/timestamp.class.php" );
lt_include( PLOG_CLASS_PATH."class/view/admin/admintemplatedview.class.php" );
lt_include( PLOG_CLASS_PATH."class/locale/ltlocales.class.php" );
lt_include( PLOG_CLASS_PATH."class/dao/articles.class.php" );
lt_include( PLOG_CLASS_PATH."class/dao/articlecomments.class.php" );
lt_include( PLOG_CLASS_PATH."class/gallery/dao/galleryalbums.class.php" );
lt_include( PLOG_CLASS_PATH."class/gallery/dao/galleryresources.class.php" );
lt_include( PLOG_CLASS_PATH."class/dao/users.class.php" );
lt_include( PLOG_CLASS_PATH."class/dao/blogs.class.php" );
$blogs = new Blogs();
$blogInfo = $blogs->getBlogInfo($blogId);
$articles = new Articles();
$posts = $articles->getBlogArticles($blogId);
WriteStuff("articles", $posts, true);
$artcomments = new ArticleComments();
$comments = $artcomments->getBlogComments($blogId);
WriteStuff("comments", $comments, true);
$usersobj = new Users();
$users = $usersobj->getBlogUsers($blogId);
foreach($users as $id => $user){
$users[$id]->_password = "erased";
}
WriteStuff("users", $users, true);
$galleryalbums = new GalleryAlbums();
$albums = $galleryalbums->getUserAlbums($blogId, false, -1);
WriteStuff("albums", $albums, true);
$galleryresources = new GalleryResources();
$resources = $galleryresources->getUserResources($blogId, GALLERY_NO_ALBUM, GALLERY_RESOURCE_ANY, "", -1);
WriteStuff("resources", $resources, true);
function WriteStuff($file, $obj, $init=false){
$file = preg_replace("[^a-z]", "", $file);
$f = fopen("$file.out", $init ? "w" : "a");
if($f){
fwrite($f, serialize($obj));
fclose($f);
}
}
Import code, once you get the files where you want them. You'll need to do some more work here, since you will want to put it into a database, or save it some place so the "other" system will be able to figure out what data is what.
- Code: Select all
<?php
class UserInfo{}
class GalleryAlbum{}
class GalleryResource{}
class Article{}
class UserComment{}
$users = ReadStuff("users");
$albums = ReadStuff("albums");
$resources = ReadStuff("resources");
$articles = ReadStuff("articles");
$comments = ReadStuff("comments");
foreach($users as $user){
print "user: " . $user->_id . "\n";
// print_r($user);
}
foreach($albums as $album){
print "album: " . $album->_id . "\n";
// print_r($album);
}
foreach($resources as $resource){
print "resource: " . $resource->_id . "\n";
// print_r($resource);
}
foreach($articles as $article){
print "article: " . $article->_id . "\n";
// print_r($article);
}
foreach($comments as $comment){
print "comment: " . $comment->_id . "\n";
// print_r($comment);
}
function ReadStuff($file){
$file = preg_replace("[^a-z]", "", $file);
return unserialize(file_get_contents("$file.out"));
}
