Reply to Re: PhP vin decoder

Your name:

Reply:


Posted by Steve on 11/05/06 00:57

<?
require_once 'vin.manufacturer.interface.php';

class toyota implements manufacturer
{
private $_bodies = array(
'{3}A' => '2 DOOR SEDAN 2 WHEEL
DRIVE' ,
'{3}B' => '4 DOOR SEDAN 2 WHEEL
DRIVE' ,
'{3}C' => '2 DOOR COUPE 2 WHEEL
DRIVE' ,
'{3}D' => '3 DOOR LIFTBACK 2WD'
,
'{3}F' => '2 DOOR CONVERTIBLE 2WD'
,
'{3}G' => '4 DOOR WAGON 2 WD'
,
'{3}H' => '4 DOOR WAGON 4 WHEEL
DRIVE' ,
'{3}J' => '4 DOOR TRUCK 2 WHEEL
DRIVE' ,
'{3}K' => '5 DOOR WAGON 2 WHEEL
DRIVE' ,
'{3}L' => '5 DOOR WAGON 4 WHEEL
DRIVE' ,
'{3}M' => '5 DOOR DOOR VAN 2 WHEEL
DRIVE' ,
'{3}Z' => '5 DOOR WAGON 2 WHEEL
DRIVE'
);
private $_engines = array(
'{4}[APG]' => '3.3L DOHC'
,
'{4}[BK]' => '1.0L DOHC'
,
'{4}[DEL]' => '2.4L DOHC 16 VALVE'
,
'{4}F' => '1.0L DOHC'
,
'{4}H' => '2.0L DOHC 16 VALVE'
,
'{4}M' => '2.7L DOHC L-4'
,
'{4}N' => '3.4L DOHC'
,
'{4}R' => '1.8L DOHC 16 VALVE'
,
'{4}S' => '1BM'
,
'{4}T' => '4.7L DOHC'
,
'{4}U' => '1.0L DOHC/VVT-I'
);
private $_manufacturers = array(
'N' => 'NUMMI'
,
'[^N]' => 'TOYOTA'
);
private $_models = array(
'{7}0' => 'MR2 SPYDER'
,
'{7}1' => 'TUNDRA'
,
'{7}3' => 'ECHO'
,
'{7}4' => 'SCION XA OR XB'
,
'{7}A' => 'HIGHLANDER OR SEQUOIA'
,
'{7}B' => 'AVALON'
,
'{7}C' => 'SIENNA'
,
'{7}E' => 'COROLLA OR MATRIX'
,
'{7}J' => 'LAND CRUISER'
,
'{7}K' => 'CAMRY'
,
'{7}N' => 'TACOMA'
,
'{7}P' => 'CAMRY SOLARA'
,
'{7}R' => '4RUNNER OR COROLLA'
,
'{7}T' => 'CELICA'
,
'{7}U' => 'PRIUS'
,
'{7}V' => 'RAV4/RAV4-EV'
);
private $_plants = array(
'{10}[0-9]' => 'JAPAN'
,
'{10}C' => 'CAMBRIDGE, ONTARIO'
,
'{10}S' => 'PRINCETON, IN'
,
'{10}U' => 'GEORGETOWN, KY'
,
'{10}Z' => 'FREMONT, CA'
);
private $_restraints = array(
'{6}0' => 'MANUAL BELTS WITH 2
AIRBAGS AND CURTAIN AIRBAGS' ,
'{6}1' => 'MANUAL BELT WITH 1
STANDARD' ,
'{6}2' => 'MANUAL BELTS WITH 2
AIRBAGS' ,
'{6}3' => 'MANUAL BELTS WITH 2
AIRBAGS' ,
'{6}8' => 'MANUAL BELTS WITH 2
AIRBAGS AND SIDE AIRBAGS'
);
private $_types = array(
'{2}1' => 'PASSENGER CAR'
,
'{2}2' => 'PASSENGER CAR'
,
'{2}3' => 'MULTIPURPOSE PASSENGER
VEHICLE' ,
'{2}5' => 'INCOMPLETE VEHICLE'
,
'{2}B' => 'TRUCK'
,
'{2}D' => 'PASSENGER CAR'
,
'{2}E' => 'MULTIPURPOSE PASSENGER
VEHICLE' ,
'{2}K' => 'PASSENGER CAR'
,
'{2}L' => 'MULTIPURPOSE PASSENGER
VEHICLE' ,
'{2}M' => 'TRUCK'
,
'{2}X' => 'PASSENGER CAR'
);

private $_body = '';
private $_country = '';
private $_engine = '';
private $_manufacturer = '';
private $_model = '';
private $_plant = '';
private $_rating = '';
private $_restraint = '';
private $_serial = '';
private $_series = '';
private $_type = '';
private $_vin = '';
private $_year = '';

public function __construct($country = '', $vin = 'JTEGH20V910032005')
{
$this->_country = $country;
$this->_vin = strtoupper($vin);
$this->_body = $this->getValue($this->_bodies);
$this->_engine = $this->getValue($this->_engines);
$this->_manufacturer = $this->getValue($this->_manufacturers);
$this->_model = $this->getValue($this->_models);
$this->_plant = $this->getValue($this->_plants);
$this->_restraint = $this->getValue($this->_restraints);
$this->_serial = substr($vin, -6);
$this->_series = substr($vin, 5, 1);
$this->_type = $this->getValue($this->_types);
$this->_year = substr($vin, 9, 1);
$yearDiff = date('Y') - 1980;
$yearOffset = 0;
if ($this->_year < 1 || $this->_year > 9)
{
$yearOffset = ord($this->_year) - ord('A');
if (ord($this->_year) > ord('I')){ $yearOffset--; }
if (ord($this->_year) > ord('O')){ $yearOffset--; }
if (ord($this->_year) > ord('Q')){ $yearOffset--; }
} else {
$yearOffset = 21;
}
$this->_year = 1980 + (30 * floor($yearDiff / 30)) + $yearOffset;
}

public function getBody(){ return $this->_body; }
public function getCountry(){ return $this->_country; }
public function getEngine(){ return $this->_engine; }
public function getManufacturer(){ return $this->_manufacturer; }
public function getModel(){ return $this->_model; }
public function getPlant(){ return $this->_plant; }
public function getRating(){ return $this->_rating; }
public function getRestraints(){ return $this->_restraint; }
public function getSerial(){ return $this->_serial; }
public function getSeries(){ return $this->_series; }
public function getType(){ return $this->_type; }
public function getVIN(){ return $this->_vin; }
public function getYear(){ return $this->_year; }

private function getValue($array, $usePrefix = true)
{
foreach ($array as $pattern => $value)
{
$prefix = $usePrefix ? '^[A-HJ-NPR-Z0-9]' : '';
$pattern = '/' . $prefix . $pattern . '/';
if (preg_match($pattern, $this->_vin)){ return $value; }
}
return '';
}
}
?>

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация