MSAccess

From Wiki RB4
Revision as of 10:28, 12 March 2007 by 127.0.0.1 (talk)

<?php echo "Test1\n"; echo "Test2\n"; $outfilename = "MediaWiki.txt"; echo $argv[1] . "\n"; $infile = fopen($argv[1], 'rb') or die("couldn't open " . $argv[1]); $incontents = fread($infile, filesize ($argv[1])); fclose ($infile);

$outcontents = $incontents;

/* if (preg_match_all($pattern,$outcontents,$hits)) {

 print_r($hits);

} else {

 echo 'no hits\n';

}

  • /


$pattern = '/!!!(.*)\r\n/'; $outcontents = preg_replace($pattern, "\r\n". '==\1==' . "\r\n", $outcontents); $pattern = '/!!(.*)\r\n/'; $outcontents = preg_replace($pattern, "\r\n". '===\1===' . "\r\n", $outcontents); $pattern = '/!(.*)\r\n/'; $outcontents = preg_replace($pattern, "\r\n". '====\1====' . "\r\n", $outcontents); $pattern = '/\\\\\\\\\\r\n/'; $outcontents = preg_replace($pattern, "\r\n", $outcontents); $pattern = '/\\\\\\\\\\==/'; $outcontents = preg_replace($pattern, "==", $outcontents);

$outfile = fopen($outfilename, 'wb') or die("couldn't open " . $outfilename); $pattern = '/\r\n/'; // $pattern = '/\n/'; $lines = preg_split($pattern,$outcontents); $handle_table = false; $table_pattern = '/^\|/'; foreach ($lines as $line) {

 echo "LINE: " . $line . "\n";
 
 if ($handle_table)
 {
   if (preg_match($table_pattern, $line))
   {
     echo "Table line\n";
     $line = preg_replace('/\|/', "\r\n|", $line);
     $line = "\r\n|-\n" . $line;
   }
   else
   {
     echo "Line after table\n";
     $line = "\r\n|}\r\n" . $line;
     $handle_table = false;
   }
 }
 else if (preg_match($table_pattern, $line))
 {
   echo "Table start\n";
   $line = "{| border=1 cellpadding=2 cellspacing=0\r\n|-\n" . preg_replace('/\|/', "\r\n|", $line); 
   $handle_table = true;
 }
 else
 {
   $line = $line . "\r\n";
 }
 fwrite($outfile, $line);

}


//fwrite($outfile, $outcontents); ?>