source: titan/titan/httpdfunc.h @ 32698

Last change on this file since 32698 was 32698, checked in by tobayer, 8 years ago

[titan] additional info bar timeouts also in httpdfunc.h

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