Пример #1
0
<?php

$x = ob_get_contents();
ob_end_clean();
echo replacePngTags($x);
function replacePngTags($x)
{
    // make sure that we are only replacing for the Windows versions of Internet
    // Explorer 5+, and not Opera identified as MSIE
    $msie = '/msie\\s([5-9])\\.?[0-9]*.*(win)/i';
    $opera = '/opera\\s+[0-9]+/i';
    if (!isset($_SERVER['HTTP_USER_AGENT']) || !preg_match($msie, $_SERVER['HTTP_USER_AGENT']) || preg_match($opera, $_SERVER['HTTP_USER_AGENT'])) {
        return $x;
    }
    // OK, time to find all the IMG tags with ".png" in them
    preg_match_all('/<img.*\\.png.*>/Ui', $x, $images);
    while (list($imgnum, $v) = @each($images[0])) {
        $original = $v;
        $atts = '';
        $width = 0;
        $height = 0;
        // If the size is defined by styles, find
        preg_match_all('/style=".*(width: ([0-9]+))px.*' . '(height: ([0-9]+))px.*"/Ui', $v, $arr2);
        if (is_array($arr2) && count($arr2[0])) {
            // size was defined by styles, get values
            $width = $arr2[2][0];
            $height = $arr2[4][0];
        }
        // size was not defined by styles, get values
        preg_match_all('/width=\\"?([0-9]+)\\"?/i', $v, $arr2);
        if (is_array($arr2) && count($arr2[0])) {
Пример #2
0
                <div id="right_body" style="background-image:url("images/MainBoxMiddle.png");">
                    <div id="right_body_text">
                        <!-- All main page content here. --><h2>Barry, Egham</h2>
                        <div id="portfoliopage">
                        <a href="images/barry_egham_1.jpg"><img align="right" src="images/thumb_barry_egham_1.JPG"/></a>
						<b>Brief:</b> To design and create a back garden to suit the client's needs, including a small area to sunbathe on, and a border around the edge.
                        <br/>
                        <br/>
						<br/>
						<br/>
						<br/>
						<br/>
                        <a href="images/barry_egham_2.jpg"><img align="left" src="images/thumb_barry_egham_2.jpg"/></a>
						<b>Work:</b> We took up all of the grass and disposed of it, marked out a border around the outside and dug a small trench. We then concreted a border in place and placed membrane inside. Te area for the paving was marked out and dug ready for the paving. We created an individual raised bed using new railway sleepers, and paved the area with “fossil mint” Indian sandstone, and added a border using red bricks. The rest of the area was then covered with shingle and stepping stones were placed around the outside.
						<div id="centerimages">
							<a href="images/barry_egham_3.jpg"><img src="images/thumb_barry_egham_3.jpg"/></a>
							<a href="images/barry_egham_4.jpg"><img src="images/thumb_barry_egham_4.jpg"/></a>
						</div>
                        </div>
                        <br/>
                    </div>
                </div>
                <img class="right_footer" src="images/MainBoxBottom.png"/>
            </div>
        </div>
    </body>
</html>
<?php 
include_once 'replacePngTags.php';
echo replacePngTags(ob_get_clean());