global: 'Dream Multimedia' -> 'Dream Property'
[enigma2-plugins.git] / fancontrol2 / src / FC2webSite.py
1 # -*- coding: utf-8 -*-
2 from twisted.web import resource, http
3 from globals import *
4 from plugin import *
5 from Sensors import sensors
6 from Components.config import configfile, config
7
8 import os
9 import datetime
10
11 ########################################################
12 class FC2web(resource.Resource):
13     
14         title = "FanControl2 Webinterface"
15         isLeaf = False
16    
17         def render(self, req):
18                 req.setHeader('Content-type', 'text/html')
19                 req.setHeader('charset', 'UTF-8')
20
21                 """ rendering server response """
22                 command = req.args.get("cmd",None)
23
24                 html = "<html>"
25                 html += "<head>\n"
26                 html += "<meta http-equiv=\"Content-Language\" content=\"de\">\n"
27                 html += "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=windows-1252\">\n"
28                 html += "<meta http-equiv=\"cache-control\" content=\"no-cache\" />\n"
29                 html += "<meta http-equiv=\"pragma\" content=\"no-cache\" />\n"
30                 html += "<meta http-equiv=\"expires\" content=\"0\">\n"
31                 html += "<meta http-equiv=\"refresh\" content=\"20\">\n"
32                 html += "<title>Fan Control 2 - Info</title>\n"
33                 html += "</head>"
34                 html += "<body bgcolor=\"#666666\" text=\"#FFFFFF\">\n"
35                 html += "<form method=\"POST\" action=\"--WEBBOT-SELF--\">\n"
36                 html += "<table border=\"1\" width=\"500\" bordercolorlight=\"#000000\" bordercolordark=\"#000000\" cellspacing=\"1\"><tr><td bgcolor=\"#000000\" width=\"200\">\n"
37                 html += "<p align=\"center\"><img border=\"0\" src=\"/fancontrol/FC2dreambox.png\" width=\"181\" height=\"10\">\n"
38                 html += "<font color=\"#FFFFFF\"><BR><b>Fan Control 2 - Info</b></font></p>\n"
39                 html += "</td><td bgcolor=\"#000000\">\n"
40                 html += "<p align=\"right\">"
41                 html += BoxStatus()
42                 if os.path.exists(config.plugins.FanControl.LogPath.value + "FC2data.csv"):
43                         html += "<a href=\"/fancontrol/chart\"><img border=\"0\" src=\"/fancontrol/FC2Chart.png\" width=\"100\" height=\"40\"></a>\n"
44                 html += "<a href=\"/fancontrol/log\"><img border=\"0\" src=\"/fancontrol/FC2Setup.png\" width=\"100\" height=\"40\"></a></td></tr></table>\n"
45                 html += "<table border=\"1\" width=\"500\" id=\"table1\">\n"
46                 html += "<tr>\n"
47                 html += "<td>%s: <b><font color=\"#FFCC00\">%4.1f �C</font></b></td>\n" % (_("Temperature"),FC2werte[0])
48                 html += "<td>%s: <font color=\"#FFCC00\"><b>%4d rpm</b></font></td>\n" % (_("Speed"),FC2werte[1])
49                 html += "<td>%s: <font color=\"#FFCC00\"><b>%03d</b></font></td>\n" % (_("Voltage"),FC2werte[2])
50                 html += "<td>PWM: <font color=\"#FFCC00\"><b>%03d</b></font></td>\n" % FC2werte[3]
51                 html += "</tr>\n"
52                 html += "</table>\n"
53
54                 html += "<table border=\"1\" width=\"500\">\n"
55                 html += "<tr>\n"
56                 html += "<td>%s �C</td>\n" % _("Sensors")
57                 templist = sensors.getSensorsList(sensors.TYPE_TEMPERATURE)
58                 tempcount = len(templist)
59                 for count in range(tempcount):
60                         if sensors.getSensorName(count) == "undefined":
61                                 N = TempName[count]
62                         else:
63                                 N = sensors.getSensorName(count)
64                         html += "<td><font color=\"#FFCC00\" title=\"%s\">%d</font></td>" % (N,sensors.getSensorValue(count))
65                 if FC2werte[4] > 0:
66                         html += "<td><font size=\"1\">HDD </font><font color=\"#FFCC00\">%d</font></td>\n" % FC2werte[4]
67                 html += "</tr>\n"
68                 html += "</table>\n"
69
70                 html += "<table border=\"1\" width=\"500\">\n"
71                 html += "<tr>\n"
72                 for count in range(0,12):
73                         tmp = ("<BR>-" if FC2stunde[count] == "-" else FC2stunde[count])
74                         html +="<td><p align=\"center\"><font size=\"1\">%02d:00<br><font color=\"#FFCC00\">%s</font></font></td>\n" % (count,tmp)
75                 html += "</tr><tr>\n"
76                 for count in range(12,24):
77                         tmp = ("<BR>-" if FC2stunde[count] == "-" else FC2stunde[count])
78                         html +="<td><p align=\"center\"><font size=\"1\">%02d:00<br><font color=\"#FFCC00\">%s</font></font></td>\n" % (count,tmp)
79                 html += "</tr></table>\n"
80
81                 html += "<script type=\"text/javascript\">\n"
82                 html += "function doLogWrite() {\n"
83                 html += "var iFrameWin = window.myIFrameName;\n"
84                 html += "iFrameWin.document.write('<html><head><title>FC2 Log Window</title></head><body bgcolor=\"#D3D3D3\">');\n"
85                 html += "iFrameWin.document.write('<font size=\"-1\">');\n"
86                 for L in FC2Log:
87                         html += "iFrameWin.document.write('" + L + "<br>');\n"
88                 html += "iFrameWin.document.write('</font>');\n"
89                 html += "iFrameWin.document.write('</body></html>');\n"
90                 html += "iFrameWin.document.close();\n"
91                 html += "}\n"
92                 html += "</script>\n"
93                 html += "<iframe id=\"myIFrameId\" name=\"myIFrameName\" width=\"500\" height=\"320\" marginwidth=\"5\" vspace=\"2\" marginheight=\"5\" frameborder=\"1\" scrolling=\"auto\"></iframe>\n"
94                 html += "<script>doLogWrite();\n"
95                 html += "myIFrameName.document.body.scrollTop = myIFrameName.document.body.scrollHeight*100;\n" 
96                 html += "</script>\n"
97
98                 html += "<table border=\"1\" width=\"500\">\n"
99                 html += "<tr>\n"
100                 html += "<td>Version: %s </td>\n" % Version
101                 html += "<td>Settings: %s-%s �C</td>\n" % (config.plugins.FanControl.temp.value,config.plugins.FanControl.tempmax.value)
102                 html += "<td>%s-%s rpm</td>\n" % (config.plugins.FanControl.minRPM.value,config.plugins.FanControl.maxRPM.value)
103                 html += "</tr>\n"
104                 html += "</table>\n"
105                 html += "</body>\n"
106                 html += "</html>\n"
107
108                 html += "</form>\n"
109
110                 return html
111
112 ##########################################################
113 class FC2webLog(resource.Resource):
114     
115         title = "FanControl2 Webinterface"
116         isLeaf = True
117
118         def render(self, req):
119                 command = req.args.get("cmd",None)
120                 html = ""
121                 if command is None:
122                         req.setHeader('Content-type', 'text/html')
123                         req.setHeader('charset', 'UTF-8')
124
125                         """ rendering server response """
126
127                         html = "<html>"
128                         html += "<head>"
129                         html += "<meta http-equiv=\"Content-Language\" content=\"de\">"
130                         html += "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=windows-1252\">"
131                         html += "<meta http-equiv=\"cache-control\" content=\"no-cache\" />"
132                         html += "<meta http-equiv=\"pragma\" content=\"no-cache\" />"
133                         html += "<meta http-equiv=\"expires\" content=\"0\">"
134                         html += "<meta http-equiv=\"refresh\" content=\"30\">"
135                         html += "<title>Fan Control 2 - Logging</title>"
136                         html += "</head>"
137                         html += "<body bgcolor=\"#666666\" text=\"#FFFFFF\">\n"
138                         html += "<table border=\"1\" width=\"500\" bordercolorlight=\"#000000\" bordercolordark=\"#000000\" cellspacing=\"1\"><tr><td bgcolor=\"#000000\" width=\"200\">\n"
139                         html += "<p align=\"center\"><img border=\"0\" src=\"/fancontrol/FC2dreambox.png\" width=\"181\" height=\"10\">\n"
140                         html += "<font color=\"#FFFFFF\"><BR><b>Fan Control 2 - Logging</b></font></p>\n"
141                         html += "</td><td bgcolor=\"#000000\">\n"
142                         html += "<p align=\"right\">"
143                         html += BoxStatus()
144                         if os.path.exists(config.plugins.FanControl.LogPath.value + "FC2data.csv"):
145                                 html += "<a href=\"/fancontrol/chart\"><img border=\"0\" src=\"/fancontrol/FC2Chart.png\" width=\"100\" height=\"40\"></a>\n"
146                         html += "<a href=\"/fancontrol\"><img border=\"0\" src=\"/fancontrol/FC2Info.png\" width=\"100\" height=\"40\"></a></td></tr></table>\n"
147
148                         html += "<table border=\"1\" width=\"500\">"
149                         html += "<tr><td width=\"50%\" align=\"center\" valign=\"top\">Data Logging "
150                         if config.plugins.FanControl.EnableDataLog.value:
151                                 html += "<font color=\"#00FF00\">%s</font>" % _("active")
152                                 html += "<form method=\"GET\">"
153                                 html += "<input type=\"hidden\" name=\"cmd\" value=\"dataenable\">"
154                                 html += "<input type=\"submit\" value=\"%s\">" % _("turn off")
155                                 html += "</form>"
156                         else:
157                                 html += "<font color=\"#FF0000\">%s</font>" % _("not active")
158                                 html += "<form method=\"GET\">"
159                                 html += "<input type=\"hidden\" name=\"cmd\" value=\"dataenable\">"
160                                 html += "<input type=\"submit\" value=\"%s\">" % _("turn on")
161                                 html += "</form>"
162                         if os.path.exists(config.plugins.FanControl.LogPath.value + "FC2data.csv"):
163                                 s = os.stat(config.plugins.FanControl.LogPath.value + "FC2data.csv")
164                                 if int(s.st_size/1024) == 0:
165                                         html += "<BR>" + _("Filesize : %d %sByte") % (int(s.st_size), "")
166                                 else:
167                                         html += "<BR>" + _("Filesize : %d %sByte") % (int(s.st_size/1024), "k")
168                                 s = os.statvfs(config.plugins.FanControl.LogPath.value)
169                                 html += "<BR>" + _("Disk free : %d MByte") % (int(s.f_bsize * s.f_bavail / 1024 / 1024))
170                                 html += "<form method=\"GET\">"
171                                 html += "<input type=\"hidden\" name=\"cmd\" value=\"data\">"
172                                 html += "<input type=\"submit\" value=\"%s\">" % _("Download")
173                                 html += "</form>"
174                                 html += "<form method=\"GET\">"
175                                 html += "<input type=\"hidden\" name=\"cmd\" value=\"datadel\">"
176                                 html += "<input type=\"submit\" value=\"%s\">" % _("Delete")
177                                 html += "</form>"
178                                 html += "<form method=\"GET\">"
179                                 html += "<input type=\"hidden\" name=\"cmd\" value=\"datadel48h\">"
180                                 html += "<input type=\"submit\" value=\"%s\">" % _("Delete older 48h")
181                                 html += "</form>"
182                         else:
183                                 html += "<BR>" + _("File %s does not exists") % "FC2data.csv"
184
185                         html += "</td><td width=\"50%\" align=\"center\" valign=\"top\">Event Logging "
186                         if config.plugins.FanControl.EnableEventLog.value:
187                                 html += "<font color=\"#00FF00\">%s</font>" % _("active")
188                                 html += "<form method=\"GET\">"
189                                 html += "<input type=\"hidden\" name=\"cmd\" value=\"eventsenable\">"
190                                 html += "<input type=\"submit\" value=\"%s\">" % _("turn off")
191                                 html += "</form>"
192                         else:
193                                 html += "<font color=\"#FF0000\">%s</font>" % _("not active")
194                                 html += "<form method=\"GET\">"
195                                 html += "<input type=\"hidden\" name=\"cmd\" value=\"eventsenable\">"
196                                 html += "<input type=\"submit\" value=\"%s\">" % _("turn on")
197                                 html += "</form>"
198                         if os.path.exists(config.plugins.FanControl.LogPath.value + "FC2events.txt"):
199                                 s = os.stat(config.plugins.FanControl.LogPath.value + "FC2events.txt")
200                                 if int(s.st_size/1024) == 0:
201                                         html += "<BR>" + _("Filesize : %d %sByte") % (int(s.st_size), "")
202                                 else:
203                                         html += "<BR>" + _("Filesize : %d %sByte") % (int(s.st_size/1024), "k")
204                                 s = os.statvfs(config.plugins.FanControl.LogPath.value)
205                                 html += "<BR>" + _("Disk free : %d MByte") % (int(s.f_bsize * s.f_bavail / 1024 / 1024))
206                                 html += "<form method=\"GET\">"
207                                 html += "<input type=\"hidden\" name=\"cmd\" value=\"events\">"
208                                 html += "<input type=\"submit\" value=\"%s\">" % _("Download")
209                                 html += "</form>"
210                                 html += "<form method=\"GET\">"
211                                 html += "<input type=\"hidden\" name=\"cmd\" value=\"eventsdel\">"
212                                 html += "<input type=\"submit\" value=\"%s\">" % _("Delete")
213                                 html += "</form>"
214 #                               html += "<form method=\"GET\">"
215 #                               html += "<input type=\"hidden\" name=\"cmd\" value=\"eventsdel48h\">"
216 #                               html += "<input type=\"submit\" value=\"%s\">" % _("Delete older 48h")
217 #                               html += "</form>"
218
219                         else:
220                                 html += "<BR>" + _("File %s does not exists") % "FC2events.txt"
221                         html += "</td></tr></table>"
222                         html += _("Logging-Path: %s") % config.plugins.FanControl.LogPath.value
223                         html += "<BR>" + _("Auto-Delete older %s Days") % config.plugins.FanControl.DeleteData.value
224                         html += "</html>"
225
226                 elif command[0] ==  "data":
227                         req.setResponseCode(http.OK)
228 #                       req.setHeader('Content-type', 'application/octet-stream')
229                         req.setHeader('Content-type', 'application/vnd.ms-excel')
230                         req.setHeader('Content-Disposition', 'attachment;filename=FC2data.csv')
231                         req.setHeader('Content-Length', os.stat(config.plugins.FanControl.LogPath.value + "FC2data.csv").st_size)
232 #                       req.setHeader('Content-Disposition', 'inline;filename=FC2data.csv')
233                         req.setHeader('charset', 'UTF-8')
234                         f = open(config.plugins.FanControl.LogPath.value + "FC2data.csv","r")
235                         html = f.read()
236                         f.close()
237                 elif command[0] ==  "datadel":
238                         if os.path.exists(config.plugins.FanControl.LogPath.value + "FC2data.csv"):
239                                 os.remove(config.plugins.FanControl.LogPath.value + "FC2data.csv")
240                         CreateDataHead()
241                         html = LogRefresh()
242                 elif command[0] ==  "datadel48h":
243                         if os.path.exists(config.plugins.FanControl.LogPath.value + "FC2data.csv") and os.stat(config.plugins.FanControl.LogPath.value + "FC2data.csv").st_size > 10000:
244                                 f = open(config.plugins.FanControl.LogPath.value + "FC2data.csv","a")
245                                 s = f.tell()
246                                 f.close()
247                                 f = open(config.plugins.FanControl.LogPath.value + "FC2data.csv","r")
248                                 f.seek(s-100)
249                                 line = f.readline()
250                                 line = f.readline()
251                                 DT = line.split(";")
252                                 DT = DT[0].split(" ")
253                                 DD = DT[0].split(".")
254                                 DD48h = datetime.date(int(DD[0]),int(DD[1]),int(DD[2])) - datetime.timedelta(2)
255                                 Dfind = "%04d.%02d.%02d %s" % (DD48h.year,DD48h.month,DD48h.day,DT[1])
256                                 f.seek(0)
257                                 line = f.readline()
258                                 fw = open(config.plugins.FanControl.LogPath.value + "FC2data.csv.tmp","w")
259                                 fw.write(HeadLine)
260                                 for line in f.readlines():
261                                         DT = line.split(";")
262                                         if DT[0] > Dfind:
263                                                 fw.write(line)
264                                 f.close()
265                                 fw.close()
266                                 if os.path.exists(config.plugins.FanControl.LogPath.value + "FC2data.csv"):
267                                         os.remove(config.plugins.FanControl.LogPath.value + "FC2data.csv")
268                                 if os.path.exists(config.plugins.FanControl.LogPath.value + "FC2data.csv.tmp"):
269                                         os.rename(config.plugins.FanControl.LogPath.value + "FC2data.csv.tmp",config.plugins.FanControl.LogPath.value + "FC2data.csv")
270                         html = LogRefresh()
271                 elif command[0] ==  "dataenable":
272                         config.plugins.FanControl.EnableDataLog.value = not config.plugins.FanControl.EnableDataLog.value
273                         CreateDataHead()
274                         config.plugins.FanControl.EnableDataLog.save()
275                         html = LogRefresh()
276
277                 elif command[0] ==  "events":
278                         req.setResponseCode(http.OK)
279                         req.setHeader('Content-type', 'application/octet-stream')
280                         req.setHeader('Content-Disposition', 'attachment;filename=FC2events.txt')
281                         req.setHeader('Content-Length', os.stat(config.plugins.FanControl.LogPath.value + "FC2events.txt").st_size)
282 #                       req.setHeader('Content-Disposition', 'inline;filename=FC2events.txt')
283                         req.setHeader('charset', 'UTF-8')
284                         f = open(config.plugins.FanControl.LogPath.value + "FC2events.txt","r")
285                         html = f.read()
286                         f.close()
287                 elif command[0] ==  "eventsdel":
288                         if os.path.exists(config.plugins.FanControl.LogPath.value + "FC2events.txt"):
289                                 os.remove(config.plugins.FanControl.LogPath.value + "FC2events.txt")
290                         html = LogRefresh()
291                 elif command[0] ==  "eventsdel48h":
292                         if os.path.exists(config.plugins.FanControl.LogPath.value + "FC2events.txt"):
293                                 f = open(config.plugins.FanControl.LogPath.value + "FC2events.txt","a")
294                                 s = f.tell()
295                                 f.close()
296                                 f = open(config.plugins.FanControl.LogPath.value + "FC2events.txt","r")
297                                 f.seek(s-100)
298                                 line = f.readline()
299                                 line = f.readline()
300                                 DT = line.split(";")
301                                 DT = DT[0].split(" ")
302                                 DD = DT[0].split(".")
303                                 DD48h = datetime.date(int(DD[0]),int(DD[1]),int(DD[2])) - datetime.timedelta(2)
304                                 Dfind = "%04d.%02d.%02d %s" % (DD48h.year,DD48h.month,DD48h.day,DT[1])
305                                 f.seek(0)
306                                 line = f.readline()
307                                 fw = open(config.plugins.FanControl.LogPath.value + "FC2events.txt.tmp","w")
308                                 fw.write(HeadLine)
309                                 for line in f.readlines():
310                                         DT = line.split(";")
311                                         if DT[0] > Dfind:
312                                                 fw.write(line)
313                                 f.close()
314                                 fw.close()
315                                 if os.path.exists(config.plugins.FanControl.LogPath.value + "FC2events.txt"):
316                                         os.remove(config.plugins.FanControl.LogPath.value + "FC2events.txt")
317                                 if os.path.exists(config.plugins.FanControl.LogPath.value + "FC2events.txt.tmp"):
318                                         os.rename(config.plugins.FanControl.LogPath.value + "FC2events.txt.tmp",config.plugins.FanControl.LogPath.value + "FC2events.txt")
319                         html = LogRefresh()
320                 elif command[0] ==  "eventsenable":
321                         config.plugins.FanControl.EnableEventLog.value = not config.plugins.FanControl.EnableEventLog.value
322                         config.plugins.FanControl.EnableEventLog.save()
323                         html = LogRefresh()
324
325                 return html
326
327 def LogRefresh():
328         h = "<html>"
329         h += "<head>"
330         h += "<meta http-equiv=\"refresh\" content=\"1; url=/fancontrol/log\">"
331         h += "<a href=\"/fancontrol/log\">Execution completed... jump back...</a>"
332         h += "</html>"
333         h += "</head>"
334         return h
335
336 def CreateDataHead():
337         if not os.path.exists(config.plugins.FanControl.LogPath.value + "FC2data.csv") and config.plugins.FanControl.EnableDataLog.value and Free(config.plugins.FanControl.LogPath.value):
338                 try:
339                         f = open(config.plugins.FanControl.LogPath.value + "FC2data.csv","w")
340                         try:
341                                 f.write(HeadLine)
342                         except:
343                                 f.close()
344                 except IOError:
345                         pass
346
347 ##########################################################
348 class FC2webChart(resource.Resource):
349     
350         title = "FanControl2 Webinterface"
351         isLeaf = True
352     
353         def render(self, req):
354                 command = req.args.get("cmd",None)
355                 html = ""
356                 if os.path.exists(config.plugins.FanControl.LogPath.value + "FC2data.csv"):
357                         req.setHeader('Content-type', 'text/html')
358                         req.setHeader('charset', 'UTF-8')
359
360                         """ rendering server response """
361
362                         f = open(config.plugins.FanControl.LogPath.value + "FC2data.csv","a")
363                         s = f.tell()
364                         f.close()
365                         if s < 150:
366                                 html = "<html><body><html>Not enough Data (wait 3min)!</body></html>"
367                                 return html
368                         f = open(config.plugins.FanControl.LogPath.value + "FC2data.csv","r")
369                         f.seek(s-100)
370                         line = f.readline()
371                         line = f.readline()
372                         DT = line.split(";")
373                         DT = DT[0].split(" ")
374                         DD = DT[0].split(".")
375                         DD48h = datetime.date(int(DD[0]),int(DD[1]),int(DD[2])) - datetime.timedelta(2)
376                         Dfind = "%04d.%02d.%02d %s" % (DD48h.year,DD48h.month,DD48h.day,DT[1])
377                         f.seek(0)
378                         line = f.readline()
379                         Anzahl = 0
380                         for line in f.readlines():
381                                 DT = line.split(";")
382                                 if DT[0] > Dfind:
383                                         Anzahl += 1
384 #                       Anzahl -= 1
385                         html = "<html>"
386                         html += "<head>"
387                         html += "<meta http-equiv=\"Content-Language\" content=\"de\">"
388                         html += "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=windows-1252\">"
389                         html += "<meta http-equiv=\"cache-control\" content=\"no-cache\" />"
390                         html += "<meta http-equiv=\"pragma\" content=\"no-cache\" />"
391                         html += "<meta http-equiv=\"expires\" content=\"0\">"
392                         html += "<title>Fan Control 2 - Chart</title>"
393                         html += "</head>"
394                         html += "<body bgcolor=\"#666666\" text=\"#FFFFFF\">\n"
395                         html += "<table border=\"1\" width=\"900\" bordercolorlight=\"#000000\" bordercolordark=\"#000000\"  cellspacing=\"1\"><tr><td bgcolor=\"#000000\" width=\"200\">\n"
396                         html += "<p align=\"center\"><img border=\"0\" src=\"/fancontrol/FC2dreambox.png\" width=\"181\" height=\"10\">\n"
397                         html += "<font color=\"#FFFFFF\"><BR><b>Fan Control 2 - Chart</b></font></p>\n"
398                         html += "</td><td bgcolor=\"#000000\">\n"
399                         html += "<p align=\"right\">"
400                         html += BoxStatus()
401                         if os.path.exists(config.plugins.FanControl.LogPath.value + "FC2data.csv"):
402                                 html += "<a href=\"/fancontrol\"><img border=\"0\" src=\"/fancontrol/FC2Info.png\" width=\"100\" height=\"40\"></a>\n"
403                         html += "<a href=\"/fancontrol/log\"><img border=\"0\" src=\"/fancontrol/FC2Setup.png\" width=\"100\" height=\"40\"></a></td></tr></table>\n"
404
405                         html += "<applet code=\"diagram.class\" codebase=\"/fancontrol/\" name=\"DiaTemp\" "
406                         html += "align=\"baseline\" width=\"900\" height=\"250\" mayscript>\n"
407                         html += "<param name=\"title\" value=\"Temp  (48h - %s)\">\n" % DT[0]
408                         html += "<param name=\"bgcolor\" value=\"240; 240; 240\">\n"
409                         html += "<param name=\"ytitle\" value=\"Temp\">\n"
410                         html += "<param name=\"rolling\" value=\"%d\">\n" % Anzahl
411                         html += "<param name=\"show_xscale\" value=\"atText\">\n"
412                         html += "<param name=\"show_ygrid\" value=\"true\">\n"
413                         html += "<param name=\"show_xgrid\" value=\"true\">\n"
414
415                         html += "<param name=\"y0\" value=\"\">\n"
416                         html += "<param name=\"color0\" value=\"240; 0; 0\">\n"
417                         html += "<param name=\"style0\" value=\"LINE\">\n"
418                         html += "<param name=\"ylabel0\" value=\"Temp\">\n"
419
420                         html += "<param name=\"y1\" value=\"\">\n"
421                         html += "<param name=\"color1\" value=\"240; 0; 240\">\n"
422                         html += "<param name=\"style1\" value=\"LINE\">\n"
423                         html += "<param name=\"ylabel1\" value=\"HDD\">\n"
424
425                         html += "<param name=\"y2\" value=\"\">\n"
426                         html += "<param name=\"color2\" value=\"0; 255; 0\">\n"
427                         html += "<param name=\"style2\" value=\"LINE\">\n"
428                         html += "<param name=\"ylabel2\" value=\"BoxOn\">\n"
429
430                         html += "<param name=\"y3\" value=\"\">\n"
431                         html += "<param name=\"color3\" value=\"72; 118; 255\">\n"
432                         html += "<param name=\"style3\" value=\"LINE\">\n"
433                         html += "<param name=\"ylabel3\" value=\"HDDon\">\n"
434
435                         html += "<param name=\"y4\" value=\"\">\n"
436                         html += "<param name=\"color4\" value=\"255; 165; 0\">\n"
437                         html += "<param name=\"style4\" value=\"LINE\">\n"
438                         html += "<param name=\"ylabel4\" value=\"Record\">\n"
439
440                         html += "</applet>\n"
441
442 #                       html += "<div style=\"position: absolute; width: 100px; height: 100px; z-index: 1; left: 910px; top: 146px\" id=\"Ebene1\">\n"
443 #                       html += "<img border=\"0\" src=\"/web-data/fc2/FC2Status.png\" width=\"115\" height=\"168\"></div>\n"
444
445                         html += "<applet code=\"diagram.class\" codebase=\"/fancontrol/\" name=\"DiaRPM\" "
446                         html += "align=\"baseline\" width=\"900\" height=\"250\" mayscript>\n"
447                         html += "<param name=\"title\" value=\"RPM  (48h - %s)\">\n" % DT[0]
448                         html += "<param name=\"bgcolor\" value=\"240; 240; 240\">\n"
449                         html += "<param name=\"ytitle\" value=\"RPM\">\n"
450                         html += "<param name=\"rolling\" value=\"%d\">\n" % Anzahl
451                         html += "<param name=\"show_xscale\" value=\"atText\">\n"
452                         html += "<param name=\"show_ygrid\" value=\"true\">\n"
453                         html += "<param name=\"show_xgrid\" value=\"true\">\n"
454
455                         html += "<param name=\"y0\" value=\"\">\n"
456                         html += "<param name=\"color0\" value=\"240; 0; 0\">\n"
457                         html += "<param name=\"style0\" value=\"LINE\">\n"
458                         html += "<param name=\"ylabel0\" value=\"RPM\">\n"
459
460                         html += "</applet>\n"
461
462                         f.seek(0)
463                         line = f.readline()
464                         html += "<script language=javascript>\n"
465                         html += "dT = document.DiaTemp\n"
466                         html += "dR = document.DiaRPM\n"
467                         t = 0
468                         Xtime = int((Anzahl/20))
469                         if Anzahl < 1000:
470                                 Xtime += 1
471                         for line in f.readlines():
472                                 DT = line.split(";")
473                                 if DT[0] > Dfind:
474                                         if Xtime > 0:
475                                                 tmp = ("\"" + DT[0].split(" ")[1] + "\"") if t % Xtime == 0 else "null"
476                                         else:
477                                                 tmp = "null"
478                                         t += 1
479                                         if len(DT[6])>1:
480                                                 DT[6]="0"
481                                         B = 0
482                                         H = 0
483                                         R = 0
484                                         S = int(DT[6])
485                                         if (S & 1)>0 :
486                                                 B = 3
487                                         if (S & 2)>0 :
488                                                 H = 6
489                                         if (S & 4)>0 :
490                                                 R = 9
491                                         html += "dT.AddPoint(\"%s; %s; %d; %d; %d\", %s, null);\n" % (DT[1].replace(",","."),DT[5],B,H,R,tmp)
492                                         html += "dR.AddPoint(\"%s\", %s, null);\n" % (DT[2],tmp)
493                         f.close()
494                         html += "dT.repaint();\ndR.repaint();\n"
495                         html += "</script>"
496                 else:
497                         html = "<html>no Data!"
498                 html += "</body>"
499                 html += "</html>"
500
501                 return html
502
503 def BoxStatus():
504         h = ""
505         S = int(FC2werte[5])
506         if (S & 1)>0 :
507                 h += "<img border=\"0\" src=\"/fancontrol/FC2on.png\" width=\"20\" height=\"20\" title=\"Box On\" align=\"left\" hspace=\"2\" vspace=\"5\">\n"
508         if (S & 2)>0 :
509                 h += "<img border=\"0\" src=\"/fancontrol/FC2hdd.png\" width=\"20\" height=\"20\" title=\"HDD On\" align=\"left\" hspace=\"2\" vspace=\"5\">\n"
510         if (S & 4)>0 :
511                 h += "<img border=\"0\" src=\"/fancontrol/FC2record.png\" width=\"20\" height=\"20\" title=\"Recording\" align=\"left\" hspace=\"2\" vspace=\"5\">\n"
512         return h