you need == operator
if ($str == 1) {
}
in Your view
if ($str == 1) {
echo "<body bgcolor=\"green\">";
echo "<font color=\"white\"><img src=\"https://minotar.net/helm/$uname/32\"> -- $uname is online!</font>";
}
For ZERO you can use === operator
if ($str === 0) {
echo "<body bgcolor=\"red\">";
echo "<font color=\"white\"><img src=\"https://minotar.net/helm/$uname/32\"> -- $uname is offline!</font>";
}