|
<?php |
|
|
|
define('__TYPECHO_ROOT_DIR__', dirname(__FILE__)); |
|
|
|
|
|
define('__TYPECHO_PLUGIN_DIR__', '/usr/plugins'); |
|
|
|
|
|
define('__TYPECHO_THEME_DIR__', '/usr/themes'); |
|
|
|
|
|
define('__TYPECHO_ADMIN_DIR__', '/admin/'); |
|
|
|
|
|
require_once __TYPECHO_ROOT_DIR__ . '/var/Typecho/Common.php'; |
|
|
|
|
|
\Typecho\Common::init(); |
|
|
|
|
|
if(!getenv('DB_HOST')){ |
|
$matches = []; |
|
preg_match("/^(mysql:\/\/)?([^:]*?):(.*?)@([^@^:]*?):?(\d+)?\/([^\/]*?)$/", getenv('DB_COON_STR'), $matches); |
|
putenv('DB_USER='.$matches[2]); |
|
putenv('DB_PASS='.$matches[3]); |
|
putenv('DB_HOST='.$matches[4]); |
|
putenv('DB_PORT='.($matches[5] ? $matches[5] : '3306')); |
|
putenv('DB_NAME='.$matches[6]); |
|
} |
|
|
|
|
|
$db = new \Typecho\Db('Pdo_Mysql', 'typecho_'); |
|
$db->addServer(array ( |
|
'host' => getenv('DB_HOST'), |
|
'port' => intval(getenv('DB_PORT')), |
|
'user' => getenv('DB_USER'), |
|
'password' => getenv('DB_PASS'), |
|
'charset' => 'utf8mb4', |
|
'database' => getenv('DB_NAME'), |
|
'engine' => 'InnoDB', |
|
'sslCa' => '', |
|
'sslVerify' => true, |
|
), \Typecho\Db::READ | \Typecho\Db::WRITE); |
|
\Typecho\Db::set($db); |
|
|