@@ -3706,6 +3706,7 @@ public function wrapCommand($cmd, $memcheck_filename, $check_all)
3706
3706
}
3707
3707
}
3708
3708
3709
+
3709
3710
function init_output_buffers ()
3710
3711
{
3711
3712
// Delete as much output buffers as possible.
@@ -3738,4 +3739,79 @@ function check_proc_open_function_exists()
3738
3739
}
3739
3740
}
3740
3741
3742
+ class OutputHandler
3743
+ {
3744
+
3745
+ /**
3746
+ * @var null|string
3747
+ */
3748
+ private $ htmlOutputFilename = null ;
3749
+
3750
+ /**
3751
+ * @var null|resource
3752
+ */
3753
+ private $ htmlHandle = null ;
3754
+
3755
+ /**
3756
+ * @param string $outputFilename
3757
+ */
3758
+ public function setHtmlOutputFilename ($ outputFilename )
3759
+ {
3760
+ $ this ->htmlOutputFilename = $ outputFilename ;
3761
+ }
3762
+
3763
+ public function clearHtmlFile ()
3764
+ {
3765
+ ftruncate ($ this ->getHtmlFileHandle (), 0 );
3766
+ }
3767
+
3768
+ /**
3769
+ * @return string
3770
+ */
3771
+ public function getHtmlOutputFilename ()
3772
+ {
3773
+ if ($ this ->htmlOutputFilename === null ) {
3774
+ throw new \Exception ('No output filename has been set. ' );
3775
+ }
3776
+
3777
+ return $ this ->htmlOutputFilename ;
3778
+ }
3779
+
3780
+ /**
3781
+ * @return false|resource
3782
+ */
3783
+ public function getHtmlFileHandle ()
3784
+ {
3785
+ if ($ this ->htmlHandle !== null ) {
3786
+ return $ this ->htmlHandle ;
3787
+ }
3788
+
3789
+ $ this ->fileHandle = fopen ($ this ->getHtmlOutputFilename (), 'at+ ' );
3790
+
3791
+ return $ this ->fileHandle ;
3792
+ }
3793
+
3794
+ /**
3795
+ * @return bool
3796
+ */
3797
+ public function isHtmlEnabled ()
3798
+ {
3799
+ return !empty ($ this ->getHtmlOutputFilename ()) && is_resource ($ this ->getHtmlFileHandle ());
3800
+ }
3801
+
3802
+ public function closeHtmlHandle ()
3803
+ {
3804
+ fclose ($ this ->getHtmlFileHandle ());
3805
+ }
3806
+
3807
+ /**
3808
+ * @param $content
3809
+ */
3810
+ public function writeHtml ($ content )
3811
+ {
3812
+ fwrite ($ this ->getHtmlFileHandle (), $ content );
3813
+ }
3814
+
3815
+ }
3816
+
3741
3817
main ();
0 commit comments