<?php
	if (!extension_loaded('infosec'))
        {
                if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN')
                {
                        dl('php_infosec.dll');
                }
                else
                {
                        dl('infosec.so');
                }
        }
        else
        {
                echo "loaded infosec module success <br/>";
        }
	if(isset($_POST["getcertid"]))
	{
		$certfile=$_POST["cert"];
		if(strlen($certfile) <= 0)
		{
			echo "WARNING : no input data<br/>";
			exit();
		}
		$fp = fopen($certfile,"rb");
        	if($fp == NULL)
        	{
                	echo "open file error<br/>";
                	exit();
        	}

        	fseek($fp,0,SEEK_END);
        	$filelen=ftell($fp);
        	fseek($fp,0,SEEK_SET);
        	$cert = fread($fp,$filelen);
        	fclose($fp);
		
		$certID = getCertID($cert);
		#echo $certID,"<br/>";
		echo "CertID : ",current($certID),"<br/>";
		echo "CertID len: ",next($certID),"<br/>";
	}
	exit();
?>
