edwagbb commited on
Commit
d20961a
·
1 Parent(s): fc0c1a3

Update config.inc.php

Browse files
Files changed (1) hide show
  1. config.inc.php +21 -2
config.inc.php CHANGED
@@ -17,9 +17,28 @@ require_once __TYPECHO_ROOT_DIR__ . '/var/Typecho/Common.php';
17
  // init
18
  \Typecho\Common::init();
19
 
 
 
 
 
 
 
 
 
 
 
 
20
  // config db
21
- $db = new \Typecho\Db('SQLite', 'typecho_');
22
  $db->addServer(array (
23
- 'file' => '/var/www/typecho.db',
 
 
 
 
 
 
 
 
24
  ), \Typecho\Db::READ | \Typecho\Db::WRITE);
25
  \Typecho\Db::set($db);
 
17
  // init
18
  \Typecho\Common::init();
19
 
20
+ //'mysql://user:pass@x.x.x.x:3306/dbname'
21
+ if(!getenv('DB_HOST')){
22
+ $matches = [];
23
+ preg_match("/^(mysql:\/\/)?([^:]*?):(.*?)@([^@^:]*?):?(\d+)?$/", getenv('DB_COON_STR'), $matches);
24
+ putenv('DB_USER='.$matches[2]);
25
+ putenv('DB_PASS='.$matches[3]);
26
+ putenv('DB_HOST='.$matches[4]);
27
+ putenv('DB_PORT='.($matches[5] ? $matches[5] : '3306'));
28
+ putenv('DB_NAME='.$matches[6]);
29
+ }
30
+
31
  // config db
32
+ $db = new \Typecho\Db('Pdo_Mysql', 'typecho_');
33
  $db->addServer(array (
34
+ 'host' => getenv('DB_HOST'),
35
+ 'port' => intval(getenv('DB_PORT')),
36
+ 'user' => getenv('DB_USER'),
37
+ 'password' => getenv('DB_PASS'),
38
+ 'charset' => 'utf8mb4',
39
+ 'database' => getenv('DB_NAME'),
40
+ 'engine' => 'InnoDB',
41
+ 'sslCa' => '',
42
+ 'sslVerify' => true,
43
  ), \Typecho\Db::READ | \Typecho\Db::WRITE);
44
  \Typecho\Db::set($db);