1 | <?php |
---|
2 | /* |
---|
3 | * Jaws import plugin |
---|
4 | * by Omar Bazavilvazo - http://OmarBazavilvazo.com/ |
---|
5 | */ |
---|
6 | |
---|
7 | /** |
---|
8 | Add These Functions to make our lives easier |
---|
9 | **/ |
---|
10 | if(!function_exists('get_catbynicename')) |
---|
11 | { |
---|
12 | function get_catbynicename($category_nicename) |
---|
13 | { |
---|
14 | global $wpdb; |
---|
15 | |
---|
16 | $cat_id -= 0; // force numeric |
---|
17 | $name = $wpdb->get_var('SELECT cat_ID FROM '.$wpdb->categories.' WHERE category_nicename="'.$category_nicename.'"'); |
---|
18 | |
---|
19 | return $name; |
---|
20 | } |
---|
21 | } |
---|
22 | |
---|
23 | if(!function_exists('get_comment_count')) |
---|
24 | { |
---|
25 | function get_comment_count($post_ID) |
---|
26 | { |
---|
27 | global $wpdb; |
---|
28 | return $wpdb->get_var('SELECT count(*) FROM '.$wpdb->comments.' WHERE comment_post_ID = '.$post_ID); |
---|
29 | } |
---|
30 | } |
---|
31 | |
---|
32 | if(!function_exists('link_exists')) |
---|
33 | { |
---|
34 | function link_exists($linkname) |
---|
35 | { |
---|
36 | global $wpdb; |
---|
37 | return $wpdb->get_var('SELECT link_id FROM '.$wpdb->links.' WHERE link_name = "'.$wpdb->escape($linkname).'"'); |
---|
38 | } |
---|
39 | } |
---|
40 | |
---|
41 | /** |
---|
42 | The Main Importer Class |
---|
43 | **/ |
---|
44 | class Jaws_Import { |
---|
45 | |
---|
46 | function header() |
---|
47 | { |
---|
48 | echo '<div class="wrap">'; |
---|
49 | echo '<h2>'.__('Import Jaws').'</h2>'; |
---|
50 | echo '<p>'.__('Steps may take a few minutes depending on the size of your database. Please be patient.').'</p>'; |
---|
51 | } |
---|
52 | |
---|
53 | function footer() |
---|
54 | { |
---|
55 | echo '</div>'; |
---|
56 | } |
---|
57 | |
---|
58 | function greet() { |
---|
59 | echo '<div class="narrow">'; |
---|
60 | echo '<p>'.__('Howdy! This imports categories, users, posts, comments, and links from any Jaws 0.6.1+ into this blog.').'</p>'; |
---|
61 | echo '<p>'.__('This has not been tested on previous versions of Jaws. Mileage may vary.').'</p>'; |
---|
62 | echo '<p>'.__('Your Jaws Configuration settings are as follows:').'</p>'; |
---|
63 | echo '<form action="admin.php?import=jaws&step=1" method="post">'; |
---|
64 | $this->db_form(); |
---|
65 | echo '<p class="submit"><input type="submit" name="submit" value="'.__('Import Categories').' »" /></p>'; |
---|
66 | echo '</form>'; |
---|
67 | echo '</div>'; |
---|
68 | } |
---|
69 | |
---|
70 | function get_jaws_cats() |
---|
71 | { |
---|
72 | global $wpdb; |
---|
73 | // General Housekeeping |
---|
74 | $jawsdb = new wpdb(get_option('jawsuser'), get_option('jawspass'), get_option('jawsname'), get_option('jawshost')); |
---|
75 | set_magic_quotes_runtime(0); |
---|
76 | $prefix = get_option('tpre'); |
---|
77 | |
---|
78 | // Get Categories |
---|
79 | return $jawsdb->get_results('SELECT |
---|
80 | id, |
---|
81 | name |
---|
82 | FROM '.$prefix.'blog_category', |
---|
83 | ARRAY_A); |
---|
84 | } |
---|
85 | |
---|
86 | function get_jaws_users() |
---|
87 | { |
---|
88 | global $wpdb; |
---|
89 | // General Housekeeping |
---|
90 | $jawsdb = new wpdb(get_option('jawsuser'), get_option('jawspass'), get_option('jawsname'), get_option('jawshost')); |
---|
91 | set_magic_quotes_runtime(0); |
---|
92 | $prefix = get_option('tpre'); |
---|
93 | |
---|
94 | // Get Users |
---|
95 | |
---|
96 | return $jawsdb->get_results('SELECT |
---|
97 | id as user_id, |
---|
98 | username, |
---|
99 | passwd, |
---|
100 | name, |
---|
101 | email, |
---|
102 | createtime |
---|
103 | FROM '.$prefix.'users WHERE username != "admin"', ARRAY_A); |
---|
104 | } |
---|
105 | |
---|
106 | function get_jaws_posts() |
---|
107 | { |
---|
108 | // General Housekeeping |
---|
109 | $jawsdb = new wpdb(get_option('jawsuser'), get_option('jawspass'), get_option('jawsname'), get_option('jawshost')); |
---|
110 | set_magic_quotes_runtime(0); |
---|
111 | $prefix = get_option('tpre'); |
---|
112 | |
---|
113 | // Get Posts |
---|
114 | return $jawsdb->get_results('SELECT *, id as post_id FROM '.$prefix.'blog', ARRAY_A); |
---|
115 | } |
---|
116 | |
---|
117 | function get_jaws_post_categories($id_post) |
---|
118 | { |
---|
119 | // General Housekeeping |
---|
120 | $jawsdb = new wpdb(get_option('jawsuser'), get_option('jawspass'), get_option('jawsname'), get_option('jawshost')); |
---|
121 | set_magic_quotes_runtime(0); |
---|
122 | $prefix = get_option('tpre'); |
---|
123 | |
---|
124 | // Get Categories |
---|
125 | return $jawsdb->get_results('SELECT category_id as cat_id FROM '.$prefix.'blog_entrycat |
---|
126 | WHERE entry_id='.$id_post, ARRAY_A); |
---|
127 | |
---|
128 | } |
---|
129 | |
---|
130 | function get_jaws_comments() |
---|
131 | { |
---|
132 | global $wpdb; |
---|
133 | // General Housekeeping |
---|
134 | $jawsdb = new wpdb(get_option('jawsuser'), get_option('jawspass'), get_option('jawsname'), get_option('jawshost')); |
---|
135 | set_magic_quotes_runtime(0); |
---|
136 | $prefix = get_option('tpre'); |
---|
137 | |
---|
138 | // Get Comments |
---|
139 | return $jawsdb->get_results('SELECT *, id as comment_id FROM '.$prefix.'comments WHERE gadget="Blog"', ARRAY_A); |
---|
140 | } |
---|
141 | |
---|
142 | function get_jaws_links() |
---|
143 | { |
---|
144 | //General Housekeeping |
---|
145 | $jawsdb = new wpdb(get_option('jawsuser'), get_option('jawspass'), get_option('jawsname'), get_option('jawshost')); |
---|
146 | set_magic_quotes_runtime(0); |
---|
147 | $prefix = get_option('tpre'); |
---|
148 | |
---|
149 | // Get Friends... |
---|
150 | return $jawsdb->get_results('SELECT * FROM '.$prefix.'friend', ARRAY_A); |
---|
151 | } |
---|
152 | |
---|
153 | function cat2wp($categories='') |
---|
154 | { |
---|
155 | // General Housekeeping |
---|
156 | global $wpdb; |
---|
157 | $count = 0; |
---|
158 | $jawscat2wpcat = array(); |
---|
159 | // Do the Magic |
---|
160 | if(is_array($categories)) |
---|
161 | { |
---|
162 | echo '<p>'.__('Importing Categories...').'<br /><br /></p>'; |
---|
163 | foreach ($categories as $category) |
---|
164 | { |
---|
165 | $count++; |
---|
166 | extract($category); |
---|
167 | |
---|
168 | |
---|
169 | // Make Nice Variables |
---|
170 | $name = $wpdb->escape($name); |
---|
171 | $title = $wpdb->escape($name); |
---|
172 | |
---|
173 | if($cinfo = category_exists($name)) |
---|
174 | { |
---|
175 | $ret_id = wp_insert_category(array('cat_ID' => $cinfo, 'category_nicename' => $name, 'cat_name' => $title)); |
---|
176 | } |
---|
177 | else |
---|
178 | { |
---|
179 | $ret_id = wp_insert_category(array('category_nicename' => $name, 'cat_name' => $title)); |
---|
180 | } |
---|
181 | $jawscat2wpcat[$id] = $ret_id; |
---|
182 | } |
---|
183 | |
---|
184 | // Store category translation for future use |
---|
185 | add_option('jawscat2wpcat',$jawscat2wpcat); |
---|
186 | echo '<p>'.sprintf(__('Done! <strong>%1$s</strong> categories imported.'), $count).'<br /><br /></p>'; |
---|
187 | return true; |
---|
188 | } |
---|
189 | echo __('No Categories to Import!'); |
---|
190 | return false; |
---|
191 | } |
---|
192 | |
---|
193 | function users2wp($users='') |
---|
194 | { |
---|
195 | // General Housekeeping |
---|
196 | global $wpdb; |
---|
197 | $count = 0; |
---|
198 | $jawsid2wpid = array(); |
---|
199 | |
---|
200 | // Midnight Mojo |
---|
201 | if(is_array($users)) |
---|
202 | { |
---|
203 | echo '<p>'.__('Importing Users...').'<br /><br /></p>'; |
---|
204 | foreach($users as $user) |
---|
205 | { |
---|
206 | $count++; |
---|
207 | extract($user); |
---|
208 | |
---|
209 | // Make Nice Variables |
---|
210 | $username = $wpdb->escape($username); |
---|
211 | $name = $wpdb->escape($name); |
---|
212 | |
---|
213 | if($uinfo = get_userdatabylogin($username)) |
---|
214 | { |
---|
215 | |
---|
216 | $ret_id = wp_insert_user(array( |
---|
217 | 'ID' => $uinfo->ID, |
---|
218 | 'user_login' => $username, |
---|
219 | 'user_nicename' => $name, |
---|
220 | 'user_email' => $email, |
---|
221 | 'user_url' => 'http://', |
---|
222 | 'display_name' => $name) |
---|
223 | ); |
---|
224 | } |
---|
225 | else |
---|
226 | { |
---|
227 | $ret_id = wp_insert_user(array( |
---|
228 | 'user_login' => $username, |
---|
229 | 'user_nicename' => $name, |
---|
230 | 'user_email' => $email, |
---|
231 | 'user_url' => 'http://', |
---|
232 | 'display_name' => $name) |
---|
233 | ); |
---|
234 | } |
---|
235 | $jawsid2wpid[$user_id] = $ret_id; |
---|
236 | |
---|
237 | // Set Jaws-to-WordPress permissions translation |
---|
238 | $transperms = array(0 => '10', 1 => '9', 2 => '4'); |
---|
239 | |
---|
240 | // Update Usermeta Data |
---|
241 | $user = new WP_User($ret_id); |
---|
242 | if('10' == $transperms[$privs]) { $user->set_role('administrator'); } |
---|
243 | if('9' == $transperms[$privs]) { $user->set_role('editor'); } |
---|
244 | if('5' == $transperms[$privs]) { $user->set_role('editor'); } |
---|
245 | if('4' == $transperms[$privs]) { $user->set_role('author'); } |
---|
246 | if('3' == $transperms[$privs]) { $user->set_role('contributor'); } |
---|
247 | if('2' == $transperms[$privs]) { $user->set_role('contributor'); } |
---|
248 | if('0' == $transperms[$privs]) { $user->set_role('subscriber'); } |
---|
249 | |
---|
250 | update_usermeta( $ret_id, 'wp_user_level', $transperms[$privs] ); |
---|
251 | update_usermeta( $ret_id, 'rich_editing', 'false'); |
---|
252 | }// End foreach($users as $user) |
---|
253 | |
---|
254 | // Store id translation array for future use |
---|
255 | add_option('jawsid2wpid',$jawsid2wpid); |
---|
256 | |
---|
257 | echo '<p>'.sprintf(__('Done! <strong>%1$s</strong> users imported.'), $count).'<br /><br /></p>'; |
---|
258 | return true; |
---|
259 | }// End if(is_array($users) |
---|
260 | |
---|
261 | echo __('No Users to Import!'); |
---|
262 | return false; |
---|
263 | |
---|
264 | }// End function user2wp() |
---|
265 | |
---|
266 | function posts2wp($posts='') |
---|
267 | { |
---|
268 | // General Housekeeping |
---|
269 | global $wpdb; |
---|
270 | $count = 0; |
---|
271 | $jawsposts2wpposts = array(); |
---|
272 | $jawscat2wpcat = get_option('jawscat2wpcat'); |
---|
273 | $jawsid2wpid = get_option('jawsid2wpid'); |
---|
274 | |
---|
275 | // Do the Magic |
---|
276 | if(is_array($posts)) |
---|
277 | { |
---|
278 | echo '<p>'.__('Importing Posts...').'<br /><br /></p>'; |
---|
279 | foreach($posts as $post) |
---|
280 | { |
---|
281 | $count++; |
---|
282 | extract($post); |
---|
283 | |
---|
284 | // Set Jaws-to-WordPress status translation |
---|
285 | $stattrans = array(0 => 'draft', 1 => 'publish'); |
---|
286 | |
---|
287 | //Can we do this more efficiently? |
---|
288 | $uinfo = ( get_userdatabylogin( $user_id ) ) ? get_userdatabylogin( $user_id ) : 1; |
---|
289 | $authorid = ( is_object( $uinfo ) ) ? $uinfo->ID : $uinfo ; |
---|
290 | |
---|
291 | $Title = $wpdb->escape($title); |
---|
292 | $Body = $wpdb->escape($text); |
---|
293 | //$Excerpt = $wpdb->escape($Excerpt); |
---|
294 | $Excerpt = ""; //TODO: calculate it somehow |
---|
295 | $post_status = $stattrans[$published]; |
---|
296 | |
---|
297 | // Import Post data into WordPress |
---|
298 | |
---|
299 | if($pinfo = post_exists($Title,$Body)) |
---|
300 | { |
---|
301 | $ret_id = wp_insert_post(array( |
---|
302 | 'ID' => $pinfo, |
---|
303 | 'post_date' => $createtime, |
---|
304 | 'post_date_gmt' => $createtime, |
---|
305 | 'post_author' => $jawsid2wpid[$user_id], |
---|
306 | 'post_modified' => $updatetime, |
---|
307 | 'post_modified_gmt' => $updatetime, |
---|
308 | 'post_title' => $Title, |
---|
309 | 'post_content' => $Body, |
---|
310 | 'post_excerpt' => $Excerpt, |
---|
311 | 'post_status' => $post_status, |
---|
312 | 'post_name' => $fast_url, |
---|
313 | 'comment_count' => $comments) |
---|
314 | ); |
---|
315 | } |
---|
316 | else |
---|
317 | { |
---|
318 | $ret_id = wp_insert_post(array( |
---|
319 | 'post_date' => $createtime, |
---|
320 | 'post_date_gmt' => $createtime, |
---|
321 | 'post_author' => $jawsid2wpid[$user_id], |
---|
322 | 'post_modified' => $updatetime, |
---|
323 | 'post_modified_gmt' => $updatetime, |
---|
324 | 'post_title' => $Title, |
---|
325 | 'post_content' => $Body, |
---|
326 | 'post_excerpt' => $Excerpt, |
---|
327 | 'post_status' => $post_status, |
---|
328 | 'post_name' => $fast_url, |
---|
329 | 'comment_count' => $comments) |
---|
330 | ); |
---|
331 | } |
---|
332 | $jawsposts2wpposts[$post_id] = $ret_id; |
---|
333 | |
---|
334 | // Make Post-to-Category associations |
---|
335 | $categories = array(); |
---|
336 | $cats = array(); |
---|
337 | $categories = $this->get_jaws_post_categories($post_id); |
---|
338 | |
---|
339 | if(!empty($categories)) |
---|
340 | { |
---|
341 | $cat_index = 0; |
---|
342 | foreach ($categories as $category) { |
---|
343 | $cats[$cat_index] = $jawscat2wpcat[$category['cat_id']]; |
---|
344 | $cat_index++; |
---|
345 | } |
---|
346 | |
---|
347 | wp_set_post_categories($ret_id, $cats); |
---|
348 | } |
---|
349 | } |
---|
350 | } |
---|
351 | // Store ID translation for later use |
---|
352 | add_option('jawsposts2wpposts',$jawsposts2wpposts); |
---|
353 | |
---|
354 | echo '<p>'.sprintf(__('Done! <strong>%1$s</strong> posts imported.'), $count).'<br /><br /></p>'; |
---|
355 | return true; |
---|
356 | } |
---|
357 | |
---|
358 | function comments2wp($comments='') |
---|
359 | { |
---|
360 | // General Housekeeping |
---|
361 | global $wpdb; |
---|
362 | $count = 0; |
---|
363 | $jawscm2wpcm = array(); |
---|
364 | $postarr = get_option('jawsposts2wpposts'); |
---|
365 | |
---|
366 | // Magic Mojo |
---|
367 | if(is_array($comments)) |
---|
368 | { |
---|
369 | echo '<p>'.__('Importing Comments...').'<br /><br /></p>'; |
---|
370 | foreach($comments as $comment) |
---|
371 | { |
---|
372 | $count++; |
---|
373 | extract($comment); |
---|
374 | |
---|
375 | // WordPressify Data |
---|
376 | $comment_ID = ltrim($id, '0'); |
---|
377 | $comment_post_ID = $postarr[$gadget_reference]; |
---|
378 | //$comment_approved = ('approved' == $status) ? 1 : 0; |
---|
379 | $comment_approved = 1; //TODO: check |
---|
380 | $name = $wpdb->escape($name); |
---|
381 | $email = $wpdb->escape($email); |
---|
382 | $web = $wpdb->escape($url); |
---|
383 | $message = $wpdb->escape($message); |
---|
384 | |
---|
385 | if($cinfo = comment_exists($name, $createtime)) |
---|
386 | { |
---|
387 | // Update comments |
---|
388 | $ret_id = wp_update_comment(array( |
---|
389 | 'comment_ID' => $cinfo, |
---|
390 | 'comment_post_ID' => $comment_post_ID, |
---|
391 | 'comment_author' => $name, |
---|
392 | 'comment_author_email' => $email, |
---|
393 | 'comment_author_url' => $web, |
---|
394 | 'comment_date' => $posted, |
---|
395 | 'comment_content' => $message, |
---|
396 | 'comment_approved' => $comment_approved, |
---|
397 | 'comment_parent' => $postarr[$parent]) |
---|
398 | ); |
---|
399 | } |
---|
400 | else |
---|
401 | { |
---|
402 | // Insert comments |
---|
403 | $ret_id = wp_insert_comment(array( |
---|
404 | 'comment_post_ID' => $comment_post_ID, |
---|
405 | 'comment_author' => $name, |
---|
406 | 'comment_author_email' => $email, |
---|
407 | 'comment_author_url' => $web, |
---|
408 | 'comment_author_IP' => $ip, |
---|
409 | 'comment_date' => $posted, |
---|
410 | 'comment_content' => $message, |
---|
411 | 'comment_approved' => $comment_approved, |
---|
412 | 'comment_parent' => $postarr[$parent]) |
---|
413 | ); |
---|
414 | } |
---|
415 | $jawscm2wpcm[$comment_id] = $ret_id; |
---|
416 | } |
---|
417 | // Store Comment ID translation for future use |
---|
418 | add_option('jawscm2wpcm', $jawscm2wpcm); |
---|
419 | |
---|
420 | // Associate newly formed categories with posts |
---|
421 | get_comment_count($ret_id); |
---|
422 | |
---|
423 | |
---|
424 | echo '<p>'.sprintf(__('Done! <strong>%1$s</strong> comments imported.'), $count).'<br /><br /></p>'; |
---|
425 | return true; |
---|
426 | } |
---|
427 | echo __('No Comments to Import!'); |
---|
428 | return false; |
---|
429 | } |
---|
430 | |
---|
431 | function links2wp($links='') |
---|
432 | { |
---|
433 | // General Housekeeping |
---|
434 | global $wpdb; |
---|
435 | $count = 0; |
---|
436 | |
---|
437 | // Deal with the links |
---|
438 | if(is_array($links)) |
---|
439 | { |
---|
440 | echo '<p>'.__('Importing Links (Friends)...').'<br /><br /></p>'; |
---|
441 | foreach($links as $link) |
---|
442 | { |
---|
443 | $count++; |
---|
444 | extract($link); |
---|
445 | |
---|
446 | // Make nice vars |
---|
447 | $category = $wpdb->escape("Blogroll"); |
---|
448 | $linkname = $wpdb->escape($friend); |
---|
449 | $description = ""; |
---|
450 | |
---|
451 | if($linfo = link_exists($linkname)) |
---|
452 | { |
---|
453 | $ret_id = wp_insert_link(array( |
---|
454 | 'link_id' => $linfo, |
---|
455 | 'link_url' => $url, |
---|
456 | 'link_name' => $linkname, |
---|
457 | 'link_category' => $category, |
---|
458 | 'link_description' => $description, |
---|
459 | 'link_updated' => time()) |
---|
460 | ); |
---|
461 | } |
---|
462 | else |
---|
463 | { |
---|
464 | $ret_id = wp_insert_link(array( |
---|
465 | 'link_url' => $url, |
---|
466 | 'link_name' => $linkname, |
---|
467 | 'link_category' => $category, |
---|
468 | 'link_description' => $description, |
---|
469 | 'link_updated' => time()) |
---|
470 | ); |
---|
471 | } |
---|
472 | $jawslinks2wplinks[$id] = $ret_id; |
---|
473 | } |
---|
474 | add_option('jawslinks2wplinks',$jawslinks2wplinks); |
---|
475 | echo '<p>'; |
---|
476 | printf(__('Done! <strong>%s</strong> Links (Friends) imported'), $count); |
---|
477 | echo '<br /><br /></p>'; |
---|
478 | return true; |
---|
479 | } |
---|
480 | echo __('No Links to Import!'); |
---|
481 | return false; |
---|
482 | } |
---|
483 | |
---|
484 | function import_categories() |
---|
485 | { |
---|
486 | // Category Import |
---|
487 | $cats = $this->get_jaws_cats(); |
---|
488 | $this->cat2wp($cats); |
---|
489 | add_option('jaws_cats', $cats); |
---|
490 | |
---|
491 | |
---|
492 | |
---|
493 | echo '<form action="admin.php?import=jaws&step=2" method="post">'; |
---|
494 | printf('<input type="submit" name="submit" value="%s" />', __('Import Users')); |
---|
495 | echo '</form>'; |
---|
496 | |
---|
497 | } |
---|
498 | |
---|
499 | function import_users() |
---|
500 | { |
---|
501 | // User Import |
---|
502 | $users = $this->get_jaws_users(); |
---|
503 | $this->users2wp($users); |
---|
504 | |
---|
505 | echo '<form action="admin.php?import=jaws&step=3" method="post">'; |
---|
506 | printf('<input type="submit" name="submit" value="%s" />', __('Import Posts')); |
---|
507 | echo '</form>'; |
---|
508 | } |
---|
509 | |
---|
510 | function import_posts() |
---|
511 | { |
---|
512 | // Post Import |
---|
513 | $posts = $this->get_jaws_posts(); |
---|
514 | $this->posts2wp($posts); |
---|
515 | |
---|
516 | echo '<form action="admin.php?import=jaws&step=4" method="post">'; |
---|
517 | printf('<input type="submit" name="submit" value="%s" />', __('Import Comments')); |
---|
518 | echo '</form>'; |
---|
519 | } |
---|
520 | |
---|
521 | function import_comments() |
---|
522 | { |
---|
523 | // Comment Import |
---|
524 | $comments = $this->get_jaws_comments(); |
---|
525 | $this->comments2wp($comments); |
---|
526 | |
---|
527 | echo '<form action="admin.php?import=jaws&step=5" method="post">'; |
---|
528 | printf('<input type="submit" name="submit" value="%s" />', __('Import Links')); |
---|
529 | echo '</form>'; |
---|
530 | } |
---|
531 | |
---|
532 | function import_links() |
---|
533 | { |
---|
534 | //Link Import |
---|
535 | $links = $this->get_jaws_links(); |
---|
536 | $this->links2wp($links); |
---|
537 | add_option('jaws_links', $links); |
---|
538 | |
---|
539 | echo '<form action="admin.php?import=jaws&step=6" method="post">'; |
---|
540 | printf('<input type="submit" name="submit" value="%s" />', __('Finish')); |
---|
541 | echo '</form>'; |
---|
542 | } |
---|
543 | |
---|
544 | function cleanup_txpimport() |
---|
545 | { |
---|
546 | delete_option('tpre'); |
---|
547 | delete_option('jaws_cats'); |
---|
548 | delete_option('jawsid2wpid'); |
---|
549 | delete_option('jawscat2wpcat'); |
---|
550 | delete_option('jawsposts2wpposts'); |
---|
551 | delete_option('jawscm2wpcm'); |
---|
552 | delete_option('jawslinks2wplinks'); |
---|
553 | delete_option('jawsuser'); |
---|
554 | delete_option('jawspass'); |
---|
555 | delete_option('jawsname'); |
---|
556 | delete_option('jawshost'); |
---|
557 | $this->tips(); |
---|
558 | } |
---|
559 | |
---|
560 | function tips() |
---|
561 | { |
---|
562 | echo '<p>'.__('Welcome to WordPress. We hope (and expect!) that you will find this platform incredibly rewarding! As a new WordPress user coming from Jaws, there are some things that we would like to point out. Hopefully, they will help your transition go as smoothly as possible.').'</p>'; |
---|
563 | echo '<h3>'.__('Users').'</h3>'; |
---|
564 | echo '<p>'.sprintf(__('You have already setup WordPress and have been assigned an administrative login and password. Forget it. You didn\'t have that login in Jaws, why should you have it here? Instead we have taken care to import all of your users into our system. Unfortunately there is one downside. Because both WordPress and Jaws uses a strong encryption hash with passwords, it is impossible to decrypt it and we are forced to assign temporary passwords to all your users. <strong>Every user has the same username, but their passwords are reset to password123.</strong> So <a href="%1$s">Login</a> and change it.'), '/wp-login.php').'</p>'; |
---|
565 | echo '<h3>'.__('Preserving Authors').'</h3>'; |
---|
566 | echo '<p>'.__('Secondly, we have attempted to preserve post authors. If you are the only author or contributor to your blog, then you are safe. In most cases, we are successful in this preservation endeavor. However, if we cannot ascertain the name of the writer due to discrepancies between database tables, we assign it to you, the administrative user.').'</p>'; |
---|
567 | echo '<h3>'.__('Textile').'</h3>'; |
---|
568 | echo '<p>'.__('Also, since you\'re coming from Jaws, you probably have been using Textile to format your comments and posts. If this is the case, we recommend downloading and installing <a href="http://www.huddledmasses.org/category/development/wordpress/textile/">Textile for WordPress</a>. Trust me... You\'ll want it.').'</p>'; |
---|
569 | echo '<h3>'.__('WordPress Resources').'</h3>'; |
---|
570 | echo '<p>'.__('Finally, there are numerous WordPress resources around the internet. Some of them are:').'</p>'; |
---|
571 | echo '<ul>'; |
---|
572 | echo '<li>'.__('<a href="http://www.wordpress.org">The official WordPress site</a>').'</li>'; |
---|
573 | echo '<li>'.__('<a href="http://wordpress.org/support/">The WordPress support forums</a>').'</li>'; |
---|
574 | echo '<li>'.__('<a href="http://codex.wordpress.org">The Codex (In other words, the WordPress Bible)</a>').'</li>'; |
---|
575 | echo '</ul>'; |
---|
576 | echo '<p>'.sprintf(__('That\'s it! What are you waiting for? Go <a href="%1$s">login</a>!'), '/wp-login.php').'</p>'; |
---|
577 | } |
---|
578 | |
---|
579 | function db_form() |
---|
580 | { |
---|
581 | echo '<table class="editform">'; |
---|
582 | printf('<tr><th scope="row"><label for="dbuser">%s</label></th><td><input type="text" name="dbuser" id="dbuser" /></td></tr>', __('Jaws Database User:')); |
---|
583 | printf('<tr><th scope="row"><label for="dbpass">%s</label></th><td><input type="password" name="dbpass" id="dbpass" /></td></tr>', __('Jaws Database Password:')); |
---|
584 | printf('<tr><th scope="row"><label for="dbname">%s</label></th><td><input type="text" id="dbname" name="dbname" /></td></tr>', __('Jaws Database Name:')); |
---|
585 | printf('<tr><th scope="row"><label for="dbhost">%s</label></th><td><input type="text" id="dbhost" name="dbhost" value="localhost" /></td></tr>', __('Jaws Database Host:')); |
---|
586 | printf('<tr><th scope="row"><label for="dbprefix">%s</label></th><td><input type="text" name="dbprefix" id="dbprefix" value="jaws_"/></td></tr>', __('Jaws Table prefix (if any):')); |
---|
587 | echo '</table>'; |
---|
588 | } |
---|
589 | |
---|
590 | function dispatch() |
---|
591 | { |
---|
592 | |
---|
593 | if (empty ($_GET['step'])) |
---|
594 | $step = 0; |
---|
595 | else |
---|
596 | $step = (int) $_GET['step']; |
---|
597 | $this->header(); |
---|
598 | |
---|
599 | if ( $step > 0 ) |
---|
600 | { |
---|
601 | if($_POST['dbuser']) |
---|
602 | { |
---|
603 | if(get_option('jawsuser')) |
---|
604 | delete_option('jawsuser'); |
---|
605 | add_option('jawsuser',$_POST['dbuser']); |
---|
606 | } |
---|
607 | if($_POST['dbpass']) |
---|
608 | { |
---|
609 | if(get_option('jawspass')) |
---|
610 | delete_option('jawspass'); |
---|
611 | add_option('jawspass',$_POST['dbpass']); |
---|
612 | } |
---|
613 | |
---|
614 | if($_POST['dbname']) |
---|
615 | { |
---|
616 | if(get_option('jawsname')) |
---|
617 | delete_option('jawsname'); |
---|
618 | add_option('jawsname',$_POST['dbname']); |
---|
619 | } |
---|
620 | if($_POST['dbhost']) |
---|
621 | { |
---|
622 | if(get_option('jawshost')) |
---|
623 | delete_option('jawshost'); |
---|
624 | add_option('jawshost',$_POST['dbhost']); |
---|
625 | } |
---|
626 | if($_POST['dbprefix']) |
---|
627 | { |
---|
628 | if(get_option('tpre')) |
---|
629 | delete_option('tpre'); |
---|
630 | add_option('tpre',$_POST['dbprefix']); |
---|
631 | } |
---|
632 | |
---|
633 | |
---|
634 | } |
---|
635 | |
---|
636 | switch ($step) |
---|
637 | { |
---|
638 | default: |
---|
639 | case 0 : |
---|
640 | $this->greet(); |
---|
641 | break; |
---|
642 | case 1 : |
---|
643 | $this->import_categories(); |
---|
644 | break; |
---|
645 | case 2 : |
---|
646 | $this->import_users(); |
---|
647 | break; |
---|
648 | case 3 : |
---|
649 | $this->import_posts(); |
---|
650 | break; |
---|
651 | case 4 : |
---|
652 | $this->import_comments(); |
---|
653 | break; |
---|
654 | case 5 : |
---|
655 | $this->import_links(); |
---|
656 | break; |
---|
657 | case 6 : |
---|
658 | $this->cleanup_txpimport(); |
---|
659 | break; |
---|
660 | } |
---|
661 | |
---|
662 | $this->footer(); |
---|
663 | } |
---|
664 | |
---|
665 | function Jaws_Import() |
---|
666 | { |
---|
667 | // Nothing. |
---|
668 | } |
---|
669 | } |
---|
670 | |
---|
671 | $jaws_import = new Jaws_Import(); |
---|
672 | register_importer('jaws', __('Jaws'), __('Import categories, users, posts, comments, and links from a Jaws blog'), array ($jaws_import, 'dispatch')); |
---|
673 | ?> |
---|