mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-23 17:48:01 +01:00
Allow gzipped files for MT/TypePad import. Props mtdewvirus. fixes #7971
git-svn-id: http://svn.automattic.com/wordpress/trunk@9358 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
296afd1941
commit
2ef93d9391
@ -69,9 +69,36 @@ class MT_Import {
|
||||
</select>
|
||||
<?php
|
||||
|
||||
|
||||
}
|
||||
|
||||
function has_gzip() {
|
||||
return is_callable('gzopen');
|
||||
}
|
||||
|
||||
function fopen($filename, $mode='r') {
|
||||
if ( $this->has_gzip() )
|
||||
return gzopen($filename, $mode);
|
||||
return fopen($filename, $mode);
|
||||
}
|
||||
|
||||
function feof($fp) {
|
||||
if ( $this->has_gzip() )
|
||||
return gzeof($fp);
|
||||
return feof($fp);
|
||||
}
|
||||
|
||||
function fgets($fp, $len=8192) {
|
||||
if ( $this->has_gzip() )
|
||||
return gzgets($fp, $len);
|
||||
return fgets($fp, $len);
|
||||
}
|
||||
|
||||
function fclose($fp) {
|
||||
if ( $this->has_gzip() )
|
||||
return gzclose($fp);
|
||||
return fclose($fp);
|
||||
}
|
||||
|
||||
//function to check the authorname and do the mapping
|
||||
function checkauthor($author) {
|
||||
global $wpdb;
|
||||
@ -103,12 +130,12 @@ class MT_Import {
|
||||
$temp = array();
|
||||
$authors = array();
|
||||
|
||||
$handle = fopen($this->file, 'r');
|
||||
$handle = $this->fopen($this->file, 'r');
|
||||
if ( $handle == null )
|
||||
return false;
|
||||
|
||||
$in_comment = false;
|
||||
while ( $line = fgets($handle) ) {
|
||||
while ( $line = $this->fgets($handle) ) {
|
||||
$line = trim($line);
|
||||
|
||||
if ( 'COMMENT:' == $line )
|
||||
@ -131,7 +158,7 @@ class MT_Import {
|
||||
array_push($authors, "$next");
|
||||
}
|
||||
|
||||
fclose($handle);
|
||||
$this->fclose($handle);
|
||||
|
||||
return $authors;
|
||||
}
|
||||
@ -286,7 +313,7 @@ class MT_Import {
|
||||
function process_posts() {
|
||||
global $wpdb;
|
||||
|
||||
$handle = fopen($this->file, 'r');
|
||||
$handle = $this->fopen($this->file, 'r');
|
||||
if ( $handle == null )
|
||||
return false;
|
||||
|
||||
@ -299,7 +326,7 @@ class MT_Import {
|
||||
|
||||
echo "<div class='wrap'><ol>";
|
||||
|
||||
while ( $line = fgets($handle) ) {
|
||||
while ( $line = $this->fgets($handle) ) {
|
||||
$line = trim($line);
|
||||
|
||||
if ( '-----' == $line ) {
|
||||
@ -428,6 +455,8 @@ class MT_Import {
|
||||
}
|
||||
}
|
||||
|
||||
$this->fclose($handle);
|
||||
|
||||
echo '</ol>';
|
||||
|
||||
wp_import_cleanup($this->id);
|
||||
|
Loading…
Reference in New Issue
Block a user