From: Michael Tremer Date: Thu, 7 Feb 2013 12:51:24 +0000 (+0000) Subject: Remove obsolete pakfire CGI scripts. X-Git-Url: http://git.ipfire.org/?p=ipfire.org.git;a=commitdiff_plain;h=aff15b745e6e0871878b237ceb9e3e78a3249b59 Remove obsolete pakfire CGI scripts. --- diff --git a/pakfire/counter.py b/pakfire/counter.py deleted file mode 100644 index fcaa2be2..00000000 --- a/pakfire/counter.py +++ /dev/null @@ -1,49 +0,0 @@ -#!/usr/bin/python - -import cgitb, sys, os, time, cgi -cgitb.enable() - -### HTTP-Header -# -print "Content-type: text/html" -print - -form = cgi.FieldStorage() - -uuid = form.getfirst('uuid') -ver = form.getfirst('ver') -ipak = form.getfirst('ipak') -dpak = form.getfirst('dpak') -upak = form.getfirst('upak') -ret = form.getfirst('return') - -if not uuid or not ver: - sys.exit(1) # Exit when the arguments are not set - -if not os.path.exists("version/"+ver): - os.mkdir("version/"+ver) - -zeit = time.time() -string = "%s %d" % (os.environ['REMOTE_ADDR'], zeit) - -if ipak: - string += " installed %s %s" % (ipak, ret) -elif dpak: - string += " deleted %s %s" % (dpak, ret) -elif upak: - string += " upgraded %s %s" % (upak, ret) -else: - string += " update" - -string += "\n" - -f = open("version/"+ver+"/"+uuid, "a") -f.write(string) -f.close() - -for file in os.listdir("version/"+ver): - time_diff = zeit - os.path.getmtime("version/"+ver+"/"+file) - if time_diff > 259200: - os.remove("version/"+ver+"/"+file) - -print "200 OK" diff --git a/pakfire/show.py b/pakfire/show.py deleted file mode 100644 index ac69ee08..00000000 --- a/pakfire/show.py +++ /dev/null @@ -1,237 +0,0 @@ -#!/usr/bin/python - -import cgitb -import os -import time -import socket -import cgi -#import DNS -import GeoIP -cgitb.enable() - -#gi = GeoIP.new(GeoIP.GEOIP_STANDARD) -gi = GeoIP.new(GeoIP.GEOIP_MEMORY_CACHE) - -def print_header(): - print ''' - - - IPFire - Distribution - - - - -

IPFire Distribution

-

Made: %s

''' % (os.environ['SCRIPT_NAME'], ver, uuid, time.ctime()) - print "" - -def beautify_ip(ip): - try: - hostname = socket.gethostbyaddr(ip) - string = "%s (%s - %s)" % (hostname[0], ip, gi.country_code_by_addr(ip)) - except socket.herror, e: - error = "Couldn't look up name: %s" % e - string = "%s (%s)" % (error, ip) - return string - -def beautify_time(timestamp): - return time.strftime("%d-%m-%Y - %H:%M", time.localtime(float(timestamp))) - -def get_attributes(line): - status = "" - pak = "" - command = "" - args = line.split(" ") - ip = args[0] - timestamp = args[1] - if len(args) > 2: - command = args[2] - if len(args) > 3: - pak = args[3] - if len(args) > 4: - status = args[4] - - return ip, timestamp, command, pak, status - -def showuuid(uuid, ver): - print "

%s

" % (os.environ['SCRIPT_NAME'], dir, uuid, uuid, uuid) - -def summurize_addons(): - addons={} - installed={} - upgraded={} - deleted={} - oldest="9999999999999" - newest="0000000000000" - for dir in os.listdir("version/"): - if (dir == "empty.txt" ): - pass - else: - # print dir+"
" - for uuid in os.listdir("version/"+dir): - # print uuid+"
" - f = open("version/"+dir+"/"+uuid) - while True: - line = f.readline() - if len(line) == 0: - break # EOF - status = "" - pak = "" - command = "" - args = line.split(" ") - if oldest > args[1]: - oldest = args[1] - if newest < args[1]: - newest = args[1] - if len(args) > 2: - command = args[2] - # print command - if len(args) > 3: - pak = args[3] - # print pak - if len(args) > 4: - status = args[4] - # print status+"
" - if (status == "0\n") and (command == "installed") and (dir == "2.1" or dir == "2.3" ): - addons[pak] = addons.get(pak,0)+1 - installed[pak] = installed.get(pak,0)+1 - if (status == "0\n") and (command == "deleted") and (dir == "2.1" or dir == "2.3"): - addons[pak] = addons.get(pak,0)-1 - deleted[pak] = deleted.get(pak,0)+1 - if (status == "0\n") and (command == "upgraded") and (dir == "2.1" or dir == "2.3"): - upgraded[pak] = upgraded.get(pak,0)+1 - f.close() - print "Oldest one installed - %s" % beautify_time(oldest) - for x in range(10): - print " " - print "Latest action done - %s" % beautify_time(newest) - print "

" - - for x in range(1,31): - if ( x % 8 ): - print "" % (x,upgraded.get("core-upgrade-" + str(x),0)) - else: - print "" % (x,upgraded.get("core-upgrade-" + str(x),0)) - print "
Core %s - %sCore %s - %s


" - - print "" - for name, nummer in sorted(addons.items()): - print "" - print "
AddonAnzahlInstalliertDeinstalliert
" - print name - print "" - print nummer - print "+" - print installed.get(name, 0) - print "-" - print deleted.get(name, 0) - print "
" - -def showdetails(uuid, ver): - f = open("version/"+dir+"/"+uuid) - print "\n

"+uuid+"

" - print "" - print "" % timestamp - - print string - - print "
IP-addressUpdates" - while True: - line = f.readline() - if len(line) == 0: - break # EOF - - ip, timestamp, command, pak, status = get_attributes(line) - - if command == "update\n": - last_update = timestamp - continue - - string = "
" - string += beautify_ip(ip) - - timestamp = beautify_time(timestamp) - - - if command: - string += " - %s - %s" % (command, command, pak) - if not status == "0\n": - string += " %s" % status - - string += "%s
Last update:%s" % beautify_time(timestamp) - print "
" - f.close() - - -def summary(type): - print "" - print "" - if type == "global": - print "" - - count = 0 - version={} - - for dir in os.listdir("version/"): - if (dir == "empty.txt" ): - pass - else: - count += len(os.listdir("version/"+dir)) - print "" - - - print "
Summary
Versions available:", - for dir in os.listdir("version/"): - if (dir == "empty.txt" ): - pass - else: - print "%s (%s)
" % (dir, len(os.listdir("version/"+dir))), - print "
Number of total hosts:",count, - print "
" - -### HTTP-Header -# -print "Content-type: text/html" -print - -form = cgi.FieldStorage() - -ver = form.getfirst('ver') -uuid = form.getfirst('uuid') - -if not uuid: - uuid = "" - -print_header() - -summary("global") - -for dir in os.listdir("version/"): - if (dir == "empty.txt" ): - pass - else: - print "

%s

" % (os.environ['SCRIPT_NAME'], dir, dir) - if ver == dir: - for i in os.listdir("version/"+dir): - if i == uuid: - showdetails(i, dir) - else: - showuuid(i, dir) - -summurize_addons() - -print "" diff --git a/pakfire/version/empty.txt b/pakfire/version/empty.txt deleted file mode 100644 index e69de29b..00000000