[ Index ]

WordPress Source Cross Reference

title

Body

[close]

/wp-admin/import/ -> dotclear.php (source)

   1  <?php
   2  /*
   3   * Dotclear import plugin
   4   * by Thomas Quinot - http://thomas.quinot.org/
   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_cat_exists'))
  33  {
  34  	function link_cat_exists($catname)
  35      {
  36          global $wpdb;
  37          return $wpdb->get_var('SELECT cat_id FROM '.$wpdb->linkcategories.' WHERE cat_name = "'.$wpdb->escape($catname).'"');
  38      }
  39  }
  40  
  41  if(!function_exists('link_exists'))
  42  {
  43  	function link_exists($linkname)
  44      {
  45          global $wpdb;
  46          return $wpdb->get_var('SELECT link_id FROM '.$wpdb->links.' WHERE link_name = "'.$linkname.'"');
  47      }
  48  }
  49  
  50  /*
  51   Identify UTF-8 text
  52   Taken from http://www.php.net/manual/fr/function.mb-detect-encoding.php#50087
  53  */
  54  //
  55  //    utf8 encoding validation developed based on Wikipedia entry at:
  56  //    http://en.wikipedia.org/wiki/UTF-8
  57  //
  58  //    Implemented as a recursive descent parser based on a simple state machine
  59  //    copyright 2005 Maarten Meijer
  60  //
  61  //    This cries out for a C-implementation to be included in PHP core
  62  //
  63     function valid_1byte($char) {
  64         if(!is_int($char)) return false;
  65         return ($char & 0x80) == 0x00;
  66     }
  67    
  68     function valid_2byte($char) {
  69         if(!is_int($char)) return false;
  70         return ($char & 0xE0) == 0xC0;
  71     }
  72  
  73     function valid_3byte($char) {
  74         if(!is_int($char)) return false;
  75         return ($char & 0xF0) == 0xE0;
  76     }
  77  
  78     function valid_4byte($char) {
  79         if(!is_int($char)) return false;
  80         return ($char & 0xF8) == 0xF0;
  81     }
  82    
  83     function valid_nextbyte($char) {
  84         if(!is_int($char)) return false;
  85         return ($char & 0xC0) == 0x80;
  86     }
  87    
  88     function valid_utf8($string) {
  89         $len = strlen($string);
  90         $i = 0;   
  91         while( $i < $len ) {
  92             $char = ord(substr($string, $i++, 1));
  93             if(valid_1byte($char)) {    // continue
  94                 continue;
  95             } else if(valid_2byte($char)) { // check 1 byte
  96                 if(!valid_nextbyte(ord(substr($string, $i++, 1))))
  97                     return false;
  98             } else if(valid_3byte($char)) { // check 2 bytes
  99                 if(!valid_nextbyte(ord(substr($string, $i++, 1))))
 100                     return false;
 101                 if(!valid_nextbyte(ord(substr($string, $i++, 1))))
 102                     return false;
 103             } else if(valid_4byte($char)) { // check 3 bytes
 104                 if(!valid_nextbyte(ord(substr($string, $i++, 1))))
 105                     return false;
 106                 if(!valid_nextbyte(ord(substr($string, $i++, 1))))
 107                     return false;
 108                 if(!valid_nextbyte(ord(substr($string, $i++, 1))))
 109                     return false;
 110             } // goto next char
 111         }
 112         return true; // done
 113     }
 114  
 115  function csc ($s) {
 116      if (valid_utf8 ($s)) {
 117          return $s;
 118      } else {
 119          return iconv(get_option ("dccharset"),"UTF-8",$s);
 120      }
 121  }
 122  
 123  function textconv ($s) {
 124      return csc (preg_replace ('|(?<!<br />)\s*\n|', ' ', $s));
 125  }
 126  
 127  /**
 128      The Main Importer Class
 129  **/
 130  class Dotclear_Import {
 131  
 132  	function header() 
 133      {
 134          echo '<div class="wrap">';
 135          echo '<h2>'.__('Import Dotclear').'</h2>';
 136          echo '<p>'.__('Steps may take a few minutes depending on the size of your database. Please be patient.').'</p>';
 137      }
 138  
 139  	function footer() 
 140      {
 141          echo '</div>';
 142      }
 143  
 144  	function greet() 
 145      {
 146          echo '<p>'.__('Howdy! This importer allows you to extract posts from a Dotclear database into your blog.  Mileage may vary.').'</p>';
 147          echo '<p>'.__('Your Dotclear Configuration settings are as follows:').'</p>';
 148          echo '<form action="admin.php?import=dotclear&amp;step=1" method="post">';
 149          $this->db_form();
 150          echo '<input type="submit" name="submit" value="'.__('Import Categories').'" />';
 151          echo '</form>';
 152      }
 153  
 154  	function get_dc_cats() 
 155      {
 156          global $wpdb;
 157          // General Housekeeping
 158          $dcdb = new wpdb(get_option('dcuser'), get_option('dcpass'), get_option('dcname'), get_option('dchost'));
 159          set_magic_quotes_runtime(0);
 160          $dbprefix = get_option('dcdbprefix');
 161  
 162          // Get Categories
 163          return $dcdb->get_results('SELECT * FROM '.$dbprefix.'categorie', ARRAY_A);
 164      }
 165  
 166  	function get_dc_users()
 167      {
 168          global $wpdb;
 169          // General Housekeeping
 170          $dcdb = new wpdb(get_option('dcuser'), get_option('dcpass'), get_option('dcname'), get_option('dchost'));
 171          set_magic_quotes_runtime(0);
 172          $dbprefix = get_option('dcdbprefix');
 173  
 174          // Get Users
 175  
 176          return $dcdb->get_results('SELECT * FROM '.$dbprefix.'user', ARRAY_A);
 177      }
 178  
 179  	function get_dc_posts()
 180      {
 181          // General Housekeeping
 182          $dcdb = new wpdb(get_option('dcuser'), get_option('dcpass'), get_option('dcname'), get_option('dchost'));
 183          set_magic_quotes_runtime(0);
 184          $dbprefix = get_option('dcdbprefix');
 185  
 186          // Get Posts
 187          return $dcdb->get_results('SELECT '.$dbprefix.'post.*, '.$dbprefix.'categorie.cat_libelle_url AS post_cat_name
 188                          FROM '.$dbprefix.'post INNER JOIN '.$dbprefix.'categorie
 189                            ON '.$dbprefix.'post.cat_id = '.$dbprefix.'categorie.cat_id', ARRAY_A);
 190      }
 191  
 192  	function get_dc_comments()
 193      {
 194          global $wpdb;
 195          // General Housekeeping
 196          $dcdb = new wpdb(get_option('dcuser'), get_option('dcpass'), get_option('dcname'), get_option('dchost'));
 197          set_magic_quotes_runtime(0);
 198          $dbprefix = get_option('dcdbprefix');
 199  
 200          // Get Comments
 201          return $dcdb->get_results('SELECT * FROM '.$dbprefix.'comment', ARRAY_A);
 202      }
 203  
 204  	function get_dc_links()
 205      {
 206          //General Housekeeping
 207          $dcdb = new wpdb(get_option('dcuser'), get_option('dcpass'), get_option('dcname'), get_option('dchost'));
 208          set_magic_quotes_runtime(0);
 209          $dbprefix = get_option('dcdbprefix');
 210  
 211          return $dcdb->get_results('SELECT * FROM '.$dbprefix.'link ORDER BY position', ARRAY_A);
 212      }
 213  
 214  	function cat2wp($categories='') 
 215      {
 216          // General Housekeeping
 217          global $wpdb;
 218          $count = 0;
 219          $dccat2wpcat = array();
 220          // Do the Magic
 221          if(is_array($categories))
 222          {
 223              echo '<p>'.__('Importing Categories...').'<br /><br /></p>';
 224              foreach ($categories as $category) 
 225              {
 226                  $count++;
 227                  extract($category);
 228  
 229                  // Make Nice Variables
 230                  $name = $wpdb->escape($cat_libelle_url);
 231                  $title = $wpdb->escape(csc ($cat_libelle));
 232                  $desc = $wpdb->escape(csc ($cat_desc));
 233  
 234                  if($cinfo = category_exists($name))
 235                  {
 236                      $ret_id = wp_insert_category(array('cat_ID' => $cinfo, 'category_nicename' => $name, 'cat_name' => $title, 'category_description' => $desc));
 237                  }
 238                  else
 239                  {
 240                      $ret_id = wp_insert_category(array('category_nicename' => $name, 'cat_name' => $title, 'category_description' => $desc));
 241                  }
 242                  $dccat2wpcat[$id] = $ret_id;
 243              }
 244  
 245              // Store category translation for future use
 246              add_option('dccat2wpcat',$dccat2wpcat);
 247              echo '<p>'.sprintf(__('Done! <strong>%1$s</strong> categories imported.'), $count).'<br /><br /></p>';
 248              return true;
 249          }
 250          echo __('No Categories to Import!');
 251          return false;
 252      }
 253  
 254  	function users2wp($users='')
 255      {
 256          // General Housekeeping
 257          global $wpdb;
 258          $count = 0;
 259          $dcid2wpid = array();
 260  
 261          // Midnight Mojo
 262          if(is_array($users))
 263          {
 264              echo '<p>'.__('Importing Users...').'<br /><br /></p>';
 265              foreach($users as $user)
 266              {
 267                  $count++;
 268                  extract($user);
 269  
 270                  // Make Nice Variables
 271                  $name = $wpdb->escape(csc ($name));
 272                  $RealName = $wpdb->escape(csc ($user_pseudo));
 273  
 274                  if($uinfo = get_userdatabylogin($name))
 275                  {
 276  
 277                      $ret_id = wp_insert_user(array(
 278                                  'ID'        => $uinfo->ID,
 279                                  'user_login'    => $user_id,
 280                                  'user_nicename'    => $Realname,
 281                                  'user_email'    => $user_email,
 282                                  'user_url'    => 'http://',
 283                                  'display_name'    => $Realname)
 284                                  );
 285                  }
 286                  else 
 287                  {
 288                      $ret_id = wp_insert_user(array(
 289                                  'user_login'    => $user_id,
 290                                  'user_nicename'    => csc ($user_pseudo),
 291                                  'user_email'    => $user_email,
 292                                  'user_url'    => 'http://',
 293                                  'display_name'    => $Realname)
 294                                  );
 295                  }
 296                  $dcid2wpid[$user_id] = $ret_id;
 297  
 298                  // Set Dotclear-to-WordPress permissions translation
 299  
 300                  // Update Usermeta Data
 301                  $user = new WP_User($ret_id);
 302                  $wp_perms = $user_level + 1;
 303                  if(10 == $wp_perms) { $user->set_role('administrator'); }
 304                  else if(9  == $wp_perms) { $user->set_role('editor'); }
 305                  else if(5  <= $wp_perms) { $user->set_role('editor'); }
 306                  else if(4  <= $wp_perms) { $user->set_role('author'); }
 307                  else if(3  <= $wp_perms) { $user->set_role('contributor'); }
 308                  else if(2  <= $wp_perms) { $user->set_role('contributor'); }
 309                  else                     { $user->set_role('subscriber'); }
 310  
 311                  update_usermeta( $ret_id, 'wp_user_level', $wp_perms);
 312                  update_usermeta( $ret_id, 'rich_editing', 'false');
 313                  update_usermeta( $ret_id, 'first_name', csc ($user_prenom));
 314                  update_usermeta( $ret_id, 'last_name', csc ($user_nom));
 315              }// End foreach($users as $user)
 316  
 317              // Store id translation array for future use
 318              add_option('dcid2wpid',$dcid2wpid);
 319  
 320  
 321              echo '<p>'.sprintf(__('Done! <strong>%1$s</strong> users imported.'), $count).'<br /><br /></p>';
 322              return true;
 323          }// End if(is_array($users)
 324  
 325          echo __('No Users to Import!');
 326          return false;
 327  
 328      }// End function user2wp()
 329  
 330  	function posts2wp($posts='')
 331      {
 332          // General Housekeeping
 333          global $wpdb;
 334          $count = 0;
 335          $dcposts2wpposts = array();
 336          $cats = array();
 337  
 338          // Do the Magic
 339          if(is_array($posts))
 340          {
 341              echo '<p>'.__('Importing Posts...').'<br /><br /></p>';
 342              foreach($posts as $post)
 343              {
 344                  $count++;
 345                  extract($post);
 346  
 347                  // Set Dotclear-to-WordPress status translation
 348                  $stattrans = array(0 => 'draft', 1 => 'publish');
 349                  $comment_status_map = array (0 => 'closed', 1 => 'open');
 350  
 351                  //Can we do this more efficiently?
 352                  $uinfo = ( get_userdatabylogin( $user_id ) ) ? get_userdatabylogin( $user_id ) : 1;
 353                  $authorid = ( is_object( $uinfo ) ) ? $uinfo->ID : $uinfo ;
 354  
 355                  $Title = $wpdb->escape(csc ($post_titre));
 356                  $post_content = textconv ($post_content);
 357                  $post_excerpt = "";
 358                  if ($post_chapo != "") {
 359                      $post_excerpt = textconv ($post_chapo);
 360                      $post_content = $post_excerpt ."\n<!--more-->\n".$post_content;
 361                  }
 362                  $post_excerpt = $wpdb->escape ($post_excerpt);
 363                  $post_content = $wpdb->escape ($post_content);
 364                  $post_status = $stattrans[$post_pub];
 365  
 366                  // Import Post data into WordPress
 367  
 368                  if($pinfo = post_exists($Title,$post_content))
 369                  {
 370                      $ret_id = wp_insert_post(array(
 371                              'ID'            => $pinfo,
 372                              'post_author'        => $authorid,
 373                              'post_date'        => $post_dt,
 374                              'post_date_gmt'        => $post_dt,
 375                              'post_modified'        => $post_upddt,
 376                              'post_modified_gmt'    => $post_upddt,
 377                              'post_title'        => $Title,
 378                              'post_content'        => $post_content,
 379                              'post_excerpt'        => $post_excerpt,
 380                              'post_status'        => $post_status,
 381                              'post_name'        => $post_titre_url,
 382                              'comment_status'    => $comment_status_map[$post_open_comment],
 383                              'ping_status'        => $comment_status_map[$post_open_tb],
 384                              'comment_count'        => $post_nb_comment + $post_nb_trackback)
 385                              );
 386                  }
 387                  else 
 388                  {
 389                      $ret_id = wp_insert_post(array(
 390                              'post_author'        => $authorid,
 391                              'post_date'        => $post_dt,
 392                              'post_date_gmt'        => $post_dt,
 393                              'post_modified'        => $post_modified_gmt,
 394                              'post_modified_gmt'    => $post_modified_gmt,
 395                              'post_title'        => $Title,
 396                              'post_content'        => $post_content,
 397                              'post_excerpt'        => $post_excerpt,
 398                              'post_status'        => $post_status,
 399                              'post_name'        => $post_titre_url,
 400                              'comment_status'    => $comment_status_map[$post_open_comment],
 401                              'ping_status'        => $comment_status_map[$post_open_tb],
 402                              'comment_count'        => $post_nb_comment + $post_nb_trackback)
 403                              );
 404                  }
 405                  $dcposts2wpposts[$post_id] = $ret_id;
 406  
 407                  // Make Post-to-Category associations
 408                  $cats = array();
 409                  if($cat1 = get_catbynicename($post_cat_name)) { $cats[1] = $cat1; }
 410  
 411                  if(!empty($cats)) { wp_set_post_cats('', $ret_id, $cats); }
 412              }
 413          }
 414          // Store ID translation for later use
 415          add_option('dcposts2wpposts',$dcposts2wpposts);
 416  
 417          echo '<p>'.sprintf(__('Done! <strong>%1$s</strong> posts imported.'), $count).'<br /><br /></p>';
 418          return true;
 419      }
 420  
 421  	function comments2wp($comments='')
 422      {
 423          // General Housekeeping
 424          global $wpdb;
 425          $count = 0;
 426          $dccm2wpcm = array();
 427          $postarr = get_option('dcposts2wpposts');
 428  
 429          // Magic Mojo
 430          if(is_array($comments))
 431          {
 432              echo '<p>'.__('Importing Comments...').'<br /><br /></p>';
 433              foreach($comments as $comment)
 434              {
 435                  $count++;
 436                  extract($comment);
 437  
 438                  // WordPressify Data
 439                  $comment_ID = ltrim($comment_id, '0');
 440                  $comment_post_ID = $postarr[$post_id];
 441                  $comment_approved = "$comment_pub";
 442                  $name = $wpdb->escape(csc ($comment_auteur));
 443                  $email = $wpdb->escape($comment_email);
 444                  $web = "http://".$wpdb->escape($comment_site);
 445                  $message = $wpdb->escape(textconv ($comment_content));
 446  
 447                  if($cinfo = comment_exists($name, $comment_dt))
 448                  {
 449                      // Update comments
 450                      $ret_id = wp_update_comment(array(
 451                              'comment_ID'        => $cinfo,
 452                              'comment_post_ID'    => $comment_post_ID,
 453                              'comment_author'    => $name,
 454                              'comment_author_email'    => $email,
 455                              'comment_author_url'    => $web,
 456                              'comment_author_IP'    => $comment_ip,
 457                              'comment_date'        => $comment_dt,
 458                              'comment_date_gmt'    => $comment_dt,
 459                              'comment_content'    => $message,
 460                              'comment_approved'    => $comment_approved)
 461                              );
 462                  }
 463                  else 
 464                  {
 465                      // Insert comments
 466                      $ret_id = wp_insert_comment(array(
 467                              'comment_post_ID'    => $comment_post_ID,
 468                              'comment_author'    => $name,
 469                              'comment_author_email'    => $email,
 470                              'comment_author_url'    => $web,
 471                              'comment_author_IP'    => $comment_ip,
 472                              'comment_date'        => $comment_dt,
 473                              'comment_date_gmt'    => $comment_dt,
 474                              'comment_content'    => $message,
 475                              'comment_approved'    => $comment_approved)
 476                              );
 477                  }
 478                  $dccm2wpcm[$comment_ID] = $ret_id;
 479              }
 480              // Store Comment ID translation for future use
 481              add_option('dccm2wpcm', $dccm2wpcm);
 482  
 483              // Associate newly formed categories with posts
 484              get_comment_count($ret_id);
 485  
 486  
 487              echo '<p>'.sprintf(__('Done! <strong>%1$s</strong> comments imported.'), $count).'<br /><br /></p>';
 488              return true;
 489          }
 490          echo __('No Comments to Import!');
 491          return false;
 492      }
 493  
 494  	function links2wp($links='')
 495      {
 496          // General Housekeeping
 497          global $wpdb;
 498          $count = 0;
 499  
 500          // Deal with the links
 501          if(is_array($links))
 502          {
 503              echo '<p>'.__('Importing Links...').'<br /><br /></p>';
 504              foreach($links as $link)
 505              {
 506                  $count++;
 507                  extract($link);
 508  
 509                  if ($title != "") {
 510                      if ($cinfo = link_cat_exists (csc ($title))) {
 511                          $category = $cinfo;
 512                      } else {
 513                          $wpdb->query ("INSERT INTO $wpdb->linkcategories (cat_name) VALUES ('".
 514                              $wpdb->escape (csc ($title))."')");
 515                          $category = $wpdb->insert_id;
 516                      }
 517                  } else {
 518                      $linkname = $wpdb->escape(csc ($label));
 519                      $description = $wpdb->escape(csc ($title));
 520  
 521                      if($linfo = link_exists($linkname)) {
 522                          $ret_id = wp_insert_link(array(
 523                                      'link_id'        => $linfo,
 524                                      'link_url'        => $href,
 525                                      'link_name'        => $linkname,
 526                                      'link_category'        => $category,
 527                                      'link_description'    => $description)
 528                                      );
 529                      } else {
 530                          $ret_id = wp_insert_link(array(
 531                                      'link_url'        => $url,
 532                                      'link_name'        => $linkname,
 533                                      'link_category'        => $category,
 534                                      'link_description'    => $description)
 535                                      );
 536                      }
 537                      $dclinks2wplinks[$link_id] = $ret_id;
 538                  }
 539              }
 540              add_option('dclinks2wplinks',$dclinks2wplinks);
 541              echo '<p>';
 542              printf(__('Done! <strong>%s</strong> links or link categories imported'), $count);
 543              echo '<br /><br /></p>';
 544              return true;
 545          }
 546          echo __('No Links to Import!');
 547          return false;
 548      }
 549  
 550  	function import_categories() 
 551      {
 552          // Category Import
 553          $cats = $this->get_dc_cats();
 554          $this->cat2wp($cats);
 555          add_option('dc_cats', $cats);
 556  
 557  
 558  
 559          echo '<form action="admin.php?import=dotclear&amp;step=2" method="post">';
 560          printf('<input type="submit" name="submit" value="%s" />', __('Import Users'));
 561          echo '</form>';
 562  
 563      }
 564  
 565  	function import_users()
 566      {
 567          // User Import
 568          $users = $this->get_dc_users(); 
 569          $this->users2wp($users);
 570  
 571          echo '<form action="admin.php?import=dotclear&amp;step=3" method="post">';
 572          printf('<input type="submit" name="submit" value="%s" />', __('Import Posts'));
 573          echo '</form>';
 574      }
 575  
 576  	function import_posts()
 577      {
 578          // Post Import
 579          $posts = $this->get_dc_posts();
 580          $this->posts2wp($posts);
 581  
 582          echo '<form action="admin.php?import=dotclear&amp;step=4" method="post">';
 583          printf('<input type="submit" name="submit" value="%s" />', __('Import Comments'));
 584          echo '</form>';
 585      }
 586  
 587  	function import_comments()
 588      {
 589          // Comment Import
 590          $comments = $this->get_dc_comments();
 591          $this->comments2wp($comments);
 592  
 593          echo '<form action="admin.php?import=dotclear&amp;step=5" method="post">';
 594          printf('<input type="submit" name="submit" value="%s" />', __('Import Links'));
 595          echo '</form>';
 596      }
 597  
 598  	function import_links()
 599      {
 600          //Link Import
 601          $links = $this->get_dc_links();
 602          $this->links2wp($links);
 603          add_option('dc_links', $links);
 604  
 605          echo '<form action="admin.php?import=dotclear&amp;step=6" method="post">';
 606          printf('<input type="submit" name="submit" value="%s" />', __('Finish'));
 607          echo '</form>';
 608      }
 609  
 610  	function cleanup_dcimport()
 611      {
 612          delete_option('dcdbprefix');
 613          delete_option('dc_cats');
 614          delete_option('dcid2wpid');
 615          delete_option('dccat2wpcat');
 616          delete_option('dcposts2wpposts');
 617          delete_option('dccm2wpcm');
 618          delete_option('dclinks2wplinks');
 619          delete_option('dcuser');
 620          delete_option('dcpass');
 621          delete_option('dcname');
 622          delete_option('dchost');
 623          delete_option('dccharset');
 624          $this->tips();
 625      }
 626  
 627  	function tips()
 628      {
 629          echo '<p>'.__('Welcome to WordPress.  We hope (and expect!) that you will find this platform incredibly rewarding!  As a new WordPress user coming from Dotclear, there are some things that we would like to point out.  Hopefully, they will help your transition go as smoothly as possible.').'</p>';
 630          echo '<h3>'.__('Users').'</h3>';
 631          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 Dotclear, 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 Dotclear 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>';
 632          echo '<h3>'.__('Preserving Authors').'</h3>';
 633          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>';
 634          echo '<h3>'.__('Textile').'</h3>';
 635          echo '<p>'.__('Also, since you\'re coming from Dotclear, 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/2004/04/19/wordpress-plugin-textile-20/">Textile for WordPress</a>.  Trust me... You\'ll want it.').'</p>';
 636          echo '<h3>'.__('WordPress Resources').'</h3>';
 637          echo '<p>'.__('Finally, there are numerous WordPress resources around the internet.  Some of them are:').'</p>';
 638          echo '<ul>';
 639          echo '<li>'.__('<a href="http://www.wordpress.org">The official WordPress site</a>').'</li>';
 640          echo '<li>'.__('<a href="http://wordpress.org/support/">The WordPress support forums').'</li>';
 641          echo '<li>'.__('<a href="http://codex.wordpress.org">The Codex (In other words, the WordPress Bible)</a>').'</li>';
 642          echo '</ul>';
 643          echo '<p>'.sprintf(__('That\'s it! What are you waiting for? Go <a href="%1$s">login</a>!'), '/wp-login.php').'</p>';
 644      }
 645  
 646  	function db_form()
 647      {
 648          echo '<ul>';
 649          printf('<li><label for="dbuser">%s</label> <input type="text" name="dbuser" id="dbuser" /></li>', __('Dotclear Database User:'));
 650          printf('<li><label for="dbpass">%s</label> <input type="password" name="dbpass" id="dbpass" /></li>', __('Dotclear Database Password:'));
 651          printf('<li><label for="dbname">%s</label> <input type="text" name="dbname" id="dbname" /></li>', __('Dotclear Database Name:'));
 652          printf('<li><label for="dbhost">%s</label> <input type="text" name="dbhost" nameid="dbhost" value="localhost" /></li>', __('Dotclear Database Host:'));
 653          printf('<li><label for="dbprefix">%s</label> <input type="text" name="dbprefix" id="dbprefix" value="dc_"/></li>', __('Dotclear Table prefix:'));
 654          printf('<li><label for="dccharset">%s</label> <input type="text" name="dccharset" id="dccharset" value="ISO-8859-15"/></li>', __('Originating character set:'));
 655          echo '</ul>';
 656      }
 657  
 658  	function dispatch() 
 659      {
 660  
 661          if (empty ($_GET['step']))
 662              $step = 0;
 663          else
 664              $step = (int) $_GET['step'];
 665          $this->header();
 666  
 667          if ( $step > 0 ) 
 668          {
 669              if($_POST['dbuser'])
 670              {
 671                  if(get_option('dcuser'))
 672                      delete_option('dcuser');
 673                  add_option('dcuser',$_POST['dbuser']);
 674              }
 675              if($_POST['dbpass'])
 676              {
 677                  if(get_option('dcpass'))
 678                      delete_option('dcpass');
 679                  add_option('dcpass',$_POST['dbpass']);
 680              }
 681  
 682              if($_POST['dbname'])
 683              {
 684                  if(get_option('dcname'))
 685                      delete_option('dcname');
 686                  add_option('dcname',$_POST['dbname']);
 687              }
 688              if($_POST['dbhost'])
 689              {
 690                  if(get_option('dchost'))
 691                      delete_option('dchost');
 692                  add_option('dchost',$_POST['dbhost']); 
 693              }
 694              if($_POST['dccharset'])
 695              {
 696                  if(get_option('dccharset'))
 697                      delete_option('dccharset');
 698                  add_option('dccharset',$_POST['dccharset']); 
 699              }
 700              if($_POST['dbprefix'])
 701              {
 702                  if(get_option('dcdbprefix'))
 703                      delete_option('dcdbprefix');
 704                  add_option('dcdbprefix',$_POST['dbprefix']); 
 705              }
 706  
 707  
 708          }
 709  
 710          switch ($step) 
 711          {
 712              default:
 713              case 0 :
 714                  $this->greet();
 715                  break;
 716              case 1 :
 717                  $this->import_categories();
 718                  break;
 719              case 2 :
 720                  $this->import_users();
 721                  break;
 722              case 3 :
 723                  $this->import_posts();
 724                  break;
 725              case 4 :
 726                  $this->import_comments();
 727                  break;
 728              case 5 :
 729                  $this->import_links();
 730                  break;
 731              case 6 :
 732                  $this->cleanup_dcimport();
 733                  break;
 734          }
 735  
 736          $this->footer();
 737      }
 738  
 739  	function Dotclear_Import() 
 740      {
 741          // Nothing.
 742      }
 743  }
 744  
 745  $dc_import = new Dotclear_Import();
 746  register_importer('dotclear', 'Dotclear', __('Import posts from a Dotclear Blog'), array ($dc_import, 'dispatch'));
 747  ?>

Your comment here...

Name: Location:
Comments:


List: Classes | Functions | Variables | Constants | Tables

Generated: Sat Jul 15 11:57:04 2006 Courtesy of Taragana