@@ -16,8 +16,8 @@ discard block |
||
16 | 16 | $eport = 3306; |
17 | 17 | } |
18 | 18 | if (!empty($eport)) { |
19 | - $config['DB_HOST'] = env('DB_PORT_' . $eport . '_TCP_ADDR'); |
|
20 | - $config['DB_PORT'] = env('DB_PORT_' . $eport . '_TCP_PORT'); |
|
19 | + $config['DB_HOST'] = env('DB_PORT_'.$eport.'_TCP_ADDR'); |
|
20 | + $config['DB_PORT'] = env('DB_PORT_'.$eport.'_TCP_PORT'); |
|
21 | 21 | } elseif (getenv('DB_PORT') === false) { |
22 | 22 | error('The env DB_PORT does not exist. Make sure to run with "--link mypostgresinstance:DB"'); |
23 | 23 | } elseif (is_numeric(getenv('DB_PORT')) && getenv('DB_HOST') !== false) { |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | $config['DB_TYPE'] = 'pgsql'; |
34 | 34 | break; |
35 | 35 | default: |
36 | - error('Database on non-standard port ' . $config['DB_PORT'] . ' and env DB_TYPE not present'); |
|
36 | + error('Database on non-standard port '.$config['DB_PORT'].' and env DB_TYPE not present'); |
|
37 | 37 | } |
38 | 38 | } |
39 | 39 | } |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | $config['DB_USER'] = env('DB_USER', $config['DB_NAME']); |
46 | 46 | $config['DB_PASS'] = env('DB_PASS', $config['DB_USER']); |
47 | 47 | if (!dbcheck($config)) { |
48 | - echo 'Database login failed, trying to create...' . PHP_EOL; |
|
48 | + echo 'Database login failed, trying to create...'.PHP_EOL; |
|
49 | 49 | // superuser account to create new database and corresponding user account |
50 | 50 | // username (SU_USER) can be supplied or defaults to "docker" |
51 | 51 | // password (SU_PASS) can be supplied or defaults to username |
@@ -55,15 +55,15 @@ discard block |
||
55 | 55 | $super['DB_PASS'] = env('DB_ENV_PASS', $super['DB_USER']); |
56 | 56 | $pdo = dbconnect($super); |
57 | 57 | if ($super['DB_TYPE'] === 'mysql') { |
58 | - $pdo->exec('CREATE DATABASE ' . ($config['DB_NAME'])); |
|
59 | - $pdo->exec('GRANT ALL PRIVILEGES ON ' . ($config['DB_NAME']) . '.* TO ' . $pdo->quote($config['DB_USER']) . '@"%" IDENTIFIED BY ' . $pdo->quote($config['DB_PASS'])); |
|
58 | + $pdo->exec('CREATE DATABASE '.($config['DB_NAME'])); |
|
59 | + $pdo->exec('GRANT ALL PRIVILEGES ON '.($config['DB_NAME']).'.* TO '.$pdo->quote($config['DB_USER']).'@"%" IDENTIFIED BY '.$pdo->quote($config['DB_PASS'])); |
|
60 | 60 | } else { |
61 | - $pdo->exec('CREATE ROLE ' . ($config['DB_USER']) . ' WITH LOGIN PASSWORD ' . $pdo->quote($config['DB_PASS'])); |
|
62 | - $pdo->exec('CREATE DATABASE ' . ($config['DB_NAME']) . ' WITH OWNER ' . ($config['DB_USER'])); |
|
61 | + $pdo->exec('CREATE ROLE '.($config['DB_USER']).' WITH LOGIN PASSWORD '.$pdo->quote($config['DB_PASS'])); |
|
62 | + $pdo->exec('CREATE DATABASE '.($config['DB_NAME']).' WITH OWNER '.($config['DB_USER'])); |
|
63 | 63 | } |
64 | 64 | unset($pdo); |
65 | 65 | if (dbcheck($config)) { |
66 | - echo 'Database login created and confirmed' . PHP_EOL; |
|
66 | + echo 'Database login created and confirmed'.PHP_EOL; |
|
67 | 67 | } else { |
68 | 68 | error('Database login failed, trying to create login failed as well'); |
69 | 69 | } |
@@ -74,8 +74,8 @@ discard block |
||
74 | 74 | // reached this point => table found, assume db is complete |
75 | 75 | } |
76 | 76 | catch (PDOException $e) { |
77 | - echo 'Database table not found, applying schema... ' . PHP_EOL; |
|
78 | - $schema = file_get_contents('schema/ttrss_schema_' . $config['DB_TYPE'] . '.sql'); |
|
77 | + echo 'Database table not found, applying schema... '.PHP_EOL; |
|
78 | + $schema = file_get_contents('schema/ttrss_schema_'.$config['DB_TYPE'].'.sql'); |
|
79 | 79 | $schema = preg_replace('/--(.*?);/', '', $schema); |
80 | 80 | $schema = preg_replace('/[\r\n]/', ' ', $schema); |
81 | 81 | $schema = trim($schema, ' ;'); |
@@ -88,35 +88,35 @@ discard block |
||
88 | 88 | foreach ($_SERVER as $name => $value) { |
89 | 89 | if (strpos($name, $config_prefix) === 0) { |
90 | 90 | $name = substr($name, strlen($config_prefix)); |
91 | - echo 'Getting config from env: ' . $name . PHP_EOL; |
|
91 | + echo 'Getting config from env: '.$name.PHP_EOL; |
|
92 | 92 | $config[$name] = $value; |
93 | 93 | } |
94 | 94 | } |
95 | 95 | $contents = file_get_contents($confpath); |
96 | 96 | foreach ($config as $name => $value) { |
97 | - $contents = preg_replace('/(define\s*\(\'' . $name . '\',\s*)(.*)(\);)/', '$1"' . $value . '"$3', $contents); |
|
97 | + $contents = preg_replace('/(define\s*\(\''.$name.'\',\s*)(.*)(\);)/', '$1"'.$value.'"$3', $contents); |
|
98 | 98 | } |
99 | 99 | file_put_contents($confpath, $contents); |
100 | 100 | function env($name, $default = null) |
101 | 101 | { |
102 | 102 | $v = getenv($name) ?: $default; |
103 | 103 | if ($v === null) { |
104 | - error('The env ' . $name . ' does not exist'); |
|
104 | + error('The env '.$name.' does not exist'); |
|
105 | 105 | } |
106 | 106 | return $v; |
107 | 107 | } |
108 | 108 | function error($text) |
109 | 109 | { |
110 | - echo 'Error: ' . $text . PHP_EOL; |
|
110 | + echo 'Error: '.$text.PHP_EOL; |
|
111 | 111 | exit(1); |
112 | 112 | } |
113 | 113 | function dbconnect($config) |
114 | 114 | { |
115 | 115 | $map = array('host' => 'HOST', 'port' => 'PORT', 'dbname' => 'NAME'); |
116 | - $dsn = $config['DB_TYPE'] . ':'; |
|
116 | + $dsn = $config['DB_TYPE'].':'; |
|
117 | 117 | foreach ($map as $d => $h) { |
118 | - if (isset($config['DB_' . $h])) { |
|
119 | - $dsn .= $d . '=' . $config['DB_' . $h] . ';'; |
|
118 | + if (isset($config['DB_'.$h])) { |
|
119 | + $dsn .= $d.'='.$config['DB_'.$h].';'; |
|
120 | 120 | } |
121 | 121 | } |
122 | 122 | $pdo = new \PDO($dsn, $config['DB_USER'], $config['DB_PASS']); |
@@ -201,7 +201,7 @@ |
||
201 | 201 | |
202 | 202 | public function getDebugInfo() |
203 | 203 | { |
204 | - return array ( 37 => 1,); |
|
204 | + return array(37 => 1,); |
|
205 | 205 | } |
206 | 206 | |
207 | 207 | public function getSourceContext() |
@@ -31,7 +31,7 @@ |
||
31 | 31 | } |
32 | 32 | } |
33 | 33 | if (T_CLASS === $tokens[$index][0] && T_WHITESPACE === $tokens[$index + 1][0] && T_STRING === $tokens[$index + 2][0]) { |
34 | - $index += 2; |
|
34 | + $index += 2; |
|
35 | 35 | $filterClasses[] = $namespace.'\\'.$tokens[$index][1]; |
36 | 36 | break; |
37 | 37 | } |
@@ -31,7 +31,7 @@ |
||
31 | 31 | } |
32 | 32 | } |
33 | 33 | if (T_CLASS === $tokens[$index][0] && T_WHITESPACE === $tokens[$index + 1][0] && T_STRING === $tokens[$index + 2][0]) { |
34 | - $index += 2; |
|
34 | + $index += 2; |
|
35 | 35 | $functionClasses[] = $namespace.'\\'.$tokens[$index][1]; |
36 | 36 | break; |
37 | 37 | } |
@@ -11,7 +11,7 @@ |
||
11 | 11 | { |
12 | 12 | $query = ""; |
13 | 13 | if (!(strpos($filename, "?") === false)) { |
14 | - $query = substr($filename, strpos($filename, "?")+1); |
|
14 | + $query = substr($filename, strpos($filename, "?") + 1); |
|
15 | 15 | $filename = substr($filename, 0, strpos($filename, "?")); |
16 | 16 | } |
17 | 17 | $timestamp = filemtime(BASEPATH.DS.'public'.DS.'js'.DS.$filename); |