Spaces:
Sleeping
Sleeping
File size: 10,841 Bytes
69dc47b f1e78f8 69dc47b f1e78f8 69dc47b f1e78f8 69dc47b 8d0a95f a862982 8d0a95f a862982 8d0a95f 69dc47b a862982 69dc47b f1e78f8 7ccc57f 1d7d746 ea500c2 1d7d746 ea500c2 1d7d746 ea500c2 1d7d746 7ea86b3 ea500c2 7ea86b3 1d7d746 | 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 | import socket
import requests
from flask import Flask, render_template_string, request, session, redirect, url_for
from mcstatus import JavaServer
app = Flask(__name__)
app.secret_key = "une_cle_tres_secrete"
# --- CONFIGURATION ---
MAC_ADRESSE = "d4:3d:7e:31:e8:84"
MON_HOST_NOIP = "cobblev2.redirectme.net"
MOT_DE_PASSE = "pouletcrousty"
MC_PORT = 25565
IMAGE_FOND = "https://images.alphacoders.com/132/1327533.png"
IMAGES_GALERIE = [
"https://i.redd.it/ag4307hy62qe1.jpeg", "https://pbs.twimg.com/profile_images/1627794683362480129/3xUrVnUY_400x400.jpg",
"https://sativa.fr/wp-content/uploads/SnoopDogg.jpg", "https://media.zenfs.com/fr_FR/News/Gameblog/kate-upton-gta-v.jpg",
"https://i1.sndcdn.com/artworks-000148945005-hx6vn7-t1080x1080.jpg", "https://www.shutterstock.com/image-illustration/internet-meme-stupid-troll-face-260nw-201587906.jpg",
"https://www.lycee3vallees.fr/wp-content/uploads/2024/08/Logo-Pole-emploi.png", "https://img.freepik.com/photos-gratuite/belle-photo-chaton-british-shorthair-blanc_181624-57681.jpg",
"https://img.freepik.com/photos-premium/mignon-petit-chaton-britannique-bleu-gris-dormant-enveloppe-dans-couverture-carreaux-blanche-concept-adorables-animaux-compagnie_106368-4291.jpg",
"https://images.eatself.com/811/38179_10273994.png", "https://miro.medium.com/0*Ug2qG0Ph4JkU5pEZ.png",
"https://storage.googleapis.com/pod_public/1300/245798.jpg", "https://www.nextplz.fr/wp-content/uploads/nextplz/2018/05/18068280901060695.jpg",
"https://passed.fr/wp-content/uploads/2019/12/Zidane-1.jpg", "https://i.kym-cdn.com/entries/icons/original/000/038/806/tco_-_2021-11-10T112501.292.jpg",
"https://thumbs.dreamstime.com/z/homme-chinois-asiatique-d-affaires-7045702.jpg", "https://c8.alamy.com/compfr/b332ew/un-chinois-d-une-vingtaine-d-annees-avec-un-grand-sourire-b332ew.jpg",
"https://www.toutpourvosfetes.fr/30551-large_default/moustache-et-barbe-chinois.jpg", "https://thumbs.dreamstime.com/b/nain-petit-homme-4339718.jpg",
"https://pbs.twimg.com/media/GaecrTvaEAAreDl.jpg", "https://i.pinimg.com/736x/7f/a7/84/7fa78427092842091603dfcff6f849ca.jpg",
"https://retrogems.fr/wp-content/uploads/2025/12/asterion-copine-virale.jpg", "https://tribunedelyon.fr/wp-content/uploads/sites/5/2025/10/khalamite-pierre-ferrandis-10.jpg",
"https://media.tenor.com/JzOOJNV1gZUAAAAe/antoine-daniel-wtc.png", "https://www.pokepedia.fr/images/thumb/0/03/Lockpin-DP.png/800px-Lockpin-DP.png",
"https://i.pinimg.com/736x/8a/42/d2/8a42d20954675f8f5bcb931f2560d380.jpg", "https://www.clipartmax.com/png/middle/166-1665846_pikachu-meets-minecraft-by-drpoochew-pikachu-face-meme-png.png",
"https://www.picclickimg.com/ekoAAOSwrBBjrwRk/Flag-Palestine-Drapeau-Palestine-ecusson-brodu00e9-patche-thermocollant.webp",
"https://www.radiofrance.fr/s3/cruiser-production/2019/10/2ccb44bb-6211-4340-b063-4d7a015575d4/1200x680_kaaris-or-noir.jpg_or_noir.jpg",
"https://i.ebayimg.com/images/g/jagAAOxyu1BTj-fx/s-l1200.jpg", "https://www.radiofrance.fr/s3/cruiser-production-eu3/2019/06/d12bbc34-45f9-4b03-b762-25ae9988b888/640x340_gettyimages-624736982.jpg",
"https://upload.wikimedia.org/wikipedia/fr/b/b2/Minecraft%2C_le_film.png",
]
def get_server_status():
try:
server = JavaServer.lookup(f"{MON_HOST_NOIP}:{MC_PORT}")
status = server.status()
ping = round(status.latency, 1)
info = f"EN LIGNE 🟢 ({status.players.online}/{status.players.max})"
sub_info = f"<br><small style='color:#aaa'>Ping: {ping}ms</small>"
return info + sub_info, "#00ff00"
except:
try:
ip = socket.gethostbyname(MON_HOST_NOIP)
with socket.create_connection((ip, MC_PORT), timeout=1):
return "DÉMARRAGE... 🟡", "#fbbf24"
except:
return "HORS LIGNE 🔴", "#ff4444"
HTML_TEMPLATE = '''
<!DOCTYPE html>
<html>
<head>
<title>Cobblemon Dashboard</title>
<style>
body { background: url("{{ bg_image }}") no-repeat center center fixed; background-size: cover; font-family: 'Segoe UI', sans-serif; color: white; margin: 0; overflow: hidden; display: flex; justify-content: center; align-items: center; height: 100vh; }
.galerie-background { position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: 1; pointer-events: none; }
.sticker { position: absolute; border-radius: 10px; box-shadow: 0 4px 15px rgba(0,0,0,0.5); pointer-events: auto; transition: transform 0.3s ease; max-width: 150px; }
.container { background: rgba(0, 0, 0, 0.85); backdrop-filter: blur(15px); padding: 40px; border-radius: 30px; text-align: center; z-index: 10; border: 1px solid rgba(255,255,255,0.1); width: 90%; max-width: 400px; }
.status-msg { margin: 20px 0; font-size: 1.2em; line-height: 1.4; }
.btn-wake { padding: 18px 36px; cursor: pointer; border-radius: 15px; border: none; background: #059669; color: white; font-weight: bold; font-size: 1.1em; transition: transform 0.2s, background 0.2s; }
.btn-wake:hover { transform: scale(1.05); background: #10b981; }
.confirmation { color: #fbbf24; background: rgba(251, 191, 36, 0.1); padding: 10px; border-radius: 10px; margin-bottom: 15px; border: 1px solid #fbbf24; }
#snakeGame { border: 2px solid #2563eb; background: #000; margin-top: 20px; border-radius: 10px; }
.keys { display: flex; justify-content: center; gap: 8px; margin-top: 10px; }
.key { background: rgba(255,255,255,0.2); padding: 5px 12px; border-radius: 5px; border-bottom: 3px solid white; font-weight: bold; }
</style>
</head>
<body>
<div class="galerie-background">
{% for img_url in galerie %} <img src="{{ img_url }}" class="sticker"> {% endfor %}
</div>
<div class="container">
<h1>Cobblemon V2</h1>
<div class="status-msg">
Statut : <strong style="color: {{ status_color }};">{{ status_text|safe }}</strong>
</div>
{% if not logged_in %}
<form method="post" action="/login">
<input type="password" name="password" placeholder="Mot de passe" style="padding:12px; border-radius:8px; width: 80%; border:none;"><br><br>
<button type="submit" class="btn-wake" style="background: #2563eb;">CONNEXION</button>
</form>
{% else %}
{% if message %} <div class="confirmation">⚡ {{ message }}</div> {% endif %}
{% if show_snake %}
<canvas id="snakeGame" width="300" height="300"></canvas>
<div class="keys">
<div class="key">↑</div><div class="key">↓</div><div class="key">←</div><div class="key">→</div>
</div>
<script>
const canvas = document.getElementById("snakeGame"); const ctx = canvas.getContext("2d");
let snake = [{x:10, y:10}]; let food = {x:5, y:5}; let dx=0, dy=0;
document.addEventListener("keydown", e => {
if(e.key==="ArrowUp" && dy===0) {dx=0; dy=-1;}
if(e.key==="ArrowDown" && dy===0) {dx=0; dy=1;}
if(e.key==="ArrowLeft" && dx===0) {dx=-1; dy=0;}
if(e.key==="ArrowRight" && dx===0) {dx=1; dy=0;}
});
function draw() {
let head = {x: snake[0].x + dx, y: snake[0].y + dy};
snake.unshift(head);
if(head.x===food.x && head.y===food.y) {
food = {x:Math.floor(Math.random()*15), y:Math.floor(Math.random()*15)};
} else { snake.pop(); }
if(head.x<0 || head.x>=15 || head.y<0 || head.y>=15) return location.reload();
ctx.fillStyle = "black"; ctx.fillRect(0,0,300,300);
ctx.fillStyle = "red"; ctx.fillRect(food.x*20, food.y*20, 18, 18);
ctx.fillStyle = "#2563eb"; snake.forEach(p => ctx.fillRect(p.x*20, p.y*20, 18, 18));
setTimeout(draw, 100);
} draw();
</script>
{% else %}
<form action="/wake" method="post">
<button type="submit" class="btn-wake">🚀 ALLUMER SERVEUR</button>
</form>
{% endif %}
<p><a href="/" style="color: #666; text-decoration: none; font-size: 0.8em; margin-top: 20px; display: block;">🔄 ACTUALISER</a></p>
{% endif %}
</div>
<script>
document.querySelectorAll('.sticker').forEach((s, i) => {
s.style.left = Math.floor(Math.random() * 80) + "%";
s.style.top = Math.floor(Math.random() * 80) + "%";
s.style.transform = "rotate(" + (Math.floor(Math.random() * 40) - 20) + "deg)";
});
</script>
</body>
</html>
'''
@app.route('/')
def index():
status_text, status_color = get_server_status()
return render_template_string(HTML_TEMPLATE, logged_in=session.get('auth'),
status_text=status_text, status_color=status_color,
bg_image=IMAGE_FOND, galerie=IMAGES_GALERIE, show_snake=False)
@app.route('/login', methods=['POST'])
def login():
if request.form.get('password') == MOT_DE_PASSE: session['auth'] = True
return redirect('/')
@app.route('/wake', methods=['POST'])
def wake():
if not session.get('auth'): return redirect('/')
mac_clean = MAC_ADRESSE.replace(':', '').upper()
try:
# Résolution DNS de ton IP publique
target_ip = socket.gethostbyname(MON_HOST_NOIP)
# On utilise le service DNSExit qui est très direct
url = f"https://www.dnsexit.com/api/wol?mac={mac_clean}&host={target_ip}"
headers = {'User-Agent': 'Mozilla/5.0'}
r = requests.get(url, headers=headers, timeout=10)
if r.status_code == 200:
msg = f"🚀 Signal envoyé à {target_ip} !"
else:
msg = f"Signal envoyé (Code {r.status_code})"
except Exception as e:
msg = f"Erreur : {str(e)}"
status_text, status_color = get_server_status()
return render_template_string(HTML_TEMPLATE, logged_in=True, status_text=status_text,
status_color=status_color, bg_image=IMAGE_FOND,
galerie=IMAGES_GALERIE, show_snake=True, message=msg)
if __name__ == "__main__":
app.run(host='0.0.0.0', port=7860) |