Is this a valid statement in php?
<p>I am setting up a Pandora FMS server and console on Solaris 10u8 on a v65x. Everything hasn't exactly been going smoothly but I managed to get MySQL, PHP and the various pandora components installed. However, when I try to go to the website (myserver/pandora/index.php) it is just a gray background with a white box. I hit "View Page Source" in Firefox and got this:</p>

<pre><code>    &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
    &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
    &lt;head&gt;
 &lt;title&gt;Pandora FMS - the Flexible Monitoring System&lt;/title&gt;
 &lt;meta http-equiv="expires" content="0" /&gt;
 &lt;meta http-equiv="content-type" content="text/html; charset=utf-8" /&gt;
 &lt;meta http-equiv="Content-Style-Type" content="text/css" /&gt;
 &lt;meta name="resource-type" content="document" /&gt;
 &lt;meta name="distribution" content="global" /&gt;
 &lt;meta name="author" content="Sancho Lerena" /&gt;

 &lt;meta name="copyright" content="This is GPL software. Created by Sancho Lerena and others" /&gt;
 &lt;meta name="keywords" content="pandora, monitoring, system, GPL, software" /&gt;
 &lt;meta name="robots" content="index, follow" /&gt;
 &lt;link rel="icon" href="images/pandora.ico" type="image/ico" /&gt;
 &lt;link rel="alternate" href="operation/events/events_rss.php" title="Pandora RSS Feed" type="application/rss+xml" /&gt;
 &lt;link rel="stylesheet" href="include/styles/common.css" type="text/css" /&gt;
 &lt;link rel="stylesheet" href="include/styles/menu.css" type="text/css" /&gt;
 &lt;link rel="stylesheet" href="include/styles/tip.css" type="text/css" /&gt;
 &lt;link rel="stylesheet" href="include/styles/pandora.css" type="text/css" /&gt;

 &lt;script type="text/javascript" src="include/javascript/pandora.js"&gt;&lt;/script&gt;
 &lt;script type="text/javascript" src="include/javascript/jquery.js"&gt;&lt;/script&gt;
 &lt;script type="text/javascript" src="include/javascript/jquery.pandora.js"&gt;&lt;/script&gt;
 &lt;!--[if gte IE 6]&gt;
 &lt;link rel="stylesheet" href="include/styles/ie.css" type="text/css"/&gt;
 &lt;![endif]--&gt;&lt;/head&gt;
&lt;body&gt;&lt;div class="databox" id="login"&gt;&lt;br&gt;&lt;br&gt;
 &lt;div class="databox" id="login_in"&gt;
  &lt;form method="post" action="index.php?login=1"&gt;
  &lt;table cellpadding="4" cellspacing="1" width="420"&gt;&lt;tr&gt;&lt;td rowspan="3" align="left" style="border-right: solid 1px #678;"&gt;&lt;a href="http://pandorafms.org" title="Go to pandorafms.org..."&gt;&lt;/body&gt;
</code></pre>

<p>I do know HTML pretty well and I can plainly see something is a little off with this (Notice the abrupt ending just after that anchor tag). Furthermore, when I used Chrome's source viewer developer thing, it tells me I received a 500 error. So I did some investigating and found the offending line. See this excerpt from function_html.php, a file containing a function (print_image) which is called by login_page.php which is called by index.php:</p>

<pre><code> $output = '&lt;img src="'.safe_input ($src).'" '; //safe input necessary to strip out html entities correctly
</code></pre>

<p>I can tell is the problematic line because the previous statement worked but the next did not. I then commented out this function call, and the page rendered correctly (except it was missing the pandora logo. Is valid in PHP and my PHP isn't working correctly or is it somehow incorrect? I ran php -l function_html.php and it said there a re no syntax errors.</p>

<p>TLDR: Is the above line beginning with $output prone to causing a 500 error for some reason?</p>

<pre><code>function safe_input($value) {
    //Stop!! Are you sure to modify this critical code? Because the older
    //versions are serius headache in many places of Pandora.

    if (is_numeric($value))
            return $value;

    if (is_array($value)) {
            array_walk($value, "safe_input");
            return $value;
    }

    //Clean the trash mix into string because of magic quotes.
    if (get_magic_quotes_gpc() == 1) {
            $value = stripslashes($value);
    }

    if (! mb_check_encoding ($value, 'UTF-8'))
            $value = utf8_encode ($value);

    $valueHtmlEncode =  htmlentities ($value, ENT_QUOTES, "UTF-8", true);

    //Replace the character '\' for the equivalent html entitie
    $valueHtmlEncode = str_replace('\\', "&amp;#92;", $valueHtmlEncode);

    return $valueHtmlEncode;
}
</code></pre>

<p>The input ($src) is something like this: "directory/filename.extension"</p>

<p>The (slightly modified for debugging purposes) print_image function:</p>

<pre><code>function print_image ($src, $return = false, $options = false) {
    echo '&lt;p&gt;eat shit blarg&lt;/p&gt;';
    $output = '&lt;img src="'.safe_input ($src).'" '; //safe input necessary to strip out html entities correctly
    echo '&lt;p&gt;bloop&lt;/p&gt;';
    $style = '';
    echo '&lt;p&gt;blah 1&lt;/p&gt;';
    if (!empty ($options)) {
            //Deprecated or value-less attributes
            if (isset ($options["align"])) {
                    $style .= 'align:'.$options["align"].';'; //Align is deprecated, use styles.
            }
    echo '&lt;p&gt;blah 2&lt;/p&gt;';

            if (isset ($options["border"])) {
                    $style .= 'border:'.$options["border"].'px;'; //Border is deprecated, use styles
            }
    echo '&lt;p&gt;blah 3&lt;/p&gt;';

            if (isset ($options["hspace"])) {
                    $style .= 'margin-left:'.$options["hspace"].'px;'; //hspace is deprecated, use styles
                    $style .= 'margin-right:'.$options["hspace"].'px;';
            }
    echo '&lt;p&gt;blah 4&lt;/p&gt;';

            if (isset ($options["ismap"])) {
                    $output .= 'ismap="ismap" '; //Defines the image as a server-side image map
            }
    echo '&lt;p&gt;blah 5&lt;/p&gt;';

            if (isset ($options["vspace"])) {
                    $style .= 'margin-top:'.$options["vspace"].'px;'; //hspace is deprecated, use styles
                    $style .= 'margin-bottom:'.$options["vspace"].'px;';
            }
    echo '&lt;p&gt;blah 6&lt;/p&gt;';

            if (isset ($options["style"])) {
                    $style .= $options["style"];
            }
    echo '&lt;p&gt;blah 7&lt;/p&gt;';

            //Valid attributes (invalid attributes get skipped)
            $attrs = array ("height", "longdesc", "usemap","width","id","class","title","lang","xml:lang",
                                            "onclick", "ondblclick", "onmousedown", "onmouseup", "onmouseover", "onmousemove",
                                            "onmouseout", "onkeypress", "onkeydown", "onkeyup");
    echo '&lt;p&gt;blah 8&lt;/p&gt;';

            foreach ($attrs as $attribute) {
                    if (isset ($options[$attribute])) {
                            $output .= $attribute.'="'.safe_input ($options[$attribute]).'" ';
                    }
            }
    echo '&lt;p&gt;blah 9&lt;/p&gt;';
    } else {
    echo '&lt;p&gt;blah 0&lt;/p&gt;';
            $options = array ();
    }
    echo '&lt;p&gt;blah a&lt;/p&gt;';

    if (!isset ($options["alt"]) &amp;&amp; isset ($options["title"])) {
            $options["alt"] = $options["title"]; //Set alt to title if it's not set
    } elseif (!isset ($options["alt"])) {
            $options["alt"] = "";
    }
    echo '&lt;p&gt;blah b&lt;/p&gt;';

    if (!empty ($style)) {
            $output .= 'style="'.$style.'" ';
    }
    echo '&lt;p&gt;blah c&lt;/p&gt;';

    $output .= 'alt="'.safe_input ($options['alt']).'" /&gt;';

    if (!$return) {
            echo $output;
    }
    echo '&lt;p&gt;blah d&lt;/p&gt;';

    return $output;
}
</code></pre>

<p>The original page:
    

<pre><code>// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2009 Artica Soluciones Tecnologicas

// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation for version 2.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

$url = '?login=1';
//These variables come from index.php
if (!empty ($page) &amp;&amp; !empty ($sec)) {
        foreach ($_GET as $key =&gt; $value) {
                $url .= '&amp;amp;'.$key.'='.$value;
    }
}

echo '&lt;div class="databox" id="login"&gt;';

    //echo '&lt;h1&gt;Put here your custom welcome message&lt;/h1&gt;";

echo '&lt;br&gt;&lt;br&gt;';
echo '
    &lt;div class="databox" id="login_in"&gt;
            &lt;form method="post" action="index.php'.$url.'"&gt;
            &lt;table cellpadding="4" cellspacing="1" width="420"&gt;';

if (isset ($login_failed)) {
    echo '&lt;tr&gt;&lt;td colspan="3"&gt;';
    echo '&lt;h3 class="error"&gt;'.__('Login failed').': '.$config["auth_error"].'&lt;/h3&gt;';
    echo '&lt;/td&gt;&lt;/tr&gt;';
} 

echo '&lt;tr&gt;&lt;td rowspan="3" align="left" style="border-right: solid 1px #678;"&gt;';

if (!empty ($page) &amp;&amp; !empty ($sec)) {
    foreach ($_POST as $key =&gt; $value) {
            print_input_hidden ($key, $value);
    }
}

//TODO: Put branding in variables (external file) or database
/* CUSTOM BRANDING STARTS HERE */

// Replace the following with your own URL and logo.
// A mashup of the Pandora FMS logo and your companies highly preferred
echo '&lt;a href="http://pandorafms.org" title="Go to pandorafms.org..."&gt;';
print_image ("images/pandora_logo.png", false, array ("alt" =&gt; "logo", "border" =&gt; 0));
echo '&lt;/a&gt;&lt;br /&gt;';

// This prints the current pandora console version.
// For stable/live function it might be wise to comment it out
echo $pandora_version.(($develop_bypass == 1) ? ' '.__('Build').' '.$build_version : '');

/* CUSTOM BRANDING ENDS HERE */

echo '&lt;/td&gt;&lt;td class="f9b"&gt;
            '.__('Login').':&lt;br /&gt;'.print_input_text_extended ("nick", '', "nick", '', '', '' ,false, '', 'class="login"', true).'
    &lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td class="f9b"&gt;
            '.__('Password').':&lt;br /&gt;'.print_input_text_extended ("pass", '', "pass", '', '', '' ,false, '', 'class="login"', true, true).'
    &lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td align="center"&gt;
            '.print_submit_button ("Login",'',false,'class="sub next"',true).'
    &lt;/td&gt;&lt;/tr&gt;
    &lt;/table&gt;
    &lt;/form&gt;
    &lt;/div&gt;
    &lt;div id="ip"&gt;'.__('Your IP').': &lt;b class="f10"&gt;'.$config["remote_addr"].'&lt;/b&gt;&lt;/div&gt;
&lt;/div&gt;';
?&gt;
&lt;script type="text/javascript" language="javascript"&gt;
/* &lt;![CDATA[ */
document.getElementById('nick').focus();
/* ]]&gt; */
&lt;/script&gt;
</code></pre>
