I wanted to share this with the community. I wrote this function to fix quotes in imported posts so they wouldn't show the unparsable SMF style quote code and the view post button next to the author's name would work. It uses the importpostid column to lookup the new postid. There are no guarantees on this, so make sure to test it out before doing the real import.
In the # Posts section of cleaner.php find
Add after
In the # PM text section of cleaner.php find
Add after
Place this at the bottom of cleaner.php
If interested I also used the following for the replacer varaibles
In the # Posts section of cleaner.php find
Code:
$text = str_replace(array_keys($replacer), $replacer, $post['pagetext']);
Code:
$text = parse_quote($text);
Code:
$text = str_replace(array_keys($replacer), $replacer, $pm['message']);
Code:
$text = parse_quote($text);
Code:
function parse_quote($post) { global $Db_target, $targettableprefix; // no quote tag found, next post if(($start = strpos($post, '[quote author=')) === false) return $post; // no end of tag found, next post if(($end = strpos($post, ']', $start)) === false) return $post; // grab section to replace $found = substr($post, $start, $end - $start + 1); echo '<br /><br \>found: ' . $found . "<br \>\n"; $parts = explode(' ', $found); for($i=0; $i<count($parts); $i++) { $part = $parts[$i]; if(($pos = strpos($part, 'author=')) !== false) { $filter['author'] = substr($part, $pos + 7); while(strpos($parts[$i + 1], '=') === false && $i < count($parts)) { $i++; $filter['author'] .= ' ' . $parts[$i]; } $filter['author'] = trim($filter['author']); if($filter['author'][strlen($filter['author']) - 1] == ']') $filter['author'] = substr($filter['author'], 0, strlen($filter['author']) - 1); echo 'filtered: author: ' . $filter['author'] . "<br \>\n"; } if(($pos = strpos($part, 'link=topic=')) !== false) { $tmp = explode('#', substr($part, $pos)); if(isset($post[1])) { $tmppost = substr($tmp[1], 3); echo 'filtered: post: ' . $tmppost . "<br \>\n"; $request = $Db_target->query(" SELECT postid FROM " . $targettableprefix . "post WHERE importpostid = " . $tmppost); if($row = $Db_target->fetch_array($request)) { $filter['post'] = $row['postid']; echo 'converted: post: ' . $filter['post'] . "<br \>\n"; } } } } if(isset($filter['author']) && isset($filter['post'])) { $replace = '[quote=' . $filter['author'] . ';' . $filter['post'] . ']'; echo 'replacing: post: ' . $replace . "\n"; $post = str_replace($found, $replace, $post); } else if(isset($filter['author'])) { $replace = '[quote=' . $filter['author'] . ']'; echo 'replacing: author: ' . $replace . "\n"; $post = str_replace($found, $replace, $post); } else { echo "replacing: generic\n"; $post = str_replace($found, '[quote]', $post); } return parse_quote($post); }
Code:
// Set true or false as to the data you want to clean $do_posts = true; $do_sigs = true; $do_thread_titles = false; $do_pm_text = true; $do_pm_text_title = false;
Code:
$replacer = array( "[li]" => "[*]", "[/li]" => "", """ => "\"", "&" => "&",
Comment