$wgLoadBalancer->commitAll();

$PDFFile = $_SERVER["DOCUMENT_ROOT"] . '/printouts/' . str_replace("'","_",str_replace(" ","_",$wgTitle->getText())) . ".pdf"; $PDFExec = "/usr/bin/htmldoc --webpage -f " . $PDFFile; $addedText = "";

$SaveText = $wgOut->mBodytext; $wgOut->mBodytext = "";

$i = strpos($SaveText,"{"); while ($i >= 0 && $SaveText != "") {

 $j = strpos($SaveText,"}");
 if ($j <= $i) break;
 $multi_art = explode('|',substr($SaveText, $i+1, $j-$i-1));
 if (strlen($SaveText) > $j+1)
   $SaveText = substr($SaveText, $j+1);
 else
   $SaveText = "";
 $NewBodyText = "";
 foreach ($multi_art as $one_art) {
   $wgOut->mBodytext = "";
   $art = trim($one_art);
   $addedText .= "Creating: (" . $art . ")
"; $PDFTitle = Title::newFromURL( $art ); $PDFArticle = new Article($PDFTitle); $PDFArticle->view(); $bodyText = str_replace('<img src="/stylesheets/images/magnify-clip.png" width="15" height="11" alt="Enlarge" />', ,

str_replace('

[',
               ,
str_replace('>modifier</a>]

',

               '></a>', 
               $wgOut->mBodytext)));

$NewBodyText .= "

" . $art . "


" . str_replace('href="/mediawiki', 'href="http://' . $_SERVER["SERVER_NAME"] . '/mediawiki',

                   str_replace('src="/mediawiki', 'src="http://' . $_SERVER["SERVER_NAME"] . '/mediawiki',
                   str_replace('<a href="/index.php', '<a href="http://' . $_SERVER["SERVER_NAME"] . '/index.php',
                   str_replace('<img src="/images/thumb',
                   '<img src="' . $_SERVER["DOCUMENT_ROOT"] . '/images/thumb', $bodyText))));
 }
 $h = fopen("/tmp/" . str_replace("'","_",str_replace(" ","_",$art)) . ".htm" ,"w");
 fwrite($h,"<html><body>");
 fwrite($h,$NewBodyText);
 fwrite($h,"</body></html>");
 fclose($h);
 exec("iconv --from-code=UTF8 --to-code=ISO_8859-1 -o /tmp/toto_" . str_replace(" ","_",$art) . " /tmp/" . str_replace("'","_",str_replace(" ","_",$art)) . ".htm");
 exec("mv -f /tmp/toto_" . str_replace(" ","_",$art) . " /tmp/" . str_replace("'","_",str_replace(" ","_",$art)) . ".htm");
 $PDFExec .= " " . "/tmp/" . str_replace("'","_",str_replace(" ","_",$art)) . ".htm";
 $i = strpos($SaveText,"{");

}

exec($PDFExec, $results); foreach ($results as $line)

 $addedText .= $line . "
";

$addedText .= "
<a href='http://" . $_SERVER["SERVER_NAME"] . '/printouts/' .

             str_replace("'","_",str_replace(" ","_",$wgTitle->getText())) . ".pdf'>" . 
             $wgTitle->getText() . ".pdf</a>";

$wgOut->mBodytext = "";

$wgArticle->view(); $wgOut->addHTML($addedText);

$wgOut->output();

"https://ml.wikipedia.org/w/index.php?title=ഉപയോക്താവ്:Raghith/lab/printarticles.php&oldid=912968" എന്ന താളിൽനിന്ന് ശേഖരിച്ചത്