<?php
if (isset($_GET['logopng']))
{
	$data=' ';
	header('Content-type: image/png');
	echo base64_decode($data);
	exit;
}
else if (isset($_GET['background']))
{
	$data=' ';
	header('Content-type: image/gif');
	echo base64_decode($data);
	exit;
}

$php_ok = (function_exists('version_compare') && version_compare(phpversion(), '5.6.0', '>='));
$pcre_ok = extension_loaded('pcre');
$curl_ok = function_exists('curl_exec');
$zlib_ok = extension_loaded('zlib');
$mbstring_ok = extension_loaded('mbstring');
$iconv_ok = extension_loaded('iconv');
$intl_ok = version_compare(phpversion(), '5.5.0', '>=') && extension_loaded('intl');
if (extension_loaded('xmlreader'))
{
	$xml_ok = true;
}
elseif (extension_loaded('xml'))
{
	$parser_check = xml_parser_create();
	xml_parse_into_struct($parser_check, '<foo>&amp;</foo>', $values);
	xml_parser_free($parser_check);
	$xml_ok = isset($values[0]['value']);
}
else
{
	$xml_ok = false;
}



if( php_sapi_name() === 'cli' ):

$testHeader = <<<EOF

         +-----------------------------------------------------------------+
         |               SimplePie: Server Compatibility Test              |
         +-----------------------------------------------------------------+
         |        Test         |        Should Be    |     What You Have   |
+--------------------------------------------------------------------------+
EOF;

$testRow = <<<EOF

| %s| %s| %s| %s|
+--------------------------------------------------------------------------+
EOF;

echo $testHeader;


echo sprintf($testRow,str_pad(($php_ok ? 'Passed' : 'Failed'), 7),str_pad('PHP',20),str_pad('5.6.0 or higher', 20),str_pad(phpversion(), 20));



echo sprintf($testRow,str_pad(($xml_ok ? 'Passed' : 'Failed'), 7),str_pad('XML',20),str_pad('Enabled', 20),str_pad(($xml_ok ? 'Enabled, and sane' : 'Disabled, or broken'), 20));


echo sprintf($testRow,str_pad(($pcre_ok ? 'Passed' : 'Failed'), 7),str_pad('PCRE ^^^',20),str_pad('Enabled', 20),str_pad(($pcre_ok ? 'Enabled' : 'Disabled'), 20));


echo sprintf($testRow,str_pad(($curl_ok ? 'Passed' : 'Failed'), 7),str_pad('cURL',20),str_pad('Enabled', 20),str_pad((extension_loaded('curl') ? 'Enabled' : 'Disabled'), 20));



echo sprintf($testRow,str_pad(($zlib_ok ? 'Passed' : 'Failed'), 7),str_pad('Zlib',20),str_pad('Enabled', 20),str_pad(($zlib_ok ? 'Enabled' : 'Disabled'), 20));


echo sprintf($testRow,str_pad(($mbstring_ok ? 'Passed' : 'Failed'), 7),str_pad('mbstring',20),str_pad('Enabled', 20),str_pad(( $mbstring_ok ? 'Enabled' : 'Disabled' ), 20));


echo sprintf($testRow,str_pad(($iconv_ok ? 'Passed' : 'Failed'), 7),str_pad('iconv',20),str_pad('Enabled', 20),str_pad(( $iconv_ok ? 'Enabled' : 'Disabled' ), 20));


echo sprintf($testRow,str_pad(($intl_ok ? 'Passed' : 'Failed'), 7),str_pad('intl',20),str_pad('Enabled', 20),str_pad(( $intl_ok ? 'Enabled' : 'Disabled' ), 20));


echo "\n\n";

echo "What does this mean? \n\n";

if ($php_ok && $xml_ok && $pcre_ok && $mbstring_ok && $iconv_ok && $intl_ok && $curl_ok && $zlib_ok):
	echo "You have everything you need to run SimplePie properly!  Congratulations!\n\n";
else:
	if ($php_ok):
		echo "PHP: You are running a supported version of PHP.  No problems here.\n";

		if ($xml_ok):
			echo "XML: You have XMLReader support or a version of XML support that isn't broken installed.  No problems here.\n";
		if ($pcre_ok):
			echo "PCRE: You have PCRE support installed.  No problems here.\n";
            if ($curl_ok):
                echo "cURL: You have cURL support installed.  No problems here.\n";
            else:
                echo "cURL: The cURL extension is not available.  SimplePie will use fsockopen() instead.\n";
            endif;

            if ($zlib_ok):
                echo "Zlib: You have Zlib enabled.  This allows SimplePie to support GZIP-encoded feeds.  No problems here.\n";
            else:
                echo "Zlib: The Zlib extension is not available.  SimplePie will ignore any GZIP-encoding, and instead handle feeds as uncompressed text.\n";
            endif;

            if ($mbstring_ok && $iconv_ok && $intl_ok):
                echo "mbstring, iconv and intl: You have both mbstring, iconv and intl installed and enabled!  This will allow SimplePie to handle the greatest number of languages. \nCheck the http://simplepie.org/wiki/faq/supported_character_encodings chart to see what's supported on your webhost.\n";
            elseif (($mbstring_ok && $iconv_ok) ||
                ($mbstring_ok && $intl_ok) ||
                ($iconv_ok && $intl_ok)
            ):
                if ($mbstring_ok):
                    echo "mbstring: mbstring is installed and enabled.\n";
                else:
                    echo "mbstring: mbstring extension is not available.\n";
                endif;
                if ($iconv_ok):
                    echo "iconv: iconv is installed and enabled.\n";
                else:
                    echo "iconv: iconv extension is not available.\n";
                endif;
                if ($intl_ok):
                    echo "intl: intl is installed and enabled.\n";
                else:
                    echo "intl: intl extension is not supported/available (PHP 5.5+).\n";
                endif;
                echo "Check the http://simplepie.org/wiki/faq/supported_character_encodings chart to see what's supported on your webhost.\n";
            else:
                echo "mbstring, iconv and intl: You do not have either of the extensions installed and enabled, (intl supported as of PHP 5.5+). This will significantly impair your ability to read non-English feeds, as well as even some English ones.  Check the http://simplepie.org/wiki/faq/supported_character_encodings chart to see what's supported on your webhost.\n";
            endif;

        else:
            echo "PCRE: Your PHP installation doesn't support Perl-Compatible Regular Expressions.  SimplePie is a no-go at the moment.\n";
        endif;


        else:
            echo "XML: Your PHP installation doesn't support XML parsing. SimplePie is a no-go at the moment.\n";
        endif;
	
	else:
		echo "PHP: You are running an unsupported version of PHP.  SimplePie is a no-go at the moment.\n";
    endif;

endif;


$bottomLineFooter = <<<EOF
You can download the latest version of SimplePie from http://simplepie.org/downloads/ and install it by http://simplepie.org/wiki/setup/start .
You can find example uses with http://simplepie.org/ideas/ .
Take the time to read http://simplepie.org/wiki/setup/start to make sure you're prepared to use SimplePie. No seriously, read them.

Note: Passing this test does not guarantee that SimplePie will run on your webhost -- it only ensures that the basic requirements have been addressed.
EOF;

if ($php_ok && $xml_ok && $pcre_ok && $mbstring_ok && $iconv_ok):

echo <<<EOF

Bottom Line: Yes, you can!
Your webhost has its act together!"

{$bottomLineFooter}
EOF;


elseif ($php_ok && $xml_ok && $pcre_ok):
echo <<<EOF

Bottom Line: Yes, you can!
For most feeds, it'll run with no problems. There are http://simplepie.org/wiki/faq/supported_character_encodings that you might have a hard time with though.
	
{$bottomLineFooter}
EOF;

else:

echo <<<EOF

Bottom Line: We're sorry ...
Your webhost does not support the minimum requirements for SimplePie. 
It may be a good idea to contact your webhost, and ask them to install a more recent version of PHP as well as the xmlreader, xml, mbstring, iconv, curl, and zlib extensions.

EOF;

endif;



echo "\n\n^^^ Some recent versions of the PCRE (PERL-Compatible Regular Expression) engine compiled into PHP have been buggy, and are the source of PHP segmentation faults (e.g. crashes) which cause random things like blank, white screens. Check the http://simplepie.org/support/ for the latest information on patches and ongoing fixes.\n";

exit(0);

endif;



header('Content-type: text/html; charset=UTF-8');

?><!DOCTYPE html>

<html lang="en">
<head>
<title>SimplePie: Server Compatibility Test</title>

<style type="text/css">
body {
	font:14px/1.4em "Lucida Grande", Verdana, Arial, Helvetica, Clean, Sans, sans-serif;
	letter-spacing:0px;
	color:#333;
	margin:0;
	padding:0;
	background:#fff url(<?php echo pathinfo(__FILE__, PATHINFO_BASENAME); ?>?background) repeat-x top left;
}

div#site {
	width:550px;
	margin:20px auto 0 auto;
}

a {
	color:#000;
	text-decoration:underline;
	padding:0 1px;
}

a:hover {
	color:#fff;
	background-color:#333;
	text-decoration:none;
	padding:0 1px;
}

p {
	margin:0;
	padding:5px 0;
}

em {
	font-style:normal;
	background-color:#ffc;
}

ul, ol {
	margin:10px 0 10px 20px;
	padding:0 0 0 15px;
}

ul li, ol li {
	margin:0 0 7px 0;
	padding:0 0 0 3px;
}

h2 {
	font-size:18px;
	padding:0;
	margin:30px 0 10px 0;
}

h3 {
	font-size:16px;
	padding:0;
	margin:20px 0 5px 0;
}

h4 {
	font-size:14px;
	padding:0;
	margin:15px 0 5px 0;
}

code {
	font-size:1.1em;
	background-color:#f3f3ff;
	color:#000;
}

em strong {
    text-transform: uppercase;
}

table#chart {
	border-collapse:collapse;
}

table#chart th {
	background-color:#eee;
	padding:2px 3px;
	border:1px solid #fff;
}

table#chart td {
	text-align:center;
	padding:2px 3px;
	border:1px solid #eee;
}

table#chart tr.enabled td {
	/* Leave this alone */
}

table#chart tr.disabled td, 
table#chart tr.disabled td a {
	color:#999;
	font-style:italic;
}

table#chart tr.disabled td a {
	text-decoration:underline;
}

div.chunk {
	margin:20px 0 0 0;
	padding:0 0 10px 0;
	border-bottom:1px solid #ccc;
}

.footnote,
.footnote a {
	font:10px/12px verdana, sans-serif;
	color:#aaa;
}

.footnote em {
	background-color:transparent;
	font-style:italic;
}
</style>

<script type="text/javascript">
// Sleight - Alpha transparency PNG's in Internet Explorer 5.5/6.0
// (c) 2001, Aaron Boodman; http://www.youngpup.net

if (navigator.platform == "Win32" && navigator.appName == "Microsoft Internet Explorer" && window.attachEvent) {
	document.writeln('<style type="text/css">img, input.image { visibility:hidden; } </style>');
	window.attachEvent("onload", fnLoadPngs);
}

function fnLoadPngs() {
	var rslt = navigator.appVersion.match(/MSIE (\d+\.\d+)/, '');
	var itsAllGood = (rslt != null && Number(rslt[1]) >= 5.5);

	for (var i = document.images.length - 1, img = null; (img = document.images[i]); i--) {
		if (itsAllGood && img.src.match(/\png$/i) != null) {
			var src = img.src;
			var div = document.createElement("DIV");
			div.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "', sizing='scale')";
			div.style.width = img.width + "px";
			div.style.height = img.height + "px";
			img.replaceNode(div);
		}
		img.style.visibility = "visible";
	}
}
</script>

</head>

<body>

<div id="site">
	<div id="content">

		<div class="chunk">
			<h2 style="text-align:center;"><img src="<?php echo pathinfo(__FILE__, PATHINFO_BASENAME); ?>?logopng" alt="SimplePie Compatibility Test" title="SimplePie Compatibility Test" /></h2>
			<table cellpadding="0" cellspacing="0" border="0" width="100%" id="chart">
				<thead>
					<tr>
						<th>Test</th>
						<th>Should Be</th>
						<th>What You Have</th>
					</tr>
				</thead>
				<tbody>
					<tr class="<?php echo ($php_ok) ? 'enabled' : 'disabled'; ?>">
						<td>PHP</td>
						<td>5.6.0 or higher</td>
						<td><?php echo phpversion(); ?></td>
					</tr>
					<tr class="<?php echo ($xml_ok) ? 'enabled, and sane' : 'disabled, or broken'; ?>">
						<td><a href="http://php.net/xml">XML</a></td>
						<td>Enabled</td>
						<td><?php echo ($xml_ok) ? 'Enabled, and sane' : 'Disabled, or broken'; ?></td>
					</tr>
					<tr class="<?php echo ($pcre_ok) ? 'enabled' : 'disabled'; ?>">
						<td><a href="http://php.net/pcre">PCRE</a>&sup1;</td>
						<td>Enabled</td>
						<td><?php echo ($pcre_ok) ? 'Enabled' : 'Disabled'; ?></td>
					</tr>
					<tr class="<?php echo ($curl_ok) ? 'enabled' : 'disabled'; ?>">
						<td><a href="http://php.net/curl">cURL</a></td>
						<td>Enabled</td>
						<td><?php echo (extension_loaded('curl')) ? 'Enabled' : 'Disabled'; ?></td>
					</tr>
					<tr class="<?php echo ($zlib_ok) ? 'enabled' : 'disabled'; ?>">
						<td><a href="http://php.net/zlib">Zlib</a></td>
						<td>Enabled</td>
						<td><?php echo ($zlib_ok) ? 'Enabled' : 'Disabled'; ?></td>
					</tr>
					<tr class="<?php echo ($mbstring_ok) ? 'enabled' : 'disabled'; ?>">
						<td><a href="http://php.net/mbstring">mbstring</a></td>
						<td>Enabled</td>
						<td><?php echo ($mbstring_ok) ? 'Enabled' : 'Disabled'; ?></td>
					</tr>
					<tr class="<?php echo ($iconv_ok) ? 'enabled' : 'disabled'; ?>">
						<td><a href="http://php.net/iconv">iconv</a></td>
						<td>Enabled</td>
						<td><?php echo ($iconv_ok) ? 'Enabled' : 'Disabled'; ?></td>
					</tr>
				</tbody>
			</table>
		</div>

		<div class="chunk">
			<h3>What does this mean?</h3>
			<ol>
				<?php if ($php_ok && $xml_ok && $pcre_ok && $mbstring_ok && $iconv_ok && $curl_ok && $zlib_ok): ?>
				<li><em>You have everything you need to run SimplePie properly!  Congratulations!</em></li>
				<?php else: ?>
					<?php if ($php_ok): ?>
						<li><strong>PHP:</strong> You are running a supported version of PHP.  <em>No problems here.</em></li>
						<?php if ($xml_ok): ?>
							<li><strong>XML:</strong> You have XMLReader support or a version of XML support that isn't broken installed.  <em>No problems here.</em></li>
							<?php if ($pcre_ok): ?>
								<li><strong>PCRE:</strong> You have PCRE support installed. <em>No problems here.</em></li>
								<?php if ($curl_ok): ?>
									<li><strong>cURL:</strong> You have <code>cURL</code> support installed.  <em>No problems here.</em></li>
								<?php else: ?>
									<li><strong>cURL:</strong> The <code>cURL</code> extension is not available.  SimplePie will use <code>fsockopen()</code> instead.</li>
								<?php endif; ?>
	
								<?php if ($zlib_ok): ?>
									<li><strong>Zlib:</strong> You have <code>Zlib</code> enabled.  This allows SimplePie to support GZIP-encoded feeds.  <em>No problems here.</em></li>
								<?php else: ?>
									<li><strong>Zlib:</strong> The <code>Zlib</code> extension is not available.  SimplePie will ignore any GZIP-encoding, and instead handle feeds as uncompressed text.</li>
								<?php endif; ?>
	
								<?php if ($mbstring_ok && $iconv_ok): ?>
									<li><strong>mbstring and iconv:</strong> You have both <code>mbstring</code> and <code>iconv</code> installed!  This will allow SimplePie to handle the greatest number of languages.  Check the <a href="http://simplepie.org/wiki/faq/supported_character_encodings">Supported Character Encodings</a> chart to see what's supported on your webhost.</li>
								<?php elseif ($mbstring_ok): ?>
									<li><strong>mbstring:</strong> <code>mbstring</code> is installed, but <code>iconv</code> is not.  Check the <a href="http://simplepie.org/wiki/faq/supported_character_encodings">Supported Character Encodings</a> chart to see what's supported on your webhost.</li>
								<?php elseif ($iconv_ok): ?>
									<li><strong>iconv:</strong> <code>iconv</code> is installed, but <code>mbstring</code> is not.  Check the <a href="http://simplepie.org/wiki/faq/supported_character_encodings">Supported Character Encodings</a> chart to see what's supported on your webhost.</li>
								<?php else: ?>
									<li><strong>mbstring and iconv:</strong> <em>You do not have either of the extensions installed.</em> This will significantly impair your ability to read non-English feeds, as well as even some English ones.  Check the <a href="http://simplepie.org/wiki/faq/supported_character_encodings">Supported Character Encodings</a> chart to see what's supported on your webhost.</li>
								<?php endif; ?>
							<?php else: ?>
								<li><strong>PCRE:</strong> Your PHP installation doesn't support Perl-Compatible Regular Expressions.  <em>SimplePie is a no-go at the moment.</em></li>
							<?php endif; ?>
						<?php else: ?>
							<li><strong>XML:</strong> Your PHP installation doesn't support XML parsing.  <em>SimplePie is a no-go at the moment.</em></li>
						<?php endif; ?>
					<?php else: ?>
						<li><strong>PHP:</strong> You are running an unsupported version of PHP.  <em>SimplePie is a no-go at the moment.</em></li>
					<?php endif; ?>
				<?php endif; ?>
			</ol>
		</div>

		<div class="chunk">
			<?php if ($php_ok && $xml_ok && $pcre_ok && $mbstring_ok && $iconv_ok) { ?>
				<h3>Bottom Line: Yes, you can!</h3>
				<p><em>Your webhost has its act together!</em></p>
				<p>You can download the latest version of SimplePie from <a href="http://simplepie.org/downloads/">SimplePie.org</a> and install it by <a href="http://simplepie.org/wiki/setup/start">following the instructions</a>.  You can find example uses with <a href="http://simplepie.org/ideas/">SimplePie Ideas</a>.</p>
				<p>Take the time to read <a href="http://simplepie.org/wiki/setup/start">Requirements and Getting Started</a> to make sure you're prepared to use SimplePie. No seriously, read them.</p>
				<p class="footnote"><em><strong>Note</strong></em>: Passing this test does not guarantee that SimplePie will run on your webhost &mdash; it only ensures that the basic requirements have been addressed.</p>
			<?php } else if ($php_ok && $xml_ok && $pcre_ok) { ?>
				<h3>Bottom Line: Yes, you can!</h3>
				<p><em>For most feeds, it'll run with no problems.</em>  There are <a href="http://simplepie.org/wiki/faq/supported_character_encodings">certain languages</a> that you might have a hard time with though.</p>
				<p>You can download the latest version of SimplePie from <a href="http://simplepie.org/downloads/">SimplePie.org</a> and install it by <a href="http://simplepie.org/wiki/setup/start">following the instructions</a>.  You can find example uses with <a href="http://simplepie.org/ideas/">SimplePie Ideas</a>.</p>
				<p>Take the time to read <a href="http://simplepie.org/wiki/setup/start">Requirements and Getting Started</a> to make sure you're prepared to use SimplePie. No seriously, read them.</p>
				<p class="footnote"><em><strong>Note</strong></em>: Passing this test does not guarantee that SimplePie will run on your webhost &mdash; it only ensures that the basic requirements have been addressed.</p>
			<?php } else { ?>
				<h3>Bottom Line: We're sorry…</h3>
				<p><em>Your webhost does not support the minimum requirements for SimplePie.</em>  It may be a good idea to contact your webhost, and ask them to install a more recent version of PHP as well as the <code>xmlreader</code>, <code>xml</code>, <code>mbstring</code>, <code>iconv</code>, <code>curl</code>, and <code>zlib</code> extensions.</p>
			<?php } ?>
		</div>

		<div class="chunk">
			<p class="footnote">&sup1; &mdash; Some recent versions of the PCRE (PERL-Compatible Regular Expression) engine compiled into PHP have been buggy, and are the source of PHP segmentation faults (e.g. crashes) which cause random things like blank, white screens. Check the <a href="http://simplepie.org/support/">Support Forums</a> for the latest information on patches and ongoing fixes.</p>
		</div>

	</div>

</div>

</body>
</html>