function xmlentities($str)
{
    $from[0] = '&';
    $to[0] = '&';
    $from[1] = '<';
    $to[1] = '&lt;';
    $from[2] = '>';
    $to[2] = '&gt;';
    $from[3] = '"';
    $to[3] = '&quot;';
    $from[4] = '\'';
    $to[4] = '&apos;';
    for ($i = 0; $i <= 4; $i++) {
        $str = mb_ereg_replace($from[$i], $to[$i], $str);
    }
    $str = output_convert($str);
    return filterevilchars($str);
}
Example #2
0
 function output_convert($data)
 {
     foreach ($data as $row) {
         if (is_array($row)) {
             $row = output_convert($row);
         } elseif (is_object($row)) {
             if (!empty($row->attributes)) {
                 foreach ($row->attributes as $key => $value) {
                     if (isset($key) and ($key == 'id' or $key == 'free' or $key == 'used' or $key == 'size' or $key == 'speed' or $key == 'total' or $key == 'col_order' or $key == 'access_level' or $key == 'count')) {
                         $row->attributes->{$key} = intval($value);
                     } elseif (strrpos($key, 'id') === strlen($key) - 2 or strrpos($key, 'count') === strlen($key) - 5 or strrpos($key, 'percent') === strlen($key) - 7 or strrpos($key, 'size') === strlen($key) - 4) {
                         $row->attributes->{$key} = intval($value);
                     } elseif (strrpos($key, 'ip') === strlen($key) - 2 or strrpos($key, 'next_hop') === strlen($key) - 8 or strrpos($key, 'destination') === strlen($key) - 11) {
                         $temp_name = $key . '_padded';
                         $row->attributes->{$temp_name} = ip_address_from_db($value);
                         $row->attributes->{$temp_name} = ip_address_to_db($row->attributes->{$temp_name});
                         $row->attributes->{$key} = ip_address_from_db($value);
                         if ($row->attributes->{$temp_name} == $row->attributes->{$key}) {
                             unset($row->attributes->{$temp_name});
                         }
                     }
                 }
             }
         }
     }
     return $data;
 }