/
app.py.bak
323 lines (243 loc) · 8.71 KB
/
app.py.bak
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
import os
import urllib2
import string
import stripe
import string
import time
from random import randint
import jinja2
from flask import Flask, render_template, request, jsonify, Markup, redirect, session
from flask import send_from_directory
from werkzeug import secure_filename
import dataset
import sqlite
# create the application object
stripe_keys = {
'secret_key': os.environ['SECRET_KEY'],
'publishable_key': os.environ['PUBLISHABLE_KEY']
}
stripe.api_key = stripe_keys['secret_key']
ADVECTIVE_1 = ['shiny', 'flying', 'explosive', 'fantastic', 'embarrassed', 'flashy', 'stingy', 'dapper', 'implosive','confusing']
COLOUR = ['white', 'red', 'emerald', 'maroon', 'umber', 'ivory', 'jasper', 'chocolate', 'jade', 'silver']
NOUN = ['bomb', 'direction', 'push', 'medic', 'pie', 'eggnog', 'quartz', 'border', 'cub', 'soldier']
PIC_EXTENSIONS = ['aac', 'ai', 'aiff', 'avi', 'c', 'cpp', 'css', 'dat', 'dmg', 'doc', 'exe', 'flv', 'gif', 'h', 'hpp','html', 'ics', 'jar', 'jpg', 'key', 'mid', 'mp3', 'mpg', 'pdf', 'php', 'png', 'ppt', 'psd', 'py','qt', 'rar', 'rb', 'rtf', 'sql', 'tiff', 'txt', 'wav', 'xls', 'xml', 'yml', 'zip']
db = dataset.connect('sqlite:///databse/database.db')
table = db['table']
app = Flask(__name__)
import requests
word_site = "http://svnweb.freebsd.org/csrg/share/dict/words?view=co&content-type=text/plain"
response = requests.get(word_site)
WORDS = response.content.splitlines()
# config
app.secret_key = 'you shall not pass'
def randomword():
randomNumber = randint(0, len(WORDS))
return(WORDS[randomNumber])
@app.route('/uploadz/<sid>', methods=['GET', 'POST', 'VIEW'])
def upload_fileAP(sid):
text = ''
seises = os.listdir("/home/finbar/www/static/uploads")
for x in range(len(seises)):
if sid in seises[x]:
text = seises[x]
if request.method == 'POST':
file = request.files['file']
if file:
filename = secure_filename(file.filename)
file_path = "/home/finbar/www/static/uploads/" + text + "/"
file.save(os.path.join(file_path, filename))
return send_from_directory(file_path, filename)
def isacceptedpic(extension):
if extension in PIC_EXTENSIONS:
return True
@app.route('/buy')
def buy():
return render_template("selectpurchase.html")
@app.route('/buy', methods = ['POST'])
def buycheck():
sessions = request.form['sessions']
if int(sessions) <= 99:
return render_template("selectpurchase.html", error="Minimum sessions is 100 sessions")
else:
return redirect("/checkout/"+sessions)
@app.route('/checkout/<sessions>')
def checkout(sessions):
return render_template("checkout.html", key=stripe_keys['publishable_key'], num=float(sessions), displnum=sessions)
@app.route('/charge/<amount>', methods=['POST'])
def charge(amount):
customer = stripe.Customer.create(
email='customer@example.com',
source=request.form['stripeToken']
)
charge = stripe.Charge.create(
customer=customer.id,
amount=amount,
currency='usd',
description='Cyberstick Charge'
)
string = randomword()+randomword()+randomword()+randomword()+randomword()
table.insert(dict(name='Hai Doe', age=46, country='China'))
return render_template('thanks.html', amount=int(amount), string=string)
def id_generator(size=10, chars=string.ascii_uppercase + string.digits):
return ''.join(random.choice(chars) for _ in range(size))
@app.route('/premium')
def premium():
return render_template("premium.html")
@app.route('/uploadandroid')
def upload_android():
path = "/home/finbar/www/static/uploads/"
now = time.time()
name = randomword()
name += randomword()
name += randomword()
seis = name + '-' + str(now)
upPath = path + seis
os.mkdir(upPath)
return render_template('uploadsimplistic.html', displayPath=seis)
@app.route('/downloadfile/<cyberID>/<fileName>')
def downloadzor(cyberID, fileName):
return send_from_directory("/home/finbar/www/static/uploads/" + cyberID, fileName)
@app.route('/johnluke')
def johnluke():
return render_template("johnlukesprivatewebsites.html")
@app.route('/api/upload', methods=['GET', 'POST'])
def add_message():
path = "/home/finbar/www/static/uploads/"
now = time.time()
name = randomword()
name += randomword()
name += randomword()
seis = name + '-' + str(now)
upPath = path + seis
os.mkdir(upPath)
if request.method == 'POST':
file = request.files['file']
if file:
filename = secure_filename(file.filename)
file_path = "/home/finbar/www/static/uploads/" + seis + "/"
file.save(os.path.join(file_path, filename))
return (name)
@app.route('/api/download/<did>')
def downloadApi(did):
sessionFolder = ""
sessions = os.listdir("static/uploads")
for session in sessions:
name, stime = session.split('-')
if name == did:
sessionTime = stime
sessionFolder = session
sessionFilesList = os.listdir("static/uploads/" + sessionFolder + "/")
files = []
for file in sessionFilesList:
fileSplit = file.rsplit(".", 1)
name = fileSplit[0]
if len(fileSplit) >= 1:
extension = fileSplit[1]
else:
extension = "None!"
files.append({'name': name, 'extension': extension})
filesession = {'session': sessionFolder}
return jsonify(zfile=files, xfile=filesession)
@app.route('/help')
def help():
return render_template("help.html")
@app.route('/uplads/<sid>/<filename>')
def uploaded_file(sid, filename):
print "teste"
return send_from_directory("/home/finbar/www/static/uploads/" + sid + "/", filename)
@app.route('/upload', methods=['GET', 'POST', 'VIEW'])
def upload_file():
if 'username' in session:
path = "/home/finbar/www/static/uploads/"
now = time.time()
name = randomword()
name += randomword()
name += randomword()
seis = name + '-' + str(now)
upPath = path + seis
os.mkdir(upPath)
UPLOAD_FOLDER = upPath
return render_template('upload.html', displayPath=seis, linker=name)
return redirect("/login")
@app.route('/login')
def login():
if request.method == 'POST':
key = request.form['username']
keys = db['keys'].all()
if key in keys:
session['username'] = key
return redirect(url_for('upload'))
return render_template("login.html")
@app.route('/konami')
def konami():
return render_template('konami.html')
def stream_template(template_name, **context):
app.update_template_context(context)
t = app.jinja_env.get_template(template_name)
rv = t.stream(context)
rv.enable_buffering(5)
return rv
@app.route('/contact')
def contact():
return render_template('contact.html')
@app.route('/download/<did>')
def download(did):
sessionFolder = ""
sessions = os.listdir("static/uploads")
for session in sessions:
name, stime = session.split('-')
if name == did:
sessionTime = stime
sessionFolder = session
sessionFilesList = os.listdir("static/uploads/" + sessionFolder + "/")
seconds = round(900 - (time.time() - float(sessionTime)), 0)
m, s = divmod(seconds, 60)
timeRemain = "%02d minutes %02d seconds" % (m, s)
return render_template('download.html', timeRemain=timeRemain, session=sessionFolder, fileList=sessionFilesList, PIC_EXTENSIONS=PIC_EXTENSIONS)
def istoolong(string):
return string[:7]+"..."
def short_caption(someitem):
return len(someitem) < 11
@app.route('/about')
def about():
return render_template('about.html')
@app.route('/')
def home():
return render_template("index.html")
# ignore from here on -------------------------
@app.route('/maxlisten')
def maxlisten():
return ('Max stop watching vines')
@app.route('/patrick')
def patrick():
return ('got your ip dos time')
print jsonify({'ip': request.remote_addr}), 200
@app.route('/easteregg')
def easteregg():
return render_template("csdsports.html")
@app.route('/said')
def said():
return render_template('said.html')
@app.route('/joshua')
def joshua():
return render_template("joshua.html")
# y route for handling the login page logic
@app.route('/brian')
def brian():
return render_template('brian.html')
@app.route('/eetu')
def eetu():
return render_template("html.html")
@app.route('/oscar')
def oscar():
return render_template("folder/index.html")
@app.errorhandler(404)
def error404(e):
return render_template("error.html"), 404
@app.errorhandler(500)
def error500(e):
return render_template("error.html"), 500
@app.route('/csdget')
def csdget():
return render_template('csdget.html')
app.run(host='0.0.0.0', port=80, debug=True)