2020-02-23 21:40:16 +01:00
|
|
|
#!/usr/bin/python2
|
|
|
|
|
|
|
|
print """
|
|
|
|
Variable Grabbler - version 1.0
|
|
|
|
-------------------------------"""
|
|
|
|
|
|
|
|
# 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__))
|
|
|
|
fext = "*.php"
|
2020-02-23 21:40:16 +01:00
|
|
|
|
|
|
|
print "Opening config file..."
|
2020-02-23 23:06:34 +01:00
|
|
|
config = open(os.path.join(dir, "variable_grabbler.cfg"),"r")
|
|
|
|
parsed = json.load(config)
|
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):
|
|
|
|
for fname in fnmatch.filter(files, fext):
|
|
|
|
fpath = os.path.join(path, fname)
|
|
|
|
with open(fpath) as f:
|
|
|
|
s = f.read()
|
|
|
|
s = s.replace("%" + x + "%", parsed[x])
|
|
|
|
with open(fpath, "w") as f:
|
|
|
|
f.write(s)
|
2020-02-23 21:40:16 +01:00
|
|
|
|
|
|
|
config.close()
|