Location: PHPKode > scripts > Verify ID > verify-id/verifyID.php
<?php
/*
 * verifyID
 * Copyright (C) 2005 Joshua Preston
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or (at
 * your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 * verifyID.php
 *
 * If this class doesn't work, be sure to check your php.ini file and
 * set allow_url_fopen to On.
 *
 *
 * allow_url_fopen = On
 *


Taken from www.verifymyidentification.com:

VerifyME is an international fraud prevention, age and identity verification service
that integrates a government-issued ID database check, algorithms and web-based signature
capture. VerifyMe performs both international identity verification and domestic identity
verification with age verification in most countries. The service provides merchants and
government agencies with Patriot Act compliance and compliance with age verification laws
and guidelines.

VerifyME eliminates costs associated with manual intervention, simplifies, automates and
streamlines the verification process. Verification information is returned real-time
through a cost-effective, web-based solution.

*/

/* This class is a handy wrapper to www.verifymyidentification.com */
class verifyID {
	var $submitdata;
	var $result;

	var $error_codes = array (
		"0" => "Successfully Verified",
		"2001" => "Missing Zip/Postal Code",
		"2002" => "No Account Found",
		"2003" => "Account Closed",
		"2004" => "Invalid DOB",
		"2005" => "Account Not Opened",
		"2006" => "Invalid Zip/Postal Code",
		"2007" => "Database Error Occurred",
		"2008" => "Missing State",
		"2009" => "DOB out of valid range for verification (i.e. 1/1/1995)",
		"2010" => "DOB before 1900",
		"2011" => "Missing or Invalid Verification Data",
		"2012" => "Missing DOB",
		"2013" => "Zip/State do not match",
		"2015" => "Must provide State or Zip",
		"2016" => "XX: Country Not Supported",
		"2017" => "ID# Not Submitted",
		"2030" => "VME is not available",
		"2031" => "Invalid IP",
		"2032" => "Invalid ID",
		"2050" => "Missing First Name",
		"2051" => "Missing Last Name",
		"2052" => "Missing Address",
		"2070" => "Missing Contact Phone",
		"2071" => "Missing Contact Email",
		"2072" => "Missing Contact Amount",
		"2073" => "Missing Phone",
		"2074" => "Missing Social Security No.",
		"2999" => "Invalid Acct Type",
		"2110" => "E-Sig Failure"
	);

	var $countries = array (
		"AL" => "Albania",
		"DZ" => "Algeria",
		"AD" => "Andorra",
		"AO" => "Angola",
		"AR" => "Argentina",
		"AM" => "Armenia",
		"AU" => "Australia",
		"AT" => "Austria",
		"AZ" => "Azerbaijan",
		"BS" => "Bahamas",
		"BD" => "Bangladesh",
		"BB" => "Barbados",
		"BY" => "Belarus",
		"BE" => "Belgium",
		"BO" => "Bolivia",
		"BA" => "Bosnia And Herzegovina",
		"BW" => "Botswana",
		"BR" => "Brazil",
		"BG" => "Bulgaria",
		"BF" => "Burkina Faso",
		"BI" => "Burundi",
		"KH" => "Cambodia",
		"CM" => "Cameroon",
		"CA" => "Canada",
		"CV" => "Cape Verde",
		"KY" => "Cayman Islands",
		"CL" => "Chile",
		"CN" => "China",
		"CO" => "Colombia",
		"CR" => "Costa Rica",
		"HR" => "Croatia",
		"CU" => "Cuba",
		"CY" => "Cyprus",
		"CZ" => "Czech Republic",
		"DK" => "Denmark",
		"DJ" => "Djibouti",
		"DM" => "Dominica",
		"DO" => "Dominican Republic",
		"EC" => "Ecuador",
		"EG" => "Egypt",
		"SV" => "El Salvador",
		"GQ" => "Equatorial Guinea",
		"ER" => "Eritrea",
		"EE" => "Estonia",
		"ET" => "Ethiopia",
		"FJ" => "Fiji",
		"FI" => "Finland",
		"FR" => "France",
		"GM" => "Gambia",
		"GE" => "Georgia",
		"DE" => "Germany",
		"GR" => "Greece",
		"GT" => "Guatemala",
		"GN" => "Guinea",
		"GY" => "Guyana",
		"HT" => "Haiti",
		"HN" => "Honduras",
		"HK" => "Hong Kong",
		"HU" => "Hungary",
		"IS" => "Iceland",
		"IN" => "India",
		"ID" => "Indonesia",
		"IR" => "Iran, Islamic Republic Of",
		"IQ" => "Iraq",
		"IE" => "Ireland",
		"IM" => "Isle of Man",
		"IL" => "Israel",
		"IT" => "Italy",
		"JM" => "Jamaica",
		"JP" => "Japan",
		"JO" => "Jordan",
		"KZ" => "Kazakstan",
		"KE" => "Kenya",
		"KI" => "Kiribati",
		"KR" => "Korea, Republic Of",
		"KW" => "Kuwait",
		"LV" => "Latvia",
		"LB" => "Lebanon",
		"LY" => "Libyan Arab Jamahiriya",
		"LI" => "Liechtenstein",
		"LT" => "Lithuania",
		"LU" => "Luxembourg",
		"MO" => "Macau",
		"MK" => "Macedonia",
		"MW" => "Malawi",
		"MY" => "Malaysia",
		"MV" => "Maldives",
		"ML" => "Mali",
		"MT" => "Malta",
		"MR" => "Mauritania",
		"MU" => "Mauritius",
		"MX" => "Mexico",
		"MD" => "Moldova, Republic Of",
		"MC" => "Monaco",
		"MN" => "Mongolia",
		"MA" => "Morocco",
		"MZ" => "Mozambique",
		"MM" => "Myanmar",
		"NP" => "Nepal",
		"NL" => "Netherlands",
		"AN" => "Netherlands Antilles",
		"NZ" => "New Zealand",
		"NI" => "Nicaragua",
		"NE" => "Niger",
		"NG" => "Nigeria",
		"NO" => "Norway",
		"OM" => "Oman",
		"PK" => "Pakistan",
		"PA" => "Panama",
		"PG" => "Papua New Guinea",
		"PE" => "Peru",
		"PH" => "Philippines",
		"PL" => "Poland",
		"PT" => "Portugal",
		"PR" => "Puerto Rico",
		"RO" => "Romania",
		"RU" => "Russian Federation",
		"KN" => "Saint Kitts And Nevis",
		"SM" => "San Marino",
		"SA" => "Saudi Arabia",
		"SN" => "Senegal",
		"SC" => "Seychelles",
		"SL" => "Sierra Leone",
		"SG" => "Singapore",
		"SK" => "Slovakia",
		"SI" => "Slovenia",
		"SO" => "Somalia",
		"ZA" => "South Africa",
		"ES" => "Spain",
		"LK" => "Sri Lanka",
		"SD" => "Sudan",
		"SR" => "Suriname",
		"SZ" => "Swaziland",
		"SE" => "Sweden",
		"CH" => "Switzerland",
		"SY" => "Syrian Arab Republic",
		"TW" => "Taiwan",
		"TZ" => "Tanzania, United Republic Of",
		"TH" => "Thailand",
		"TG" => "Togo",
		"TT" => "Trinidad And Tobago",
		"TN" => "Tunisia",
		"TR" => "Turkey",
		"UG" => "Uganda",
		"UA" => "Ukraine",
		"AE" => "United Arab Emirates",
		"GB" => "United Kingdom",
		"US" => "United States",
		"UY" => "Uruguay",
		"UZ" => "Uzbekistan",
		"VE" => "Venezuela",
		"YE" => "Yemen",
		"YU" => "Yugoslavia",
		"ZM" => "Zambia",
		"ZW" => "Zimbabwe"
	);

	var $ireland_counties = array (
		"CE" => "Co Clare",
		"CK" => "Co Cork",
		"CN" => "Co Cavan",
		"CW" => "Co Carlow",
		"DL" => "Co Donegal",
		"DN" => "Co Dublin",
		"DN1" => "Dublin 1",
		"DN2" => "Dublin 2",
		"DN3" => "Dublin 3",
		"DN4" => "Dublin 4",
		"DN5" => "Dublin 5",
		"DN6" => "Dublin 6",
		"DN6w" => "Dublin 6w",
		"DN7" => "Dublin 7",
		"DN8" => "Dublin 8",
		"DN9" => "Dublin 9",
		"DN10" => "Dublin 10",
		"DN11" => "Dublin 11",
		"DN12" => "Dublin 12",
		"DN13" => "Dublin 13",
		"DN14" => "Dublin 14",
		"DN15" => "Dublin 15",
		"DN16" => "Dublin 16",
		"DN17" => "Dublin 17",
		"DN18" => "Dublin 18",
		"DN20" => "Dublin 20",
		"DN22" => "Dublin 22",
		"DN24" => "Dublin 24",
		"GY" => "Co Galway",
		"KE" => "Co Kildare",
		"KK" => "Co Kilkenny",
		"KY" => "Co Kerry",
		"LD" => "Co Longford",
		"LH" => "Co Louth",
		"LK" => "Co Limerick",
		"LM" => "Co Leitrim",
		"LS" => "Co Laois",
		"MH" => "Co Meath",
		"MN" => "Co Monaghan",
		"MO" => "Co Mayo",
		"OY" => "Co Offaly",
		"RN" => "Co Roscommon",
		"SO" => "Co Sligo",
		"TY" => "Co Tipperary",
		"WD" => "Co Waterford",
		"WH" => "Co Westmeath",
		"WW" => "Co Wicklow",
		"WX" => "Co Wexford"
	);

	var $us_states = array (
		"AL" => "Alabama",
		"AK" => "Alaska",
		"AZ" => "Arizona",
		"AR" => "Arkansas",
		"CA" => "California",
		"CO" => "Colorado",
		"CT" => "Connecticut",
		"DE" => "Delaware",
		"DC" => "Dist. of Columbia",
		"FL" => "Florida",
		"GA" => "Georgia",
		"GU" => "Guam",
		"HI" => "Hawaii",
		"ID" => "Idaho",
		"IL" => "Illinois",
		"IN" => "Indiana",
		"IA" => "Iowa",
		"KS" => "Kansas",
		"KY" => "Kentucky",
		"LA" => "Louisiana",
		"ME" => "Maine",
		"MD" => "Maryland",
		"MA" => "Massachusetts",
		"MI" => "Michigan",
		"MN" => "Minnesota",
		"MS" => "Mississippi",
		"MO" => "Missouri",
		"MT" => "Montana",
		"NE" => "Nebraska",
		"NV" => "Nevada",
		"NH" => "New Hampshire",
		"NJ" => "New Jersey",
		"NM" => "New Mexico",
		"NY" => "New York",
		"NC" => "North Carolina",
		"ND" => "North Dakota",
		"OH" => "Ohio",
		"OK" => "Oklahoma",
		"OR" => "Oregon",
		"PA" => "Pennsylvania",
		"PR" => "Puerto Rico",
		"RI" => "Rhode Island",
		"SC" => "South Carolina",
		"SD" => "South Dakota",
		"TN" => "Tennessee",
		"TX" => "Texas",
		"UT" => "Utah",
		"VT" => "Vermont",
		"VA" => "Virginia",
		"VI" => "Virgin Islands",
		"WA" => "Washington",
		"WV" => "West Virginia",
		"WI" => "Wisconsin",
		"WY" => "Wyoming"
	);

	function getCountriesArray () {
		return $this->countries;
	}

	function getCountriesHtml () {
		$string = "<table>\n";

		foreach ( $this->countries as $code => $text ) {
			$string .= "	<tr>\n		<td>$code</td>\n		<td>$text</td>\n	</tr>\n";
		}

		$string .= "</table>\n";

		return $string;
	}

	function getCountriesDropDown () {
		$string = "	<select name=\"country\">\n";

		foreach ( $this->countries as $code => $text ) {
			$string .= "		<option value=\"$code\">$text</option>\n";
		}

		$string .= "	</select>\n";

		return $string;
	}

	function getUsStatesArray() {
		return $this->us_states;
	}

	function getUsStatesHtml () {
		$string = "<table>\n";

		foreach ( $this->us_states as $code => $text ) {
			$string .= "	<tr>\n		<td>$code</td>\n		<td>$text</td>\n	</tr>\n";
		}

		$string .= "</table>\n";

		return $string;
	}

	function getUsStatesDropDown () {
		$string = "	<select name=\"state\">\n";

		foreach ( $this->us_states as $code => $text ) {
			$string .= "		<option value=\"$code\">$text</option>\n";
		}

		$string .= "	</select>\n";

		return $string;
	}

	function getIrelandCountiesArray() {
		return $this->ireland_counties;
	}

	function getIrelandCountiesHtml () {
		$string = "<table>\n";

		foreach ( $this->ireland_counties as $code => $text ) {
			$string .= "	<tr>\n		<td>$code</td>\n		<td>$text</td>\n	</tr>\n";
		}

		$string .= "</table>\n";

		return $string;
	}

	function getIrelandCountiesDropDown () {
		$string = "	<select name=\"county\">\n";

		foreach ( $this->ireland_counties as $code => $text ) {
			$string .= "		<option value=\"$code\">$text</option>\n";
		}

		$string .= "	</select>\n";

		return $string;
	}

	function setCountry ( $string ) {
		if ( array_key_exists($string, $this->countries) ) {
			$string = strtoupper($string);
			$this->submitdata["country"] = substr($string, 0, 2);
			return true;
		} else {
			$code = array_search($string, $this->countries);
			if ( $code !== false ) {
				$this->submitdata["country"] = substr($code, 0, 2);
				return true;
			}
		}

		return false;
	}

	function setIrelandCounty ( $string ) {
		if ( array_key_exists($string, $this->ireland_counties) ) {
			$string = strtoupper($string);
			$this->submitdata["county"] = substr($string, 0, 2);
			return true;
		} else {
			$code = array_search($string, $this->ireland_counties);
			if ( $code !== false ) {
				$this->submitdata["county"] = substr($code, 0, 2);
				return true;
			}
		}

		return false;
	}

	function setUsState ( $string ) {
		if ( array_key_exists($string, $this->us_states) ) {
			$string = strtoupper($string);
			$this->submitdata["state"] = substr($string, 0, 2);
			return true;
		} else {
			$code = array_search($string, $this->us_states);
			if ( $code !== false ) {
				$this->submitdata["state"] = substr($code, 0,2);
				return true;
			}
		}

		return false;
	}

	function setData ( $code, $value ) {
		$this->submitdata[$code] = $value;
	}
	
	function getData ( $code ) {
		if ( isset($this->submitdata[$code] ) ) {
			return $this->submitdata[$code];
		} else {
			return null;
		}
	}
	
	function makeRequest ( ) {
		if ( isset( $this->submitdata["sid"] ) ) {
			// only process if we have the sid set
			$request = "https://www.kidsheriff.com/online/authentication_url.asp?";
			$request .= rawurlencode("sid") . "=" . rawurlencode($this->submitdata["sid"]);

			foreach ( $this->submitdata as $code => $text ) {
				if ( $code != "sid" ) {
					$request .= "&" . rawurlencode($code) ."=" . rawurlencode($text);
				}
			}
			return $request;
		} else {
			return null;
		}
	}

	function parseResult ( $string ) {
		$status = "";

		$temp = split('&', $string);

		foreach ( $temp as $key => $val ) {
			$arr = explode('=',$val);
			$status[$arr[0]] = $arr[1];
		}

		return $status;
	}

	function submitRequest ( ) {
		$request = $this->makeRequest();
		$result = "";
		$nHandle = "";

		if ( $request != null ) {
			$nHandle= fopen($request,"r");
			$result = fgets($nHandle,4096);
			fclose($nHandle);
		}

		$this->result = $this->parseResult($result);

		if ( $this->result["err_code"] == "0" ) {
			$this->result["err_desc"] = $this->error_codes["0"];
		}
	}

	function getTransactionId () {
		if ( isset($this->result["tid"] ) ) {
			return $this->result["tid"];
		}
		else {
			return null;
		}
	}

	function getErrorCode ( ) {
		if ( isset($this->result["err_code"]) ) {
			return $this->result["err_code"];
		}
		else {
			return null;
		}
	}

	function getErrorCodeText ( ) {
		if ( isset($this->result["err_desc"]) ) {
			return $this->result["err_desc"];
		} else {
			return null;
		}
	}

	function getMatchCode ( ) {
		if ( isset($this->result["mc"]) ) {
			return $this->result["mc"];
		} else {
			return null;
		}
	}

	function isVerified ( ) {
		if ( isset($this->result["err_code"]) && $this->result["err_code"] == "0" ) {
			return true;
		} else {
			return false;
		}
	}

	function getDataXML ( ) {
		$string = "<?xml version=\"1.0\"?>\n	<person>\n";

		foreach ( $this->submitdata as $key => $value ) {
			$string .= "		<$key>$value</$key>\n";
		}

		$string .= "	</person>\n";
		return $string;
	}

	function getResultXML ( ) {
		$string = "<?xml version=\"1.0\"?>\n	<result>\n";

		foreach ( $this->result as $key => $value ) {
			$string .= "		<$key>$value</$key>\n";
		}

		$string .= "	</result>\n";
		return $string;
	}
}
?>
Return current item: Verify ID