<html>
<body>
<?php
error_reporting(E_ALL);
define('PHPMANUAL','./phpmanual');
if ((isset($_POST['checkversion'])) && ($_FILES['scriptfile']['size']>0))
{
$file=fopen($_FILES['scriptfile']['tmp_name'],'r');
$script=fread($file,filesize($_FILES['scriptfile']['tmp_name']));
fclose($file);
preg_match_all('/([\w]|[_])*[(]/',$script,$matches);
$results=array();
for ($x=0;$x<count($matches[0]);$x++)
{
if (($matches[0][$x]!='(') && (!in_array(str_replace('(','',$matches[0][$x]),$results)))
{
$results[]=str_replace('(','',$matches[0][$x]);
}
}
$minversion=0;
for ($x=0;$x<count($results);$x++)
{
if (file_exists(PHPMANUAL.'/function.'.str_replace('_','-',$results[$x]).'.html'))
{
$file=fopen(PHPMANUAL.'/function.'.str_replace('_','-',$results[$x]).'.html','r');
$info=fread($file,filesize(PHPMANUAL.'/function.'.str_replace('_','-',$results[$x]).'.html'));
fclose($file);
preg_match('|\(PHP.*\)</P|',$info,$matches);
if (!empty($matches))
{
$versions=explode(',',str_replace(' ','',str_replace('(','',str_replace(')</P','',$matches[0]))));
$requiredversion=$versions[0];
if (strpos($requiredversion,'='))
{
$requiredversion=substr($requiredversion,strpos($requiredversion,'=')+1);
}
else
{
$requiredversion=substr($requiredversion,3);
}
if ($requiredversion>$minversion)
{
$minversion=$requiredversion;
}
}
}
}
echo $_FILES['scriptfile']['name'].' requires PHP '.$minversion.'<hr>';
}
?>
<form method="post" action="versioncheck.php" enctype="multipart/form-data">
<input type="file" name="scriptfile">
<br>
<input type="submit" name="checkversion" value="Check version">
</form>
</body>
</html>