// Replacement function for _read_file() in Smarty.class.php to add support
// for reading both ionCube encrypted templates and plain text templates.
// Smarty.class.php must be encoded by the creator of the templates for
// ioncube_read_file() to decode encrypted template files

    function _read_file($filename)
    {
        $res = false;

        if (file_exists($filename)) {
            if (function_exists('ioncube_read_file')) {
                $res = ioncube_read_file($filename);
                if (is_int($res)) $res = false;
            }
            else if ( ($fd = @fopen($filename, 'rb')) ) {
                $res = ($size = filesize($filename)) ? fread($fd, $size) : '';
                fclose($fd);
            }
        }

        return $res;
    }