tools:db:wpimport
no way to compare when less than two revisions
Differences
This shows you the differences between two versions of the page.
Last revision | |||
— | tools:db:wpimport [2019/01/12 17:53] – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | Please notice that categories are not imported as of WP3.0; if you want to improve the following code, feel free. --- // | ||
+ | <code php> | ||
+ | <?php | ||
+ | |||
+ | |||
+ | require_once(' | ||
+ | require_once(INCLUDES_DIR.' | ||
+ | |||
+ | // first time execute with debug = true; | ||
+ | define(' | ||
+ | define(' | ||
+ | define(' | ||
+ | |||
+ | if (function_exists(' | ||
+ | system_init(); | ||
+ | } else { | ||
+ | plugin_loadall(); | ||
+ | } | ||
+ | |||
+ | header(' | ||
+ | |||
+ | function toutf($str) { | ||
+ | return ISO_TO_UTF? | ||
+ | } | ||
+ | | ||
+ | function cat_tree($arr, | ||
+ | $string = ''; | ||
+ | $pad = str_repeat(' | ||
+ | foreach($subtree as $v) { | ||
+ | $string .= " | ||
+ | if (isset($arr[$v[0]])) | ||
+ | $string .= cat_tree($arr, | ||
+ | } | ||
+ | return $string; | ||
+ | } | ||
+ | |||
+ | error_reporting(E_ALL); | ||
+ | |||
+ | $WP_PREFIX = ' | ||
+ | |||
+ | mysql_connect(' | ||
+ | mysql_select_db(' | ||
+ | |||
+ | |||
+ | if (!SKIP_CATEGORIES) { | ||
+ | |||
+ | | ||
+ | or die(mysql_error()); | ||
+ | |||
+ | |||
+ | | ||
+ | while (false !== ($cat = mysql_fetch_assoc($cats))) { | ||
+ | $cat_arr[ $cat[' | ||
+ | } | ||
+ | |||
+ | echo " | ||
+ | $string = cat_tree($cat_arr, | ||
+ | |||
+ | if ($cat_arr && !DEBUG) { | ||
+ | io_write_file(CONTENT_DIR . ' | ||
+ | entry_categories_encode(); | ||
+ | |||
+ | } | ||
+ | |||
+ | echo $string; | ||
+ | echo " | ||
+ | } // SKIP CATEGORIES | ||
+ | |||
+ | $q = mysql_query(' | ||
+ | or die(mysql_error()); | ||
+ | |||
+ | while(false !== ( $arr = mysql_fetch_assoc( $q ) ) ) { | ||
+ | $cats = array(); | ||
+ | |||
+ | if (! SKIP_CATEGORIES ) { | ||
+ | $ccq = mysql_query(' | ||
+ | or die(mysql_error()); | ||
+ | |||
+ | while (false !== ($cc = mysql_fetch_assoc($ccq))) $cats[] = $cc[' | ||
+ | } | ||
+ | $entry = array( | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ); | ||
+ | if ($cats) | ||
+ | $entry[' | ||
+ | |||
+ | echo "SAVE: {$entry[' | ||
+ | $id = null; | ||
+ | if (!DEBUG) { | ||
+ | if ($arr[' | ||
+ | $id = static_save($entry, | ||
+ | } else { | ||
+ | $id = entry_save($entry); | ||
+ | } | ||
+ | } | ||
+ | |||
+ | if (!$id && !DEBUG) | ||
+ | trigger_error(" | ||
+ | |||
+ | if ($arr[' | ||
+ | echo " | ||
+ | continue; | ||
+ | } | ||
+ | |||
+ | $cq = mysql_query(' | ||
+ | or die(mysql_error()); | ||
+ | |||
+ | while (false !== ( $carr = mysql_fetch_assoc($cq) ) ) { | ||
+ | $comment = array( | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ); | ||
+ | if ($carr[' | ||
+ | $comment[' | ||
+ | if ($carr[' | ||
+ | $comment[' | ||
+ | |||
+ | echo " | ||
+ | |||
+ | if (!DEBUG) { | ||
+ | $comment = array_change_key_case($comment, | ||
+ | $comment_dir = bdb_idtofile($id, | ||
+ | $id = bdb_idfromtime(BDB_COMMENT, | ||
+ | $f = $comment_dir . $id . EXT; | ||
+ | $str = utils_kimplode($comment); | ||
+ | io_write_file($f, | ||
+ | } | ||
+ | |||
+ | } | ||
+ | |||
+ | } | ||
+ | mysql_close(); | ||
+ | echo " | ||
+ | |||
+ | </ |