Doku5

From Fxp Wiki

Jump to: navigation, search

Attention
Warning


Comme ce code contient "</code>", qui entre en conflit avec l'affichage de ce wiki, j'ai remplacé toutes les occurences de "</code>" par "</\code>".

As this code contains "</code>", which conflict with the display of this wiki, I replaced every occurence of "</code>" by "</\code>".

 
<html>
<body>
<?php
//Global $pre, $strFile, $countd;
$filePathIn = "./dokuwiki-2004-09-25/data/cib/";
$dh = opendir($filePathIn) or die("couldn't open directory");
$version = 1;
$countFile = 0;
    while (!(($file = readdir($dh)) === false)) {
        if (is_dir("$filePathIn/$file")) {
        }
        else {
         $fileName = "$file";
         $filePathIn = "./dokuwiki-2004-09-25/data/cib/";
         $file = "$filePathIn$file";
            if ($fp = fopen($file, "r")) {
            $count++;
            $baseName = basename($file);
            $baseName = str_replace(".txt","", $baseName);
            $strFile = file_get_contents($file);
            fclose($fp);
            echo "<h2>" . $countFile . " - " . $baseName . "</h2> \n";
            $countFile++;
            
//Null preg
 
 
 
//Replace all INSERT
echo "<h3>" . $baseName . " Insert</h3> \n";
//preg_match_all("#<!--<code>\[\{INSERT(.*?)}\]</\code>-->#", $strFile, $matches);
preg_match_all("#<!--<code>\[\{INSERT(.*?)pname=([^,]*)(.*?)}\]</\code>-->#", $strFile, $matches);
//preg_match_all("#\[\{INSERT(.*?)\}\]#", $strFile, $matches);
$countd = 0;
            for ($i=0; $i< count($matches[0]); $i++) {
                $pre3[$countd] = "$matches[2][$i]";
                $strFile = preg_replace("#<!--<code>\[\{INSERT(.*?)pname=([^,]*)(.*?)}\]</\code>-->#","",$strFile);
                //$strFile = preg_replace("/\[{INSERT(.*?)}\]/","ZZZ-$countd",$strFile);
                echo "<div style='color: red;'>" . $matches[0][$i] . "</div>\n";
                echo "<div style='color: red;'>" . $matches[1][$i] . "</div>\n";
                echo "<div style='color: red;'>" . $matches[2][$i] . "</div>\n";
                $countd++;
            }
            
 
preg_match_all("#<!--<code>\[\{INSERT(.*?)ReferringPagesPlugin(.*?)\}\]</\code>-->#", $strFile, $matches);
$countd = 0;
            for ($i=0; $i< count($matches[0]); $i++) {
                $pre3[$countd] = "$matches[2][$i]";
                $rep = ("<!--" . $matches[0][$i] . "-->");
                echo $rep;
                $strFile = preg_replace("#<!--<code>\[\{INSERT(.*?)ReferringPagesPlugin(.*?)\}\]</\code>-->#","{BACKLINKS(page=>cib:$baseName)}{BACKLINKS}",$strFile);
                //$strFile = preg_replace("/\[{INSERT(.*?)}\]/","ZZZ-$countd",$strFile);
                echo "<div style='color: red;'>" . $matches[0][$i] . "</div>\n";
                echo "<div style='color: red;'>" . $matches[1][$i] . "</div>\n";
                echo "<div style='color: red;'>" . $matches[2][$i] . "</div>\n";
                $countd++;
            }
            
            
preg_match_all("#<!--<code>\[\{INSERT(.*?)\}\]</\code>-->#", $strFile, $matches);
$countd = 0;
            for ($i=0; $i< count($matches[0]); $i++) {
                $pre3[$countd] = "$matches[2][$i]";
                $rep = ("<!--" . $matches[0][$i] . "-->");
                echo $rep;
                $strFile = preg_replace("#\<!--<code>(\[\{INSERT(.*?)\}\])</\code>-->#","<!--$1-->",$strFile);
                //$strFile = preg_replace("/\[{INSERT(.*?)}\]/","ZZZ-$countd",$strFile);
                echo "<div style='color: red;'>" . $matches[0][$i] . "</div>\n";
                echo "<div style='color: red;'>" . $matches[1][$i] . "</div>\n";
                echo "<div style='color: red;'>" . $matches[2][$i] . "</div>\n";
                $countd++;
            }
 
$countb=0;
preg_match_all("#<img src=\"([^ ^>\n\r]+(?=[\s\.,]))([^>]*)>#", $strFile, $matches);
            for ($i=0; $i< count($matches[0]); $i++) {
            $str2="";
            $result="";
                $str = htmlspecialchars($matches[0][$i]);
                echo "<div style='color: red;'>SUPER: " . $str . "</div>\n";
                $str2 = str_replace("<img src=\"images","", $matches[0][$i]);
                $str2 = preg_replace("/\"(.*?)>/","",$str2);
                echo "<div style='color: red;'>STR2: " . $str2 . "</div>\n";
                echo "<div style='color: red;'>STR3: " . $str3 . "</div>\n";
                echo "<div style='color: red;'>" . $matches[1][$i] . "</div>\n";
                echo "<div style='color: red;'>" . $matches[2][$i] . "</div>\n";
                
                $str2 = str_replace("/",":",$str2);
                $str2 = str_replace("\\",":",$str2);
                $result = "[[Image:Cib".$str_2."]]<!--{{cib".$str2."|}}-->%%<!--".$matches[0][$i]."-->%%";
                print "\nResult: $result\n";
                $countd++;
                $pre[2][$countb] = $result;
                $m1 = $matches[0][$i];
                $strFile = str_replace("$m1","YYY-$countb", $strFile);
                $countb++;
            }
            
 
for ($i=0; $i<= $countb; $i++) {
$strFile = str_replace("YYY-$i",$pre[2][$i],$strFile);
            }
/*
for ($i=0; $i<= $countd; $i++) {
printf("<code>$pre3[$i]/\code");
$strFile = str_replace("ZZZ-$i","<!--<code>$pre3[$i]</\code>-->",$strFile);
            }
*/
 
 
    $outputDir = "./dokuwiki-2004-09-25/data/cib4/";
    $outputFile = ($outputDir . $baseName.".txt");
    $out = fopen($outputFile, "w");
    fwrite($out,$strFile);
 
 
        }
    }
    }
    
 
Personal tools