Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #deprecated
- def grep_php_const(lines, name):
- regexp = "^define\(\s*'%s',\s*'(.*)'\s*\);\s*$" % name
- for line in lines:
- m = re.match(regexp, line)
- if m:
- return m.group(1)
- #deprecated
- def parse_wp_config():
- wp_config_file = os.path.join(BASEDIR, 'wp-config.php')
- lines = open(wp_config_file, 'r').read().split('\n')
- lines = [ line.strip() for line in lines ]
- db_name = grep_php_const(lines, 'DB_NAME')
- db_user = grep_php_const(lines, 'DB_USER')
- db_host = grep_php_const(lines, 'DB_HOST')
- db_password = grep_php_const(lines, 'DB_PASSWORD')
- return {
- 'username': db_user,
- 'password': db_password,
- 'host': db_host,
- 'db': db_name,
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement