Welcome to Geeklog, Anonymous Saturday, December 21 2024 @ 09:03 pm EST
Geeklog Forums
Export GL to MT
Status: offline
alinford
Forum User
Regular Poster
Registered: 01/06/03
Posts: 96
I need to export my GL site to movable type. Is there any export script available for MT, CSV, Blogger, Nuke? Anything?
Answer below
I found this script and it worked:
<?php
// You need the host, user, pass, db name and GL table prefix to run this script.
// Place the script on your server so that you can run it in your browser.
// The script creates and export file in the same directory it is placed.
// Connect to geeklog db. Fill in "host", "user", "pass" with your MySQL info.
$dbHandle = @mysql_connect("host", "user", "pass");
if (mysql_errno() > 0) {
echo("mySql returned an error on connect: " . mysql_error());
exit;
}
// Fill in "database_name" with the name of your DB.
@mysql_select_db("database_name", $dbHandle);
if (mysql_errno() > 0) {
echo("mySql returned an error on db connect: " . mysql_error());
exit;
}
// Creates the export file.
$exportFile = @fopen("geeklog_export.txt", "w+");
// Selects stories. You may need to change the prefix to match your Geeklog install.
// The current table prefix is "gl_".
$sql = "SELECT
gl_stories.sid as sid, gl_stories.owner_id as ownerid,
date_format(gl_stories.date, '%m/%d/%Y %h:%i:%S') as date,
gl_stories.title as title,
gl_stories.introtext as introtext,
gl_stories.bodytext as bodytext,
gl_stories.comments as comments,
gl_stories.tid as topicid,
gl_users.fullname as fullname,
gl_topics.topic as topic,
gl_topics.tid as ftid,
gl_users.uid as userid
FROM gl_stories, gl_users, gl_topics
WHERE gl_stories.owner_id =gl_users.uid
AND gl_stories.tid=gl_topics.tid
ORDER BY gl_stories.date DESC";
$sqlResult = mysql_query($sql, $dbHandle);
if (mysql_errno() > 0) {
die("Cannot execute mySql query: " . mysql_error());
}
while ($currentArr = mysql_fetch_assoc($sqlResult)) {
// Write out the metadata and article text.
fwrite($exportFile, "AUTHOR: " . $currentArr["fullname"] . "\n");
fwrite($exportFile, "TITLE: " . $currentArr["title"] . "\n");
fwrite($exportFile, "DATE: " . $currentArr["date"] . "\n");
fwrite($exportFile, "CATEGORY: " . $currentArr["topic"] . "\n");
fwrite($exportFile, "-----\n");
fwrite($exportFile, "BODY:\n");
fwrite($exportFile, $currentArr["introtext"] . "\n");
fwrite($exportFile, "-----\n");
fwrite($exportFile, "EXTENDED BODY:\n");
fwrite($exportFile, $currentArr["bodytext"] . "\n");
fwrite($exportFile, "-----\n");
// Fetch all of the comments related to this article, if this
// article has any.
if ($currentArr["comments"] > 0) {
$sql = "SELECT date_format(gl_comments.date, '%m/%d/%Y %h:%i:%S') as date,
gl_comments.title,
gl_comments.comment,
gl_comments.uid as uid,
gl_users.uid as fuid,
gl_users.username
FROM (gl_comments LEFT JOIN gl_users ON
gl_comments.uid = gl_users.uid)
WHERE gl_comments.sid = '" . $currentArr["sid"] . "';";
$sqlCommentResult = mysql_query($sql);
if (mysql_errno() > 0) {
die("Could not query comments: " . mysql_error());
}
while ($commentArr = mysql_fetch_assoc($sqlCommentResult)) {
fwrite($exportFile, "COMMENT:\n");
fwrite($exportFile, "AUTHOR: ");
if (!is_null($commentArr["uid"])) {
fwrite($exportFile, $commentArr["username"] . "\n");
} else {
fwrite($exportFile, "[Anonymous]" . "\n");
}
fwrite($exportFile, "DATE: " . $commentArr["date"] . "\n");
fwrite($exportFile, $commentArr["comment"] . "\n");
fwrite($exportFile, "-----\n");
}
}
// We don't handle trackbacks, because my site had so few of them.
// This should be an easy add if you've hacked standalone
// trackback into Geeklog - just import the trackback file
// from the appropriate directory.
// Write end-of-article terminator.
fwrite($exportFile, "\n\n--------\n");
}
fclose($exportFile);
?>
Answer below
I found this script and it worked:
Text Formatted Code
<?php
// You need the host, user, pass, db name and GL table prefix to run this script.
// Place the script on your server so that you can run it in your browser.
// The script creates and export file in the same directory it is placed.
// Connect to geeklog db. Fill in "host", "user", "pass" with your MySQL info.
$dbHandle = @mysql_connect("host", "user", "pass");
if (mysql_errno() > 0) {
echo("mySql returned an error on connect: " . mysql_error());
exit;
}
// Fill in "database_name" with the name of your DB.
@mysql_select_db("database_name", $dbHandle);
if (mysql_errno() > 0) {
echo("mySql returned an error on db connect: " . mysql_error());
exit;
}
// Creates the export file.
$exportFile = @fopen("geeklog_export.txt", "w+");
// Selects stories. You may need to change the prefix to match your Geeklog install.
// The current table prefix is "gl_".
$sql = "SELECT
gl_stories.sid as sid, gl_stories.owner_id as ownerid,
date_format(gl_stories.date, '%m/%d/%Y %h:%i:%S') as date,
gl_stories.title as title,
gl_stories.introtext as introtext,
gl_stories.bodytext as bodytext,
gl_stories.comments as comments,
gl_stories.tid as topicid,
gl_users.fullname as fullname,
gl_topics.topic as topic,
gl_topics.tid as ftid,
gl_users.uid as userid
FROM gl_stories, gl_users, gl_topics
WHERE gl_stories.owner_id =gl_users.uid
AND gl_stories.tid=gl_topics.tid
ORDER BY gl_stories.date DESC";
$sqlResult = mysql_query($sql, $dbHandle);
if (mysql_errno() > 0) {
die("Cannot execute mySql query: " . mysql_error());
}
while ($currentArr = mysql_fetch_assoc($sqlResult)) {
// Write out the metadata and article text.
fwrite($exportFile, "AUTHOR: " . $currentArr["fullname"] . "\n");
fwrite($exportFile, "TITLE: " . $currentArr["title"] . "\n");
fwrite($exportFile, "DATE: " . $currentArr["date"] . "\n");
fwrite($exportFile, "CATEGORY: " . $currentArr["topic"] . "\n");
fwrite($exportFile, "-----\n");
fwrite($exportFile, "BODY:\n");
fwrite($exportFile, $currentArr["introtext"] . "\n");
fwrite($exportFile, "-----\n");
fwrite($exportFile, "EXTENDED BODY:\n");
fwrite($exportFile, $currentArr["bodytext"] . "\n");
fwrite($exportFile, "-----\n");
// Fetch all of the comments related to this article, if this
// article has any.
if ($currentArr["comments"] > 0) {
$sql = "SELECT date_format(gl_comments.date, '%m/%d/%Y %h:%i:%S') as date,
gl_comments.title,
gl_comments.comment,
gl_comments.uid as uid,
gl_users.uid as fuid,
gl_users.username
FROM (gl_comments LEFT JOIN gl_users ON
gl_comments.uid = gl_users.uid)
WHERE gl_comments.sid = '" . $currentArr["sid"] . "';";
$sqlCommentResult = mysql_query($sql);
if (mysql_errno() > 0) {
die("Could not query comments: " . mysql_error());
}
while ($commentArr = mysql_fetch_assoc($sqlCommentResult)) {
fwrite($exportFile, "COMMENT:\n");
fwrite($exportFile, "AUTHOR: ");
if (!is_null($commentArr["uid"])) {
fwrite($exportFile, $commentArr["username"] . "\n");
} else {
fwrite($exportFile, "[Anonymous]" . "\n");
}
fwrite($exportFile, "DATE: " . $commentArr["date"] . "\n");
fwrite($exportFile, $commentArr["comment"] . "\n");
fwrite($exportFile, "-----\n");
}
}
// We don't handle trackbacks, because my site had so few of them.
// This should be an easy add if you've hacked standalone
// trackback into Geeklog - just import the trackback file
// from the appropriate directory.
// Write end-of-article terminator.
fwrite($exportFile, "\n\n--------\n");
}
fclose($exportFile);
?>
15
9
Quote
All times are EST. The time is now 09:03 pm.
- Normal Topic
- Sticky Topic
- Locked Topic
- New Post
- Sticky Topic W/ New Post
- Locked Topic W/ New Post
- View Anonymous Posts
- Able to post
- Filtered HTML Allowed
- Censored Content