]>
git.ipfire.org Git - ipfire.org.git/blob - pakfire/show.py
12 #gi = GeoIP.new(GeoIP.GEOIP_STANDARD)
13 gi
= GeoIP
.new(GeoIP
.GEOIP_MEMORY_CACHE
)
16 print '''<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
17 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
18 <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
20 <title>IPFire - Distribution</title>
21 <style type="text/css">
22 body { font-family: Verdana; font-size: 9pt; background-color:#f0f0f0; }
23 a:link { color: black; text-decoration: none; }
24 a:visited { color: black; text-decoration: none; }
25 table { font-family: Verdana; font-size: 8pt; border: 1px solid; }
26 td.header { background-color: #a0a0a0; text-align: center; color: white; }
27 td.date { text-align: center; }
28 font.installed { color: green; }
29 font.deleted { color: red; }
30 font.update { color: blue; }
31 font.error { color: red; }
32 td.online { background: green; color: white; text-align: center; }
33 td.offline { background: red; color: white; text-align: center; }
35 <meta http-equiv="refresh" content="60; URL=%s?ver=%s&uuid=%s" />
38 <h1>IPFire Distribution</h1>
39 <p>Made: %s</p>''' % (os
.environ
['SCRIPT_NAME'], ver
, uuid
, time
.ctime())
44 hostname
= socket
.gethostbyaddr(ip
)
45 string
= "<b>%s</b> (%s - %s)" % (hostname
[0], ip
, gi
.country_code_by_addr(ip
))
46 except socket
.herror
, e
:
47 error
= "Couldn't look up name: %s" % e
48 string
= "<b>%s</b> (%s)" % (error
, ip
)
51 def beautify_time(timestamp
):
52 return time
.strftime("%d-%m-%Y - %H:%M", time
.localtime(float(timestamp
)))
54 def get_attributes(line
):
58 args
= line
.split(" ")
68 return ip
, timestamp
, command
, pak
, status
70 def showuuid(uuid
, ver
):
71 print "<h3><a href='%s?ver=%s&uuid=%s#%s'>%s</a></h3>" % (os
.environ
['SCRIPT_NAME'], dir, uuid
, uuid
, uuid
)
73 def summurize_addons():
78 oldest
="9999999999999"
79 newest
="0000000000000"
80 for dir in os
.listdir("version/"):
81 if (dir == "empty.txt" ):
85 for uuid
in os
.listdir("version/"+dir):
87 f
= open("version/"+dir+"/"+uuid
)
95 args
= line
.split(" ")
108 # print status+"<br />"
109 if (status
== "0\n") and (command
== "installed") and (dir == "2.1" or dir == "2.3" ):
110 addons
[pak
] = addons
.get(pak
,0)+1
111 installed
[pak
] = installed
.get(pak
,0)+1
112 if (status
== "0\n") and (command
== "deleted") and (dir == "2.1" or dir == "2.3"):
113 addons
[pak
] = addons
.get(pak
,0)-1
114 deleted
[pak
] = deleted
.get(pak
,0)+1
115 if (status
== "0\n") and (command
== "upgraded") and (dir == "2.1" or dir == "2.3"):
116 upgraded
[pak
] = upgraded
.get(pak
,0)+1
118 print "Oldest one installed - %s" % beautify_time(oldest
)
121 print "Latest action done - %s" % beautify_time(newest
)
122 print "<br /><br /><table width='50%'><tr>"
124 for x
in range(1,31):
126 print "<td align='center'>Core %s - %s</td>" % (x
,upgraded
.get("core-upgrade-" + str(x
),0))
128 print "<td align='center'>Core %s - %s</td></tr><tr>" % (x
,upgraded
.get("core-upgrade-" + str(x
),0))
129 print "</table><br /><br /><table width='50%'>"
131 print "<tr><td class='header'>Addon</td><td class='header'>Anzahl</td><td class='header'>Installiert</td><td class='header'>Deinstalliert</td></tr>"
132 for name
, nummer
in sorted(addons
.items()):
133 print "<tr><td align='center'>"
135 print "</td><td align='center'>"
137 print "</td><td align='center'><font color=green>+"
138 print installed
.get(name
, 0)
139 print "</fond></td><td align='center'><font color=red>-"
140 print deleted
.get(name
, 0)
144 def showdetails(uuid
, ver
):
145 f
= open("version/"+dir+"/"+uuid
)
146 print "<a name='"+uuid
+"' />\n<h3>"+uuid
+"</h3>"
147 print "<table width='70%'>"
148 print "<tr><td class='header' width='70%'>IP-address<td class='header' width='30%'>Updates"
154 ip
, timestamp
, command
, pak
, status
= get_attributes(line
)
156 if command
== "update\n":
157 last_update
= timestamp
161 string
+= beautify_ip(ip
)
163 timestamp
= beautify_time(timestamp
)
167 string
+= " - <font class='%s'>%s</font> - %s" % (command
, command
, pak
)
168 if not status
== "0\n":
169 string
+= " <font class='error'>%s</font>" % status
171 string
+= "</td><td class='date'>%s</td></tr>" % timestamp
175 print "<tr><td>Last update:</td><td align='center'>%s" % beautify_time(timestamp
)
181 print "<table width='50%'>"
182 print "<tr><td class='header' colspan='2'>Summary</td></tr>"
184 print "<tr><td>Versions available:</td><td>",
185 for dir in os
.listdir("version/"):
186 if (dir == "empty.txt" ):
189 print "%s (%s)<br>" % (dir, len(os
.listdir("version/"+dir))),
195 for dir in os
.listdir("version/"):
196 if (dir == "empty.txt" ):
199 count
+= len(os
.listdir("version/"+dir))
200 print "<tr><td>Number of total hosts:</td><td>",count
,
208 print "Content-type: text/html"
211 form
= cgi
.FieldStorage()
213 ver
= form
.getfirst('ver')
214 uuid
= form
.getfirst('uuid')
223 for dir in os
.listdir("version/"):
224 if (dir == "empty.txt" ):
227 print "<h2><a href='%s?ver=%s&uuid='>%s</a></h2>" % (os
.environ
['SCRIPT_NAME'], dir, dir)
229 for i
in os
.listdir("version/"+dir):
237 print "</body></html>"