Changeset 4495 for trunk/wp-admin/import/dotclear.php
- Timestamp:
- 11/19/2006 07:56:05 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/import/dotclear.php
r4424 r4495 10 10 if(!function_exists('get_catbynicename')) 11 11 { 12 function get_catbynicename($category_nicename) 12 function get_catbynicename($category_nicename) 13 13 { 14 14 global $wpdb; … … 61 61 // This cries out for a C-implementation to be included in PHP core 62 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 } 63 64 function valid_1byte($char) { 65 if(!is_int($char)) return false; 66 return ($char & 0x80) == 0x00; 67 } 68 69 function valid_2byte($char) { 70 if(!is_int($char)) return false; 71 return ($char & 0xE0) == 0xC0; 72 } 73 74 function valid_3byte($char) { 75 if(!is_int($char)) return false; 76 return ($char & 0xF0) == 0xE0; 77 } 78 79 function valid_4byte($char) { 80 if(!is_int($char)) return false; 81 return ($char & 0xF8) == 0xF0; 82 } 83 84 function valid_nextbyte($char) { 85 if(!is_int($char)) return false; 86 return ($char & 0xC0) == 0x80; 87 } 88 89 function valid_utf8($string) { 90 $len = strlen($string); 91 $i = 0; 92 while( $i < $len ) { 93 $char = ord(substr($string, $i++, 1)); 94 if(valid_1byte($char)) { // continue 95 continue; 96 } else if(valid_2byte($char)) { // check 1 byte 97 if(!valid_nextbyte(ord(substr($string, $i++, 1)))) 98 return false; 99 } else if(valid_3byte($char)) { // check 2 bytes 100 if(!valid_nextbyte(ord(substr($string, $i++, 1)))) 101 return false; 102 if(!valid_nextbyte(ord(substr($string, $i++, 1)))) 103 return false; 104 } else if(valid_4byte($char)) { // check 3 bytes 105 if(!valid_nextbyte(ord(substr($string, $i++, 1)))) 106 return false; 107 if(!valid_nextbyte(ord(substr($string, $i++, 1)))) 108 return false; 109 if(!valid_nextbyte(ord(substr($string, $i++, 1)))) 110 return false; 111 } // goto next char 112 } 113 return true; // done 114 } 114 115 115 116 function csc ($s) { … … 152 153 } 153 154 154 function get_dc_cats() 155 function get_dc_cats() 155 156 { 156 157 global $wpdb; … … 187 188 return $dcdb->get_results('SELECT '.$dbprefix.'post.*, '.$dbprefix.'categorie.cat_libelle_url AS post_cat_name 188 189 FROM '.$dbprefix.'post INNER JOIN '.$dbprefix.'categorie 189 190 ON '.$dbprefix.'post.cat_id = '.$dbprefix.'categorie.cat_id', ARRAY_A); 190 191 } 191 192 … … 212 213 } 213 214 214 function cat2wp($categories='') 215 function cat2wp($categories='') 215 216 { 216 217 // General Housekeeping … … 222 223 { 223 224 echo '<p>'.__('Importing Categories...').'<br /><br /></p>'; 224 foreach ($categories as $category) 225 foreach ($categories as $category) 225 226 { 226 227 $count++; … … 284 285 ); 285 286 } 286 else 287 else 287 288 { 288 289 $ret_id = wp_insert_user(array( … … 385 386 ); 386 387 } 387 else 388 else 388 389 { 389 390 $ret_id = wp_insert_post(array( … … 461 462 ); 462 463 } 463 else 464 else 464 465 { 465 466 // Insert comments … … 548 549 } 549 550 550 function import_categories() 551 function import_categories() 551 552 { 552 553 // Category Import … … 566 567 { 567 568 // User Import 568 $users = $this->get_dc_users(); 569 $users = $this->get_dc_users(); 569 570 $this->users2wp($users); 570 571 … … 656 657 } 657 658 658 function dispatch() 659 function dispatch() 659 660 { 660 661 … … 665 666 $this->header(); 666 667 667 if ( $step > 0 ) 668 if ( $step > 0 ) 668 669 { 669 670 if($_POST['dbuser']) … … 690 691 if(get_option('dchost')) 691 692 delete_option('dchost'); 692 add_option('dchost',$_POST['dbhost']); 693 add_option('dchost',$_POST['dbhost']); 693 694 } 694 695 if($_POST['dccharset']) … … 696 697 if(get_option('dccharset')) 697 698 delete_option('dccharset'); 698 add_option('dccharset',$_POST['dccharset']); 699 add_option('dccharset',$_POST['dccharset']); 699 700 } 700 701 if($_POST['dbprefix']) … … 702 703 if(get_option('dcdbprefix')) 703 704 delete_option('dcdbprefix'); 704 add_option('dcdbprefix',$_POST['dbprefix']); 705 add_option('dcdbprefix',$_POST['dbprefix']); 705 706 } 706 707 … … 708 709 } 709 710 710 switch ($step) 711 switch ($step) 711 712 { 712 713 default: … … 737 738 } 738 739 739 function Dotclear_Import() 740 function Dotclear_Import() 740 741 { 741 742 // Nothing.
Note: See TracChangeset
for help on using the changeset viewer.