From f25ddbb3a623fd4d314ecdf389568b417791f1cb Mon Sep 17 00:00:00 2001 From: Savetheinternet Date: Fri, 3 Jun 2011 17:04:51 +1000 Subject: [PATCH 01/11] init --- README.md | 22 ++++++ kusabax.php | 227 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 249 insertions(+) create mode 100755 README.md create mode 100755 kusabax.php diff --git a/README.md b/README.md new file mode 100755 index 00000000..8d5fb5c3 --- /dev/null +++ b/README.md @@ -0,0 +1,22 @@ +# Kusaba X Database Migration + +## About +This script pulls board information, posts and images from an already existing [Kusaba X][k] installation and replicates them in [Tinyboard][o]. It should be helpful for those who already use Kusaba X][k], and want to switch over to Tinyboard. +[o]: http://tinyboard.org/ +[k]: http://kusabax.cultnet.net/ + +## Requirements + 1. [Tinyboard][o] >= v0.9.2 + +## Use + 1. Install Tinyboard (>= v0.9.2) normally. + 2. Download and place `kusabax.php` in the root folder of Tinyboard. + 3. Edit the script and fill in your Kusaba X configuration. You can find KU_RANDOMSEED from Kusaba X's config.php file. + 4. Run the script in a web browser. + +## Documentation +Visit the Tinyboard development wiki at for help. + +## License +See [LICENSE.md][l] for the license. +[l]: http://github.com/savetheinternet/Tinyboard/blob/master/LICENSE.md \ No newline at end of file diff --git a/kusabax.php b/kusabax.php new file mode 100755 index 00000000..4d8637e8 --- /dev/null +++ b/kusabax.php @@ -0,0 +1,227 @@ + Array('timeout' => 5, 'persistent' => false)); + $kusabaxc['db']['type'] = 'mysql'; + $kusabaxc['db']['server'] = 'localhost'; + $kusabaxc['db']['user'] = ''; + $kusabaxc['db']['password'] = ''; + $kusabaxc['db']['database'] = ''; + // KusabaX table prefix + $kusabaxc['db']['prefix'] = ''; + // Anything more to add to the DSN string (eg. port=xxx;foo=bar) + $kusabaxc['db']['dsn'] = ''; + // From your KusabaX config; needed to decode IP addresses + $kusabaxc['randomseed'] = ''; //KU_RANDOMSEED + // KusabaX directory (without trailing slash) + $kusabaxc['root'] = '/var/www/kusabax'; + + /* End Config */ + + + // KusabaX functions + function md5_decrypt($enc_text, $password, $iv_len = 16) { + $enc_text = base64_decode($enc_text); + $n = strlen($enc_text); + $i = $iv_len; + $plain_text = ''; + $iv = substr($password ^ substr($enc_text, 0, $iv_len), 0, 512); + while ($i < $n) { + $block = substr($enc_text, $i, 16); + $plain_text .= $block ^ pack('H*', md5($iv)); + $iv = substr($block . $iv, 0, 512) ^ $password; + $i += 16; + } + return preg_replace('/\\x13\\x00*$/', '', $plain_text); + } + + // KusabaX -> Tinyboard HTML + function convert_markup($body) { + global $config; + $body = stripslashes($body); + + // Replace >quotes + $body = str_replace('"unkfunc"', '"quote"', $body); + + // Replace >>cites + $body = preg_replace('//', '', $body); + + return $body; + } + + require 'inc/functions.php'; + require 'inc/display.php'; + require 'inc/template.php'; + require 'inc/database.php'; + require 'inc/user.php'; + $step = isset($_GET['step']) ? round($_GET['step']) : 0; + $page = Array( + 'config' => $config, + 'title' => 'KusabaX Database Migration', + 'body' => '' + ); + + $log = Array(); + + // Trick Tinyboard into opening the KusabaX databse instead + $__temp = $config['db']; + $config['db'] = $kusabaxc['db']; + sql_open(); + // Get databse link + $kusabax = $pdo; + // Clear + unset($pdo); + + // Open Tinyboard database + $config['db'] = $__temp; + unset($__temp); + sql_open(); + + $k_query = $kusabax->query('SELECT * FROM `' . $kusabaxc['db']['prefix'] . 'boards`'); + $boards = listBoards(); + + // Copy boards table, briefly + $kusabax_boards = Array(); + while($board = $k_query->fetch()) { + // For later use... + $kusabax_boards[(int)$board['id']] = $board['name']; + + $already_exists = false; + foreach($boards as &$_board) { + if($_board['uri'] == $board['name']) { + // Board already exists in Tinyboard... + $log[] = 'Board /' . $board['name'] . '/ already exists.'; + $already_exists = true; + break; + } + } + if($already_exists) + continue; + + $log[] = 'Creating board: /' . $board['name'] . '/'; + + // Go ahead and create this new board... + $query = prepare('INSERT INTO `boards` VALUES (NULL, :uri, :title, :subtitle)'); + $query->bindValue(':uri', $board['name']); + $query->bindValue(':title', $board['desc']); + $query->bindValue(':subtitle', null, PDO::PARAM_NULL); + $query->execute() or error(db_error($query)); + + // Posting table + query(Element('posts.sql', Array('board' => $board['name']))) or error(db_error()); + + // Set up board (create directories, etc.) by opening it + openBoard($board['name']); + } + + + $k_query = $kusabax->query('SELECT * FROM `' . $kusabaxc['db']['prefix'] . 'posts` WHERE `IS_DELETED` = 0'); + while($post = $k_query->fetch()) { + if(!isset($kusabax_boards[(int)$post['boardid']])) { + // Board doesn't exist... + continue; + } + $board = $kusabax_boards[(int)$post['boardid']]; + + $query = prepare(sprintf("INSERT INTO `posts_%s` VALUES (:id, :thread, :subject, :email, :name, :trip, :capcode, :body, :time, :bump, :thumb, :thumbwidth, :thumbheight, :file, :width, :height, :filesize, :filename, :filehash, :password, :ip, :sticky, :locked, :embed)", $board)); + + // Post ID + $query->bindValue(':id', $post['id'], PDO::PARAM_INT); + + // Thread (`parentid`) + if($post['parentid'] == 0) + $query->bindValue(':thread', null, PDO::PARAM_NULL); + else + $query->bindValue(':thread', (int)$post['parentid'], PDO::PARAM_INT); + + // Name + if(empty($post['name'])) + $post['name'] = $config['anonymous']; + $query->bindValue(':name', $post['name'], PDO::PARAM_INT); + + // Trip + if(empty($post['tripcode'])) + $query->bindValue(':trip', null, PDO::PARAM_NULL); + else + $query->bindValue(':trip', $post['tripcode'], PDO::PARAM_STR); + + // Email + $query->bindValue(':email', $post['email'], PDO::PARAM_STR); + + // Subject + $query->bindValue(':subject', $post['subject'], PDO::PARAM_STR); + + // Body (`message`) + $query->bindValue(':body', convert_markup($post['message']), PDO::PARAM_STR); + + // File + if(empty($post['file'])) { + $query->bindValue(':file', null, PDO::PARAM_NULL); + $query->bindValue(':width', null, PDO::PARAM_NULL); + $query->bindValue(':height', null, PDO::PARAM_NULL); + $query->bindValue(':filesize', null, PDO::PARAM_NULL); + $query->bindValue(':filename', null, PDO::PARAM_NULL); + $query->bindValue(':filehash', null, PDO::PARAM_NULL); + $query->bindValue(':thumb', null, PDO::PARAM_NULL); + $query->bindValue(':thumbwidth', null, PDO::PARAM_NULL); + $query->bindValue(':thumbheight', null, PDO::PARAM_NULL); + } else { + $query->bindValue(':file', $post['file'] . '.' . $post['file_type'], PDO::PARAM_STR); + $query->bindValue(':width', $post['image_w'], PDO::PARAM_INT); + $query->bindValue(':height', $post['image_h'], PDO::PARAM_INT); + $query->bindValue(':filesize', $post['file_size'], PDO::PARAM_INT); + $query->bindValue(':filename', $post['file_original'] . '.' . $post['file_type'], PDO::PARAM_STR); + // They use MD5; we use SHA1 by default. + $query->bindValue(':filehash', null, PDO::PARAM_NULL); + + $query->bindValue(':thumb', $post['file'] . '.' . $post['file_type'], PDO::PARAM_STR); + $query->bindValue(':thumbwidth', $post['thumb_w'], PDO::PARAM_INT); + $query->bindValue(':thumbheight', $post['thumb_h'], PDO::PARAM_INT); + } + + // IP + $query->bindValue(':ip', md5_decrypt($post['ip'], $kusabaxc['randomseed']), PDO::PARAM_STR); + + // Time (`timestamp`) + $query->bindValue(':time', $post['timestamp'], PDO::PARAM_INT); + + // Bump (`bumped`) + $query->bindValue(':bump', $post['bumped'], PDO::PARAM_INT); + + // Locked + $query->bindValue(':locked', $post['locked'], PDO::PARAM_INT); + + // Sticky + $query->bindValue(':sticky', $post['stickied'], PDO::PARAM_INT); + + // Stuff we can't do (yet) + $query->bindValue(':embed', null, PDO::PARAM_NULL); + $query->bindValue(':password', null, PDO::PARAM_NULL); + $query->bindValue(':capcode', null, PDO::PARAM_NULL); + + + $log[] = 'Replicating post ' . $post['id'] . ' on /' . $board . '/'; + + if(!empty($post['file'])) { + // Copy file + $file_path = $kusabaxc['root'] . '/' . $board . '/src/' . $post['file'] . '.' . $post['file_type']; + $thumb_path = $kusabaxc['root'] . '/' . $board . '/thumb/' . $post['file'] . 's.' . $post['file_type']; + + $log[] = 'Copying file: ' . $file_path . ''; + + copy($file_path, sprintf($config['board_path'], $board) . $config['dir']['img'] . $post['file'] . '.' . $post['file_type']); + copy($thumb_path, sprintf($config['board_path'], $board) . $config['dir']['thumb'] . $post['file'] . '.' . $post['file_type']); + } + + // Insert post + $query->execute() or $log[] = 'Error: ' . db_error($query); + } + + $page['body'] = '

Migrating…

'; + foreach($log as &$l) { + $page['body'] .= $l . '
'; + } + $page['body'] .= '

'; + + echo Element('page.html', $page); +?> \ No newline at end of file From f4f76bf3c6824dcd3339c3616ab1c14ceb1c8f7b Mon Sep 17 00:00:00 2001 From: Savetheinternet Date: Fri, 3 Jun 2011 17:09:05 +1000 Subject: [PATCH 02/11] check if configured before running --- kusabax.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/kusabax.php b/kusabax.php index 4d8637e8..e70f1f1e 100755 --- a/kusabax.php +++ b/kusabax.php @@ -18,6 +18,8 @@ /* End Config */ + if(empty($kusabaxc['db']['user'])) + error('Did you forget to configure the script?'); // KusabaX functions function md5_decrypt($enc_text, $password, $iv_len = 16) { From 9826aae5b9e69f3e87905d86e1ad948b1a669be4 Mon Sep 17 00:00:00 2001 From: Savetheinternet Date: Fri, 3 Jun 2011 17:09:28 +1000 Subject: [PATCH 03/11] stupid mistake --- kusabax.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kusabax.php b/kusabax.php index e70f1f1e..317c8ebf 100755 --- a/kusabax.php +++ b/kusabax.php @@ -19,7 +19,7 @@ /* End Config */ if(empty($kusabaxc['db']['user'])) - error('Did you forget to configure the script?'); + die('Did you forget to configure the script?'); // KusabaX functions function md5_decrypt($enc_text, $password, $iv_len = 16) { From 66df02c2e46a302078f31c4c2e247a4d9d5938b5 Mon Sep 17 00:00:00 2001 From: Savetheinternet Date: Fri, 3 Jun 2011 17:31:01 +1000 Subject: [PATCH 04/11] infinite timeout --- kusabax.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/kusabax.php b/kusabax.php index 317c8ebf..f1ae080c 100755 --- a/kusabax.php +++ b/kusabax.php @@ -21,6 +21,9 @@ if(empty($kusabaxc['db']['user'])) die('Did you forget to configure the script?'); + // Infinite timeout + set_time_limit(0); + // KusabaX functions function md5_decrypt($enc_text, $password, $iv_len = 16) { $enc_text = base64_decode($enc_text); @@ -42,12 +45,15 @@ global $config; $body = stripslashes($body); - // Replace >quotes + // >quotes $body = str_replace('"unkfunc"', '"quote"', $body); - // Replace >>cites + // >>cites $body = preg_replace('/
/', '', $body); + // Public bans + $body = preg_replace('/
\((.+?)\)<\/b><\/font>/', '$1', $body); + return $body; } From 399a5ab5d10d7db4083c4af62326f3f4e6c97280 Mon Sep 17 00:00:00 2001 From: Savetheinternet Date: Fri, 3 Jun 2011 17:33:08 +1000 Subject: [PATCH 05/11] public bans; --- kusabax.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/kusabax.php b/kusabax.php index f1ae080c..9f6ea7a5 100755 --- a/kusabax.php +++ b/kusabax.php @@ -4,9 +4,9 @@ $kusabaxc = Array('db' => Array('timeout' => 5, 'persistent' => false)); $kusabaxc['db']['type'] = 'mysql'; $kusabaxc['db']['server'] = 'localhost'; - $kusabaxc['db']['user'] = ''; - $kusabaxc['db']['password'] = ''; - $kusabaxc['db']['database'] = ''; + $kusabaxc['db']['user'] = 'kusaba'; + $kusabaxc['db']['password'] = 'kusaba'; + $kusabaxc['db']['database'] = 'kusaba'; // KusabaX table prefix $kusabaxc['db']['prefix'] = ''; // Anything more to add to the DSN string (eg. port=xxx;foo=bar) @@ -52,7 +52,7 @@ $body = preg_replace('/
/', '', $body); // Public bans - $body = preg_replace('/
\((.+?)\)<\/b><\/font>/', '$1', $body); + $body = preg_replace('/
\((.+?)\)<\/b><\/font>/', '($1)', $body); return $body; } From 6ce881284330487fe3dff3cf740f6befc49914de Mon Sep 17 00:00:00 2001 From: Savetheinternet Date: Fri, 3 Jun 2011 17:36:36 +1000 Subject: [PATCH 06/11] safer IP address decryption (KU_RANDOMSEED) --- kusabax.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/kusabax.php b/kusabax.php index 9f6ea7a5..6b17499a 100755 --- a/kusabax.php +++ b/kusabax.php @@ -188,7 +188,14 @@ } // IP - $query->bindValue(':ip', md5_decrypt($post['ip'], $kusabaxc['randomseed']), PDO::PARAM_STR); + $ip = md5_decrypt($post['ip'], $kusabaxc['randomseed']); + if(!preg_match('/^\d+\.\d+\.\d+\.\d+$/', $ip)) { + // Invalid IP address. Wrong KU_RANDOMSEED? + + $log[] = 'Invalid IP address returned after decryption. Wrong KU_RANDOMSEED?'; + $ip = '0.0.0.0'; // just set it to something valid and continue + } + $query->bindValue(':ip', $ip, PDO::PARAM_STR); // Time (`timestamp`) $query->bindValue(':time', $post['timestamp'], PDO::PARAM_INT); From 5c942f8c9e2305c529b83ef7a544b56febc7e3ae Mon Sep 17 00:00:00 2001 From: Savetheinternet Date: Fri, 3 Jun 2011 17:43:01 +1000 Subject: [PATCH 07/11] check if destination and source files exist before attempting to copy --- kusabax.php | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/kusabax.php b/kusabax.php index 6b17499a..ebe76773 100755 --- a/kusabax.php +++ b/kusabax.php @@ -4,9 +4,9 @@ $kusabaxc = Array('db' => Array('timeout' => 5, 'persistent' => false)); $kusabaxc['db']['type'] = 'mysql'; $kusabaxc['db']['server'] = 'localhost'; - $kusabaxc['db']['user'] = 'kusaba'; - $kusabaxc['db']['password'] = 'kusaba'; - $kusabaxc['db']['database'] = 'kusaba'; + $kusabaxc['db']['user'] = ''; + $kusabaxc['db']['password'] = ''; + $kusabaxc['db']['database'] = ''; // KusabaX table prefix $kusabaxc['db']['prefix'] = ''; // Anything more to add to the DSN string (eg. port=xxx;foo=bar) @@ -222,10 +222,24 @@ $file_path = $kusabaxc['root'] . '/' . $board . '/src/' . $post['file'] . '.' . $post['file_type']; $thumb_path = $kusabaxc['root'] . '/' . $board . '/thumb/' . $post['file'] . 's.' . $post['file_type']; - $log[] = 'Copying file: ' . $file_path . ''; + $to_file_path = sprintf($config['board_path'], $board) . $config['dir']['img'] . $post['file'] . '.' . $post['file_type']; + $to_thumb_path = sprintf($config['board_path'], $board) . $config['dir']['thumb'] . $post['file'] . '.' . $post['file_type']; - copy($file_path, sprintf($config['board_path'], $board) . $config['dir']['img'] . $post['file'] . '.' . $post['file_type']); - copy($thumb_path, sprintf($config['board_path'], $board) . $config['dir']['thumb'] . $post['file'] . '.' . $post['file_type']); + if(!file_exists($to_file_path)) { + $log[] = 'Copying file: ' . $file_path . ''; + if(!@copy($file_path, $to_file_path)) { + $err = error_get_last(); + $log[] = 'Could not copy ' . $file_path . ': ' . $err['message']; + } + } + + if(!file_exists($to_thumb_path)) { + $log[] = 'Copying file: ' . $thumb_path . ''; + if(!@copy($thumb_path, $to_thumb_path)) { + $err = error_get_last(); + $log[] = 'Could not copy ' . $thumb_path. ': ' . $err['message']; + } + } } // Insert post From 0a37976936cb1194bd91d3c6f74dcbb93fa5610a Mon Sep 17 00:00:00 2001 From: Savetheinternet Date: Fri, 3 Jun 2011 18:02:58 +1000 Subject: [PATCH 08/11] deleted/removed images --- kusabax.php | 60 ++++++++++++++++++++++++++++++------------------------------ 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/kusabax.php b/kusabax.php index ebe76773..983bf21e 100755 --- a/kusabax.php +++ b/kusabax.php @@ -131,6 +131,8 @@ } $board = $kusabax_boards[(int)$post['boardid']]; + $log[] = 'Replicating post ' . $post['id'] . ' on /' . $board . '/'; + $query = prepare(sprintf("INSERT INTO `posts_%s` VALUES (:id, :thread, :subject, :email, :name, :trip, :capcode, :body, :time, :bump, :thumb, :thumbwidth, :thumbheight, :file, :width, :height, :filesize, :filename, :filehash, :password, :ip, :sticky, :locked, :embed)", $board)); // Post ID @@ -163,8 +165,11 @@ $query->bindValue(':body', convert_markup($post['message']), PDO::PARAM_STR); // File - if(empty($post['file'])) { - $query->bindValue(':file', null, PDO::PARAM_NULL); + if(empty($post['file']) || $post['file'] == 'removed') { + if($post['file'] == 'removed') + $query->bindValue(':file', 'deleted', PDO::PARAM_STR); + else + $query->bindValue(':file', null, PDO::PARAM_NULL); $query->bindValue(':width', null, PDO::PARAM_NULL); $query->bindValue(':height', null, PDO::PARAM_NULL); $query->bindValue(':filesize', null, PDO::PARAM_NULL); @@ -185,6 +190,29 @@ $query->bindValue(':thumb', $post['file'] . '.' . $post['file_type'], PDO::PARAM_STR); $query->bindValue(':thumbwidth', $post['thumb_w'], PDO::PARAM_INT); $query->bindValue(':thumbheight', $post['thumb_h'], PDO::PARAM_INT); + + // Copy file + $file_path = $kusabaxc['root'] . '/' . $board . '/src/' . $post['file'] . '.' . $post['file_type']; + $thumb_path = $kusabaxc['root'] . '/' . $board . '/thumb/' . $post['file'] . 's.' . $post['file_type']; + + $to_file_path = sprintf($config['board_path'], $board) . $config['dir']['img'] . $post['file'] . '.' . $post['file_type']; + $to_thumb_path = sprintf($config['board_path'], $board) . $config['dir']['thumb'] . $post['file'] . '.' . $post['file_type']; + + if(!file_exists($to_file_path)) { + $log[] = 'Copying file: ' . $file_path . ''; + if(!@copy($file_path, $to_file_path)) { + $err = error_get_last(); + $log[] = 'Could not copy ' . $file_path . ': ' . $err['message']; + } + } + + if(!file_exists($to_thumb_path)) { + $log[] = 'Copying file: ' . $thumb_path . ''; + if(!@copy($thumb_path, $to_thumb_path)) { + $err = error_get_last(); + $log[] = 'Could not copy ' . $thumb_path. ': ' . $err['message']; + } + } } // IP @@ -214,34 +242,6 @@ $query->bindValue(':password', null, PDO::PARAM_NULL); $query->bindValue(':capcode', null, PDO::PARAM_NULL); - - $log[] = 'Replicating post ' . $post['id'] . ' on /' . $board . '/'; - - if(!empty($post['file'])) { - // Copy file - $file_path = $kusabaxc['root'] . '/' . $board . '/src/' . $post['file'] . '.' . $post['file_type']; - $thumb_path = $kusabaxc['root'] . '/' . $board . '/thumb/' . $post['file'] . 's.' . $post['file_type']; - - $to_file_path = sprintf($config['board_path'], $board) . $config['dir']['img'] . $post['file'] . '.' . $post['file_type']; - $to_thumb_path = sprintf($config['board_path'], $board) . $config['dir']['thumb'] . $post['file'] . '.' . $post['file_type']; - - if(!file_exists($to_file_path)) { - $log[] = 'Copying file: ' . $file_path . ''; - if(!@copy($file_path, $to_file_path)) { - $err = error_get_last(); - $log[] = 'Could not copy ' . $file_path . ': ' . $err['message']; - } - } - - if(!file_exists($to_thumb_path)) { - $log[] = 'Copying file: ' . $thumb_path . ''; - if(!@copy($thumb_path, $to_thumb_path)) { - $err = error_get_last(); - $log[] = 'Could not copy ' . $thumb_path. ': ' . $err['message']; - } - } - } - // Insert post $query->execute() or $log[] = 'Error: ' . db_error($query); } From 4488965f91209ea433f69e60ac3bee508ab34e06 Mon Sep 17 00:00:00 2001 From: Savetheinternet Date: Fri, 3 Jun 2011 18:12:18 +1000 Subject: [PATCH 09/11] news --- kusabax.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/kusabax.php b/kusabax.php index 983bf21e..b2f6322f 100755 --- a/kusabax.php +++ b/kusabax.php @@ -246,6 +246,25 @@ $query->execute() or $log[] = 'Error: ' . db_error($query); } + // News + $k_query = $kusabax->query('SELECT * FROM `' . $kusabaxc['db']['prefix'] . 'front` WHERE `page` = 0'); + while($news = $k_query->fetch()) { + // Check if already exists + $query = prepare("SELECT 1 FROM `news` WHERE `body` = :body AND `time` = :time"); + $query->bindValue(':time', $news['timestamp'], PDO::PARAM_INT); + $query->bindValue(':body', $news['message'], PDO::PARAM_STR); + $query->execute() or error(db_error($query)); + if($query->fetch()) + continue; + + $query = prepare("INSERT INTO `news` VALUES (NULL, :name, :time, :subject, :body)"); + $query->bindValue(':name', $news['poster'], PDO::PARAM_STR); + $query->bindValue(':time', $news['timestamp'], PDO::PARAM_INT); + $query->bindValue(':subject', $news['subject'], PDO::PARAM_STR); + $query->bindValue(':body', $news['message'], PDO::PARAM_STR); + $query->execute() or $log[] = 'Error: ' . db_error($query); + } + $page['body'] = '

Migrating…

'; foreach($log as &$l) { $page['body'] .= $l . '
'; From d7ff4947b5f8d8e429e4f8fccae50a7c06b646bc Mon Sep 17 00:00:00 2001 From: Savetheinternet Date: Sat, 4 Jun 2011 17:37:11 +1000 Subject: [PATCH 10/11] readme update --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index 8d5fb5c3..162a3787 100755 --- a/README.md +++ b/README.md @@ -14,6 +14,11 @@ This script pulls board information, posts and images from an already existing [ 3. Edit the script and fill in your Kusaba X configuration. You can find KU_RANDOMSEED from Kusaba X's config.php file. 4. Run the script in a web browser. +## What's copied? (in the future, more will be added.) + 1. Basic board information + 2. Posts + 3. News + ## Documentation Visit the Tinyboard development wiki at for help. From cce8b3955d5df03a6adca5e5e11d2bef039cc917 Mon Sep 17 00:00:00 2001 From: Savetheinternet Date: Wed, 23 Nov 2011 21:44:22 +1100 Subject: [PATCH 11/11] compatibility with >= v0.9.4 --- README.md | 6 +++--- kusabax.php | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 162a3787..8c5d9eee 100755 --- a/README.md +++ b/README.md @@ -6,10 +6,10 @@ This script pulls board information, posts and images from an already existing [ [k]: http://kusabax.cultnet.net/ ## Requirements - 1. [Tinyboard][o] >= v0.9.2 + 1. [Tinyboard][o] >= v0.9.4 ## Use - 1. Install Tinyboard (>= v0.9.2) normally. + 1. Install Tinyboard (>= v0.9.4) normally. 2. Download and place `kusabax.php` in the root folder of Tinyboard. 3. Edit the script and fill in your Kusaba X configuration. You can find KU_RANDOMSEED from Kusaba X's config.php file. 4. Run the script in a web browser. @@ -24,4 +24,4 @@ Visit the Tinyboard development wiki at for help. ## License See [LICENSE.md][l] for the license. -[l]: http://github.com/savetheinternet/Tinyboard/blob/master/LICENSE.md \ No newline at end of file +[l]: http://github.com/savetheinternet/Tinyboard/blob/master/LICENSE.md diff --git a/kusabax.php b/kusabax.php index b2f6322f..eed12e0a 100755 --- a/kusabax.php +++ b/kusabax.php @@ -74,7 +74,7 @@ // Trick Tinyboard into opening the KusabaX databse instead $__temp = $config['db']; $config['db'] = $kusabaxc['db']; - sql_open(); + // Get databse link $kusabax = $pdo; // Clear @@ -83,7 +83,6 @@ // Open Tinyboard database $config['db'] = $__temp; unset($__temp); - sql_open(); $k_query = $kusabax->query('SELECT * FROM `' . $kusabaxc['db']['prefix'] . 'boards`'); $boards = listBoards(); @@ -133,7 +132,7 @@ $log[] = 'Replicating post ' . $post['id'] . ' on /' . $board . '/'; - $query = prepare(sprintf("INSERT INTO `posts_%s` VALUES (:id, :thread, :subject, :email, :name, :trip, :capcode, :body, :time, :bump, :thumb, :thumbwidth, :thumbheight, :file, :width, :height, :filesize, :filename, :filehash, :password, :ip, :sticky, :locked, :embed)", $board)); + $query = prepare(sprintf("INSERT INTO `posts_%s` VALUES (:id, :thread, :subject, :email, :name, :trip, :capcode, :body, :time, :bump, :thumb, :thumbwidth, :thumbheight, :file, :width, :height, :filesize, :filename, :filehash, :password, :ip, :sticky, :locked, 0, :embed)", $board)); // Post ID $query->bindValue(':id', $post['id'], PDO::PARAM_INT); @@ -272,4 +271,5 @@ $page['body'] .= '

'; echo Element('page.html', $page); -?> \ No newline at end of file + +