diff options
-rw-r--r-- | phpBB/includes/sql_parse.php | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/phpBB/includes/sql_parse.php b/phpBB/includes/sql_parse.php index d57b44eb9c..c2bb4db4c6 100644 --- a/phpBB/includes/sql_parse.php +++ b/phpBB/includes/sql_parse.php @@ -32,32 +32,34 @@ // remove_comments will strip the sql comment lines out of an uploaded sql file // specifically for mssql and postgres type files in the install.... // -function remove_comments($sql) +function remove_comments(&$output) { - $lines = explode("\n", $sql); + $lines = explode("\n", $output); + $output = ""; // try to keep mem. use down - $sql = ""; $linecount = count($lines); - $output = ""; + $in_comment = false; for($i = 0; $i < $linecount; $i++) { - if( ereg("^\/\*", $lines[$i]) ) + if( preg_match("/^\/\*/", preg_quote($lines[$i])) ) { $in_comment = true; } - if( ereg("\*\/$", $lines[$i]) ) + + if( !$in_comment ) { - $in_comment = false; - $i++; + $output .= $lines[$i] . "\n"; } - if(!$in_comment) + + if( preg_match("/\*\/$/", preg_quote($lines[$i])) ) { - $output .= $lines[$i] . "\n"; + $in_comment = false; } - $lines[$i] = ''; } + + unset($lines); return $output; } // |