function __env($key) { if (isset($_SERVER[$key])) { return $_SERVER[$key]; } elseif (isset($_ENV[$key])) { return $_ENV[$key]; } elseif (getenv($key) !== false) { return getenv($key); } if ($key == 'DOCUMENT_ROOT') { $offset = 0; if (!strpos(__env('SCRIPT_NAME'), '.php')) { $offset = 4; } return substr(__env('SCRIPT_FILENAME'), 0, strlen(__env('SCRIPT_FILENAME')) - (strlen(__env('SCRIPT_NAME')) + $offset)); } if ($key == 'PHP_SELF') { return r(__env('DOCUMENT_ROOT'), '', __env('SCRIPT_FILENAME')); } return null; }
{ $value = $_ENV[$key]; return empty($value) ? $default : $value; } $DEFAULT_HOST = "dbmaster1"; $DEFAULT_USER = "******"; $DEFAULT_PWD = "BUAAnic@ihome2012"; $host = __env("IHOME_DBHOST", $DEFAULT_HOST); $user = __env("IHOME_DBUSER", $DEFAULT_USER); $pwd = __env("IHOME_DBPWD", $DEFAULT_PWD); $slave_host = __env("IHOME_SLAVE_HOST", $DEFAULT_HOST); $slave_user = __env("IHOME_SLAVE_USER", $DEFAULT_USER); $slave_pwd = __env("IHOME_SLAVE_PWD", $DEFAULT_PWD); $mongo_host = __env("IHOME_MONGO_HOST", $DEFAULT_HOST); $mongo_user = __env("IHOME_MONGO_USER", $DEFAULT_USER); $mongo_pwd = __env("IHOME_MONGO_PWD", $DEFAULT_PWD); $_SC = array(); $_SC['dbhost'] = $host; //????????ַ $_SC['dbuser'] = $user; //?û? $_SC['dbpw'] = $pwd; //???? $_SC['dbcharset'] = 'utf8'; //?ַ??? $_SC['pconnect'] = 0; //?Ƿ?????��?? $_SC['dbname'] = 'ihome'; //???ݿ? $_SC['tablepre'] = 'ihome_'; //????ǰ