source: titan/titan/httpdfunc.h @ 30689

Last change on this file since 30689 was 30689, checked in by ago123, 9 years ago

[webif] fix queryraw for getepg and getsingleepg

File size: 198.9 KB
Line 
1#ifndef HTTPDFUNC_H
2#define HTTPDFUNC_H
3
4time_t webcreatetimeline(char** buf, int* maxlen, int* pos)
5{
6        int i = 0;
7        struct tm *loctime = NULL;
8        int timeadd = 15 * 60;
9        char* buf1 = NULL;
10        time_t akttimeadd = 0;
11
12#ifdef SIMULATE
13        time_t akttime = 1307871000;
14        akttime = 1315614961;
15#else
16        time_t akttime = time(NULL);
17#endif
18
19        akttime -= (((akttime) % 100));
20        akttime -= (((akttime / 60) % 15) * 60);
21        akttimeadd = akttime;
22
23        buf1 = malloc(6);
24        if(buf1 == NULL)
25        {
26                err("no mem");
27                return akttime;
28        }
29
30        //not shown
31        ostrcatbig(buf, "<th class=gepgchannel1> </th><th style=\"width: 1px; max-width: 1px; min-width: 1px;\"></th>", maxlen, pos);
32        for(i = 0; i < 96; i++)
33        {
34                loctime = olocaltime(&akttimeadd);
35                if(loctime != NULL)
36                        strftime(buf1, 6, "%H:%M", loctime);
37                else
38                        snprintf(buf1, 6, "00:00");
39                free(loctime); loctime = NULL;
40
41                ostrcatbig(buf, "<th class=gepgtimelinecell><div class=gepgcellborder>", maxlen, pos);
42                ostrcatbig(buf, buf1, maxlen, pos);
43                ostrcatbig(buf, "</div></th>", maxlen, pos);
44
45                akttimeadd += timeadd;
46        }
47
48        free(buf1);
49        return akttime / 60;
50}
51
52void webcreatetailbig(char** buf, int* maxlen, int* pos, int flag)
53{
54        ostrcatbig(buf, "</table></font></center></body></html>", maxlen, pos);
55}
56
57
58char* webcreatetail(char* buf, int flag)
59{
60        buf = ostrcat(buf, "</table></font></center></body></html>", 1, 0);
61        return buf;
62}
63
64void webcreateheadbig(char** buf, int* maxlen, char* meta, int* pos, int flag)
65{
66        ostrcatbig(buf, "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"><link rel=stylesheet type=text/css href=titan.css>", maxlen, pos);
67        if(meta != NULL)
68                ostrcatbig(buf, meta, maxlen, pos);
69        ostrcatbig(buf, "</head><body class=body>", maxlen, pos);
70        if(flag == 0)
71                ostrcatbig(buf, "<center><table border=0 width=100%>", maxlen, pos);
72        else
73                ostrcatbig(buf, "<center><table border=0 width=100% height=100%>", maxlen, pos);
74}
75
76char* webcreatehead(char* buf, char* meta, int flag)
77{
78        buf = ostrcat(buf, "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"><link rel=stylesheet type=text/css href=titan.css>", 1, 0);
79        if(meta != NULL)
80                buf = ostrcat(buf, meta, 1, 0);
81        buf = ostrcat(buf, "</head><body class=body>", 1, 0);
82        if(flag == 0)
83                buf = ostrcat(buf, "<center><table border=0 width=100%>", 1, 0);
84        else
85                buf = ostrcat(buf, "<center><table border=0 width=100% height=100%>", 1, 0);
86        return buf;
87}
88
89void webcreatechannelbody(char** buf, int line, struct channel* chnode, char* channellist, int* maxlen, int* pos, int flag, int fmt)
90{
91        char* tmpstr = NULL, *buf1 = NULL, *serviceid = NULL, *transponderid = NULL;
92        struct epg* epgnode = getepgakt(chnode);
93        int ret = 0, proz = 0;
94        struct tm *loctime = NULL;
95        time_t max = 0, akt = 0;
96
97        if(chnode == NULL) return;
98        ret = channelnottunable(chnode);
99
100        buf1 = malloc(MINMALLOC);
101        if(buf1 == NULL)
102        {
103                err("no mem");
104                return;
105        }
106
107        if(fmt == 0)
108        {
109                if(line == 0)
110                        ostrcatbig(buf, "<tr class=line1>", maxlen, pos);
111                else
112                        ostrcatbig(buf, "<tr class=line2>", maxlen, pos);
113        }
114
115        if(epgnode != NULL)
116        {
117                proz = (time(NULL) - epgnode->starttime) * 100 / (epgnode->endtime - epgnode->starttime);
118                if(proz > 100) proz = 100;
119                if(proz < 0) proz = 0;
120        }
121
122        if(fmt == 0)
123        {
124                ostrcatbig(buf, "<td width=100% valign=middle nowrap class=link><div class=timelineborder><div class=timelinebar style=\"width: ", maxlen, pos);
125                tmpstr = oitoa(proz);
126                ostrcatbig(buf, tmpstr, maxlen, pos);
127                free(tmpstr); tmpstr = NULL;
128                ostrcatbig(buf, "%;\"> </div></div>", maxlen, pos);
129        }
130
131        serviceid = oitoa(chnode->serviceid);
132        transponderid = ollutoa(chnode->transponderid);
133
134        if(fmt == 0 && ret == 0)
135        {
136                ostrcatbig(buf, "<a target=aktservice class=link href=query?switch&", maxlen, pos);
137                ostrcatbig(buf, serviceid, maxlen, pos);
138                ostrcatbig(buf, "&", maxlen, pos);
139                ostrcatbig(buf, transponderid, maxlen, pos);
140                ostrcatbig(buf, "&", maxlen, pos);
141                ostrcatbig(buf, channellist, maxlen, pos);
142                ostrcatbig(buf, ">", maxlen, pos);
143        }
144
145        if(fmt == 0)
146        {
147                ostrcatbig(buf, chnode->name, maxlen, pos);
148                if(ret == 0)
149                        ostrcatbig(buf, "</a>", maxlen, pos);
150        }
151        else
152        {
153                *buf = ostrcat(*buf, chnode->name, 1, 0);
154                *buf = ostrcat(*buf, "#", 1, 0);
155                *buf = ostrcat(*buf, oitoa(proz), 1, 1);
156                *buf = ostrcat(*buf, "#", 1, 0);
157                *buf = ostrcat(*buf, serviceid, 1, 0);
158                *buf = ostrcat(*buf, "#", 1, 0);
159                *buf = ostrcat(*buf, transponderid, 1, 0);
160                *buf = ostrcat(*buf, "#", 1, 0);
161                *buf = ostrcat(*buf, channellist, 1, 0);
162                *buf = ostrcat(*buf, "#", 1, 0);
163                *buf = ostrcat(*buf, oitoa(chnode->servicetype), 1, 1);
164                *buf = ostrcat(*buf, "#", 1, 0);
165                if(epgnode != NULL)
166                {
167                        *buf = ostrcat(*buf, oitoa(epgnode->eventid), 1, 1);
168                        *buf = ostrcat(*buf, "#", 1, 0);
169                        *buf = ostrcat(*buf, olutoa(epgnode->starttime), 1, 1);
170                        *buf = ostrcat(*buf, "#", 1, 0);
171                        *buf = ostrcat(*buf, epgnode->title, 1, 0);
172                        *buf = ostrcat(*buf, "#", 1, 0);
173                        if(epgnode->next != NULL)
174                        {
175                                *buf = ostrcat(*buf, olutoa(epgnode->next->starttime), 1, 1);
176                                *buf = ostrcat(*buf, "#", 1, 0);
177                                *buf = ostrcat(*buf, olutoa(epgnode->next->endtime), 1, 1);
178                                *buf = ostrcat(*buf, "#", 1, 0);
179                                *buf = ostrcat(*buf, epgnode->next->title, 1, 0);
180                                *buf = ostrcat(*buf, "#", 1, 0);
181                                *buf = ostrcat(*buf, oitoa(epgnode->next->eventid), 1, 1);
182                        }
183                        else
184                        {
185                                *buf = ostrcat(*buf, olutoa(epgnode->endtime), 1, 1);
186                                *buf = ostrcat(*buf, "#", 1, 0);
187                                *buf = ostrcat(*buf, "#", 1, 0);
188                                *buf = ostrcat(*buf, "#", 1, 0);
189                                *buf = ostrcat(*buf, "0", 1, 0);
190                        }
191                }
192                else
193                {
194                        *buf = ostrcat(*buf, "0", 1, 0);
195                        *buf = ostrcat(*buf, "#", 1, 0);
196                        *buf = ostrcat(*buf, "#", 1, 0);
197                        *buf = ostrcat(*buf, "#", 1, 0);
198                        *buf = ostrcat(*buf, "#", 1, 0);
199                        *buf = ostrcat(*buf, "#", 1, 0);
200                        *buf = ostrcat(*buf, "#", 1, 0);
201                        *buf = ostrcat(*buf, "0", 1, 0);
202                }
203                *buf = ostrcat(*buf, "#", 1, 0);
204
205                if(ret == 1)
206                        *buf = ostrcat(*buf, "1", 1, 0);
207                else
208                        *buf = ostrcat(*buf, "0", 1, 0);
209
210                *buf = ostrcat(*buf, "\n", 1, 0);
211        }
212
213        //akt epg
214        if(fmt == 0 && epgnode != NULL)
215        {
216                if(flag == 0)
217                        ostrcatbig(buf, "<br><a target=main class=smalllink href=query?getepg&", maxlen, pos);
218                else
219                        ostrcatbig(buf, " <a target=main class=smalllink href=query?getepg&", maxlen, pos);
220
221                ostrcatbig(buf, serviceid, maxlen, pos);
222                ostrcatbig(buf, "&", maxlen, pos);
223                ostrcatbig(buf, transponderid, maxlen, pos);
224                ostrcatbig(buf, "&", maxlen, pos);
225                tmpstr = oitoa(epgnode->eventid);
226                ostrcatbig(buf, tmpstr, maxlen, pos);
227                free(tmpstr); tmpstr = NULL;
228                ostrcatbig(buf, ">", maxlen, pos);
229
230                loctime = olocaltime(&epgnode->starttime);
231                if(loctime != NULL)
232                        strftime(buf1, MINMALLOC, "%H:%M -", loctime);
233                free(loctime); loctime = NULL;
234                loctime = olocaltime(&epgnode->endtime);
235                if(loctime != NULL)
236                        strftime(&buf1[7], MINMALLOC - 8, " %H:%M ", loctime);
237                free(loctime); loctime = NULL;
238
239                ostrcatbig(buf, buf1, maxlen, pos);
240                ostrcatbig(buf, epgnode->title, maxlen, pos);
241
242                max = (epgnode->endtime - epgnode->starttime) / 60;
243                akt = (time(NULL) - epgnode->starttime) / 60;
244                if(max < 0) max = 0;
245                if(akt < 0) akt = 0;
246                snprintf(buf1, MINMALLOC, " (%ld from %ld min, %d%%)", akt, max, proz);
247                ostrcatbig(buf, buf1, maxlen, pos);
248
249                ostrcatbig(buf, "</a>", maxlen, pos);
250
251                //next epg
252                epgnode = epgnode->next;
253                if(flag == 0 && epgnode != NULL)
254                {
255                        ostrcatbig(buf, "<br><a target=main class=smalllink href=query?getepg&", maxlen, pos);
256                        ostrcatbig(buf, serviceid, maxlen, pos);
257                        ostrcatbig(buf, "&", maxlen, pos);
258                        ostrcatbig(buf, transponderid, maxlen, pos);
259                        ostrcatbig(buf, "&", maxlen, pos);
260                        tmpstr = oitoa(epgnode->eventid);
261                        ostrcatbig(buf, tmpstr, maxlen, pos);
262                        free(tmpstr); tmpstr = NULL;
263                        ostrcatbig(buf, ">", maxlen, pos);
264
265                        loctime = olocaltime(&epgnode->starttime);
266                        if(loctime != NULL)
267                                strftime(buf1, 8, "%H:%M -", loctime);
268                        free(loctime); loctime = NULL;
269                        loctime = olocaltime(&epgnode->endtime);
270                        if(loctime != NULL)
271                                strftime(&buf1[7], 8, " %H:%M ", loctime);
272                        free(loctime); loctime = NULL;
273
274                        ostrcatbig(buf, buf1, maxlen, pos);
275                        ostrcatbig(buf, epgnode->title, maxlen, pos);
276                        ostrcatbig(buf, "</a>", maxlen, pos);
277                }
278        }
279
280        //tv - radio
281        if(fmt == 0)
282        {
283                if(chnode->servicetype == 0)
284                        ostrcatbig(buf, "</td><td width=100 align=right valign=middle nowrap><img style=\"margin-left: 5\" border=0 src=img/tv.png alt=TV width=16 height=16>", maxlen, pos);
285                else
286                        ostrcatbig(buf, "</td><td width=100 align=right valign=middle nowrap><img style=\"margin-left: 5\" border=0 src=img/radio.png alt=Radio width=16 height=16>", maxlen, pos);
287
288                //single epg
289                ostrcatbig(buf, "<a target=main href=query?getsingleepg&", maxlen, pos);
290                ostrcatbig(buf, serviceid, maxlen, pos);
291                ostrcatbig(buf, "&", maxlen, pos);
292                ostrcatbig(buf, transponderid, maxlen, pos);
293                ostrcatbig(buf, "><img style=\"margin-left: 5\" border=0 src=img/singleepg.png alt=\"Single EPG\" width=16 height=16></a>", maxlen, pos);
294
295                //m3u stream + webstream
296                if(ret == 0)
297                {
298                        ostrcatbig(buf, "<a target=nothing href=query?getm3u&", maxlen, pos);
299                        ostrcatbig(buf, serviceid, maxlen, pos);
300                        ostrcatbig(buf, ",", maxlen, pos);
301                        ostrcatbig(buf, transponderid, maxlen, pos);
302                        ostrcatbig(buf, "><img style=\"margin-left: 5\" border=0 src=img/stream.png alt=Stream width=16 height=16></a>", maxlen, pos);
303
304                        ostrcatbig(buf, "<a target=_blank href=query?getvideo&", maxlen, pos);
305                        ostrcatbig(buf, serviceid, maxlen, pos);
306                        ostrcatbig(buf, ",", maxlen, pos);
307                        ostrcatbig(buf, transponderid, maxlen, pos);
308                        ostrcatbig(buf, "><img style=\"margin-left: 5\" border=0 src=img/webstream.png alt=WebStream width=16 height=16></a>", maxlen, pos);
309                }
310                else
311                        ostrcatbig(buf, "<img style=\"margin-left: 5\" border=0 src=img/cross.png alt=\"Channel not availabel\" width=16 height=16>", maxlen, pos);
312                ostrcatbig(buf, "</td></tr>", maxlen, pos);
313        }
314
315        free(buf1);
316        free(serviceid);
317        free(transponderid);
318}
319
320char* webgetbouquetchannel(char* param, int fmt)
321{
322        char* buf = NULL, *tmpstr = NULL, *tmpstr1 = NULL;
323        struct mainbouquet *mbouquet = NULL;
324        struct bouquet *node = NULL;
325        struct channel* chnode = NULL;
326        int line = 0, maxlen = 0, pos = 0;
327
328        if(param == NULL) return NULL;
329
330        if(fmt == 0) webcreateheadbig(&buf, &maxlen, "<meta http-equiv=refresh content=60>", &pos, 0);
331
332        mbouquet = getmainbouquet(param);
333        if(mbouquet != NULL)
334        {
335                node = mbouquet->bouquet;
336                tmpstr = ostrcat(tmpstr, "(BOUQUET)-", 1, 0);
337                tmpstr = ostrcat(tmpstr, mbouquet->name, 1, 0);
338                tmpstr1 = htmlencode(tmpstr);
339                free(tmpstr); tmpstr = NULL;
340                while(node != NULL)
341                {
342                        chnode = getchannel(node->serviceid, node->transponderid);
343                        if(chnode != NULL)
344                        {
345                                webcreatechannelbody(&buf, line, chnode, tmpstr1, &maxlen, &pos, 0, fmt);
346                                if(line == 0)
347                                        line = 1;
348                                else
349                                        line = 0;
350                        }
351                        node = node->next;
352                }
353                free(tmpstr1); tmpstr1 = NULL;
354        }
355        if(fmt == 0) webcreatetailbig(&buf, &maxlen, &pos, 0);
356
357        return buf;
358}
359
360//flag 0: all
361//flag 1: sat
362//flag 2: provider
363//flag 3: A-Z
364char* webgetchannel(int param, int flag, int page, int fmt)
365{
366        char* buf = NULL, *tmpnr = NULL, *tmpstr = NULL, *tmpstr1 = NULL;
367        struct channel* chnode = channel;
368        int line = 0, maxcount = 0, maxlen = 0, pos = 0;
369
370        if(fmt == 0) webcreateheadbig(&buf, &maxlen, "<meta http-equiv=refresh content=60>", &pos, 0);
371
372        if(flag == 0) tmpstr1 = ostrcat(tmpstr1, "(ALL)", 1, 0);
373        if(flag == 1)
374        {
375                struct sat* node = getsatbyorbitalpos(param);
376                if(node != NULL)
377                {
378                        tmpstr = ostrcat(tmpstr, "(SAT)-", 1, 0);
379                        tmpstr = ostrcat(tmpstr, node->name, 1, 0);
380                        tmpstr1 = htmlencode(tmpstr);
381                        free(tmpstr); tmpstr = NULL;
382                }
383        }
384        if(flag == 2)
385        {
386                struct provider* node = getprovider(param);
387                if(node != NULL)
388                {
389                        tmpstr = ostrcat(tmpstr, "(PROVIDER)-", 1, 0);
390                        tmpstr = ostrcat(tmpstr, node->name, 1, 0);
391                        tmpstr1 = htmlencode(tmpstr);
392                        free(tmpstr); tmpstr = NULL;
393                }
394        }
395        if(flag == 3)
396        {
397                tmpstr = malloc(2);
398                if(tmpstr != NULL)
399                        snprintf(tmpstr, 2, "%c", param);
400                tmpstr = ostrcat("(A-Z)-", tmpstr, 0, 1);
401                tmpstr1 = htmlencode(tmpstr);
402                free(tmpstr); tmpstr = NULL;
403        }
404
405        while(chnode != NULL)
406        {
407                if(chnode->transponder == NULL)
408                {
409                        chnode = chnode->next;
410                        continue;
411                }
412                if(chnode->name == NULL)
413                {
414                        chnode = chnode->next;
415                        continue;
416                }
417                if(flag == 1 && chnode->transponder->orbitalpos != param)
418                {
419                        chnode = chnode->next;
420                        continue;
421                }
422                if(flag == 2 && chnode->providerid != param)
423                {
424                        chnode = chnode->next;
425                        continue;
426                }
427                if(flag == 3 && chnode->name[0] != param && chnode->name[0] != param + 32)
428                {
429                        chnode = chnode->next;
430                        continue;
431                }
432
433                maxcount++;
434                if(maxcount <= (MAXHTMLLINE * page) - MAXHTMLLINE || maxcount > MAXHTMLLINE * page)
435                {
436                        chnode = chnode->next;
437                        continue;
438                }
439                webcreatechannelbody(&buf, line, chnode, tmpstr1, &maxlen, &pos, 0, fmt);
440
441                if(line == 0)
442                        line = 1;
443                else
444                        line = 0;
445
446                chnode = chnode->next;
447        }
448        free(tmpstr); tmpstr = NULL;
449
450        if(fmt == 0 && maxcount > MAXHTMLLINE)
451        {
452                int i;
453                ostrcatbig(&buf, "<tr><td align=center><br>", &maxlen, &pos);
454                for(i = 1; i <= (int)ceil(((float)maxcount / MAXHTMLLINE)); i++)
455                {
456                        if(page == i)
457                                ostrcatbig(&buf, "<a class=pagesellink href=query?getchannelpage&", &maxlen, &pos);
458                        else
459                                ostrcatbig(&buf, "<a class=pagelink href=query?getchannelpage&", &maxlen, &pos);
460                        tmpnr = oitoa(param);
461                        ostrcatbig(&buf, tmpnr, &maxlen, &pos);
462                        ostrcatbig(&buf, "&", &maxlen, &pos);
463                        free(tmpnr); tmpnr = NULL;
464                        tmpnr = oitoa(flag);
465                        ostrcatbig(&buf, tmpnr, &maxlen, &pos);
466                        ostrcatbig(&buf, "&", &maxlen, &pos);
467                        free(tmpnr); tmpnr = NULL;
468
469                        tmpnr = oitoa(i);
470                        ostrcatbig(&buf, tmpnr, &maxlen, &pos);
471                        ostrcatbig(&buf, ">", &maxlen, &pos);
472                        ostrcatbig(&buf, tmpnr, &maxlen, &pos);
473                        ostrcatbig(&buf, "</a>", &maxlen, &pos);
474                        free(tmpnr); tmpnr = NULL;
475                }
476                ostrcatbig(&buf, "</td></tr>", &maxlen, &pos);
477        }
478
479        if(fmt == 0) webcreatetailbig(&buf, &maxlen, &pos, 0);
480        return buf;
481}
482
483char* webgetprovider(int fmt)
484{
485        char* buf = NULL, *tmpstr = NULL;
486        struct provider* node = provider;
487        int line = 0, maxlen = 0, pos = 0;
488
489        if(fmt == 0) webcreateheadbig(&buf, &maxlen, NULL, &pos, 0);
490
491        while(node != NULL)
492        {
493                if(fmt == 0)
494                {
495                        if(line == 0)
496                        {
497                                ostrcatbig(&buf, "<tr class=line1><td nowrap><a class=link href=\"query?getproviderchannel&", &maxlen, &pos);
498                                tmpstr = oitoa(node->providerid);
499                                ostrcatbig(&buf, tmpstr, &maxlen, &pos);
500                                free(tmpstr); tmpstr = NULL;
501                                ostrcatbig(&buf, "\">", &maxlen, &pos);
502                                line = 1;
503                        }
504                        else
505                        {
506                                ostrcatbig(&buf, "<tr class=line2><td nowrap><a class=link href=\"query?getproviderchannel&", &maxlen, &pos);
507                                tmpstr = oitoa(node->providerid);
508                                ostrcatbig(&buf, tmpstr, &maxlen, &pos);
509                                free(tmpstr); tmpstr = NULL;
510                                ostrcatbig(&buf, "\">", &maxlen, &pos);
511                                line = 0;
512                        }
513                        ostrcatbig(&buf, node->name, &maxlen, &pos);
514                        ostrcatbig(&buf, "</td></tr>", &maxlen, &pos);
515                }
516                else
517                {
518                        buf = ostrcat(buf, node->name, 1, 0);
519                        buf = ostrcat(buf, "#", 1, 0);
520                        buf = ostrcat(buf, oitoa(node->providerid), 1, 1);
521                        buf = ostrcat(buf, "\n", 1, 0);
522                }
523
524                node = node->next;
525        }
526
527        if(fmt == 0) webcreatetailbig(&buf, &maxlen, &pos, 0);
528        return buf;
529}
530
531char* webgetsat(int fmt)
532{
533        char* buf = NULL, *tmpstr = NULL;
534        struct sat* node = sat;
535        int line = 0, maxlen = 0, pos = 0;
536
537        if(fmt == 0) webcreateheadbig(&buf, &maxlen, NULL, &pos, 0);
538
539        while(node != NULL)
540        {
541                if(fmt == 0)
542                {
543                        if(line == 0)
544                        {
545                                ostrcatbig(&buf, "<tr class=line1><td nowrap><a class=link href=\"query?getsatchannel&", &maxlen, &pos);
546                                tmpstr = oitoa(node->orbitalpos);
547                                ostrcatbig(&buf, tmpstr, &maxlen, &pos);
548                                free(tmpstr); tmpstr = NULL;
549                                ostrcatbig(&buf, "\">", &maxlen, &pos);
550                                line = 1;
551                        }
552                        else
553                        {
554                                ostrcatbig(&buf, "<tr class=line2><td nowrap><a class=link href=\"query?getsatchannel&", &maxlen, &pos);
555                                tmpstr = oitoa(node->orbitalpos);
556                                ostrcatbig(&buf, tmpstr, &maxlen, &pos);
557                                free(tmpstr); tmpstr = NULL;
558                                ostrcatbig(&buf, "\">", &maxlen, &pos);
559                                line = 0;
560                        }
561                        ostrcatbig(&buf, node->name, &maxlen, &pos);
562                        ostrcatbig(&buf, "</td></tr>", &maxlen, &pos);
563                }
564                else
565                {
566                        buf = ostrcat(buf, node->name, 1, 0);
567                        buf = ostrcat(buf, "#", 1, 0);
568                        buf = ostrcat(buf, oitoa(node->orbitalpos), 1, 1);
569                        buf = ostrcat(buf, "\n", 1, 0);
570                }
571
572                node = node->next;
573        }
574
575        if(fmt == 0) webcreatetailbig(&buf, &maxlen, &pos, 0);
576        return buf;
577}
578
579char* webgetaz(int fmt)
580{
581        char* buf = NULL, *tmpstr = NULL, *tmpnr = NULL;
582        int line = 0, maxlen = 0, pos = 0, i;
583
584        tmpstr = malloc(2);
585        if(tmpstr == NULL)
586        {
587                err("no memory");
588                return NULL;
589        }
590
591        if(fmt == 0) webcreateheadbig(&buf, &maxlen, NULL, &pos, 0);
592
593        for(i = 65; i < 91; i++)
594        {
595                if(fmt == 0)
596                {
597                        if(line == 0)
598                        {
599                                ostrcatbig(&buf, "<tr class=line1><td nowrap><a class=link href=\"query?getazchannel&", &maxlen, &pos);
600                                tmpnr = oitoa(i);
601                                ostrcatbig(&buf, tmpnr, &maxlen, &pos);
602                                free(tmpnr); tmpnr = NULL;
603                                ostrcatbig(&buf, "\">", &maxlen, &pos);
604                                line = 1;
605                        }
606                        else
607                        {
608                                ostrcatbig(&buf, "<tr class=line2><td nowrap><a class=link href=\"query?getazchannel&", &maxlen, &pos);
609                                tmpnr = oitoa(i);
610                                ostrcatbig(&buf, tmpnr, &maxlen, &pos);
611                                free(tmpnr); tmpnr = NULL;
612                                ostrcatbig(&buf, "\">", &maxlen, &pos);
613                                line = 0;
614                        }
615                        snprintf(tmpstr, 2, "%c", i);
616                        ostrcatbig(&buf, tmpstr, &maxlen, &pos);
617                        ostrcatbig(&buf, "</td></tr>", &maxlen, &pos);
618                }
619                else
620                {
621                        snprintf(tmpstr, 2, "%c", i);
622                        buf = ostrcat(buf, tmpstr, 1, 0);
623                        buf = ostrcat(buf, "\n", 1, 0);
624                }
625        }
626
627        if(fmt == 0) webcreatetailbig(&buf, &maxlen, &pos, 0);
628        free(tmpstr);
629        return buf;
630}
631
632char* webgetbouquet(int fmt)
633{
634        char* buf = NULL;
635        struct mainbouquet* node = mainbouquet;
636        int line = 0, maxlen = 0, pos = 0;
637
638        if(fmt == 0) webcreateheadbig(&buf, &maxlen, NULL, &pos, 0);
639
640        while(node != NULL)
641        {
642                if(fmt == 0)
643                {
644                        if(line == 0)
645                        {
646                                ostrcatbig(&buf, "<tr class=line1><td width=100% nowrap><a class=link href=\"query?getbouquetchannel&", &maxlen, &pos);
647                                ostrcatbig(&buf, node->name, &maxlen, &pos);
648                                ostrcatbig(&buf, "\">", &maxlen, &pos);
649                                line = 1;
650                        }
651                        else
652                        {
653                                ostrcatbig(&buf, "<tr class=line2><td width=100% nowrap><a class=link href=\"query?getbouquetchannel&", &maxlen, &pos);
654                                ostrcatbig(&buf, node->name, &maxlen, &pos);
655                                ostrcatbig(&buf, "\">", &maxlen, &pos);
656                                line = 0;
657                        }
658                        ostrcatbig(&buf, node->name, &maxlen, &pos);
659                        ostrcatbig(&buf, "</a></td>", &maxlen, &pos);
660
661                        ostrcatbig(&buf, "<td width=50 nowrap align=right valign=middle><img style=\"margin-left: 5\" border=0 src=", &maxlen, &pos);
662
663                        if(node->type == 0)
664                                ostrcatbig(&buf, "img/tv.png width=16 height=16 alt=TV>", &maxlen, &pos);
665                        else
666                                ostrcatbig(&buf, "img/radio.png width=16 height=16 alt=Radio>", &maxlen, &pos);
667                        ostrcatbig(&buf, "<a href=\"query?getgmultiepg&", &maxlen, &pos);
668                        ostrcatbig(&buf, node->name, &maxlen, &pos);
669                        ostrcatbig(&buf, "\">", &maxlen, &pos);
670                        ostrcatbig(&buf, "<img style=\"margin-left: 5\" border=0 width=16 height=16 alt=\"Graphical Multi EPG\" src=img/gmultiepg.png></a>", &maxlen, &pos);
671                        ostrcatbig(&buf, "</td></tr>", &maxlen, &pos);
672                }
673                else
674                {
675                        buf = ostrcat(buf, node->name, 1, 0);
676                        buf = ostrcat(buf, "#", 1, 0);
677                        buf = ostrcat(buf, oitoa(node->type), 1, 1);
678                        buf = ostrcat(buf, "\n", 1, 0);
679                }
680
681                node = node->next;
682        }
683
684        if(fmt == 0) webcreatetailbig(&buf, &maxlen, &pos, 0);
685        return buf;
686}
687
688char* websetmute(char* param, int fmt)
689{
690        char* buf = NULL;
691        int mute = status.mute;
692
693        if(param != NULL)
694                mute = atoi(param);
695
696        if(fmt == 0)
697        {
698                buf = ostrcat(buf, "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"><link rel=stylesheet type=text/css href=titan.css></head><body class=body><center>", 1, 0);
699                if(mute == 0)
700                        buf = ostrcat(buf, "<a href=query?setmute&1><img src=img/speak_on.png border=0 alt=\"Mute on\"></img></a>", 1, 0);
701                else
702                        buf = ostrcat(buf, "<a href=query?setmute&0><img src=img/speak_off.png border=0 alt=\"Mute off\"></img></a>", 1, 0);
703                buf = ostrcat(buf, "</center></body></html>", 1, 0);
704        }
705        else
706        {
707                if(mute == 0)
708                        buf = ostrcat(buf, "0", 1, 0);
709                else
710                        buf = ostrcat(buf, "1", 1, 0);
711        }
712
713        if(mute != status.mute)
714                screenmute(NULL, NULL, 0);
715       
716        return buf;
717}
718
719char* websetvol(char* param, int fmt)
720{
721        char* buf = NULL;
722        int vol = 30;
723
724        if(param == NULL)
725                vol = getvol();
726        else
727                vol = atoi(param);
728
729        if(fmt == 0)
730        {
731                buf = ostrcat(buf, "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"><link rel=stylesheet type=text/css href=titan.css></head><body class=body><center>", 1, 0);
732                if(vol >=10)
733                        buf = ostrcat(buf, "<a href=query?setvol&10><img src=img/led_on.png border=0></img></a> ", 1, 0);
734                else
735                        buf = ostrcat(buf, "<a href=query?setvol&10><img src=img/led_off.png border=0></img></a> ", 1, 0);
736                if(vol >=20)
737                        buf = ostrcat(buf, "<a href=query?setvol&20><img src=img/led_on.png border=0></img></a> ", 1, 0);
738                else
739                        buf = ostrcat(buf, "<a href=query?setvol&20><img src=img/led_off.png border=0></img></a> ", 1, 0);
740                if(vol >=30)
741                        buf = ostrcat(buf, "<a href=query?setvol&30><img src=img/led_on.png border=0></img></a> ", 1, 0);
742                else
743                        buf = ostrcat(buf, "<a href=query?setvol&30><img src=img/led_off.png border=0></img></a> ", 1, 0);
744                if(vol >=40)
745                        buf = ostrcat(buf, "<a href=query?setvol&40><img src=img/led_on.png border=0></img></a> ", 1, 0);
746                else
747                        buf = ostrcat(buf, "<a href=query?setvol&40><img src=img/led_off.png border=0></img></a> ", 1, 0);
748                if(vol >=50)
749                        buf = ostrcat(buf, "<a href=query?setvol&50><img src=img/led_on.png border=0></img></a> ", 1, 0);
750                else
751                        buf = ostrcat(buf, "<a href=query?setvol&50><img src=img/led_off.png border=0></img></a> ", 1, 0);
752                if(vol >=60)
753                        buf = ostrcat(buf, "<a href=query?setvol&60><img src=img/led_on.png border=0></img></a> ", 1, 0);
754                else
755                        buf = ostrcat(buf, "<a href=query?setvol&60><img src=img/led_off.png border=0></img></a> ", 1, 0);
756                if(vol >=70)
757                        buf = ostrcat(buf, "<a href=query?setvol&70><img src=img/led_on.png border=0></img></a> ", 1, 0);
758                else
759                        buf = ostrcat(buf, "<a href=query?setvol&70><img src=img/led_off.png border=0></img></a> ", 1, 0);
760                if(vol >=80)
761                        buf = ostrcat(buf, "<a href=query?setvol&80><img src=img/led_on.png border=0></img></a> ", 1, 0);
762                else
763                        buf = ostrcat(buf, "<a href=query?setvol&80><img src=img/led_off.png border=0></img></a> ", 1, 0);
764                if(vol >=90)
765                        buf = ostrcat(buf, "<a href=query?setvol&90><img src=img/led_on.png border=0></img></a> ", 1, 0);
766                else
767                        buf = ostrcat(buf, "<a href=query?setvol&90><img src=img/led_off.png border=0></img></a> ", 1, 0);
768                if(vol >=100)
769                        buf = ostrcat(buf, "<a href=query?setvol&100><img src=img/led_on.png border=0></img></a> ", 1, 0);
770                else
771                        buf = ostrcat(buf, "<a href=query?setvol&100><img src=img/led_off.png border=0></img></a> ", 1, 0);
772                buf = ostrcat(buf, "</center></body></html>", 1, 0);
773        }
774        else
775                buf = ostrcat(buf, oitoa(vol), 1, 1);
776
777        if(param != NULL)
778        {
779                setvol(vol);
780                if(status.mute == 1)
781                        screenmute(NULL, NULL, 0);
782        }
783        return buf;
784}
785
786char* webgetaktservice(int fmt)
787{
788        char* buf = NULL;
789        struct channel* chnode = status.aktservice->channel;
790        int line = 0, maxlen = 0, pos = 0;
791
792        if(fmt == 0) webcreateheadbig(&buf, &maxlen, NULL, &pos, 1);
793        webcreatechannelbody(&buf, line, chnode, getconfig("channellist", NULL), &maxlen, &pos ,1, fmt);
794        if(fmt == 0) webcreatetailbig(&buf, &maxlen, &pos, 1);
795
796        return buf;
797}
798
799char* webgetservice(char* param, int fmt)
800{
801        char* buf = NULL, *param1 = NULL;
802        struct channel* chnode = NULL;
803        int line = 0, maxlen = 0, pos = 0;
804
805        if(param == NULL) return NULL;
806
807        //create param1
808        param1 = strchr(param, '&');
809        if(param1 != NULL)
810                *param1++ = '\0';
811
812        if(param1 == NULL) return NULL;
813
814        chnode = getchannel(atoi(param), strtoull(param1, NULL, 10));
815
816        if(fmt == 0) webcreateheadbig(&buf, &maxlen, NULL, &pos, 1);
817        webcreatechannelbody(&buf, line, chnode, getconfig("channellist", NULL), &maxlen, &pos ,1, fmt);
818        if(fmt == 0) webcreatetailbig(&buf, &maxlen, &pos, 1);
819
820        return buf;
821}
822
823char* webswitch(char* param, int fmt)
824{
825        if(status.channelswitch == 1) goto end;
826
827        int ret = 0;
828        char* param1 = NULL, *param2 = NULL;
829        struct channel* chnode = NULL;
830
831        if(param == NULL) goto end;
832
833        //create param1
834        param1 = strchr(param, '&');
835        if(param1 != NULL)
836        {
837                *param1++ = '\0';
838                param2 = strchr(param1, '&');
839                if(param2 != NULL)
840                        *param2++ = '\0';
841        }
842
843        if(param1 == NULL && param2 == NULL) goto end;
844
845        chnode = getchannel(atoi(param), strtoull(param1, NULL, 10));
846        if(chnode != NULL)
847        {
848                ret = channelnottunable(chnode);
849                if(ret == 0)
850                        ret = servicestart(chnode, param2, NULL, 0);
851        }
852
853end:
854        return webgetaktservice(fmt);
855}
856
857char* webgetm3u(char* param, int connfd, int fmt)
858{
859        int extip = 1;
860        char* buf = NULL, *ip = NULL, *tmpbuf = NULL;
861        struct sockaddr_in sin;
862        socklen_t len = sizeof(sin);
863
864        if(param == NULL) return NULL;
865
866        if(getconfigint("webifip", NULL) == 1)
867                ip = getispip();
868
869        if(ip == NULL)
870        {
871                if(getsockname(connfd, &sin, &len) < 0)
872                {
873                        perr("getsockname");
874                        return NULL;
875                }
876
877                extip = 0;
878                ip = inet_ntoa(sin.sin_addr);
879                        if(ip == NULL) return NULL;
880        }
881
882        buf = ostrcat(buf, "#EXTM3U\n", 1, 0);
883        buf = ostrcat(buf, "#EXTVLCOPT--http-reconnect=true\n", 1, 0);
884        buf = ostrcat(buf, "http://", 1, 0);
885        buf = ostrcat(buf, ip, 1, 0);
886        buf = ostrcat(buf, ":", 1, 0);
887        buf = ostrcat(buf, getconfig("streamport", NULL), 1, 0);
888        buf = ostrcat(buf, "/", 1, 0);
889
890        tmpbuf = htmlencode(param);
891        if(tmpbuf != NULL)
892                param = tmpbuf;
893
894        buf = ostrcat(buf, param, 1, 0);
895        free(tmpbuf); tmpbuf = NULL;
896
897        if(extip == 1) free(ip);
898        return buf;
899}
900
901char* webgetvideo(char* param, int connfd, int fmt)
902{
903        int extip = 1;
904        char* buf = NULL, *ip = NULL, *tmpbuf = NULL;
905        struct sockaddr_in sin;
906        socklen_t len = sizeof(sin);
907
908        if(param == NULL) return NULL;
909
910        if(getconfigint("webifip", NULL) == 1)
911                ip = getispip();
912
913        if(ip == NULL)
914        {
915                if(getsockname(connfd, &sin, &len) < 0)
916                {
917                        perr("getsockname");
918                        return NULL;
919                }
920
921                extip = 0;
922                ip = inet_ntoa(sin.sin_addr);
923                if(ip == NULL) return NULL;
924        }
925
926        if(fmt == 0)
927        {
928                buf = ostrcat(buf, "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"><link rel=stylesheet type=text/css href=titan.css></head><body class=body><table border=0 width=100% height=100%><tr><td align=center valign=middle>", 1, 0);
929                buf = ostrcat(buf, "<embed width=100% height=100% type=application/x-vlc-plugin name=video autoplay=yes target=\"http://", 1, 0);
930        }
931        else
932                buf = ostrcat(buf, "http://", 1, 0);
933
934        buf = ostrcat(buf, ip, 1, 0);
935        buf = ostrcat(buf, ":", 1, 0);
936        buf = ostrcat(buf, getconfig("streamport", NULL), 1, 0);
937        buf = ostrcat(buf, "/", 1, 0);
938
939        tmpbuf = htmlencode(param);
940        if(tmpbuf != NULL)
941                param = tmpbuf;
942
943        buf = ostrcat(buf, param, 1, 0);
944        free(tmpbuf); tmpbuf = NULL;
945
946        if(fmt == 0)
947        {
948                buf = ostrcat(buf, "\" />", 1, 0);
949                //buf = ostrcat(buf, "<a href=javascript:; onclick='document.video.play()'>Play</a>", 1, 0);
950                //buf = ostrcat(buf, "<a href=javascript:; onclick='document.video.stop()'>Stop</a>", 1, 0);
951                //buf = ostrcat(buf, "<a href=javascript:; onclick='document.video.fullscreen()'>Fullscreen</a>", 1, 0);
952                buf = ostrcat(buf, "</td></tr></body></html>", 1, 0);
953        }
954
955        if(extip == 1) free(ip);
956        return buf;
957}
958
959char* webvideo(char* param, int fmt)
960{
961        char* buf = NULL, *param1 = NULL, *tmpbuf = NULL;
962
963        if(param == NULL) return NULL;
964
965        if(ostrcmp("status", param) == 0) // status is only available for queryraw
966        {
967                char buf[30];
968                int active = (status.webplayfile != NULL ? 1 : 0);
969                int st = 0; // status, 0: paused, 1: playing
970                unsigned long pos = 0; // current position
971                unsigned long len = 0; // stream length
972               
973                if(status.play == 1)
974                        st = 1;
975               
976                if(active == 1)
977                {
978                        pos = playergetpts() / 90000;
979                        len = playergetlength();
980                }
981               
982                snprintf(buf, 30, "%d#%d#%lu#%lu", active, st, pos, len);
983               
984                return ostrcat(buf, NULL, 0, 0);
985        }
986
987        //create param1
988        param1 = strchr(param, '&');
989        if(param1 != NULL)
990                *param1++ = '\0';
991
992        if(param1 == NULL) return NULL;
993
994        htmldecode(param1, param1);
995        if(param1 != NULL)
996        {
997                if(status.play == 0 && status.webplayfile == NULL)
998                {
999                        if(ostrstr(param1, "url=") == param1)
1000                                status.webplayfile = ostrcat(param1 + 4, NULL, 0, 0);
1001                        else if(ostrstr(param1, "hosterurl=") == param1)
1002                        {
1003                                status.webplayfile = ostrcat(param1 + 10, NULL, 0, 0);
1004
1005                                // stream over tithek enable start
1006                                printf("status.webplayfile: %s\n",status.webplayfile);
1007                                struct skin* tithekplugin = getplugin("TiTan Mediathek");
1008                                if(tithekplugin != NULL)
1009                                {
1010                                        struct tithek* (*startplugin)(char*);
1011               
1012                                        startplugin = dlsym(tithekplugin->pluginhandle, "hoster");
1013                                        if(startplugin != NULL)
1014                                        {
1015                                                status.webplayfile = (char*)startplugin(status.webplayfile);
1016                                                printf("status.webplayfile changed: %s\n",status.webplayfile);
1017                                        }
1018                                }
1019                                // stream over tithek enable end
1020                        }
1021                        else
1022                                status.webplayfile = ostrcat(param1, NULL, 0, 0);
1023                }
1024        }
1025        tmpbuf = ostrcat("not in play mode", NULL, 0, 0);
1026   
1027        int count = 0;
1028        if(status.timeshift == 0 && status.play == 0 && (ostrcmp("play", param) == 0 || ostrcmp("play=", param) == 0))
1029        {
1030                int count = 0;
1031
1032                int rcret = getrcconfigint("rcwebplay", NULL);
1033                if(rcret == 0) rcret = getrcconfigint("rcarchive", NULL);
1034                if(rcret == 0) rcret = getrcconfigint("rcplay", NULL);
1035                writerc(rcret);
1036                while(status.play == 0 && count < 30)
1037                {
1038                        usleep(100000);
1039                        count++;
1040                }
1041        }
1042        else
1043                count = 31;
1044
1045        if(count >= 30 && status.play == 0)
1046        {
1047                free(status.webplayfile); status.webplayfile = NULL;
1048                free(tmpbuf); tmpbuf = NULL;
1049                tmpbuf = ostrcat("can not start playback", NULL, 0, 0);
1050        }
1051
1052        if(status.timeshift == 0 && status.play == 1)
1053        {
1054                if(ostrcmp("stop", param) == 0 || ostrcmp("stop=", param) == 0)
1055                        writerc(getrcconfigint("rcstop", NULL));
1056
1057                if(ostrcmp("pause", param) == 0 || ostrcmp("pause=", param) == 0)
1058                        writerc(getrcconfigint("rcpause", NULL));
1059   
1060                if(ostrcmp("ff", param) == 0 || ostrcmp("ff=", param) == 0)
1061                        writerc(getrcconfigint("rcff", NULL));
1062   
1063                if(ostrcmp("fr", param) == 0 || ostrcmp("fr=", param) == 0)
1064                        writerc(getrcconfigint("rcfr", NULL));
1065
1066                free(tmpbuf); tmpbuf = NULL;
1067                tmpbuf = ostrcat(param, NULL, 0, 0);
1068
1069                if(ostrcmp("getlen", param) == 0 || ostrcmp("getlen=", param) == 0)
1070                {
1071                        unsigned long len = 0;
1072                        free(tmpbuf); tmpbuf = NULL;
1073   
1074                        len = playergetlength();
1075                        tmpbuf = ostrcat(buf, olutoa(len), 1, 1);
1076                }
1077 
1078                if(ostrcmp("getpos", param) == 0 || ostrcmp("getpos=", param) == 0)
1079                {
1080                        unsigned long pos = 0;
1081                        free(tmpbuf); tmpbuf = NULL;
1082   
1083                        pos = playergetpts() / 90000;
1084                        tmpbuf = ostrcat(buf, olutoa(pos), 1, 1);
1085                }
1086 
1087                if(ostrcmp("getisplaying", param) == 0 || ostrcmp("getisplaying=", param) == 0)
1088                {
1089                        int playing = 0;
1090                        free(tmpbuf); tmpbuf = NULL;
1091   
1092                        playing = playerisplaying();
1093                        tmpbuf = ostrcat(buf, oitoa(playing), 1, 1);
1094                }
1095 
1096                if(ostrcmp("getplayercan", param) == 0 || ostrcmp("getplayercan=", param) == 0)
1097                {
1098                        free(tmpbuf); tmpbuf = NULL;
1099                        tmpbuf = ostrcat(buf, olutoa(status.playercan), 1, 1);
1100                }
1101        }
1102
1103        if(fmt == 0)
1104        {
1105                buf = webcreatehead(buf, NULL, 1);
1106                buf = ostrcat(buf, "<tr><td align=center valign=top><font class=biglabel><br><br>Video ", 1, 0);
1107                buf = ostrcat(buf, tmpbuf, 1, 1);
1108                buf = ostrcat(buf, " !!!</font></td></tr>", 1, 0);
1109                buf = webcreatetail(buf, 1);
1110        }
1111        else
1112                buf = ostrcat(buf, tmpbuf, 1, 1);
1113 
1114        return buf;
1115}
1116
1117char* webgetchannelpage(char* param, int fmt)
1118{
1119        char* param1 = NULL, *param2 = NULL;
1120
1121        if(param == NULL) return NULL;
1122
1123        //create param1 + 2
1124        param1 = strchr(param, '&');
1125        if(param1 != NULL)
1126        {
1127                *param1++ = '\0';
1128                param2 = strchr(param1, '&');
1129                if(param2 != NULL)
1130                        *param2++ = '\0';
1131        }
1132
1133        if(param1 == NULL || param2 == NULL) return NULL;
1134
1135        return webgetchannel(atoi(param), atoi(param1), atoi(param2), fmt);
1136}
1137
1138void webmessage(struct stimerthread* timernode, char* text, int flag)
1139{
1140        textbox(_("Message"), text, _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 200, 0, 0);
1141        free(text);
1142}
1143
1144char* websendmessage(char* param, int fmt)
1145{
1146        char* text = NULL, *buf = NULL;
1147
1148        if(param == NULL) return NULL;
1149        param = strchr(param, '=');
1150        if(param != NULL)
1151        {
1152                param++;
1153                stringreplacechar(param, '+', ' ');
1154                text = ostrcat(text, param, 1, 0);
1155        }
1156        addtimer(&webmessage, START, 1000, 1, (void*)text, NULL, NULL);
1157
1158        if(fmt == 0)
1159        {
1160                buf = webcreatehead(buf, NULL, 1);
1161                buf = ostrcat(buf, "<tr><td align=center valign=top><font class=biglabel><br><br>Message Send !!!</font></td></tr>", 1, 0);
1162                buf = webcreatetail(buf, 1);
1163        }
1164        else
1165                buf = ostrcat(buf, "Message Send", 1, 0);
1166               
1167        return buf;
1168}
1169
1170char* webgetsignal(int fmt)
1171{
1172        char* buf = NULL, *tmpnr = NULL;
1173        uint16_t snr = 0, signal = 0;
1174        uint32_t ber = 0, unc = 0;
1175
1176        ber = fereadber(status.aktservice->fedev);
1177        unc = fereaduncorrectedblocks(status.aktservice->fedev);
1178        signal = fereadsignalstrength(status.aktservice->fedev);
1179        snr = fereadsnr(status.aktservice->fedev);
1180        snr = (snr * 100) / 0xffff;
1181
1182        if(fmt == 0)
1183        {
1184                buf = webcreatehead(buf, "<meta http-equiv=refresh content=1>", 0);
1185
1186                buf = ostrcat(buf, "<tr><td align=center><font class=biglabel><br><br>BER: ", 1, 0);
1187                tmpnr = oitoa(ber);
1188                buf = ostrcat(buf, tmpnr, 1, 0);
1189                free(tmpnr); tmpnr = NULL;
1190
1191                buf = ostrcat(buf, "<br>UNC: ", 1, 0);
1192                tmpnr = oitoa(unc);
1193                buf = ostrcat(buf, tmpnr, 1, 0);
1194                free(tmpnr); tmpnr = NULL;
1195
1196                buf = ostrcat(buf, "<br>SIG: ", 1, 0);
1197                tmpnr = oitoa(signal);
1198                buf = ostrcat(buf, tmpnr, 1, 0);
1199                free(tmpnr); tmpnr = NULL;
1200
1201                buf = ostrcat(buf, "<br>SNR: ", 1, 0);
1202                tmpnr = oitoa(snr);
1203                buf = ostrcat(buf, tmpnr, 1, 0);
1204                free(tmpnr); tmpnr = NULL;
1205
1206                buf = ostrcat(buf, "</font></td></tr>", 1, 0);
1207                buf = webcreatetail(buf, 0);
1208        }
1209        else
1210        {
1211                buf = ostrcat(buf, oitoa(ber), 1, 1);
1212                buf = ostrcat(buf, "#", 1, 0);
1213                buf = ostrcat(buf, oitoa(unc), 1, 1);
1214                buf = ostrcat(buf, "#", 1, 0);
1215                buf = ostrcat(buf, oitoa(signal), 1, 1);
1216                buf = ostrcat(buf, "#", 1, 0);
1217                buf = ostrcat(buf, oitoa(snr), 1, 1);
1218        }
1219
1220        return buf;
1221}
1222
1223char* webgetepg(char* param, int fmt)
1224{
1225        char* buf = NULL, *buf1 = NULL, *tmpstr = NULL, *param1 = NULL, *param2 = NULL;
1226        struct epg* epgnode = NULL;
1227        struct channel* chnode = NULL;
1228        struct tm *loctime = NULL;
1229
1230        if(param == NULL) return NULL;
1231
1232        //create param1 + 2
1233        param1 = strchr(param, '&');
1234        if(param1 != NULL)
1235        {
1236                *param1++ = '\0';
1237                param2 = strchr(param1, '&');
1238                if(param2 != NULL)
1239                        *param2++ = '\0';
1240        }
1241
1242        if(param1 == NULL || param2 == NULL) return NULL;
1243
1244        chnode = getchannel(atoi(param), strtoull(param1, NULL, 10));
1245        if(chnode == NULL) return NULL;
1246
1247        epgnode = getepg(chnode, atoi(param2), 0);
1248        if(epgnode == NULL) return NULL;
1249
1250        if(fmt == 0) buf = webcreatehead(buf, NULL, 0);
1251
1252        buf1 = malloc(MINMALLOC);
1253        if(buf1 == NULL)
1254        {
1255                err("no mem");
1256                return buf;
1257        }
1258
1259        if(fmt == 0)
1260        {
1261                buf = ostrcat(buf, "<tr class=channelname><td><h4 style=\"margin:2px 0px\">", 1, 0);
1262                buf = ostrcat(buf, chnode->name, 1, 0);
1263                buf = ostrcat(buf, "</h4></td></tr>", 1, 0);
1264        }
1265
1266        if(fmt == 0) buf = ostrcat(buf, "<tr><td><font class=biglabel>", 1, 0);
1267        if(epgnode->title != NULL)
1268        {
1269                buf = ostrcat(buf, epgnode->title, 1, 0);
1270                if(fmt == 0)
1271                {
1272                        buf = ostrcat(buf, " (", 1, 0);
1273                        loctime = olocaltime(&epgnode->starttime);
1274                        if(loctime != NULL)
1275                                strftime(buf1, MINMALLOC, "%H:%M -", loctime);
1276                        free(loctime); loctime = NULL;
1277                        loctime = olocaltime(&epgnode->endtime);
1278                        if(loctime != NULL)
1279                                strftime(&buf1[7], MINMALLOC - 8, " %H:%M", loctime);
1280                        free(loctime); loctime = NULL;
1281                        buf = ostrcat(buf, buf1, 1, 0);
1282                        buf = ostrcat(buf, ")", 1, 0);
1283                }
1284        }
1285        if(fmt == 0)
1286        {
1287                buf = ostrcat(buf, "<br><br></font></td></tr>", 1, 0);
1288                buf = ostrcat(buf, "<tr><td><font class=label>", 1, 0);
1289        }
1290        else
1291        {
1292                buf = ostrcat(buf, "#", 1, 0);
1293                buf = ostrcat(buf, olutoa(epgnode->starttime), 1, 1);
1294                buf = ostrcat(buf, "#", 1, 0);
1295                buf = ostrcat(buf, olutoa(epgnode->endtime), 1, 1);
1296                buf = ostrcat(buf, "#", 1, 0);
1297        }
1298
1299        if(epgnode->subtitle != NULL)
1300                buf = ostrcat(buf, epgnode->subtitle, 1, 0);
1301
1302        if(fmt == 0)
1303        {
1304                buf = ostrcat(buf, "<br><br></font></td></tr>", 1, 0);
1305                buf = ostrcat(buf, "<tr><td><font class=label>", 1, 0);
1306        }
1307        else
1308                buf = ostrcat(buf, "#", 1, 0);
1309
1310        tmpstr = epgdescunzip(epgnode);
1311        if(tmpstr != NULL)
1312                buf = ostrcat(buf, tmpstr, 1, 0);
1313        free(tmpstr); tmpstr = NULL;
1314
1315        if(fmt == 0)
1316        {
1317                buf = ostrcat(buf, "</font></td></tr>", 1, 0);
1318                buf = webcreatetail(buf, 0);
1319        }
1320
1321        free(buf1);
1322        return buf;
1323}
1324
1325char* webgetsingleepg(char* param, int fmt)
1326{
1327        int line = 0, maxlen = 0, pos = 0, longdesc = 1;
1328        char* buf = NULL, *buf1 = NULL, *buf2 = NULL, *param1 = NULL, *param2 = NULL, *tmpstr = NULL;
1329        struct epg* epgnode = NULL;
1330        struct channel* chnode = NULL;
1331        struct tm *loctime = NULL;
1332       
1333        if(param == NULL) return NULL;
1334
1335        //create param1 + 2
1336        param1 = strchr(param, '&');
1337        if(param1 != NULL)
1338        {
1339                *param1++ = '\0';
1340                param2 = strchr(param1, '&');
1341                if(param2 != NULL)
1342                        *param2++ = '\0';
1343        }
1344
1345        if(param1 == NULL) return NULL;
1346        if(param2 != NULL) longdesc = atoi(param2);
1347
1348        chnode = getchannel(atoi(param), strtoull(param1, NULL, 10));
1349        if(chnode == NULL) return NULL;
1350        epgnode = getepgakt(chnode);;
1351
1352        if(fmt == 0) webcreateheadbig(&buf, &maxlen, NULL, &pos, 0);
1353
1354        buf1 = malloc(MINMALLOC);
1355        if(buf1 == NULL)
1356        {
1357                err("no mem");
1358                return buf;
1359        }
1360
1361        if(fmt == 0)
1362        {
1363                ostrcatbig(&buf, "<tr class=channelname><td colspan=4><h4 style=\"margin:2px 0px\">", &maxlen, &pos);
1364                ostrcatbig(&buf, chnode->name, &maxlen, &pos);
1365                ostrcatbig(&buf, "</h4></td></tr>", &maxlen, &pos);
1366                ostrcatbig(&buf, "<tr class=tabledesc><td width=70px align=center>Datum</td><td width=70px align=center>Uhrzeit</td><td align=left>Beschreibung</td><td width=50px align=center>Timer</td></tr>", &maxlen, &pos);
1367        }       
1368       
1369        while(epgnode != NULL)
1370        {
1371                if(fmt == 0)
1372                {
1373                        if(line == 0)
1374                        {
1375                                ostrcatbig(&buf, "<tr class=line1>", &maxlen, &pos);
1376                                line = 1;
1377                        }
1378                        else
1379                        {
1380                                ostrcatbig(&buf, "<tr class=line2>", &maxlen, &pos);
1381                                line = 0;
1382                        }
1383
1384                        loctime = olocaltime(&epgnode->starttime);
1385                        if(loctime != NULL)
1386                                strftime(buf1, MINMALLOC, "%d.%m", loctime);
1387                        ostrcatbig(&buf, "<td nowrap class=coldate>", &maxlen, &pos);
1388                        ostrcatbig(&buf, buf1, &maxlen, &pos);
1389                        if(loctime != NULL)
1390                                strftime(buf1, MINMALLOC, "%H.%M", loctime);
1391                        ostrcatbig(&buf, "</td><td nowrap class=coltime>", &maxlen, &pos);
1392                        ostrcatbig(&buf, buf1, &maxlen, &pos);
1393                        free(loctime); loctime = NULL; 
1394                       
1395                        ostrcatbig(&buf, "</td><td nowrap><a target=main class=link href=query?getepg&", &maxlen, &pos);
1396                        tmpstr = oitoa(chnode->serviceid);
1397                        ostrcatbig(&buf, tmpstr, &maxlen, &pos);
1398                        buf2 = ostrcat("<td nowrap class=linkimage><a target=main class=link href=query?addrectimer&", tmpstr, 0, 0);
1399                        buf2 = ostrcat(buf2, "&", 0, 0);
1400                        free(tmpstr); tmpstr = NULL;
1401                        ostrcatbig(&buf, "&", &maxlen, &pos);
1402                        tmpstr = ollutoa(chnode->transponderid);
1403                        ostrcatbig(&buf, tmpstr, &maxlen, &pos);
1404                        buf2 = ostrcat(buf2, tmpstr, 0, 0);
1405                        buf2 = ostrcat(buf2, "&", 0, 0);
1406                        free(tmpstr); tmpstr = NULL;
1407                        ostrcatbig(&buf, "&", &maxlen, &pos);
1408                        tmpstr = oitoa(epgnode->eventid);
1409                        ostrcatbig(&buf, tmpstr, &maxlen, &pos);
1410                        buf2 = ostrcat(buf2, tmpstr, 0, 0);
1411                        buf2 = ostrcat(buf2, ">", 0, 0);
1412                        free(tmpstr); tmpstr = NULL;
1413                        ostrcatbig(&buf, ">", &maxlen, &pos);
1414
1415                        ostrcatbig(&buf, epgnode->title, &maxlen, &pos);
1416                        if(epgnode->subtitle != NULL)
1417                        {
1418                                ostrcatbig(&buf, " (", &maxlen, &pos);
1419                                ostrcatbig(&buf, epgnode->subtitle, &maxlen, &pos);
1420                                ostrcatbig(&buf, ")", &maxlen, &pos);
1421                        }
1422
1423                        ostrcatbig(&buf, "</a></td>", &maxlen, &pos);
1424                        ostrcatbig(&buf, buf2, &maxlen, &pos);
1425                       
1426                        ostrcatbig(&buf, "<img border=0 width=16 height=16 src=img/timer.png alt=\"set timer\"/>", &maxlen, &pos);
1427                        ostrcatbig(&buf, "</a></td></tr>", &maxlen, &pos);
1428                }
1429                else
1430                {
1431                        buf = ostrcat(buf, epgnode->title, 1, 0);
1432                        buf = ostrcat(buf, "#", 1, 0);
1433                        buf = ostrcat(buf, olutoa(epgnode->starttime), 1, 1);
1434                        buf = ostrcat(buf, "#", 1, 0);
1435                        buf = ostrcat(buf, olutoa(epgnode->endtime), 1, 1);
1436                        buf = ostrcat(buf, "#", 1, 0);
1437                        buf = ostrcat(buf, epgnode->subtitle, 1, 0);
1438                        buf = ostrcat(buf, "#", 1, 0);
1439                        if(longdesc == 1)
1440                        {
1441                                tmpstr = epgdescunzip(epgnode);
1442                                if(tmpstr != NULL)
1443                                        buf = ostrcat(buf, tmpstr, 1, 0);
1444                                free(tmpstr); tmpstr = NULL;
1445                        }
1446                        buf = ostrcat(buf, "#", 1, 0);
1447                        buf = ostrcat(buf, oitoa(epgnode->eventid), 1, 1);
1448                        buf = ostrcat(buf, "\n", 1, 0);
1449                }
1450       
1451                epgnode = epgnode->next;
1452                free(buf2); buf2 = NULL;
1453        }
1454
1455        if(fmt == 0)
1456                webcreatetailbig(&buf, &maxlen, &pos, 0);
1457        else if(buf == NULL)
1458                buf = ostrcat("no data", NULL, 0, 0);
1459
1460        free(buf1);
1461        return buf;
1462}
1463
1464//TODO: create rectimer line
1465void webcalcrecline(char** buf, int* maxlen, int* pos)
1466{
1467        //ostrcatbig(buf, "<table border=0 cellpadding=0 cellspacing=0 style=\"table-layout: fixed\"><tr><td width=500 style=\"background-color: c0c0c0; height: 2; border-left: 2px solid #303030;\"></td></tr></table>", maxlen, pos);
1468}
1469
1470char* webgetgmultiepg(char* param, int fmt)
1471{
1472        int page = 1, i, line = 0, treffer = 0, maxlen = 0, pos = 0;
1473        char* buf = NULL, *tmpnr = NULL, *param1 = NULL;
1474        struct mainbouquet *mbouquet = NULL;
1475        struct bouquet *node = NULL;
1476        struct channel* chnode = NULL;
1477        struct epg* epgnode = NULL;
1478        time_t akttime = 0, difftime = 0, starttime = 0, endtime = 0, lastendtime = 0;
1479
1480        if(param == NULL) return NULL;
1481
1482        //create param1
1483        param1 = strchr(param, '&');
1484        if(param1 != NULL)
1485                *param1++ = '\0';
1486
1487        if(param1 != NULL) page = atoi(param1);
1488
1489        ostrcatbig(&buf, "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"><link rel=stylesheet type=text/css href=titan.css><script type=text/javascript src=titan.js></script></head><body class=body><center><table width=100% height=100%><tr><td height=100%><table cellpadding=0 cellspacing=0 border=0 id=gmultiepg class=scrolltable style=\"table-layout: fixed;\" cellpadding=0><thead><tr>", &maxlen, &pos);
1490
1491        akttime = webcreatetimeline(&buf, &maxlen, &pos);
1492        akttime += ((page - 1) * 1440);
1493        ostrcatbig(&buf, "</tr></thead><tbody>", &maxlen, &pos);
1494
1495        mbouquet = getmainbouquet(param);
1496        if(mbouquet != NULL)
1497        {
1498                node = mbouquet->bouquet;
1499                while(node != NULL)
1500                {
1501                        chnode = getchannel(node->serviceid, node->transponderid);
1502                        if(chnode != NULL)
1503                        {
1504                                if(line == 0)
1505                                {
1506                                        ostrcatbig(&buf, "<tr><th class=gepgchannel1>", &maxlen, &pos);
1507                                        ostrcatbig(&buf, chnode->name, &maxlen, &pos);
1508                                        ostrcatbig(&buf, "</th><td class=gepgchannelcell colspan=1000>", &maxlen, &pos);
1509                                        webcalcrecline(&buf, &maxlen, &pos);
1510                                        ostrcatbig(&buf, "<table border=0 cellpadding=0 cellspacing=0 style=\"table-layout: fixed;\"><tr class=line1>", &maxlen, &pos);
1511                                        line = 1;
1512                                }
1513                                else
1514                                {
1515                                        ostrcatbig(&buf, "<tr><th class=gepgchannel2>", &maxlen, &pos);
1516                                        ostrcatbig(&buf, chnode->name, &maxlen, &pos);
1517                                        ostrcatbig(&buf, "</th><td class=gepgchannelcell colspan=1000>", &maxlen, &pos);
1518                                        webcalcrecline(&buf, &maxlen, &pos);
1519
1520                                        ostrcatbig(&buf, "<table border=0 cellpadding=0 cellspacing=0 style=\"table-layout: fixed;\"><tr class=line2>", &maxlen, &pos);
1521                                        line = 0;
1522                                }
1523
1524                                treffer = 0;
1525                                lastendtime = 0;
1526                                epgnode = getepgakt(chnode);
1527                                while(epgnode != NULL)
1528                                {
1529                                        treffer = 1;
1530                                        starttime = epgnode->starttime / 60;
1531                                        endtime = epgnode->endtime / 60;
1532
1533                                        if(endtime <= starttime || starttime >= akttime + 1440)
1534                                        {
1535                                                epgnode = epgnode->next;
1536                                                continue;
1537                                        }
1538
1539                                        //check if old endtime > new starttime
1540                                        if(lastendtime > 0 && starttime > lastendtime)
1541                                        {
1542                                                difftime = (starttime - lastendtime) * 5;
1543
1544                                                if(difftime <= 0)
1545                                                {
1546                                                        epgnode = epgnode->next;
1547                                                        continue;
1548                                                }
1549
1550                                                ostrcatbig(&buf, "<td class=gepgcellblank style=\"", &maxlen, &pos);
1551                                                tmpnr = oitoa(difftime);
1552                                                ostrcatbig(&buf, "width:", &maxlen, &pos);
1553                                                ostrcatbig(&buf, tmpnr, &maxlen, &pos);
1554                                                ostrcatbig(&buf, "px;", &maxlen, &pos);
1555                                                ostrcatbig(&buf, "min-width:", &maxlen, &pos);
1556                                                ostrcatbig(&buf, tmpnr, &maxlen, &pos);
1557                                                ostrcatbig(&buf, "px;", &maxlen, &pos);
1558                                                ostrcatbig(&buf, "max-width:", &maxlen, &pos);
1559                                                ostrcatbig(&buf, tmpnr, &maxlen, &pos);
1560                                                ostrcatbig(&buf, "px;", &maxlen, &pos);
1561                                                free(tmpnr); tmpnr = NULL;
1562
1563                                                ostrcatbig(&buf, "\"> </td>", &maxlen, &pos);
1564                                        }
1565
1566                                        //check if starttime < last endtime
1567                                        if(starttime < lastendtime)
1568                                                starttime = lastendtime;
1569
1570                                        //check if endtime is in next day
1571                                        if(endtime > akttime + 1440)
1572                                                endtime = endtime - (endtime - (akttime + 1440));
1573
1574                                        //check if starttime is in prev day
1575                                        if(starttime < akttime)
1576                                                difftime = (endtime - akttime) * 5;
1577                                        else
1578                                                difftime = (endtime - starttime) * 5;
1579
1580                                        if(difftime <= 0)
1581                                        {
1582                                                epgnode = epgnode->next;
1583                                                continue;
1584                                        }
1585
1586                                        lastendtime = endtime;
1587
1588                                        ostrcatbig(&buf, "<td class=gepgcell style=\"", &maxlen, &pos);
1589                                        tmpnr = oitoa(difftime);
1590                                        ostrcatbig(&buf, "width:", &maxlen, &pos);
1591                                        ostrcatbig(&buf, tmpnr, &maxlen, &pos);
1592                                        ostrcatbig(&buf, "px;", &maxlen, &pos);
1593                                        ostrcatbig(&buf, "min-width:", &maxlen, &pos);
1594                                        ostrcatbig(&buf, tmpnr, &maxlen, &pos);
1595                                        ostrcatbig(&buf, "px;", &maxlen, &pos);
1596                                        ostrcatbig(&buf, "max-width:", &maxlen, &pos);
1597                                        ostrcatbig(&buf, tmpnr, &maxlen, &pos);
1598                                        ostrcatbig(&buf, "px;", &maxlen, &pos);
1599                                        free(tmpnr); tmpnr = NULL;
1600
1601                                        ostrcatbig(&buf, "\"><div class=gepgcellborder>", &maxlen, &pos);
1602                                        ostrcatbig(&buf, epgnode->title, &maxlen, &pos);
1603                                        ostrcatbig(&buf, "</div></div></td>", &maxlen, &pos);
1604                                       
1605                                        epgnode = epgnode->next;
1606                                }
1607                                if(treffer == 0)
1608                                        ostrcatbig(&buf, "<td class=gepgcellblank> </td>", &maxlen, &pos);
1609                        }
1610                        ostrcatbig(&buf, "</tr></table></td></tr>", &maxlen, &pos);
1611
1612                        node = node->next;
1613                }
1614        }
1615        ostrcatbig(&buf, "<script type=text/javascript>if(typeof tableScroll == 'function'){tableScroll('gmultiepg');}</script></tbody></table></td></tr><tr><td align=center>", &maxlen, &pos);
1616
1617        for(i = 1; i <= 14; i++)
1618        {
1619                if(page == i)
1620                        ostrcatbig(&buf, "<a class=pagesellink href=\"query?getgmultiepg&", &maxlen, &pos);
1621                else
1622                        ostrcatbig(&buf, "<a class=pagelink href=\"query?getgmultiepg&", &maxlen, &pos);
1623                ostrcatbig(&buf, param, &maxlen, &pos);
1624                ostrcatbig(&buf, "&", &maxlen, &pos);
1625                tmpnr = oitoa(i);
1626                ostrcatbig(&buf, tmpnr, &maxlen, &pos);
1627                ostrcatbig(&buf, "\">", &maxlen, &pos);
1628                ostrcatbig(&buf, tmpnr, &maxlen, &pos);
1629                ostrcatbig(&buf, "</a>", &maxlen, &pos);
1630                free(tmpnr); tmpnr = NULL;
1631        }
1632       
1633        ostrcatbig(&buf, "</td></tr></table></center></body></html>", &maxlen, &pos);
1634        return buf;
1635}
1636
1637char* webgetdrawcount(char* param, int fmt)
1638{
1639        return oitoa(status.drawscreencount);
1640}
1641
1642void webgetshoot(char* param, int fmt)
1643{
1644        printf("param: %s\n",param);
1645        printf("parm: %d\n",fmt);
1646        screenshoot(atoi(param));
1647}
1648
1649char* webgetepgsearch(char* query, char* param, int fmt)
1650{
1651        int line = 0, maxlen = 0, pos = 0, maxcount = 0, page = 1, newchannel = 0, longepg = 0;
1652        char* buf = NULL, *buf1 = NULL, *buf2 = NULL, *tmpstr = NULL, *tmpnr = NULL, *param1 = NULL, *param2 = NULL;
1653        struct channel* chnode = channel;
1654        struct epg* epgnode = NULL;
1655        struct tm *loctime = NULL;
1656
1657        if(query == NULL) return NULL;
1658
1659        if(param == NULL)
1660        {
1661                query = strchr(query, '=');
1662                if(query != NULL)
1663                {
1664                        query++;
1665                        stringreplacechar(param, '+', ' ');
1666                        param = query;
1667                }
1668        }
1669        else
1670        {
1671                //create param1 + 2
1672                param1 = strchr(param, '&');
1673                if(param1 != NULL)
1674                {
1675                        *param1++ = '\0';
1676                        param2 = strchr(param1, '&');
1677                        if(param2 != NULL)
1678                                *param2++ = '\0';
1679                }
1680        }
1681
1682        if(param1 != NULL) page = atoi(param1);
1683        if(param2 != NULL) longepg = atoi(param2);
1684
1685        buf1 = malloc(MINMALLOC);
1686        if(buf1 == NULL)
1687        {
1688                err("no mem");
1689                return buf;
1690        }
1691
1692        if(fmt == 0) webcreateheadbig(&buf, &maxlen, NULL, &pos, 0);
1693        while(chnode != NULL)
1694        {
1695                newchannel = 1;
1696                epgnode = getepgakt(chnode);
1697                while(epgnode != NULL)
1698                {
1699                        if(epgnode->title != NULL && ostrstrcase(epgnode->title, param) != NULL)
1700                        {
1701
1702                                maxcount++;
1703
1704                                if(page >= 0)
1705                                {
1706                                        if(maxcount <= (MAXHTMLLINE * page) - MAXHTMLLINE || maxcount > MAXHTMLLINE * page)
1707                                        {
1708                                                epgnode = epgnode->next;
1709                                                continue;
1710                                        }
1711                                }
1712
1713                                if(fmt == 0)
1714                                {
1715                                        if(line == 0)
1716                                        {
1717                                                ostrcatbig(&buf, "<tr class=line1>", &maxlen, &pos);
1718                                                line = 1;
1719                                        }
1720                                        else
1721                                        {
1722                                                ostrcatbig(&buf, "<tr class=line2>", &maxlen, &pos);
1723                                                line = 0;
1724                                        }
1725                                }
1726
1727                                if(fmt == 1 && newchannel == 1)
1728                                {
1729                                        newchannel = 0;
1730                                        ostrcatbig(&buf, "BeginNewChannel", &maxlen, &pos);
1731                                        ostrcatbig(&buf, "#", &maxlen, &pos);
1732                                        ostrcatbig(&buf, chnode->name, &maxlen, &pos);
1733                                        ostrcatbig(&buf, "#", &maxlen, &pos);
1734                                        tmpstr = oitoa(chnode->serviceid);
1735                                        ostrcatbig(&buf, tmpstr, &maxlen, &pos);
1736                                        free(tmpstr); tmpstr = NULL;
1737                                        ostrcatbig(&buf, "#", &maxlen, &pos);
1738                                        tmpstr = ollutoa(chnode->transponderid);
1739                                        ostrcatbig(&buf, tmpstr, &maxlen, &pos);
1740                                        free(tmpstr); tmpstr = NULL;
1741                                        ostrcatbig(&buf, "#", &maxlen, &pos);
1742                                        tmpstr = oitoa(chnode->servicetype);
1743                                        ostrcatbig(&buf, tmpstr, &maxlen, &pos);
1744                                        free(tmpstr); tmpstr = NULL;
1745                                        ostrcatbig(&buf, "\n", &maxlen, &pos);
1746                                }
1747
1748                                if(fmt == 0)
1749                                {
1750                                        ostrcatbig(&buf, "<td nowrap><a target=main class=link href=query?getepg&", &maxlen, &pos);
1751                                        tmpstr = oitoa(chnode->serviceid);
1752                                        buf2 = ostrcat("<td nowrap><a target=main class=link href=query?addrectimer&", tmpstr, 0, 0);
1753                                        buf2 = ostrcat(buf2, "&", 0, 0);
1754                                        ostrcatbig(&buf, tmpstr, &maxlen, &pos);
1755                                        free(tmpstr); tmpstr = NULL;
1756                                        ostrcatbig(&buf, "&", &maxlen, &pos);
1757                                        tmpstr = ollutoa(chnode->transponderid);
1758                                        ostrcatbig(&buf, tmpstr, &maxlen, &pos);
1759                                        buf2 = ostrcat(buf2, tmpstr, 0, 0);
1760                                        buf2 = ostrcat(buf2, "&", 0, 0);
1761                                        free(tmpstr); tmpstr = NULL;
1762                                        ostrcatbig(&buf, "&", &maxlen, &pos);
1763                                        tmpstr = oitoa(epgnode->eventid);
1764                                        ostrcatbig(&buf, tmpstr, &maxlen, &pos);
1765                                        buf2 = ostrcat(buf2, tmpstr, 0, 0);
1766                                        buf2 = ostrcat(buf2, ">", 0, 0);
1767                                        free(tmpstr); tmpstr = NULL;
1768                                        ostrcatbig(&buf, ">", &maxlen, &pos);
1769       
1770                                        loctime = olocaltime(&epgnode->starttime);
1771                                        if(loctime != NULL)
1772                                                strftime(buf1, MINMALLOC, "%d.%m _ %H:%M __ ", loctime);
1773                                                //strftime(buf1, MINMALLOC, "%H:%M -", loctime);
1774                                        free(loctime); loctime = NULL;
1775                                        //loctime = olocaltime(&epgnode->endtime);
1776                                        //if(loctime != NULL)
1777                                        //      strftime(&buf1[7], MINMALLOC - 8, " %H:%M ", loctime);
1778                                        //free(loctime); loctime = NULL;
1779                                        ostrcatbig(&buf, buf1, &maxlen, &pos);
1780                                        ostrcatbig(&buf, " ", &maxlen, &pos);
1781       
1782                                        ostrcatbig(&buf, epgnode->title, &maxlen, &pos);
1783                                        if(chnode->name != NULL)
1784                                        {
1785                                                ostrcatbig(&buf, " (", &maxlen, &pos);
1786                                                ostrcatbig(&buf, chnode->name, &maxlen, &pos);
1787                                                ostrcatbig(&buf, ")", &maxlen, &pos);
1788                                        }
1789
1790                                        ostrcatbig(&buf, "</a><br><font class=smalllabel1>", &maxlen, &pos);
1791                                        ostrcatbig(&buf, epgnode->subtitle, &maxlen, &pos);
1792
1793                                        ostrcatbig(&buf, "</font></td>", &maxlen, &pos);
1794                                        ostrcatbig(&buf, buf2, &maxlen, &pos);
1795                                        ostrcatbig(&buf, "<img border=0 width=16 height=16 src=img/timer.png alt=\"set timer\"/>", &maxlen, &pos);
1796                                        ostrcatbig(&buf, "</a></td></tr>", &maxlen, &pos);
1797                                }
1798                                else
1799                                {
1800                                        ostrcatbig(&buf, epgnode->title, &maxlen, &pos);
1801                                        ostrcatbig(&buf, "#", &maxlen, &pos);
1802
1803                                        tmpstr = olutoa(epgnode->starttime);
1804                                        ostrcatbig(&buf, tmpstr, &maxlen, &pos);
1805                                        free(tmpstr); tmpstr = NULL;
1806                                        ostrcatbig(&buf, "#", &maxlen, &pos);
1807
1808                                        tmpstr = olutoa(epgnode->endtime);
1809                                        ostrcatbig(&buf, tmpstr, &maxlen, &pos);
1810                                        free(tmpstr); tmpstr = NULL;
1811                                        ostrcatbig(&buf, "#", &maxlen, &pos);
1812
1813                                        ostrcatbig(&buf, epgnode->subtitle, &maxlen, &pos);
1814                                        ostrcatbig(&buf, "#", &maxlen, &pos);
1815
1816                                        if(longepg == 1)
1817                                        {
1818                                                tmpstr = epgdescunzip(epgnode);
1819                                                if(tmpstr != NULL)
1820                                                        ostrcatbig(&buf, tmpstr, &maxlen, &pos);
1821                                                free(tmpstr); tmpstr = NULL;
1822                                        }
1823                                        ostrcatbig(&buf, "#", &maxlen, &pos);
1824
1825                                        tmpstr = oitoa(epgnode->eventid);
1826                                        ostrcatbig(&buf, tmpstr, &maxlen, &pos);
1827                                        free(tmpstr); tmpstr = NULL;
1828                                        ostrcatbig(&buf, "\n", &maxlen, &pos);
1829                                }
1830                        }
1831                        epgnode = epgnode->next;
1832                        free(buf2); buf2 = NULL;
1833                }
1834                chnode = chnode->next;
1835        }
1836
1837        if(maxcount > MAXHTMLLINE && fmt == 0)
1838        {
1839                int i;
1840                ostrcatbig(&buf, "<tr><td align=center><br>", &maxlen, &pos);
1841                for(i = 1; i <= (int)ceil(((float)maxcount / MAXHTMLLINE)); i++)
1842                {
1843                        if(page == i)
1844                                ostrcatbig(&buf, "<a class=pagesellink href=query?getepgsearch&", &maxlen, &pos);
1845                        else
1846                                ostrcatbig(&buf, "<a class=pagelink href=query?getepgsearch&", &maxlen, &pos);
1847                        ostrcatbig(&buf, param, &maxlen, &pos);
1848                        ostrcatbig(&buf, "&", &maxlen, &pos);
1849                        free(tmpnr); tmpnr = NULL;
1850
1851                        tmpnr = oitoa(i);
1852                        ostrcatbig(&buf, tmpnr, &maxlen, &pos);
1853                        ostrcatbig(&buf, ">", &maxlen, &pos);
1854                        ostrcatbig(&buf, tmpnr, &maxlen, &pos);
1855                        ostrcatbig(&buf, "</a>", &maxlen, &pos);
1856                        free(tmpnr); tmpnr = NULL;
1857                }
1858                ostrcatbig(&buf, "</td></tr>", &maxlen, &pos);
1859        }
1860
1861        if(fmt == 0)
1862                webcreatetailbig(&buf, &maxlen, &pos, 0);
1863        else if(buf == NULL)
1864                buf = ostrcat("no data", NULL, 0, 0);
1865
1866        free(buf1);
1867        return buf;
1868}
1869
1870//flagbit 0: restrict to path
1871//flagbit 1: show epg icon
1872//flagbit 2: show delete icon
1873//flagbit 3: show stream icon
1874//flagbit 4: show websteam icon
1875char* webgetfilelist(char* param, char* link, char* dellink, char* path, char* mask, int flag, int fmt)
1876{
1877        char* buf = NULL, *tmppath = NULL, *tmpnr = NULL, *param1 = NULL;
1878        int maxlen = 0, pos = 0, line = 0, maxcount = 0, page = 1;
1879        struct skin* webdir = getscreen("webdir");
1880        struct skin* filelist = getscreennode(webdir, "filelist");
1881        struct skin* filelistpath = getscreennode(webdir, "filelistpath");
1882        struct skin* node = NULL;
1883
1884        if(param == NULL) param = path;
1885
1886        //create param1
1887        param1 = strchr(param, '&');
1888        if(param1 != NULL)
1889                *param1++ = '\0';
1890
1891        if(param1 != NULL) page = atoi(param1);
1892
1893        if(strlen(param) == 0 || !isdir(param))
1894                tmppath = ostrcat(path, NULL, 0, 0);
1895        else
1896                tmppath = ostrcat(param, NULL, 0, 0);
1897
1898        char* tmppath1 = createpath(tmppath, "");
1899        free(tmppath); tmppath = tmppath1;
1900
1901        if(checkbit(flag, 0) == 1)
1902        {
1903                if(ostrstr(tmppath, path) != tmppath)
1904                {
1905                        free(tmppath); tmppath = NULL;
1906                        tmppath = ostrcat(path, NULL, 0, 0);
1907                }
1908        }
1909
1910        changemask(filelist, mask);
1911        changeinput(filelist, tmppath);
1912        changetext(filelistpath, filelist->input);
1913
1914        free(tmppath); tmppath = NULL;
1915
1916        delmarkedscreennodes(webdir, FILELISTDELMARK);
1917        createfilelist(webdir, filelist, 0);
1918
1919        if(fmt == 0) ostrcatbig(&buf, "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"><link rel=stylesheet type=text/css href=titan.css><script type=text/javascript src=titan.js></script></head><body class=body><center><table width=100%>", &maxlen, &pos);
1920
1921        node = filelist;
1922        while(node != NULL)
1923        {
1924                if(node->del == FILELISTDELMARK)
1925                {
1926                        maxcount++;
1927                        if(maxcount <= (MAXHTMLLINE * page) - MAXHTMLLINE || maxcount > MAXHTMLLINE * page)
1928                        {
1929                                node = node->next;
1930                                continue;
1931                        }
1932
1933                        if(fmt == 0)
1934                        {
1935                                if(line == 0)
1936                                {
1937                                        ostrcatbig(&buf, "<tr class=line1>", &maxlen, &pos);
1938                                        line = 1;
1939                                }
1940                                else
1941                                {
1942                                        ostrcatbig(&buf, "<tr class=line2>", &maxlen, &pos);
1943                                        line = 0;
1944                                }
1945
1946                                ostrcatbig(&buf, "<td>", &maxlen, &pos);
1947                        }
1948                        if(node->input != NULL) //dir
1949                        {
1950                                if(fmt == 0)
1951                                {
1952                                        ostrcatbig(&buf, "<img border=0 width=16 height=16 src=img/folder.png alt=Directory> <a class=link href=\"query?", &maxlen, &pos);
1953                                        ostrcatbig(&buf, link, &maxlen, &pos);
1954                                        ostrcatbig(&buf, "&", &maxlen, &pos);
1955                                        ostrcatbig(&buf, node->input, &maxlen, &pos);
1956                                        ostrcatbig(&buf, "\">", &maxlen, &pos);
1957                                        ostrcatbig(&buf, node->text, &maxlen, &pos);
1958                                        ostrcatbig(&buf, "</a><td> </td>", &maxlen, &pos);
1959                                }
1960                                else
1961                                {
1962                                        ostrcatbig(&buf, node->text, &maxlen, &pos);
1963                                        ostrcatbig(&buf, "#0", &maxlen, &pos);
1964                                        ostrcatbig(&buf, "\n", &maxlen, &pos);
1965                                }
1966                        }
1967                        else
1968                        {
1969                                if(fmt == 0)
1970                                {
1971                                        ostrcatbig(&buf, "<font class=label1>", &maxlen, &pos);
1972                                        ostrcatbig(&buf, node->text, &maxlen, &pos);
1973                                        ostrcatbig(&buf, "</font></td>", &maxlen, &pos);
1974
1975                                        ostrcatbig(&buf, "<td width=80 align=right>", &maxlen, &pos);
1976
1977                                        //epg png
1978                                        if(checkbit(flag, 1) == 1)
1979                                        {
1980                                                ostrcatbig(&buf, "<a href=\"query?getmovieepg&", &maxlen, &pos);
1981                                                ostrcatbig(&buf, filelistpath->text, &maxlen, &pos);
1982                                                ostrcatbig(&buf, "/", &maxlen, &pos);
1983                                                ostrcatbig(&buf, node->text, &maxlen, &pos);
1984                                                ostrcatbig(&buf, "\">", &maxlen, &pos);
1985                                                ostrcatbig(&buf, "<img border=0 src=img/movieepg.png width=16 height=16 alt=EPG></a>", &maxlen, &pos);
1986                                        }
1987                                        //delete png
1988                                        if(checkbit(flag, 2) == 1)
1989                                        {
1990                                                ostrcatbig(&buf, "<img border=0 src=img/delete.png width=16 height=16 alt=Delete onclick='delquestion(\"", &maxlen, &pos);
1991                                                ostrcatbig(&buf, "query?", &maxlen, &pos);
1992                                                ostrcatbig(&buf, dellink, &maxlen, &pos);
1993                                                ostrcatbig(&buf, "&", &maxlen, &pos);
1994                                                ostrcatbig(&buf, filelistpath->text, &maxlen, &pos);
1995                                                ostrcatbig(&buf, "&", &maxlen, &pos);
1996                                                tmpnr = oitoa(page);
1997                                                ostrcatbig(&buf, tmpnr, &maxlen, &pos);
1998                                                free(tmpnr); tmpnr = NULL;
1999                                                ostrcatbig(&buf, "&", &maxlen, &pos);
2000                                                ostrcatbig(&buf, node->text, &maxlen, &pos);
2001                                                ostrcatbig(&buf, "\");'>", &maxlen, &pos);
2002                                        }
2003                                        //stream png
2004                                        if(checkbit(flag, 3) == 1)
2005                                        {
2006                                                ostrcatbig(&buf, "<a target=nothing href=\"query?getm3u&0,0,", &maxlen, &pos);
2007                                                ostrcatbig(&buf, filelistpath->text, &maxlen, &pos);
2008                                                ostrcatbig(&buf, "/", &maxlen, &pos);
2009                                                ostrcatbig(&buf, node->text, &maxlen, &pos);
2010                                                ostrcatbig(&buf, "\">", &maxlen, &pos);
2011
2012                                                ostrcatbig(&buf, "<img border=0 src=img/stream.png width=16 height=16 alt=Stream></a>", &maxlen, &pos);
2013                                        }
2014                                        //webstream png
2015                                        if(checkbit(flag, 4) == 1)
2016                                        {
2017                                                ostrcatbig(&buf, "<a target=_blank href=\"query?getvideo&0,0,", &maxlen, &pos);
2018                                                ostrcatbig(&buf, filelistpath->text, &maxlen, &pos);
2019                                                ostrcatbig(&buf, "/", &maxlen, &pos);
2020                                                ostrcatbig(&buf, node->text, &maxlen, &pos);
2021                                                ostrcatbig(&buf, "\">", &maxlen, &pos);
2022
2023                                                ostrcatbig(&buf, "<img border=0 src=img/webstream.png width=16 height=16 alt=WebStream></a>", &maxlen, &pos);
2024
2025                                                ostrcatbig(&buf, "<a target=_blank href=\"", &maxlen, &pos);
2026                                                ostrcatbig(&buf, filelistpath->text, &maxlen, &pos);
2027                                                ostrcatbig(&buf, "/", &maxlen, &pos);
2028                                                ostrcatbig(&buf, node->text, &maxlen, &pos);
2029                                                ostrcatbig(&buf, "\">", &maxlen, &pos);
2030       
2031                                                ostrcatbig(&buf, "<img border=0 src=img/icon_restart.png width=16 height=16 alt=Download></a>", &maxlen, &pos);
2032                                        }
2033                                }
2034                                else
2035                                {
2036                                        ostrcatbig(&buf, node->text, &maxlen, &pos);
2037                                        ostrcatbig(&buf, "#1", &maxlen, &pos);
2038                                        ostrcatbig(&buf, "\n", &maxlen, &pos);
2039                                }
2040                        }
2041                        if(fmt == 0)
2042                        {
2043                                ostrcatbig(&buf, "</td>", &maxlen, &pos);
2044                                ostrcatbig(&buf, "</tr>", &maxlen, &pos);
2045                        }
2046                }
2047
2048                node = node->next;
2049        }
2050
2051        if(maxcount > MAXHTMLLINE)
2052        {
2053                int i;
2054                ostrcatbig(&buf, "<tr><td align=center><br>", &maxlen, &pos);
2055                for(i = 1; i <= (int)ceil(((float)maxcount / MAXHTMLLINE)); i++)
2056                {
2057                        if(page == i)
2058                        {
2059                                ostrcatbig(&buf, "<a class=pagesellink href=query?", &maxlen, &pos);
2060                                ostrcatbig(&buf, link, &maxlen, &pos);
2061                                ostrcatbig(&buf, "&", &maxlen, &pos);
2062                        }
2063                        else
2064                        {
2065                                ostrcatbig(&buf, "<a class=pagelink href=query?", &maxlen, &pos);
2066                                ostrcatbig(&buf, link, &maxlen, &pos);
2067                                ostrcatbig(&buf, "&", &maxlen, &pos);
2068                        }
2069                        ostrcatbig(&buf, param, &maxlen, &pos);
2070                        ostrcatbig(&buf, "&", &maxlen, &pos);
2071
2072                        tmpnr = oitoa(i);
2073                        ostrcatbig(&buf, tmpnr, &maxlen, &pos);
2074                        ostrcatbig(&buf, ">", &maxlen, &pos);
2075                        ostrcatbig(&buf, tmpnr, &maxlen, &pos);
2076                        ostrcatbig(&buf, "</a>", &maxlen, &pos);
2077                        free(tmpnr); tmpnr = NULL;
2078                }
2079                ostrcatbig(&buf, "</td></tr>", &maxlen, &pos);
2080        }
2081
2082        if(fmt == 0) webcreatetailbig(&buf, &maxlen, &pos, 0);
2083        delmarkedscreennodes(webdir, FILELISTDELMARK);
2084        return buf;
2085}
2086
2087char* webgetmovieepg(char* param, char* path, int flag, int fmt)
2088{
2089        char* buf = NULL, *tmpstr = NULL;
2090        char tstr[2];
2091        char c = 0;
2092        int first = 1, maxlen = 0, pos = 0;
2093        FILE* fd = NULL;
2094
2095        if(fmt == 0)
2096        {
2097                webcreateheadbig(&buf, &maxlen, NULL, &pos, 0);
2098                ostrcatbig(&buf, "<tr><td><font class=biglabel>", &maxlen, &pos);
2099        }
2100
2101        if(flag == 1)
2102        {
2103                if(param != NULL && ostrstr(param, path) == param)
2104                {
2105                        tmpstr = changefilenameext(param, ".epg");
2106                        fd = fopen(tmpstr, "r");
2107                }
2108        }
2109        else
2110        {
2111                tmpstr = changefilenameext(param, ".epg");
2112                fd = fopen(tmpstr, "r");
2113        }
2114
2115        if(fd != NULL)
2116        {
2117                while(c != EOF)
2118                {
2119                        c = fgetc(fd);
2120                        if(fmt == 0 && c == '\n')
2121                        {
2122                                if(first == 1)
2123                                {
2124                                        ostrcatbig(&buf, "</font><br><font class=label>", &maxlen, &pos);
2125                                        first = 0;
2126                                }
2127                                ostrcatbig(&buf, "<br>", &maxlen, &pos);
2128                                continue;
2129                        }
2130                        if(c != EOF)
2131                        {
2132                                sprintf(tstr, "%c", c);
2133                                ostrcatbig(&buf, tstr, &maxlen, &pos);
2134                        }
2135                }
2136                fclose(fd);
2137        }
2138
2139        if(fmt == 0)
2140        {
2141                ostrcatbig(&buf, "</font></td></tr>", &maxlen, &pos);
2142                webcreatetailbig(&buf, &maxlen, &pos, 0);
2143        }
2144
2145        free(tmpstr); tmpstr = NULL;
2146        return buf;
2147}
2148
2149char* webdelfile(char* param, char* link, char* dellink, char* path, char* mask, int flag, int fmt)
2150{
2151        int del = 0;
2152        char* buf = NULL, *param1 = NULL, *param2 = NULL, *tmpparam = NULL;
2153
2154        if(param == NULL) return NULL;
2155
2156        //create param1 + 2
2157        param1 = strchr(param, '&');
2158        if(param1 != NULL)
2159        {
2160                *param1++ = '\0';
2161                param2 = strchr(param1, '&');
2162                if(param2 != NULL)
2163                        *param2++ = '\0';
2164        }
2165
2166        if(param1 == NULL || param2 == NULL) return NULL;
2167
2168        tmpparam = createpath(param, param2);
2169
2170        if(checkbit(flag, 0) == 1)
2171        {
2172                if(tmpparam != NULL && ostrstr(tmpparam, path) == tmpparam)
2173                        del = 1;
2174        }
2175        else
2176                del = 1;
2177
2178        if(del == 1)
2179        {
2180                char* epgfilename = NULL;
2181
2182                unlink(tmpparam);
2183
2184                if(cmpfilenameext(tmpparam, ".ts") == 0)
2185                {
2186                        epgfilename = changefilenameext(tmpparam, ".epg");
2187                        unlink(epgfilename);
2188                        free(epgfilename); epgfilename = NULL;
2189                        epgfilename = changefilenameext(tmpparam, ".se");
2190                        unlink(epgfilename);
2191                        free(epgfilename); epgfilename = NULL;
2192                        epgfilename = changefilenameext(tmpparam, ".ma");
2193                        unlink(epgfilename);
2194                        free(epgfilename); epgfilename = NULL;
2195                }
2196        }
2197
2198        free(tmpparam); tmpparam = NULL;
2199        tmpparam = ostrcat(tmpparam, param, 1, 0);
2200        tmpparam = ostrcat(tmpparam, "&", 1, 0);
2201        tmpparam = ostrcat(tmpparam, param1, 1, 0);
2202
2203        buf = webgetfilelist(tmpparam, link, dellink, path, mask, flag, fmt);
2204        free(tmpparam); tmpparam = NULL;
2205        return buf;
2206}
2207
2208char* websendrc(char* param, int fmt)
2209{
2210        int rccode = 0;
2211        char* buf = NULL;
2212
2213        rccode = getrcconfigint(param, NULL);
2214        writerc(rccode);
2215
2216        buf = ostrcat("ok", NULL, 0, 0);
2217        return buf;
2218}
2219
2220//flag 0: get aktiv timer
2221//flag 1: get old timer
2222char* webgetrectimer(char* param, int flag, int fmt)
2223{
2224        char* buf = NULL, *buf1 = NULL;
2225        struct rectimer* node = rectimer;
2226        struct channel* chnode = NULL;
2227        int line = 0, maxlen = 0, pos = 0;
2228        struct tm *loctime = NULL;
2229
2230        buf1 = malloc(MINMALLOC);
2231        if(buf1 == NULL)
2232        {
2233                err("no mem");
2234                return NULL;
2235        }
2236
2237        if(fmt == 0) ostrcatbig(&buf, "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"><link rel=stylesheet type=text/css href=titan.css><script type=text/javascript src=titan.js></script></head><body class=body><center><table width=100%>", &maxlen, &pos);
2238
2239        while(node != NULL)
2240        {
2241                if((flag == 0 && (node->status == 2 || node->status == 3)) || (flag == 1 && (node->status == 0 || node->status == 1)) || node->status == 4 || node->status == 5)
2242                {
2243                        node = node->next;
2244                        continue;
2245                }
2246                if(fmt == 0)
2247                {
2248                        if(line == 0)
2249                        {
2250                                ostrcatbig(&buf, "<tr class=line1><td>", &maxlen, &pos);
2251                                line = 1;
2252                        }
2253                        else
2254                        {
2255                                ostrcatbig(&buf, "<tr class=line2><td>", &maxlen, &pos);
2256                                line = 0;
2257                        }
2258
2259                        loctime = olocaltime(&node->begin);
2260                        if(loctime != NULL)
2261                                strftime(buf1, MINMALLOC, "%d-%m-%Y %H:%M -", loctime);
2262                        free(loctime); loctime = NULL;
2263                        loctime = olocaltime(&node->end);
2264                        if(loctime != NULL)
2265                                strftime(&buf1[18], MINMALLOC - 19, " %H:%M ", loctime);
2266                        free(loctime); loctime = NULL;
2267       
2268                        ostrcatbig(&buf, "<font class=label1>", &maxlen, &pos);
2269                        ostrcatbig(&buf, buf1, &maxlen, &pos);
2270
2271                        ostrcatbig(&buf, " (", &maxlen, &pos);
2272                        if(node->justplay == 0)
2273                                ostrcatbig(&buf, "rec - ", &maxlen, &pos);
2274                        else
2275                                ostrcatbig(&buf, "switch - ", &maxlen, &pos);
2276                        if(node->repeate == 0)
2277                                ostrcatbig(&buf, "once", &maxlen, &pos);
2278                        else
2279                                ostrcatbig(&buf, "repeate", &maxlen, &pos);
2280
2281                        ostrcatbig(&buf, ")</font><br><font class=smalllabel1>", &maxlen, &pos);
2282                        if(node->name == NULL || strlen(node->name) == 0)
2283                                ostrcatbig(&buf, "---", &maxlen, &pos);
2284                        else
2285                                ostrcatbig(&buf, node->name, &maxlen, &pos);
2286
2287                        chnode = getchannel(node->serviceid, node->transponderid);
2288                        if(chnode != NULL)
2289                        {
2290                                ostrcatbig(&buf, " (", &maxlen, &pos);
2291                                ostrcatbig(&buf, chnode->name, &maxlen, &pos);
2292                                ostrcatbig(&buf, ")", &maxlen, &pos);
2293                        }
2294                        ostrcatbig(&buf, "<br>", &maxlen, &pos);
2295
2296                        if(node->status == 0)
2297                                ostrcatbig(&buf, "waiting", &maxlen, &pos);
2298                        else if(node->status == 1)
2299                                ostrcatbig(&buf, "running", &maxlen, &pos);
2300                        else if(node->status == 2)
2301                                ostrcatbig(&buf, "succes", &maxlen, &pos);
2302                        else if(node->status == 3)
2303                        {
2304                                ostrcatbig(&buf, "error", &maxlen, &pos);
2305                                if(node->errstr != NULL && strlen(node->errstr) > 0)
2306                                {
2307                                        ostrcatbig(&buf, " (", &maxlen, &pos);
2308                                        ostrcatbig(&buf, node->errstr, &maxlen, &pos);
2309                                        ostrcatbig(&buf, ")", &maxlen, &pos);
2310                                }
2311                        }
2312
2313                        ostrcatbig(&buf, "</font>", &maxlen, &pos);
2314
2315                        if(flag == 0)
2316                        {
2317                                ostrcatbig(&buf, "</td><td width=40 align=right>", &maxlen, &pos);
2318
2319                                //edit png
2320                                ostrcatbig(&buf, "<a target=main href=\"query?editrectimer", &maxlen, &pos);
2321                                ostrcatbig(&buf, "&", &maxlen, &pos);
2322                                ostrcatbig(&buf, node->timestamp, &maxlen, &pos);
2323                                ostrcatbig(&buf, "\">", &maxlen, &pos);
2324
2325                                ostrcatbig(&buf, "<img border=0 src=img/edit.png width=16 height=16 alt=\"Edit Timer\"></a>", &maxlen, &pos);
2326
2327                                //delete png
2328                                ostrcatbig(&buf, "<img border=0 src=img/delete.png width=16 height=16 alt=Delete onclick='delquestion(\"", &maxlen, &pos);
2329                                ostrcatbig(&buf, "query?delrectimer", &maxlen, &pos);
2330                                ostrcatbig(&buf, "&", &maxlen, &pos);
2331                                ostrcatbig(&buf, node->timestamp, &maxlen, &pos);
2332                                //ostrcatbig(&buf, filelistpath->text, &maxlen, &pos);
2333                                //ostrcatbig(&buf, "&", &maxlen, &pos);
2334                                //tmpnr = oitoa(page);
2335                                //ostrcatbig(&buf, tmpnr, &maxlen, &pos);
2336                                //free(tmpnr); tmpnr = NULL;
2337                                //ostrcatbig(&buf, "&", &maxlen, &pos);
2338                                //ostrcatbig(&buf, node->text, &maxlen, &pos);
2339                                ostrcatbig(&buf, "\");'>", &maxlen, &pos);
2340                        }
2341
2342                        ostrcatbig(&buf, "</td></tr>", &maxlen, &pos);
2343                }
2344                else
2345                {
2346                        buf = ostrcat(buf, olutoa(node->begin), 1, 1);
2347                        buf = ostrcat(buf, "#", 1, 0);
2348                        buf = ostrcat(buf, olutoa(node->end), 1, 1);
2349                        buf = ostrcat(buf, "#", 1, 0);
2350                        buf = ostrcat(buf, oitoa(node->justplay), 1, 1);
2351                        buf = ostrcat(buf, "#", 1, 0);
2352                        buf = ostrcat(buf, oitoa(node->repeate), 1, 1);
2353                        buf = ostrcat(buf, "#", 1, 0);
2354                        buf = ostrcat(buf, node->name, 1, 0);
2355                        buf = ostrcat(buf, "#", 1, 0);
2356                        buf = ostrcat(buf, oitoa(node->serviceid), 1, 1);
2357                        buf = ostrcat(buf, "#", 1, 0);
2358                        buf = ostrcat(buf, ollutoa(node->transponderid), 1, 1);
2359                        buf = ostrcat(buf, "#", 1, 0);
2360                        buf = ostrcat(buf, oitoa(node->status), 1, 1);
2361                        buf = ostrcat(buf, "#", 1, 0);
2362                        buf = ostrcat(buf, node->errstr, 1, 0);
2363                        buf = ostrcat(buf, "#", 1, 0);
2364                        buf = ostrcat(buf, node->timestamp, 1, 0);
2365                        buf = ostrcat(buf, "#", 1, 0);
2366                        chnode = getchannel(node->serviceid, node->transponderid);
2367                        if(chnode != NULL)
2368                                buf = ostrcat(buf, chnode->name, 1, 0);
2369                        buf = ostrcat(buf, "#", 1, 0);
2370                        buf = ostrcat(buf, oitoa(node->afterevent), 1, 1);
2371                        buf = ostrcat(buf, "\n", 1, 0);
2372                }
2373
2374                node = node->next;
2375        }
2376
2377        if(fmt == 0)
2378                webcreatetailbig(&buf, &maxlen, &pos, 0);
2379        else if(buf == NULL)
2380                buf = ostrcat("no data", NULL, 0, 0);
2381
2382        free(buf1);
2383        return buf;
2384}
2385
2386char* webaddrectimer(char* param, int fmt)
2387{
2388        char* buf = NULL, *buf1 = NULL, *buf2 = NULL, *param1 = NULL, *param2 = NULL;
2389        struct channel* chnode = NULL;
2390        struct epg* epgnode = NULL;
2391//      int maxlen = 0, pos = 0, tmpservicetype = 0;
2392        int maxlen = 0, pos = 0;
2393        struct tm* loctime = NULL;
2394        time_t akttime = time(NULL);
2395       
2396        if(param != NULL)
2397        {
2398                //create param1 + 2
2399                param1 = strchr(param, '&');
2400                if(param1 != NULL)
2401                {
2402                        *param1++ = '\0';
2403                        param2 = strchr(param1, '&');
2404                        if(param2 != NULL)
2405                                *param2++ = '\0';
2406                }
2407                if(param1 == NULL || param2 == NULL) return NULL;
2408                chnode = getchannel(atoi(param), strtoull(param1, NULL, 10));
2409                if(chnode == NULL) return NULL;
2410
2411                epgnode = getepg(chnode, atoi(param2), 0);
2412                if(epgnode == NULL) return NULL;
2413        }
2414
2415               
2416        ostrcatbig(&buf, "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"><link rel=\"stylesheet\" type=\"text/css\" href=\"titan.css\"></head>", &maxlen, &pos);
2417        ostrcatbig(&buf, "<body class=body ><center>", &maxlen, &pos);
2418        ostrcatbig(&buf, "<form name=F1 action=query method=get><br><br>", &maxlen, &pos);
2419        if(chnode == NULL)
2420                ostrcatbig(&buf, "<input type=\"hidden\" name=\"rectimercheck&node\" value=\"", &maxlen, &pos);
2421        else
2422                ostrcatbig(&buf, "<input type=\"hidden\" name=\"rectimersend&node\" value=\"", &maxlen, &pos);
2423        ostrcatbig(&buf, "0", &maxlen, &pos);
2424        ostrcatbig(&buf, "\">", &maxlen, &pos);
2425        ostrcatbig(&buf, "<table border=\"0\"><tr>", &maxlen, &pos);
2426        ostrcatbig(&buf, "<td><font class=label>Name:&nbsp;</font></td>", &maxlen, &pos);
2427        ostrcatbig(&buf, "<td><input class=inputbox type=\"text\" name=\"name\" value=\"", &maxlen, &pos);
2428        if(epgnode != NULL)
2429                ostrcatbig(&buf, epgnode->title, &maxlen, &pos);
2430        else   
2431                ostrcatbig(&buf, " ", &maxlen, &pos);
2432        ostrcatbig(&buf, "\" /></td></tr>", &maxlen, &pos);
2433        ostrcatbig(&buf, "<td><font class=label>Type:&nbsp;</font></td>", &maxlen, &pos);
2434        ostrcatbig(&buf, "<td><select name=\"type\" border=0><option selected>", &maxlen, &pos);
2435        ostrcatbig(&buf, "record", &maxlen, &pos);
2436        ostrcatbig(&buf, "<option>record<option>switch channel</select></td></tr>", &maxlen, &pos);
2437
2438        buf2 = malloc(MINMALLOC);
2439        if(epgnode != NULL)
2440                loctime =       olocaltime(&epgnode->starttime);
2441        else
2442                loctime = olocaltime(&akttime);
2443        if(loctime != NULL)
2444                strftime(buf2, MINMALLOC, "%H:%M %d-%m-%Y", loctime);
2445        free(loctime); loctime = NULL;
2446
2447        buf1 = ostrcat(buf2, NULL, 0, 0);
2448        ostrcatbig(&buf, "<td><font class=label>Begin:&nbsp;</font></td>", &maxlen, &pos);
2449        ostrcatbig(&buf, "<td><input class=inputbox type=\"text\" name=\"begin\" value=\"", &maxlen, &pos);
2450        ostrcatbig(&buf, buf1, &maxlen, &pos);
2451        ostrcatbig(&buf, "\" /></td></tr>", &maxlen, &pos);
2452        free(buf1); buf1 = NULL;
2453       
2454        if(epgnode != NULL)
2455                loctime =       olocaltime(&epgnode->endtime);
2456        else
2457                loctime = olocaltime(&akttime);
2458        if(loctime != NULL)
2459                strftime(buf2, MINMALLOC, "%H:%M %d-%m-%Y", loctime);
2460        free(loctime); loctime = NULL;
2461       
2462        buf1 = ostrcat(buf2, NULL, 0, 0);
2463        ostrcatbig(&buf, "<td><font class=label>End:&nbsp;</font></td>", &maxlen, &pos);
2464        ostrcatbig(&buf, "<td><input class=inputbox type=\"text\" name=\"end\" value=\"", &maxlen, &pos);
2465        ostrcatbig(&buf, buf1, &maxlen, &pos);
2466        ostrcatbig(&buf, "\" /></td></tr>", &maxlen, &pos);
2467        free(buf1); buf1 = NULL;
2468        free(buf2); buf2 = NULL;
2469
2470        ostrcatbig(&buf, "<td><font class=label>Channel:&nbsp;</font></td>", &maxlen, &pos);
2471        if(chnode == NULL)
2472                ostrcatbig(&buf, "<td><input class=inputbox type=\"text\" name=\"channel\" value=\"", &maxlen, &pos);
2473        else
2474        {
2475                ostrcatbig(&buf, "<td>", &maxlen, &pos);
2476                ostrcatbig(&buf, "<input class=inputbox type=\"hidden\" name=\"sid\" value=\"", &maxlen, &pos);
2477                buf1 = oitoa(chnode->serviceid);
2478                ostrcatbig(&buf, buf1, &maxlen, &pos);
2479                free(buf1); buf1 = NULL;
2480                ostrcatbig(&buf, "\" />", &maxlen, &pos);
2481                ostrcatbig(&buf, "<input class=inputbox type=\"hidden\" name=\"tid\" value=\"", &maxlen, &pos);
2482                buf1 = ollutoa(chnode->transponderid);
2483                ostrcatbig(&buf, buf1, &maxlen, &pos);
2484                free(buf1); buf1 = NULL;
2485                ostrcatbig(&buf, "\" />", &maxlen, &pos);
2486                ostrcatbig(&buf, "<input readonly class=inputbox type=\"text\" name=\"channel\" value=\"", &maxlen, &pos);
2487        }
2488        if(chnode != NULL)
2489                ostrcatbig(&buf, chnode->name, &maxlen, &pos);
2490        else if(status.aktservice->channel != NULL)
2491                ostrcatbig(&buf, status.aktservice->channel->name, &maxlen, &pos);
2492        ostrcatbig(&buf, "\" /></td></tr>", &maxlen, &pos);
2493        free(buf1); buf1 = NULL;
2494       
2495        ostrcatbig(&buf, "<td><font class=label>after event:&nbsp;</font></td>", &maxlen, &pos);
2496        ostrcatbig(&buf, "<td><select name=\"afterevent\" border=0><option selected>", &maxlen, &pos);
2497        ostrcatbig(&buf, "auto", &maxlen, &pos);
2498        ostrcatbig(&buf, "<option>auto<option>nothing<option>standby<option>off</select></td></tr>", &maxlen, &pos);
2499       
2500        ostrcatbig(&buf, "</table><br><br><input class=button type=submit name=send value=\"Send\" onClick=\"return checkdaytime(begin.value, end.value)\"></input>&nbsp;<input class=button type=reset name=reset value=\"Reset\"></input></form></center></body></html>", &maxlen, &pos);
2501
2502        //ostrcatbig(&buf, param, &maxlen, &pos);
2503        return buf;
2504}
2505
2506char* webrectimercheck(char* param, int fmt)
2507{
2508        char* buf = NULL, *buf1 = NULL, *string = NULL, *param1 = NULL, *name = NULL, *begin = NULL, *end = NULL, *type = NULL, *anode = NULL, *channelname = NULL, *ext = NULL, *afterevent = NULL, *repeat = NULL;
2509        int maxlen = 0, pos = 0, channelfind = 0;
2510        struct channel *channel1 = NULL;
2511       
2512        anode = ostrstr(param, "node=");
2513        if(anode != NULL)
2514                anode = anode + 5;
2515        name = ostrstr(param, "name=");
2516        if(name != NULL)
2517                name = name + 5;
2518        begin = ostrstr(param, "begin=");
2519        if(begin != NULL)
2520                begin = begin + 6;
2521        end = ostrstr(param, "end=");
2522        if(end != NULL)
2523                end = end + 4;
2524        type = ostrstr(param, "type=");
2525        if(type != NULL)
2526                type = type + 5;
2527        channelname = ostrstr(param, "channel=");
2528        if(channelname != NULL)
2529                channelname = channelname + 8;
2530        ext = ostrstr(param, "ext=");
2531        if(ext != NULL)
2532                ext = ext + 4;
2533        afterevent = ostrstr(param, "afterevent=");
2534        if(afterevent != NULL)
2535                afterevent = afterevent + 11;
2536        repeat = ostrstr(param, "repeat=");
2537        if(repeat != NULL)
2538                repeat = repeat + 7;
2539
2540        param1 = ostrcat(param, NULL, 0, 0);
2541        string = param;
2542        while(string != NULL)
2543        {
2544                string = strchr(string, '&');
2545                if(string != NULL)
2546                        *string++ = '\0';
2547        }
2548       
2549        ostrcatbig(&buf, "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"><link rel=\"stylesheet\" type=\"text/css\" href=\"titan.css\"></head>", &maxlen, &pos);
2550        ostrcatbig(&buf, "<body class=body ><center>", &maxlen, &pos);
2551        ostrcatbig(&buf, "<form name=F1 action=query method=get><br><br>", &maxlen, &pos);
2552       
2553        if(anode != NULL)
2554        {
2555                ostrcatbig(&buf, "<input type=\"hidden\" name=\"rectimersend&node\" value=\"", &maxlen, &pos);
2556                ostrcatbig(&buf, anode, &maxlen, &pos);
2557                ostrcatbig(&buf, "\" />", &maxlen, &pos);
2558        }
2559       
2560        if(name != NULL)
2561        {       
2562                ostrcatbig(&buf, "<input type=\"hidden\" name=\"name\" value=\"", &maxlen, &pos);
2563                ostrcatbig(&buf, name, &maxlen, &pos);
2564                ostrcatbig(&buf, "\" />", &maxlen, &pos);
2565        }
2566       
2567        if(begin != NULL)
2568        {
2569                ostrcatbig(&buf, "<input type=\"hidden\" name=\"begin\" value=\"", &maxlen, &pos);
2570                ostrcatbig(&buf, begin, &maxlen, &pos);
2571                ostrcatbig(&buf, "\" />", &maxlen, &pos);
2572        }
2573       
2574        if(end != NULL)
2575        {
2576                ostrcatbig(&buf, "<input type=\"hidden\" name=\"end\" value=\"", &maxlen, &pos);
2577                ostrcatbig(&buf, end, &maxlen, &pos);             
2578                ostrcatbig(&buf, "\" />", &maxlen, &pos);
2579        }
2580       
2581        if(type != NULL)
2582        {
2583                ostrcatbig(&buf, "<input type=\"hidden\" name=\"type\" value=\"", &maxlen, &pos);
2584                ostrcatbig(&buf, type, &maxlen, &pos);
2585                ostrcatbig(&buf, "\" />", &maxlen, &pos);
2586        }
2587       
2588        if(ext != NULL)
2589        {
2590                ostrcatbig(&buf, "<input type=\"hidden\" name=\"ext\" value=\"", &maxlen, &pos);
2591                ostrcatbig(&buf, ext, &maxlen, &pos);
2592                ostrcatbig(&buf, "\" />", &maxlen, &pos);
2593        }
2594       
2595        if(afterevent != NULL)
2596        {
2597                ostrcatbig(&buf, "<input type=\"hidden\" name=\"afterevent\" value=\"", &maxlen, &pos);
2598                ostrcatbig(&buf, afterevent, &maxlen, &pos);
2599                ostrcatbig(&buf, "\" />", &maxlen, &pos);
2600        }
2601       
2602        if(repeat != NULL)
2603        {
2604                ostrcatbig(&buf, "<input type=\"hidden\" name=\"repeat\" value=\"", &maxlen, &pos);
2605                ostrcatbig(&buf, repeat, &maxlen, &pos);
2606                ostrcatbig(&buf, "\" />", &maxlen, &pos);
2607        }
2608       
2609        ostrcatbig(&buf, "<table border=\"0\"><tr>", &maxlen, &pos);
2610        ostrcatbig(&buf, "<td><select name=sid size=10 border=0>", &maxlen, &pos);
2611       
2612        /*
2613        channel1 = channel;             
2614        while(channel1 != NULL)
2615        {
2616                if(ostrcmp(channel1->name, channelname) == 0 && (channel1->servicetype == 0 || channel1->servicetype == 1))
2617                {
2618                        if(channelfind == 0)
2619                                ostrcatbig(&buf, "<option selected value=\"", &maxlen, &pos);
2620                        else
2621                                ostrcatbig(&buf, "<option value=\"", &maxlen, &pos);
2622                       
2623                        buf1 = oitoa(channel1->serviceid);
2624                        ostrcatbig(&buf, buf1, &maxlen, &pos);
2625                        free(buf1); buf1 = NULL;
2626                        ostrcatbig(&buf, "&tid=", &maxlen, &pos);
2627                        buf1 = ollutoa(channel1->transponderid);
2628                        ostrcatbig(&buf, buf1, &maxlen, &pos);
2629                        free(buf1); buf1 = NULL;
2630                        ostrcatbig(&buf, "\">", &maxlen, &pos);
2631                       
2632                        ostrcatbig(&buf, channel1->name, &maxlen, &pos);
2633                        ostrcatbig(&buf, " (", &maxlen, &pos);
2634                       
2635                        //get satname from channel
2636                        if(channel1->transponder != NULL)
2637                        {
2638                                struct sat* snode = getsatbyorbitalpos(channel1->transponder->orbitalpos);
2639                                if(snode != NULL)
2640                                        ostrcatbig(&buf, snode->name, &maxlen, &pos);
2641                                else
2642                                        ostrcatbig(&buf, _("unknown"), &maxlen, &pos);
2643                                       
2644                                if(channel1->provider != NULL)
2645                                        ostrcatbig(&buf, " - ", &maxlen, &pos);                 
2646                        }
2647                       
2648                        //get provider from channel
2649                        if(channel1->provider != NULL)
2650                        {
2651                                if(channel1->provider->name != NULL)
2652                                        ostrcatbig(&buf, channel1->provider->name, &maxlen, &pos);
2653                                else
2654                                        ostrcatbig(&buf, _("unknown"), &maxlen, &pos);                 
2655                        }
2656                       
2657                        ostrcatbig(&buf, ")", &maxlen, &pos);   
2658                       
2659                        channelfind++;
2660                }
2661                channel1 = channel1->next;
2662        }
2663        */
2664       
2665        if(channelfind == 0)
2666        {
2667                channel1 = channel;             
2668                while(channel1 != NULL)
2669                {
2670                        if(ostrstrcase(channel1->name, channelname) != NULL && (channel1->servicetype == 0 || channel1->servicetype == 1))
2671                        {
2672                                if(channelfind == 0)
2673                                        ostrcatbig(&buf, "<option selected value=\"", &maxlen, &pos);
2674                                else
2675                                        ostrcatbig(&buf, "<option value=\"", &maxlen, &pos);
2676                               
2677                                buf1 = oitoa(channel1->serviceid);
2678                                ostrcatbig(&buf, buf1, &maxlen, &pos);
2679                                free(buf1); buf1 = NULL;
2680                                ostrcatbig(&buf, "&tid=", &maxlen, &pos);
2681                                buf1 = ollutoa(channel1->transponderid);
2682                                ostrcatbig(&buf, buf1, &maxlen, &pos);
2683                                free(buf1); buf1 = NULL;
2684                                ostrcatbig(&buf, "\">", &maxlen, &pos);
2685                               
2686                                ostrcatbig(&buf, channel1->name, &maxlen, &pos);
2687                                ostrcatbig(&buf, " (", &maxlen, &pos);
2688                               
2689                                //get satname from channel
2690                                if(channel1->transponder != NULL)
2691                                {
2692                                        struct sat* snode = getsatbyorbitalpos(channel1->transponder->orbitalpos);
2693                                        if(snode != NULL)
2694                                                ostrcatbig(&buf, snode->name, &maxlen, &pos);
2695                                        else
2696                                                ostrcatbig(&buf, _("unknown"), &maxlen, &pos);
2697                                               
2698                                        if(channel1->provider != NULL)
2699                                                ostrcatbig(&buf, " - ", &maxlen, &pos);                 
2700                                }
2701                               
2702                                //get provider from channel
2703                                if(channel1->provider != NULL)
2704                                {
2705                                        if(channel1->provider->name != NULL)
2706                                                ostrcatbig(&buf, channel1->provider->name, &maxlen, &pos);
2707                                        else
2708                                                ostrcatbig(&buf, _("unknown"), &maxlen, &pos);                 
2709                                }
2710                               
2711                                ostrcatbig(&buf, ")", &maxlen, &pos);   
2712                               
2713                                channelfind++;
2714                        }
2715                        channel1 = channel1->next;
2716                }
2717        }
2718       
2719        ostrcatbig(&buf, "</td></tr></table><br><br></select><input class=button type=submit name=send value=\"Send\" onClick=\"return checkdaytime(begin.value, end.value)\"></input>&nbsp;<input class=button type=reset name=reset value=\"Reset\"></input></form></center></body></html>", &maxlen, &pos);
2720
2721        if(channelfind < 2)
2722        {
2723                free(buf); buf = NULL;
2724                buf = webrectimersend(param1, fmt);     
2725                free(param1); param1 = NULL;
2726        }
2727
2728        return buf;             
2729}
2730
2731char* webrectimersend(char* param, int fmt)
2732{
2733        char* buf = NULL, *string = NULL, *name = NULL, *begin = NULL, *end = NULL, *type = NULL, *anode = NULL, *channelname = NULL, *sid = NULL, *tid = NULL, *ext = NULL, *afterevent = NULL, *repeat = NULL;
2734        int newnode = 0, channelfind = 0;
2735        struct rectimer *node = NULL;
2736        char* tmpstr = NULL;
2737        struct tm* loctime = NULL;
2738        struct channel *channel1 = NULL;
2739
2740        anode = ostrstr(param, "node=");
2741        if(anode != NULL)
2742                anode = anode + 5;
2743        name = ostrstr(param, "name=");
2744        if(name != NULL)
2745                name = name + 5;
2746        begin = ostrstr(param, "begin=");
2747        if(begin != NULL)
2748                begin = begin + 6;
2749        end = ostrstr(param, "end=");
2750        if(end != NULL)
2751                end = end + 4;
2752        type = ostrstr(param, "type=");
2753        if(type != NULL)
2754                type = type + 5;
2755        channelname = ostrstr(param, "channel=");
2756        if(channelname != NULL)
2757                channelname = channelname + 8;
2758        sid = ostrstr(param, "sid=");
2759        if(sid != NULL)
2760                sid = sid + 4;
2761        tid = ostrstr(param, "tid=");
2762        if(tid != NULL)
2763                tid = tid + 4;
2764        ext = ostrstr(param, "ext=");
2765        if(ext != NULL)
2766                ext = ext + 4;
2767        afterevent = ostrstr(param, "afterevent=");
2768        if(afterevent != NULL)
2769                afterevent = afterevent + 11;
2770        repeat = ostrstr(param, "repeat=");
2771        if(repeat != NULL)
2772                repeat = repeat + 7;
2773       
2774        string = param;
2775        while(string != NULL)
2776        {       
2777                string = strchr(string, '&');
2778                if(string != NULL)
2779                        *string++ = '\0';
2780        }
2781       
2782        if((sid == NULL && tid != NULL) || (sid != NULL && tid == NULL))
2783        {
2784                buf = ostrcat(buf, "ERROR: sid and tid required or only channel", 1, 0);       
2785                return buf;
2786        }
2787               
2788        if(channelname != NULL && sid == NULL)
2789        {
2790                channelfind = 0;
2791                channel1 = channel;
2792                while(channel1 != NULL)
2793                {
2794                        if(ostrcmp(channel1->name, channelname) == 0 && (channel1->servicetype == 0 || channel1->servicetype == 1))
2795                        {
2796                                        channelfind = 1;
2797                                        break;
2798                        }
2799                        channel1 = channel1->next;
2800                }
2801                if(channelfind == 0)
2802                {
2803                        channel1 = channel;             
2804                        while(channel1 != NULL)
2805                        {
2806                                if(ostrstr(channel1->name, channelname) != NULL && (channel1->servicetype == 0 || channel1->servicetype == 1))
2807                                {
2808                                                channelfind = 1;
2809                                                break;
2810                                }
2811                                channel1 = channel1->next;
2812                        }
2813                }
2814                if(channelfind == 0)
2815                {
2816                        buf = ostrcat(buf, "ERROR: channel not found", 1, 0);   
2817                        return buf;
2818                }
2819        }
2820       
2821        newnode = 0;
2822        node = getrectimerbytimestamp(anode);
2823        if(node == NULL)
2824        {
2825                node = addrectimernode(NULL, NULL);
2826                if(node != NULL)
2827                {
2828                        newnode = 1;
2829                        node->pincode = ostrcat("0000", NULL, 0, 0);
2830                        node->recpath = ostrcat(NULL, getconfig("rec_path", NULL), 0, 0);
2831                        node->afterevent = 0;
2832                        node->repeate = 0;
2833                }
2834        }
2835       
2836        if(node != NULL)
2837        {
2838                if(channelfind == 1 && channel1 != NULL)
2839                {
2840                        node->serviceid = channel1->serviceid;
2841                        node->servicetype = channel1->servicetype;
2842                        node->transponderid = channel1->transponderid;
2843                }
2844       
2845                if(sid != NULL && tid != NULL)
2846                {
2847                        node->serviceid = atoi(sid);
2848                        node->transponderid = strtoull(tid, NULL, 10);
2849                        node->servicetype = 0;
2850                }
2851       
2852                free(node->name); node->name = NULL;
2853                node->name = ostrcat(name, NULL, 0, 0);
2854       
2855                if(ostrcmp(type, "record") == 0)
2856                        node->justplay = 0;
2857                else
2858                        node->justplay = 1;
2859                       
2860                if(afterevent != NULL)
2861                {
2862                        if(ostrcmp(afterevent, "auto") == 0)
2863                                node->afterevent = 0;
2864                        else if(ostrcmp(afterevent, "nothing") == 0)
2865                                node->afterevent = 1;
2866                        else if(ostrcmp(afterevent, "standby") == 0)
2867                                node->afterevent = 2;
2868                        else if(ostrcmp(afterevent, "off") == 0)
2869                                node->afterevent = 3;
2870                }
2871
2872                if(repeat != NULL)
2873                        node->repeate = atoi(repeat);
2874       
2875                loctime = olocaltime(&node->begin);
2876                if(loctime != NULL && begin != NULL)
2877                {
2878                        tmpstr = strptime(begin, "%H:%M %d-%m-%Y", loctime);
2879                        if(tmpstr != NULL) {
2880                                loctime->tm_isdst = -1;
2881                                node->begin = mktime(loctime);
2882                        }
2883                }
2884                if(node->justplay == 0 && newnode == 1) node->begin -= getconfigint("recforerun" , NULL) * 60;
2885                node->begin -= (node->begin % 60);
2886                tmpstr = NULL;
2887                free(loctime); loctime = NULL;
2888
2889                loctime = olocaltime(&node->end);
2890                if(loctime != NULL && end != NULL)
2891                {
2892                        tmpstr = strptime(end, "%H:%M %d-%m-%Y", loctime);
2893                        if(tmpstr != NULL) {
2894                                loctime->tm_isdst = -1;
2895                                node->end = mktime(loctime);
2896                        }
2897                }
2898                if(node->justplay == 0 && newnode == 1) node->end += getconfigint("recoverrun" , NULL) * 60;
2899                node->end -= (node->end % 60);
2900                tmpstr = NULL;
2901                free(loctime); loctime = NULL;
2902
2903                if(newnode == 1)
2904                        node->disabled = 0;
2905       
2906                status.writerectimer = 1;
2907                writerectimer(getconfig("rectimerfile", NULL), 0);
2908               
2909                if(ext == NULL)
2910                        buf = webgetrectimer(NULL, 0, fmt);
2911                else
2912                {
2913                        buf = ostrcat(buf, "ok -> TimerID=", 1, 0);
2914                        buf = ostrcat(buf, node->timestamp, 1, 0);
2915                }
2916        }
2917        else
2918                buf = ostrcat(buf, "Timer not ok", 1, 0);
2919
2920        return buf;
2921}
2922
2923char* webeditrectimer(char* param, int fmt)
2924{
2925        char* buf = NULL, *buf1 = NULL, *buf2 = NULL;
2926        int maxlen = 0, pos = 0;
2927        struct rectimer *node = NULL;
2928        struct tm* loctime = NULL;
2929
2930        node = getrectimerbytimestamp(param);
2931        if(node == NULL) return NULL;
2932               
2933        ostrcatbig(&buf, "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"><link rel=\"stylesheet\" type=\"text/css\" href=\"titan.css\"></head>", &maxlen, &pos);
2934        ostrcatbig(&buf, "<body class=body ><center>", &maxlen, &pos);
2935        ostrcatbig(&buf, "<form name=F1 action=query method=get><br><br>", &maxlen, &pos);
2936        ostrcatbig(&buf, "<input type=\"hidden\" name=\"rectimersend&node\" value=\"", &maxlen, &pos);
2937        ostrcatbig(&buf, node->timestamp, &maxlen, &pos);
2938        ostrcatbig(&buf, "\">", &maxlen, &pos);
2939        ostrcatbig(&buf, "<table border=\"0\"><tr>", &maxlen, &pos);
2940        ostrcatbig(&buf, "<td><font class=label>Name:&nbsp;</font></td>", &maxlen, &pos);
2941        ostrcatbig(&buf, "<td><input class=inputbox type=\"text\" name=\"name\" value=\"", &maxlen, &pos);
2942        ostrcatbig(&buf, node->name, &maxlen, &pos);
2943        ostrcatbig(&buf, "\" /></td></tr>", &maxlen, &pos);
2944
2945        ostrcatbig(&buf, "<td><font class=label>Type:&nbsp;</font></td>", &maxlen, &pos);
2946        ostrcatbig(&buf, "<td><select name=\"type\" border=0><option selected>", &maxlen, &pos);
2947        if( node->justplay == 0 )
2948                ostrcatbig(&buf, "record", &maxlen, &pos);
2949        else
2950                ostrcatbig(&buf, "switch channel", &maxlen, &pos);
2951        ostrcatbig(&buf, "<option>record<option>switch channel</select></td></tr>", &maxlen, &pos);
2952       
2953        /*ostrcatbig(&buf, "<td><font class=label>Repeate:&nbsp;</font></td>", &maxlen, &pos);
2954        ostrcatbig(&buf, "<td><select name=\"repeate\" border=0><option selected>", &maxlen, &pos);
2955        if( node->repeate == 0 )
2956                ostrcatbig(&buf, "once", &maxlen, &pos);
2957        else
2958                ostrcatbig(&buf, "repeate", &maxlen, &pos);
2959        ostrcatbig(&buf, "<option>once<option>repeate</select></td></tr>", &maxlen, &pos);     
2960        */
2961       
2962        /*ostrcatbig(&buf, "<td><font class=label>Repeate type:&nbsp;</font></td>", &maxlen, &pos);
2963        ostrcatbig(&buf, "<td><select name=\"repeatetype\" border=0><option selected>", &maxlen, &pos);
2964        if( node->repeate == 0 )
2965                ostrcatbig(&buf, "daily", &maxlen, &pos);
2966        else if( node->repeate == 1 )
2967                ostrcatbig(&buf, "weekly", &maxlen, &pos);
2968        else if( node->repeate == 2 )
2969                ostrcatbig(&buf, "workdays", &maxlen, &pos);
2970        else
2971                ostrcatbig(&buf, "user defined", &maxlen, &pos);
2972        ostrcatbig(&buf, "<option>daily<option>weekly<option>workdays<option>user defined</select></td></tr>", &maxlen, &pos); 
2973        */
2974               
2975        buf2 = malloc(20);
2976        loctime = olocaltime(&node->begin);
2977        if(loctime != NULL && buf2 != NULL)
2978                strftime(buf2, 20, "%H:%M %d-%m-%Y", loctime);
2979        free(loctime); loctime = NULL;
2980
2981        buf1 = ostrcat(buf2, NULL, 0, 0);
2982        ostrcatbig(&buf, "<td><font class=label>Begin:&nbsp;</font></td>", &maxlen, &pos);
2983        ostrcatbig(&buf, "<td><input class=inputbox type=\"text\" name=\"begin\" value=\"", &maxlen, &pos);
2984        ostrcatbig(&buf, buf1, &maxlen, &pos);
2985        ostrcatbig(&buf, "\" /></td></tr>", &maxlen, &pos);
2986        free(buf1); buf1 = NULL;
2987       
2988        loctime = olocaltime(&node->end);
2989        if(loctime != NULL && buf2 != NULL)
2990                strftime(buf2, 20, "%H:%M %d-%m-%Y", loctime);
2991        free(loctime); loctime = NULL;
2992
2993        buf1 = ostrcat(buf2, NULL, 0, 0);
2994        ostrcatbig(&buf, "<td><font class=label>End:&nbsp;</font></td>", &maxlen, &pos);
2995        ostrcatbig(&buf, "<td><input class=inputbox type=\"text\" name=\"end\" value=\"", &maxlen, &pos);
2996        ostrcatbig(&buf, buf1, &maxlen, &pos);
2997        ostrcatbig(&buf, "\" /></td></tr>", &maxlen, &pos);
2998        free(buf1); buf1 = NULL;
2999        free(buf2); buf2 = NULL;
3000       
3001        ostrcatbig(&buf, "<td><font class=label>after event:&nbsp;</font></td>", &maxlen, &pos);
3002        ostrcatbig(&buf, "<td><select name=\"afterevent\" border=0><option selected>", &maxlen, &pos);
3003        if( node->afterevent == 0 )
3004                ostrcatbig(&buf, "auto", &maxlen, &pos);
3005        else if( node->afterevent == 1 )
3006                ostrcatbig(&buf, "nothing", &maxlen, &pos);
3007        else if( node->afterevent == 2 )
3008                ostrcatbig(&buf, "standby", &maxlen, &pos);
3009        else if( node->afterevent == 3 )
3010                ostrcatbig(&buf, "off", &maxlen, &pos);
3011        else
3012                ostrcatbig(&buf, "auto", &maxlen, &pos);
3013        ostrcatbig(&buf, "<option>auto<option>nothing<option>standby<option>off</select></td></tr>", &maxlen, &pos);
3014       
3015        ostrcatbig(&buf, "</table><br><br><input class=button type=submit name=send value=\"Send\" onClick=\"return checkdaytime(begin.value, end.value)\"></input>&nbsp;<input class=button type=reset name=reset value=\"Reset\"></input></form></center></body></html>", &maxlen, &pos);
3016       
3017        //ostrcatbig(&buf, param, &maxlen, &pos);
3018        return buf;
3019}
3020
3021char* webdelrectimer(char* param, int fmt)
3022{
3023        char* buf = NULL, *string = NULL, *timerid = NULL;
3024        struct rectimer *node = NULL;
3025        int ext = 0;
3026       
3027        timerid = ostrstr(param, "timerid=");
3028        if(timerid != NULL)
3029        {
3030                timerid = timerid + 8;
3031                ext = 1;
3032        }
3033
3034        node = NULL;
3035        if(ext == 1)
3036        {
3037                string = param;
3038                while(string != NULL)
3039                {       
3040                        string = strchr(string, '&');
3041                        if(string != NULL)
3042                                *string++ = '\0';
3043                }
3044                node = getrectimerbytimestamp(timerid);
3045        }
3046        else
3047                node = getrectimerbytimestamp(param);
3048
3049        if(node == NULL)
3050        {
3051                buf = ostrcat(buf, "ERROR: timer not found", 1, 0);     
3052                return buf;
3053        }
3054       
3055        delrectimer(node, 1, 0);
3056       
3057        if(ext == 1)
3058                buf = ostrcat(buf, "ok -> timer deleted", 1, 0);
3059        else
3060                buf = webgetrectimer(NULL, 0, fmt);
3061       
3062        return buf;
3063}
3064
3065void putxmessage(struct stimerthread* timernode, char* captiontime, char* body)
3066{
3067        struct splitstr* ret1 = NULL;
3068        char* caption = NULL;
3069        int count1 = 0;
3070        int timeout = 5;
3071
3072        ret1 = strsplit(captiontime, "\t", &count1);
3073
3074        if(count1 >= 2)
3075        {
3076                caption = ostrcat(caption, (&ret1[0])->part, 1, 0);
3077                if((&ret1[1])->part != NULL)
3078                        timeout = atoi((&ret1[1])->part);
3079                textbox(caption, body, _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 280, timeout, 0);
3080        }
3081
3082        free(caption); free(body); free(captiontime); free(ret1);
3083}
3084
3085void xmessage(char* filename)
3086{
3087        char* param=NULL, *param1 = NULL, *param2 = NULL, *param3 = NULL, *param4 = NULL;
3088        char* caption=NULL, *body=NULL;
3089        char* timeout=NULL;
3090
3091        param4 = ostrstr(filename, "icon=");
3092        param3 = ostrstr(filename, "charset=");
3093        param2 = ostrstr(filename, "timeout=");
3094        param1 = ostrstr(filename, "caption=");
3095        param = ostrstr(filename, "body=");
3096
3097        if(param4 != NULL)
3098        {
3099                param4 = param4 - 1;
3100                *param4 = '\0';
3101                param4 = param4 + 5;
3102                *param4++ = '\0';
3103        }
3104        if(param3 != NULL)
3105        {
3106                param3 = param3 - 1;
3107                *param3 = '\0';
3108                param3 = param3 + 8;
3109                *param3++ = '\0';
3110        }
3111        if(param2 != NULL)
3112        {
3113                param2 = param2 - 1;
3114                *param2 = '\0';
3115                param2 = param2 + 8;
3116                *param2++ = '\0';
3117        }
3118        if(param1 != NULL)
3119        {
3120                param1 = param1 - 1;
3121                *param1 = '\0';
3122                param1 = param1 + 8;
3123                *param1++ = '\0';
3124        }
3125        if(param != NULL)
3126        {
3127                param = param - 1;
3128                *param = '\0';
3129                param = param + 5;
3130                *param++ = '\0';
3131                body = ostrcat(body, param, 1, 0);
3132        }
3133        else
3134                body = ostrcat(body, " ", 1, 0);
3135               
3136        if(param2 != NULL)
3137                timeout = ostrcat(timeout, param2, 1, 0);
3138        else
3139                timeout = ostrcat(timeout, "5", 1, 0);
3140               
3141        if(param1 != NULL)
3142                caption = ostrcat(caption, param1, 1, 0);
3143        else
3144                caption = ostrcat(caption, "XMESSAGE", 1, 0);
3145       
3146        caption = ostrcat(caption, "\t", 1, 0);
3147        caption = ostrcat(caption, timeout, 1, 1);
3148               
3149        addtimer(&putxmessage, START, 1000, 1, (void*)caption, (void*)body, NULL);
3150        return;
3151}
3152
3153char* webgetvol(int fmt)
3154{
3155        char* buf = NULL;
3156
3157        buf = oitoa(getvol());
3158        return buf;
3159}
3160
3161char* webgetrecsteampath(int fmt)
3162{
3163        char* buf = NULL;
3164       
3165        if(getconfig("rec_streampath", NULL) == NULL)
3166                buf = ostrcat(buf, "/var/media/hdd/movie", 1, 0);
3167        else
3168                buf = ostrcat(buf, getconfig("rec_streampath", NULL), 1, 0);
3169
3170        return buf;
3171}
3172
3173char* webgetmute(int fmt)
3174{
3175        char* buf = NULL;
3176
3177        buf = oitoa(status.mute);
3178        return buf;
3179}
3180
3181char* webgetrccodes(int fmt)
3182{
3183        int i = 0;
3184        char* buf = NULL;
3185        struct clist* node = NULL;
3186
3187        m_lock(&status.clistmutex, 12);
3188        struct clist **clist = rcconfig;
3189
3190        for(i = 0; i < LISTHASHSIZE; i++)
3191        {
3192                node = clist[i];
3193
3194                while(node != NULL)
3195                {
3196                        buf = ostrcat(buf, node->key, 1, 0);
3197                        buf = ostrcat(buf, "#", 1, 0);
3198                        buf = ostrcat(buf, node->value, 1, 0);
3199                        buf = ostrcat(buf, "\n", 1, 0);
3200                        node = node->next;
3201                }
3202        }
3203
3204        m_unlock(&status.clistmutex, 12);
3205        return buf;
3206}
3207
3208char* webgetconfig(int fmt)
3209{
3210        char* buf = NULL;
3211        struct clist *node = NULL;
3212        int i = 0;
3213
3214        m_lock(&status.clistmutex, 12);
3215        if(fmt == 0)
3216        {
3217                buf = ostrcat(buf, "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">", 1, 0);
3218                buf = ostrcat(buf, "<link rel=stylesheet type=text/css href=titan.css><script type=text/javascript src=titan.js></script>", 1, 0);
3219                buf = ostrcat(buf, "</head><body class=body id=\"configinfo\">", 1, 0);
3220        }
3221                                                       
3222        struct clist **clist = config;
3223
3224        for(i = 0; i < LISTHASHSIZE; i++)
3225        {
3226                node = clist[i];
3227
3228                while(node != NULL)
3229                {
3230                        if(node->tmp != NULL && strlen(node->tmp) > 0)
3231                        {
3232                                buf = ostrcat(buf, node->key, 1, 0);
3233                                buf = ostrcat(buf, "#", 1, 0);
3234                                buf = ostrcat(buf, node->tmp, 1, 0);
3235                                buf = ostrcat(buf, "\n", 1, 0);
3236                        }
3237                        else if(node->value != NULL)
3238                        {
3239                                buf = ostrcat(buf, node->key, 1, 0);
3240                                buf = ostrcat(buf, "#", 1, 0);
3241                                buf = ostrcat(buf, node->value, 1, 0);
3242                                buf = ostrcat(buf, "\n", 1, 0);
3243                        }
3244                        else
3245                        {
3246                                buf = ostrcat(buf, node->key, 1, 0);
3247                                buf = ostrcat(buf, "#", 1, 0);
3248                                buf = ostrcat(buf, node->def, 1, 0);
3249                                buf = ostrcat(buf, "\n", 1, 0);
3250                        }
3251
3252                        node = node->next;
3253                }
3254        }
3255
3256        buf = string_replace_all("\n", "<br>\n", buf, 1);
3257
3258        if(fmt == 0)
3259        {
3260                buf = ostrcat(buf, "</body></html>", 1, 0);
3261        }
3262       
3263        m_unlock(&status.clistmutex, 12);
3264        return buf;
3265}
3266
3267char* webgetsysteminfo(int fmt)
3268{
3269        char* buf = NULL;
3270        char* imgversion = NULL;
3271
3272        if(fmt == 0)
3273        {
3274                buf = ostrcat(buf, "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">", 1, 0);
3275                buf = ostrcat(buf, "<link rel=stylesheet type=text/css href=titan.css><script type=text/javascript src=titan.js></script>", 1, 0);
3276                buf = ostrcat(buf, "</head><body class=body id=\"systeminfo\">", 1, 0);
3277        }
3278
3279        buf = ostrcat(buf, PROGNAME, 1, 0);
3280        buf = ostrcat(buf, "#", 1, 0);
3281        buf = ostrcat(buf, COPYRIGHT, 1, 0);
3282        buf = ostrcat(buf, "#", 1, 0);
3283        buf = ostrcat(buf, OVERSION, 1, 0);
3284        buf = ostrcat(buf, "#", 1, 0);
3285       
3286        if(isfile(getconfig("imagenamefile", NULL))     != 0)
3287                imgversion = readsys(getconfig("imagenamefile", NULL), 1);
3288        else
3289                imgversion = ostrcat("unknown", NULL, 0, 0);
3290       
3291        buf = ostrcat(buf, imgversion, 1, 1);
3292        buf = ostrcat(buf, "#", 1, 0);
3293        buf = ostrcat(buf, getboxtype(), 1, 0);
3294        buf = ostrcat(buf, "#", 1, 0);
3295        buf = ostrcat(buf, ollutoa(time(NULL)), 1, 1);
3296        buf = ostrcat(buf, "#", 1, 0);
3297
3298        if(status.standby == 0)
3299                buf = ostrcat(buf, "0", 1, 0);
3300        else
3301                buf = ostrcat(buf, "1", 1, 0);
3302
3303        if(fmt == 0)
3304        {
3305                buf = ostrcat(buf, "</body></html>", 1, 0);
3306        }       
3307       
3308        return buf;
3309}
3310
3311char* webgetchannellock(char* param, int fmt)
3312{
3313        char* buf = NULL, *param1 = NULL;
3314        struct channel* chnode = NULL;
3315
3316        if(param == NULL) return NULL;
3317
3318        //create param1
3319        param1 = strchr(param, '&');
3320        if(param1 != NULL)
3321                *param1++ = '\0';
3322
3323        if(param1 == NULL) return NULL;
3324
3325        chnode = getchannel(atoi(param), strtoull(param1, NULL, 10));
3326        if(chnode != NULL)
3327        {
3328                buf = ostrcat(buf, chnode->name, 1, 0);
3329                buf = ostrcat(buf, "#", 1, 0);
3330                buf = ostrcat(buf, oitoa(chnode->serviceid), 1, 1);
3331                buf = ostrcat(buf, "#", 1, 0);
3332                buf = ostrcat(buf, ollutoa(chnode->transponderid), 1, 1);
3333                buf = ostrcat(buf, "#", 1, 0);
3334
3335                if(channelnottunable(chnode) == 1)
3336                        buf = ostrcat(buf, "1", 1, 0);
3337                else
3338                        buf = ostrcat(buf, "0", 1, 0);
3339        }
3340        else
3341                buf = ostrcat("no data", NULL, 0, 0);
3342
3343        return buf;
3344}
3345
3346char* webgetbouquetepg(char* param, int fmt)
3347{
3348        char* buf = NULL, *tmpstr = NULL, *tmpstr1 = NULL;
3349        char* param1 = NULL, *param2 = NULL, *param3 = NULL;
3350        struct mainbouquet *mbouquet = NULL;
3351        struct bouquet *node = NULL;
3352        struct channel* chnode = NULL;
3353        struct epg* epgnode = NULL;
3354        int longepg = 0;
3355        time_t start = 0, end = 0;
3356
3357        if(param == NULL) return NULL;
3358
3359        //create param1 + 2 + 3
3360        param1 = strchr(param, '&');
3361        if(param1 != NULL)
3362        {
3363                *param1++ = '\0';
3364                param2 = strchr(param1, '&');
3365                if(param2 != NULL)
3366                {
3367                        *param2++ = '\0';
3368                        param3 = strchr(param2, '&');
3369                        if(param3 != NULL)
3370                                *param3++ = '\0';
3371                }
3372        }
3373        if(param1 == NULL || param2 == NULL || param3 == NULL) return NULL;
3374
3375        longepg = atoi(param1);
3376        start = atoi(param2);
3377        end = atoi(param3);
3378
3379        mbouquet = getmainbouquet(param);
3380        if(mbouquet != NULL)
3381        {
3382                node = mbouquet->bouquet;
3383                tmpstr = ostrcat(tmpstr, "(BOUQUET)-", 1, 0);
3384                tmpstr = ostrcat(tmpstr, mbouquet->name, 1, 0);
3385                tmpstr1 = htmlencode(tmpstr);
3386                free(tmpstr); tmpstr = NULL;
3387                while(node != NULL)
3388                {
3389                        chnode = getchannel(node->serviceid, node->transponderid);
3390                        if(chnode != NULL)
3391                        {
3392                                buf = ostrcat(buf, "BeginNewChannel", 1, 0);
3393                                buf = ostrcat(buf, "#", 1, 0);
3394                                buf = ostrcat(buf, chnode->name, 1, 0);
3395                                buf = ostrcat(buf, "#", 1, 0);
3396                                buf = ostrcat(buf, oitoa(chnode->serviceid), 1, 1);
3397                                buf = ostrcat(buf, "#", 1, 0);
3398                                buf = ostrcat(buf, ollutoa(chnode->transponderid), 1, 1);
3399                                buf = ostrcat(buf, "#", 1, 0);
3400                                buf = ostrcat(buf, oitoa(chnode->servicetype), 1, 1);
3401                                buf = ostrcat(buf, "\n", 1, 0);
3402
3403                                epgnode = chnode->epg;
3404                                while(epgnode != NULL)
3405                                {
3406                                        if((epgnode->starttime >= start && epgnode->starttime < end) || (epgnode->endtime > start && epgnode->endtime <= end) || (epgnode->starttime < start && epgnode->endtime > end))
3407                                        {
3408                                                buf = ostrcat(buf, epgnode->title, 1, 0);
3409                                                buf = ostrcat(buf, "#", 1, 0);
3410                                                buf = ostrcat(buf, olutoa(epgnode->starttime), 1, 1);
3411                                                buf = ostrcat(buf, "#", 1, 0);
3412                                                buf = ostrcat(buf, olutoa(epgnode->endtime), 1, 1);
3413                                                buf = ostrcat(buf, "#", 1, 0);
3414                                                buf = ostrcat(buf, epgnode->subtitle, 1, 0);
3415                                                buf = ostrcat(buf, "#", 1, 0);
3416
3417                                                if(longepg == 1)
3418                                                {
3419                                                        tmpstr = epgdescunzip(epgnode);
3420                                                        if(tmpstr != NULL)
3421                                                                buf = ostrcat(buf, tmpstr, 1, 0);
3422                                                        free(tmpstr); tmpstr = NULL;
3423                                                }
3424
3425                                                buf = ostrcat(buf, "#", 1, 0);
3426                                                buf = ostrcat(buf, oitoa(epgnode->eventid), 1, 1);
3427                                                buf = ostrcat(buf, "\n", 1, 0);
3428                                        }
3429
3430                                        epgnode = epgnode->next;
3431                                }
3432                        }
3433                        node = node->next;
3434                }
3435                free(tmpstr1); tmpstr1 = NULL;
3436        }
3437
3438        if(buf == NULL)
3439                buf = ostrcat("no data", NULL, 0, 0);
3440        return buf;
3441}
3442
3443char* webadjust(char* param, int fmt)
3444{
3445printf("webadjust param: %s\n",param);
3446printf("webadjust fmt: %d\n",fmt);
3447
3448        char* buf = NULL, *tmpstr = NULL, *tmpstr1 = NULL, *sendstr = NULL;
3449        int i = 0, max = 0, count = 0, maxlen = 0, pos = 0;
3450
3451       
3452        ostrcatbig(&buf, "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"><link rel=\"stylesheet\" type=\"text/css\" href=\"titan.css\"></head>", &maxlen, &pos);
3453        ostrcatbig(&buf, "<body class=body ><center>", &maxlen, &pos);
3454        ostrcatbig(&buf, "<form name=F1 action=query method=get><br><br>", &maxlen, &pos);
3455        ostrcatbig(&buf, "<input type=\"hidden\" name=\"adjustsend&node\" value=\"", &maxlen, &pos);
3456        ostrcatbig(&buf, "0", &maxlen, &pos);
3457        ostrcatbig(&buf, "\">", &maxlen, &pos);
3458//      ostrcatbig(&buf, "<input type=\"hidden\" name=\"adjustsend\">", &maxlen, &pos);
3459        ostrcatbig(&buf, "<table border=\"0\"><tr>", &maxlen, &pos);
3460
3461        ostrcatbig(&buf, "<table>", &maxlen, &pos);
3462
3463///////////////////
3464//      ostrcatbig(&buf, "<tr><td><font class=\"label\">Volbartimeout:&nbsp;</font></td><td><select name=\"volbartimeout\" border=\"0\"><option value=\"1\" selected>1</option><option value=\"2\">2</option><option value=\"3\">3</option><option value=\"4\">4</option><option value=\"5\">5</option><option value=\"6\">6</option><option value=\"7\">7</option><option value=\"8\">8</option><option value=\"9\">9</option><option value=\"10\">10</option></select></td></tr>", &maxlen, &pos);
3465        max = 10;
3466        ostrcatbig(&buf, "<tr><td><font class=\"label\">", &maxlen, &pos);
3467        ostrcatbig(&buf, _("Volumebar Timeout"), &maxlen, &pos);
3468        ostrcatbig(&buf, "&nbsp;</font></td><td><select name=\"volbartimeout\" border=\"0\">", &maxlen, &pos);
3469        for(i = 1; i <= max; i++)
3470        {
3471                ostrcatbig(&buf, "<option value=\"", &maxlen, &pos);
3472                ostrcatbig(&buf, oitoa(i), &maxlen, &pos);             
3473                if(getconfigint("volbartimeout", NULL) == i)
3474                        ostrcatbig(&buf, "\" selected>", &maxlen, &pos);               
3475                else
3476                        ostrcatbig(&buf, "\">", &maxlen, &pos);
3477                ostrcatbig(&buf, oitoa(i), &maxlen, &pos);
3478                ostrcatbig(&buf, "</option>", &maxlen, &pos);
3479        }
3480        ostrcatbig(&buf,"</select></td></tr>", &maxlen, &pos);
3481        sendstr = ostrcat(sendstr, "volbartimeout.value", 1 , 0);
3482
3483///////////////////
3484//      ostrcatbig(&buf, "<tr><td><font class=\"label\">Infobartimeout:&nbsp;</font></td><td><select name=\"infobartimeout\" border=\"0\"><option value=\"1\" selected>1</option><option value=\"2\">2</option><option value=\"3\">3</option><option value=\"4\">4</option><option value=\"5\">5</option><option value=\"6\">6</option><option value=\"7\">7</option><option value=\"8\">8</option><option value=\"9\">9</option><option value=\"10\">10</option></select></td></tr>", &maxlen, &pos);
3485        max = 10;
3486        ostrcatbig(&buf, "<tr><td><font class=\"label\">", &maxlen, &pos);
3487        ostrcatbig(&buf, _("Infobar Timeout"), &maxlen, &pos);
3488        ostrcatbig(&buf, "&nbsp;</font></td><td><select name=\"infobartimeout\" border=\"0\">", &maxlen, &pos);
3489        for(i = 1; i <= max; i++)
3490        {
3491                ostrcatbig(&buf, "<option value=\"", &maxlen, &pos);
3492                ostrcatbig(&buf, oitoa(i), &maxlen, &pos);     
3493                if(getconfigint("infobartimeout", NULL) == i)
3494                        ostrcatbig(&buf, "\" selected>", &maxlen, &pos);               
3495                else
3496                        ostrcatbig(&buf, "\">", &maxlen, &pos);
3497                ostrcatbig(&buf, oitoa(i), &maxlen, &pos);
3498                ostrcatbig(&buf, "</option>", &maxlen, &pos);
3499        }
3500        ostrcatbig(&buf,"</select></td></tr>", &maxlen, &pos);
3501        sendstr = ostrcat(sendstr, ", infobartimeout.value", 1 , 0);
3502
3503///////////////////
3504//      ostrcatbig(&buf, "<tr><td><font class=\"label\">Infobar Sleep:&nbsp;</font></td><td><select name=\"infobarsleep\" border=\"0\"><option value=\"0\">0</option><option value=\"1\" selected>1</option><option value=\"2\">2</option><option value=\"3\">3</option><option value=\"4\">4</option><option value=\"5\">5</option></select></td></tr>", &maxlen, &pos);
3505        max = 5;
3506        ostrcatbig(&buf, "<tr><td><font class=\"label\">", &maxlen, &pos);
3507        ostrcatbig(&buf, _("Infobar Sleep"), &maxlen, &pos);
3508        ostrcatbig(&buf, "&nbsp;</font></td><td><select name=\"infobarsleep\" border=\"0\">", &maxlen, &pos);
3509        for(i = 0; i <= max; i++)
3510        {
3511                ostrcatbig(&buf, "<option value=\"", &maxlen, &pos);
3512                ostrcatbig(&buf, oitoa(i), &maxlen, &pos);             
3513                if(getconfigint("infobarsleep", NULL) == i)
3514                        ostrcatbig(&buf, "\" selected>", &maxlen, &pos);               
3515                else
3516                        ostrcatbig(&buf, "\">", &maxlen, &pos);
3517                ostrcatbig(&buf, oitoa(i), &maxlen, &pos);
3518                ostrcatbig(&buf, "</option>", &maxlen, &pos);
3519        }
3520        ostrcatbig(&buf,"</select></td></tr>", &maxlen, &pos);
3521        sendstr = ostrcat(sendstr, ", infobarsleep.value", 1 , 0);
3522
3523///////////////////
3524//      ostrcatbig(&buf, "<tr><td><font class=\"label\">Infobar Sleep:&nbsp;</font></td><td><select name=\"infobarsleep\" border=\"0\"><option value=\"0\">0</option><option value=\"1\" selected>1</option><option value=\"2\">2</option><option value=\"3\">3</option><option value=\"4\">4</option><option value=\"5\">5</option></select></td></tr>", &maxlen, &pos);
3525        max = 5;
3526        tmpstr = ostrcat("1\n3\n9\n12\n15\n18\n21\n24\n27\n30", NULL, 0, 0);
3527
3528        ostrcatbig(&buf, "<tr><td><font class=\"label\">", &maxlen, &pos);
3529        ostrcatbig(&buf, _("Spinnerspeed"), &maxlen, &pos);
3530        ostrcatbig(&buf, "&nbsp;</font></td><td><select name=\"spinnerspeed\" border=\"0\">", &maxlen, &pos);
3531
3532        count = 0;
3533        struct splitstr* ret1 = NULL;
3534        ret1 = strsplit(tmpstr, "\n", &count);
3535        max = count - 1;
3536
3537        if(ret1 != NULL)
3538        {
3539                for(i = 0; i <= max; i++)
3540                {
3541                        ostrcatbig(&buf, "<option value=\"", &maxlen, &pos);
3542                        ostrcatbig(&buf, ret1[i].part, &maxlen, &pos);
3543                        tmpstr1 = ostrcat(ret1[i].part, NULL, 0, 0);
3544                        if(getconfigint("spinnerspeed", NULL) == atoi(tmpstr1))
3545                                ostrcatbig(&buf, "\" selected>", &maxlen, &pos);               
3546                        else
3547                                ostrcatbig(&buf, "\">", &maxlen, &pos);
3548                        ostrcatbig(&buf, ret1[i].part, &maxlen, &pos);
3549                        ostrcatbig(&buf, "</option>", &maxlen, &pos);
3550                }
3551        }
3552        ostrcatbig(&buf,"</select></td></tr>", &maxlen, &pos);
3553        sendstr = ostrcat(sendstr, ", spinnerspeed.value", 1 , 0);
3554        free(ret1), ret1 = NULL;
3555        free(tmpstr), tmpstr = NULL;
3556        free(tmpstr1), tmpstr1 = NULL;
3557
3558///////////////////
3559        tmpstr = ostrcat("1\n2\n3\n4\n5\n6\n7\n8\n10000", NULL, 0, 0);
3560
3561        ostrcatbig(&buf, "<tr><td><font class=\"label\">", &maxlen, &pos);
3562        ostrcatbig(&buf, _("Spinnertime"), &maxlen, &pos);
3563        ostrcatbig(&buf, "&nbsp;</font></td><td><select name=\"spinnertime\" border=\"0\">", &maxlen, &pos);
3564
3565        count = 0;
3566        ret1 = strsplit(tmpstr, "\n", &count);
3567        max = count - 1;
3568
3569        if(ret1 != NULL)
3570        {
3571                for(i = 0; i <= max; i++)
3572                {
3573                        ostrcatbig(&buf, "<option value=\"", &maxlen, &pos);
3574                        ostrcatbig(&buf, ret1[i].part, &maxlen, &pos);
3575                        tmpstr1 = ostrcat(ret1[i].part, NULL, 0, 0);
3576                        if(getconfigint("spinnertime", NULL) == atoi(tmpstr1)) 
3577                                ostrcatbig(&buf, "\" selected>", &maxlen, &pos);               
3578                        else
3579                                ostrcatbig(&buf, "\">", &maxlen, &pos);
3580                        ostrcatbig(&buf, ret1[i].part, &maxlen, &pos);
3581                        ostrcatbig(&buf, "</option>", &maxlen, &pos);
3582                }
3583        }
3584        ostrcatbig(&buf,"</select></td></tr>", &maxlen, &pos);
3585        sendstr = ostrcat(sendstr, ", spinnertime.value", 1 , 0);
3586        free(ret1), ret1 = NULL;
3587        free(tmpstr), tmpstr = NULL;
3588        free(tmpstr1), tmpstr1 = NULL;
3589
3590///////////////////
3591        tmpstr = ostrcat("5\n10\n15\n30\n60\n120\n10000", NULL, 0, 0);
3592
3593        ostrcatbig(&buf, "<tr><td><font class=\"label\">", &maxlen, &pos);
3594        ostrcatbig(&buf, _("Hangtime"), &maxlen, &pos);
3595        ostrcatbig(&buf, "&nbsp;</font></td><td><select name=\"hangtime\" border=\"0\">", &maxlen, &pos);
3596
3597        count = 0;
3598        ret1 = strsplit(tmpstr, "\n", &count);
3599        max = count - 1;
3600
3601        if(ret1 != NULL)
3602        {
3603                for(i = 0; i <= max; i++)
3604                {
3605                        ostrcatbig(&buf, "<option value=\"", &maxlen, &pos);
3606                        ostrcatbig(&buf, ret1[i].part, &maxlen, &pos);         
3607                        tmpstr1 = ostrcat(ret1[i].part, NULL, 0, 0);
3608                        if(getconfigint("hangtime", NULL) == atoi(tmpstr1))
3609                                ostrcatbig(&buf, "\" selected>", &maxlen, &pos);               
3610                        else
3611                                ostrcatbig(&buf, "\">", &maxlen, &pos);
3612                        ostrcatbig(&buf, ret1[i].part, &maxlen, &pos);
3613                        ostrcatbig(&buf, "</option>", &maxlen, &pos);
3614                }
3615        }
3616        ostrcatbig(&buf,"</select></td></tr>", &maxlen, &pos);
3617        sendstr = ostrcat(sendstr, ", hangtime.value", 1 , 0);
3618        free(ret1), ret1 = NULL;
3619        free(tmpstr), tmpstr = NULL;
3620        free(tmpstr1), tmpstr1 = NULL;
3621
3622///////////////////
3623//      ostrcatbig(&buf, "<tr><td><font class=\"label\">Second Infobar:&nbsp;</font></td><td><select name=\"secondinfobar\" border=\"0\"><option value=\"0\">no</option><option value=\"1\" selected>infobar</option><option value=\"2\">epg</option><option value=\"3\">channel epg</option></select></td></tr>", &maxlen, &pos);
3624        ostrcatbig(&buf, "<tr><td><font class=\"label\">", &maxlen, &pos);
3625        ostrcatbig(&buf, _("Second Infobar"), &maxlen, &pos);
3626        ostrcatbig(&buf, "&nbsp;</font></td><td><select name=\"secondinfobar\" border=\"0\">", &maxlen, &pos);
3627       
3628        if(getconfigint("secondinfobar", NULL) == 0)
3629                ostrcatbig(&buf, "<option value=\"0\" selected>", &maxlen, &pos);               
3630        else
3631                ostrcatbig(&buf, "<option value=\"0\">", &maxlen, &pos);
3632        ostrcatbig(&buf, _("no"), &maxlen, &pos);
3633        ostrcatbig(&buf, "</option>", &maxlen, &pos);
3634
3635        if(getconfigint("secondinfobar", NULL) == 1)
3636                ostrcatbig(&buf, "<option value=\"1\" selected>", &maxlen, &pos);               
3637        else
3638                ostrcatbig(&buf, "<option value=\"1\">", &maxlen, &pos);
3639        ostrcatbig(&buf, _("infobar"), &maxlen, &pos);
3640        ostrcatbig(&buf, "</option>", &maxlen, &pos);
3641
3642        if(getconfigint("secondinfobar", NULL) == 2)
3643                ostrcatbig(&buf, "<option value=\"2\" selected>", &maxlen, &pos);               
3644        else
3645                ostrcatbig(&buf, "<option value=\"2\">", &maxlen, &pos);
3646        ostrcatbig(&buf, _("epg"), &maxlen, &pos);
3647        ostrcatbig(&buf, "</option>", &maxlen, &pos);
3648
3649        if(getconfigint("secondinfobar", NULL) == 3)
3650                ostrcatbig(&buf, "<option value=\"3\" selected>", &maxlen, &pos);               
3651        else
3652                ostrcatbig(&buf, "<option value=\"3\">", &maxlen, &pos);
3653        ostrcatbig(&buf, _("Channel EPG"), &maxlen, &pos);
3654        ostrcatbig(&buf, "</option>", &maxlen, &pos);
3655       
3656        ostrcatbig(&buf,"</select></td></tr>", &maxlen, &pos);
3657        sendstr = ostrcat(sendstr, ", secondinfobar.value", 1 , 0);
3658
3659///////////////////
3660        if(checkbox("ATEMIO7600") != 1)
3661        {
3662                ostrcatbig(&buf, "<tr><td><font class=\"label\">", &maxlen, &pos);
3663                ostrcatbig(&buf, _("Don't clear TV on zap (only with fastzap)"), &maxlen, &pos);
3664                ostrcatbig(&buf, "&nbsp;</font></td><td><select name=\"nozapclear\" border=\"0\">", &maxlen, &pos);
3665       
3666                if(getconfigint("nozapclear", NULL) == 0)
3667                        ostrcatbig(&buf, "<option value=\"0\" selected>", &maxlen, &pos);               
3668                else
3669                        ostrcatbig(&buf, "<option value=\"0\">", &maxlen, &pos);
3670                ostrcatbig(&buf, _("no"), &maxlen, &pos);
3671                ostrcatbig(&buf, "</option>", &maxlen, &pos);
3672
3673                if(getconfigint("nozapclear", NULL) == 1)
3674                        ostrcatbig(&buf, "<option value=\"1\" selected>", &maxlen, &pos);               
3675                else
3676                        ostrcatbig(&buf, "<option value=\"1\">", &maxlen, &pos);
3677                ostrcatbig(&buf, _("yes"), &maxlen, &pos);
3678                ostrcatbig(&buf, "</option>", &maxlen, &pos);
3679       
3680                ostrcatbig(&buf,"</select></td></tr>", &maxlen, &pos);
3681                sendstr = ostrcat(sendstr, ", nozapclear.value", 1 , 0);
3682        }
3683
3684///////////////////
3685        ostrcatbig(&buf, "<tr><td><font class=\"label\">", &maxlen, &pos);
3686        ostrcatbig(&buf, _("Fastzap"), &maxlen, &pos);
3687        ostrcatbig(&buf, "&nbsp;</font></td><td><select name=\"fastzap\" border=\"0\">", &maxlen, &pos);
3688       
3689        if(getconfigint("fastzap", NULL) == 0)
3690                ostrcatbig(&buf, "<option value=\"0\" selected>", &maxlen, &pos);               
3691        else
3692                ostrcatbig(&buf, "<option value=\"0\">", &maxlen, &pos);
3693        ostrcatbig(&buf, _("no"), &maxlen, &pos);
3694        ostrcatbig(&buf, "</option>", &maxlen, &pos);
3695
3696        if(getconfigint("fastzap", NULL) == 1)
3697                ostrcatbig(&buf, "<option value=\"1\" selected>", &maxlen, &pos);               
3698        else
3699                ostrcatbig(&buf, "<option value=\"1\">", &maxlen, &pos);
3700        ostrcatbig(&buf, _("medium"), &maxlen, &pos);
3701        ostrcatbig(&buf, "</option>", &maxlen, &pos);
3702
3703        if(getconfigint("fastzap", NULL) == 2)
3704                ostrcatbig(&buf, "<option value=\"2\" selected>", &maxlen, &pos);               
3705        else
3706                ostrcatbig(&buf, "<option value=\"2\">", &maxlen, &pos);
3707        ostrcatbig(&buf, _("fast"), &maxlen, &pos);
3708        ostrcatbig(&buf, "</option>", &maxlen, &pos);
3709       
3710        ostrcatbig(&buf,"</select></td></tr>", &maxlen, &pos);
3711        sendstr = ostrcat(sendstr, ", fastzap.value", 1 , 0);
3712
3713///////////////////
3714        ostrcatbig(&buf, "<tr><td><font class=\"label\">", &maxlen, &pos);
3715        ostrcatbig(&buf, _("Faststop"), &maxlen, &pos);
3716        ostrcatbig(&buf, "&nbsp;</font></td><td><select name=\"faststop\" border=\"0\">", &maxlen, &pos);
3717       
3718        if(getconfigint("faststop", NULL) == 0)
3719                ostrcatbig(&buf, "<option value=\"0\" selected>", &maxlen, &pos);               
3720        else
3721                ostrcatbig(&buf, "<option value=\"0\">", &maxlen, &pos);
3722        ostrcatbig(&buf, _("no"), &maxlen, &pos);
3723        ostrcatbig(&buf, "</option>", &maxlen, &pos);
3724
3725        if(getconfigint("faststop", NULL) == 1)
3726                ostrcatbig(&buf, "<option value=\"1\" selected>", &maxlen, &pos);               
3727        else
3728                ostrcatbig(&buf, "<option value=\"1\">", &maxlen, &pos);
3729        ostrcatbig(&buf, _("yes"), &maxlen, &pos);
3730        ostrcatbig(&buf, "</option>", &maxlen, &pos);
3731       
3732        ostrcatbig(&buf,"</select></td></tr>", &maxlen, &pos);
3733        sendstr = ostrcat(sendstr, ", faststop.value", 1 , 0);
3734
3735///////////////////
3736        ostrcatbig(&buf, "<tr><td><font class=\"label\">", &maxlen, &pos);
3737        ostrcatbig(&buf, _("Dirsort"), &maxlen, &pos);
3738        ostrcatbig(&buf, "&nbsp;</font></td><td><select name=\"dirsort\" border=\"0\">", &maxlen, &pos);
3739       
3740        if(getconfigint("dirsort", NULL) == 0)
3741                ostrcatbig(&buf, "<option value=\"0\" selected>", &maxlen, &pos);               
3742        else
3743                ostrcatbig(&buf, "<option value=\"0\">", &maxlen, &pos);
3744        ostrcatbig(&buf, _("alpha"), &maxlen, &pos);
3745        ostrcatbig(&buf, "</option>", &maxlen, &pos);
3746
3747        if(getconfigint("dirsort", NULL) == 1)
3748                ostrcatbig(&buf, "<option value=\"1\" selected>", &maxlen, &pos);               
3749        else
3750                ostrcatbig(&buf, "<option value=\"1\">", &maxlen, &pos);
3751        ostrcatbig(&buf, _("reverse alpha"), &maxlen, &pos);
3752        ostrcatbig(&buf, "</option>", &maxlen, &pos);
3753
3754        if(getconfigint("dirsort", NULL) == 2)
3755                ostrcatbig(&buf, "<option value=\"2\" selected>", &maxlen, &pos);               
3756        else
3757                ostrcatbig(&buf, "<option value=\"2\">", &maxlen, &pos);
3758        ostrcatbig(&buf, _("size"), &maxlen, &pos);
3759        ostrcatbig(&buf, "</option>", &maxlen, &pos);
3760
3761        if(getconfigint("dirsort", NULL) == 3)
3762                ostrcatbig(&buf, "<option value=\"3\" selected>", &maxlen, &pos);               
3763        else
3764                ostrcatbig(&buf, "<option value=\"3\">", &maxlen, &pos);
3765        ostrcatbig(&buf, _("reverse size"), &maxlen, &pos);
3766        ostrcatbig(&buf, "</option>", &maxlen, &pos);
3767
3768        if(getconfigint("dirsort", NULL) == 4)
3769                ostrcatbig(&buf, "<option value=\"4\" selected>", &maxlen, &pos);               
3770        else
3771                ostrcatbig(&buf, "<option value=\"4\">", &maxlen, &pos);
3772        ostrcatbig(&buf, _("date"), &maxlen, &pos);
3773        ostrcatbig(&buf, "</option>", &maxlen, &pos);   
3774
3775        if(getconfigint("dirsort", NULL) == 5)
3776                ostrcatbig(&buf, "<option value=\"5\" selected>", &maxlen, &pos);               
3777        else
3778                ostrcatbig(&buf, "<option value=\"5\">", &maxlen, &pos);
3779        ostrcatbig(&buf, _("reverse date"), &maxlen, &pos);
3780        ostrcatbig(&buf, "</option>", &maxlen, &pos);
3781       
3782        ostrcatbig(&buf,"</select></td></tr>", &maxlen, &pos);
3783        sendstr = ostrcat(sendstr, ", dirsort.value", 1 , 0);
3784
3785///////////////////
3786        ostrcatbig(&buf, "<tr><td><font class=\"label\">", &maxlen, &pos);
3787        ostrcatbig(&buf, _("Power aktion"), &maxlen, &pos);
3788        ostrcatbig(&buf, "&nbsp;</font></td><td><select name=\"poweraktion\" border=\"0\">", &maxlen, &pos);
3789       
3790        if(getconfigint("poweraktion", NULL) == 0)
3791                ostrcatbig(&buf, "<option value=\"0\" selected>", &maxlen, &pos);               
3792        else
3793                ostrcatbig(&buf, "<option value=\"0\">", &maxlen, &pos);
3794        ostrcatbig(&buf, _("Power Menu"), &maxlen, &pos);
3795        ostrcatbig(&buf, "</option>", &maxlen, &pos);
3796
3797        if(getconfigint("poweraktion", NULL) == 1)
3798                ostrcatbig(&buf, "<option value=\"1\" selected>", &maxlen, &pos);               
3799        else
3800                ostrcatbig(&buf, "<option value=\"1\">", &maxlen, &pos);
3801        ostrcatbig(&buf, _("Power Off"), &maxlen, &pos);
3802        ostrcatbig(&buf, "</option>", &maxlen, &pos);
3803
3804        if(getconfigint("poweraktion", NULL) == 2)
3805                ostrcatbig(&buf, "<option value=\"2\" selected>", &maxlen, &pos);               
3806        else
3807                ostrcatbig(&buf, "<option value=\"2\">", &maxlen, &pos);
3808        ostrcatbig(&buf, _("Standby"), &maxlen, &pos);
3809        ostrcatbig(&buf, "</option>", &maxlen, &pos);
3810
3811        if(getconfigint("poweraktion", NULL) == 3)
3812                ostrcatbig(&buf, "<option value=\"3\" selected>", &maxlen, &pos);               
3813        else
3814                ostrcatbig(&buf, "<option value=\"3\">", &maxlen, &pos);
3815        ostrcatbig(&buf, _("Restart"), &maxlen, &pos);
3816        ostrcatbig(&buf, "</option>", &maxlen, &pos);
3817
3818        if(getconfigint("poweraktion", NULL) == 4)
3819                ostrcatbig(&buf, "<option value=\"4\" selected>", &maxlen, &pos);               
3820        else
3821                ostrcatbig(&buf, "<option value=\"4\">", &maxlen, &pos);
3822        ostrcatbig(&buf, _("Gui Restart"), &maxlen, &pos);
3823        ostrcatbig(&buf, "</option>", &maxlen, &pos);   
3824       
3825        ostrcatbig(&buf,"</select></td></tr>", &maxlen, &pos);
3826        sendstr = ostrcat(sendstr, ", poweraktion.value", 1 , 0);
3827
3828///////////////////
3829        ostrcatbig(&buf, "<tr><td><font class=\"label\">", &maxlen, &pos);
3830        ostrcatbig(&buf, _("Virtualzap Timeout"), &maxlen, &pos);
3831        ostrcatbig(&buf, "&nbsp;</font></td><td><select name=\"virtualzap\" border=\"0\">", &maxlen, &pos);
3832       
3833        if(getconfigint("virtualzap", NULL) == 0)
3834                ostrcatbig(&buf, "<option value=\"0\" selected>", &maxlen, &pos);               
3835        else
3836                ostrcatbig(&buf, "<option value=\"0\">", &maxlen, &pos);
3837        ostrcatbig(&buf, _("deaktiv"), &maxlen, &pos);
3838        ostrcatbig(&buf, "</option>", &maxlen, &pos);
3839
3840        if(getconfigint("virtualzap", NULL) == 1)
3841                ostrcatbig(&buf, "<option value=\"1\" selected>", &maxlen, &pos);               
3842        else
3843                ostrcatbig(&buf, "<option value=\"1\">", &maxlen, &pos);
3844        ostrcatbig(&buf, _("1 sec"), &maxlen, &pos);
3845        ostrcatbig(&buf, "</option>", &maxlen, &pos);
3846
3847        if(getconfigint("virtualzap", NULL) == 2)
3848                ostrcatbig(&buf, "<option value=\"2\" selected>", &maxlen, &pos);               
3849        else
3850                ostrcatbig(&buf, "<option value=\"2\">", &maxlen, &pos);
3851        ostrcatbig(&buf, _("2 sec"), &maxlen, &pos);
3852        ostrcatbig(&buf, "</option>", &maxlen, &pos);
3853
3854        if(getconfigint("virtualzap", NULL) == 3)
3855                ostrcatbig(&buf, "<option value=\"3\" selected>", &maxlen, &pos);               
3856        else
3857                ostrcatbig(&buf, "<option value=\"3\">", &maxlen, &pos);
3858        ostrcatbig(&buf, _("endless"), &maxlen, &pos);
3859        ostrcatbig(&buf, "</option>", &maxlen, &pos);
3860       
3861        ostrcatbig(&buf,"</select></td></tr>", &maxlen, &pos);
3862        sendstr = ostrcat(sendstr, ", virtualzap.value", 1 , 0);
3863       
3864///////////////////
3865        ostrcatbig(&buf, "<tr><td><font class=\"label\">", &maxlen, &pos);
3866        ostrcatbig(&buf, _("Fast Text Render"), &maxlen, &pos);
3867        ostrcatbig(&buf, "&nbsp;</font></td><td><select name=\"fasttextrender\" border=\"0\">", &maxlen, &pos);
3868       
3869        if(getconfigint("fasttextrender", NULL) == 0)
3870                ostrcatbig(&buf, "<option value=\"0\" selected>", &maxlen, &pos);               
3871        else
3872                ostrcatbig(&buf, "<option value=\"0\">", &maxlen, &pos);
3873        ostrcatbig(&buf, _("no"), &maxlen, &pos);
3874        ostrcatbig(&buf, "</option>", &maxlen, &pos);
3875
3876        if(getconfigint("fasttextrender", NULL) == 1)
3877                ostrcatbig(&buf, "<option value=\"1\" selected>", &maxlen, &pos);               
3878        else
3879                ostrcatbig(&buf, "<option value=\"1\">", &maxlen, &pos);
3880        ostrcatbig(&buf, _("yes"), &maxlen, &pos);
3881        ostrcatbig(&buf, "</option>", &maxlen, &pos);
3882       
3883        ostrcatbig(&buf,"</select></td></tr>", &maxlen, &pos);
3884        sendstr = ostrcat(sendstr, ", fasttextrender.value", 1 , 0);
3885
3886///////////////////
3887        ostrcatbig(&buf, "<tr><td><font class=\"label\">", &maxlen, &pos);
3888        ostrcatbig(&buf, _("Record Split Size"), &maxlen, &pos);
3889        ostrcatbig(&buf, "&nbsp;</font></td><td><select name=\"recsplitsize\" border=\"0\">", &maxlen, &pos);
3890       
3891        if(getconfigint("recsplitsize", NULL) == 0)
3892                ostrcatbig(&buf, "<option value=\"0\" selected>", &maxlen, &pos);               
3893        else
3894                ostrcatbig(&buf, "<option value=\"0\">", &maxlen, &pos);
3895        ostrcatbig(&buf, _("deaktiv"), &maxlen, &pos);
3896        ostrcatbig(&buf, "</option>", &maxlen, &pos);
3897
3898        if(getconfigint("recsplitsize", NULL) == 1)
3899                ostrcatbig(&buf, "<option value=\"1\" selected>", &maxlen, &pos);               
3900        else
3901                ostrcatbig(&buf, "<option value=\"1\">", &maxlen, &pos);
3902        ostrcatbig(&buf, _("1 GB"), &maxlen, &pos);
3903        ostrcatbig(&buf, "</option>", &maxlen, &pos);
3904
3905        if(getconfigint("recsplitsize", NULL) == 2)
3906                ostrcatbig(&buf, "<option value=\"2\" selected>", &maxlen, &pos);               
3907        else
3908                ostrcatbig(&buf, "<option value=\"2\">", &maxlen, &pos);
3909        ostrcatbig(&buf, _("2 GB"), &maxlen, &pos);
3910        ostrcatbig(&buf, "</option>", &maxlen, &pos);
3911
3912        if(getconfigint("recsplitsize", NULL) == 3)
3913                ostrcatbig(&buf, "<option value=\"3\" selected>", &maxlen, &pos);               
3914        else
3915                ostrcatbig(&buf, "<option value=\"3\">", &maxlen, &pos);
3916        ostrcatbig(&buf, _("3 GB"), &maxlen, &pos);
3917        ostrcatbig(&buf, "</option>", &maxlen, &pos);
3918
3919        if(getconfigint("recsplitsize", NULL) == 4)
3920                ostrcatbig(&buf, "<option value=\"4\" selected>", &maxlen, &pos);               
3921        else
3922                ostrcatbig(&buf, "<option value=\"4\">", &maxlen, &pos);
3923        ostrcatbig(&buf, _("4 GB"), &maxlen, &pos);
3924        ostrcatbig(&buf, "</option>", &maxlen, &pos);   
3925       
3926        ostrcatbig(&buf,"</select></td></tr>", &maxlen, &pos);
3927        sendstr = ostrcat(sendstr, ", recsplitsize.value", 1 , 0);
3928
3929///////////////////
3930        tmpstr = ostrcat("0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n15\n20\n25\n30\n35\n40\n45\n50\n55\n60", NULL, 0, 0);
3931
3932        ostrcatbig(&buf, "<tr><td><font class=\"label\">", &maxlen, &pos);
3933        ostrcatbig(&buf, _("Record Forerun (min)"), &maxlen, &pos);
3934        ostrcatbig(&buf, "&nbsp;</font></td><td><select name=\"recforerun\" border=\"0\">", &maxlen, &pos);
3935
3936        count = 0;
3937        ret1 = strsplit(tmpstr, "\n", &count);
3938        max = count - 1;
3939
3940        if(ret1 != NULL)
3941        {
3942                for(i = 0; i <= max; i++)
3943                {
3944                        ostrcatbig(&buf, "<option value=\"", &maxlen, &pos);
3945                        ostrcatbig(&buf, ret1[i].part, &maxlen, &pos);         
3946                        tmpstr1 = ostrcat(ret1[i].part, NULL, 0, 0);
3947                        if(getconfigint("recforerun", NULL) == atoi(tmpstr1))
3948                                ostrcatbig(&buf, "\" selected>", &maxlen, &pos);               
3949                        else
3950                                ostrcatbig(&buf, "\">", &maxlen, &pos);
3951                        ostrcatbig(&buf, ret1[i].part, &maxlen, &pos);
3952                        ostrcatbig(&buf, "</option>", &maxlen, &pos);
3953                }
3954        }
3955        ostrcatbig(&buf,"</select></td></tr>", &maxlen, &pos);
3956        sendstr = ostrcat(sendstr, ", recforerun.value", 1 , 0);
3957        free(ret1), ret1 = NULL;
3958        free(tmpstr), tmpstr = NULL;
3959        free(tmpstr1), tmpstr1 = NULL;
3960
3961///////////////////
3962        tmpstr = ostrcat("0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n15\n20\n25\n30\n35\n40\n45\n50\n55\n60", NULL, 0, 0);
3963
3964        ostrcatbig(&buf, "<tr><td><font class=\"label\">", &maxlen, &pos);
3965        ostrcatbig(&buf, _("Record Overrun (min)"), &maxlen, &pos);
3966        ostrcatbig(&buf, "&nbsp;</font></td><td><select name=\"recoverrun\" border=\"0\">", &maxlen, &pos);
3967
3968        count = 0;
3969        ret1 = strsplit(tmpstr, "\n", &count);
3970        max = count - 1;
3971
3972        if(ret1 != NULL)
3973        {
3974                for(i = 0; i <= max; i++)
3975                {
3976                        ostrcatbig(&buf, "<option value=\"", &maxlen, &pos);
3977                        ostrcatbig(&buf, ret1[i].part, &maxlen, &pos);         
3978                        tmpstr1 = ostrcat(ret1[i].part, NULL, 0, 0);
3979                        if(getconfigint("recoverrun", NULL) == atoi(tmpstr1))
3980                                ostrcatbig(&buf, "\" selected>", &maxlen, &pos);               
3981                        else
3982                                ostrcatbig(&buf, "\">", &maxlen, &pos);
3983                        ostrcatbig(&buf, ret1[i].part, &maxlen, &pos);
3984                        ostrcatbig(&buf, "</option>", &maxlen, &pos);
3985                }
3986        }
3987        ostrcatbig(&buf,"</select></td></tr>", &maxlen, &pos);
3988        sendstr = ostrcat(sendstr, ", recoverrun.value", 1 , 0);
3989        free(ret1), ret1 = NULL;
3990        free(tmpstr), tmpstr = NULL;
3991        free(tmpstr1), tmpstr1 = NULL;
3992
3993///////////////////
3994        tmpstr = ostrcat("15\n20\n30\n45\n60\n90\n120\n180\n300\n600\n900\n1200", NULL, 0, 0);
3995
3996        ostrcatbig(&buf, "<tr><td><font class=\"label\">", &maxlen, &pos);
3997        ostrcatbig(&buf, _("Skip 1/3"), &maxlen, &pos);
3998        ostrcatbig(&buf, "&nbsp;</font></td><td><select name=\"skip13\" border=\"0\">", &maxlen, &pos);
3999
4000        count = 0;
4001        ret1 = strsplit(tmpstr, "\n", &count);
4002        max = count - 1;
4003
4004        if(ret1 != NULL)
4005        {
4006                for(i = 0; i <= max; i++)
4007                {
4008                        ostrcatbig(&buf, "<option value=\"", &maxlen, &pos);
4009                        ostrcatbig(&buf, ret1[i].part, &maxlen, &pos);         
4010                        tmpstr1 = ostrcat(ret1[i].part, NULL, 0, 0);
4011                        if(getconfigint("skip13", NULL) == atoi(tmpstr1))
4012                                ostrcatbig(&buf, "\" selected>", &maxlen, &pos);               
4013                        else
4014                                ostrcatbig(&buf, "\">", &maxlen, &pos);
4015                        ostrcatbig(&buf, ret1[i].part, &maxlen, &pos);
4016                        ostrcatbig(&buf, "</option>", &maxlen, &pos);
4017                }
4018        }
4019        ostrcatbig(&buf,"</select></td></tr>", &maxlen, &pos);
4020        sendstr = ostrcat(sendstr, ", skip13.value", 1 , 0);
4021        free(ret1), ret1 = NULL;
4022        free(tmpstr), tmpstr = NULL;
4023        free(tmpstr1), tmpstr1 = NULL;
4024
4025///////////////////
4026        tmpstr = ostrcat("15\n20\n30\n45\n60\n90\n120\n180\n300\n600\n900\n1200", NULL, 0, 0);
4027
4028        ostrcatbig(&buf, "<tr><td><font class=\"label\">", &maxlen, &pos);
4029        ostrcatbig(&buf, _("Skip 4/6"), &maxlen, &pos);
4030        ostrcatbig(&buf, "&nbsp;</font></td><td><select name=\"skip46\" border=\"0\">", &maxlen, &pos);
4031
4032        count = 0;
4033        ret1 = strsplit(tmpstr, "\n", &count);
4034        max = count - 1;
4035
4036        if(ret1 != NULL)
4037        {
4038                for(i = 0; i <= max; i++)
4039                {
4040                        ostrcatbig(&buf, "<option value=\"", &maxlen, &pos);
4041                        ostrcatbig(&buf, ret1[i].part, &maxlen, &pos);         
4042                        tmpstr1 = ostrcat(ret1[i].part, NULL, 0, 0);
4043                        if(getconfigint("skip46", NULL) == atoi(tmpstr1))
4044                                ostrcatbig(&buf, "\" selected>", &maxlen, &pos);               
4045                        else
4046                                ostrcatbig(&buf, "\">", &maxlen, &pos);
4047                        ostrcatbig(&buf, ret1[i].part, &maxlen, &pos);
4048                        ostrcatbig(&buf, "</option>", &maxlen, &pos);
4049                }
4050        }
4051        ostrcatbig(&buf,"</select></td></tr>", &maxlen, &pos);
4052        sendstr = ostrcat(sendstr, ", skip46.value", 1 , 0);
4053        free(ret1), ret1 = NULL;
4054        free(tmpstr), tmpstr = NULL;
4055        free(tmpstr1), tmpstr1 = NULL;
4056       
4057///////////////////
4058        tmpstr = ostrcat("15\n20\n30\n45\n60\n90\n120\n180\n300\n600\n900\n1200", NULL, 0, 0);
4059
4060        ostrcatbig(&buf, "<tr><td><font class=\"label\">", &maxlen, &pos);
4061        ostrcatbig(&buf, _("Skip 7/9"), &maxlen, &pos);
4062        ostrcatbig(&buf, "&nbsp;</font></td><td><select name=\"skip79\" border=\"0\">", &maxlen, &pos);
4063
4064        count = 0;
4065        ret1 = strsplit(tmpstr, "\n", &count);
4066        max = count - 1;
4067
4068        if(ret1 != NULL)
4069        {
4070                for(i = 0; i <= max; i++)
4071                {
4072                        ostrcatbig(&buf, "<option value=\"", &maxlen, &pos);
4073                        ostrcatbig(&buf, ret1[i].part, &maxlen, &pos);         
4074                        tmpstr1 = ostrcat(ret1[i].part, NULL, 0, 0);
4075                        if(getconfigint("skip79", NULL) == atoi(tmpstr1))
4076                                ostrcatbig(&buf, "\" selected>", &maxlen, &pos);               
4077                        else
4078                                ostrcatbig(&buf, "\">", &maxlen, &pos);
4079                        ostrcatbig(&buf, ret1[i].part, &maxlen, &pos);
4080                        ostrcatbig(&buf, "</option>", &maxlen, &pos);
4081                }
4082        }
4083        ostrcatbig(&buf,"</select></td></tr>", &maxlen, &pos);
4084        sendstr = ostrcat(sendstr, ", skip79.value", 1 , 0);
4085        free(ret1), ret1 = NULL;
4086        free(tmpstr), tmpstr = NULL;
4087        free(tmpstr1), tmpstr1 = NULL;
4088       
4089///////////////////
4090        ostrcatbig(&buf, "<tr><td><font class=\"label\">", &maxlen, &pos);
4091        ostrcatbig(&buf, _("Player for .ts"), &maxlen, &pos);
4092        ostrcatbig(&buf, "&nbsp;</font></td><td><select name=\"playertype\" border=\"0\">", &maxlen, &pos);
4093       
4094        if(getconfigint("playertype", NULL) == 0)
4095                ostrcatbig(&buf, "<option value=\"0\" selected>", &maxlen, &pos);               
4096        else
4097                ostrcatbig(&buf, "<option value=\"0\">", &maxlen, &pos);
4098        ostrcatbig(&buf, _("extern"), &maxlen, &pos);
4099        ostrcatbig(&buf, "</option>", &maxlen, &pos);
4100
4101        if(getconfigint("faststop", NULL) == 1)
4102                ostrcatbig(&buf, "<option value=\"1\" selected>", &maxlen, &pos);               
4103        else
4104                ostrcatbig(&buf, "<option value=\"1\">", &maxlen, &pos);
4105        ostrcatbig(&buf, _("intern"), &maxlen, &pos);
4106        ostrcatbig(&buf, "</option>", &maxlen, &pos);
4107       
4108        ostrcatbig(&buf,"</select></td></tr>", &maxlen, &pos);
4109        sendstr = ostrcat(sendstr, ", playertype.value", 1 , 0);
4110
4111///////////////////
4112        ostrcatbig(&buf, "<tr><td><font class=\"label\">", &maxlen, &pos);
4113        ostrcatbig(&buf, _("Change Channelname auto."), &maxlen, &pos);
4114        ostrcatbig(&buf, "&nbsp;</font></td><td><select name=\"autochangechannelname\" border=\"0\">", &maxlen, &pos);
4115       
4116        if(getconfigint("autochangechannelname", NULL) == 0)
4117                ostrcatbig(&buf, "<option value=\"0\" selected>", &maxlen, &pos);               
4118        else
4119                ostrcatbig(&buf, "<option value=\"0\">", &maxlen, &pos);
4120        ostrcatbig(&buf, _("no"), &maxlen, &pos);
4121        ostrcatbig(&buf, "</option>", &maxlen, &pos);
4122
4123        if(getconfigint("autochangechannelname", NULL) == 1)
4124                ostrcatbig(&buf, "<option value=\"1\" selected>", &maxlen, &pos);               
4125        else
4126                ostrcatbig(&buf, "<option value=\"1\">", &maxlen, &pos);
4127        ostrcatbig(&buf, _("yes"), &maxlen, &pos);
4128        ostrcatbig(&buf, "</option>", &maxlen, &pos);
4129       
4130        ostrcatbig(&buf,"</select></td></tr>", &maxlen, &pos);
4131        sendstr = ostrcat(sendstr, ", autochangechannelname.value", 1 , 0);
4132
4133///////////////////
4134        ostrcatbig(&buf, "<tr><td><font class=\"label\">", &maxlen, &pos);
4135        ostrcatbig(&buf, _("Set action after rec"), &maxlen, &pos);
4136        ostrcatbig(&buf, "&nbsp;</font></td><td><select name=\"def_rectimer_after\" border=\"0\">", &maxlen, &pos);
4137       
4138        if(getconfigint("def_rectimer_after", NULL) == 0)
4139                ostrcatbig(&buf, "<option value=\"0\" selected>", &maxlen, &pos);               
4140        else
4141                ostrcatbig(&buf, "<option value=\"0\">", &maxlen, &pos);
4142        ostrcatbig(&buf, _("auto"), &maxlen, &pos);
4143        ostrcatbig(&buf, "</option>", &maxlen, &pos);
4144
4145        if(getconfigint("def_rectimer_after", NULL) == 1)
4146                ostrcatbig(&buf, "<option value=\"1\" selected>", &maxlen, &pos);               
4147        else
4148                ostrcatbig(&buf, "<option value=\"1\">", &maxlen, &pos);
4149        ostrcatbig(&buf, _("nothing"), &maxlen, &pos);
4150        ostrcatbig(&buf, "</option>", &maxlen, &pos);
4151
4152        if(getconfigint("def_rectimer_after", NULL) == 2)
4153                ostrcatbig(&buf, "<option value=\"2\" selected>", &maxlen, &pos);               
4154        else
4155                ostrcatbig(&buf, "<option value=\"2\">", &maxlen, &pos);
4156        ostrcatbig(&buf, _("standby"), &maxlen, &pos);
4157        ostrcatbig(&buf, "</option>", &maxlen, &pos);
4158
4159        if(getconfigint("def_rectimer_after", NULL) == 3)
4160                ostrcatbig(&buf, "<option value=\"3\" selected>", &maxlen, &pos);               
4161        else
4162                ostrcatbig(&buf, "<option value=\"3\">", &maxlen, &pos);
4163        ostrcatbig(&buf, _("power off"), &maxlen, &pos);
4164        ostrcatbig(&buf, "</option>", &maxlen, &pos);
4165       
4166        ostrcatbig(&buf,"</select></td></tr>", &maxlen, &pos);
4167        sendstr = ostrcat(sendstr, ", def_rectimer_after.value", 1 , 0);
4168
4169///////////////////
4170        ostrcatbig(&buf, "<tr><td><font class=\"label\">", &maxlen, &pos);
4171        ostrcatbig(&buf, _("Show Timeline in Channellist"), &maxlen, &pos);
4172        ostrcatbig(&buf, "&nbsp;</font></td><td><select name=\"showchanneltimeline\" border=\"0\">", &maxlen, &pos);
4173       
4174        if(getconfigint("showchanneltimeline", NULL) == 0)
4175                ostrcatbig(&buf, "<option value=\"0\" selected>", &maxlen, &pos);               
4176        else
4177                ostrcatbig(&buf, "<option value=\"0\">", &maxlen, &pos);
4178        ostrcatbig(&buf, _("no"), &maxlen, &pos);
4179        ostrcatbig(&buf, "</option>", &maxlen, &pos);
4180
4181        if(getconfigint("showchanneltimeline", NULL) == 1)
4182                ostrcatbig(&buf, "<option value=\"1\" selected>", &maxlen, &pos);               
4183        else
4184                ostrcatbig(&buf, "<option value=\"1\">", &maxlen, &pos);
4185        ostrcatbig(&buf, _("yes"), &maxlen, &pos);
4186        ostrcatbig(&buf, "</option>", &maxlen, &pos);
4187       
4188        ostrcatbig(&buf,"</select></td></tr>", &maxlen, &pos);
4189        sendstr = ostrcat(sendstr, ", showchanneltimeline.value", 1 , 0);
4190
4191///////////////////
4192        ostrcatbig(&buf, "<tr><td><font class=\"label\">", &maxlen, &pos);
4193        ostrcatbig(&buf, _("Animated Screens"), &maxlen, &pos);
4194        ostrcatbig(&buf, "&nbsp;</font></td><td><select name=\"screenanim\" border=\"0\">", &maxlen, &pos);
4195       
4196        if(getconfigint("screenanim", NULL) == 0)
4197                ostrcatbig(&buf, "<option value=\"0\" selected>", &maxlen, &pos);               
4198        else
4199                ostrcatbig(&buf, "<option value=\"0\">", &maxlen, &pos);
4200        ostrcatbig(&buf, _("no"), &maxlen, &pos);
4201        ostrcatbig(&buf, "</option>", &maxlen, &pos);
4202
4203        if(getconfigint("screenanim", NULL) == 1)
4204                ostrcatbig(&buf, "<option value=\"1\" selected>", &maxlen, &pos);               
4205        else
4206                ostrcatbig(&buf, "<option value=\"1\">", &maxlen, &pos);
4207        ostrcatbig(&buf, _("anim. width"), &maxlen, &pos);
4208        ostrcatbig(&buf, "</option>", &maxlen, &pos);
4209
4210        if(getconfigint("screenanim", NULL) == 2)
4211                ostrcatbig(&buf, "<option value=\"2\" selected>", &maxlen, &pos);               
4212        else
4213                ostrcatbig(&buf, "<option value=\"2\">", &maxlen, &pos);
4214        ostrcatbig(&buf, _("anim. height"), &maxlen, &pos);
4215        ostrcatbig(&buf, "</option>", &maxlen, &pos);
4216
4217        if(getconfigint("screenanim", NULL) == 3)
4218                ostrcatbig(&buf, "<option value=\"3\" selected>", &maxlen, &pos);               
4219        else
4220                ostrcatbig(&buf, "<option value=\"3\">", &maxlen, &pos);
4221        ostrcatbig(&buf, _("anim. both"), &maxlen, &pos);
4222        ostrcatbig(&buf, "</option>", &maxlen, &pos);
4223       
4224        ostrcatbig(&buf,"</select></td></tr>", &maxlen, &pos);
4225        sendstr = ostrcat(sendstr, ", screenanim.value", 1 , 0);
4226
4227///////////////////
4228        ostrcatbig(&buf, "<tr><td><font class=\"label\">", &maxlen, &pos);
4229        ostrcatbig(&buf, _("Animated Speed"), &maxlen, &pos);
4230        ostrcatbig(&buf, "&nbsp;</font></td><td><select name=\"screenanimspeed\" border=\"0\">", &maxlen, &pos);
4231       
4232        if(getconfigint("screenanimspeed", NULL) == 1)
4233                ostrcatbig(&buf, "<option value=\"1\" selected>", &maxlen, &pos);               
4234        else
4235                ostrcatbig(&buf, "<option value=\"1\">", &maxlen, &pos);
4236        ostrcatbig(&buf, _("very fast"), &maxlen, &pos);
4237        ostrcatbig(&buf, "</option>", &maxlen, &pos);
4238
4239        if(getconfigint("screenanimspeed", NULL) == 5)
4240                ostrcatbig(&buf, "<option value=\"5\" selected>", &maxlen, &pos);               
4241        else
4242                ostrcatbig(&buf, "<option value=\"5\">", &maxlen, &pos);
4243        ostrcatbig(&buf, _("fast"), &maxlen, &pos);
4244        ostrcatbig(&buf, "</option>", &maxlen, &pos);
4245
4246        if(getconfigint("screenanimspeed", NULL) == 10)
4247                ostrcatbig(&buf, "<option value=\"10\" selected>", &maxlen, &pos);             
4248        else
4249                ostrcatbig(&buf, "<option value=\"10\">", &maxlen, &pos);
4250        ostrcatbig(&buf, _("normal"), &maxlen, &pos);
4251        ostrcatbig(&buf, "</option>", &maxlen, &pos);
4252
4253        if(getconfigint("screenanimspeed", NULL) == 15)
4254                ostrcatbig(&buf, "<option value=\"15\" selected>", &maxlen, &pos);             
4255        else
4256                ostrcatbig(&buf, "<option value=\"15\">", &maxlen, &pos);
4257        ostrcatbig(&buf, _("slow"), &maxlen, &pos);
4258        ostrcatbig(&buf, "</option>", &maxlen, &pos);
4259
4260        if(getconfigint("screenanimspeed", NULL) == 20)
4261                ostrcatbig(&buf, "<option value=\"20\" selected>", &maxlen, &pos);             
4262        else
4263                ostrcatbig(&buf, "<option value=\"20\">", &maxlen, &pos);
4264        ostrcatbig(&buf, _("very slow"), &maxlen, &pos);
4265        ostrcatbig(&buf, "</option>", &maxlen, &pos);
4266       
4267        ostrcatbig(&buf,"</select></td></tr>", &maxlen, &pos);
4268        sendstr = ostrcat(sendstr, ", screenanimspeed.value", 1 , 0);
4269
4270///////////////////
4271        ostrcatbig(&buf, "<tr><td><font class=\"label\">", &maxlen, &pos);
4272        ostrcatbig(&buf, _("Channellist view"), &maxlen, &pos);
4273        ostrcatbig(&buf, "&nbsp;</font></td><td><select name=\"channellistview\" border=\"0\">", &maxlen, &pos);
4274       
4275        if(getconfigint("channellistview", NULL) == 0)
4276                ostrcatbig(&buf, "<option value=\"0\" selected>", &maxlen, &pos);               
4277        else
4278                ostrcatbig(&buf, "<option value=\"0\">", &maxlen, &pos);
4279        ostrcatbig(&buf, _("hidden"), &maxlen, &pos);
4280        ostrcatbig(&buf, "</option>", &maxlen, &pos);
4281
4282        if(getconfigint("channellistview", NULL) == 1)
4283                ostrcatbig(&buf, "<option value=\"1\" selected>", &maxlen, &pos);               
4284        else
4285                ostrcatbig(&buf, "<option value=\"1\">", &maxlen, &pos);
4286        ostrcatbig(&buf, _("deaktiv"), &maxlen, &pos);
4287        ostrcatbig(&buf, "</option>", &maxlen, &pos);
4288       
4289        ostrcatbig(&buf,"</select></td></tr>", &maxlen, &pos);
4290        sendstr = ostrcat(sendstr, ", channellistview.value", 1 , 0);
4291
4292///////////////////
4293        ostrcatbig(&buf, "<tr><td><font class=\"label\">", &maxlen, &pos);
4294        ostrcatbig(&buf, _("Show last pos Question"), &maxlen, &pos);
4295        ostrcatbig(&buf, "&nbsp;</font></td><td><select name=\"showlastpos\" border=\"0\">", &maxlen, &pos);
4296       
4297        if(getconfigint("showlastpos", NULL) == 0)
4298                ostrcatbig(&buf, "<option value=\"0\" selected>", &maxlen, &pos);               
4299        else
4300                ostrcatbig(&buf, "<option value=\"0\">", &maxlen, &pos);
4301        ostrcatbig(&buf, _("no"), &maxlen, &pos);
4302        ostrcatbig(&buf, "</option>", &maxlen, &pos);
4303
4304        if(getconfigint("showlastpos", NULL) == 1)
4305                ostrcatbig(&buf, "<option value=\"1\" selected>", &maxlen, &pos);               
4306        else
4307                ostrcatbig(&buf, "<option value=\"1\">", &maxlen, &pos);
4308        ostrcatbig(&buf, _("yes"), &maxlen, &pos);
4309        ostrcatbig(&buf, "</option>", &maxlen, &pos);
4310       
4311        ostrcatbig(&buf,"</select></td></tr>", &maxlen, &pos);
4312        sendstr = ostrcat(sendstr, ", showlastpos.value", 1 , 0);
4313
4314///////////////////
4315        ostrcatbig(&buf, "<tr><td><font class=\"label\">", &maxlen, &pos);
4316        ostrcatbig(&buf, _("Resync Recording immediately"), &maxlen, &pos);
4317        ostrcatbig(&buf, "&nbsp;</font></td><td><select name=\"recsync\" border=\"0\">", &maxlen, &pos);
4318       
4319        if(getconfigint("recsync", NULL) == 0)
4320                ostrcatbig(&buf, "<option value=\"0\" selected>", &maxlen, &pos);               
4321        else
4322                ostrcatbig(&buf, "<option value=\"0\">", &maxlen, &pos);
4323        ostrcatbig(&buf, _("no"), &maxlen, &pos);
4324        ostrcatbig(&buf, "</option>", &maxlen, &pos);
4325
4326        if(getconfigint("recsync", NULL) == 1)
4327                ostrcatbig(&buf, "<option value=\"1\" selected>", &maxlen, &pos);               
4328        else
4329                ostrcatbig(&buf, "<option value=\"1\">", &maxlen, &pos);
4330        ostrcatbig(&buf, _("yes"), &maxlen, &pos);
4331        ostrcatbig(&buf, "</option>", &maxlen, &pos);
4332       
4333        ostrcatbig(&buf,"</select></td></tr>", &maxlen, &pos);
4334        sendstr = ostrcat(sendstr, ", recsync.value", 1 , 0);
4335
4336///////////////////
4337        ostrcatbig(&buf, "<tr><td><font class=\"label\">", &maxlen, &pos);
4338        ostrcatbig(&buf, _("Recording name"), &maxlen, &pos);
4339        ostrcatbig(&buf, "&nbsp;</font></td><td><select name=\"recordnamefmt\" border=\"0\">", &maxlen, &pos);
4340       
4341        if(getconfigint("recordnamefmt", NULL) == 0)
4342                ostrcatbig(&buf, "<option value=\"0\" selected>", &maxlen, &pos);               
4343        else
4344                ostrcatbig(&buf, "<option value=\"0\">", &maxlen, &pos);
4345        ostrcatbig(&buf, _("channel-movie"), &maxlen, &pos);
4346        ostrcatbig(&buf, "</option>", &maxlen, &pos);
4347
4348        if(getconfigint("recordnamefmt", NULL) == 1)
4349                ostrcatbig(&buf, "<option value=\"1\" selected>", &maxlen, &pos);               
4350        else
4351                ostrcatbig(&buf, "<option value=\"1\">", &maxlen, &pos);
4352        ostrcatbig(&buf, _("movie-channel"), &maxlen, &pos);
4353        ostrcatbig(&buf, "</option>", &maxlen, &pos);
4354       
4355        ostrcatbig(&buf,"</select></td></tr>", &maxlen, &pos);
4356        sendstr = ostrcat(sendstr, ", recordnamefmt.value", 1 , 0);
4357
4358///////////////////
4359        ostrcatbig(&buf, "<tr><td><font class=\"label\">", &maxlen, &pos);
4360        ostrcatbig(&buf, _("Newsletter"), &maxlen, &pos);
4361        ostrcatbig(&buf, "&nbsp;</font></td><td><select name=\"newsletter\" border=\"0\">", &maxlen, &pos);
4362       
4363        if(getconfigint("newsletter", NULL) == 0)
4364                ostrcatbig(&buf, "<option value=\"0\" selected>", &maxlen, &pos);               
4365        else
4366                ostrcatbig(&buf, "<option value=\"0\">", &maxlen, &pos);
4367        ostrcatbig(&buf, _("no"), &maxlen, &pos);
4368        ostrcatbig(&buf, "</option>", &maxlen, &pos);
4369
4370        if(getconfigint("newsletter", NULL) == 1)
4371                ostrcatbig(&buf, "<option value=\"1\" selected>", &maxlen, &pos);               
4372        else
4373                ostrcatbig(&buf, "<option value=\"1\">", &maxlen, &pos);
4374        ostrcatbig(&buf, _("yes"), &maxlen, &pos);
4375        ostrcatbig(&buf, "</option>", &maxlen, &pos);
4376       
4377        ostrcatbig(&buf,"</select></td></tr>", &maxlen, &pos);
4378        sendstr = ostrcat(sendstr, ", newsletter.value", 1 , 0);
4379
4380///////////////////
4381        ostrcatbig(&buf, "<tr><td><font class=\"label\">", &maxlen, &pos);
4382        ostrcatbig(&buf, _("Show hidden files"), &maxlen, &pos);
4383        ostrcatbig(&buf, "&nbsp;</font></td><td><select name=\"showhiddenfiles\" border=\"0\">", &maxlen, &pos);
4384       
4385        if(getconfigint("showhiddenfiles", NULL) == 0)
4386                ostrcatbig(&buf, "<option value=\"0\" selected>", &maxlen, &pos);               
4387        else
4388                ostrcatbig(&buf, "<option value=\"0\">", &maxlen, &pos);
4389        ostrcatbig(&buf, _("no"), &maxlen, &pos);
4390        ostrcatbig(&buf, "</option>", &maxlen, &pos);
4391
4392        if(getconfigint("showhiddenfiles", NULL) == 1)
4393                ostrcatbig(&buf, "<option value=\"1\" selected>", &maxlen, &pos);               
4394        else
4395                ostrcatbig(&buf, "<option value=\"1\">", &maxlen, &pos);
4396        ostrcatbig(&buf, _("yes"), &maxlen, &pos);
4397        ostrcatbig(&buf, "</option>", &maxlen, &pos);
4398       
4399        ostrcatbig(&buf,"</select></td></tr>", &maxlen, &pos);
4400        sendstr = ostrcat(sendstr, ", showhiddenfiles.value", 1 , 0);
4401
4402///////////////////
4403        ostrcatbig(&buf, "<tr><td><font class=\"label\">", &maxlen, &pos);
4404        ostrcatbig(&buf, _("Expert Modus"), &maxlen, &pos);
4405        ostrcatbig(&buf, "&nbsp;</font></td><td><select name=\"expertmodus\" border=\"0\">", &maxlen, &pos);
4406       
4407        if(getconfigint("expertmodus", NULL) == 0)
4408                ostrcatbig(&buf, "<option value=\"0\" selected>", &maxlen, &pos);               
4409        else
4410                ostrcatbig(&buf, "<option value=\"0\">", &maxlen, &pos);
4411        ostrcatbig(&buf, _("no"), &maxlen, &pos);
4412        ostrcatbig(&buf, "</option>", &maxlen, &pos);
4413
4414        if(getconfigint("expertmodus", NULL) == 10)
4415                ostrcatbig(&buf, "<option value=\"10\" selected>", &maxlen, &pos);             
4416        else
4417                ostrcatbig(&buf, "<option value=\"10\">", &maxlen, &pos);
4418        ostrcatbig(&buf, _("yes"), &maxlen, &pos);
4419        ostrcatbig(&buf, "</option>", &maxlen, &pos);
4420
4421        if(getconfigint("expertmodus", NULL) == 11)
4422                ostrcatbig(&buf, "<option value=\"11\" selected>", &maxlen, &pos);             
4423        else
4424                ostrcatbig(&buf, "<option value=\"11\">", &maxlen, &pos);
4425        ostrcatbig(&buf, _("expert (11)"), &maxlen, &pos);
4426        ostrcatbig(&buf, "</option>", &maxlen, &pos);
4427       
4428        ostrcatbig(&buf,"</select></td></tr>", &maxlen, &pos);
4429        sendstr = ostrcat(sendstr, ", expertmodus.value", 1 , 0);
4430
4431///////////////////
4432        ostrcatbig(&buf, "<tr><td><font class=\"label\">", &maxlen, &pos);
4433        ostrcatbig(&buf, _("Show infobar on program change"), &maxlen, &pos);
4434        ostrcatbig(&buf, "&nbsp;</font></td><td><select name=\"infobarprogram\" border=\"0\">", &maxlen, &pos);
4435       
4436        if(getconfigint("infobarprogram", NULL) == 0)
4437                ostrcatbig(&buf, "<option value=\"0\" selected>", &maxlen, &pos);               
4438        else
4439                ostrcatbig(&buf, "<option value=\"0\">", &maxlen, &pos);
4440        ostrcatbig(&buf, _("no"), &maxlen, &pos);
4441        ostrcatbig(&buf, "</option>", &maxlen, &pos);
4442
4443        if(getconfigint("infobarprogram", NULL) == 1)
4444                ostrcatbig(&buf, "<option value=\"1\" selected>", &maxlen, &pos);               
4445        else
4446                ostrcatbig(&buf, "<option value=\"1\">", &maxlen, &pos);
4447        ostrcatbig(&buf, _("yes"), &maxlen, &pos);
4448        ostrcatbig(&buf, "</option>", &maxlen, &pos);
4449       
4450        ostrcatbig(&buf,"</select></td></tr>", &maxlen, &pos);
4451        sendstr = ostrcat(sendstr, ", infobarprogram.value", 1 , 0);
4452
4453///////////////////
4454        ostrcatbig(&buf, "<tr><td><font class=\"label\">", &maxlen, &pos);
4455        ostrcatbig(&buf, _("Use cross control for fast zapping and vol"), &maxlen, &pos);
4456        ostrcatbig(&buf, "&nbsp;</font></td><td><select name=\"crosscontrol\" border=\"0\">", &maxlen, &pos);
4457       
4458        if(getconfigint("crosscontrol", NULL) == 0)
4459                ostrcatbig(&buf, "<option value=\"0\" selected>", &maxlen, &pos);               
4460        else
4461                ostrcatbig(&buf, "<option value=\"0\">", &maxlen, &pos);
4462        ostrcatbig(&buf, _("no"), &maxlen, &pos);
4463        ostrcatbig(&buf, "</option>", &maxlen, &pos);
4464
4465        if(getconfigint("crosscontrol", NULL) == 1)
4466                ostrcatbig(&buf, "<option value=\"1\" selected>", &maxlen, &pos);               
4467        else
4468                ostrcatbig(&buf, "<option value=\"1\">", &maxlen, &pos);
4469        ostrcatbig(&buf, _("yes"), &maxlen, &pos);
4470        ostrcatbig(&buf, "</option>", &maxlen, &pos);
4471
4472        if(getconfigint("crosscontrol", NULL) == 2)
4473                ostrcatbig(&buf, "<option value=\"2\" selected>", &maxlen, &pos);               
4474        else
4475                ostrcatbig(&buf, "<option value=\"2\">", &maxlen, &pos);
4476        ostrcatbig(&buf, _("yes / vzap 1 sec"), &maxlen, &pos);
4477        ostrcatbig(&buf, "</option>", &maxlen, &pos);
4478
4479        if(getconfigint("crosscontrol", NULL) == 3)
4480                ostrcatbig(&buf, "<option value=\"3\" selected>", &maxlen, &pos);               
4481        else
4482                ostrcatbig(&buf, "<option value=\"3\">", &maxlen, &pos);
4483        ostrcatbig(&buf, _("yes / vzap 2 sec"), &maxlen, &pos);
4484        ostrcatbig(&buf, "</option>", &maxlen, &pos);
4485
4486        if(getconfigint("crosscontrol", NULL) == 9999)
4487                ostrcatbig(&buf, "<option value=\"9999\" selected>", &maxlen, &pos);           
4488        else
4489                ostrcatbig(&buf, "<option value=\"9999\">", &maxlen, &pos);
4490        ostrcatbig(&buf, _("yes / vzap endless"), &maxlen, &pos);
4491        ostrcatbig(&buf, "</option>", &maxlen, &pos);
4492       
4493        ostrcatbig(&buf,"</select></td></tr>", &maxlen, &pos);
4494        sendstr = ostrcat(sendstr, ", crosscontrol.value", 1 , 0);
4495       
4496///////////////////
4497        if(status.security == 1)
4498        {
4499                ostrcatbig(&buf, "<tr><td><font class=\"label\">", &maxlen, &pos);
4500                ostrcatbig(&buf, _("Deactivate Crypt Support on Media Playback"), &maxlen, &pos);
4501                ostrcatbig(&buf, "&nbsp;</font></td><td><select name=\"emucontrol\" border=\"0\">", &maxlen, &pos);
4502       
4503                if(getconfigint("emucontrol", NULL) == 0)
4504                        ostrcatbig(&buf, "<option value=\"0\" selected>", &maxlen, &pos);               
4505                else
4506                        ostrcatbig(&buf, "<option value=\"0\">", &maxlen, &pos);
4507                ostrcatbig(&buf, _("no"), &maxlen, &pos);
4508                ostrcatbig(&buf, "</option>", &maxlen, &pos);
4509
4510                if(getconfigint("emucontrol", NULL) == 1)
4511                        ostrcatbig(&buf, "<option value=\"1\" selected>", &maxlen, &pos);               
4512                else
4513                        ostrcatbig(&buf, "<option value=\"1\">", &maxlen, &pos);
4514                ostrcatbig(&buf, _("yes"), &maxlen, &pos);
4515                ostrcatbig(&buf, "</option>", &maxlen, &pos);
4516       
4517                ostrcatbig(&buf,"</select></td></tr>", &maxlen, &pos);
4518                sendstr = ostrcat(sendstr, ", emucontrol.value", 1 , 0);
4519        }
4520
4521///////////////////
4522        ostrcatbig(&buf, "<tr><td><font class=\"label\">", &maxlen, &pos);
4523        ostrcatbig(&buf, _("Deactivate MiniTV"), &maxlen, &pos);
4524        ostrcatbig(&buf, "&nbsp;</font></td><td><select name=\"choiceminitv\" border=\"0\">", &maxlen, &pos);
4525       
4526        if(getconfigint("choiceminitv", NULL) == 0)
4527                ostrcatbig(&buf, "<option value=\"0\" selected>", &maxlen, &pos);               
4528        else
4529                ostrcatbig(&buf, "<option value=\"0\">", &maxlen, &pos);
4530        ostrcatbig(&buf, _("no"), &maxlen, &pos);
4531        ostrcatbig(&buf, "</option>", &maxlen, &pos);
4532
4533        if(getconfigint("choiceminitv", NULL) == 1)
4534                ostrcatbig(&buf, "<option value=\"1\" selected>", &maxlen, &pos);               
4535        else
4536                ostrcatbig(&buf, "<option value=\"1\">", &maxlen, &pos);
4537        ostrcatbig(&buf, _("yes"), &maxlen, &pos);
4538        ostrcatbig(&buf, "</option>", &maxlen, &pos);
4539       
4540        ostrcatbig(&buf,"</select></td></tr>", &maxlen, &pos);
4541        sendstr = ostrcat(sendstr, ", choiceminitv.value", 1 , 0);
4542
4543///////////////////
4544        if(checkbox("ATEMIO510") == 1 || checkbox("UFS912") == 1 || checkbox("ATEMIO7600") == 1 || checkbox("ATEMIO520") == 1 || checkbox("ATEMIO530") == 1)
4545        {
4546                ostrcatbig(&buf, "<tr><td><font class=\"label\">", &maxlen, &pos);
4547                ostrcatbig(&buf, _("Activate CEC"), &maxlen, &pos);
4548                ostrcatbig(&buf, "&nbsp;</font></td><td><select name=\"usecec\" border=\"0\">", &maxlen, &pos);
4549       
4550                if(getconfigint("usecec", NULL) == 0)
4551                        ostrcatbig(&buf, "<option value=\"0\" selected>", &maxlen, &pos);               
4552                else
4553                        ostrcatbig(&buf, "<option value=\"0\">", &maxlen, &pos);
4554                ostrcatbig(&buf, _("no"), &maxlen, &pos);
4555                ostrcatbig(&buf, "</option>", &maxlen, &pos);
4556
4557                if(getconfigint("usecec", NULL) == 1)
4558                        ostrcatbig(&buf, "<option value=\"1\" selected>", &maxlen, &pos);               
4559                else
4560                        ostrcatbig(&buf, "<option value=\"1\">", &maxlen, &pos);
4561                ostrcatbig(&buf, _("yes"), &maxlen, &pos);
4562                ostrcatbig(&buf, "</option>", &maxlen, &pos);
4563       
4564                ostrcatbig(&buf,"</select></td></tr>", &maxlen, &pos);
4565                sendstr = ostrcat(sendstr, ", usecec.value", 1 , 0);
4566        }
4567
4568///////////////////
4569        if(checkbox("ATEMIO7600") == 1)
4570        {
4571                ostrcatbig(&buf, "<tr><td><font class=\"label\">", &maxlen, &pos);
4572                ostrcatbig(&buf, _("SATA Connector"), &maxlen, &pos);
4573                ostrcatbig(&buf, "&nbsp;</font></td><td><select name=\"sataswitch\" border=\"0\">", &maxlen, &pos);
4574       
4575                if(getconfigint("sataswitch", NULL) == 0)
4576                        ostrcatbig(&buf, "<option value=\"0\" selected>", &maxlen, &pos);               
4577                else
4578                        ostrcatbig(&buf, "<option value=\"0\">", &maxlen, &pos);
4579                ostrcatbig(&buf, _("extern"), &maxlen, &pos);
4580                ostrcatbig(&buf, "</option>", &maxlen, &pos);
4581
4582                if(getconfigint("sataswitch", NULL) == 1)
4583                        ostrcatbig(&buf, "<option value=\"1\" selected>", &maxlen, &pos);               
4584                else
4585                        ostrcatbig(&buf, "<option value=\"1\">", &maxlen, &pos);
4586                ostrcatbig(&buf, _("intern"), &maxlen, &pos);
4587                ostrcatbig(&buf, "</option>", &maxlen, &pos);
4588       
4589                ostrcatbig(&buf,"</select></td></tr>", &maxlen, &pos);
4590                sendstr = ostrcat(sendstr, ", sataswitch.value", 1 , 0);
4591        }
4592
4593///////////////////
4594//      ostrcatbig(&buf, "<tr><td><font class=\"label\">Volbartimeout:&nbsp;</font></td><td><select name=\"volbartimeout\" border=\"0\"><option value=\"1\" selected>1</option><option value=\"2\">2</option><option value=\"3\">3</option><option value=\"4\">4</option><option value=\"5\">5</option><option value=\"6\">6</option><option value=\"7\">7</option><option value=\"8\">8</option><option value=\"9\">9</option><option value=\"10\">10</option></select></td></tr>", &maxlen, &pos);
4595        max = 10;
4596        ostrcatbig(&buf, "<tr><td><font class=\"label\">", &maxlen, &pos);
4597        ostrcatbig(&buf, _("Time to wait after seek for fill buffer"), &maxlen, &pos);
4598        ostrcatbig(&buf, "&nbsp;</font></td><td><select name=\"playerbufferseektime\" border=\"0\">", &maxlen, &pos);
4599        for(i = 1; i <= max; i++)
4600        {
4601                ostrcatbig(&buf, "<option value=\"", &maxlen, &pos);
4602                ostrcatbig(&buf, oitoa(i), &maxlen, &pos);             
4603                if(getconfigint("playerbufferseektime", NULL) == i)
4604                        ostrcatbig(&buf, "\" selected>", &maxlen, &pos);               
4605                else
4606                        ostrcatbig(&buf, "\">", &maxlen, &pos);
4607                ostrcatbig(&buf, oitoa(i), &maxlen, &pos);
4608                ostrcatbig(&buf, "</option>", &maxlen, &pos);
4609        }       
4610        ostrcatbig(&buf, "</select></td></tr>", &maxlen, &pos);
4611        sendstr = ostrcat(sendstr, ", playerbufferseektime.value", 1 , 0);
4612       
4613///////////////////     
4614#ifdef MIPSEL
4615        ostrcatbig(&buf, "<tr><td><font class=\"label\">", &maxlen, &pos);
4616        ostrcatbig(&buf, _("Dualboot Menu TitanNit / E2"), &maxlen, &pos);
4617        ostrcatbig(&buf, "&nbsp;</font></td><td><select name=\"dualboot\" border=\"0\">", &maxlen, &pos);
4618
4619//              if(getconfigint("dualboot", NULL) == 0)
4620        if(!file_exist("/mnt/config/dualboot"))
4621                ostrcatbig(&buf, "<option value=\"0\" selected>", &maxlen, &pos);               
4622        else
4623                ostrcatbig(&buf, "<option value=\"0\">", &maxlen, &pos);
4624        ostrcatbig(&buf, _("no"), &maxlen, &pos);
4625        ostrcatbig(&buf, "</option>", &maxlen, &pos);
4626
4627//              if(getconfigint("dualboot", NULL) == 1)
4628        if(file_exist("/mnt/config/dualboot"))
4629                ostrcatbig(&buf, "<option value=\"1\" selected>", &maxlen, &pos);               
4630        else
4631                ostrcatbig(&buf, "<option value=\"1\">", &maxlen, &pos);
4632        ostrcatbig(&buf, _("yes"), &maxlen, &pos);
4633        ostrcatbig(&buf, "</option>", &maxlen, &pos);
4634
4635        ostrcatbig(&buf,"</select></td></tr>", &maxlen, &pos); 
4636        sendstr = ostrcat(sendstr, ", dualboot.value", 1 , 0);
4637#endif
4638       
4639
4640//      ostrcatbig(&buf, "</table><br><br><input class=button type=submit name=send value=\"Send\" onClick=\"return checkdaytime(begin.value, end.value)\"></input>&nbsp;<input class=button type=reset name=reset value=\"Reset\"></input></form></center></body></html>", &maxlen, &pos);
4641//      ostrcatbig(&buf, "</table><br><br><input class=button type=submit name=send value=\"Send\" onClick=\"return volbartimeout.value, infobartimeout.value, infobarsleep.value, spinnerspeed.value, spinnertime.value, hangtime.value, secondinfobar.value, nozapclear.value, fastzap.value, faststop.value, dirsort.value, poweraktion.value, virtualzap.value, fasttextrender.value, recsplitsize.value, recforerun.value, recoverrun.value, skip13.value, skip46.value, skip79.value, playertype.value, autochangechannelname.value, def_rectimer_after.value, showchanneltimeline.value, screenanim.value, screenanimspeed.value, channellistview.value, showlastpos.value, recsync.value, recordnamefmt.value, newsletter.value, showhiddenfiles.value, expertmodus.value, infobarprogram.value, emucontrol.value, choiceminitv.value, usecec.value, playerbufferseektime.value, dualboot.value\"></input>&nbsp;<input class=button type=reset name=reset value=\"Reset\"></input></form></center></body></html>", &maxlen, &pos);
4642// sendstr verwenden
4643        ostrcatbig(&buf, "</table><br><br><input class=button type=submit name=send value=\"Send\" onClick=\"return ", &maxlen, &pos);
4644        ostrcatbig(&buf, sendstr, &maxlen, &pos);
4645        ostrcatbig(&buf, "\"></input>&nbsp;<input class=button type=reset name=reset value=\"Reset\"></input></form></center></body></html>", &maxlen, &pos);
4646       
4647       
4648//writesys("/tmp/tmpstr", buf, 1);
4649        //ostrcatbig(&buf, param, &maxlen, &pos);
4650        return buf;
4651}
4652
4653char* webadjustsend(char* param, int fmt)
4654{
4655        debug(77, "fmt: %d param: %s",fmt , param);
4656
4657        char* buf = NULL;
4658        char* tmpstr = NULL, *tmpstr1 = NULL;
4659
4660        int count, count2,  max, i;
4661
4662        tmpstr = ostrcat(param, NULL, 0, 0);
4663       
4664        count = 0;
4665        struct splitstr* ret1 = NULL;
4666        ret1 = strsplit(tmpstr, "&", &count);
4667        max = count - 1;
4668       
4669        if(ret1 != NULL)
4670        {
4671                for(i = 0; i <= max; i++)
4672                {
4673                        if(ostrcmp(ret1[i].part, "node=0") == 0 || ostrcmp(ret1[i].part, "send=Send") == 0)
4674                        {
4675                                debug(77, "skip: %s", ret1[i].part);
4676                                continue;
4677                        }
4678                        tmpstr1 = ostrcat(ret1[i].part, NULL, 0, 0);
4679                        count2 = 0;
4680                        struct splitstr* ret2 = NULL;
4681                        ret2 = strsplit(tmpstr1, "=", &count2);
4682                        if(ret2 != NULL && count2 > 1)
4683                        {
4684                                if(ret2[1].part != NULL && ostrcmp(ret2[0].part, "dualboot") == 0)
4685                                {
4686                                        debug(77, "add %s: %s", ret2[0].part, ret2[1].part);
4687                                        if(ostrcmp(ret2[1].part, "0") == 0)
4688                                        {
4689                                                debug(77, "unlink /mnt/config/dualboot");
4690                                                unlink("/mnt/config/dualboot");
4691                                        }
4692                                        else
4693                                        {
4694                                                debug(77, "touch /mnt/config/dualboot");
4695                                                system("touch /mnt/config/dualboot");
4696                                        }
4697                                }
4698                                else if(ret2[1].part != NULL)
4699                                {
4700                                        debug(77, "add %s: %s", ret2[0].part, ret2[1].part);
4701                                        addconfigtmp(ret2[0].part, ret2[1].part);
4702                                }
4703
4704                        }
4705                        free(ret2), ret2 = NULL;
4706                        free(tmpstr1), tmpstr1 = NULL;
4707                }
4708        }
4709        free(ret1), ret1 = NULL;
4710        free(tmpstr), tmpstr = NULL;
4711       
4712        buf = webadjust(NULL, fmt);
4713        writeallconfig(1);
4714
4715        return buf;
4716}
4717
4718char* webgetparamvalue(char* param, char* searchparam)
4719{
4720        char* buf = NULL;
4721        char* tmpstr = NULL;
4722       
4723        tmpstr = ostrcat(param, NULL, 0, 0);
4724        if(tmpstr != NULL) buf = ostrstr(tmpstr, searchparam);
4725        if(buf != NULL) buf = buf + strlen(searchparam);
4726        free(tmpstr); tmpstr = NULL;
4727        buf = stringreplacecharonce(buf, '&', '\0');
4728        debug(77, "webgetparamvalue param: %s", param);
4729        debug(77, "webgetparamvalue search: %s", searchparam);
4730        debug(77, "webgetparamvalue value: %s", buf);
4731        return buf;
4732}
4733
4734char* webgetcommand(char* param, int fmt)
4735{
4736        char* buf = NULL, *tmpstr = NULL;
4737        if(param == NULL) return NULL;
4738        if(status.security == 0) return NULL;
4739
4740//      if(fmt == 0)
4741//      {
4742                buf = ostrcat(buf, "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">", 1, 0);
4743                buf = ostrcat(buf, "<link rel=stylesheet type=text/css href=titan.css><script type=text/javascript src=titan.js></script>", 1, 0);
4744                buf = ostrcat(buf, "</head><body class=body id=\"command\"><center>", 1, 0);
4745//      }
4746
4747        debug(10, "cmd: %s", param);
4748        tmpstr = command(param);
4749        buf = ostrcat(buf, tmpstr, 1, 0);
4750        free(tmpstr), tmpstr = NULL;   
4751
4752        buf = string_replace_all("\n", "<br>", buf, 1);
4753        buf = string_replace_all("<br>", "<br>\n", buf, 1);
4754
4755//      if(fmt == 0)
4756                buf = ostrcat(buf, "</center></body></html>", 1, 0);
4757
4758        return buf;
4759}
4760
4761char* webgetsystem(char* param, int fmt)
4762{
4763        char* buf = NULL;
4764        int ret = 0;
4765        if(param == NULL) return NULL;
4766        if(status.security == 0) return NULL;
4767
4768//      if(fmt == 0)
4769//      {
4770                buf = ostrcat(buf, "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">", 1, 0);
4771                buf = ostrcat(buf, "<link rel=stylesheet type=text/css href=titan.css><script type=text/javascript src=titan.js></script>", 1, 0);
4772                buf = ostrcat(buf, "</head><body class=body id=\"system\"><center>", 1, 0);
4773                buf = ostrcat(buf, "<h1>", 1, 0);
4774//      }
4775
4776        debug(10, "cmd: %s", param);
4777        ret = system(param);
4778
4779        if(ret != 0)
4780                buf = ostrcat(buf, _("Error, Program not started."), 1, 0);
4781        else
4782                buf = ostrcat(buf, _("Program started successfully"), 1, 0);
4783        buf = ostrcat(buf, "<br>", 1, 0);
4784
4785        buf = string_replace_all("<br>", "<br>\n", buf, 1);
4786
4787//      if(fmt == 0)
4788                buf = ostrcat(buf, "</h1></center></body></html>", 1, 0);
4789
4790        return buf;
4791}
4792
4793char* webgethelp(char* param, int fmt)
4794{
4795        char* buf = NULL, *tmpstr = NULL, *tmpstr1 = NULL, *helppath = NULL, *lang = NULL;
4796        if(param == NULL) return NULL;
4797
4798//      if(fmt == 0)
4799//      {
4800                buf = ostrcat(buf, "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">", 1, 0);
4801                buf = ostrcat(buf, "<link rel=stylesheet type=text/css href=titan.css><script type=text/javascript src=titan.js></script>", 1, 0);
4802                buf = ostrcat(buf, "</head><body class=body id=\"help\"><center>", 1, 0);
4803                buf = ostrcat(buf, "<br>", 1, 0);
4804                buf = ostrcat(buf, "<h1>", 1, 0);
4805                buf = ostrcat(buf, _(param), 1, 0);
4806                buf = ostrcat(buf, "</h1>", 1, 0);
4807                buf = ostrcat(buf, "<br>", 1, 0);
4808//      }
4809
4810        helppath = getconfig("helppath", NULL);
4811        if(helppath == NULL) return NULL;
4812
4813        //get language
4814        lang = ostrcat(getconfig("lang", NULL), NULL, 0, 0);
4815        lang = string_replace("po/", "", lang, 1);
4816
4817        //create full filename
4818        tmpstr = ostrcat(helppath, "/", 0, 0);
4819        tmpstr = ostrcat(tmpstr, lang, 1, 0);
4820        tmpstr = ostrcat(tmpstr, "/", 1, 0);
4821        tmpstr = ostrcat(tmpstr, param, 1, 0);
4822        tmpstr = ostrcat(tmpstr, ".txt", 1, 0);
4823       
4824        debug(10, "file: %s", tmpstr);
4825        tmpstr1 = readfiletomem(tmpstr, 1);
4826
4827        buf = ostrcat(buf, _(tmpstr1), 1, 0);
4828
4829// segfault ??
4830//      free(helppath), helppath = NULL;
4831
4832        free(lang), lang = NULL;
4833        free(tmpstr), tmpstr = NULL;
4834        free(tmpstr1), tmpstr1 = NULL;
4835        buf = string_replace_all("<br>", "<br>\n", buf, 1);
4836
4837//      if(fmt == 0)
4838                buf = ostrcat(buf, "</center></body></html>", 1, 0);
4839
4840        return buf;
4841}
4842
4843char* webgethelpchoices(int fmt)
4844{
4845        char* buf = NULL, *tmpstr = NULL, *helppath = NULL, *lang = NULL, *cmd = NULL;
4846       
4847//      if(fmt == 0)
4848//      {
4849                buf = ostrcat(buf, "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">", 1, 0);
4850                buf = ostrcat(buf, "<link rel=stylesheet type=text/css href=titan.css><script type=text/javascript src=titan.js></script>", 1, 0);
4851                buf = ostrcat(buf, "</head><body class=body id=\"helpchoices\"><center>", 1, 0);
4852                buf = ostrcat(buf, "<br>", 1, 0);
4853                buf = ostrcat(buf, "<h1>", 1, 0);
4854                buf = ostrcat(buf, _("Help"), 1, 0);
4855                buf = ostrcat(buf, "</h1>", 1, 0);
4856                buf = ostrcat(buf, "<br>", 1, 0);
4857//      }
4858
4859        helppath = getconfig("helppath", NULL);
4860        if(helppath == NULL) return NULL;
4861
4862        //get language
4863        lang = ostrcat(getconfig("lang", NULL), NULL, 0, 0);
4864        lang = string_replace("po/", "", lang, 1);
4865
4866        //create full filename
4867        cmd = ostrcat("ls -1 ", helppath, 0, 0);
4868        cmd = ostrcat(cmd, "/", 1, 0);
4869        cmd = ostrcat(cmd, lang, 1, 1);
4870        cmd = ostrcat(cmd, "/", 1, 0);
4871       
4872        debug(10, "cmd: %s", cmd);
4873        tmpstr = command(cmd);
4874       
4875        int count, i, max;
4876        count = 0;
4877        struct splitstr* ret1 = NULL;
4878        ret1 = strsplit(tmpstr, "\n", &count);
4879        max = count - 1;
4880       
4881        buf = ostrcat(buf, "<table cellpadding=5 cellspacing=5><tr><td nowrap>", 1, 0);
4882 
4883        if(ret1 != NULL)
4884        {
4885                for(i = 0; i <= max; i++)
4886                {
4887                        buf = ostrcat(buf, "<a class=linelink2 href=queryraw?gethelp&", 1, 0);
4888                        buf = ostrcat(buf, stringreplacecharonce(ret1[i].part, '.', '\0'), 1, 0);
4889                        buf = ostrcat(buf, " target=main>", 1, 0);
4890                        buf = ostrcat(buf, _(stringreplacecharonce(ret1[i].part, '.', '\0')), 1, 0);
4891                        buf = ostrcat(buf, "</a>", 1, 0);
4892                        buf = ostrcat(buf, "</br></br>", 1, 0);
4893                }
4894        }               
4895
4896// segfault ??
4897//      free(helppath), helppath = NULL;
4898        free(ret1), ret1 = NULL;
4899
4900        free(tmpstr), tmpstr = NULL;
4901        buf = string_replace_all("<br>", "<br>\n", buf, 1);
4902
4903//      if(fmt == 0)
4904                buf = ostrcat(buf, "</td></tr></table></center></body></html>", 1, 0);
4905
4906        return buf;
4907}
4908
4909char* webgettestpage(char* param, int fmt)
4910{
4911        char* buf = NULL, *tmpstr = NULL;
4912        if(param == NULL) return NULL;
4913        if(status.security == 0) return NULL;
4914
4915//      if(fmt == 0)
4916//      {
4917                buf = ostrcat(buf, "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">", 1, 0);
4918                buf = ostrcat(buf, "<link rel=stylesheet type=text/css href=titan.css><script type=text/javascript src=titan.js></script>", 1, 0);
4919                buf = ostrcat(buf, "</head><body class=body id=\"help\"><center>", 1, 0);
4920//      }
4921       
4922        debug(10, "file: %s", param);
4923        tmpstr = readfiletomem(param, 1);
4924
4925        buf = ostrcat(buf, tmpstr, 1, 0);
4926
4927        free(tmpstr), tmpstr = NULL;   
4928        buf = string_replace_all("<br>", "<br>\n", buf, 1);
4929
4930//      if(fmt == 0)
4931                buf = ostrcat(buf, "</center></body></html>", 1, 0);
4932
4933        debug(10, "buf: %s", buf);
4934
4935        return buf;
4936}
4937
4938char* webgetsysteminfos(char* param, int fmt)
4939{
4940        char* buf = NULL, *tmpstr = NULL;
4941        int mode;
4942
4943        mode = atoi(param);
4944        if(fmt == 0)
4945        {
4946                buf = ostrcat(buf, "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">", 1, 0);
4947                buf = ostrcat(buf, "<link rel=stylesheet type=text/css href=titan.css><script type=text/javascript src=titan.js></script>", 1, 0);
4948                buf = ostrcat(buf, "</head><body class=body id=\"systeminfos\"><center>", 1, 0);
4949                buf = ostrcat(buf, "<br>", 1, 0);
4950                buf = ostrcat(buf, "<h1>", 1, 0);
4951                if(mode == 0)
4952                        buf = ostrcat(buf, _("System Status"), 1, 0);
4953                else if(mode == 1)
4954                        buf = ostrcat(buf, _("Free Space"), 1, 0);
4955                else if(mode == 2)
4956                        buf = ostrcat(buf, _("Kernel"), 1, 0);
4957                else if(mode == 3)
4958                        buf = ostrcat(buf, _("Mounts"), 1, 0);
4959                else if(mode == 4)
4960                        buf = ostrcat(buf, _("Network"), 1, 0);
4961                else if(mode == 5)
4962                        buf = ostrcat(buf, _("Ram"), 1, 0);
4963
4964                buf = ostrcat(buf, "</h1>", 1, 0);
4965                buf = ostrcat(buf, "<br>", 1, 0);
4966        }
4967
4968        tmpstr = system_infos(mode);
4969        tmpstr = string_replace_all("\n", "<br>", tmpstr, 1);
4970
4971        buf = ostrcat(buf, tmpstr, 1, 0);
4972
4973        free(tmpstr), tmpstr = NULL;
4974        buf = string_replace_all("<br>", "<br>\n", buf, 1);
4975
4976        if(fmt == 0)
4977        {
4978                buf = ostrcat(buf, "</center></body></html>", 1, 0);
4979        }       
4980       
4981        return buf;
4982}       
4983
4984char* webgetsysinfos(char* param, int fmt)
4985{
4986        char* buf = NULL, *tmpstr = NULL;
4987        int mode;
4988
4989        mode = atoi(param);
4990        if(fmt == 0)
4991        {
4992                buf = ostrcat(buf, "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">", 1, 0);
4993                buf = ostrcat(buf, "<link rel=stylesheet type=text/css href=titan.css><script type=text/javascript src=titan.js></script>", 1, 0);
4994                buf = ostrcat(buf, "</head><body class=body id=\"sysinfos\"><center>", 1, 0);
4995                buf = ostrcat(buf, "<br>", 1, 0);
4996                buf = ostrcat(buf, "<h1>", 1, 0);
4997                if(mode == 0)
4998                        buf = ostrcat(buf, _("CPU"), 1, 0);
4999                else if(mode == 1)
5000                        buf = ostrcat(buf, _("Memory"), 1, 0);
5001                else if(mode == 2)
5002                        buf = ostrcat(buf, _("MTD"), 1, 0);
5003                else if(mode == 3)
5004                        buf = ostrcat(buf, _("Module"), 1, 0);
5005                else if(mode == 4)
5006                        buf = ostrcat(buf, _("Devices"), 1, 0);
5007                else if(mode == 5)
5008                        buf = ostrcat(buf, _("Swap"), 1, 0);
5009                else if(mode == 6)
5010                        buf = ostrcat(buf, _("Top"), 1, 0);
5011                else if(mode == 7)
5012                        buf = ostrcat(buf, _("Prozesslist"), 1, 0);
5013                else if(mode == 8)
5014                        buf = ostrcat(buf, _("USB"), 1, 0);
5015
5016                buf = ostrcat(buf, "</h1>", 1, 0);
5017                buf = ostrcat(buf, "<br>", 1, 0);
5018        }
5019
5020        tmpstr = system_infos_sysinfo(mode);
5021        tmpstr = string_replace_all("\n", "<br>", tmpstr, 1);
5022
5023        buf = ostrcat(buf, tmpstr, 1, 0);
5024
5025        free(tmpstr), tmpstr = NULL;
5026        buf = string_replace_all("<br>", "<br>\n", buf, 1);
5027
5028        if(fmt == 0)
5029        {
5030                buf = ostrcat(buf, "</center></body></html>", 1, 0);
5031        }       
5032       
5033        return buf;
5034}       
5035
5036char* webgetlogs(char* param, int fmt)
5037{
5038        char* buf = NULL, *tmpstr = NULL;
5039        int mode;
5040
5041        mode = atoi(param);
5042        if(fmt == 0)
5043        {
5044                buf = ostrcat(buf, "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">", 1, 0);
5045                buf = ostrcat(buf, "<link rel=stylesheet type=text/css href=titan.css><script type=text/javascript src=titan.js></script>", 1, 0);
5046                buf = ostrcat(buf, "</head><body class=body id=\"logs\"><center>", 1, 0);
5047                buf = ostrcat(buf, "<br>", 1, 0);
5048                buf = ostrcat(buf, "<h1>", 1, 0);
5049                if(mode == 0)
5050                        buf = ostrcat(buf, _("Hotline"), 1, 0);
5051                else if(mode == 1)
5052                        buf = ostrcat(buf, _("Svn Changelog"), 1, 0);
5053                else if(mode == 2)
5054                        buf = ostrcat(buf, _("Git Changelog"), 1, 0);
5055                else if(mode == 3)
5056                        buf = ostrcat(buf, _("titan Log"), 1, 0);
5057                else if(mode == 4)
5058                        buf = ostrcat(buf, _("Svn Changelog Full"), 1, 0);
5059                else if(mode == 5)
5060                        buf = ostrcat(buf, _("Git Changelog Full"), 1, 0);
5061
5062                buf = ostrcat(buf, "</h1>", 1, 0);
5063                buf = ostrcat(buf, "<br>", 1, 0);
5064        }
5065
5066        tmpstr = system_logs(mode);
5067        tmpstr = string_replace_all("\n", "<br>", tmpstr, 1);
5068
5069        buf = ostrcat(buf, tmpstr, 1, 0);
5070
5071        free(tmpstr), tmpstr = NULL;
5072        buf = string_replace_all("<br>", "<br>\n", buf, 1);
5073
5074        if(fmt == 0)
5075        {
5076                buf = ostrcat(buf, "</center></body></html>", 1, 0);
5077        }       
5078       
5079        return buf;
5080}       
5081
5082char* webgetabout(int fmt)
5083{
5084        char* buf = NULL, *tmpstr = NULL;
5085
5086        if(fmt == 0)
5087        {
5088                buf = ostrcat(buf, "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">", 1, 0);
5089                buf = ostrcat(buf, "<link rel=stylesheet type=text/css href=titan.css><script type=text/javascript src=titan.js></script>", 1, 0);
5090                buf = ostrcat(buf, "</head><body class=body id=\"about\"><center>", 1, 0);
5091                buf = ostrcat(buf, "<br>", 1, 0);
5092                buf = ostrcat(buf, "<h1>", 1, 0);
5093                buf = ostrcat(buf, _("About"), 1, 0);
5094                buf = ostrcat(buf, "</h1>", 1, 0);
5095                buf = ostrcat(buf, "<br>", 1, 0);
5096        }
5097
5098        tmpstr = getabout();
5099        tmpstr = string_replace_all("\n", "<br>", tmpstr, 1);
5100
5101        buf = ostrcat(buf, tmpstr, 1, 0);
5102
5103        free(tmpstr), tmpstr = NULL;
5104        buf = string_replace_all("<br>", "<br>\n", buf, 1);
5105
5106        if(fmt == 0)
5107        {
5108                buf = ostrcat(buf, "</center></body></html>", 1, 0);
5109        }       
5110       
5111        return buf;
5112}
5113
5114char* webgetnewsletterchoices(int fmt)
5115{
5116        char* buf = NULL;
5117
5118        if(fmt == 0)
5119        {
5120                buf = ostrcat(buf, "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">", 1, 0);
5121                buf = ostrcat(buf, "<link rel=stylesheet type=text/css href=titan.css><script type=text/javascript src=titan.js></script>", 1, 0);
5122                buf = ostrcat(buf, "</head><body class=body id=\"newsletterchoices\"><center>", 1, 0);
5123                buf = ostrcat(buf, "<br>", 1, 0);
5124                buf = ostrcat(buf, "<h1>", 1, 0);
5125                buf = ostrcat(buf, _("Newsletter"), 1, 0);
5126                buf = ostrcat(buf, "</h1>", 1, 0);
5127                buf = ostrcat(buf, "<br>", 1, 0);
5128        }
5129
5130        buf = ostrcat(buf, "<table cellpadding=5 cellspacing=5><tr><td nowrap>", 1, 0);
5131
5132        struct newsletter* node = NULL;
5133
5134        m_lock(&status.newslettermutex, 19);
5135        long unsigned lastnewsletter = getconfiglu("lastnewsletter", NULL);
5136
5137        readnewsletter();
5138        node = newsletter;
5139
5140        while(node != NULL)
5141        {
5142                buf = ostrcat(buf, "<a class=linelink2 href=queryraw?getnewsletter&", 1, 0);
5143                buf = ostrcat(buf, oitoa(node->nr), 1, 0);
5144                buf = ostrcat(buf, " target=main>", 1, 0);
5145                buf = ostrcat(buf, node->title, 1, 0);
5146                buf = ostrcat(buf, " - ", 1, 0);
5147                buf = ostrcat(buf, node->date, 1, 0);   
5148                buf = ostrcat(buf, "</a>", 1, 0);
5149                buf = ostrcat(buf, "</br></br>", 1, 0);
5150
5151                if(node->nr > lastnewsletter)
5152                        addconfiglu("lastnewsletter", node->nr);
5153
5154                node = node->next;
5155        }
5156
5157        freenewsletter();
5158        m_unlock(&status.newslettermutex, 19);
5159
5160        buf = string_replace_all("<br>", "<br>\n", buf, 1);
5161
5162        if(fmt == 0)
5163                buf = ostrcat(buf, "</td></tr></table></center></body></html>", 1, 0);
5164       
5165        return buf;
5166}
5167
5168char* webgetnewsletter(char* param, int fmt)
5169{
5170        char* buf = NULL, *tmpstr = NULL, *tmpstr1 = NULL;
5171
5172//      if(fmt == 0)
5173//      {
5174                buf = ostrcat(buf, "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">", 1, 0);
5175                buf = ostrcat(buf, "<link rel=stylesheet type=text/css href=titan.css><script type=text/javascript src=titan.js></script>", 1, 0);
5176                buf = ostrcat(buf, "</head><body class=body id=\"newsletter\"><center>", 1, 0);
5177//      }
5178
5179        struct newsletter* node = NULL;
5180
5181        m_lock(&status.newslettermutex, 19);
5182
5183        readnewsletter();
5184        node = newsletter;
5185
5186        while(node != NULL)
5187        {
5188                if(ostrcmp(oitoa(node->nr), param) == 0)       
5189                {
5190                        tmpstr1 = ostrcat(node->title, " - ", 0, 0);
5191                        tmpstr1 = ostrcat(tmpstr1, node->date, 1, 0);
5192                        tmpstr = ostrcat(node->text, "\n", 0, 0);
5193                        break;
5194                }
5195                node = node->next;
5196        }
5197
5198//      if(fmt == 0)
5199//      {
5200                buf = ostrcat(buf, "<br>", 1, 0);
5201                buf = ostrcat(buf, "<h1>", 1, 0);
5202                buf = ostrcat(buf, tmpstr1, 1, 0);
5203                buf = ostrcat(buf, "</h1>", 1, 0);
5204                buf = ostrcat(buf, "<br>", 1, 0);
5205//      }
5206
5207
5208        freenewsletter();
5209        m_unlock(&status.newslettermutex, 19);
5210
5211        tmpstr = string_replace_all("\n", "<br>\n", tmpstr, 1);
5212
5213        buf = ostrcat(buf, tmpstr, 1, 0);
5214
5215        free(tmpstr), tmpstr = NULL;
5216        free(tmpstr1), tmpstr1 = NULL;
5217        buf = string_replace_all("<br>", "<br>\n", buf, 1);
5218
5219//      if(fmt == 0)
5220                buf = ostrcat(buf, "</center></body></html>", 1, 0);
5221       
5222        return buf;
5223}
5224
5225char* webgetstreamingchoices(int fmt)
5226{
5227        char* buf = NULL, *tmpstr = NULL;
5228
5229        if(fmt == 0)
5230        {
5231                buf = ostrcat(buf, "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">", 1, 0);
5232                buf = ostrcat(buf, "<link rel=stylesheet type=text/css href=titan.css><script type=text/javascript src=titan.js></script>", 1, 0);
5233                buf = ostrcat(buf, "</head><body class=body id=\"streamingchoices\"><center>", 1, 0);
5234                buf = ostrcat(buf, "<br>", 1, 0);
5235                buf = ostrcat(buf, "<h1>", 1, 0);
5236                buf = ostrcat(buf, _("Streaming"), 1, 0);
5237                buf = ostrcat(buf, "</h1>", 1, 0);
5238                buf = ostrcat(buf, "<br>", 1, 0);
5239        }
5240
5241        int count = 0;
5242        struct service* servicenode = service;
5243
5244        while(servicenode != NULL)
5245        {
5246                if(servicenode->type == RECORDSTREAM && servicenode->recname != NULL)
5247                {
5248                        buf = ostrcat(buf, "<a class=linelink2 href=queryraw?getstreaming&", 1, 0);
5249                        tmpstr = htmlencode(servicenode->recname);
5250                        buf = ostrcat(buf, tmpstr, 1, 0);
5251                        buf = ostrcat(buf, " target=main>", 1, 0);
5252                        buf = ostrcat(buf, _("stop"), 1, 0);
5253                        buf = ostrcat(buf, " - ", 1, 0);
5254                        buf = ostrcat(buf, servicenode->recname, 1, 0);
5255                        buf = ostrcat(buf, " (", 1, 0);
5256                        if(servicenode->channel != NULL && servicenode->channel->name != NULL)
5257                                buf = ostrcat(buf, servicenode->channel->name, 1, 0);
5258                        else
5259                                buf = ostrcat(buf, _("unknown"), 1, 0);
5260                        buf = ostrcat(buf, ")", 1, 0);
5261                        buf = ostrcat(buf, "</a>", 1, 0);
5262                        buf = ostrcat(buf, "</br></br>", 1, 0);
5263                        count++;
5264                        free(tmpstr), tmpstr = NULL;
5265                }
5266                servicenode = servicenode->next;
5267        }
5268
5269        if(count == 0)
5270                buf = ostrcat(buf, _("No Live Stream running"), 1, 0);
5271
5272        buf = string_replace_all("<br>", "<br>\n", buf, 1);
5273
5274        if(fmt == 0)
5275                buf = ostrcat(buf, "</center></body></html>", 1, 0);
5276       
5277        return buf;
5278}
5279
5280char* webgetstreaming(char* param, int fmt)
5281{
5282        char* buf = NULL, *tmpstr = NULL;
5283
5284//      if(fmt == 0)
5285//      {
5286                buf = ostrcat(buf, "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">", 1, 0);
5287                buf = ostrcat(buf, "<link rel=stylesheet type=text/css href=titan.css><script type=text/javascript src=titan.js></script>", 1, 0);
5288                buf = ostrcat(buf, "</head><body class=body id=\"streaming\"><center>", 1, 0);
5289//      }
5290
5291        htmldecode(param, param);
5292
5293        struct service* servicenode = service;
5294        while(servicenode != NULL)
5295        {
5296                if(servicenode->recname != NULL && ostrcmp(servicenode->recname, param) == 0)
5297                {
5298                        tmpstr = ostrcat(tmpstr, _("stop"), 1, 0);
5299                        tmpstr = ostrcat(tmpstr, " ", 1, 0);
5300                        tmpstr = ostrcat(tmpstr, servicenode->recname, 1, 0);
5301                        tmpstr = ostrcat(tmpstr, " (", 1, 0);
5302                        if(servicenode->channel != NULL && servicenode->channel->name != NULL)
5303                                tmpstr = ostrcat(tmpstr, servicenode->channel->name, 1, 0);
5304                        else
5305                                tmpstr = ostrcat(tmpstr, _("unknown"), 1, 0);
5306                        tmpstr = ostrcat(tmpstr, ")", 1, 0);
5307                        break;
5308                }
5309                servicenode = servicenode->next;
5310        }
5311
5312//      if(fmt == 0)
5313//      {
5314                buf = ostrcat(buf, "<br>", 1, 0);
5315                buf = ostrcat(buf, "<h1>", 1, 0);
5316                buf = ostrcat(buf, tmpstr, 1, 0);
5317                buf = ostrcat(buf, "</h1>", 1, 0);
5318                buf = ostrcat(buf, "<br>", 1, 0);
5319//      }
5320
5321        servicenode = getrecordbyname(param, RECORDSTREAM);
5322        if(servicenode != NULL)
5323        {
5324                servicenode->recendtime = 1;
5325                buf = ostrcat(buf, _("Streaming succesfull stopped."), 1, 0);
5326        }
5327        else
5328                buf = ostrcat(buf, _("ERROR, Streaming can not be stopped."), 1, 0);
5329
5330        buf = string_replace_all("<br>", "<br>\n", buf, 1);
5331        free(tmpstr) , tmpstr = NULL;
5332
5333//      if(fmt == 0)
5334                buf = ostrcat(buf, "</center></body></html>", 1, 0);
5335       
5336        return buf;
5337}
5338
5339char* webgetupdatelist(char* param, int fmt)
5340{
5341        if(status.security == 0) return NULL;
5342
5343        char* buf = NULL, *tmpstr = NULL, *tmpstr1 = NULL, *cmd = NULL;
5344        int mode;
5345
5346        mode = atoi(param);
5347
5348        struct update* node = createupdatelist(mode);
5349
5350        if(fmt == 0)
5351        {
5352                buf = ostrcat(buf, "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">", 1, 0);
5353                buf = ostrcat(buf, "<link rel=stylesheet type=text/css href=titan.css><script type=text/javascript src=titan.js></script>", 1, 0);
5354                buf = ostrcat(buf, "</head><body class=body id=\"updatelist\">", 1, 0);
5355                buf = ostrcat(buf, "<br><center>", 1, 0);
5356                buf = ostrcat(buf, "<h1>", 1, 0);
5357                buf = ostrcat(buf, _("System Update"), 1, 0);
5358                buf = ostrcat(buf, "</h1>", 1, 0);
5359                buf = ostrcat(buf, "<br>", 1, 0);
5360        }
5361
5362        tmpstr = getimgnamereal();
5363        if(tmpstr != NULL)
5364        {
5365                buf = ostrcat(buf, _("Installed:"), 1, 0);
5366                buf = ostrcat(buf, " ", 1, 0);
5367                buf = ostrcat(buf, tmpstr, 1, 1);
5368                buf = ostrcat(buf, "<br><br>", 1, 0);
5369        }
5370
5371        if(mode == 0)
5372                tmpstr = command("ls -1 /tmp/online | grep .img | sort -r");
5373        else
5374                tmpstr = command("ls -1 /tmp | grep .img | sort -r");
5375       
5376        int count, i, max;
5377        count = 0;
5378        struct splitstr* ret1 = NULL;
5379        ret1 = strsplit(tmpstr, "\n", &count);
5380        max = count - 1;
5381
5382        buf = ostrcat(buf, "<table cellpadding=5 cellspacing=5><tr><td nowrap>", 1, 0);
5383 
5384        if(ret1 != NULL)
5385        {
5386                for(i = 0; i <= max; i++)
5387                {
5388                        buf = ostrcat(buf, "<a class=linelink2 href=queryraw?getupdate&", 1, 0);
5389
5390                        if(ostrstr(ret1[i].part, "_FULL_") != NULL)
5391                        {
5392                                cmd = ostrcat(cmd, "/sbin/update.sh ", 1, 0);
5393                                cmd = ostrcat(cmd, node->type, 1, 0);
5394                                cmd = ostrcat(cmd, " ", 1, 0);
5395
5396                                cmd = ostrcat(cmd, "full ", 1, 0);
5397
5398                                if(mode == 0)
5399                                        cmd = ostrcat(cmd, "/tmp/online/", 1, 0);
5400                                else
5401                                        cmd = ostrcat(cmd, "/tmp/", 1, 0);
5402                                cmd = ostrcat(cmd, ret1[i].part, 1, 0);
5403
5404                                cmd = ostrcat(cmd, node->auth, 1, 0);
5405                                if(node->imgtype == 1)
5406                                        cmd = ostrcat(cmd, " dev beta.dyndns.tv", 1, 0);
5407                                else
5408                                        cmd = ostrcat(cmd, " release atemio.dyndns.tv", 1, 0);
5409                                if(file_exist("/var/swap"))
5410                                {
5411                                        if(!file_exist("/var/swap/logs"))
5412                                                 mkdir("/var/swap/logs", 777);
5413                               
5414                                        if(file_exist("/etc/.beta") && file_exist("/var/swap/logs"))
5415                                                cmd = ostrcat(cmd, " > /var/swap/logs/update_debug.log 2>&1", 1, 0);           
5416                                }
5417                                else if(checkbox("ATEMIO510") != 1 && checkbox("UFS910") != 1 && checkbox("UFS922") != 1 && checkbox("ATEVIO700") != 1 && checkbox("ATEVIO7000") != 1 && checkbox("IPBOX91") != 1 && checkbox("IPBOX900") != 1 && checkbox("IPBOX910") != 1 && checkbox("IPBOX9000") != 1)
5418                                {
5419                                        if(!file_exist("/mnt/logs"))
5420                                                 mkdir("/mnt/logs", 777);
5421                               
5422                                        if(file_exist("/etc/.beta") && file_exist("/mnt/logs"))
5423                                                cmd = ostrcat(cmd, " > /mnt/logs/update_debug.log 2>&1", 1, 0);
5424                                }
5425                                tmpstr1 = htmlencode(cmd);
5426                                buf = ostrcat(buf, tmpstr1, 1, 0);
5427                                free(tmpstr1), tmpstr1 = NULL;
5428                                free(cmd), cmd = NULL;
5429                        }
5430
5431                        buf = ostrcat(buf, " target=main>", 1, 0);
5432                        buf = ostrcat(buf, _(stringreplacecharonce(ret1[i].part, '.', '\0')), 1, 0);
5433                        buf = ostrcat(buf, "</a>", 1, 0);
5434                        buf = ostrcat(buf, "</br></br>", 1, 0);
5435                }
5436        }
5437
5438        free(tmpstr), tmpstr = NULL;
5439        free(ret1), ret1 = NULL;
5440
5441        buf = string_replace_all("<br>", "<br>\n", buf, 1);
5442
5443        if(fmt == 0)
5444                buf = ostrcat(buf, "</td></tr></table></center></body></html>", 1, 0);
5445
5446// needed ??
5447//      freeupdatelist(node);
5448
5449        return buf;
5450}
5451
5452char* webgetupdate(char* param, int fmt)
5453{
5454        if(status.security == 0) return NULL;
5455
5456        char* buf = NULL, *cmd = NULL;
5457        printf("param: %s\n",param);
5458
5459//      if(fmt == 0)
5460//      {
5461                buf = ostrcat(buf, "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">", 1, 0);
5462                buf = ostrcat(buf, "<link rel=stylesheet type=text/css href=titan.css><script type=text/javascript src=titan.js></script>", 1, 0);
5463                buf = ostrcat(buf, "</head><body class=body id=\"updatelist\"><center>", 1, 0);
5464                buf = ostrcat(buf, "<br>", 1, 0);
5465                buf = ostrcat(buf, "<h1 id=\"updatetitle\">", 1, 0);
5466                buf = ostrcat(buf, _("System Update"), 1, 0);
5467                buf = ostrcat(buf, "</h1>", 1, 0);
5468                buf = ostrcat(buf, "<br>", 1, 0);
5469//      }
5470
5471        writeallconfig(1);
5472
5473        cmd = htmlencode(param);
5474
5475        buf = ostrcat(buf, "<title>", 1, 0);
5476        buf = ostrcat(buf, _("Message"), 1, 0);
5477        buf = ostrcat(buf, "</title>\n", 1, 0);
5478        buf = ostrcat(buf, " <script type=\"text/javascript\">\n", 1, 0);
5479        buf = ostrcat(buf, "var bRepeat=confirm(\"", 1, 0);
5480        buf = ostrcat(buf, _("starting Full Update ?"), 1, 0);
5481        buf = ostrcat(buf, "\");\n", 1, 0);
5482        buf = ostrcat(buf, "if(bRepeat==true)\n", 1, 0);
5483        buf = ostrcat(buf, "{\n", 1, 0);
5484        buf = ostrcat(buf, "document.getElementById(\"updatetitle\").innerHTML = \"", 1, 0);
5485        buf = ostrcat(buf, _("System Update started Please wait 5 Minutes and Refresh this Page, more infos they see on your TV."), 1, 0);
5486        buf = ostrcat(buf, "\";\n", 1, 0);
5487        buf = ostrcat(buf, "window.location = \"../queryraw?getsystem&", 1, 0);
5488        buf = ostrcat(buf, cmd, 1, 0);
5489        buf = ostrcat(buf, "\";\n", 1, 0);
5490        buf = ostrcat(buf, "}\n", 1, 0);
5491        buf = ostrcat(buf, "else\n", 1, 0);
5492        buf = ostrcat(buf, "alert(\"exit\");\n", 1, 0);
5493        buf = ostrcat(buf, "</script>\n", 1, 0);
5494
5495        buf = string_replace_all("<br>", "<br>\n", buf, 1);
5496
5497        free(cmd), cmd = NULL;
5498       
5499//      if(fmt == 0)
5500                buf = ostrcat(buf, "</center></body></html>", 1, 0);
5501
5502        return buf;
5503}
5504
5505char* webgettpksection(int fmt)
5506{
5507        if(status.security == 0) return NULL;
5508
5509        char* buf = NULL;
5510
5511        if(fmt == 0)
5512        {
5513                buf = ostrcat(buf, "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">", 1, 0);
5514                buf = ostrcat(buf, "<link rel=stylesheet type=text/css href=titan.css><script type=text/javascript src=titan.js></script>", 1, 0);
5515                buf = ostrcat(buf, "</head><body class=body id=\"tpksection\"><center>", 1, 0);
5516                buf = ostrcat(buf, "<br>", 1, 0);
5517                buf = ostrcat(buf, "<h1>", 1, 0);
5518                buf = ostrcat(buf, _("Tpk Install - select section"), 1, 0);
5519                buf = ostrcat(buf, "</h1>", 1, 0);
5520                buf = ostrcat(buf, "<br>", 1, 0);
5521        }
5522
5523        status.hangtime = 99999;
5524
5525        unlink(TPKLOG);
5526        tpkgetindex(0);
5527        tpklist();
5528
5529        struct tpk* node = tpk;
5530
5531        if(node == NULL) buf = ostrcat(buf, _("No Tpk Sections Found."), 1, 0);
5532       
5533        while(node != NULL)
5534        {
5535                if(findsectiondone(node->section) == 1)
5536                {
5537                        node = node->next;
5538                        continue;
5539                }
5540
5541                node->done = 1;
5542
5543                buf = ostrcat(buf, "<a class=linelink2 href=queryraw?gettpklist&", 1, 0);
5544                buf = ostrcat(buf, node->section, 1, 0);
5545                buf = ostrcat(buf, " target=main>", 1, 0);
5546                buf = ostrcat(buf, _(node->section), 1, 0);
5547                buf = ostrcat(buf, "</a>", 1, 0);
5548                buf = ostrcat(buf, "</br></br>", 1, 0);
5549
5550                node = node->next;
5551        }
5552
5553        freetpk();
5554
5555        buf = string_replace_all("<br>", "<br>\n", buf, 1);
5556
5557        if(fmt == 0)
5558        {
5559                buf = ostrcat(buf, "</center></body></html>", 1, 0);
5560        }       
5561
5562        tpkcleantmp(0);
5563        status.hangtime = getconfigint("hangtime", NULL);
5564       
5565        return buf;
5566}
5567
5568char* webgettpklist(char* param, int fmt)
5569{
5570        if(status.security == 0) return NULL;
5571        int skip = 0;
5572
5573        char* buf = NULL;
5574
5575//      if(fmt == 0)
5576//      {
5577                buf = ostrcat(buf, "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">", 1, 0);
5578                buf = ostrcat(buf, "<link rel=stylesheet type=text/css href=titan.css><script type=text/javascript src=titan.js></script>", 1, 0);
5579                buf = ostrcat(buf, "</head><body class=body id=\"tpklist\"><center>", 1, 0);
5580                buf = ostrcat(buf, "<br>", 1, 0);
5581                buf = ostrcat(buf, "<h1>", 1, 0);
5582                buf = ostrcat(buf, _("Tpk Install - select file"), 1, 0);
5583                buf = ostrcat(buf, "</h1>", 1, 0);
5584                buf = ostrcat(buf, "<br>", 1, 0);
5585//      }
5586
5587        status.hangtime = 99999;
5588
5589        unlink(TPKLOG);
5590        tpkgetindex(0);
5591        tpklist();
5592
5593        struct tpk* node = tpk, *tpk_installed = NULL, *node_installed = NULL;
5594
5595        if(node == NULL) buf = ostrcat(buf, _("No Tpk Files Found."), 1, 0);
5596
5597        tpk = NULL;
5598        tpklistinstalled(0);
5599        tpk_installed = tpk;
5600        tpk = node;
5601               
5602        while(node != NULL)
5603        {
5604                node_installed = tpk_installed;
5605                skip = 0;
5606                while(node_installed != NULL)
5607                {
5608                        if(ostrcmp(node->section, node_installed->section) == 0 && ostrcmp(node->showname, node_installed->showname) == 0)
5609                        {
5610                                skip = 1;
5611                                break;
5612                        }
5613                        node_installed = node_installed->next;
5614                }
5615               
5616                //check if tpk is in section
5617                if(param != NULL && ostrcmp(node->section, param) != 0)
5618                        skip = 1;
5619
5620                if(skip == 1)
5621                {
5622                        node = node->next;
5623                        continue;
5624                }
5625
5626                buf = ostrcat(buf, "<a class=linelink2 href=queryraw?gettpkinstallpath&", 1, 0);
5627                buf = ostrcat(buf, node->filename, 1, 0);
5628                buf = ostrcat(buf, " target=main>", 1, 0);
5629                buf = ostrcat(buf, _(node->showname), 1, 0);
5630                buf = ostrcat(buf, " v.", 1, 0);
5631                buf = ostrcat(buf, oitoa(node->version), 1, 1);
5632                buf = ostrcat(buf, "</a>", 1, 0);
5633                buf = ostrcat(buf, "</br></br>", 1, 0);
5634
5635                node = node->next;
5636        }
5637
5638        freetpk();
5639        tpkcleantmp(0);
5640        status.hangtime = getconfigint("hangtime", NULL);
5641
5642        buf = string_replace_all("<br>", "<br>\n", buf, 1);
5643
5644//      if(fmt == 0)
5645//      {
5646                buf = ostrcat(buf, "</center></body></html>", 1, 0);
5647//      }       
5648       
5649        return buf;
5650}
5651
5652char* webgettpkinstallpath(char* param, int fmt)
5653{
5654        if(status.security == 0) return NULL;
5655
5656        char* buf = NULL, *tmpstr = NULL, *path = NULL, *url = NULL, *showname = NULL;
5657        int count = 0, size = 0;
5658
5659        status.hangtime = 99999;
5660
5661        unlink(TPKLOG);
5662        tpkgetindex(0);
5663        tpklist();
5664
5665        struct tpk* node = tpk;
5666
5667        while(node != NULL)
5668        {
5669                if(ostrcmp(node->filename, param) == 0)
5670                {
5671                        size = node->size;
5672                        showname = ostrcat(node->showname, NULL, 0, 0);
5673                        url = htmlencode(node->url);
5674                        path = ostrcat(node->usepath, NULL, 0, 0);
5675                        break;
5676                }
5677                node = node->next;
5678        }
5679
5680//      if(fmt == 0)
5681//      {
5682                buf = ostrcat(buf, "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">", 1, 0);
5683                buf = ostrcat(buf, "<link rel=stylesheet type=text/css href=titan.css><script type=text/javascript src=titan.js></script>", 1, 0);
5684                buf = ostrcat(buf, "</head><body class=body id=\"tpkinstallpath\"><center>", 1, 0);
5685                buf = ostrcat(buf, "<br>", 1, 0);
5686                buf = ostrcat(buf, "<h1>", 1, 0);
5687                buf = ostrcat(buf, _("Choice Install Medium"), 1, 0);
5688                buf = ostrcat(buf, "</h1>", 1, 0);
5689                buf = ostrcat(buf, "<br>", 1, 0);
5690//      }
5691
5692        if(path == NULL || path[0] == '*' || ostrstr(path, "mnt") != NULL)
5693        {
5694                if(tpkchecksize(NULL, "/mnt/swapextensions", size) == 0)
5695                {
5696                        tmpstr = ostrcat(tmpstr, "<a class=linelink2 href=queryraw?gettpkinstall&", 1, 0);
5697                        tmpstr = ostrcat(tmpstr, param, 1, 0);
5698                        tmpstr = ostrcat(tmpstr, "&", 1, 0);
5699                        tmpstr = ostrcat(tmpstr, url, 1, 0);
5700                        tmpstr = ostrcat(tmpstr, "&", 1, 0);
5701                        tmpstr = ostrcat(tmpstr, "/mnt/swapextensions", 1, 0);
5702                        tmpstr = ostrcat(tmpstr, " target=main>", 1, 0);
5703                        tmpstr = ostrcat(tmpstr, _("Install to MNT"), 1, 0);
5704                        tmpstr = ostrcat(tmpstr, "</a>\n", 1, 0);
5705                        tmpstr = ostrcat(tmpstr, "</br></br>\n", 1, 0);
5706                        count++;
5707                }
5708        }
5709       
5710        if(path == NULL || path[0] == '*' || ostrstr(path, "var") != NULL)
5711        {
5712                if(tpkchecksize(NULL, "/var", size) == 0)
5713                {
5714                        tmpstr = ostrcat(tmpstr, "<a class=linelink2 href=queryraw?gettpkinstall&", 1, 0);
5715                        tmpstr = ostrcat(tmpstr, param, 1, 0);
5716                        tmpstr = ostrcat(tmpstr, "&", 1, 0);
5717                        tmpstr = ostrcat(tmpstr, url, 1, 0);
5718                        tmpstr = ostrcat(tmpstr, "&", 1, 0);
5719                        tmpstr = ostrcat(tmpstr, "/var", 1, 0);
5720                        tmpstr = ostrcat(tmpstr, " target=main>", 1, 0);
5721                        tmpstr = ostrcat(tmpstr, _("Install to FLASH"), 1, 0);
5722                        tmpstr = ostrcat(tmpstr, "</a>\n", 1, 0);
5723                        tmpstr = ostrcat(tmpstr, "</br></br>\n", 1, 0);
5724                        count++;
5725                }
5726        }
5727       
5728        if(path == NULL || path[0] == '*' || ostrstr(path, "swap") != NULL)
5729        {
5730                if(file_exist("/tmp/.swapextensionsdev") == 1 || file_exist("/var/swap"))
5731                {
5732                        if(tpkchecksize(NULL, "/var/swap", size) == 0)
5733                        {
5734                                tmpstr = ostrcat(tmpstr, "<a class=linelink2 href=queryraw?gettpkinstall&", 1, 0);
5735                                tmpstr = ostrcat(tmpstr, param, 1, 0);
5736                                tmpstr = ostrcat(tmpstr, "&", 1, 0);
5737                                tmpstr = ostrcat(tmpstr, url, 1, 0);
5738                                tmpstr = ostrcat(tmpstr, "&", 1, 0);
5739                                tmpstr = ostrcat(tmpstr, "/var/swap", 1, 0);
5740                                tmpstr = ostrcat(tmpstr, " target=main>", 1, 0);
5741                                tmpstr = ostrcat(tmpstr, _("Install to SWAP"), 1, 0);
5742                                tmpstr = ostrcat(tmpstr, "</a>", 1, 0);
5743                                tmpstr = ostrcat(tmpstr, "</br></br>", 1, 0);
5744                                count++;
5745                        }
5746                }
5747        }
5748
5749        if(node == NULL && tmpstr == NULL) buf = ostrcat(buf, _("No Tpk Files Found."), 1, 0);
5750        freetpk();
5751
5752        if(count == 0)
5753        {
5754                buf = ostrcat(buf, "<br>", 1, 0);
5755                buf = ostrcat(buf, _("Can't install Package. Package to big."), 1, 0);
5756        }
5757
5758        buf = ostrcat(buf, tmpstr, 1, 0);
5759
5760        buf = string_replace_all("<br>", "<br>\n", buf, 1);
5761
5762        free(tmpstr), tmpstr = NULL;
5763        free(showname), showname = NULL;
5764        free(url), url = NULL;
5765        free(path), path = NULL;
5766
5767        tpkcleantmp(0);
5768        status.hangtime = getconfigint("hangtime", NULL);
5769       
5770//      if(fmt == 0)
5771//      {
5772                buf = ostrcat(buf, "</center></body></html>", 1, 0);
5773//      }       
5774       
5775        return buf;
5776}
5777
5778char* webgettpkinstall(char* param, int fmt)
5779{
5780        if(status.security == 0) return NULL;
5781
5782        char* buf = NULL, *tmpstr = NULL, *param1 = NULL, *param2 = NULL;
5783
5784        //create param1
5785        param1 = strchr(param, '&');
5786        if(param1 != NULL)
5787                *param1++ = '\0';
5788
5789        //create param2
5790        param2 = strchr(param1, '&');
5791        if(param2 != NULL)
5792                *param2++ = '\0';
5793
5794        if(param == NULL) return NULL;
5795        if(param1 == NULL) return NULL;
5796        if(param2 == NULL) return NULL;
5797
5798        status.hangtime = 99999;
5799
5800        char* log = NULL;
5801        int tpkret = tpkgetpackage(param, param1, param2, 0, 1);
5802
5803        if(tpkret == 0)
5804                tmpstr = ostrcat(_("Tpk Install Info - Install OK"), NULL, 0, 0);
5805        else if(tpkret == 2)
5806                tmpstr = ostrcat(_("Tpk Install Info - Install ERROR"), NULL, 0, 0);
5807        else
5808                tmpstr = ostrcat(_("Tpk Install Info - Install ERROR"), NULL, 0, 0);
5809
5810//      if(fmt == 0)
5811//      {
5812                buf = ostrcat(buf, "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">", 1, 0);
5813                buf = ostrcat(buf, "<link rel=stylesheet type=text/css href=titan.css><script type=text/javascript src=titan.js></script>", 1, 0);
5814                buf = ostrcat(buf, "</head><body class=body id=\"tpkinstall\"><center>", 1, 0);
5815                buf = ostrcat(buf, "<br>", 1, 0);
5816                buf = ostrcat(buf, "<h1>", 1, 0);
5817                buf = ostrcat(buf, _(tmpstr), 1, 0);
5818                buf = ostrcat(buf, "</h1>", 1, 0);
5819                buf = ostrcat(buf, "<br>", 1, 0);
5820                buf = ostrcat(buf, "<br>", 1, 0);
5821//      }
5822
5823        free(tmpstr), tmpstr = NULL;
5824
5825        if(tpkret == 0)
5826        {
5827                log = gettpklog(param2, 0);
5828                log = string_replace_all("\n", "<br>\n", log, 1);
5829                buf = ostrcat(buf, "<br>", 1, 0);
5830                buf = ostrcat(buf, _("Install Log:"), 1, 0);
5831                buf = ostrcat(buf, "<br>", 1, 0);
5832                buf = ostrcat(buf, "<br>", 1, 0);
5833                buf = ostrcat(buf, log, 1, 0);
5834        }
5835        else if(tpkret == 2)
5836        {
5837                buf = ostrcat(buf, "<br>", 1, 0);
5838                buf = ostrcat(buf, _("Install Log:"), 1, 0);
5839                buf = ostrcat(buf, "<br>", 1, 0);
5840                buf = ostrcat(buf, "<br>", 1, 0);
5841                buf = ostrcat(buf, _("It may only be a package to be installed. If they want to install another package of this section, they only remove the installed packet. Is not the plugin after reinstalling the software TitanNit in TitanNit Menu Visible then perform an update by Tpk to: "), 1, 0);
5842        }
5843        else
5844        {
5845                log = gettpklog(param2, 1);
5846                log = string_replace_all("\n", "<br>\n", log, 1);
5847                buf = ostrcat(buf, "<br>", 1, 0);
5848                buf = ostrcat(buf, _("Install Log:"), 1, 0);
5849                buf = ostrcat(buf, "<br>", 1, 0);
5850                buf = ostrcat(buf, "<br>", 1, 0);
5851                buf = ostrcat(buf, log, 1, 0);
5852        }
5853
5854        buf = string_replace_all("<br>", "<br>\n", buf, 1);
5855
5856        loadplugin();
5857        free(log), log = NULL;
5858        unlink(TPKLOG);
5859        if(file_exist("/tmp/.tpk_needs_reboot"))
5860        {
5861// need other..
5862                textbox(_("Message"), _("TPK Install done, your system will reboot !"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 800, 200, 0, 0);
5863                buf = ostrcat(buf, "<br>", 1, 0);
5864                buf = ostrcat(buf, _("TPK Install done, your system will reboot !"), 1, 0);
5865                buf = string_replace_all("<br>", "<br>\n", buf, 1);
5866                //write only config file
5867                writeallconfig(3);
5868                oshutdown(2,2);
5869                system("init 6");
5870        }
5871
5872        status.hangtime = getconfigint("hangtime", NULL);
5873
5874//      if(fmt == 0)
5875//      {
5876                buf = ostrcat(buf, "</center></body></html>", 1, 0);
5877//      }       
5878       
5879        return buf;
5880}
5881
5882char* webgettpktmplist(char* param, int fmt)
5883{
5884        if(status.security == 0) return NULL;
5885        int mode = atoi(param);
5886
5887        char* buf = NULL, *tmpstr = NULL, *tmpstr1 = NULL, *tmpstr2 = NULL, *tmpstr3 = NULL;
5888
5889        if(fmt == 0)
5890        {
5891                buf = ostrcat(buf, "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">", 1, 0);
5892                buf = ostrcat(buf, "<link rel=stylesheet type=text/css href=titan.css><script type=text/javascript src=titan.js></script>", 1, 0);
5893                buf = ostrcat(buf, "</head><body class=body id=\"tpktmplist\"><center>", 1, 0);
5894                buf = ostrcat(buf, "<br>", 1, 0);
5895                buf = ostrcat(buf, "<h1>", 1, 0);
5896                if(mode == 0)
5897                        buf = ostrcat(buf, _("TPK tmp (tmp)"), 1, 0);
5898                else
5899                        buf = ostrcat(buf, _("TPK media (media)"), 1, 0);
5900               
5901                buf = ostrcat(buf, "</h1>", 1, 0);
5902                buf = ostrcat(buf, "<br>", 1, 0);
5903        }
5904
5905        if(mode == 0)
5906                tmpstr = gettpktmplist("/tmp");
5907        else
5908        {
5909                int treffer = 0;
5910                struct hdd *node = NULL;
5911
5912                addhddall();
5913                node = hdd;
5914       
5915                while(node != NULL)
5916                {
5917                        if(node->partition != 0)
5918                        {
5919                                tmpstr1 = ostrcat("/autofs/", node->device, 0, 0);
5920                                tmpstr2 = gettpktmplist(tmpstr1);
5921       
5922                                if(tmpstr2 != NULL)
5923                                {
5924                                        treffer = 1;
5925//                                      screenextensions(2, tmpstr1, NULL, 1);
5926                                        tmpstr3 = ostrcat(tmpstr3, tmpstr1, 1, 0);                                     
5927                                        tmpstr3 = ostrcat(tmpstr3, "\n", 1, 0);
5928                                }
5929       
5930                                free(tmpstr1); tmpstr1 = NULL;
5931                                free(tmpstr2); tmpstr2 = NULL;
5932                        }
5933                        node = node->next;
5934                }
5935       
5936                tmpstr = gettpktmplist(tmpstr3);       
5937                free(tmpstr3), tmpstr = NULL;
5938        }
5939       
5940        if(mode == 0)
5941        {
5942                if(tmpstr == NULL) buf = ostrcat(buf, _("No Tpk Files Found on /tmp Directory."), 1, 0);
5943        }
5944        else
5945        {
5946                if(tmpstr == NULL) buf = ostrcat(buf, _("No Tpk Files Found on Media Devices."), 1, 0);
5947        }
5948
5949        int count, i, max;
5950        count = 0;
5951        struct splitstr* ret1 = NULL;
5952        ret1 = strsplit(tmpstr, "\n", &count);
5953        max = count - 1;
5954
5955        buf = ostrcat(buf, "<table cellpadding=5 cellspacing=5><tr><td nowrap>", 1, 0);
5956 
5957        if(ret1 != NULL)
5958        {
5959                for(i = 0; i <= max; i++)
5960                {
5961                        buf = ostrcat(buf, "<a class=linelink2 href=queryraw?gettpkinstallpath&", 1, 0);
5962                        buf = ostrcat(buf, ret1[i].part, 1, 0);
5963                        buf = ostrcat(buf, " target=main>", 1, 0);
5964                        buf = ostrcat(buf, _(stringreplacecharonce(ret1[i].part, '.', '\0')), 1, 0);
5965                        buf = ostrcat(buf, "</a>", 1, 0);
5966                        buf = ostrcat(buf, "</br></br>", 1, 0);
5967                }
5968        }
5969
5970        free(tmpstr), tmpstr = NULL;
5971        free(ret1), ret1 = NULL;
5972
5973        buf = string_replace_all("<br>", "<br>\n", buf, 1);
5974
5975        if(fmt == 0)
5976        {
5977                buf = ostrcat(buf, "</center></body></html>", 1, 0);
5978        }       
5979       
5980        return buf;
5981}
5982
5983char* webgettpkremovelist(int fmt)
5984{
5985        if(status.security == 0) return NULL;
5986
5987        char* buf = NULL;
5988        int skip;
5989
5990//      if(fmt == 0)
5991//      {
5992                buf = ostrcat(buf, "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">", 1, 0);
5993                buf = ostrcat(buf, "<link rel=stylesheet type=text/css href=titan.css><script type=text/javascript src=titan.js></script>", 1, 0);
5994                buf = ostrcat(buf, "</head><body class=body id=\"tpkremovelist\"><center>", 1, 0);
5995                buf = ostrcat(buf, "<br>", 1, 0);
5996                buf = ostrcat(buf, "<h1>", 1, 0);
5997                buf = ostrcat(buf, _("Tpk Remove - select file"), 1, 0);
5998                buf = ostrcat(buf, "</h1>", 1, 0);
5999                buf = ostrcat(buf, "<br>", 1, 0);
6000//      }
6001
6002        status.hangtime = 99999;
6003
6004        unlink(TPKLOG);
6005        tpkgetindex(0);
6006        tpklist();
6007
6008        struct tpk* node = tpk, *tpk_installed = NULL, *node_installed = NULL;
6009
6010        if(node == NULL) buf = ostrcat(buf, _("No Tpk Files Found."), 1, 0);
6011
6012        tpk = NULL;
6013        tpklistinstalled(0);
6014        tpk_installed = tpk;
6015        tpk = node;
6016       
6017        while(node != NULL)
6018        {
6019                node_installed = tpk_installed;
6020                skip = 1;
6021                while(node_installed != NULL)
6022                {
6023                        if(ostrcmp(node->showname, node_installed->showname) == 0)
6024                        {
6025                                skip = 0;
6026                                break;
6027                        }
6028                        node_installed = node_installed->next;
6029                }
6030
6031                if(skip == 1)
6032                {
6033                        node = node->next;
6034                        continue;
6035                }
6036
6037                buf = ostrcat(buf, "<a class=linelink2 href=queryraw?gettpkremove&", 1, 0);
6038                buf = ostrcat(buf, node->name, 1, 0);
6039                buf = ostrcat(buf, " target=main>", 1, 0);
6040                buf = ostrcat(buf, _(node->showname), 1, 0);
6041                buf = ostrcat(buf, " (", 1, 0);
6042                buf = ostrcat(buf, _(node->section), 1, 0);
6043                buf = ostrcat(buf, ")</a>", 1, 0);
6044                buf = ostrcat(buf, "</br></br>", 1, 0);
6045
6046                node = node->next;
6047        }
6048
6049        freetpk();
6050        tpkcleantmp(0);
6051        status.hangtime = getconfigint("hangtime", NULL);
6052
6053        buf = string_replace_all("<br>", "<br>\n", buf, 1);
6054
6055//      if(fmt == 0)
6056//      {
6057                buf = ostrcat(buf, "</center></body></html>", 1, 0);
6058//      }       
6059       
6060        return buf;
6061}
6062
6063char* webgettpkremove(char* param, int fmt)
6064{
6065        if(status.security == 0) return NULL;
6066
6067        char* buf = NULL, *tmpstr = NULL;
6068
6069        status.hangtime = 99999;
6070
6071        char* log = NULL;
6072
6073        int tpkret = tpkremove(param, 0, 0);
6074
6075        if(tpkret == 0)
6076        {
6077                tmpstr = ostrcat(_("Tpk Remove Info - Remove OK"), NULL, 0, 0);
6078                if(param != NULL && param[0] != '*') delplugin(param);
6079        }
6080        else
6081                tmpstr = ostrcat(_("Tpk Remove Info - Remove ERROR"), NULL, 0, 0);
6082
6083//      if(fmt == 0)
6084//      {
6085                buf = ostrcat(buf, "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">", 1, 0);
6086                buf = ostrcat(buf, "<link rel=stylesheet type=text/css href=titan.css><script type=text/javascript src=titan.js></script>", 1, 0);
6087                buf = ostrcat(buf, "</head><body class=body id=\"tpkremove\"><center>", 1, 0);
6088                buf = ostrcat(buf, "<br>", 1, 0);
6089                buf = ostrcat(buf, "<h1>", 1, 0);
6090                buf = ostrcat(buf, _(tmpstr), 1, 0);
6091                buf = ostrcat(buf, "</h1>", 1, 0);
6092                buf = ostrcat(buf, "<br>", 1, 0);
6093                buf = ostrcat(buf, "<br>", 1, 0);
6094//      }
6095
6096        free(tmpstr), tmpstr = NULL;
6097
6098        if(tpkret == 0)
6099        {
6100                log = gettpklog(NULL, 2);
6101                log = string_replace_all("\n", "<br>\n", log, 1);
6102                buf = ostrcat(buf, "<br>", 1, 0);
6103                buf = ostrcat(buf, _("Remove Log:"), 1, 0);
6104                buf = ostrcat(buf, "<br>", 1, 0);
6105                buf = ostrcat(buf, "<br>", 1, 0);
6106                buf = ostrcat(buf, log, 1, 0);
6107        }
6108        else
6109        {
6110                log = gettpklog(NULL, 3);
6111                log = string_replace_all("\n", "<br>\n", log, 1);
6112                buf = ostrcat(buf, "<br>", 1, 0);
6113                buf = ostrcat(buf, _("Remove Log:"), 1, 0);
6114                buf = ostrcat(buf, "<br>", 1, 0);
6115                buf = ostrcat(buf, "<br>", 1, 0);
6116                buf = ostrcat(buf, log, 1, 0);
6117        }
6118
6119        buf = string_replace_all("<br>", "<br>\n", buf, 1);
6120
6121        loadplugin();
6122        free(log), log = NULL;
6123        unlink(TPKLOG);
6124        if(file_exist("/tmp/.tpk_needs_reboot"))
6125        {
6126// need other..
6127                textbox(_("Message"), _("TPK Remove done, your system will reboot !"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 800, 200, 0, 0);
6128                buf = ostrcat(buf, "<br>", 1, 0);
6129                buf = ostrcat(buf, _("TPK Install done, your system will reboot !"), 1, 0);
6130                buf = string_replace_all("<br>", "<br>\n", buf, 1);
6131                //write only config file
6132                writeallconfig(3);
6133                oshutdown(2,2);
6134                system("init 6");
6135        }
6136
6137        status.hangtime = getconfigint("hangtime", NULL);
6138
6139//      if(fmt == 0)
6140//      {
6141                buf = ostrcat(buf, "</center></body></html>", 1, 0);
6142//      }       
6143       
6144        return buf;
6145}
6146
6147char* webgettpkupgrade(int fmt)
6148{
6149        if(status.security == 0) return NULL;
6150
6151        char* buf = NULL;
6152
6153        status.hangtime = 99999;
6154
6155        if(fmt == 0)
6156        {
6157                buf = ostrcat(buf, "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">", 1, 0);
6158                buf = ostrcat(buf, "<link rel=stylesheet type=text/css href=titan.css><script type=text/javascript src=titan.js></script>", 1, 0);
6159                buf = ostrcat(buf, "</head><body class=body id=\"tpkupgrade\"><center>", 1, 0);
6160        }
6161
6162        if(tpkgetindex(1) != 0)
6163        {
6164                buf = ostrcat(buf, "<br>", 1, 0);
6165                buf = ostrcat(buf, "<h1>", 1, 0);
6166                buf = ostrcat(buf, _("Tpk Update Info - Update ERROR"), 1, 0);
6167                buf = ostrcat(buf, "</h1>", 1, 0);
6168                buf = ostrcat(buf, "<br>", 1, 0);
6169                buf = ostrcat(buf, _("Can't get all TPK index !"), 1, 0);
6170                buf = ostrcat(buf, "<br>", 1, 0);
6171        }
6172               
6173        writesys("/tmp/.tpk_upgrade_start", "0", 0);
6174        if(tpkupdate(0) != 0)
6175        {
6176                buf = ostrcat(buf, "<br>", 1, 0);
6177                buf = ostrcat(buf, "<h1>", 1, 0);
6178                buf = ostrcat(buf, _("Tpk Update Info - Update ERROR"), 1, 0);
6179                buf = ostrcat(buf, "</h1>", 1, 0);
6180                buf = ostrcat(buf, "<br>", 1, 0);
6181                buf = ostrcat(buf, _("Can't update all packages !"), 1, 0);
6182                buf = ostrcat(buf, "<br>", 1, 0);
6183        }
6184        else
6185        {
6186                buf = ostrcat(buf, "<br>", 1, 0);
6187                buf = ostrcat(buf, "<h1>", 1, 0);
6188                buf = ostrcat(buf, _("Tpk Update Info - Update OK"), 1, 0);
6189                buf = ostrcat(buf, "</h1>", 1, 0);
6190                buf = ostrcat(buf, "<br>", 1, 0);
6191        }
6192
6193        loadplugin();
6194        unlink(TPKLOG);
6195
6196        if(file_exist("/tmp/.tpk_needs_reboot"))
6197        {
6198                textbox(_("Message"), _("TPK Upgrade done, your system will reboot !"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 200, 0, 0);
6199                //write only config file
6200                writeallconfig(3);
6201                oshutdown(2,2);
6202                system("init 6");
6203        }
6204        unlink("/tmp/.tpk_upgrade_start");
6205
6206        status.hangtime = getconfigint("hangtime", NULL);
6207
6208        if(fmt == 0)
6209        {
6210                buf = ostrcat(buf, "</center></body></html>", 1, 0);
6211        }       
6212       
6213        return buf;
6214}
6215
6216char* webgetserviceinfo(int fmt)
6217{
6218        char* buf = NULL, *tmpstr = NULL;
6219
6220        if(fmt == 0)
6221        {
6222                buf = ostrcat(buf, "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">", 1, 0);
6223                buf = ostrcat(buf, "<link rel=stylesheet type=text/css href=titan.css><script type=text/javascript src=titan.js></script>", 1, 0);
6224                buf = ostrcat(buf, "</head><body class=body id=\"serviceinfo\"><center>", 1, 0);
6225                buf = ostrcat(buf, "<br>", 1, 0);
6226                buf = ostrcat(buf, "<h1>", 1, 0);
6227                buf = ostrcat(buf, _("Service"), 1, 0);
6228                buf = ostrcat(buf, "</h1>", 1, 0);
6229                buf = ostrcat(buf, "<br>", 1, 0);
6230        }
6231
6232//      tmpstr = getabout();
6233//      readnewsletter();
6234        tmpstr = readfiletomem("/tmp/Service.txt", 0);
6235        tmpstr = ostrcat(tmpstr, "\ncomming soon...\n", 1, 0);
6236       
6237        tmpstr = string_replace_all("\n", "<br>\n", tmpstr, 1);
6238
6239        buf = ostrcat(buf, tmpstr, 1, 1);
6240
6241        if(fmt == 0)
6242        {
6243                buf = ostrcat(buf, "</center></body></html>", 1, 0);
6244        }       
6245       
6246        return buf;
6247}
6248
6249char* webgetbackup(int fmt)
6250{
6251        if(status.security == 0) return NULL;
6252
6253        char* buf = NULL, *tmpstr = NULL;
6254
6255        if(fmt == 0)
6256        {
6257                buf = ostrcat(buf, "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">", 1, 0);
6258                buf = ostrcat(buf, "<link rel=stylesheet type=text/css href=titan.css><script type=text/javascript src=titan.js></script>", 1, 0);
6259                buf = ostrcat(buf, "</head><body class=body id=\"backup\"><center>", 1, 0);
6260                buf = ostrcat(buf, "<br>", 1, 0);
6261                buf = ostrcat(buf, "<h1>", 1, 0);
6262                buf = ostrcat(buf, _("System Backup"), 1, 0);
6263                buf = ostrcat(buf, "</h1>", 1, 0);
6264                buf = ostrcat(buf, "<br>", 1, 0);
6265        }
6266
6267//      tmpstr = getabout();
6268//      readnewsletter();
6269        tmpstr = readfiletomem("/tmp/Service.txt", 0);
6270        tmpstr = ostrcat(tmpstr, "\ncomming soon...\n", 1, 0);
6271       
6272        tmpstr = string_replace_all("\n", "<br>\n", tmpstr, 1);
6273
6274        buf = ostrcat(buf, tmpstr, 1, 1);
6275
6276        if(fmt == 0)
6277        {
6278                buf = ostrcat(buf, "</center></body></html>", 1, 0);
6279        }       
6280       
6281        return buf;
6282}
6283
6284char* webgetrestore(int fmt)
6285{
6286        if(status.security == 0) return NULL;
6287
6288        char* buf = NULL, *tmpstr = NULL;
6289
6290        if(fmt == 0)
6291        {
6292                buf = ostrcat(buf, "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">", 1, 0);
6293                buf = ostrcat(buf, "<link rel=stylesheet type=text/css href=titan.css><script type=text/javascript src=titan.js></script>", 1, 0);
6294                buf = ostrcat(buf, "</head><body class=body id=\"restore\"><center>", 1, 0);
6295                buf = ostrcat(buf, "<br>", 1, 0);
6296                buf = ostrcat(buf, "<h1>", 1, 0);
6297                buf = ostrcat(buf, _("Settings backup/restore"), 1, 0);
6298                buf = ostrcat(buf, "</h1>", 1, 0);
6299                buf = ostrcat(buf, "<br>", 1, 0);
6300        }
6301
6302//      tmpstr = getabout();
6303//      readnewsletter();
6304        tmpstr = readfiletomem("/tmp/Service.txt", 0);
6305        tmpstr = ostrcat(tmpstr, "\ncomming soon...\n", 1, 0);
6306       
6307        tmpstr = string_replace_all("\n", "<br>\n", tmpstr, 1);
6308
6309        buf = ostrcat(buf, tmpstr, 1, 1);
6310
6311        if(fmt == 0)
6312        {
6313                buf = ostrcat(buf, "</center></body></html>", 1, 0);
6314        }       
6315       
6316        return buf;
6317}
6318
6319char* webstartplugin(char* param, int fmt)
6320{
6321        void (*startplugin)(void);
6322        char* buf = NULL;
6323       
6324        struct skin* pluginnode = getplugin(param);
6325       
6326        if(pluginnode != NULL)
6327        {
6328                startplugin = dlsym(pluginnode->pluginhandle, "start");
6329                if(startplugin != NULL)
6330                {
6331                        resettvpic();
6332                        startplugin();
6333                        resettvpic();
6334                        buf = ostrcat(buf, "ok", 1, 0);
6335                }
6336                else
6337                        buf = ostrcat(buf, "internal error", 1, 0);
6338        }
6339        else
6340                buf = ostrcat(buf, "wrong plugin name", 1, 0);
6341               
6342        return buf;
6343}
6344       
6345       
6346#endif
Note: See TracBrowser for help on using the repository browser.