<?php
/**
 * 小于  lt
 * 小于等于 le
 * 大于  gt
 * 大于等于 ge
 * 等于 eq
 * 不等于 ne。
 *
 */
class version
{
		public static function getClientVer()
		{
			return isset($_POST['version']) ? $_POST['version'] : '1.0.0.0';
		}

		public static function lt($ver)
		{
			$clientVer = self::getClientVer();
			if (version_compare($clientVer, $ver, '<'))
			{
				return true;
			}
			return false;
		}

		public static function le($ver)
		{
			$clientVer = self::getClientVer();
			if (version_compare($clientVer, $ver, '<='))
			{
				return true;
			}
			return false;
		}

		public static function eq($ver)
		{
			$clientVer = self::getClientVer();
			if (version_compare($clientVer, $ver, '='))
			{
				return true;
			}
			return false;
		}
		public static function eq2($ver)
		{
			$clientVer = self::getClientVer();
			$v1 = explode('.',$clientVer);
    		$v2 = explode('.',$ver);
    		if($v1[0] == $v2[0] && $v1[1] == $v2[1] && $v1[2] == $v2[2]){
    			return true;
    		}
			return false;
		}

		public static function ne($ver)
		{
			$clientVer = self::getClientVer();
			if (version_compare($clientVer, $ver, '!='))
			{
				return true;
			}
			return false;
		}

		public static function gt($ver)
		{
			$clientVer = self::getClientVer();
			if (version_compare($clientVer, $ver, '>'))
			{
				return true;
			}
			return false;
		}

		public static function ge($ver)
		{
			$clientVer = self::getClientVer();
			if (version_compare($clientVer, $ver, '>='))
			{
				return true;
			}
			return false;
		}
}
