2020-02-23 21:40:16 +01:00
|
|
|
#!/usr/bin/python2
|
|
|
|
|
|
|
|
print """
|
2020-02-23 23:42:13 +01:00
|
|
|
Variable Grabbler - version 1.4
|
2020-02-23 21:40:16 +01:00
|
|
|
-------------------------------"""
|
|
|
|
|
|
|
|
# definitions
|
2020-02-23 23:06:34 +01:00
|
|
|
import os, json, fnmatch
|
2020-02-23 21:40:16 +01:00
|
|
|
|
2020-02-23 23:06:34 +01:00
|
|
|
dir = os.path.dirname(os.path.abspath(__file__))
|
2020-02-23 23:45:08 +01:00
|
|
|
file_name_pattern = "*.php"
|
2020-02-23 21:40:16 +01:00
|
|
|
|
|
|
|
print "Opening config file..."
|
2020-02-23 23:19:40 +01:00
|
|
|
config = open("variable_grabbler.cfg","r")
|
2020-02-23 23:06:34 +01:00
|
|
|
parsed = json.load(config)
|
2020-02-23 23:42:13 +01:00
|
|
|
config.close()
|
2020-02-23 21:40:16 +01:00
|
|
|
|
2020-02-23 23:06:34 +01:00
|
|
|
for x in parsed:
|
|
|
|
for path, dirs, files in os.walk(dir):
|
2020-02-23 23:45:08 +01:00
|
|
|
for fname in fnmatch.filter(files, file_name_pattern):
|
2020-02-23 23:42:13 +01:00
|
|
|
file_path = os.path.join(path, fname)
|
|
|
|
|
|
|
|
print "Working on file: "+file_path
|
|
|
|
|
|
|
|
file_in = open(file_path, "r")
|
2020-02-23 23:19:40 +01:00
|
|
|
file_content = file_in.read()
|
|
|
|
file_in.close()
|
|
|
|
|
2020-02-23 23:37:55 +01:00
|
|
|
file_content = file_content.decode('utf-8').replace("%" + x + "%", parsed[x]).encode('utf-8')
|
2020-02-23 23:19:40 +01:00
|
|
|
|
2020-02-23 23:42:13 +01:00
|
|
|
file_out = open(file_path, "w")
|
2020-02-23 23:19:40 +01:00
|
|
|
file_out.write(file_content)
|
|
|
|
file_out.close()
|