raynor009 Posted October 30, 2012 Report Posted October 30, 2012 Deci am aici un script facut in Python(nu de mine) care are trebuie sa imi arate statusul unui server la un joc, cu numarul de jucatori online,statusul serverului(on sau off) si numarul de zile activ. Acest script este facut pentru o pagina web, dar nu stiu cum sa il instalez. Imi puteti explica si mie cum se face? Mai jos aveti si scriptu.#!/usr/bin/python # -*- coding: utf-8 -*-# cvet: For correct ping send 4 bytes to server - 0xFFFFFFFF, than receive 16 bytes, where 4 is current online, 4 bytes is uptime in seconds, others 8 is reserved. After server drop connection.# 22:08:|52<@Ghosthack> Send 0xFFFFFFFF to server, it will respond with 16 bytes, where first 4 is current number online, 4 bytes is uptime in seconds, the other 8 is reserved.# 23:43:|03<@Ghosthack> It sends in that order, how you retrieve it depends on your receive buffer. Use DWORD type, it's 4 bytes. One variable for number online and one for uptime.## FOStatus.py# by jan0s1kversion = "v1.3"import socketimport structaddress="fonline2238.net"port=2238s = socket.socket( socket.AF_INET, socket.SOCK_STREAM)s.settimeout(1.0)try: s.connect((address, port)) s.send("\xFF" * 4) recive = s.recv(16) players, uptime = struct.unpack('LL', recive[:8]) uptime_human = uptime / 86400 zmienna1 = "Online: " zmienna2 = "days, " zmienna3 = "players online" zmienna4 = "%s %d %s %d %s" % (zmienna1, uptime_human, zmienna2, players, zmienna3) print zmienna4 s.close()except Exception, e: print 'Server is offline' Quote
B7ackAnge7z Posted October 31, 2012 Report Posted October 31, 2012 P?i, depinde unde dore?ti s? execu?i acest script. De exemplu, dac? pe un server ce are instalat Python-ul ?i ai folderul /cgi-bin — salveaz?-l acolo, folosind extensia „.py”. Quote
raynor009 Posted October 31, 2012 Author Report Posted October 31, 2012 P?i, depinde unde dore?ti s? execu?i acest script. De exemplu, dac? pe un server ce are instalat Python-ul ?i ai folderul /cgi-bin — salveaz?-l acolo, folosind extensia „.py”.Pai pe prima pagina sau ceva de genu pe index. Dar tu spui ca hostul respectiv trebuie sa aiba instalat python ca sa functioneze? Exista ceva hosturi gratis cu python? Quote