-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
125 lines (96 loc) · 2.92 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#!/usr/bin/python
#
# /rcm/main.py
#
# given a list of domain & filePath strings create a folder structure
# that matches and create and populate an index.php for every folder.
#
# ---------------------------------------------------------------------
# imports
import os
import CreatePath as CP
# ---------------------------------------------------------------------
# constants - Only this section is editable
# domains purchased
domains = [
"domain1.com",
"domain2.com",
"domain3.com",
"domain4.com",
"domain5.com"
]
# file paths to create
# on windows use \\ notation for separating folders
# on linux use /
file_paths = [
"\one\\two\\three\\four",
"\one\\two",
"\one\\two\\three",
"\one\\two\\three\\four",
"\one"
]
# landing pages
landing_pages = [
"landingPage1.com/",
"landingPage2.com/",
"landingPage3.com/",
"landingPage4.com/",
"landingPage5.com/"
]
# end constants
# ---------------------------------------------------------------------
# step 1
# join file paths to domains
fullPath = []
for i in range(len(domains)):
fullPath.append(domains[i] + file_paths
[i])
# go to target folder
os.chdir(CP.targetFolder)
# make directories on target folder
for i in fullPath:
CP.mkdir_p(i)
# end step 1
# ---------------------------------------------------------------------
# step 2
# -----------------------------------------------------------------
# step 2.1 - create a list of every folder that needs an index file
# build the url that will be forwarded to
landing_urls = []
for i in range(len(landing_pages)):
landing_urls.append("http://" + landing_pages[i])
# build the list of sub targets
target_paths = []
for i in range(len(domains)):
target_paths.append(CP.targetFolder + "\\" + domains[i] + file_paths[i])
# append all branches of target paths to a list
target_branches = []
for i in target_paths:
os.chdir(i)
while os.getcwd() != CP.targetFolder:
target_branches.append(os.getcwd())
os.chdir(os.path.dirname(os.getcwd()))
# verify contents of target_branches
# print "\nThe following branches will be acted on: "
# for i in target_branches:
# print i
# end step 2.1
# ---------------------------------------------------------------------------------
# step 2.2 - go to every folder and create an index file pointed at the landing url
print("")
# go to every folder
for i in target_branches:
print("Target folder: " + i)
# create an index.php
file_name = i + "\\index.php"
IFH = open(file_name, 'w')
print("created index.php")
# write the forwarding script to the index
# todo write the proper php statement
payload = "<?php echo 'success' ?>"
IFH.write(payload)
print("forwarding script written to file")
IFH.close()
print("File saved\n")
# end step 2
# end main.py