Advertisement
Guest User

modethirteen

a guest
Apr 15th, 2009
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.30 KB | None | 0 0
  1. <?php
  2. class DATABASE_CONFIG {
  3.  
  4.     # home server  
  5.     var $home = array(
  6.         'driver' => 'mysql',
  7.         'persistent' => false,
  8.         'host' => 'localhost',
  9.         'login' => '',
  10.         'password' => '',
  11.         'database' => '_home',
  12.     );
  13.  
  14.     # dev server
  15.     var $dev = array(
  16.         'driver' => 'mysql',
  17.         'persistent' => false,
  18.         'host' => 'mysql.devsite.com',
  19.         'login' => '',
  20.         'password' => '',
  21.         'database' => '_dev',
  22.     );
  23.  
  24.     # live server
  25.     var $live = array(
  26.         'driver' => 'mysql',
  27.         'persistent' => false,
  28.         'host' => 'mysql.livesite.com',
  29.         'login' => '',
  30.         'password' => '',
  31.         'database' => '_live',
  32.     );
  33.  
  34.     # switch between configs
  35.     var $default = array();
  36.     var $test = array();
  37.     function __construct() {
  38.  
  39.         #wildcard the subdomains
  40.         $host_r = explode('.', $_SERVER['SERVER_NAME']);
  41.         if(count($host_r)>2) while(count($host_r)>2)array_shift($host_r);
  42.         $mainhost = implode('.', $host_r);
  43.  
  44.         #switch between servers
  45.         switch(strtolower($mainhost)) {
  46.             case 'workstation':
  47.                 $this->default = $this->home;
  48.                 break;
  49.             case 'dojoserver.com':
  50.                 $this->default = $this->live;
  51.                 break;
  52.             case 'remotedojo.com':
  53.                 $this->default = $this->dev;
  54.                 break;
  55.             default:
  56.                 $this->default = $this->home;
  57.         }
  58.     }
  59.  
  60.     #php 4 compatibility
  61.     function DATABASE_CONFIG() {
  62.         $this->__construct();
  63.     }
  64. }
  65. ?>
  66.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement