[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/lib/pear/Net/GeoIP/ -> DMA.php (source)

   1  <?php
   2  /**
   3   * +----------------------------------------------------------------------+
   4   * | PHP version 5                                                        |
   5   * +----------------------------------------------------------------------+
   6   * | Copyright (C) 2004 MaxMind LLC                                       |
   7   * +----------------------------------------------------------------------+
   8   * | This library is free software; you can redistribute it and/or        |
   9   * | modify it under the terms of the GNU Lesser General Public           |
  10   * | License as published by the Free Software Foundation; either         |
  11   * | version 2.1 of the License, or (at your option) any later version.   |
  12   * |                                                                      |
  13   * | This library is distributed in the hope that it will be useful,      |
  14   * | but WITHOUT ANY WARRANTY; without even the implied warranty of       |
  15   * | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU    |
  16   * | Lesser General Public License for more details.                      |
  17   * |                                                                      |
  18   * | You should have received a copy of the GNU Lesser General Public     |
  19   * | License along with this library; if not, write to the Free Software  |
  20   * | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 |
  21   * | USA, or view it online at http://www.gnu.org/licenses/lgpl.txt.      |
  22   * +----------------------------------------------------------------------+
  23   * | Authors: Jim Winstead <jimw@apache.org> (original Maxmind version)   |
  24   * |          Hans Lellelid <hans@xmpl.org>                               |
  25   * +----------------------------------------------------------------------+
  26   *
  27   * @category Net
  28   * @package  Net_GeoIP
  29   * @author   Hans Lellelid <hans@xmpl.org>
  30   * @license  LGPL http://www.gnu.org/licenses/lgpl.txt
  31   * @link     http://pear.php.net/package/Net_GeoIp
  32   * $Id$
  33   */
  34  
  35  /**
  36   * Static class to handle mapping of DMA codes to metro regions.
  37   * 
  38   * Use this class with the dmaCode property of the Net_GeoIpLocation object.
  39   * 
  40   * <code>
  41   * $region = Net_GeoIPDMA::getMetroRegion($record->dmaCode);
  42   * </code>
  43   * 
  44   * @category Net
  45   * @package  Net_GeoIP
  46   * @author   Hans Lellelid <hans@xmpl.org>
  47   * @author   Dmitri Snytkine <d.snytkine@gmail.com>
  48   * @license  LGPL http://www.gnu.org/licenses/lgpl.txt
  49   * @version  $Revision$
  50   * @link     http://pear.php.net/package/Net_GeoIp
  51   */
  52  class Net_GeoIP_DMA
  53  {
  54      /**
  55       * Holds DMA -> Metro mapping.
  56       * @var array
  57       */
  58      private static $dmaMap;
  59      
  60      /**
  61       * Initialize
  62       * 
  63       * @return void
  64       */
  65      public static function initialize()
  66      {
  67          self::$dmaMap = array(
  68              500 => 'Portland-Auburn, ME',
  69              501 => 'New York, NY',
  70              502 => 'Binghamton, NY',
  71              503 => 'Macon, GA',
  72              504 => 'Philadelphia, PA',
  73              505 => 'Detroit, MI',
  74              506 => 'Boston, MA',
  75              507 => 'Savannah, GA',
  76              508 => 'Pittsburgh, PA',
  77              509 => 'Ft Wayne, IN',
  78              510 => 'Cleveland, OH',
  79              511 => 'Washington, DC',
  80              512 => 'Baltimore, MD',
  81              513 => 'Flint, MI',
  82              514 => 'Buffalo, NY',
  83              515 => 'Cincinnati, OH',
  84              516 => 'Erie, PA',
  85              517 => 'Charlotte, NC',
  86              518 => 'Greensboro, NC',
  87              519 => 'Charleston, SC',
  88              520 => 'Augusta, GA',
  89              521 => 'Providence, RI',
  90              522 => 'Columbus, GA',
  91              523 => 'Burlington, VT',
  92              524 => 'Atlanta, GA',
  93              525 => 'Albany, GA',
  94              526 => 'Utica-Rome, NY',
  95              527 => 'Indianapolis, IN',
  96              528 => 'Miami, FL',
  97              529 => 'Louisville, KY',
  98              530 => 'Tallahassee, FL',
  99              531 => 'Tri-Cities, TN',
 100              532 => 'Albany-Schenectady-Troy, NY',
 101              533 => 'Hartford, CT',
 102              534 => 'Orlando, FL',
 103              535 => 'Columbus, OH',
 104              536 => 'Youngstown-Warren, OH',
 105              537 => 'Bangor, ME',
 106              538 => 'Rochester, NY',
 107              539 => 'Tampa, FL',
 108              540 => 'Traverse City-Cadillac, MI',
 109              541 => 'Lexington, KY',
 110              542 => 'Dayton, OH',
 111              543 => 'Springfield-Holyoke, MA',
 112              544 => 'Norfolk-Portsmouth, VA',
 113              545 => 'Greenville-New Bern-Washington, NC',
 114              546 => 'Columbia, SC',
 115              547 => 'Toledo, OH',
 116              548 => 'West Palm Beach, FL',
 117              549 => 'Watertown, NY',
 118              550 => 'Wilmington, NC',
 119              551 => 'Lansing, MI',
 120              552 => 'Presque Isle, ME',
 121              553 => 'Marquette, MI',
 122              554 => 'Wheeling, WV',
 123              555 => 'Syracuse, NY',
 124              556 => 'Richmond-Petersburg, VA',
 125              557 => 'Knoxville, TN',
 126              558 => 'Lima, OH',
 127              559 => 'Bluefield-Beckley-Oak Hill, WV',
 128              560 => 'Raleigh-Durham, NC',
 129              561 => 'Jacksonville, FL',
 130              563 => 'Grand Rapids, MI',
 131              564 => 'Charleston-Huntington, WV',
 132              565 => 'Elmira, NY',
 133              566 => 'Harrisburg-Lancaster-Lebanon-York, PA',
 134              567 => 'Greenville-Spartenburg, SC',
 135              569 => 'Harrisonburg, VA',
 136              570 => 'Florence-Myrtle Beach, SC',
 137              571 => 'Ft Myers, FL',
 138              573 => 'Roanoke-Lynchburg, VA',
 139              574 => 'Johnstown-Altoona, PA',
 140              575 => 'Chattanooga, TN',
 141              576 => 'Salisbury, MD',
 142              577 => 'Wilkes Barre-Scranton, PA',
 143              581 => 'Terre Haute, IN',
 144              582 => 'Lafayette, IN',
 145              583 => 'Alpena, MI',
 146              584 => 'Charlottesville, VA',
 147              588 => 'South Bend, IN',
 148              592 => 'Gainesville, FL',
 149              596 => 'Zanesville, OH',
 150              597 => 'Parkersburg, WV',
 151              598 => 'Clarksburg-Weston, WV',
 152              600 => 'Corpus Christi, TX',
 153              602 => 'Chicago, IL',
 154              603 => 'Joplin-Pittsburg, MO',
 155              604 => 'Columbia-Jefferson City, MO',
 156              605 => 'Topeka, KS',
 157              606 => 'Dothan, AL',
 158              609 => 'St Louis, MO',
 159              610 => 'Rockford, IL',
 160              611 => 'Rochester-Mason City-Austin, MN',
 161              612 => 'Shreveport, LA',
 162              613 => 'Minneapolis-St Paul, MN',
 163              616 => 'Kansas City, MO',
 164              617 => 'Milwaukee, WI',
 165              618 => 'Houston, TX',
 166              619 => 'Springfield, MO',
 167              620 => 'Tuscaloosa, AL',
 168              622 => 'New Orleans, LA',
 169              623 => 'Dallas-Fort Worth, TX',
 170              624 => 'Sioux City, IA',
 171              625 => 'Waco-Temple-Bryan, TX',
 172              626 => 'Victoria, TX',
 173              627 => 'Wichita Falls, TX',
 174              628 => 'Monroe, LA',
 175              630 => 'Birmingham, AL',
 176              631 => 'Ottumwa-Kirksville, IA',
 177              632 => 'Paducah, KY',
 178              633 => 'Odessa-Midland, TX',
 179              634 => 'Amarillo, TX',
 180              635 => 'Austin, TX',
 181              636 => 'Harlingen, TX',
 182              637 => 'Cedar Rapids-Waterloo, IA',
 183              638 => 'St Joseph, MO',
 184              639 => 'Jackson, TN',
 185              640 => 'Memphis, TN',
 186              641 => 'San Antonio, TX',
 187              642 => 'Lafayette, LA',
 188              643 => 'Lake Charles, LA',
 189              644 => 'Alexandria, LA',
 190              646 => 'Anniston, AL',
 191              647 => 'Greenwood-Greenville, MS',
 192              648 => 'Champaign-Springfield-Decatur, IL',
 193              649 => 'Evansville, IN',
 194              650 => 'Oklahoma City, OK',
 195              651 => 'Lubbock, TX',
 196              652 => 'Omaha, NE',
 197              656 => 'Panama City, FL',
 198              657 => 'Sherman, TX',
 199              658 => 'Green Bay-Appleton, WI',
 200              659 => 'Nashville, TN',
 201              661 => 'San Angelo, TX',
 202              662 => 'Abilene-Sweetwater, TX',
 203              669 => 'Madison, WI',
 204              670 => 'Ft Smith-Fay-Springfield, AR',
 205              671 => 'Tulsa, OK',
 206              673 => 'Columbus-Tupelo-West Point, MS',
 207              675 => 'Peoria-Bloomington, IL',
 208              676 => 'Duluth, MN',
 209              678 => 'Wichita, KS',
 210              679 => 'Des Moines, IA',
 211              682 => 'Davenport-Rock Island-Moline, IL',
 212              686 => 'Mobile, AL',
 213              687 => 'Minot-Bismarck-Dickinson, ND',
 214              691 => 'Huntsville, AL',
 215              692 => 'Beaumont-Port Author, TX',
 216              693 => 'Little Rock-Pine Bluff, AR',
 217              698 => 'Montgomery, AL',
 218              702 => 'La Crosse-Eau Claire, WI',
 219              705 => 'Wausau-Rhinelander, WI',
 220              709 => 'Tyler-Longview, TX',
 221              710 => 'Hattiesburg-Laurel, MS',
 222              711 => 'Meridian, MS',
 223              716 => 'Baton Rouge, LA',
 224              717 => 'Quincy, IL',
 225              718 => 'Jackson, MS',
 226              722 => 'Lincoln-Hastings, NE',
 227              724 => 'Fargo-Valley City, ND',
 228              725 => 'Sioux Falls, SD',
 229              734 => 'Jonesboro, AR',
 230              736 => 'Bowling Green, KY',
 231              737 => 'Mankato, MN',
 232              740 => 'North Platte, NE',
 233              743 => 'Anchorage, AK',
 234              744 => 'Honolulu, HI',
 235              745 => 'Fairbanks, AK',
 236              746 => 'Biloxi-Gulfport, MS',
 237              747 => 'Juneau, AK',
 238              749 => 'Laredo, TX',
 239              751 => 'Denver, CO',
 240              752 => 'Colorado Springs, CO',
 241              753 => 'Phoenix, AZ',
 242              754 => 'Butte-Bozeman, MT',
 243              755 => 'Great Falls, MT',
 244              756 => 'Billings, MT',
 245              757 => 'Boise, ID',
 246              758 => 'Idaho Falls-Pocatello, ID',
 247              759 => 'Cheyenne, WY',
 248              760 => 'Twin Falls, ID',
 249              762 => 'Missoula, MT',
 250              764 => 'Rapid City, SD',
 251              765 => 'El Paso, TX',
 252              766 => 'Helena, MT',
 253              767 => 'Casper-Riverton, WY',
 254              770 => 'Salt Lake City, UT',
 255              771 => 'Yuma, AZ',
 256              773 => 'Grand Junction, CO',
 257              789 => 'Tucson, AZ',
 258              790 => 'Albuquerque, NM',
 259              798 => 'Glendive, MT',
 260              800 => 'Bakersfield, CA',
 261              801 => 'Eugene, OR',
 262              802 => 'Eureka, CA',
 263              803 => 'Los Angeles, CA',
 264              804 => 'Palm Springs, CA',
 265              807 => 'San Francisco, CA',
 266              810 => 'Yakima-Pasco, WA',
 267              811 => 'Reno, NV',
 268              813 => 'Medford-Klamath Falls, OR',
 269              819 => 'Seattle-Tacoma, WA',
 270              820 => 'Portland, OR',
 271              821 => 'Bend, OR',
 272              825 => 'San Diego, CA',
 273              828 => 'Monterey-Salinas, CA',
 274              839 => 'Las Vegas, NV',
 275              855 => 'Santa Barbara, CA',
 276              862 => 'Sacramento, CA',
 277              866 => 'Fresno, CA',
 278              868 => 'Chico-Redding, CA',
 279              881 => 'Spokane, WA');
 280      }
 281      
 282      /**
 283       * Lookup the metro region based on the provided DMA code.
 284       * 
 285       * @param int $dmaCode The DMA code
 286       * 
 287       * @return string Metro region name.
 288       */
 289      public static function getMetroRegion($dmaCode)
 290      {
 291          if ($dmaCode === null) {
 292              return null;
 293          }
 294          if (self::$dmaMap === null) {
 295              self::initialize();
 296          }
 297          return self::$dmaMap[$dmaCode];
 298      }
 299  
 300      /**
 301       * Reverse lookup of DMA code if [exact] metro region name is known.
 302       * 
 303       * @param string $metro Metro region name.
 304       * 
 305       * @return int DMA code, or false if not found.
 306       */
 307      public static function getDMACode($metro)    
 308      {
 309          if (self::$dmaMap === null) {
 310              self::initialize();
 311          }
 312          return array_search($metro, self::$dmaMap);
 313      }
 314  
 315  }


Generated: Thu Aug 11 10:00:09 2016 Cross-referenced by PHPXref 0.7.1