瀏覽代碼

new file: Beaches/auverp

new file:   Beaches/mkinrs
	new file:   Cities/flshra
	new file:   Cities/jtiomq
	new file:   Mountains/noftaz
	new file:   download.py
	new file:   extensions_changer.py
	new file:   links.txt
	new file:   login.py
	new file:   server.py
	new file:   upload.py
master
TheBidouilleur 2 週之前
當前提交
4c25dec8ac
共有 11 個文件被更改,包括 276 次插入0 次删除
  1. 二進制
      Beaches/auverp
  2. 二進制
      Beaches/mkinrs
  3. 二進制
      Cities/flshra
  4. 二進制
      Cities/jtiomq
  5. 二進制
      Mountains/noftaz
  6. +59
    -0
      download.py
  7. +17
    -0
      extensions_changer.py
  8. +0
    -0
      links.txt
  9. +93
    -0
      login.py
  10. +13
    -0
      server.py
  11. +94
    -0
      upload.py

二進制
Beaches/auverp 查看文件

Before After
Width: 460  |  Height: 305  |  Size: 27 KiB

二進制
Beaches/mkinrs 查看文件

Before After
Width: 1500  |  Height: 1030  |  Size: 403 KiB

二進制
Cities/flshra 查看文件

Before After
Width: 3528  |  Height: 1970  |  Size: 1.4 MiB

二進制
Cities/jtiomq 查看文件

Before After
Width: 1900  |  Height: 1266  |  Size: 500 KiB

二進制
Mountains/noftaz 查看文件

Before After
Width: 680  |  Height: 340  |  Size: 179 KiB

+ 59
- 0
download.py 查看文件

@@ -0,0 +1,59 @@
# coding: utf-8

import cgi
import cgitb; cgitb.enable()
import glob
import random
import string
import requests
form = cgi.FieldStorage()

def get_random_string(length):
letters = string.ascii_lowercase
result_str = ''.join(random.choice(letters) for i in range(length))
return result_str

header = """
<!DOCTYPE html>
<head>
<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
<title>Download the image</title>
</head>
<body>
"""

link = form.getvalue("link")
choice = form.getvalue("choice")
print(header)

if link is not None :
print("""<h2 class="w3-center w3-teal"> Add an image </h2>""")
print("<title> Adding the image </title>")

path = str(choice) + '/' + get_random_string(6)
print("<h4> Generating a unique URL... </h4>")
with open("links.txt", "a") as myfile:
myfile.write(choice + " - " + path + " - " + link + "\n")

if True:
print("<h4>Valid URL, ready for download! </h4> ")
r = requests.get(link, allow_redirects=True)
print("<h4> " + r.headers.get('content-type') + "</h4>")
header = r.headers.get('content-type')
header = header.split("/")
print("<h4> File identification : " + header[0] + "</h4>")
if header[0] == "image":
print("<h4> Downloading... </h4>")
open(path, 'wb').write(r.content)
print(""" <div class="w3-panel w3-green">
<h2 class="w3-opacity">Done ! </h2>
</div>""")
print("<img class='w3-round' src='%s' >" % path)
else :
print(""" <div class="w3-panel w3-red">
<h2 class="w3-opacity">Echec ! </h2>
</div>""")


else :
print("Echec")

+ 17
- 0
extensions_changer.py 查看文件

@@ -0,0 +1,17 @@
import os
import glob
import random
import string

def get_random_string(length):
letters = string.ascii_lowercase
result_str = ''.join(random.choice(letters) for i in range(length))
return result_str

file = glob.glob("*")

for i in range(len(file)):
if file[i] != "extensions.py" :
cmd = "mv " + file[i] + " " + get_random_string(6)
print(cmd)
os.system(cmd)

+ 0
- 0
links.txt 查看文件


+ 93
- 0
login.py 查看文件

@@ -0,0 +1,93 @@
# coding: utf-8

import cgi
import cgitb; cgitb.enable()
import glob
form = cgi.FieldStorage()
print("Content-type: text/html; charset=utf-8\n")

header = """
<!DOCTYPE html>
<head>
<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
<title>Simple Image Uploader</title>
</head>
<body>

"""

print(header)

password = form.getvalue("password")
choix = form.getvalue("choice")

if str(password) == "TheBidouilleur" and choix is None:
print("""<h2 class="w3-center w3-teal"> Choix du choice </h2>""")
print("""<h3 class="w3-center">Choisissez un choice </h3>""")
Choix = """
<title> Choix des photos </title>
<form action="./login.py" method="post" class="w3-container">
<select class="w3-select" name="choice">
<option value="" disabled selected>Selectionnez une option</option>
<option value="Cities">Cities</option>
<option value="Beaches">Beaches</option>
<option value="Mountains">Mountains</option>
<option value="Skies">Skies</option>
</select>
<br>
<input type="submit" name="send" value="Check photos" class="w3-btn w3-teal">
</form>"""
print(Choix)

elif str(password) != "TheBidouilleur" and password is not None and choix is None :
print("""<h2 class="w3-center w3-teal"> Connexion </h2>""")
print("""<div class="w3-panel w3-red">
<h2 class="w3-opacity">Bad password ! </h2>
</div>
""")
formulaire = """<form action="./login.py" method="post" class="w3-container">
<h3>Log in to access the page </h3>
<br>
<input class="w3-input" type="password" name="password" value="" />
<br>
<input type="submit" name="send" value="Login" class="w3-btn w3-teal">
<br>
</form>"""
print(formulaire)
elif choix is None :
print("""<h2 class="w3-center w3-teal"> Connexion </h2>""")
formulaire ="""<form action="./login.py" method="post" class="w3-container">
<h3> Log in to access the page </h3>
<br>
<input class="w3-input" type="password" name="password" value="" />
<br>
<input type="submit" name="send" value="Login" class="w3-btn w3-teal">
<br>
</form>"""
print(formulaire)

if choix is not None :
if choix == "Beaches":
print("""<h2 class="w3-center w3-teal"> Beaches</h2>""")
file = glob.glob("Beaches/*")
if choix == "Cities":
print("""<h2 class="w3-center w3-teal"> Cities </h2>""")
file = glob.glob("Cities/*")
if choix == "Skies":
print("""<h2 class="w3-center w3-teal"> Skies</h2>""")
file = glob.glob("Skies/*")
if choix == "Mountains":
print("""<h2 class="w3-center w3-teal"> Mountains </h2>""")
file = glob.glob("Mountains/*")

print("<div class='w3-container'>")
for i in range(len(file)):
print("<img class='w3-round' width=200px src='" + file[i] + "'>")


end = """
</body>
</html>
"""

print(end)

+ 13
- 0
server.py 查看文件

@@ -0,0 +1,13 @@
import http.server
from discord_webhook import DiscordWebhook

PORT = 80
server_address = ("", PORT

server = http.server.HTTPServer
handler = http.server.CGIHTTPRequestHandler
handler.cgi_directories = ["/"]
print("Used port :", PORT)

httpd = server(server_address, handler)
httpd.serve_forever()

+ 94
- 0
upload.py 查看文件

@@ -0,0 +1,94 @@
# coding: utf-8

import cgi
import cgitb; cgitb.enable()
import glob
form = cgi.FieldStorage()

header = """
<!DOCTYPE html>
<head>
<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
<title>Envoyer une image</title>
</head>
<body>
"""

print(header)
password = form.getvalue("password")
link = form.getvalue("link")
choice = form.getvalue("choice")

if link is not None :
print("""<h2 class="w3-center w3-teal"> Confirmation </h2>""")
print("""<h3 class="w3-left">Do you want to add this image to the """ + str(form.getvalue("choice")) + """ folder ? </h3> <br> <br>""" )
print("<img class='w3-round' width=200px src='" + str(link) + "'>")
formulaire = """<form action="download.py" method="post" class="w3-container"> """
formulaire += "<p class='w3-wide'> Link </p>"
formulaire += """ <input class="w3-input" type="text" name="link" value='"""
formulaire += str(link) + "'"
formulaire += ' > <br> <br>'
formulaire += "<p class='w3-wide'> Folder </p>"
formulaire += """ <input class="w3-input" type="text" name="choice" value='"""
formulaire += str(choice) + "'"
formulaire += ' " > <br> <br>'
formulaire += '<input type="submit" value="Ok!" class="w3-btn w3-teal">'
formulaire += '</form>'
print(formulaire)

else :
if password is None:
print("""<h2 class="w3-center w3-teal"> Send a picture </h2>""")
formulaire ="""<form action="./upload.py" method="post" class="w3-container">
<h3> Login </h3>
<br>
<input class="w3-input" type="password" name="password" value="" />
<br>
<input type="submit" name="send" value="Login" class="w3-btn w3-teal">
<br>
</form>"""
print(formulaire)

if str(password) == "TheBidouilleur" and link is None:
print("""<h2 class="w3-center w3-teal"> Choose the folder </h2>""")
print("""<h3 class="w3-center">Please choose a folder </h3>""")
choice = """
<title> choice des photos </title>
<form action="./upload.py" method="post" class="w3-container">
<select class="w3-select" name="choice">
<option value="" disabled selected>Select a folder</option>
<option value="Cities">Cities</option>
<option value="Beaches">Beaches</option>
<option value="Mountains">Mountains</option>
<option value="Skies">Skies</option>
</select>
<br>
<input class="w3-input" type="text" name="link" value="https://link_of_the/image.png" required>
<br>
<input type="submit" name="send" value="Download the photo" class="w3-btn w3-teal">
</form>"""
print(choice)

elif str(password) != "TheBidouilleur" and password is not None and link is None:
print("""<h2 class="w3-center w3-teal"> Connexion </h2>""")
print("""<div class="w3-panel w3-red">
<h2 class="w3-opacity">Mauvais MDP ! </h2>
</div>
""")

formulaire ="""<form action="./upload.py" method="post" class="w3-container">
<h3>Please enter password </h3>
<br>
<input class="w3-input" type="password" name="password" value="" />
<br>
<input type="submit" name="send" value="Login" class="w3-btn w3-teal">
<br>
</form>"""
print(formulaire)

end = """
</body>
</html>
"""

print(end)

Loading…
取消
儲存