-
Notifications
You must be signed in to change notification settings - Fork 0
/
Server.rb
482 lines (441 loc) · 12.6 KB
/
Server.rb
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
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
require 'sinatra'
get '/' do
'<title>No Page</title>
<h1>Please access the home page</h1>
<a href="/home">Home Page</a>'
end
get '/home' do
'<title>Home Page</title>
<h1>Welcome to Online Web-Store</h1>
We at Online Web-Store, not only have a large catalog of products to choose from, we also have a huge customer base.<br>
See a list of our products <a href="/products">here</a> and a selection of our customers <a href="/customers">here</a><br>
If you already have an account you can login here
<form action="/login" method="post">
Username:<input type="text" name="username"><br><br>
Password:<input type="password" name="pwd"><br><br>
<input type="submit" value="Submit">'
end
get '/products' do
'<title>Products</title>
<h2>Product List</h2><br>
<a href="/products/cable">Cable</a><br>
<a href="/products/cookie">Cookie</a><br>
<a href="/products/dandelions">Dandelions</a><br>
<a href="/products/eagle">Eagle</a><br>
<a href="/products/google">Google</a><br>
<a href="/products/ice">Ice</a><br>
<a href="/products/orange">Orange</a><br>
<a href="/products/strangerThings3">Stranger Things Season 3</a><br>
<a href="/products/zoo">Zoo</a><br>'
end
get '/products/cable' do
'<title>Cable</title>
<h2>Cable</h2><br>
<p><img src="https://upload.wikimedia.org/wikipedia/commons/thumb/1/11/Male_type_N_connector.jpg/1200px-Male_type_N_connector.jpg" alt="Male type N connector.jpg" height="400" width="400"></p>
The RF Coaxial Cable is the ultimate cable. It does everything and you will never need any other cable.<br>
<h4>$10</h4><br>
Please login to add to your cart.'
end
get '/products/cookie' do
'<title>Cookie</title>
<h2>Cookie</h2><br>
<p><img src="https://upload.wikimedia.org/wikipedia/commons/2/23/Nice_biscuit.jpg" alt="Nice biscuit.jpg" height="400" width="400"></p>
This is The Cookie and any other cookies you might come across are merely fakes.<br>
<h4>$500,000,000</h4><br>
Please login to add to your cart.'
end
get '/products/dandelions' do
'<title>Dandelions</title>
<h2>Dandelions</h2><br>
<p><img src="https://upload.wikimedia.org/wikipedia/commons/thumb/5/54/TaraxacumOfficinaleSeed.JPG/1200px-TaraxacumOfficinaleSeed.JPG" alt="TaraxacumOfficinaleSeed.JPG" height="400" width="400"></p>
Why go outside and enjoy scattering the seeds of a dandelion, when you can have a bundle of them delivered right to your doorstep.<br>
<h4>$3</h4><br>
Please login to add to your cart.<br>
This is one of our premier Express Items, if you have updated payment information stored in your account you can enter your email here to immediately order the item.
<form action="/order" method="post">
<input type="hidden" name="product" value="dandelions">
Email: <input type="text" name="email"><br><br>
<input type="submit" value="Submit">
</form>'
end
get '/products/eagle' do
'<title>Eagle</title>
<h2>Eagle</h2><br>
<p><img src="https://upload.wikimedia.org/wikipedia/commons/thumb/d/d6/Golden_Eagle_in_flight_-_5.jpg/1200px-Golden_Eagle_in_flight_-_5.jpg" alt="Golden Eagle in flight - 5.jpg" height="400" width="400"></p>
Please note that while it is called a Golden Eagle, the Eagle is neither gold nor does it lay golden eggs.<br>
<h4>$350</h4><br>
Please login to add to your cart.'
end
get '/products/google' do
'<title>Google</title>
<h2>Google</h2><br>
<p><img src="https://upload.wikimedia.org/wikipedia/commons/thumb/2/2f/Google_2015_logo.svg/1200px-Google_2015_logo.svg.png" alt="The letters of "Google" are each purely colored (from left to right) in blue, red, yellow, blue, green, and red." height="400" width="400"></p>
A small company that is trying to compete with Yahoo over the Search Engine market.<br>
<h4>$19.99</h4><br>
Sorry, we are currently sold out.'
end
get '/products/ice' do
'<title>Ice</title>
<h2>Ice</h2><br>
<p><img src="https://upload.wikimedia.org/wikipedia/commons/c/c2/SnowflakesWilsonBentley.jpg" alt="SnowflakesWilsonBentley.jpg" height="400" width="400"></p>
They actually just look like cubes.<br>
<h4>$50</h4><br>
Please login to add to your cart.'
end
get '/products/orange' do
'<title>Orange</title>
<h2>Orange</h2><br>
<p><img src="https://upload.wikimedia.org/wikipedia/commons/a/ac/Kleurenovergang_van_rood_naar_geel.png" alt="Kleurenovergang van rood naar geel.png" height="400" width="400"></p>
Please note that this purchase entitles you to everything that is orange, this includes but is not limited to Oranges, Saffron, Pumpkins, Tigers, and Poppies.<br>
<h4>$50</h4><br>
Please login to add to your cart.'
end
get '/products/strangerThings3' do
'<title>Stranger Things Season 3</title>
<h2>Stranger Things Season 3</h2><br>
<p><img src="https://upload.wikimedia.org/wikipedia/commons/3/38/Stranger_Things_logo.png" alt="Stranger Things logo.png" height="400" width="400"></p>
Who wants to wait until October for Season 2 when you can buy Season 3 now?<br>
<h4>$100</h4><br>
Please login to add to your cart.'
end
get '/products/zoo' do
'<title>Zoo</title>
<h2>Zoo</h2><br>
<p><img src="https://upload.wikimedia.org/wikipedia/commons/2/2e/San_Diego_Zoo_entrance_elephant.jpg" alt="San Diego Zoo entrance elephant.jpg" height="400" width="400"></p>
Please note, while the "animals" are included, they are all made from trees and hedges.<br>
<h4>$26,000</h4><br>
Please login to add to your cart.'
end
get '/customers' do
num = Random.rand(3)
if num.eql? 1
'<title>Customers</title>
Here is a random selection of usernames from our customer base:<br>
<a href="/customers/Slim_Shady">Slim_Shady</a><br>
<a href="/customers/Pilkington">Pilkington</a><br>
<a href="/customers/The_Real_Slim_Shady">The_Real_Slim_Shady</a><br>
<a href="/customers/Lord_of_the_Beetles">Lord_of_the_Beetles</a><br>
<a href="/customers/Mr._Mister">Mr._Mister</a><br>
<a href="/customers/H@X0R">H@X0R</a><br>
<a href="/customers/Actual_Slim_Shady">Actual_Slim_Shady</a><br>
<a href="/customers/2B_or_!2B">2B_or_!2B</a>
<br>You can return to the home page <a href="/home">here</a>.'
elsif num.eql? 2
'<title>Customers</title>
Here is a random selection of usernames from our customer base:<br>
<a href="/customers/BaconLover">BaconLover</a><br>
<a href="/customers/Kratos">Kratos</a><br>
<a href="/customers/Beets-or-Beats">Beets-or-Beats</a><br>
<a href="/customers/BohemianRhapsody">BohemianRhapsody</a><br>
<a href="/customers/Robotico">Robotico</a><br>
<a href="/customers/Nier">Nier</a><br>
<a href="/customers/MnM">MnM</a><br>
<a href="/customers/The_Real_Slim_Shady_782">The_Real_Slim_Shady_782</a>
<br>You can return to the home page <a href="/home">here</a>.'
else
'<title>Customers</title>
Here is a random selection of usernames from our customer base:<br>
<a href="/customers/THE_LIGHT">THE_LIGHT</a><br>
<a href="/customers/kMrIGlqQGYXU">kMrIGlqQGYXU</a><br>
<a href="/customers/Batman">Batman</a><br>
<a href="/customers/MarshallMathers">MarshallMathers</a><br>
<a href="/customers/grassyKnoll">grassyKnoll</a><br>
<a href="/customers/donutsAreGr8">donutsAreGr8</a><br>
<a href="/customers/11">11</a><br>
<a href="/customers/RapGod">RapGod</a>
<br>You can return to the home page <a href="/home">here</a>.'
end
end
get '/customers/Slim_Shady' do
'<title>User Bio</title>
<h2>Slim_Shady</h2>
<h3>Name</h3>
Bilbo Baggins
<h3>Hobbies</h3>
Sneaking, trying on rings, and hanging out with Sam
<h3>Email</h3>
'
end
get '/customers/Pilkington' do
'<title>User Bio</title>
<h2>Pilkington</h2>
<h3>Name</h3>
Karl
<h3>Hobbies</h3>
Not going to other countries, not eating new food, and not talking to Ricky
<h3>Email</h3>
'
end
get '/customers/The_Real_Slim_Shady' do
'<title>User Bio</title>
<h2>The_Real_Slim_Shady</h2>
<h3>Name</h3>
Frank Abernathy
<h3>Hobbies</h3>
Listening to classical music and yelling at kids to get off my lawn
<h3>Email</h3>
Unknown
'
end
get '/customers/Lord_of_the_Beetles' do
'<title>User Bio</title>
<h2>Lord_of_the_Beetles</h2>
<h3>Name</h3>
Piggy
<h3>Hobbies</h3>
Reading and running away from choir boys
<h3>Email</h3>
Unknown
'
end
get '/customers/Mr._Mister' do
'<title>User Bio</title>
<h2>Mr._Mister</h2>
<h3>Name</h3>
Sir
<h3>Hobbies</h3>
Being rich, spending money, and making money
<h3>Email</h3>
Mr@$$.rich
'
end
get '/customers/H@X0R' do
'<title>User Bio</title>
<h2>H@X0R</h2>
<h3>Name</h3>
Steve
<h3>Hobbies</h3>
Haxing nwbs, pwning nwbs, wreking nwbs, and trashing nwbs
<h3>Email</h3>
'
end
get '/customers/Actual_Slim_Shady' do
'<title>User Bio</title>
<h2>Actual_Slim_Shady</h2>
<h3>Name</h3>
Dr. Dre
<h3>Hobbies</h3>
Rapping, producing, and making beats
<h3>Email</h3>
'
end
get '/customers/2B_or_!2B' do
'<title>User Bio</title>
<h2>2B_or_!2B</h2>
<h3>Name</h3>
9S
<h3>Hobbies</h3>
Destroying machines, admiring 2B, and reporting to Command
<h3>Email</h3>
'
end
get '/customers/BaconLover' do
'<title>User Bio</title>
<h2>BaconLover</h2>
<h3>Name</h3>
Ralph
<h3>Hobbies</h3>
Blowing conch shells, starting fires, and having fun
<h3>Email</h3>
'
end
get '/customers/Kratos' do
'<title>User Bio</title>
<h2>Kratos</h2>
<h3>Name</h3>
Spartan #1247
<h3>Hobbies</h3>
Vengeance
<h3>Email</h3>
'
end
get '/customers/Beets-or-Beats' do
'<title>User Bio</title>
<h2>Beets-or-Beats</h2>
<h3>Name</h3>
Unknown
<h3>Hobbies</h3>
Unknown
<h3>Email</h3>
Unknown
'
end
get '/customers/BohemianRhapsody' do
'<title>User Bio</title>
<h2>BohemianRhapsody</h2>
<h3>Name</h3>
Freddie
<h3>Hobbies</h3>
Singing, songwriting, and playing piano
<h3>Email</h3>
'
end
get '/customers/Robotico' do
'<title>User Bio</title>
<h2>Robotico</h2>
<h3>Name</h3>
Robo
<h3>Hobbies</h3>
Usurping humans
<h3>Email</h3>
'
end
get '/customers/Nier' do
'<title>User Bio</title>
<h2>Nier</h2>
<h3>Name</h3>
2B
<h3>Hobbies</h3>
Killing, existential crises, not killing
<h3>Email</h3>
'
end
get '/customers/MnM' do
'<title>User Bio</title>
<h2>MnM</h2>
<h3>Name</h3>
Red
<h3>Hobbies</h3>
Not getting eaten
<h3>Email</h3>
'
end
get '/customers/The_Real_Slim_Shady_782' do
'<title>User Bio</title>
<h2>The_Real_Slim_Shady_782</h2>
<h3>Name</h3>
Generic Fan
<h3>Hobbies</h3>
Listening to rap, pretending to be able to rap, and bragging about rapping
<h3>Email</h3>
'
end
get '/customers/THE_LIGHT' do
'<title>User Bio</title>
<h2>THE_LIGHT</h2>
<h3>Name</h3>
Thomas
<h3>Hobbies</h3>
EnLIGHTening people
<h3>Email</h3>
'
end
get '/customers/kMrIGlqQGYXU' do
'<title>User Bio</title>
<h2>kMrIGlqQGYXU</h2>
<h3>Name</h3>
Unknown
<h3>Hobbies</h3>
Having secure accounts
<h3>Email</h3>
Unknown
'
end
get '/customers/Batman' do
'<title>User Bio</title>
<h2>Batman</h2>
<h3>Name</h3>
The Dark (K)Night
<h3>Hobbies</h3>
Fighting crime and training children to fight crime
<h3>Email</h3>
'
end
get '/customers/MarshallMathers' do
'<title>User Bio</title>
<h2>MarshallMathers</h2>
<h3>Name</h3>
Marshall Mathers
<h3>Hobbies</h3>
Maintaining websites
<h3>Email</h3>
default@default-VirtualBox
'
end
get '/customers/grassyKnoll' do
'<title>User Bio</title>
<h2>grassyKnoll</h2>
<h3>Name</h3>
Illuminati Tracker
<h3>Hobbies</h3>
Telling people they are wrong
<h3>Email</h3>
'
end
get '/customers/donutsAreGr8' do
'<title>User Bio</title>
<h2>donutsAreGr8</h2>
<h3>Name</h3>
Foodie
<h3>Hobbies</h3>
Eating chocolate and bacon
<h3>Email</h3>
'
end
get '/customers/11' do
'<title>User Bio</title>
<h2>11</h2>
<h3>Name</h3>
Jane
<h3>Hobbies</h3>
Making friends, escaping labs, and eating waffles
<h3>Email</h3>
'
end
get '/customers/RapGod' do
'<title>User Bio</title>
<h2>RapGod</h2>
<h3>Name</h3>
Unknown
<h3>Hobbies</h3>
Unknown
<h3>Email</h3>
Unknown
'
end
post '/login' do
'<title>Incorrect</title>
Incorrect username or password. Please click <a href="/home">here</a> to try again.'
end
post '/order' do
if params['product'].to_s.eql? "dandelions"
if params['email'].to_s.eql? "[email protected]"
'<title>Successful Order</title>
Your order for dandelions has been placed and should arrive on ERROR MCA{aCzb163wL9} ERROR.'
else
if Random.rand(2).eql? 1
'<title>Sorry</title>
Unfortunately we cannot find an account with that email address. You can return to our product list <a href="/products">here</a>'
else
'<title>Sorry</title>
Unfortunately your account does not have updated payment information. You can return to our product list <a href="/products">here</a>'
end
end
else
'<title>Sorry</title>
Unfortunately that product is not available for Express Ordering. You can return to our product list <a href="/products">here</a>'
end
end
get '/*' do
redirect '/'
end
post '/*' do
redirect '/'
end