Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/php
- <?php
- function getEnvironmentValue($key, $default)
- {
- $env = getenv($key);
- if ($env === false)
- {
- $env = $default;
- }
- if (is_string($env))
- {
- return "'" . addslashes($env) . "'";
- }
- else if (is_numeric($env))
- {
- return $env;
- }
- else
- {
- echo "Invalid type for environment variable '$key'\n";
- return "''";
- }
- }
- $mysqlUsername = getEnvironmentValue('MYSQL_USERNAME', 'root');
- $mysqlPassword = getEnvironmentValue('MYSQL_PASSWORD', '');
- $mysqlHost = getEnvironmentValue('MYSQL_HOST', '127.0.0.1');
- $mysqlPort = getEnvironmentValue('MYSQL_PORT', 3306);
- $mysqlDbname = getEnvironmentValue('MYSQL_DBNAME', 'xenforo');
- $superAdmins = getEnvironmentValue('SUPER_ADMINS', '1');
- $mpqFilesPath = getEnvironmentValue('MPQ_FILES_PATH', '/usr/share/mpq');
- $debug = getEnvironmentValue('DEBUG', 0);
- $cacheHost = getEnvironmentValue('MEMCACHED_HOST', '127.0.0.1');
- $cachePort = getEnvironmentValue('MEMCACHED_PORT', 11211);
- $cacheCompression = getEnvironmentValue('CACHE_COMPRESSION', 1);
- $importLogTable = getEnvironmentValue('IMPORT_LOG_TABLE', 'xf_import_log');
- $xenGalleryImportLogTable = getEnvironmentValue('XENGALLERY_IMPORT_LOG_TABLE', 'xf_import_log');
- // E.g. HTTP_X_FORWARDED_FOR
- $proxyIpCode = '';
- if (getenv('PROXY_IP_HEADER'))
- {
- $proxyIpHeader = getEnvironmentValue('PROXY_IP_HEADER', '');
- $proxyIpCode = "if (isset(\$_SERVER[$proxyIpHeader]))
- {
- \$_SERVER['REMOTE_ADDR'] = \$_SERVER[$proxyIpHeader];
- }
- ";
- }
- $config = "<?php
- \$config['db']['host'] = $mysqlHost;
- \$config['db']['port'] = $mysqlPort;
- \$config['db']['username'] = $mysqlUsername;
- \$config['db']['password'] = $mysqlPassword;
- \$config['db']['dbname'] = $mysqlDbname;
- \$config['mpqFilesPath'] = $mpqFilesPath;
- \$config['superAdmins'] = $superAdmins;
- \$config['debug'] = $debug;
- \$config['cache']['backend'] = 'Memcached';
- \$config['cache']['backendOptions'] = array(
- 'compression' => $cacheCompression,
- 'servers' => array(
- array(
- 'host' => $cacheHost,
- 'port' => $cachePort,
- )
- )
- );
- $proxyIpCode
- ";
- $importConfig = "
- <?php
- define('IMPORT_LOG_TABLE', $importLogTable);
- define('XENGALLERY_IMPORT_LOG_TABLE', $xenGalleryImportLogTable);
- define('INCLUDE_PAGE_LINKS', true);
- \$fileDir = dirname(__FILE__) . '/..';
- ";
- $result1 = file_put_contents('/var/www/html/library/config.php', $config) !== false;
- $result2 = file_put_contents('/var/www/html/forums/301config.php', $importConfig) !== false;
- exit(($result1 && $result2) ? 0 : 1);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement